2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2019-07-16 09:24:13 +00:00
|
|
|
/* exported WorkspacesView, WorkspacesDisplay */
|
2010-01-22 02:33:48 +00:00
|
|
|
|
2019-10-16 05:39:48 +00:00
|
|
|
const { Clutter, Gio, GLib, GObject, Meta, Shell, St } = imports.gi;
|
2010-01-22 02:33:48 +00:00
|
|
|
|
|
|
|
const Main = imports.ui.main;
|
2019-07-08 08:47:04 +00:00
|
|
|
const SwipeTracker = imports.ui.swipeTracker;
|
2020-12-29 21:05:29 +00:00
|
|
|
const Util = imports.misc.util;
|
2010-01-22 02:33:48 +00:00
|
|
|
const Workspace = imports.ui.workspace;
|
|
|
|
|
2020-06-25 17:54:54 +00:00
|
|
|
var { ANIMATION_TIME } = imports.ui.overview;
|
2019-08-01 23:13:10 +00:00
|
|
|
var WORKSPACE_SWITCH_TIME = 250;
|
2010-01-22 02:33:48 +00:00
|
|
|
|
2018-11-08 09:47:25 +00:00
|
|
|
const MUTTER_SCHEMA = 'org.gnome.mutter';
|
2010-03-16 15:51:24 +00:00
|
|
|
|
2020-12-29 21:05:29 +00:00
|
|
|
const WORKSPACE_MIN_SPACING = 24;
|
|
|
|
const WORKSPACE_MAX_SPACING = 80;
|
|
|
|
|
2020-12-31 17:19:43 +00:00
|
|
|
const WORKSPACE_INACTIVE_SCALE = 0.94;
|
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
var WorkspacesViewBase = GObject.registerClass({
|
2019-08-20 21:43:54 +00:00
|
|
|
GTypeFlags: GObject.TypeFlags.ABSTRACT,
|
2019-07-16 09:24:13 +00:00
|
|
|
}, class WorkspacesViewBase extends St.Widget {
|
|
|
|
_init(monitorIndex) {
|
2020-06-25 23:15:33 +00:00
|
|
|
const { x, y, width, height } =
|
2020-06-25 23:08:29 +00:00
|
|
|
Main.layoutManager.getWorkAreaForMonitor(monitorIndex);
|
2020-06-25 23:15:33 +00:00
|
|
|
|
|
|
|
super._init({
|
|
|
|
style_class: 'workspaces-view',
|
|
|
|
x, y, width, height,
|
|
|
|
});
|
2019-07-16 09:24:13 +00:00
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
|
|
|
global.focus_manager.add_group(this);
|
2010-01-22 02:33:48 +00:00
|
|
|
|
2013-09-11 16:12:42 +00:00
|
|
|
this._monitorIndex = monitorIndex;
|
2010-02-18 15:43:58 +00:00
|
|
|
|
2013-09-11 16:12:42 +00:00
|
|
|
this._inDrag = false;
|
2017-12-02 00:27:35 +00:00
|
|
|
this._windowDragBeginId = Main.overview.connect('window-drag-begin', this._dragBegin.bind(this));
|
|
|
|
this._windowDragEndId = Main.overview.connect('window-drag-end', this._dragEnd.bind(this));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-09-11 16:12:42 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onDestroy() {
|
2013-09-11 16:12:42 +00:00
|
|
|
this._dragEnd();
|
|
|
|
|
|
|
|
if (this._windowDragBeginId > 0) {
|
|
|
|
Main.overview.disconnect(this._windowDragBeginId);
|
|
|
|
this._windowDragBeginId = 0;
|
|
|
|
}
|
|
|
|
if (this._windowDragEndId > 0) {
|
|
|
|
Main.overview.disconnect(this._windowDragEndId);
|
|
|
|
this._windowDragEndId = 0;
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-09-11 16:12:42 +00:00
|
|
|
|
2020-06-03 00:22:40 +00:00
|
|
|
_dragBegin() {
|
2013-09-11 16:12:42 +00:00
|
|
|
this._inDrag = true;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-09-11 16:12:42 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_dragEnd() {
|
2013-09-11 16:12:42 +00:00
|
|
|
this._inDrag = false;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-09-11 16:12:42 +00:00
|
|
|
|
2020-06-03 16:17:54 +00:00
|
|
|
vfunc_allocate(box) {
|
|
|
|
this.set_allocation(box);
|
|
|
|
|
|
|
|
for (const child of this)
|
|
|
|
child.allocate_available_size(0, 0, box.get_width(), box.get_height());
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2019-07-16 09:24:13 +00:00
|
|
|
});
|
2013-09-11 16:12:42 +00:00
|
|
|
|
2020-12-29 21:05:29 +00:00
|
|
|
var FitMode = {
|
|
|
|
SINGLE: 0,
|
|
|
|
ALL: 1,
|
|
|
|
};
|
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
var WorkspacesView = GObject.registerClass(
|
|
|
|
class WorkspacesView extends WorkspacesViewBase {
|
2020-12-29 21:05:29 +00:00
|
|
|
_init(monitorIndex, scrollAdjustment, fitModeAdjustment) {
|
2018-01-03 07:55:38 +00:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
super._init(monitorIndex);
|
2020-08-31 19:11:18 +00:00
|
|
|
this.clip_to_allocation = true;
|
2013-09-11 14:09:13 +00:00
|
|
|
|
2020-12-29 21:05:29 +00:00
|
|
|
this._fitModeAdjustment = fitModeAdjustment;
|
|
|
|
this._fitModeNotifyId = this._fitModeAdjustment.connect('notify::value', () => {
|
|
|
|
this._updateVisibility();
|
2020-12-31 17:19:43 +00:00
|
|
|
this._updateWorkspacesState();
|
2020-12-29 21:05:29 +00:00
|
|
|
this.queue_relayout();
|
|
|
|
});
|
|
|
|
|
2010-11-12 09:28:28 +00:00
|
|
|
this._animating = false; // tweening
|
2019-03-20 17:19:01 +00:00
|
|
|
this._gestureActive = false; // touch(pad) gestures
|
2010-01-22 02:33:48 +00:00
|
|
|
|
2019-07-07 17:51:55 +00:00
|
|
|
this._scrollAdjustment = scrollAdjustment;
|
2020-06-26 14:04:44 +00:00
|
|
|
this._onScrollId = this._scrollAdjustment.connect('notify::value',
|
2020-12-18 15:21:58 +00:00
|
|
|
this._onScrollAdjustmentChanged.bind(this));
|
2010-01-22 02:33:48 +00:00
|
|
|
|
2013-09-11 14:09:13 +00:00
|
|
|
this._workspaces = [];
|
|
|
|
this._updateWorkspaces();
|
2018-01-03 07:55:38 +00:00
|
|
|
this._updateWorkspacesId =
|
|
|
|
workspaceManager.connect('notify::n-workspaces',
|
|
|
|
this._updateWorkspaces.bind(this));
|
2019-07-09 12:03:22 +00:00
|
|
|
this._reorderWorkspacesId =
|
|
|
|
workspaceManager.connect('workspaces-reordered', () => {
|
|
|
|
this._workspaces.sort((a, b) => {
|
|
|
|
return a.metaWorkspace.index() - b.metaWorkspace.index();
|
|
|
|
});
|
2020-06-26 14:04:44 +00:00
|
|
|
this._workspaces.forEach(
|
|
|
|
(ws, i) => this.set_child_at_index(ws, i));
|
2019-07-09 12:03:22 +00:00
|
|
|
});
|
|
|
|
|
2010-01-22 02:33:48 +00:00
|
|
|
this._switchWorkspaceNotifyId =
|
|
|
|
global.window_manager.connect('switch-workspace',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._activeWorkspaceChanged.bind(this));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-11-25 14:44:17 +00:00
|
|
|
|
2020-12-29 21:05:29 +00:00
|
|
|
_getFitAllBox(box, spacing, vertical) {
|
|
|
|
const { nWorkspaces } = global.workspaceManager;
|
|
|
|
const [width, height] = box.get_size();
|
|
|
|
const [workspace] = this._workspaces;
|
|
|
|
|
|
|
|
const fitAllBox = new Clutter.ActorBox();
|
|
|
|
|
|
|
|
let x1 = 0;
|
|
|
|
let y1 = 0;
|
|
|
|
|
|
|
|
// Spacing here is not only the space between workspaces, but also the
|
|
|
|
// space before the first workspace, and after the last one. This prevents
|
|
|
|
// workspaces from touching the edges of the allocation box.
|
|
|
|
if (vertical) {
|
|
|
|
const availableHeight = height - spacing * (nWorkspaces + 1);
|
|
|
|
let workspaceHeight = availableHeight / nWorkspaces;
|
|
|
|
let [, workspaceWidth] =
|
|
|
|
workspace.get_preferred_width(workspaceHeight);
|
|
|
|
|
|
|
|
y1 = spacing;
|
|
|
|
if (workspaceWidth > width) {
|
|
|
|
[, workspaceHeight] = workspace.get_preferred_height(width);
|
|
|
|
y1 += Math.max((availableHeight - workspaceHeight * nWorkspaces) / 2, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
fitAllBox.set_size(width, workspaceHeight);
|
|
|
|
} else {
|
|
|
|
const availableWidth = width - spacing * (nWorkspaces + 1);
|
|
|
|
let workspaceWidth = availableWidth / nWorkspaces;
|
|
|
|
let [, workspaceHeight] =
|
|
|
|
workspace.get_preferred_height(workspaceWidth);
|
|
|
|
|
|
|
|
x1 = spacing;
|
|
|
|
if (workspaceHeight > height) {
|
|
|
|
[, workspaceWidth] = workspace.get_preferred_width(height);
|
|
|
|
x1 += Math.max((availableWidth - workspaceWidth * nWorkspaces) / 2, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
fitAllBox.set_size(workspaceWidth, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
fitAllBox.set_origin(x1, y1);
|
|
|
|
|
|
|
|
return fitAllBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
_getFitSingleBox(box, spacing, vertical) {
|
|
|
|
const [width, height] = box.get_size();
|
|
|
|
const [workspace] = this._workspaces;
|
|
|
|
|
2020-12-30 15:44:00 +00:00
|
|
|
const rtl = this.text_direction === Clutter.TextDirection.RTL;
|
|
|
|
const adj = this._scrollAdjustment;
|
|
|
|
const currentWorkspace = vertical || !rtl
|
2021-02-09 09:17:29 +00:00
|
|
|
? adj.value : adj.upper - adj.value - 1;
|
2020-12-30 15:44:00 +00:00
|
|
|
|
2020-12-29 21:05:29 +00:00
|
|
|
// Single fit mode implies centered too
|
|
|
|
let x1 = 0;
|
|
|
|
let y1 = 0;
|
|
|
|
if (vertical) {
|
|
|
|
const [, workspaceHeight] = workspace.get_preferred_height(width);
|
|
|
|
y1 += (height - workspaceHeight) / 2;
|
2020-12-30 15:44:00 +00:00
|
|
|
y1 -= currentWorkspace * (workspaceHeight + spacing);
|
2020-12-29 21:05:29 +00:00
|
|
|
} else {
|
|
|
|
const [, workspaceWidth] = workspace.get_preferred_width(height);
|
|
|
|
x1 += (width - workspaceWidth) / 2;
|
2020-12-30 15:44:00 +00:00
|
|
|
x1 -= currentWorkspace * (workspaceWidth + spacing);
|
2020-12-29 21:05:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const fitSingleBox = new Clutter.ActorBox({ x1, y1 });
|
|
|
|
|
|
|
|
if (vertical) {
|
|
|
|
const [, workspaceHeight] = workspace.get_preferred_height(width);
|
|
|
|
fitSingleBox.set_size(width, workspaceHeight);
|
|
|
|
} else {
|
|
|
|
const [, workspaceWidth] = workspace.get_preferred_width(height);
|
|
|
|
fitSingleBox.set_size(workspaceWidth, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
return fitSingleBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
_getSpacing(box, fitMode, vertical) {
|
|
|
|
const [width, height] = box.get_size();
|
|
|
|
const [workspace] = this._workspaces;
|
|
|
|
|
|
|
|
let availableSpace;
|
|
|
|
let workspaceSize;
|
|
|
|
if (vertical) {
|
|
|
|
[, workspaceSize] = workspace.get_preferred_height(width);
|
|
|
|
availableSpace = (height - workspaceSize) / 2;
|
|
|
|
} else {
|
|
|
|
[, workspaceSize] = workspace.get_preferred_width(height);
|
|
|
|
availableSpace = (width - workspaceSize) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
const spacing = (availableSpace - workspaceSize * 0.05) * (1 - fitMode);
|
|
|
|
|
|
|
|
return Math.clamp(spacing, WORKSPACE_MIN_SPACING, WORKSPACE_MAX_SPACING);
|
|
|
|
}
|
|
|
|
|
2020-12-31 17:19:43 +00:00
|
|
|
_updateWorkspacesState() {
|
|
|
|
const adj = this._scrollAdjustment;
|
2021-01-01 16:10:19 +00:00
|
|
|
const fitMode = this._fitModeAdjustment.value;
|
2020-12-31 17:19:43 +00:00
|
|
|
|
|
|
|
// Fade and scale inactive workspaces
|
|
|
|
this._workspaces.forEach((w, index) => {
|
2021-01-01 16:10:19 +00:00
|
|
|
w.stateAdjustment.value = Util.lerp(1, 0, fitMode);
|
|
|
|
|
2020-12-31 17:19:43 +00:00
|
|
|
const distanceToCurrentWorkspace = Math.abs(adj.value - index);
|
|
|
|
|
|
|
|
const progress = 1 - Math.clamp(distanceToCurrentWorkspace, 0, 1);
|
|
|
|
|
|
|
|
const scale = Util.lerp(WORKSPACE_INACTIVE_SCALE, 1, progress);
|
|
|
|
w.set_scale(scale, scale);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-06-26 14:04:44 +00:00
|
|
|
vfunc_allocate(box) {
|
|
|
|
this.set_allocation(box);
|
|
|
|
|
|
|
|
if (this.get_n_children() === 0)
|
|
|
|
return;
|
|
|
|
|
2020-12-29 21:05:29 +00:00
|
|
|
const vertical = global.workspaceManager.layout_rows === -1;
|
2020-06-26 14:04:44 +00:00
|
|
|
const rtl = this.text_direction === Clutter.TextDirection.RTL;
|
|
|
|
|
2020-12-29 21:05:29 +00:00
|
|
|
const fitMode = this._fitModeAdjustment.value;
|
2020-12-11 18:57:49 +00:00
|
|
|
|
2020-12-29 21:05:29 +00:00
|
|
|
const fitSingleSpacing =
|
|
|
|
this._getSpacing(box, FitMode.SINGLE, vertical);
|
|
|
|
const fitSingleBox =
|
|
|
|
this._getFitSingleBox(box, fitSingleSpacing, vertical);
|
2020-06-26 14:04:44 +00:00
|
|
|
|
2020-12-29 21:05:29 +00:00
|
|
|
const fitAllSpacing =
|
|
|
|
this._getSpacing(box, FitMode.ALL, vertical);
|
|
|
|
const fitAllBox =
|
|
|
|
this._getFitAllBox(box, fitAllSpacing, vertical);
|
|
|
|
|
|
|
|
// Account for RTL locales by reversing the list
|
|
|
|
const workspaces = this._workspaces.slice();
|
|
|
|
if (rtl)
|
|
|
|
workspaces.reverse();
|
|
|
|
|
|
|
|
workspaces.forEach(child => {
|
|
|
|
if (fitMode === FitMode.SINGLE)
|
|
|
|
box = fitSingleBox;
|
|
|
|
else if (fitMode === FitMode.ALL)
|
|
|
|
box = fitAllBox;
|
|
|
|
else
|
|
|
|
box = fitSingleBox.interpolate(fitAllBox, fitMode);
|
|
|
|
|
|
|
|
child.allocate_align_fill(box, 0.5, 0.5, false, false);
|
|
|
|
|
|
|
|
if (vertical) {
|
|
|
|
fitSingleBox.set_origin(
|
|
|
|
fitSingleBox.x1,
|
|
|
|
fitSingleBox.y1 + fitSingleBox.get_height() + fitSingleSpacing);
|
|
|
|
fitAllBox.set_origin(
|
|
|
|
fitAllBox.x1,
|
|
|
|
fitAllBox.y1 + fitAllBox.get_height() + fitAllSpacing);
|
|
|
|
} else {
|
|
|
|
fitSingleBox.set_origin(
|
|
|
|
fitSingleBox.x1 + fitSingleBox.get_width() + fitSingleSpacing,
|
|
|
|
fitSingleBox.y1);
|
|
|
|
fitAllBox.set_origin(
|
|
|
|
fitAllBox.x1 + fitAllBox.get_width() + fitAllSpacing,
|
|
|
|
fitAllBox.y1);
|
|
|
|
}
|
2020-06-26 14:04:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
getActiveWorkspace() {
|
2018-01-03 07:55:38 +00:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let active = workspaceManager.get_active_workspace_index();
|
2010-07-15 14:21:32 +00:00
|
|
|
return this._workspaces[active];
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-07-15 14:21:32 +00:00
|
|
|
|
2020-06-28 12:42:44 +00:00
|
|
|
animateToOverview() {
|
2020-10-02 17:26:46 +00:00
|
|
|
this._updateVisibility();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-01-22 02:33:48 +00:00
|
|
|
|
2020-06-28 12:42:44 +00:00
|
|
|
animateFromOverview() {
|
|
|
|
for (let w = 0; w < this._workspaces.length; w++)
|
2021-01-01 16:10:19 +00:00
|
|
|
this._workspaces[w].prepareToLeaveOverview();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-02-18 15:43:58 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
syncStacking(stackIndices) {
|
2010-01-22 02:33:48 +00:00
|
|
|
for (let i = 0; i < this._workspaces.length; i++)
|
|
|
|
this._workspaces[i].syncStacking(stackIndices);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-01-22 02:33:48 +00:00
|
|
|
|
2020-06-26 14:04:44 +00:00
|
|
|
_scrollToActive() {
|
|
|
|
const { workspaceManager } = global;
|
|
|
|
const active = workspaceManager.get_active_workspace_index();
|
2010-03-22 23:01:44 +00:00
|
|
|
|
2020-06-26 14:04:44 +00:00
|
|
|
this._animating = true;
|
|
|
|
this._updateVisibility();
|
2010-02-10 05:56:36 +00:00
|
|
|
|
2020-06-26 14:04:44 +00:00
|
|
|
this._scrollAdjustment.remove_transition('value');
|
|
|
|
this._scrollAdjustment.ease(active, {
|
|
|
|
duration: WORKSPACE_SWITCH_TIME,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_CUBIC,
|
|
|
|
onComplete: () => {
|
|
|
|
this._animating = false;
|
|
|
|
this._updateVisibility();
|
|
|
|
},
|
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-02-11 14:52:49 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateVisibility() {
|
2018-01-03 07:55:38 +00:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let active = workspaceManager.get_active_workspace_index();
|
2010-02-11 14:52:49 +00:00
|
|
|
|
2020-12-30 15:44:00 +00:00
|
|
|
const fitMode = this._fitModeAdjustment.value;
|
|
|
|
const singleFitMode = fitMode === FitMode.SINGLE;
|
|
|
|
|
2010-03-22 23:01:44 +00:00
|
|
|
for (let w = 0; w < this._workspaces.length; w++) {
|
|
|
|
let workspace = this._workspaces[w];
|
2019-08-20 02:10:46 +00:00
|
|
|
|
2020-12-30 15:44:00 +00:00
|
|
|
if (this._animating || this._gestureActive || !singleFitMode)
|
2019-07-16 09:24:13 +00:00
|
|
|
workspace.show();
|
2019-08-20 02:10:46 +00:00
|
|
|
else
|
2020-12-29 21:05:29 +00:00
|
|
|
workspace.visible = Math.abs(w - active) <= 1;
|
2010-02-11 14:52:49 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-02-11 14:52:49 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateWorkspaces() {
|
2018-01-03 07:55:38 +00:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let newNumWorkspaces = workspaceManager.n_workspaces;
|
2013-09-11 14:09:13 +00:00
|
|
|
|
2014-01-03 18:04:06 +00:00
|
|
|
for (let j = 0; j < newNumWorkspaces; j++) {
|
2018-01-03 07:55:38 +00:00
|
|
|
let metaWorkspace = workspaceManager.get_workspace_by_index(j);
|
2014-01-03 18:04:06 +00:00
|
|
|
let workspace;
|
|
|
|
|
|
|
|
if (j >= this._workspaces.length) { /* added */
|
|
|
|
workspace = new Workspace.Workspace(metaWorkspace, this._monitorIndex);
|
2019-07-16 09:24:13 +00:00
|
|
|
this.add_actor(workspace);
|
2014-01-03 18:04:06 +00:00
|
|
|
this._workspaces[j] = workspace;
|
|
|
|
} else {
|
|
|
|
workspace = this._workspaces[j];
|
|
|
|
|
|
|
|
if (workspace.metaWorkspace != metaWorkspace) { /* removed */
|
|
|
|
workspace.destroy();
|
|
|
|
this._workspaces.splice(j, 1);
|
|
|
|
} /* else kept */
|
2011-06-01 12:47:51 +00:00
|
|
|
}
|
2010-01-22 02:33:48 +00:00
|
|
|
}
|
2013-09-11 14:09:13 +00:00
|
|
|
|
2020-09-29 16:38:40 +00:00
|
|
|
for (let j = this._workspaces.length - 1; j >= newNumWorkspaces; j--) {
|
|
|
|
this._workspaces[j].destroy();
|
|
|
|
this._workspaces.splice(j, 1);
|
|
|
|
}
|
2020-12-31 17:19:43 +00:00
|
|
|
|
|
|
|
this._updateWorkspacesState();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-01-22 02:33:48 +00:00
|
|
|
|
2019-01-31 14:08:10 +00:00
|
|
|
_activeWorkspaceChanged(_wm, _from, _to, _direction) {
|
2010-02-10 05:56:36 +00:00
|
|
|
if (this._scrolling)
|
|
|
|
return;
|
|
|
|
|
2020-06-26 14:04:44 +00:00
|
|
|
this._scrollToActive();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-01-22 02:33:48 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onDestroy() {
|
2017-10-31 01:19:44 +00:00
|
|
|
super._onDestroy();
|
2013-09-11 16:12:42 +00:00
|
|
|
|
2019-07-07 17:51:55 +00:00
|
|
|
this._scrollAdjustment.disconnect(this._onScrollId);
|
2020-12-29 21:05:29 +00:00
|
|
|
this._fitModeAdjustment.disconnect(this._fitModeNotifyId);
|
2010-11-12 09:28:28 +00:00
|
|
|
global.window_manager.disconnect(this._switchWorkspaceNotifyId);
|
2018-01-03 07:55:38 +00:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
workspaceManager.disconnect(this._updateWorkspacesId);
|
2019-07-09 12:03:22 +00:00
|
|
|
workspaceManager.disconnect(this._reorderWorkspacesId);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-03-16 15:51:24 +00:00
|
|
|
|
2019-03-20 17:19:01 +00:00
|
|
|
startTouchGesture() {
|
|
|
|
this._gestureActive = true;
|
2020-07-10 13:41:09 +00:00
|
|
|
|
|
|
|
this._updateVisibility();
|
2019-03-20 17:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
endTouchGesture() {
|
|
|
|
this._gestureActive = false;
|
|
|
|
|
|
|
|
// Make sure title captions etc are shown as necessary
|
2020-06-26 14:04:44 +00:00
|
|
|
this._scrollToActive();
|
2019-03-20 17:19:01 +00:00
|
|
|
this._updateVisibility();
|
|
|
|
}
|
|
|
|
|
2010-07-11 12:41:17 +00:00
|
|
|
// sync the workspaces' positions to the value of the scroll adjustment
|
2010-02-10 05:56:36 +00:00
|
|
|
// and change the active workspace if appropriate
|
2020-12-18 15:21:58 +00:00
|
|
|
_onScrollAdjustmentChanged() {
|
2020-06-26 14:04:44 +00:00
|
|
|
if (!this.has_allocation())
|
2010-02-10 05:56:36 +00:00
|
|
|
return;
|
|
|
|
|
2020-06-26 14:04:44 +00:00
|
|
|
const adj = this._scrollAdjustment;
|
|
|
|
const allowSwitch =
|
|
|
|
adj.get_transition('value') === null && !this._gestureActive;
|
|
|
|
|
2018-01-03 07:55:38 +00:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let active = workspaceManager.get_active_workspace_index();
|
2010-02-10 05:56:36 +00:00
|
|
|
let current = Math.round(adj.value);
|
|
|
|
|
2020-06-26 14:04:44 +00:00
|
|
|
if (allowSwitch && active !== current) {
|
2013-01-19 01:26:44 +00:00
|
|
|
if (!this._workspaces[current]) {
|
|
|
|
// The current workspace was destroyed. This could happen
|
|
|
|
// when you are on the last empty workspace, and consolidate
|
|
|
|
// windows using the thumbnail bar.
|
|
|
|
// In that case, the intended behavior is to stay on the empty
|
|
|
|
// workspace, which is the last one, so pick it.
|
|
|
|
current = this._workspaces.length - 1;
|
|
|
|
}
|
|
|
|
|
2010-02-14 23:32:57 +00:00
|
|
|
let metaWorkspace = this._workspaces[current].metaWorkspace;
|
2010-07-11 12:41:17 +00:00
|
|
|
metaWorkspace.activate(global.get_current_time());
|
2010-02-10 05:56:36 +00:00
|
|
|
}
|
|
|
|
|
2020-12-31 17:19:43 +00:00
|
|
|
this._updateWorkspacesState();
|
2020-12-30 15:44:00 +00:00
|
|
|
this.queue_relayout();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2019-07-16 09:24:13 +00:00
|
|
|
});
|
2010-10-04 14:42:11 +00:00
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
var ExtraWorkspaceView = GObject.registerClass(
|
|
|
|
class ExtraWorkspaceView extends WorkspacesViewBase {
|
|
|
|
_init(monitorIndex) {
|
|
|
|
super._init(monitorIndex);
|
2013-09-11 16:12:42 +00:00
|
|
|
this._workspace = new Workspace.Workspace(null, monitorIndex);
|
2019-07-16 09:24:13 +00:00
|
|
|
this.add_actor(this._workspace);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-09-11 16:12:42 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
getActiveWorkspace() {
|
2016-06-24 16:15:48 +00:00
|
|
|
return this._workspace;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2016-06-24 16:15:48 +00:00
|
|
|
|
2020-06-28 12:42:44 +00:00
|
|
|
animateToOverview() {
|
|
|
|
this._workspace.zoomToOverview();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-09-11 16:12:42 +00:00
|
|
|
|
2020-06-28 12:42:44 +00:00
|
|
|
animateFromOverview() {
|
|
|
|
this._workspace.zoomFromOverview();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-09-11 16:12:42 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
syncStacking(stackIndices) {
|
2013-09-11 16:12:42 +00:00
|
|
|
this._workspace.syncStacking(stackIndices);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-09-11 16:12:42 +00:00
|
|
|
|
2019-03-20 17:19:01 +00:00
|
|
|
startTouchGesture() {
|
|
|
|
}
|
|
|
|
|
|
|
|
endTouchGesture() {
|
|
|
|
}
|
2013-11-04 22:23:44 +00:00
|
|
|
});
|
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
var WorkspacesDisplay = GObject.registerClass(
|
|
|
|
class WorkspacesDisplay extends St.Widget {
|
2019-07-08 08:03:20 +00:00
|
|
|
_init(scrollAdjustment) {
|
2020-06-02 17:15:45 +00:00
|
|
|
super._init({
|
|
|
|
visible: false,
|
|
|
|
clip_to_allocation: true,
|
|
|
|
});
|
2019-07-16 09:24:13 +00:00
|
|
|
this.connect('notify::allocation', this._updateWorkspacesActualGeometry.bind(this));
|
2012-12-13 19:19:44 +00:00
|
|
|
|
2020-12-29 21:05:29 +00:00
|
|
|
this._fitModeAdjustment = new St.Adjustment({
|
|
|
|
actor: this,
|
|
|
|
value: FitMode.SINGLE,
|
|
|
|
lower: FitMode.SINGLE,
|
|
|
|
upper: FitMode.ALL,
|
|
|
|
});
|
|
|
|
|
2020-10-03 08:12:13 +00:00
|
|
|
Main.overview.connect('relayout',
|
|
|
|
() => this._updateWorkspacesActualGeometry());
|
|
|
|
|
2019-07-07 17:51:55 +00:00
|
|
|
let workspaceManager = global.workspace_manager;
|
2019-07-08 08:03:20 +00:00
|
|
|
this._scrollAdjustment = scrollAdjustment;
|
2019-07-07 17:51:55 +00:00
|
|
|
|
|
|
|
this._switchWorkspaceId =
|
|
|
|
global.window_manager.connect('switch-workspace',
|
|
|
|
this._activeWorkspaceChanged.bind(this));
|
|
|
|
|
|
|
|
this._reorderWorkspacesdId =
|
|
|
|
workspaceManager.connect('workspaces-reordered',
|
|
|
|
this._workspacesReordered.bind(this));
|
|
|
|
|
2019-07-08 08:47:04 +00:00
|
|
|
this._swipeTracker = new SwipeTracker.SwipeTracker(
|
|
|
|
Main.layoutManager.overviewGroup, Shell.ActionMode.OVERVIEW);
|
2021-02-07 20:06:02 +00:00
|
|
|
this._swipeTracker.allowLongSwipes = true;
|
2019-07-08 08:47:04 +00:00
|
|
|
this._swipeTracker.connect('begin', this._switchWorkspaceBegin.bind(this));
|
|
|
|
this._swipeTracker.connect('update', this._switchWorkspaceUpdate.bind(this));
|
|
|
|
this._swipeTracker.connect('end', this._switchWorkspaceEnd.bind(this));
|
2020-01-28 19:08:32 +00:00
|
|
|
this.connect('notify::mapped', this._updateSwipeTracker.bind(this));
|
|
|
|
|
|
|
|
this._windowDragBeginId =
|
|
|
|
Main.overview.connect('window-drag-begin',
|
|
|
|
this._windowDragBegin.bind(this));
|
|
|
|
this._windowDragEndId =
|
2020-12-27 19:33:34 +00:00
|
|
|
Main.overview.connect('window-drag-end',
|
2020-01-28 19:08:32 +00:00
|
|
|
this._windowDragEnd.bind(this));
|
2020-07-11 16:19:27 +00:00
|
|
|
this._overviewShownId = Main.overview.connect('shown', () => {
|
|
|
|
this._syncWorkspacesActualGeometry();
|
|
|
|
});
|
2019-03-20 17:19:01 +00:00
|
|
|
|
2020-06-05 05:23:53 +00:00
|
|
|
this._primaryVisible = true;
|
2011-11-25 17:25:31 +00:00
|
|
|
this._primaryIndex = Main.layoutManager.primaryIndex;
|
2012-12-16 23:46:34 +00:00
|
|
|
this._workspacesViews = [];
|
2011-11-25 17:25:31 +00:00
|
|
|
|
2018-11-08 09:47:25 +00:00
|
|
|
this._settings = new Gio.Settings({ schema_id: MUTTER_SCHEMA });
|
2011-11-25 17:25:31 +00:00
|
|
|
this._settings.connect('changed::workspaces-only-on-primary',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._workspacesOnlyOnPrimaryChanged.bind(this));
|
2011-11-25 17:25:31 +00:00
|
|
|
this._workspacesOnlyOnPrimaryChanged();
|
2011-01-31 01:35:58 +00:00
|
|
|
|
2011-11-25 23:02:13 +00:00
|
|
|
this._notifyOpacityId = 0;
|
2018-09-25 22:00:53 +00:00
|
|
|
this._restackedNotifyId = 0;
|
2012-10-22 15:39:46 +00:00
|
|
|
this._scrollEventId = 0;
|
2015-03-26 15:17:35 +00:00
|
|
|
this._keyPressEventId = 0;
|
2020-06-03 16:17:54 +00:00
|
|
|
this._syncActualGeometryLater = 0;
|
2013-02-25 23:25:27 +00:00
|
|
|
|
2020-05-20 10:05:04 +00:00
|
|
|
this._actualGeometry = null;
|
2020-01-28 19:08:32 +00:00
|
|
|
this._inWindowDrag = false;
|
2021-01-13 22:24:49 +00:00
|
|
|
this._leavingOverview = false;
|
2019-08-12 14:25:48 +00:00
|
|
|
|
2019-07-07 17:51:55 +00:00
|
|
|
this._gestureActive = false; // touch(pad) gestures
|
2020-12-30 22:59:02 +00:00
|
|
|
this._animating = false;
|
2019-07-07 17:51:55 +00:00
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
2019-08-12 14:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_onDestroy() {
|
|
|
|
if (this._notifyOpacityId) {
|
2019-07-16 09:24:13 +00:00
|
|
|
let parent = this.get_parent();
|
2019-08-12 14:25:48 +00:00
|
|
|
if (parent)
|
|
|
|
parent.disconnect(this._notifyOpacityId);
|
|
|
|
this._notifyOpacityId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._parentSetLater) {
|
|
|
|
Meta.later_remove(this._parentSetLater);
|
|
|
|
this._parentSetLater = 0;
|
|
|
|
}
|
2019-07-07 17:51:55 +00:00
|
|
|
|
2020-06-03 16:17:54 +00:00
|
|
|
if (this._syncActualGeometryLater) {
|
|
|
|
Meta.later_remove(this._syncActualGeometryLater);
|
|
|
|
this._syncActualGeometryLater = 0;
|
|
|
|
}
|
|
|
|
|
2019-07-07 17:51:55 +00:00
|
|
|
global.window_manager.disconnect(this._switchWorkspaceId);
|
|
|
|
global.workspace_manager.disconnect(this._reorderWorkspacesdId);
|
2020-01-28 19:08:32 +00:00
|
|
|
Main.overview.disconnect(this._windowDragBeginId);
|
|
|
|
Main.overview.disconnect(this._windowDragEndId);
|
2020-07-07 11:25:47 +00:00
|
|
|
Main.overview.disconnect(this._overviewShownId);
|
2020-01-28 19:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_windowDragBegin() {
|
|
|
|
this._inWindowDrag = true;
|
|
|
|
this._updateSwipeTracker();
|
|
|
|
}
|
|
|
|
|
|
|
|
_windowDragEnd() {
|
|
|
|
this._inWindowDrag = false;
|
|
|
|
this._updateSwipeTracker();
|
|
|
|
}
|
|
|
|
|
|
|
|
_updateSwipeTracker() {
|
2021-01-13 22:24:49 +00:00
|
|
|
this._swipeTracker.enabled =
|
|
|
|
this.mapped &&
|
|
|
|
!this._inWindowDrag &&
|
|
|
|
!this._leavingOverview;
|
2019-07-07 17:51:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_workspacesReordered() {
|
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
|
|
|
|
this._scrollAdjustment.value =
|
|
|
|
workspaceManager.get_active_workspace_index();
|
|
|
|
}
|
|
|
|
|
2020-06-25 22:25:22 +00:00
|
|
|
_activeWorkspaceChanged(_wm, _from, to, _direction) {
|
2019-07-08 08:47:04 +00:00
|
|
|
if (this._gestureActive)
|
2019-07-07 17:51:55 +00:00
|
|
|
return;
|
|
|
|
|
2020-06-25 22:25:22 +00:00
|
|
|
this._scrollAdjustment.ease(to, {
|
2019-07-08 08:47:04 +00:00
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_CUBIC,
|
2019-07-07 17:51:55 +00:00
|
|
|
duration: WORKSPACE_SWITCH_TIME,
|
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-10-19 11:55:18 +00:00
|
|
|
|
2019-07-08 08:47:04 +00:00
|
|
|
_directionForProgress(progress) {
|
|
|
|
if (global.workspace_manager.layout_rows === -1) {
|
|
|
|
return progress > 0
|
|
|
|
? Meta.MotionDirection.DOWN
|
|
|
|
: Meta.MotionDirection.UP;
|
|
|
|
} else if (this.text_direction === Clutter.TextDirection.RTL) {
|
|
|
|
return progress > 0
|
|
|
|
? Meta.MotionDirection.LEFT
|
|
|
|
: Meta.MotionDirection.RIGHT;
|
|
|
|
} else {
|
|
|
|
return progress > 0
|
|
|
|
? Meta.MotionDirection.RIGHT
|
|
|
|
: Meta.MotionDirection.LEFT;
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-11-26 04:40:48 +00:00
|
|
|
|
2019-07-08 08:47:04 +00:00
|
|
|
_switchWorkspaceBegin(tracker, monitor) {
|
|
|
|
if (this._workspacesOnlyOnPrimary && monitor !== this._primaryIndex)
|
|
|
|
return;
|
2019-03-20 17:19:01 +00:00
|
|
|
|
2019-07-08 08:47:04 +00:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let adjustment = this._scrollAdjustment;
|
|
|
|
if (this._gestureActive)
|
|
|
|
adjustment.remove_transition('value');
|
|
|
|
|
|
|
|
tracker.orientation = workspaceManager.layout_rows !== -1
|
|
|
|
? Clutter.Orientation.HORIZONTAL
|
|
|
|
: Clutter.Orientation.VERTICAL;
|
2019-03-20 17:19:01 +00:00
|
|
|
|
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].startTouchGesture();
|
|
|
|
|
2019-07-08 08:47:04 +00:00
|
|
|
let distance = global.workspace_manager.layout_rows === -1
|
2020-06-27 15:25:25 +00:00
|
|
|
? this.height : this.width;
|
2019-03-20 17:19:01 +00:00
|
|
|
|
2019-07-08 08:47:04 +00:00
|
|
|
let progress = adjustment.value / adjustment.page_size;
|
|
|
|
let points = Array.from(
|
|
|
|
{ length: workspaceManager.n_workspaces }, (v, i) => i);
|
2019-03-20 17:19:01 +00:00
|
|
|
|
2019-07-08 08:47:04 +00:00
|
|
|
tracker.confirmSwipe(distance, points, progress, Math.round(progress));
|
|
|
|
|
|
|
|
this._gestureActive = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
_switchWorkspaceUpdate(tracker, progress) {
|
2019-03-20 17:19:01 +00:00
|
|
|
let adjustment = this._scrollAdjustment;
|
2019-07-08 08:47:04 +00:00
|
|
|
adjustment.value = progress * adjustment.page_size;
|
2019-03-20 17:19:01 +00:00
|
|
|
}
|
|
|
|
|
2019-07-08 08:47:04 +00:00
|
|
|
_switchWorkspaceEnd(tracker, duration, endProgress) {
|
2019-03-20 17:19:01 +00:00
|
|
|
let workspaceManager = global.workspace_manager;
|
2019-07-08 08:47:04 +00:00
|
|
|
let newWs = workspaceManager.get_workspace_by_index(endProgress);
|
|
|
|
|
|
|
|
this._scrollAdjustment.ease(endProgress, {
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_CUBIC,
|
|
|
|
duration,
|
|
|
|
onComplete: () => {
|
2020-06-29 14:50:27 +00:00
|
|
|
if (!newWs.active)
|
2019-07-08 08:47:04 +00:00
|
|
|
newWs.activate(global.get_current_time());
|
|
|
|
this._endTouchGesture();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2019-03-20 17:19:01 +00:00
|
|
|
|
2019-07-08 08:47:04 +00:00
|
|
|
_endTouchGesture() {
|
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].endTouchGesture();
|
|
|
|
this._gestureActive = false;
|
2019-03-20 17:19:01 +00:00
|
|
|
}
|
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
vfunc_navigate_focus(from, direction) {
|
|
|
|
return this._getPrimaryView().navigate_focus(from, direction, false);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-11-04 22:23:44 +00:00
|
|
|
|
2020-06-05 05:23:53 +00:00
|
|
|
setPrimaryWorkspaceVisible(visible) {
|
|
|
|
if (this._primaryVisible === visible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._primaryVisible = visible;
|
|
|
|
|
|
|
|
const primaryIndex = Main.layoutManager.primaryIndex;
|
|
|
|
const primaryWorkspace = this._workspacesViews[primaryIndex];
|
|
|
|
if (primaryWorkspace)
|
|
|
|
primaryWorkspace.visible = visible;
|
|
|
|
}
|
|
|
|
|
2020-06-28 12:42:44 +00:00
|
|
|
animateToOverview() {
|
2020-06-02 17:15:45 +00:00
|
|
|
this.show();
|
2011-11-25 17:25:31 +00:00
|
|
|
this._updateWorkspacesViews();
|
2020-05-20 11:39:11 +00:00
|
|
|
|
2020-06-28 12:42:44 +00:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].animateToOverview();
|
2020-07-11 16:19:27 +00:00
|
|
|
|
2020-06-28 12:42:44 +00:00
|
|
|
if (this._actualGeometry)
|
2020-07-11 16:10:18 +00:00
|
|
|
this._syncWorkspacesActualGeometry();
|
|
|
|
|
2011-01-31 01:44:05 +00:00
|
|
|
this._restackedNotifyId =
|
2012-12-13 16:00:30 +00:00
|
|
|
Main.overview.connect('windows-restacked',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._onRestacked.bind(this));
|
2012-10-22 15:39:46 +00:00
|
|
|
if (this._scrollEventId == 0)
|
2017-12-02 00:27:35 +00:00
|
|
|
this._scrollEventId = Main.overview.connect('scroll-event', this._onScrollEvent.bind(this));
|
2015-03-26 15:17:35 +00:00
|
|
|
|
|
|
|
if (this._keyPressEventId == 0)
|
2017-12-02 00:27:35 +00:00
|
|
|
this._keyPressEventId = global.stage.connect('key-press-event', this._onKeyPressEvent.bind(this));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-10-04 14:42:11 +00:00
|
|
|
|
2020-06-28 12:42:44 +00:00
|
|
|
animateFromOverview() {
|
2020-12-30 22:59:02 +00:00
|
|
|
this._animating = true;
|
|
|
|
|
2020-06-28 12:42:44 +00:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].animateFromOverview();
|
2020-07-11 16:19:27 +00:00
|
|
|
|
2021-01-13 22:24:49 +00:00
|
|
|
this._leavingOverview = true;
|
|
|
|
this._updateSwipeTracker();
|
|
|
|
|
2020-07-07 11:06:29 +00:00
|
|
|
const { primaryIndex } = Main.layoutManager;
|
|
|
|
const { x, y, width, height } =
|
|
|
|
Main.layoutManager.getWorkAreaForMonitor(primaryIndex);
|
|
|
|
this._getPrimaryView().ease({
|
|
|
|
x, y, width, height,
|
2020-06-28 12:42:44 +00:00
|
|
|
duration: ANIMATION_TIME,
|
2020-07-07 11:06:29 +00:00
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
2020-12-30 22:59:02 +00:00
|
|
|
onStopped: () => (this._animating = false),
|
2020-07-07 11:06:29 +00:00
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-11-25 23:02:13 +00:00
|
|
|
|
2020-06-02 17:15:45 +00:00
|
|
|
vfunc_hide() {
|
2020-12-30 22:59:02 +00:00
|
|
|
this._animating = false;
|
|
|
|
|
2019-01-29 01:27:05 +00:00
|
|
|
if (this._restackedNotifyId > 0) {
|
2012-12-13 16:00:30 +00:00
|
|
|
Main.overview.disconnect(this._restackedNotifyId);
|
2011-01-31 01:44:05 +00:00
|
|
|
this._restackedNotifyId = 0;
|
|
|
|
}
|
2012-10-22 15:39:46 +00:00
|
|
|
if (this._scrollEventId > 0) {
|
|
|
|
Main.overview.disconnect(this._scrollEventId);
|
|
|
|
this._scrollEventId = 0;
|
|
|
|
}
|
2015-03-26 15:17:35 +00:00
|
|
|
if (this._keyPressEventId > 0) {
|
|
|
|
global.stage.disconnect(this._keyPressEventId);
|
|
|
|
this._keyPressEventId = 0;
|
|
|
|
}
|
2011-11-25 17:25:31 +00:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].destroy();
|
2012-12-16 23:46:34 +00:00
|
|
|
this._workspacesViews = [];
|
2020-06-02 17:15:45 +00:00
|
|
|
|
2021-01-13 22:24:49 +00:00
|
|
|
this._leavingOverview = false;
|
|
|
|
|
2020-06-02 17:15:45 +00:00
|
|
|
super.vfunc_hide();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-11-25 17:25:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_workspacesOnlyOnPrimaryChanged() {
|
2011-11-25 17:25:31 +00:00
|
|
|
this._workspacesOnlyOnPrimary = this._settings.get_boolean('workspaces-only-on-primary');
|
|
|
|
|
|
|
|
if (!Main.overview.visible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._updateWorkspacesViews();
|
2020-07-07 11:23:50 +00:00
|
|
|
this._syncWorkspacesActualGeometry();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-11-25 17:25:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateWorkspacesViews() {
|
2020-12-30 22:59:02 +00:00
|
|
|
this._animating = false;
|
|
|
|
|
2012-12-16 23:46:34 +00:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].destroy();
|
2011-11-25 17:25:31 +00:00
|
|
|
|
2015-02-04 14:35:34 +00:00
|
|
|
this._primaryIndex = Main.layoutManager.primaryIndex;
|
2011-11-25 17:25:31 +00:00
|
|
|
this._workspacesViews = [];
|
|
|
|
let monitors = Main.layoutManager.monitors;
|
|
|
|
for (let i = 0; i < monitors.length; i++) {
|
2013-09-11 16:12:42 +00:00
|
|
|
let view;
|
2011-11-25 17:25:31 +00:00
|
|
|
if (this._workspacesOnlyOnPrimary && i != this._primaryIndex)
|
2013-09-11 16:12:42 +00:00
|
|
|
view = new ExtraWorkspaceView(i);
|
|
|
|
else
|
2020-12-29 21:05:29 +00:00
|
|
|
view = new WorkspacesView(i, this._scrollAdjustment, this._fitModeAdjustment);
|
2011-11-25 17:25:31 +00:00
|
|
|
|
2011-11-28 16:51:53 +00:00
|
|
|
this._workspacesViews.push(view);
|
2019-07-16 09:24:13 +00:00
|
|
|
Main.layoutManager.overviewGroup.add_actor(view);
|
2010-10-04 14:42:11 +00:00
|
|
|
}
|
2020-06-05 05:23:53 +00:00
|
|
|
|
|
|
|
this._workspacesViews[this._primaryIndex].visible = this._primaryVisible;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-11-25 17:25:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_getMonitorIndexForEvent(event) {
|
2016-06-24 16:15:48 +00:00
|
|
|
let [x, y] = event.get_coords();
|
2019-08-19 19:06:04 +00:00
|
|
|
let rect = new Meta.Rectangle({ x, y, width: 1, height: 1 });
|
2018-01-03 07:55:38 +00:00
|
|
|
return global.display.get_monitor_index_for_rect(rect);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2016-06-24 16:15:48 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_getPrimaryView() {
|
2012-12-16 23:46:34 +00:00
|
|
|
if (!this._workspacesViews.length)
|
2011-11-25 17:25:31 +00:00
|
|
|
return null;
|
2013-09-11 16:12:42 +00:00
|
|
|
return this._workspacesViews[this._primaryIndex];
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-02-14 23:32:57 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
activeWorkspaceHasMaximizedWindows() {
|
2011-11-25 17:25:31 +00:00
|
|
|
return this._getPrimaryView().getActiveWorkspace().hasMaximizedWindows();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-11-25 23:02:13 +00:00
|
|
|
|
2019-09-10 05:42:48 +00:00
|
|
|
vfunc_parent_set(oldParent) {
|
2011-11-25 23:02:13 +00:00
|
|
|
if (oldParent && this._notifyOpacityId)
|
|
|
|
oldParent.disconnect(this._notifyOpacityId);
|
|
|
|
this._notifyOpacityId = 0;
|
|
|
|
|
2019-08-12 14:25:48 +00:00
|
|
|
if (this._parentSetLater)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._parentSetLater = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
|
|
|
|
this._parentSetLater = 0;
|
2019-07-16 09:24:13 +00:00
|
|
|
let newParent = this.get_parent();
|
2017-10-31 00:38:18 +00:00
|
|
|
if (!newParent)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// This is kinda hackish - we want the primary view to
|
2019-07-16 09:24:13 +00:00
|
|
|
// appear as parent of this, though in reality it
|
2017-10-31 00:38:18 +00:00
|
|
|
// is added directly to Main.layoutManager.overviewGroup
|
|
|
|
this._notifyOpacityId = newParent.connect('notify::opacity', () => {
|
2019-07-16 09:24:13 +00:00
|
|
|
let opacity = this.get_parent().opacity;
|
2017-10-31 00:38:18 +00:00
|
|
|
let primaryView = this._getPrimaryView();
|
|
|
|
if (!primaryView)
|
2011-11-25 23:02:13 +00:00
|
|
|
return;
|
2019-07-16 09:24:13 +00:00
|
|
|
primaryView.opacity = opacity;
|
|
|
|
primaryView.visible = opacity != 0;
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-11-25 23:02:13 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateWorkspacesActualGeometry() {
|
2020-05-20 10:05:04 +00:00
|
|
|
const [x, y] = this.get_transformed_position();
|
|
|
|
const width = this.allocation.get_width();
|
|
|
|
const height = this.allocation.get_height();
|
|
|
|
|
|
|
|
this._actualGeometry = { x, y, width, height };
|
2020-06-03 16:17:54 +00:00
|
|
|
|
|
|
|
if (this._syncActualGeometryLater > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._syncActualGeometryLater =
|
|
|
|
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
|
2020-12-30 22:59:02 +00:00
|
|
|
if (this._animating)
|
|
|
|
return GLib.SOURCE_CONTINUE;
|
|
|
|
|
2020-06-03 16:17:54 +00:00
|
|
|
this._syncWorkspacesActualGeometry();
|
|
|
|
|
|
|
|
this._syncActualGeometryLater = 0;
|
|
|
|
return GLib.SOURCE_REMOVE;
|
|
|
|
});
|
2020-05-20 10:05:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_syncWorkspacesActualGeometry() {
|
2020-06-25 23:15:33 +00:00
|
|
|
const primaryView = this._getPrimaryView();
|
2020-06-28 12:42:44 +00:00
|
|
|
if (!primaryView)
|
2013-02-25 23:34:17 +00:00
|
|
|
return;
|
|
|
|
|
2020-06-25 17:54:54 +00:00
|
|
|
primaryView.ease({
|
|
|
|
...this._actualGeometry,
|
|
|
|
duration: Main.overview.animationInProgress ? ANIMATION_TIME : 0,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-02-25 23:34:17 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onRestacked(overview, stackIndices) {
|
2011-11-25 17:25:31 +00:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].syncStacking(stackIndices);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-01-31 01:44:05 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onScrollEvent(actor, event) {
|
2019-07-08 08:47:04 +00:00
|
|
|
if (this._swipeTracker.canHandleScrollEvent(event))
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
if (!this.mapped)
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2016-05-26 16:51:30 +00:00
|
|
|
|
|
|
|
if (this._workspacesOnlyOnPrimary &&
|
|
|
|
this._getMonitorIndexForEvent(event) != this._primaryIndex)
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
2021-01-29 19:22:52 +00:00
|
|
|
return Main.wm.handleWorkspaceScroll(event);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2015-03-26 15:17:35 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onKeyPressEvent(actor, event) {
|
2019-07-16 09:24:13 +00:00
|
|
|
if (!this.mapped)
|
2015-03-26 15:17:35 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2018-01-03 07:55:38 +00:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let activeWs = workspaceManager.get_active_workspace();
|
2015-03-26 15:17:35 +00:00
|
|
|
let ws;
|
|
|
|
switch (event.get_key_symbol()) {
|
|
|
|
case Clutter.KEY_Page_Up:
|
|
|
|
ws = activeWs.get_neighbor(Meta.MotionDirection.UP);
|
|
|
|
break;
|
|
|
|
case Clutter.KEY_Page_Down:
|
|
|
|
ws = activeWs.get_neighbor(Meta.MotionDirection.DOWN);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
}
|
|
|
|
Main.wm.actionMoveWorkspace(ws);
|
|
|
|
return Clutter.EVENT_STOP;
|
2010-02-14 23:32:57 +00:00
|
|
|
}
|
2020-12-29 21:51:40 +00:00
|
|
|
|
|
|
|
get fitModeAdjustment() {
|
|
|
|
return this._fitModeAdjustment;
|
|
|
|
}
|
2019-07-16 09:24:13 +00:00
|
|
|
});
|