[five-or-more/arnaudb/wip/gtk4: 20/37] 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: 20/37] Make on_window_state_event work.
- Date: Tue, 4 Aug 2020 15:17:06 +0000 (UTC)
commit d9b0a9b59d4265400127007c51f00aa626121892
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..95786ed 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.SurfaceState tiled_state = Gdk.SurfaceState.TILED
+ | Gdk.SurfaceState.TOP_TILED
+ | Gdk.SurfaceState.BOTTOM_TILED
+ | Gdk.SurfaceState.LEFT_TILED
+ | Gdk.SurfaceState.RIGHT_TILED;
+ private inline 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]