From 7e97c2513f12392ad043fa8e64352f82b31e54b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 7 Jul 2020 15:45:30 +0100 Subject: [PATCH] gtk#767 add a way to change the application_id of a toplevel wayland GdkSurface so LibreOffice can reuse toplevels and get the right task icons references; https://gitlab.gnome.org/GNOME/gtk/-/issues/767 https://lists.freedesktop.org/archives/wayland-devel/2019-July/040704.html https://gitlab.freedesktop.org/wayland/wayland-protocols/commit/e0d6ad1d5e7e80321285a9b14ca3329289eb02e6 https://bugs.documentfoundation.org/show_bug.cgi?id=125934 https://bugzilla.redhat.com/show_bug.cgi?id=1334915 https://bugreports.qt.io/browse/QTBUG-77182 --- gdk/wayland/gdksurface-wayland.c | 46 +++++++++++++++++++++++--------- gdk/wayland/gdkwaylandsurface.h | 4 +++ 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index 8f8b791f88..ef3f277664 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -1648,6 +1648,38 @@ create_zxdg_toplevel_v6_resources (GdkSurface *surface) surface); } +void +gdk_wayland_surface_set_application_id (GdkSurface *surface, const char* application_id) +{ + GdkWaylandSurface *impl; + GdkWaylandDisplay *display_wayland; + + g_return_if_fail (application_id != NULL); + + if (GDK_SURFACE_DESTROYED (surface)) + return; + + if (!is_realized_toplevel (surface)) + return; + + display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface)); + impl = GDK_WAYLAND_SURFACE (surface); + + switch (display_wayland->shell_variant) + { + case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL: + xdg_toplevel_set_app_id (impl->display_server.xdg_toplevel, + application_id); + break; + case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6: + zxdg_toplevel_v6_set_app_id (impl->display_server.zxdg_toplevel_v6, + application_id); + break; + default: + g_assert_not_reached (); + } +} + static void gdk_wayland_surface_create_xdg_toplevel (GdkSurface *surface) { @@ -1702,19 +1734,7 @@ gdk_wayland_surface_create_xdg_toplevel (GdkSurface *surface) if (app_id == NULL) app_id = "GTK+ Application"; - switch (display_wayland->shell_variant) - { - case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL: - xdg_toplevel_set_app_id (impl->display_server.xdg_toplevel, - app_id); - break; - case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6: - zxdg_toplevel_v6_set_app_id (impl->display_server.zxdg_toplevel_v6, - app_id); - break; - default: - g_assert_not_reached (); - } + gdk_wayland_surface_set_application_id (surface, app_id); maybe_set_gtk_surface_dbus_properties (surface); maybe_set_gtk_surface_modal (surface); diff --git a/gdk/wayland/gdkwaylandsurface.h b/gdk/wayland/gdkwaylandsurface.h index 57decfcf3d..4af358c33e 100644 --- a/gdk/wayland/gdkwaylandsurface.h +++ b/gdk/wayland/gdkwaylandsurface.h @@ -74,6 +74,10 @@ GDK_AVAILABLE_IN_ALL gboolean gdk_wayland_surface_set_transient_for_exported (GdkSurface *surface, char *parent_handle_str); +GDK_AVAILABLE_IN_ALL +void gdk_wayland_surface_set_application_id (GdkSurface *surface, + const char *application_id); + void gdk_wayland_surface_announce_csd (GdkSurface *surface); G_END_DECLS