viewSelector: Open context for highlighted search result

To make search more efficient, users don't need to move the actual
keyboard focus away from the search entry to activate the first
result. However the shift+f10 shortcut to pop up the context menu
via keyboard still acts on the actually focused widget, which is
the entry. It makes more sense to open the context menu of the
selected result instead, as that's what's highlighted and responds
to keyboard activation.

https://bugzilla.gnome.org/show_bug.cgi?id=675315
This commit is contained in:
Florian Müllner 2017-08-16 01:25:15 +02:00
parent 5067ac1598
commit 093b73b616
2 changed files with 16 additions and 0 deletions

View File

@ -681,6 +681,15 @@ var SearchResults = new Lang.Class({
this._setSelected(this._defaultResult, highlight); this._setSelected(this._defaultResult, highlight);
}, },
popupMenuDefault: function() {
// If we have a search queued up, force the search now.
if (this._searchTimeoutId > 0)
this._doSearch();
if (this._defaultResult)
this._defaultResult.actor.popup_menu();
},
navigateFocus: function(direction) { navigateFocus: function(direction) {
let rtl = this.actor.get_text_direction() == Clutter.TextDirection.RTL; let rtl = this.actor.get_text_direction() == Clutter.TextDirection.RTL;
if (direction == Gtk.DirectionType.TAB_BACKWARD || if (direction == Gtk.DirectionType.TAB_BACKWARD ||

View File

@ -163,6 +163,13 @@ var ViewSelector = new Lang.Class({
this._text.connect('key-focus-out', Lang.bind(this, function() { this._text.connect('key-focus-out', Lang.bind(this, function() {
this._searchResults.highlightDefault(false); this._searchResults.highlightDefault(false);
})); }));
this._entry.connect('popup-menu', () => {
if (!this._searchActive)
return;
this._entry.menu.close();
this._searchResults.popupMenuDefault();
});
this._entry.connect('notify::mapped', Lang.bind(this, this._onMapped)); this._entry.connect('notify::mapped', Lang.bind(this, this._onMapped));
global.stage.connect('notify::key-focus', Lang.bind(this, this._onStageKeyFocusChanged)); global.stage.connect('notify::key-focus', Lang.bind(this, this._onStageKeyFocusChanged));