[gimp] app: use "map-event" if you want to make sure that a window is mapped.



commit 3f51d4eb48f4d2ab3a6d1aa4ce73f10b349cfb8a
Author: Jehan <jehan girinstud io>
Date:   Sat Sep 5 22:17:36 2015 +0200

    app: use "map-event" if you want to make sure that a window is mapped.
    
    The "map" signal does not mean a widget is mapped. It may be emitted
    before. Yet pointer and keyboard grabs won't work on non viewable
    widgets and will fail with GDK_GRAB_NOT_VIEWABLE.
    For some reason, a GtkWindow with type GTK_WINDOW_POPUP was always
    mapped when "map" is emitted but not yet with type GTK_WINDOW_TOPLEVEL
    (at least in my tests). Thus switch to "map-event" to make sure the
    widget is actually mapped.

 app/widgets/gimppopup.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/app/widgets/gimppopup.c b/app/widgets/gimppopup.c
index 7061f8b..4a7df39 100644
--- a/app/widgets/gimppopup.c
+++ b/app/widgets/gimppopup.c
@@ -41,7 +41,8 @@ enum
 };
 
 
-static void     gimp_popup_map          (GtkWidget      *widget);
+static gboolean gimp_popup_map_event    (GtkWidget      *widget,
+                                         GdkEventAny    *event);
 static gboolean gimp_popup_button_press (GtkWidget      *widget,
                                          GdkEventButton *bevent);
 static gboolean gimp_popup_key_press    (GtkWidget      *widget,
@@ -82,7 +83,7 @@ gimp_popup_class_init (GimpPopupClass *klass)
                   gimp_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
 
-  widget_class->map                = gimp_popup_map;
+  widget_class->map_event          = gimp_popup_map_event;
   widget_class->button_press_event = gimp_popup_button_press;
   widget_class->key_press_event    = gimp_popup_key_press;
 
@@ -133,10 +134,11 @@ gimp_popup_grab_broken_event (GtkWidget          *widget,
   return FALSE;
 }
 
-static void
-gimp_popup_map (GtkWidget *widget)
+static gboolean
+gimp_popup_map_event (GtkWidget                 *widget,
+                      G_GNUC_UNUSED GdkEventAny *event)
 {
-  GTK_WIDGET_CLASS (parent_class)->map (widget);
+  GTK_WIDGET_CLASS (parent_class)->map_event (widget, event);
 
   /*  grab with owner_events == TRUE so the popup's widgets can
    *  receive events. we filter away events outside this toplevel
@@ -159,7 +161,7 @@ gimp_popup_map (GtkWidget *widget)
                             G_CALLBACK (gimp_popup_grab_broken_event),
                             widget);
 
-          return;
+          return FALSE;
         }
       else
         {
@@ -172,6 +174,7 @@ gimp_popup_map (GtkWidget *widget)
    *  around uncloseable.
    */
   g_signal_emit (widget, popup_signals[CANCEL], 0);
+  return FALSE;
 }
 
 static gboolean


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