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.
This commit is contained in:
Brian Daniels 2020-05-30 14:05:41 -04:00
parent 86924c9d23
commit 8504ddef27

View file

@ -160,7 +160,6 @@ Copyright © 20152016 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 = (InfoBar) builder.get_object ("info_bar");
pause_resume_button = (Button) builder.get_object ("pause_button");
@ -284,6 +283,10 @@ Copyright © 20152016 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)
@ -296,15 +299,6 @@ Copyright © 20152016 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 ()
{
Builder promotion_type_selector_builder = new Builder.from_resource ("/org/gnome/Chess/ui/promotion-type-selector.ui");