2008-12-01 14:51:43 -05:00
|
|
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2008-11-21 09:02:09 -05:00
|
|
|
|
|
|
|
const Clutter = imports.gi.Clutter;
|
2010-09-10 21:30:50 -04:00
|
|
|
const GLib = imports.gi.GLib;
|
|
|
|
const Gio = imports.gi.Gio;
|
2009-09-15 13:09:51 -04:00
|
|
|
const Lang = imports.lang;
|
2008-11-21 16:34:10 -05:00
|
|
|
const Meta = imports.gi.Meta;
|
2010-02-10 17:26:24 -05:00
|
|
|
const St = imports.gi.St;
|
2011-05-20 05:14:54 -04:00
|
|
|
const Shell = imports.gi.Shell;
|
2008-11-21 09:02:09 -05:00
|
|
|
|
2009-04-13 10:55:41 -04:00
|
|
|
const AltTab = imports.ui.altTab;
|
2010-02-12 17:52:15 -05:00
|
|
|
const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup;
|
2008-11-21 09:02:09 -05:00
|
|
|
const Main = imports.ui.main;
|
2009-02-10 11:12:58 -05:00
|
|
|
const Tweener = imports.ui.tweener;
|
2008-11-21 09:02:09 -05:00
|
|
|
|
2008-12-28 23:44:03 -05:00
|
|
|
const WINDOW_ANIMATION_TIME = 0.25;
|
2010-09-10 21:30:50 -04:00
|
|
|
const DIM_TIME = 0.500;
|
|
|
|
const UNDIM_TIME = 0.250;
|
|
|
|
|
|
|
|
var dimShader = undefined;
|
|
|
|
|
2011-09-17 03:06:00 -04:00
|
|
|
function getDimShaderSource() {
|
|
|
|
if (!dimShader)
|
|
|
|
dimShader = Shell.get_file_contents_utf8_sync(global.datadir + '/shaders/dim-window.glsl');
|
2010-09-10 21:30:50 -04:00
|
|
|
return dimShader;
|
|
|
|
}
|
|
|
|
|
2011-09-17 15:56:59 -04:00
|
|
|
function getTopInvisibleBorder(metaWindow) {
|
|
|
|
let outerRect = metaWindow.get_outer_rect();
|
|
|
|
let inputRect = metaWindow.get_input_rect();
|
|
|
|
return outerRect.y - inputRect.y;
|
|
|
|
}
|
|
|
|
|
2011-09-20 14:21:45 -04:00
|
|
|
function WindowDimmer(actor) {
|
|
|
|
this._init(actor);
|
2010-09-10 21:30:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
WindowDimmer.prototype = {
|
2011-09-20 14:21:45 -04:00
|
|
|
_init: function(actor) {
|
2011-09-17 03:06:00 -04:00
|
|
|
this.effect = new Clutter.ShaderEffect({ shader_type: Clutter.ShaderType.FRAGMENT_SHADER });
|
|
|
|
this.effect.set_shader_source(getDimShaderSource());
|
|
|
|
|
2010-09-10 21:30:50 -04:00
|
|
|
this.actor = actor;
|
|
|
|
},
|
|
|
|
|
|
|
|
set dimFraction(fraction) {
|
|
|
|
this._dimFraction = fraction;
|
2011-09-17 03:06:00 -04:00
|
|
|
if (!Meta.prefs_get_attach_modal_dialogs()) {
|
|
|
|
this.effect.enabled = false;
|
2010-09-10 21:30:50 -04:00
|
|
|
return;
|
|
|
|
}
|
2011-09-17 03:06:00 -04:00
|
|
|
|
2010-09-10 21:30:50 -04:00
|
|
|
if (fraction > 0.01) {
|
2011-09-17 03:06:00 -04:00
|
|
|
Shell.shader_effect_set_double_uniform(this.effect, 'height', this.actor.get_height());
|
|
|
|
Shell.shader_effect_set_double_uniform(this.effect, 'fraction', fraction);
|
|
|
|
|
|
|
|
if (!this.effect.actor)
|
|
|
|
this.actor.add_effect(this.effect);
|
|
|
|
} else {
|
|
|
|
if (this.effect.actor)
|
|
|
|
this.actor.remove_effect(this.effect);
|
|
|
|
}
|
2010-09-10 21:30:50 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
get dimFraction() {
|
|
|
|
return this._dimFraction;
|
|
|
|
},
|
|
|
|
|
|
|
|
_dimFraction: 0.0
|
|
|
|
};
|
|
|
|
|
2011-09-20 14:21:45 -04:00
|
|
|
function getWindowDimmer(actor) {
|
|
|
|
if (!actor._windowDimmer)
|
|
|
|
actor._windowDimmer = new WindowDimmer(actor);
|
2010-09-10 21:30:50 -04:00
|
|
|
|
2011-09-20 14:21:45 -04:00
|
|
|
return actor._windowDimmer;
|
2010-09-10 21:30:50 -04:00
|
|
|
}
|
2008-11-21 16:34:10 -05:00
|
|
|
|
2008-11-21 10:10:11 -05:00
|
|
|
function WindowManager() {
|
|
|
|
this._init();
|
2008-11-21 09:02:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
WindowManager.prototype = {
|
2008-12-01 14:51:43 -05:00
|
|
|
_init : function() {
|
2010-03-15 22:06:58 -04:00
|
|
|
this._shellwm = global.window_manager;
|
2008-11-21 16:34:10 -05:00
|
|
|
|
2010-03-15 22:06:58 -04:00
|
|
|
this._keyBindingHandlers = [];
|
2008-12-28 23:44:03 -05:00
|
|
|
this._minimizing = [];
|
|
|
|
this._maximizing = [];
|
|
|
|
this._unmaximizing = [];
|
|
|
|
this._mapping = [];
|
|
|
|
this._destroying = [];
|
2008-11-21 16:34:10 -05:00
|
|
|
|
2010-09-12 05:39:52 -04:00
|
|
|
this._dimmedWindows = [];
|
|
|
|
|
2011-02-16 15:05:20 -05:00
|
|
|
this._animationBlockCount = 0;
|
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
this._switchData = null;
|
2010-03-15 22:06:58 -04:00
|
|
|
this._shellwm.connect('kill-switch-workspace', Lang.bind(this, this._switchWorkspaceDone));
|
2010-06-16 17:28:57 -04:00
|
|
|
this._shellwm.connect('kill-window-effects', Lang.bind(this, function (shellwm, actor) {
|
|
|
|
this._minimizeWindowDone(shellwm, actor);
|
|
|
|
this._maximizeWindowDone(shellwm, actor);
|
|
|
|
this._unmaximizeWindowDone(shellwm, actor);
|
|
|
|
this._mapWindowDone(shellwm, actor);
|
|
|
|
this._destroyWindowDone(shellwm, actor);
|
|
|
|
}));
|
|
|
|
|
|
|
|
this._shellwm.connect('switch-workspace', Lang.bind(this, this._switchWorkspace));
|
2010-03-15 22:06:58 -04:00
|
|
|
this._shellwm.connect('minimize', Lang.bind(this, this._minimizeWindow));
|
|
|
|
this._shellwm.connect('maximize', Lang.bind(this, this._maximizeWindow));
|
|
|
|
this._shellwm.connect('unmaximize', Lang.bind(this, this._unmaximizeWindow));
|
|
|
|
this._shellwm.connect('map', Lang.bind(this, this._mapWindow));
|
|
|
|
this._shellwm.connect('destroy', Lang.bind(this, this._destroyWindow));
|
2010-02-12 17:52:15 -05:00
|
|
|
|
|
|
|
this._workspaceSwitcherPopup = null;
|
2010-03-15 22:06:58 -04:00
|
|
|
this.setKeybindingHandler('switch_to_workspace_left', Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setKeybindingHandler('switch_to_workspace_right', Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setKeybindingHandler('switch_to_workspace_up', Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setKeybindingHandler('switch_to_workspace_down', Lang.bind(this, this._showWorkspaceSwitcher));
|
|
|
|
this.setKeybindingHandler('switch_windows', Lang.bind(this, this._startAppSwitcher));
|
2011-01-29 17:11:25 -05:00
|
|
|
this.setKeybindingHandler('switch_group', Lang.bind(this, this._startAppSwitcher));
|
2011-07-05 18:05:45 -04:00
|
|
|
this.setKeybindingHandler('switch_windows_backward', Lang.bind(this, this._startAppSwitcher));
|
|
|
|
this.setKeybindingHandler('switch_group_backward', Lang.bind(this, this._startAppSwitcher));
|
2011-02-07 11:29:34 -05:00
|
|
|
this.setKeybindingHandler('switch_panels', Lang.bind(this, this._startA11ySwitcher));
|
2010-09-12 05:39:52 -04:00
|
|
|
|
|
|
|
Main.overview.connect('showing', Lang.bind(this, function() {
|
|
|
|
for (let i = 0; i < this._dimmedWindows.length; i++)
|
2011-03-07 22:09:41 -05:00
|
|
|
this._undimWindow(this._dimmedWindows[i], true);
|
2010-09-12 05:39:52 -04:00
|
|
|
}));
|
|
|
|
Main.overview.connect('hiding', Lang.bind(this, function() {
|
|
|
|
for (let i = 0; i < this._dimmedWindows.length; i++)
|
2011-03-07 22:09:41 -05:00
|
|
|
this._dimWindow(this._dimmedWindows[i], true);
|
2010-09-12 05:39:52 -04:00
|
|
|
}));
|
2010-03-15 22:06:58 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
setKeybindingHandler: function(keybinding, handler){
|
|
|
|
if (this._keyBindingHandlers[keybinding])
|
|
|
|
this._shellwm.disconnect(this._keyBindingHandlers[keybinding]);
|
|
|
|
else
|
|
|
|
this._shellwm.takeover_keybinding(keybinding);
|
2010-02-12 17:52:15 -05:00
|
|
|
|
2010-03-15 22:06:58 -04:00
|
|
|
this._keyBindingHandlers[keybinding] =
|
|
|
|
this._shellwm.connect('keybinding::' + keybinding, handler);
|
2008-12-28 23:44:03 -05:00
|
|
|
},
|
|
|
|
|
2011-02-16 15:05:20 -05:00
|
|
|
blockAnimations: function() {
|
|
|
|
this._animationBlockCount++;
|
|
|
|
},
|
|
|
|
|
|
|
|
unblockAnimations: function() {
|
|
|
|
this._animationBlockCount = Math.max(0, this._animationBlockCount - 1);
|
|
|
|
},
|
|
|
|
|
2009-02-03 13:25:34 -05:00
|
|
|
_shouldAnimate : function(actor) {
|
2011-02-16 15:05:20 -05:00
|
|
|
if (Main.overview.visible || this._animationsBlocked > 0)
|
2009-02-03 13:25:34 -05:00
|
|
|
return false;
|
2010-09-30 02:42:14 -04:00
|
|
|
if (actor && (actor.meta_window.get_window_type() != Meta.WindowType.NORMAL))
|
2009-02-03 13:25:34 -05:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
},
|
2008-12-28 23:44:03 -05:00
|
|
|
|
2009-02-05 19:57:54 -05:00
|
|
|
_removeEffect : function(list, actor) {
|
|
|
|
let idx = list.indexOf(actor);
|
|
|
|
if (idx != -1) {
|
|
|
|
list.splice(idx, 1);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
_minimizeWindow : function(shellwm, actor) {
|
2009-02-03 13:25:34 -05:00
|
|
|
if (!this._shouldAnimate(actor)) {
|
2009-09-15 13:09:51 -04:00
|
|
|
shellwm.completed_minimize(actor);
|
2008-12-28 23:44:03 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
actor.set_scale(1.0, 1.0);
|
|
|
|
actor.move_anchor_point_from_gravity(Clutter.Gravity.CENTER);
|
|
|
|
|
|
|
|
/* scale window down to 0x0.
|
|
|
|
* maybe TODO: get icon geometry passed through and move the window towards it?
|
|
|
|
*/
|
|
|
|
this._minimizing.push(actor);
|
2010-02-05 07:50:11 -05:00
|
|
|
|
2011-06-13 09:54:05 -04:00
|
|
|
let primary = Main.layoutManager.primaryMonitor;
|
2010-02-10 17:26:24 -05:00
|
|
|
let xDest = primary.x;
|
|
|
|
if (St.Widget.get_default_direction() == St.TextDirection.RTL)
|
|
|
|
xDest += primary.width;
|
2010-02-05 07:50:11 -05:00
|
|
|
|
2008-12-28 23:44:03 -05:00
|
|
|
Tweener.addTween(actor,
|
|
|
|
{ scale_x: 0.0,
|
|
|
|
scale_y: 0.0,
|
2010-02-10 17:26:24 -05:00
|
|
|
x: xDest,
|
2010-02-05 07:50:11 -05:00
|
|
|
y: 0,
|
2008-12-28 23:44:03 -05:00
|
|
|
time: WINDOW_ANIMATION_TIME,
|
2010-05-13 15:46:04 -04:00
|
|
|
transition: 'easeOutQuad',
|
2008-12-28 23:44:03 -05:00
|
|
|
onComplete: this._minimizeWindowDone,
|
|
|
|
onCompleteScope: this,
|
2009-09-15 13:09:51 -04:00
|
|
|
onCompleteParams: [shellwm, actor],
|
2009-02-05 19:57:54 -05:00
|
|
|
onOverwrite: this._minimizeWindowOverwritten,
|
|
|
|
onOverwriteScope: this,
|
2009-09-15 13:09:51 -04:00
|
|
|
onOverwriteParams: [shellwm, actor]
|
2008-12-28 23:44:03 -05:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
_minimizeWindowDone : function(shellwm, actor) {
|
2009-02-05 19:57:54 -05:00
|
|
|
if (this._removeEffect(this._minimizing, actor)) {
|
2008-12-28 23:44:03 -05:00
|
|
|
Tweener.removeTweens(actor);
|
|
|
|
actor.set_scale(1.0, 1.0);
|
|
|
|
actor.move_anchor_point_from_gravity(Clutter.Gravity.NORTH_WEST);
|
2009-02-05 19:57:54 -05:00
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
shellwm.completed_minimize(actor);
|
2009-02-05 19:57:54 -05:00
|
|
|
}
|
|
|
|
},
|
2008-12-28 23:44:03 -05:00
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
_minimizeWindowOverwritten : function(shellwm, actor) {
|
2009-02-05 19:57:54 -05:00
|
|
|
if (this._removeEffect(this._minimizing, actor)) {
|
2009-09-15 13:09:51 -04:00
|
|
|
shellwm.completed_minimize(actor);
|
2008-12-28 23:44:03 -05:00
|
|
|
}
|
|
|
|
},
|
2009-02-05 19:57:54 -05:00
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
_maximizeWindow : function(shellwm, actor, targetX, targetY, targetWidth, targetHeight) {
|
|
|
|
shellwm.completed_maximize(actor);
|
2008-12-28 23:44:03 -05:00
|
|
|
},
|
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
_maximizeWindowDone : function(shellwm, actor) {
|
2009-02-05 19:57:54 -05:00
|
|
|
},
|
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
_maximizeWindowOverwrite : function(shellwm, actor) {
|
2008-12-28 23:44:03 -05:00
|
|
|
},
|
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
_unmaximizeWindow : function(shellwm, actor, targetX, targetY, targetWidth, targetHeight) {
|
|
|
|
shellwm.completed_unmaximize(actor);
|
2008-12-28 23:44:03 -05:00
|
|
|
},
|
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
_unmaximizeWindowDone : function(shellwm, actor) {
|
2008-12-28 23:44:03 -05:00
|
|
|
},
|
|
|
|
|
2011-03-07 22:09:41 -05:00
|
|
|
_hasAttachedDialogs: function(window, ignoreWindow) {
|
2010-09-10 21:30:50 -04:00
|
|
|
var count = 0;
|
2011-03-07 22:09:41 -05:00
|
|
|
window.foreach_transient(function(win) {
|
2011-04-05 10:16:50 -04:00
|
|
|
if (win != ignoreWindow && win.is_attached_dialog())
|
2010-09-10 21:30:50 -04:00
|
|
|
count++;
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
return count != 0;
|
|
|
|
},
|
|
|
|
|
2011-03-07 22:09:41 -05:00
|
|
|
_checkDimming: function(window, ignoreWindow) {
|
2011-04-05 10:16:50 -04:00
|
|
|
let shouldDim = this._hasAttachedDialogs(window, ignoreWindow);
|
2011-03-07 22:09:41 -05:00
|
|
|
|
|
|
|
if (shouldDim && !window._dimmed) {
|
|
|
|
window._dimmed = true;
|
|
|
|
this._dimmedWindows.push(window);
|
|
|
|
if (!Main.overview.visible)
|
|
|
|
this._dimWindow(window, true);
|
|
|
|
} else if (!shouldDim && window._dimmed) {
|
|
|
|
window._dimmed = false;
|
|
|
|
this._dimmedWindows = this._dimmedWindows.filter(function(win) {
|
|
|
|
return win != window;
|
|
|
|
});
|
|
|
|
if (!Main.overview.visible)
|
|
|
|
this._undimWindow(window, true);
|
2010-09-30 17:09:15 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-03-07 22:09:41 -05:00
|
|
|
_dimWindow: function(window, animate) {
|
|
|
|
let actor = window.get_compositor_private();
|
|
|
|
if (!actor)
|
2010-09-10 21:30:50 -04:00
|
|
|
return;
|
2010-09-12 05:39:52 -04:00
|
|
|
if (animate)
|
2011-09-20 14:21:45 -04:00
|
|
|
Tweener.addTween(getWindowDimmer(actor),
|
2010-09-10 21:30:50 -04:00
|
|
|
{ dimFraction: 1.0,
|
|
|
|
time: DIM_TIME,
|
|
|
|
transition: 'linear'
|
|
|
|
});
|
2010-09-12 05:39:52 -04:00
|
|
|
else
|
2011-09-20 14:21:45 -04:00
|
|
|
getWindowDimmer(actor).dimFraction = 1.0;
|
2010-09-10 21:30:50 -04:00
|
|
|
},
|
|
|
|
|
2011-03-07 22:09:41 -05:00
|
|
|
_undimWindow: function(window, animate) {
|
|
|
|
let actor = window.get_compositor_private();
|
|
|
|
if (!actor)
|
2010-09-10 21:30:50 -04:00
|
|
|
return;
|
2010-09-12 05:39:52 -04:00
|
|
|
if (animate)
|
2011-09-20 14:21:45 -04:00
|
|
|
Tweener.addTween(getWindowDimmer(actor),
|
2010-09-10 21:30:50 -04:00
|
|
|
{ dimFraction: 0.0,
|
|
|
|
time: UNDIM_TIME,
|
|
|
|
transition: 'linear'
|
|
|
|
});
|
2010-09-12 05:39:52 -04:00
|
|
|
else
|
2011-09-20 14:21:45 -04:00
|
|
|
getWindowDimmer(actor).dimFraction = 0.0;
|
2010-09-10 21:30:50 -04:00
|
|
|
},
|
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
_mapWindow : function(shellwm, actor) {
|
2010-09-30 17:09:15 -04: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-07 22:09:41 -05: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 17:09:15 -04:00
|
|
|
|
|
|
|
actor._windowType = type;
|
|
|
|
}));
|
2011-04-05 10:16:50 -04:00
|
|
|
if (actor.meta_window.is_attached_dialog()) {
|
2011-03-07 22:09:41 -05:00
|
|
|
this._checkDimming(actor.get_meta_window().get_transient_for());
|
2010-09-12 05:39:52 -04:00
|
|
|
if (this._shouldAnimate()) {
|
|
|
|
actor.set_scale(1.0, 0.0);
|
|
|
|
actor.show();
|
|
|
|
this._mapping.push(actor);
|
|
|
|
|
|
|
|
Tweener.addTween(actor,
|
|
|
|
{ scale_y: 1,
|
|
|
|
time: WINDOW_ANIMATION_TIME,
|
|
|
|
transition: "easeOutQuad",
|
|
|
|
onComplete: this._mapWindowDone,
|
|
|
|
onCompleteScope: this,
|
|
|
|
onCompleteParams: [shellwm, actor],
|
|
|
|
onOverwrite: this._mapWindowOverwrite,
|
|
|
|
onOverwriteScope: this,
|
|
|
|
onOverwriteParams: [shellwm, actor]
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
shellwm.completed_map(actor);
|
2010-09-10 21:30:50 -04:00
|
|
|
return;
|
|
|
|
}
|
2009-02-03 13:25:34 -05:00
|
|
|
if (!this._shouldAnimate(actor)) {
|
2009-09-15 13:09:51 -04:00
|
|
|
shellwm.completed_map(actor);
|
2008-12-28 23:44:03 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-02 13:44:05 -04:00
|
|
|
actor.opacity = 0;
|
2008-12-28 23:44:03 -05:00
|
|
|
actor.show();
|
2010-04-02 14:30:10 -04:00
|
|
|
|
|
|
|
/* Fade window in */
|
2008-12-28 23:44:03 -05:00
|
|
|
this._mapping.push(actor);
|
|
|
|
Tweener.addTween(actor,
|
2010-04-02 13:44:05 -04:00
|
|
|
{ opacity: 255,
|
2008-12-28 23:44:03 -05:00
|
|
|
time: WINDOW_ANIMATION_TIME,
|
2010-05-13 15:46:04 -04:00
|
|
|
transition: 'easeOutQuad',
|
2008-12-28 23:44:03 -05:00
|
|
|
onComplete: this._mapWindowDone,
|
|
|
|
onCompleteScope: this,
|
2009-09-15 13:09:51 -04:00
|
|
|
onCompleteParams: [shellwm, actor],
|
2009-02-05 19:57:54 -05:00
|
|
|
onOverwrite: this._mapWindowOverwrite,
|
|
|
|
onOverwriteScope: this,
|
2009-09-15 13:09:51 -04:00
|
|
|
onOverwriteParams: [shellwm, actor]
|
2008-12-28 23:44:03 -05:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
_mapWindowDone : function(shellwm, actor) {
|
2009-02-05 19:57:54 -05:00
|
|
|
if (this._removeEffect(this._mapping, actor)) {
|
2008-12-28 23:44:03 -05:00
|
|
|
Tweener.removeTweens(actor);
|
2010-04-02 14:30:10 -04:00
|
|
|
actor.opacity = 255;
|
2009-09-15 13:09:51 -04:00
|
|
|
shellwm.completed_map(actor);
|
2009-02-05 19:57:54 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
_mapWindowOverwrite : function(shellwm, actor) {
|
2009-02-05 19:57:54 -05:00
|
|
|
if (this._removeEffect(this._mapping, actor)) {
|
2009-09-15 13:09:51 -04:00
|
|
|
shellwm.completed_map(actor);
|
2008-12-28 23:44:03 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-09-15 07:52:20 -04:00
|
|
|
_destroyWindow : function(shellwm, actor) {
|
2011-03-07 22:09:41 -05:00
|
|
|
let window = actor.meta_window;
|
2010-09-30 17:09:15 -04:00
|
|
|
if (actor._notifyWindowTypeSignalId) {
|
2011-03-07 22:09:41 -05:00
|
|
|
window.disconnect(actor._notifyWindowTypeSignalId);
|
2010-09-30 17:09:15 -04:00
|
|
|
actor._notifyWindowTypeSignalId = 0;
|
|
|
|
}
|
2011-03-07 22:09:41 -05:00
|
|
|
if (window._dimmed) {
|
|
|
|
this._dimmedWindows = this._dimmedWindows.filter(function(win) {
|
|
|
|
return win != window;
|
|
|
|
});
|
|
|
|
}
|
2011-04-05 10:16:50 -04:00
|
|
|
if (window.is_attached_dialog()) {
|
|
|
|
let parent = window.get_transient_for();
|
2011-03-07 22:09:41 -05:00
|
|
|
this._checkDimming(parent, window);
|
2011-04-05 10:16:50 -04:00
|
|
|
if (!this._shouldAnimate()) {
|
|
|
|
shellwm.completed_destroy(actor);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-10 21:30:50 -04:00
|
|
|
actor.set_scale(1.0, 1.0);
|
|
|
|
actor.show();
|
2010-09-15 07:52:20 -04:00
|
|
|
this._destroying.push(actor);
|
|
|
|
|
|
|
|
actor._parentDestroyId = parent.connect('unmanaged', Lang.bind(this, function () {
|
|
|
|
Tweener.removeTweens(actor);
|
|
|
|
this._destroyWindowDone(shellwm, actor);
|
|
|
|
}));
|
2010-09-10 21:30:50 -04:00
|
|
|
|
|
|
|
Tweener.addTween(actor,
|
|
|
|
{ scale_y: 0,
|
|
|
|
time: WINDOW_ANIMATION_TIME,
|
|
|
|
transition: "easeOutQuad",
|
|
|
|
onComplete: this._destroyWindowDone,
|
|
|
|
onCompleteScope: this,
|
|
|
|
onCompleteParams: [shellwm, actor],
|
2010-09-15 07:52:20 -04:00
|
|
|
onOverwrite: this._destroyWindowDone,
|
2010-09-10 21:30:50 -04:00
|
|
|
onOverwriteScope: this,
|
|
|
|
onOverwriteParams: [shellwm, actor]
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
2009-09-26 17:32:22 -04:00
|
|
|
shellwm.completed_destroy(actor);
|
2008-12-01 14:51:43 -05:00
|
|
|
},
|
2010-09-10 21:30:50 -04:00
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
_destroyWindowDone : function(shellwm, actor) {
|
2010-09-15 07:52:20 -04: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-10 21:30:50 -04:00
|
|
|
}
|
2010-09-15 07:52:20 -04:00
|
|
|
shellwm.completed_destroy(actor);
|
2010-09-10 21:30:50 -04:00
|
|
|
}
|
2008-12-28 23:44:03 -05:00
|
|
|
},
|
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
_switchWorkspace : function(shellwm, from, to, direction) {
|
2009-02-03 13:25:34 -05:00
|
|
|
if (!this._shouldAnimate()) {
|
2009-09-15 13:09:51 -04:00
|
|
|
shellwm.completed_switch_workspace();
|
2008-12-04 10:16:16 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-10-19 14:55:43 -04:00
|
|
|
let windows = global.get_window_actors();
|
2009-09-15 13:09:51 -04:00
|
|
|
|
2008-12-01 14:51:43 -05: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 16:34:10 -05:00
|
|
|
direction == Meta.MotionDirection.UP_LEFT ||
|
|
|
|
direction == Meta.MotionDirection.UP_RIGHT)
|
2009-09-11 17:23:23 -04:00
|
|
|
yDest = global.screen_height;
|
2008-12-01 14:51:43 -05:00
|
|
|
else if (direction == Meta.MotionDirection.DOWN ||
|
2008-11-21 16:34:10 -05:00
|
|
|
direction == Meta.MotionDirection.DOWN_LEFT ||
|
|
|
|
direction == Meta.MotionDirection.DOWN_RIGHT)
|
2009-09-11 17:23:23 -04:00
|
|
|
yDest = -global.screen_height;
|
2008-11-21 16:34:10 -05:00
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
if (direction == Meta.MotionDirection.LEFT ||
|
2008-11-21 16:34:10 -05:00
|
|
|
direction == Meta.MotionDirection.UP_LEFT ||
|
|
|
|
direction == Meta.MotionDirection.DOWN_LEFT)
|
2009-09-11 17:23:23 -04:00
|
|
|
xDest = global.screen_width;
|
2008-12-01 14:51:43 -05:00
|
|
|
else if (direction == Meta.MotionDirection.RIGHT ||
|
|
|
|
direction == Meta.MotionDirection.UP_RIGHT ||
|
|
|
|
direction == Meta.MotionDirection.DOWN_RIGHT)
|
2009-09-11 17:23:23 -04:00
|
|
|
xDest = -global.screen_width;
|
2008-12-01 14:51:43 -05:00
|
|
|
|
|
|
|
let switchData = {};
|
|
|
|
this._switchData = switchData;
|
|
|
|
switchData.inGroup = new Clutter.Group();
|
|
|
|
switchData.outGroup = new Clutter.Group();
|
|
|
|
switchData.windows = [];
|
|
|
|
|
2009-09-11 17:23:23 -04:00
|
|
|
let wgroup = global.window_group;
|
2008-12-01 14:51:43 -05:00
|
|
|
wgroup.add_actor(switchData.inGroup);
|
|
|
|
wgroup.add_actor(switchData.outGroup);
|
|
|
|
|
|
|
|
for (let i = 0; i < windows.length; i++) {
|
|
|
|
let window = windows[i];
|
2009-05-11 13:06:42 -04:00
|
|
|
|
|
|
|
if (!window.meta_window.showing_on_its_workspace())
|
|
|
|
continue;
|
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
if (window.get_workspace() == from) {
|
|
|
|
switchData.windows.push({ window: window,
|
|
|
|
parent: window.get_parent() });
|
|
|
|
window.reparent(switchData.outGroup);
|
|
|
|
} else if (window.get_workspace() == to) {
|
|
|
|
switchData.windows.push({ window: window,
|
|
|
|
parent: window.get_parent() });
|
|
|
|
window.reparent(switchData.inGroup);
|
|
|
|
window.show_all();
|
|
|
|
}
|
2008-11-21 16:34:10 -05:00
|
|
|
}
|
|
|
|
|
2008-12-01 14:51:43 -05:00
|
|
|
switchData.inGroup.set_position(-xDest, -yDest);
|
|
|
|
switchData.inGroup.raise_top();
|
|
|
|
|
|
|
|
Tweener.addTween(switchData.outGroup,
|
|
|
|
{ x: xDest,
|
|
|
|
y: yDest,
|
2009-05-13 15:24:32 -04:00
|
|
|
time: WINDOW_ANIMATION_TIME,
|
2010-05-13 15:46:04 -04:00
|
|
|
transition: 'easeOutQuad',
|
2009-01-08 18:34:19 -05:00
|
|
|
onComplete: this._switchWorkspaceDone,
|
2009-09-15 13:09:51 -04:00
|
|
|
onCompleteScope: this,
|
|
|
|
onCompleteParams: [shellwm]
|
2008-12-01 14:51:43 -05:00
|
|
|
});
|
|
|
|
Tweener.addTween(switchData.inGroup,
|
|
|
|
{ x: 0,
|
|
|
|
y: 0,
|
2009-05-13 15:24:32 -04:00
|
|
|
time: WINDOW_ANIMATION_TIME,
|
2010-05-13 15:46:04 -04:00
|
|
|
transition: 'easeOutQuad'
|
2008-12-01 14:51:43 -05:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
_switchWorkspaceDone : function(shellwm) {
|
2008-12-01 14:51:43 -05: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 13:25:00 -05:00
|
|
|
if (w.window.is_destroyed()) // Window gone
|
|
|
|
continue;
|
2008-12-01 14:51:43 -05: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();
|
2008-11-21 16:34:10 -05:00
|
|
|
|
2009-09-15 13:09:51 -04:00
|
|
|
shellwm.completed_switch_workspace();
|
2009-04-13 10:55:41 -04:00
|
|
|
},
|
|
|
|
|
2011-09-06 22:38:38 -04:00
|
|
|
_startAppSwitcher : function(shellwm, binding, mask, window, backwards) {
|
2010-02-12 17:52:15 -05:00
|
|
|
/* prevent a corner case where both popups show up at once */
|
|
|
|
if (this._workspaceSwitcherPopup != null)
|
|
|
|
this._workspaceSwitcherPopup.actor.hide();
|
|
|
|
|
2009-09-15 11:11:32 -04:00
|
|
|
let tabPopup = new AltTab.AltTabPopup();
|
2008-11-21 16:34:10 -05:00
|
|
|
|
2011-09-06 22:38:38 -04:00
|
|
|
if (!tabPopup.show(backwards, binding, mask))
|
2009-09-15 11:11:32 -04:00
|
|
|
tabPopup.destroy();
|
2010-02-12 17:52:15 -05:00
|
|
|
},
|
|
|
|
|
2011-09-06 22:38:38 -04:00
|
|
|
_startA11ySwitcher : function(shellwm, binding, mask, window, backwards) {
|
|
|
|
Main.ctrlAltTabManager.popup(backwards, mask);
|
2011-02-07 11:29:34 -05:00
|
|
|
},
|
|
|
|
|
2011-09-06 22:38:38 -04:00
|
|
|
_showWorkspaceSwitcher : function(shellwm, binding, mask, window, backwards) {
|
2010-02-12 17:52:15 -05:00
|
|
|
if (global.screen.n_workspaces == 1)
|
|
|
|
return;
|
|
|
|
|
2010-03-18 14:53:58 -04:00
|
|
|
if (this._workspaceSwitcherPopup == null)
|
2010-02-12 17:52:15 -05:00
|
|
|
this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
|
|
|
|
|
2011-01-30 18:21:31 -05:00
|
|
|
if (binding == 'switch_to_workspace_up')
|
|
|
|
this.actionMoveWorkspaceUp();
|
|
|
|
else if (binding == 'switch_to_workspace_down')
|
|
|
|
this.actionMoveWorkspaceDown();
|
|
|
|
// left/right would effectively act as synonyms for up/down if we enabled them;
|
|
|
|
// but that could be considered confusing.
|
|
|
|
// else if (binding == 'switch_to_workspace_left')
|
|
|
|
// this.actionMoveWorkspaceLeft();
|
|
|
|
// else if (binding == 'switch_to_workspace_right')
|
|
|
|
// this.actionMoveWorkspaceRight();
|
2010-03-16 22:08:52 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
actionMoveWorkspaceLeft: function() {
|
2010-11-12 10:22:05 -05:00
|
|
|
let rtl = (St.Widget.get_default_direction() == St.TextDirection.RTL);
|
2010-03-16 22:08:52 -04:00
|
|
|
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
|
2010-11-12 10:22:05 -05:00
|
|
|
let indexToActivate = activeWorkspaceIndex;
|
|
|
|
if (rtl && activeWorkspaceIndex < global.screen.n_workspaces - 1)
|
|
|
|
indexToActivate++;
|
|
|
|
else if (!rtl && activeWorkspaceIndex > 0)
|
|
|
|
indexToActivate--;
|
|
|
|
|
|
|
|
if (indexToActivate != activeWorkspaceIndex)
|
|
|
|
global.screen.get_workspace_by_index(indexToActivate).activate(global.get_current_time());
|
|
|
|
|
|
|
|
if (!Main.overview.visible)
|
2011-02-09 10:00:29 -05:00
|
|
|
this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.UP, indexToActivate);
|
2010-03-16 22:08:52 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
actionMoveWorkspaceRight: function() {
|
2010-11-12 10:22:05 -05:00
|
|
|
let rtl = (St.Widget.get_default_direction() == St.TextDirection.RTL);
|
2010-03-16 22:08:52 -04:00
|
|
|
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
|
2010-11-12 10:22:05 -05:00
|
|
|
let indexToActivate = activeWorkspaceIndex;
|
|
|
|
if (rtl && activeWorkspaceIndex > 0)
|
|
|
|
indexToActivate--;
|
|
|
|
else if (!rtl && activeWorkspaceIndex < global.screen.n_workspaces - 1)
|
|
|
|
indexToActivate++;
|
|
|
|
|
|
|
|
if (indexToActivate != activeWorkspaceIndex)
|
|
|
|
global.screen.get_workspace_by_index(indexToActivate).activate(global.get_current_time());
|
|
|
|
|
2011-01-30 18:21:31 -05:00
|
|
|
if (!Main.overview.visible)
|
2011-02-09 10:00:29 -05:00
|
|
|
this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.DOWN, indexToActivate);
|
2011-01-30 18:21:31 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
actionMoveWorkspaceUp: function() {
|
|
|
|
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
|
|
|
|
let indexToActivate = activeWorkspaceIndex;
|
|
|
|
if (activeWorkspaceIndex > 0)
|
|
|
|
indexToActivate--;
|
|
|
|
|
|
|
|
if (indexToActivate != activeWorkspaceIndex)
|
|
|
|
global.screen.get_workspace_by_index(indexToActivate).activate(global.get_current_time());
|
|
|
|
|
|
|
|
if (!Main.overview.visible)
|
2011-02-09 10:00:29 -05:00
|
|
|
this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.UP, indexToActivate);
|
2011-01-30 18:21:31 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
actionMoveWorkspaceDown: function() {
|
|
|
|
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
|
|
|
|
let indexToActivate = activeWorkspaceIndex;
|
|
|
|
if (activeWorkspaceIndex < global.screen.n_workspaces - 1)
|
|
|
|
indexToActivate++;
|
|
|
|
|
|
|
|
if (indexToActivate != activeWorkspaceIndex)
|
|
|
|
global.screen.get_workspace_by_index(indexToActivate).activate(global.get_current_time());
|
|
|
|
|
2010-11-12 10:22:05 -05:00
|
|
|
if (!Main.overview.visible)
|
2011-02-09 10:00:29 -05:00
|
|
|
this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.DOWN, indexToActivate);
|
2009-09-15 11:11:32 -04:00
|
|
|
}
|
2008-11-21 09:02:09 -05:00
|
|
|
};
|