From ac16e375c733970095fc3df08e86b8092bdcd036 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 16 Aug 2024 01:26:56 +0200 Subject: [PATCH] wayland: Implement GdkToplevel::decorated ... and use that instead of custom announce_csd/announce_ssd APIs. --- gdk/wayland/gdktoplevel-wayland-private.h | 3 - gdk/wayland/gdktoplevel-wayland.c | 67 ++++++++++------------- gtk/gtkwindow.c | 11 ---- 3 files changed, 29 insertions(+), 52 deletions(-) diff --git a/gdk/wayland/gdktoplevel-wayland-private.h b/gdk/wayland/gdktoplevel-wayland-private.h index bd0836c0a0..acfe56e1f9 100644 --- a/gdk/wayland/gdktoplevel-wayland-private.h +++ b/gdk/wayland/gdktoplevel-wayland-private.h @@ -33,9 +33,6 @@ void gdk_wayland_toplevel_set_dbus_properties (GdkToplevel *toplevel, const char *application_object_path, const char *unique_bus_name); -void gdk_wayland_toplevel_announce_csd (GdkToplevel *toplevel); -void gdk_wayland_toplevel_announce_ssd (GdkToplevel *toplevel); - gboolean gdk_wayland_toplevel_inhibit_idle (GdkToplevel *toplevel); void gdk_wayland_toplevel_uninhibit_idle (GdkToplevel *toplevel); diff --git a/gdk/wayland/gdktoplevel-wayland.c b/gdk/wayland/gdktoplevel-wayland.c index a8d15bc208..c5489b4c1a 100644 --- a/gdk/wayland/gdktoplevel-wayland.c +++ b/gdk/wayland/gdktoplevel-wayland.c @@ -141,6 +141,7 @@ struct _GdkWaylandToplevel gboolean has_bounds; char *title; + gboolean decorated; GdkGeometry geometry_hints; GdkSurfaceHints geometry_mask; @@ -1256,6 +1257,32 @@ gdk_wayland_toplevel_set_transient_for (GdkWaylandToplevel *toplevel, #define LAST_PROP 1 +static void +gdk_wayland_toplevel_set_decorated (GdkWaylandToplevel *self, + gboolean decorated) +{ + GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SURFACE (self))); + + if (self->decorated == decorated) + return; + + self->decorated = decorated; + + if (display_wayland->server_decoration_manager) + { + if (self->server_decoration == NULL) + self->server_decoration = + org_kde_kwin_server_decoration_manager_create (display_wayland->server_decoration_manager, + gdk_wayland_surface_get_wl_surface (GDK_SURFACE (self))); + + org_kde_kwin_server_decoration_request_mode (self->server_decoration, + decorated ? ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER + : ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT); + } + + g_object_notify (G_OBJECT (self), "decorated"); +} + static void gdk_wayland_toplevel_set_property (GObject *object, guint prop_id, @@ -1291,6 +1318,7 @@ gdk_wayland_toplevel_set_property (GObject *object, break; case LAST_PROP + GDK_TOPLEVEL_PROP_DECORATED: + gdk_wayland_toplevel_set_decorated (toplevel, g_value_get_boolean (value)); break; case LAST_PROP + GDK_TOPLEVEL_PROP_DELETABLE: @@ -1346,6 +1374,7 @@ gdk_wayland_toplevel_get_property (GObject *object, break; case LAST_PROP + GDK_TOPLEVEL_PROP_DECORATED: + g_value_set_boolean (value, toplevel->decorated); break; case LAST_PROP + GDK_TOPLEVEL_PROP_DELETABLE: @@ -2451,44 +2480,6 @@ gdk_wayland_toplevel_set_application_id (GdkToplevel *toplevel, } } -void -gdk_wayland_toplevel_announce_csd (GdkToplevel *toplevel) -{ - GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SURFACE (toplevel))); - GdkWaylandToplevel *toplevel_wayland; - - g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel)); - toplevel_wayland = GDK_WAYLAND_TOPLEVEL (toplevel); - - if (!display_wayland->server_decoration_manager) - return; - toplevel_wayland->server_decoration = - org_kde_kwin_server_decoration_manager_create (display_wayland->server_decoration_manager, - gdk_wayland_surface_get_wl_surface (GDK_SURFACE (toplevel_wayland))); - if (toplevel_wayland->server_decoration) - org_kde_kwin_server_decoration_request_mode (toplevel_wayland->server_decoration, - ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT); -} - -void -gdk_wayland_toplevel_announce_ssd (GdkToplevel *toplevel) -{ - GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SURFACE (toplevel))); - GdkWaylandToplevel *toplevel_wayland; - - g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel)); - toplevel_wayland = GDK_WAYLAND_TOPLEVEL (toplevel); - - if (!display_wayland->server_decoration_manager) - return; - toplevel_wayland->server_decoration = - org_kde_kwin_server_decoration_manager_create (display_wayland->server_decoration_manager, - gdk_wayland_surface_get_wl_surface (GDK_SURFACE (toplevel_wayland))); - if (toplevel_wayland->server_decoration) - org_kde_kwin_server_decoration_request_mode (toplevel_wayland->server_decoration, - ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER); -} - gboolean gdk_wayland_toplevel_inhibit_idle (GdkToplevel *toplevel) { diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 7602d7228a..e9f594bc7f 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -4340,17 +4340,6 @@ gtk_window_realize (GtkWidget *widget) gdk_toplevel_set_decorated (GDK_TOPLEVEL (surface), priv->decorated && !priv->client_decorated); gdk_toplevel_set_deletable (GDK_TOPLEVEL (surface), priv->deletable); - -#ifdef GDK_WINDOWING_WAYLAND - if (GDK_IS_WAYLAND_SURFACE (surface)) - { - if (priv->client_decorated) - gdk_wayland_toplevel_announce_csd (GDK_TOPLEVEL (surface)); - else - gdk_wayland_toplevel_announce_ssd (GDK_TOPLEVEL (surface)); - } -#endif - gdk_toplevel_set_modal (GDK_TOPLEVEL (surface), priv->modal); if (priv->startup_id)