2008-12-01 19:51:43 +00:00
|
|
|
/* -*- mode: js2; js2-basic-offset: 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;
|
2008-11-21 21:34:10 +00:00
|
|
|
const Meta = imports.gi.Meta;
|
2010-02-10 22:26:24 +00:00
|
|
|
const St = imports.gi.St;
|
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;
|
2009-02-10 16:12:58 +00:00
|
|
|
const Tweener = imports.ui.tweener;
|
2008-11-21 14:02:09 +00:00
|
|
|
|
2008-12-29 04:44:03 +00:00
|
|
|
const WINDOW_ANIMATION_TIME = 0.25;
|
2010-09-11 01:30:50 +00:00
|
|
|
const DIM_TIME = 0.500;
|
|
|
|
const UNDIM_TIME = 0.250;
|
|
|
|
|
|
|
|
var dimShader = undefined;
|
|
|
|
|
|
|
|
function getDimShader() {
|
|
|
|
if (dimShader === null)
|
|
|
|
return null;
|
|
|
|
if (!dimShader) {
|
|
|
|
let [success, source, length] = GLib.file_get_contents(global.datadir +
|
|
|
|
'/shaders/dim-window.glsl');
|
|
|
|
try {
|
|
|
|
let shader = new Clutter.Shader();
|
|
|
|
shader.set_fragment_source(source, -1);
|
|
|
|
shader.compile();
|
|
|
|
|
|
|
|
dimShader = shader;
|
|
|
|
} catch (e) {
|
|
|
|
log(e.message);
|
|
|
|
dimShader = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dimShader;
|
|
|
|
}
|
|
|
|
|
|
|
|
function WindowDimmer(actor) {
|
|
|
|
this._init(actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
WindowDimmer.prototype = {
|
|
|
|
_init: function(actor) {
|
|
|
|
this.actor = actor;
|
|
|
|
},
|
|
|
|
|
|
|
|
set dimFraction(fraction) {
|
|
|
|
this._dimFraction = fraction;
|
|
|
|
let shader = getDimShader();
|
|
|
|
if (!Meta.prefs_get_attach_modal_dialogs() || !shader) {
|
|
|
|
this.actor.set_shader(null);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fraction > 0.01) {
|
|
|
|
this.actor.set_shader(shader);
|
|
|
|
this.actor.set_shader_param_float('height', this.actor.get_height());
|
|
|
|
this.actor.set_shader_param_float('fraction', fraction);
|
|
|
|
} else
|
|
|
|
this.actor.set_shader(null);
|
|
|
|
},
|
|
|
|
|
|
|
|
get dimFraction() {
|
|
|
|
return this._dimFraction;
|
|
|
|
},
|
|
|
|
|
|
|
|
_dimFraction: 0.0
|
|
|
|
};
|
|
|
|
|
|
|
|
function getWindowDimmer(texture) {
|
|
|
|
if (!texture._windowDimmer)
|
|
|
|
texture._windowDimmer = new WindowDimmer(texture);
|
|
|
|
|
|
|
|
return texture._windowDimmer;
|
|
|
|
}
|
2008-11-21 21:34:10 +00:00
|
|
|
|
2008-11-21 15:10:11 +00:00
|
|
|
function WindowManager() {
|
|
|
|
this._init();
|
2008-11-21 14:02:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WindowManager.prototype = {
|
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
|
|
|
|
2010-03-16 02:06:58 +00:00
|
|
|
this._keyBindingHandlers = [];
|
2008-12-29 04:44:03 +00:00
|
|
|
this._minimizing = [];
|
|
|
|
this._maximizing = [];
|
|
|
|
this._unmaximizing = [];
|
|
|
|
this._mapping = [];
|
|
|
|
this._destroying = [];
|
2008-11-21 21:34:10 +00:00
|
|
|
|
2010-09-12 09:39:52 +00:00
|
|
|
this._dimmedWindows = [];
|
|
|
|
|
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._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-16 02:06:58 +00: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 22:52:15 +00:00
|
|
|
|
|
|
|
this._workspaceSwitcherPopup = null;
|
2010-03-16 02:06:58 +00: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));
|
2010-09-12 09:39:52 +00:00
|
|
|
|
|
|
|
Main.overview.connect('showing', Lang.bind(this, function() {
|
|
|
|
for (let i = 0; i < this._dimmedWindows.length; i++)
|
|
|
|
this._undimParentWindow(this._dimmedWindows[i], true);
|
|
|
|
}));
|
|
|
|
Main.overview.connect('hiding', Lang.bind(this, function() {
|
|
|
|
for (let i = 0; i < this._dimmedWindows.length; i++)
|
|
|
|
this._dimParentWindow(this._dimmedWindows[i], true);
|
|
|
|
}));
|
2010-03-16 02:06:58 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setKeybindingHandler: function(keybinding, handler){
|
|
|
|
if (this._keyBindingHandlers[keybinding])
|
|
|
|
this._shellwm.disconnect(this._keyBindingHandlers[keybinding]);
|
|
|
|
else
|
|
|
|
this._shellwm.takeover_keybinding(keybinding);
|
2010-02-12 22:52:15 +00:00
|
|
|
|
2010-03-16 02:06:58 +00:00
|
|
|
this._keyBindingHandlers[keybinding] =
|
|
|
|
this._shellwm.connect('keybinding::' + keybinding, handler);
|
2008-12-29 04:44:03 +00:00
|
|
|
},
|
|
|
|
|
2009-02-03 18:25:34 +00:00
|
|
|
_shouldAnimate : function(actor) {
|
2009-08-11 11:46:10 +00:00
|
|
|
if (Main.overview.visible)
|
2009-02-03 18:25:34 +00:00
|
|
|
return false;
|
|
|
|
if (actor && (actor.get_window_type() != Meta.CompWindowType.NORMAL))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
},
|
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) {
|
2009-02-03 18:25:34 +00:00
|
|
|
if (!this._shouldAnimate(actor)) {
|
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);
|
|
|
|
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 12:50:11 +00:00
|
|
|
|
|
|
|
let primary = global.get_primary_monitor();
|
2010-02-10 22:26:24 +00:00
|
|
|
let xDest = primary.x;
|
|
|
|
if (St.Widget.get_default_direction() == St.TextDirection.RTL)
|
|
|
|
xDest += primary.width;
|
2010-02-05 12:50:11 +00:00
|
|
|
|
2008-12-29 04:44:03 +00:00
|
|
|
Tweener.addTween(actor,
|
|
|
|
{ scale_x: 0.0,
|
|
|
|
scale_y: 0.0,
|
2010-02-10 22:26:24 +00:00
|
|
|
x: xDest,
|
2010-02-05 12:50:11 +00:00
|
|
|
y: 0,
|
2008-12-29 04:44:03 +00:00
|
|
|
time: 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
|
|
|
});
|
|
|
|
},
|
|
|
|
|
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);
|
|
|
|
actor.move_anchor_point_from_gravity(Clutter.Gravity.NORTH_WEST);
|
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
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_maximizeWindow : function(shellwm, actor, targetX, targetY, targetWidth, targetHeight) {
|
|
|
|
shellwm.completed_maximize(actor);
|
2008-12-29 04:44:03 +00:00
|
|
|
},
|
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_maximizeWindowDone : function(shellwm, actor) {
|
2009-02-06 00:57:54 +00:00
|
|
|
},
|
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_maximizeWindowOverwrite : function(shellwm, actor) {
|
2008-12-29 04:44:03 +00:00
|
|
|
},
|
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_unmaximizeWindow : function(shellwm, actor, targetX, targetY, targetWidth, targetHeight) {
|
|
|
|
shellwm.completed_unmaximize(actor);
|
2008-12-29 04:44:03 +00:00
|
|
|
},
|
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_unmaximizeWindowDone : function(shellwm, actor) {
|
2008-12-29 04:44:03 +00:00
|
|
|
},
|
|
|
|
|
2010-09-11 01:30:50 +00:00
|
|
|
_parentHasOtherAttachedDialog: function(parent, self) {
|
|
|
|
var count = 0;
|
|
|
|
parent.foreach_transient(function(win) {
|
|
|
|
if (win.get_window_type() == Meta.CompWindowType.MODAL_DIALOG && win != self)
|
|
|
|
count++;
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
return count != 0;
|
|
|
|
},
|
|
|
|
|
2010-09-12 09:39:52 +00:00
|
|
|
_dimParentWindow: function(actor, animate) {
|
2010-09-11 01:30:50 +00:00
|
|
|
let meta = actor.get_meta_window();
|
|
|
|
let parent = meta.get_transient_for();
|
|
|
|
if (!parent)
|
|
|
|
return;
|
|
|
|
let parentActor = parent.get_compositor_private();
|
2010-09-12 09:39:52 +00:00
|
|
|
if (!parentActor || this._parentHasOtherAttachedDialog(parent, meta))
|
2010-09-11 01:30:50 +00:00
|
|
|
return;
|
2010-09-12 09:39:52 +00:00
|
|
|
let texture = parentActor.get_texture();
|
|
|
|
if (animate)
|
2010-09-11 01:30:50 +00:00
|
|
|
Tweener.addTween(getWindowDimmer(texture),
|
|
|
|
{ dimFraction: 1.0,
|
|
|
|
time: DIM_TIME,
|
|
|
|
transition: 'linear'
|
|
|
|
});
|
2010-09-12 09:39:52 +00:00
|
|
|
else
|
|
|
|
getWindowDimmer(texture).dimFraction = 1.0;
|
2010-09-11 01:30:50 +00:00
|
|
|
},
|
|
|
|
|
2010-09-12 09:39:52 +00:00
|
|
|
_undimParentWindow: function(actor, animate) {
|
2010-09-11 01:30:50 +00:00
|
|
|
let meta = actor.get_meta_window();
|
|
|
|
let parent = meta.get_transient_for();
|
|
|
|
if (!parent)
|
|
|
|
return;
|
|
|
|
let parentActor = parent.get_compositor_private();
|
2010-09-12 09:39:52 +00:00
|
|
|
if (!parentActor || this._parentHasOtherAttachedDialog(parent, meta))
|
2010-09-11 01:30:50 +00:00
|
|
|
return;
|
2010-09-12 09:39:52 +00:00
|
|
|
let texture = parentActor.get_texture();
|
|
|
|
if (animate)
|
2010-09-11 01:30:50 +00:00
|
|
|
Tweener.addTween(getWindowDimmer(texture),
|
|
|
|
{ dimFraction: 0.0,
|
|
|
|
time: UNDIM_TIME,
|
|
|
|
transition: 'linear'
|
|
|
|
});
|
2010-09-12 09:39:52 +00:00
|
|
|
else
|
|
|
|
getWindowDimmer(texture).dimFraction = 0.0;
|
2010-09-11 01:30:50 +00:00
|
|
|
},
|
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_mapWindow : function(shellwm, actor) {
|
2010-09-12 09:39:52 +00:00
|
|
|
if (actor.get_window_type() == Meta.CompWindowType.MODAL_DIALOG
|
2010-09-11 01:30:50 +00:00
|
|
|
&& Meta.prefs_get_attach_modal_dialogs()
|
|
|
|
&& actor.get_meta_window().get_transient_for()) {
|
2010-09-12 09:39:52 +00:00
|
|
|
this._dimmedWindows.push(actor);
|
|
|
|
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]
|
|
|
|
});
|
|
|
|
this._dimParentWindow(actor, true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
shellwm.completed_map(actor);
|
2010-09-11 01:30:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-02-03 18:25:34 +00:00
|
|
|
if (!this._shouldAnimate(actor)) {
|
2009-09-15 17:09:51 +00:00
|
|
|
shellwm.completed_map(actor);
|
2008-12-29 04:44:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-02 17:44:05 +00:00
|
|
|
actor.opacity = 0;
|
2008-12-29 04:44:03 +00:00
|
|
|
actor.show();
|
2010-04-02 18:30:10 +00:00
|
|
|
|
|
|
|
/* Fade window in */
|
2008-12-29 04:44:03 +00:00
|
|
|
this._mapping.push(actor);
|
|
|
|
Tweener.addTween(actor,
|
2010-04-02 17:44:05 +00:00
|
|
|
{ opacity: 255,
|
2008-12-29 04:44:03 +00:00
|
|
|
time: WINDOW_ANIMATION_TIME,
|
2010-05-13 19:46:04 +00:00
|
|
|
transition: 'easeOutQuad',
|
2008-12-29 04:44:03 +00:00
|
|
|
onComplete: this._mapWindowDone,
|
|
|
|
onCompleteScope: this,
|
2009-09-15 17:09:51 +00:00
|
|
|
onCompleteParams: [shellwm, actor],
|
2009-02-06 00:57:54 +00:00
|
|
|
onOverwrite: this._mapWindowOverwrite,
|
|
|
|
onOverwriteScope: this,
|
2009-09-15 17:09:51 +00:00
|
|
|
onOverwriteParams: [shellwm, actor]
|
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;
|
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-11 01:30:50 +00:00
|
|
|
_destroyWindowOverwrite : function(shellwm, actor) {
|
|
|
|
if (this._removeEffect(this._mapping, actor)) {
|
|
|
|
shellwm.completed_destroy(actor);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_destroyWindow : function(shellwm, actor) {
|
2010-09-12 09:39:52 +00:00
|
|
|
while (actor.get_window_type() == Meta.CompWindowType.MODAL_DIALOG
|
2010-09-11 01:30:50 +00:00
|
|
|
&& actor.get_meta_window().get_transient_for()) {
|
2010-09-12 09:39:52 +00:00
|
|
|
if (!Main.overview.visible)
|
|
|
|
this._undimParentWindow(actor, true);
|
|
|
|
this._dimmedWindows = this._dimmedWindows.filter(function(win) {
|
|
|
|
return win != actor;
|
|
|
|
});
|
|
|
|
if (!Meta.prefs_get_attach_modal_dialogs()
|
|
|
|
|| !this._shouldAnimate())
|
2010-09-11 01:30:50 +00:00
|
|
|
break;
|
|
|
|
actor.set_scale(1.0, 1.0);
|
|
|
|
actor.show();
|
|
|
|
this._mapping.push(actor);
|
|
|
|
|
|
|
|
Tweener.addTween(actor,
|
|
|
|
{ scale_y: 0,
|
|
|
|
time: WINDOW_ANIMATION_TIME,
|
|
|
|
transition: "easeOutQuad",
|
|
|
|
onComplete: this._destroyWindowDone,
|
|
|
|
onCompleteScope: this,
|
|
|
|
onCompleteParams: [shellwm, actor],
|
|
|
|
onOverwrite: this._destroyWindowOverwrite,
|
|
|
|
onOverwriteScope: this,
|
|
|
|
onOverwriteParams: [shellwm, actor]
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
2009-09-26 21:32:22 +00:00
|
|
|
shellwm.completed_destroy(actor);
|
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-11 01:30:50 +00:00
|
|
|
if (actor && actor.get_window_type() == Meta.CompWindowType.MODAL_DIALOG &&
|
|
|
|
actor.get_meta_window().get_transient_for()) {
|
|
|
|
if (this._removeEffect(this._mapping, actor)) {
|
|
|
|
shellwm.completed_destroy(actor);
|
|
|
|
}
|
|
|
|
}
|
2008-12-29 04:44:03 +00:00
|
|
|
},
|
|
|
|
|
2009-09-15 17:09:51 +00:00
|
|
|
_switchWorkspace : function(shellwm, from, to, direction) {
|
2009-02-03 18:25:34 +00:00
|
|
|
if (!this._shouldAnimate()) {
|
2009-09-15 17:09:51 +00:00
|
|
|
shellwm.completed_switch_workspace();
|
2008-12-04 15:16:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-06-16 21:28:57 +00:00
|
|
|
let windows = global.get_windows();
|
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)
|
2009-09-11 21:23:23 +00:00
|
|
|
yDest = global.screen_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)
|
2009-09-11 21:23:23 +00:00
|
|
|
yDest = -global.screen_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;
|
|
|
|
switchData.inGroup = new Clutter.Group();
|
|
|
|
switchData.outGroup = new Clutter.Group();
|
|
|
|
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);
|
|
|
|
|
|
|
|
for (let i = 0; i < windows.length; i++) {
|
|
|
|
let window = windows[i];
|
2009-05-11 17:06:42 +00:00
|
|
|
|
|
|
|
if (!window.meta_window.showing_on_its_workspace())
|
|
|
|
continue;
|
|
|
|
|
2008-12-01 19:51:43 +00: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 21:34:10 +00:00
|
|
|
}
|
|
|
|
|
2008-12-01 19:51:43 +00:00
|
|
|
switchData.inGroup.set_position(-xDest, -yDest);
|
|
|
|
switchData.inGroup.raise_top();
|
|
|
|
|
|
|
|
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];
|
|
|
|
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 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
|
|
|
},
|
|
|
|
|
2009-09-15 15:11:32 +00:00
|
|
|
_startAppSwitcher : function(shellwm, binding, window, backwards) {
|
2010-02-12 22:52:15 +00:00
|
|
|
/* prevent a corner case where both popups show up at once */
|
|
|
|
if (this._workspaceSwitcherPopup != null)
|
|
|
|
this._workspaceSwitcherPopup.actor.hide();
|
|
|
|
|
2009-09-15 15:11:32 +00:00
|
|
|
let tabPopup = new AltTab.AltTabPopup();
|
2008-11-21 21:34:10 +00:00
|
|
|
|
2009-10-01 09:23:00 +00:00
|
|
|
if (!tabPopup.show(backwards))
|
2009-09-15 15:11:32 +00:00
|
|
|
tabPopup.destroy();
|
2010-02-12 22:52:15 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_showWorkspaceSwitcher : function(shellwm, binding, window, backwards) {
|
|
|
|
/* We don't support this kind of layout */
|
2010-05-13 19:46:04 +00:00
|
|
|
if (binding == 'switch_to_workspace_up' || binding == 'switch_to_workspace_down')
|
2010-02-12 22:52:15 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (global.screen.n_workspaces == 1)
|
|
|
|
return;
|
|
|
|
|
2010-03-18 18:53:58 +00:00
|
|
|
if (this._workspaceSwitcherPopup == null)
|
2010-02-12 22:52:15 +00:00
|
|
|
this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
|
|
|
|
|
2010-05-13 19:46:04 +00:00
|
|
|
if (binding == 'switch_to_workspace_left') {
|
2010-03-17 02:08:52 +00:00
|
|
|
this.actionMoveWorkspaceLeft();
|
2010-02-12 22:52:15 +00:00
|
|
|
}
|
|
|
|
|
2010-05-13 19:46:04 +00:00
|
|
|
if (binding == 'switch_to_workspace_right') {
|
2010-03-17 02:08:52 +00:00
|
|
|
this.actionMoveWorkspaceRight();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
actionMoveWorkspaceLeft: function() {
|
|
|
|
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
|
|
|
|
if (activeWorkspaceIndex > 0) {
|
|
|
|
global.screen.get_workspace_by_index(activeWorkspaceIndex - 1).activate(global.get_current_time());
|
2010-03-18 18:53:58 +00:00
|
|
|
if (!Main.overview.visible)
|
2010-03-17 02:08:52 +00:00
|
|
|
this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.LEFT, activeWorkspaceIndex - 1);
|
2010-03-18 18:53:58 +00:00
|
|
|
} else if (!Main.overview.visible) {
|
2010-03-17 02:08:52 +00:00
|
|
|
this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.LEFT, activeWorkspaceIndex);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
actionMoveWorkspaceRight: function() {
|
|
|
|
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
|
|
|
|
if (activeWorkspaceIndex < global.screen.n_workspaces - 1) {
|
|
|
|
global.screen.get_workspace_by_index(activeWorkspaceIndex + 1).activate(global.get_current_time());
|
2010-03-18 18:53:58 +00:00
|
|
|
if (!Main.overview.visible)
|
2010-02-12 22:52:15 +00:00
|
|
|
this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.RIGHT, activeWorkspaceIndex + 1);
|
2010-03-18 18:53:58 +00:00
|
|
|
} else if (!Main.overview.visible) {
|
2010-03-17 02:08:52 +00:00
|
|
|
this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.RIGHT, activeWorkspaceIndex);
|
2010-02-12 22:52:15 +00:00
|
|
|
}
|
2009-09-15 15:11:32 +00:00
|
|
|
}
|
2008-11-21 14:02:09 +00:00
|
|
|
};
|