2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2010-11-12 12:45:29 -05:00
|
|
|
|
|
|
|
const Clutter = imports.gi.Clutter;
|
2012-10-08 12:16:55 -04:00
|
|
|
const Gio = imports.gi.Gio;
|
2013-11-28 19:45:39 -05:00
|
|
|
const GLib = imports.gi.GLib;
|
2011-02-23 14:21:47 -05:00
|
|
|
const Gtk = imports.gi.Gtk;
|
2010-11-12 12:45:29 -05:00
|
|
|
const Mainloop = imports.mainloop;
|
|
|
|
const Meta = imports.gi.Meta;
|
|
|
|
const Signals = imports.signals;
|
|
|
|
const Lang = imports.lang;
|
|
|
|
const Shell = imports.gi.Shell;
|
|
|
|
const St = imports.gi.St;
|
2017-03-21 13:47:36 -04:00
|
|
|
const GObject = imports.gi.GObject;
|
2010-11-12 12:45:29 -05:00
|
|
|
|
2012-07-28 16:06:46 -04:00
|
|
|
const AppDisplay = imports.ui.appDisplay;
|
2010-11-12 12:45:29 -05:00
|
|
|
const Main = imports.ui.main;
|
2013-01-24 01:35:19 -05:00
|
|
|
const OverviewControls = imports.ui.overviewControls;
|
2012-12-13 17:20:46 -05:00
|
|
|
const Params = imports.misc.params;
|
2010-11-12 12:45:29 -05:00
|
|
|
const Search = imports.ui.search;
|
2011-10-11 18:38:24 -04:00
|
|
|
const ShellEntry = imports.ui.shellEntry;
|
2010-11-12 12:45:29 -05:00
|
|
|
const Tweener = imports.ui.tweener;
|
2012-07-28 16:06:46 -04:00
|
|
|
const WorkspacesView = imports.ui.workspacesView;
|
2014-08-05 10:25:30 -04:00
|
|
|
const EdgeDragAction = imports.ui.edgeDragAction;
|
2014-06-17 13:10:54 -04:00
|
|
|
const IconGrid = imports.ui.iconGrid;
|
2010-11-12 12:45:29 -05:00
|
|
|
|
2012-10-08 12:16:55 -04:00
|
|
|
const SHELL_KEYBINDINGS_SCHEMA = 'org.gnome.shell.keybindings';
|
2017-07-18 13:47:27 -04:00
|
|
|
var PINCH_GESTURE_THRESHOLD = 0.7;
|
2010-11-12 12:45:29 -05:00
|
|
|
|
2017-07-18 13:47:27 -04:00
|
|
|
var ViewPage = {
|
2013-02-13 16:13:14 -05:00
|
|
|
WINDOWS: 1,
|
|
|
|
APPS: 2,
|
|
|
|
SEARCH: 3
|
|
|
|
};
|
|
|
|
|
2017-07-18 13:41:25 -04:00
|
|
|
var FocusTrap = new Lang.Class({
|
2012-03-09 19:33:31 -05:00
|
|
|
Name: 'FocusTrap',
|
|
|
|
Extends: St.Widget,
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_navigate_focus(from, direction) {
|
2012-03-09 19:33:31 -05:00
|
|
|
if (direction == Gtk.DirectionType.TAB_FORWARD ||
|
|
|
|
direction == Gtk.DirectionType.TAB_BACKWARD)
|
|
|
|
return this.parent(from, direction);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-02-08 21:05:15 -05:00
|
|
|
function getTermsForSearchString(searchString) {
|
|
|
|
searchString = searchString.replace(/^\s+/g, '').replace(/\s+$/g, '');
|
|
|
|
if (searchString == '')
|
|
|
|
return [];
|
|
|
|
|
|
|
|
let terms = searchString.split(/\s+/);
|
|
|
|
return terms;
|
|
|
|
}
|
2012-03-09 19:33:31 -05:00
|
|
|
|
2017-07-18 13:41:25 -04:00
|
|
|
var TouchpadShowOverviewAction = new Lang.Class({
|
2016-04-15 11:48:25 -04:00
|
|
|
Name: 'TouchpadShowOverviewAction',
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init(actor) {
|
2017-12-01 19:27:35 -05:00
|
|
|
actor.connect('captured-event', this._handleEvent.bind(this));
|
2016-04-15 11:48:25 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_handleEvent(actor, event) {
|
2016-04-15 11:48:25 -04:00
|
|
|
if (event.type() != Clutter.EventType.TOUCHPAD_PINCH)
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
|
|
|
if (event.get_touchpad_gesture_finger_count() != 3)
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
|
|
|
if (event.get_gesture_phase() == Clutter.TouchpadGesturePhase.END)
|
|
|
|
this.emit('activated', event.get_gesture_pinch_scale ());
|
|
|
|
|
|
|
|
return Clutter.EVENT_STOP;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Signals.addSignalMethods(TouchpadShowOverviewAction.prototype);
|
|
|
|
|
2017-07-18 13:41:25 -04:00
|
|
|
var ShowOverviewAction = new Lang.Class({
|
2014-06-25 12:12:04 -04:00
|
|
|
Name: 'ShowOverviewAction',
|
|
|
|
Extends: Clutter.GestureAction,
|
2017-03-21 13:47:36 -04:00
|
|
|
Signals: { 'activated': { param_types: [GObject.TYPE_DOUBLE] } },
|
2014-06-25 12:12:04 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init() {
|
2014-06-25 12:12:04 -04:00
|
|
|
this.parent();
|
|
|
|
this.set_n_touch_points(3);
|
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
global.display.connect('grab-op-begin', () => {
|
2014-06-25 12:12:04 -04:00
|
|
|
this.cancel();
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2014-06-25 12:12:04 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_gesture_prepare(action, actor) {
|
2014-12-11 09:35:40 -05:00
|
|
|
return Main.actionMode == Shell.ActionMode.NORMAL &&
|
2014-11-27 14:46:50 -05:00
|
|
|
this.get_n_current_points() == this.get_n_touch_points();
|
2014-06-25 12:12:04 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_getBoundingRect(motion) {
|
2014-06-25 12:12:04 -04:00
|
|
|
let minX, minY, maxX, maxY;
|
|
|
|
|
|
|
|
for (let i = 0; i < this.get_n_current_points(); i++) {
|
|
|
|
let x, y;
|
|
|
|
|
|
|
|
if (motion == true) {
|
|
|
|
[x, y] = this.get_motion_coords(i);
|
|
|
|
} else {
|
|
|
|
[x, y] = this.get_press_coords(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
minX = maxX = x;
|
|
|
|
minY = maxY = y;
|
|
|
|
} else {
|
|
|
|
minX = Math.min(minX, x);
|
|
|
|
minY = Math.min(minY, y);
|
|
|
|
maxX = Math.max(maxX, x);
|
|
|
|
maxY = Math.max(maxY, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Meta.Rectangle({ x: minX,
|
|
|
|
y: minY,
|
|
|
|
width: maxX - minX,
|
|
|
|
height: maxY - minY });
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_gesture_begin(action, actor) {
|
2014-06-25 12:12:04 -04:00
|
|
|
this._initialRect = this._getBoundingRect(false);
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_gesture_end(action, actor) {
|
2014-06-25 12:12:04 -04:00
|
|
|
let rect = this._getBoundingRect(true);
|
|
|
|
let oldArea = this._initialRect.width * this._initialRect.height;
|
|
|
|
let newArea = rect.width * rect.height;
|
|
|
|
let areaDiff = newArea / oldArea;
|
|
|
|
|
|
|
|
this.emit('activated', areaDiff);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-07-18 13:41:25 -04:00
|
|
|
var ViewSelector = new Lang.Class({
|
2012-06-21 18:52:56 -04:00
|
|
|
Name: 'ViewSelector',
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init(searchEntry, showAppsButton) {
|
2012-12-13 17:21:53 -05:00
|
|
|
this.actor = new Shell.Stack({ name: 'viewSelector' });
|
2012-06-21 18:52:56 -04:00
|
|
|
|
|
|
|
this._showAppsButton = showAppsButton;
|
2017-12-01 19:27:35 -05:00
|
|
|
this._showAppsButton.connect('notify::checked', this._onShowAppsButtonToggled.bind(this));
|
2012-06-21 18:52:56 -04:00
|
|
|
|
2012-06-21 18:52:56 -04:00
|
|
|
this._activePage = null;
|
2010-11-18 07:51:47 -05:00
|
|
|
|
2012-08-24 12:24:49 -04:00
|
|
|
this._searchActive = false;
|
2010-11-18 07:51:47 -05:00
|
|
|
|
2012-07-28 16:47:55 -04:00
|
|
|
this._entry = searchEntry;
|
2011-10-11 18:38:24 -04:00
|
|
|
ShellEntry.addContextMenu(this._entry);
|
2012-06-21 18:52:56 -04:00
|
|
|
|
2011-02-16 13:20:03 -05:00
|
|
|
this._text = this._entry.clutter_text;
|
2017-12-01 19:27:35 -05:00
|
|
|
this._text.connect('text-changed', this._onTextChanged.bind(this));
|
|
|
|
this._text.connect('key-press-event', this._onKeyPress.bind(this));
|
2017-10-30 20:38:18 -04:00
|
|
|
this._text.connect('key-focus-in', () => {
|
2012-06-21 18:52:56 -04:00
|
|
|
this._searchResults.highlightDefault(true);
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
|
|
|
this._text.connect('key-focus-out', () => {
|
2012-06-21 18:52:56 -04:00
|
|
|
this._searchResults.highlightDefault(false);
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2017-08-15 19:25:15 -04:00
|
|
|
this._entry.connect('popup-menu', () => {
|
|
|
|
if (!this._searchActive)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._entry.menu.close();
|
|
|
|
this._searchResults.popupMenuDefault();
|
|
|
|
});
|
2017-12-01 19:27:35 -05:00
|
|
|
this._entry.connect('notify::mapped', this._onMapped.bind(this));
|
|
|
|
global.stage.connect('notify::key-focus', this._onStageKeyFocusChanged.bind(this));
|
2011-02-16 13:20:03 -05:00
|
|
|
|
2013-03-03 13:56:12 -05:00
|
|
|
this._entry.set_primary_icon(new St.Icon({ style_class: 'search-entry-icon',
|
|
|
|
icon_name: 'edit-find-symbolic' }));
|
2014-09-05 12:56:21 -04:00
|
|
|
this._clearIcon = new St.Icon({ style_class: 'search-entry-icon',
|
|
|
|
icon_name: 'edit-clear-symbolic' });
|
2011-02-16 13:20:03 -05:00
|
|
|
|
|
|
|
this._iconClickedId = 0;
|
2012-06-21 18:52:56 -04:00
|
|
|
this._capturedEventId = 0;
|
2011-02-16 13:20:03 -05:00
|
|
|
|
2012-06-21 18:52:56 -04:00
|
|
|
this._workspacesDisplay = new WorkspacesView.WorkspacesDisplay();
|
2012-12-13 17:20:46 -05:00
|
|
|
this._workspacesPage = this._addPage(this._workspacesDisplay.actor,
|
2015-03-12 08:40:36 -04:00
|
|
|
_("Windows"), 'focus-windows-symbolic');
|
2011-02-16 13:20:03 -05:00
|
|
|
|
2011-07-09 09:30:42 -04:00
|
|
|
this.appDisplay = new AppDisplay.AppDisplay();
|
|
|
|
this._appsPage = this._addPage(this.appDisplay.actor,
|
2016-02-09 09:05:41 -05:00
|
|
|
_("Applications"), 'view-app-grid-symbolic');
|
2011-02-16 13:20:03 -05:00
|
|
|
|
2013-10-30 12:38:46 -04:00
|
|
|
this._searchResults = new Search.SearchResults();
|
2012-12-13 17:20:46 -05:00
|
|
|
this._searchPage = this._addPage(this._searchResults.actor,
|
|
|
|
_("Search"), 'edit-find-symbolic',
|
|
|
|
{ a11yFocus: this._entry });
|
2011-02-16 13:20:03 -05:00
|
|
|
|
2011-11-11 23:40:56 -05:00
|
|
|
// Since the entry isn't inside the results container we install this
|
|
|
|
// dummy widget as the last results container child so that we can
|
2012-03-09 19:33:31 -05:00
|
|
|
// include the entry in the keynav tab path
|
|
|
|
this._focusTrap = new FocusTrap({ can_focus: true });
|
2017-10-30 20:38:18 -04:00
|
|
|
this._focusTrap.connect('key-focus-in', () => {
|
2011-11-11 23:40:56 -05:00
|
|
|
this._entry.grab_key_focus();
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2011-11-11 23:40:56 -05:00
|
|
|
this._searchResults.actor.add_actor(this._focusTrap);
|
|
|
|
|
|
|
|
global.focus_manager.add_group(this._searchResults.actor);
|
2012-06-21 18:52:56 -04:00
|
|
|
|
|
|
|
this._stageKeyPressId = 0;
|
2017-10-30 20:38:18 -04:00
|
|
|
Main.overview.connect('showing', () => {
|
|
|
|
this._stageKeyPressId = global.stage.connect('key-press-event',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onStageKeyPress.bind(this));
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
|
|
|
Main.overview.connect('hiding', () => {
|
|
|
|
if (this._stageKeyPressId != 0) {
|
|
|
|
global.stage.disconnect(this._stageKeyPressId);
|
|
|
|
this._stageKeyPressId = 0;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Main.overview.connect('shown', () => {
|
|
|
|
// If we were animating from the desktop view to the
|
|
|
|
// apps page the workspace page was visible, allowing
|
|
|
|
// the windows to animate, but now we no longer want to
|
|
|
|
// show it given that we are now on the apps page or
|
|
|
|
// search page.
|
|
|
|
if (this._activePage != this._workspacesPage) {
|
|
|
|
this._workspacesPage.opacity = 0;
|
|
|
|
this._workspacesPage.hide();
|
|
|
|
}
|
|
|
|
});
|
2012-06-21 18:52:56 -04:00
|
|
|
|
2012-08-16 08:46:23 -04:00
|
|
|
Main.wm.addKeybinding('toggle-application-view',
|
2014-06-24 15:17:09 -04:00
|
|
|
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
|
2018-06-22 08:20:44 -04:00
|
|
|
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
2014-12-11 09:35:40 -05:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2017-12-01 19:27:35 -05:00
|
|
|
this._toggleAppsPage.bind(this));
|
2013-04-17 19:26:06 -04:00
|
|
|
|
|
|
|
Main.wm.addKeybinding('toggle-overview',
|
2014-06-24 15:17:09 -04:00
|
|
|
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
|
2018-06-22 08:20:44 -04:00
|
|
|
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
2014-12-11 09:35:40 -05:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2017-12-01 19:27:35 -05:00
|
|
|
Main.overview.toggle.bind(Main.overview));
|
2013-04-17 19:26:06 -04:00
|
|
|
|
2015-03-14 17:49:22 -04:00
|
|
|
let side;
|
|
|
|
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL)
|
|
|
|
side = St.Side.RIGHT;
|
|
|
|
else
|
|
|
|
side = St.Side.LEFT;
|
|
|
|
let gesture = new EdgeDragAction.EdgeDragAction(side,
|
|
|
|
Shell.ActionMode.NORMAL);
|
2017-10-30 20:38:18 -04:00
|
|
|
gesture.connect('activated', () => {
|
2014-06-25 11:52:19 -04:00
|
|
|
if (Main.overview.visible)
|
|
|
|
Main.overview.hide();
|
|
|
|
else
|
|
|
|
this.showApps();
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2014-06-25 11:52:19 -04:00
|
|
|
global.stage.add_action(gesture);
|
2014-06-25 12:12:04 -04:00
|
|
|
|
|
|
|
gesture = new ShowOverviewAction();
|
2017-12-01 19:27:35 -05:00
|
|
|
gesture.connect('activated', this._pinchGestureActivated.bind(this));
|
2014-06-25 12:12:04 -04:00
|
|
|
global.stage.add_action(gesture);
|
2016-04-15 11:48:25 -04:00
|
|
|
|
|
|
|
gesture = new TouchpadShowOverviewAction(global.stage);
|
2017-12-01 19:27:35 -05:00
|
|
|
gesture.connect('activated', this._pinchGestureActivated.bind(this));
|
2016-04-15 11:48:25 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_pinchGestureActivated(action, scale) {
|
2016-04-15 11:48:25 -04:00
|
|
|
if (scale < PINCH_GESTURE_THRESHOLD)
|
|
|
|
Main.overview.show();
|
2012-10-08 12:16:55 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_toggleAppsPage() {
|
2012-08-16 08:46:23 -04:00
|
|
|
this._showAppsButton.checked = !this._showAppsButton.checked;
|
2014-07-14 13:06:08 -04:00
|
|
|
Main.overview.show();
|
2012-06-21 18:52:56 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
showApps() {
|
2013-04-24 13:32:41 -04:00
|
|
|
this._showAppsButton.checked = true;
|
2014-07-14 13:06:08 -04:00
|
|
|
Main.overview.show();
|
2013-04-24 13:32:41 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
show() {
|
2013-02-16 12:54:19 -05:00
|
|
|
this.reset();
|
2014-07-14 13:06:08 -04:00
|
|
|
this._workspacesDisplay.show(this._showAppsButton.checked);
|
2013-11-20 12:06:14 -05:00
|
|
|
this._activePage = null;
|
2014-07-14 13:06:08 -04:00
|
|
|
if (this._showAppsButton.checked)
|
|
|
|
this._showPage(this._appsPage);
|
|
|
|
else
|
|
|
|
this._showPage(this._workspacesPage);
|
2012-06-21 18:52:56 -04:00
|
|
|
|
|
|
|
if (!this._workspacesDisplay.activeWorkspaceHasMaximizedWindows())
|
|
|
|
Main.overview.fadeOutDesktop();
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
animateFromOverview() {
|
2014-07-14 13:06:08 -04:00
|
|
|
// Make sure workspace page is fully visible to allow
|
|
|
|
// workspace.js do the animation of the windows
|
|
|
|
this._workspacesPage.opacity = 255;
|
|
|
|
|
|
|
|
this._workspacesDisplay.animateFromOverview(this._activePage != this._workspacesPage);
|
|
|
|
|
2014-07-14 12:55:34 -04:00
|
|
|
this._showAppsButton.checked = false;
|
2012-06-21 18:52:56 -04:00
|
|
|
|
|
|
|
if (!this._workspacesDisplay.activeWorkspaceHasMaximizedWindows())
|
|
|
|
Main.overview.fadeInDesktop();
|
2010-11-18 07:51:47 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setWorkspacesFullGeometry(geom) {
|
2013-02-25 18:25:27 -05:00
|
|
|
this._workspacesDisplay.setWorkspacesFullGeometry(geom);
|
2013-02-25 18:11:59 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
hide() {
|
2018-08-23 10:11:10 -04:00
|
|
|
this.reset();
|
2012-06-21 18:52:56 -04:00
|
|
|
this._workspacesDisplay.hide();
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_addPage(actor, name, a11yIcon, params) {
|
2012-12-13 17:20:46 -05:00
|
|
|
params = Params.parse(params, { a11yFocus: null });
|
|
|
|
|
2012-06-21 18:52:56 -04:00
|
|
|
let page = new St.Bin({ child: actor,
|
|
|
|
x_align: St.Align.START,
|
|
|
|
y_align: St.Align.START,
|
|
|
|
x_fill: true,
|
|
|
|
y_fill: true });
|
2012-12-13 17:20:46 -05:00
|
|
|
if (params.a11yFocus)
|
|
|
|
Main.ctrlAltTabManager.addGroup(params.a11yFocus, name, a11yIcon);
|
2012-06-21 18:52:56 -04:00
|
|
|
else
|
|
|
|
Main.ctrlAltTabManager.addGroup(actor, name, a11yIcon,
|
|
|
|
{ proxy: this.actor,
|
2017-10-30 20:38:18 -04:00
|
|
|
focusCallback: () => {
|
|
|
|
this._a11yFocusPage(page);
|
|
|
|
}
|
2012-06-21 18:52:56 -04:00
|
|
|
});;
|
2013-11-20 12:06:14 -05:00
|
|
|
page.hide();
|
2012-12-13 17:21:53 -05:00
|
|
|
this.actor.add_actor(page);
|
2012-11-01 09:45:04 -04:00
|
|
|
return page;
|
2012-06-21 18:52:56 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_fadePageIn() {
|
2014-06-17 13:10:54 -04:00
|
|
|
Tweener.addTween(this._activePage,
|
|
|
|
{ opacity: 255,
|
|
|
|
time: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_fadePageOut(page) {
|
2014-06-17 13:10:54 -04:00
|
|
|
let oldPage = page;
|
|
|
|
Tweener.addTween(page,
|
|
|
|
{ opacity: 0,
|
|
|
|
time: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad',
|
2017-10-30 20:38:18 -04:00
|
|
|
onComplete: () => {
|
2014-06-17 13:10:54 -04:00
|
|
|
this._animateIn(oldPage);
|
2017-10-30 20:38:18 -04:00
|
|
|
}
|
2014-06-17 13:10:54 -04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_animateIn(oldPage) {
|
2013-02-16 12:59:54 -05:00
|
|
|
if (oldPage)
|
|
|
|
oldPage.hide();
|
|
|
|
|
2013-02-15 20:43:45 -05:00
|
|
|
this.emit('page-empty');
|
2014-02-18 19:44:58 -05:00
|
|
|
|
2013-01-24 01:35:19 -05:00
|
|
|
this._activePage.show();
|
2014-06-17 13:10:54 -04:00
|
|
|
|
|
|
|
if (this._activePage == this._appsPage && oldPage == this._workspacesPage) {
|
|
|
|
// Restore opacity, in case we animated via _fadePageOut
|
|
|
|
this._activePage.opacity = 255;
|
|
|
|
this.appDisplay.animate(IconGrid.AnimationDirection.IN);
|
|
|
|
} else {
|
|
|
|
this._fadePageIn();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_animateOut(page) {
|
2014-06-17 13:10:54 -04:00
|
|
|
let oldPage = page;
|
|
|
|
if (page == this._appsPage &&
|
|
|
|
this._activePage == this._workspacesPage &&
|
|
|
|
!Main.overview.animationInProgress) {
|
2017-10-30 20:38:18 -04:00
|
|
|
this.appDisplay.animate(IconGrid.AnimationDirection.OUT, () => {
|
|
|
|
this._animateIn(oldPage)
|
|
|
|
});
|
2014-06-17 13:10:54 -04:00
|
|
|
} else {
|
|
|
|
this._fadePageOut(page);
|
|
|
|
}
|
2013-01-24 01:35:19 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_showPage(page) {
|
2014-07-14 13:06:08 -04:00
|
|
|
if (!Main.overview.visible)
|
|
|
|
return;
|
|
|
|
|
2013-01-24 16:35:11 -05:00
|
|
|
if (page == this._activePage)
|
2012-06-21 18:52:56 -04:00
|
|
|
return;
|
2012-06-21 18:52:56 -04:00
|
|
|
|
2013-01-24 16:35:11 -05:00
|
|
|
let oldPage = this._activePage;
|
2013-01-24 01:35:19 -05:00
|
|
|
this._activePage = page;
|
|
|
|
this.emit('page-changed');
|
|
|
|
|
2014-07-14 12:55:34 -04:00
|
|
|
if (oldPage)
|
2014-06-17 13:10:54 -04:00
|
|
|
this._animateOut(oldPage)
|
2013-01-24 01:35:19 -05:00
|
|
|
else
|
2014-06-17 13:10:54 -04:00
|
|
|
this._animateIn();
|
2012-06-21 18:52:56 -04:00
|
|
|
},
|
2012-06-21 18:52:56 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_a11yFocusPage(page) {
|
2012-06-21 18:52:56 -04:00
|
|
|
this._showAppsButton.checked = page == this._appsPage;
|
|
|
|
page.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
|
2012-06-21 18:52:56 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onShowAppsButtonToggled() {
|
2013-02-16 12:55:59 -05:00
|
|
|
this._showPage(this._showAppsButton.checked ?
|
|
|
|
this._appsPage : this._workspacesPage);
|
2012-06-21 18:52:56 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onStageKeyPress(actor, event) {
|
2012-11-12 12:41:14 -05:00
|
|
|
// Ignore events while anything but the overview has
|
|
|
|
// pushed a modal (system modals, looking glass, ...)
|
|
|
|
if (Main.modalCount > 1)
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2012-11-12 12:41:14 -05:00
|
|
|
|
2012-06-21 18:52:56 -04:00
|
|
|
let modifiers = event.get_state();
|
|
|
|
let symbol = event.get_key_symbol();
|
|
|
|
|
|
|
|
if (symbol == Clutter.Escape) {
|
2012-08-24 12:24:49 -04:00
|
|
|
if (this._searchActive)
|
2012-06-21 18:52:56 -04:00
|
|
|
this.reset();
|
2012-08-15 06:20:24 -04:00
|
|
|
else if (this._showAppsButton.checked)
|
2013-02-16 12:50:25 -05:00
|
|
|
this._showAppsButton.checked = false;
|
2012-06-21 18:52:56 -04:00
|
|
|
else
|
|
|
|
Main.overview.hide();
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_STOP;
|
2013-02-22 14:56:24 -05:00
|
|
|
} else if (this._shouldTriggerSearch(symbol)) {
|
2012-06-21 18:52:56 -04:00
|
|
|
this.startSearch(event);
|
2014-05-23 11:14:20 -04:00
|
|
|
} else if (!this._searchActive && !global.stage.key_focus) {
|
2014-02-18 19:44:58 -05:00
|
|
|
if (symbol == Clutter.Tab || symbol == Clutter.Down) {
|
|
|
|
this._activePage.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
|
2014-06-10 14:25:16 -04:00
|
|
|
return Clutter.EVENT_STOP;
|
2014-02-18 19:44:58 -05:00
|
|
|
} else if (symbol == Clutter.ISO_Left_Tab) {
|
|
|
|
this._activePage.navigate_focus(null, Gtk.DirectionType.TAB_BACKWARD, false);
|
2014-06-10 14:25:16 -04:00
|
|
|
return Clutter.EVENT_STOP;
|
2014-02-18 19:44:58 -05:00
|
|
|
}
|
2012-06-21 18:52:56 -04:00
|
|
|
}
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2012-06-21 18:52:56 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_searchCancelled() {
|
2012-06-21 18:52:56 -04:00
|
|
|
this._showPage(this._showAppsButton.checked ? this._appsPage
|
|
|
|
: this._workspacesPage);
|
2010-11-18 07:51:47 -05:00
|
|
|
|
2011-04-07 19:10:24 -04:00
|
|
|
// Leave the entry focused when it doesn't have any text;
|
|
|
|
// when replacing a selected search term, Clutter emits
|
|
|
|
// two 'text-changed' signals, one for deleting the previous
|
|
|
|
// text and one for the new one - the second one is handled
|
|
|
|
// incorrectly when we remove focus
|
|
|
|
// (https://bugzilla.gnome.org/show_bug.cgi?id=636341) */
|
|
|
|
if (this._text.text != '')
|
2012-02-27 09:17:33 -05:00
|
|
|
this.reset();
|
2011-02-16 13:20:03 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
reset() {
|
2011-02-16 13:27:05 -05:00
|
|
|
global.stage.set_key_focus(null);
|
2011-02-16 13:20:03 -05:00
|
|
|
|
2012-02-27 09:17:33 -05:00
|
|
|
this._entry.text = '';
|
|
|
|
|
2011-02-16 13:20:03 -05:00
|
|
|
this._text.set_cursor_visible(true);
|
|
|
|
this._text.set_selection(0, 0);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onStageKeyFocusChanged() {
|
2011-02-16 13:20:03 -05:00
|
|
|
let focus = global.stage.get_key_focus();
|
2012-03-09 23:50:17 -05:00
|
|
|
let appearFocused = (this._entry.contains(focus) ||
|
|
|
|
this._searchResults.actor.contains(focus));
|
2012-02-27 12:43:59 -05:00
|
|
|
|
2012-03-09 23:50:17 -05:00
|
|
|
this._text.set_cursor_visible(appearFocused);
|
|
|
|
|
|
|
|
if (appearFocused)
|
|
|
|
this._entry.add_style_pseudo_class('focus');
|
|
|
|
else
|
|
|
|
this._entry.remove_style_pseudo_class('focus');
|
2011-02-16 13:20:03 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onMapped() {
|
2011-02-16 13:20:03 -05:00
|
|
|
if (this._entry.mapped) {
|
|
|
|
// Enable 'find-as-you-type'
|
|
|
|
this._capturedEventId = global.stage.connect('captured-event',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onCapturedEvent.bind(this));
|
2011-02-16 13:20:03 -05:00
|
|
|
this._text.set_cursor_visible(true);
|
|
|
|
this._text.set_selection(0, 0);
|
|
|
|
} else {
|
|
|
|
// Disable 'find-as-you-type'
|
|
|
|
if (this._capturedEventId > 0)
|
|
|
|
global.stage.disconnect(this._capturedEventId);
|
|
|
|
this._capturedEventId = 0;
|
|
|
|
}
|
2010-11-18 07:51:47 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_shouldTriggerSearch(symbol) {
|
2015-08-07 09:16:58 -04:00
|
|
|
if (symbol == Clutter.Multi_key)
|
|
|
|
return true;
|
|
|
|
|
2015-08-07 08:37:04 -04:00
|
|
|
if (symbol == Clutter.BackSpace && this._searchActive)
|
|
|
|
return true;
|
|
|
|
|
2013-02-22 14:56:24 -05:00
|
|
|
let unicode = Clutter.keysym_to_unicode(symbol);
|
|
|
|
if (unicode == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (getTermsForSearchString(String.fromCharCode(unicode)).length > 0)
|
|
|
|
return true;
|
|
|
|
|
2015-08-07 08:37:04 -04:00
|
|
|
return false;
|
2013-02-22 14:56:24 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
startSearch(event) {
|
2011-02-16 13:27:05 -05:00
|
|
|
global.stage.set_key_focus(this._text);
|
2014-07-09 06:06:40 -04:00
|
|
|
|
|
|
|
let synthEvent = event.copy();
|
|
|
|
synthEvent.set_source(this._text);
|
2018-02-27 17:34:09 -05:00
|
|
|
this._text.event(synthEvent, false);
|
2011-02-16 13:27:05 -05:00
|
|
|
},
|
|
|
|
|
2011-02-16 13:20:03 -05:00
|
|
|
// the entry does not show the hint
|
2017-10-30 20:03:21 -04:00
|
|
|
_isActivated() {
|
2011-02-16 13:20:03 -05:00
|
|
|
return this._text.text == this._entry.get_text();
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onTextChanged(se, prop) {
|
2013-02-08 21:05:15 -05:00
|
|
|
let terms = getTermsForSearchString(this._entry.get_text());
|
|
|
|
|
|
|
|
this._searchActive = (terms.length > 0);
|
2014-09-11 17:15:50 -04:00
|
|
|
this._searchResults.setTerms(terms);
|
2012-08-24 12:24:49 -04:00
|
|
|
|
|
|
|
if (this._searchActive) {
|
2014-09-11 17:15:50 -04:00
|
|
|
this._showPage(this._searchPage);
|
|
|
|
|
2013-03-03 13:56:12 -05:00
|
|
|
this._entry.set_secondary_icon(this._clearIcon);
|
2011-02-16 13:20:03 -05:00
|
|
|
|
2012-08-24 12:24:49 -04:00
|
|
|
if (this._iconClickedId == 0)
|
2011-02-16 13:20:03 -05:00
|
|
|
this._iconClickedId = this._entry.connect('secondary-icon-clicked',
|
2017-12-01 19:27:35 -05:00
|
|
|
this.reset.bind(this));
|
2010-11-18 07:51:47 -05:00
|
|
|
} else {
|
2012-08-24 12:24:49 -04:00
|
|
|
if (this._iconClickedId > 0) {
|
2011-02-16 13:20:03 -05:00
|
|
|
this._entry.disconnect(this._iconClickedId);
|
2012-08-24 12:24:49 -04:00
|
|
|
this._iconClickedId = 0;
|
|
|
|
}
|
2011-02-16 13:20:03 -05:00
|
|
|
|
2013-03-03 13:56:12 -05:00
|
|
|
this._entry.set_secondary_icon(null);
|
2012-08-24 12:24:49 -04:00
|
|
|
this._searchCancelled();
|
2010-11-18 07:51:47 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onKeyPress(entry, event) {
|
2010-11-18 07:51:47 -05:00
|
|
|
let symbol = event.get_key_symbol();
|
2011-11-13 22:13:26 -05:00
|
|
|
if (symbol == Clutter.Escape) {
|
2011-02-16 13:27:05 -05:00
|
|
|
if (this._isActivated()) {
|
2012-02-27 09:17:33 -05:00
|
|
|
this.reset();
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_STOP;
|
2011-02-16 13:27:05 -05:00
|
|
|
}
|
2012-08-24 12:24:49 -04:00
|
|
|
} else if (this._searchActive) {
|
2012-03-09 21:40:46 -05:00
|
|
|
let arrowNext, nextDirection;
|
|
|
|
if (entry.get_text_direction() == Clutter.TextDirection.RTL) {
|
|
|
|
arrowNext = Clutter.Left;
|
|
|
|
nextDirection = Gtk.DirectionType.LEFT;
|
|
|
|
} else {
|
|
|
|
arrowNext = Clutter.Right;
|
|
|
|
nextDirection = Gtk.DirectionType.RIGHT;
|
|
|
|
}
|
|
|
|
|
2011-11-11 23:40:56 -05:00
|
|
|
if (symbol == Clutter.Tab) {
|
2011-11-13 22:13:26 -05:00
|
|
|
this._searchResults.navigateFocus(Gtk.DirectionType.TAB_FORWARD);
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_STOP;
|
2011-11-11 23:40:56 -05:00
|
|
|
} else if (symbol == Clutter.ISO_Left_Tab) {
|
|
|
|
this._focusTrap.can_focus = false;
|
2011-11-13 22:13:26 -05:00
|
|
|
this._searchResults.navigateFocus(Gtk.DirectionType.TAB_BACKWARD);
|
2011-11-11 23:40:56 -05:00
|
|
|
this._focusTrap.can_focus = true;
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_STOP;
|
2012-03-09 21:40:46 -05:00
|
|
|
} else if (symbol == Clutter.Down) {
|
|
|
|
this._searchResults.navigateFocus(Gtk.DirectionType.DOWN);
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_STOP;
|
2012-03-09 21:40:46 -05:00
|
|
|
} else if (symbol == arrowNext && this._text.position == -1) {
|
|
|
|
this._searchResults.navigateFocus(nextDirection);
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_STOP;
|
2013-01-27 14:00:59 -05:00
|
|
|
} else if (symbol == Clutter.Return || symbol == Clutter.KP_Enter) {
|
|
|
|
this._searchResults.activateDefault();
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_STOP;
|
2011-11-11 23:40:56 -05:00
|
|
|
}
|
2010-11-18 07:51:47 -05:00
|
|
|
}
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2010-11-18 07:51:47 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onCapturedEvent(actor, event) {
|
2011-02-16 13:27:05 -05:00
|
|
|
if (event.type() == Clutter.EventType.BUTTON_PRESS) {
|
|
|
|
let source = event.get_source();
|
2015-02-26 13:21:52 -05:00
|
|
|
if (source != this._text &&
|
|
|
|
this._text.text == '' &&
|
|
|
|
!this._text.has_preedit () &&
|
2011-10-09 16:24:59 -04:00
|
|
|
!Main.layoutManager.keyboardBox.contains(source)) {
|
2011-02-16 13:20:03 -05:00
|
|
|
// the user clicked outside after activating the entry, but
|
2011-10-09 16:24:59 -04:00
|
|
|
// with no search term entered and no keyboard button pressed
|
|
|
|
// - cancel the search
|
2012-02-27 09:17:33 -05:00
|
|
|
this.reset();
|
2011-02-16 13:27:05 -05:00
|
|
|
}
|
2011-02-16 13:20:03 -05:00
|
|
|
}
|
2011-02-16 13:44:03 -05:00
|
|
|
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2011-02-16 13:20:03 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
getActivePage() {
|
2013-02-13 16:13:14 -05:00
|
|
|
if (this._activePage == this._workspacesPage)
|
|
|
|
return ViewPage.WINDOWS;
|
|
|
|
else if (this._activePage == this._appsPage)
|
|
|
|
return ViewPage.APPS;
|
|
|
|
else
|
|
|
|
return ViewPage.SEARCH;
|
2013-02-17 23:45:24 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
fadeIn() {
|
2013-02-17 23:45:24 -05:00
|
|
|
let actor = this._activePage;
|
|
|
|
Tweener.addTween(actor, { opacity: 255,
|
|
|
|
time: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME / 2,
|
|
|
|
transition: 'easeInQuad'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
fadeHalf() {
|
2013-02-17 23:45:24 -05:00
|
|
|
let actor = this._activePage;
|
|
|
|
Tweener.addTween(actor, { opacity: 128,
|
|
|
|
time: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME / 2,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
2010-11-12 12:45:29 -05:00
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2010-11-12 12:45:29 -05:00
|
|
|
Signals.addSignalMethods(ViewSelector.prototype);
|