[gnome-mahjongg/arnaudb/wip/gtk4: 13/24] Adapt to size_allocate.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-mahjongg/arnaudb/wip/gtk4: 13/24] Adapt to size_allocate.
- Date: Fri, 25 Sep 2020 14:20:32 +0000 (UTC)
commit 92dac1d91b20d37e744ab7d622343843b9eb09e4
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Mar 27 19:45:05 2020 +0100
Adapt to size_allocate.
src/gnome-mahjongg.vala | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/src/gnome-mahjongg.vala b/src/gnome-mahjongg.vala
index 7c1d766..e5d37e9 100644
--- a/src/gnome-mahjongg.vala
+++ b/src/gnome-mahjongg.vala
@@ -80,7 +80,6 @@ public class Mahjongg : Gtk.Application
history.load ();
window = new Gtk.ApplicationWindow (this);
- 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"))
@@ -186,13 +185,6 @@ public class Mahjongg : Gtk.Application
tick_cb ();
}
- private void size_allocate_cb (Gtk.Allocation allocation)
- {
- if (is_maximized || is_tiled)
- return;
- window.get_size (out window_width, out window_height);
- }
-
private void init_state_watcher ()
{
Gdk.Surface? nullable_surface = window.get_surface (); // TODO report bug, get_surface()
returns a nullable Surface
@@ -200,6 +192,15 @@ public class Mahjongg : 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 (is_maximized || 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]