From 36abb4b829259a190c1660dd2e1d66e466865c0c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 7 Jan 2014 17:49:31 +0100 Subject: [PATCH] gtkmain: Let windows handle WM-related events before delivering to the grab_widget This makes it possible to move/resize client-side decorated windows that are otherwise obscured by a GTK+ grab somewhere else, either a popover within the window itself or a modal dialog above the window. --- gtk/gtkmain.c | 6 ++++++ gtk/gtkwindow.c | 21 +++++++++++++++++++++ gtk/gtkwindowprivate.h | 2 ++ 3 files changed, 29 insertions(+) diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 40f0b05807..c1b08cf131 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -1568,6 +1568,12 @@ gtk_main_do_event (GdkEvent *event) event_widget = gtk_get_event_widget (event); } + if (GTK_IS_WINDOW (event_widget)) + { + if (_gtk_window_check_handle_wm_event (event)) + return; + } + window_group = gtk_main_get_window_group (event_widget); device = gdk_event_get_device (event); diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 6f7ce0fb29..260f57aded 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -7704,6 +7704,27 @@ gtk_window_button_press_event (GtkWidget *widget, return FALSE; } +gboolean +_gtk_window_check_handle_wm_event (GdkEvent *event) +{ + GtkWidget *widget; + + widget = gtk_get_event_widget (event); + + if (!GTK_IS_WINDOW (widget)) + return FALSE; + + if (event->type == GDK_BUTTON_PRESS || + event->type == GDK_2BUTTON_PRESS) + return gtk_window_button_press_event (widget, &event->button); + else if (event->type == GDK_BUTTON_RELEASE) + gtk_window_button_release_event (widget, &event->button); + else if (event->type == GDK_MOTION_NOTIFY) + return gtk_window_motion_notify_event (widget, &event->motion); + else + return FALSE; +} + static void gtk_window_real_activate_default (GtkWindow *window) { diff --git a/gtk/gtkwindowprivate.h b/gtk/gtkwindowprivate.h index d9f9f4d4a2..5395eb077b 100644 --- a/gtk/gtkwindowprivate.h +++ b/gtk/gtkwindowprivate.h @@ -75,6 +75,8 @@ void _gtk_window_keys_foreach (GtkWindow *window, GtkWindowKeysForeachFunc func, gpointer func_data); +gboolean _gtk_window_check_handle_wm_event (GdkEvent *event); + /* --- internal (GtkAcceleratable) --- */ gboolean _gtk_window_query_nonaccels (GtkWindow *window, guint accel_key,