[gtk+/popovers: 27/45] gtkmain: Let windows handle WM-related events before delivering to the grab_widget



commit 4aa457fcc90073f3188ea69d05ca6d2ebd24343a
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Jan 7 17:49:31 2014 +0100

    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(+), 0 deletions(-)
---
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index a30ff70..e80f15f 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 6c0b919..ad6512f 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -7697,6 +7697,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 d9f9f4d..5395eb0 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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]