[gnome-chess/gnome-3-36] Fix layout changing when menu button is pushed.



commit 44b10952329c5e4bf5138f28beadedd70f56066a
Author: Brian Daniels <brianddaniels gmail com>
Date:   Sat May 30 14:05:41 2020 -0400

    Fix layout changing when menu button is pushed.
    
    Use the size_allocate event instead of the configure event to update the
    layout on window size change. The configure event receives an event when
    the menu button is pushed, which provides the size of the Popover menu,
    not the ApplicationWindow. The size_allocate event does not receive this
    event.

 src/gnome-chess.vala | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
---
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index edc65e9..bb49341 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -158,7 +158,6 @@ Copyright © 2015–2016 Sahil Sareen""";
             window.maximize ();
         window.size_allocate.connect (size_allocate_cb);
         window.window_state_event.connect (window_state_event_cb);
-        window.configure_event.connect (configure_event_cb);
 
         info_bar = (Gtk.InfoBar) builder.get_object ("info_bar");
         pause_resume_button = (Gtk.Button) builder.get_object ("pause_button");
@@ -287,6 +286,10 @@ Copyright © 2015–2016 Sahil Sareen""";
         if (is_maximized || is_tiled)
             return;
         window.get_size (out window_width, out window_height);
+        if (window_width <= 500 && layout_mode == LayoutMode.NORMAL)
+            set_layout_mode (LayoutMode.NARROW);
+        else if (window_width > 500 && layout_mode == LayoutMode.NARROW)
+            set_layout_mode (LayoutMode.NORMAL);
     }
 
     private bool window_state_event_cb (Gdk.EventWindowState event)
@@ -299,15 +302,6 @@ Copyright © 2015–2016 Sahil Sareen""";
         return false;
     }
 
-    private bool configure_event_cb (Gdk.EventConfigure event)
-    {
-        if (event.width <= 500 && layout_mode == LayoutMode.NORMAL)
-            set_layout_mode(LayoutMode.NARROW);
-        else if (event.width > 500 && layout_mode == LayoutMode.NARROW)
-            set_layout_mode(LayoutMode.NORMAL);
-        return Gdk.EVENT_PROPAGATE;
-    }
-
     public PieceType? show_promotion_type_selector ()
     {
         Gtk.Builder promotion_type_selector_builder = new Gtk.Builder.from_resource 
("/org/gnome/Chess/ui/promotion-type-selector.ui");


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