-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Fullscreen without video mode change #3378
Comments
@M374LX It's been a few months, but I vaguely remember something about Did you successfully implement it with a single |
@ubkp Not yet tested extensively, but it worked well on a quick test with a single monitor in which the refresh rate was passed to |
@M374LX Unless I'm missing something, "GLFW_REFRESH_RATE specifies the desired refresh rate for full screen windows. A value of GLFW_DONT_CARE means the highest available refresh rate will be used. This hint is ignored for windowed mode windows." But regarding a single |
@ubkp On Openbox, the window does not get minimized with Alt+Tab, but is loses focus and the new focused window is displayed over it. The same happens with SDL when using I have also just added a third approach to the issue description. |
@M374LX If it doesn't trigger the window to get minimized, then that could be a nice replacement for Do you want to send a PR? Or should I review it here? |
Creating a draft PR is in my plans. |
@M374LX Excellent! Suggestion: see if you can integrate it on If that gives you trouble, option 2 is probably the safest alternative. Also, if possible, test it on a multimonitor configuration. |
@M374LX Tested this scenario: "If the closest match for the desired video mode is the current one, the video mode will not be changed,[...]" by setting
Unfortunately, when alt-tabbing, it causes the window to get minimized here on Gnome (Fedora 38 64-bit). I remember it also would cause the window to get minimized on MATE (Mint 21.1 64-bit). So that solution may actually require some testing. Edit 1: clarification. |
@M374LX Sorry, I'm a bit lost with this improvement, why is it needed considering |
Mainly because a borderless window is still movable. |
What's the problem with that? |
Don't you agree that a window occupying the entire screen, be it fullscreen or borderless, should stay at position (0, 0)? We could try to check if the window position is not (0, 0) (possibly in |
|
At this point I'm quite lost with all those fullscreen issues and PR, I highly agree with all the @ubkp comments and I prefer to avoid any redesign and overengineered implementation looking for problems that hardly ever occur. |
Here are the differences:
|
I'm closing this issue, discussion can be probably continued on #3390 |
Update: in fact, what makes it difficult for raylib to properly implement fullscreen without a video mode change is GLFW's lack of a function that just makes the window fullscreen and lets the window manager do the rest without touching the video mode.
Issue description
Problems with an incorrect resolution when toggling fullscreen mode have been reported in #3099. However, according to the GLFW documentation at https://www.glfw.org/docs/latest/window_guide.html#window_windowed_full_screen, "If the closest match for the desired video mode is the current one, the video mode will not be changed, making window creation faster and application switching much smoother".
The same effect can be achieved in SDL2 by calling
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
(withSDL_WINDOW_FULLSCREEN_DESKTOP
instead ofSDL_WINDOW_FULLSCREEN
).With a borderless window, as implemented in #3216, there is still a problem: the window is movable (noticeably on a window manager that allows moving a window while holding a key, like dwm from https://suckless.org).
Fullscreen toggling without a video mode change can be implemented in GLFW like so:
As we can see, we need to pass the refresh rate along with the width and height of the monitor to
glfwSetWindowMonitor()
.In https://github.com/raysan5/raylib/blob/bc15c19518968878b68bbfe8eac3fe4297f11770/src/rcore.c#L1222C37-L1222C37, we have
GLFW_DONT_CARE
instead of the actual refresh rate, but I don't think this should be changed, as it is possible that a programmer using raylib actually wants a video mode change and the monitor does not support the same refresh rate on a different video mode.Some of the possible approaches to implement fullscreen toggling without a video mode change include:
FLAG_FULLSCREEN_MODE
andToggleFullscreen()
, but pass the refresh rate toglfwSetWindowMonitor()
when the screen size corresponds to monitor butGLFW_DONT_CARE
otherwise.FLAG_FULLSCREEN_DESKTOP_MODE
, and a new function, likeToggleDesktopFullscreen()
. This one could automatically use the monitor size and free the programmer from the need to callSetWindowSize()
before toggling fullscreen mode.FLAG_FULLSCREEN_MODE
andToggleFullscreen()
, but create a new flag, likeFLAG_FULLSCREEN_DESKTOP
, to specify that a video mode change should not happen.Environment
Linux
The text was updated successfully, but these errors were encountered: