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




commit 32847bba310eedc0bbcccdd04aa6604214cef7d0
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 | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index db32149bc0..7d31957cab 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -496,6 +496,9 @@ gimp_image_window_constructed (GObject *object)
   g_signal_connect_object (config, "notify::tabs-position",
                            G_CALLBACK (gimp_image_window_config_notify),
                            window, G_CONNECT_SWAPPED);
+  g_signal_connect_object (config, "notify::fullscreened",
+                           G_CALLBACK (gimp_image_window_config_notify),
+                           window, G_CONNECT_SWAPPED);
 
   gimp_image_window_session_update (window,
                                     NULL /*new_display*/,
@@ -690,6 +693,16 @@ gimp_image_window_configure_event (GtkWidget         *widget,
   return TRUE;
 }
 
+static void
+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 +728,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, our title bar stays visible when going fullscreen by
+       * default. There is no getter for it and it's an internal child, so use
+       * this workaround instead */
+      gtk_container_forall (GTK_CONTAINER (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]