2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2008-10-31 23:09:46 +00:00
|
|
|
|
2008-11-21 00:53:11 +00:00
|
|
|
const Clutter = imports.gi.Clutter;
|
2013-11-29 00:45:39 +00:00
|
|
|
const GLib = imports.gi.GLib;
|
2011-01-21 13:08:42 +00:00
|
|
|
const Gtk = imports.gi.Gtk;
|
2010-07-15 14:21:32 +00:00
|
|
|
const Meta = imports.gi.Meta;
|
2009-02-02 23:02:16 +00:00
|
|
|
const Mainloop = imports.mainloop;
|
|
|
|
const Signals = imports.signals;
|
2009-04-13 18:45:58 +00:00
|
|
|
const Lang = imports.lang;
|
2010-01-22 02:33:48 +00:00
|
|
|
const St = imports.gi.St;
|
2011-01-05 14:39:36 +00:00
|
|
|
const Shell = imports.gi.Shell;
|
2011-01-05 14:47:27 +00:00
|
|
|
const Gdk = imports.gi.Gdk;
|
2009-02-02 23:02:16 +00:00
|
|
|
|
2012-12-24 14:20:39 +00:00
|
|
|
const Background = imports.ui.background;
|
2011-01-05 14:47:27 +00:00
|
|
|
const DND = imports.ui.dnd;
|
2013-03-01 23:00:59 +00:00
|
|
|
const LayoutManager = imports.ui.layout;
|
2009-02-02 23:02:16 +00:00
|
|
|
const Main = imports.ui.main;
|
2010-07-22 15:49:43 +00:00
|
|
|
const MessageTray = imports.ui.messageTray;
|
2012-12-11 22:26:09 +00:00
|
|
|
const OverviewControls = imports.ui.overviewControls;
|
2009-02-02 23:02:16 +00:00
|
|
|
const Panel = imports.ui.panel;
|
2011-08-28 14:24:48 +00:00
|
|
|
const Params = imports.misc.params;
|
2009-02-10 16:12:58 +00:00
|
|
|
const Tweener = imports.ui.tweener;
|
2013-04-22 21:56:34 +00:00
|
|
|
const WorkspaceThumbnail = imports.ui.workspaceThumbnail;
|
2008-10-31 23:09:46 +00:00
|
|
|
|
2009-08-11 11:46:10 +00:00
|
|
|
// Time for initial animation going into Overview mode
|
2009-06-02 17:43:34 +00:00
|
|
|
const ANIMATION_TIME = 0.25;
|
2008-11-06 14:00:14 +00:00
|
|
|
|
2012-12-24 14:20:39 +00:00
|
|
|
// Must be less than ANIMATION_TIME, since we switch to
|
|
|
|
// or from the overview completely after ANIMATION_TIME,
|
|
|
|
// and don't want the shading animation to get cut off
|
|
|
|
const SHADE_ANIMATION_TIME = .20;
|
2011-01-05 14:47:27 +00:00
|
|
|
|
2013-05-29 16:54:45 +00:00
|
|
|
const DND_WINDOW_SWITCH_TIMEOUT = 750;
|
2012-08-30 00:22:39 +00:00
|
|
|
|
2013-03-01 21:00:37 +00:00
|
|
|
const OVERVIEW_ACTIVATION_TIMEOUT = 0.5;
|
|
|
|
|
2011-11-20 17:56:27 +00:00
|
|
|
const ShellInfo = new Lang.Class({
|
|
|
|
Name: 'ShellInfo',
|
2010-07-22 15:49:43 +00:00
|
|
|
|
|
|
|
_init: function() {
|
|
|
|
this._source = null;
|
2010-02-08 22:50:50 +00:00
|
|
|
this._undoCallback = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
_onUndoClicked: function() {
|
|
|
|
if (this._undoCallback)
|
|
|
|
this._undoCallback();
|
|
|
|
this._undoCallback = null;
|
|
|
|
|
2010-07-22 15:49:43 +00:00
|
|
|
if (this._source)
|
|
|
|
this._source.destroy();
|
2010-02-08 22:50:50 +00:00
|
|
|
},
|
|
|
|
|
2012-11-02 17:06:40 +00:00
|
|
|
setMessage: function(text, options) {
|
|
|
|
options = Params.parse(options, { undoCallback: null,
|
|
|
|
forFeedback: false
|
|
|
|
});
|
|
|
|
|
|
|
|
let undoCallback = options.undoCallback;
|
|
|
|
let forFeedback = options.forFeedback;
|
|
|
|
|
2010-07-22 15:49:43 +00:00
|
|
|
if (this._source == null) {
|
2010-11-30 15:47:28 +00:00
|
|
|
this._source = new MessageTray.SystemNotificationSource();
|
2010-07-22 15:49:43 +00:00
|
|
|
this._source.connect('destroy', Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
this._source = null;
|
|
|
|
}));
|
|
|
|
Main.messageTray.add(this._source);
|
|
|
|
}
|
2010-02-08 22:50:50 +00:00
|
|
|
|
2011-03-21 21:43:34 +00:00
|
|
|
let notification = null;
|
|
|
|
if (this._source.notifications.length == 0) {
|
2010-07-22 15:49:43 +00:00
|
|
|
notification = new MessageTray.Notification(this._source, text, null);
|
2012-08-20 14:14:22 +00:00
|
|
|
notification.setTransient(true);
|
2012-11-02 17:06:40 +00:00
|
|
|
notification.setForFeedback(forFeedback);
|
2011-03-21 21:43:34 +00:00
|
|
|
} else {
|
|
|
|
notification = this._source.notifications[0];
|
2010-07-22 15:49:43 +00:00
|
|
|
notification.update(text, null, { clear: true });
|
2011-03-21 21:43:34 +00:00
|
|
|
}
|
2010-03-10 14:14:56 +00:00
|
|
|
|
2010-02-08 22:50:50 +00:00
|
|
|
this._undoCallback = undoCallback;
|
2013-10-14 03:06:09 +00:00
|
|
|
if (undoCallback)
|
|
|
|
notification.addAction(_("Undo"), Lang.bind(this, this._onUndoClicked));
|
2010-07-22 15:49:43 +00:00
|
|
|
|
|
|
|
this._source.notify(notification);
|
2010-02-08 22:50:50 +00:00
|
|
|
}
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|
2010-02-08 22:50:50 +00:00
|
|
|
|
2011-11-20 17:56:27 +00:00
|
|
|
const Overview = new Lang.Class({
|
|
|
|
Name: 'Overview',
|
2008-11-21 00:53:11 +00:00
|
|
|
|
2012-09-01 12:42:53 +00:00
|
|
|
_init: function() {
|
|
|
|
this._overviewCreated = false;
|
2012-11-29 16:58:31 +00:00
|
|
|
this._initCalled = false;
|
2012-09-01 12:42:53 +00:00
|
|
|
|
|
|
|
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
|
|
|
|
this._sessionUpdated();
|
|
|
|
},
|
2011-08-28 14:24:48 +00:00
|
|
|
|
2012-09-01 12:42:53 +00:00
|
|
|
_createOverview: function() {
|
|
|
|
if (this._overviewCreated)
|
2011-08-28 14:24:48 +00:00
|
|
|
return;
|
2012-09-01 12:42:53 +00:00
|
|
|
|
|
|
|
if (this.isDummy)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._overviewCreated = true;
|
2011-08-28 14:24:48 +00:00
|
|
|
|
2012-12-24 14:20:39 +00:00
|
|
|
// The main Background actors are inside global.window_group which are
|
2011-08-29 01:37:41 +00:00
|
|
|
// hidden when displaying the overview, so we create a new
|
|
|
|
// one. Instances of this class share a single CoglTexture behind the
|
|
|
|
// scenes which allows us to show the background with different
|
|
|
|
// rendering options without duplicating the texture data.
|
2012-12-24 14:20:39 +00:00
|
|
|
let monitor = Main.layoutManager.primaryMonitor;
|
2010-07-15 14:21:32 +00:00
|
|
|
|
2013-03-01 02:17:50 +00:00
|
|
|
let layout = new Clutter.BinLayout();
|
|
|
|
this._stack = new Clutter.Actor({ layout_manager: layout });
|
2013-03-01 23:00:59 +00:00
|
|
|
this._stack.add_constraint(new LayoutManager.MonitorConstraint({ primary: true }));
|
2013-03-01 02:17:50 +00:00
|
|
|
|
2012-03-05 15:07:37 +00:00
|
|
|
/* Translators: This is the main view to select
|
|
|
|
activities. See also note for "Activities" string. */
|
2012-12-10 20:39:15 +00:00
|
|
|
this._overview = new St.BoxLayout({ name: 'overview',
|
|
|
|
accessible_name: _("Overview"),
|
|
|
|
reactive: true,
|
2013-03-01 23:00:59 +00:00
|
|
|
vertical: true,
|
|
|
|
x_expand: true,
|
|
|
|
y_expand: true });
|
2012-12-10 20:39:15 +00:00
|
|
|
this._overview._delegate = this;
|
|
|
|
|
2012-12-24 14:20:39 +00:00
|
|
|
this._backgroundGroup = new Meta.BackgroundGroup();
|
2013-05-21 20:15:01 +00:00
|
|
|
Main.layoutManager.overviewGroup.add_child(this._backgroundGroup);
|
2012-12-24 14:20:39 +00:00
|
|
|
this._bgManagers = [];
|
|
|
|
|
2014-01-24 22:05:46 +00:00
|
|
|
this._desktopFade = new St.Widget();
|
2013-11-14 15:34:59 +00:00
|
|
|
Main.layoutManager.overviewGroup.add_child(this._desktopFade);
|
|
|
|
|
2013-03-01 21:00:37 +00:00
|
|
|
this._activationTime = 0;
|
|
|
|
|
2011-01-05 14:39:36 +00:00
|
|
|
this.visible = false; // animating to overview, in overview, animating out
|
|
|
|
this._shown = false; // show() and not hide()
|
|
|
|
this._modal = false; // have a modal grab
|
2009-08-07 22:22:05 +00:00
|
|
|
this.animationInProgress = false;
|
2013-02-16 17:45:10 +00:00
|
|
|
this.visibleTarget = false;
|
2009-06-24 22:24:48 +00:00
|
|
|
|
2009-09-13 18:54:56 +00: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.
|
2013-05-09 01:53:20 +00:00
|
|
|
this._coverPane = new Clutter.Actor({ opacity: 0,
|
|
|
|
reactive: true });
|
2013-09-29 21:20:27 +00:00
|
|
|
Main.layoutManager.overviewGroup.add_child(this._coverPane);
|
2013-11-29 18:17:34 +00:00
|
|
|
this._coverPane.connect('event', Lang.bind(this, function (actor, event) { return Clutter.EVENT_STOP; }));
|
2009-09-13 18:54:56 +00:00
|
|
|
|
2013-03-01 02:17:50 +00:00
|
|
|
this._stack.add_actor(this._overview);
|
2013-05-21 20:15:01 +00:00
|
|
|
Main.layoutManager.overviewGroup.add_child(this._stack);
|
2009-06-24 22:24:48 +00:00
|
|
|
|
2011-02-11 22:53:27 +00:00
|
|
|
this._coverPane.hide();
|
|
|
|
|
|
|
|
// 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));
|
|
|
|
|
2012-12-13 16:00:30 +00:00
|
|
|
global.screen.connect('restacked', Lang.bind(this, this._onRestacked));
|
|
|
|
|
2011-02-11 22:53:27 +00:00
|
|
|
this._windowSwitchTimeoutId = 0;
|
|
|
|
this._windowSwitchTimestamp = 0;
|
|
|
|
this._lastActiveWorkspaceIndex = -1;
|
|
|
|
this._lastHoveredWindow = null;
|
|
|
|
this._needsFakePointerEvent = false;
|
2012-11-29 16:58:31 +00:00
|
|
|
|
|
|
|
if (this._initCalled)
|
|
|
|
this.init();
|
2011-02-11 22:53:27 +00:00
|
|
|
},
|
|
|
|
|
2012-12-24 14:20:39 +00:00
|
|
|
_updateBackgrounds: function() {
|
|
|
|
for (let i = 0; i < this._bgManagers.length; i++)
|
|
|
|
this._bgManagers[i].destroy();
|
|
|
|
|
|
|
|
this._bgManagers = [];
|
|
|
|
|
|
|
|
for (let i = 0; i < Main.layoutManager.monitors.length; i++) {
|
|
|
|
let bgManager = new Background.BackgroundManager({ container: this._backgroundGroup,
|
|
|
|
monitorIndex: i,
|
|
|
|
effects: Meta.BackgroundEffects.VIGNETTE });
|
|
|
|
this._bgManagers.push(bgManager);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_unshadeBackgrounds: function() {
|
|
|
|
let backgrounds = this._backgroundGroup.get_children();
|
|
|
|
for (let i = 0; i < backgrounds.length; i++) {
|
|
|
|
let background = backgrounds[i]._delegate;
|
|
|
|
|
|
|
|
Tweener.addTween(background,
|
|
|
|
{ brightness: 1.0,
|
|
|
|
time: SHADE_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
|
|
|
Tweener.addTween(background,
|
|
|
|
{ vignetteSharpness: 0.0,
|
|
|
|
time: SHADE_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_shadeBackgrounds: function() {
|
|
|
|
let backgrounds = this._backgroundGroup.get_children();
|
|
|
|
for (let i = 0; i < backgrounds.length; i++) {
|
|
|
|
let background = backgrounds[i]._delegate;
|
|
|
|
|
|
|
|
Tweener.addTween(background,
|
|
|
|
{ brightness: 0.8,
|
|
|
|
time: SHADE_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
|
|
|
Tweener.addTween(background,
|
|
|
|
{ vignetteSharpness: 0.7,
|
|
|
|
time: SHADE_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-09-01 12:42:53 +00:00
|
|
|
_sessionUpdated: function() {
|
|
|
|
this.isDummy = !Main.sessionMode.hasOverview;
|
|
|
|
this._createOverview();
|
|
|
|
},
|
|
|
|
|
2011-02-11 22:53:27 +00:00
|
|
|
// The members we construct that are implemented in JS might
|
|
|
|
// want to access the overview as Main.overview to connect
|
|
|
|
// signal handlers and so forth. So we create them after
|
|
|
|
// construction in this init() method.
|
|
|
|
init: function() {
|
2012-11-29 16:58:31 +00:00
|
|
|
this._initCalled = true;
|
|
|
|
|
2011-08-28 14:24:48 +00:00
|
|
|
if (this.isDummy)
|
|
|
|
return;
|
|
|
|
|
2011-08-28 14:07:44 +00:00
|
|
|
this._shellInfo = new ShellInfo();
|
2011-02-11 22:53:27 +00:00
|
|
|
|
2012-12-10 20:39:15 +00:00
|
|
|
// Add a clone of the panel to the overview so spacing and such is
|
|
|
|
// automatic
|
|
|
|
this._panelGhost = new St.Bin({ child: new Clutter.Clone({ source: Main.panel.actor }),
|
|
|
|
reactive: false,
|
|
|
|
opacity: 0 });
|
|
|
|
this._overview.add_actor(this._panelGhost);
|
|
|
|
|
2012-07-28 20:47:55 +00:00
|
|
|
this._searchEntry = new St.Entry({ name: 'searchEntry',
|
|
|
|
/* Translators: this is the text displayed
|
|
|
|
in the search entry when no search is
|
|
|
|
active; it should not exceed ~30
|
|
|
|
characters. */
|
2012-12-03 15:59:28 +00:00
|
|
|
hint_text: _("Type to search…"),
|
2012-07-28 20:47:55 +00:00
|
|
|
track_hover: true,
|
|
|
|
can_focus: true });
|
2012-12-10 20:39:15 +00:00
|
|
|
this._searchEntryBin = new St.Bin({ child: this._searchEntry,
|
|
|
|
x_align: St.Align.MIDDLE });
|
|
|
|
this._overview.add_actor(this._searchEntryBin);
|
2012-07-28 20:47:55 +00:00
|
|
|
|
2013-02-15 23:25:36 +00:00
|
|
|
// Create controls
|
2013-02-25 23:05:45 +00:00
|
|
|
this._controls = new OverviewControls.ControlsManager(this._searchEntry);
|
|
|
|
this._dash = this._controls.dash;
|
2011-07-09 13:30:42 +00:00
|
|
|
this.viewSelector = this._controls.viewSelector;
|
2012-12-11 22:26:09 +00:00
|
|
|
|
2012-12-10 20:39:15 +00:00
|
|
|
// Add our same-line elements after the search entry
|
2013-02-25 23:05:45 +00:00
|
|
|
this._overview.add(this._controls.actor, { y_fill: true, expand: true });
|
|
|
|
this._controls.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
|
2012-12-10 20:39:15 +00:00
|
|
|
|
2013-03-01 02:19:03 +00:00
|
|
|
this._stack.add_actor(this._controls.indicatorActor);
|
|
|
|
|
2013-02-15 23:25:36 +00:00
|
|
|
// TODO - recalculate everything when desktop size changes
|
|
|
|
this.dashIconSize = this._dash.iconSize;
|
|
|
|
this._dash.connect('icon-size-changed',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
this.dashIconSize = this._dash.iconSize;
|
|
|
|
}));
|
2013-01-24 21:34:06 +00:00
|
|
|
|
2011-06-13 13:54:05 +00:00
|
|
|
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._relayout));
|
|
|
|
this._relayout();
|
2009-06-24 22:24:48 +00:00
|
|
|
},
|
|
|
|
|
2011-09-03 10:01:33 +00:00
|
|
|
addSearchProvider: function(provider) {
|
2011-07-09 13:30:42 +00:00
|
|
|
this.viewSelector.addSearchProvider(provider);
|
2011-08-28 11:20:37 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
removeSearchProvider: function(provider) {
|
2011-07-09 13:30:42 +00:00
|
|
|
this.viewSelector.removeSearchProvider(provider);
|
2011-09-03 10:01:33 +00:00
|
|
|
},
|
|
|
|
|
2012-11-02 17:06:40 +00:00
|
|
|
//
|
|
|
|
// options:
|
|
|
|
// - undoCallback (function): the callback to be called if undo support is needed
|
|
|
|
// - forFeedback (boolean): whether the message is for direct feedback of a user action
|
|
|
|
//
|
|
|
|
setMessage: function(text, options) {
|
2011-08-28 14:24:48 +00:00
|
|
|
if (this.isDummy)
|
|
|
|
return;
|
|
|
|
|
2012-11-02 17:06:40 +00:00
|
|
|
this._shellInfo.setMessage(text, options);
|
2011-08-28 14:07:44 +00:00
|
|
|
},
|
|
|
|
|
2011-01-05 14:47:27 +00:00
|
|
|
_onDragBegin: function() {
|
2013-03-04 22:02:02 +00:00
|
|
|
this._inXdndDrag = true;
|
|
|
|
|
2011-01-05 14:47:27 +00:00
|
|
|
DND.addDragMonitor(this._dragMonitor);
|
|
|
|
// Remember the workspace we started from
|
|
|
|
this._lastActiveWorkspaceIndex = global.screen.get_active_workspace_index();
|
|
|
|
},
|
|
|
|
|
|
|
|
_onDragEnd: function(time) {
|
2013-03-04 22:02:02 +00:00
|
|
|
this._inXdndDrag = false;
|
|
|
|
|
2011-01-05 14:47:27 +00:00
|
|
|
// In case the drag was canceled while in the overview
|
|
|
|
// we have to go back to where we started and hide
|
|
|
|
// the overview
|
2013-03-04 22:02:02 +00:00
|
|
|
if (this._shown) {
|
2011-01-05 14:47:27 +00:00
|
|
|
global.screen.get_workspace_by_index(this._lastActiveWorkspaceIndex).activate(time);
|
2013-03-04 22:02:02 +00:00
|
|
|
this.hide();
|
2011-01-05 14:47:27 +00:00
|
|
|
}
|
2011-02-24 10:30:46 +00:00
|
|
|
this._resetWindowSwitchTimeout();
|
2011-01-07 10:12:00 +00:00
|
|
|
this._lastHoveredWindow = null;
|
2011-06-27 16:59:56 +00:00
|
|
|
DND.removeDragMonitor(this._dragMonitor);
|
2011-03-13 18:34:47 +00:00
|
|
|
this.endItemDrag();
|
2011-01-05 14:47:27 +00:00
|
|
|
},
|
|
|
|
|
2011-02-24 10:30:46 +00:00
|
|
|
_resetWindowSwitchTimeout: function() {
|
|
|
|
if (this._windowSwitchTimeoutId != 0) {
|
|
|
|
Mainloop.source_remove(this._windowSwitchTimeoutId);
|
|
|
|
this._windowSwitchTimeoutId = 0;
|
|
|
|
this._needsFakePointerEvent = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-01-05 14:47:27 +00:00
|
|
|
_fakePointerEvent: function() {
|
|
|
|
let display = Gdk.Display.get_default();
|
|
|
|
let deviceManager = display.get_device_manager();
|
|
|
|
let pointer = deviceManager.get_client_pointer();
|
2011-01-05 22:34:27 +00:00
|
|
|
let [screen, pointerX, pointerY] = pointer.get_position();
|
2011-01-05 14:47:27 +00:00
|
|
|
|
2011-01-05 22:34:27 +00:00
|
|
|
pointer.warp(screen, pointerX, pointerY);
|
2011-01-05 14:47:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onDragMotion: function(dragEvent) {
|
2011-01-07 10:12:00 +00:00
|
|
|
let targetIsWindow = dragEvent.targetActor &&
|
|
|
|
dragEvent.targetActor._delegate &&
|
2011-03-21 22:20:36 +00:00
|
|
|
dragEvent.targetActor._delegate.metaWindow &&
|
|
|
|
!(dragEvent.targetActor._delegate instanceof WorkspaceThumbnail.WindowClone);
|
2011-01-07 10:12:00 +00:00
|
|
|
|
2011-02-24 10:25:29 +00:00
|
|
|
this._windowSwitchTimestamp = global.get_current_time();
|
|
|
|
|
2011-01-07 10:12:00 +00:00
|
|
|
if (targetIsWindow &&
|
|
|
|
dragEvent.targetActor._delegate.metaWindow == this._lastHoveredWindow)
|
2011-01-20 15:46:55 +00:00
|
|
|
return DND.DragMotionResult.CONTINUE;
|
|
|
|
|
|
|
|
this._lastHoveredWindow = null;
|
2011-01-07 10:12:00 +00:00
|
|
|
|
2011-02-24 10:30:46 +00:00
|
|
|
this._resetWindowSwitchTimeout();
|
2011-01-05 14:47:27 +00:00
|
|
|
|
2011-01-07 10:12:00 +00:00
|
|
|
if (targetIsWindow) {
|
|
|
|
this._lastHoveredWindow = dragEvent.targetActor._delegate.metaWindow;
|
2011-01-05 14:47:27 +00:00
|
|
|
this._windowSwitchTimeoutId = Mainloop.timeout_add(DND_WINDOW_SWITCH_TIMEOUT,
|
|
|
|
Lang.bind(this, function() {
|
2013-11-08 03:48:51 +00:00
|
|
|
this._windowSwitchTimeoutId = 0;
|
2011-01-05 14:47:27 +00:00
|
|
|
this._needsFakePointerEvent = true;
|
|
|
|
Main.activateWindow(dragEvent.targetActor._delegate.metaWindow,
|
|
|
|
this._windowSwitchTimestamp);
|
2013-03-04 22:02:02 +00:00
|
|
|
this.hide();
|
2011-01-07 10:12:00 +00:00
|
|
|
this._lastHoveredWindow = null;
|
2013-11-29 00:45:39 +00:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2011-01-05 14:47:27 +00:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
return DND.DragMotionResult.CONTINUE;
|
|
|
|
},
|
|
|
|
|
2012-10-22 15:39:19 +00:00
|
|
|
_onScrollEvent: function(actor, event) {
|
|
|
|
this.emit('scroll-event', event);
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2012-10-22 15:39:19 +00:00
|
|
|
},
|
|
|
|
|
2012-11-26 04:40:48 +00:00
|
|
|
addAction: function(action) {
|
|
|
|
if (this.isDummy)
|
|
|
|
return;
|
|
|
|
|
2012-12-10 20:39:15 +00:00
|
|
|
this._overview.add_action(action);
|
2012-11-26 04:40:48 +00:00
|
|
|
},
|
|
|
|
|
2010-07-15 14:21:32 +00: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;
|
|
|
|
|
2012-10-04 18:01:03 +00:00
|
|
|
let window = windows[0];
|
|
|
|
let clone = new Clutter.Clone({ source: window.get_texture(),
|
|
|
|
x: window.x, y: window.y });
|
2010-07-15 14:21:32 +00:00
|
|
|
clone.source.connect('destroy', Lang.bind(this, function() {
|
|
|
|
clone.destroy();
|
|
|
|
}));
|
|
|
|
return clone;
|
|
|
|
},
|
|
|
|
|
2011-06-13 13:54:05 +00:00
|
|
|
_relayout: function () {
|
|
|
|
// To avoid updating the position and size of the workspaces
|
|
|
|
// we just hide the overview. The positions will be updated
|
|
|
|
// when it is next shown.
|
|
|
|
this.hide();
|
|
|
|
|
2013-01-28 05:09:12 +00:00
|
|
|
let workArea = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex);
|
2009-09-13 18:54:56 +00:00
|
|
|
|
2013-01-28 05:09:12 +00:00
|
|
|
this._coverPane.set_position(0, workArea.y);
|
|
|
|
this._coverPane.set_size(workArea.width, workArea.height);
|
2012-12-24 14:20:39 +00:00
|
|
|
|
|
|
|
this._updateBackgrounds();
|
2008-12-01 19:51:43 +00:00
|
|
|
},
|
|
|
|
|
2012-12-13 16:00:30 +00: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.emit('windows-restacked', stackIndices);
|
|
|
|
},
|
|
|
|
|
2010-05-08 14:06:28 +00:00
|
|
|
//// Public methods ////
|
|
|
|
|
|
|
|
beginItemDrag: function(source) {
|
|
|
|
this.emit('item-drag-begin');
|
2013-03-27 17:31:43 +00:00
|
|
|
this._inDrag = true;
|
2009-03-11 19:21:45 +00:00
|
|
|
},
|
|
|
|
|
2011-03-09 15:40:48 +00:00
|
|
|
cancelledItemDrag: function(source) {
|
|
|
|
this.emit('item-drag-cancelled');
|
|
|
|
},
|
|
|
|
|
2010-05-08 14:06:28 +00:00
|
|
|
endItemDrag: function(source) {
|
|
|
|
this.emit('item-drag-end');
|
2013-03-27 17:31:43 +00:00
|
|
|
this._inDrag = false;
|
2010-05-08 14:06:28 +00:00
|
|
|
},
|
2009-03-11 19:21:45 +00:00
|
|
|
|
2013-09-11 18:20:39 +00:00
|
|
|
beginWindowDrag: function(clone) {
|
|
|
|
this.emit('window-drag-begin', clone);
|
2013-03-27 17:31:43 +00:00
|
|
|
this._inDrag = true;
|
2010-11-15 20:58:27 +00:00
|
|
|
},
|
|
|
|
|
2013-09-11 18:20:39 +00:00
|
|
|
cancelledWindowDrag: function(clone) {
|
|
|
|
this.emit('window-drag-cancelled', clone);
|
2011-03-08 13:44:47 +00:00
|
|
|
},
|
|
|
|
|
2013-09-11 18:20:39 +00:00
|
|
|
endWindowDrag: function(clone) {
|
|
|
|
this.emit('window-drag-end', clone);
|
2013-03-27 17:31:43 +00:00
|
|
|
this._inDrag = false;
|
2010-11-15 20:58:27 +00:00
|
|
|
},
|
|
|
|
|
2011-01-05 14:39:36 +00:00
|
|
|
// show:
|
|
|
|
//
|
|
|
|
// Animates the overview visible and grabs mouse and keyboard input
|
2013-05-22 16:05:24 +00:00
|
|
|
show: function() {
|
2011-08-28 14:24:48 +00:00
|
|
|
if (this.isDummy)
|
|
|
|
return;
|
2011-01-05 14:39:36 +00:00
|
|
|
if (this._shown)
|
2008-12-01 19:51:43 +00:00
|
|
|
return;
|
2012-12-10 08:58:59 +00:00
|
|
|
this._shown = true;
|
2013-03-04 22:02:02 +00:00
|
|
|
|
2013-05-22 16:05:24 +00:00
|
|
|
if (!this._syncGrab())
|
2009-09-16 15:37:51 +00:00
|
|
|
return;
|
2013-03-04 22:02:02 +00:00
|
|
|
|
2013-05-22 16:05:24 +00:00
|
|
|
Main.layoutManager.showOverview();
|
2011-01-05 14:39:36 +00:00
|
|
|
this._animateVisible();
|
|
|
|
},
|
|
|
|
|
2013-05-17 15:31:27 +00:00
|
|
|
focusSearch: function() {
|
|
|
|
this.show();
|
|
|
|
this._searchEntry.grab_key_focus();
|
|
|
|
},
|
|
|
|
|
2012-07-28 20:06:46 +00:00
|
|
|
fadeInDesktop: function() {
|
|
|
|
this._desktopFade.opacity = 0;
|
|
|
|
this._desktopFade.show();
|
|
|
|
Tweener.addTween(this._desktopFade,
|
|
|
|
{ opacity: 255,
|
|
|
|
time: ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad' });
|
|
|
|
},
|
|
|
|
|
|
|
|
fadeOutDesktop: function() {
|
2014-02-03 10:26:19 +00:00
|
|
|
if (!this._desktopFade.get_n_children()) {
|
|
|
|
let clone = this._getDesktopClone();
|
|
|
|
if (!clone)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._desktopFade.add_child(clone);
|
|
|
|
}
|
2012-07-28 20:06:46 +00:00
|
|
|
|
|
|
|
this._desktopFade.opacity = 255;
|
|
|
|
this._desktopFade.show();
|
|
|
|
Tweener.addTween(this._desktopFade,
|
|
|
|
{ opacity: 0,
|
|
|
|
time: ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2011-01-05 14:39:36 +00:00
|
|
|
_animateVisible: function() {
|
|
|
|
if (this.visible || this.animationInProgress)
|
|
|
|
return;
|
2008-11-28 20:12:20 +00:00
|
|
|
|
2008-12-01 19:51:43 +00:00
|
|
|
this.visible = true;
|
2009-08-07 22:22:05 +00:00
|
|
|
this.animationInProgress = true;
|
2013-02-16 17:45:10 +00:00
|
|
|
this.visibleTarget = true;
|
2013-03-01 21:00:37 +00:00
|
|
|
this._activationTime = Date.now() / 1000;
|
2008-11-28 20:12:20 +00:00
|
|
|
|
2011-08-29 21:55:42 +00:00
|
|
|
Meta.disable_unredirect_for_screen(global.screen);
|
2011-07-09 13:30:42 +00:00
|
|
|
this.viewSelector.show();
|
2010-07-15 14:21:32 +00:00
|
|
|
|
2013-03-01 17:14:33 +00:00
|
|
|
this._stack.opacity = 0;
|
|
|
|
Tweener.addTween(this._stack,
|
2009-08-10 22:31:39 +00:00
|
|
|
{ opacity: 255,
|
|
|
|
transition: 'easeOutQuad',
|
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 16:04:03 +00:00
|
|
|
time: ANIMATION_TIME,
|
|
|
|
onComplete: this._showDone,
|
|
|
|
onCompleteScope: this
|
2009-03-20 16:06:34 +00:00
|
|
|
});
|
2012-12-24 14:20:39 +00:00
|
|
|
this._shadeBackgrounds();
|
2011-08-29 01:41:28 +00:00
|
|
|
|
2009-09-13 18:54:56 +00:00
|
|
|
this._coverPane.raise_top();
|
2011-01-21 13:08:42 +00:00
|
|
|
this._coverPane.show();
|
2009-05-07 13:47:48 +00:00
|
|
|
this.emit('showing');
|
2008-12-01 19:51:43 +00:00
|
|
|
},
|
|
|
|
|
2011-01-05 14:39:36 +00:00
|
|
|
// hide:
|
|
|
|
//
|
|
|
|
// Reverses the effect of show()
|
2009-09-11 16:39:59 +00:00
|
|
|
hide: function() {
|
2011-08-28 14:24:48 +00:00
|
|
|
if (this.isDummy)
|
|
|
|
return;
|
|
|
|
|
2011-01-05 14:39:36 +00:00
|
|
|
if (!this._shown)
|
|
|
|
return;
|
|
|
|
|
2013-03-04 22:54:02 +00:00
|
|
|
let event = Clutter.get_current_event();
|
2013-03-14 15:34:09 +00:00
|
|
|
if (event) {
|
|
|
|
let type = event.type();
|
|
|
|
let button = (type == Clutter.EventType.BUTTON_PRESS ||
|
|
|
|
type == Clutter.EventType.BUTTON_RELEASE);
|
|
|
|
let ctrl = (event.get_state() & Clutter.ModifierType.CONTROL_MASK) != 0;
|
|
|
|
if (button && ctrl)
|
|
|
|
return;
|
|
|
|
}
|
2013-02-21 14:57:00 +00:00
|
|
|
|
2013-03-04 22:02:02 +00:00
|
|
|
this._animateNotVisible();
|
2011-01-05 14:39:36 +00:00
|
|
|
|
|
|
|
this._shown = false;
|
2013-05-22 16:05:24 +00:00
|
|
|
this._syncGrab();
|
2011-01-05 14:39:36 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
toggle: function() {
|
2011-08-28 14:24:48 +00:00
|
|
|
if (this.isDummy)
|
|
|
|
return;
|
|
|
|
|
overview: Fix stuck grabs when mashing the overlay-key
When pressing the overlay key three times, things went like this:
* show(), push a modal
* hide(), will pop a modal after hiding is done
* show(), push a modal
Thus, when the showing is done, and then it activated the hiding,
it popped one modal, but not the other. This patch changes things
to be:
* show(), push a modal
* hide(), will pop a modal after hiding is done
* hide(), no-op
That is, mashing the overlay-key when it's showing will always make
it hide, not mashing an odd number of times.
https://bugzilla.gnome.org/show_bug.cgi?id=688589
2012-11-18 15:49:31 +00:00
|
|
|
if (this.visible)
|
2011-01-05 14:39:36 +00:00
|
|
|
this.hide();
|
|
|
|
else
|
|
|
|
this.show();
|
|
|
|
},
|
|
|
|
|
2013-03-01 21:00:37 +00:00
|
|
|
// Checks if the Activities button is currently sensitive to
|
|
|
|
// clicks. The first call to this function within the
|
|
|
|
// OVERVIEW_ACTIVATION_TIMEOUT time of the hot corner being
|
|
|
|
// triggered will return false. This avoids opening and closing
|
|
|
|
// the overview if the user both triggered the hot corner and
|
|
|
|
// clicked the Activities button.
|
|
|
|
shouldToggleByCornerOrButton: function() {
|
|
|
|
if (this.animationInProgress)
|
|
|
|
return false;
|
2013-03-27 17:31:43 +00:00
|
|
|
if (this._inDrag)
|
|
|
|
return false;
|
2013-03-01 21:00:37 +00:00
|
|
|
if (this._activationTime == 0 || Date.now() / 1000 - this._activationTime > OVERVIEW_ACTIVATION_TIMEOUT)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2011-01-05 14:39:36 +00:00
|
|
|
//// Private methods ////
|
|
|
|
|
2013-05-22 16:05:24 +00:00
|
|
|
_syncGrab: function() {
|
|
|
|
// We delay grab changes during animation so that when removing the
|
2011-01-05 14:39:36 +00:00
|
|
|
// overview we don't have a problem with the release of a press/release
|
|
|
|
// going to an application.
|
|
|
|
if (this.animationInProgress)
|
2013-03-04 22:02:02 +00:00
|
|
|
return true;
|
2011-01-05 14:39:36 +00:00
|
|
|
|
|
|
|
if (this._shown) {
|
2013-03-04 22:02:02 +00:00
|
|
|
let shouldBeModal = !this._inXdndDrag;
|
|
|
|
if (shouldBeModal) {
|
|
|
|
if (!this._modal) {
|
|
|
|
if (Main.pushModal(this._overview,
|
|
|
|
{ keybindingMode: Shell.KeyBindingMode.OVERVIEW })) {
|
|
|
|
this._modal = true;
|
|
|
|
} else {
|
|
|
|
this.hide();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-01-05 14:39:36 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (this._modal) {
|
2012-12-10 20:39:15 +00:00
|
|
|
Main.popModal(this._overview);
|
2011-01-05 14:39:36 +00:00
|
|
|
this._modal = false;
|
|
|
|
}
|
|
|
|
}
|
2013-03-04 22:02:02 +00:00
|
|
|
return true;
|
2011-01-05 14:39:36 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_animateNotVisible: function() {
|
|
|
|
if (!this.visible || this.animationInProgress)
|
2008-12-01 19:51:43 +00:00
|
|
|
return;
|
|
|
|
|
2009-08-07 22:22:05 +00:00
|
|
|
this.animationInProgress = true;
|
2013-02-16 17:45:10 +00:00
|
|
|
this.visibleTarget = false;
|
2010-07-15 14:21:32 +00:00
|
|
|
|
2011-07-09 13:30:42 +00:00
|
|
|
this.viewSelector.zoomFromOverview();
|
2008-12-04 15:16:16 +00:00
|
|
|
|
2010-11-11 17:50:19 +00:00
|
|
|
// Make other elements fade out.
|
2013-03-01 17:14:33 +00:00
|
|
|
Tweener.addTween(this._stack,
|
2009-08-10 22:31:39 +00:00
|
|
|
{ opacity: 0,
|
|
|
|
transition: 'easeOutQuad',
|
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 16:04:03 +00:00
|
|
|
time: ANIMATION_TIME,
|
|
|
|
onComplete: this._hideDone,
|
|
|
|
onCompleteScope: this
|
2008-12-04 15:16:16 +00:00
|
|
|
});
|
2012-12-24 14:20:39 +00:00
|
|
|
this._unshadeBackgrounds();
|
2011-08-29 01:41:28 +00:00
|
|
|
|
2009-09-13 18:54:56 +00:00
|
|
|
this._coverPane.raise_top();
|
2011-01-21 13:08:42 +00:00
|
|
|
this._coverPane.show();
|
2009-05-07 13:47:48 +00:00
|
|
|
this.emit('hiding');
|
|
|
|
},
|
|
|
|
|
2009-04-22 00:23:06 +00:00
|
|
|
_showDone: function() {
|
2009-08-07 22:22:05 +00:00
|
|
|
this.animationInProgress = false;
|
2010-07-15 14:21:32 +00:00
|
|
|
this._desktopFade.hide();
|
2011-01-21 13:08:42 +00:00
|
|
|
this._coverPane.hide();
|
2009-08-07 22:22:05 +00:00
|
|
|
|
2009-05-07 13:47:48 +00:00
|
|
|
this.emit('shown');
|
2011-01-05 14:39:36 +00:00
|
|
|
// Handle any calls to hide* while we were showing
|
2013-03-04 22:02:02 +00:00
|
|
|
if (!this._shown)
|
2011-01-05 14:39:36 +00:00
|
|
|
this._animateNotVisible();
|
|
|
|
|
2013-05-22 16:05:24 +00:00
|
|
|
this._syncGrab();
|
2011-03-21 18:46:46 +00:00
|
|
|
global.sync_pointer();
|
2009-04-22 00:23:06 +00:00
|
|
|
},
|
2009-03-20 16:06:34 +00:00
|
|
|
|
2008-12-04 15:16:16 +00:00
|
|
|
_hideDone: function() {
|
2011-08-29 21:55:42 +00:00
|
|
|
// Re-enable unredirection
|
|
|
|
Meta.enable_unredirect_for_screen(global.screen);
|
|
|
|
|
2011-07-09 13:30:42 +00:00
|
|
|
this.viewSelector.hide();
|
2010-07-15 14:21:32 +00:00
|
|
|
this._desktopFade.hide();
|
2013-05-22 16:05:24 +00:00
|
|
|
this._coverPane.hide();
|
2009-03-20 16:06:34 +00:00
|
|
|
|
2010-01-22 02:33:48 +00:00
|
|
|
this.visible = false;
|
2009-08-07 22:22:05 +00:00
|
|
|
this.animationInProgress = false;
|
2008-12-01 19:51:43 +00:00
|
|
|
|
2009-05-07 13:47:48 +00:00
|
|
|
this.emit('hidden');
|
2011-01-05 14:39:36 +00:00
|
|
|
// Handle any calls to show* while we were hiding
|
2013-03-04 22:02:02 +00:00
|
|
|
if (this._shown)
|
2011-01-05 14:39:36 +00:00
|
|
|
this._animateVisible();
|
2013-05-22 16:05:24 +00:00
|
|
|
else
|
|
|
|
Main.layoutManager.hideOverview();
|
2011-01-05 14:39:36 +00:00
|
|
|
|
2013-05-22 16:05:24 +00:00
|
|
|
this._syncGrab();
|
2011-01-05 14:47:27 +00:00
|
|
|
|
|
|
|
// Fake a pointer event if requested
|
|
|
|
if (this._needsFakePointerEvent) {
|
|
|
|
this._fakePointerEvent();
|
|
|
|
this._needsFakePointerEvent = false;
|
|
|
|
}
|
2008-12-01 19:51:43 +00:00
|
|
|
}
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|
2009-08-11 11:46:10 +00:00
|
|
|
Signals.addSignalMethods(Overview.prototype);
|