[gtksourceview] CompletionInfo: fix popup window under Wayland



commit bb45b308cb64daf945153bbe17e98cdc44750238
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Tue Jan 12 16:55:38 2016 +0100

    CompletionInfo: fix popup window under Wayland
    
    Wayland requires popup windows to be attached to another toplevel
    window so that it can be translated either as an xdg-popup or a
    subsurface depending if there is a grab associated with the popup or
    not.
    
    GtkCompletionInfo uses gtk popup windows type but doesn't set the
    transient relationship with the toplevel window, causing the
    CompletionInfo window to fail to map under Wayland.
    
    Reuse the attached_to widget to determine the toplevel window and set
    the transient relationship prior to map the CompletionInfo window so
    that it can work under Wayland as well.
    
    Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=759623

 gtksourceview/gtksourcecompletioninfo.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletioninfo.c b/gtksourceview/gtksourcecompletioninfo.c
index d5e6703..a0c0f18 100644
--- a/gtksourceview/gtksourcecompletioninfo.c
+++ b/gtksourceview/gtksourcecompletioninfo.c
@@ -71,6 +71,8 @@ struct _GtkSourceCompletionInfoPrivate
        gulong focus_out_event_handler;
 
        gint xoffset;
+
+       gboolean transient_set;
 };
 
 /* Signals */
@@ -236,6 +238,7 @@ set_attached_to (GtkSourceCompletionInfo *info,
                return;
        }
 
+       info->priv->transient_set = FALSE;
        g_object_add_weak_pointer (G_OBJECT (attached_to),
                                   (gpointer *) &info->priv->attached_to);
 
@@ -293,9 +296,24 @@ gtk_source_completion_info_dispose (GObject *object)
 static void
 gtk_source_completion_info_show (GtkWidget *widget)
 {
+       GtkSourceCompletionInfo *info;
+
        /* First emit BEFORE_SHOW and then chain up */
        g_signal_emit (widget, signals[BEFORE_SHOW], 0);
 
+       info = GTK_SOURCE_COMPLETION_INFO (widget);
+       if (info->priv->attached_to != NULL && !info->priv->transient_set)
+       {
+               GtkWidget *toplevel;
+
+               toplevel = gtk_widget_get_toplevel (GTK_WIDGET (info->priv->attached_to));
+               if (gtk_widget_is_toplevel (toplevel))
+               {
+                       gtk_window_set_transient_for (GTK_WINDOW (info),
+                                                     GTK_WINDOW (toplevel));
+                       info->priv->transient_set = TRUE;
+               }
+       }
        GTK_WIDGET_CLASS (gtk_source_completion_info_parent_class)->show (widget);
 }
 


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