[gnome-games/wip/exalm/gtk4: 30/45] application-window: Stop using 'window-state-event' signal
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/gtk4: 30/45] application-window: Stop using 'window-state-event' signal
- Date: Sun, 17 Feb 2019 10:13:26 +0000 (UTC)
commit adbebaac1a9ce2abc6b584783153749650099fa1
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Sun Jul 29 10:41:05 2018 +0500
application-window: Stop using 'window-state-event' signal
Use 'notify::state' of GdkSurface instead.
data/ui/application-window.ui | 1 -
src/ui/application-window.vala | 24 +++++++++++++++---------
2 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/data/ui/application-window.ui b/data/ui/application-window.ui
index 052cdb46..dfdf3feb 100644
--- a/data/ui/application-window.ui
+++ b/data/ui/application-window.ui
@@ -7,7 +7,6 @@
<property name="default-height">600</property>
<property name="show-menubar">False</property>
<signal name="close-request" after="yes" handler="on_close_request"/>
- <signal name="window-state-event" after="yes" handler="on_window_state_event"/>
<signal name="notify::is-active" after="yes" handler="on_active_changed"/>
<child>
<object class="GtkEventControllerKey">
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 455f3945..8d6a0000 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -99,6 +99,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
private ResumeFailedDialog resume_failed_dialog;
private QuitDialog quit_dialog;
+ private Gdk.SurfaceState state;
private long window_size_update_timeout;
private long focus_out_timeout_id;
@@ -163,6 +164,10 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
get_style_context ().add_class ("devel");
set_help_overlay (new ShortcutsWindow ());
+
+ var surface = get_surface ();
+ state = surface.state;
+ surface.notify["state"].connect(on_surface_state_changed);
}
public void run_game (Game game) {
@@ -244,18 +249,21 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
on_display_back ();
}
- [GtkCallback]
- public bool on_window_state_event (Gdk.EventWindowState event) {
- var is_maximized = (bool) (event.new_window_state & Gdk.WindowState.MAXIMIZED);
+ public void on_surface_state_changed () {
+ var surface = get_surface ();
+ var changed_mask = state ^ surface.state;
+ state = surface.state;
+
+ var is_maximized = (bool) (state & Gdk.SurfaceState.MAXIMIZED);
settings.set_boolean ("window-maximized", is_maximized);
- is_fullscreen = (bool) (event.new_window_state & Gdk.WindowState.FULLSCREEN);
+ is_fullscreen = (bool) (state & Gdk.SurfaceState.FULLSCREEN);
update_pause (false);
- if (!(bool) (event.changed_mask & Gdk.WindowState.FOCUSED))
- return false;
+ if (!(bool) (changed_mask & Gdk.SurfaceState.FOCUSED))
+ return;
- var focused = (bool) (event.new_window_state & Gdk.WindowState.FOCUSED);
+ var focused = (bool) (state & Gdk.SurfaceState.FOCUSED);
var playing = (ui_state == UiState.DISPLAY);
if (focused && playing)
@@ -263,8 +271,6 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
if (!focused)
uninhibit (Gtk.ApplicationInhibitFlags.IDLE);
-
- return false;
}
public bool gamepad_button_press_event (Manette.Event event) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]