2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2010-01-21 21:33:48 -05:00
|
|
|
|
|
|
|
const Clutter = imports.gi.Clutter;
|
2011-11-25 09:44:17 -05:00
|
|
|
const Gio = imports.gi.Gio;
|
2012-11-25 23:40:48 -05:00
|
|
|
const GObject = imports.gi.GObject;
|
2010-01-21 21:33:48 -05:00
|
|
|
const Lang = imports.lang;
|
|
|
|
const Mainloop = imports.mainloop;
|
2011-01-30 16:38:13 -05:00
|
|
|
const Meta = imports.gi.Meta;
|
2010-01-21 21:33:48 -05:00
|
|
|
const Shell = imports.gi.Shell;
|
|
|
|
const St = imports.gi.St;
|
|
|
|
const Signals = imports.signals;
|
|
|
|
|
|
|
|
const DND = imports.ui.dnd;
|
|
|
|
const Main = imports.ui.main;
|
|
|
|
const Overview = imports.ui.overview;
|
|
|
|
const Tweener = imports.ui.tweener;
|
|
|
|
const Workspace = imports.ui.workspace;
|
2011-01-30 21:18:12 -05:00
|
|
|
const WorkspaceThumbnail = imports.ui.workspaceThumbnail;
|
2010-01-21 21:33:48 -05:00
|
|
|
|
|
|
|
const WORKSPACE_SWITCH_TIME = 0.25;
|
|
|
|
// Note that mutter has a compile-time limit of 36
|
|
|
|
const MAX_WORKSPACES = 16;
|
|
|
|
|
2011-11-25 09:44:17 -05:00
|
|
|
const OVERRIDE_SCHEMA = 'org.gnome.shell.overrides';
|
2010-03-16 11:51:24 -04:00
|
|
|
|
2010-10-04 10:42:11 -04:00
|
|
|
const CONTROLS_POP_IN_TIME = 0.1;
|
2010-11-12 04:28:28 -05:00
|
|
|
|
|
|
|
|
2011-11-20 12:56:27 -05:00
|
|
|
const WorkspacesView = new Lang.Class({
|
|
|
|
Name: 'WorkspacesView',
|
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
|
|
|
_init: function(workspaces) {
|
2012-02-14 11:33:26 -05:00
|
|
|
this.actor = new St.Widget({ style_class: 'workspaces-view' });
|
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
|
|
|
|
this.actor.set_size(0, 0);
|
|
|
|
|
2010-02-18 10:43:58 -05:00
|
|
|
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
|
|
|
|
2010-02-10 01:00:02 -05:00
|
|
|
this.actor.connect('style-changed', Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
let node = this.actor.get_theme_node();
|
StThemeNode: simplify use of get_color/get_double/get_length
Although within St itself there are situations where the semantics of
these functions (return TRUE or FALSE and return the actual value in
an out parameter) is useful, it's mostly just annoying at the
application level, where you generally know that the CSS property is
going to specified, and there is no especially sane fallback if it's
not.
So rename the current methods to lookup_color, lookup_double, and
lookup_length, and add new get_color, get_double, and get_length
methods that don't take an "inherit" parameter, and return their
values directly. (Well, except for get_color, due to the lack of (out
caller-allocates) in gjs.)
And update the code to use either the old or new methods as appropriate.
https://bugzilla.gnome.org/show_bug.cgi?id=632590
2010-09-26 17:38:36 -04:00
|
|
|
this._spacing = node.get_length('spacing');
|
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._updateWorkspaceActors(false);
|
2010-02-10 01:00:02 -05:00
|
|
|
}));
|
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._width = 0;
|
|
|
|
this._height = 0;
|
|
|
|
this._x = 0;
|
|
|
|
this._y = 0;
|
workspaces-view: Handle clip rectangle separately
After completing the overview transition, the workspace view is
clipped to avoid overlapping the search entry/view selector titles
while switching workspaces. For clipping, the view's position and
size was used, which works well assuming that the workspace pager
will start hidden or stay zoomed out while the overview is visible.
However, that assumption holds no longer true, as auto-hiding the
pager now depends on the number of workspaces, and thus may change
while in the overview. For instance, when starting with the pager
being visible, the clip area ends up being too small when moving
all windows to the first workspace (and thus triggering auto-hide).
As a fix, handle the clip rectangle separately from the view's
geometry, and set it always to the area the workspaces would
occupy with the pager hidden.
https://bugzilla.gnome.org/show_bug.cgi?id=653142
2011-06-21 18:28:42 -04:00
|
|
|
this._clipX = 0;
|
|
|
|
this._clipY = 0;
|
|
|
|
this._clipWidth = 0;
|
|
|
|
this._clipHeight = 0;
|
2010-02-10 01:00:02 -05:00
|
|
|
this._spacing = 0;
|
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
|
2010-11-12 04:28:28 -05:00
|
|
|
this._animatingScroll = false; // programatically updating the adjustment
|
2011-01-30 20:35:58 -05:00
|
|
|
this._zoomOut = false; // zoom to a larger area
|
2010-11-12 04:28:28 -05:00
|
|
|
this._inDrag = false; // dragging a window
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2011-11-25 09:44:17 -05:00
|
|
|
this._settings = new Gio.Settings({ schema: OVERRIDE_SCHEMA });
|
|
|
|
this._updateExtraWorkspacesId =
|
|
|
|
this._settings.connect('changed::workspaces-only-on-primary',
|
|
|
|
Lang.bind(this, this._updateExtraWorkspaces));
|
|
|
|
|
2010-01-21 21:33:48 -05:00
|
|
|
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
|
2010-02-14 18:32:57 -05:00
|
|
|
this._workspaces = workspaces;
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2010-02-14 18:32:57 -05:00
|
|
|
// Add workspace actors
|
2010-11-15 15:58:27 -05:00
|
|
|
for (let w = 0; w < global.screen.n_workspaces; w++)
|
2010-03-21 20:39:49 -04:00
|
|
|
this._workspaces[w].actor.reparent(this.actor);
|
2010-01-21 21:33:48 -05:00
|
|
|
this._workspaces[activeWorkspaceIndex].actor.raise_top();
|
|
|
|
|
2012-03-30 14:31:25 -04:00
|
|
|
this._extraWorkspaces = [];
|
2011-11-25 09:44:17 -05:00
|
|
|
this._updateExtraWorkspaces();
|
2011-03-03 16:33:27 -05:00
|
|
|
|
2010-01-21 21:33:48 -05:00
|
|
|
// Position/scale the desktop windows and their children after the
|
|
|
|
// workspaces have been created. This cannot be done first because
|
|
|
|
// window movement depends on the Workspaces object being accessible
|
|
|
|
// as an Overview member.
|
|
|
|
this._overviewShowingId =
|
|
|
|
Main.overview.connect('showing',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
for (let w = 0; w < this._workspaces.length; w++)
|
2010-02-14 18:32:57 -05:00
|
|
|
this._workspaces[w].zoomToOverview();
|
2011-03-03 16:33:27 -05:00
|
|
|
for (let w = 0; w < this._extraWorkspaces.length; w++)
|
|
|
|
this._extraWorkspaces[w].zoomToOverview();
|
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 =
|
|
|
|
Main.overview.connect('shown',
|
|
|
|
Lang.bind(this, function() {
|
workspaces-view: Handle clip rectangle separately
After completing the overview transition, the workspace view is
clipped to avoid overlapping the search entry/view selector titles
while switching workspaces. For clipping, the view's position and
size was used, which works well assuming that the workspace pager
will start hidden or stay zoomed out while the overview is visible.
However, that assumption holds no longer true, as auto-hiding the
pager now depends on the number of workspaces, and thus may change
while in the overview. For instance, when starting with the pager
being visible, the clip area ends up being too small when moving
all windows to the first workspace (and thus triggering auto-hide).
As a fix, handle the clip rectangle separately from the view's
geometry, and set it always to the area the workspaces would
occupy with the pager hidden.
https://bugzilla.gnome.org/show_bug.cgi?id=653142
2011-06-21 18:28:42 -04:00
|
|
|
this.actor.set_clip(this._clipX, this._clipY,
|
|
|
|
this._clipWidth, this._clipHeight);
|
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
|
|
|
}));
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2011-11-28 11:51:53 -05:00
|
|
|
this.scrollAdjustment = new St.Adjustment({ value: activeWorkspaceIndex,
|
|
|
|
lower: 0,
|
|
|
|
page_increment: 1,
|
|
|
|
page_size: 1,
|
|
|
|
step_increment: 0,
|
|
|
|
upper: this._workspaces.length });
|
|
|
|
this.scrollAdjustment.connect('notify::value',
|
|
|
|
Lang.bind(this, this._onScroll));
|
2010-11-12 04:28:28 -05:00
|
|
|
|
2010-01-21 21:33:48 -05:00
|
|
|
this._switchWorkspaceNotifyId =
|
|
|
|
global.window_manager.connect('switch-workspace',
|
|
|
|
Lang.bind(this, this._activeWorkspaceChanged));
|
2010-11-12 04:28:28 -05:00
|
|
|
|
|
|
|
this._itemDragBeginId = Main.overview.connect('item-drag-begin',
|
|
|
|
Lang.bind(this, this._dragBegin));
|
|
|
|
this._itemDragEndId = Main.overview.connect('item-drag-end',
|
|
|
|
Lang.bind(this, this._dragEnd));
|
2010-11-15 15:58:27 -05:00
|
|
|
this._windowDragBeginId = Main.overview.connect('window-drag-begin',
|
|
|
|
Lang.bind(this, this._dragBegin));
|
|
|
|
this._windowDragEndId = Main.overview.connect('window-drag-end',
|
|
|
|
Lang.bind(this, this._dragEnd));
|
2010-01-21 21:33:48 -05:00
|
|
|
},
|
|
|
|
|
2011-11-25 09:44:17 -05:00
|
|
|
_updateExtraWorkspaces: function() {
|
|
|
|
this._destroyExtraWorkspaces();
|
|
|
|
|
|
|
|
if (!this._settings.get_boolean('workspaces-only-on-primary'))
|
|
|
|
return;
|
|
|
|
|
|
|
|
let monitors = Main.layoutManager.monitors;
|
|
|
|
for (let i = 0; i < monitors.length; i++) {
|
|
|
|
if (i == Main.layoutManager.primaryIndex)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
let ws = new Workspace.Workspace(null, i);
|
2012-12-10 15:39:15 -05:00
|
|
|
ws.setGeometry(monitors[i].x,
|
|
|
|
monitors[i].y,
|
|
|
|
monitors[i].width,
|
|
|
|
monitors[i].height);
|
2011-11-25 09:44:17 -05:00
|
|
|
global.overlay_group.add_actor(ws.actor);
|
|
|
|
this._extraWorkspaces.push(ws);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_destroyExtraWorkspaces: function() {
|
|
|
|
for (let m = 0; m < this._extraWorkspaces.length; m++)
|
|
|
|
this._extraWorkspaces[m].destroy();
|
2012-03-30 14:31:25 -04:00
|
|
|
this._extraWorkspaces = [];
|
2011-11-25 09:44:17 -05:00
|
|
|
},
|
|
|
|
|
2012-08-09 11:38:36 -04:00
|
|
|
setGeometry: function(x, y, width, height) {
|
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
|
|
|
if (this._x == x && this._y == y &&
|
|
|
|
this._width == width && this._height == height)
|
|
|
|
return;
|
2012-08-09 11:38:36 -04: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._width = width;
|
|
|
|
this._height = height;
|
|
|
|
this._x = x;
|
|
|
|
this._y = y;
|
2011-02-10 17:15: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
|
|
|
for (let i = 0; i < this._workspaces.length; i++)
|
|
|
|
this._workspaces[i].setGeometry(x, y, width, height);
|
2011-02-10 17:15:36 -05:00
|
|
|
},
|
|
|
|
|
workspaces-view: Handle clip rectangle separately
After completing the overview transition, the workspace view is
clipped to avoid overlapping the search entry/view selector titles
while switching workspaces. For clipping, the view's position and
size was used, which works well assuming that the workspace pager
will start hidden or stay zoomed out while the overview is visible.
However, that assumption holds no longer true, as auto-hiding the
pager now depends on the number of workspaces, and thus may change
while in the overview. For instance, when starting with the pager
being visible, the clip area ends up being too small when moving
all windows to the first workspace (and thus triggering auto-hide).
As a fix, handle the clip rectangle separately from the view's
geometry, and set it always to the area the workspaces would
occupy with the pager hidden.
https://bugzilla.gnome.org/show_bug.cgi?id=653142
2011-06-21 18:28:42 -04:00
|
|
|
setClipRect: function(x, y, width, height) {
|
|
|
|
this._clipX = x;
|
|
|
|
this._clipY = y;
|
|
|
|
this._clipWidth = width;
|
|
|
|
this._clipHeight = height;
|
|
|
|
},
|
|
|
|
|
2010-01-21 21:33:48 -05:00
|
|
|
_lookupWorkspaceForMetaWindow: function (metaWindow) {
|
|
|
|
for (let i = 0; i < this._workspaces.length; i++) {
|
|
|
|
if (this._workspaces[i].containsMetaWindow(metaWindow))
|
|
|
|
return this._workspaces[i];
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
2010-07-15 10:21:32 -04:00
|
|
|
getActiveWorkspace: function() {
|
|
|
|
let active = global.screen.get_active_workspace_index();
|
|
|
|
return this._workspaces[active];
|
|
|
|
},
|
|
|
|
|
2010-01-21 21:33:48 -05:00
|
|
|
hide: function() {
|
|
|
|
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
|
|
|
|
let activeWorkspace = this._workspaces[activeWorkspaceIndex];
|
|
|
|
|
|
|
|
activeWorkspace.actor.raise_top();
|
|
|
|
|
2012-07-18 20:21:58 -04:00
|
|
|
this.actor.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
|
|
|
|
2010-01-21 21:33:48 -05:00
|
|
|
for (let w = 0; w < this._workspaces.length; w++)
|
|
|
|
this._workspaces[w].zoomFromOverview();
|
2011-03-03 16:33:27 -05:00
|
|
|
for (let w = 0; w < this._extraWorkspaces.length; w++)
|
|
|
|
this._extraWorkspaces[w].zoomFromOverview();
|
2010-01-21 21:33:48 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
2010-02-18 10:43:58 -05:00
|
|
|
this.actor.destroy();
|
|
|
|
},
|
|
|
|
|
2011-01-30 20:44:05 -05:00
|
|
|
syncStacking: function(stackIndices) {
|
2010-01-21 21:33:48 -05:00
|
|
|
for (let i = 0; i < this._workspaces.length; i++)
|
|
|
|
this._workspaces[i].syncStacking(stackIndices);
|
2011-03-03 16:33:27 -05:00
|
|
|
for (let i = 0; i < this._extraWorkspaces.length; i++)
|
|
|
|
this._extraWorkspaces[i].syncStacking(stackIndices);
|
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
|
|
|
updateWindowPositions: function() {
|
|
|
|
for (let w = 0; w < this._workspaces.length; w++)
|
|
|
|
this._workspaces[w].positionWindows(Workspace.WindowPositionFlags.ANIMATE);
|
2010-02-15 08:29:34 -05:00
|
|
|
},
|
|
|
|
|
2012-11-25 23:54:11 -05:00
|
|
|
_scrollToActive: function() {
|
2010-02-10 00:56:36 -05:00
|
|
|
let active = global.screen.get_active_workspace_index();
|
|
|
|
|
2012-11-25 23:54:11 -05:00
|
|
|
this._updateWorkspaceActors(true);
|
|
|
|
this._updateScrollAdjustment(active);
|
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
|
2010-03-16 11:51:24 -04:00
|
|
|
_updateWorkspaceActors: function(showAnimation) {
|
2010-02-10 00:56:36 -05:00
|
|
|
let active = global.screen.get_active_workspace_index();
|
|
|
|
|
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];
|
|
|
|
|
2010-03-22 19:01:44 -04:00
|
|
|
Tweener.removeTweens(workspace.actor);
|
|
|
|
|
2012-08-09 11:38:36 -04:00
|
|
|
let y = (w - active) * (this._height + this._spacing);
|
2010-02-10 00:56:36 -05:00
|
|
|
|
|
|
|
if (showAnimation) {
|
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
|
|
|
let params = { y: y,
|
2010-10-04 14:04:23 -04:00
|
|
|
time: WORKSPACE_SWITCH_TIME,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
};
|
|
|
|
// 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();
|
|
|
|
params.onComplete = Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
this._animating = false;
|
|
|
|
this._updateVisibility();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
Tweener.addTween(workspace.actor, params);
|
2010-01-21 21:33:48 -05:00
|
|
|
} else {
|
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
|
|
|
workspace.actor.set_position(0, y);
|
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
|
|
|
}
|
2010-03-22 19:01:44 -04:00
|
|
|
},
|
2010-02-11 09:52:49 -05:00
|
|
|
|
2010-03-22 19:01:44 -04:00
|
|
|
_updateVisibility: function() {
|
|
|
|
let active = global.screen.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];
|
|
|
|
if (this._animating || this._scrolling) {
|
|
|
|
workspace.actor.show();
|
2010-02-11 09:52:49 -05:00
|
|
|
} else {
|
2010-03-22 19:01:44 -04:00
|
|
|
if (this._inDrag)
|
|
|
|
workspace.actor.visible = (Math.abs(w - active) <= 1);
|
|
|
|
else
|
|
|
|
workspace.actor.visible = (w == active);
|
2010-02-11 09:52:49 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-11-25 23:54:11 -05:00
|
|
|
_updateScrollAdjustment: function(index) {
|
2010-07-11 08:41:17 -04:00
|
|
|
if (this._scrolling)
|
2010-02-10 00:56:36 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
this._animatingScroll = true;
|
|
|
|
|
2012-11-25 23:54:11 -05:00
|
|
|
Tweener.addTween(this.scrollAdjustment, {
|
|
|
|
value: index,
|
|
|
|
time: WORKSPACE_SWITCH_TIME,
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
onComplete: Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
this._animatingScroll = false;
|
|
|
|
})
|
|
|
|
});
|
2010-02-10 00:56:36 -05:00
|
|
|
},
|
|
|
|
|
2011-05-31 22:23:12 -04:00
|
|
|
updateWorkspaces: function(oldNumWorkspaces, newNumWorkspaces) {
|
2010-05-19 13:26:41 -04:00
|
|
|
let active = global.screen.get_active_workspace_index();
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2011-11-28 11:51:53 -05:00
|
|
|
Tweener.addTween(this.scrollAdjustment,
|
2010-07-11 08:41:17 -04:00
|
|
|
{ upper: newNumWorkspaces,
|
|
|
|
time: WORKSPACE_SWITCH_TIME,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
2010-01-21 21:33:48 -05:00
|
|
|
|
|
|
|
if (newNumWorkspaces > oldNumWorkspaces) {
|
2011-06-01 08:47:51 -04:00
|
|
|
for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++) {
|
|
|
|
this._workspaces[w].setGeometry(this._x, this._y,
|
|
|
|
this._width, this._height);
|
2010-03-21 20:39:49 -04:00
|
|
|
this.actor.add_actor(this._workspaces[w].actor);
|
2011-06-01 08:47:51 -04:00
|
|
|
}
|
2010-02-14 18:32:57 -05:00
|
|
|
|
2010-03-22 19:01:44 -04:00
|
|
|
this._updateWorkspaceActors(false);
|
2010-01-21 21:33:48 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_activeWorkspaceChanged: function(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();
|
2010-01-21 21:33:48 -05:00
|
|
|
},
|
|
|
|
|
2010-03-16 11:51:24 -04:00
|
|
|
_onDestroy: function() {
|
2011-11-25 09:44:17 -05:00
|
|
|
this._destroyExtraWorkspaces();
|
2011-11-28 11:51:53 -05:00
|
|
|
this.scrollAdjustment.run_dispose();
|
2010-11-12 04:28:28 -05:00
|
|
|
Main.overview.disconnect(this._overviewShowingId);
|
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);
|
2011-11-25 09:44:17 -05:00
|
|
|
this._settings.disconnect(this._updateExtraWorkspacesId);
|
2010-11-12 04:28:28 -05:00
|
|
|
|
2011-03-13 14:34:47 -04:00
|
|
|
if (this._inDrag)
|
|
|
|
this._dragEnd();
|
|
|
|
|
2010-05-08 10:06:28 -04:00
|
|
|
if (this._itemDragBeginId > 0) {
|
|
|
|
Main.overview.disconnect(this._itemDragBeginId);
|
|
|
|
this._itemDragBeginId = 0;
|
|
|
|
}
|
|
|
|
if (this._itemDragEndId > 0) {
|
|
|
|
Main.overview.disconnect(this._itemDragEndId);
|
|
|
|
this._itemDragEndId = 0;
|
|
|
|
}
|
2010-11-15 15:58:27 -05:00
|
|
|
if (this._windowDragBeginId > 0) {
|
|
|
|
Main.overview.disconnect(this._windowDragBeginId);
|
|
|
|
this._windowDragBeginId = 0;
|
|
|
|
}
|
|
|
|
if (this._windowDragEndId > 0) {
|
|
|
|
Main.overview.disconnect(this._windowDragEndId);
|
|
|
|
this._windowDragEndId = 0;
|
2010-03-22 15:52:50 -04:00
|
|
|
}
|
2010-03-16 11:51:24 -04:00
|
|
|
},
|
|
|
|
|
2010-05-08 10:06:28 -04:00
|
|
|
_dragBegin: function() {
|
2010-07-11 08:41:17 -04:00
|
|
|
if (this._scrolling)
|
2010-03-16 11:51:24 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
this._inDrag = true;
|
2011-03-04 09:49:13 -05:00
|
|
|
this._firstDragMotion = true;
|
2010-03-16 11:51:24 -04:00
|
|
|
|
2010-06-06 11:24:51 -04:00
|
|
|
this._dragMonitor = {
|
|
|
|
dragMotion: Lang.bind(this, this._onDragMotion)
|
|
|
|
};
|
|
|
|
DND.addDragMonitor(this._dragMonitor);
|
2010-03-16 11:51:24 -04:00
|
|
|
},
|
|
|
|
|
2010-06-06 11:24:51 -04:00
|
|
|
_onDragMotion: function(dragEvent) {
|
2011-01-05 09:47:27 -05:00
|
|
|
if (Main.overview.animationInProgress)
|
|
|
|
return DND.DragMotionResult.CONTINUE;
|
|
|
|
|
2011-03-04 09:49:13 -05:00
|
|
|
if (this._firstDragMotion) {
|
|
|
|
this._firstDragMotion = false;
|
|
|
|
for (let i = 0; i < this._workspaces.length; i++)
|
|
|
|
this._workspaces[i].setReservedSlot(dragEvent.dragActor._delegate);
|
|
|
|
for (let i = 0; i < this._extraWorkspaces.length; i++)
|
|
|
|
this._extraWorkspaces[i].setReservedSlot(dragEvent.dragActor._delegate);
|
|
|
|
}
|
|
|
|
|
2011-10-03 19:27:07 -04:00
|
|
|
return DND.DragMotionResult.CONTINUE;
|
2010-03-16 11:51:24 -04:00
|
|
|
},
|
|
|
|
|
2010-05-08 10:06:28 -04:00
|
|
|
_dragEnd: function() {
|
2011-06-27 12:59:56 -04:00
|
|
|
DND.removeDragMonitor(this._dragMonitor);
|
2010-03-16 11:51:24 -04:00
|
|
|
this._inDrag = false;
|
|
|
|
|
|
|
|
for (let i = 0; i < this._workspaces.length; i++)
|
|
|
|
this._workspaces[i].setReservedSlot(null);
|
2011-03-04 09:49:13 -05:00
|
|
|
for (let i = 0; i < this._extraWorkspaces.length; i++)
|
|
|
|
this._extraWorkspaces[i].setReservedSlot(null);
|
2010-03-16 11:51:24 -04:00
|
|
|
},
|
|
|
|
|
2011-11-28 11:51:53 -05:00
|
|
|
startSwipeScroll: function() {
|
2011-01-21 13:47:54 -05:00
|
|
|
this._scrolling = true;
|
|
|
|
},
|
|
|
|
|
2012-11-25 23:40:48 -05:00
|
|
|
endSwipeScroll: function() {
|
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();
|
|
|
|
},
|
|
|
|
|
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
|
|
|
|
_onScroll: function(adj) {
|
|
|
|
if (this._animatingScroll)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let active = global.screen.get_active_workspace_index();
|
|
|
|
let current = Math.round(adj.value);
|
|
|
|
|
|
|
|
if (active != current) {
|
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
|
|
|
}
|
|
|
|
|
|
|
|
let last = this._workspaces.length - 1;
|
2011-01-30 18:21:31 -05:00
|
|
|
let firstWorkspaceY = this._workspaces[0].actor.y;
|
|
|
|
let lastWorkspaceY = this._workspaces[last].actor.y;
|
|
|
|
let workspacesHeight = lastWorkspaceY - firstWorkspaceY;
|
2010-02-10 00:56:36 -05:00
|
|
|
|
|
|
|
if (adj.upper == 1)
|
|
|
|
return;
|
|
|
|
|
2011-01-30 18:21:31 -05:00
|
|
|
let currentY = firstWorkspaceY;
|
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
|
|
|
let newY = - adj.value / (adj.upper - 1) * workspacesHeight;
|
2010-02-10 00:56:36 -05:00
|
|
|
|
2011-01-30 18:21:31 -05:00
|
|
|
let dy = newY - currentY;
|
2010-02-10 00:56:36 -05:00
|
|
|
|
|
|
|
for (let i = 0; i < this._workspaces.length; i++) {
|
2010-03-16 11:51:24 -04:00
|
|
|
this._workspaces[i].actor.visible = Math.abs(i - adj.value) <= 1;
|
2011-01-30 18:21:31 -05:00
|
|
|
this._workspaces[i].actor.y += dy;
|
2010-02-10 00:56:36 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-10-04 10:42:11 -04:00
|
|
|
_getWorkspaceIndexToRemove: function() {
|
|
|
|
return global.screen.get_active_workspace_index();
|
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2010-10-04 10:42:11 -04:00
|
|
|
Signals.addSignalMethods(WorkspacesView.prototype);
|
|
|
|
|
|
|
|
|
2011-11-20 12:56:27 -05:00
|
|
|
const WorkspacesDisplay = new Lang.Class({
|
|
|
|
Name: 'WorkspacesDisplay',
|
2010-02-14 18:32:57 -05:00
|
|
|
|
2010-07-29 03:55:08 -04:00
|
|
|
_init: function() {
|
2011-01-30 22:54:05 -05:00
|
|
|
this.actor = new Shell.GenericContainer();
|
|
|
|
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
|
|
|
|
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
|
|
|
|
this.actor.connect('allocate', Lang.bind(this, this._allocate));
|
2011-11-25 18:02:13 -05:00
|
|
|
this.actor.connect('parent-set', Lang.bind(this, this._parentSet));
|
2011-03-08 04:04:49 -05:00
|
|
|
this.actor.set_clip_to_allocation(true);
|
2012-11-30 19:37:28 -05:00
|
|
|
|
|
|
|
let clickAction = new Clutter.ClickAction()
|
|
|
|
clickAction.connect('clicked', Lang.bind(this, function(action) {
|
|
|
|
// 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.
|
|
|
|
if (action.get_button() == 1 &&
|
|
|
|
this._getPrimaryView().getActiveWorkspace().isEmpty())
|
|
|
|
Main.overview.hide();
|
|
|
|
}));
|
|
|
|
Main.overview.addAction(clickAction);
|
|
|
|
this.actor.bind_property('mapped', clickAction, 'enabled', GObject.BindingFlags.SYNC_CREATE);
|
|
|
|
|
|
|
|
let panAction = new Clutter.PanAction();
|
|
|
|
panAction.connect('pan', Lang.bind(this, this._onPan));
|
|
|
|
panAction.connect('gesture-begin', Lang.bind(this, function() {
|
2012-11-25 23:40:48 -05:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].startSwipeScroll();
|
|
|
|
return true;
|
|
|
|
}));
|
2012-11-30 19:37:28 -05:00
|
|
|
panAction.connect('gesture-end', Lang.bind(this, function() {
|
|
|
|
clickAction.release();
|
2012-11-25 23:40:48 -05:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].endSwipeScroll();
|
|
|
|
}));
|
2012-11-30 19:37:28 -05:00
|
|
|
Main.overview.addAction(panAction);
|
|
|
|
this.actor.bind_property('mapped', panAction, 'enabled', GObject.BindingFlags.SYNC_CREATE);
|
2010-10-04 10:42:11 -04:00
|
|
|
|
2011-02-09 18:54:46 -05:00
|
|
|
let controls = new St.Bin({ style_class: 'workspace-controls',
|
|
|
|
request_mode: Clutter.RequestMode.WIDTH_FOR_HEIGHT,
|
2011-02-12 15:23:27 -05:00
|
|
|
y_align: St.Align.START,
|
|
|
|
y_fill: true });
|
2011-01-30 20:35:58 -05:00
|
|
|
this._controls = controls;
|
|
|
|
this.actor.add_actor(controls);
|
|
|
|
|
|
|
|
controls.reactive = true;
|
|
|
|
controls.track_hover = true;
|
|
|
|
controls.connect('notify::hover',
|
|
|
|
Lang.bind(this, this._onControlsHoverChanged));
|
2011-02-12 04:11:20 -05:00
|
|
|
controls.connect('scroll-event',
|
|
|
|
Lang.bind(this, this._onScrollEvent));
|
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
this._primaryIndex = Main.layoutManager.primaryIndex;
|
2010-10-04 10:42:11 -04:00
|
|
|
|
2011-02-09 15:48:11 -05:00
|
|
|
this._thumbnailsBox = new WorkspaceThumbnail.ThumbnailsBox();
|
2011-02-09 18:54:46 -05:00
|
|
|
controls.add_actor(this._thumbnailsBox.actor);
|
2011-01-30 21:18:12 -05:00
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
this._workspacesViews = null;
|
2011-11-28 11:51:53 -05:00
|
|
|
this._primaryScrollAdjustment = null;
|
2011-11-25 12:25:31 -05:00
|
|
|
|
|
|
|
this._settings = new Gio.Settings({ schema: OVERRIDE_SCHEMA });
|
|
|
|
this._settings.connect('changed::workspaces-only-on-primary',
|
|
|
|
Lang.bind(this,
|
|
|
|
this._workspacesOnlyOnPrimaryChanged));
|
|
|
|
this._workspacesOnlyOnPrimaryChanged();
|
2011-01-30 20:35:58 -05:00
|
|
|
|
|
|
|
this._inDrag = false;
|
2011-03-08 08:50:34 -05:00
|
|
|
this._cancelledDrag = false;
|
2011-03-18 09:49:27 -04:00
|
|
|
|
2012-03-12 20:58:34 -04:00
|
|
|
this._controlsInitiallyHovered = false;
|
2011-03-18 09:49:27 -04:00
|
|
|
this._alwaysZoomOut = false;
|
2011-01-30 20:35:58 -05:00
|
|
|
this._zoomOut = false;
|
2011-01-30 22:54:05 -05:00
|
|
|
this._zoomFraction = 0;
|
2011-01-30 20:35:58 -05:00
|
|
|
|
2011-03-18 09:49:27 -04:00
|
|
|
this._updateAlwaysZoom();
|
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
// If we stop hiding the overview on layout changes, we will need to
|
|
|
|
// update the _workspacesViews here
|
2011-06-13 09:54:05 -04:00
|
|
|
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._updateAlwaysZoom));
|
2011-06-21 16:02:32 -04:00
|
|
|
|
2011-03-21 18:20:36 -04:00
|
|
|
Main.xdndHandler.connect('drag-begin', Lang.bind(this, function(){
|
|
|
|
this._alwaysZoomOut = true;
|
|
|
|
}));
|
|
|
|
|
|
|
|
Main.xdndHandler.connect('drag-end', Lang.bind(this, function(){
|
|
|
|
this._alwaysZoomOut = false;
|
|
|
|
this._updateAlwaysZoom();
|
|
|
|
}));
|
2011-03-18 09:49:27 -04:00
|
|
|
|
2012-03-28 09:25:33 -04:00
|
|
|
global.screen.connect('notify::n-workspaces',
|
|
|
|
Lang.bind(this, this._workspacesChanged));
|
|
|
|
|
2011-01-30 20:35:58 -05:00
|
|
|
this._switchWorkspaceNotifyId = 0;
|
|
|
|
|
|
|
|
this._itemDragBeginId = 0;
|
2011-03-09 10:53:26 -05:00
|
|
|
this._itemDragCancelledId = 0;
|
2011-01-30 20:35:58 -05:00
|
|
|
this._itemDragEndId = 0;
|
|
|
|
this._windowDragBeginId = 0;
|
2011-03-08 08:50:34 -05:00
|
|
|
this._windowDragCancelledId = 0;
|
2011-01-30 20:35:58 -05:00
|
|
|
this._windowDragEndId = 0;
|
2011-11-25 18:02:13 -05:00
|
|
|
this._notifyOpacityId = 0;
|
2011-11-28 11:51:53 -05:00
|
|
|
this._swipeScrollBeginId = 0;
|
|
|
|
this._swipeScrollEndId = 0;
|
2012-10-19 07:55:18 -04:00
|
|
|
|
|
|
|
this._settings = new Gio.Settings({ schema: OVERRIDE_SCHEMA });
|
|
|
|
this._settings.connect('changed::dynamic-workspaces',
|
|
|
|
Lang.bind(this, this._updateSwitcherVisibility));
|
|
|
|
},
|
|
|
|
|
2012-11-25 23:40:48 -05:00
|
|
|
_onPan: function(action) {
|
|
|
|
let [dist, dx, dy] = action.get_motion_delta(0);
|
|
|
|
let adjustment = this._scrollAdjustment;
|
|
|
|
adjustment.value -= (dy / this.actor.height) * adjustment.page_size;
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2012-10-19 07:55:18 -04:00
|
|
|
_updateSwitcherVisibility: function() {
|
|
|
|
this._thumbnailsBox.actor.visible =
|
|
|
|
this._settings.get_boolean('dynamic-workspaces') ||
|
|
|
|
global.screen.n_workspaces > 1;
|
2010-02-14 18:32:57 -05:00
|
|
|
},
|
|
|
|
|
2011-09-01 16:09:46 -04:00
|
|
|
show: function() {
|
2012-03-12 20:58:34 -04:00
|
|
|
if(!this._alwaysZoomOut) {
|
|
|
|
let [mouseX, mouseY] = global.get_pointer();
|
|
|
|
let [x, y] = this._controls.get_transformed_position();
|
|
|
|
let [width, height] = this._controls.get_transformed_size();
|
|
|
|
let visibleWidth = this._controls.get_theme_node().get_length('visible-width');
|
|
|
|
let rtl = (Clutter.get_default_text_direction () == Clutter.TextDirection.RTL);
|
|
|
|
if(rtl)
|
|
|
|
x = x + width - visibleWidth;
|
|
|
|
if(mouseX > x - 0.5 && mouseX < x + visibleWidth + 0.5 &&
|
|
|
|
mouseY > y - 0.5 && mouseY < y + height + 0.5)
|
|
|
|
this._controlsInitiallyHovered = true;
|
|
|
|
}
|
|
|
|
|
2011-03-22 07:46:56 -04:00
|
|
|
this._zoomOut = this._alwaysZoomOut;
|
|
|
|
this._zoomFraction = this._alwaysZoomOut ? 1 : 0;
|
|
|
|
this._updateZoom();
|
|
|
|
|
2011-01-30 20:35:58 -05:00
|
|
|
this._controls.show();
|
2011-02-09 15:48:11 -05:00
|
|
|
this._thumbnailsBox.show();
|
2012-10-19 07:55:18 -04:00
|
|
|
this._updateSwitcherVisibility();
|
2010-10-04 10:42:11 -04:00
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
this._updateWorkspacesViews();
|
2010-02-14 18:32:57 -05:00
|
|
|
|
2011-01-30 20:44:05 -05:00
|
|
|
this._restackedNotifyId =
|
|
|
|
global.screen.connect('restacked',
|
|
|
|
Lang.bind(this, this._onRestacked));
|
|
|
|
|
2011-01-30 20:35:58 -05:00
|
|
|
if (this._itemDragBeginId == 0)
|
|
|
|
this._itemDragBeginId = Main.overview.connect('item-drag-begin',
|
|
|
|
Lang.bind(this, this._dragBegin));
|
2011-03-09 10:53:26 -05:00
|
|
|
if (this._itemDragCancelledId == 0)
|
|
|
|
this._itemDragCancelledId = Main.overview.connect('item-drag-cancelled',
|
|
|
|
Lang.bind(this, this._dragCancelled));
|
2011-01-30 20:35:58 -05:00
|
|
|
if (this._itemDragEndId == 0)
|
|
|
|
this._itemDragEndId = Main.overview.connect('item-drag-end',
|
|
|
|
Lang.bind(this, this._dragEnd));
|
|
|
|
if (this._windowDragBeginId == 0)
|
|
|
|
this._windowDragBeginId = Main.overview.connect('window-drag-begin',
|
|
|
|
Lang.bind(this, this._dragBegin));
|
2011-03-08 08:50:34 -05:00
|
|
|
if (this._windowDragCancelledId == 0)
|
|
|
|
this._windowDragCancelledId = Main.overview.connect('window-drag-cancelled',
|
|
|
|
Lang.bind(this, this._dragCancelled));
|
2011-01-30 20:35:58 -05:00
|
|
|
if (this._windowDragEndId == 0)
|
|
|
|
this._windowDragEndId = Main.overview.connect('window-drag-end',
|
|
|
|
Lang.bind(this, this._dragEnd));
|
2011-01-30 20:44:05 -05:00
|
|
|
|
|
|
|
this._onRestacked();
|
2010-10-04 10:42:11 -04:00
|
|
|
},
|
|
|
|
|
2011-11-25 18:02:13 -05:00
|
|
|
zoomFromOverview: function() {
|
2011-11-25 12:25:31 -05:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++) {
|
|
|
|
this._workspacesViews[i].hide();
|
|
|
|
}
|
2011-11-25 18:02:13 -05:00
|
|
|
},
|
|
|
|
|
2010-10-04 10:42:11 -04:00
|
|
|
hide: function() {
|
2011-01-30 20:35:58 -05:00
|
|
|
this._controls.hide();
|
2011-02-09 15:48:11 -05:00
|
|
|
this._thumbnailsBox.hide();
|
2010-10-04 10:42:11 -04:00
|
|
|
|
2012-03-12 20:58:34 -04:00
|
|
|
if (!this._alwaysZoomOut)
|
|
|
|
this.zoomFraction = 0;
|
|
|
|
|
2011-01-30 20:44:05 -05:00
|
|
|
if (this._restackedNotifyId > 0){
|
|
|
|
global.screen.disconnect(this._restackedNotifyId);
|
|
|
|
this._restackedNotifyId = 0;
|
|
|
|
}
|
2011-01-30 20:35:58 -05:00
|
|
|
if (this._itemDragBeginId > 0) {
|
|
|
|
Main.overview.disconnect(this._itemDragBeginId);
|
|
|
|
this._itemDragBeginId = 0;
|
|
|
|
}
|
2011-03-09 10:53:26 -05:00
|
|
|
if (this._itemDragCancelledId > 0) {
|
|
|
|
Main.overview.disconnect(this._itemDragCancelledId);
|
|
|
|
this._itemDragCancelledId = 0;
|
|
|
|
}
|
|
|
|
if (this._itemDragEndId > 0) {
|
2011-01-30 20:35:58 -05:00
|
|
|
Main.overview.disconnect(this._itemDragEndId);
|
|
|
|
this._itemDragEndId = 0;
|
|
|
|
}
|
|
|
|
if (this._windowDragBeginId > 0) {
|
|
|
|
Main.overview.disconnect(this._windowDragBeginId);
|
|
|
|
this._windowDragBeginId = 0;
|
|
|
|
}
|
2011-03-08 08:50:34 -05:00
|
|
|
if (this._windowDragCancelledId > 0) {
|
|
|
|
Main.overview.disconnect(this._windowDragCancelledId);
|
|
|
|
this._windowDragCancelledId = 0;
|
|
|
|
}
|
2011-01-30 20:35:58 -05:00
|
|
|
if (this._windowDragEndId > 0) {
|
|
|
|
Main.overview.disconnect(this._windowDragEndId);
|
|
|
|
this._windowDragEndId = 0;
|
|
|
|
}
|
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].destroy();
|
|
|
|
this._workspacesViews = null;
|
|
|
|
|
|
|
|
for (let i = 0; i < this._workspaces.length; i++)
|
|
|
|
for (let w = 0; w < this._workspaces[i].length; w++) {
|
|
|
|
this._workspaces[i][w].disconnectAll();
|
|
|
|
this._workspaces[i][w].destroy();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_workspacesOnlyOnPrimaryChanged: function() {
|
|
|
|
this._workspacesOnlyOnPrimary = this._settings.get_boolean('workspaces-only-on-primary');
|
|
|
|
|
|
|
|
if (!Main.overview.visible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._updateWorkspacesViews();
|
|
|
|
},
|
|
|
|
|
|
|
|
_updateWorkspacesViews: function() {
|
|
|
|
if (this._workspacesViews)
|
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].destroy();
|
|
|
|
|
|
|
|
if (this._workspaces)
|
|
|
|
for (let i = 0; i < this._workspaces.length; i++)
|
|
|
|
for (let w = 0; w < this._workspaces[i].length; w++)
|
|
|
|
this._workspaces[i][w].destroy();
|
|
|
|
|
|
|
|
this._workspacesViews = [];
|
|
|
|
this._workspaces = [];
|
|
|
|
let monitors = Main.layoutManager.monitors;
|
|
|
|
for (let i = 0; i < monitors.length; i++) {
|
|
|
|
if (this._workspacesOnlyOnPrimary && i != this._primaryIndex)
|
|
|
|
continue; // we are only interested in the primary monitor
|
|
|
|
|
|
|
|
let monitorWorkspaces = [];
|
|
|
|
for (let w = 0; w < global.screen.n_workspaces; w++) {
|
|
|
|
let metaWorkspace = global.screen.get_workspace_by_index(w);
|
|
|
|
monitorWorkspaces.push(new Workspace.Workspace(metaWorkspace, i));
|
|
|
|
}
|
|
|
|
|
|
|
|
this._workspaces.push(monitorWorkspaces);
|
2011-11-28 11:51:53 -05:00
|
|
|
|
|
|
|
let view = new WorkspacesView(monitorWorkspaces);
|
|
|
|
if (this._workspacesOnlyOnPrimary || i == this._primaryIndex) {
|
|
|
|
this._scrollAdjustment = view.scrollAdjustment;
|
|
|
|
this._scrollAdjustment.connect('notify::value',
|
|
|
|
Lang.bind(this, this._scrollValueChanged));
|
|
|
|
}
|
|
|
|
this._workspacesViews.push(view);
|
2010-10-04 10:42:11 -04:00
|
|
|
}
|
2011-11-25 12:25:31 -05:00
|
|
|
|
|
|
|
this._updateWorkspacesGeometry();
|
|
|
|
|
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
global.overlay_group.add_actor(this._workspacesViews[i].actor);
|
|
|
|
},
|
|
|
|
|
2011-11-28 11:51:53 -05:00
|
|
|
_scrollValueChanged: function() {
|
|
|
|
if (this._workspacesOnlyOnPrimary)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++) {
|
|
|
|
if (i == this._primaryIndex)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
let adjustment = this._workspacesViews[i].scrollAdjustment;
|
|
|
|
// the adjustments work in terms of workspaces, so the
|
|
|
|
// values map directly
|
|
|
|
adjustment.value = this._scrollAdjustment.value;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
_getPrimaryView: function() {
|
|
|
|
if (!this._workspacesViews)
|
|
|
|
return null;
|
|
|
|
if (this._workspacesOnlyOnPrimary)
|
|
|
|
return this._workspacesViews[0];
|
|
|
|
else
|
|
|
|
return this._workspacesViews[this._primaryIndex];
|
2010-02-14 18:32:57 -05:00
|
|
|
},
|
|
|
|
|
2011-11-25 18:02:13 -05:00
|
|
|
activeWorkspaceHasMaximizedWindows: function() {
|
2011-11-25 12:25:31 -05:00
|
|
|
return this._getPrimaryView().getActiveWorkspace().hasMaximizedWindows();
|
2011-11-25 18:02:13 -05:00
|
|
|
},
|
|
|
|
|
2011-01-30 22:54:05 -05:00
|
|
|
// zoomFraction property allows us to tween the controls sliding in and out
|
|
|
|
set zoomFraction(fraction) {
|
|
|
|
this._zoomFraction = fraction;
|
|
|
|
this.actor.queue_relayout();
|
|
|
|
},
|
|
|
|
|
|
|
|
get zoomFraction() {
|
|
|
|
return this._zoomFraction;
|
|
|
|
},
|
|
|
|
|
2011-03-18 09:49:27 -04:00
|
|
|
_updateAlwaysZoom: function() {
|
2011-06-16 08:10:15 -04:00
|
|
|
// Always show the pager if workspaces are actually used,
|
|
|
|
// e.g. there are windows on more than one
|
|
|
|
this._alwaysZoomOut = global.screen.n_workspaces > 2;
|
|
|
|
|
|
|
|
if (this._alwaysZoomOut)
|
|
|
|
return;
|
2011-03-18 09:49:27 -04:00
|
|
|
|
2011-06-13 09:54:05 -04:00
|
|
|
let monitors = Main.layoutManager.monitors;
|
|
|
|
let primary = Main.layoutManager.primaryMonitor;
|
2011-03-18 09:49:27 -04:00
|
|
|
|
|
|
|
/* Look for any monitor to the right of the primary, if there is
|
|
|
|
* one, we always keep zoom out, otherwise its hard to reach
|
|
|
|
* the thumbnail area without passing into the next monitor. */
|
|
|
|
for (let i = 0; i < monitors.length; i++) {
|
|
|
|
if (monitors[i].x >= primary.x + primary.width) {
|
|
|
|
this._alwaysZoomOut = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-01-30 22:54:05 -05:00
|
|
|
_getPreferredWidth: function (actor, forHeight, alloc) {
|
|
|
|
// pass through the call in case the child needs it, but report 0x0
|
|
|
|
this._controls.get_preferred_width(forHeight);
|
|
|
|
},
|
|
|
|
|
|
|
|
_getPreferredHeight: function (actor, forWidth, alloc) {
|
|
|
|
// pass through the call in case the child needs it, but report 0x0
|
|
|
|
this._controls.get_preferred_height(forWidth);
|
|
|
|
},
|
|
|
|
|
|
|
|
_allocate: function (actor, box, flags) {
|
|
|
|
let childBox = new Clutter.ActorBox();
|
|
|
|
|
|
|
|
let totalWidth = box.x2 - box.x1;
|
|
|
|
|
|
|
|
// width of the controls
|
|
|
|
let [controlsMin, controlsNatural] = this._controls.get_preferred_width(box.y2 - box.y1);
|
|
|
|
|
|
|
|
// Amount of space on the screen we reserve for the visible control
|
2011-02-09 19:07:27 -05:00
|
|
|
let controlsVisible = this._controls.get_theme_node().get_length('visible-width');
|
|
|
|
let controlsReserved = controlsVisible * (1 - this._zoomFraction) + controlsNatural * this._zoomFraction;
|
2011-01-30 22:54:05 -05:00
|
|
|
|
2012-02-13 20:37:28 -05:00
|
|
|
let rtl = (Clutter.get_default_text_direction () == Clutter.TextDirection.RTL);
|
2011-01-30 22:54:05 -05:00
|
|
|
if (rtl) {
|
|
|
|
childBox.x2 = controlsReserved;
|
|
|
|
childBox.x1 = childBox.x2 - controlsNatural;
|
|
|
|
} else {
|
|
|
|
childBox.x1 = totalWidth - controlsReserved;
|
|
|
|
childBox.x2 = childBox.x1 + controlsNatural;
|
|
|
|
}
|
|
|
|
|
|
|
|
childBox.y1 = 0;
|
|
|
|
childBox.y2 = box.y2- box.y1;
|
|
|
|
this._controls.allocate(childBox, flags);
|
2011-02-10 17:15: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
|
|
|
this._updateWorkspacesGeometry();
|
2011-02-10 17:15:36 -05:00
|
|
|
},
|
|
|
|
|
2011-11-25 18:02:13 -05:00
|
|
|
_parentSet: function(actor, oldParent) {
|
|
|
|
if (oldParent && this._notifyOpacityId)
|
|
|
|
oldParent.disconnect(this._notifyOpacityId);
|
|
|
|
this._notifyOpacityId = 0;
|
|
|
|
|
|
|
|
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
let newParent = this.actor.get_parent();
|
|
|
|
if (!newParent)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// This is kinda hackish - we want the primary view to
|
|
|
|
// appear as parent of this.actor, though in reality it
|
|
|
|
// is added directly to overlay_group
|
|
|
|
this._notifyOpacityId = newParent.connect('notify::opacity',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
let opacity = this.actor.get_parent().opacity;
|
2011-11-25 12:25:31 -05:00
|
|
|
let primaryView = this._getPrimaryView();
|
|
|
|
if (!primaryView)
|
|
|
|
return;
|
|
|
|
primaryView.actor.opacity = opacity;
|
2012-03-16 18:53:14 -04:00
|
|
|
primaryView.actor.visible = opacity != 0;
|
2011-11-25 18:02:13 -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
|
|
|
_updateWorkspacesGeometry: function() {
|
2011-11-25 12:25:31 -05:00
|
|
|
if (!this._workspacesViews)
|
2011-02-10 17:15:36 -05:00
|
|
|
return;
|
|
|
|
|
2011-03-11 19:03:20 -05:00
|
|
|
let fullWidth = this.actor.allocation.x2 - this.actor.allocation.x1;
|
|
|
|
let fullHeight = this.actor.allocation.y2 - this.actor.allocation.y1;
|
|
|
|
|
|
|
|
let width = fullWidth;
|
|
|
|
let height = fullHeight;
|
2011-02-10 17:15: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
|
|
|
let [controlsMin, controlsNatural] = this._controls.get_preferred_width(height);
|
2011-02-10 17:15:36 -05:00
|
|
|
let controlsVisible = this._controls.get_theme_node().get_length('visible-width');
|
|
|
|
|
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
|
|
|
let [x, y] = this.actor.get_transformed_position();
|
|
|
|
|
2012-02-13 20:37:28 -05:00
|
|
|
let rtl = (Clutter.get_default_text_direction () == Clutter.TextDirection.RTL);
|
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
|
|
|
|
workspaces-view: Handle clip rectangle separately
After completing the overview transition, the workspace view is
clipped to avoid overlapping the search entry/view selector titles
while switching workspaces. For clipping, the view's position and
size was used, which works well assuming that the workspace pager
will start hidden or stay zoomed out while the overview is visible.
However, that assumption holds no longer true, as auto-hiding the
pager now depends on the number of workspaces, and thus may change
while in the overview. For instance, when starting with the pager
being visible, the clip area ends up being too small when moving
all windows to the first workspace (and thus triggering auto-hide).
As a fix, handle the clip rectangle separately from the view's
geometry, and set it always to the area the workspaces would
occupy with the pager hidden.
https://bugzilla.gnome.org/show_bug.cgi?id=653142
2011-06-21 18:28:42 -04:00
|
|
|
let clipWidth = width - controlsVisible;
|
2012-08-09 11:38:36 -04:00
|
|
|
let clipHeight = fullHeight;
|
workspaces-view: Handle clip rectangle separately
After completing the overview transition, the workspace view is
clipped to avoid overlapping the search entry/view selector titles
while switching workspaces. For clipping, the view's position and
size was used, which works well assuming that the workspace pager
will start hidden or stay zoomed out while the overview is visible.
However, that assumption holds no longer true, as auto-hiding the
pager now depends on the number of workspaces, and thus may change
while in the overview. For instance, when starting with the pager
being visible, the clip area ends up being too small when moving
all windows to the first workspace (and thus triggering auto-hide).
As a fix, handle the clip rectangle separately from the view's
geometry, and set it always to the area the workspaces would
occupy with the pager hidden.
https://bugzilla.gnome.org/show_bug.cgi?id=653142
2011-06-21 18:28:42 -04:00
|
|
|
let clipX = rtl ? x + controlsVisible : x;
|
|
|
|
let clipY = y + (fullHeight - clipHeight) / 2;
|
|
|
|
|
2012-08-08 16:21:19 -04:00
|
|
|
let widthAdjust = this._zoomOut ? controlsNatural : controlsVisible;
|
|
|
|
width -= widthAdjust;
|
|
|
|
if (rtl)
|
|
|
|
x += widthAdjust;
|
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
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
let monitors = Main.layoutManager.monitors;
|
|
|
|
let m = 0;
|
|
|
|
for (let i = 0; i < monitors.length; i++) {
|
|
|
|
if (i == this._primaryIndex) {
|
|
|
|
this._workspacesViews[m].setClipRect(clipX, clipY,
|
|
|
|
clipWidth, clipHeight);
|
2012-08-09 11:38:36 -04:00
|
|
|
this._workspacesViews[m].setGeometry(x, y, width, height);
|
2011-11-25 12:25:31 -05:00
|
|
|
m++;
|
|
|
|
} else if (!this._workspacesOnlyOnPrimary) {
|
|
|
|
this._workspacesViews[m].setClipRect(monitors[i].x,
|
|
|
|
monitors[i].y,
|
|
|
|
monitors[i].width,
|
|
|
|
monitors[i].height);
|
2012-12-10 15:39:15 -05:00
|
|
|
this._workspacesViews[m].setGeometry(monitors[i].x,
|
|
|
|
monitors[i].y,
|
|
|
|
monitors[i].width,
|
|
|
|
monitors[i].height);
|
2011-11-25 12:25:31 -05:00
|
|
|
m++;
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 22:54:05 -05:00
|
|
|
},
|
|
|
|
|
2011-01-30 20:44:05 -05:00
|
|
|
_onRestacked: function() {
|
|
|
|
let stack = global.get_window_actors();
|
|
|
|
let stackIndices = {};
|
|
|
|
|
|
|
|
for (let i = 0; i < stack.length; i++) {
|
|
|
|
// Use the stable sequence for an integer to use as a hash key
|
|
|
|
stackIndices[stack[i].get_meta_window().get_stable_sequence()] = i;
|
|
|
|
}
|
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].syncStacking(stackIndices);
|
|
|
|
|
2011-02-09 15:48:11 -05:00
|
|
|
this._thumbnailsBox.syncStacking(stackIndices);
|
2011-01-30 20:44:05 -05:00
|
|
|
},
|
|
|
|
|
2010-02-14 18:32:57 -05:00
|
|
|
_workspacesChanged: function() {
|
2011-06-21 16:02:32 -04:00
|
|
|
this._updateAlwaysZoom();
|
|
|
|
this._updateZoom();
|
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
if (this._workspacesViews == null)
|
2011-06-21 16:02:32 -04:00
|
|
|
return;
|
|
|
|
|
2012-03-28 09:25:33 -04:00
|
|
|
let oldNumWorkspaces = this._workspaces[0].length;
|
|
|
|
let newNumWorkspaces = global.screen.n_workspaces;
|
|
|
|
let active = global.screen.get_active_workspace_index();
|
|
|
|
|
2010-02-14 18:32:57 -05:00
|
|
|
let lostWorkspaces = [];
|
|
|
|
if (newNumWorkspaces > oldNumWorkspaces) {
|
2011-11-25 12:25:31 -05:00
|
|
|
let monitors = Main.layoutManager.monitors;
|
|
|
|
let m = 0;
|
|
|
|
for (let i = 0; i < monitors.length; i++) {
|
2012-10-19 14:03:05 -04:00
|
|
|
if (this._workspacesOnlyOnPrimary &&
|
2011-11-25 12:25:31 -05:00
|
|
|
i != this._primaryIndex)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Assume workspaces are only added at the end
|
|
|
|
for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++) {
|
|
|
|
let metaWorkspace = global.screen.get_workspace_by_index(w);
|
2012-10-19 13:58:05 -04:00
|
|
|
this._workspaces[m][w] =
|
2011-11-25 12:25:31 -05:00
|
|
|
new Workspace.Workspace(metaWorkspace, i);
|
|
|
|
}
|
2012-10-19 13:58:05 -04:00
|
|
|
m++;
|
2010-02-14 18:32:57 -05:00
|
|
|
}
|
2011-02-09 15:48:11 -05:00
|
|
|
|
|
|
|
this._thumbnailsBox.addThumbnails(oldNumWorkspaces, newNumWorkspaces - oldNumWorkspaces);
|
2010-02-14 18:32:57 -05:00
|
|
|
} else {
|
|
|
|
// Assume workspaces are only removed sequentially
|
|
|
|
// (e.g. 2,3,4 - not 2,4,7)
|
|
|
|
let removedIndex;
|
|
|
|
let removedNum = oldNumWorkspaces - newNumWorkspaces;
|
|
|
|
for (let w = 0; w < oldNumWorkspaces; w++) {
|
|
|
|
let metaWorkspace = global.screen.get_workspace_by_index(w);
|
2011-11-25 12:25:31 -05:00
|
|
|
if (this._workspaces[0][w].metaWorkspace != metaWorkspace) {
|
2010-02-14 18:32:57 -05:00
|
|
|
removedIndex = w;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
for (let i = 0; i < this._workspaces.length; i++) {
|
|
|
|
lostWorkspaces = this._workspaces[i].splice(removedIndex,
|
|
|
|
removedNum);
|
2010-02-14 18:32:57 -05:00
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
for (let l = 0; l < lostWorkspaces.length; l++) {
|
|
|
|
lostWorkspaces[l].disconnectAll();
|
|
|
|
lostWorkspaces[l].destroy();
|
|
|
|
}
|
2011-05-31 22:23:12 -04:00
|
|
|
}
|
2011-01-30 21:18:12 -05:00
|
|
|
|
2012-09-26 08:24:48 -04:00
|
|
|
this._thumbnailsBox.removeThumbnails(removedIndex, removedNum);
|
2010-02-14 18:32:57 -05:00
|
|
|
}
|
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].updateWorkspaces(oldNumWorkspaces,
|
|
|
|
newNumWorkspaces);
|
2012-10-19 07:55:18 -04:00
|
|
|
this._updateSwitcherVisibility();
|
2011-01-30 20:35:58 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_updateZoom : function() {
|
|
|
|
if (Main.overview.animationInProgress)
|
|
|
|
return;
|
|
|
|
|
2011-06-16 08:53:17 -04:00
|
|
|
let shouldZoom = this._alwaysZoomOut || this._controls.hover;
|
2011-01-30 20:35:58 -05:00
|
|
|
if (shouldZoom != this._zoomOut) {
|
|
|
|
this._zoomOut = shouldZoom;
|
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._updateWorkspacesGeometry();
|
2011-01-30 20:35:58 -05:00
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
if (!this._workspacesViews)
|
2011-01-30 20:35:58 -05:00
|
|
|
return;
|
|
|
|
|
2011-01-30 22:54:05 -05:00
|
|
|
Tweener.addTween(this,
|
|
|
|
{ zoomFraction: this._zoomOut ? 1 : 0,
|
2011-01-30 20:35:58 -05:00
|
|
|
time: WORKSPACE_SWITCH_TIME,
|
|
|
|
transition: 'easeOutQuad' });
|
|
|
|
|
2011-11-25 12:25:31 -05:00
|
|
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
|
|
|
this._workspacesViews[i].updateWindowPositions();
|
2011-01-30 20:35:58 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_onControlsHoverChanged: function() {
|
2012-03-12 20:58:34 -04:00
|
|
|
if(!this._controls.hover)
|
|
|
|
this._controlsInitiallyHovered = false;
|
|
|
|
if(!this._controlsInitiallyHovered)
|
|
|
|
this._updateZoom();
|
2011-01-30 20:35:58 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_dragBegin: function() {
|
|
|
|
this._inDrag = true;
|
2011-03-08 08:50:34 -05:00
|
|
|
this._cancelledDrag = false;
|
2011-06-16 08:53:17 -04:00
|
|
|
this._dragMonitor = {
|
|
|
|
dragMotion: Lang.bind(this, this._onDragMotion)
|
|
|
|
};
|
|
|
|
DND.addDragMonitor(this._dragMonitor);
|
2011-03-08 08:50:34 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_dragCancelled: function() {
|
|
|
|
this._cancelledDrag = true;
|
2011-06-16 08:53:17 -04:00
|
|
|
DND.removeDragMonitor(this._dragMonitor);
|
|
|
|
},
|
|
|
|
|
|
|
|
_onDragMotion: function(dragEvent) {
|
|
|
|
let controlsHovered = this._controls.contains(dragEvent.targetActor);
|
|
|
|
this._controls.set_hover(controlsHovered);
|
|
|
|
|
|
|
|
return DND.DragMotionResult.CONTINUE;
|
2011-01-30 20:35:58 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_dragEnd: function() {
|
|
|
|
this._inDrag = false;
|
2011-01-30 16:38:13 -05:00
|
|
|
|
|
|
|
// We do this deferred because drag-end is emitted before dnd.js emits
|
|
|
|
// event/leave events that were suppressed during the drag. If we didn't
|
|
|
|
// defer this, we'd zoom out then immediately zoom in because of the
|
|
|
|
// enter event we received. That would normally be invisible but we
|
|
|
|
// might as well avoid it.
|
|
|
|
Meta.later_add(Meta.LaterType.BEFORE_REDRAW,
|
|
|
|
Lang.bind(this, this._updateZoom));
|
2011-02-12 04:11:20 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onScrollEvent: function (actor, event) {
|
|
|
|
switch ( event.get_scroll_direction() ) {
|
|
|
|
case Clutter.ScrollDirection.UP:
|
2012-04-14 08:40:30 -04:00
|
|
|
Main.wm.actionMoveWorkspace(Meta.MotionDirection.UP);
|
2011-02-12 04:11:20 -05:00
|
|
|
break;
|
|
|
|
case Clutter.ScrollDirection.DOWN:
|
2012-04-14 08:40:30 -04:00
|
|
|
Main.wm.actionMoveWorkspace(Meta.MotionDirection.DOWN);
|
2011-02-12 04:11:20 -05:00
|
|
|
break;
|
|
|
|
}
|
2010-02-14 18:32:57 -05:00
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2010-10-04 10:42:11 -04:00
|
|
|
Signals.addSignalMethods(WorkspacesDisplay.prototype);
|