[five-or-more/arnaudb/wip/gtk4: 59/80] 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: 59/80] Make on_window_state_event work.
- Date: Sun, 25 Oct 2020 18:51:47 +0000 (UTC)
commit 3ed1794b25beeb8e9bffd283880590f97010b0ab
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 | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/src/window.vala b/src/window.vala
index 9f6e048..276d1e1 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -74,6 +74,8 @@ private class GameWindow : ApplicationWindow
{
add_action_entries (win_actions, this);
+ map.connect (init_state_watcher);
+
SimpleAction theme_action = (SimpleAction) lookup_action ("change-theme");
string theme_value = settings.get_string (FiveOrMoreApp.KEY_THEME);
if (theme_value != "balls.svg" && theme_value != "shapes.svg" && theme_value != "tango.svg") /* TODO
use an enum in GSchema file? */
@@ -125,15 +127,27 @@ private class GameWindow : ApplicationWindow
init_scores_dialog ();
}
- 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.ToplevelState tiled_state = Gdk.ToplevelState.TILED
+ | Gdk.ToplevelState.TOP_TILED
+ | Gdk.ToplevelState.BOTTOM_TILED
+ | Gdk.ToplevelState.LEFT_TILED
+ | Gdk.ToplevelState.RIGHT_TILED;
+ private inline void on_window_state_event ()
+ {
+ Gdk.ToplevelState state = surface.get_state ();
- return false;
+ window_maximized = (state & Gdk.ToplevelState.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]