1
0
Fork 0

wayland/xdg-shell: Set the suspended state to suspended windows

This will allow clients to e.g. enter power saving mode when they are
e.g. on another workspace, minimized or fully obstructed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3019>
This commit is contained in:
Jonas Ådahl 2023-05-24 14:40:55 +02:00 committed by Marge Bot
parent 3af02e1b57
commit 5071a6df87
6 changed files with 33 additions and 5 deletions

View file

@ -47,7 +47,7 @@ gudev_req = '>= 232'
# wayland version requirements # wayland version requirements
wayland_server_req = '>= 1.21' wayland_server_req = '>= 1.21'
wayland_protocols_req = '>= 1.31' wayland_protocols_req = '>= 1.32'
# native backend version requirements # native backend version requirements
libinput_req = '>= 1.19.0' libinput_req = '>= 1.19.0'

View file

@ -36,7 +36,7 @@
/* Global/master objects (version exported by wl_registry and negotiated through bind) */ /* Global/master objects (version exported by wl_registry and negotiated through bind) */
#define META_WL_COMPOSITOR_VERSION 5 #define META_WL_COMPOSITOR_VERSION 5
#define META_WL_DATA_DEVICE_MANAGER_VERSION 3 #define META_WL_DATA_DEVICE_MANAGER_VERSION 3
#define META_XDG_WM_BASE_VERSION 5 #define META_XDG_WM_BASE_VERSION 6
#define META_WL_SEAT_VERSION 8 #define META_WL_SEAT_VERSION 8
#define META_WL_OUTPUT_VERSION 4 #define META_WL_OUTPUT_VERSION 4
#define META_XSERVER_VERSION 1 #define META_XSERVER_VERSION 1

View file

@ -49,6 +49,7 @@ meta_wayland_window_configuration_new (MetaWindow *window,
.flags = flags, .flags = flags,
.is_fullscreen = meta_window_is_fullscreen (window), .is_fullscreen = meta_window_is_fullscreen (window),
.is_suspended = meta_window_is_suspended (window),
}; };
if (flags & META_MOVE_RESIZE_MOVE_ACTION || if (flags & META_MOVE_RESIZE_MOVE_ACTION ||

View file

@ -51,6 +51,7 @@ struct _MetaWaylandWindowConfiguration
int bounds_height; int bounds_height;
gboolean is_fullscreen; gboolean is_fullscreen;
gboolean is_suspended;
}; };
MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new (MetaWindow *window, MetaWaylandWindowConfiguration * meta_wayland_window_configuration_new (MetaWindow *window,

View file

@ -695,8 +695,9 @@ add_state_value (struct wl_array *states,
} }
static void static void
fill_states (MetaWaylandXdgToplevel *xdg_toplevel, fill_states (MetaWaylandXdgToplevel *xdg_toplevel,
struct wl_array *states) MetaWaylandWindowConfiguration *configuration,
struct wl_array *states)
{ {
MetaWaylandSurfaceRole *surface_role = MetaWaylandSurfaceRole *surface_role =
META_WAYLAND_SURFACE_ROLE (xdg_toplevel); META_WAYLAND_SURFACE_ROLE (xdg_toplevel);
@ -717,6 +718,10 @@ fill_states (MetaWaylandXdgToplevel *xdg_toplevel,
add_state_value (states, XDG_TOPLEVEL_STATE_RESIZING); add_state_value (states, XDG_TOPLEVEL_STATE_RESIZING);
if (meta_window_appears_focused (window)) if (meta_window_appears_focused (window))
add_state_value (states, XDG_TOPLEVEL_STATE_ACTIVATED); add_state_value (states, XDG_TOPLEVEL_STATE_ACTIVATED);
if (configuration->is_suspended &&
wl_resource_get_version (xdg_toplevel->resource) >=
XDG_TOPLEVEL_STATE_SUSPENDED_SINCE_VERSION)
add_state_value (states, XDG_TOPLEVEL_STATE_SUSPENDED);
if (wl_resource_get_version (xdg_toplevel->resource) >= if (wl_resource_get_version (xdg_toplevel->resource) >=
XDG_TOPLEVEL_STATE_TILED_LEFT_SINCE_VERSION) XDG_TOPLEVEL_STATE_TILED_LEFT_SINCE_VERSION)
@ -749,7 +754,7 @@ meta_wayland_xdg_toplevel_send_configure (MetaWaylandXdgToplevel *xdg_to
struct wl_array states; struct wl_array states;
wl_array_init (&states); wl_array_init (&states);
fill_states (xdg_toplevel, &states); fill_states (xdg_toplevel, configuration, &states);
if (wl_resource_get_version (xdg_toplevel->resource) >= if (wl_resource_get_version (xdg_toplevel->resource) >=
XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION && XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION &&

View file

@ -77,6 +77,8 @@ struct _MetaWindowWayland
MetaWaylandWindowConfiguration *last_acked_configuration; MetaWaylandWindowConfiguration *last_acked_configuration;
gboolean has_been_shown; gboolean has_been_shown;
gboolean is_suspended;
}; };
struct _MetaWindowWaylandClass struct _MetaWindowWaylandClass
@ -692,6 +694,23 @@ appears_focused_changed (GObject *object,
surface_state_changed (window); surface_state_changed (window);
} }
static void
suspend_state_changed (GObject *object,
GParamSpec *pspec,
gpointer user_data)
{
MetaWindow *window = META_WINDOW (object);
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
gboolean is_suspended;
is_suspended = meta_window_is_suspended (window);
if (wl_window->is_suspended == is_suspended)
return;
wl_window->is_suspended = is_suspended;
surface_state_changed (window);
}
static void static void
on_window_shown (MetaWindow *window) on_window_shown (MetaWindow *window)
{ {
@ -714,6 +733,8 @@ meta_window_wayland_init (MetaWindowWayland *wl_window)
g_signal_connect (window, "notify::appears-focused", g_signal_connect (window, "notify::appears-focused",
G_CALLBACK (appears_focused_changed), NULL); G_CALLBACK (appears_focused_changed), NULL);
g_signal_connect (window, "notify::suspend-state",
G_CALLBACK (suspend_state_changed), NULL);
g_signal_connect (window, "shown", g_signal_connect (window, "shown",
G_CALLBACK (on_window_shown), NULL); G_CALLBACK (on_window_shown), NULL);
} }