[gnome-initial-setup/wip/idle-handlers-are-the-devils-workshop] gis-driver: Don't defer window state changes to idle handlers




commit 72a4b47b078b9faa9bf5bc4c80de6d15f02891f4
Author: Ray Strode <rstrode redhat com>
Date:   Fri Sep 11 14:46:04 2020 -0400

    gis-driver: Don't defer window state changes to idle handlers
    
    gnome-initial-setup tries to conserve space on small screens by
    maximizing the window. When it decides to maximize the window,
    it does this unnecessarly from an idle handler.
    
    Unfortunately, a bug somewhere else in the stack gets exposed by
    using this idle handler.  Sometimes, the maximization request
    doesn't make it through.
    
    This commit cleans up the unnecessary idle handler, and at the same
    time side steps the other bug.
    
    https://gitlab.gnome.org/GNOME/gnome-initial-setup/-/issues/110

 gnome-initial-setup/gis-driver.c | 28 ++++------------------------
 1 file changed, 4 insertions(+), 24 deletions(-)
---
diff --git a/gnome-initial-setup/gis-driver.c b/gnome-initial-setup/gis-driver.c
index 2332aee0..4ecf313d 100644
--- a/gnome-initial-setup/gis-driver.c
+++ b/gnome-initial-setup/gis-driver.c
@@ -723,28 +723,6 @@ gis_driver_activate (GApplication *app)
   gtk_window_present (GTK_WINDOW (priv->main_window));
 }
 
-static gboolean
-maximize (gpointer data)
-{
-  GtkWindow *window = data;
-
-  gtk_window_maximize (window);
-  gtk_window_present (window);
-
-  return G_SOURCE_REMOVE;
-}
-
-static gboolean
-unmaximize (gpointer data)
-{
-  GtkWindow *window = data;
-
-  gtk_window_unmaximize (window);
-  gtk_window_present (window);
-
-  return G_SOURCE_REMOVE;
-}
-
 static void
 set_small_screen_based_on_primary_monitor (GisDriver *driver)
 {
@@ -819,7 +797,8 @@ update_screen_size (GisDriver *driver)
       gtk_window_set_resizable (priv->main_window, TRUE);
       gtk_window_set_position (priv->main_window, GTK_WIN_POS_NONE);
 
-      g_idle_add (maximize, priv->main_window);
+      gtk_window_maximize (priv->main_window);
+      gtk_window_present (priv->main_window);
     }
   else
     {
@@ -843,7 +822,8 @@ update_screen_size (GisDriver *driver)
       gtk_window_set_resizable (priv->main_window, FALSE);
       gtk_window_set_position (priv->main_window, GTK_WIN_POS_CENTER_ALWAYS);
 
-      g_idle_add (unmaximize, priv->main_window);
+      gtk_window_unmaximize (priv->main_window);
+      gtk_window_present (priv->main_window);
     }
 }
 


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