[gnome-mines/arnaudb/wip/gtk4: 37/40] Adapt size-allocate stuff.




commit 4d9ce61fa98bb60be0aaa5bc0e2e28405b31723d
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Tue Sep 8 16:32:02 2020 +0200

    Adapt size-allocate stuff.

 src/gnome-mines.vala | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/src/gnome-mines.vala b/src/gnome-mines.vala
index ff17259..8b9405e 100644
--- a/src/gnome-mines.vala
+++ b/src/gnome-mines.vala
@@ -203,7 +203,6 @@ public class Mines : Gtk.Application
         add_action (settings.create_action (KEY_USE_QUESTION_MARKS));
 
         window = (ApplicationWindow) ui_builder.get_object ("main_window");
-        window.size_allocate.connect (size_allocate_cb);
         window.map.connect (init_state_watcher);
         window.notify["is-active"].connect (on_window_focus_change);
         window.set_default_size (settings.get_int ("window-width"), settings.get_int ("window-height"));
@@ -405,16 +404,6 @@ public class Mines : Gtk.Application
         button.clicked.connect (custom_size_clicked_cb);
     }
 
-    private void size_allocate_cb (int width, int height, int baseline)
-    {
-        if (!window_is_maximized && !window_is_fullscreen && !window_is_tiled && !window_skip_configure)
-        {
-            window.get_size (out window_width, out window_height);
-        }
-
-        window_skip_configure = false;
-    }
-
     private inline void init_state_watcher ()
     {
         Gdk.Surface? nullable_surface = window.get_surface ();
@@ -422,6 +411,18 @@ public class Mines : Gtk.Application
             assert_not_reached ();
         surface = (Gdk.Toplevel) (!) nullable_surface;
         surface.notify ["state"].connect (on_window_state_event);
+        surface.size_changed.connect (on_size_changed);
+    }
+
+    private inline void on_size_changed (Gdk.Surface _surface, int width, int height)
+    {
+        if (!window_is_maximized && !window_is_fullscreen && !window_is_tiled && !window_skip_configure)
+        {
+            window_width  = width;
+            window_height = height;
+        }
+
+        window_skip_configure = false;
     }
 
     private Gdk.Toplevel surface;


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