From: Matthias Clasen Date: Wed, 9 Nov 2022 11:22:00 +0000 (+0100) Subject: wayland: Add zxdg_foreign_v2 protocol support X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~9^2~106^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0ba8e16e1417fdb;p=gtk4.git wayland: Add zxdg_foreign_v2 protocol support --- diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index c1881bfb42..b798dd832b 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -52,6 +52,7 @@ #include "tablet-unstable-v2-client-protocol.h" #include #include +#include #include #include "wm-button-layout-translation.h" @@ -455,6 +456,12 @@ gdk_registry_handle_global (void *data, wl_registry_bind (display_wayland->wl_registry, id, &zxdg_exporter_v1_interface, 1); } + else if (strcmp (interface, "zxdg_exporter_v2") == 0) + { + display_wayland->xdg_exporter_v2 = + wl_registry_bind (display_wayland->wl_registry, id, + &zxdg_exporter_v2_interface, 1); + } else if (strcmp (interface, "zxdg_importer_v1") == 0) { display_wayland->xdg_importer = diff --git a/gdk/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h index 8907d20212..b23c30a208 100644 --- a/gdk/wayland/gdkdisplay-wayland.h +++ b/gdk/wayland/gdkdisplay-wayland.h @@ -104,6 +104,7 @@ struct _GdkWaylandDisplay struct zwp_primary_selection_device_manager_v1 *primary_selection_manager; struct zwp_tablet_manager_v2 *tablet_manager; struct zxdg_exporter_v1 *xdg_exporter; + struct zxdg_exporter_v2 *xdg_exporter_v2; struct zxdg_importer_v1 *xdg_importer; struct zwp_keyboard_shortcuts_inhibit_manager_v1 *keyboard_shortcuts_inhibit; struct org_kde_kwin_server_decoration_manager *server_decoration_manager; diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index dbb63c84bb..711e621fa0 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -35,6 +35,7 @@ #include "gdkdevice-wayland-private.h" #include +#include #include #include @@ -250,6 +251,7 @@ struct _GdkWaylandToplevel struct org_kde_kwin_server_decoration *server_decoration; struct zxdg_exported_v1 *xdg_exported; + struct zxdg_exported_v2 *xdg_exported_v2; struct { GdkWaylandToplevelExported callback; @@ -5236,16 +5238,29 @@ gdk_wayland_toplevel_restore_system_shortcuts (GdkToplevel *toplevel) } static void -xdg_exported_handle2 (void *data, - struct zxdg_exported_v1 *zxdg_exported_v1, - const char *handle) +xdg_exported_handle_v1 (void *data, + struct zxdg_exported_v1 *zxdg_exported_v1, + const char *handle) { g_task_return_pointer (G_TASK (data), g_strdup (handle), g_free); g_object_unref (data); } -static const struct zxdg_exported_v1_listener xdg_exported_listener2 = { - xdg_exported_handle2 +static const struct zxdg_exported_v1_listener xdg_exported_listener_v1 = { + xdg_exported_handle_v1 +}; + +static void +xdg_exported_handle_v2 (void *data, + struct zxdg_exported_v2 *zxdg_exported_v2, + const char *handle) +{ + g_task_return_pointer (G_TASK (data), g_strdup (handle), g_free); + g_object_unref (data); +} + +static const struct zxdg_exported_v2_listener xdg_exported_listener_v2 = { + xdg_exported_handle_v2 }; static void @@ -5258,24 +5273,32 @@ gdk_wayland_toplevel_real_export_handle (GdkToplevel *toplevel, GdkSurface *surface = GDK_SURFACE (toplevel); GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (toplevel)); GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display); - struct zxdg_exported_v1 *xdg_exported; GTask *task; task = g_task_new (toplevel, cancellable, callback, user_data); - if (!display_wayland->xdg_exporter) + if (display_wayland->xdg_exporter_v2) + { + wayland_toplevel->xdg_exported_v2 = + zxdg_exporter_v2_export_toplevel (display_wayland->xdg_exporter_v2, + gdk_wayland_surface_get_wl_surface (surface)); + zxdg_exported_v2_add_listener (wayland_toplevel->xdg_exported_v2, + &xdg_exported_listener_v2, task); + } + else if (display_wayland->xdg_exporter) + { + wayland_toplevel->xdg_exported = + zxdg_exporter_v1_export (display_wayland->xdg_exporter, + gdk_wayland_surface_get_wl_surface (surface)); + zxdg_exported_v1_add_listener (wayland_toplevel->xdg_exported, + &xdg_exported_listener_v1, task); + } + else { g_task_return_pointer (task, NULL, NULL); g_object_unref (task); return; } - - xdg_exported = - zxdg_exporter_v1_export (display_wayland->xdg_exporter, - gdk_wayland_surface_get_wl_surface (surface)); - - zxdg_exported_v1_add_listener (xdg_exported, &xdg_exported_listener2, task); - wayland_toplevel->xdg_exported = xdg_exported; } static char * @@ -5289,16 +5312,16 @@ gdk_wayland_toplevel_real_export_handle_finish (GdkToplevel *toplevel, static void gdk_wayland_toplevel_real_unexport_handle (GdkToplevel *toplevel) { - GdkWaylandToplevel *wayland_toplevel; + GdkWaylandToplevel *wayland_toplevel = GDK_WAYLAND_TOPLEVEL (toplevel); + GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (toplevel)); + GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display); g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel)); - wayland_toplevel = GDK_WAYLAND_TOPLEVEL (toplevel); - - g_return_if_fail (wayland_toplevel->xdg_exported); - - g_clear_pointer (&wayland_toplevel->xdg_exported, - zxdg_exported_v1_destroy); + if (display_wayland->xdg_exporter_v2) + g_clear_pointer (&wayland_toplevel->xdg_exported_v2, zxdg_exported_v2_destroy); + else if (display_wayland->xdg_exporter) + g_clear_pointer (&wayland_toplevel->xdg_exported, zxdg_exported_v1_destroy); } static void diff --git a/gdk/wayland/meson.build b/gdk/wayland/meson.build index 801d55509a..0fd040960d 100644 --- a/gdk/wayland/meson.build +++ b/gdk/wayland/meson.build @@ -51,6 +51,7 @@ proto_sources = [ ['xdg-shell', 'unstable', 'v6', ], ['xdg-shell', 'stable', ], ['xdg-foreign', 'unstable', 'v1', ], + ['xdg-foreign', 'unstable', 'v2', ], ['tablet', 'unstable', 'v2', ], ['keyboard-shortcuts-inhibit', 'unstable', 'v1', ], ['server-decoration', 'private' ],