-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
DisplayServer.WINDOW_MODE_WINDOWED
not working correctly after window is maximized and then made fullscreen
#70166
Comments
The workaround I got for this right now is by changing the first if statement to:
This way it's forced to skip to the elif and never enters fullscreen while being maximized. The set_size and set_position aren't needed this way either. Also Windows seems to have a weird stretching problem when changing window modes that didn't exist in 3.5. |
To be clear, the exact behaviour in 3.5 was that you can't leave fullscreen by toggling OS.window_maximized. You had to exit fullscreen first which was fine. I can't replicate that in 4.0 though, even if I convert the 3.5 code exactly (not the example). It just keeps thinking DisplayServer.WINDOW_MODE_WINDOWED means fullscreen for some reason. |
Tested with this code func _process(delta: float) -> void:
if Input.is_action_just_pressed("ui_accept"):
if DisplayServer.window_get_mode() != DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
else:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
#DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED) If you maximize the window and switch to fullscreen, |
I just got to try this and it didn't work for me, with 1 line of Edit: Just want to mention that it's not a Windows bug as it seems to work fine in random programs like windows terminal, explorer etc. They allow you to go from |
Possibly associated - if you set Project Settings / Display / Window / Mode to Fullscreen and then:
The print returns 0 in the console (ie |
I spent some time looking at the problem again because it clearly is possible based on:
And I just noticed that print(DisplayServer.window_get_mode())
if Input.is_action_just_pressed("toggle_fullscreen"):
if DisplayServer.window_get_mode() != DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
elif DisplayServer.window_get_mode() != DisplayServer.WINDOW_MODE_WINDOWED:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED) To reproduce:
Toggling between maximized and windowed does work correctly if you don't go fullscreen in between. |
The bug is also reproducible on Linux (
Setting back to windowed mode twice still fails on my machine. |
DisplayServer.WINDOW_MODE_WINDOWED
not working correctly after window is maximized and then made fullscreen
Confirming on v4.2.1.stable.official [b09f793] on Windows 11. |
Faced same issue in Godot v4.2.1
|
This issues persists in in |
The issue is still present in v4.2.2.stable.official [15073af]. Even with resizable=false. The game just becomes a black screen when setting
|
Encountered this—or something like it—on Useful findingsI tried toggling fullscreen with the borderless flag always set to true and found that it resulted in much more consistent window restoration. So, I tried manually setting the borderless flag to true before entering fullscreen (although immediately after also works), with the following line of code: DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_BORDERLESS, true) Then, when the user changes the mode back to windowed, I set the borderless flag back to the user's preferred borderless setting for windowed mode (typically This resulted in consistently switching between fullscreen and the pseudo-maximized state I describe below. So, it's not as clean as toggling between a permanently borderless window and fullscreen. But, at least it works. It also works when switching between windowed and exclusive fullscreen. However, something breaks when switching from fullscreen to exclusive fullscreen. So, my current solution is to just never switch between fullscreen and exclusive fullscreen mode. Instead, to change fullscreen exclusivity, the user must exit their existing fullscreen mode before entering another. It's not ideal, but it works. Perhaps something could be done with Also, I have only tested this on Linux. So, I'm not sure if it works on any other platform. Methods and initial findingsI'm using a CheckBox to toggle between fullscreen and windowed mode. The following was observed before implementing the borderless fix mentioned above. The first time I exit fullscreen, it works. The second time I do, it fails. Then, it works again. This repeats unless I move the window in between fullscreen toggles. If I exit fullscreen, move the window, and enter fullscreen again, the next exit works. And, this can be repeated. When I exit out of fullscreen, the window is positioned and sized as if it were maximized (although I set it to windowed). However, looking at the title bar, I can see that the maximize button (enabled via GNOME Tweaks) suggests that it is not truly maximized, and moving the window doesn't require unsticking it from the top edge of the screen. Clicking the maximize button enables the true maximized state. I have also tried switching between fullscreen and maximized (instead of fullscreen and windowed) and observed the same result. It would repeat working and doing nothing. Also, I tested the editor's own fullscreen toggle implementation and noticed similar behavior. Pressing the "Toggle Fullscreen" hotkey ( System informationSoftware:
Raw system info paste:
|
Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.
Godot version
v4.0.beta8.official [45cac42]
System information
Windows 10
Issue description
In 3.5 I had this issue: #61871
4.0 beta 8 fixed this by adding the non exclusive fullscreen, but the changes caused a problem where you can't get back to windowed mode in script at all after entering fullscreen or exclusive fullscreen while having a maximized window. This is what I'm trying to do, 2 different toggles for maximize/windowed and fullscreen/windowed:
What happens is that the 3 lines in both the elif statement don't do what they should be doing and just go back to fullscreen instead of windowed. You should be able to reproduce this in a small example as well.
In Godot 3.5 this was working by doing the following:
Steps to reproduce
Maximize window (in script or just manually) then enable fullscreen or exclusive fullscreen. Now if you disable fullscreen again you are unable to change the window size, position or set it to windowed mode through script.
Minimal reproduction project
N/A, just try to leave either maximized or fullscreen window after going from maximized>fullscreen.
This is probably a windows specific issue just like my last one.
The text was updated successfully, but these errors were encountered: