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

Window node fullscreen mode not working #78530

Closed
jeanahelver opened this issue Jun 21, 2023 · 5 comments · Fixed by #79016
Closed

Window node fullscreen mode not working #78530

jeanahelver opened this issue Jun 21, 2023 · 5 comments · Fixed by #79016

Comments

@jeanahelver
Copy link
Contributor

Godot version

4.0.3.stable

System information

windows 11

Issue description

fullscreen on the window node is not working and will show up as a windowed.

Steps to reproduce

disable Embed Subwindows in Project Settings/Display/Window.
create a window node and set its mode to fullscreen.

Minimal reproduction project

fullscreen.zip

@akien-mga
Copy link
Member

akien-mga commented Jun 21, 2023

I can't reproduce the issue on Linux (KDE on X11) with 4.0.3. Might be Windows specific? CC @bruvzg

@jpcerrone
Copy link
Contributor

I can reproduce it on Windows 11 on the latest master (e74bf83) . I'll try taking a look!

@jpcerrone
Copy link
Contributor

I think I figured out where the problem is. It starts inside the Window::_make_window function.

The DisplayServer::get_singleton()->window_set_mouse_passthrough(mpath, window_id); call resets the wd.fullscreen property to false, and this, during the call to _update_window_size(); is what ends up re-setting the window to not be fullscreen.

Inside window_set_mouse_passthrough , the function call

SetWindowRgn(windows[p_window].hWnd, nullptr, TRUE);
generates a WM_WINDOWPOSCHANGED message (as mentioned in the MSDN docs). It is the handling of this message that ends up setting the wd.fullscreen property to false. It then fails to reset it to true because the next condition isn't met:

if (window_rect.position == screen_position && window_rect.size == screen_size) {
	window.fullscreen = true;
}

The handling of this message can be confirmed to be the culprit since commenting out the SetWindowRgn(windows[p_window].hWnd, nullptr, TRUE); line makes it so that the wd.fullscreen property isn't reset and it fixes the problem.

I' haven't been able to figure out what should be changed here. I'm not sure whether the SetWindowRgn(windows[p_window].hWnd, nullptr, TRUE); is even needed (since it's setting the region to NULL). Or if a change should be made inside the WM_WINDOWPOSCHANGED handling to account for cases where the screen is in fullscreen mode.

Hope this helps someone with more knowledge than I have figure out what to do.

@jpcerrone
Copy link
Contributor

Looking into it a bit more, it seems that the next portion of the WM_WINDOWPOSCHANGED handling code is indeed the culprit:

if (window_rect.position == screen_position && window_rect.size == screen_size) {
	window.fullscreen = true;
}

Since in fullscreen mode there's a 1px border around the entire window, this comparisson fails since it compares [-1,-1, 1921, 1081] with [0, 0, 1920, 1080].

Something that could be done is to detect when this kind of border is present and ignore it before comparing. Like this:

RECT wrect;
GetWindowRect(hWnd, &wrect);

// In fullscreen mode, the window rect can have a 1px border around its full resolution, so ignore it for the rect comparissons.
if (wrect.left < 0){
	int offset = wrect.left;
	wrect.left -= offset;
	wrect.right += offset;
}
if (wrect.top < 0){
	int offset = wrect.top;
	wrect.top -= offset;
	wrect.bottom += offset;
}

I tested adding the previous section of code and the issue dissapears. I also checked to see if #57787 re-appears with these changes but it doesn't. (It's the issue that was intended to be fixed by #57790)

@bruvzg
Copy link
Member

bruvzg commented Jul 4, 2023

Since in fullscreen mode there's a 1px border around the entire window, this comparisson fails since it compares [-1,-1, 1921, 1081] with [0, 0, 1920, 1080].

This should never happen (client rect can be 1 pixel smaller, but window size should be exact), so something else is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants