Alexandre Julliard : winex11: Store the process name at startup to avoid grabbing the loader lock again.

Alexandre Julliard julliard at winehq.org
Mon Jul 17 15:37:19 CDT 2017


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Jul 17 11:12:48 2017 +0200

winex11: Store the process name at startup to avoid grabbing the loader lock again.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winex11.drv/window.c      | 33 ---------------------------------
 dlls/winex11.drv/x11drv.h      |  1 +
 dlls/winex11.drv/x11drv_main.c | 21 ++++++++++++++-------
 3 files changed, 15 insertions(+), 40 deletions(-)

diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index eaf6dcf..d35328c 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -803,38 +803,6 @@ static void set_style_hints( struct x11drv_win_data *data, DWORD style, DWORD ex
 
 
 /***********************************************************************
- *              get_process_name
- *
- * get the name of the current process for setting class hints
- */
-static char *get_process_name(void)
-{
-    static char *name;
-
-    if (!name)
-    {
-        WCHAR module[MAX_PATH];
-        DWORD len = GetModuleFileNameW( 0, module, MAX_PATH );
-        if (len && len < MAX_PATH)
-        {
-            char *ptr;
-            WCHAR *p, *appname = module;
-
-            if ((p = strrchrW( appname, '/' ))) appname = p + 1;
-            if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
-            len = WideCharToMultiByte( CP_UNIXCP, 0, appname, -1, NULL, 0, NULL, NULL );
-            if ((ptr = HeapAlloc( GetProcessHeap(), 0, len )))
-            {
-                WideCharToMultiByte( CP_UNIXCP, 0, appname, -1, ptr, len, NULL, NULL );
-                name = ptr;
-            }
-        }
-    }
-    return name;
-}
-
-
-/***********************************************************************
  *              set_initial_wm_hints
  *
  * Set the window manager hints that don't change over the lifetime of a window.
@@ -845,7 +813,6 @@ static void set_initial_wm_hints( Display *display, Window window )
     Atom protocols[3];
     Atom dndVersion = WINE_XDND_VERSION;
     XClassHint *class_hints;
-    char *process_name = get_process_name();
 
     /* wm protocols */
     i = 0;
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index f125289..721c082 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -395,6 +395,7 @@ extern int copy_default_colors DECLSPEC_HIDDEN;
 extern int alloc_system_colors DECLSPEC_HIDDEN;
 extern int xrender_error_base DECLSPEC_HIDDEN;
 extern HMODULE x11drv_module DECLSPEC_HIDDEN;
+extern char *process_name DECLSPEC_HIDDEN;
 extern Display *clipboard_display DECLSPEC_HIDDEN;
 
 /* atoms */
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index 2127df4..65ef59b 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -49,6 +49,7 @@
 #include "x11drv.h"
 #include "xcomposite.h"
 #include "wine/server.h"
+#include "wine/unicode.h"
 #include "wine/debug.h"
 #include "wine/library.h"
 
@@ -84,6 +85,7 @@ int alloc_system_colors = 256;
 DWORD thread_data_tls_index = TLS_OUT_OF_INDEXES;
 int xrender_error_base = 0;
 HMODULE x11drv_module = 0;
+char *process_name = NULL;
 
 static x11drv_error_callback err_callback;   /* current callback for error */
 static Display *err_callback_display;        /* display callback is set for */
@@ -323,7 +325,9 @@ static inline DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name,
  */
 static void setup_options(void)
 {
-    char buffer[MAX_PATH+16];
+    static const WCHAR x11driverW[] = {'\\','X','1','1',' ','D','r','i','v','e','r',0};
+    char buffer[64];
+    WCHAR bufferW[MAX_PATH+16];
     HKEY hkey, appkey = 0;
     DWORD len;
 
@@ -332,18 +336,21 @@ static void setup_options(void)
 
     /* open the app-specific key */
 
-    len = (GetModuleFileNameA( 0, buffer, MAX_PATH ));
+    len = (GetModuleFileNameW( 0, bufferW, MAX_PATH ));
     if (len && len < MAX_PATH)
     {
         HKEY tmpkey;
-        char *p, *appname = buffer;
-        if ((p = strrchr( appname, '/' ))) appname = p + 1;
-        if ((p = strrchr( appname, '\\' ))) appname = p + 1;
-        strcat( appname, "\\X11 Driver" );
+        WCHAR *p, *appname = bufferW;
+        if ((p = strrchrW( appname, '/' ))) appname = p + 1;
+        if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
+        len = WideCharToMultiByte( CP_UNIXCP, 0, appname, -1, NULL, 0, NULL, NULL );
+        if ((process_name = HeapAlloc( GetProcessHeap(), 0, len )))
+            WideCharToMultiByte( CP_UNIXCP, 0, appname, -1, process_name, len, NULL, NULL );
+        strcatW( appname, x11driverW );
         /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\X11 Driver */
         if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey ))
         {
-            if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0;
+            if (RegOpenKeyW( tmpkey, appname, &appkey )) appkey = 0;
             RegCloseKey( tmpkey );
         }
     }




More information about the wine-cvs mailing list