[gnome-games/wip/exalm/gtk4: 17/31] 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: 17/31] application-window: Stop using 'window-state-event' signal
- Date: Sun, 7 Oct 2018 07:43:15 +0000 (UTC)
commit 9c9bd2cf618506fc86ab1e6e34f2a338a148b5e8
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 d81f1a84..61303365 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 ab399701..a172b179 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -96,6 +96,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;
@@ -158,6 +159,10 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
if (Config.PROFILE == "Devel")
get_style_context ().add_class ("devel");
+
+ var surface = get_surface ();
+ state = surface.state;
+ surface.notify["state"].connect(on_surface_state_changed);
}
public void run_game (Game game) {
@@ -237,18 +242,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)
@@ -256,8 +264,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]