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
|
|
|
|
2019-03-20 13:19:01 -04:00
|
|
|
const { Clutter, Gio, GObject, Meta, Shell, St } = imports.gi;
|
2010-01-21 21:33:48 -05:00
|
|
|
|
|
|
|
const Main = imports.ui.main;
|
2019-03-20 13:19:01 -04:00
|
|
|
const WindowManager = imports.ui.windowManager;
|
2010-01-21 21:33:48 -05:00
|
|
|
const Workspace = imports.ui.workspace;
|
|
|
|
|
2019-08-01 19:13:10 -04:00
|
|
|
var WORKSPACE_SWITCH_TIME = 250;
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2017-07-18 13:47:27 -04:00
|
|
|
var AnimationType = {
|
2014-07-14 13:06:08 -04:00
|
|
|
ZOOM: 0,
|
2019-08-20 17:43:54 -04:00
|
|
|
FADE: 1,
|
2014-07-14 13:06:08 -04:00
|
|
|
};
|
|
|
|
|
2018-11-08 04:47:25 -05:00
|
|
|
const MUTTER_SCHEMA = 'org.gnome.mutter';
|
2010-03-16 11:51:24 -04: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 {
|
|
|
|
_init(monitorIndex) {
|
|
|
|
super._init({ style_class: 'workspaces-view', reactive: true });
|
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
|
|
|
global.focus_manager.add_group(this);
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2011-01-30 20:35:58 -05:00
|
|
|
// The actor itself isn't a drop target, so we don't want to pick on its area
|
2019-07-16 05:24:13 -04:00
|
|
|
this.set_size(0, 0);
|
2011-01-30 20:35:58 -05:00
|
|
|
|
2013-09-11 12:12:42 -04:00
|
|
|
this._monitorIndex = monitorIndex;
|
2010-02-18 10:43:58 -05:00
|
|
|
|
2013-02-25 18:25:27 -05:00
|
|
|
this._fullGeometry = null;
|
2013-02-25 18:34:17 -05:00
|
|
|
this._actualGeometry = null;
|
2013-02-25 18:25:27 -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));
|
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;
|
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_dragBegin(overview, window) {
|
2013-09-11 12:12:42 -04:00
|
|
|
this._inDrag = true;
|
2014-09-03 15:55:05 -04:00
|
|
|
this._setReservedSlot(window);
|
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;
|
|
|
|
this._setReservedSlot(null);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setFullGeometry(geom) {
|
2013-09-11 12:12:42 -04:00
|
|
|
this._fullGeometry = geom;
|
2014-05-08 13:15:19 -04:00
|
|
|
this._syncFullGeometry();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setActualGeometry(geom) {
|
2013-09-11 12:12:42 -04:00
|
|
|
this._actualGeometry = geom;
|
2014-05-08 13:15:19 -04:00
|
|
|
this._syncActualGeometry();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2019-07-16 05:24:13 -04:00
|
|
|
});
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
var WorkspacesView = GObject.registerClass(
|
|
|
|
class WorkspacesView extends WorkspacesViewBase {
|
|
|
|
_init(monitorIndex) {
|
2018-01-03 02:55:38 -05:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
super._init(monitorIndex);
|
2013-09-11 10:09:13 -04:00
|
|
|
|
2010-11-12 04:28:28 -05:00
|
|
|
this._animating = false; // tweening
|
2011-01-21 13:47:54 -05:00
|
|
|
this._scrolling = false; // swipe-scrolling
|
2019-03-20 13:19:01 -04:00
|
|
|
this._gestureActive = false; // touch(pad) gestures
|
2019-05-15 15:32:29 -04:00
|
|
|
this._animatingScroll = false; // programmatically updating the adjustment
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2018-01-03 02:55:38 -05:00
|
|
|
let activeWorkspaceIndex = workspaceManager.get_active_workspace_index();
|
2013-09-11 10:09:13 -04:00
|
|
|
this.scrollAdjustment = new St.Adjustment({ value: activeWorkspaceIndex,
|
|
|
|
lower: 0,
|
|
|
|
page_increment: 1,
|
|
|
|
page_size: 1,
|
|
|
|
step_increment: 0,
|
2018-01-03 02:55:38 -05:00
|
|
|
upper: workspaceManager.n_workspaces });
|
2013-09-11 10:09:13 -04:00
|
|
|
this.scrollAdjustment.connect('notify::value',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onScroll.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();
|
|
|
|
});
|
|
|
|
this._updateWorkspaceActors(false);
|
|
|
|
});
|
|
|
|
|
2010-01-21 21:33:48 -05:00
|
|
|
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
this._overviewShownId =
|
2017-10-30 20:38:18 -04:00
|
|
|
Main.overview.connect('shown', () => {
|
2019-07-16 05:24:13 -04:00
|
|
|
this.set_clip(this._fullGeometry.x, this._fullGeometry.y,
|
|
|
|
this._fullGeometry.width, this._fullGeometry.height);
|
2017-10-30 20:38:18 -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));
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-11-25 09:44:17 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_setReservedSlot(window) {
|
2013-09-11 12:12:42 -04:00
|
|
|
for (let i = 0; i < this._workspaces.length; i++)
|
2014-09-03 10:03:24 -04:00
|
|
|
this._workspaces[i].setReservedSlot(window);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-11-25 09:44:17 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_syncFullGeometry() {
|
2013-09-11 10:09:13 -04:00
|
|
|
for (let i = 0; i < this._workspaces.length; i++)
|
|
|
|
this._workspaces[i].setFullGeometry(this._fullGeometry);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2014-05-08 13:15:19 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_syncActualGeometry() {
|
2013-09-11 10:09:13 -04:00
|
|
|
for (let i = 0; i < this._workspaces.length; i++)
|
|
|
|
this._workspaces[i].setActualGeometry(this._actualGeometry);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-09-11 10:09:13 -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
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
animateToOverview(animationType) {
|
2014-07-14 13:06:08 -04:00
|
|
|
for (let w = 0; w < this._workspaces.length; w++) {
|
|
|
|
if (animationType == AnimationType.ZOOM)
|
|
|
|
this._workspaces[w].zoomToOverview();
|
|
|
|
else
|
|
|
|
this._workspaces[w].fadeToOverview();
|
|
|
|
}
|
2013-10-30 18:19:18 -04:00
|
|
|
this._updateWorkspaceActors(false);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
animateFromOverview(animationType) {
|
2019-07-16 05:24:13 -04:00
|
|
|
this.remove_clip();
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
|
2014-07-14 13:06:08 -04:00
|
|
|
for (let w = 0; w < this._workspaces.length; w++) {
|
|
|
|
if (animationType == AnimationType.ZOOM)
|
|
|
|
this._workspaces[w].zoomFromOverview();
|
|
|
|
else
|
|
|
|
this._workspaces[w].fadeFromOverview();
|
|
|
|
}
|
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
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_scrollToActive() {
|
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
|
|
|
|
2012-11-25 23:54:11 -05:00
|
|
|
this._updateWorkspaceActors(true);
|
|
|
|
this._updateScrollAdjustment(active);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2010-02-10 00:56:36 -05:00
|
|
|
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
// Update workspace actors parameters
|
2010-03-22 19:01:44 -04:00
|
|
|
// @showAnimation: iff %true, transition between states
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateWorkspaceActors(showAnimation) {
|
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
|
|
|
|
2010-03-22 19:01:44 -04:00
|
|
|
this._animating = showAnimation;
|
|
|
|
|
2010-02-10 00:56:36 -05:00
|
|
|
for (let w = 0; w < this._workspaces.length; w++) {
|
|
|
|
let workspace = this._workspaces[w];
|
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
workspace.remove_all_transitions();
|
2010-03-22 19:01:44 -04:00
|
|
|
|
2019-06-04 15:49:23 -04:00
|
|
|
let params = {};
|
|
|
|
if (workspaceManager.layout_rows == -1)
|
|
|
|
params.y = (w - active) * this._fullGeometry.height;
|
2019-07-16 05:24:13 -04:00
|
|
|
else if (this.text_direction == Clutter.TextDirection.RTL)
|
2019-06-04 15:49:23 -04:00
|
|
|
params.x = (active - w) * this._fullGeometry.width;
|
|
|
|
else
|
|
|
|
params.x = (w - active) * this._fullGeometry.width;
|
2010-02-10 00:56:36 -05:00
|
|
|
|
|
|
|
if (showAnimation) {
|
2018-07-20 15:46:19 -04:00
|
|
|
let easeParams = Object.assign(params, {
|
|
|
|
duration: WORKSPACE_SWITCH_TIME,
|
2019-08-20 17:43:54 -04:00
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
2019-06-04 15:49:23 -04:00
|
|
|
});
|
2010-10-04 14:04:23 -04:00
|
|
|
// we have to call _updateVisibility() once before the
|
|
|
|
// animation and once afterwards - it does not really
|
|
|
|
// matter which tween we use, so we pick the first one ...
|
|
|
|
if (w == 0) {
|
|
|
|
this._updateVisibility();
|
2018-07-20 15:46:19 -04:00
|
|
|
easeParams.onComplete = () => {
|
2017-10-30 20:38:18 -04:00
|
|
|
this._animating = false;
|
|
|
|
this._updateVisibility();
|
|
|
|
};
|
2010-10-04 14:04:23 -04:00
|
|
|
}
|
2019-07-16 05:24:13 -04:00
|
|
|
workspace.ease(easeParams);
|
2010-01-21 21:33:48 -05:00
|
|
|
} else {
|
2019-07-16 05:24:13 -04:00
|
|
|
workspace.set(params);
|
2010-10-04 14:04:23 -04:00
|
|
|
if (w == 0)
|
|
|
|
this._updateVisibility();
|
2010-01-21 21:33:48 -05:00
|
|
|
}
|
2010-03-16 11:51:24 -04: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
|
|
|
_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
|
|
|
|
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
|
|
|
|
|
|
|
if (this._animating || this._scrolling || this._gestureActive)
|
2019-07-16 05:24:13 -04:00
|
|
|
workspace.show();
|
2019-08-19 22:10:46 -04:00
|
|
|
else if (this._inDrag)
|
|
|
|
workspace.visible = (Math.abs(w - active) <= 1);
|
|
|
|
else
|
|
|
|
workspace.visible = (w == active);
|
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
|
|
|
_updateScrollAdjustment(index) {
|
2019-03-20 13:19:01 -04:00
|
|
|
if (this._scrolling || this._gestureActive)
|
2010-02-10 00:56:36 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
this._animatingScroll = true;
|
|
|
|
|
2019-07-24 15:03:17 -04:00
|
|
|
this.scrollAdjustment.ease(index, {
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
duration: WORKSPACE_SWITCH_TIME,
|
2019-08-20 17:43:54 -04:00
|
|
|
onComplete: () => (this._animatingScroll = false),
|
2012-11-25 23:54:11 -05:00
|
|
|
});
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2010-02-10 00:56:36 -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
|
|
|
|
2013-09-11 11:47:56 -04:00
|
|
|
this.scrollAdjustment.upper = newNumWorkspaces;
|
2010-01-21 21:33:48 -05: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 */
|
|
|
|
workspace = new Workspace.Workspace(metaWorkspace, this._monitorIndex);
|
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
|
|
|
|
2014-05-08 13:15:19 -04:00
|
|
|
if (this._fullGeometry) {
|
2014-01-03 13:04:06 -05:00
|
|
|
this._updateWorkspaceActors(false);
|
2014-05-08 13:15:19 -04:00
|
|
|
this._syncFullGeometry();
|
|
|
|
}
|
|
|
|
if (this._actualGeometry)
|
|
|
|
this._syncActualGeometry();
|
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) {
|
2010-02-10 00:56:36 -05:00
|
|
|
if (this._scrolling)
|
|
|
|
return;
|
|
|
|
|
2012-11-25 23:54:11 -05: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
|
|
|
|
2011-11-28 11:51:53 -05:00
|
|
|
this.scrollAdjustment.run_dispose();
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
Main.overview.disconnect(this._overviewShownId);
|
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
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
startSwipeScroll() {
|
2011-01-21 13:47:54 -05:00
|
|
|
this._scrolling = true;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-01-21 13:47:54 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
endSwipeScroll() {
|
2011-01-21 13:47:54 -05:00
|
|
|
this._scrolling = false;
|
|
|
|
|
|
|
|
// Make sure title captions etc are shown as necessary
|
2012-11-25 23:40:48 -05:00
|
|
|
this._scrollToActive();
|
2011-01-21 13:47:54 -05:00
|
|
|
this._updateVisibility();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-01-21 13:47:54 -05:00
|
|
|
|
2019-03-20 13:19:01 -04:00
|
|
|
startTouchGesture() {
|
|
|
|
this._gestureActive = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
endTouchGesture() {
|
|
|
|
this._gestureActive = false;
|
|
|
|
|
|
|
|
// Make sure title captions etc are shown as necessary
|
|
|
|
this._scrollToActive();
|
|
|
|
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
|
2017-10-30 20:03:21 -04:00
|
|
|
_onScroll(adj) {
|
2010-02-10 00:56:36 -05:00
|
|
|
if (this._animatingScroll)
|
|
|
|
return;
|
|
|
|
|
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);
|
|
|
|
|
2019-03-20 13:19:01 -04:00
|
|
|
if (active != current && !this._gestureActive) {
|
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
|
|
|
}
|
|
|
|
|
|
|
|
if (adj.upper == 1)
|
|
|
|
return;
|
|
|
|
|
2019-06-04 15:49:23 -04:00
|
|
|
let last = this._workspaces.length - 1;
|
|
|
|
|
|
|
|
if (workspaceManager.layout_rows == -1) {
|
2019-07-16 05:24:13 -04:00
|
|
|
let firstWorkspaceY = this._workspaces[0].y;
|
|
|
|
let lastWorkspaceY = this._workspaces[last].y;
|
2019-06-04 15:49:23 -04:00
|
|
|
let workspacesHeight = lastWorkspaceY - firstWorkspaceY;
|
|
|
|
|
|
|
|
let currentY = firstWorkspaceY;
|
|
|
|
let newY = -adj.value / (adj.upper - 1) * workspacesHeight;
|
|
|
|
|
|
|
|
let dy = newY - currentY;
|
2010-02-10 00:56:36 -05:00
|
|
|
|
2019-06-04 15:49:23 -04:00
|
|
|
for (let i = 0; i < this._workspaces.length; i++) {
|
2019-07-16 05:24:13 -04:00
|
|
|
this._workspaces[i].visible = Math.abs(i - adj.value) <= 1;
|
|
|
|
this._workspaces[i].y += dy;
|
2019-06-04 15:49:23 -04:00
|
|
|
}
|
|
|
|
} else {
|
2019-07-16 05:24:13 -04:00
|
|
|
let firstWorkspaceX = this._workspaces[0].x;
|
|
|
|
let lastWorkspaceX = this._workspaces[last].x;
|
2019-06-04 15:49:23 -04:00
|
|
|
let workspacesWidth = lastWorkspaceX - firstWorkspaceX;
|
|
|
|
|
|
|
|
let currentX = firstWorkspaceX;
|
|
|
|
let newX = -adj.value / (adj.upper - 1) * workspacesWidth;
|
2010-02-10 00:56:36 -05:00
|
|
|
|
2019-06-04 15:49:23 -04:00
|
|
|
let dx = newX - currentX;
|
|
|
|
|
|
|
|
for (let i = 0; i < this._workspaces.length; i++) {
|
2019-07-16 05:24:13 -04:00
|
|
|
this._workspaces[i].visible = Math.abs(i - adj.value) <= 1;
|
|
|
|
this._workspaces[i].x += dx;
|
2019-06-04 15:49:23 -04:00
|
|
|
}
|
2010-02-10 00:56:36 -05:00
|
|
|
}
|
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 {
|
|
|
|
_init(monitorIndex) {
|
|
|
|
super._init(monitorIndex);
|
2013-09-11 12:12:42 -04:00
|
|
|
this._workspace = new Workspace.Workspace(null, monitorIndex);
|
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
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_setReservedSlot(window) {
|
2014-09-03 10:03:24 -04:00
|
|
|
this._workspace.setReservedSlot(window);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_syncFullGeometry() {
|
2013-09-11 12:12:42 -04:00
|
|
|
this._workspace.setFullGeometry(this._fullGeometry);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2014-05-08 13:15:19 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_syncActualGeometry() {
|
2013-09-11 12:12:42 -04:00
|
|
|
this._workspace.setActualGeometry(this._actualGeometry);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-09-11 12:12:42 -04:00
|
|
|
|
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
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
animateToOverview(animationType) {
|
2014-07-14 13:06:08 -04:00
|
|
|
if (animationType == AnimationType.ZOOM)
|
|
|
|
this._workspace.zoomToOverview();
|
|
|
|
else
|
|
|
|
this._workspace.fadeToOverview();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
animateFromOverview(animationType) {
|
2014-07-14 13:06:08 -04:00
|
|
|
if (animationType == AnimationType.ZOOM)
|
|
|
|
this._workspace.zoomFromOverview();
|
|
|
|
else
|
|
|
|
this._workspace.fadeFromOverview();
|
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
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
startSwipeScroll() {
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
endSwipeScroll() {
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2019-03-20 13:19:01 -04:00
|
|
|
|
|
|
|
startTouchGesture() {
|
|
|
|
}
|
|
|
|
|
|
|
|
endTouchGesture() {
|
|
|
|
}
|
2013-11-04 17:23:44 -05:00
|
|
|
});
|
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
var WorkspacesDisplay = GObject.registerClass(
|
|
|
|
class WorkspacesDisplay extends St.Widget {
|
|
|
|
_init() {
|
|
|
|
super._init({ clip_to_allocation: true });
|
|
|
|
this.connect('notify::allocation', this._updateWorkspacesActualGeometry.bind(this));
|
2012-12-13 14:19:44 -05:00
|
|
|
|
2015-03-25 19:05:07 -04:00
|
|
|
let clickAction = new Clutter.ClickAction();
|
2017-10-30 20:38:18 -04:00
|
|
|
clickAction.connect('clicked', action => {
|
2012-11-30 19:37:28 -05:00
|
|
|
// Only switch to the workspace when there's no application
|
|
|
|
// windows open. The problem is that it's too easy to miss
|
|
|
|
// an app window and get the wrong one focused.
|
2016-06-24 12:15:48 -04:00
|
|
|
let event = Clutter.get_current_event();
|
|
|
|
let index = this._getMonitorIndexForEvent(event);
|
2015-10-16 12:00:01 -04:00
|
|
|
if ((action.get_button() == 1 || action.get_button() == 0) &&
|
2016-06-24 12:15:48 -04:00
|
|
|
this._workspacesViews[index].getActiveWorkspace().isEmpty())
|
2012-11-30 19:37:28 -05:00
|
|
|
Main.overview.hide();
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2012-11-30 19:37:28 -05:00
|
|
|
Main.overview.addAction(clickAction);
|
2019-07-16 05:24:13 -04:00
|
|
|
this.bind_property('mapped', clickAction, 'enabled', GObject.BindingFlags.SYNC_CREATE);
|
2012-11-30 19:37:28 -05:00
|
|
|
|
2014-01-17 08:25:49 -05:00
|
|
|
let panAction = new Clutter.PanAction({ threshold_trigger_edge: Clutter.GestureTriggerEdge.AFTER });
|
2017-12-01 19:27:35 -05:00
|
|
|
panAction.connect('pan', this._onPan.bind(this));
|
2017-10-30 20:38:18 -04:00
|
|
|
panAction.connect('gesture-begin', () => {
|
2016-06-24 12:19:40 -04:00
|
|
|
if (this._workspacesOnlyOnPrimary) {
|
|
|
|
let event = Clutter.get_current_event();
|
|
|
|
if (this._getMonitorIndexForEvent(event) != this._primaryIndex)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-03-20 13:19:01 -04:00
|
|
|
this._startSwipeScroll();
|
2012-11-25 23:40:48 -05:00
|
|
|
return true;
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
|
|
|
panAction.connect('gesture-cancel', () => {
|
2016-06-24 12:10:28 -04:00
|
|
|
clickAction.release();
|
2019-03-20 13:19:01 -04:00
|
|
|
this._endSwipeScroll();
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
|
|
|
panAction.connect('gesture-end', () => {
|
2012-11-30 19:37:28 -05:00
|
|
|
clickAction.release();
|
2019-03-20 13:19:01 -04:00
|
|
|
this._endSwipeScroll();
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2012-11-30 19:37:28 -05:00
|
|
|
Main.overview.addAction(panAction);
|
2019-07-16 05:24:13 -04:00
|
|
|
this.bind_property('mapped', panAction, 'enabled', GObject.BindingFlags.SYNC_CREATE);
|
2010-10-04 10:42:11 -04:00
|
|
|
|
2019-03-20 13:19:01 -04:00
|
|
|
let allowedModes = Shell.ActionMode.OVERVIEW;
|
|
|
|
let switchGesture = new WindowManager.WorkspaceSwitchAction(allowedModes);
|
|
|
|
switchGesture.connect('motion', this._onSwitchWorkspaceMotion.bind(this));
|
|
|
|
switchGesture.connect('activated', this._onSwitchWorkspaceActivated.bind(this));
|
|
|
|
switchGesture.connect('cancel', this._endTouchGesture.bind(this));
|
|
|
|
Main.overview.addAction(switchGesture);
|
2019-07-16 05:24:13 -04:00
|
|
|
this.bind_property('mapped', switchGesture, 'enabled', GObject.BindingFlags.SYNC_CREATE);
|
2019-03-20 13:19:01 -04:00
|
|
|
|
|
|
|
switchGesture = new WindowManager.TouchpadWorkspaceSwitchAction(global.stage, allowedModes);
|
|
|
|
switchGesture.connect('motion', this._onSwitchWorkspaceMotion.bind(this));
|
|
|
|
switchGesture.connect('activated', this._onSwitchWorkspaceActivated.bind(this));
|
|
|
|
switchGesture.connect('cancel', this._endTouchGesture.bind(this));
|
|
|
|
|
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-11-25 12:25:31 -05:00
|
|
|
this._settings.connect('changed::workspaces-only-on-primary',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._workspacesOnlyOnPrimaryChanged.bind(this));
|
2011-11-25 12:25:31 -05:00
|
|
|
this._workspacesOnlyOnPrimaryChanged();
|
2011-01-30 20:35:58 -05:00
|
|
|
|
2011-11-25 18:02:13 -05:00
|
|
|
this._notifyOpacityId = 0;
|
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
|
|
|
|
|
|
|
this._fullGeometry = null;
|
2019-08-12 10:25:48 -04:00
|
|
|
|
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._notifyOpacityId) {
|
2019-07-16 05:24:13 -04:00
|
|
|
let parent = this.get_parent();
|
2019-08-12 10:25:48 -04:00
|
|
|
if (parent)
|
|
|
|
parent.disconnect(this._notifyOpacityId);
|
|
|
|
this._notifyOpacityId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._parentSetLater) {
|
|
|
|
Meta.later_remove(this._parentSetLater);
|
|
|
|
this._parentSetLater = 0;
|
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-10-19 07:55:18 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onPan(action) {
|
2019-01-31 09:08:00 -05:00
|
|
|
let [dist_, dx, dy] = action.get_motion_delta(0);
|
2012-11-25 23:40:48 -05:00
|
|
|
let adjustment = this._scrollAdjustment;
|
2019-06-04 15:49:23 -04:00
|
|
|
if (global.workspace_manager.layout_rows == -1)
|
2019-07-16 05:24:13 -04:00
|
|
|
adjustment.value -= (dy / this.height) * adjustment.page_size;
|
|
|
|
else if (this.text_direction == Clutter.TextDirection.RTL)
|
|
|
|
adjustment.value += (dx / this.width) * adjustment.page_size;
|
2019-06-04 15:49:23 -04:00
|
|
|
else
|
2019-07-16 05:24:13 -04:00
|
|
|
adjustment.value -= (dx / this.width) * adjustment.page_size;
|
2012-11-25 23:40:48 -05:00
|
|
|
return false;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-11-25 23:40:48 -05:00
|
|
|
|
2019-03-20 13:19:01 -04:00
|
|
|
_startSwipeScroll() {
|
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].startSwipeScroll();
|
|
|
|
}
|
|
|
|
|
|
|
|
_endSwipeScroll() {
|
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].endSwipeScroll();
|
|
|
|
}
|
|
|
|
|
|
|
|
_startTouchGesture() {
|
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].startTouchGesture();
|
|
|
|
}
|
|
|
|
|
|
|
|
_endTouchGesture() {
|
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].endTouchGesture();
|
|
|
|
}
|
|
|
|
|
|
|
|
_onSwitchWorkspaceMotion(action, xRel, yRel) {
|
|
|
|
// We don't have a way to hook into start of touchpad actions,
|
|
|
|
// luckily this is safe to call repeatedly.
|
|
|
|
this._startTouchGesture();
|
|
|
|
|
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let active = workspaceManager.get_active_workspace_index();
|
|
|
|
let adjustment = this._scrollAdjustment;
|
2019-06-04 15:49:23 -04:00
|
|
|
if (workspaceManager.layout_rows == -1)
|
2019-07-16 05:24:13 -04:00
|
|
|
adjustment.value = (active - yRel / this.height) * adjustment.page_size;
|
|
|
|
else if (this.text_direction == Clutter.TextDirection.RTL)
|
|
|
|
adjustment.value = (active + xRel / this.width) * adjustment.page_size;
|
2019-06-04 15:49:23 -04:00
|
|
|
else
|
2019-07-16 05:24:13 -04:00
|
|
|
adjustment.value = (active - xRel / this.width) * adjustment.page_size;
|
2019-03-20 13:19:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
_onSwitchWorkspaceActivated(action, direction) {
|
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let activeWorkspace = workspaceManager.get_active_workspace();
|
|
|
|
let newWs = activeWorkspace.get_neighbor(direction);
|
|
|
|
if (newWs != activeWorkspace)
|
|
|
|
newWs.activate(global.get_current_time());
|
|
|
|
|
|
|
|
this._endTouchGesture();
|
|
|
|
}
|
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
vfunc_navigate_focus(from, direction) {
|
|
|
|
return this._getPrimaryView().navigate_focus(from, direction, false);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-11-04 17:23:44 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
show(fadeOnPrimary) {
|
2011-11-25 12:25:31 -05:00
|
|
|
this._updateWorkspacesViews();
|
2014-07-14 13:06:08 -04:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++) {
|
|
|
|
let animationType;
|
|
|
|
if (fadeOnPrimary && i == this._primaryIndex)
|
|
|
|
animationType = AnimationType.FADE;
|
|
|
|
else
|
|
|
|
animationType = AnimationType.ZOOM;
|
|
|
|
this._workspacesViews[i].animateToOverview(animationType);
|
|
|
|
}
|
2010-02-14 18:32:57 -05: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
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
animateFromOverview(fadeOnPrimary) {
|
2014-07-14 13:06:08 -04:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++) {
|
|
|
|
let animationType;
|
|
|
|
if (fadeOnPrimary && i == this._primaryIndex)
|
|
|
|
animationType = AnimationType.FADE;
|
|
|
|
else
|
|
|
|
animationType = AnimationType.ZOOM;
|
|
|
|
this._workspacesViews[i].animateFromOverview(animationType);
|
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-11-25 18:02:13 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
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 = [];
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-11-25 12:25:31 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_workspacesOnlyOnPrimaryChanged() {
|
2011-11-25 12:25:31 -05:00
|
|
|
this._workspacesOnlyOnPrimary = this._settings.get_boolean('workspaces-only-on-primary');
|
|
|
|
|
|
|
|
if (!Main.overview.visible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._updateWorkspacesViews();
|
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;
|
2011-11-25 12:25:31 -05:00
|
|
|
if (this._workspacesOnlyOnPrimary && i != this._primaryIndex)
|
2013-09-11 12:12:42 -04:00
|
|
|
view = new ExtraWorkspaceView(i);
|
|
|
|
else
|
|
|
|
view = new WorkspacesView(i);
|
2011-11-25 12:25:31 -05:00
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
view.connect('scroll-event', this._onScrollEvent.bind(this));
|
2013-09-11 12:12:42 -04:00
|
|
|
if (i == this._primaryIndex) {
|
2011-11-28 11:51:53 -05:00
|
|
|
this._scrollAdjustment = view.scrollAdjustment;
|
|
|
|
this._scrollAdjustment.connect('notify::value',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._scrollValueChanged.bind(this));
|
2011-11-28 11:51:53 -05:00
|
|
|
}
|
2013-09-11 12:12:42 -04:00
|
|
|
|
2019-07-11 23:26:51 -04:00
|
|
|
// HACK: Avoid spurious allocation changes while updating views
|
2019-07-16 05:24:13 -04:00
|
|
|
view.hide();
|
2019-07-11 23:26:51 -04:00
|
|
|
|
2011-11-28 11:51:53 -05:00
|
|
|
this._workspacesViews.push(view);
|
2019-07-16 05:24:13 -04:00
|
|
|
Main.layoutManager.overviewGroup.add_actor(view);
|
2010-10-04 10:42:11 -04:00
|
|
|
}
|
2011-11-25 12:25:31 -05:00
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
this._workspacesViews.forEach(v => v.show());
|
2019-07-11 23:26:51 -04:00
|
|
|
|
2013-02-25 18:25:27 -05:00
|
|
|
this._updateWorkspacesFullGeometry();
|
2013-02-25 18:34:17 -05:00
|
|
|
this._updateWorkspacesActualGeometry();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-11-25 12:25:31 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_scrollValueChanged() {
|
2011-11-28 11:51:53 -05:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++) {
|
|
|
|
if (i == this._primaryIndex)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
let adjustment = this._workspacesViews[i].scrollAdjustment;
|
2013-09-11 12:12:42 -04:00
|
|
|
if (!adjustment)
|
|
|
|
continue;
|
|
|
|
|
2011-11-28 11:51:53 -05:00
|
|
|
// the adjustments work in terms of workspaces, so the
|
|
|
|
// values map directly
|
|
|
|
adjustment.value = this._scrollAdjustment.value;
|
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-11-28 11:51:53 -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() {
|
2011-11-25 12:25:31 -05:00
|
|
|
return this._getPrimaryView().getActiveWorkspace().hasMaximizedWindows();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-11-25 18:02:13 -05:00
|
|
|
|
2019-09-10 01:42:48 -04:00
|
|
|
vfunc_parent_set(oldParent) {
|
2011-11-25 18:02:13 -05:00
|
|
|
if (oldParent && this._notifyOpacityId)
|
|
|
|
oldParent.disconnect(this._notifyOpacityId);
|
|
|
|
this._notifyOpacityId = 0;
|
|
|
|
|
2019-08-12 10:25:48 -04:00
|
|
|
if (this._parentSetLater)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._parentSetLater = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
|
|
|
|
this._parentSetLater = 0;
|
2019-07-16 05:24:13 -04:00
|
|
|
let newParent = this.get_parent();
|
2017-10-30 20:38:18 -04:00
|
|
|
if (!newParent)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// This is kinda hackish - we want the primary view to
|
2019-07-16 05:24:13 -04:00
|
|
|
// appear as parent of this, though in reality it
|
2017-10-30 20:38:18 -04:00
|
|
|
// is added directly to Main.layoutManager.overviewGroup
|
|
|
|
this._notifyOpacityId = newParent.connect('notify::opacity', () => {
|
2019-07-16 05:24:13 -04:00
|
|
|
let opacity = this.get_parent().opacity;
|
2017-10-30 20:38:18 -04:00
|
|
|
let primaryView = this._getPrimaryView();
|
|
|
|
if (!primaryView)
|
2011-11-25 18:02:13 -05:00
|
|
|
return;
|
2019-07-16 05:24:13 -04:00
|
|
|
primaryView.opacity = opacity;
|
|
|
|
primaryView.visible = opacity != 0;
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
|
|
|
});
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-11-25 18:02:13 -05:00
|
|
|
|
2013-02-25 18:11:59 -05:00
|
|
|
// This geometry should always be the fullest geometry
|
|
|
|
// the workspaces switcher can ever be allocated, as if
|
|
|
|
// the sliding controls were never slid in at all.
|
2017-10-30 20:03:21 -04:00
|
|
|
setWorkspacesFullGeometry(geom) {
|
2013-02-25 18:25:27 -05:00
|
|
|
this._fullGeometry = geom;
|
|
|
|
this._updateWorkspacesFullGeometry();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-02-25 18:11:59 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateWorkspacesFullGeometry() {
|
2012-12-16 18:46:34 -05:00
|
|
|
if (!this._workspacesViews.length)
|
2011-02-10 17:15:36 -05:00
|
|
|
return;
|
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
let monitors = Main.layoutManager.monitors;
|
|
|
|
for (let i = 0; i < monitors.length; i++) {
|
2013-09-11 12:12:42 -04:00
|
|
|
let geometry = (i == this._primaryIndex) ? this._fullGeometry : monitors[i];
|
|
|
|
this._workspacesViews[i].setFullGeometry(geometry);
|
2011-11-25 12:25:31 -05:00
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-01-30 22:54:05 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateWorkspacesActualGeometry() {
|
2013-02-25 18:34:17 -05:00
|
|
|
if (!this._workspacesViews.length)
|
|
|
|
return;
|
|
|
|
|
2019-07-16 05:24:13 -04:00
|
|
|
let [x, y] = this.get_transformed_position();
|
|
|
|
let allocation = this.allocation;
|
2014-05-08 13:17:26 -04:00
|
|
|
let width = allocation.x2 - allocation.x1;
|
|
|
|
let height = allocation.y2 - allocation.y1;
|
2019-08-19 15:06:04 -04:00
|
|
|
let primaryGeometry = { x, y, width, height };
|
2013-02-25 18:34:17 -05:00
|
|
|
|
|
|
|
let monitors = Main.layoutManager.monitors;
|
|
|
|
for (let i = 0; i < monitors.length; i++) {
|
2013-09-11 12:12:42 -04:00
|
|
|
let geometry = (i == this._primaryIndex) ? primaryGeometry : monitors[i];
|
|
|
|
this._workspacesViews[i].setActualGeometry(geometry);
|
2013-02-25 18:34:17 -05:00
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-02-25 18:34:17 -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-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;
|
|
|
|
|
2018-01-03 02:55:38 -05:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let activeWs = workspaceManager.get_active_workspace();
|
2013-05-18 14:53:49 -04:00
|
|
|
let ws;
|
2012-10-22 11:39:46 -04:00
|
|
|
switch (event.get_scroll_direction()) {
|
|
|
|
case Clutter.ScrollDirection.UP:
|
2013-05-18 14:53:49 -04:00
|
|
|
ws = activeWs.get_neighbor(Meta.MotionDirection.UP);
|
|
|
|
break;
|
2012-10-22 11:39:46 -04:00
|
|
|
case Clutter.ScrollDirection.DOWN:
|
2013-05-18 14:53:49 -04:00
|
|
|
ws = activeWs.get_neighbor(Meta.MotionDirection.DOWN);
|
|
|
|
break;
|
2019-06-04 15:49:23 -04:00
|
|
|
case Clutter.ScrollDirection.LEFT:
|
|
|
|
ws = activeWs.get_neighbor(Meta.MotionDirection.LEFT);
|
|
|
|
break;
|
|
|
|
case Clutter.ScrollDirection.RIGHT:
|
|
|
|
ws = activeWs.get_neighbor(Meta.MotionDirection.RIGHT);
|
|
|
|
break;
|
2013-05-18 14:53:49 -04:00
|
|
|
default:
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2012-10-22 11:39:46 -04:00
|
|
|
}
|
2013-05-18 14:53:49 -04:00
|
|
|
Main.wm.actionMoveWorkspace(ws);
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_STOP;
|
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) {
|
2019-07-16 05:24:13 -04:00
|
|
|
if (!this.mapped)
|
2015-03-26 11:17:35 -04:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2018-01-03 02:55:38 -05:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let activeWs = workspaceManager.get_active_workspace();
|
2015-03-26 11:17:35 -04: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 18:32:57 -05:00
|
|
|
}
|
2019-07-16 05:24:13 -04:00
|
|
|
});
|