Alexandre Julliard : user32: Allow the default desktop name to be specified on a per-app basis.

Alexandre Julliard julliard at winehq.org
Thu Apr 24 15:56:34 CDT 2008


Module: wine
Branch: master
Commit: 9359ff6fe0fc7f4e5986394069c42bc89f1190ca
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9359ff6fe0fc7f4e5986394069c42bc89f1190ca

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Apr 24 17:22:04 2008 +0200

user32: Allow the default desktop name to be specified on a per-app basis.

---

 dlls/user32/user_main.c |   59 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c
index 01b396d..77913a8 100644
--- a/dlls/user32/user_main.c
+++ b/dlls/user32/user_main.c
@@ -154,6 +154,61 @@ static void palette_init(void)
 
 
 /***********************************************************************
+ *           get_default_desktop
+ *
+ * Get the name of the desktop to use for this app if not specified explicitly.
+ */
+static const WCHAR *get_default_desktop(void)
+{
+    static const WCHAR defaultW[] = {'D','e','f','a','u','l','t',0};
+    static const WCHAR desktopW[] = {'D','e','s','k','t','o','p',0};
+    static const WCHAR explorerW[] = {'\\','E','x','p','l','o','r','e','r',0};
+    static const WCHAR app_defaultsW[] = {'S','o','f','t','w','a','r','e','\\',
+                                          'W','i','n','e','\\',
+                                          'A','p','p','D','e','f','a','u','l','t','s',0};
+    static WCHAR buffer[MAX_PATH + sizeof(explorerW)/sizeof(WCHAR)];
+    WCHAR *p, *appname = buffer;
+    const WCHAR *ret = defaultW;
+    DWORD len;
+    HKEY tmpkey, appkey;
+
+    len = (GetModuleFileNameW( 0, buffer, MAX_PATH ));
+    if (!len || len >= MAX_PATH) return ret;
+    if ((p = strrchrW( appname, '/' ))) appname = p + 1;
+    if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
+    p = appname + strlenW(appname);
+    strcpyW( p, explorerW );
+
+    /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Explorer */
+    if (!RegOpenKeyW( HKEY_CURRENT_USER, app_defaultsW, &tmpkey ))
+    {
+        if (RegOpenKeyW( tmpkey, appname, &appkey )) appkey = 0;
+        RegCloseKey( tmpkey );
+        if (appkey)
+        {
+            len = sizeof(buffer);
+            if (!RegQueryValueExW( appkey, desktopW, 0, NULL, (LPBYTE)buffer, &len )) ret = buffer;
+            RegCloseKey( appkey );
+            if (ret && strcmpiW( ret, defaultW )) return ret;
+            ret = defaultW;
+        }
+    }
+
+    memcpy( buffer, app_defaultsW, 13 * sizeof(WCHAR) );  /* copy only software\\wine */
+    strcpyW( buffer + 13, explorerW );
+
+    /* @@ Wine registry key: HKCU\Software\Wine\Explorer */
+    if (!RegOpenKeyW( HKEY_CURRENT_USER, buffer, &appkey ))
+    {
+        len = sizeof(buffer);
+        if (!RegQueryValueExW( appkey, desktopW, 0, NULL, (LPBYTE)buffer, &len )) ret = buffer;
+        RegCloseKey( appkey );
+    }
+    return ret;
+}
+
+
+/***********************************************************************
  *           winstation_init
  *
  * Connect to the process window station and desktop.
@@ -161,7 +216,6 @@ static void palette_init(void)
 static void winstation_init(void)
 {
     static const WCHAR WinSta0[] = {'W','i','n','S','t','a','0',0};
-    static const WCHAR Default[] = {'D','e','f','a','u','l','t',0};
 
     STARTUPINFOW info;
     WCHAR *winstation = NULL, *desktop = NULL, *buffer = NULL;
@@ -200,7 +254,8 @@ static void winstation_init(void)
     }
     if (buffer || !GetThreadDesktop( GetCurrentThreadId() ))
     {
-        handle = CreateDesktopW( desktop ? desktop : Default, NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
+        handle = CreateDesktopW( desktop ? desktop : get_default_desktop(),
+                                 NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
         if (handle) SetThreadDesktop( handle );
     }
     HeapFree( GetProcessHeap(), 0, buffer );




More information about the wine-cvs mailing list