From c7dbffca96ec36322abfca624ad200abb8cbde38 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard <julliard@winehq.org> Date: Fri, 1 Jul 2005 16:16:00 +0000 Subject: [PATCH] Set the class resource name to the name of the main binary (suggested by Rasterman). --- dlls/x11drv/window.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/dlls/x11drv/window.c b/dlls/x11drv/window.c index c896c911337..e0cd8a036ac 100644 --- a/dlls/x11drv/window.c +++ b/dlls/x11drv/window.c @@ -373,6 +373,38 @@ static void set_size_hints( Display *display, struct x11drv_win_data *data, DWOR } +/*********************************************************************** + * 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; +} + + /*********************************************************************** * X11DRV_set_wm_hints * @@ -390,6 +422,7 @@ void X11DRV_set_wm_hints( Display *display, struct x11drv_win_data *data ) DWORD style = GetWindowLongW( data->hwnd, GWL_STYLE ); DWORD ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE ); HWND owner = GetWindow( data->hwnd, GW_OWNER ); + char *process_name = get_process_name(); /* transient for hint */ if (owner) @@ -415,7 +448,7 @@ void X11DRV_set_wm_hints( Display *display, struct x11drv_win_data *data ) /* class hints */ if ((class_hints = XAllocClassHint())) { - class_hints->res_name = "wine"; + class_hints->res_name = process_name; class_hints->res_class = "Wine"; XSetClassHint( display, data->whole_window, class_hints ); XFree( class_hints ); -- GitLab