From e5b18671185178103ca0c0cbb4ec45ed32bd94e5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 14 Dec 2017 18:51:38 -0500 Subject: [PATCH] gdk: Add a GdkWindow::state property This will eventually replace the window state event. --- gdk/gdkevents.c | 1 + gdk/gdkwindow.c | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index db702b2a63..32da413ec4 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -2013,6 +2013,7 @@ _gdk_set_window_state (GdkWindow *window, case GDK_WINDOW_TOPLEVEL: case GDK_WINDOW_TEMP: /* ? */ gdk_display_put_event (display, temp_event); + g_object_notify (G_OBJECT (window), "state"); break; case GDK_WINDOW_FOREIGN: case GDK_WINDOW_ROOT: diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index e6f9fa3791..931079d577 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -100,6 +100,7 @@ enum { PROP_0, PROP_CURSOR, PROP_DISPLAY, + PROP_STATE, LAST_PROP }; @@ -275,6 +276,13 @@ gdk_window_class_init (GdkWindowClass *klass) GDK_TYPE_DISPLAY, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + properties[PROP_STATE] = + g_param_spec_flags ("state", + P_("State"), + P_("State"), + GDK_TYPE_WINDOW_STATE, GDK_WINDOW_STATE_WITHDRAWN, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, LAST_PROP, properties); /** @@ -435,6 +443,10 @@ gdk_window_get_property (GObject *object, g_value_set_object (value, window->display); break; + case PROP_STATE: + g_value_set_flags (value, window->state); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1345,6 +1357,8 @@ _gdk_window_destroy_hierarchy (GdkWindow *window, cairo_region_destroy (window->clip_region); window->clip_region = NULL; } + + g_object_notify_by_pspec (G_OBJECT (window), properties[PROP_STATE]); } break; } @@ -3343,6 +3357,7 @@ gdk_window_show_internal (GdkWindow *window, gboolean raise) else { window->state = 0; + g_object_notify_by_pspec (G_OBJECT (window), properties[PROP_STATE]); } did_show = _gdk_window_update_viewable (window); @@ -3622,7 +3637,10 @@ gdk_window_hide (GdkWindow *window) GDK_WINDOW_STATE_WITHDRAWN); } else if (was_mapped) - window->state = GDK_WINDOW_STATE_WITHDRAWN; + { + window->state = GDK_WINDOW_STATE_WITHDRAWN; + g_object_notify_by_pspec (G_OBJECT (window), properties[PROP_STATE]); + } if (was_mapped) {