2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2019-07-16 05:24:13 -04:00
|
|
|
/* exported WorkspacesView, WorkspacesDisplay */
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2020-06-26 12:38:28 -04:00
|
|
|
const { Clutter, Gio, GObject, Meta, Shell, St } = imports.gi;
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2021-02-19 16:03:07 -05:00
|
|
|
const Layout = imports.ui.layout;
|
2010-01-21 21:33:48 -05:00
|
|
|
const Main = imports.ui.main;
|
2021-01-02 14:06:34 -05:00
|
|
|
const OverviewControls = imports.ui.overviewControls;
|
2019-07-08 04:47:04 -04:00
|
|
|
const SwipeTracker = imports.ui.swipeTracker;
|
2020-12-29 16:05:29 -05:00
|
|
|
const Util = imports.misc.util;
|
2010-01-21 21:33:48 -05:00
|
|
|
const Workspace = imports.ui.workspace;
|
2021-02-20 05:18:29 -05:00
|
|
|
const { ThumbnailsBox, MAX_THUMBNAIL_SCALE } = imports.ui.workspaceThumbnail;
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2019-08-01 19:13:10 -04:00
|
|
|
var WORKSPACE_SWITCH_TIME = 250;
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2018-11-08 04:47:25 -05:00
|
|
|
const MUTTER_SCHEMA = 'org.gnome.mutter';
|
2010-03-16 11:51:24 -04:00
|
|
|
|
2020-12-29 16:05:29 -05:00
|
|
|
const WORKSPACE_MIN_SPACING = 24;
|
|
|
|
const WORKSPACE_MAX_SPACING = 80;
|
|
|
|
|
2020-12-31 12:19:43 -05:00
|
|
|
const WORKSPACE_INACTIVE_SCALE = 0.94;
|
|
|
|
|
2021-05-12 10:38:09 -04:00
|
|
|
const SECONDARY_WORKSPACE_SCALE = 0.80;
|
2021-02-20 07:34:39 -05:00
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
var WorkspacesViewBase = GObject.registerClass({
|
2019-08-20 17:43:54 -04:00
|
|
|
GTypeFlags: GObject.TypeFlags.ABSTRACT,
|
2019-07-16 05:24:13 -04:00
|
|
|
}, class WorkspacesViewBase extends St.Widget {
|
2021-01-02 14:06:34 -05:00
|
|
|
_init(monitorIndex, overviewAdjustment) {
|
2020-06-25 19:15:33 -04:00
|
|
|
super._init({
|
|
|
|
style_class: 'workspaces-view',
|
2020-06-26 12:38:28 -04:00
|
|
|
x_expand: true,
|
|
|
|
y_expand: true,
|
2020-06-25 19:15:33 -04:00
|
|
|
});
|
2019-07-16 05:24:13 -04:00
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
|
|
|
global.focus_manager.add_group(this);
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2013-09-11 12:12:42 -04:00
|
|
|
this._monitorIndex = monitorIndex;
|
2010-02-18 10:43:58 -05:00
|
|
|
|
2013-09-11 12:12:42 -04:00
|
|
|
this._inDrag = false;
|
2017-12-01 19:27:35 -05: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));
|
2021-01-02 14:06:34 -05:00
|
|
|
|
|
|
|
this._overviewAdjustment = overviewAdjustment;
|
|
|
|
this._overviewId = overviewAdjustment.connect('notify::value', () => {
|
|
|
|
this._updateWorkspaceMode();
|
|
|
|
});
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onDestroy() {
|
2013-09-11 12:12:42 -04: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;
|
|
|
|
}
|
2021-01-02 14:06:34 -05:00
|
|
|
if (this._overviewId > 0) {
|
|
|
|
this._overviewAdjustment.disconnect(this._overviewId);
|
|
|
|
delete this._overviewId;
|
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2020-06-02 20:22:40 -04:00
|
|
|
_dragBegin() {
|
2013-09-11 12:12:42 -04:00
|
|
|
this._inDrag = true;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_dragEnd() {
|
2013-09-11 12:12:42 -04:00
|
|
|
this._inDrag = false;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2021-01-02 14:06:34 -05:00
|
|
|
_updateWorkspaceMode() {
|
|
|
|
}
|
|
|
|
|
2020-06-03 12:17:54 -04: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-30 21:19:44 -04:00
|
|
|
}
|
2020-06-26 12:38:28 -04:00
|
|
|
|
|
|
|
vfunc_get_preferred_width() {
|
|
|
|
return [0, 0];
|
|
|
|
}
|
|
|
|
|
|
|
|
vfunc_get_preferred_height() {
|
|
|
|
return [0, 0];
|
|
|
|
}
|
2019-07-16 05:24:13 -04:00
|
|
|
});
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2020-12-29 16:05:29 -05:00
|
|
|
var FitMode = {
|
|
|
|
SINGLE: 0,
|
|
|
|
ALL: 1,
|
|
|
|
};
|
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
var WorkspacesView = GObject.registerClass(
|
|
|
|
class WorkspacesView extends WorkspacesViewBase {
|
workspacesView: Interpolate against relative workspace boxes
The overview transition consists of getting the initial and final
states of the overview adjustment, derivating various other internal
states from them (such as the fit mode, opacities, translations, etc),
and finally interpolating the allocation boxes.
When interpolating between the fit mode, WorkspacesView uses the current
allocation box to derivate the SINGLE and ALL fit mode boxes. However,
that creates a curved path during overview transitions. What we really
want to do here is calculate the fit mode box relative to the corresponding
overview state. For example:
+----------------+----------+------------------------+
| Overview State | Fit Mode | Workspaces geometry |
+----------------+----------+------------------------+
| HIDDEN | SINGLE | Cover entire screen |
| WINDOW PICKER | SINGLE | Between minimap & Dash |
| APP GRID | ALL | 15% screen height |
+----------------+----------+------------------------+
Using the table above as the reference, when the overview transitions
between WINDOW PICKER and APP GRID, we must interpolate between
(SINGLE fit mode @ between minimap & Dash) and (ALL fit mode @ 15% screen
height). That way, we always interpolate the final boxes, which corrects
the odd path that workspaces follow during this transition.
Make the WorkspacesView of the primary monitor use these cached boxes
when the overview is in the middle of a transition, and the fit modes of
the initial and final state differ, to calculate the workspaces positions.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>
2021-02-02 14:34:59 -05:00
|
|
|
_init(monitorIndex, controls, scrollAdjustment, fitModeAdjustment, overviewAdjustment) {
|
2018-01-03 02:55:38 -05:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
|
2021-01-02 14:06:34 -05:00
|
|
|
super._init(monitorIndex, overviewAdjustment);
|
2013-09-11 10:09:13 -04:00
|
|
|
|
workspacesView: Interpolate against relative workspace boxes
The overview transition consists of getting the initial and final
states of the overview adjustment, derivating various other internal
states from them (such as the fit mode, opacities, translations, etc),
and finally interpolating the allocation boxes.
When interpolating between the fit mode, WorkspacesView uses the current
allocation box to derivate the SINGLE and ALL fit mode boxes. However,
that creates a curved path during overview transitions. What we really
want to do here is calculate the fit mode box relative to the corresponding
overview state. For example:
+----------------+----------+------------------------+
| Overview State | Fit Mode | Workspaces geometry |
+----------------+----------+------------------------+
| HIDDEN | SINGLE | Cover entire screen |
| WINDOW PICKER | SINGLE | Between minimap & Dash |
| APP GRID | ALL | 15% screen height |
+----------------+----------+------------------------+
Using the table above as the reference, when the overview transitions
between WINDOW PICKER and APP GRID, we must interpolate between
(SINGLE fit mode @ between minimap & Dash) and (ALL fit mode @ 15% screen
height). That way, we always interpolate the final boxes, which corrects
the odd path that workspaces follow during this transition.
Make the WorkspacesView of the primary monitor use these cached boxes
when the overview is in the middle of a transition, and the fit modes of
the initial and final state differ, to calculate the workspaces positions.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>
2021-02-02 14:34:59 -05:00
|
|
|
this._controls = controls;
|
2020-12-29 16:05:29 -05:00
|
|
|
this._fitModeAdjustment = fitModeAdjustment;
|
|
|
|
this._fitModeNotifyId = this._fitModeAdjustment.connect('notify::value', () => {
|
|
|
|
this._updateVisibility();
|
2020-12-31 12:19:43 -05:00
|
|
|
this._updateWorkspacesState();
|
2020-12-29 16:05:29 -05:00
|
|
|
this.queue_relayout();
|
|
|
|
});
|
|
|
|
|
2010-11-12 04:28:28 -05:00
|
|
|
this._animating = false; // tweening
|
2019-03-20 13:19:01 -04:00
|
|
|
this._gestureActive = false; // touch(pad) gestures
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2019-07-07 13:51:55 -04:00
|
|
|
this._scrollAdjustment = scrollAdjustment;
|
2020-06-26 10:04:44 -04:00
|
|
|
this._onScrollId = this._scrollAdjustment.connect('notify::value',
|
2020-12-18 10:21:58 -05:00
|
|
|
this._onScrollAdjustmentChanged.bind(this));
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2013-09-11 10:09:13 -04:00
|
|
|
this._workspaces = [];
|
|
|
|
this._updateWorkspaces();
|
2018-01-03 02:55:38 -05:00
|
|
|
this._updateWorkspacesId =
|
|
|
|
workspaceManager.connect('notify::n-workspaces',
|
|
|
|
this._updateWorkspaces.bind(this));
|
2019-07-09 08:03:22 -04:00
|
|
|
this._reorderWorkspacesId =
|
|
|
|
workspaceManager.connect('workspaces-reordered', () => {
|
|
|
|
this._workspaces.sort((a, b) => {
|
|
|
|
return a.metaWorkspace.index() - b.metaWorkspace.index();
|
|
|
|
});
|
2020-06-26 10:04:44 -04:00
|
|
|
this._workspaces.forEach(
|
|
|
|
(ws, i) => this.set_child_at_index(ws, i));
|
2019-07-09 08:03:22 -04:00
|
|
|
});
|
|
|
|
|
2010-01-21 21:33:48 -05:00
|
|
|
this._switchWorkspaceNotifyId =
|
|
|
|
global.window_manager.connect('switch-workspace',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._activeWorkspaceChanged.bind(this));
|
2021-01-02 14:17:17 -05:00
|
|
|
this._updateVisibility();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-11-25 09:44:17 -05:00
|
|
|
|
workspacesView: Interpolate against relative workspace boxes
The overview transition consists of getting the initial and final
states of the overview adjustment, derivating various other internal
states from them (such as the fit mode, opacities, translations, etc),
and finally interpolating the allocation boxes.
When interpolating between the fit mode, WorkspacesView uses the current
allocation box to derivate the SINGLE and ALL fit mode boxes. However,
that creates a curved path during overview transitions. What we really
want to do here is calculate the fit mode box relative to the corresponding
overview state. For example:
+----------------+----------+------------------------+
| Overview State | Fit Mode | Workspaces geometry |
+----------------+----------+------------------------+
| HIDDEN | SINGLE | Cover entire screen |
| WINDOW PICKER | SINGLE | Between minimap & Dash |
| APP GRID | ALL | 15% screen height |
+----------------+----------+------------------------+
Using the table above as the reference, when the overview transitions
between WINDOW PICKER and APP GRID, we must interpolate between
(SINGLE fit mode @ between minimap & Dash) and (ALL fit mode @ 15% screen
height). That way, we always interpolate the final boxes, which corrects
the odd path that workspaces follow during this transition.
Make the WorkspacesView of the primary monitor use these cached boxes
when the overview is in the middle of a transition, and the fit modes of
the initial and final state differ, to calculate the workspaces positions.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>
2021-02-02 14:34:59 -05:00
|
|
|
_getFirstFitAllWorkspaceBox(box, spacing, vertical) {
|
2020-12-29 16:05:29 -05:00
|
|
|
const { nWorkspaces } = global.workspaceManager;
|
|
|
|
const [width, height] = box.get_size();
|
|
|
|
const [workspace] = this._workspaces;
|
|
|
|
|
|
|
|
const fitAllBox = new Clutter.ActorBox();
|
|
|
|
|
workspacesView: Interpolate against relative workspace boxes
The overview transition consists of getting the initial and final
states of the overview adjustment, derivating various other internal
states from them (such as the fit mode, opacities, translations, etc),
and finally interpolating the allocation boxes.
When interpolating between the fit mode, WorkspacesView uses the current
allocation box to derivate the SINGLE and ALL fit mode boxes. However,
that creates a curved path during overview transitions. What we really
want to do here is calculate the fit mode box relative to the corresponding
overview state. For example:
+----------------+----------+------------------------+
| Overview State | Fit Mode | Workspaces geometry |
+----------------+----------+------------------------+
| HIDDEN | SINGLE | Cover entire screen |
| WINDOW PICKER | SINGLE | Between minimap & Dash |
| APP GRID | ALL | 15% screen height |
+----------------+----------+------------------------+
Using the table above as the reference, when the overview transitions
between WINDOW PICKER and APP GRID, we must interpolate between
(SINGLE fit mode @ between minimap & Dash) and (ALL fit mode @ 15% screen
height). That way, we always interpolate the final boxes, which corrects
the odd path that workspaces follow during this transition.
Make the WorkspacesView of the primary monitor use these cached boxes
when the overview is in the middle of a transition, and the fit modes of
the initial and final state differ, to calculate the workspaces positions.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>
2021-02-02 14:34:59 -05:00
|
|
|
let [x1, y1] = box.get_origin();
|
2020-12-29 16:05:29 -05:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
workspacesView: Interpolate against relative workspace boxes
The overview transition consists of getting the initial and final
states of the overview adjustment, derivating various other internal
states from them (such as the fit mode, opacities, translations, etc),
and finally interpolating the allocation boxes.
When interpolating between the fit mode, WorkspacesView uses the current
allocation box to derivate the SINGLE and ALL fit mode boxes. However,
that creates a curved path during overview transitions. What we really
want to do here is calculate the fit mode box relative to the corresponding
overview state. For example:
+----------------+----------+------------------------+
| Overview State | Fit Mode | Workspaces geometry |
+----------------+----------+------------------------+
| HIDDEN | SINGLE | Cover entire screen |
| WINDOW PICKER | SINGLE | Between minimap & Dash |
| APP GRID | ALL | 15% screen height |
+----------------+----------+------------------------+
Using the table above as the reference, when the overview transitions
between WINDOW PICKER and APP GRID, we must interpolate between
(SINGLE fit mode @ between minimap & Dash) and (ALL fit mode @ 15% screen
height). That way, we always interpolate the final boxes, which corrects
the odd path that workspaces follow during this transition.
Make the WorkspacesView of the primary monitor use these cached boxes
when the overview is in the middle of a transition, and the fit modes of
the initial and final state differ, to calculate the workspaces positions.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>
2021-02-02 14:34:59 -05:00
|
|
|
_getFirstFitSingleWorkspaceBox(box, spacing, vertical) {
|
2020-12-29 16:05:29 -05:00
|
|
|
const [width, height] = box.get_size();
|
|
|
|
const [workspace] = this._workspaces;
|
|
|
|
|
2020-12-30 10:44:00 -05:00
|
|
|
const rtl = this.text_direction === Clutter.TextDirection.RTL;
|
|
|
|
const adj = this._scrollAdjustment;
|
|
|
|
const currentWorkspace = vertical || !rtl
|
2021-02-09 04:17:29 -05:00
|
|
|
? adj.value : adj.upper - adj.value - 1;
|
2020-12-30 10:44:00 -05:00
|
|
|
|
2020-12-29 16:05:29 -05:00
|
|
|
// Single fit mode implies centered too
|
workspacesView: Interpolate against relative workspace boxes
The overview transition consists of getting the initial and final
states of the overview adjustment, derivating various other internal
states from them (such as the fit mode, opacities, translations, etc),
and finally interpolating the allocation boxes.
When interpolating between the fit mode, WorkspacesView uses the current
allocation box to derivate the SINGLE and ALL fit mode boxes. However,
that creates a curved path during overview transitions. What we really
want to do here is calculate the fit mode box relative to the corresponding
overview state. For example:
+----------------+----------+------------------------+
| Overview State | Fit Mode | Workspaces geometry |
+----------------+----------+------------------------+
| HIDDEN | SINGLE | Cover entire screen |
| WINDOW PICKER | SINGLE | Between minimap & Dash |
| APP GRID | ALL | 15% screen height |
+----------------+----------+------------------------+
Using the table above as the reference, when the overview transitions
between WINDOW PICKER and APP GRID, we must interpolate between
(SINGLE fit mode @ between minimap & Dash) and (ALL fit mode @ 15% screen
height). That way, we always interpolate the final boxes, which corrects
the odd path that workspaces follow during this transition.
Make the WorkspacesView of the primary monitor use these cached boxes
when the overview is in the middle of a transition, and the fit modes of
the initial and final state differ, to calculate the workspaces positions.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>
2021-02-02 14:34:59 -05:00
|
|
|
let [x1, y1] = box.get_origin();
|
2020-12-29 16:05:29 -05:00
|
|
|
if (vertical) {
|
|
|
|
const [, workspaceHeight] = workspace.get_preferred_height(width);
|
|
|
|
y1 += (height - workspaceHeight) / 2;
|
2020-12-30 10:44:00 -05:00
|
|
|
y1 -= currentWorkspace * (workspaceHeight + spacing);
|
2020-12-29 16:05:29 -05:00
|
|
|
} else {
|
|
|
|
const [, workspaceWidth] = workspace.get_preferred_width(height);
|
|
|
|
x1 += (width - workspaceWidth) / 2;
|
2020-12-30 10:44:00 -05:00
|
|
|
x1 -= currentWorkspace * (workspaceWidth + spacing);
|
2020-12-29 16:05:29 -05: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;
|
|
|
|
}
|
|
|
|
|
2021-02-19 13:37:58 -05:00
|
|
|
const spacing = (availableSpace - workspaceSize * 0.4) * (1 - fitMode);
|
2021-02-19 13:20:32 -05:00
|
|
|
const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
|
2020-12-29 16:05:29 -05:00
|
|
|
|
2021-02-19 13:20:32 -05:00
|
|
|
return Math.clamp(spacing, WORKSPACE_MIN_SPACING * scaleFactor,
|
|
|
|
WORKSPACE_MAX_SPACING * scaleFactor);
|
2020-12-29 16:05:29 -05:00
|
|
|
}
|
|
|
|
|
2021-01-15 13:58:33 -05:00
|
|
|
_getWorkspaceModeForOverviewState(state) {
|
2021-01-02 14:06:34 -05:00
|
|
|
const { ControlsState } = OverviewControls;
|
|
|
|
|
2021-01-15 13:58:33 -05:00
|
|
|
switch (state) {
|
|
|
|
case ControlsState.HIDDEN:
|
|
|
|
return 0;
|
|
|
|
case ControlsState.WINDOW_PICKER:
|
|
|
|
return 1;
|
|
|
|
case ControlsState.APP_GRID:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_updateWorkspacesState() {
|
2020-12-31 12:19:43 -05:00
|
|
|
const adj = this._scrollAdjustment;
|
2021-01-01 11:10:19 -05:00
|
|
|
const fitMode = this._fitModeAdjustment.value;
|
2021-01-02 14:06:34 -05:00
|
|
|
|
2021-01-15 13:58:33 -05:00
|
|
|
const { initialState, finalState, progress } =
|
|
|
|
this._overviewAdjustment.getStateTransitionParams();
|
|
|
|
|
|
|
|
const workspaceMode = (1 - fitMode) * Util.lerp(
|
|
|
|
this._getWorkspaceModeForOverviewState(initialState),
|
|
|
|
this._getWorkspaceModeForOverviewState(finalState),
|
|
|
|
progress);
|
2020-12-31 12:19:43 -05:00
|
|
|
|
|
|
|
// Fade and scale inactive workspaces
|
|
|
|
this._workspaces.forEach((w, index) => {
|
2021-01-02 14:06:34 -05:00
|
|
|
w.stateAdjustment.value = workspaceMode;
|
2021-01-01 11:10:19 -05:00
|
|
|
|
2020-12-31 12:19:43 -05:00
|
|
|
const distanceToCurrentWorkspace = Math.abs(adj.value - index);
|
|
|
|
|
2021-01-15 13:58:33 -05:00
|
|
|
const scaleProgress = 1 - Math.clamp(distanceToCurrentWorkspace, 0, 1);
|
2020-12-31 12:19:43 -05:00
|
|
|
|
2021-01-15 13:58:33 -05:00
|
|
|
const scale = Util.lerp(WORKSPACE_INACTIVE_SCALE, 1, scaleProgress);
|
2020-12-31 12:19:43 -05:00
|
|
|
w.set_scale(scale, scale);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
workspacesView: Interpolate against relative workspace boxes
The overview transition consists of getting the initial and final
states of the overview adjustment, derivating various other internal
states from them (such as the fit mode, opacities, translations, etc),
and finally interpolating the allocation boxes.
When interpolating between the fit mode, WorkspacesView uses the current
allocation box to derivate the SINGLE and ALL fit mode boxes. However,
that creates a curved path during overview transitions. What we really
want to do here is calculate the fit mode box relative to the corresponding
overview state. For example:
+----------------+----------+------------------------+
| Overview State | Fit Mode | Workspaces geometry |
+----------------+----------+------------------------+
| HIDDEN | SINGLE | Cover entire screen |
| WINDOW PICKER | SINGLE | Between minimap & Dash |
| APP GRID | ALL | 15% screen height |
+----------------+----------+------------------------+
Using the table above as the reference, when the overview transitions
between WINDOW PICKER and APP GRID, we must interpolate between
(SINGLE fit mode @ between minimap & Dash) and (ALL fit mode @ 15% screen
height). That way, we always interpolate the final boxes, which corrects
the odd path that workspaces follow during this transition.
Make the WorkspacesView of the primary monitor use these cached boxes
when the overview is in the middle of a transition, and the fit modes of
the initial and final state differ, to calculate the workspaces positions.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>
2021-02-02 14:34:59 -05:00
|
|
|
_getFitModeForState(state) {
|
|
|
|
const { ControlsState } = OverviewControls;
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case ControlsState.HIDDEN:
|
|
|
|
case ControlsState.WINDOW_PICKER:
|
|
|
|
return FitMode.SINGLE;
|
|
|
|
case ControlsState.APP_GRID:
|
|
|
|
return FitMode.ALL;
|
|
|
|
default:
|
|
|
|
return FitMode.SINGLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_getInitialBoxes(box) {
|
|
|
|
const offsetBox = new Clutter.ActorBox();
|
|
|
|
offsetBox.set_size(...box.get_size());
|
|
|
|
|
|
|
|
let fitSingleBox = offsetBox;
|
|
|
|
let fitAllBox = offsetBox;
|
|
|
|
|
|
|
|
const { transitioning, initialState, finalState } =
|
|
|
|
this._overviewAdjustment.getStateTransitionParams();
|
|
|
|
|
|
|
|
const isPrimary = Main.layoutManager.primaryIndex === this._monitorIndex;
|
|
|
|
|
|
|
|
if (isPrimary && transitioning) {
|
|
|
|
const initialFitMode = this._getFitModeForState(initialState);
|
|
|
|
const finalFitMode = this._getFitModeForState(finalState);
|
|
|
|
|
|
|
|
// Only use the relative boxes when the overview is in a state
|
|
|
|
// transition, and the corresponding fit modes are different.
|
|
|
|
if (initialFitMode !== finalFitMode) {
|
|
|
|
const initialBox =
|
|
|
|
this._controls.getWorkspacesBoxForState(initialState).copy();
|
|
|
|
const finalBox =
|
|
|
|
this._controls.getWorkspacesBoxForState(finalState).copy();
|
|
|
|
|
|
|
|
// Boxes are relative to ControlsManager, transform them;
|
|
|
|
// this.apply_relative_transform_to_point(controls,
|
|
|
|
// new Graphene.Point3D());
|
|
|
|
// would be more correct, but also more expensive
|
|
|
|
const [parentOffsetX, parentOffsetY] =
|
|
|
|
this.get_parent().allocation.get_origin();
|
|
|
|
[initialBox, finalBox].forEach(b => {
|
|
|
|
b.set_origin(b.x1 - parentOffsetX, b.y1 - parentOffsetY);
|
|
|
|
});
|
|
|
|
|
|
|
|
if (initialFitMode === FitMode.SINGLE)
|
|
|
|
[fitSingleBox, fitAllBox] = [initialBox, finalBox];
|
|
|
|
else
|
|
|
|
[fitAllBox, fitSingleBox] = [initialBox, finalBox];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return [fitSingleBox, fitAllBox];
|
|
|
|
}
|
|
|
|
|
2021-01-02 14:06:34 -05:00
|
|
|
_updateWorkspaceMode() {
|
|
|
|
this._updateWorkspacesState();
|
|
|
|
}
|
|
|
|
|
2020-06-26 10:04:44 -04:00
|
|
|
vfunc_allocate(box) {
|
|
|
|
this.set_allocation(box);
|
|
|
|
|
|
|
|
if (this.get_n_children() === 0)
|
|
|
|
return;
|
|
|
|
|
2020-12-29 16:05:29 -05:00
|
|
|
const vertical = global.workspaceManager.layout_rows === -1;
|
2020-06-26 10:04:44 -04:00
|
|
|
const rtl = this.text_direction === Clutter.TextDirection.RTL;
|
|
|
|
|
2020-12-29 16:05:29 -05:00
|
|
|
const fitMode = this._fitModeAdjustment.value;
|
2020-12-11 13:57:49 -05:00
|
|
|
|
workspacesView: Interpolate against relative workspace boxes
The overview transition consists of getting the initial and final
states of the overview adjustment, derivating various other internal
states from them (such as the fit mode, opacities, translations, etc),
and finally interpolating the allocation boxes.
When interpolating between the fit mode, WorkspacesView uses the current
allocation box to derivate the SINGLE and ALL fit mode boxes. However,
that creates a curved path during overview transitions. What we really
want to do here is calculate the fit mode box relative to the corresponding
overview state. For example:
+----------------+----------+------------------------+
| Overview State | Fit Mode | Workspaces geometry |
+----------------+----------+------------------------+
| HIDDEN | SINGLE | Cover entire screen |
| WINDOW PICKER | SINGLE | Between minimap & Dash |
| APP GRID | ALL | 15% screen height |
+----------------+----------+------------------------+
Using the table above as the reference, when the overview transitions
between WINDOW PICKER and APP GRID, we must interpolate between
(SINGLE fit mode @ between minimap & Dash) and (ALL fit mode @ 15% screen
height). That way, we always interpolate the final boxes, which corrects
the odd path that workspaces follow during this transition.
Make the WorkspacesView of the primary monitor use these cached boxes
when the overview is in the middle of a transition, and the fit modes of
the initial and final state differ, to calculate the workspaces positions.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>
2021-02-02 14:34:59 -05:00
|
|
|
let [fitSingleBox, fitAllBox] = this._getInitialBoxes(box);
|
2020-12-29 16:05:29 -05:00
|
|
|
const fitSingleSpacing =
|
workspacesView: Interpolate against relative workspace boxes
The overview transition consists of getting the initial and final
states of the overview adjustment, derivating various other internal
states from them (such as the fit mode, opacities, translations, etc),
and finally interpolating the allocation boxes.
When interpolating between the fit mode, WorkspacesView uses the current
allocation box to derivate the SINGLE and ALL fit mode boxes. However,
that creates a curved path during overview transitions. What we really
want to do here is calculate the fit mode box relative to the corresponding
overview state. For example:
+----------------+----------+------------------------+
| Overview State | Fit Mode | Workspaces geometry |
+----------------+----------+------------------------+
| HIDDEN | SINGLE | Cover entire screen |
| WINDOW PICKER | SINGLE | Between minimap & Dash |
| APP GRID | ALL | 15% screen height |
+----------------+----------+------------------------+
Using the table above as the reference, when the overview transitions
between WINDOW PICKER and APP GRID, we must interpolate between
(SINGLE fit mode @ between minimap & Dash) and (ALL fit mode @ 15% screen
height). That way, we always interpolate the final boxes, which corrects
the odd path that workspaces follow during this transition.
Make the WorkspacesView of the primary monitor use these cached boxes
when the overview is in the middle of a transition, and the fit modes of
the initial and final state differ, to calculate the workspaces positions.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>
2021-02-02 14:34:59 -05:00
|
|
|
this._getSpacing(fitSingleBox, FitMode.SINGLE, vertical);
|
|
|
|
fitSingleBox =
|
|
|
|
this._getFirstFitSingleWorkspaceBox(fitSingleBox, fitSingleSpacing, vertical);
|
2020-06-26 10:04:44 -04:00
|
|
|
|
2020-12-29 16:05:29 -05:00
|
|
|
const fitAllSpacing =
|
workspacesView: Interpolate against relative workspace boxes
The overview transition consists of getting the initial and final
states of the overview adjustment, derivating various other internal
states from them (such as the fit mode, opacities, translations, etc),
and finally interpolating the allocation boxes.
When interpolating between the fit mode, WorkspacesView uses the current
allocation box to derivate the SINGLE and ALL fit mode boxes. However,
that creates a curved path during overview transitions. What we really
want to do here is calculate the fit mode box relative to the corresponding
overview state. For example:
+----------------+----------+------------------------+
| Overview State | Fit Mode | Workspaces geometry |
+----------------+----------+------------------------+
| HIDDEN | SINGLE | Cover entire screen |
| WINDOW PICKER | SINGLE | Between minimap & Dash |
| APP GRID | ALL | 15% screen height |
+----------------+----------+------------------------+
Using the table above as the reference, when the overview transitions
between WINDOW PICKER and APP GRID, we must interpolate between
(SINGLE fit mode @ between minimap & Dash) and (ALL fit mode @ 15% screen
height). That way, we always interpolate the final boxes, which corrects
the odd path that workspaces follow during this transition.
Make the WorkspacesView of the primary monitor use these cached boxes
when the overview is in the middle of a transition, and the fit modes of
the initial and final state differ, to calculate the workspaces positions.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>
2021-02-02 14:34:59 -05:00
|
|
|
this._getSpacing(fitAllBox, FitMode.ALL, vertical);
|
|
|
|
fitAllBox =
|
|
|
|
this._getFirstFitAllWorkspaceBox(fitAllBox, fitAllSpacing, vertical);
|
2020-12-29 16:05:29 -05:00
|
|
|
|
|
|
|
// Account for RTL locales by reversing the list
|
|
|
|
const workspaces = this._workspaces.slice();
|
|
|
|
if (rtl)
|
|
|
|
workspaces.reverse();
|
|
|
|
|
2021-03-09 12:12:02 -05:00
|
|
|
const [fitSingleX1, fitSingleY1] = fitSingleBox.get_origin();
|
|
|
|
const [fitSingleWidth, fitSingleHeight] = fitSingleBox.get_size();
|
|
|
|
const [fitAllX1, fitAllY1] = fitAllBox.get_origin();
|
|
|
|
const [fitAllWidth, fitAllHeight] = fitAllBox.get_size();
|
|
|
|
|
2020-12-29 16:05:29 -05:00
|
|
|
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(
|
2021-03-09 12:12:02 -05:00
|
|
|
fitSingleX1,
|
|
|
|
fitSingleBox.y1 + fitSingleHeight + fitSingleSpacing);
|
2020-12-29 16:05:29 -05:00
|
|
|
fitAllBox.set_origin(
|
2021-03-09 12:12:02 -05:00
|
|
|
fitAllX1,
|
|
|
|
fitAllBox.y1 + fitAllHeight + fitAllSpacing);
|
2020-12-29 16:05:29 -05:00
|
|
|
} else {
|
|
|
|
fitSingleBox.set_origin(
|
2021-03-09 12:12:02 -05:00
|
|
|
fitSingleBox.x1 + fitSingleWidth + fitSingleSpacing,
|
|
|
|
fitSingleY1);
|
2020-12-29 16:05:29 -05:00
|
|
|
fitAllBox.set_origin(
|
2021-03-09 12:12:02 -05:00
|
|
|
fitAllBox.x1 + fitAllWidth + fitAllSpacing,
|
|
|
|
fitAllY1);
|
2020-12-29 16:05:29 -05:00
|
|
|
}
|
2020-06-26 10:04:44 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
getActiveWorkspace() {
|
2018-01-03 02:55:38 -05:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let active = workspaceManager.get_active_workspace_index();
|
2010-07-15 10:21:32 -04:00
|
|
|
return this._workspaces[active];
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2010-07-15 10:21:32 -04:00
|
|
|
|
2021-01-02 14:17:17 -05:00
|
|
|
prepareToLeaveOverview() {
|
2020-06-28 08:42:44 -04:00
|
|
|
for (let w = 0; w < this._workspaces.length; w++)
|
2021-01-01 11:10:19 -05:00
|
|
|
this._workspaces[w].prepareToLeaveOverview();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2010-02-18 10:43:58 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
syncStacking(stackIndices) {
|
2010-01-21 21:33:48 -05:00
|
|
|
for (let i = 0; i < this._workspaces.length; i++)
|
|
|
|
this._workspaces[i].syncStacking(stackIndices);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2020-06-26 10:04:44 -04:00
|
|
|
_scrollToActive() {
|
|
|
|
const { workspaceManager } = global;
|
|
|
|
const active = workspaceManager.get_active_workspace_index();
|
2010-03-22 19:01:44 -04:00
|
|
|
|
2020-06-26 10:04:44 -04:00
|
|
|
this._animating = true;
|
|
|
|
this._updateVisibility();
|
2010-02-10 00:56:36 -05:00
|
|
|
|
2020-06-26 10:04:44 -04: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-30 21:19:44 -04:00
|
|
|
}
|
2010-02-11 09:52:49 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateVisibility() {
|
2018-01-03 02:55:38 -05:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let active = workspaceManager.get_active_workspace_index();
|
2010-02-11 09:52:49 -05:00
|
|
|
|
2020-12-30 10:44:00 -05:00
|
|
|
const fitMode = this._fitModeAdjustment.value;
|
|
|
|
const singleFitMode = fitMode === FitMode.SINGLE;
|
|
|
|
|
2010-03-22 19:01:44 -04:00
|
|
|
for (let w = 0; w < this._workspaces.length; w++) {
|
|
|
|
let workspace = this._workspaces[w];
|
2019-08-19 22:10:46 -04:00
|
|
|
|
2020-12-30 10:44:00 -05:00
|
|
|
if (this._animating || this._gestureActive || !singleFitMode)
|
2019-07-16 05:24:13 -04:00
|
|
|
workspace.show();
|
2019-08-19 22:10:46 -04:00
|
|
|
else
|
2020-12-29 16:05:29 -05:00
|
|
|
workspace.visible = Math.abs(w - active) <= 1;
|
2010-02-11 09:52:49 -05:00
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2010-02-11 09:52:49 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateWorkspaces() {
|
2018-01-03 02:55:38 -05:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let newNumWorkspaces = workspaceManager.n_workspaces;
|
2013-09-11 10:09:13 -04:00
|
|
|
|
2014-01-03 13:04:06 -05:00
|
|
|
for (let j = 0; j < newNumWorkspaces; j++) {
|
2018-01-03 02:55:38 -05:00
|
|
|
let metaWorkspace = workspaceManager.get_workspace_by_index(j);
|
2014-01-03 13:04:06 -05:00
|
|
|
let workspace;
|
|
|
|
|
|
|
|
if (j >= this._workspaces.length) { /* added */
|
2021-02-05 11:22:18 -05:00
|
|
|
workspace = new Workspace.Workspace(
|
|
|
|
metaWorkspace,
|
|
|
|
this._monitorIndex,
|
|
|
|
this._overviewAdjustment);
|
2019-07-16 05:24:13 -04:00
|
|
|
this.add_actor(workspace);
|
2014-01-03 13:04:06 -05: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 08:47:51 -04:00
|
|
|
}
|
2010-01-21 21:33:48 -05:00
|
|
|
}
|
2013-09-11 10:09:13 -04:00
|
|
|
|
2020-09-29 12:38:40 -04:00
|
|
|
for (let j = this._workspaces.length - 1; j >= newNumWorkspaces; j--) {
|
|
|
|
this._workspaces[j].destroy();
|
|
|
|
this._workspaces.splice(j, 1);
|
|
|
|
}
|
2020-12-31 12:19:43 -05:00
|
|
|
|
|
|
|
this._updateWorkspacesState();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2019-01-31 09:08:10 -05:00
|
|
|
_activeWorkspaceChanged(_wm, _from, _to, _direction) {
|
2020-06-26 10:04:44 -04:00
|
|
|
this._scrollToActive();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onDestroy() {
|
2017-10-30 21:19:44 -04:00
|
|
|
super._onDestroy();
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2020-06-26 12:38:28 -04:00
|
|
|
this._workspaces = [];
|
2019-07-07 13:51:55 -04:00
|
|
|
this._scrollAdjustment.disconnect(this._onScrollId);
|
2020-12-29 16:05:29 -05:00
|
|
|
this._fitModeAdjustment.disconnect(this._fitModeNotifyId);
|
2010-11-12 04:28:28 -05:00
|
|
|
global.window_manager.disconnect(this._switchWorkspaceNotifyId);
|
2018-01-03 02:55:38 -05:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
workspaceManager.disconnect(this._updateWorkspacesId);
|
2019-07-09 08:03:22 -04:00
|
|
|
workspaceManager.disconnect(this._reorderWorkspacesId);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2010-03-16 11:51:24 -04:00
|
|
|
|
2019-03-20 13:19:01 -04:00
|
|
|
startTouchGesture() {
|
|
|
|
this._gestureActive = true;
|
2020-07-10 09:41:09 -04:00
|
|
|
|
|
|
|
this._updateVisibility();
|
2019-03-20 13:19:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
endTouchGesture() {
|
|
|
|
this._gestureActive = false;
|
|
|
|
|
|
|
|
// Make sure title captions etc are shown as necessary
|
2020-06-26 10:04:44 -04:00
|
|
|
this._scrollToActive();
|
2019-03-20 13:19:01 -04:00
|
|
|
this._updateVisibility();
|
|
|
|
}
|
|
|
|
|
2010-07-11 08:41:17 -04:00
|
|
|
// sync the workspaces' positions to the value of the scroll adjustment
|
2010-02-10 00:56:36 -05:00
|
|
|
// and change the active workspace if appropriate
|
2020-12-18 10:21:58 -05:00
|
|
|
_onScrollAdjustmentChanged() {
|
2020-06-26 10:04:44 -04:00
|
|
|
if (!this.has_allocation())
|
2010-02-10 00:56:36 -05:00
|
|
|
return;
|
|
|
|
|
2020-06-26 10:04:44 -04:00
|
|
|
const adj = this._scrollAdjustment;
|
|
|
|
const allowSwitch =
|
|
|
|
adj.get_transition('value') === null && !this._gestureActive;
|
|
|
|
|
2018-01-03 02:55:38 -05:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let active = workspaceManager.get_active_workspace_index();
|
2010-02-10 00:56:36 -05:00
|
|
|
let current = Math.round(adj.value);
|
|
|
|
|
2020-06-26 10:04:44 -04:00
|
|
|
if (allowSwitch && active !== current) {
|
2013-01-18 20:26:44 -05: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 18:32:57 -05:00
|
|
|
let metaWorkspace = this._workspaces[current].metaWorkspace;
|
2010-07-11 08:41:17 -04:00
|
|
|
metaWorkspace.activate(global.get_current_time());
|
2010-02-10 00:56:36 -05:00
|
|
|
}
|
|
|
|
|
2020-12-31 12:19:43 -05:00
|
|
|
this._updateWorkspacesState();
|
2020-12-30 10:44:00 -05:00
|
|
|
this.queue_relayout();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2019-07-16 05:24:13 -04:00
|
|
|
});
|
2010-10-04 10:42:11 -04:00
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
var ExtraWorkspaceView = GObject.registerClass(
|
|
|
|
class ExtraWorkspaceView extends WorkspacesViewBase {
|
2021-01-02 14:06:34 -05:00
|
|
|
_init(monitorIndex, overviewAdjustment) {
|
|
|
|
super._init(monitorIndex, overviewAdjustment);
|
2021-02-05 11:22:18 -05:00
|
|
|
this._workspace =
|
|
|
|
new Workspace.Workspace(null, monitorIndex, overviewAdjustment);
|
2019-07-16 05:24:13 -04:00
|
|
|
this.add_actor(this._workspace);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2021-01-02 14:06:34 -05:00
|
|
|
_updateWorkspaceMode() {
|
|
|
|
const overviewState = this._overviewAdjustment.value;
|
|
|
|
|
|
|
|
const progress = Math.clamp(overviewState,
|
|
|
|
OverviewControls.ControlsState.HIDDEN,
|
|
|
|
OverviewControls.ControlsState.WINDOW_PICKER);
|
|
|
|
|
|
|
|
this._workspace.stateAdjustment.value = progress;
|
|
|
|
}
|
|
|
|
|
2021-02-20 07:33:29 -05:00
|
|
|
vfunc_allocate(box) {
|
|
|
|
this.set_allocation(box);
|
|
|
|
|
|
|
|
const [width, height] = box.get_size();
|
|
|
|
const [, childWidth] = this._workspace.get_preferred_width(height);
|
|
|
|
|
|
|
|
const childBox = new Clutter.ActorBox();
|
|
|
|
childBox.set_origin(Math.round((width - childWidth) / 2), 0);
|
|
|
|
childBox.set_size(childWidth, height);
|
|
|
|
this._workspace.allocate(childBox);
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
getActiveWorkspace() {
|
2016-06-24 12:15:48 -04:00
|
|
|
return this._workspace;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2016-06-24 12:15:48 -04:00
|
|
|
|
2021-01-02 14:17:17 -05:00
|
|
|
prepareToLeaveOverview() {
|
2021-01-02 14:06:34 -05:00
|
|
|
this._workspace.prepareToLeaveOverview();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
syncStacking(stackIndices) {
|
2013-09-11 12:12:42 -04:00
|
|
|
this._workspace.syncStacking(stackIndices);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2019-03-20 13:19:01 -04:00
|
|
|
startTouchGesture() {
|
|
|
|
}
|
|
|
|
|
|
|
|
endTouchGesture() {
|
|
|
|
}
|
2013-11-04 17:23:44 -05:00
|
|
|
});
|
|
|
|
|
2021-02-19 16:03:07 -05:00
|
|
|
const SecondaryMonitorDisplay = GObject.registerClass(
|
|
|
|
class SecondaryMonitorDisplay extends St.Widget {
|
|
|
|
_init(monitorIndex, controls, scrollAdjustment, fitModeAdjustment, overviewAdjustment) {
|
|
|
|
this._monitorIndex = monitorIndex;
|
|
|
|
this._controls = controls;
|
|
|
|
this._scrollAdjustment = scrollAdjustment;
|
|
|
|
this._fitModeAdjustment = fitModeAdjustment;
|
|
|
|
this._overviewAdjustment = overviewAdjustment;
|
|
|
|
|
|
|
|
super._init({
|
2021-02-20 05:18:29 -05:00
|
|
|
style_class: 'secondary-monitor-workspaces',
|
2021-02-19 16:03:07 -05:00
|
|
|
constraints: new Layout.MonitorConstraint({
|
|
|
|
index: this._monitorIndex,
|
|
|
|
work_area: true,
|
|
|
|
}),
|
2021-03-03 06:37:51 -05:00
|
|
|
clip_to_allocation: true,
|
2021-02-19 16:03:07 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
this.connect('destroy', () => this._onDestroy());
|
|
|
|
|
2021-02-20 05:18:29 -05:00
|
|
|
this._thumbnails = new ThumbnailsBox(
|
|
|
|
this._scrollAdjustment, monitorIndex);
|
|
|
|
this.add_child(this._thumbnails);
|
|
|
|
|
|
|
|
this._thumbnails.connect('notify::should-show',
|
|
|
|
() => this._updateThumbnailVisibility());
|
|
|
|
|
|
|
|
this._stateChangedId = this._overviewAdjustment.connect('notify::value',
|
2021-05-12 10:57:23 -04:00
|
|
|
() => {
|
|
|
|
this._updateThumbnailParams();
|
|
|
|
this.queue_relayout();
|
|
|
|
});
|
2021-02-20 05:18:29 -05:00
|
|
|
|
2021-02-19 16:03:07 -05:00
|
|
|
this._settings = new Gio.Settings({ schema_id: MUTTER_SCHEMA });
|
|
|
|
this._settings.connect('changed::workspaces-only-on-primary',
|
2021-02-20 05:18:29 -05:00
|
|
|
() => this._workspacesOnPrimaryChanged());
|
|
|
|
this._workspacesOnPrimaryChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
_getThumbnailParamsForState(state) {
|
|
|
|
const { ControlsState } = OverviewControls;
|
|
|
|
|
|
|
|
let opacity, scale;
|
|
|
|
switch (state) {
|
|
|
|
case ControlsState.HIDDEN:
|
|
|
|
case ControlsState.WINDOW_PICKER:
|
|
|
|
opacity = 255;
|
|
|
|
scale = 1;
|
|
|
|
break;
|
|
|
|
case ControlsState.APP_GRID:
|
|
|
|
opacity = 0;
|
|
|
|
scale = 0.5;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
opacity = 255;
|
|
|
|
scale = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return { opacity, scale };
|
2021-02-19 16:03:07 -05:00
|
|
|
}
|
|
|
|
|
2021-02-20 05:18:29 -05:00
|
|
|
_getThumbnailsHeight(box) {
|
|
|
|
if (!this._thumbnails.visible)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
const [width, height] = box.get_size();
|
|
|
|
const { expandFraction } = this._thumbnails;
|
|
|
|
const [thumbnailsHeight] = this._thumbnails.get_preferred_height(width);
|
|
|
|
return Math.min(
|
|
|
|
thumbnailsHeight * expandFraction,
|
|
|
|
height * MAX_THUMBNAIL_SCALE);
|
|
|
|
}
|
|
|
|
|
|
|
|
_getWorkspacesBoxForState(state, box, padding, thumbnailsHeight, spacing) {
|
2021-02-20 07:34:39 -05:00
|
|
|
const { ControlsState } = OverviewControls;
|
|
|
|
const workspaceBox = box.copy();
|
|
|
|
const [width, height] = workspaceBox.get_size();
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case ControlsState.HIDDEN:
|
|
|
|
break;
|
|
|
|
case ControlsState.WINDOW_PICKER:
|
2021-02-20 05:18:29 -05:00
|
|
|
workspaceBox.set_origin(0, padding + thumbnailsHeight + spacing);
|
|
|
|
workspaceBox.set_size(
|
|
|
|
width,
|
|
|
|
height - 2 * padding - thumbnailsHeight - spacing);
|
|
|
|
break;
|
2021-02-20 07:34:39 -05:00
|
|
|
case ControlsState.APP_GRID:
|
|
|
|
workspaceBox.set_origin(0, padding);
|
|
|
|
workspaceBox.set_size(
|
|
|
|
width,
|
|
|
|
height - 2 * padding);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return workspaceBox;
|
|
|
|
}
|
|
|
|
|
2021-02-19 16:03:07 -05:00
|
|
|
vfunc_allocate(box) {
|
|
|
|
this.set_allocation(box);
|
|
|
|
|
|
|
|
const themeNode = this.get_theme_node();
|
|
|
|
const contentBox = themeNode.get_content_box(box);
|
2021-02-20 05:18:29 -05:00
|
|
|
const [width, height] = contentBox.get_size();
|
|
|
|
const { expandFraction } = this._thumbnails;
|
|
|
|
const spacing = themeNode.get_length('spacing') * expandFraction;
|
2021-02-20 07:34:39 -05:00
|
|
|
const padding =
|
|
|
|
Math.round((1 - SECONDARY_WORKSPACE_SCALE) * height / 2);
|
|
|
|
|
2021-02-20 05:18:29 -05:00
|
|
|
const thumbnailsHeight = this._getThumbnailsHeight(contentBox);
|
|
|
|
|
|
|
|
if (this._thumbnails.visible) {
|
|
|
|
const childBox = new Clutter.ActorBox();
|
|
|
|
childBox.set_origin(0, padding);
|
|
|
|
childBox.set_size(width, thumbnailsHeight);
|
|
|
|
this._thumbnails.allocate(childBox);
|
|
|
|
}
|
|
|
|
|
2021-02-20 07:34:39 -05:00
|
|
|
const {
|
|
|
|
currentState, initialState, finalState, transitioning, progress,
|
|
|
|
} = this._overviewAdjustment.getStateTransitionParams();
|
|
|
|
|
|
|
|
let workspacesBox;
|
2021-02-20 05:18:29 -05:00
|
|
|
const workspaceParams = [contentBox, padding, thumbnailsHeight, spacing];
|
2021-02-20 07:34:39 -05:00
|
|
|
if (!transitioning) {
|
|
|
|
workspacesBox =
|
|
|
|
this._getWorkspacesBoxForState(currentState, ...workspaceParams);
|
|
|
|
} else {
|
|
|
|
const initialBox =
|
|
|
|
this._getWorkspacesBoxForState(initialState, ...workspaceParams);
|
|
|
|
const finalBox =
|
|
|
|
this._getWorkspacesBoxForState(finalState, ...workspaceParams);
|
|
|
|
workspacesBox = initialBox.interpolate(finalBox, progress);
|
|
|
|
}
|
|
|
|
this._workspacesView.allocate(workspacesBox);
|
2021-02-19 16:03:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
_onDestroy() {
|
|
|
|
if (this._settings)
|
|
|
|
this._settings.run_dispose();
|
|
|
|
this._settings = null;
|
2021-02-20 05:18:29 -05:00
|
|
|
|
|
|
|
if (this._stateChangedId)
|
|
|
|
this._overviewAdjustment.disconnect(this._stateChangedId);
|
|
|
|
this._stateChangedId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_workspacesOnPrimaryChanged() {
|
|
|
|
this._updateWorkspacesView();
|
|
|
|
this._updateThumbnailVisibility();
|
2021-02-19 16:03:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
_updateWorkspacesView() {
|
|
|
|
if (this._workspacesView)
|
|
|
|
this._workspacesView.destroy();
|
|
|
|
|
|
|
|
if (this._settings.get_boolean('workspaces-only-on-primary')) {
|
|
|
|
this._workspacesView = new ExtraWorkspaceView(
|
|
|
|
this._monitorIndex,
|
|
|
|
this._overviewAdjustment);
|
|
|
|
} else {
|
|
|
|
this._workspacesView = new WorkspacesView(
|
|
|
|
this._monitorIndex,
|
|
|
|
this._controls,
|
|
|
|
this._scrollAdjustment,
|
|
|
|
this._fitModeAdjustment,
|
|
|
|
this._overviewAdjustment);
|
|
|
|
}
|
|
|
|
this.add_child(this._workspacesView);
|
|
|
|
}
|
|
|
|
|
2021-02-20 05:18:29 -05:00
|
|
|
_updateThumbnailVisibility() {
|
|
|
|
const visible =
|
|
|
|
this._thumbnails.should_show &&
|
|
|
|
!this._settings.get_boolean('workspaces-only-on-primary');
|
|
|
|
|
|
|
|
if (this._thumbnails.visible === visible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._thumbnails.show();
|
2021-05-12 10:55:34 -04:00
|
|
|
this._updateThumbnailParams();
|
2021-02-20 05:18:29 -05:00
|
|
|
this._thumbnails.ease_property('expand-fraction', visible ? 1 : 0, {
|
|
|
|
duration: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
onComplete: () => (this._thumbnails.visible = visible),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_updateThumbnailParams() {
|
2021-05-12 10:55:34 -04:00
|
|
|
if (!this._thumbnails.visible)
|
|
|
|
return;
|
|
|
|
|
2021-02-20 05:18:29 -05:00
|
|
|
const { initialState, finalState, progress } =
|
|
|
|
this._overviewAdjustment.getStateTransitionParams();
|
|
|
|
|
|
|
|
const initialParams = this._getThumbnailParamsForState(initialState);
|
|
|
|
const finalParams = this._getThumbnailParamsForState(finalState);
|
|
|
|
|
|
|
|
const opacity =
|
|
|
|
Util.lerp(initialParams.opacity, finalParams.opacity, progress);
|
|
|
|
const scale =
|
|
|
|
Util.lerp(initialParams.scale, finalParams.scale, progress);
|
|
|
|
|
|
|
|
this._thumbnails.set({
|
|
|
|
opacity,
|
|
|
|
scale_x: scale,
|
|
|
|
scale_y: scale,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-02-19 16:03:07 -05:00
|
|
|
getActiveWorkspace() {
|
|
|
|
return this._workspacesView.getActiveWorkspace();
|
|
|
|
}
|
|
|
|
|
|
|
|
prepareToLeaveOverview() {
|
|
|
|
this._workspacesView.prepareToLeaveOverview();
|
|
|
|
}
|
|
|
|
|
|
|
|
syncStacking(stackIndices) {
|
|
|
|
this._workspacesView.syncStacking(stackIndices);
|
|
|
|
}
|
|
|
|
|
|
|
|
startTouchGesture() {
|
|
|
|
this._workspacesView.startTouchGesture();
|
|
|
|
}
|
|
|
|
|
|
|
|
endTouchGesture() {
|
|
|
|
this._workspacesView.endTouchGesture();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
var WorkspacesDisplay = GObject.registerClass(
|
|
|
|
class WorkspacesDisplay extends St.Widget {
|
workspacesView: Interpolate against relative workspace boxes
The overview transition consists of getting the initial and final
states of the overview adjustment, derivating various other internal
states from them (such as the fit mode, opacities, translations, etc),
and finally interpolating the allocation boxes.
When interpolating between the fit mode, WorkspacesView uses the current
allocation box to derivate the SINGLE and ALL fit mode boxes. However,
that creates a curved path during overview transitions. What we really
want to do here is calculate the fit mode box relative to the corresponding
overview state. For example:
+----------------+----------+------------------------+
| Overview State | Fit Mode | Workspaces geometry |
+----------------+----------+------------------------+
| HIDDEN | SINGLE | Cover entire screen |
| WINDOW PICKER | SINGLE | Between minimap & Dash |
| APP GRID | ALL | 15% screen height |
+----------------+----------+------------------------+
Using the table above as the reference, when the overview transitions
between WINDOW PICKER and APP GRID, we must interpolate between
(SINGLE fit mode @ between minimap & Dash) and (ALL fit mode @ 15% screen
height). That way, we always interpolate the final boxes, which corrects
the odd path that workspaces follow during this transition.
Make the WorkspacesView of the primary monitor use these cached boxes
when the overview is in the middle of a transition, and the fit modes of
the initial and final state differ, to calculate the workspaces positions.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>
2021-02-02 14:34:59 -05:00
|
|
|
_init(controls, scrollAdjustment, overviewAdjustment) {
|
2020-06-02 13:15:45 -04:00
|
|
|
super._init({
|
2020-06-26 12:38:28 -04:00
|
|
|
layout_manager: new Clutter.BinLayout(),
|
2020-06-02 13:15:45 -04:00
|
|
|
});
|
2012-12-13 14:19:44 -05:00
|
|
|
|
workspacesView: Interpolate against relative workspace boxes
The overview transition consists of getting the initial and final
states of the overview adjustment, derivating various other internal
states from them (such as the fit mode, opacities, translations, etc),
and finally interpolating the allocation boxes.
When interpolating between the fit mode, WorkspacesView uses the current
allocation box to derivate the SINGLE and ALL fit mode boxes. However,
that creates a curved path during overview transitions. What we really
want to do here is calculate the fit mode box relative to the corresponding
overview state. For example:
+----------------+----------+------------------------+
| Overview State | Fit Mode | Workspaces geometry |
+----------------+----------+------------------------+
| HIDDEN | SINGLE | Cover entire screen |
| WINDOW PICKER | SINGLE | Between minimap & Dash |
| APP GRID | ALL | 15% screen height |
+----------------+----------+------------------------+
Using the table above as the reference, when the overview transitions
between WINDOW PICKER and APP GRID, we must interpolate between
(SINGLE fit mode @ between minimap & Dash) and (ALL fit mode @ 15% screen
height). That way, we always interpolate the final boxes, which corrects
the odd path that workspaces follow during this transition.
Make the WorkspacesView of the primary monitor use these cached boxes
when the overview is in the middle of a transition, and the fit modes of
the initial and final state differ, to calculate the workspaces positions.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>
2021-02-02 14:34:59 -05:00
|
|
|
this._controls = controls;
|
2021-01-02 14:06:34 -05:00
|
|
|
this._overviewAdjustment = overviewAdjustment;
|
2020-12-29 16:05:29 -05:00
|
|
|
this._fitModeAdjustment = new St.Adjustment({
|
|
|
|
actor: this,
|
|
|
|
value: FitMode.SINGLE,
|
|
|
|
lower: FitMode.SINGLE,
|
|
|
|
upper: FitMode.ALL,
|
|
|
|
});
|
|
|
|
|
2019-07-07 13:51:55 -04:00
|
|
|
let workspaceManager = global.workspace_manager;
|
2019-07-08 04:03:20 -04:00
|
|
|
this._scrollAdjustment = scrollAdjustment;
|
2019-07-07 13:51:55 -04: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 04:47:04 -04:00
|
|
|
this._swipeTracker = new SwipeTracker.SwipeTracker(
|
2021-01-08 15:25:45 -05:00
|
|
|
Main.layoutManager.overviewGroup,
|
2021-03-01 11:53:55 -05:00
|
|
|
Clutter.Orientation.HORIZONTAL,
|
2021-01-08 15:25:45 -05:00
|
|
|
Shell.ActionMode.OVERVIEW,
|
|
|
|
{ allowDrag: false });
|
2021-02-07 15:06:02 -05:00
|
|
|
this._swipeTracker.allowLongSwipes = true;
|
2019-07-08 04:47:04 -04: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 14:08:32 -05:00
|
|
|
this.connect('notify::mapped', this._updateSwipeTracker.bind(this));
|
|
|
|
|
2021-02-11 18:24:13 -05:00
|
|
|
this._layoutRowsNotifyId = workspaceManager.connect(
|
|
|
|
'notify::layout-rows', this._updateTrackerOrientation.bind(this));
|
|
|
|
this._updateTrackerOrientation();
|
|
|
|
|
2020-01-28 14:08:32 -05:00
|
|
|
this._windowDragBeginId =
|
|
|
|
Main.overview.connect('window-drag-begin',
|
|
|
|
this._windowDragBegin.bind(this));
|
|
|
|
this._windowDragEndId =
|
2020-12-27 14:33:34 -05:00
|
|
|
Main.overview.connect('window-drag-end',
|
2020-01-28 14:08:32 -05:00
|
|
|
this._windowDragEnd.bind(this));
|
2019-03-20 13:19:01 -04:00
|
|
|
|
2020-06-05 01:23:53 -04:00
|
|
|
this._primaryVisible = true;
|
2011-11-25 12:25:31 -05:00
|
|
|
this._primaryIndex = Main.layoutManager.primaryIndex;
|
2012-12-16 18:46:34 -05:00
|
|
|
this._workspacesViews = [];
|
2011-11-25 12:25:31 -05:00
|
|
|
|
2018-11-08 04:47:25 -05:00
|
|
|
this._settings = new Gio.Settings({ schema_id: MUTTER_SCHEMA });
|
2011-01-30 20:35:58 -05:00
|
|
|
|
2018-09-25 18:00:53 -04:00
|
|
|
this._restackedNotifyId = 0;
|
2012-10-22 11:39:46 -04:00
|
|
|
this._scrollEventId = 0;
|
2015-03-26 11:17:35 -04:00
|
|
|
this._keyPressEventId = 0;
|
2013-02-25 18:25:27 -05:00
|
|
|
|
2020-01-28 14:08:32 -05:00
|
|
|
this._inWindowDrag = false;
|
2021-01-13 17:24:49 -05:00
|
|
|
this._leavingOverview = false;
|
2019-08-12 10:25:48 -04:00
|
|
|
|
2019-07-07 13:51:55 -04:00
|
|
|
this._gestureActive = false; // touch(pad) gestures
|
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
2019-08-12 10:25:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
_onDestroy() {
|
|
|
|
if (this._parentSetLater) {
|
|
|
|
Meta.later_remove(this._parentSetLater);
|
|
|
|
this._parentSetLater = 0;
|
|
|
|
}
|
2019-07-07 13:51:55 -04:00
|
|
|
|
|
|
|
global.window_manager.disconnect(this._switchWorkspaceId);
|
|
|
|
global.workspace_manager.disconnect(this._reorderWorkspacesdId);
|
2021-02-11 18:24:13 -05:00
|
|
|
global.workspace_manager.disconnect(this._layoutRowsNotifyId);
|
2020-01-28 14:08:32 -05:00
|
|
|
Main.overview.disconnect(this._windowDragBeginId);
|
|
|
|
Main.overview.disconnect(this._windowDragEndId);
|
|
|
|
}
|
|
|
|
|
|
|
|
_windowDragBegin() {
|
|
|
|
this._inWindowDrag = true;
|
|
|
|
this._updateSwipeTracker();
|
|
|
|
}
|
|
|
|
|
|
|
|
_windowDragEnd() {
|
|
|
|
this._inWindowDrag = false;
|
|
|
|
this._updateSwipeTracker();
|
|
|
|
}
|
|
|
|
|
|
|
|
_updateSwipeTracker() {
|
2021-01-13 17:24:49 -05:00
|
|
|
this._swipeTracker.enabled =
|
|
|
|
this.mapped &&
|
|
|
|
!this._inWindowDrag &&
|
|
|
|
!this._leavingOverview;
|
2019-07-07 13:51:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
_workspacesReordered() {
|
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
|
|
|
|
this._scrollAdjustment.value =
|
|
|
|
workspaceManager.get_active_workspace_index();
|
|
|
|
}
|
|
|
|
|
2020-06-25 18:25:22 -04:00
|
|
|
_activeWorkspaceChanged(_wm, _from, to, _direction) {
|
2019-07-08 04:47:04 -04:00
|
|
|
if (this._gestureActive)
|
2019-07-07 13:51:55 -04:00
|
|
|
return;
|
|
|
|
|
2020-06-25 18:25:22 -04:00
|
|
|
this._scrollAdjustment.ease(to, {
|
2019-07-08 04:47:04 -04:00
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_CUBIC,
|
2019-07-07 13:51:55 -04:00
|
|
|
duration: WORKSPACE_SWITCH_TIME,
|
|
|
|
});
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-10-19 07:55:18 -04:00
|
|
|
|
2021-02-11 18:24:13 -05:00
|
|
|
_updateTrackerOrientation() {
|
|
|
|
const { layoutRows } = global.workspace_manager;
|
|
|
|
this._swipeTracker.orientation = layoutRows !== -1
|
|
|
|
? Clutter.Orientation.HORIZONTAL
|
|
|
|
: Clutter.Orientation.VERTICAL;
|
|
|
|
}
|
|
|
|
|
2019-07-08 04:47:04 -04: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-30 21:19:44 -04:00
|
|
|
}
|
2012-11-25 23:40:48 -05:00
|
|
|
|
2019-07-08 04:47:04 -04:00
|
|
|
_switchWorkspaceBegin(tracker, monitor) {
|
|
|
|
if (this._workspacesOnlyOnPrimary && monitor !== this._primaryIndex)
|
|
|
|
return;
|
2019-03-20 13:19:01 -04:00
|
|
|
|
2019-07-08 04:47:04 -04:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let adjustment = this._scrollAdjustment;
|
|
|
|
if (this._gestureActive)
|
|
|
|
adjustment.remove_transition('value');
|
|
|
|
|
2021-02-15 21:50:52 -05:00
|
|
|
const distance = global.workspace_manager.layout_rows === -1
|
|
|
|
? this.height : this.width;
|
|
|
|
|
2019-03-20 13:19:01 -04:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].startTouchGesture();
|
|
|
|
|
2019-07-08 04:47:04 -04:00
|
|
|
let progress = adjustment.value / adjustment.page_size;
|
|
|
|
let points = Array.from(
|
|
|
|
{ length: workspaceManager.n_workspaces }, (v, i) => i);
|
2019-03-20 13:19:01 -04:00
|
|
|
|
2019-07-08 04:47:04 -04:00
|
|
|
tracker.confirmSwipe(distance, points, progress, Math.round(progress));
|
|
|
|
|
|
|
|
this._gestureActive = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
_switchWorkspaceUpdate(tracker, progress) {
|
2019-03-20 13:19:01 -04:00
|
|
|
let adjustment = this._scrollAdjustment;
|
2019-07-08 04:47:04 -04:00
|
|
|
adjustment.value = progress * adjustment.page_size;
|
2019-03-20 13:19:01 -04:00
|
|
|
}
|
|
|
|
|
2019-07-08 04:47:04 -04:00
|
|
|
_switchWorkspaceEnd(tracker, duration, endProgress) {
|
2019-03-20 13:19:01 -04:00
|
|
|
let workspaceManager = global.workspace_manager;
|
2019-07-08 04:47:04 -04:00
|
|
|
let newWs = workspaceManager.get_workspace_by_index(endProgress);
|
|
|
|
|
|
|
|
this._scrollAdjustment.ease(endProgress, {
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_CUBIC,
|
|
|
|
duration,
|
|
|
|
onComplete: () => {
|
2020-06-29 10:50:27 -04:00
|
|
|
if (!newWs.active)
|
2019-07-08 04:47:04 -04:00
|
|
|
newWs.activate(global.get_current_time());
|
|
|
|
this._endTouchGesture();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2019-03-20 13:19:01 -04:00
|
|
|
|
2019-07-08 04:47:04 -04:00
|
|
|
_endTouchGesture() {
|
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].endTouchGesture();
|
|
|
|
this._gestureActive = false;
|
2019-03-20 13:19:01 -04:00
|
|
|
}
|
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
vfunc_navigate_focus(from, direction) {
|
2021-08-12 20:52:09 -04:00
|
|
|
return this._getPrimaryView()?.navigate_focus(from, direction, false);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-11-04 17:23:44 -05:00
|
|
|
|
2020-06-05 01:23:53 -04: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;
|
|
|
|
}
|
|
|
|
|
2021-01-02 14:17:17 -05:00
|
|
|
prepareToEnterOverview() {
|
2020-06-02 13:15:45 -04:00
|
|
|
this.show();
|
2011-11-25 12:25:31 -05:00
|
|
|
this._updateWorkspacesViews();
|
2020-05-20 07:39:11 -04:00
|
|
|
|
2011-01-30 20:44:05 -05:00
|
|
|
this._restackedNotifyId =
|
2012-12-13 11:00:30 -05:00
|
|
|
Main.overview.connect('windows-restacked',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onRestacked.bind(this));
|
2012-10-22 11:39:46 -04:00
|
|
|
if (this._scrollEventId == 0)
|
2017-12-01 19:27:35 -05:00
|
|
|
this._scrollEventId = Main.overview.connect('scroll-event', this._onScrollEvent.bind(this));
|
2015-03-26 11:17:35 -04:00
|
|
|
|
|
|
|
if (this._keyPressEventId == 0)
|
2017-12-01 19:27:35 -05:00
|
|
|
this._keyPressEventId = global.stage.connect('key-press-event', this._onKeyPressEvent.bind(this));
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2010-10-04 10:42:11 -04:00
|
|
|
|
2021-01-02 14:17:17 -05:00
|
|
|
prepareToLeaveOverview() {
|
2020-06-28 08:42:44 -04:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
2021-01-02 14:17:17 -05:00
|
|
|
this._workspacesViews[i].prepareToLeaveOverview();
|
2020-07-11 12:19:27 -04:00
|
|
|
|
2021-01-13 17:24:49 -05:00
|
|
|
this._leavingOverview = true;
|
|
|
|
this._updateSwipeTracker();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-11-25 18:02:13 -05:00
|
|
|
|
2020-06-02 13:15:45 -04:00
|
|
|
vfunc_hide() {
|
2019-01-28 20:27:05 -05:00
|
|
|
if (this._restackedNotifyId > 0) {
|
2012-12-13 11:00:30 -05:00
|
|
|
Main.overview.disconnect(this._restackedNotifyId);
|
2011-01-30 20:44:05 -05:00
|
|
|
this._restackedNotifyId = 0;
|
|
|
|
}
|
2012-10-22 11:39:46 -04:00
|
|
|
if (this._scrollEventId > 0) {
|
|
|
|
Main.overview.disconnect(this._scrollEventId);
|
|
|
|
this._scrollEventId = 0;
|
|
|
|
}
|
2015-03-26 11:17:35 -04:00
|
|
|
if (this._keyPressEventId > 0) {
|
|
|
|
global.stage.disconnect(this._keyPressEventId);
|
|
|
|
this._keyPressEventId = 0;
|
|
|
|
}
|
2011-11-25 12:25:31 -05:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].destroy();
|
2012-12-16 18:46:34 -05:00
|
|
|
this._workspacesViews = [];
|
2020-06-02 13:15:45 -04:00
|
|
|
|
2021-01-13 17:24:49 -05:00
|
|
|
this._leavingOverview = false;
|
|
|
|
|
2020-06-02 13:15:45 -04:00
|
|
|
super.vfunc_hide();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-11-25 12:25:31 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateWorkspacesViews() {
|
2012-12-16 18:46:34 -05:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].destroy();
|
2011-11-25 12:25:31 -05:00
|
|
|
|
2015-02-04 09:35:34 -05:00
|
|
|
this._primaryIndex = Main.layoutManager.primaryIndex;
|
2011-11-25 12:25:31 -05:00
|
|
|
this._workspacesViews = [];
|
|
|
|
let monitors = Main.layoutManager.monitors;
|
|
|
|
for (let i = 0; i < monitors.length; i++) {
|
2013-09-11 12:12:42 -04:00
|
|
|
let view;
|
2021-02-19 16:03:07 -05:00
|
|
|
if (i === this._primaryIndex) {
|
workspacesView: Interpolate against relative workspace boxes
The overview transition consists of getting the initial and final
states of the overview adjustment, derivating various other internal
states from them (such as the fit mode, opacities, translations, etc),
and finally interpolating the allocation boxes.
When interpolating between the fit mode, WorkspacesView uses the current
allocation box to derivate the SINGLE and ALL fit mode boxes. However,
that creates a curved path during overview transitions. What we really
want to do here is calculate the fit mode box relative to the corresponding
overview state. For example:
+----------------+----------+------------------------+
| Overview State | Fit Mode | Workspaces geometry |
+----------------+----------+------------------------+
| HIDDEN | SINGLE | Cover entire screen |
| WINDOW PICKER | SINGLE | Between minimap & Dash |
| APP GRID | ALL | 15% screen height |
+----------------+----------+------------------------+
Using the table above as the reference, when the overview transitions
between WINDOW PICKER and APP GRID, we must interpolate between
(SINGLE fit mode @ between minimap & Dash) and (ALL fit mode @ 15% screen
height). That way, we always interpolate the final boxes, which corrects
the odd path that workspaces follow during this transition.
Make the WorkspacesView of the primary monitor use these cached boxes
when the overview is in the middle of a transition, and the fit modes of
the initial and final state differ, to calculate the workspaces positions.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>
2021-02-02 14:34:59 -05:00
|
|
|
view = new WorkspacesView(i,
|
|
|
|
this._controls,
|
|
|
|
this._scrollAdjustment,
|
|
|
|
this._fitModeAdjustment,
|
|
|
|
this._overviewAdjustment);
|
2020-06-05 01:23:53 -04:00
|
|
|
|
2020-06-26 12:38:28 -04:00
|
|
|
view.visible = this._primaryVisible;
|
2021-01-14 18:23:15 -05:00
|
|
|
this.bind_property('opacity', view, 'opacity', GObject.BindingFlags.SYNC_CREATE);
|
2020-06-26 12:38:28 -04:00
|
|
|
this.add_child(view);
|
|
|
|
} else {
|
2021-02-19 16:03:07 -05:00
|
|
|
view = new SecondaryMonitorDisplay(i,
|
|
|
|
this._controls,
|
|
|
|
this._scrollAdjustment,
|
|
|
|
this._fitModeAdjustment,
|
|
|
|
this._overviewAdjustment);
|
2020-06-26 12:38:28 -04:00
|
|
|
Main.layoutManager.overviewGroup.add_actor(view);
|
|
|
|
}
|
2021-02-19 16:03:07 -05:00
|
|
|
|
|
|
|
this._workspacesViews.push(view);
|
2020-06-26 12:38:28 -04:00
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-11-25 12:25:31 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_getMonitorIndexForEvent(event) {
|
2016-06-24 12:15:48 -04:00
|
|
|
let [x, y] = event.get_coords();
|
2019-08-19 15:06:04 -04:00
|
|
|
let rect = new Meta.Rectangle({ x, y, width: 1, height: 1 });
|
2018-01-03 02:55:38 -05:00
|
|
|
return global.display.get_monitor_index_for_rect(rect);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2016-06-24 12:15:48 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_getPrimaryView() {
|
2012-12-16 18:46:34 -05:00
|
|
|
if (!this._workspacesViews.length)
|
2011-11-25 12:25:31 -05:00
|
|
|
return null;
|
2013-09-11 12:12:42 -04:00
|
|
|
return this._workspacesViews[this._primaryIndex];
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2010-02-14 18:32:57 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
activeWorkspaceHasMaximizedWindows() {
|
2021-01-04 11:42:26 -05:00
|
|
|
const primaryView = this._getPrimaryView();
|
|
|
|
return primaryView
|
|
|
|
? primaryView.getActiveWorkspace().hasMaximizedWindows()
|
|
|
|
: false;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-11-25 18:02:13 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onRestacked(overview, stackIndices) {
|
2011-11-25 12:25:31 -05:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].syncStacking(stackIndices);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-01-30 20:44:05 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onScrollEvent(actor, event) {
|
2019-07-08 04:47:04 -04:00
|
|
|
if (this._swipeTracker.canHandleScrollEvent(event))
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
if (!this.mapped)
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2016-05-26 12:51:30 -04:00
|
|
|
|
|
|
|
if (this._workspacesOnlyOnPrimary &&
|
|
|
|
this._getMonitorIndexForEvent(event) != this._primaryIndex)
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
2021-01-29 14:22:52 -05:00
|
|
|
return Main.wm.handleWorkspaceScroll(event);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2015-03-26 11:17:35 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onKeyPressEvent(actor, event) {
|
2021-04-08 11:31:54 -04:00
|
|
|
const { ControlsState } = OverviewControls;
|
|
|
|
if (this._overviewAdjustment.value !== ControlsState.WINDOW_PICKER)
|
2015-03-26 11:17:35 -04:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2021-04-08 11:19:37 -04:00
|
|
|
|
|
|
|
const { workspaceManager } = global;
|
|
|
|
const vertical = workspaceManager.layout_rows === -1;
|
|
|
|
const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
|
|
|
|
|
|
|
|
let dir;
|
2015-03-26 11:17:35 -04:00
|
|
|
switch (event.get_key_symbol()) {
|
|
|
|
case Clutter.KEY_Page_Up:
|
2021-04-08 11:19:37 -04:00
|
|
|
if (vertical)
|
|
|
|
dir = Meta.MotionDirection.UP;
|
|
|
|
else if (rtl)
|
|
|
|
dir = Meta.MotionDirection.RIGHT;
|
|
|
|
else
|
|
|
|
dir = Meta.MotionDirection.LEFT;
|
2015-03-26 11:17:35 -04:00
|
|
|
break;
|
|
|
|
case Clutter.KEY_Page_Down:
|
2021-04-08 11:19:37 -04:00
|
|
|
if (vertical)
|
|
|
|
dir = Meta.MotionDirection.DOWN;
|
|
|
|
else if (rtl)
|
|
|
|
dir = Meta.MotionDirection.LEFT;
|
|
|
|
else
|
|
|
|
dir = Meta.MotionDirection.RIGHT;
|
2015-03-26 11:17:35 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
}
|
2021-04-08 11:19:37 -04:00
|
|
|
|
|
|
|
const ws = workspaceManager.get_active_workspace().get_neighbor(dir);
|
|
|
|
if (ws)
|
|
|
|
Main.wm.actionMoveWorkspace(ws);
|
2015-03-26 11:17:35 -04:00
|
|
|
return Clutter.EVENT_STOP;
|
2010-02-14 18:32:57 -05:00
|
|
|
}
|
2020-12-29 16:51:40 -05:00
|
|
|
|
2021-02-19 16:03:07 -05:00
|
|
|
get _workspacesOnlyOnPrimary() {
|
|
|
|
return this._settings.get_boolean('workspaces-only-on-primary');
|
|
|
|
}
|
|
|
|
|
2020-12-29 16:51:40 -05:00
|
|
|
get fitModeAdjustment() {
|
|
|
|
return this._fitModeAdjustment;
|
|
|
|
}
|
2019-07-16 05:24:13 -04:00
|
|
|
});
|