diff options
author | Ian Douglas Scott <idscott@system76.com> | 2021-09-03 15:16:59 -0700 |
---|---|---|
committer | Ian Douglas Scott <idscott@system76.com> | 2021-11-08 14:46:34 -0800 |
commit | fcdc5538cf0bee131395b2b61d5a7e0d32d0ee14 (patch) | |
tree | 52f595f8cc919fc8b901409c048ff206801c646c | |
parent | dd327bc8a69cc38a887d9956daf13078ac87d424 (diff) | |
download | gtk+-fcdc5538cf0bee131395b2b61d5a7e0d32d0ee14.tar.gz |
gdk/wayland/surface: Move `*idle_inhibitor*` to `GdkWaylandToplevel`
-rw-r--r-- | gdk/wayland/gdksurface-wayland.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index 565692ebb3..ca7ff459eb 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -224,9 +224,6 @@ struct _GdkWaylandSurface struct zxdg_imported_v1 *imported_transient_for; GHashTable *shortcuts_inhibitors; - - struct zwp_idle_inhibitor_v1 *idle_inhibitor; - size_t idle_inhibitor_refcount; }; typedef struct _GdkWaylandSurfaceClass GdkWaylandSurfaceClass; @@ -251,6 +248,9 @@ struct _GdkWaylandToplevel gpointer user_data; GDestroyNotify destroy_func; } exported; + + struct zwp_idle_inhibitor_v1 *idle_inhibitor; + size_t idle_inhibitor_refcount; }; typedef struct @@ -2274,21 +2274,24 @@ gboolean gdk_wayland_toplevel_inhibit_idle (GdkToplevel *toplevel) { GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SURFACE (toplevel))); - GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (toplevel); + GdkWaylandToplevel *wayland_toplevel; g_return_val_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel), FALSE); + wayland_toplevel = GDK_WAYLAND_TOPLEVEL (toplevel); if (!display_wayland->idle_inhibit_manager) return FALSE; - if (!impl->idle_inhibitor) + if (!wayland_toplevel->idle_inhibitor) { - g_assert (impl->idle_inhibitor_refcount == 0); - impl->idle_inhibitor = - zwp_idle_inhibit_manager_v1_create_inhibitor (display_wayland->idle_inhibit_manager, - impl->display_server.wl_surface); + g_assert (wayland_toplevel->idle_inhibitor && + wayland_toplevel->idle_inhibitor_refcount > 0); + + wayland_toplevel->idle_inhibitor = + zwp_idle_inhibit_manager_v1_create_inhibitor (display_wayland->idle_inhibit_manager, + gdk_wayland_surface_get_wl_surface (GDK_SURFACE (wayland_toplevel))); } - ++impl->idle_inhibitor_refcount; + ++wayland_toplevel->idle_inhibitor_refcount; return TRUE; } @@ -2296,14 +2299,19 @@ gdk_wayland_toplevel_inhibit_idle (GdkToplevel *toplevel) void gdk_wayland_toplevel_uninhibit_idle (GdkToplevel *toplevel) { - GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (toplevel); + GdkWaylandToplevel *wayland_toplevel; g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel)); + wayland_toplevel = GDK_WAYLAND_TOPLEVEL (toplevel); - g_assert (impl->idle_inhibitor && impl->idle_inhibitor_refcount > 0); + g_assert (wayland_toplevel->idle_inhibitor && + wayland_toplevel->idle_inhibitor_refcount > 0); - if (--impl->idle_inhibitor_refcount == 0) - g_clear_pointer (&impl->idle_inhibitor, zwp_idle_inhibitor_v1_destroy); + if (--wayland_toplevel->idle_inhibitor_refcount == 0) + { + g_clear_pointer (&wayland_toplevel->idle_inhibitor, + zwp_idle_inhibitor_v1_destroy); + } } static void |