From: Andrea Faulds <ajf@ajf.me> This means that, in desktop mode, appbars like the Microsoft Office Shortcut Bar can avoid overlapping the taskbar. --- programs/explorer/appbar.c | 42 ++++++++++++++++++++++------ programs/explorer/desktop.c | 3 +- programs/explorer/explorer_private.h | 1 + programs/explorer/systray.c | 6 ++++ 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/programs/explorer/appbar.c b/programs/explorer/appbar.c index 18b125257ee..46a988ebbed 100644 --- a/programs/explorer/appbar.c +++ b/programs/explorer/appbar.c @@ -73,13 +73,19 @@ struct appbar_data static struct list appbars = LIST_INIT(appbars); +static struct appbar_data* get_taskbar(void) +{ + return (struct appbar_data*)list_head( &appbars ); +} + static struct appbar_data* get_appbar(HWND hwnd) { struct appbar_data* data; LIST_FOR_EACH_ENTRY(data, &appbars, struct appbar_data, entry) { - if (data->hwnd == hwnd) + /* ignore taskbar to prevent accidental modification */ + if (data->hwnd == hwnd && data != get_taskbar()) return data; } @@ -92,7 +98,7 @@ static void send_poschanged(HWND hwnd) struct appbar_data* data; LIST_FOR_EACH_ENTRY(data, &appbars, struct appbar_data, entry) { - if (data->hwnd != hwnd) + if (data->hwnd != hwnd && data != get_taskbar()) { PostMessageW(data->hwnd, data->callback_msg, ABN_POSCHANGED, 0); } @@ -202,12 +208,9 @@ static UINT_PTR handle_appbarmessage(DWORD msg, struct appbar_data_msg *abd) return ABS_ALWAYSONTOP | ABS_AUTOHIDE; case ABM_GETTASKBARPOS: FIXME( "SHAppBarMessage(ABM_GETTASKBARPOS, hwnd=%p): stub\n", hwnd ); - /* Report the taskbar is at the bottom of the screen. */ - abd->rc.left = 0; - abd->rc.right = GetSystemMetrics(SM_CXSCREEN); - abd->rc.bottom = GetSystemMetrics(SM_CYSCREEN); - abd->rc.top = abd->rc.bottom-1; - abd->uEdge = ABE_BOTTOM; + data = get_taskbar(); + abd->rc = data->rc; + abd->uEdge = data->edge; return TRUE; case ABM_ACTIVATE: return TRUE; @@ -288,6 +291,8 @@ static LRESULT CALLBACK appbar_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARA void initialize_appbar(void) { WNDCLASSEXW class; + struct appbar_data* data; + int taskbar_height; /* register the appbar window class */ ZeroMemory(&class, sizeof(class)); @@ -308,4 +313,25 @@ void initialize_appbar(void) ERR( "Could not create appbar message window\n" ); return; } + + /* create appbar record for the taskbar (it has a privileged status and + * isn't registered like a normal appbar, this just simplifies accounting) + */ + data = calloc( 1, sizeof(struct appbar_data) ); + if (!data) + { + ERR( "out of memory\n" ); + return; + } + data->rc.left = 0; + data->rc.right = GetSystemMetrics(SM_CXSCREEN); + data->rc.bottom = GetSystemMetrics(SM_CYSCREEN); + taskbar_height = get_taskbar_height(); + if (taskbar_height == 0) + taskbar_height = 1; /* ensure taskbar has non-zero height */ + data->rc.top = data->rc.bottom - taskbar_height; + data->edge = ABE_BOTTOM; + data->space_reserved = TRUE; + + list_add_tail(&appbars, &data->entry); } diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c index ce70c5dd79d..4f52b93afc7 100644 --- a/programs/explorer/desktop.c +++ b/programs/explorer/desktop.c @@ -1288,9 +1288,8 @@ void manage_desktop( WCHAR *arg ) SystemParametersInfoW( SPI_SETDESKWALLPAPER, 0, NULL, FALSE ); ClipCursor( NULL ); initialize_display_settings( width, height ); - initialize_appbar(); - initialize_systray( using_root, enable_shell, show_systray, no_tray_items ); + initialize_appbar(); if (!using_root && enable_launchers) initialize_launchers( hwnd ); if ((shell32 = LoadLibraryW( L"shell32.dll" )) && diff --git a/programs/explorer/explorer_private.h b/programs/explorer/explorer_private.h index 10e8aa0653f..443b8fcaee9 100644 --- a/programs/explorer/explorer_private.h +++ b/programs/explorer/explorer_private.h @@ -27,5 +27,6 @@ extern void initialize_appbar(void); extern void handle_parent_notify( HWND hwnd, WPARAM wp ); extern void do_startmenu( HWND owner ); extern LRESULT menu_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); +extern int get_taskbar_height(void); #endif /* __WINE_EXPLORER_PRIVATE_H */ diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c index 69d3ec61b6a..175bc4d13a0 100644 --- a/programs/explorer/systray.c +++ b/programs/explorer/systray.c @@ -1097,6 +1097,12 @@ static void do_show_systray(void) sync_taskbar_buttons(); } +/* for use by appbar.c's accounting */ +int get_taskbar_height(void) +{ + return enable_taskbar ? tray_height : 0; +} + static LRESULT WINAPI shell_traywnd_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { switch (msg) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11699