From 4673eeaf5fe59f2ba4c1af945924347bcaac782e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 24 Oct 2018 14:45:11 +0200 Subject: [PATCH] wayland/xdg-shell: Add toplevel tile state support The second version of xdg_wm_base added toplevel tile states (top, right, bottom, left), so lets communicate that. --- src/wayland/meta-wayland-versions.h | 2 +- src/wayland/meta-wayland-xdg-shell.c | 29 +++++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/wayland/meta-wayland-versions.h b/src/wayland/meta-wayland-versions.h index 63ca9b0d6..9e1139a91 100644 --- a/src/wayland/meta-wayland-versions.h +++ b/src/wayland/meta-wayland-versions.h @@ -37,7 +37,7 @@ /* Global/master objects (version exported by wl_registry and negotiated through bind) */ #define META_WL_COMPOSITOR_VERSION 4 #define META_WL_DATA_DEVICE_MANAGER_VERSION 3 -#define META_XDG_WM_BASE_VERSION 1 +#define META_XDG_WM_BASE_VERSION 2 #define META_ZXDG_SHELL_V6_VERSION 1 #define META_WL_SHELL_VERSION 1 #define META_WL_SEAT_VERSION 5 diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c index 3e5a18e57..9e1d86bd5 100644 --- a/src/wayland/meta-wayland-xdg-shell.c +++ b/src/wayland/meta-wayland-xdg-shell.c @@ -583,9 +583,15 @@ add_state_value (struct wl_array *states, } static void -fill_states (struct wl_array *states, - MetaWindow *window) +fill_states (MetaWaylandXdgToplevel *xdg_toplevel, + struct wl_array *states) { + MetaWaylandSurfaceRole *surface_role = + META_WAYLAND_SURFACE_ROLE (xdg_toplevel); + MetaWaylandSurface *surface = + meta_wayland_surface_role_get_surface (surface_role); + MetaWindow *window = surface->window; + if (META_WINDOW_MAXIMIZED (window)) add_state_value (states, XDG_TOPLEVEL_STATE_MAXIMIZED); if (meta_window_is_fullscreen (window)) @@ -594,6 +600,19 @@ fill_states (struct wl_array *states, add_state_value (states, XDG_TOPLEVEL_STATE_RESIZING); if (meta_window_appears_focused (window)) add_state_value (states, XDG_TOPLEVEL_STATE_ACTIVATED); + + if (wl_resource_get_version (xdg_toplevel->resource) >= + XDG_TOPLEVEL_STATE_TILED_LEFT_SINCE_VERSION) + { + if (window->edge_constraints.top != META_EDGE_CONSTRAINT_NONE) + add_state_value (states, XDG_TOPLEVEL_STATE_TILED_TOP); + if (window->edge_constraints.right != META_EDGE_CONSTRAINT_NONE) + add_state_value (states, XDG_TOPLEVEL_STATE_TILED_RIGHT); + if (window->edge_constraints.bottom != META_EDGE_CONSTRAINT_NONE) + add_state_value (states, XDG_TOPLEVEL_STATE_TILED_BOTTOM); + if (window->edge_constraints.left != META_EDGE_CONSTRAINT_NONE) + add_state_value (states, XDG_TOPLEVEL_STATE_TILED_LEFT); + } } static void @@ -603,15 +622,11 @@ meta_wayland_xdg_toplevel_send_configure (MetaWaylandXdgToplevel *xdg_toplevel, MetaWaylandSerial *sent_serial) { MetaWaylandXdgSurface *xdg_surface = META_WAYLAND_XDG_SURFACE (xdg_toplevel); - MetaWaylandSurfaceRole *surface_role = - META_WAYLAND_SURFACE_ROLE (xdg_toplevel); - MetaWaylandSurface *surface = - meta_wayland_surface_role_get_surface (surface_role); struct wl_array states; uint32_t serial; wl_array_init (&states); - fill_states (&states, surface->window); + fill_states (xdg_toplevel, &states); xdg_toplevel_send_configure (xdg_toplevel->resource, new_width, new_height,