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

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Alexandre Julliard 2017-07-17 11:12:48 +02:00
parent 52d90e3ce0
commit fc21a83a91
3 changed files with 15 additions and 40 deletions

View File

@ -802,38 +802,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
*
@ -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;

View File

@ -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 */

View File

@ -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 );
}
}