From 5c3b0cda2e4098557e71f05c2ec7bd2cd70967cf Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 21 Sep 2010 12:31:32 +0200 Subject: [PATCH] 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 8ce50aee0..fa59b6ad0 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 4b09dc917..3b34bde28 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; }