From: Vincent Povirk Subject: [4/6] explorer: Create a separate parent window for the start menu. Message-Id: Date: Tue, 10 Dec 2013 15:09:58 -0600 This helps encapsulation and makes the next patch possible. From c16a7817b27db1d2fa8307f26eb75d4ac6940168 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Fri, 6 Dec 2013 15:14:21 -0600 Subject: [PATCH 4/6] explorer: Create a separate parent window for the start menu. --- programs/explorer/explorer_private.h | 1 - programs/explorer/startmenu.c | 34 +++++++++++++++++++++++++++++++--- programs/explorer/systray.c | 4 ---- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/programs/explorer/explorer_private.h b/programs/explorer/explorer_private.h index 108a3ab..c407a61 100644 --- a/programs/explorer/explorer_private.h +++ b/programs/explorer/explorer_private.h @@ -25,6 +25,5 @@ extern void manage_desktop( WCHAR *arg ); extern void initialize_systray( HMODULE graphics_driver, BOOL using_root ); extern void initialize_appbar(void); extern void do_startmenu( HWND owner ); -extern LRESULT CALLBACK menu_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); #endif /* __WINE_EXPLORER_PRIVATE_H */ diff --git a/programs/explorer/startmenu.c b/programs/explorer/startmenu.c index 6fcca46..b0cc702 100644 --- a/programs/explorer/startmenu.c +++ b/programs/explorer/startmenu.c @@ -52,6 +52,9 @@ static struct menu_item root_menu = {{0}}; static struct menu_item public_startmenu = {{0}}; static struct menu_item user_startmenu = {{0}}; +static ATOM menu_parent_class; +static HWND menu_parent; + static ULONG copy_pidls(struct menu_item* item, LPITEMIDLIST dest) { ULONG item_size; @@ -365,6 +368,33 @@ void do_startmenu(HWND hwnd) MENUINFO mi; RECT rc={0,0,0,0}; TPMPARAMS tpm; + WNDCLASSEXW class; + static const WCHAR classname[] = {'W','i','n','e','M','e','n','u','P','a','r','e','n','t',0}; + + if (!menu_parent_class) + { + memset(&class, 0, sizeof(class)); + class.cbSize = sizeof(class); + class.lpfnWndProc = menu_wndproc; + class.lpszClassName = classname; + menu_parent_class = RegisterClassExW(&class); + if (!menu_parent_class) + { + WINE_ERR("Could not register menu parent class\n"); + return; + } + } + + if (!menu_parent) + { + menu_parent = CreateWindowExW(0, classname, NULL, WS_POPUP, 0, 0, 1, 1, + hwnd, NULL, NULL, NULL); + if (!menu_parent) + { + WINE_ERR("Could not create menu parent window\n"); + return; + } + } destroy_menus(); @@ -372,9 +402,7 @@ void do_startmenu(HWND hwnd) root_menu.menuhandle = public_startmenu.menuhandle = user_startmenu.menuhandle = CreatePopupMenu(); if (!root_menu.menuhandle) - { return; - } user_startmenu.parent = public_startmenu.parent = &root_menu; user_startmenu.base = &public_startmenu; @@ -411,7 +439,7 @@ void do_startmenu(HWND hwnd) if (!TrackPopupMenuEx(root_menu.menuhandle, TPM_LEFTALIGN|TPM_BOTTOMALIGN|TPM_VERTICAL, - rc.left, rc.top, hwnd, &tpm)) + rc.left, rc.top, menu_parent, &tpm)) { WINE_ERR("couldn't display menu\n"); } diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c index f263205..e7f5f73 100644 --- a/programs/explorer/systray.c +++ b/programs/explorer/systray.c @@ -626,10 +626,6 @@ static LRESULT WINAPI tray_wndproc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM l do_startmenu(hwnd); break; - case WM_INITMENUPOPUP: - case WM_MENUCOMMAND: - return menu_wndproc(hwnd, msg, wparam, lparam); - default: return DefWindowProcW( hwnd, msg, wparam, lparam ); } -- 1.8.1.2