[five-or-more/arnaudb/wip/gtk4: 12/29] 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: 12/29] Make on_window_state_event work.
- Date: Fri, 27 Mar 2020 15:47:38 +0000 (UTC)
commit 1a27c0f17a621820db5536b0b8e0866013a31d09
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 474d928..77a0c47 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);
@@ -95,15 +100,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 & Gdk.SurfaceState.TILED) != 0;
}
protected override void size_allocate (Allocation allocation)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]