2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2008-11-21 14:02:09 +00:00
|
|
|
|
|
|
|
const Clutter = imports.gi.Clutter;
|
2010-09-11 01:30:50 +00:00
|
|
|
const GLib = imports.gi.GLib;
|
|
|
|
const Gio = imports.gi.Gio;
|
2009-09-15 17:09:51 +00:00
|
|
|
const Lang = imports.lang;
|
2012-12-23 03:10:27 +00:00
|
|
|
const Mainloop = imports.mainloop;
|
2008-11-21 21:34:10 +00:00
|
|
|
const Meta = imports.gi.Meta;
|
2013-08-17 15:42:39 +00:00
|
|
|
const Pango = imports.gi.Pango;
|
2010-02-10 22:26:24 +00:00
|
|
|
const St = imports.gi.St;
|
2011-05-20 09:14:54 +00:00
|
|
|
const Shell = imports.gi.Shell;
|
2014-06-25 16:13:26 +00:00
|
|
|
const Signals = imports.signals;
|
2008-11-21 14:02:09 +00:00
|
|
|
|
2009-04-13 14:55:41 +00:00
|
|
|
const AltTab = imports.ui.altTab;
|
2010-02-12 22:52:15 +00:00
|
|
|
const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup;
|
2008-11-21 14:02:09 +00:00
|
|
|
const Main = imports.ui.main;
|
2013-08-17 15:42:39 +00:00
|
|
|
const ModalDialog = imports.ui.modalDialog;
|
2009-02-10 16:12:58 +00:00
|
|
|
const Tweener = imports.ui.tweener;
|
2014-03-13 22:51:10 +00:00
|
|
|
const WindowMenu = imports.ui.windowMenu;
|
2008-11-21 14:02:09 +00:00
|
|
|
|
2012-03-27 13:26:20 +00:00
|
|
|
const SHELL_KEYBINDINGS_SCHEMA = 'org.gnome.shell.keybindings';
|
2014-07-07 15:18:07 +00:00
|
|
|
const MINIMIZE_WINDOW_ANIMATION_TIME = 0.2;
|
2014-07-28 16:12:30 +00:00
|
|
|
const SHOW_WINDOW_ANIMATION_TIME = 0.15;
|
|
|
|
const DIALOG_SHOW_WINDOW_ANIMATION_TIME = 0.1;
|
|
|
|
const DESTROY_WINDOW_ANIMATION_TIME = 0.15;
|
|
|
|
const DIALOG_DESTROY_WINDOW_ANIMATION_TIME = 0.1;
|
2008-12-29 04:44:03 +00:00
|
|
|
const WINDOW_ANIMATION_TIME = 0.25;
|
2012-08-10 12:39:42 +00:00
|
|
|
const DIM_BRIGHTNESS = -0.3;
|
2010-09-11 01:30:50 +00:00
|
|
|
const DIM_TIME = 0.500;
|
|
|
|
const UNDIM_TIME = 0.250;
|
|
|
|
|
2013-08-17 15:42:39 +00:00
|
|
|
const DISPLAY_REVERT_TIMEOUT = 20; // in seconds - keep in sync with mutter
|
|
|
|
const ONE_SECOND = 1000; // in ms
|
|
|
|
|
|
|
|
const DisplayChangeDialog = new Lang.Class({
|
|
|
|
Name: 'DisplayChangeDialog',
|
|
|
|
Extends: ModalDialog.ModalDialog,
|
|
|
|
|
|
|
|
_init: function(wm) {
|
|
|
|
this.parent({ styleClass: 'prompt-dialog' });
|
|
|
|
|
|
|
|
this._wm = wm;
|
|
|
|
|
|
|
|
let mainContentBox = new St.BoxLayout({ style_class: 'prompt-dialog-main-layout',
|
|
|
|
vertical: false });
|
|
|
|
this.contentLayout.add(mainContentBox,
|
|
|
|
{ x_fill: true,
|
|
|
|
y_fill: true });
|
|
|
|
|
|
|
|
let icon = new St.Icon({ icon_name: 'preferences-desktop-display-symbolic' });
|
|
|
|
mainContentBox.add(icon,
|
|
|
|
{ x_fill: true,
|
|
|
|
y_fill: false,
|
|
|
|
x_align: St.Align.END,
|
|
|
|
y_align: St.Align.START });
|
|
|
|
|
|
|
|
let messageBox = new St.BoxLayout({ style_class: 'prompt-dialog-message-layout',
|
|
|
|
vertical: true });
|
|
|
|
mainContentBox.add(messageBox,
|
|
|
|
{ expand: true, y_align: St.Align.START });
|
|
|
|
|
2015-03-10 17:27:43 +00:00
|
|
|
let subjectLabel = new St.Label({ style_class: 'prompt-dialog-headline',
|
2013-08-17 15:42:39 +00:00
|
|
|
text: _("Do you want to keep these display settings?") });
|
|
|
|
messageBox.add(subjectLabel,
|
|
|
|
{ y_fill: false,
|
|
|
|
y_align: St.Align.START });
|
|
|
|
|
|
|
|
this._countDown = DISPLAY_REVERT_TIMEOUT;
|
|
|
|
let message = this._formatCountDown();
|
|
|
|
this._descriptionLabel = new St.Label({ style_class: 'prompt-dialog-description',
|
|
|
|
text: this._formatCountDown() });
|
|
|
|
this._descriptionLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
|
|
|
|
this._descriptionLabel.clutter_text.line_wrap = true;
|
|
|
|
|
|
|
|
messageBox.add(this._descriptionLabel,
|
|
|
|
{ y_fill: true,
|
|
|
|
y_align: St.Align.START });
|
|
|
|
|
|
|
|
/* Translators: this and the following message should be limited in lenght,
|
|
|
|
to avoid ellipsizing the labels.
|
|
|
|
*/
|
|
|
|
this._cancelButton = this.addButton({ label: _("Revert Settings"),
|
|
|
|
action: Lang.bind(this, this._onFailure),
|
2015-07-29 11:45:11 +00:00
|
|
|
key: Clutter.Escape });
|
2013-08-17 15:42:39 +00:00
|
|
|
this._okButton = this.addButton({ label: _("Keep Changes"),
|
|
|
|
action: Lang.bind(this, this._onSuccess),
|
2015-07-29 11:45:11 +00:00
|
|
|
default: true });
|
2013-08-17 15:42:39 +00:00
|
|
|
|
|
|
|
this._timeoutId = Mainloop.timeout_add(ONE_SECOND, Lang.bind(this, this._tick));
|
2014-04-10 17:26:52 +00:00
|
|
|
GLib.Source.set_name_by_id(this._timeoutId, '[gnome-shell] this._tick');
|
2013-08-17 15:42:39 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
close: function(timestamp) {
|
|
|
|
if (this._timeoutId > 0) {
|
|
|
|
Mainloop.source_remove(this._timeoutId);
|
|
|
|
this._timeoutId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.parent(timestamp);
|
|
|
|
},
|
|
|
|
|
|
|
|
_formatCountDown: function() {
|
|
|
|
let fmt = ngettext("Settings changes will revert in %d second",
|
|
|
|
"Settings changes will revert in %d seconds");
|
|
|
|
return fmt.format(this._countDown);
|
|
|
|
},
|
|
|
|
|
|
|
|
_tick: function() {
|
|
|
|
this._countDown--;
|
|
|
|
|
|
|
|
if (this._countDown == 0) {
|
|
|
|
/* mutter already takes care of failing at timeout */
|
|
|
|
this._timeoutId = 0;
|
|
|
|
this.close();
|
2013-11-29 00:45:39 +00:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2013-08-17 15:42:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this._descriptionLabel.text = this._formatCountDown();
|
2013-11-29 00:45:39 +00:00
|
|
|
return GLib.SOURCE_CONTINUE;
|
2013-08-17 15:42:39 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onFailure: function() {
|
|
|
|
this._wm.complete_display_change(false);
|
|
|
|
this.close();
|
|
|
|
},
|
|
|
|
|
|
|
|
_onSuccess: function() {
|
|
|
|
this._wm.complete_display_change(true);
|
|
|
|
this.close();
|
|
|
|
},
|
|
|
|
});
|
2010-09-11 01:30:50 +00:00
|
|
|
|
2011-11-20 17:56:27 +00:00
|
|
|
const WindowDimmer = new Lang.Class({
|
|
|
|
Name: 'WindowDimmer',
|
2010-09-11 01:30:50 +00:00
|
|
|
|
2011-09-20 18:21:45 +00:00
|
|
|
_init: function(actor) {
|
2012-07-13 17:57:36 +00:00
|
|
|
this._brightnessEffect = new Clutter.BrightnessContrastEffect();
|
|
|
|
actor.add_effect(this._brightnessEffect);
|
2010-09-11 01:30:50 +00:00
|
|
|
this.actor = actor;
|
2012-08-30 19:32:44 +00:00
|
|
|
this._enabled = true;
|
2012-07-13 17:57:36 +00:00
|
|
|
this._dimFactor = 0.0;
|
2012-08-30 19:32:44 +00:00
|
|
|
this._syncEnabled();
|
|
|
|
},
|
|
|
|
|
|
|
|
_syncEnabled: function() {
|
|
|
|
this._brightnessEffect.enabled = (this._enabled && this._dimFactor > 0);
|
2010-09-11 01:30:50 +00:00
|
|
|
},
|
|
|
|
|
2012-07-13 17:57:36 +00:00
|
|
|
setEnabled: function(enabled) {
|
2012-08-30 19:32:44 +00:00
|
|
|
this._enabled = enabled;
|
|
|
|
this._syncEnabled();
|
2010-09-11 01:30:50 +00:00
|
|
|
},
|
|
|
|
|
2012-07-13 17:57:36 +00:00
|
|
|
set dimFactor(factor) {
|
|
|
|
this._dimFactor = factor;
|
|
|
|
this._brightnessEffect.set_brightness(factor * DIM_BRIGHTNESS);
|
2012-08-30 19:32:44 +00:00
|
|
|
this._syncEnabled();
|
2010-09-11 01:30:50 +00:00
|
|
|
},
|
|
|
|
|
2012-07-13 17:57:36 +00:00
|
|
|
get dimFactor() {
|
|
|
|
return this._dimFactor;
|
|
|
|
}
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|
2010-09-11 01:30:50 +00:00
|
|
|
|
2011-09-20 18:21:45 +00:00
|
|
|
function getWindowDimmer(actor) {
|
2012-08-30 19:32:44 +00:00
|
|
|
let enabled = Meta.prefs_get_attach_modal_dialogs();
|
|
|
|
if (actor._windowDimmer)
|
|
|
|
actor._windowDimmer.setEnabled(enabled);
|
|
|
|
|
|
|
|
if (enabled) {
|
|
|
|
if (!actor._windowDimmer)
|
|
|
|
actor._windowDimmer = new WindowDimmer(actor);
|
|
|
|
return actor._windowDimmer;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2010-09-11 01:30:50 +00:00
|
|
|
}
|
2008-11-21 21:34:10 +00:00
|
|
|
|
2012-12-23 03:10:27 +00:00
|
|
|
/*
|
|
|
|
* When the last window closed on a workspace is a dialog or splash
|
|
|
|
* screen, we assume that it might be an initial window shown before
|
|
|
|
* the main window of an application, and give the app a grace period
|
|
|
|
* where it can map another window before we remove the workspace.
|
|
|
|
*/
|
|
|
|
const LAST_WINDOW_GRACE_TIME = 1000;
|
|
|
|
|
|
|
|
const WorkspaceTracker = new Lang.Class({
|
|
|
|
Name: 'WorkspaceTracker',
|
|
|
|
|
|
|
|
_init: function(wm) {
|
|
|
|
this._wm = wm;
|
|
|
|
|
|
|
|
this._workspaces = [];
|
|
|
|
this._checkWorkspacesId = 0;
|
|
|
|
|
2015-03-27 13:34:28 +00:00
|
|
|
this._pauseWorkspaceCheck = false;
|
|
|
|
|
2012-12-23 03:10:27 +00:00
|
|
|
let tracker = Shell.WindowTracker.get_default();
|
|
|
|
tracker.connect('startup-sequence-changed', Lang.bind(this, this._queueCheckWorkspaces));
|
|
|
|
|
|
|
|
global.screen.connect('notify::n-workspaces', Lang.bind(this, this._nWorkspacesChanged));
|
2013-09-30 17:59:09 +00:00
|
|
|
global.window_manager.connect('switch-workspace', Lang.bind(this, this._queueCheckWorkspaces));
|
2012-12-23 03:10:27 +00:00
|
|
|
|
|
|
|
global.screen.connect('window-entered-monitor', Lang.bind(this, this._windowEnteredMonitor));
|
|
|
|
global.screen.connect('window-left-monitor', Lang.bind(this, this._windowLeftMonitor));
|
|
|
|
global.screen.connect('restacked', Lang.bind(this, this._windowsRestacked));
|
|
|
|
|
2014-06-05 16:09:47 +00:00
|
|
|
this._workspaceSettings = this._getWorkspaceSettings();
|
2013-06-06 16:47:56 +00:00
|
|
|
this._workspaceSettings.connect('changed::dynamic-workspaces', Lang.bind(this, this._queueCheckWorkspaces));
|
2012-12-23 03:10:27 +00:00
|
|
|
|
|
|
|
this._nWorkspacesChanged();
|
|
|
|
},
|
|
|
|
|
2014-06-05 16:09:47 +00:00
|
|
|
_getWorkspaceSettings: function() {
|
|
|
|
let settings = global.get_overrides_settings();
|
2015-07-03 20:11:24 +00:00
|
|
|
if (settings &&
|
|
|
|
settings.settings_schema.list_keys().indexOf('dynamic-workspaces') > -1)
|
2014-06-05 16:09:47 +00:00
|
|
|
return settings;
|
2014-06-24 19:17:09 +00:00
|
|
|
return new Gio.Settings({ schema_id: 'org.gnome.mutter' });
|
2014-06-05 16:09:47 +00:00
|
|
|
},
|
|
|
|
|
2015-03-27 13:34:28 +00:00
|
|
|
blockUpdates: function() {
|
|
|
|
this._pauseWorkspaceCheck = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
unblockUpdates: function() {
|
|
|
|
this._pauseWorkspaceCheck = false;
|
|
|
|
},
|
|
|
|
|
2012-12-23 03:10:27 +00:00
|
|
|
_checkWorkspaces: function() {
|
|
|
|
let i;
|
|
|
|
let emptyWorkspaces = [];
|
|
|
|
|
|
|
|
if (!Meta.prefs_get_dynamic_workspaces()) {
|
|
|
|
this._checkWorkspacesId = 0;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-03-27 13:34:28 +00:00
|
|
|
// Update workspaces only if Dynamic Workspace Management has not been paused by some other function
|
|
|
|
if (this._pauseWorkspaceCheck)
|
|
|
|
return true;
|
|
|
|
|
2012-12-23 03:10:27 +00:00
|
|
|
for (i = 0; i < this._workspaces.length; i++) {
|
|
|
|
let lastRemoved = this._workspaces[i]._lastRemovedWindow;
|
|
|
|
if ((lastRemoved &&
|
|
|
|
(lastRemoved.get_window_type() == Meta.WindowType.SPLASHSCREEN ||
|
|
|
|
lastRemoved.get_window_type() == Meta.WindowType.DIALOG ||
|
|
|
|
lastRemoved.get_window_type() == Meta.WindowType.MODAL_DIALOG)) ||
|
|
|
|
this._workspaces[i]._keepAliveId)
|
|
|
|
emptyWorkspaces[i] = false;
|
|
|
|
else
|
|
|
|
emptyWorkspaces[i] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
let sequences = Shell.WindowTracker.get_default().get_startup_sequences();
|
|
|
|
for (i = 0; i < sequences.length; i++) {
|
|
|
|
let index = sequences[i].get_workspace();
|
|
|
|
if (index >= 0 && index <= global.screen.n_workspaces)
|
|
|
|
emptyWorkspaces[index] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
let windows = global.get_window_actors();
|
|
|
|
for (i = 0; i < windows.length; i++) {
|
2013-11-05 02:24:27 +00:00
|
|
|
let actor = windows[i];
|
|
|
|
let win = actor.get_meta_window();
|
2012-12-23 03:10:27 +00:00
|
|
|
|
2013-11-05 02:24:27 +00:00
|
|
|
if (win.is_on_all_workspaces())
|
2012-12-23 03:10:27 +00:00
|
|
|
continue;
|
|
|
|
|
2013-11-05 02:24:27 +00:00
|
|
|
let workspaceIndex = win.get_workspace().index();
|
2012-12-23 03:10:27 +00:00
|
|
|
emptyWorkspaces[workspaceIndex] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we don't have an empty workspace at the end, add one
|
|
|
|
if (!emptyWorkspaces[emptyWorkspaces.length -1]) {
|
|
|
|
global.screen.append_new_workspace(false, global.get_current_time());
|
|
|
|
emptyWorkspaces.push(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
|
2013-09-30 17:59:09 +00:00
|
|
|
emptyWorkspaces[activeWorkspaceIndex] = false;
|
2012-12-23 03:10:27 +00:00
|
|
|
|
|
|
|
// Delete other empty workspaces; do it from the end to avoid index changes
|
|
|
|
for (i = emptyWorkspaces.length - 2; i >= 0; i--) {
|
|
|
|
if (emptyWorkspaces[i])
|
|
|
|
global.screen.remove_workspace(this._workspaces[i], global.get_current_time());
|
|
|
|
}
|
|
|
|
|
|
|
|
this._checkWorkspacesId = 0;
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
keepWorkspaceAlive: function(workspace, duration) {
|
|
|
|
if (workspace._keepAliveId)
|
|
|
|
Mainloop.source_remove(workspace._keepAliveId);
|
|
|
|
|
|
|
|
workspace._keepAliveId = Mainloop.timeout_add(duration, Lang.bind(this, function() {
|
|
|
|
workspace._keepAliveId = 0;
|
|
|
|
this._queueCheckWorkspaces();
|
2013-11-29 00:45:39 +00:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2012-12-23 03:10:27 +00:00
|
|
|
}));
|
2014-04-10 17:26:52 +00:00
|
|
|
GLib.Source.set_name_by_id(workspace._keepAliveId, '[gnome-shell] this._queueCheckWorkspaces');
|
2012-12-23 03:10:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_windowRemoved: function(workspace, window) {
|
|
|
|
workspace._lastRemovedWindow = window;
|
|
|
|
this._queueCheckWorkspaces();
|
2014-04-10 17:26:52 +00:00
|
|
|
let id = Mainloop.timeout_add(LAST_WINDOW_GRACE_TIME, Lang.bind(this, function() {
|
2012-12-23 03:10:27 +00:00
|
|
|
if (workspace._lastRemovedWindow == window) {
|
|
|
|
workspace._lastRemovedWindow = null;
|
|
|
|
this._queueCheckWorkspaces();
|
|
|
|
}
|
2013-11-29 00:45:39 +00:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2012-12-23 03:10:27 +00:00
|
|
|
}));
|
2014-04-10 17:26:52 +00:00
|
|
|
GLib.Source.set_name_by_id(id, '[gnome-shell] this._queueCheckWorkspaces');
|
2012-12-23 03:10:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_windowLeftMonitor: function(metaScreen, monitorIndex, metaWin) {
|
|
|
|
// If the window left the primary monitor, that
|
|
|
|
// might make that workspace empty
|
|
|
|
if (monitorIndex == Main.layoutManager.primaryIndex)
|
|
|
|
this._queueCheckWorkspaces();
|
|
|
|
},
|
|
|
|
|
|
|
|
_windowEnteredMonitor: function(metaScreen, monitorIndex, metaWin) {
|
|
|
|
// If the window entered the primary monitor, that
|
|
|
|
// might make that workspace non-empty
|
|
|
|
if (monitorIndex == Main.layoutManager.primaryIndex)
|
|
|
|
this._queueCheckWorkspaces();
|
|
|
|
},
|
|
|
|
|
|
|
|
_windowsRestacked: function() {
|
|
|
|
// Figure out where the pointer is in case we lost track of
|
|
|
|
// it during a grab. (In particular, if a trayicon popup menu
|
|
|
|
// is dismissed, see if we need to close the message tray.)
|
|
|
|
global.sync_pointer();
|
|
|
|
},
|
|
|
|
|
|
|
|
_queueCheckWorkspaces: function() {
|
|
|
|
if (this._checkWorkspacesId == 0)
|
|
|
|
this._checkWorkspacesId = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, this._checkWorkspaces));
|
|
|
|
},
|
|
|
|
|
|
|
|
_nWorkspacesChanged: function() {
|
|
|
|
let oldNumWorkspaces = this._workspaces.length;
|
|
|
|
let newNumWorkspaces = global.screen.n_workspaces;
|
|
|
|
|
|
|
|
if (oldNumWorkspaces == newNumWorkspaces)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
let lostWorkspaces = [];
|
|
|
|
if (newNumWorkspaces > oldNumWorkspaces) {
|
|
|
|
let w;
|
|
|
|
|
|
|
|
// Assume workspaces are only added at the end
|
|
|
|
for (w = oldNumWorkspaces; w < newNumWorkspaces; w++)
|
|
|
|
this._workspaces[w] = global.screen.get_workspace_by_index(w);
|
|
|
|
|
|
|
|
for (w = oldNumWorkspaces; w < newNumWorkspaces; w++) {
|
|
|
|
let workspace = this._workspaces[w];
|
|
|
|
workspace._windowAddedId = workspace.connect('window-added', Lang.bind(this, this._queueCheckWorkspaces));
|
|
|
|
workspace._windowRemovedId = workspace.connect('window-removed', Lang.bind(this, this._windowRemoved));
|
|
|
|
}
|
|
|
|
|
|
|
|
} 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 workspace = global.screen.get_workspace_by_index(w);
|
|
|
|
if (this._workspaces[w] != workspace) {
|
|
|
|
removedIndex = w;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let lostWorkspaces = this._workspaces.splice(removedIndex, removedNum);
|
|
|
|
lostWorkspaces.forEach(function(workspace) {
|
|
|
|
workspace.disconnect(workspace._windowAddedId);
|
|
|
|
workspace.disconnect(workspace._windowRemovedId);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
this._queueCheckWorkspaces();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-09-01 22:26:12 +00:00
|
|
|
const TilePreview = new Lang.Class({
|
|
|
|
Name: 'TilePreview',
|
|
|
|
|
|
|
|
_init: function() {
|
2013-09-02 00:17:58 +00:00
|
|
|
this.actor = new St.Widget();
|
2013-09-01 22:26:12 +00:00
|
|
|
global.window_group.add_actor(this.actor);
|
|
|
|
|
2013-09-02 00:17:58 +00:00
|
|
|
this._reset();
|
2013-09-01 22:26:12 +00:00
|
|
|
this._showing = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
show: function(window, tileRect, monitorIndex) {
|
|
|
|
let windowActor = window.get_compositor_private();
|
|
|
|
if (!windowActor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
global.window_group.set_child_below_sibling(this.actor, windowActor);
|
|
|
|
|
2013-09-02 00:17:58 +00:00
|
|
|
if (this._rect && this._rect.equal(tileRect))
|
|
|
|
return;
|
|
|
|
|
|
|
|
let changeMonitor = (this._monitorIndex == -1 ||
|
|
|
|
this._monitorIndex != monitorIndex);
|
|
|
|
|
|
|
|
this._monitorIndex = monitorIndex;
|
|
|
|
this._rect = tileRect;
|
2013-09-01 22:26:12 +00:00
|
|
|
|
2013-09-02 00:17:58 +00:00
|
|
|
let monitor = Main.layoutManager.monitors[monitorIndex];
|
|
|
|
|
|
|
|
this._updateStyle(monitor);
|
|
|
|
|
|
|
|
if (!this._showing || changeMonitor) {
|
|
|
|
let monitorRect = new Meta.Rectangle({ x: monitor.x,
|
|
|
|
y: monitor.y,
|
|
|
|
width: monitor.width,
|
|
|
|
height: monitor.height });
|
2014-09-18 21:02:45 +00:00
|
|
|
let [, rect] = window.get_frame_rect().intersect(monitorRect);
|
2013-09-02 00:17:58 +00:00
|
|
|
this.actor.set_size(rect.width, rect.height);
|
|
|
|
this.actor.set_position(rect.x, rect.y);
|
|
|
|
this.actor.opacity = 0;
|
|
|
|
}
|
2013-09-01 22:26:12 +00:00
|
|
|
|
|
|
|
this._showing = true;
|
|
|
|
this.actor.show();
|
2013-09-02 00:17:58 +00:00
|
|
|
Tweener.addTween(this.actor,
|
|
|
|
{ x: tileRect.x,
|
|
|
|
y: tileRect.y,
|
|
|
|
width: tileRect.width,
|
|
|
|
height: tileRect.height,
|
|
|
|
opacity: 255,
|
|
|
|
time: WINDOW_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
2013-09-01 22:26:12 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
hide: function() {
|
|
|
|
if (!this._showing)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._showing = false;
|
2013-09-02 00:17:58 +00:00
|
|
|
Tweener.addTween(this.actor,
|
|
|
|
{ opacity: 0,
|
|
|
|
time: WINDOW_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
onComplete: Lang.bind(this, this._reset)
|
|
|
|
});
|
2013-09-01 22:26:12 +00:00
|
|
|
},
|
|
|
|
|
2013-09-02 00:17:58 +00:00
|
|
|
_reset: function() {
|
|
|
|
this.actor.hide();
|
|
|
|
this._rect = null;
|
|
|
|
this._monitorIndex = -1;
|
|
|
|
},
|
2013-09-01 22:26:12 +00:00
|
|
|
|
2013-09-02 00:17:58 +00:00
|
|
|
_updateStyle: function(monitor) {
|
2013-09-01 22:26:12 +00:00
|
|
|
let styles = ['tile-preview'];
|
2013-09-02 00:17:58 +00:00
|
|
|
if (this._monitorIndex == Main.layoutManager.primaryIndex)
|
2013-09-01 22:26:12 +00:00
|
|
|
styles.push('on-primary');
|
2013-09-02 00:17:58 +00:00
|
|
|
if (this._rect.x == monitor.x)
|
2013-09-01 22:26:12 +00:00
|
|
|
styles.push('tile-preview-left');
|
2013-09-02 00:17:58 +00:00
|
|
|
if (this._rect.x + this._rect.width == monitor.x + monitor.width)
|
2013-09-01 22:26:12 +00:00
|
|
|
styles.push('tile-preview-right');
|
|
|
|
|
|
|
|
this.actor.style_class = styles.join(' ');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-07-22 19:19:18 +00:00
|
|
|
const TouchpadWorkspaceSwitchAction = new Lang.Class({
|
|
|
|
Name: 'TouchpadWorkspaceSwitchAction',
|
|
|
|
|
|
|
|
_init: function(actor) {
|
|
|
|
this._dx = 0;
|
|
|
|
this._dy = 0;
|
|
|
|
actor.connect('captured-event', Lang.bind(this, this._handleEvent));
|
|
|
|
},
|
|
|
|
|
|
|
|
_checkActivated: function() {
|
|
|
|
const MOTION_THRESHOLD = 50;
|
|
|
|
let allowedModes = Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW;
|
|
|
|
let dir;
|
|
|
|
|
|
|
|
if ((allowedModes & Main.actionMode) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (this._dy < -MOTION_THRESHOLD)
|
|
|
|
dir = Meta.MotionDirection.DOWN;
|
|
|
|
else if (this._dy > MOTION_THRESHOLD)
|
|
|
|
dir = Meta.MotionDirection.UP;
|
|
|
|
else if (this._dx < -MOTION_THRESHOLD)
|
|
|
|
dir = Meta.MotionDirection.RIGHT;
|
|
|
|
else if (this._dx > MOTION_THRESHOLD)
|
|
|
|
dir = Meta.MotionDirection.LEFT;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.emit('activated', dir);
|
|
|
|
},
|
|
|
|
|
|
|
|
_handleEvent: function(actor, event) {
|
|
|
|
if (event.type() != Clutter.EventType.TOUCHPAD_SWIPE)
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
|
|
|
if (event.get_gesture_swipe_finger_count() != 4)
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
|
|
|
if (event.get_gesture_phase() == Clutter.TouchpadGesturePhase.UPDATE) {
|
|
|
|
let [dx, dy] = event.get_gesture_motion_delta(event);
|
|
|
|
|
|
|
|
this._dx += dx;
|
|
|
|
this._dy += dy;
|
|
|
|
} else {
|
|
|
|
if (event.get_gesture_phase() == Clutter.TouchpadGesturePhase.END)
|
|
|
|
this._checkActivated();
|
|
|
|
|
|
|
|
this._dx = 0;
|
|
|
|
this._dy = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Clutter.EVENT_STOP;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Signals.addSignalMethods(TouchpadWorkspaceSwitchAction.prototype);
|
|
|
|
|
2014-06-25 16:13:26 +00:00
|
|
|
const WorkspaceSwitchAction = new Lang.Class({
|
|
|
|
Name: 'WorkspaceSwitchAction',
|
2015-05-22 17:05:10 +00:00
|
|
|
Extends: Clutter.SwipeAction,
|
2014-06-25 16:13:26 +00:00
|
|
|
|
|
|
|
_init : function() {
|
2015-05-22 17:05:10 +00:00
|
|
|
const MOTION_THRESHOLD = 50;
|
|
|
|
|
2014-06-25 16:13:26 +00:00
|
|
|
this.parent();
|
|
|
|
this.set_n_touch_points(4);
|
2015-05-22 17:05:10 +00:00
|
|
|
this.set_threshold_trigger_distance(MOTION_THRESHOLD, MOTION_THRESHOLD);
|
2014-06-25 16:13:26 +00:00
|
|
|
|
|
|
|
global.display.connect('grab-op-begin', Lang.bind(this, function() {
|
|
|
|
this.cancel();
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
2015-05-22 17:05:10 +00:00
|
|
|
vfunc_gesture_prepare : function(actor) {
|
2014-12-11 14:35:40 +00:00
|
|
|
let allowedModes = Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW;
|
2014-06-25 16:13:26 +00:00
|
|
|
|
2015-05-22 17:05:10 +00:00
|
|
|
if (!this.parent(actor))
|
|
|
|
return false;
|
2014-06-25 16:13:26 +00:00
|
|
|
|
2015-05-22 17:05:10 +00:00
|
|
|
return (allowedModes & Main.actionMode);
|
|
|
|
},
|
2014-06-25 16:13:26 +00:00
|
|
|
|
2015-05-22 17:05:10 +00:00
|
|
|
vfunc_swept : function(actor, direction) {
|
|
|
|
let dir;
|
2014-06-25 16:13:26 +00:00
|
|
|
|
2015-05-22 17:05:10 +00:00
|
|
|
if (direction & Clutter.SwipeDirection.UP)
|
|
|
|
dir = Meta.MotionDirection.DOWN;
|
|
|
|
else if (direction & Clutter.SwipeDirection.DOWN)
|
|
|
|
dir = Meta.MotionDirection.UP;
|
|
|
|
else if (direction & Clutter.SwipeDirection.LEFT)
|
|
|
|
dir = Meta.MotionDirection.RIGHT;
|
|
|
|
else if (direction & Clutter.SwipeDirection.RIGHT)
|
|
|
|
dir = Meta.MotionDirection.LEFT;
|
2014-06-25 16:13:26 +00:00
|
|
|
|
2015-05-22 17:05:10 +00:00
|
|
|
this.emit('activated', dir);
|
2014-06-25 16:13:26 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
Signals.addSignalMethods(WorkspaceSwitchAction.prototype);
|
|
|
|
|
2014-06-27 20:45:58 +00:00
|
|
|
const AppSwitchAction = new Lang.Class({
|
|
|
|
Name: 'AppSwitchAction',
|
|
|
|
Extends: Clutter.GestureAction,
|
|
|
|
|
|
|
|
_init : function() {
|
|
|
|
this.parent();
|
|
|
|
this.set_n_touch_points(3);
|
|
|
|
|
|
|
|
global.display.connect('grab-op-begin', Lang.bind(this, function() {
|
|
|
|
this.cancel();
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
vfunc_gesture_prepare : function(action, actor) {
|
2014-12-11 14:35:40 +00:00
|
|
|
if (Main.actionMode != Shell.ActionMode.NORMAL) {
|
2014-09-05 20:44:19 +00:00
|
|
|
this.cancel();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-06-27 20:45:58 +00:00
|
|
|
return this.get_n_current_points() <= 4;
|
|
|
|
},
|
|
|
|
|
|
|
|
vfunc_gesture_begin : function(action, actor) {
|
|
|
|
// in milliseconds
|
|
|
|
const LONG_PRESS_TIMEOUT = 250;
|
|
|
|
|
|
|
|
let nPoints = this.get_n_current_points();
|
|
|
|
let event = this.get_last_event (nPoints - 1);
|
|
|
|
|
|
|
|
if (nPoints == 3)
|
|
|
|
this._longPressStartTime = event.get_time();
|
|
|
|
else if (nPoints == 4) {
|
|
|
|
// Check whether the 4th finger press happens after a 3-finger long press,
|
|
|
|
// this only needs to be checked on the first 4th finger press
|
|
|
|
if (this._longPressStartTime != null &&
|
|
|
|
event.get_time() < this._longPressStartTime + LONG_PRESS_TIMEOUT)
|
|
|
|
this.cancel();
|
|
|
|
else {
|
|
|
|
this._longPressStartTime = null;
|
|
|
|
this.emit('activated');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.get_n_current_points() <= 4;
|
|
|
|
},
|
|
|
|
|
|
|
|
vfunc_gesture_progress : function(action, actor) {
|
|
|
|
const MOTION_THRESHOLD = 30;
|
|
|
|
|
|
|
|
if (this.get_n_current_points() == 3) {
|
|
|
|
for (let i = 0; i < this.get_n_current_points(); i++) {
|
|
|
|
[startX, startY] = this.get_press_coords(i);
|
|
|
|
[x, y] = this.get_motion_coords(i);
|
|
|
|
|
|
|
|
if (Math.abs(x - startX) > MOTION_THRESHOLD ||
|
|
|
|
Math.abs(y - startY) > MOTION_THRESHOLD)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Signals.addSignalMethods(AppSwitchAction.prototype);
|
|
|
|
|
2014-12-30 01:30:38 +00:00
|
|
|
const ResizePopup = new Lang.Class({
|
|
|
|
Name: 'ResizePopup',
|
|
|
|
|
|
|
|
_init: function() {
|
|
|
|
this._widget = new St.Widget({ layout_manager: new Clutter.BinLayout() });
|
|
|
|
this._label = new St.Label({ style_class: 'resize-popup',
|
|
|
|
x_align: Clutter.ActorAlign.CENTER,
|
|
|
|
y_align: Clutter.ActorAlign.CENTER,
|
|
|
|
x_expand: true, y_expand: true });
|
|
|
|
this._widget.add_child(this._label);
|
|
|
|
Main.uiGroup.add_actor(this._widget);
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function(rect, displayW, displayH) {
|
|
|
|
/* Translators: This represents the size of a window. The first number is
|
|
|
|
* the width of the window and the second is the height. */
|
|
|
|
let text = _("%d x %d").format(displayW, displayH);
|
|
|
|
this._label.set_text(text);
|
|
|
|
|
|
|
|
this._widget.set_position(rect.x, rect.y);
|
|
|
|
this._widget.set_size(rect.width, rect.height);
|
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
|
|
|
this._widget.destroy();
|
|
|
|
this._widget = null;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2011-11-20 17:56:27 +00:00
|
|
|
const WindowManager = new Lang.Class({
|
|
|
|
Name: 'WindowManager',
|
2008-11-21 14:02:09 +00:00
|
|
|
|
2008-12-01 19:51:43 +00:00
|
|
|
_init : function() {
|
2010-03-16 02:06:58 +00:00
|
|
|
this._shellwm = global.window_manager;
|
2008-11-21 21:34:10 +00:00
|
|
|
|
2008-12-29 04:44:03 +00:00
|
|
|
this._minimizing = [];
|
2015-02-27 11:13:26 +00:00
|
|
|
this._unminimizing = [];
|
2008-12-29 04:44:03 +00:00
|
|
|
this._mapping = [];
|
|
|
|
this._destroying = [];
|
2012-06-26 18:11:44 +00:00
|
|
|
this._movingWindow = null;
|
2008-11-21 21:34:10 +00:00
|
|
|
|
2010-09-12 09:39:52 +00:00
|
|
|
this._dimmedWindows = [];
|
|
|
|
|
2012-08-11 00:53:38 +00:00
|
|
|
this._allowedKeybindings = {};
|
|
|
|
|
2015-03-27 13:34:28 +00:00
|
|
|
this._isWorkspacePrepended = false;
|
|
|
|
|
2008-12-01 19:51:43 +00:00
|
|
|
this._switchData = null;
|
2010-03-16 02:06:58 +00:00
|
|
|
this._shellwm.connect('kill-switch-workspace', Lang.bind(this, this._switchWorkspaceDone));
|
2010-06-16 21:28:57 +00:00
|
|
|
this._shellwm.connect('kill-window-effects', Lang.bind(this, function (shellwm, actor) {
|
|
|
|
this._minimizeWindowDone(shellwm, actor);
|
|
|
|
this._mapWindowDone(shellwm, actor);
|
|
|
|
this._destroyWindowDone(shellwm, actor);
|
|
|
|
}));
|
|
|
|
|
|
|
|
this._shellwm.connect('switch-workspace', Lang.bind(this, this._switchWorkspace));
|
2013-09-01 22:26:12 +00:00
|
|
|
this._shellwm.connect('show-tile-preview', Lang.bind(this, this._showTilePreview));
|
|
|
|
this._shellwm.connect('hide-tile-preview', Lang.bind(this, this._hideTilePreview));
|
2014-03-13 22:51:10 +00:00
|
|
|
this._shellwm.connect('show-window-menu', Lang.bind(this, this._showWindowMenu));
|
2010-03-16 02:06:58 +00:00
|
|
|
this._shellwm.connect('minimize', Lang.bind(this, this._minimizeWindow));
|
2015-02-27 11:13:26 +00:00
|
|
|
this._shellwm.connect('unminimize', Lang.bind(this, this._unminimizeWindow));
|
2015-07-06 06:10:51 +00:00
|
|
|
this._shellwm.connect('size-change', Lang.bind(this, this._sizeChangeWindow));
|
2010-03-16 02:06:58 +00:00
|
|
|
this._shellwm.connect('map', Lang.bind(this, this._mapWindow));
|
|
|
|
this._shellwm.connect('destroy', Lang.bind(this, this._destroyWindow));
|
2012-08-20 08:38:13 +00:00
|
|
|
this._shellwm.connect('filter-keybinding', Lang.bind(this, this._filterKeybinding));
|
2013-08-17 15:42:39 +00:00
|
|
|
this._shellwm.connect('confirm-display-change', Lang.bind(this, this._confirmDisplayChange));
|
2014-12-17 21:57:44 +00:00
|
|
|
global.screen.connect('restacked', Lang.bind(this, this._syncStacking));
|
2010-02-12 22:52:15 +00:00
|
|
|
|
|
|
|
this._workspaceSwitcherPopup = null;
|
2013-09-01 22:26:12 +00:00
|
|
|
this._tilePreview = null;
|
|
|
|
|
2015-02-19 19:39:26 +00:00
|
|
|
this.allowKeybinding('switch-to-session-1', Shell.ActionMode.ALL);
|
|
|
|
this.allowKeybinding('switch-to-session-2', Shell.ActionMode.ALL);
|
|
|
|
this.allowKeybinding('switch-to-session-3', Shell.ActionMode.ALL);
|
|
|
|
this.allowKeybinding('switch-to-session-4', Shell.ActionMode.ALL);
|
|
|
|
this.allowKeybinding('switch-to-session-5', Shell.ActionMode.ALL);
|
|
|
|
this.allowKeybinding('switch-to-session-6', Shell.ActionMode.ALL);
|
|
|
|
this.allowKeybinding('switch-to-session-7', Shell.ActionMode.ALL);
|
2015-02-19 19:39:26 +00:00
|
|
|
this.allowKeybinding('switch-to-session-8', Shell.ActionMode.ALL);
|
|
|
|
this.allowKeybinding('switch-to-session-9', Shell.ActionMode.ALL);
|
|
|
|
this.allowKeybinding('switch-to-session-10', Shell.ActionMode.ALL);
|
|
|
|
this.allowKeybinding('switch-to-session-11', Shell.ActionMode.ALL);
|
|
|
|
this.allowKeybinding('switch-to-session-12', Shell.ActionMode.ALL);
|
2015-02-19 19:39:26 +00:00
|
|
|
|
2012-08-11 04:34:53 +00:00
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-left',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2012-08-11 04:34:53 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-right',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2012-08-11 04:34:53 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-up',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2012-08-11 04:34:53 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-down',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2012-08-11 04:34:53 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
2013-05-18 17:55:05 +00:00
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-last',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2013-05-18 17:55:05 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
2012-08-11 04:34:53 +00:00
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-left',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2012-08-11 04:34:53 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-right',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2012-08-11 04:34:53 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-up',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2012-08-11 04:34:53 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-down',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2012-08-11 04:34:53 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
2013-05-17 14:54:23 +00:00
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-1',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-2',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-3',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-4',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-5',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-6',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-7',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-8',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-9',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-10',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-11',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-to-workspace-12',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-1',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-2',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-3',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-4',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-5',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-6',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-7',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-8',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-9',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-10',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-11',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-12',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2013-05-17 14:54:23 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
2013-05-18 17:55:05 +00:00
|
|
|
this.setCustomKeybindingHandler('move-to-workspace-last',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2013-05-18 17:55:05 +00:00
|
|
|
Lang.bind(this, this._showWorkspaceSwitcher));
|
2012-11-23 00:18:06 +00:00
|
|
|
this.setCustomKeybindingHandler('switch-applications',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2012-08-11 04:34:53 +00:00
|
|
|
Lang.bind(this, this._startAppSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-group',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2012-08-11 04:34:53 +00:00
|
|
|
Lang.bind(this, this._startAppSwitcher));
|
2012-11-23 00:18:06 +00:00
|
|
|
this.setCustomKeybindingHandler('switch-applications-backward',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2012-08-11 04:34:53 +00:00
|
|
|
Lang.bind(this, this._startAppSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-group-backward',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2012-08-11 04:34:53 +00:00
|
|
|
Lang.bind(this, this._startAppSwitcher));
|
2012-11-23 02:20:10 +00:00
|
|
|
this.setCustomKeybindingHandler('switch-windows',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2012-11-23 02:20:10 +00:00
|
|
|
Lang.bind(this, this._startWindowSwitcher));
|
|
|
|
this.setCustomKeybindingHandler('switch-windows-backward',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL,
|
2012-11-23 02:20:10 +00:00
|
|
|
Lang.bind(this, this._startWindowSwitcher));
|
2012-08-11 04:34:53 +00:00
|
|
|
this.setCustomKeybindingHandler('switch-panels',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW |
|
|
|
|
Shell.ActionMode.LOCK_SCREEN |
|
|
|
|
Shell.ActionMode.UNLOCK_SCREEN |
|
|
|
|
Shell.ActionMode.LOGIN_SCREEN,
|
2012-08-11 04:34:53 +00:00
|
|
|
Lang.bind(this, this._startA11ySwitcher));
|
2012-12-03 10:07:28 +00:00
|
|
|
this.setCustomKeybindingHandler('switch-panels-backward',
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
|
|
|
Shell.ActionMode.OVERVIEW |
|
|
|
|
Shell.ActionMode.LOCK_SCREEN |
|
|
|
|
Shell.ActionMode.UNLOCK_SCREEN |
|
|
|
|
Shell.ActionMode.LOGIN_SCREEN,
|
2012-12-03 10:07:28 +00:00
|
|
|
Lang.bind(this, this._startA11ySwitcher));
|
2012-08-11 04:34:53 +00:00
|
|
|
|
2014-01-14 22:58:51 +00:00
|
|
|
this.addKeybinding('pause-resume-tweens',
|
2014-06-24 19:17:09 +00:00
|
|
|
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
|
2014-01-14 13:49:32 +00:00
|
|
|
Meta.KeyBindingFlags.NONE,
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.ALL,
|
2014-01-14 13:49:32 +00:00
|
|
|
Lang.bind(this, this._toggleTweens));
|
|
|
|
|
2012-08-11 04:34:53 +00:00
|
|
|
this.addKeybinding('open-application-menu',
|
2014-06-24 19:17:09 +00:00
|
|
|
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
|
2012-08-11 04:34:53 +00:00
|
|
|
Meta.KeyBindingFlags.NONE,
|
2014-12-11 14:35:40 +00:00
|
|
|
Shell.ActionMode.NORMAL |
|
2015-02-26 00:00:41 +00:00
|
|
|
Shell.ActionMode.POPUP,
|
2013-04-26 14:14:55 +00:00
|
|
|
Lang.bind(this, this._toggleAppMenu));
|
2010-09-12 09:39:52 +00:00
|
|
|
|
2015-02-18 01:52:07 +00:00
|
|
|
this.addKeybinding('toggle-message-tray',
|
|
|
|
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
|
|
|
|
Meta.KeyBindingFlags.NONE,
|
|
|
|
Shell.ActionMode.NORMAL |
|
2015-03-06 17:02:57 +00:00
|
|
|
Shell.ActionMode.OVERVIEW |
|
2015-02-26 00:00:41 +00:00
|
|
|
Shell.ActionMode.POPUP,
|
2015-02-18 01:52:07 +00:00
|
|
|
Lang.bind(this, this._toggleCalendar));
|
|
|
|
|
2014-12-30 01:30:38 +00:00
|
|
|
global.display.connect('show-resize-popup', Lang.bind(this, this._showResizePopup));
|
|
|
|
|
2014-01-19 15:12:15 +00:00
|
|
|
Main.overview.connect('showing', Lang.bind(this, function() {
|
|
|
|
for (let i = 0; i < this._dimmedWindows.length; i++)
|
|
|
|
this._undimWindow(this._dimmedWindows[i]);
|
|
|
|
}));
|
|
|
|
Main.overview.connect('hiding', Lang.bind(this, function() {
|
|
|
|
for (let i = 0; i < this._dimmedWindows.length; i++)
|
|
|
|
this._dimWindow(this._dimmedWindows[i]);
|
|
|
|
}));
|
|
|
|
|
2014-03-13 22:51:10 +00:00
|
|
|
this._windowMenuManager = new WindowMenu.WindowMenuManager();
|
|
|
|
|
2013-06-16 04:21:21 +00:00
|
|
|
if (Main.sessionMode.hasWorkspaces)
|
|
|
|
this._workspaceTracker = new WorkspaceTracker(this);
|
2012-12-23 03:10:48 +00:00
|
|
|
|
|
|
|
global.screen.override_workspace_layout(Meta.ScreenCorner.TOPLEFT,
|
|
|
|
false, -1, 1);
|
2014-06-25 16:13:26 +00:00
|
|
|
|
|
|
|
let gesture = new WorkspaceSwitchAction();
|
2015-07-01 13:51:15 +00:00
|
|
|
gesture.connect('activated', Lang.bind(this, this._actionSwitchWorkspace));
|
2014-06-25 16:13:26 +00:00
|
|
|
global.stage.add_action(gesture);
|
2014-06-27 20:45:58 +00:00
|
|
|
|
2015-07-22 19:19:18 +00:00
|
|
|
// This is not a normal Clutter.GestureAction, doesn't need add_action()
|
|
|
|
gesture = new TouchpadWorkspaceSwitchAction(global.stage);
|
|
|
|
gesture.connect('activated', Lang.bind(this, this._actionSwitchWorkspace));
|
|
|
|
|
2014-06-27 20:45:58 +00:00
|
|
|
gesture = new AppSwitchAction();
|
|
|
|
gesture.connect('activated', Lang.bind(this, this._switchApp));
|
|
|
|
global.stage.add_action(gesture);
|
2015-07-01 13:51:15 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
_actionSwitchWorkspace: function(action, direction) {
|
|
|
|
let newWs = global.screen.get_active_workspace().get_neighbor(direction);
|
|
|
|
this.actionMoveWorkspace(newWs);
|
2014-06-27 20:45:58 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_lookupIndex: function (windows, metaWindow) {
|
|
|
|
for (let i = 0; i < windows.length; i++) {
|
|
|
|
if (windows[i].metaWindow == metaWindow) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
},
|
|
|
|
|
|
|
|
_switchApp : function () {
|
|
|
|
let windows = global.get_window_actors().filter(Lang.bind(this, function(actor) {
|
|
|
|
let win = actor.metaWindow;
|
|
|
|
return (!win.is_override_redirect() &&
|
|
|
|
win.located_on_workspace(global.screen.get_active_workspace()));
|
|
|
|
}));
|
|
|
|
|
|
|
|
if (windows.length == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let focusWindow = global.display.focus_window;
|
|
|
|
let nextWindow;
|
|
|
|
|
|
|
|
if (focusWindow == null)
|
|
|
|
nextWindow = windows[0].metaWindow;
|
|
|
|
else {
|
|
|
|
let index = this._lookupIndex (windows, focusWindow) + 1;
|
|
|
|
|
|
|
|
if (index >= windows.length)
|
|
|
|
index = 0;
|
|
|
|
|
|
|
|
nextWindow = windows[index].metaWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
Main.activateWindow(nextWindow);
|
2010-03-16 02:06:58 +00:00
|
|
|
},
|
|
|
|
|
2015-01-15 22:03:24 +00:00
|
|
|
insertWorkspace: function(pos) {
|
|
|
|
if (!Meta.prefs_get_dynamic_workspaces())
|
|
|
|
return;
|
|
|
|
|
2015-03-27 13:34:28 +00:00
|
|
|
global.screen.append_new_workspace(false, global.get_current_time());
|
|
|
|
|
2015-01-15 22:03:24 +00:00
|
|
|
let windows = global.get_window_actors().map(function(winActor) {
|
|
|
|
return winActor.meta_window;
|
|
|
|
});
|
|
|
|
|
|
|
|
// To create a new workspace, we slide all the windows on workspaces
|
|
|
|
// below us to the next workspace, leaving a blank workspace for us
|
|
|
|
// to recycle.
|
|
|
|
windows.forEach(function(window) {
|
|
|
|
// If the window is attached to an ancestor, we don't need/want
|
|
|
|
// to move it
|
|
|
|
if (window.get_transient_for() != null)
|
|
|
|
return;
|
2015-01-16 00:19:37 +00:00
|
|
|
// Same for OR windows
|
|
|
|
if (window.is_override_redirect())
|
|
|
|
return;
|
2015-01-15 22:03:24 +00:00
|
|
|
// Windows on workspaces below pos don't need moving
|
|
|
|
let index = window.get_workspace().index();
|
|
|
|
if (index < pos)
|
|
|
|
return;
|
|
|
|
window.change_workspace_by_index(index + 1, true);
|
|
|
|
});
|
2015-01-15 23:32:27 +00:00
|
|
|
|
|
|
|
// If the new workspace was inserted before the active workspace,
|
|
|
|
// activate the workspace to which its windows went
|
|
|
|
let activeIndex = global.screen.get_active_workspace_index();
|
|
|
|
if (activeIndex >= pos) {
|
|
|
|
let newWs = global.screen.get_workspace_by_index(activeIndex + 1);
|
|
|
|
this._blockAnimations = true;
|
|
|
|
newWs.activate(global.get_current_time());
|
|
|
|
this._blockAnimations = false;
|
|
|
|
}
|
2015-01-15 22:03:24 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
2013-06-16 04:12:22 +00:00
|
|
|
keepWorkspaceAlive: function(workspace, duration) {
|
2013-06-16 04:21:21 +00:00
|
|
|
if (!this._workspaceTracker)
|
|
|
|
return;
|
|
|
|
|
2013-06-16 04:12:22 +00:00
|
|
|
this._workspaceTracker.keepWorkspaceAlive(workspace, duration);
|
|
|
|
},
|
|
|
|
|
2012-08-11 00:53:38 +00:00
|
|
|
setCustomKeybindingHandler: function(name, modes, handler) {
|
|
|
|
if (Meta.keybindings_set_custom_handler(name, handler))
|
|
|
|
this.allowKeybinding(name, modes);
|
|
|
|
},
|
|
|
|
|
|
|
|
addKeybinding: function(name, settings, flags, modes, handler) {
|
2012-12-12 08:40:49 +00:00
|
|
|
let action = global.display.add_keybinding(name, settings, flags, handler);
|
|
|
|
if (action != Meta.KeyBindingAction.NONE)
|
2012-08-11 00:53:38 +00:00
|
|
|
this.allowKeybinding(name, modes);
|
2012-12-12 08:40:49 +00:00
|
|
|
return action;
|
2012-08-11 00:53:38 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
removeKeybinding: function(name) {
|
|
|
|
if (global.display.remove_keybinding(name))
|
2014-12-11 14:35:40 +00:00
|
|
|
this.allowKeybinding(name, Shell.ActionMode.NONE);
|
2012-08-11 00:53:38 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
allowKeybinding: function(name, modes) {
|
|
|
|
this._allowedKeybindings[name] = modes;
|
|
|
|
},
|
|
|
|
|
2012-07-14 00:43:07 +00:00
|
|
|
_shouldAnimate: function() {
|
2015-01-15 23:32:27 +00:00
|
|
|
return !(Main.overview.visible || this._blockAnimations);
|
2012-07-14 00:43:07 +00:00
|
|
|
},
|
|
|
|
|
2014-07-07 15:18:07 +00:00
|
|
|
_shouldAnimateActor: function(actor, types) {
|
2012-07-14 00:43:07 +00:00
|
|
|
if (!this._shouldAnimate())
|
2009-02-03 18:25:34 +00:00
|
|
|
return false;
|
2014-07-07 15:18:07 +00:00
|
|
|
|
|
|
|
let type = actor.meta_window.get_window_type();
|
|
|
|
return types.indexOf(type) >= 0;
|
2009-02-03 18:25:34 +00:00
|
|
|
},
|
2008-12-29 04:44:03 +00:00
|
|
|
|
2009-02-06 00:57:54 +00:00
|
|
|
_removeEffect : function(list, actor) {
|
|
|
|
let idx = list.indexOf(actor);
|
|
|
|
if (idx != -1) {
|
|
|
|
list.splice(idx, 1);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_minimizeWindow : function(shellwm, actor) {
|
2014-07-07 15:18:07 +00:00
|
|
|
let types = [Meta.WindowType.NORMAL,
|
|
|
|
Meta.WindowType.MODAL_DIALOG,
|
|
|
|
Meta.WindowType.DIALOG];
|
|
|
|
if (!this._shouldAnimateActor(actor, types)) {
|
2009-09-15 17:09:51 +00:00
|
|
|
shellwm.completed_minimize(actor);
|
2008-12-29 04:44:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
actor.set_scale(1.0, 1.0);
|
|
|
|
|
|
|
|
this._minimizing.push(actor);
|
2010-02-05 12:50:11 +00:00
|
|
|
|
2013-02-18 18:26:13 +00:00
|
|
|
if (actor.meta_window.is_monitor_sized()) {
|
|
|
|
Tweener.addTween(actor,
|
|
|
|
{ opacity: 0,
|
2014-07-07 15:18:07 +00:00
|
|
|
time: MINIMIZE_WINDOW_ANIMATION_TIME,
|
2010-05-13 19:46:04 +00:00
|
|
|
transition: 'easeOutQuad',
|
2008-12-29 04:44:03 +00:00
|
|
|
onComplete: this._minimizeWindowDone,
|
|
|
|
onCompleteScope: this,
|
2009-09-15 17:09:51 +00:00
|
|
|
onCompleteParams: [shellwm, actor],
|
2009-02-06 00:57:54 +00:00
|
|
|
onOverwrite: this._minimizeWindowOverwritten,
|
|
|
|
onOverwriteScope: this,
|
2009-09-15 17:09:51 +00:00
|
|
|
onOverwriteParams: [shellwm, actor]
|
2008-12-29 04:44:03 +00:00
|
|
|
});
|
2013-02-18 18:26:13 +00:00
|
|
|
} else {
|
|
|
|
let xDest, yDest, xScale, yScale;
|
|
|
|
let [success, geom] = actor.meta_window.get_icon_geometry();
|
|
|
|
if (success) {
|
|
|
|
xDest = geom.x;
|
|
|
|
yDest = geom.y;
|
|
|
|
xScale = geom.width / actor.width;
|
|
|
|
yScale = geom.height / actor.height;
|
|
|
|
} else {
|
|
|
|
let monitor = Main.layoutManager.monitors[actor.meta_window.get_monitor()];
|
|
|
|
xDest = monitor.x;
|
|
|
|
yDest = monitor.y;
|
|
|
|
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL)
|
|
|
|
xDest += monitor.width;
|
|
|
|
xScale = 0;
|
|
|
|
yScale = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Tweener.addTween(actor,
|
|
|
|
{ scale_x: xScale,
|
|
|
|
scale_y: yScale,
|
|
|
|
x: xDest,
|
|
|
|
y: yDest,
|
2014-07-07 15:18:07 +00:00
|
|
|
time: MINIMIZE_WINDOW_ANIMATION_TIME,
|
|
|
|
transition: 'easeInExpo',
|
2013-02-18 18:26:13 +00:00
|
|
|
onComplete: this._minimizeWindowDone,
|
|
|
|
onCompleteScope: this,
|
|
|
|
onCompleteParams: [shellwm, actor],
|
|
|
|
onOverwrite: this._minimizeWindowOverwritten,
|
|
|
|
onOverwriteScope: this,
|
|
|
|
onOverwriteParams: [shellwm, actor]
|
|
|
|
});
|
|
|
|
}
|
2008-12-29 04:44:03 +00:00
|
|
|
},
|
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_minimizeWindowDone : function(shellwm, actor) {
|
2009-02-06 00:57:54 +00:00
|
|
|
if (this._removeEffect(this._minimizing, actor)) {
|
2008-12-29 04:44:03 +00:00
|
|
|
Tweener.removeTweens(actor);
|
|
|
|
actor.set_scale(1.0, 1.0);
|
2013-02-18 18:26:13 +00:00
|
|
|
actor.set_opacity(255);
|
2014-07-07 15:18:07 +00:00
|
|
|
actor.set_pivot_point(0, 0);
|
2009-02-06 00:57:54 +00:00
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
shellwm.completed_minimize(actor);
|
2009-02-06 00:57:54 +00:00
|
|
|
}
|
|
|
|
},
|
2008-12-29 04:44:03 +00:00
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_minimizeWindowOverwritten : function(shellwm, actor) {
|
2009-02-06 00:57:54 +00:00
|
|
|
if (this._removeEffect(this._minimizing, actor)) {
|
2009-09-15 17:09:51 +00:00
|
|
|
shellwm.completed_minimize(actor);
|
2008-12-29 04:44:03 +00:00
|
|
|
}
|
|
|
|
},
|
2009-02-06 00:57:54 +00:00
|
|
|
|
2015-02-27 11:13:26 +00:00
|
|
|
_unminimizeWindow : function(shellwm, actor) {
|
|
|
|
let types = [Meta.WindowType.NORMAL,
|
|
|
|
Meta.WindowType.MODAL_DIALOG,
|
|
|
|
Meta.WindowType.DIALOG];
|
|
|
|
if (!this._shouldAnimateActor(actor, types)) {
|
|
|
|
shellwm.completed_unminimize(actor);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._unminimizing.push(actor);
|
|
|
|
|
|
|
|
if (actor.meta_window.is_monitor_sized()) {
|
|
|
|
actor.opacity = 0;
|
|
|
|
actor.set_scale(1.0, 1.0);
|
|
|
|
Tweener.addTween(actor,
|
|
|
|
{ opacity: 255,
|
|
|
|
time: MINIMIZE_WINDOW_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
onComplete: this._unminimizeWindowDone,
|
|
|
|
onCompleteScope: this,
|
|
|
|
onCompleteParams: [shellwm, actor],
|
|
|
|
onOverwrite: this._unminimizeWindowOverwritten,
|
|
|
|
onOverwriteScope: this,
|
|
|
|
onOverwriteParams: [shellwm, actor]
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
let [success, geom] = actor.meta_window.get_icon_geometry();
|
|
|
|
if (success) {
|
|
|
|
actor.set_position(geom.x, geom.y);
|
|
|
|
actor.set_scale(geom.width / actor.width,
|
|
|
|
geom.height / actor.height);
|
|
|
|
} else {
|
|
|
|
let monitor = Main.layoutManager.monitors[actor.meta_window.get_monitor()];
|
|
|
|
actor.set_position(monitor.x, monitor.y);
|
|
|
|
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL)
|
|
|
|
actor.x += monitor.width;
|
|
|
|
actor.set_scale(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
let rect = actor.meta_window.get_frame_rect();
|
|
|
|
let [xDest, yDest] = [rect.x, rect.y];
|
|
|
|
|
|
|
|
actor.show();
|
|
|
|
Tweener.addTween(actor,
|
|
|
|
{ scale_x: 1.0,
|
|
|
|
scale_y: 1.0,
|
|
|
|
x: xDest,
|
|
|
|
y: yDest,
|
|
|
|
time: MINIMIZE_WINDOW_ANIMATION_TIME,
|
|
|
|
transition: 'easeInExpo',
|
|
|
|
onComplete: this._unminimizeWindowDone,
|
|
|
|
onCompleteScope: this,
|
|
|
|
onCompleteParams: [shellwm, actor],
|
|
|
|
onOverwrite: this._unminimizeWindowOverwritten,
|
|
|
|
onOverwriteScope: this,
|
|
|
|
onOverwriteParams: [shellwm, actor]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_unminimizeWindowDone : function(shellwm, actor) {
|
|
|
|
if (this._removeEffect(this._unminimizing, actor)) {
|
|
|
|
Tweener.removeTweens(actor);
|
|
|
|
actor.set_scale(1.0, 1.0);
|
|
|
|
actor.set_opacity(255);
|
|
|
|
actor.set_pivot_point(0, 0);
|
|
|
|
|
|
|
|
shellwm.completed_unminimize(actor);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_unminimizeWindowOverwritten : function(shellwm, actor) {
|
|
|
|
if (this._removeEffect(this._unminimizing, actor)) {
|
|
|
|
shellwm.completed_unminimize(actor);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-07-06 04:16:33 +00:00
|
|
|
_sizeChangeWindow : function(shellwm, actor, whichChange, oldFrameRect, oldBufferRect) {
|
|
|
|
shellwm.completed_size_change(actor);
|
2008-12-29 04:44:03 +00:00
|
|
|
},
|
|
|
|
|
2011-03-08 03:09:41 +00:00
|
|
|
_hasAttachedDialogs: function(window, ignoreWindow) {
|
2010-09-11 01:30:50 +00:00
|
|
|
var count = 0;
|
2011-03-08 03:09:41 +00:00
|
|
|
window.foreach_transient(function(win) {
|
2011-04-05 14:16:50 +00:00
|
|
|
if (win != ignoreWindow && win.is_attached_dialog())
|
2010-09-11 01:30:50 +00:00
|
|
|
count++;
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
return count != 0;
|
|
|
|
},
|
|
|
|
|
2011-03-08 03:09:41 +00:00
|
|
|
_checkDimming: function(window, ignoreWindow) {
|
2011-04-05 14:16:50 +00:00
|
|
|
let shouldDim = this._hasAttachedDialogs(window, ignoreWindow);
|
2011-03-08 03:09:41 +00:00
|
|
|
|
|
|
|
if (shouldDim && !window._dimmed) {
|
|
|
|
window._dimmed = true;
|
|
|
|
this._dimmedWindows.push(window);
|
2012-08-29 22:51:53 +00:00
|
|
|
this._dimWindow(window);
|
2011-03-08 03:09:41 +00:00
|
|
|
} else if (!shouldDim && window._dimmed) {
|
|
|
|
window._dimmed = false;
|
|
|
|
this._dimmedWindows = this._dimmedWindows.filter(function(win) {
|
|
|
|
return win != window;
|
|
|
|
});
|
2012-08-29 22:51:53 +00:00
|
|
|
this._undimWindow(window);
|
2010-09-30 21:09:15 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-07-13 23:37:10 +00:00
|
|
|
_dimWindow: function(window) {
|
2011-03-08 03:09:41 +00:00
|
|
|
let actor = window.get_compositor_private();
|
|
|
|
if (!actor)
|
2010-09-11 01:30:50 +00:00
|
|
|
return;
|
2012-07-13 17:57:36 +00:00
|
|
|
let dimmer = getWindowDimmer(actor);
|
2012-08-30 19:32:44 +00:00
|
|
|
if (!dimmer)
|
2012-07-13 17:57:36 +00:00
|
|
|
return;
|
|
|
|
Tweener.addTween(dimmer,
|
|
|
|
{ dimFactor: 1.0,
|
2012-07-13 23:37:10 +00:00
|
|
|
time: DIM_TIME,
|
|
|
|
transition: 'linear'
|
|
|
|
});
|
2010-09-11 01:30:50 +00:00
|
|
|
},
|
|
|
|
|
2012-07-13 23:37:10 +00:00
|
|
|
_undimWindow: function(window) {
|
2011-03-08 03:09:41 +00:00
|
|
|
let actor = window.get_compositor_private();
|
|
|
|
if (!actor)
|
2010-09-11 01:30:50 +00:00
|
|
|
return;
|
2012-07-13 17:57:36 +00:00
|
|
|
let dimmer = getWindowDimmer(actor);
|
2012-08-30 19:32:44 +00:00
|
|
|
if (!dimmer)
|
2012-07-13 17:57:36 +00:00
|
|
|
return;
|
|
|
|
Tweener.addTween(dimmer,
|
|
|
|
{ dimFactor: 0.0,
|
2012-07-13 23:37:10 +00:00
|
|
|
time: UNDIM_TIME,
|
2012-08-30 19:32:44 +00:00
|
|
|
transition: 'linear' });
|
2010-09-11 01:30:50 +00:00
|
|
|
},
|
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_mapWindow : function(shellwm, actor) {
|
2010-09-30 21:09:15 +00:00
|
|
|
actor._windowType = actor.meta_window.get_window_type();
|
|
|
|
actor._notifyWindowTypeSignalId = actor.meta_window.connect('notify::window-type', Lang.bind(this, function () {
|
|
|
|
let type = actor.meta_window.get_window_type();
|
|
|
|
if (type == actor._windowType)
|
|
|
|
return;
|
2011-03-08 03:09:41 +00:00
|
|
|
if (type == Meta.WindowType.MODAL_DIALOG ||
|
|
|
|
actor._windowType == Meta.WindowType.MODAL_DIALOG) {
|
|
|
|
let parent = actor.get_meta_window().get_transient_for();
|
|
|
|
if (parent)
|
|
|
|
this._checkDimming(parent);
|
|
|
|
}
|
2010-09-30 21:09:15 +00:00
|
|
|
|
|
|
|
actor._windowType = type;
|
|
|
|
}));
|
2012-12-15 02:23:36 +00:00
|
|
|
|
2014-07-07 15:18:07 +00:00
|
|
|
let types = [Meta.WindowType.NORMAL,
|
|
|
|
Meta.WindowType.DIALOG,
|
|
|
|
Meta.WindowType.MODAL_DIALOG];
|
|
|
|
if (!this._shouldAnimateActor(actor, types)) {
|
2009-09-15 17:09:51 +00:00
|
|
|
shellwm.completed_map(actor);
|
2008-12-29 04:44:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-19 22:40:07 +00:00
|
|
|
if (actor.meta_window.is_attached_dialog())
|
2012-12-15 02:23:36 +00:00
|
|
|
this._checkDimming(actor.get_meta_window().get_transient_for());
|
2014-07-07 15:18:07 +00:00
|
|
|
|
|
|
|
switch (actor._windowType) {
|
|
|
|
case Meta.WindowType.NORMAL:
|
|
|
|
actor.set_pivot_point(0.5, 1.0);
|
|
|
|
actor.scale_x = 0.01;
|
2014-07-28 16:12:30 +00:00
|
|
|
actor.scale_y = 0.05;
|
2014-07-07 15:18:07 +00:00
|
|
|
actor.opacity = 0;
|
2012-12-15 02:23:36 +00:00
|
|
|
actor.show();
|
|
|
|
this._mapping.push(actor);
|
2010-04-02 18:30:10 +00:00
|
|
|
|
2012-12-15 02:23:36 +00:00
|
|
|
Tweener.addTween(actor,
|
2014-07-07 15:18:07 +00:00
|
|
|
{ opacity: 255,
|
|
|
|
scale_x: 1,
|
|
|
|
scale_y: 1,
|
|
|
|
time: SHOW_WINDOW_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutExpo',
|
2012-12-15 02:23:36 +00:00
|
|
|
onComplete: this._mapWindowDone,
|
|
|
|
onCompleteScope: this,
|
|
|
|
onCompleteParams: [shellwm, actor],
|
|
|
|
onOverwrite: this._mapWindowOverwrite,
|
|
|
|
onOverwriteScope: this,
|
|
|
|
onOverwriteParams: [shellwm, actor]
|
|
|
|
});
|
2014-07-07 15:18:07 +00:00
|
|
|
break;
|
|
|
|
case Meta.WindowType.MODAL_DIALOG:
|
|
|
|
case Meta.WindowType.DIALOG:
|
|
|
|
actor.set_pivot_point(0.5, 0.5);
|
|
|
|
actor.scale_y = 0;
|
2012-12-15 02:23:36 +00:00
|
|
|
actor.opacity = 0;
|
|
|
|
actor.show();
|
|
|
|
this._mapping.push(actor);
|
|
|
|
|
|
|
|
Tweener.addTween(actor,
|
|
|
|
{ opacity: 255,
|
2014-07-07 15:18:07 +00:00
|
|
|
scale_x: 1,
|
|
|
|
scale_y: 1,
|
2014-07-28 16:12:30 +00:00
|
|
|
time: DIALOG_SHOW_WINDOW_ANIMATION_TIME,
|
2012-12-15 02:23:36 +00:00
|
|
|
transition: 'easeOutQuad',
|
|
|
|
onComplete: this._mapWindowDone,
|
|
|
|
onCompleteScope: this,
|
|
|
|
onCompleteParams: [shellwm, actor],
|
|
|
|
onOverwrite: this._mapWindowOverwrite,
|
|
|
|
onOverwriteScope: this,
|
|
|
|
onOverwriteParams: [shellwm, actor]
|
|
|
|
});
|
2014-07-07 15:18:07 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
shellwm.completed_map(actor);
|
|
|
|
return;
|
2012-12-15 02:23:36 +00:00
|
|
|
}
|
2008-12-29 04:44:03 +00:00
|
|
|
},
|
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_mapWindowDone : function(shellwm, actor) {
|
2009-02-06 00:57:54 +00:00
|
|
|
if (this._removeEffect(this._mapping, actor)) {
|
2008-12-29 04:44:03 +00:00
|
|
|
Tweener.removeTweens(actor);
|
2010-04-02 18:30:10 +00:00
|
|
|
actor.opacity = 255;
|
2014-07-07 15:18:07 +00:00
|
|
|
actor.set_pivot_point(0, 0);
|
2012-12-16 19:02:17 +00:00
|
|
|
actor.scale_y = 1;
|
2014-07-07 15:18:07 +00:00
|
|
|
actor.scale_x = 1;
|
|
|
|
actor.translation_y = 0;
|
|
|
|
actor.translation_x = 0;
|
2009-09-15 17:09:51 +00:00
|
|
|
shellwm.completed_map(actor);
|
2009-02-06 00:57:54 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_mapWindowOverwrite : function(shellwm, actor) {
|
2009-02-06 00:57:54 +00:00
|
|
|
if (this._removeEffect(this._mapping, actor)) {
|
2009-09-15 17:09:51 +00:00
|
|
|
shellwm.completed_map(actor);
|
2008-12-29 04:44:03 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-09-15 11:52:20 +00:00
|
|
|
_destroyWindow : function(shellwm, actor) {
|
2011-03-08 03:09:41 +00:00
|
|
|
let window = actor.meta_window;
|
2010-09-30 21:09:15 +00:00
|
|
|
if (actor._notifyWindowTypeSignalId) {
|
2011-03-08 03:09:41 +00:00
|
|
|
window.disconnect(actor._notifyWindowTypeSignalId);
|
2010-09-30 21:09:15 +00:00
|
|
|
actor._notifyWindowTypeSignalId = 0;
|
|
|
|
}
|
2011-03-08 03:09:41 +00:00
|
|
|
if (window._dimmed) {
|
|
|
|
this._dimmedWindows = this._dimmedWindows.filter(function(win) {
|
|
|
|
return win != window;
|
|
|
|
});
|
|
|
|
}
|
2012-12-15 02:23:36 +00:00
|
|
|
|
2014-07-08 09:51:49 +00:00
|
|
|
let types = [Meta.WindowType.NORMAL,
|
|
|
|
Meta.WindowType.DIALOG,
|
|
|
|
Meta.WindowType.MODAL_DIALOG];
|
|
|
|
if (!this._shouldAnimateActor(actor, types)) {
|
2012-12-15 02:23:36 +00:00
|
|
|
shellwm.completed_destroy(actor);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-08 09:51:49 +00:00
|
|
|
switch (actor._windowType) {
|
|
|
|
case Meta.WindowType.NORMAL:
|
2014-06-27 14:53:14 +00:00
|
|
|
actor.set_pivot_point(0.5, 0.5);
|
2014-07-08 09:51:49 +00:00
|
|
|
this._destroying.push(actor);
|
2010-09-15 11:52:20 +00:00
|
|
|
|
2014-07-08 09:51:49 +00:00
|
|
|
Tweener.addTween(actor,
|
|
|
|
{ opacity: 0,
|
|
|
|
scale_x: 0.8,
|
|
|
|
scale_y: 0.8,
|
|
|
|
time: DESTROY_WINDOW_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad',
|
2014-08-03 19:28:04 +00:00
|
|
|
onComplete: this._destroyWindowDone,
|
2014-07-08 09:51:49 +00:00
|
|
|
onCompleteScope: this,
|
|
|
|
onCompleteParams: [shellwm, actor],
|
2014-08-03 19:28:04 +00:00
|
|
|
onOverwrite: this._destroyWindowDone,
|
2014-07-08 09:51:49 +00:00
|
|
|
onOverwriteScope: this,
|
|
|
|
onOverwriteParams: [shellwm, actor]
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case Meta.WindowType.MODAL_DIALOG:
|
|
|
|
case Meta.WindowType.DIALOG:
|
|
|
|
actor.set_pivot_point(0.5, 0.5);
|
|
|
|
this._destroying.push(actor);
|
|
|
|
|
|
|
|
if (window.is_attached_dialog()) {
|
|
|
|
let parent = window.get_transient_for();
|
|
|
|
this._checkDimming(parent, window);
|
|
|
|
actor._parentDestroyId = parent.connect('unmanaged', Lang.bind(this, function () {
|
|
|
|
Tweener.removeTweens(actor);
|
|
|
|
this._destroyWindowDone(shellwm, actor);
|
|
|
|
}));
|
|
|
|
}
|
2010-09-11 01:30:50 +00:00
|
|
|
|
|
|
|
Tweener.addTween(actor,
|
2012-08-10 13:18:40 +00:00
|
|
|
{ scale_y: 0,
|
2014-07-28 16:12:30 +00:00
|
|
|
time: DIALOG_DESTROY_WINDOW_ANIMATION_TIME,
|
2014-07-08 09:51:49 +00:00
|
|
|
transition: 'easeOutQuad',
|
2014-08-03 19:28:04 +00:00
|
|
|
onComplete: this._destroyWindowDone,
|
2010-09-11 01:30:50 +00:00
|
|
|
onCompleteScope: this,
|
|
|
|
onCompleteParams: [shellwm, actor],
|
2010-09-15 11:52:20 +00:00
|
|
|
onOverwrite: this._destroyWindowDone,
|
2010-09-11 01:30:50 +00:00
|
|
|
onOverwriteScope: this,
|
|
|
|
onOverwriteParams: [shellwm, actor]
|
|
|
|
});
|
2014-07-08 09:51:49 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
shellwm.completed_destroy(actor);
|
2010-09-11 01:30:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-12-01 19:51:43 +00:00
|
|
|
},
|
2010-09-11 01:30:50 +00:00
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_destroyWindowDone : function(shellwm, actor) {
|
2010-09-15 11:52:20 +00:00
|
|
|
if (this._removeEffect(this._destroying, actor)) {
|
|
|
|
let parent = actor.get_meta_window().get_transient_for();
|
|
|
|
if (parent && actor._parentDestroyId) {
|
|
|
|
parent.disconnect(actor._parentDestroyId);
|
|
|
|
actor._parentDestroyId = 0;
|
2010-09-11 01:30:50 +00:00
|
|
|
}
|
2010-09-15 11:52:20 +00:00
|
|
|
shellwm.completed_destroy(actor);
|
2010-09-11 01:30:50 +00:00
|
|
|
}
|
2008-12-29 04:44:03 +00:00
|
|
|
},
|
|
|
|
|
2012-08-20 08:38:13 +00:00
|
|
|
_filterKeybinding: function(shellwm, binding) {
|
2014-12-11 14:35:40 +00:00
|
|
|
if (Main.actionMode == Shell.ActionMode.NONE)
|
2012-08-20 14:20:23 +00:00
|
|
|
return true;
|
2012-08-20 08:38:13 +00:00
|
|
|
|
2012-08-11 00:53:38 +00:00
|
|
|
// There's little sense in implementing a keybinding in mutter and
|
|
|
|
// not having it work in NORMAL mode; handle this case generically
|
|
|
|
// so we don't have to explicitly allow all builtin keybindings in
|
|
|
|
// NORMAL mode.
|
2014-12-11 14:35:40 +00:00
|
|
|
if (Main.actionMode == Shell.ActionMode.NORMAL &&
|
2012-08-11 00:53:38 +00:00
|
|
|
binding.is_builtin())
|
2012-08-20 08:38:13 +00:00
|
|
|
return false;
|
|
|
|
|
2014-12-11 14:35:40 +00:00
|
|
|
return !(this._allowedKeybindings[binding.get_name()] & Main.actionMode);
|
2012-08-20 08:38:13 +00:00
|
|
|
},
|
|
|
|
|
2014-12-17 21:57:44 +00:00
|
|
|
_syncStacking: function() {
|
|
|
|
if (this._switchData == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Update stacking of windows in inGroup (aka the workspace we are
|
|
|
|
// switching to). Windows in outGroup are about to be hidden anyway,
|
|
|
|
// so we just ignore them here.
|
|
|
|
let windows = global.get_window_actors();
|
|
|
|
let sibling = null;
|
|
|
|
for (let i = 0; i < windows.length; i++) {
|
|
|
|
if (windows[i].get_parent() != this._switchData.inGroup)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
this._switchData.inGroup.set_child_above_sibling(windows[i], sibling);
|
|
|
|
sibling = windows[i];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_switchWorkspace : function(shellwm, from, to, direction) {
|
2013-06-16 04:21:21 +00:00
|
|
|
if (!Main.sessionMode.hasWorkspaces || !this._shouldAnimate()) {
|
2009-09-15 17:09:51 +00:00
|
|
|
shellwm.completed_switch_workspace();
|
2008-12-04 15:16:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-10-19 18:55:43 +00:00
|
|
|
let windows = global.get_window_actors();
|
2009-09-15 17:09:51 +00:00
|
|
|
|
2008-12-01 19:51:43 +00:00
|
|
|
/* @direction is the direction that the "camera" moves, so the
|
|
|
|
* screen contents have to move one screen's worth in the
|
|
|
|
* opposite direction.
|
|
|
|
*/
|
|
|
|
let xDest = 0, yDest = 0;
|
|
|
|
|
|
|
|
if (direction == Meta.MotionDirection.UP ||
|
2008-11-21 21:34:10 +00:00
|
|
|
direction == Meta.MotionDirection.UP_LEFT ||
|
|
|
|
direction == Meta.MotionDirection.UP_RIGHT)
|
2013-01-29 00:46:29 +00:00
|
|
|
yDest = global.screen_height - Main.panel.actor.height;
|
2008-12-01 19:51:43 +00:00
|
|
|
else if (direction == Meta.MotionDirection.DOWN ||
|
2008-11-21 21:34:10 +00:00
|
|
|
direction == Meta.MotionDirection.DOWN_LEFT ||
|
|
|
|
direction == Meta.MotionDirection.DOWN_RIGHT)
|
2013-01-29 00:46:29 +00:00
|
|
|
yDest = -global.screen_height + Main.panel.actor.height;
|
2008-11-21 21:34:10 +00:00
|
|
|
|
2008-12-01 19:51:43 +00:00
|
|
|
if (direction == Meta.MotionDirection.LEFT ||
|
2008-11-21 21:34:10 +00:00
|
|
|
direction == Meta.MotionDirection.UP_LEFT ||
|
|
|
|
direction == Meta.MotionDirection.DOWN_LEFT)
|
2009-09-11 21:23:23 +00:00
|
|
|
xDest = global.screen_width;
|
2008-12-01 19:51:43 +00:00
|
|
|
else if (direction == Meta.MotionDirection.RIGHT ||
|
|
|
|
direction == Meta.MotionDirection.UP_RIGHT ||
|
|
|
|
direction == Meta.MotionDirection.DOWN_RIGHT)
|
2009-09-11 21:23:23 +00:00
|
|
|
xDest = -global.screen_width;
|
2008-12-01 19:51:43 +00:00
|
|
|
|
|
|
|
let switchData = {};
|
|
|
|
this._switchData = switchData;
|
2013-02-22 11:23:56 +00:00
|
|
|
switchData.inGroup = new Clutter.Actor();
|
|
|
|
switchData.outGroup = new Clutter.Actor();
|
|
|
|
switchData.movingWindowBin = new Clutter.Actor();
|
2008-12-01 19:51:43 +00:00
|
|
|
switchData.windows = [];
|
|
|
|
|
2009-09-11 21:23:23 +00:00
|
|
|
let wgroup = global.window_group;
|
2008-12-01 19:51:43 +00:00
|
|
|
wgroup.add_actor(switchData.inGroup);
|
|
|
|
wgroup.add_actor(switchData.outGroup);
|
2012-06-26 18:11:44 +00:00
|
|
|
wgroup.add_actor(switchData.movingWindowBin);
|
2008-12-01 19:51:43 +00:00
|
|
|
|
|
|
|
for (let i = 0; i < windows.length; i++) {
|
2013-11-05 02:24:27 +00:00
|
|
|
let actor = windows[i];
|
|
|
|
let window = actor.get_meta_window();
|
2009-05-11 17:06:42 +00:00
|
|
|
|
2013-11-05 02:24:27 +00:00
|
|
|
if (!window.showing_on_its_workspace())
|
2009-05-11 17:06:42 +00:00
|
|
|
continue;
|
|
|
|
|
2013-11-05 02:24:27 +00:00
|
|
|
if (window.is_on_all_workspaces())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
let record = { window: actor,
|
|
|
|
parent: actor.get_parent() };
|
|
|
|
|
|
|
|
if (this._movingWindow && window == this._movingWindow) {
|
|
|
|
switchData.movingWindow = record;
|
2012-06-26 18:11:44 +00:00
|
|
|
switchData.windows.push(switchData.movingWindow);
|
2013-11-05 02:24:27 +00:00
|
|
|
actor.reparent(switchData.movingWindowBin);
|
|
|
|
} else if (window.get_workspace().index() == from) {
|
|
|
|
switchData.windows.push(record);
|
|
|
|
actor.reparent(switchData.outGroup);
|
|
|
|
} else if (window.get_workspace().index() == to) {
|
|
|
|
switchData.windows.push(record);
|
|
|
|
actor.reparent(switchData.inGroup);
|
|
|
|
actor.show();
|
2008-12-01 19:51:43 +00:00
|
|
|
}
|
2008-11-21 21:34:10 +00:00
|
|
|
}
|
|
|
|
|
2008-12-01 19:51:43 +00:00
|
|
|
switchData.inGroup.set_position(-xDest, -yDest);
|
|
|
|
switchData.inGroup.raise_top();
|
|
|
|
|
2012-06-26 18:11:44 +00:00
|
|
|
switchData.movingWindowBin.raise_top();
|
|
|
|
|
2008-12-01 19:51:43 +00:00
|
|
|
Tweener.addTween(switchData.outGroup,
|
|
|
|
{ x: xDest,
|
|
|
|
y: yDest,
|
2009-05-13 19:24:32 +00:00
|
|
|
time: WINDOW_ANIMATION_TIME,
|
2010-05-13 19:46:04 +00:00
|
|
|
transition: 'easeOutQuad',
|
2009-01-08 23:34:19 +00:00
|
|
|
onComplete: this._switchWorkspaceDone,
|
2009-09-15 17:09:51 +00:00
|
|
|
onCompleteScope: this,
|
|
|
|
onCompleteParams: [shellwm]
|
2008-12-01 19:51:43 +00:00
|
|
|
});
|
|
|
|
Tweener.addTween(switchData.inGroup,
|
|
|
|
{ x: 0,
|
|
|
|
y: 0,
|
2009-05-13 19:24:32 +00:00
|
|
|
time: WINDOW_ANIMATION_TIME,
|
2010-05-13 19:46:04 +00:00
|
|
|
transition: 'easeOutQuad'
|
2008-12-01 19:51:43 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_switchWorkspaceDone : function(shellwm) {
|
2008-12-01 19:51:43 +00:00
|
|
|
let switchData = this._switchData;
|
|
|
|
if (!switchData)
|
|
|
|
return;
|
|
|
|
this._switchData = null;
|
|
|
|
|
|
|
|
for (let i = 0; i < switchData.windows.length; i++) {
|
|
|
|
let w = switchData.windows[i];
|
2011-01-18 18:25:00 +00:00
|
|
|
if (w.window.is_destroyed()) // Window gone
|
|
|
|
continue;
|
2008-12-01 19:51:43 +00:00
|
|
|
if (w.window.get_parent() == switchData.outGroup) {
|
|
|
|
w.window.reparent(w.parent);
|
|
|
|
w.window.hide();
|
|
|
|
} else
|
|
|
|
w.window.reparent(w.parent);
|
|
|
|
}
|
|
|
|
Tweener.removeTweens(switchData.inGroup);
|
|
|
|
Tweener.removeTweens(switchData.outGroup);
|
|
|
|
switchData.inGroup.destroy();
|
|
|
|
switchData.outGroup.destroy();
|
2012-06-26 18:11:44 +00:00
|
|
|
switchData.movingWindowBin.destroy();
|
|
|
|
|
|
|
|
if (this._movingWindow)
|
|
|
|
this._movingWindow = null;
|
2008-11-21 21:34:10 +00:00
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
shellwm.completed_switch_workspace();
|
2009-04-13 14:55:41 +00:00
|
|
|
},
|
|
|
|
|
2013-09-01 22:26:12 +00:00
|
|
|
_showTilePreview: function(shellwm, window, tileRect, monitorIndex) {
|
|
|
|
if (!this._tilePreview)
|
|
|
|
this._tilePreview = new TilePreview();
|
|
|
|
this._tilePreview.show(window, tileRect, monitorIndex);
|
|
|
|
},
|
|
|
|
|
|
|
|
_hideTilePreview: function(shellwm) {
|
|
|
|
if (!this._tilePreview)
|
|
|
|
return;
|
|
|
|
this._tilePreview.hide();
|
|
|
|
},
|
|
|
|
|
2014-06-02 19:47:24 +00:00
|
|
|
_showWindowMenu: function(shellwm, window, menu, rect) {
|
|
|
|
this._windowMenuManager.showWindowMenuForWindow(window, menu, rect);
|
2014-03-13 22:51:10 +00:00
|
|
|
},
|
|
|
|
|
2011-11-07 01:16:15 +00:00
|
|
|
_startAppSwitcher : function(display, screen, window, binding) {
|
2010-02-12 22:52:15 +00:00
|
|
|
/* prevent a corner case where both popups show up at once */
|
|
|
|
if (this._workspaceSwitcherPopup != null)
|
2012-06-27 19:13:32 +00:00
|
|
|
this._workspaceSwitcherPopup.destroy();
|
2010-02-12 22:52:15 +00:00
|
|
|
|
2012-12-03 15:31:50 +00:00
|
|
|
let tabPopup = new AltTab.AppSwitcherPopup();
|
2008-11-21 21:34:10 +00:00
|
|
|
|
2014-05-29 21:26:25 +00:00
|
|
|
if (!tabPopup.show(binding.is_reversed(), binding.get_name(), binding.get_mask()))
|
2009-09-15 15:11:32 +00:00
|
|
|
tabPopup.destroy();
|
2010-02-12 22:52:15 +00:00
|
|
|
},
|
|
|
|
|
2012-11-23 02:20:10 +00:00
|
|
|
_startWindowSwitcher : function(display, screen, window, binding) {
|
|
|
|
/* prevent a corner case where both popups show up at once */
|
|
|
|
if (this._workspaceSwitcherPopup != null)
|
|
|
|
this._workspaceSwitcherPopup.destroy();
|
|
|
|
|
|
|
|
let tabPopup = new AltTab.WindowSwitcherPopup();
|
|
|
|
|
2014-05-29 21:26:25 +00:00
|
|
|
if (!tabPopup.show(binding.is_reversed(), binding.get_name(), binding.get_mask()))
|
2012-11-23 02:20:10 +00:00
|
|
|
tabPopup.destroy();
|
|
|
|
},
|
|
|
|
|
2011-11-07 01:16:15 +00:00
|
|
|
_startA11ySwitcher : function(display, screen, window, binding) {
|
2014-05-29 21:26:25 +00:00
|
|
|
Main.ctrlAltTabManager.popup(binding.is_reversed(), binding.get_name(), binding.get_mask());
|
2011-02-07 16:29:34 +00:00
|
|
|
},
|
|
|
|
|
2013-04-26 14:14:55 +00:00
|
|
|
_toggleAppMenu : function(display, screen, window, event, binding) {
|
|
|
|
Main.panel.toggleAppMenu();
|
2012-03-27 13:26:20 +00:00
|
|
|
},
|
|
|
|
|
2015-02-18 01:52:07 +00:00
|
|
|
_toggleCalendar: function(display, screen, window, event, binding) {
|
|
|
|
Main.panel.toggleCalendar();
|
|
|
|
},
|
|
|
|
|
2014-01-14 13:49:32 +00:00
|
|
|
_toggleTweens: function() {
|
|
|
|
this._tweensPaused = !this._tweensPaused;
|
|
|
|
const OrigTweener = imports.tweener.tweener;
|
|
|
|
if (this._tweensPaused)
|
|
|
|
OrigTweener.pauseAllTweens();
|
|
|
|
else
|
|
|
|
OrigTweener.resumeAllTweens();
|
|
|
|
},
|
|
|
|
|
2011-11-07 01:16:15 +00:00
|
|
|
_showWorkspaceSwitcher : function(display, screen, window, binding) {
|
2013-06-16 04:21:21 +00:00
|
|
|
if (!Main.sessionMode.hasWorkspaces)
|
|
|
|
return;
|
|
|
|
|
2011-11-07 01:16:15 +00:00
|
|
|
if (screen.n_workspaces == 1)
|
2010-02-12 22:52:15 +00:00
|
|
|
return;
|
|
|
|
|
2013-05-17 14:54:23 +00:00
|
|
|
let [action,,,target] = binding.get_name().split('-');
|
2012-06-27 19:13:32 +00:00
|
|
|
let newWs;
|
2013-05-17 14:54:23 +00:00
|
|
|
let direction;
|
|
|
|
|
2015-03-25 22:35:36 +00:00
|
|
|
if (action == 'move') {
|
|
|
|
// "Moving" a window to another workspace doesn't make sense when
|
|
|
|
// it cannot be unstuck, and is potentially confusing if a new
|
|
|
|
// workspaces is added at the start/end
|
|
|
|
if (window.is_always_on_all_workspaces() ||
|
|
|
|
(Meta.prefs_get_workspaces_only_on_primary() &&
|
|
|
|
window.get_monitor() != Main.layoutManager.primaryIndex))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-18 17:55:05 +00:00
|
|
|
if (target == 'last') {
|
|
|
|
direction = Meta.MotionDirection.DOWN;
|
|
|
|
newWs = screen.get_workspace_by_index(screen.n_workspaces - 1);
|
|
|
|
} else if (isNaN(target)) {
|
2015-01-15 23:13:58 +00:00
|
|
|
// Prepend a new workspace dynamically
|
|
|
|
if (screen.get_active_workspace_index() == 0 &&
|
2015-03-27 13:34:28 +00:00
|
|
|
action == 'move' && target == 'up' && this._isWorkspacePrepended == false) {
|
2015-01-15 23:13:58 +00:00
|
|
|
this.insertWorkspace(0);
|
2015-03-27 13:34:28 +00:00
|
|
|
this._isWorkspacePrepended = true;
|
|
|
|
}
|
2015-01-15 23:13:58 +00:00
|
|
|
|
2013-05-17 14:54:23 +00:00
|
|
|
direction = Meta.MotionDirection[target.toUpperCase()];
|
|
|
|
newWs = screen.get_active_workspace().get_neighbor(direction);
|
|
|
|
} else if (target > 0) {
|
|
|
|
target--;
|
|
|
|
newWs = screen.get_workspace_by_index(target);
|
|
|
|
|
|
|
|
if (screen.get_active_workspace().index() > target)
|
|
|
|
direction = Meta.MotionDirection.UP;
|
|
|
|
else
|
|
|
|
direction = Meta.MotionDirection.DOWN;
|
|
|
|
}
|
2012-04-14 13:29:54 +00:00
|
|
|
|
2012-06-27 20:07:32 +00:00
|
|
|
if (direction != Meta.MotionDirection.UP &&
|
|
|
|
direction != Meta.MotionDirection.DOWN)
|
|
|
|
return;
|
|
|
|
|
2012-04-14 13:29:54 +00:00
|
|
|
if (action == 'switch')
|
2013-05-17 14:54:23 +00:00
|
|
|
this.actionMoveWorkspace(newWs);
|
2012-04-14 13:29:54 +00:00
|
|
|
else
|
2013-05-17 14:54:23 +00:00
|
|
|
this.actionMoveWindow(window, newWs);
|
2012-06-27 19:13:32 +00:00
|
|
|
|
|
|
|
if (!Main.overview.visible) {
|
|
|
|
if (this._workspaceSwitcherPopup == null) {
|
2015-03-27 13:34:28 +00:00
|
|
|
this._workspaceTracker.blockUpdates();
|
2012-06-27 19:13:32 +00:00
|
|
|
this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
|
|
|
|
this._workspaceSwitcherPopup.connect('destroy', Lang.bind(this, function() {
|
2015-03-27 13:34:28 +00:00
|
|
|
this._workspaceTracker.unblockUpdates();
|
2012-06-27 19:13:32 +00:00
|
|
|
this._workspaceSwitcherPopup = null;
|
2015-03-27 13:34:28 +00:00
|
|
|
this._isWorkspacePrepended = false;
|
2012-06-27 19:13:32 +00:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
this._workspaceSwitcherPopup.display(direction, newWs.index());
|
|
|
|
}
|
2010-03-17 02:08:52 +00:00
|
|
|
},
|
|
|
|
|
2013-05-17 14:54:23 +00:00
|
|
|
actionMoveWorkspace: function(workspace) {
|
2013-06-16 04:21:21 +00:00
|
|
|
if (!Main.sessionMode.hasWorkspaces)
|
|
|
|
return;
|
|
|
|
|
2012-04-14 12:40:30 +00:00
|
|
|
let activeWorkspace = global.screen.get_active_workspace();
|
2010-11-12 15:22:05 +00:00
|
|
|
|
2013-05-17 14:54:23 +00:00
|
|
|
if (activeWorkspace != workspace)
|
|
|
|
workspace.activate(global.get_current_time());
|
2011-01-30 23:21:31 +00:00
|
|
|
},
|
2012-04-14 13:29:54 +00:00
|
|
|
|
2013-05-17 14:54:23 +00:00
|
|
|
actionMoveWindow: function(window, workspace) {
|
2013-06-16 04:21:21 +00:00
|
|
|
if (!Main.sessionMode.hasWorkspaces)
|
|
|
|
return;
|
|
|
|
|
2012-04-14 13:29:54 +00:00
|
|
|
let activeWorkspace = global.screen.get_active_workspace();
|
|
|
|
|
2013-05-17 14:54:23 +00:00
|
|
|
if (activeWorkspace != workspace) {
|
2012-04-14 13:29:54 +00:00
|
|
|
// This won't have any effect for "always sticky" windows
|
|
|
|
// (like desktop windows or docks)
|
2012-06-26 18:11:44 +00:00
|
|
|
|
|
|
|
this._movingWindow = window;
|
2013-05-17 14:54:23 +00:00
|
|
|
window.change_workspace(workspace);
|
2012-04-14 13:29:54 +00:00
|
|
|
|
|
|
|
global.display.clear_mouse_mode();
|
2013-05-17 14:54:23 +00:00
|
|
|
workspace.activate_with_focus (window, global.get_current_time());
|
2012-04-14 13:29:54 +00:00
|
|
|
}
|
|
|
|
},
|
2013-08-17 15:42:39 +00:00
|
|
|
|
|
|
|
_confirmDisplayChange: function() {
|
|
|
|
let dialog = new DisplayChangeDialog(this._shellwm);
|
|
|
|
dialog.open();
|
|
|
|
},
|
2014-12-30 01:30:38 +00:00
|
|
|
|
|
|
|
_showResizePopup: function(display, show, rect, displayW, displayH) {
|
|
|
|
if (show) {
|
|
|
|
if (!this._resizePopup)
|
|
|
|
this._resizePopup = new ResizePopup();
|
|
|
|
|
|
|
|
this._resizePopup.set(rect, displayW, displayH);
|
|
|
|
} else {
|
2015-01-02 17:27:52 +00:00
|
|
|
if (this._resizePopup) {
|
2014-12-30 01:30:38 +00:00
|
|
|
this._resizePopup.destroy();
|
2015-01-02 17:27:52 +00:00
|
|
|
this._resizePopup = null;
|
|
|
|
}
|
2014-12-30 01:30:38 +00:00
|
|
|
}
|
|
|
|
},
|
2011-11-20 17:56:27 +00:00
|
|
|
});
|