[gnome-mines/arnaudb/wip/gtk4: 83/85] Adapt size-allocate stuff.




commit fc51a09736d4f02a6ec4bb1cdb9a7a927233ea1e
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 163e3a1..9883866 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]