[gnome-sudoku/arnaudb/wip/gtk4: 24/43] Adapt size_allocate() method.




commit ba3dad9317487665d0cff7d84460294551c12c9e
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sun Apr 12 15:50:07 2020 +0200

    Adapt size_allocate() method.

 src/gnome-sudoku.vala | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index d820d23..7e1e087 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -152,7 +152,6 @@ public class Sudoku : Gtk.Application
         var builder = new Builder.from_resource ("/org/gnome/Sudoku/ui/gnome-sudoku.ui");
 
         window = (ApplicationWindow) builder.get_object ("sudoku_app");
-        window.size_allocate.connect (size_allocate_cb);
         window.map.connect (init_state_watcher);
         window.set_default_size (settings.get_int ("window-width"), settings.get_int ("window-height"));
         if (settings.get_boolean ("window-is-maximized"))
@@ -231,13 +230,6 @@ public class Sudoku : Gtk.Application
         base.shutdown ();
     }
 
-    private void size_allocate_cb (Allocation allocation)
-    {
-        if (window_is_maximized || window_is_fullscreen || window_is_tiled)
-            return;
-        window.get_size (out window_width, out window_height);
-    }
-
     private inline void init_state_watcher ()
     {
         Gdk.Surface? nullable_surface = window.get_surface ();     // TODO report bug, get_surface() returns 
a nullable Surface
@@ -245,6 +237,15 @@ public class Sudoku : 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)
+            return;
+        window_width  = width;
+        window_height = height;
     }
 
     private Gdk.Toplevel surface;


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