[gimp/wip/nielsdg/hide-csd-on-fullscreen] app: Hide CSD when going fullscreen




commit c328da6bd3ed14268ac55d75713aa0a4125ce83f
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Fri Jan 1 11:15:25 2021 +0100

    app: Hide CSD when going fullscreen
    
    By default, GTK keeps on showing client-side decorations when going
    fullscreen, as it might contain buttons or other functionality that
    would be lost. As such, we have to make sure we hide the titlebar.
    
    Getting to that titlebar to update its "visible" property needs a bit of
    effort, since it's an internal child of the GtkWindow that isn't exposed
    in any way, so we take a little detour using `gtk_container_forall()`.

 app/display/gimpimagewindow.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index db32149bc0..8f0b3fc429 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -690,6 +690,16 @@ gimp_image_window_configure_event (GtkWidget         *widget,
   return TRUE;
 }
 
+static void
+gimp_image_window_update_csd_on_fullscreen (GtkWidget *child,
+                                            gpointer   user_data)
+{
+  gboolean fullscreen = GPOINTER_TO_INT (user_data);
+
+  if (GTK_IS_HEADER_BAR (child))
+    gtk_widget_set_visible (child, !fullscreen);
+}
+
 static gboolean
 gimp_image_window_window_state_event (GtkWidget           *widget,
                                       GdkEventWindowState *event)
@@ -715,6 +725,13 @@ gimp_image_window_window_state_event (GtkWidget           *widget,
       gimp_image_window_suspend_keep_pos (window);
       gimp_display_shell_appearance_update (shell);
       gimp_image_window_resume_keep_pos (window);
+
+      /* When using CSD (for example in Wayland), our title bar stays visible
+       * when going fullscreen by default. There is no getter for it and it's
+       * an internal child, so we use this workaround instead */
+      gtk_container_forall (GTK_CONTAINER (window),
+                            gimp_image_window_update_csd_on_fullscreen,
+                            GINT_TO_POINTER (fullscreen));
     }
 
   if (event->changed_mask & GDK_WINDOW_STATE_ICONIFIED)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]