Skip to content
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_set_mode() is stuck on maximized window after changing mode #84143

Closed
kkosovsky opened this issue Oct 29, 2023 · 9 comments · Fixed by #84504
Closed

DisplayServer.window_set_mode() is stuck on maximized window after changing mode #84143

kkosovsky opened this issue Oct 29, 2023 · 9 comments · Fixed by #84504

Comments

@kkosovsky
Copy link

kkosovsky commented Oct 29, 2023

Godot version

v4.1.3.rc1.official [f80c673]

System information

Windows 11, NVIDIA GeForce GTX 1070, i7-7700K CPU 4.20GHz, 1920x1080 60Hz IPS monitor & a 2560x1440 adaptive 100Hz monitor

Issue description

related to: #84142

Steps to reproduce

Test 1:
Window -> Maximized -> Window
window is small, correct

Test 2:
Window -> Maximized -> Fullscreen -> Window
Window is stuck at maximized, but according to test 1 should be normal size
NOT CORRECT

Test 3:
Window -> Maximized -> Fullscreen -> Exclusive Fullscreen -> Window
Window is stuck at maximized, but according to test 1 should be normal size
NOT CORRECT

Test 4
Window -> Maximized -> Exclusive Fullscreen -> Window
Window is stuck at maximized, but according to test 1 should be normal size
NOT CORRECT

Test 5:
Window -> Fullscreen -> Window
window is small, correct

Test 6:
Window -> Fullscreen -> Exclusive Fullscreen -> Window
window is small, correct

Conclusion:
Window mode is not disabling the maximized flag, if you go back from any fullscreen mode

Minimal reproduction project

window_mode_issue.zip
WindowModeTestsWindows11.mkv.zip

@AThousandShips
Copy link
Member

Assuming you mean 4.1.3-rc1, unless you're from the future

@kkosovsky
Copy link
Author

Assuming you mean 4.1.3-rc1, unless you're from the future

my mistake, changed to v4.1.3.rc1.official [f80c673cd]

@Cyangmou
Copy link

Cyangmou commented Oct 30, 2023

Test 7:
Window -> Minimized -> Hand opening from taskbar -> Maximized -> Exclusive Fullscreen -> Maximized -> Window
This ends up in the fullscreen setting instead of a window

Test 8:
Window -> Maximized -> Fullscreen -> Maximized -> Window
This ends up in the fullscreen setting instead of a window

those are 2 bugs which seem to be caused by maximized in the chain, Test 8 seems to be just a shortened version of test 7.
If you go back from Fullscreen -> Maximized -> Window
this always goes last to fullscreen instead of window, so something with the maximized option after fullscreen does something wrong.

@Calinou Calinou changed the title DisplayServer.window_set_mode has several issues [Windows] DisplayServer.window_set_mode() is stuck on maximized window after changing mode Oct 31, 2023
@YuriSizov
Copy link
Contributor

@kkosovsky Can you reproduce the issue in 4.1.2 and earlier versions, or is this something new to 4.1.3?

@kkosovsky
Copy link
Author

@kkosovsky Can you reproduce the issue in 4.1.2 and earlier versions, or is this something new to 4.1.3?

@Cyangmou Can you help and check in 4.1.2? Preferable stable.

@Cyangmou
Copy link

Cyangmou commented Nov 1, 2023

@YuriSizov I just tested with 4.1.1 and the same issue can be reproduced there.

If necessary I can download 4.1.2 which I don't have, but given that the issue was reproducable in 4.1.1 and is still there in 4.1.3 I assume it also is in 4.1.2

Since I was just at it, i also tested at a single screen, as the initial test setup had 2 screens.
-> The issue can be reproduced, also when just have a single screen connected to your pc.

@YuriSizov
Copy link
Contributor

Thanks for confirming that this is not a recent regression! 👍

@YuriSizov YuriSizov added this to the 4.x milestone Nov 1, 2023
@jitspoe
Copy link
Contributor

jitspoe commented Nov 6, 2023

Just wanted to add a few notes from things I've experienced related to window modes. In Godot 3, there were separate settings for all these things (fullscreen, borderless, maximized, etc.) When they got merged to one enum for 4.x is likely when the issue was introduced.

I've also noticed that when lauching my game (at least from the editor), if there's a hitch or something, sometimes it fails to set the window mode. Happens pretty rarely, but I basically just have

func _ready():
	get_viewport().mode = Window.MODE_MAXIMIZED

and sometimes it'll be windowed.

Also, an issue I've experienced in both Godot 3 and 4 is that fullscreen will often happen on the wrong monitor. Setting the window to maximized before going fullscreen seems to fix this on both 3 and 4, like:

func _ready():
	get_viewport().mode = Window.MODE_MAXIMIZED
	get_viewport().mode = Window.MODE_EXCLUSIVE_FULLSCREEN

Regarding the bug at hand, glancing at the code, I think this block is the problem:

	if (wd.fullscreen && p_mode != WINDOW_MODE_FULLSCREEN && p_mode != WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
...
	} else if (p_mode == WINDOW_MODE_WINDOWED) {
		ShowWindow(wd.hWnd, SW_RESTORE);
		wd.maximized = false;
		wd.minimized = false;
	}

Should drop the else on the WINDOW_MODE_WINDOWED check, as the SW_RESTORE doesn't get executed.

@jitspoe
Copy link
Contributor

jitspoe commented Nov 6, 2023

Yeah, looks like that's all it was. Did a quick PR here: #84504

@akien-mga akien-mga modified the milestones: 4.x, 4.2 Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment