[polari] tabCompletion: Fix completion popup on wayland



commit 9adc8e7dc8226cd5007532b6b155f46c1786950f
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Nov 26 14:35:12 2015 +0100

    tabCompletion: Fix completion popup on wayland
    
    Unlike normal popups, the completion popup only serves as display for
    completion options, so it does not grab input and should not take away
    the focus from the corresponding entry. The latter doesn't currently
    work on wayland, which makes us dismiss the popup immediately on map.
    
    Work around this by marking the popup as tooltip (ugh), which allows
    us to keep it working without taking a grab. In the future, we might
    want to consider stop using a toplevel window for completions, for
    instance a popover.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=758476

 src/tabCompletion.js |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/tabCompletion.js b/src/tabCompletion.js
index 62c396d..cebce47 100644
--- a/src/tabCompletion.js
+++ b/src/tabCompletion.js
@@ -15,15 +15,26 @@ const TabCompletion = new Lang.Class({
         this._entry.connect('key-press-event', Lang.bind(this, this._onKeyPress));
         this._entry.connect('focus-out-event', Lang.bind(this, this._cancel));
         this._entry.connect('unmap', Lang.bind(this, this._cancel));
+        this._entry.connect('realize', Lang.bind(this,
+            function() {
+                this._popup.set_transient_for(this._entry.get_toplevel());
+            }));
 
         this._popup = new Gtk.Window({ type: Gtk.WindowType.POPUP });
 
+        // HACK: tooltips are the only popup windows that don't require a
+        //       grab on wayland
+        this._popup.set_type_hint(Gdk.WindowTypeHint.TOOLTIP);
+
+        let frame = new Gtk.Frame({ visible: true });
+        this._popup.add(frame);
+
         this._list = new Gtk.ListBox({ selection_mode: Gtk.SelectionMode.SINGLE });
         this._list.set_filter_func(Lang.bind(this, this._filter));
         this._list.connect('row-selected', Lang.bind(this, this._onRowSelected));
         this._list.connect('row-activated', Lang.bind(this, this._stop));
         this._list.connect('keynav-failed', Lang.bind(this, this._onKeynavFailed));
-        this._popup.add(this._list);
+        frame.add(this._list);
 
         this._widgetMap = {};
     },


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