[gnome-chess/arnaudb/wip/gtk4: 30/51] Adapt size-allocate stuff.




commit c03d26f510404e2e65516ebc96b5a0bd71028f48
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu Aug 13 16:10:54 2020 +0200

    Adapt size-allocate stuff.

 src/gnome-chess.vala | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index cdff9a7..13e09e1 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -159,7 +159,6 @@ Copyright © 2015–2016 Sahil Sareen""";
         window.set_default_size (settings.get_int ("width"), settings.get_int ("height"));
         if (settings.get_boolean ("maximized"))
             window.maximize ();
-        window.size_allocate.connect (size_allocate_cb);
         window.map.connect (init_state_watcher);
 
         info_bar = (InfoBar) builder.get_object ("info_bar");
@@ -279,11 +278,22 @@ Copyright © 2015–2016 Sahil Sareen""";
         navigation_box.set_orientation ((layout_mode == LayoutMode.NORMAL) ? Orientation.HORIZONTAL : 
Orientation.VERTICAL);
     }
 
-    private void size_allocate_cb (Allocation allocation)
+    private inline void init_state_watcher ()
+    {
+        Gdk.Surface? nullable_surface = window.get_surface ();     // TODO report bug, get_surface() returns 
a nullable Surface
+        if (nullable_surface == null || !((!) nullable_surface is Gdk.Toplevel))
+            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_tiled || window_is_fullscreen)
             return;
-        window.get_size (out window_width, out window_height);
+        window_width  = width;
+        window_height = height;
 
         if (window_width <= 500 && layout_mode == LayoutMode.NORMAL)
             set_layout_mode (LayoutMode.NARROW);
@@ -291,15 +301,6 @@ Copyright © 2015–2016 Sahil Sareen""";
             set_layout_mode (LayoutMode.NORMAL);
     }
 
-    private inline void init_state_watcher ()
-    {
-        Gdk.Surface? nullable_surface = window.get_surface ();     // TODO report bug, get_surface() returns 
a nullable Surface
-        if (nullable_surface == null || !((!) nullable_surface is Gdk.Toplevel))
-            assert_not_reached ();
-        surface = (Gdk.Toplevel) (!) nullable_surface;
-        surface.notify ["state"].connect (on_window_state_event);
-    }
-
     private Gdk.Toplevel surface;
     private const Gdk.ToplevelState tiled_state = Gdk.ToplevelState.TILED
                                                 | Gdk.ToplevelState.TOP_TILED


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