[3/3] explorer: update menus deleted after startup
Damjan Jovanovic
damjan.jov at gmail.com
Thu Jun 25 14:06:41 CDT 2009
Changelog:
* update menus deleted after startup
Damjan Jovanovic
-------------- next part --------------
diff --git a/programs/explorer/Makefile.in b/programs/explorer/Makefile.in
index ceb80a9..f6f163c 100644
--- a/programs/explorer/Makefile.in
+++ b/programs/explorer/Makefile.in
@@ -5,7 +5,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = explorer.exe
APPMODE = -mwindows -municode
-IMPORTS = rpcrt4 user32 gdi32 advapi32 kernel32 ntdll
+IMPORTS = rpcrt4 user32 gdi32 advapi32 kernel32 ntdll shell32
DELAYIMPORTS = comctl32
C_SRCS = \
diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c
index 67ade26..e80ea77 100644
--- a/programs/explorer/desktop.c
+++ b/programs/explorer/desktop.c
@@ -26,6 +26,7 @@
#define OEMRESOURCE
#include <windows.h>
+#include <shlobj.h>
#include <wine/debug.h>
#include "explorer_private.h"
@@ -220,6 +221,64 @@ static void initialize_display_settings( HWND desktop )
}
}
+static WINAPI DWORD menu_thread(LPVOID arg)
+{
+ static WCHAR szWinemenubuilder[] = {
+ 'w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e',
+ ' ','-','r',0 };
+ WCHAR startMenu[MAX_PATH];
+ WCHAR commonStartMenu[MAX_PATH];
+ HANDLE startMenuChangeHandles[2];
+
+ startMenu[0] = commonStartMenu[0] = 0;
+ SHGetSpecialFolderPathW(0, startMenu, CSIDL_STARTMENU, TRUE);
+ SHGetSpecialFolderPathW(0, commonStartMenu, CSIDL_COMMON_STARTMENU, TRUE);
+
+ startMenuChangeHandles[0] = FindFirstChangeNotificationW(startMenu, TRUE, FILE_NOTIFY_CHANGE_FILE_NAME);
+ startMenuChangeHandles[1] = FindFirstChangeNotificationW(commonStartMenu, TRUE, FILE_NOTIFY_CHANGE_FILE_NAME);
+
+ for (;;)
+ {
+ STARTUPINFOW si;
+ PROCESS_INFORMATION pi;
+ BOOL ret;
+
+ if (startMenuChangeHandles[0] == INVALID_HANDLE_VALUE || startMenuChangeHandles[1] == INVALID_HANDLE_VALUE)
+ break;
+ WaitForMultipleObjects(2, startMenuChangeHandles, FALSE, INFINITE);
+
+ /* avoid 100% CPU when menus are changing often */
+ Sleep(1000);
+
+ WINE_TRACE("refreshing menus\n");
+ memset(&si, 0, sizeof(si));
+ si.cb = sizeof(si);
+ ret = CreateProcessW( NULL, szWinemenubuilder, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi );
+ if (ret)
+ {
+ CloseHandle( pi.hProcess );
+ CloseHandle( pi.hThread );
+ }
+
+ if (!FindNextChangeNotification(startMenuChangeHandles[0]))
+ break;
+ if (!FindNextChangeNotification(startMenuChangeHandles[1]))
+ break;
+ }
+ if (startMenuChangeHandles[0] != INVALID_HANDLE_VALUE)
+ FindCloseChangeNotification(startMenuChangeHandles[0]);
+ if (startMenuChangeHandles[1] != INVALID_HANDLE_VALUE)
+ FindCloseChangeNotification(startMenuChangeHandles[1]);
+ return 0;
+}
+
+static void initialize_menu_scanner(void)
+{
+ HANDLE handle;
+ if (!(handle = CreateThread( NULL, 0, menu_thread, NULL, 0, NULL ))) return;
+ CloseHandle(handle);
+}
+
static void set_desktop_window_title( HWND hwnd, const WCHAR *name )
{
static const WCHAR desktop_nameW[] = {'W','i','n','e',' ','d','e','s','k','t','o','p',0};
@@ -337,6 +396,7 @@ void manage_desktop( WCHAR *arg )
initialize_display_settings( hwnd );
initialize_appbar();
initialize_systray();
+ initialize_menu_scanner();
if ((shell32 = LoadLibraryA( "shell32.dll" )) &&
(pShellDDEInit = (void *)GetProcAddress( shell32, (LPCSTR)188)))
More information about the wine-patches
mailing list