[mutter] ui: gtk_widget_show() the MetaFrames object



commit 5c3b0cda2e4098557e71f05c2ec7bd2cd70967cf
Author: Benjamin Otte <otte redhat com>
Date:   Tue Sep 21 12:31:32 2010 +0200

    ui: gtk_widget_show() the MetaFrames object
    
    The widget needs to be visible and mapped for GTK3 to deliver expose
    events to the widget. This is achieved by making the map function a
    no-op and calling gtk_widget_show() instead of just calling
    gtk_widget_realize().
    Apart from making GTK think the widget is drawable, the effect is the
    same.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=630203

 src/ui/frames.c |   22 ++++++++++++----------
 src/ui/ui.c     |    5 ++++-
 2 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 8ce50ae..fa59b6a 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -49,8 +49,8 @@ static void meta_frames_destroy    (GtkObject       *object);
 static void meta_frames_finalize   (GObject         *object);
 static void meta_frames_style_set  (GtkWidget       *widget,
                                     GtkStyle        *prev_style);
-static void meta_frames_realize    (GtkWidget       *widget);
-static void meta_frames_unrealize  (GtkWidget       *widget);
+static void meta_frames_map        (GtkWidget       *widget);
+static void meta_frames_unmap      (GtkWidget       *widget);
 
 static void meta_frames_update_prelit_control (MetaFrames      *frames,
                                                MetaUIFrame     *frame,
@@ -145,8 +145,8 @@ meta_frames_class_init (MetaFramesClass *class)
 
   widget_class->style_set = meta_frames_style_set;
 
-  widget_class->realize = meta_frames_realize;
-  widget_class->unrealize = meta_frames_unrealize;
+  widget_class->map = meta_frames_map;
+  widget_class->unmap = meta_frames_unmap;
   
   widget_class->expose_event = meta_frames_expose_event;
   widget_class->destroy_event = meta_frames_destroy_event;  
@@ -676,17 +676,19 @@ meta_frames_unmanage_window (MetaFrames *frames,
 }
 
 static void
-meta_frames_realize (GtkWidget *widget)
+meta_frames_map (GtkWidget *widget)
 {
-  if (GTK_WIDGET_CLASS (meta_frames_parent_class)->realize)
-    GTK_WIDGET_CLASS (meta_frames_parent_class)->realize (widget);
+  /* We override the parent map function to a no-op because we don't
+   * want to actually show the GDK window. But GTK needs to think that
+   * the widget is mapped or it won't deliver the events we care about.
+   */
+  gtk_widget_set_mapped (widget, TRUE);
 }
 
 static void
-meta_frames_unrealize (GtkWidget *widget)
+meta_frames_unmap (GtkWidget *widget)
 {
-  if (GTK_WIDGET_CLASS (meta_frames_parent_class)->unrealize)
-    GTK_WIDGET_CLASS (meta_frames_parent_class)->unrealize (widget);
+  gtk_widget_set_mapped (widget, FALSE);
 }
 
 static MetaUIFrame*
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 4b09dc9..3b34bde 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -128,7 +128,10 @@ meta_ui_new (Display *xdisplay,
 
   g_assert (xdisplay == GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
   ui->frames = meta_frames_new (XScreenNumberOfScreen (screen));
-  gtk_widget_realize (GTK_WIDGET (ui->frames));
+  /* This does not actually show any widget. MetaFrames has been hacked so
+   * that showing it doesn't actually do anything. But we need the flags
+   * set for GTK to deliver events properly. */
+  gtk_widget_show (GTK_WIDGET (ui->frames));
   
   return ui;
 }



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