[five-or-more/arnaudb/wip/gtk4: 1/19] Make on_window_state_event work.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [five-or-more/arnaudb/wip/gtk4: 1/19] Make on_window_state_event work.
- Date: Sun, 12 Apr 2020 11:08:35 +0000 (UTC)
commit 261cacce7018f0d84793626de1213bf49c0135b5
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Mar 12 23:20:06 2020 +0100
Make on_window_state_event work.
src/window.vala | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/src/window.vala b/src/window.vala
index 1550428..79632f6 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -55,6 +55,11 @@ private class GameWindow : ApplicationWindow
_("Score: %d")
};
+ construct
+ {
+ map.connect (init_state_watcher);
+ }
+
internal GameWindow (Gtk.Application app, GLib.Settings settings)
{
Object (application: app);
@@ -94,15 +99,27 @@ private class GameWindow : ApplicationWindow
game.game_over.connect (score_cb);
}
- protected override bool window_state_event (Gdk.EventWindowState event)
+ private void init_state_watcher ()
{
- if ((event.changed_mask & Gdk.WindowState.MAXIMIZED) != 0)
- window_maximized = (event.new_window_state & Gdk.WindowState.MAXIMIZED) != 0;
+ Gdk.Surface? nullable_surface = 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);
+ }
- if ((event.changed_mask & Gdk.WindowState.TILED) != 0)
- window_tiled = (event.new_window_state & Gdk.WindowState.TILED) != 0;
+ private Gdk.Toplevel surface;
+ private const Gdk.SurfaceState tiled_state = Gdk.SurfaceState.TILED
+ | Gdk.SurfaceState.TOP_TILED
+ | Gdk.SurfaceState.BOTTOM_TILED
+ | Gdk.SurfaceState.LEFT_TILED
+ | Gdk.SurfaceState.RIGHT_TILED;
+ private void on_window_state_event ()
+ {
+ Gdk.SurfaceState state = surface.get_state ();
- return false;
+ window_maximized = (state & Gdk.SurfaceState.MAXIMIZED) != 0;
+ window_tiled = (state & tiled_state) != 0;
}
protected override void size_allocate (Allocation allocation)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]