2008-12-01 14:51:43 -05:00
|
|
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2008-10-31 19:09:46 -04:00
|
|
|
|
2008-11-20 19:53:11 -05:00
|
|
|
const Clutter = imports.gi.Clutter;
|
2010-07-15 10:21:32 -04:00
|
|
|
const Meta = imports.gi.Meta;
|
2009-02-02 18:02:16 -05:00
|
|
|
const Mainloop = imports.mainloop;
|
|
|
|
const Signals = imports.signals;
|
2009-04-13 14:45:58 -04:00
|
|
|
const Lang = imports.lang;
|
2010-01-21 21:33:48 -05:00
|
|
|
const St = imports.gi.St;
|
2011-01-05 09:39:36 -05:00
|
|
|
const Shell = imports.gi.Shell;
|
2010-02-08 17:50:50 -05:00
|
|
|
const Gettext = imports.gettext.domain('gnome-shell');
|
|
|
|
const _ = Gettext.gettext;
|
2011-01-05 09:47:27 -05:00
|
|
|
const Gdk = imports.gi.Gdk;
|
2009-02-02 18:02:16 -05:00
|
|
|
|
2010-07-29 03:55:08 -04:00
|
|
|
const AppDisplay = imports.ui.appDisplay;
|
|
|
|
const Dash = imports.ui.dash;
|
2011-01-05 09:47:27 -05:00
|
|
|
const DND = imports.ui.dnd;
|
2010-07-29 03:55:08 -04:00
|
|
|
const DocDisplay = imports.ui.docDisplay;
|
2010-01-10 00:09:18 -05:00
|
|
|
const Lightbox = imports.ui.lightbox;
|
2009-02-02 18:02:16 -05:00
|
|
|
const Main = imports.ui.main;
|
2010-07-22 11:49:43 -04:00
|
|
|
const MessageTray = imports.ui.messageTray;
|
2009-02-02 18:02:16 -05:00
|
|
|
const Panel = imports.ui.panel;
|
2010-07-29 03:55:08 -04:00
|
|
|
const PlaceDisplay = imports.ui.placeDisplay;
|
2009-02-10 11:12:58 -05:00
|
|
|
const Tweener = imports.ui.tweener;
|
2010-07-29 03:55:08 -04:00
|
|
|
const ViewSelector = imports.ui.viewSelector;
|
2010-01-21 21:33:48 -05:00
|
|
|
const WorkspacesView = imports.ui.workspacesView;
|
2008-10-31 19:09:46 -04:00
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
// Time for initial animation going into Overview mode
|
2009-06-02 13:43:34 -04:00
|
|
|
const ANIMATION_TIME = 0.25;
|
2008-11-06 09:00:14 -05:00
|
|
|
|
2010-07-29 03:55:08 -04:00
|
|
|
// We split the screen vertically between the dash and the view selector.
|
|
|
|
const DASH_SPLIT_FRACTION = 0.1;
|
2009-06-24 18:24:48 -04:00
|
|
|
|
2011-01-05 09:47:27 -05:00
|
|
|
const DND_WINDOW_SWITCH_TIMEOUT = 1250;
|
|
|
|
|
2010-07-22 11:49:43 -04:00
|
|
|
function ShellInfo() {
|
|
|
|
this._init();
|
|
|
|
}
|
|
|
|
|
|
|
|
ShellInfo.prototype = {
|
|
|
|
_init: function() {
|
|
|
|
this._source = null;
|
2010-02-08 17:50:50 -05:00
|
|
|
this._undoCallback = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
_onUndoClicked: function() {
|
|
|
|
if (this._undoCallback)
|
|
|
|
this._undoCallback();
|
|
|
|
this._undoCallback = null;
|
|
|
|
|
2010-07-22 11:49:43 -04:00
|
|
|
if (this._source)
|
|
|
|
this._source.destroy();
|
2010-02-08 17:50:50 -05:00
|
|
|
},
|
|
|
|
|
2010-03-10 09:14:56 -05:00
|
|
|
setMessage: function(text, undoCallback, undoLabel) {
|
2010-07-22 11:49:43 -04:00
|
|
|
if (this._source == null) {
|
2010-11-30 10:47:28 -05:00
|
|
|
this._source = new MessageTray.SystemNotificationSource();
|
2010-07-22 11:49:43 -04:00
|
|
|
this._source.connect('destroy', Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
this._source = null;
|
|
|
|
}));
|
|
|
|
Main.messageTray.add(this._source);
|
|
|
|
}
|
2010-02-08 17:50:50 -05:00
|
|
|
|
2010-07-22 11:49:43 -04:00
|
|
|
let notification = this._source.notification;
|
|
|
|
if (notification == null)
|
|
|
|
notification = new MessageTray.Notification(this._source, text, null);
|
2010-03-10 09:14:56 -05:00
|
|
|
else
|
2010-07-22 11:49:43 -04:00
|
|
|
notification.update(text, null, { clear: true });
|
2010-03-10 09:14:56 -05:00
|
|
|
|
2010-12-16 16:34:39 -05:00
|
|
|
notification.setTransient(true);
|
|
|
|
|
2010-02-08 17:50:50 -05:00
|
|
|
this._undoCallback = undoCallback;
|
2010-07-22 11:49:43 -04:00
|
|
|
if (undoCallback) {
|
|
|
|
notification.addButton('system-undo',
|
|
|
|
undoLabel ? undoLabel : _("Undo"));
|
|
|
|
notification.connect('action-invoked',
|
|
|
|
Lang.bind(this, this._onUndoClicked));
|
|
|
|
}
|
|
|
|
|
|
|
|
this._source.notify(notification);
|
2010-02-08 17:50:50 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
function Overview() {
|
2009-03-31 14:12:33 -04:00
|
|
|
this._init();
|
2008-11-20 19:53:11 -05:00
|
|
|
}
|
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
Overview.prototype = {
|
2009-03-31 14:12:33 -04:00
|
|
|
_init : function() {
|
2010-07-15 10:21:32 -04:00
|
|
|
// The actual global.background_actor is inside global.window_group,
|
|
|
|
// which is hidden when displaying the overview, so we display a clone.
|
|
|
|
this._background = new Clutter.Clone({ source: global.background_actor });
|
|
|
|
this._background.hide();
|
|
|
|
global.overlay_group.add_actor(this._background);
|
|
|
|
|
|
|
|
this._desktopFade = new St.Bin();
|
|
|
|
global.overlay_group.add_actor(this._desktopFade);
|
|
|
|
|
2010-07-29 03:55:08 -04:00
|
|
|
this._spacing = 0;
|
|
|
|
|
2010-07-15 10:21:32 -04:00
|
|
|
this._group = new St.Group({ name: 'overview' });
|
Rewrite Dash, remove hardcoded width/height from GenericDisplay
This patch is a near-total rewrite of the Dash. First, the dash
code moves into a separate file, dash.js.
Inside dash.js, the components are more broken up into separate
classes; in particular there's now a Pane class and a MoreLink
class. Instead of each section of the dash, when activated,
attempting to close all N-1 other sections, instead there
is the concept of a single "active pane", and when e.g. activating
the More link for documents, if we know there's an active pane
which happens to be the apps, close it.
Many redundant containers were removed from the dash, and all
manual width, height and x/y offsets are entirely gone. We move
the visual apperance closer to the design by using the view-more.svg,
etc.
To complete the removal of height/width calculations from the dash,
we also had to do the same for GenericDisplay. Also clean up
the positioning inside overlay.js so calculation of children's
positioning is inside a single function that flows from screen.width
and screen.height, so in the future we can stop passing the width
into the Dash constructor and call this once and work on screen
resizing.
2009-07-31 22:12:01 -04:00
|
|
|
this._group._delegate = this;
|
2010-07-29 03:55:08 -04:00
|
|
|
this._group.connect('style-changed',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
let node = this._group.get_theme_node();
|
|
|
|
let spacing = node.get_length('spacing');
|
|
|
|
if (spacing != this._spacing) {
|
|
|
|
this._spacing = spacing;
|
|
|
|
this.relayout();
|
|
|
|
}
|
|
|
|
}));
|
2009-06-24 18:24:48 -04:00
|
|
|
|
2010-07-22 11:49:43 -04:00
|
|
|
this.shellInfo = new ShellInfo();
|
2010-02-08 17:50:50 -05:00
|
|
|
|
2010-10-04 10:42:11 -04:00
|
|
|
this._workspacesDisplay = null;
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2011-01-05 09:39:36 -05:00
|
|
|
this.visible = false; // animating to overview, in overview, animating out
|
|
|
|
this._shown = false; // show() and not hide()
|
|
|
|
this._shownTemporarily = false; // showTemporarily() and not hideTemporarily()
|
|
|
|
this._modal = false; // have a modal grab
|
2009-08-07 18:22:05 -04:00
|
|
|
this.animationInProgress = false;
|
Rewrite Dash, remove hardcoded width/height from GenericDisplay
This patch is a near-total rewrite of the Dash. First, the dash
code moves into a separate file, dash.js.
Inside dash.js, the components are more broken up into separate
classes; in particular there's now a Pane class and a MoreLink
class. Instead of each section of the dash, when activated,
attempting to close all N-1 other sections, instead there
is the concept of a single "active pane", and when e.g. activating
the More link for documents, if we know there's an active pane
which happens to be the apps, close it.
Many redundant containers were removed from the dash, and all
manual width, height and x/y offsets are entirely gone. We move
the visual apperance closer to the design by using the view-more.svg,
etc.
To complete the removal of height/width calculations from the dash,
we also had to do the same for GenericDisplay. Also clean up
the positioning inside overlay.js so calculation of children's
positioning is inside a single function that flows from screen.width
and screen.height, so in the future we can stop passing the width
into the Dash constructor and call this once and work on screen
resizing.
2009-07-31 22:12:01 -04:00
|
|
|
this._hideInProgress = false;
|
2009-06-24 18:24:48 -04:00
|
|
|
|
2009-09-13 14:54:56 -04:00
|
|
|
// During transitions, we raise this to the top to avoid having the overview
|
|
|
|
// area be reactive; it causes too many issues such as double clicks on
|
|
|
|
// Dash elements, or mouseover handlers in the workspaces.
|
|
|
|
this._coverPane = new Clutter.Rectangle({ opacity: 0,
|
|
|
|
reactive: true });
|
|
|
|
this._group.add_actor(this._coverPane);
|
|
|
|
this._coverPane.connect('event', Lang.bind(this, function (actor, event) { return true; }));
|
|
|
|
|
2009-06-24 18:24:48 -04:00
|
|
|
|
Rewrite Dash, remove hardcoded width/height from GenericDisplay
This patch is a near-total rewrite of the Dash. First, the dash
code moves into a separate file, dash.js.
Inside dash.js, the components are more broken up into separate
classes; in particular there's now a Pane class and a MoreLink
class. Instead of each section of the dash, when activated,
attempting to close all N-1 other sections, instead there
is the concept of a single "active pane", and when e.g. activating
the More link for documents, if we know there's an active pane
which happens to be the apps, close it.
Many redundant containers were removed from the dash, and all
manual width, height and x/y offsets are entirely gone. We move
the visual apperance closer to the design by using the view-more.svg,
etc.
To complete the removal of height/width calculations from the dash,
we also had to do the same for GenericDisplay. Also clean up
the positioning inside overlay.js so calculation of children's
positioning is inside a single function that flows from screen.width
and screen.height, so in the future we can stop passing the width
into the Dash constructor and call this once and work on screen
resizing.
2009-07-31 22:12:01 -04:00
|
|
|
this._group.hide();
|
|
|
|
global.overlay_group.add_actor(this._group);
|
2009-06-24 18:24:48 -04:00
|
|
|
|
2010-07-29 03:55:08 -04:00
|
|
|
this.viewSelector = new ViewSelector.ViewSelector();
|
|
|
|
this._group.add_actor(this.viewSelector.actor);
|
|
|
|
|
|
|
|
this._workspacesDisplay = new WorkspacesView.WorkspacesDisplay();
|
2010-12-15 18:29:43 -05:00
|
|
|
this.viewSelector.addViewTab(_("Windows"), this._workspacesDisplay.actor);
|
2010-07-29 03:55:08 -04:00
|
|
|
|
|
|
|
let appView = new AppDisplay.AllAppDisplay();
|
2010-12-15 18:29:43 -05:00
|
|
|
this.viewSelector.addViewTab(_("Applications"), appView.actor);
|
2010-07-29 03:55:08 -04:00
|
|
|
|
|
|
|
// Default search providers
|
|
|
|
this.viewSelector.addSearchProvider(new AppDisplay.AppSearchProvider());
|
|
|
|
this.viewSelector.addSearchProvider(new AppDisplay.PrefsSearchProvider());
|
|
|
|
this.viewSelector.addSearchProvider(new PlaceDisplay.PlaceSearchProvider());
|
|
|
|
this.viewSelector.addSearchProvider(new DocDisplay.DocSearchProvider());
|
|
|
|
|
Rewrite Dash, remove hardcoded width/height from GenericDisplay
This patch is a near-total rewrite of the Dash. First, the dash
code moves into a separate file, dash.js.
Inside dash.js, the components are more broken up into separate
classes; in particular there's now a Pane class and a MoreLink
class. Instead of each section of the dash, when activated,
attempting to close all N-1 other sections, instead there
is the concept of a single "active pane", and when e.g. activating
the More link for documents, if we know there's an active pane
which happens to be the apps, close it.
Many redundant containers were removed from the dash, and all
manual width, height and x/y offsets are entirely gone. We move
the visual apperance closer to the design by using the view-more.svg,
etc.
To complete the removal of height/width calculations from the dash,
we also had to do the same for GenericDisplay. Also clean up
the positioning inside overlay.js so calculation of children's
positioning is inside a single function that flows from screen.width
and screen.height, so in the future we can stop passing the width
into the Dash constructor and call this once and work on screen
resizing.
2009-07-31 22:12:01 -04:00
|
|
|
// TODO - recalculate everything when desktop size changes
|
2009-08-09 19:48:54 -04:00
|
|
|
this._dash = new Dash.Dash();
|
Rewrite Dash, remove hardcoded width/height from GenericDisplay
This patch is a near-total rewrite of the Dash. First, the dash
code moves into a separate file, dash.js.
Inside dash.js, the components are more broken up into separate
classes; in particular there's now a Pane class and a MoreLink
class. Instead of each section of the dash, when activated,
attempting to close all N-1 other sections, instead there
is the concept of a single "active pane", and when e.g. activating
the More link for documents, if we know there's an active pane
which happens to be the apps, close it.
Many redundant containers were removed from the dash, and all
manual width, height and x/y offsets are entirely gone. We move
the visual apperance closer to the design by using the view-more.svg,
etc.
To complete the removal of height/width calculations from the dash,
we also had to do the same for GenericDisplay. Also clean up
the positioning inside overlay.js so calculation of children's
positioning is inside a single function that flows from screen.width
and screen.height, so in the future we can stop passing the width
into the Dash constructor and call this once and work on screen
resizing.
2009-07-31 22:12:01 -04:00
|
|
|
this._group.add_actor(this._dash.actor);
|
2010-07-29 03:55:08 -04:00
|
|
|
this._dash.actor.add_constraint(this.viewSelector.constrainY);
|
|
|
|
this._dash.actor.add_constraint(this.viewSelector.constrainHeight);
|
2009-07-04 12:46:35 -04:00
|
|
|
|
2009-09-13 14:54:56 -04:00
|
|
|
this._coverPane.lower_bottom();
|
|
|
|
|
2011-01-05 09:47:27 -05:00
|
|
|
// XDND
|
|
|
|
this._dragMonitor = {
|
|
|
|
dragMotion: Lang.bind(this, this._onDragMotion)
|
|
|
|
};
|
|
|
|
|
|
|
|
Main.xdndHandler.connect('drag-begin', Lang.bind(this, this._onDragBegin));
|
|
|
|
Main.xdndHandler.connect('drag-end', Lang.bind(this, this._onDragEnd));
|
|
|
|
|
|
|
|
this._windowSwitchTimeoutId = 0;
|
|
|
|
this._windowSwitchTimestamp = 0;
|
|
|
|
this._lastActiveWorkspaceIndex = -1;
|
2011-01-07 05:12:00 -05:00
|
|
|
this._lastHoveredWindow = null;
|
2011-01-05 09:47:27 -05:00
|
|
|
this._needsFakePointerEvent = false;
|
|
|
|
|
2010-04-14 16:22:41 -04:00
|
|
|
this.workspaces = null;
|
2009-06-24 18:24:48 -04:00
|
|
|
},
|
|
|
|
|
2011-01-05 09:47:27 -05:00
|
|
|
_onDragBegin: function() {
|
|
|
|
DND.addDragMonitor(this._dragMonitor);
|
|
|
|
// Remember the workspace we started from
|
|
|
|
this._lastActiveWorkspaceIndex = global.screen.get_active_workspace_index();
|
|
|
|
},
|
|
|
|
|
|
|
|
_onDragEnd: function(time) {
|
|
|
|
// In case the drag was canceled while in the overview
|
|
|
|
// we have to go back to where we started and hide
|
|
|
|
// the overview
|
|
|
|
if (this._shownTemporarily) {
|
|
|
|
global.screen.get_workspace_by_index(this._lastActiveWorkspaceIndex).activate(time);
|
|
|
|
this.hideTemporarily();
|
|
|
|
}
|
2011-01-07 05:12:00 -05:00
|
|
|
this._lastHoveredWindow = null;
|
2011-01-05 09:47:27 -05:00
|
|
|
DND.removeMonitor(this._dragMonitor);
|
|
|
|
},
|
|
|
|
|
|
|
|
_fakePointerEvent: function() {
|
|
|
|
let display = Gdk.Display.get_default();
|
|
|
|
let deviceManager = display.get_device_manager();
|
|
|
|
let pointer = deviceManager.get_client_pointer();
|
2011-01-05 17:34:27 -05:00
|
|
|
let [screen, pointerX, pointerY] = pointer.get_position();
|
2011-01-05 09:47:27 -05:00
|
|
|
|
2011-01-05 17:34:27 -05:00
|
|
|
pointer.warp(screen, pointerX, pointerY);
|
2011-01-05 09:47:27 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onDragMotion: function(dragEvent) {
|
2011-01-07 05:12:00 -05:00
|
|
|
let targetIsWindow = dragEvent.targetActor &&
|
|
|
|
dragEvent.targetActor._delegate &&
|
|
|
|
dragEvent.targetActor._delegate.metaWindow;
|
|
|
|
|
|
|
|
if (targetIsWindow &&
|
|
|
|
dragEvent.targetActor._delegate.metaWindow == this._lastHoveredWindow)
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
this._lastHoveredWindow = null;
|
|
|
|
|
2011-01-05 09:47:27 -05:00
|
|
|
if (this._windowSwitchTimeoutId != 0) {
|
|
|
|
Mainloop.source_remove(this._windowSwitchTimeoutId);
|
|
|
|
this._windowSwitchTimeoutId = 0;
|
|
|
|
this._needsFakePointerEvent = false;
|
|
|
|
}
|
|
|
|
|
2011-01-07 05:12:00 -05:00
|
|
|
if (targetIsWindow) {
|
|
|
|
this._lastHoveredWindow = dragEvent.targetActor._delegate.metaWindow;
|
2011-01-05 09:47:27 -05:00
|
|
|
this._windowSwitchTimestamp = global.get_current_time();
|
|
|
|
this._windowSwitchTimeoutId = Mainloop.timeout_add(DND_WINDOW_SWITCH_TIMEOUT,
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
this._needsFakePointerEvent = true;
|
|
|
|
Main.activateWindow(dragEvent.targetActor._delegate.metaWindow,
|
|
|
|
this._windowSwitchTimestamp);
|
|
|
|
this.hideTemporarily();
|
2011-01-07 05:12:00 -05:00
|
|
|
this._lastHoveredWindow = null;
|
2011-01-05 09:47:27 -05:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
return DND.DragMotionResult.CONTINUE;
|
|
|
|
},
|
|
|
|
|
2010-07-15 10:21:32 -04:00
|
|
|
_getDesktopClone: function() {
|
|
|
|
let windows = global.get_window_actors().filter(function(w) {
|
|
|
|
return w.meta_window.get_window_type() == Meta.WindowType.DESKTOP;
|
|
|
|
});
|
|
|
|
if (windows.length == 0)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
let clone = new Clutter.Clone({ source: windows[0].get_texture() });
|
|
|
|
clone.source.connect('destroy', Lang.bind(this, function() {
|
|
|
|
clone.destroy();
|
|
|
|
}));
|
|
|
|
return clone;
|
|
|
|
},
|
|
|
|
|
2009-08-11 11:16:25 -04:00
|
|
|
relayout: function () {
|
2009-08-25 15:23:53 -04:00
|
|
|
let primary = global.get_primary_monitor();
|
2009-12-25 06:27:09 -05:00
|
|
|
let rtl = (St.Widget.get_default_direction () == St.TextDirection.RTL);
|
2009-08-25 15:23:53 -04:00
|
|
|
|
2009-09-13 14:54:56 -04:00
|
|
|
let contentY = Panel.PANEL_HEIGHT;
|
2010-07-29 03:55:08 -04:00
|
|
|
let contentHeight = primary.height - contentY - Main.messageTray.actor.height;
|
2009-09-13 14:54:56 -04:00
|
|
|
|
2010-11-11 12:50:19 -05:00
|
|
|
this._group.set_position(primary.x, primary.y);
|
|
|
|
this._group.set_size(primary.width, primary.height);
|
|
|
|
|
2009-09-13 14:54:56 -04:00
|
|
|
this._coverPane.set_position(0, contentY);
|
2009-08-25 15:23:53 -04:00
|
|
|
this._coverPane.set_size(primary.width, contentHeight);
|
2009-08-09 19:48:54 -04:00
|
|
|
|
2010-07-29 03:55:08 -04:00
|
|
|
let viewWidth = (1.0 - DASH_SPLIT_FRACTION) * primary.width - this._spacing;
|
|
|
|
let viewHeight = contentHeight - 2 * this._spacing;
|
|
|
|
let viewY = contentY + this._spacing;
|
|
|
|
let viewX = rtl ? 0
|
|
|
|
: Math.floor(DASH_SPLIT_FRACTION * primary.width) + this._spacing;
|
2009-08-09 19:48:54 -04:00
|
|
|
|
2010-07-29 03:55:08 -04:00
|
|
|
// Set the dash's x position - y is handled by a constraint
|
|
|
|
let dashX;
|
2009-12-25 06:27:09 -05:00
|
|
|
if (rtl) {
|
2010-07-29 03:55:08 -04:00
|
|
|
this._dash.actor.set_anchor_point_from_gravity(Clutter.Gravity.NORTH_EAST);
|
|
|
|
dashX = primary.width;
|
2009-12-25 06:27:09 -05:00
|
|
|
} else {
|
2010-07-29 03:55:08 -04:00
|
|
|
dashX = 0;
|
2009-12-25 06:27:09 -05:00
|
|
|
}
|
2010-07-29 03:55:08 -04:00
|
|
|
this._dash.actor.set_x(dashX);
|
2009-08-09 19:48:54 -04:00
|
|
|
|
2010-07-29 03:55:08 -04:00
|
|
|
this.viewSelector.actor.set_position(viewX, viewY);
|
|
|
|
this.viewSelector.actor.set_size(viewWidth, viewHeight);
|
2008-12-01 14:51:43 -05:00
|
|
|
},
|
|
|
|
|
2010-05-08 10:06:28 -04:00
|
|
|
//// Public methods ////
|
|
|
|
|
|
|
|
beginItemDrag: function(source) {
|
|
|
|
this.emit('item-drag-begin');
|
2009-03-11 15:21:45 -04:00
|
|
|
},
|
|
|
|
|
2010-05-08 10:06:28 -04:00
|
|
|
endItemDrag: function(source) {
|
|
|
|
this.emit('item-drag-end');
|
|
|
|
},
|
2009-03-11 15:21:45 -04:00
|
|
|
|
2010-11-15 15:58:27 -05:00
|
|
|
beginWindowDrag: function(source) {
|
|
|
|
this.emit('window-drag-begin');
|
|
|
|
},
|
|
|
|
|
|
|
|
endWindowDrag: function(source) {
|
|
|
|
this.emit('window-drag-end');
|
|
|
|
},
|
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
// Returns the scale the Overview has when we just start zooming out
|
2009-08-10 18:31:39 -04:00
|
|
|
// to overview mode. That is, when just the active workspace is showing.
|
|
|
|
getZoomedInScale : function() {
|
2010-04-14 16:22:41 -04:00
|
|
|
return 1 / this.workspaces.getScale();
|
2009-08-10 18:31:39 -04:00
|
|
|
},
|
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
// Returns the position the Overview has when we just start zooming out
|
2009-08-10 18:31:39 -04:00
|
|
|
// to overview mode. That is, when just the active workspace is showing.
|
|
|
|
getZoomedInPosition : function() {
|
2010-04-14 16:22:41 -04:00
|
|
|
let [posX, posY] = this.workspaces.getActiveWorkspacePosition();
|
2009-08-10 18:31:39 -04:00
|
|
|
let scale = this.getZoomedInScale();
|
|
|
|
|
|
|
|
return [- posX * scale, - posY * scale];
|
|
|
|
},
|
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
// Returns the current scale of the Overview.
|
2009-08-10 18:31:39 -04:00
|
|
|
getScale : function() {
|
2010-11-11 12:50:19 -05:00
|
|
|
return this.workspaces.actor.scaleX;
|
2009-08-10 18:31:39 -04:00
|
|
|
},
|
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
// Returns the current position of the Overview.
|
2009-08-10 18:31:39 -04:00
|
|
|
getPosition : function() {
|
2010-11-11 12:50:19 -05:00
|
|
|
return [this.workspaces.actor.x, this.workspaces.actor.y];
|
2009-08-10 18:31:39 -04:00
|
|
|
},
|
|
|
|
|
2011-01-05 09:39:36 -05:00
|
|
|
// show:
|
|
|
|
//
|
|
|
|
// Animates the overview visible and grabs mouse and keyboard input
|
2008-12-01 14:51:43 -05:00
|
|
|
show : function() {
|
2011-01-05 09:39:36 -05:00
|
|
|
if (this._shown)
|
2008-12-01 14:51:43 -05:00
|
|
|
return;
|
2011-01-05 09:39:36 -05:00
|
|
|
// Do this manually instead of using _syncInputMode, to handle failure
|
2010-07-29 03:55:08 -04:00
|
|
|
if (!Main.pushModal(this.viewSelector.actor))
|
2009-09-16 11:37:51 -04:00
|
|
|
return;
|
2011-01-05 09:39:36 -05:00
|
|
|
this._modal = true;
|
|
|
|
this._animateVisible();
|
|
|
|
this._shown = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
_animateVisible: function() {
|
|
|
|
if (this.visible || this.animationInProgress)
|
|
|
|
return;
|
2008-11-28 15:12:20 -05:00
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
this.visible = true;
|
2009-08-07 18:22:05 -04:00
|
|
|
this.animationInProgress = true;
|
2008-11-28 15:12:20 -05:00
|
|
|
|
2010-07-29 03:55:08 -04:00
|
|
|
// All the the actors in the window group are completely obscured,
|
|
|
|
// hiding the group holding them while the Overview is displayed greatly
|
|
|
|
// increases performance of the Overview especially when there are many
|
|
|
|
// windows visible.
|
|
|
|
//
|
|
|
|
// If we switched to displaying the actors in the Overview rather than
|
|
|
|
// clones of them, this would obviously no longer be necessary.
|
|
|
|
global.window_group.hide();
|
|
|
|
this._group.show();
|
|
|
|
this._background.show();
|
2009-08-12 15:09:56 -04:00
|
|
|
|
2010-07-29 03:55:08 -04:00
|
|
|
this.viewSelector.show();
|
2010-10-04 10:42:11 -04:00
|
|
|
this._workspacesDisplay.show();
|
2010-11-07 20:51:02 -05:00
|
|
|
this._dash.show();
|
2010-02-12 15:12:39 -05:00
|
|
|
|
2010-07-29 03:55:08 -04:00
|
|
|
this.workspaces = this._workspacesDisplay.workspacesView;
|
2010-11-11 12:50:19 -05:00
|
|
|
global.overlay_group.add_actor(this.workspaces.actor);
|
2009-09-01 11:56:41 -04:00
|
|
|
|
2010-07-15 10:21:32 -04:00
|
|
|
if (!this._desktopFade.child)
|
|
|
|
this._desktopFade.child = this._getDesktopClone();
|
|
|
|
|
|
|
|
if (!this.workspaces.getActiveWorkspace().hasMaximizedWindows()) {
|
|
|
|
this._desktopFade.opacity = 255;
|
|
|
|
this._desktopFade.show();
|
|
|
|
Tweener.addTween(this._desktopFade,
|
|
|
|
{ opacity: 0,
|
|
|
|
time: ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2010-11-11 12:50:19 -05:00
|
|
|
// Create a zoom out effect. First scale the workspaces view up and
|
2009-08-10 18:31:39 -04:00
|
|
|
// position it so that the active workspace fills up the whole screen,
|
2010-11-11 12:50:19 -05:00
|
|
|
// then transform it to its normal dimensions and position.
|
2009-08-10 18:31:39 -04:00
|
|
|
// The opposite transition is used in hide().
|
2010-11-11 12:50:19 -05:00
|
|
|
this.workspaces.actor.scaleX = this.workspaces.actor.scaleY = this.getZoomedInScale();
|
|
|
|
[this.workspaces.actor.x, this.workspaces.actor.y] = this.getZoomedInPosition();
|
2009-10-07 15:25:41 -04:00
|
|
|
let primary = global.get_primary_monitor();
|
2010-11-11 12:50:19 -05:00
|
|
|
Tweener.addTween(this.workspaces.actor,
|
|
|
|
{ x: primary.x - this._group.x,
|
|
|
|
y: primary.y - this._group.y,
|
2009-08-10 18:31:39 -04:00
|
|
|
scaleX: 1,
|
|
|
|
scaleY: 1,
|
|
|
|
transition: 'easeOutQuad',
|
2009-04-21 20:23:06 -04:00
|
|
|
time: ANIMATION_TIME,
|
|
|
|
onComplete: this._showDone,
|
2009-03-20 12:06:34 -04:00
|
|
|
onCompleteScope: this
|
2009-08-10 18:31:39 -04:00
|
|
|
});
|
2009-04-21 20:23:06 -04:00
|
|
|
|
2010-11-11 12:50:19 -05:00
|
|
|
// Make the other elements fade in.
|
|
|
|
this._group.opacity = 0;
|
|
|
|
Tweener.addTween(this._group,
|
2009-08-10 18:31:39 -04:00
|
|
|
{ opacity: 255,
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
time: ANIMATION_TIME
|
2009-03-20 12:06:34 -04:00
|
|
|
});
|
2009-05-07 09:47:48 -04:00
|
|
|
|
2009-09-13 14:54:56 -04:00
|
|
|
this._coverPane.raise_top();
|
2009-05-07 09:47:48 -04:00
|
|
|
this.emit('showing');
|
2008-12-01 14:51:43 -05:00
|
|
|
},
|
|
|
|
|
2011-01-05 09:39:36 -05:00
|
|
|
// showTemporarily:
|
|
|
|
//
|
|
|
|
// Animates the overview visible without grabbing mouse and keyboard input;
|
|
|
|
// if show() has already been called, this has no immediate effect, but
|
|
|
|
// will result in the overview not being hidden until hideTemporarily() is
|
|
|
|
// called.
|
|
|
|
showTemporarily: function() {
|
|
|
|
if (this._shownTemporarily)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._syncInputMode();
|
|
|
|
this._animateVisible();
|
|
|
|
this._shownTemporarily = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
// hide:
|
|
|
|
//
|
|
|
|
// Reverses the effect of show()
|
2009-09-11 12:39:59 -04:00
|
|
|
hide: function() {
|
2011-01-05 09:39:36 -05:00
|
|
|
if (!this._shown)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!this._shownTemporarily)
|
|
|
|
this._animateNotVisible();
|
|
|
|
|
|
|
|
this._shown = false;
|
|
|
|
this._syncInputMode();
|
|
|
|
},
|
|
|
|
|
|
|
|
// hideTemporarily:
|
|
|
|
//
|
|
|
|
// Reverses the effect of showTemporarily()
|
|
|
|
hideTemporarily: function() {
|
|
|
|
if (!this._shownTemporarily)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!this._shown)
|
|
|
|
this._animateNotVisible();
|
|
|
|
|
|
|
|
this._shownTemporarily = false;
|
|
|
|
this._syncInputMode();
|
|
|
|
},
|
|
|
|
|
|
|
|
toggle: function() {
|
|
|
|
if (this._shown)
|
|
|
|
this.hide();
|
|
|
|
else
|
|
|
|
this.show();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getWorkspacesForWindow:
|
|
|
|
* @metaWindow: A #MetaWindow
|
|
|
|
*
|
|
|
|
* Returns the Workspaces object associated with the given window.
|
|
|
|
* This method is not be accessible if the overview is not open
|
|
|
|
* and will return %null.
|
|
|
|
*/
|
|
|
|
getWorkspacesForWindow: function(metaWindow) {
|
|
|
|
return this.workspaces;
|
|
|
|
},
|
|
|
|
|
|
|
|
//// Private methods ////
|
|
|
|
|
|
|
|
_syncInputMode: function() {
|
|
|
|
// We delay input mode changes during animation so that when removing the
|
|
|
|
// overview we don't have a problem with the release of a press/release
|
|
|
|
// going to an application.
|
|
|
|
if (this.animationInProgress)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (this._shown) {
|
|
|
|
if (!this._modal) {
|
|
|
|
if (Main.pushModal(this._dash.actor))
|
|
|
|
this._modal = true;
|
|
|
|
else
|
|
|
|
this.hide();
|
|
|
|
}
|
|
|
|
} else if (this._shownTemporarily) {
|
|
|
|
if (this._modal) {
|
|
|
|
Main.popModal(this._dash.actor);
|
|
|
|
this._modal = false;
|
|
|
|
}
|
|
|
|
global.stage_input_mode = Shell.StageInputMode.FULLSCREEN;
|
|
|
|
} else {
|
|
|
|
if (this._modal) {
|
|
|
|
Main.popModal(this._dash.actor);
|
|
|
|
this._modal = false;
|
|
|
|
}
|
|
|
|
else if (global.stage_input_mode == Shell.StageInputMode.FULLSCREEN)
|
|
|
|
global.stage_input_mode = Shell.StageInputMode.NORMAL;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_animateNotVisible: function() {
|
|
|
|
if (!this.visible || this.animationInProgress)
|
2008-12-01 14:51:43 -05:00
|
|
|
return;
|
|
|
|
|
2009-08-07 18:22:05 -04:00
|
|
|
this.animationInProgress = true;
|
2009-03-20 12:06:34 -04:00
|
|
|
this._hideInProgress = true;
|
2010-07-15 10:21:32 -04:00
|
|
|
|
|
|
|
if (!this.workspaces.getActiveWorkspace().hasMaximizedWindows()) {
|
|
|
|
this._desktopFade.opacity = 0;
|
|
|
|
this._desktopFade.show();
|
|
|
|
Tweener.addTween(this._desktopFade,
|
|
|
|
{ opacity: 255,
|
|
|
|
time: ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad' });
|
|
|
|
}
|
|
|
|
|
2010-04-14 16:22:41 -04:00
|
|
|
this.workspaces.hide();
|
2008-12-04 10:16:16 -05:00
|
|
|
|
2010-11-11 12:50:19 -05:00
|
|
|
// Create a zoom in effect by transforming the workspaces view so that
|
2009-08-10 18:31:39 -04:00
|
|
|
// the active workspace fills up the whole screen. The opposite
|
|
|
|
// transition is used in show().
|
|
|
|
let scale = this.getZoomedInScale();
|
|
|
|
let [posX, posY] = this.getZoomedInPosition();
|
2010-11-11 12:50:19 -05:00
|
|
|
Tweener.addTween(this.workspaces.actor,
|
2009-08-10 18:31:39 -04:00
|
|
|
{ x: posX,
|
|
|
|
y: posY,
|
|
|
|
scaleX: scale,
|
|
|
|
scaleY: scale,
|
|
|
|
transition: 'easeOutQuad',
|
2009-04-21 20:23:06 -04:00
|
|
|
time: ANIMATION_TIME,
|
2008-12-04 10:16:16 -05:00
|
|
|
onComplete: this._hideDone,
|
|
|
|
onCompleteScope: this
|
2009-08-10 18:31:39 -04:00
|
|
|
});
|
|
|
|
|
2010-11-11 12:50:19 -05:00
|
|
|
// Make other elements fade out.
|
|
|
|
Tweener.addTween(this._group,
|
2009-08-10 18:31:39 -04:00
|
|
|
{ opacity: 0,
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
time: ANIMATION_TIME
|
2008-12-04 10:16:16 -05:00
|
|
|
});
|
2009-05-07 09:47:48 -04:00
|
|
|
|
2009-09-13 14:54:56 -04:00
|
|
|
this._coverPane.raise_top();
|
2009-05-07 09:47:48 -04:00
|
|
|
this.emit('hiding');
|
|
|
|
},
|
|
|
|
|
2009-04-21 20:23:06 -04:00
|
|
|
_showDone: function() {
|
2009-08-07 18:22:05 -04:00
|
|
|
this.animationInProgress = false;
|
2010-07-15 10:21:32 -04:00
|
|
|
this._desktopFade.hide();
|
2009-09-13 14:54:56 -04:00
|
|
|
this._coverPane.lower_bottom();
|
2009-08-07 18:22:05 -04:00
|
|
|
|
2009-05-07 09:47:48 -04:00
|
|
|
this.emit('shown');
|
2011-01-05 09:39:36 -05:00
|
|
|
// Handle any calls to hide* while we were showing
|
|
|
|
if (!this._shown && !this._shownTemporarily)
|
|
|
|
this._animateNotVisible();
|
|
|
|
|
|
|
|
this._syncInputMode();
|
2009-04-21 20:23:06 -04:00
|
|
|
},
|
2009-03-20 12:06:34 -04:00
|
|
|
|
2008-12-04 10:16:16 -05:00
|
|
|
_hideDone: function() {
|
2008-12-02 11:15:00 -05:00
|
|
|
global.window_group.show();
|
2008-12-15 15:48:59 -05:00
|
|
|
|
2010-04-14 16:22:41 -04:00
|
|
|
this.workspaces.destroy();
|
|
|
|
this.workspaces = null;
|
2009-02-03 17:58:33 -05:00
|
|
|
|
2010-07-29 03:55:08 -04:00
|
|
|
this._workspacesDisplay.hide();
|
|
|
|
this.viewSelector.hide();
|
2010-11-07 20:51:02 -05:00
|
|
|
this._dash.hide();
|
2010-02-14 18:32:57 -05:00
|
|
|
|
2010-07-15 10:21:32 -04:00
|
|
|
this._desktopFade.hide();
|
|
|
|
this._background.hide();
|
2009-02-03 17:58:33 -05:00
|
|
|
this._group.hide();
|
2009-03-20 12:06:34 -04:00
|
|
|
|
2010-01-21 21:33:48 -05:00
|
|
|
this.visible = false;
|
2009-08-07 18:22:05 -04:00
|
|
|
this.animationInProgress = false;
|
2009-03-20 12:06:34 -04:00
|
|
|
this._hideInProgress = false;
|
2008-12-01 14:51:43 -05:00
|
|
|
|
2009-09-13 14:54:56 -04:00
|
|
|
this._coverPane.lower_bottom();
|
|
|
|
|
2009-05-07 09:47:48 -04:00
|
|
|
this.emit('hidden');
|
2011-01-05 09:39:36 -05:00
|
|
|
// Handle any calls to show* while we were hiding
|
|
|
|
if (this._shown || this._shownTemporarily)
|
|
|
|
this._animateVisible();
|
|
|
|
|
|
|
|
this._syncInputMode();
|
2011-01-05 09:47:27 -05:00
|
|
|
|
|
|
|
// Fake a pointer event if requested
|
|
|
|
if (this._needsFakePointerEvent) {
|
|
|
|
this._fakePointerEvent();
|
|
|
|
this._needsFakePointerEvent = false;
|
|
|
|
}
|
2008-12-01 14:51:43 -05:00
|
|
|
}
|
2008-10-31 19:09:46 -04:00
|
|
|
};
|
2009-08-11 07:46:10 -04:00
|
|
|
Signals.addSignalMethods(Overview.prototype);
|