Module: wine Branch: master Commit: 8459a5272a5b16bf99d058aade01c946a71c94f8 URL: https://gitlab.winehq.org/wine/wine/-/commit/8459a5272a5b16bf99d058aade01c94...
Author: Zhiyi Zhang zzhang@codeweavers.com Date: Mon Nov 14 22:19:26 2022 +0800
explorer: Use a valid taskbar position when the taskbar is hidden.
Some applications use FindWindowA() with class Shell_TrayWnd to find the taskbar window on Windows. Then GetWindowRect() is called to get the taskbar window rectangle. Finally, the taskbar window rectangle is subtracted from the primary screen rectangle to calculate the work area. Without a valid taskbar window position, these applications end up getting an incorrect work area and going down the wrong path. So use the same position and size as the host system panel for explorer taskbar when it's hidden.
---
programs/explorer/systray.c | 15 +++++++++------ programs/explorer/tests/explorer.c | 1 - 2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c index 5b7216b2904..7790648d021 100644 --- a/programs/explorer/systray.c +++ b/programs/explorer/systray.c @@ -712,10 +712,7 @@ static void show_taskbar_contextmenu( HWND button, LPARAM lparam )
static void do_hide_systray(void) { - SetWindowPos( tray_window, 0, - GetSystemMetrics(SM_XVIRTUALSCREEN) + GetSystemMetrics(SM_CXVIRTUALSCREEN), - GetSystemMetrics(SM_YVIRTUALSCREEN) + GetSystemMetrics(SM_CYVIRTUALSCREEN), - 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); + ShowWindow( tray_window, SW_HIDE ); }
static BOOL notify_owner( struct icon *icon, UINT msg, POINT pt ) @@ -899,6 +896,7 @@ void initialize_systray( HMODULE graphics_driver, BOOL using_root, BOOL arg_enab { WNDCLASSEXW class; static const WCHAR classname[] = {'S','h','e','l','l','_','T','r','a','y','W','n','d',0}; + RECT work_rect, primary_rect, taskbar_rect;
if (using_root && graphics_driver) wine_notify_icon = (void *)GetProcAddress( graphics_driver, "wine_notify_icon" );
@@ -924,8 +922,13 @@ void initialize_systray( HMODULE graphics_driver, BOOL using_root, BOOL arg_enab return; }
- tray_window = CreateWindowExW( WS_EX_NOACTIVATE, classname, NULL, WS_POPUP, - 0, GetSystemMetrics( SM_CYSCREEN ), 0, 0, 0, 0, 0, 0 ); + SystemParametersInfoW( SPI_GETWORKAREA, 0, &work_rect, 0 ); + SetRect( &primary_rect, 0, 0, GetSystemMetrics( SM_CXSCREEN ), GetSystemMetrics( SM_CYSCREEN ) ); + SubtractRect( &taskbar_rect, &primary_rect, &work_rect ); + + tray_window = CreateWindowExW( WS_EX_NOACTIVATE, classname, NULL, WS_POPUP, taskbar_rect.left, + taskbar_rect.top, taskbar_rect.right - taskbar_rect.left, + taskbar_rect.bottom - taskbar_rect.top, 0, 0, 0, 0 ); if (!tray_window) { WINE_ERR("Could not create tray window\n"); diff --git a/programs/explorer/tests/explorer.c b/programs/explorer/tests/explorer.c index c9ed7a900f2..3882027ae46 100644 --- a/programs/explorer/tests/explorer.c +++ b/programs/explorer/tests/explorer.c @@ -40,7 +40,6 @@ static void test_taskbar(void) SystemParametersInfoW(SPI_GETWORKAREA, 0, &work_rect, 0); SetRect(&primary_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); SubtractRect(&expected_rect, &primary_rect, &work_rect); - todo_wine ok(EqualRect(&taskbar_rect, &expected_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&expected_rect), wine_dbgstr_rect(&taskbar_rect)); }