mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
wayland: Port to xdg_shell unstable v6
https://bugzilla.gnome.org/show_bug.cgi?id=769937
This commit is contained in:
parent
643f033923
commit
ceada4adc2
@ -23,8 +23,8 @@ noinst_LTLIBRARIES = \
|
||||
BUILT_SOURCES = \
|
||||
pointer-gestures-unstable-v1-client-protocol.h \
|
||||
pointer-gestures-unstable-v1-protocol.c \
|
||||
xdg-shell-unstable-v5-client-protocol.h \
|
||||
xdg-shell-unstable-v5-protocol.c \
|
||||
xdg-shell-unstable-v6-client-protocol.h \
|
||||
xdg-shell-unstable-v6-protocol.c \
|
||||
gtk-primary-selection-client-protocol.h \
|
||||
gtk-primary-selection-protocol.c \
|
||||
tablet-unstable-v2-client-protocol.h \
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "gdkwaylandmonitor.h"
|
||||
#include "pointer-gestures-unstable-v1-client-protocol.h"
|
||||
#include "tablet-unstable-v2-client-protocol.h"
|
||||
#include "xdg-shell-unstable-v6-client-protocol.h"
|
||||
|
||||
/**
|
||||
* SECTION:wayland_interaction
|
||||
@ -112,9 +113,9 @@ _gdk_wayland_display_async_roundtrip (GdkWaylandDisplay *display_wayland)
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_shell_ping (void *data,
|
||||
struct xdg_shell *xdg_shell,
|
||||
uint32_t serial)
|
||||
xdg_shell_ping (void *data,
|
||||
struct zxdg_shell_v6 *xdg_shell,
|
||||
uint32_t serial)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = data;
|
||||
|
||||
@ -123,10 +124,10 @@ xdg_shell_ping (void *data,
|
||||
GDK_NOTE (EVENTS,
|
||||
g_message ("ping, shell %p, serial %u\n", xdg_shell, serial));
|
||||
|
||||
xdg_shell_pong (xdg_shell, serial);
|
||||
zxdg_shell_v6_pong (xdg_shell, serial);
|
||||
}
|
||||
|
||||
static const struct xdg_shell_listener xdg_shell_listener = {
|
||||
static const struct zxdg_shell_v6_listener xdg_shell_listener = {
|
||||
xdg_shell_ping,
|
||||
};
|
||||
|
||||
@ -353,12 +354,14 @@ gdk_registry_handle_global (void *data,
|
||||
wl_registry_bind (display_wayland->wl_registry, id, &wl_shm_interface, 1);
|
||||
wl_shm_add_listener (display_wayland->shm, &wl_shm_listener, display_wayland);
|
||||
}
|
||||
else if (strcmp (interface, "xdg_shell") == 0)
|
||||
else if (strcmp (interface, "zxdg_shell_v6") == 0)
|
||||
{
|
||||
display_wayland->xdg_shell =
|
||||
wl_registry_bind (display_wayland->wl_registry, id, &xdg_shell_interface, 1);
|
||||
xdg_shell_use_unstable_version (display_wayland->xdg_shell, XDG_SHELL_VERSION_CURRENT);
|
||||
xdg_shell_add_listener (display_wayland->xdg_shell, &xdg_shell_listener, display_wayland);
|
||||
wl_registry_bind (display_wayland->wl_registry, id,
|
||||
&zxdg_shell_v6_interface, 1);
|
||||
zxdg_shell_v6_add_listener (display_wayland->xdg_shell,
|
||||
&xdg_shell_listener,
|
||||
display_wayland);
|
||||
}
|
||||
else if (strcmp (interface, "gtk_shell1") == 0)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <wayland-egl.h>
|
||||
#include <gdk/wayland/tablet-unstable-v2-client-protocol.h>
|
||||
#include <gdk/wayland/gtk-shell-client-protocol.h>
|
||||
#include <gdk/wayland/xdg-shell-unstable-v5-client-protocol.h>
|
||||
#include <gdk/wayland/xdg-shell-unstable-v6-client-protocol.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <gdk/gdkkeys.h>
|
||||
@ -66,7 +66,7 @@ struct _GdkWaylandDisplay
|
||||
struct wl_registry *wl_registry;
|
||||
struct wl_compositor *compositor;
|
||||
struct wl_shm *shm;
|
||||
struct xdg_shell *xdg_shell;
|
||||
struct zxdg_shell_v6 *xdg_shell;
|
||||
struct gtk_shell1 *gtk_shell;
|
||||
struct wl_input_device *input_device;
|
||||
struct wl_data_device_manager *data_device_manager;
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "gdkprivate-wayland.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkprivate-wayland.h"
|
||||
#include "xdg-shell-unstable-v6-client-protocol.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -102,8 +104,9 @@ struct _GdkWindowImplWayland
|
||||
GSList *outputs;
|
||||
|
||||
struct wl_surface *wl_surface;
|
||||
struct xdg_surface *xdg_surface;
|
||||
struct xdg_popup *xdg_popup;
|
||||
struct zxdg_surface_v6 *xdg_surface;
|
||||
struct zxdg_toplevel_v6 *xdg_toplevel;
|
||||
struct zxdg_popup_v6 *xdg_popup;
|
||||
struct gtk_surface1 *gtk_surface;
|
||||
struct wl_subsurface *wl_subsurface;
|
||||
struct wl_egl_window *egl_window;
|
||||
@ -113,6 +116,7 @@ struct _GdkWindowImplWayland
|
||||
EGLSurface egl_surface;
|
||||
EGLSurface dummy_egl_surface;
|
||||
|
||||
unsigned int initial_configure_received : 1;
|
||||
unsigned int mapped : 1;
|
||||
unsigned int use_custom_surface : 1;
|
||||
unsigned int pending_buffer_attached : 1;
|
||||
@ -182,6 +186,8 @@ struct _GdkWindowImplWayland
|
||||
} pending_move_to_rect;
|
||||
|
||||
struct {
|
||||
int width;
|
||||
int height;
|
||||
GdkWindowState state;
|
||||
} pending;
|
||||
};
|
||||
@ -515,6 +521,9 @@ on_frame_clock_before_paint (GdkFrameClock *clock,
|
||||
gint64 presentation_time;
|
||||
gint64 refresh_interval;
|
||||
|
||||
if (window->update_freeze_count > 0)
|
||||
return;
|
||||
|
||||
gdk_frame_clock_get_refresh_info (clock,
|
||||
timings->frame_time,
|
||||
&refresh_interval, &presentation_time);
|
||||
@ -547,6 +556,9 @@ on_frame_clock_after_paint (GdkFrameClock *clock,
|
||||
if (!impl->pending_commit)
|
||||
return;
|
||||
|
||||
if (window->update_freeze_count > 0)
|
||||
return;
|
||||
|
||||
callback = wl_surface_frame (impl->display_server.wl_surface);
|
||||
wl_callback_add_listener (callback, &frame_listener, window);
|
||||
_gdk_frame_clock_freeze (clock);
|
||||
@ -983,12 +995,12 @@ gdk_wayland_window_sync_parent (GdkWindow *window,
|
||||
{
|
||||
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
||||
GdkWindowImplWayland *impl_parent = NULL;
|
||||
struct xdg_surface *parent_surface;
|
||||
struct zxdg_toplevel_v6 *parent_toplevel;
|
||||
|
||||
g_assert (parent == NULL ||
|
||||
gdk_window_get_display (window) == gdk_window_get_display (parent));
|
||||
|
||||
if (!impl->display_server.xdg_surface)
|
||||
if (!impl->display_server.xdg_toplevel)
|
||||
return;
|
||||
|
||||
if (impl->transient_for)
|
||||
@ -1002,12 +1014,13 @@ gdk_wayland_window_sync_parent (GdkWindow *window,
|
||||
if (!impl_parent->display_server.wl_surface)
|
||||
return;
|
||||
|
||||
parent_surface = impl_parent->display_server.xdg_surface;
|
||||
parent_toplevel = impl_parent->display_server.xdg_toplevel;
|
||||
}
|
||||
else
|
||||
parent_surface = NULL;
|
||||
parent_toplevel = NULL;
|
||||
|
||||
xdg_surface_set_parent (impl->display_server.xdg_surface, parent_surface);
|
||||
zxdg_toplevel_v6_set_parent (impl->display_server.xdg_toplevel,
|
||||
parent_toplevel);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1046,13 +1059,13 @@ gdk_wayland_window_sync_title (GdkWindow *window)
|
||||
{
|
||||
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
||||
|
||||
if (!impl->display_server.xdg_surface)
|
||||
if (!impl->display_server.xdg_toplevel)
|
||||
return;
|
||||
|
||||
if (!impl->title)
|
||||
return;
|
||||
|
||||
xdg_surface_set_title (impl->display_server.xdg_surface, impl->title);
|
||||
zxdg_toplevel_v6_set_title (impl->display_server.xdg_toplevel, impl->title);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1079,11 +1092,11 @@ gdk_wayland_window_sync_margin (GdkWindow *window)
|
||||
return;
|
||||
|
||||
gdk_wayland_window_get_window_geometry (window, &geometry);
|
||||
xdg_surface_set_window_geometry (impl->display_server.xdg_surface,
|
||||
geometry.x,
|
||||
geometry.y,
|
||||
geometry.width,
|
||||
geometry.height);
|
||||
zxdg_surface_v6_set_window_geometry (impl->display_server.xdg_surface,
|
||||
geometry.x,
|
||||
geometry.y,
|
||||
geometry.width,
|
||||
geometry.height);
|
||||
}
|
||||
|
||||
static struct wl_region *
|
||||
@ -1254,42 +1267,31 @@ gdk_wayland_window_create_surface (GdkWindow *window)
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_surface_configure (void *data,
|
||||
struct xdg_surface *xdg_surface,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
struct wl_array *states,
|
||||
uint32_t serial)
|
||||
xdg_surface_configure (void *data,
|
||||
struct zxdg_surface_v6 *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
GdkWindow *window = GDK_WINDOW (data);
|
||||
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
||||
GdkWindowState new_state = 0;
|
||||
GdkWindowState new_state;
|
||||
int width = impl->pending.width;
|
||||
int height = impl->pending.height;
|
||||
gboolean fixed_size;
|
||||
uint32_t *p;
|
||||
|
||||
wl_array_for_each (p, states)
|
||||
if (!impl->initial_configure_received)
|
||||
{
|
||||
uint32_t state = *p;
|
||||
switch (state)
|
||||
{
|
||||
case XDG_SURFACE_STATE_FULLSCREEN:
|
||||
new_state |= GDK_WINDOW_STATE_FULLSCREEN;
|
||||
break;
|
||||
case XDG_SURFACE_STATE_MAXIMIZED:
|
||||
new_state |= GDK_WINDOW_STATE_MAXIMIZED;
|
||||
break;
|
||||
case XDG_SURFACE_STATE_ACTIVATED:
|
||||
new_state |= GDK_WINDOW_STATE_FOCUSED;
|
||||
break;
|
||||
case XDG_SURFACE_STATE_RESIZING:
|
||||
break;
|
||||
default:
|
||||
/* Unknown state */
|
||||
break;
|
||||
}
|
||||
gdk_window_thaw_updates (window);
|
||||
impl->initial_configure_received = TRUE;
|
||||
}
|
||||
|
||||
new_state |= impl->pending.state;
|
||||
/* xdg_popup configuration aren't handled yet so just pretend we listened. */
|
||||
if (impl->display_server.xdg_popup)
|
||||
{
|
||||
zxdg_surface_v6_ack_configure (xdg_surface, serial);
|
||||
return;
|
||||
}
|
||||
|
||||
new_state = impl->pending.state;
|
||||
impl->pending.state = 0;
|
||||
|
||||
fixed_size =
|
||||
@ -1339,15 +1341,56 @@ xdg_surface_configure (void *data,
|
||||
(new_state & GDK_WINDOW_STATE_TILED) ? " tiled" : ""));
|
||||
|
||||
_gdk_set_window_state (window, new_state);
|
||||
xdg_surface_ack_configure (xdg_surface, serial);
|
||||
zxdg_surface_v6_ack_configure (xdg_surface, serial);
|
||||
if (impl->hint != GDK_WINDOW_TYPE_HINT_DIALOG &&
|
||||
new_state & GDK_WINDOW_STATE_FOCUSED)
|
||||
gdk_wayland_window_update_dialogs (window);
|
||||
}
|
||||
|
||||
static const struct zxdg_surface_v6_listener xdg_surface_listener = {
|
||||
xdg_surface_configure,
|
||||
};
|
||||
|
||||
static void
|
||||
xdg_surface_close (void *data,
|
||||
struct xdg_surface *xdg_surface)
|
||||
xdg_toplevel_configure (void *data,
|
||||
struct zxdg_toplevel_v6 *xdg_toplevel,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
struct wl_array *states)
|
||||
{
|
||||
GdkWindow *window = GDK_WINDOW (data);
|
||||
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
||||
uint32_t *p;
|
||||
|
||||
wl_array_for_each (p, states)
|
||||
{
|
||||
uint32_t state = *p;
|
||||
switch (state)
|
||||
{
|
||||
case ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN:
|
||||
impl->pending.state |= GDK_WINDOW_STATE_FULLSCREEN;
|
||||
break;
|
||||
case ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED:
|
||||
impl->pending.state |= GDK_WINDOW_STATE_MAXIMIZED;
|
||||
break;
|
||||
case ZXDG_TOPLEVEL_V6_STATE_ACTIVATED:
|
||||
impl->pending.state |= GDK_WINDOW_STATE_FOCUSED;
|
||||
break;
|
||||
case ZXDG_TOPLEVEL_V6_STATE_RESIZING:
|
||||
break;
|
||||
default:
|
||||
/* Unknown state */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
impl->pending.width = width;
|
||||
impl->pending.height = height;
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_toplevel_close (void *data,
|
||||
struct zxdg_toplevel_v6 *xdg_toplevel)
|
||||
{
|
||||
GdkWindow *window = GDK_WINDOW (data);
|
||||
GdkDisplay *display;
|
||||
@ -1364,13 +1407,13 @@ xdg_surface_close (void *data,
|
||||
_gdk_wayland_display_deliver_event (display, event);
|
||||
}
|
||||
|
||||
static const struct xdg_surface_listener xdg_surface_listener = {
|
||||
xdg_surface_configure,
|
||||
xdg_surface_close,
|
||||
static const struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
|
||||
xdg_toplevel_configure,
|
||||
xdg_toplevel_close,
|
||||
};
|
||||
|
||||
static void
|
||||
gdk_wayland_window_create_xdg_surface (GdkWindow *window)
|
||||
gdk_wayland_window_create_xdg_toplevel (GdkWindow *window)
|
||||
{
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
||||
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
||||
@ -1381,33 +1424,57 @@ gdk_wayland_window_create_xdg_surface (GdkWindow *window)
|
||||
impl->initial_fullscreen_monitor < gdk_screen_get_n_monitors (screen))
|
||||
fullscreen_output = _gdk_wayland_screen_get_wl_output (screen, impl->initial_fullscreen_monitor);
|
||||
|
||||
impl->display_server.xdg_surface = xdg_shell_get_xdg_surface (display_wayland->xdg_shell, impl->display_server.wl_surface);
|
||||
xdg_surface_add_listener (impl->display_server.xdg_surface, &xdg_surface_listener, window);
|
||||
impl->display_server.xdg_surface =
|
||||
zxdg_shell_v6_get_xdg_surface (display_wayland->xdg_shell,
|
||||
impl->display_server.wl_surface);
|
||||
zxdg_surface_v6_add_listener (impl->display_server.xdg_surface,
|
||||
&xdg_surface_listener,
|
||||
window);
|
||||
gdk_window_freeze_updates (window);
|
||||
|
||||
impl->display_server.xdg_toplevel =
|
||||
zxdg_surface_v6_get_toplevel (impl->display_server.xdg_surface);
|
||||
zxdg_toplevel_v6_add_listener (impl->display_server.xdg_toplevel,
|
||||
&xdg_toplevel_listener,
|
||||
window);
|
||||
|
||||
gdk_wayland_window_sync_parent (window, NULL);
|
||||
gdk_wayland_window_sync_title (window);
|
||||
|
||||
if (window->state & GDK_WINDOW_STATE_MAXIMIZED)
|
||||
xdg_surface_set_maximized (impl->display_server.xdg_surface);
|
||||
zxdg_toplevel_v6_set_maximized (impl->display_server.xdg_toplevel);
|
||||
if (window->state & GDK_WINDOW_STATE_FULLSCREEN)
|
||||
xdg_surface_set_fullscreen (impl->display_server.xdg_surface, fullscreen_output);
|
||||
zxdg_toplevel_v6_set_fullscreen (impl->display_server.xdg_toplevel,
|
||||
fullscreen_output);
|
||||
|
||||
app_id = g_get_prgname ();
|
||||
if (app_id == NULL)
|
||||
app_id = gdk_get_program_class ();
|
||||
|
||||
xdg_surface_set_app_id (impl->display_server.xdg_surface, app_id);
|
||||
zxdg_toplevel_v6_set_app_id (impl->display_server.xdg_toplevel, app_id);
|
||||
|
||||
maybe_set_gtk_surface_dbus_properties (window);
|
||||
maybe_set_gtk_surface_modal (window);
|
||||
|
||||
if (impl->hint == GDK_WINDOW_TYPE_HINT_DIALOG)
|
||||
_gdk_wayland_screen_add_orphan_dialog (window);
|
||||
|
||||
wl_surface_commit (impl->display_server.wl_surface);
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_popup_done (void *data,
|
||||
struct xdg_popup *xdg_popup)
|
||||
xdg_popup_configure (void *data,
|
||||
struct zxdg_popup_v6 *xdg_popup,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
int32_t width,
|
||||
int32_t height)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_popup_done (void *data,
|
||||
struct zxdg_popup_v6 *xdg_popup)
|
||||
{
|
||||
GdkWindow *window = GDK_WINDOW (data);
|
||||
|
||||
@ -1417,7 +1484,8 @@ xdg_popup_done (void *data,
|
||||
gdk_window_hide (window);
|
||||
}
|
||||
|
||||
static const struct xdg_popup_listener xdg_popup_listener = {
|
||||
static const struct zxdg_popup_v6_listener xdg_popup_listener = {
|
||||
xdg_popup_configure,
|
||||
xdg_popup_done,
|
||||
};
|
||||
|
||||
@ -1429,30 +1497,65 @@ gdk_wayland_window_create_xdg_popup (GdkWindow *window,
|
||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
|
||||
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
||||
GdkWindowImplWayland *parent_impl = GDK_WINDOW_IMPL_WAYLAND (parent->impl);
|
||||
struct zxdg_positioner_v6 *positioner;
|
||||
GdkRectangle geometry;
|
||||
GdkRectangle parent_geometry;
|
||||
int parent_x, parent_y;
|
||||
GdkSeat *gdk_seat;
|
||||
guint32 serial;
|
||||
int x, y;
|
||||
|
||||
if (!impl->display_server.wl_surface)
|
||||
return;
|
||||
|
||||
if (!parent_impl->display_server.wl_surface)
|
||||
if (!parent_impl->display_server.xdg_surface)
|
||||
return;
|
||||
|
||||
impl->display_server.xdg_surface =
|
||||
zxdg_shell_v6_get_xdg_surface (display->xdg_shell,
|
||||
impl->display_server.wl_surface);
|
||||
zxdg_surface_v6_add_listener (impl->display_server.xdg_surface,
|
||||
&xdg_surface_listener,
|
||||
window);
|
||||
gdk_window_freeze_updates (window);
|
||||
|
||||
positioner = zxdg_shell_v6_create_positioner (display->xdg_shell);
|
||||
|
||||
gdk_wayland_window_get_window_geometry (window, &geometry);
|
||||
zxdg_positioner_v6_set_size (positioner, geometry.width, geometry.height);
|
||||
|
||||
parent_x = parent->x;
|
||||
parent_y = parent->y;
|
||||
|
||||
gdk_wayland_window_get_window_geometry (parent, &parent_geometry);
|
||||
parent_x += parent_geometry.x;
|
||||
parent_y += parent_geometry.y;
|
||||
|
||||
zxdg_positioner_v6_set_anchor_rect (positioner,
|
||||
(window->x + geometry.x) - parent_x,
|
||||
(window->y + geometry.y) - parent_y,
|
||||
1, 1);
|
||||
zxdg_positioner_v6_set_anchor (positioner,
|
||||
(ZXDG_POSITIONER_V6_ANCHOR_TOP |
|
||||
ZXDG_POSITIONER_V6_ANCHOR_LEFT));
|
||||
zxdg_positioner_v6_set_gravity (positioner,
|
||||
(ZXDG_POSITIONER_V6_GRAVITY_BOTTOM |
|
||||
ZXDG_POSITIONER_V6_GRAVITY_RIGHT));
|
||||
|
||||
impl->display_server.xdg_popup =
|
||||
zxdg_surface_v6_get_popup (impl->display_server.xdg_surface,
|
||||
parent_impl->display_server.xdg_surface,
|
||||
positioner);
|
||||
zxdg_popup_v6_add_listener (impl->display_server.xdg_popup,
|
||||
&xdg_popup_listener,
|
||||
window);
|
||||
|
||||
zxdg_positioner_v6_destroy (positioner);
|
||||
|
||||
gdk_seat = gdk_display_get_default_seat (GDK_DISPLAY (display));
|
||||
|
||||
x = window->x - parent->x;
|
||||
y = window->y - parent->y;
|
||||
|
||||
serial = _gdk_wayland_seat_get_last_implicit_grab_serial (gdk_seat, NULL);
|
||||
zxdg_popup_v6_grab (impl->display_server.xdg_popup, seat, serial);
|
||||
|
||||
impl->display_server.xdg_popup = xdg_shell_get_xdg_popup (display->xdg_shell,
|
||||
impl->display_server.wl_surface,
|
||||
parent_impl->display_server.wl_surface,
|
||||
seat, serial,
|
||||
x, y);
|
||||
|
||||
xdg_popup_add_listener (impl->display_server.xdg_popup, &xdg_popup_listener, window);
|
||||
wl_surface_commit (impl->display_server.wl_surface);
|
||||
}
|
||||
|
||||
static struct wl_seat *
|
||||
@ -1595,7 +1698,7 @@ should_map_as_subsurface (GdkWindow *window)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Get the window that can be used as a parent for a popup, i.e. a xdg_surface
|
||||
/* Get the window that can be used as a parent for a popup, i.e. a xdg_toplevel
|
||||
* or xdg_popup. If the window is not, traverse up the transiency parents until
|
||||
* we find one.
|
||||
*/
|
||||
@ -1606,7 +1709,7 @@ get_popup_parent (GdkWindow *window)
|
||||
{
|
||||
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
|
||||
|
||||
if (impl->display_server.xdg_popup || impl->display_server.xdg_surface)
|
||||
if (impl->display_server.xdg_popup || impl->display_server.xdg_toplevel)
|
||||
return window;
|
||||
|
||||
window = impl->transient_for;
|
||||
@ -1723,12 +1826,12 @@ gdk_wayland_window_map (GdkWindow *window)
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_wayland_window_create_xdg_surface (window);
|
||||
gdk_wayland_window_create_xdg_toplevel (window);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_wayland_window_create_xdg_surface (window);
|
||||
gdk_wayland_window_create_xdg_toplevel (window);
|
||||
}
|
||||
|
||||
impl->mapped = TRUE;
|
||||
@ -1818,16 +1921,22 @@ gdk_wayland_window_hide_surface (GdkWindow *window)
|
||||
impl->display_server.egl_window = NULL;
|
||||
}
|
||||
|
||||
if (impl->display_server.xdg_surface)
|
||||
if (impl->display_server.xdg_toplevel)
|
||||
{
|
||||
xdg_surface_destroy (impl->display_server.xdg_surface);
|
||||
impl->display_server.xdg_surface = NULL;
|
||||
zxdg_toplevel_v6_destroy (impl->display_server.xdg_toplevel);
|
||||
impl->display_server.xdg_toplevel = NULL;
|
||||
}
|
||||
else if (impl->display_server.xdg_popup)
|
||||
{
|
||||
xdg_popup_destroy (impl->display_server.xdg_popup);
|
||||
zxdg_popup_v6_destroy (impl->display_server.xdg_popup);
|
||||
impl->display_server.xdg_popup = NULL;
|
||||
}
|
||||
if (impl->display_server.xdg_surface)
|
||||
{
|
||||
zxdg_surface_v6_destroy (impl->display_server.xdg_surface);
|
||||
impl->display_server.xdg_surface = NULL;
|
||||
impl->initial_configure_received = FALSE;
|
||||
}
|
||||
|
||||
if (impl->display_server.wl_subsurface)
|
||||
unmap_subsurface (window);
|
||||
@ -2492,10 +2601,10 @@ gdk_wayland_window_iconify (GdkWindow *window)
|
||||
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
|
||||
return;
|
||||
|
||||
if (!impl->display_server.xdg_surface)
|
||||
if (!impl->display_server.xdg_toplevel)
|
||||
return;
|
||||
|
||||
xdg_surface_set_minimized (impl->display_server.xdg_surface);
|
||||
zxdg_toplevel_v6_set_minimized (impl->display_server.xdg_toplevel);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2531,8 +2640,8 @@ gdk_wayland_window_maximize (GdkWindow *window)
|
||||
return;
|
||||
|
||||
_gdk_wayland_window_save_size (window);
|
||||
if (impl->display_server.xdg_surface)
|
||||
xdg_surface_set_maximized (impl->display_server.xdg_surface);
|
||||
if (impl->display_server.xdg_toplevel)
|
||||
zxdg_toplevel_v6_set_maximized (impl->display_server.xdg_toplevel);
|
||||
else
|
||||
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_MAXIMIZED);
|
||||
}
|
||||
@ -2545,8 +2654,8 @@ gdk_wayland_window_unmaximize (GdkWindow *window)
|
||||
if (GDK_WINDOW_DESTROYED (window))
|
||||
return;
|
||||
|
||||
if (impl->display_server.xdg_surface)
|
||||
xdg_surface_unset_maximized (impl->display_server.xdg_surface);
|
||||
if (impl->display_server.xdg_toplevel)
|
||||
zxdg_toplevel_v6_unset_maximized (impl->display_server.xdg_toplevel);
|
||||
else
|
||||
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_MAXIMIZED, 0);
|
||||
}
|
||||
@ -2563,12 +2672,16 @@ gdk_wayland_window_fullscreen_on_monitor (GdkWindow *window, gint monitor)
|
||||
return;
|
||||
|
||||
_gdk_wayland_window_save_size (window);
|
||||
if (impl->display_server.xdg_surface)
|
||||
xdg_surface_set_fullscreen (impl->display_server.xdg_surface, fullscreen_output);
|
||||
else {
|
||||
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
|
||||
impl->initial_fullscreen_monitor = monitor;
|
||||
}
|
||||
if (impl->display_server.xdg_toplevel)
|
||||
{
|
||||
zxdg_toplevel_v6_set_fullscreen (impl->display_server.xdg_toplevel,
|
||||
fullscreen_output);
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
|
||||
impl->initial_fullscreen_monitor = monitor;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2582,8 +2695,8 @@ gdk_wayland_window_fullscreen (GdkWindow *window)
|
||||
impl->initial_fullscreen_monitor = -1;
|
||||
|
||||
_gdk_wayland_window_save_size (window);
|
||||
if (impl->display_server.xdg_surface)
|
||||
xdg_surface_set_fullscreen (impl->display_server.xdg_surface, NULL);
|
||||
if (impl->display_server.xdg_toplevel)
|
||||
zxdg_toplevel_v6_set_fullscreen (impl->display_server.xdg_toplevel, NULL);
|
||||
else
|
||||
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
|
||||
}
|
||||
@ -2598,8 +2711,8 @@ gdk_wayland_window_unfullscreen (GdkWindow *window)
|
||||
|
||||
impl->initial_fullscreen_monitor = -1;
|
||||
|
||||
if (impl->display_server.xdg_surface)
|
||||
xdg_surface_unset_fullscreen (impl->display_server.xdg_surface);
|
||||
if (impl->display_server.xdg_toplevel)
|
||||
zxdg_toplevel_v6_unset_fullscreen (impl->display_server.xdg_toplevel);
|
||||
else
|
||||
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
|
||||
}
|
||||
@ -2665,35 +2778,35 @@ gdk_wayland_window_begin_resize_drag (GdkWindow *window,
|
||||
switch (edge)
|
||||
{
|
||||
case GDK_WINDOW_EDGE_NORTH_WEST:
|
||||
resize_edges = XDG_SURFACE_RESIZE_EDGE_TOP_LEFT;
|
||||
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP_LEFT;
|
||||
break;
|
||||
|
||||
case GDK_WINDOW_EDGE_NORTH:
|
||||
resize_edges = XDG_SURFACE_RESIZE_EDGE_TOP;
|
||||
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP;
|
||||
break;
|
||||
|
||||
case GDK_WINDOW_EDGE_NORTH_EAST:
|
||||
resize_edges = XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT;
|
||||
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP_RIGHT;
|
||||
break;
|
||||
|
||||
case GDK_WINDOW_EDGE_WEST:
|
||||
resize_edges = XDG_SURFACE_RESIZE_EDGE_LEFT;
|
||||
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_LEFT;
|
||||
break;
|
||||
|
||||
case GDK_WINDOW_EDGE_EAST:
|
||||
resize_edges = XDG_SURFACE_RESIZE_EDGE_RIGHT;
|
||||
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_RIGHT;
|
||||
break;
|
||||
|
||||
case GDK_WINDOW_EDGE_SOUTH_WEST:
|
||||
resize_edges = XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT;
|
||||
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM_LEFT;
|
||||
break;
|
||||
|
||||
case GDK_WINDOW_EDGE_SOUTH:
|
||||
resize_edges = XDG_SURFACE_RESIZE_EDGE_BOTTOM;
|
||||
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM;
|
||||
break;
|
||||
|
||||
case GDK_WINDOW_EDGE_SOUTH_EAST:
|
||||
resize_edges = XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT;
|
||||
resize_edges = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM_RIGHT;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -2709,9 +2822,9 @@ gdk_wayland_window_begin_resize_drag (GdkWindow *window,
|
||||
serial = _gdk_wayland_seat_get_last_implicit_grab_serial (gdk_device_get_seat (device),
|
||||
&sequence);
|
||||
|
||||
xdg_surface_resize (impl->display_server.xdg_surface,
|
||||
gdk_wayland_device_get_wl_seat (device),
|
||||
serial, resize_edges);
|
||||
zxdg_toplevel_v6_resize (impl->display_server.xdg_toplevel,
|
||||
gdk_wayland_device_get_wl_seat (device),
|
||||
serial, resize_edges);
|
||||
|
||||
if (sequence)
|
||||
gdk_wayland_device_unset_touch_grab (device, sequence);
|
||||
@ -2745,9 +2858,9 @@ gdk_wayland_window_begin_move_drag (GdkWindow *window,
|
||||
|
||||
serial = _gdk_wayland_seat_get_last_implicit_grab_serial (gdk_device_get_seat (device),
|
||||
&sequence);
|
||||
xdg_surface_move (impl->display_server.xdg_surface,
|
||||
gdk_wayland_device_get_wl_seat (device),
|
||||
serial);
|
||||
zxdg_toplevel_v6_move (impl->display_server.xdg_toplevel,
|
||||
gdk_wayland_device_get_wl_seat (device),
|
||||
serial);
|
||||
if (sequence)
|
||||
gdk_wayland_device_unset_touch_grab (device, sequence);
|
||||
|
||||
@ -2903,6 +3016,7 @@ gdk_wayland_window_show_window_menu (GdkWindow *window,
|
||||
struct wl_seat *seat;
|
||||
GdkWaylandDevice *device;
|
||||
double x, y;
|
||||
uint32_t serial;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
@ -2922,10 +3036,9 @@ gdk_wayland_window_show_window_menu (GdkWindow *window,
|
||||
seat = gdk_wayland_device_get_wl_seat (GDK_DEVICE (device));
|
||||
gdk_event_get_coords (event, &x, &y);
|
||||
|
||||
xdg_surface_show_window_menu (impl->display_server.xdg_surface,
|
||||
seat,
|
||||
_gdk_wayland_device_get_implicit_grab_serial (device, event),
|
||||
x, y);
|
||||
serial = _gdk_wayland_device_get_implicit_grab_serial (device, event);
|
||||
zxdg_toplevel_v6_show_window_menu (impl->display_server.xdg_toplevel,
|
||||
seat, serial, x, y);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user