mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 21:51:08 +00:00
wayland: Add zxdg_foreign_v2 protocol support
This commit is contained in:
parent
f9982a61e6
commit
0ba8e16e14
@ -52,6 +52,7 @@
|
||||
#include "tablet-unstable-v2-client-protocol.h"
|
||||
#include <wayland/xdg-shell-unstable-v6-client-protocol.h>
|
||||
#include <wayland/xdg-foreign-unstable-v1-client-protocol.h>
|
||||
#include <wayland/xdg-foreign-unstable-v2-client-protocol.h>
|
||||
#include <wayland/server-decoration-client-protocol.h>
|
||||
|
||||
#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 =
|
||||
|
@ -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;
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "gdkdevice-wayland-private.h"
|
||||
|
||||
#include <wayland/xdg-shell-unstable-v6-client-protocol.h>
|
||||
#include <wayland/xdg-foreign-unstable-v2-client-protocol.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -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
|
||||
|
@ -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' ],
|
||||
|
Loading…
Reference in New Issue
Block a user