summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-12-14 22:10:44 -0500
committerMatthias Clasen <mclasen@redhat.com>2017-12-14 22:24:06 -0500
commitce251133c08478c2619a80d8b7e887cae7c5db18 (patch)
tree2b91b4befa6038da38a4c6ec0030b72a5c9264e1 /demos
parent2c267a3cf1a4d961db93c22ae8712f28b39604d2 (diff)
downloadgtk+-ce251133c08478c2619a80d8b7e887cae7c5db18.tar.gz
gtk-demo: Stop using GdkEventWindowState
Use GdkWindow::state instead - the event is going away.
Diffstat (limited to 'demos')
-rw-r--r--demos/gtk-demo/application.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/demos/gtk-demo/application.c b/demos/gtk-demo/application.c
index 732c3766d4..dec3ad2974 100644
--- a/demos/gtk-demo/application.c
+++ b/demos/gtk-demo/application.c
@@ -469,22 +469,33 @@ demo_application_window_size_allocate (GtkWidget *widget,
gtk_window_get_size (GTK_WINDOW (window), &window->width, &window->height);
}
-static gboolean
-demo_application_window_state_event (GtkWidget *widget,
- GdkEventWindowState *event)
+static void
+window_state_changed (GtkWidget *widget)
{
DemoApplicationWindow *window = (DemoApplicationWindow *)widget;
- gboolean res = GDK_EVENT_PROPAGATE;
- GdkWindowState changed, new_state;
-
- if (GTK_WIDGET_CLASS (demo_application_window_parent_class)->window_state_event)
- res = GTK_WIDGET_CLASS (demo_application_window_parent_class)->window_state_event (widget, event);
+ GdkWindowState new_state;
- gdk_event_get_window_state ((GdkEvent *)event, &changed, &new_state);
+ new_state = gdk_window_get_state (gtk_widget_get_window (widget));
window->maximized = (new_state & GDK_WINDOW_STATE_MAXIMIZED) != 0;
window->fullscreen = (new_state & GDK_WINDOW_STATE_FULLSCREEN) != 0;
+}
+
+static void
+demo_application_window_realize (GtkWidget *widget)
+{
+ GTK_WIDGET_CLASS (demo_application_window_parent_class)->realize (widget);
+
+ g_signal_connect_swapped (gtk_widget_get_window (widget), "notify::state",
+ G_CALLBACK (window_state_changed), widget);
+}
+
+static void
+demo_application_window_unrealize (GtkWidget *widget)
+{
+ g_signal_handlers_disconnect_by_func (gtk_widget_get_window (widget),
+ window_state_changed, widget);
- return res;
+ GTK_WIDGET_CLASS (demo_application_window_parent_class)->unrealize (widget);
}
static void
@@ -506,7 +517,8 @@ demo_application_window_class_init (DemoApplicationWindowClass *class)
object_class->constructed = demo_application_window_constructed;
widget_class->size_allocate = demo_application_window_size_allocate;
- widget_class->window_state_event = demo_application_window_state_event;
+ widget_class->realize = demo_application_window_realize;
+ widget_class->unrealize = demo_application_window_unrealize;
widget_class->destroy = demo_application_window_destroy;
gtk_widget_class_set_template_from_resource (widget_class, "/application_demo/application.ui");