summaryrefslogtreecommitdiff
path: root/gdk/wayland
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-11-18 18:00:42 +0000
committerMatthias Clasen <mclasen@redhat.com>2022-11-18 18:00:42 +0000
commite53c9e4832bcbf2d51a783b20b2297bd6c3e8b41 (patch)
tree270f97e5698fac2919cf8eef590470fef5e53dc4 /gdk/wayland
parent64b8a8740f0ba27f14a390a720eb035aa9fa3177 (diff)
parentb3821b19b52fc18a0e86f35d482769cbebe79705 (diff)
downloadgtk+-e53c9e4832bcbf2d51a783b20b2297bd6c3e8b41.tar.gz
Merge branch 'wayland-foreign-v2' into 'main'
wayland: Also support the v2 of the importer See merge request GNOME/gtk!5231
Diffstat (limited to 'gdk/wayland')
-rw-r--r--gdk/wayland/gdkdisplay-wayland.c6
-rw-r--r--gdk/wayland/gdkdisplay-wayland.h1
-rw-r--r--gdk/wayland/gdksurface-wayland.c52
3 files changed, 46 insertions, 13 deletions
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index 7013b2676e..a848a45b6d 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -469,6 +469,12 @@ gdk_registry_handle_global (void *data,
wl_registry_bind (display_wayland->wl_registry, id,
&zxdg_importer_v1_interface, 1);
}
+ else if (strcmp (interface, "zxdg_importer_v2") == 0)
+ {
+ display_wayland->xdg_importer_v2 =
+ wl_registry_bind (display_wayland->wl_registry, id,
+ &zxdg_importer_v2_interface, 1);
+ }
else if (strcmp (interface, "zwp_keyboard_shortcuts_inhibit_manager_v1") == 0)
{
display_wayland->keyboard_shortcuts_inhibit =
diff --git a/gdk/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h
index b23c30a208..40f101f9ff 100644
--- a/gdk/wayland/gdkdisplay-wayland.h
+++ b/gdk/wayland/gdkdisplay-wayland.h
@@ -106,6 +106,7 @@ struct _GdkWaylandDisplay
struct zxdg_exporter_v1 *xdg_exporter;
struct zxdg_exporter_v2 *xdg_exporter_v2;
struct zxdg_importer_v1 *xdg_importer;
+ struct zxdg_importer_v2 *xdg_importer_v2;
struct zwp_keyboard_shortcuts_inhibit_manager_v1 *keyboard_shortcuts_inhibit;
struct org_kde_kwin_server_decoration_manager *server_decoration_manager;
struct zxdg_output_manager_v1 *xdg_output_manager;
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index 44eaf019a2..0e0a651ead 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -185,6 +185,7 @@ struct _GdkWaylandSurface
int state_freeze_count;
struct zxdg_imported_v1 *imported_transient_for;
+ struct zxdg_imported_v2 *imported_transient_for_v2;
GHashTable *shortcuts_inhibitors;
};
@@ -1159,14 +1160,18 @@ gdk_wayland_surface_sync_parent_of_imported (GdkWaylandSurface *impl)
if (!impl->display_server.wl_surface)
return;
- if (!impl->imported_transient_for)
+ if (!impl->imported_transient_for && !impl->imported_transient_for_v2)
return;
if (!is_realized_toplevel (impl))
return;
- zxdg_imported_v1_set_parent_of (impl->imported_transient_for,
- impl->display_server.wl_surface);
+ if (impl->imported_transient_for)
+ zxdg_imported_v1_set_parent_of (impl->imported_transient_for,
+ impl->display_server.wl_surface);
+ else
+ zxdg_imported_v2_set_parent_of (impl->imported_transient_for_v2,
+ impl->display_server.wl_surface);
}
static void
@@ -4696,21 +4701,31 @@ unset_transient_for_exported (GdkSurface *surface)
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
g_clear_pointer (&impl->imported_transient_for, zxdg_imported_v1_destroy);
+ g_clear_pointer (&impl->imported_transient_for_v2, zxdg_imported_v2_destroy);
}
static void
xdg_imported_destroyed (void *data,
- struct zxdg_imported_v1 *zxdg_imported_v1)
+ struct zxdg_imported_v1 *imported)
{
- GdkSurface *surface = data;
-
- unset_transient_for_exported (surface);
+ unset_transient_for_exported (GDK_SURFACE (data));
}
static const struct zxdg_imported_v1_listener xdg_imported_listener = {
xdg_imported_destroyed,
};
+static void
+xdg_imported_v2_destroyed (void *data,
+ struct zxdg_imported_v2 *imported)
+{
+ unset_transient_for_exported (GDK_SURFACE (data));
+}
+
+static const struct zxdg_imported_v2_listener xdg_imported_listener_v2 = {
+ xdg_imported_v2_destroyed,
+};
+
/**
* gdk_wayland_toplevel_set_transient_for_exported:
* @toplevel: (type GdkWaylandToplevel): the `GdkToplevel` to make as transient
@@ -4742,7 +4757,7 @@ gdk_wayland_toplevel_set_transient_for_exported (GdkToplevel *toplevel,
impl = GDK_WAYLAND_SURFACE (toplevel);
display_wayland = GDK_WAYLAND_DISPLAY (display);
- if (!display_wayland->xdg_importer)
+ if (!display_wayland->xdg_importer && !display_wayland->xdg_importer_v2)
{
g_warning ("Server is missing xdg_foreign support");
return FALSE;
@@ -4750,11 +4765,22 @@ gdk_wayland_toplevel_set_transient_for_exported (GdkToplevel *toplevel,
gdk_wayland_toplevel_set_transient_for (GDK_WAYLAND_TOPLEVEL (impl), NULL);
- impl->imported_transient_for =
- zxdg_importer_v1_import (display_wayland->xdg_importer, parent_handle_str);
- zxdg_imported_v1_add_listener (impl->imported_transient_for,
- &xdg_imported_listener,
- toplevel);
+ if (display_wayland->xdg_importer)
+ {
+ impl->imported_transient_for =
+ zxdg_importer_v1_import (display_wayland->xdg_importer, parent_handle_str);
+ zxdg_imported_v1_add_listener (impl->imported_transient_for,
+ &xdg_imported_listener,
+ toplevel);
+ }
+ else
+ {
+ impl->imported_transient_for_v2 =
+ zxdg_importer_v2_import_toplevel (display_wayland->xdg_importer_v2, parent_handle_str);
+ zxdg_imported_v2_add_listener (impl->imported_transient_for_v2,
+ &xdg_imported_listener_v2,
+ toplevel);
+ }
gdk_wayland_surface_sync_parent_of_imported (impl);