[gnome-sudoku/arnaudb/wip/gtk4: 28/47] Adapt size_allocate() method.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sudoku/arnaudb/wip/gtk4: 28/47] Adapt size_allocate() method.
- Date: Wed, 23 Sep 2020 16:36:38 +0000 (UTC)
commit 80381600497bafc43d0137e479ca8ebc763d2c7a
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 89d5230..0cb5a94 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -155,7 +155,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"))
@@ -234,13 +233,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
@@ -248,6 +240,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]