This patch fixes a bug where if using the Wine virtual desktop, changing resolutions in a fullscreen game would cause the systray to be drawn over the game window.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=40828 Signed-off-by: Hamish Claxton hamishclaxton@gmail.com --- v2: Properly do the resolution checks
programs/explorer/systray.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c index 3d36f74e16..893a9dadda 100644 --- a/programs/explorer/systray.c +++ b/programs/explorer/systray.c @@ -780,7 +780,11 @@ static LRESULT WINAPI tray_wndproc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
case WM_DISPLAYCHANGE: if (hide_systray || (!nb_displayed && !enable_shell)) do_hide_systray(); - else do_show_systray(); + else { + if ( !( GetSystemMetrics( SM_CXFULLSCREEN ) >= GetSystemMetrics( SM_CXSCREEN ) + && GetSystemMetrics( SM_CYFULLSCREEN ) >= GetSystemMetrics( SM_CYSCREEN ) ) ) + do_show_systray(); + } break;
case WM_TIMER:
Hi Hamish,
if ( !( GetSystemMetrics(SM_CXFULLSCREEN) >= GetSystemMetrics(SM_CXSCREEN) && GetSystemMetrics(SM_CYFULLSCREEN) >= GetSystemMetrics(SM_CYSCREEN) ))
Why are you comparing two system metrics? Are they changing when a program goes fullscreen? I'm pretty sure they don't. Did you also test that it only hides the taskbar when it should? For me both SM_CXSCREEN and SM_CXFULLSCREEN are 1920 - that would hide the tray always, even in windowed mode.
Regards, Fabian Maurer
Hi Fabian,
Yes, this only hides the tray when it should. The code only happens on the WM_DISPLAYCHANGE event, which occurs on resolution changes. I wouldn't write any code that would damage any existing features.
While the resolutions shouldn't differ, actually the SM_CYFULLSCREEN reports a larger dimension by 11. What happens is beforehand, the systray was getting drawn no matter what on a resolution update. This patch checks if the current foreground game is covering the entire screen, hence covering the area where the systray would normally be drawn, which is also the entire desktop resolution, and if it is, does not draw the systray.
I tested this patch thoroughly and it only enhances existing functionality.
Thanks in Advance, Hamish
On Sun, Dec 30, 2018 at 10:44 AM Fabian Maurer dark.shadow4@web.de wrote:
Hi Hamish,
if ( !( GetSystemMetrics(SM_CXFULLSCREEN) >=
GetSystemMetrics(SM_CXSCREEN)
&& GetSystemMetrics(SM_CYFULLSCREEN) >= GetSystemMetrics(SM_CYSCREEN) ))
Why are you comparing two system metrics? Are they changing when a program goes fullscreen? I'm pretty sure they don't.
Did you also test that it only hides the taskbar when it should? For me both SM_CXSCREEN and SM_CXFULLSCREEN are 1920 - that would hide the tray always, even in windowed mode.
Regards,
Fabian Maurer
On 12/30/18 02:54, Hamish Claxton wrote:
Hi Fabian,
Yes, this only hides the tray when it should. The code only happens on the WM_DISPLAYCHANGE event, which occurs on resolution changes. I wouldn't write any code that would damage any existing features.
While the resolutions shouldn't differ, actually the SM_CYFULLSCREEN reports a larger dimension by 11. What happens is beforehand, the systray was getting drawn no matter what on a resolution update. This patch checks if the current foreground game is covering the entire screen, hence covering the area where the systray would normally be drawn, which is also the entire desktop resolution, and if it is, does not draw the systray.
I tested this patch thoroughly and it only enhances existing functionality.
Thanks in Advance, Hamish
GetSystemMetrics, as its name implies, gives system metrics (constants) and not that of the current foreground game as you want. It will always apply. Furthermore, this doesn't handle situation with multiple displays.
You probably want to check if there's a full screen window somehow, or use MonitorFromWindow / GetMonitorInfo / GetWindowRect and compare, but I don't know if that's a good way to go about this.
Am 30.12.18 um 14:57 schrieb Gabriel Ivăncescu:
You probably want to check if there's a full screen window somehow, or use MonitorFromWindow / GetMonitorInfo / GetWindowRect and compare, but I don't know if that's a good way to go about this.
There's a is_window_rect_fullscreen() in x11drv/x11drv.h that could provide some guidance.
Thanks guys for the advice and help.
I've spent the last few days rewriting the patch to solve the issues brought up. Hopefully its all good now. Would be good if I could get someone to test it for me and sign it off, though I have tested the patch thoroughly and it even works fine with games that have quirky resolution changes such as Dragon Age Inqusition. Not to mention it now supports borderless fullscreen modes.
Games tested: - Brothers - A Tale of Two Sons - Crysis 3 - Dragon Age Inquisition - Just Cause 3 - LEGO Pirates of the Caribbean - LEGO The Lord of the Rings - METAL GEAR SOLID V: THE PHANTOM PAIN - Project Eden
Thanks in Advance, Hamish
On Sun, Dec 30, 2018 at 10:54 AM Hamish Claxton hamishclaxton@gmail.com wrote:
Hi Fabian,
Yes, this only hides the tray when it should. The code only happens on the WM_DISPLAYCHANGE event, which occurs on resolution changes. I wouldn't write any code that would damage any existing features.
While the resolutions shouldn't differ, actually the SM_CYFULLSCREEN reports a larger dimension by 11. What happens is beforehand, the systray was getting drawn no matter what on a resolution update. This patch checks if the current foreground game is covering the entire screen, hence covering the area where the systray would normally be drawn, which is also the entire desktop resolution, and if it is, does not draw the systray.
I tested this patch thoroughly and it only enhances existing functionality.
Thanks in Advance, Hamish
On Sun, Dec 30, 2018 at 10:44 AM Fabian Maurer dark.shadow4@web.de wrote:
Hi Hamish,
if ( !( GetSystemMetrics(SM_CXFULLSCREEN) >=
GetSystemMetrics(SM_CXSCREEN)
&& GetSystemMetrics(SM_CYFULLSCREEN) >= GetSystemMetrics(SM_CYSCREEN) ))
Why are you comparing two system metrics? Are they changing when a program goes fullscreen? I'm pretty sure they don't.
Did you also test that it only hides the taskbar when it should? For me both SM_CXSCREEN and SM_CXFULLSCREEN are 1920 - that would hide the tray always, even in windowed mode.
Regards,
Fabian Maurer