winewayland.drv: Set wayland app-id from the process name.

Co-authored-by: Ryan Hendrickson <ryan.hendrickson@alum.mit.edu>
Co-authored-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
This commit is contained in:
Gopal Prasad 2024-02-28 07:47:50 +05:30 committed by Alexandre Julliard
parent 13e1259754
commit dbc00aecec
3 changed files with 38 additions and 0 deletions

View file

@ -253,6 +253,9 @@ void wayland_surface_make_toplevel(struct wayland_surface *surface)
if (!surface->xdg_toplevel) goto err;
xdg_toplevel_add_listener(surface->xdg_toplevel, &xdg_toplevel_listener, surface->hwnd);
if (process_name)
xdg_toplevel_set_app_id(surface->xdg_toplevel, process_name);
wl_surface_commit(surface->wl_surface);
wl_display_flush(process_wayland.wl_display);

View file

@ -51,6 +51,7 @@
* Globals
*/
extern char *process_name;
extern struct wayland process_wayland;
/**********************************************************************

View file

@ -24,11 +24,15 @@
#include "config.h"
#include <stdlib.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "waylanddrv.h"
char *process_name = NULL;
static const struct user_driver_funcs waylanddrv_funcs =
{
.pClipCursor = WAYLAND_ClipCursor,
@ -46,12 +50,42 @@ static const struct user_driver_funcs waylanddrv_funcs =
.pwine_get_wgl_driver = WAYLAND_wine_get_wgl_driver,
};
static void wayland_init_process_name(void)
{
WCHAR *p, *appname;
WCHAR appname_lower[MAX_PATH];
DWORD appname_len;
DWORD appnamez_size;
DWORD utf8_size;
int i;
appname = NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer;
if ((p = wcsrchr(appname, '/'))) appname = p + 1;
if ((p = wcsrchr(appname, '\\'))) appname = p + 1;
appname_len = lstrlenW(appname);
if (appname_len == 0 || appname_len >= MAX_PATH) return;
for (i = 0; appname[i]; i++) appname_lower[i] = RtlDowncaseUnicodeChar(appname[i]);
appname_lower[i] = 0;
appnamez_size = (appname_len + 1) * sizeof(WCHAR);
if (!RtlUnicodeToUTF8N(NULL, 0, &utf8_size, appname_lower, appnamez_size) &&
(process_name = malloc(utf8_size)))
{
RtlUnicodeToUTF8N(process_name, utf8_size, &utf8_size, appname_lower, appnamez_size);
}
}
static NTSTATUS waylanddrv_unix_init(void *arg)
{
/* Set the user driver functions now so that they are available during
* our initialization. We clear them on error. */
__wine_set_user_driver(&waylanddrv_funcs, WINE_GDI_DRIVER_VERSION);
wayland_init_process_name();
if (!wayland_process_init()) goto err;
return 0;