From: llyyr llyyr@yukari.in
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56000
Co-authored-by: Ryan Hendrickson ryan.hendrickson@alum.mit.edu Co-authored-by: Alexandros Frantzis alexandros.frantzis@collabora.com Signed-off-by: llyyr llyyr@yukari.in --- dlls/winewayland.drv/wayland_surface.c | 31 ++++++++++++++++++++++++++ dlls/winewayland.drv/waylanddrv.h | 1 + 2 files changed, 32 insertions(+)
diff --git a/dlls/winewayland.drv/wayland_surface.c b/dlls/winewayland.drv/wayland_surface.c index a955f3688c5..9ae4314adb3 100644 --- a/dlls/winewayland.drv/wayland_surface.c +++ b/dlls/winewayland.drv/wayland_surface.c @@ -235,6 +235,33 @@ void wayland_surface_destroy(struct wayland_surface *surface) free(surface); }
+static void wayland_init_process_name(struct wayland_surface *surface) +{ + 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) && + (surface->app_id = malloc(utf8_size))) + { + RtlUnicodeToUTF8N(surface->app_id, utf8_size, &utf8_size, appname_lower, appnamez_size); + } +} /********************************************************************** * wayland_surface_make_toplevel * @@ -253,6 +280,10 @@ 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);
+ wayland_init_process_name(surface); + if (surface->app_id) + xdg_toplevel_set_app_id(surface->xdg_toplevel, surface->app_id); + wl_surface_commit(surface->wl_surface); wl_display_flush(process_wayland.wl_display);
diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index f030f6fc6a0..176b54bd132 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -202,6 +202,7 @@ struct wayland_surface struct wayland_client_surface *client; int buffer_width, buffer_height; HCURSOR hcursor; + char *app_id; };
struct wayland_shm_buffer
@llyyr The primary mechanism for providing a window title is `xdg_toplevel_set_title`. The `app_id` is used mainly for broad identification and grouping purposes. Some compositors may use the `app_id` for the title, if a title is not available, but many do not. So, in terms of the linked bug, the right solution would be to implement title setting (so basically https://gitlab.winehq.org/afrantzis/wine/-/commit/1f698192c696486ec747bbe095... from the experimental branch).
In terms of this MR:
* Since the process name doesn't change during runtime, I would suggest initializing it just once during startup and making it available to the whole process (i.e., sticking to what the experimental branch and winex11 are doing). * The commit message subject (after the component) should start with a capital and end with a period.
Thanks!