2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2019-01-31 14:07:06 +00:00
|
|
|
/* exported ViewSelector */
|
2010-11-12 17:45:29 +00:00
|
|
|
|
2021-01-02 20:41:54 +00:00
|
|
|
const { Clutter, GObject, Meta, Shell, St } = imports.gi;
|
2010-11-12 17:45:29 +00:00
|
|
|
const Signals = imports.signals;
|
|
|
|
|
2012-07-28 20:06:46 +00:00
|
|
|
const AppDisplay = imports.ui.appDisplay;
|
2010-11-12 17:45:29 +00:00
|
|
|
const Main = imports.ui.main;
|
2013-01-24 06:35:19 +00:00
|
|
|
const OverviewControls = imports.ui.overviewControls;
|
2010-11-12 17:45:29 +00:00
|
|
|
const Search = imports.ui.search;
|
2011-10-11 22:38:24 +00:00
|
|
|
const ShellEntry = imports.ui.shellEntry;
|
2021-01-25 20:50:59 +00:00
|
|
|
const Util = imports.misc.util;
|
|
|
|
const WorkspaceThumbnail = imports.ui.workspaceThumbnail;
|
2012-07-28 20:06:46 +00:00
|
|
|
const WorkspacesView = imports.ui.workspacesView;
|
2010-11-12 17:45:29 +00:00
|
|
|
|
2012-10-08 16:16:55 +00:00
|
|
|
const SHELL_KEYBINDINGS_SCHEMA = 'org.gnome.shell.keybindings';
|
2017-07-18 17:47:27 +00:00
|
|
|
var PINCH_GESTURE_THRESHOLD = 0.7;
|
2010-11-12 17:45:29 +00:00
|
|
|
|
2017-07-18 17:47:27 +00:00
|
|
|
var ViewPage = {
|
2020-12-12 15:57:15 +00:00
|
|
|
ACTIVITIES: 1,
|
|
|
|
SEARCH: 2,
|
2013-02-13 21:13:14 +00:00
|
|
|
};
|
|
|
|
|
2017-10-31 01:23:39 +00:00
|
|
|
var FocusTrap = GObject.registerClass(
|
|
|
|
class FocusTrap extends St.Widget {
|
2017-10-31 00:03:21 +00:00
|
|
|
vfunc_navigate_focus(from, direction) {
|
2018-11-27 12:58:25 +00:00
|
|
|
if (direction == St.DirectionType.TAB_FORWARD ||
|
|
|
|
direction == St.DirectionType.TAB_BACKWARD)
|
2017-10-31 01:23:39 +00:00
|
|
|
return super.vfunc_navigate_focus(from, direction);
|
2012-03-10 00:33:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-02-09 02:05:15 +00:00
|
|
|
function getTermsForSearchString(searchString) {
|
|
|
|
searchString = searchString.replace(/^\s+/g, '').replace(/\s+$/g, '');
|
|
|
|
if (searchString == '')
|
|
|
|
return [];
|
|
|
|
|
|
|
|
let terms = searchString.split(/\s+/);
|
|
|
|
return terms;
|
|
|
|
}
|
2012-03-10 00:33:31 +00:00
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
var TouchpadShowOverviewAction = class {
|
|
|
|
constructor(actor) {
|
2020-01-10 07:44:35 +00:00
|
|
|
actor.connect('captured-event::touchpad', this._handleEvent.bind(this));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2016-04-15 15:48:25 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_handleEvent(actor, event) {
|
2016-04-15 15:48:25 +00: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)
|
2019-08-19 17:55:49 +00:00
|
|
|
this.emit('activated', event.get_gesture_pinch_scale());
|
2016-04-15 15:48:25 +00:00
|
|
|
|
|
|
|
return Clutter.EVENT_STOP;
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
};
|
2016-04-15 15:48:25 +00:00
|
|
|
Signals.addSignalMethods(TouchpadShowOverviewAction.prototype);
|
|
|
|
|
2017-10-31 01:23:39 +00:00
|
|
|
var ShowOverviewAction = GObject.registerClass({
|
2017-03-21 17:47:36 +00:00
|
|
|
Signals: { 'activated': { param_types: [GObject.TYPE_DOUBLE] } },
|
2017-10-31 01:23:39 +00:00
|
|
|
}, class ShowOverviewAction extends Clutter.GestureAction {
|
2017-10-31 00:03:21 +00:00
|
|
|
_init() {
|
2017-10-31 01:23:39 +00:00
|
|
|
super._init();
|
2014-06-25 16:12:04 +00:00
|
|
|
this.set_n_touch_points(3);
|
|
|
|
|
2017-10-31 00:38:18 +00:00
|
|
|
global.display.connect('grab-op-begin', () => {
|
2014-06-25 16:12:04 +00:00
|
|
|
this.cancel();
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2014-06-25 16:12:04 +00:00
|
|
|
|
2019-01-31 14:08:10 +00:00
|
|
|
vfunc_gesture_prepare(_actor) {
|
2014-12-11 14:35:40 +00:00
|
|
|
return Main.actionMode == Shell.ActionMode.NORMAL &&
|
2014-11-27 19:46:50 +00:00
|
|
|
this.get_n_current_points() == this.get_n_touch_points();
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2014-06-25 16:12:04 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_getBoundingRect(motion) {
|
2014-06-25 16:12:04 +00:00
|
|
|
let minX, minY, maxX, maxY;
|
|
|
|
|
|
|
|
for (let i = 0; i < this.get_n_current_points(); i++) {
|
|
|
|
let x, y;
|
|
|
|
|
2019-08-20 00:51:42 +00:00
|
|
|
if (motion == true)
|
2014-06-25 16:12:04 +00:00
|
|
|
[x, y] = this.get_motion_coords(i);
|
2019-08-20 00:51:42 +00:00
|
|
|
else
|
2014-06-25 16:12:04 +00:00
|
|
|
[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-31 01:23:39 +00:00
|
|
|
}
|
2014-06-25 16:12:04 +00:00
|
|
|
|
2019-01-31 14:08:10 +00:00
|
|
|
vfunc_gesture_begin(_actor) {
|
2014-06-25 16:12:04 +00:00
|
|
|
this._initialRect = this._getBoundingRect(false);
|
|
|
|
return true;
|
2017-10-31 01:23:39 +00:00
|
|
|
}
|
2014-06-25 16:12:04 +00:00
|
|
|
|
2019-01-31 14:08:10 +00:00
|
|
|
vfunc_gesture_end(_actor) {
|
2014-06-25 16:12:04 +00: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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-12-12 15:57:15 +00:00
|
|
|
var ActivitiesContainer = GObject.registerClass(
|
|
|
|
class ActivitiesContainer extends St.Widget {
|
2020-12-30 20:45:09 +00:00
|
|
|
_init(thumbnailsBox, workspacesDisplay, appDisplay, overviewAdjustment) {
|
2020-12-12 15:57:15 +00:00
|
|
|
super._init();
|
|
|
|
|
|
|
|
// 0 for window picker, 1 for app grid
|
|
|
|
this._adjustment = new St.Adjustment({
|
|
|
|
actor: this,
|
|
|
|
value: 0,
|
|
|
|
lower: 0,
|
|
|
|
upper: 1,
|
|
|
|
});
|
|
|
|
this._adjustment.connect('notify::value', () => {
|
|
|
|
this._update();
|
|
|
|
this.queue_relayout();
|
|
|
|
});
|
|
|
|
|
2020-12-30 20:45:09 +00:00
|
|
|
overviewAdjustment.connect('notify::value', () => {
|
2021-01-02 19:06:34 +00:00
|
|
|
const { ControlsState } = OverviewControls;
|
|
|
|
|
|
|
|
const overviewState = overviewAdjustment.value;
|
|
|
|
|
|
|
|
this._appDisplay.visible =
|
|
|
|
overviewState >= ControlsState.WINDOW_PICKER;
|
|
|
|
this._adjustment.value = Math.max(0,
|
|
|
|
overviewAdjustment.value - ControlsState.WINDOW_PICKER);
|
2020-12-30 20:45:09 +00:00
|
|
|
});
|
2020-12-12 15:57:15 +00:00
|
|
|
|
2021-01-25 20:50:59 +00:00
|
|
|
this._thumbnailsBox = thumbnailsBox;
|
|
|
|
this.add_child(thumbnailsBox);
|
|
|
|
|
2020-12-12 15:57:15 +00:00
|
|
|
this._appDisplay = appDisplay;
|
|
|
|
this.add_child(appDisplay);
|
|
|
|
|
|
|
|
this._workspacesDisplay = workspacesDisplay;
|
|
|
|
this.add_child(workspacesDisplay);
|
|
|
|
|
|
|
|
this.connect('notify::mapped', () => {
|
|
|
|
workspacesDisplay.setPrimaryWorkspaceVisible(this.mapped);
|
|
|
|
});
|
|
|
|
|
|
|
|
this._update();
|
|
|
|
}
|
|
|
|
|
|
|
|
_update() {
|
|
|
|
const progress = this._adjustment.value;
|
|
|
|
|
|
|
|
this._appDisplay.opacity = progress * 255;
|
2021-01-25 20:50:59 +00:00
|
|
|
|
|
|
|
this._thumbnailsBox.set({
|
|
|
|
scale_x: Util.lerp(1, 0.5, progress),
|
|
|
|
scale_y: Util.lerp(1, 0.5, progress),
|
|
|
|
translation_y: Util.lerp(0, this._thumbnailsBox.height, progress),
|
|
|
|
opacity: Util.lerp(0, 255, 1 - progress),
|
|
|
|
visible: (1 - progress) !== 0,
|
|
|
|
});
|
2020-12-29 21:51:40 +00:00
|
|
|
|
|
|
|
const { fitModeAdjustment } = this._workspacesDisplay;
|
|
|
|
fitModeAdjustment.value = Util.lerp(
|
|
|
|
WorkspacesView.FitMode.SINGLE,
|
|
|
|
WorkspacesView.FitMode.ALL,
|
|
|
|
progress);
|
2020-12-12 15:57:15 +00:00
|
|
|
}
|
|
|
|
|
2021-01-25 20:50:59 +00:00
|
|
|
_getWorkspacesBoxes(box, thumbnailsHeight) {
|
2020-12-12 15:57:15 +00:00
|
|
|
const initialBox = box.copy();
|
2021-01-25 20:50:59 +00:00
|
|
|
initialBox.y1 += thumbnailsHeight;
|
2020-12-12 15:57:15 +00:00
|
|
|
|
|
|
|
const finalBox = box.copy();
|
|
|
|
finalBox.set_size(
|
|
|
|
box.get_width(),
|
|
|
|
Math.round(box.get_height() * 0.15));
|
|
|
|
|
|
|
|
return [initialBox, finalBox];
|
|
|
|
}
|
|
|
|
|
|
|
|
vfunc_allocate(box) {
|
|
|
|
this.set_allocation(box);
|
|
|
|
|
2021-01-25 20:50:59 +00:00
|
|
|
// Workspace Thumbnails
|
|
|
|
let thumbnailsHeight = 0;
|
|
|
|
if (this._thumbnailsBox.visible) {
|
|
|
|
const maxThumbnailScale = WorkspaceThumbnail.MAX_THUMBNAIL_SCALE;
|
|
|
|
const primaryMonitor = Main.layoutManager.primaryMonitor;
|
|
|
|
const [width, height] = box.get_size();
|
|
|
|
|
|
|
|
[, thumbnailsHeight] =
|
|
|
|
this._thumbnailsBox.get_preferred_height(width);
|
|
|
|
thumbnailsHeight = Math.min(
|
|
|
|
thumbnailsHeight,
|
|
|
|
(primaryMonitor ? primaryMonitor.height : height) * maxThumbnailScale);
|
|
|
|
|
|
|
|
const thumbnailsBox = new Clutter.ActorBox();
|
|
|
|
thumbnailsBox.set_origin(0, 0);
|
|
|
|
thumbnailsBox.set_size(width, thumbnailsHeight);
|
|
|
|
this._thumbnailsBox.allocate(thumbnailsBox);
|
|
|
|
}
|
|
|
|
|
2020-12-12 15:57:15 +00:00
|
|
|
const progress = this._adjustment.value;
|
2021-01-25 20:50:59 +00:00
|
|
|
const [initialBox, finalBox] =
|
|
|
|
this._getWorkspacesBoxes(box, thumbnailsHeight);
|
2020-12-12 15:57:15 +00:00
|
|
|
const workspacesBox = initialBox.interpolate(finalBox, progress);
|
|
|
|
this._workspacesDisplay.allocate(workspacesBox);
|
|
|
|
|
|
|
|
if (this._appDisplay.visible) {
|
|
|
|
const appDisplayBox = box.copy();
|
|
|
|
appDisplayBox.y1 += Math.ceil(finalBox.get_height());
|
|
|
|
this._appDisplay.allocate(appDisplayBox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
var ViewSelector = GObject.registerClass({
|
|
|
|
Signals: {
|
|
|
|
'page-changed': {},
|
|
|
|
'page-empty': {},
|
2019-08-20 21:43:54 +00:00
|
|
|
},
|
2019-07-16 09:24:13 +00:00
|
|
|
}, class ViewSelector extends Shell.Stack {
|
2020-12-30 20:45:09 +00:00
|
|
|
_init(searchEntry, workspaceAdjustment, showAppsButton, overviewAdjustment) {
|
2019-10-21 18:44:00 +00:00
|
|
|
super._init({
|
|
|
|
name: 'viewSelector',
|
|
|
|
x_expand: true,
|
2021-01-29 14:38:08 +00:00
|
|
|
y_expand: true,
|
2020-06-02 17:21:02 +00:00
|
|
|
visible: false,
|
2019-10-21 18:44:00 +00:00
|
|
|
});
|
2012-06-21 22:52:56 +00:00
|
|
|
|
|
|
|
this._showAppsButton = showAppsButton;
|
2017-12-02 00:27:35 +00:00
|
|
|
this._showAppsButton.connect('notify::checked', this._onShowAppsButtonToggled.bind(this));
|
2012-06-21 22:52:56 +00:00
|
|
|
|
2012-06-21 22:52:56 +00:00
|
|
|
this._activePage = null;
|
2010-11-18 12:51:47 +00:00
|
|
|
|
2012-08-24 16:24:49 +00:00
|
|
|
this._searchActive = false;
|
2010-11-18 12:51:47 +00:00
|
|
|
|
2012-07-28 20:47:55 +00:00
|
|
|
this._entry = searchEntry;
|
2011-10-11 22:38:24 +00:00
|
|
|
ShellEntry.addContextMenu(this._entry);
|
2012-06-21 22:52:56 +00:00
|
|
|
|
2011-02-16 18:20:03 +00:00
|
|
|
this._text = this._entry.clutter_text;
|
2017-12-02 00:27:35 +00:00
|
|
|
this._text.connect('text-changed', this._onTextChanged.bind(this));
|
|
|
|
this._text.connect('key-press-event', this._onKeyPress.bind(this));
|
2017-10-31 00:38:18 +00:00
|
|
|
this._text.connect('key-focus-in', () => {
|
2012-06-21 22:52:56 +00:00
|
|
|
this._searchResults.highlightDefault(true);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
|
|
|
this._text.connect('key-focus-out', () => {
|
2012-06-21 22:52:56 +00:00
|
|
|
this._searchResults.highlightDefault(false);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2017-08-15 23:25:15 +00:00
|
|
|
this._entry.connect('popup-menu', () => {
|
|
|
|
if (!this._searchActive)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._entry.menu.close();
|
|
|
|
this._searchResults.popupMenuDefault();
|
|
|
|
});
|
2017-12-02 00:27:35 +00:00
|
|
|
this._entry.connect('notify::mapped', this._onMapped.bind(this));
|
|
|
|
global.stage.connect('notify::key-focus', this._onStageKeyFocusChanged.bind(this));
|
2011-02-16 18:20:03 +00:00
|
|
|
|
2013-03-03 18:56:12 +00:00
|
|
|
this._entry.set_primary_icon(new St.Icon({ style_class: 'search-entry-icon',
|
|
|
|
icon_name: 'edit-find-symbolic' }));
|
2014-09-05 16:56:21 +00:00
|
|
|
this._clearIcon = new St.Icon({ style_class: 'search-entry-icon',
|
|
|
|
icon_name: 'edit-clear-symbolic' });
|
2011-02-16 18:20:03 +00:00
|
|
|
|
|
|
|
this._iconClickedId = 0;
|
2012-06-21 22:52:56 +00:00
|
|
|
this._capturedEventId = 0;
|
2011-02-16 18:20:03 +00:00
|
|
|
|
2021-01-25 20:50:59 +00:00
|
|
|
this._thumbnailsBox =
|
|
|
|
new WorkspaceThumbnail.ThumbnailsBox(workspaceAdjustment);
|
2019-07-08 08:03:20 +00:00
|
|
|
this._workspacesDisplay =
|
2021-01-02 19:06:34 +00:00
|
|
|
new WorkspacesView.WorkspacesDisplay(workspaceAdjustment, overviewAdjustment);
|
2011-07-09 13:30:42 +00:00
|
|
|
this.appDisplay = new AppDisplay.AppDisplay();
|
2020-12-12 15:57:15 +00:00
|
|
|
|
|
|
|
const activitiesContainer = new ActivitiesContainer(
|
2021-01-25 20:50:59 +00:00
|
|
|
this._thumbnailsBox,
|
|
|
|
this._workspacesDisplay,
|
|
|
|
this.appDisplay,
|
2020-12-30 20:45:09 +00:00
|
|
|
overviewAdjustment);
|
2020-12-12 15:57:15 +00:00
|
|
|
this._activitiesPage =
|
|
|
|
this._addPage(activitiesContainer, _('Activities'), 'view-app-grid-symbolic');
|
2011-02-16 18:20:03 +00:00
|
|
|
|
2021-01-27 15:55:20 +00:00
|
|
|
Main.ctrlAltTabManager.addGroup(
|
|
|
|
this.appDisplay,
|
|
|
|
_('Applications'),
|
|
|
|
'edit-find-symbolic', {
|
|
|
|
proxy: this,
|
|
|
|
focusCallback: () => {
|
|
|
|
this._showPage(this._activitiesPage);
|
|
|
|
this._showAppsButton.checked = true;
|
|
|
|
this.appDisplay.navigate_focus(
|
|
|
|
null, St.DirectionType.TAB_FORWARD, false);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
Main.ctrlAltTabManager.addGroup(
|
|
|
|
this._workspacesDisplay,
|
|
|
|
_('Windows'),
|
|
|
|
'focus-windows-symbolic', {
|
|
|
|
proxy: this,
|
|
|
|
focusCallback: () => {
|
|
|
|
this._showPage(this._activitiesPage);
|
|
|
|
this._showAppsButton.checked = false;
|
|
|
|
this._workspacesDisplay.navigate_focus(
|
|
|
|
null, St.DirectionType.TAB_FORWARD, false);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2019-10-16 09:31:44 +00:00
|
|
|
this._searchResults = new Search.SearchResultsView();
|
2021-01-27 15:55:20 +00:00
|
|
|
this._searchPage = this._addPage(this._searchResults);
|
|
|
|
Main.ctrlAltTabManager.addGroup(this._entry, _('Search'), 'edit-find-symbolic');
|
2011-02-16 18:20:03 +00:00
|
|
|
|
2011-11-12 04:40:56 +00: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-10 00:33:31 +00:00
|
|
|
// include the entry in the keynav tab path
|
|
|
|
this._focusTrap = new FocusTrap({ can_focus: true });
|
2017-10-31 00:38:18 +00:00
|
|
|
this._focusTrap.connect('key-focus-in', () => {
|
2011-11-12 04:40:56 +00:00
|
|
|
this._entry.grab_key_focus();
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2019-07-16 09:24:13 +00:00
|
|
|
this._searchResults.add_actor(this._focusTrap);
|
2011-11-12 04:40:56 +00:00
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
global.focus_manager.add_group(this._searchResults);
|
2012-06-21 22:52:56 +00:00
|
|
|
|
|
|
|
this._stageKeyPressId = 0;
|
2017-10-31 00:38:18 +00:00
|
|
|
Main.overview.connect('showing', () => {
|
|
|
|
this._stageKeyPressId = global.stage.connect('key-press-event',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._onStageKeyPress.bind(this));
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
|
|
|
Main.overview.connect('hiding', () => {
|
|
|
|
if (this._stageKeyPressId != 0) {
|
|
|
|
global.stage.disconnect(this._stageKeyPressId);
|
|
|
|
this._stageKeyPressId = 0;
|
|
|
|
}
|
|
|
|
});
|
2012-06-21 22:52:56 +00:00
|
|
|
|
2021-01-05 13:33:59 +00:00
|
|
|
let gesture = new ShowOverviewAction();
|
2017-12-02 00:27:35 +00:00
|
|
|
gesture.connect('activated', this._pinchGestureActivated.bind(this));
|
2014-06-25 16:12:04 +00:00
|
|
|
global.stage.add_action(gesture);
|
2016-04-15 15:48:25 +00:00
|
|
|
|
|
|
|
gesture = new TouchpadShowOverviewAction(global.stage);
|
2017-12-02 00:27:35 +00:00
|
|
|
gesture.connect('activated', this._pinchGestureActivated.bind(this));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2016-04-15 15:48:25 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_pinchGestureActivated(action, scale) {
|
2016-04-15 15:48:25 +00:00
|
|
|
if (scale < PINCH_GESTURE_THRESHOLD)
|
|
|
|
Main.overview.show();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-10-08 16:16:55 +00:00
|
|
|
|
2021-01-02 19:17:17 +00:00
|
|
|
prepareToEnterOverview() {
|
2020-06-02 17:21:02 +00:00
|
|
|
this.show();
|
2013-02-16 17:54:19 +00:00
|
|
|
this.reset();
|
2021-01-02 19:17:17 +00:00
|
|
|
this._workspacesDisplay.prepareToEnterOverview();
|
2013-11-20 17:06:14 +00:00
|
|
|
this._activePage = null;
|
2020-12-12 15:57:15 +00:00
|
|
|
this._showPage(this._activitiesPage);
|
2012-06-21 22:52:56 +00:00
|
|
|
|
|
|
|
if (!this._workspacesDisplay.activeWorkspaceHasMaximizedWindows())
|
|
|
|
Main.overview.fadeOutDesktop();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-06-21 22:52:56 +00:00
|
|
|
|
2021-01-02 19:17:17 +00:00
|
|
|
prepareToLeaveOverview() {
|
|
|
|
this._workspacesDisplay.prepareToLeaveOverview();
|
2014-07-14 17:06:08 +00:00
|
|
|
|
2012-06-21 22:52:56 +00:00
|
|
|
if (!this._workspacesDisplay.activeWorkspaceHasMaximizedWindows())
|
|
|
|
Main.overview.fadeInDesktop();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-02-25 23:11:59 +00:00
|
|
|
|
2020-06-02 17:21:02 +00:00
|
|
|
vfunc_hide() {
|
2018-08-23 14:11:10 +00:00
|
|
|
this.reset();
|
2012-06-21 22:52:56 +00:00
|
|
|
this._workspacesDisplay.hide();
|
2020-06-02 17:21:02 +00:00
|
|
|
|
|
|
|
super.vfunc_hide();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-06-21 22:52:56 +00:00
|
|
|
|
2021-01-27 15:55:20 +00:00
|
|
|
_addPage(actor) {
|
2019-10-17 21:40:24 +00:00
|
|
|
let page = new St.Bin({ child: actor });
|
2013-11-20 17:06:14 +00:00
|
|
|
page.hide();
|
2019-07-16 09:24:13 +00:00
|
|
|
this.add_actor(page);
|
2012-11-01 13:45:04 +00:00
|
|
|
return page;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-06-21 22:52:56 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_fadePageIn() {
|
2018-07-20 19:46:19 +00:00
|
|
|
this._activePage.ease({
|
|
|
|
opacity: 255,
|
|
|
|
duration: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
|
2019-08-20 21:43:54 +00:00
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
2018-07-20 19:46:19 +00:00
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2014-06-17 17:10:54 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_fadePageOut(page) {
|
2014-06-17 17:10:54 +00:00
|
|
|
let oldPage = page;
|
2018-07-20 19:46:19 +00:00
|
|
|
page.ease({
|
|
|
|
opacity: 0,
|
|
|
|
duration: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
2019-08-20 21:43:54 +00:00
|
|
|
onStopped: () => this._animateIn(oldPage),
|
2018-07-20 19:46:19 +00:00
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2014-06-17 17:10:54 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_animateIn(oldPage) {
|
2013-02-16 17:59:54 +00:00
|
|
|
if (oldPage)
|
|
|
|
oldPage.hide();
|
|
|
|
|
2013-02-16 01:43:45 +00:00
|
|
|
this.emit('page-empty');
|
2014-02-19 00:44:58 +00:00
|
|
|
|
2020-12-12 15:57:15 +00:00
|
|
|
if (this._activePage) {
|
|
|
|
this._activePage.show();
|
2014-06-17 17:10:54 +00:00
|
|
|
this._fadePageIn();
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2014-06-17 17:10:54 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_animateOut(page) {
|
2020-12-12 15:57:15 +00:00
|
|
|
this._fadePageOut(page);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-01-24 06:35:19 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_showPage(page) {
|
2014-07-14 17:06:08 +00:00
|
|
|
if (!Main.overview.visible)
|
|
|
|
return;
|
|
|
|
|
2013-01-24 21:35:11 +00:00
|
|
|
if (page == this._activePage)
|
2012-06-21 22:52:56 +00:00
|
|
|
return;
|
2012-06-21 22:52:56 +00:00
|
|
|
|
2013-01-24 21:35:11 +00:00
|
|
|
let oldPage = this._activePage;
|
2013-01-24 06:35:19 +00:00
|
|
|
this._activePage = page;
|
|
|
|
this.emit('page-changed');
|
|
|
|
|
2014-07-14 16:55:34 +00:00
|
|
|
if (oldPage)
|
2019-01-29 01:18:52 +00:00
|
|
|
this._animateOut(oldPage);
|
2013-01-24 06:35:19 +00:00
|
|
|
else
|
2014-06-17 17:10:54 +00:00
|
|
|
this._animateIn();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-06-21 22:52:56 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onShowAppsButtonToggled() {
|
2020-12-12 15:57:15 +00:00
|
|
|
this._showPage(this._activitiesPage);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-06-21 22:52:56 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onStageKeyPress(actor, event) {
|
2012-11-12 17:41:14 +00:00
|
|
|
// Ignore events while anything but the overview has
|
|
|
|
// pushed a modal (system modals, looking glass, ...)
|
|
|
|
if (Main.modalCount > 1)
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2012-11-12 17:41:14 +00:00
|
|
|
|
2012-06-21 22:52:56 +00:00
|
|
|
let symbol = event.get_key_symbol();
|
|
|
|
|
2019-11-05 19:37:28 +00:00
|
|
|
if (symbol === Clutter.KEY_Escape) {
|
2012-08-24 16:24:49 +00:00
|
|
|
if (this._searchActive)
|
2012-06-21 22:52:56 +00:00
|
|
|
this.reset();
|
2012-08-15 10:20:24 +00:00
|
|
|
else if (this._showAppsButton.checked)
|
2013-02-16 17:50:25 +00:00
|
|
|
this._showAppsButton.checked = false;
|
2012-06-21 22:52:56 +00:00
|
|
|
else
|
|
|
|
Main.overview.hide();
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_STOP;
|
2013-02-22 19:56:24 +00:00
|
|
|
} else if (this._shouldTriggerSearch(symbol)) {
|
2012-06-21 22:52:56 +00:00
|
|
|
this.startSearch(event);
|
2014-05-23 15:14:20 +00:00
|
|
|
} else if (!this._searchActive && !global.stage.key_focus) {
|
2019-11-05 19:37:28 +00:00
|
|
|
if (symbol === Clutter.KEY_Tab || symbol === Clutter.KEY_Down) {
|
2018-11-27 12:58:25 +00:00
|
|
|
this._activePage.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
|
2014-06-10 18:25:16 +00:00
|
|
|
return Clutter.EVENT_STOP;
|
2019-11-05 19:37:28 +00:00
|
|
|
} else if (symbol === Clutter.KEY_ISO_Left_Tab) {
|
2018-11-27 12:58:25 +00:00
|
|
|
this._activePage.navigate_focus(null, St.DirectionType.TAB_BACKWARD, false);
|
2014-06-10 18:25:16 +00:00
|
|
|
return Clutter.EVENT_STOP;
|
2014-02-19 00:44:58 +00:00
|
|
|
}
|
2012-06-21 22:52:56 +00:00
|
|
|
}
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-06-21 22:52:56 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_searchCancelled() {
|
2020-12-12 15:57:15 +00:00
|
|
|
this._showPage(this._activitiesPage);
|
2010-11-18 12:51:47 +00:00
|
|
|
|
2011-04-07 23:10:24 +00: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 14:17:33 +00:00
|
|
|
this.reset();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-02-16 18:20:03 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
reset() {
|
2018-10-04 13:05:44 +00:00
|
|
|
// Don't drop the key focus on Clutter's side if anything but the
|
|
|
|
// overview has pushed a modal (e.g. system modals when activated using
|
|
|
|
// the overview).
|
|
|
|
if (Main.modalCount <= 1)
|
|
|
|
global.stage.set_key_focus(null);
|
2011-02-16 18:20:03 +00:00
|
|
|
|
2012-02-27 14:17:33 +00:00
|
|
|
this._entry.text = '';
|
|
|
|
|
2011-02-16 18:20:03 +00:00
|
|
|
this._text.set_cursor_visible(true);
|
|
|
|
this._text.set_selection(0, 0);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-02-16 18:20:03 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onStageKeyFocusChanged() {
|
2011-02-16 18:20:03 +00:00
|
|
|
let focus = global.stage.get_key_focus();
|
2019-08-19 19:38:51 +00:00
|
|
|
let appearFocused = this._entry.contains(focus) ||
|
|
|
|
this._searchResults.contains(focus);
|
2012-02-27 17:43:59 +00:00
|
|
|
|
2012-03-10 04:50:17 +00:00
|
|
|
this._text.set_cursor_visible(appearFocused);
|
|
|
|
|
|
|
|
if (appearFocused)
|
|
|
|
this._entry.add_style_pseudo_class('focus');
|
|
|
|
else
|
|
|
|
this._entry.remove_style_pseudo_class('focus');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-02-16 18:20:03 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onMapped() {
|
2011-02-16 18:20:03 +00:00
|
|
|
if (this._entry.mapped) {
|
|
|
|
// Enable 'find-as-you-type'
|
|
|
|
this._capturedEventId = global.stage.connect('captured-event',
|
2019-01-29 19:36:54 +00:00
|
|
|
this._onCapturedEvent.bind(this));
|
2011-02-16 18:20:03 +00: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;
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-11-18 12:51:47 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_shouldTriggerSearch(symbol) {
|
2019-11-05 19:37:28 +00:00
|
|
|
if (symbol === Clutter.KEY_Multi_key)
|
2015-08-07 13:16:58 +00:00
|
|
|
return true;
|
|
|
|
|
2019-11-05 19:37:28 +00:00
|
|
|
if (symbol === Clutter.KEY_BackSpace && this._searchActive)
|
2015-08-07 12:37:04 +00:00
|
|
|
return true;
|
|
|
|
|
2013-02-22 19:56:24 +00: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 12:37:04 +00:00
|
|
|
return false;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-02-22 19:56:24 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
startSearch(event) {
|
2011-02-16 18:27:05 +00:00
|
|
|
global.stage.set_key_focus(this._text);
|
2014-07-09 10:06:40 +00:00
|
|
|
|
|
|
|
let synthEvent = event.copy();
|
|
|
|
synthEvent.set_source(this._text);
|
2018-02-27 22:34:09 +00:00
|
|
|
this._text.event(synthEvent, false);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-02-16 18:27:05 +00:00
|
|
|
|
2011-02-16 18:20:03 +00:00
|
|
|
// the entry does not show the hint
|
2017-10-31 00:03:21 +00:00
|
|
|
_isActivated() {
|
2011-02-16 18:20:03 +00:00
|
|
|
return this._text.text == this._entry.get_text();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-02-16 18:20:03 +00:00
|
|
|
|
2019-02-04 11:30:53 +00:00
|
|
|
_onTextChanged() {
|
2013-02-09 02:05:15 +00:00
|
|
|
let terms = getTermsForSearchString(this._entry.get_text());
|
|
|
|
|
2019-08-19 19:38:51 +00:00
|
|
|
this._searchActive = terms.length > 0;
|
2014-09-11 21:15:50 +00:00
|
|
|
this._searchResults.setTerms(terms);
|
2012-08-24 16:24:49 +00:00
|
|
|
|
|
|
|
if (this._searchActive) {
|
2014-09-11 21:15:50 +00:00
|
|
|
this._showPage(this._searchPage);
|
|
|
|
|
2013-03-03 18:56:12 +00:00
|
|
|
this._entry.set_secondary_icon(this._clearIcon);
|
2011-02-16 18:20:03 +00:00
|
|
|
|
2019-08-20 00:51:42 +00:00
|
|
|
if (this._iconClickedId == 0) {
|
2011-02-16 18:20:03 +00:00
|
|
|
this._iconClickedId = this._entry.connect('secondary-icon-clicked',
|
2019-01-29 19:36:54 +00:00
|
|
|
this.reset.bind(this));
|
2019-08-20 00:51:42 +00:00
|
|
|
}
|
2010-11-18 12:51:47 +00:00
|
|
|
} else {
|
2012-08-24 16:24:49 +00:00
|
|
|
if (this._iconClickedId > 0) {
|
2011-02-16 18:20:03 +00:00
|
|
|
this._entry.disconnect(this._iconClickedId);
|
2012-08-24 16:24:49 +00:00
|
|
|
this._iconClickedId = 0;
|
|
|
|
}
|
2011-02-16 18:20:03 +00:00
|
|
|
|
2013-03-03 18:56:12 +00:00
|
|
|
this._entry.set_secondary_icon(null);
|
2012-08-24 16:24:49 +00:00
|
|
|
this._searchCancelled();
|
2010-11-18 12:51:47 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-11-18 12:51:47 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onKeyPress(entry, event) {
|
2010-11-18 12:51:47 +00:00
|
|
|
let symbol = event.get_key_symbol();
|
2019-11-05 19:37:28 +00:00
|
|
|
if (symbol === Clutter.KEY_Escape) {
|
2011-02-16 18:27:05 +00:00
|
|
|
if (this._isActivated()) {
|
2012-02-27 14:17:33 +00:00
|
|
|
this.reset();
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_STOP;
|
2011-02-16 18:27:05 +00:00
|
|
|
}
|
2012-08-24 16:24:49 +00:00
|
|
|
} else if (this._searchActive) {
|
2012-03-10 02:40:46 +00:00
|
|
|
let arrowNext, nextDirection;
|
|
|
|
if (entry.get_text_direction() == Clutter.TextDirection.RTL) {
|
2019-11-05 19:37:28 +00:00
|
|
|
arrowNext = Clutter.KEY_Left;
|
2018-11-27 12:58:25 +00:00
|
|
|
nextDirection = St.DirectionType.LEFT;
|
2012-03-10 02:40:46 +00:00
|
|
|
} else {
|
2019-11-05 19:37:28 +00:00
|
|
|
arrowNext = Clutter.KEY_Right;
|
2018-11-27 12:58:25 +00:00
|
|
|
nextDirection = St.DirectionType.RIGHT;
|
2012-03-10 02:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-11-05 19:37:28 +00:00
|
|
|
if (symbol === Clutter.KEY_Tab) {
|
2018-11-27 12:58:25 +00:00
|
|
|
this._searchResults.navigateFocus(St.DirectionType.TAB_FORWARD);
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_STOP;
|
2019-11-05 19:37:28 +00:00
|
|
|
} else if (symbol === Clutter.KEY_ISO_Left_Tab) {
|
2011-11-12 04:40:56 +00:00
|
|
|
this._focusTrap.can_focus = false;
|
2018-11-27 12:58:25 +00:00
|
|
|
this._searchResults.navigateFocus(St.DirectionType.TAB_BACKWARD);
|
2011-11-12 04:40:56 +00:00
|
|
|
this._focusTrap.can_focus = true;
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_STOP;
|
2019-11-05 19:37:28 +00:00
|
|
|
} else if (symbol === Clutter.KEY_Down) {
|
2018-11-27 12:58:25 +00:00
|
|
|
this._searchResults.navigateFocus(St.DirectionType.DOWN);
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_STOP;
|
2012-03-10 02:40:46 +00:00
|
|
|
} else if (symbol == arrowNext && this._text.position == -1) {
|
|
|
|
this._searchResults.navigateFocus(nextDirection);
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_STOP;
|
2019-11-05 19:37:28 +00:00
|
|
|
} else if (symbol === Clutter.KEY_Return || symbol === Clutter.KEY_KP_Enter) {
|
2013-01-27 19:00:59 +00:00
|
|
|
this._searchResults.activateDefault();
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_STOP;
|
2011-11-12 04:40:56 +00:00
|
|
|
}
|
2010-11-18 12:51:47 +00:00
|
|
|
}
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-11-18 12:51:47 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onCapturedEvent(actor, event) {
|
2011-02-16 18:27:05 +00:00
|
|
|
if (event.type() == Clutter.EventType.BUTTON_PRESS) {
|
|
|
|
let source = event.get_source();
|
2015-02-26 18:21:52 +00:00
|
|
|
if (source != this._text &&
|
2019-08-18 10:49:42 +00:00
|
|
|
this._text.has_key_focus() &&
|
2015-02-26 18:21:52 +00:00
|
|
|
this._text.text == '' &&
|
2019-08-19 17:55:49 +00:00
|
|
|
!this._text.has_preedit() &&
|
2011-10-09 20:24:59 +00:00
|
|
|
!Main.layoutManager.keyboardBox.contains(source)) {
|
2011-02-16 18:20:03 +00:00
|
|
|
// the user clicked outside after activating the entry, but
|
2011-10-09 20:24:59 +00:00
|
|
|
// with no search term entered and no keyboard button pressed
|
|
|
|
// - cancel the search
|
2012-02-27 14:17:33 +00:00
|
|
|
this.reset();
|
2011-02-16 18:27:05 +00:00
|
|
|
}
|
2011-02-16 18:20:03 +00:00
|
|
|
}
|
2011-02-16 18:44:03 +00:00
|
|
|
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-02-16 18:20:03 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
getActivePage() {
|
2020-12-12 15:57:15 +00:00
|
|
|
if (this._activePage === this._activitiesPage)
|
|
|
|
return ViewPage.ACTIVITIES;
|
2013-02-13 21:13:14 +00:00
|
|
|
else
|
|
|
|
return ViewPage.SEARCH;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2019-07-16 09:24:13 +00:00
|
|
|
});
|