2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2008-12-02 11:15:00 -05:00
|
|
|
|
|
|
|
const Clutter = imports.gi.Clutter;
|
2008-12-22 17:06:47 -05:00
|
|
|
const Lang = imports.lang;
|
2009-02-04 09:50:50 -05:00
|
|
|
const Mainloop = imports.mainloop;
|
2009-02-02 18:02:16 -05:00
|
|
|
const Meta = imports.gi.Meta;
|
2009-01-23 14:21:20 -05:00
|
|
|
const Pango = imports.gi.Pango;
|
2009-02-02 18:02:16 -05:00
|
|
|
const Shell = imports.gi.Shell;
|
2009-11-11 19:26:52 -05:00
|
|
|
const St = imports.gi.St;
|
2009-01-23 14:21:20 -05:00
|
|
|
const Signals = imports.signals;
|
2008-12-02 11:15:00 -05:00
|
|
|
|
2009-02-10 11:15:59 -05:00
|
|
|
const DND = imports.ui.dnd;
|
2009-09-22 15:24:14 -04:00
|
|
|
const Lightbox = imports.ui.lightbox;
|
2008-12-02 11:15:00 -05:00
|
|
|
const Main = imports.ui.main;
|
2009-08-11 07:46:10 -04:00
|
|
|
const Overview = imports.ui.overview;
|
2008-12-02 11:15:00 -05:00
|
|
|
const Panel = imports.ui.panel;
|
2009-02-10 11:12:58 -05:00
|
|
|
const Tweener = imports.ui.tweener;
|
2008-12-02 11:15:00 -05:00
|
|
|
|
2009-01-19 18:06:59 -05:00
|
|
|
const FOCUS_ANIMATION_TIME = 0.15;
|
2008-12-02 11:15:00 -05:00
|
|
|
|
2010-03-09 17:31:06 -05:00
|
|
|
const WINDOW_DND_SIZE = 256;
|
|
|
|
|
2009-09-04 15:25:17 -04:00
|
|
|
const SCROLL_SCALE_AMOUNT = 100 / 5;
|
|
|
|
|
2012-01-15 09:30:59 -05:00
|
|
|
const WINDOW_CLONE_MAXIMUM_SCALE = 0.7;
|
|
|
|
|
2010-06-10 11:22:23 -04:00
|
|
|
const LIGHTBOX_FADE_TIME = 0.1;
|
|
|
|
const CLOSE_BUTTON_FADE_TIME = 0.1;
|
2009-09-04 15:25:17 -04:00
|
|
|
|
2010-03-09 17:31:06 -05:00
|
|
|
const DRAGGING_WINDOW_OPACITY = 100;
|
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
// When calculating a layout, we calculate the scale of windows and the percent
|
|
|
|
// of the available area the new layout uses. If the values for the new layout,
|
|
|
|
// when weighted with the values as below, are worse than the previous layout's,
|
|
|
|
// we stop looking for a new layout and use the previous layout.
|
|
|
|
// Otherwise, we keep looking for a new layout.
|
|
|
|
const LAYOUT_SCALE_WEIGHT = 1;
|
|
|
|
const LAYOUT_SPACE_WEIGHT = 0.1;
|
2009-09-04 15:25:17 -04:00
|
|
|
|
|
|
|
function _interpolate(start, end, step) {
|
|
|
|
return start + (end - start) * step;
|
|
|
|
}
|
|
|
|
|
|
|
|
function _clamp(value, min, max) {
|
|
|
|
return Math.max(min, Math.min(max, value));
|
|
|
|
}
|
|
|
|
|
2008-12-04 10:16:16 -05:00
|
|
|
|
2011-11-20 12:56:27 -05:00
|
|
|
const ScaledPoint = new Lang.Class({
|
|
|
|
Name: 'ScaledPoint',
|
|
|
|
|
|
|
|
_init: function(x, y, scaleX, scaleY) {
|
|
|
|
[this.x, this.y, this.scaleX, this.scaleY] = arguments;
|
|
|
|
},
|
2009-09-04 15:25:17 -04:00
|
|
|
|
|
|
|
getPosition : function() {
|
|
|
|
return [this.x, this.y];
|
|
|
|
},
|
|
|
|
|
|
|
|
getScale : function() {
|
|
|
|
return [this.scaleX, this.scaleY];
|
|
|
|
},
|
|
|
|
|
|
|
|
setPosition : function(x, y) {
|
|
|
|
[this.x, this.y] = arguments;
|
|
|
|
},
|
|
|
|
|
|
|
|
setScale : function(scaleX, scaleY) {
|
|
|
|
[this.scaleX, this.scaleY] = arguments;
|
|
|
|
},
|
|
|
|
|
|
|
|
interpPosition : function(other, step) {
|
|
|
|
return [_interpolate(this.x, other.x, step),
|
|
|
|
_interpolate(this.y, other.y, step)];
|
|
|
|
},
|
|
|
|
|
|
|
|
interpScale : function(other, step) {
|
|
|
|
return [_interpolate(this.scaleX, other.scaleX, step),
|
|
|
|
_interpolate(this.scaleY, other.scaleY, step)];
|
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2009-09-04 15:25:17 -04:00
|
|
|
|
|
|
|
|
2011-11-20 12:56:27 -05:00
|
|
|
const WindowClone = new Lang.Class({
|
|
|
|
Name: 'WindowClone',
|
2009-01-29 16:21:50 -05:00
|
|
|
|
2011-11-25 18:02:13 -05:00
|
|
|
_init : function(realWindow, workspace) {
|
2009-01-29 16:21:50 -05:00
|
|
|
this.realWindow = realWindow;
|
2009-02-04 09:50:50 -05:00
|
|
|
this.metaWindow = realWindow.meta_window;
|
2009-09-09 21:14:31 -04:00
|
|
|
this.metaWindow._delegate = this;
|
2011-11-25 18:02:13 -05:00
|
|
|
this._workspace = workspace;
|
2011-08-29 12:25:11 -04:00
|
|
|
|
|
|
|
let [borderX, borderY] = this._getInvisibleBorderPadding();
|
|
|
|
this._windowClone = new Clutter.Clone({ source: realWindow.get_texture(),
|
|
|
|
x: -borderX,
|
|
|
|
y: -borderY });
|
2011-09-09 18:47:21 -04:00
|
|
|
// We expect this.actor to be used for all interaction rather than
|
|
|
|
// this._windowClone; as the former is reactive and the latter
|
|
|
|
// is not, this just works for most cases. However, for DND all
|
|
|
|
// actors are picked, so DND operations would operate on the clone.
|
|
|
|
// To avoid this, we hide it from pick.
|
|
|
|
Shell.util_set_hidden_from_pick(this._windowClone, true);
|
2011-08-29 12:25:11 -04:00
|
|
|
|
|
|
|
this.origX = realWindow.x + borderX;
|
|
|
|
this.origY = realWindow.y + borderY;
|
|
|
|
|
|
|
|
let outerRect = realWindow.meta_window.get_outer_rect();
|
|
|
|
|
|
|
|
// The MetaShapedTexture that we clone has a size that includes
|
|
|
|
// the invisible border; this is inconvenient; rather than trying
|
|
|
|
// to compensate all over the place we insert a ClutterGroup into
|
|
|
|
// the hierarchy that is sized to only the visible portion.
|
|
|
|
this.actor = new Clutter.Group({ reactive: true,
|
|
|
|
x: this.origX,
|
|
|
|
y: this.origY,
|
|
|
|
width: outerRect.width,
|
|
|
|
height: outerRect.height });
|
|
|
|
|
|
|
|
this.actor.add_actor(this._windowClone);
|
|
|
|
|
|
|
|
this.actor._delegate = this;
|
2009-01-29 16:21:50 -05:00
|
|
|
|
2012-12-16 18:40:48 -05:00
|
|
|
this._slot = [0, 0, 0, 0];
|
|
|
|
this._dragSlot = [0, 0, 0, 0];
|
2009-09-28 19:48:03 -04:00
|
|
|
this._stackAbove = null;
|
|
|
|
|
2011-08-29 12:25:11 -04:00
|
|
|
this._sizeChangedId = this.realWindow.connect('size-changed',
|
|
|
|
Lang.bind(this, this._onRealWindowSizeChanged));
|
2011-02-03 13:25:59 -05:00
|
|
|
this._realWindowDestroyId = this.realWindow.connect('destroy',
|
|
|
|
Lang.bind(this, this._disconnectRealWindowSignals));
|
2011-01-30 17:03:12 -05:00
|
|
|
|
2011-09-20 20:54:06 -04:00
|
|
|
let clickAction = new Clutter.ClickAction();
|
|
|
|
clickAction.connect('clicked', Lang.bind(this, this._onClicked));
|
|
|
|
clickAction.connect('long-press', Lang.bind(this, this._onLongPress));
|
|
|
|
|
|
|
|
this.actor.add_action(clickAction);
|
2009-02-10 11:15:59 -05:00
|
|
|
|
2009-09-04 15:25:17 -04:00
|
|
|
this.actor.connect('scroll-event',
|
|
|
|
Lang.bind(this, this._onScroll));
|
|
|
|
|
2010-02-07 09:25:16 -05:00
|
|
|
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
2009-01-29 16:21:50 -05:00
|
|
|
this.actor.connect('leave-event',
|
|
|
|
Lang.bind(this, this._onLeave));
|
2009-02-10 11:15:59 -05:00
|
|
|
|
2010-03-19 16:46:08 -04:00
|
|
|
this._draggable = DND.makeDraggable(this.actor,
|
2010-05-20 10:44:45 -04:00
|
|
|
{ restoreOnSuccess: true,
|
2011-09-20 20:54:06 -04:00
|
|
|
manualMode: true,
|
2010-05-20 10:44:45 -04:00
|
|
|
dragActorMaxSize: WINDOW_DND_SIZE,
|
2010-03-19 16:46:08 -04:00
|
|
|
dragActorOpacity: DRAGGING_WINDOW_OPACITY });
|
2009-02-10 11:15:59 -05:00
|
|
|
this._draggable.connect('drag-begin', Lang.bind(this, this._onDragBegin));
|
2011-03-08 08:44:47 -05:00
|
|
|
this._draggable.connect('drag-cancelled', Lang.bind(this, this._onDragCancelled));
|
2009-02-10 11:15:59 -05:00
|
|
|
this._draggable.connect('drag-end', Lang.bind(this, this._onDragEnd));
|
2010-03-19 16:46:08 -04:00
|
|
|
this.inDrag = false;
|
2009-09-28 19:48:03 -04:00
|
|
|
|
2010-03-21 14:33:52 -04:00
|
|
|
this._windowIsZooming = false;
|
2009-09-28 19:48:03 -04:00
|
|
|
this._zooming = false;
|
2010-02-15 17:11:09 -05:00
|
|
|
this._selected = false;
|
2009-01-29 16:21:50 -05:00
|
|
|
},
|
|
|
|
|
2012-12-16 18:40:48 -05:00
|
|
|
set slot(slot) {
|
|
|
|
this._slot = slot;
|
|
|
|
},
|
2012-10-19 12:37:29 -04:00
|
|
|
|
2012-12-16 18:40:48 -05:00
|
|
|
get slot() {
|
|
|
|
if (this.inDrag)
|
|
|
|
return this._dragSlot;
|
|
|
|
else
|
|
|
|
return this._slot;
|
2012-10-19 12:37:29 -04:00
|
|
|
},
|
|
|
|
|
2009-09-28 19:48:03 -04:00
|
|
|
setStackAbove: function (actor) {
|
|
|
|
this._stackAbove = actor;
|
2010-03-19 16:46:08 -04:00
|
|
|
if (this.inDrag || this._zooming)
|
2009-09-28 19:48:03 -04:00
|
|
|
// We'll fix up the stack after the drag/zooming
|
|
|
|
return;
|
2010-07-15 10:21:32 -04:00
|
|
|
if (this._stackAbove == null)
|
|
|
|
this.actor.lower_bottom();
|
|
|
|
else
|
|
|
|
this.actor.raise(this._stackAbove);
|
2009-09-28 19:48:03 -04:00
|
|
|
},
|
|
|
|
|
2009-01-29 16:21:50 -05:00
|
|
|
destroy: function () {
|
|
|
|
this.actor.destroy();
|
|
|
|
},
|
2009-02-10 11:15:59 -05:00
|
|
|
|
2010-02-15 17:11:09 -05:00
|
|
|
zoomFromOverview: function() {
|
|
|
|
if (this._zooming) {
|
|
|
|
// If the user clicked on the zoomed window, or we are
|
|
|
|
// returning there anyways, then we can zoom right to the
|
|
|
|
// window, but if we are going to some other window, then
|
|
|
|
// we need to cancel the zoom before animating, or it
|
|
|
|
// will look funny.
|
|
|
|
|
|
|
|
if (!this._selected &&
|
2011-07-13 12:34:31 -04:00
|
|
|
this.metaWindow != global.display.focus_window)
|
2010-02-15 17:11:09 -05:00
|
|
|
this._zoomEnd();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-02-03 13:25:59 -05:00
|
|
|
_disconnectRealWindowSignals: function() {
|
|
|
|
if (this._sizeChangedId > 0)
|
|
|
|
this.realWindow.disconnect(this._sizeChangedId);
|
2011-01-30 17:03:12 -05:00
|
|
|
this._sizeChangedId = 0;
|
|
|
|
|
2011-02-03 13:25:59 -05:00
|
|
|
if (this._realWindowDestroyId > 0)
|
|
|
|
this.realWindow.disconnect(this._realWindowDestroyId);
|
|
|
|
this._realWindowDestroyId = 0;
|
|
|
|
},
|
|
|
|
|
2011-08-29 12:25:11 -04:00
|
|
|
_getInvisibleBorderPadding: function() {
|
|
|
|
// We need to adjust the position of the actor because of the
|
|
|
|
// consequences of invisible borders -- in reality, the texture
|
|
|
|
// has an extra set of "padding" around it that we need to trim
|
|
|
|
// down.
|
|
|
|
|
|
|
|
// The outer rect paradoxically is the smaller rectangle,
|
|
|
|
// containing the positions of the visible frame. The input
|
|
|
|
// rect contains everything, including the invisible border
|
|
|
|
// padding.
|
|
|
|
let outerRect = this.metaWindow.get_outer_rect();
|
|
|
|
let inputRect = this.metaWindow.get_input_rect();
|
|
|
|
let [borderX, borderY] = [outerRect.x - inputRect.x,
|
|
|
|
outerRect.y - inputRect.y];
|
|
|
|
|
|
|
|
return [borderX, borderY];
|
|
|
|
},
|
|
|
|
|
|
|
|
_onRealWindowSizeChanged: function() {
|
|
|
|
let [borderX, borderY] = this._getInvisibleBorderPadding();
|
|
|
|
let outerRect = this.metaWindow.get_outer_rect();
|
|
|
|
this.actor.set_size(outerRect.width, outerRect.height);
|
|
|
|
this._windowClone.set_position(-borderX, -borderY);
|
|
|
|
this.emit('size-changed');
|
|
|
|
},
|
|
|
|
|
2011-02-03 13:25:59 -05:00
|
|
|
_onDestroy: function() {
|
|
|
|
this._disconnectRealWindowSignals();
|
|
|
|
|
2010-03-17 18:23:32 -04:00
|
|
|
this.metaWindow._delegate = null;
|
|
|
|
this.actor._delegate = null;
|
2010-02-07 09:25:16 -05:00
|
|
|
if (this._zoomLightbox)
|
|
|
|
this._zoomLightbox.destroy();
|
2010-03-17 18:23:32 -04:00
|
|
|
|
2010-03-19 16:46:08 -04:00
|
|
|
if (this.inDrag) {
|
2010-03-18 16:39:11 -04:00
|
|
|
this.emit('drag-end');
|
2010-03-19 16:46:08 -04:00
|
|
|
this.inDrag = false;
|
2010-03-18 16:39:11 -04:00
|
|
|
}
|
|
|
|
|
2010-03-17 18:23:32 -04:00
|
|
|
this.disconnectAll();
|
2010-02-07 09:25:16 -05:00
|
|
|
},
|
|
|
|
|
2009-01-29 16:21:50 -05:00
|
|
|
_onLeave: function (actor, event) {
|
2009-09-04 15:25:17 -04:00
|
|
|
if (this._zoomStep)
|
|
|
|
this._zoomEnd();
|
|
|
|
},
|
2009-01-29 16:21:50 -05:00
|
|
|
|
2009-09-04 15:25:17 -04:00
|
|
|
_onScroll : function (actor, event) {
|
|
|
|
let direction = event.get_scroll_direction();
|
2012-11-04 10:55:37 -05:00
|
|
|
let delta;
|
|
|
|
|
|
|
|
if (event.is_pointer_emulated())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (direction == Clutter.ScrollDirection.DOWN) {
|
|
|
|
delta = -SCROLL_SCALE_AMOUNT;
|
|
|
|
} else if (direction == Clutter.ScrollDirection.UP) {
|
|
|
|
delta = +SCROLL_SCALE_AMOUNT;
|
|
|
|
} else if (direction == Clutter.ScrollDirection.SMOOTH) {
|
|
|
|
let [dx, dy] = event.get_scroll_delta();
|
|
|
|
delta = -dy * 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (delta > 0) {
|
2009-09-04 15:25:17 -04:00
|
|
|
if (this._zoomStep == undefined)
|
|
|
|
this._zoomStart();
|
|
|
|
if (this._zoomStep < 100) {
|
2012-11-04 10:55:37 -05:00
|
|
|
this._zoomStep += delta;
|
|
|
|
this._zoomStep = Math.min(100, this._zoomStep);
|
2009-09-04 15:25:17 -04:00
|
|
|
this._zoomUpdate();
|
|
|
|
}
|
2012-11-04 10:55:37 -05:00
|
|
|
} else if (delta < 0) {
|
2009-09-04 15:25:17 -04:00
|
|
|
if (this._zoomStep > 0) {
|
2012-11-04 10:55:37 -05:00
|
|
|
this._zoomStep += delta;
|
2009-09-04 15:25:17 -04:00
|
|
|
this._zoomStep = Math.max(0, this._zoomStep);
|
|
|
|
this._zoomUpdate();
|
|
|
|
}
|
|
|
|
if (this._zoomStep <= 0.0)
|
|
|
|
this._zoomEnd();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_zoomUpdate : function () {
|
|
|
|
[this.actor.x, this.actor.y] = this._zoomGlobalOrig.interpPosition(this._zoomTarget, this._zoomStep / 100);
|
|
|
|
[this.actor.scale_x, this.actor.scale_y] = this._zoomGlobalOrig.interpScale(this._zoomTarget, this._zoomStep / 100);
|
|
|
|
|
|
|
|
let [width, height] = this.actor.get_transformed_size();
|
|
|
|
|
2013-01-27 23:17:53 -05:00
|
|
|
let availArea = this.metaWindow.get_work_area_current_monitor();
|
2011-03-09 09:59:58 -05:00
|
|
|
this.actor.x = _clamp(this.actor.x, availArea.x, availArea.x + availArea.width - width);
|
|
|
|
this.actor.y = _clamp(this.actor.y, availArea.y, availArea.y + availArea.height - height);
|
2009-09-04 15:25:17 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_zoomStart : function () {
|
2009-09-28 19:48:03 -04:00
|
|
|
this._zooming = true;
|
2009-11-11 19:26:52 -05:00
|
|
|
this.emit('zoom-start');
|
2009-09-28 19:48:03 -04:00
|
|
|
|
2010-03-17 10:36:57 -04:00
|
|
|
if (!this._zoomLightbox)
|
2011-05-11 17:41:05 -04:00
|
|
|
this._zoomLightbox = new Lightbox.Lightbox(Main.uiGroup,
|
2012-02-06 17:28:48 -05:00
|
|
|
{ fadeInTime: LIGHTBOX_FADE_TIME,
|
|
|
|
fadeOutTime: LIGHTBOX_FADE_TIME });
|
2010-03-17 10:36:57 -04:00
|
|
|
this._zoomLightbox.show();
|
2009-09-04 15:25:17 -04:00
|
|
|
|
|
|
|
this._zoomLocalOrig = new ScaledPoint(this.actor.x, this.actor.y, this.actor.scale_x, this.actor.scale_y);
|
|
|
|
this._zoomGlobalOrig = new ScaledPoint();
|
|
|
|
let parent = this._origParent = this.actor.get_parent();
|
2009-09-25 18:48:34 -04:00
|
|
|
let [width, height] = this.actor.get_transformed_size();
|
2009-09-04 15:25:17 -04:00
|
|
|
this._zoomGlobalOrig.setPosition.apply(this._zoomGlobalOrig, this.actor.get_transformed_position());
|
|
|
|
this._zoomGlobalOrig.setScale(width / this.actor.width, height / this.actor.height);
|
|
|
|
|
2011-05-11 17:41:05 -04:00
|
|
|
this.actor.reparent(Main.uiGroup);
|
2009-09-22 15:24:14 -04:00
|
|
|
this._zoomLightbox.highlight(this.actor);
|
2009-09-04 15:25:17 -04:00
|
|
|
|
|
|
|
[this.actor.x, this.actor.y] = this._zoomGlobalOrig.getPosition();
|
|
|
|
[this.actor.scale_x, this.actor.scale_y] = this._zoomGlobalOrig.getScale();
|
|
|
|
|
|
|
|
this.actor.raise_top();
|
|
|
|
|
|
|
|
this._zoomTarget = new ScaledPoint(0, 0, 1.0, 1.0);
|
|
|
|
this._zoomTarget.setPosition(this.actor.x - (this.actor.width - width) / 2, this.actor.y - (this.actor.height - height) / 2);
|
|
|
|
this._zoomStep = 0;
|
|
|
|
|
|
|
|
this._zoomUpdate();
|
|
|
|
},
|
|
|
|
|
|
|
|
_zoomEnd : function () {
|
2009-09-28 19:48:03 -04:00
|
|
|
this._zooming = false;
|
2009-11-11 19:26:52 -05:00
|
|
|
this.emit('zoom-end');
|
2009-09-28 19:48:03 -04:00
|
|
|
|
2009-09-04 15:25:17 -04:00
|
|
|
this.actor.reparent(this._origParent);
|
2010-07-15 10:21:32 -04:00
|
|
|
if (this._stackAbove == null)
|
|
|
|
this.actor.lower_bottom();
|
2010-02-07 09:25:16 -05:00
|
|
|
// If the workspace has been destroyed while we were reparented to
|
|
|
|
// the stage, _stackAbove will be unparented and we can't raise our
|
|
|
|
// actor above it - as we are bound to be destroyed anyway in that
|
|
|
|
// case, we can skip that step
|
2010-07-15 10:21:32 -04:00
|
|
|
else if (this._stackAbove.get_parent())
|
2010-02-07 09:25:16 -05:00
|
|
|
this.actor.raise(this._stackAbove);
|
2009-09-04 15:25:17 -04:00
|
|
|
|
|
|
|
[this.actor.x, this.actor.y] = this._zoomLocalOrig.getPosition();
|
|
|
|
[this.actor.scale_x, this.actor.scale_y] = this._zoomLocalOrig.getScale();
|
|
|
|
|
2010-03-17 10:36:57 -04:00
|
|
|
this._zoomLightbox.hide();
|
2009-09-04 15:25:17 -04:00
|
|
|
|
|
|
|
this._zoomLocalPosition = undefined;
|
|
|
|
this._zoomLocalScale = undefined;
|
|
|
|
this._zoomGlobalPosition = undefined;
|
|
|
|
this._zoomGlobalScale = undefined;
|
|
|
|
this._zoomTargetPosition = undefined;
|
2009-09-22 15:24:14 -04:00
|
|
|
this._zoomStep = undefined;
|
2009-01-29 16:21:50 -05:00
|
|
|
},
|
|
|
|
|
2011-09-20 20:54:06 -04:00
|
|
|
_onClicked: function(action, actor) {
|
2010-02-15 17:11:09 -05:00
|
|
|
this._selected = true;
|
2011-09-20 20:54:06 -04:00
|
|
|
this.emit('selected', global.get_current_time());
|
|
|
|
},
|
|
|
|
|
|
|
|
_onLongPress: function(action, actor, state) {
|
|
|
|
// Take advantage of the Clutter policy to consider
|
|
|
|
// a long-press canceled when the pointer movement
|
|
|
|
// exceeds dnd-drag-threshold to manually start the drag
|
|
|
|
if (state == Clutter.LongPressState.CANCEL) {
|
|
|
|
// A click cancels a long-press before any click handler is
|
|
|
|
// run - make sure to not start a drag in that case
|
|
|
|
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
if (this._selected)
|
|
|
|
return;
|
|
|
|
let [x, y] = action.get_coords();
|
2012-01-21 11:07:59 -05:00
|
|
|
action.release();
|
2011-09-20 20:54:06 -04:00
|
|
|
this._draggable.startDrag(x, y, global.get_current_time());
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
return true;
|
2009-01-29 16:21:50 -05:00
|
|
|
},
|
|
|
|
|
2009-02-10 11:15:59 -05:00
|
|
|
_onDragBegin : function (draggable, time) {
|
2011-05-11 17:43:25 -04:00
|
|
|
if (this._zooming)
|
|
|
|
this._zoomEnd();
|
|
|
|
|
2012-12-16 18:40:48 -05:00
|
|
|
this._dragSlot = this._slot;
|
2011-03-08 08:46:34 -05:00
|
|
|
[this.dragOrigX, this.dragOrigY] = this.actor.get_position();
|
|
|
|
this.dragOrigScale = this.actor.scale_x;
|
2010-03-19 16:46:08 -04:00
|
|
|
this.inDrag = true;
|
2009-07-23 17:36:41 -04:00
|
|
|
this.emit('drag-begin');
|
2009-01-29 16:21:50 -05:00
|
|
|
},
|
|
|
|
|
2011-06-07 17:15:33 -04:00
|
|
|
handleDragOver : function(source, actor, x, y, time) {
|
2011-11-25 18:02:13 -05:00
|
|
|
return this._workspace.handleDragOver(source, actor, x, y, time);
|
2011-06-07 17:15:33 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
acceptDrop : function(source, actor, x, y, time) {
|
2011-11-25 18:02:13 -05:00
|
|
|
this._workspace.acceptDrop(source, actor, x, y, time);
|
2011-06-07 17:15:33 -04:00
|
|
|
},
|
|
|
|
|
2011-03-08 08:44:47 -05:00
|
|
|
_onDragCancelled : function (draggable, time) {
|
|
|
|
this.emit('drag-cancelled');
|
|
|
|
},
|
|
|
|
|
2009-07-23 17:36:41 -04:00
|
|
|
_onDragEnd : function (draggable, time, snapback) {
|
2010-03-19 16:46:08 -04:00
|
|
|
this.inDrag = false;
|
2009-01-29 16:21:50 -05:00
|
|
|
|
2009-09-28 19:48:03 -04:00
|
|
|
// We may not have a parent if DnD completed successfully, in
|
|
|
|
// which case our clone will shortly be destroyed and replaced
|
|
|
|
// with a new one on the target workspace.
|
2010-07-15 10:21:32 -04:00
|
|
|
if (this.actor.get_parent() != null) {
|
|
|
|
if (this._stackAbove == null)
|
|
|
|
this.actor.lower_bottom();
|
|
|
|
else
|
|
|
|
this.actor.raise(this._stackAbove);
|
2010-01-05 22:53:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-15 10:21:32 -04:00
|
|
|
this.emit('drag-end');
|
2009-01-29 16:21:50 -05:00
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2010-07-15 10:21:32 -04:00
|
|
|
Signals.addSignalMethods(WindowClone.prototype);
|
2009-01-29 16:21:50 -05:00
|
|
|
|
|
|
|
|
2009-11-11 19:26:52 -05:00
|
|
|
/**
|
|
|
|
* @windowClone: Corresponding window clone
|
|
|
|
* @parentActor: The actor which will be the parent of all overlay items
|
|
|
|
* such as app icon and window caption
|
|
|
|
*/
|
2011-11-20 12:56:27 -05:00
|
|
|
const WindowOverlay = new Lang.Class({
|
|
|
|
Name: 'WindowOverlay',
|
2009-11-11 19:26:52 -05:00
|
|
|
|
|
|
|
_init : function(windowClone, parentActor) {
|
|
|
|
let metaWindow = windowClone.metaWindow;
|
|
|
|
|
2009-11-19 19:39:00 -05:00
|
|
|
this._windowClone = windowClone;
|
2009-11-11 19:26:52 -05:00
|
|
|
this._parentActor = parentActor;
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
this._hidden = false;
|
2009-11-11 19:26:52 -05:00
|
|
|
|
2012-10-27 12:18:54 -04:00
|
|
|
this.borderSize = 0;
|
|
|
|
this.border = new St.Bin({ style_class: 'window-clone-border' });
|
|
|
|
|
2010-05-13 15:46:04 -04:00
|
|
|
let title = new St.Label({ style_class: 'window-caption',
|
2010-01-21 21:33:48 -05:00
|
|
|
text: metaWindow.title });
|
2009-11-11 19:26:52 -05:00
|
|
|
title.clutter_text.ellipsize = Pango.EllipsizeMode.END;
|
|
|
|
title._spacing = 0;
|
|
|
|
|
2010-02-06 21:06:50 -05:00
|
|
|
this._updateCaptionId = metaWindow.connect('notify::title',
|
|
|
|
Lang.bind(this, function(w) {
|
|
|
|
this.title.text = w.title;
|
2012-12-16 18:40:48 -05:00
|
|
|
this.relayout(false);
|
2010-02-06 21:06:50 -05:00
|
|
|
}));
|
|
|
|
|
2010-05-13 15:46:04 -04:00
|
|
|
let button = new St.Button({ style_class: 'window-close' });
|
2009-11-11 19:26:52 -05:00
|
|
|
button._overlap = 0;
|
|
|
|
|
2010-02-17 23:15:10 -05:00
|
|
|
this._idleToggleCloseId = 0;
|
|
|
|
button.connect('clicked', Lang.bind(this, this._closeWindow));
|
|
|
|
|
2009-11-21 00:46:02 -05:00
|
|
|
windowClone.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
2009-11-11 19:26:52 -05:00
|
|
|
windowClone.actor.connect('enter-event',
|
|
|
|
Lang.bind(this, this._onEnter));
|
|
|
|
windowClone.actor.connect('leave-event',
|
|
|
|
Lang.bind(this, this._onLeave));
|
|
|
|
|
2009-11-21 00:46:02 -05:00
|
|
|
this._windowAddedId = 0;
|
2009-11-11 19:26:52 -05:00
|
|
|
windowClone.connect('zoom-start', Lang.bind(this, this.hide));
|
|
|
|
windowClone.connect('zoom-end', Lang.bind(this, this.show));
|
|
|
|
|
|
|
|
button.hide();
|
|
|
|
|
|
|
|
this.title = title;
|
|
|
|
this.closeButton = button;
|
|
|
|
|
|
|
|
parentActor.add_actor(this.title);
|
2012-10-27 12:18:54 -04:00
|
|
|
parentActor.add_actor(this.border);
|
2009-11-11 19:26:52 -05:00
|
|
|
parentActor.add_actor(this.closeButton);
|
2010-02-17 23:15:28 -05:00
|
|
|
title.connect('style-changed',
|
|
|
|
Lang.bind(this, this._onStyleChanged));
|
|
|
|
button.connect('style-changed',
|
|
|
|
Lang.bind(this, this._onStyleChanged));
|
2012-10-27 12:18:54 -04:00
|
|
|
this.border.connect('style-changed', Lang.bind(this, this._onStyleChanged));
|
2010-02-17 23:15:28 -05:00
|
|
|
// force a style change if we are already on a stage - otherwise
|
|
|
|
// the signal will be emitted normally when we are added
|
|
|
|
if (parentActor.get_stage())
|
|
|
|
this._onStyleChanged();
|
2009-11-11 19:26:52 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
hide: function() {
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
this._hidden = true;
|
2009-11-11 19:26:52 -05:00
|
|
|
this.title.hide();
|
2012-10-27 12:18:54 -04:00
|
|
|
|
2012-11-23 22:04:38 -05:00
|
|
|
this.hideCloseButton();
|
2009-11-11 19:26:52 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
show: function() {
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
this._hidden = false;
|
2012-10-27 12:18:54 -04:00
|
|
|
|
2009-11-11 19:26:52 -05:00
|
|
|
this.title.show();
|
2012-10-27 12:18:54 -04:00
|
|
|
if (this._windowClone.actor.has_pointer)
|
|
|
|
this._animateVisible();
|
2009-11-11 19:26:52 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
fadeIn: function() {
|
2011-12-04 15:40:40 -05:00
|
|
|
if (!this._hidden)
|
|
|
|
return;
|
|
|
|
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
this.show();
|
2009-11-11 19:26:52 -05:00
|
|
|
this.title.opacity = 0;
|
2010-01-21 21:33:48 -05:00
|
|
|
this._parentActor.raise_top();
|
2009-11-11 19:26:52 -05:00
|
|
|
Tweener.addTween(this.title,
|
2012-08-08 13:21:20 -04:00
|
|
|
{ opacity: 255,
|
|
|
|
time: CLOSE_BUTTON_FADE_TIME,
|
|
|
|
transition: 'easeOutQuad' });
|
2009-11-11 19:26:52 -05:00
|
|
|
},
|
|
|
|
|
2010-02-17 11:52:50 -05:00
|
|
|
chromeHeights: function () {
|
2012-10-27 12:18:54 -04:00
|
|
|
return [Math.max(this.borderSize, this.closeButton.height - this.closeButton._overlap),
|
2012-08-08 13:21:20 -04:00
|
|
|
this.title.height + this.title._spacing];
|
2009-11-11 19:26:52 -05:00
|
|
|
},
|
|
|
|
|
2012-10-27 12:18:54 -04:00
|
|
|
chromeWidths: function () {
|
2012-12-13 16:39:02 -05:00
|
|
|
return [this.borderSize,
|
|
|
|
Math.max(this.borderSize, this.closeButton.width - this.closeButton._overlap)];
|
2012-10-27 12:18:54 -04:00
|
|
|
},
|
|
|
|
|
2012-12-16 18:40:48 -05:00
|
|
|
relayout: function(animate) {
|
2009-11-11 19:26:52 -05:00
|
|
|
let button = this.closeButton;
|
|
|
|
let title = this.title;
|
2013-02-16 11:26:28 -05:00
|
|
|
let border = this.border;
|
|
|
|
|
|
|
|
Tweener.removeTweens(button);
|
|
|
|
Tweener.removeTweens(title);
|
|
|
|
Tweener.removeTweens(border);
|
|
|
|
|
|
|
|
let [cloneX, cloneY, cloneWidth, cloneHeight] = this._windowClone.slot;
|
2009-11-11 19:26:52 -05:00
|
|
|
|
2012-11-28 17:02:46 -05:00
|
|
|
let layout = Meta.prefs_get_button_layout();
|
|
|
|
let side = layout.left_buttons.indexOf(Meta.ButtonFunction.CLOSE) > -1 ? St.Side.LEFT : St.Side.RIGHT;
|
2011-06-07 06:27:52 -04:00
|
|
|
|
2011-03-03 19:08:59 -05:00
|
|
|
let buttonX;
|
|
|
|
let buttonY = cloneY - (button.height - button._overlap);
|
2011-06-07 06:27:52 -04:00
|
|
|
if (side == St.Side.LEFT)
|
2011-03-03 19:08:59 -05:00
|
|
|
buttonX = cloneX - (button.width - button._overlap);
|
|
|
|
else
|
|
|
|
buttonX = cloneX + (cloneWidth - button._overlap);
|
|
|
|
|
2011-12-04 15:40:40 -05:00
|
|
|
if (animate)
|
|
|
|
this._animateOverlayActor(button, Math.floor(buttonX), Math.floor(buttonY), button.width);
|
|
|
|
else
|
|
|
|
button.set_position(Math.floor(buttonX), Math.floor(buttonY));
|
2009-11-11 19:26:52 -05:00
|
|
|
|
2012-12-16 18:42:40 -05:00
|
|
|
// Clutter.Actor.get_preferred_width() will return the fixed width if one
|
|
|
|
// is set, so we need to reset the width by calling set_width(-1), to forward
|
|
|
|
// the call down to StLabel.
|
|
|
|
// We also need to save and restore the current width, otherwise the animation
|
|
|
|
// starts from the wrong point.
|
|
|
|
let prevTitleWidth = title.width;
|
|
|
|
title.set_width(-1);
|
2012-10-19 12:37:29 -04:00
|
|
|
let [titleMinWidth, titleNatWidth] = title.get_preferred_width(-1);
|
|
|
|
let titleWidth = Math.max(titleMinWidth, Math.min(titleNatWidth, cloneWidth));
|
2012-12-16 18:42:40 -05:00
|
|
|
title.width = prevTitleWidth;
|
2009-11-11 19:26:52 -05:00
|
|
|
|
2011-12-04 15:40:40 -05:00
|
|
|
let titleX = cloneX + (cloneWidth - titleWidth) / 2;
|
2009-11-21 22:51:28 -05:00
|
|
|
let titleY = cloneY + cloneHeight + title._spacing;
|
2011-12-04 15:40:40 -05:00
|
|
|
|
|
|
|
if (animate)
|
|
|
|
this._animateOverlayActor(title, Math.floor(titleX), Math.floor(titleY), titleWidth);
|
|
|
|
else {
|
|
|
|
title.width = titleWidth;
|
|
|
|
title.set_position(Math.floor(titleX), Math.floor(titleY));
|
|
|
|
}
|
2012-10-27 12:18:54 -04:00
|
|
|
|
|
|
|
let borderX = cloneX - this.borderSize;
|
|
|
|
let borderY = cloneY - this.borderSize;
|
|
|
|
let borderWidth = cloneWidth + 2 * this.borderSize;
|
|
|
|
let borderHeight = cloneHeight + 2 * this.borderSize;
|
|
|
|
|
|
|
|
if (animate) {
|
|
|
|
this._animateOverlayActor(this.border, borderX, borderY,
|
|
|
|
borderWidth, borderHeight);
|
|
|
|
} else {
|
|
|
|
this.border.set_position(borderX, borderY);
|
|
|
|
this.border.set_size(borderWidth, borderHeight);
|
|
|
|
}
|
2011-12-04 15:40:40 -05:00
|
|
|
},
|
|
|
|
|
2012-10-27 12:18:54 -04:00
|
|
|
_animateOverlayActor: function(actor, x, y, width, height) {
|
|
|
|
let params = { x: x,
|
|
|
|
y: y,
|
|
|
|
width: width,
|
|
|
|
time: Overview.ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad' };
|
|
|
|
|
|
|
|
if (height !== undefined)
|
|
|
|
params.height = height;
|
|
|
|
|
|
|
|
Tweener.addTween(actor, params);
|
2009-11-11 19:26:52 -05:00
|
|
|
},
|
|
|
|
|
2010-02-17 23:15:10 -05:00
|
|
|
_closeWindow: function(actor) {
|
2009-11-21 00:46:02 -05:00
|
|
|
let metaWindow = this._windowClone.metaWindow;
|
|
|
|
this._workspace = metaWindow.get_workspace();
|
|
|
|
|
|
|
|
this._windowAddedId = this._workspace.connect('window-added',
|
|
|
|
Lang.bind(this,
|
|
|
|
this._onWindowAdded));
|
|
|
|
|
2010-02-17 23:15:10 -05:00
|
|
|
metaWindow.delete(global.get_current_time());
|
2009-11-21 00:46:02 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onWindowAdded: function(workspace, win) {
|
|
|
|
let metaWindow = this._windowClone.metaWindow;
|
|
|
|
|
|
|
|
if (win.get_transient_for() == metaWindow) {
|
|
|
|
workspace.disconnect(this._windowAddedId);
|
|
|
|
this._windowAddedId = 0;
|
|
|
|
|
|
|
|
// use an idle handler to avoid mapping problems -
|
|
|
|
// see comment in Workspace._windowAdded
|
|
|
|
Mainloop.idle_add(Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
this._windowClone.emit('selected');
|
|
|
|
return false;
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_onDestroy: function() {
|
|
|
|
if (this._windowAddedId > 0) {
|
|
|
|
this._workspace.disconnect(this._windowAddedId);
|
|
|
|
this._windowAddedId = 0;
|
|
|
|
}
|
|
|
|
if (this._idleToggleCloseId > 0) {
|
|
|
|
Mainloop.source_remove(this._idleToggleCloseId);
|
|
|
|
this._idleToggleCloseId = 0;
|
|
|
|
}
|
2010-02-06 21:06:50 -05:00
|
|
|
this._windowClone.metaWindow.disconnect(this._updateCaptionId);
|
2009-11-21 00:46:02 -05:00
|
|
|
this.title.destroy();
|
|
|
|
this.closeButton.destroy();
|
2012-10-27 12:18:54 -04:00
|
|
|
this.border.destroy();
|
|
|
|
},
|
|
|
|
|
|
|
|
_animateVisible: function() {
|
|
|
|
this._parentActor.raise_top();
|
2012-11-23 22:04:38 -05:00
|
|
|
|
2012-10-27 12:18:54 -04:00
|
|
|
this.closeButton.show();
|
2012-11-23 22:04:38 -05:00
|
|
|
this.closeButton.opacity = 0;
|
|
|
|
Tweener.addTween(this.closeButton,
|
|
|
|
{ opacity: 255,
|
|
|
|
time: CLOSE_BUTTON_FADE_TIME,
|
|
|
|
transition: 'easeOutQuad' });
|
2012-10-27 12:18:54 -04:00
|
|
|
|
|
|
|
this.border.show();
|
|
|
|
this.border.opacity = 0;
|
|
|
|
Tweener.addTween(this.border,
|
|
|
|
{ opacity: 255,
|
|
|
|
time: CLOSE_BUTTON_FADE_TIME,
|
|
|
|
transition: 'easeOutQuad' });
|
|
|
|
|
|
|
|
this.title.add_style_pseudo_class('hover');
|
2009-11-21 00:46:02 -05:00
|
|
|
},
|
|
|
|
|
2012-11-23 22:04:38 -05:00
|
|
|
_animateInvisible: function() {
|
|
|
|
this.closeButton.opacity = 255;
|
|
|
|
Tweener.addTween(this.closeButton,
|
|
|
|
{ opacity: 0,
|
|
|
|
time: CLOSE_BUTTON_FADE_TIME,
|
|
|
|
transition: 'easeInQuad' });
|
|
|
|
|
|
|
|
this.border.opacity = 255;
|
|
|
|
Tweener.addTween(this.border,
|
|
|
|
{ opacity: 0,
|
|
|
|
time: CLOSE_BUTTON_FADE_TIME,
|
|
|
|
transition: 'easeInQuad' });
|
|
|
|
|
|
|
|
this.title.remove_style_pseudo_class('hover');
|
|
|
|
},
|
|
|
|
|
2009-11-11 19:26:52 -05:00
|
|
|
_onEnter: function() {
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
// We might get enter events on the clone while the overlay is
|
|
|
|
// hidden, e.g. during animations, we ignore these events,
|
|
|
|
// as the close button will be shown as needed when the overlays
|
|
|
|
// are shown again
|
|
|
|
if (this._hidden)
|
|
|
|
return;
|
2012-10-27 12:18:54 -04:00
|
|
|
|
|
|
|
this._animateVisible();
|
2009-11-19 19:39:00 -05:00
|
|
|
this.emit('show-close-button');
|
2009-11-11 19:26:52 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onLeave: function() {
|
2009-11-19 19:39:00 -05:00
|
|
|
if (this._idleToggleCloseId == 0)
|
|
|
|
this._idleToggleCloseId = Mainloop.timeout_add(750, Lang.bind(this, this._idleToggleCloseButton));
|
|
|
|
},
|
|
|
|
|
|
|
|
_idleToggleCloseButton: function() {
|
|
|
|
this._idleToggleCloseId = 0;
|
2012-10-27 12:18:54 -04:00
|
|
|
|
2012-11-23 22:04:38 -05:00
|
|
|
if (!this._windowClone.actor.has_pointer &&
|
|
|
|
!this.closeButton.has_pointer)
|
|
|
|
this._animateInvisible();
|
2012-10-27 12:18:54 -04:00
|
|
|
|
2009-11-19 19:39:00 -05:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
hideCloseButton: function() {
|
|
|
|
if (this._idleToggleCloseId > 0) {
|
|
|
|
Mainloop.source_remove(this._idleToggleCloseId);
|
|
|
|
this._idleToggleCloseId = 0;
|
|
|
|
}
|
2009-11-11 19:26:52 -05:00
|
|
|
this.closeButton.hide();
|
2012-10-27 12:18:54 -04:00
|
|
|
this.border.hide();
|
|
|
|
this.title.remove_style_pseudo_class('hover');
|
2009-11-11 19:26:52 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onStyleChanged: function() {
|
|
|
|
let titleNode = this.title.get_theme_node();
|
StThemeNode: simplify use of get_color/get_double/get_length
Although within St itself there are situations where the semantics of
these functions (return TRUE or FALSE and return the actual value in
an out parameter) is useful, it's mostly just annoying at the
application level, where you generally know that the CSS property is
going to specified, and there is no especially sane fallback if it's
not.
So rename the current methods to lookup_color, lookup_double, and
lookup_length, and add new get_color, get_double, and get_length
methods that don't take an "inherit" parameter, and return their
values directly. (Well, except for get_color, due to the lack of (out
caller-allocates) in gjs.)
And update the code to use either the old or new methods as appropriate.
https://bugzilla.gnome.org/show_bug.cgi?id=632590
2010-09-26 17:38:36 -04:00
|
|
|
this.title._spacing = titleNode.get_length('-shell-caption-spacing');
|
2009-11-11 19:26:52 -05:00
|
|
|
|
|
|
|
let closeNode = this.closeButton.get_theme_node();
|
StThemeNode: simplify use of get_color/get_double/get_length
Although within St itself there are situations where the semantics of
these functions (return TRUE or FALSE and return the actual value in
an out parameter) is useful, it's mostly just annoying at the
application level, where you generally know that the CSS property is
going to specified, and there is no especially sane fallback if it's
not.
So rename the current methods to lookup_color, lookup_double, and
lookup_length, and add new get_color, get_double, and get_length
methods that don't take an "inherit" parameter, and return their
values directly. (Well, except for get_color, due to the lack of (out
caller-allocates) in gjs.)
And update the code to use either the old or new methods as appropriate.
https://bugzilla.gnome.org/show_bug.cgi?id=632590
2010-09-26 17:38:36 -04:00
|
|
|
this.closeButton._overlap = closeNode.get_length('-shell-close-overlap');
|
2009-11-11 19:26:52 -05:00
|
|
|
|
2012-10-27 12:18:54 -04:00
|
|
|
let borderNode = this.border.get_theme_node();
|
|
|
|
this.borderSize = borderNode.get_border_width(St.Side.TOP);
|
|
|
|
|
2009-11-11 19:26:52 -05:00
|
|
|
this._parentActor.queue_relayout();
|
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2009-11-11 19:26:52 -05:00
|
|
|
Signals.addSignalMethods(WindowOverlay.prototype);
|
|
|
|
|
2010-01-21 21:33:48 -05:00
|
|
|
const WindowPositionFlags = {
|
2012-12-11 17:26:09 -05:00
|
|
|
NONE: 0,
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
INITIAL: 1 << 0,
|
2010-01-21 21:33:48 -05:00
|
|
|
ANIMATE: 1 << 1
|
|
|
|
};
|
2009-11-11 19:26:52 -05:00
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
const LayoutStrategy = new Lang.Class({
|
|
|
|
Name: 'LayoutStrategy',
|
|
|
|
Abstract: true,
|
|
|
|
|
2012-12-13 13:28:25 -05:00
|
|
|
_init: function(monitor, rowSpacing, columnSpacing) {
|
2012-08-08 13:27:46 -04:00
|
|
|
this._monitor = monitor;
|
|
|
|
this._rowSpacing = rowSpacing;
|
|
|
|
this._columnSpacing = columnSpacing;
|
|
|
|
},
|
|
|
|
|
|
|
|
_newRow: function() {
|
|
|
|
// Row properties:
|
|
|
|
//
|
|
|
|
// * x, y are the position of row, relative to area
|
|
|
|
//
|
|
|
|
// * width, height are the scaled versions of fullWidth, fullHeight
|
|
|
|
//
|
|
|
|
// * width also has the spacing in between windows. It's not in
|
|
|
|
// fullWidth, as the spacing is constant, whereas fullWidth is
|
|
|
|
// meant to be scaled
|
|
|
|
//
|
|
|
|
// * neither height/fullHeight have any sort of spacing or padding
|
|
|
|
//
|
|
|
|
// * if cellWidth is present, all windows in the row will occupy
|
|
|
|
// the space of cellWidth, centered.
|
|
|
|
return { x: 0, y: 0,
|
|
|
|
width: 0, height: 0,
|
|
|
|
fullWidth: 0, fullHeight: 0,
|
|
|
|
cellWidth: 0,
|
|
|
|
windows: [] };
|
|
|
|
},
|
|
|
|
|
2012-10-27 22:46:27 -04:00
|
|
|
// Computes and returns a fancy scale for @window using the
|
2012-08-08 13:27:46 -04:00
|
|
|
// base scale, @scale.
|
2012-10-27 22:46:27 -04:00
|
|
|
_computeWindowScale: function(window, scale) {
|
2012-10-26 11:43:38 -04:00
|
|
|
// Since we align windows next to each other, the height of the
|
|
|
|
// thumbnails is much more important to preserve than the width of
|
|
|
|
// them, so two windows with equal height, but maybe differering
|
|
|
|
// widths line up.
|
|
|
|
let ratio = window.actor.height / this._monitor.height;
|
|
|
|
|
|
|
|
// The purpose of this manipulation here is to prevent windows
|
|
|
|
// from getting too small. For something like a calculator window,
|
|
|
|
// we need to bump up the size just a bit to make sure it looks
|
|
|
|
// good. We'll use a multiplier of 1.5 for this.
|
|
|
|
|
|
|
|
// Map from [0, 1] to [1.5, 1]
|
|
|
|
let fancyScale = _interpolate(1.5, 1, ratio) * scale;
|
2012-10-27 22:46:27 -04:00
|
|
|
return fancyScale;
|
2012-08-08 13:27:46 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
// Compute the size of each row, by assigning to the properties
|
|
|
|
// row.width, row.height, row.fullWidth, row.fullHeight, and
|
|
|
|
// (optionally) row.cellWidth, for each row in @layout.rows.
|
|
|
|
// This method is intended to be called by subclasses.
|
|
|
|
_computeRowSizes: function(layout) {
|
|
|
|
throw new Error('_computeRowSizes not implemented');
|
|
|
|
},
|
|
|
|
|
|
|
|
// Compute strategy-specific window slots for each window in
|
|
|
|
// @windows, given the @layout. The strategy may also use @layout
|
|
|
|
// as strategy-specific storage.
|
|
|
|
//
|
|
|
|
// This must calculate:
|
|
|
|
// * maxColumns - The maximum number of columns used by the layout.
|
|
|
|
// * gridWidth - The total width used by the grid, unscaled, unspaced.
|
|
|
|
// * gridHeight - The totial height used by the grid, unscaled, unspaced.
|
|
|
|
// * rows - A list of rows, which should be instantiated by _newRow.
|
|
|
|
computeLayout: function(windows, layout) {
|
|
|
|
throw new Error('computeLayout not implemented');
|
|
|
|
},
|
|
|
|
|
|
|
|
// Given @layout, compute the overall scale and space of the layout.
|
|
|
|
// The scale is the individual, non-fancy scale of each window, and
|
|
|
|
// the space is the percentage of the available area eventually
|
|
|
|
// used by the layout.
|
|
|
|
|
|
|
|
// This method does not return anything, but instead installs
|
|
|
|
// the properties "scale" and "space" on @layout directly.
|
|
|
|
//
|
|
|
|
// Make sure to call this methods before calling computeWindowSlots(),
|
|
|
|
// as it depends on the scale property installed in @layout here.
|
|
|
|
computeScaleAndSpace: function(layout) {
|
|
|
|
let area = layout.area;
|
|
|
|
|
|
|
|
let hspacing = (layout.maxColumns - 1) * this._columnSpacing;
|
2012-12-13 13:28:25 -05:00
|
|
|
let vspacing = (layout.numRows - 1) * this._rowSpacing;
|
2012-08-08 13:27:46 -04:00
|
|
|
|
|
|
|
let spacedWidth = area.width - hspacing;
|
|
|
|
let spacedHeight = area.height - vspacing;
|
|
|
|
|
|
|
|
let horizontalScale = spacedWidth / layout.gridWidth;
|
|
|
|
let verticalScale = spacedHeight / layout.gridHeight;
|
|
|
|
|
|
|
|
// Thumbnails should be less than 70% of the original size
|
|
|
|
let scale = Math.min(horizontalScale, verticalScale, WINDOW_CLONE_MAXIMUM_SCALE);
|
|
|
|
|
|
|
|
let scaledLayoutWidth = layout.gridWidth * scale + hspacing;
|
|
|
|
let scaledLayoutHeight = layout.gridHeight * scale + vspacing;
|
|
|
|
let space = (scaledLayoutWidth * scaledLayoutHeight) / (area.width * area.height);
|
|
|
|
|
|
|
|
layout.scale = scale;
|
|
|
|
layout.space = space;
|
|
|
|
},
|
|
|
|
|
2013-02-17 06:12:55 -05:00
|
|
|
_getDistance: function (row, actor) {
|
|
|
|
let dist_x = actor.x - row.x;
|
|
|
|
let dist_y = actor.y - row.y;
|
|
|
|
|
|
|
|
return Math.sqrt(Math.pow(dist_x, 2) + Math.pow(dist_y, 2));
|
|
|
|
},
|
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
computeWindowSlots: function(layout, area) {
|
|
|
|
this._computeRowSizes(layout);
|
|
|
|
|
|
|
|
let { rows: rows, scale: scale, state: state } = layout;
|
|
|
|
|
|
|
|
let slots = [];
|
|
|
|
|
|
|
|
let y = 0;
|
|
|
|
for (let i = 0; i < rows.length; i++) {
|
|
|
|
let row = rows[i];
|
|
|
|
row.x = area.x + (area.width - row.width) / 2;
|
|
|
|
row.y = area.y + y;
|
|
|
|
y += row.height + this._rowSpacing;
|
2013-02-17 06:12:55 -05:00
|
|
|
row.windows.sort(Lang.bind(this, function(a, b) {
|
|
|
|
return this._getDistance(row, a.realWindow) - this._getDistance(row, b.realWindow);
|
|
|
|
}));
|
2012-08-08 13:27:46 -04:00
|
|
|
}
|
|
|
|
|
2012-12-13 13:28:25 -05:00
|
|
|
let height = y - this._rowSpacing;
|
2012-08-08 13:27:46 -04:00
|
|
|
let baseY = (area.height - height) / 2;
|
|
|
|
|
|
|
|
for (let i = 0; i < rows.length; i++) {
|
|
|
|
let row = rows[i];
|
|
|
|
row.y += baseY;
|
|
|
|
let baseX = row.x;
|
|
|
|
for (let j = 0; j < row.windows.length; j++) {
|
|
|
|
let window = row.windows[j];
|
|
|
|
|
2012-10-27 22:46:27 -04:00
|
|
|
let s = this._computeWindowScale(window, scale);
|
|
|
|
s = Math.min(s, WINDOW_CLONE_MAXIMUM_SCALE);
|
|
|
|
let width = window.actor.width * s;
|
|
|
|
let height = window.actor.height * s;
|
2012-08-08 13:27:46 -04:00
|
|
|
let y = row.y + row.height - height;
|
|
|
|
|
|
|
|
let x = baseX;
|
|
|
|
if (row.cellWidth) {
|
|
|
|
x += (row.cellWidth - width) / 2;
|
|
|
|
width = row.cellWidth;
|
|
|
|
}
|
|
|
|
|
2013-02-17 06:12:55 -05:00
|
|
|
slots.push([x, y, s, window]);
|
2012-08-08 13:27:46 -04:00
|
|
|
baseX += width + this._columnSpacing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return slots;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const UnalignedLayoutStrategy = new Lang.Class({
|
|
|
|
Name: 'UnalignedLayoutStrategy',
|
|
|
|
Extends: LayoutStrategy,
|
|
|
|
|
|
|
|
_computeRowSizes: function(layout) {
|
|
|
|
let { rows: rows, scale: scale } = layout;
|
|
|
|
for (let i = 0; i < rows.length; i++) {
|
|
|
|
let row = rows[i];
|
|
|
|
row.width = row.fullWidth * scale + (row.windows.length - 1) * this._columnSpacing;
|
|
|
|
row.height = row.fullHeight * scale;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_keepSameRow: function(row, window, width, idealRowWidth) {
|
|
|
|
if (row.fullWidth + width <= idealRowWidth)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
let oldRatio = row.fullWidth / idealRowWidth;
|
|
|
|
let newRatio = (row.fullWidth + width) / idealRowWidth;
|
|
|
|
|
|
|
|
if (Math.abs(1 - newRatio) < Math.abs(1 - oldRatio))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
computeLayout: function(windows, layout) {
|
|
|
|
let numRows = layout.numRows;
|
|
|
|
|
|
|
|
let rows = [];
|
|
|
|
let totalWidth = 0;
|
|
|
|
for (let i = 0; i < windows.length; i++) {
|
|
|
|
totalWidth += windows[i].actor.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
let idealRowWidth = totalWidth / numRows;
|
|
|
|
let windowIdx = 0;
|
|
|
|
for (let i = 0; i < numRows; i++) {
|
|
|
|
let col = 0;
|
|
|
|
let row = this._newRow();
|
|
|
|
rows.push(row);
|
|
|
|
|
|
|
|
for (; windowIdx < windows.length; windowIdx++) {
|
|
|
|
let window = windows[windowIdx];
|
2012-10-27 22:46:27 -04:00
|
|
|
let s = this._computeWindowScale(window, 1);
|
|
|
|
let width = window.actor.width * s;
|
|
|
|
let height = window.actor.height * s;
|
2012-08-08 13:27:46 -04:00
|
|
|
row.fullHeight = Math.max(row.fullHeight, height);
|
|
|
|
|
|
|
|
// either new width is < idealWidth or new width is nearer from idealWidth then oldWidth
|
|
|
|
if (this._keepSameRow(row, window, width, idealRowWidth) || (i == numRows - 1)) {
|
|
|
|
row.windows.push(window);
|
|
|
|
row.fullWidth += width;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let gridHeight = 0;
|
|
|
|
let maxRow;
|
|
|
|
for (let i = 0; i < numRows; i++) {
|
|
|
|
let row = rows[i];
|
|
|
|
if (!maxRow || row.fullWidth > maxRow.fullWidth)
|
|
|
|
maxRow = row;
|
|
|
|
gridHeight += row.fullHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
layout.rows = rows;
|
|
|
|
layout.maxColumns = maxRow.windows.length;
|
|
|
|
layout.gridWidth = maxRow.fullWidth;
|
|
|
|
layout.gridHeight = gridHeight;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const GridLayoutStrategy = new Lang.Class({
|
|
|
|
Name: 'GridLayoutStrategy',
|
|
|
|
Extends: LayoutStrategy,
|
|
|
|
|
|
|
|
_computeRowSizes: function(layout) {
|
|
|
|
let { rows: rows, scale: scale } = layout;
|
|
|
|
|
|
|
|
let gridWidth = layout.numColumns * layout.maxWindowWidth;
|
|
|
|
let hspacing = (layout.numColumns - 1) * this._columnSpacing;
|
|
|
|
for (let i = 0; i < rows.length; i++) {
|
|
|
|
let row = rows[i];
|
|
|
|
row.fullWidth = layout.gridWidth;
|
|
|
|
row.fullHeight = layout.maxWindowHeight;
|
|
|
|
|
|
|
|
row.width = row.fullWidth * scale + hspacing;
|
|
|
|
row.height = row.fullHeight * scale;
|
|
|
|
row.cellWidth = layout.maxWindowWidth * scale;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computeLayout: function(windows, layout) {
|
|
|
|
let { numRows: numRows, numColumns: numColumns } = layout;
|
|
|
|
let rows = [];
|
|
|
|
let windowIdx = 0;
|
|
|
|
|
|
|
|
let maxWindowWidth = 0;
|
|
|
|
let maxWindowHeight = 0;
|
|
|
|
for (let i = 0; i < numRows; i++) {
|
|
|
|
let row = this._newRow();
|
|
|
|
rows.push(row);
|
|
|
|
for (; windowIdx < windows.length; windowIdx++) {
|
|
|
|
if (row.windows.length >= numColumns)
|
|
|
|
break;
|
|
|
|
|
|
|
|
let window = windows[windowIdx];
|
|
|
|
row.windows.push(window);
|
|
|
|
|
2012-10-27 22:46:27 -04:00
|
|
|
let s = this._computeWindowScale(window, 1);
|
|
|
|
maxWindowWidth = Math.max(maxWindowWidth, window.actor.width * s);
|
|
|
|
maxWindowHeight = Math.max(maxWindowHeight, window.actor.height * s);
|
2012-08-08 13:27:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
layout.rows = rows;
|
|
|
|
layout.maxColumns = numColumns;
|
|
|
|
layout.gridWidth = numColumns * maxWindowWidth;
|
|
|
|
layout.gridHeight = numRows * maxWindowHeight;
|
|
|
|
layout.maxWindowWidth = maxWindowWidth;
|
|
|
|
layout.maxWindowHeight = maxWindowHeight;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2009-07-23 17:36:41 -04:00
|
|
|
/**
|
2011-03-03 16:33:27 -05:00
|
|
|
* @metaWorkspace: a #Meta.Workspace, or null
|
2009-07-23 17:36:41 -04:00
|
|
|
*/
|
2011-11-20 12:56:27 -05:00
|
|
|
const Workspace = new Lang.Class({
|
|
|
|
Name: 'Workspace',
|
2008-12-22 16:51:34 -05:00
|
|
|
|
2011-03-01 03:14:56 -05:00
|
|
|
_init : function(metaWorkspace, monitorIndex) {
|
2010-03-16 11:51:24 -04:00
|
|
|
// When dragging a window, we use this slot for reserve space.
|
|
|
|
this._reservedSlot = null;
|
2010-02-14 18:32:57 -05:00
|
|
|
this.metaWorkspace = metaWorkspace;
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
this._x = 0;
|
|
|
|
this._y = 0;
|
|
|
|
this._width = 0;
|
|
|
|
this._height = 0;
|
|
|
|
|
2011-03-01 03:14:56 -05:00
|
|
|
this.monitorIndex = monitorIndex;
|
2011-06-13 09:54:05 -04:00
|
|
|
this._monitor = Main.layoutManager.monitors[this.monitorIndex];
|
2010-01-21 21:33:48 -05:00
|
|
|
this._windowOverlaysGroup = new Clutter.Group();
|
|
|
|
// Without this the drop area will be overlapped.
|
|
|
|
this._windowOverlaysGroup.set_size(0, 0);
|
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
this.actor = new St.Widget({ style_class: 'window-picker' });
|
2012-12-13 13:28:25 -05:00
|
|
|
if (monitorIndex != Main.layoutManager.primaryIndex)
|
|
|
|
this.actor.add_style_class_name('external-monitor');
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
this.actor.set_size(0, 0);
|
2010-02-18 10:43:58 -05:00
|
|
|
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
this._dropRect = new Clutter.Rectangle({ opacity: 0 });
|
|
|
|
this._dropRect._delegate = this;
|
2010-02-18 10:43:58 -05:00
|
|
|
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
this.actor.add_actor(this._dropRect);
|
|
|
|
this.actor.add_actor(this._windowOverlaysGroup);
|
2010-02-14 18:32:57 -05:00
|
|
|
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
2008-12-22 16:51:34 -05:00
|
|
|
|
2011-03-01 03:14:56 -05:00
|
|
|
let windows = global.get_window_actors().filter(this._isMyWindow, this);
|
2008-12-22 16:51:34 -05:00
|
|
|
|
2011-02-19 18:39:10 -05:00
|
|
|
// Create clones for windows that should be
|
2009-08-11 07:46:10 -04:00
|
|
|
// visible in the Overview
|
2010-07-15 10:21:32 -04:00
|
|
|
this._windows = [];
|
|
|
|
this._windowOverlays = [];
|
2008-12-22 16:51:34 -05:00
|
|
|
for (let i = 0; i < windows.length; i++) {
|
2009-08-11 07:46:10 -04:00
|
|
|
if (this._isOverviewWindow(windows[i])) {
|
2009-01-23 14:21:20 -05:00
|
|
|
this._addWindowClone(windows[i]);
|
2008-12-22 16:51:34 -05:00
|
|
|
}
|
|
|
|
}
|
2008-12-22 17:06:47 -05:00
|
|
|
|
2009-02-04 09:50:50 -05:00
|
|
|
// Track window changes
|
2011-03-03 16:33:27 -05:00
|
|
|
if (this.metaWorkspace) {
|
|
|
|
this._windowAddedId = this.metaWorkspace.connect('window-added',
|
|
|
|
Lang.bind(this, this._windowAdded));
|
|
|
|
this._windowRemovedId = this.metaWorkspace.connect('window-removed',
|
|
|
|
Lang.bind(this, this._windowRemoved));
|
|
|
|
}
|
2011-03-01 03:14:56 -05:00
|
|
|
this._windowEnteredMonitorId = global.screen.connect('window-entered-monitor',
|
2012-08-08 13:21:20 -04:00
|
|
|
Lang.bind(this, this._windowEnteredMonitor));
|
2011-03-01 03:14:56 -05:00
|
|
|
this._windowLeftMonitorId = global.screen.connect('window-left-monitor',
|
2012-08-08 13:21:20 -04:00
|
|
|
Lang.bind(this, this._windowLeftMonitor));
|
2010-02-28 01:56:04 -05:00
|
|
|
this._repositionWindowsId = 0;
|
2009-02-04 09:50:50 -05:00
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
this.leavingOverview = false;
|
2012-08-08 13:16:28 -04:00
|
|
|
|
|
|
|
this._positionWindowsFlags = 0;
|
|
|
|
this._positionWindowsId = 0;
|
2012-08-08 15:47:05 -04:00
|
|
|
|
|
|
|
this._currentLayout = null;
|
2008-12-22 17:06:47 -05:00
|
|
|
},
|
|
|
|
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
setGeometry: function(x, y, width, height) {
|
|
|
|
this._x = x;
|
|
|
|
this._y = y;
|
|
|
|
this._width = width;
|
|
|
|
this._height = height;
|
|
|
|
|
2012-08-08 13:16:28 -04:00
|
|
|
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
|
|
|
|
this._dropRect.set_position(x, y);
|
|
|
|
this._dropRect.set_size(width, height);
|
|
|
|
return false;
|
|
|
|
}));
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
|
2012-12-11 17:26:09 -05:00
|
|
|
this.positionWindows(WindowPositionFlags.NONE);
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
},
|
|
|
|
|
2009-07-23 17:36:41 -04:00
|
|
|
_lookupIndex: function (metaWindow) {
|
2009-07-31 17:20:26 -04:00
|
|
|
for (let i = 0; i < this._windows.length; i++) {
|
|
|
|
if (this._windows[i].metaWindow == metaWindow) {
|
2009-07-23 17:36:41 -04:00
|
|
|
return i;
|
2009-07-31 17:20:26 -04:00
|
|
|
}
|
|
|
|
}
|
2009-07-23 17:36:41 -04:00
|
|
|
return -1;
|
2009-07-31 17:20:26 -04:00
|
|
|
},
|
|
|
|
|
2009-09-01 14:15:29 -04:00
|
|
|
containsMetaWindow: function (metaWindow) {
|
|
|
|
return this._lookupIndex(metaWindow) >= 0;
|
|
|
|
},
|
|
|
|
|
2011-01-21 13:47:54 -05:00
|
|
|
isEmpty: function() {
|
|
|
|
return this._windows.length == 0;
|
|
|
|
},
|
|
|
|
|
2010-03-16 11:51:24 -04:00
|
|
|
setReservedSlot: function(clone) {
|
2011-02-09 19:42:01 -05:00
|
|
|
if (this._reservedSlot == clone)
|
|
|
|
return;
|
|
|
|
|
2012-08-23 22:33:35 -04:00
|
|
|
if (clone && this.containsMetaWindow(clone.metaWindow))
|
|
|
|
clone = null;
|
|
|
|
|
|
|
|
this._reservedSlot = clone;
|
2012-08-08 15:47:05 -04:00
|
|
|
this._currentLayout = null;
|
2010-03-16 11:51:24 -04:00
|
|
|
this.positionWindows(WindowPositionFlags.ANIMATE);
|
|
|
|
},
|
|
|
|
|
2009-09-11 12:39:59 -04:00
|
|
|
/**
|
|
|
|
* positionWindows:
|
2010-01-21 21:33:48 -05:00
|
|
|
* @flags:
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
* INITIAL - this is the initial positioning of the windows.
|
2010-01-21 21:33:48 -05:00
|
|
|
* ANIMATE - Indicates that we need animate changing position.
|
2009-09-11 12:39:59 -04:00
|
|
|
*/
|
2012-08-08 13:16:28 -04:00
|
|
|
positionWindows: function(flags) {
|
|
|
|
this._positionWindowsFlags |= flags;
|
|
|
|
|
|
|
|
if (this._positionWindowsId > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._positionWindowsId = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
|
|
|
|
this._realPositionWindows(this._positionWindowsFlags);
|
|
|
|
this._positionWindowsFlags = 0;
|
|
|
|
this._positionWindowsId = 0;
|
|
|
|
return false;
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
_realPositionWindows : function(flags) {
|
2010-02-28 01:56:04 -05:00
|
|
|
if (this._repositionWindowsId > 0) {
|
|
|
|
Mainloop.source_remove(this._repositionWindowsId);
|
|
|
|
this._repositionWindowsId = 0;
|
|
|
|
}
|
|
|
|
|
2011-02-12 14:03:44 -05:00
|
|
|
let clones = this._windows.slice();
|
2012-08-08 13:27:46 -04:00
|
|
|
|
|
|
|
clones.sort(function(a, b) {
|
|
|
|
return a.metaWindow.get_stable_sequence() - b.metaWindow.get_stable_sequence();
|
|
|
|
});
|
|
|
|
|
2010-03-16 11:51:24 -04:00
|
|
|
if (this._reservedSlot)
|
2011-02-12 14:03:44 -05:00
|
|
|
clones.push(this._reservedSlot);
|
2009-09-01 14:15:29 -04:00
|
|
|
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
let initialPositioning = flags & WindowPositionFlags.INITIAL;
|
2010-01-21 21:33:48 -05:00
|
|
|
let animate = flags & WindowPositionFlags.ANIMATE;
|
|
|
|
|
2009-09-28 19:48:03 -04:00
|
|
|
// Start the animations
|
2012-08-08 13:27:46 -04:00
|
|
|
let slots = this._computeAllWindowSlots(clones);
|
2009-01-23 14:21:20 -05:00
|
|
|
|
2010-12-16 14:21:12 -05:00
|
|
|
let currentWorkspace = global.screen.get_active_workspace();
|
2011-03-03 16:33:27 -05:00
|
|
|
let isOnCurrentWorkspace = this.metaWorkspace == null || this.metaWorkspace == currentWorkspace;
|
2010-12-16 14:21:12 -05:00
|
|
|
|
2013-02-17 06:12:55 -05:00
|
|
|
for (let i = 0; i < slots.length; i++) {
|
2009-09-18 15:08:56 -04:00
|
|
|
let slot = slots[i];
|
2013-02-17 06:12:55 -05:00
|
|
|
let [x, y, scale, clone] = slot;
|
2010-02-19 13:27:07 -05:00
|
|
|
let metaWindow = clone.metaWindow;
|
2012-10-19 12:38:20 -04:00
|
|
|
let overlay = clone.overlay;
|
|
|
|
clone.slotId = i;
|
2009-09-01 14:15:29 -04:00
|
|
|
|
2010-03-19 16:46:08 -04:00
|
|
|
// Positioning a window currently being dragged must be avoided;
|
|
|
|
// we'll just leave a blank spot in the layout for it.
|
|
|
|
if (clone.inDrag)
|
|
|
|
continue;
|
|
|
|
|
2012-12-16 18:40:48 -05:00
|
|
|
clone.slot = [x, y, clone.actor.width * scale, clone.actor.height * scale];
|
2009-01-23 14:21:20 -05:00
|
|
|
|
2011-12-04 15:40:40 -05:00
|
|
|
if (overlay && initialPositioning)
|
2010-03-16 11:51:24 -04:00
|
|
|
overlay.hide();
|
2012-08-08 13:27:46 -04:00
|
|
|
|
2010-12-16 14:21:12 -05:00
|
|
|
if (animate && isOnCurrentWorkspace) {
|
2010-01-23 02:37:34 -05:00
|
|
|
if (!metaWindow.showing_on_its_workspace()) {
|
|
|
|
/* Hidden windows should fade in and grow
|
|
|
|
* therefore we need to resize them now so they
|
|
|
|
* can be scaled up later */
|
2012-08-08 13:21:20 -04:00
|
|
|
if (initialPositioning) {
|
|
|
|
clone.actor.opacity = 0;
|
|
|
|
clone.actor.scale_x = 0;
|
|
|
|
clone.actor.scale_y = 0;
|
|
|
|
clone.actor.x = x;
|
|
|
|
clone.actor.y = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
Tweener.addTween(clone.actor,
|
2013-02-17 08:20:34 -05:00
|
|
|
{ opacity: 255,
|
2012-08-08 13:21:20 -04:00
|
|
|
time: Overview.ANIMATION_TIME,
|
|
|
|
transition: 'easeInQuad'
|
|
|
|
});
|
2010-01-23 02:37:34 -05:00
|
|
|
}
|
|
|
|
|
2011-12-04 15:40:40 -05:00
|
|
|
this._animateClone(clone, overlay, x, y, scale, initialPositioning);
|
2010-01-21 21:33:48 -05:00
|
|
|
} else {
|
2012-08-08 13:27:46 -04:00
|
|
|
// cancel any active tweens (otherwise they might override our changes)
|
|
|
|
Tweener.removeTweens(clone.actor);
|
2010-01-21 21:33:48 -05:00
|
|
|
clone.actor.set_position(x, y);
|
|
|
|
clone.actor.set_scale(scale, scale);
|
2012-12-16 18:40:48 -05:00
|
|
|
clone.overlay.relayout(false);
|
2010-12-16 14:21:12 -05:00
|
|
|
this._showWindowOverlay(clone, overlay, isOnCurrentWorkspace);
|
2010-01-21 21:33:48 -05:00
|
|
|
}
|
2009-01-23 14:21:20 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-09-28 19:48:03 -04:00
|
|
|
syncStacking: function(stackIndices) {
|
2011-02-12 14:03:44 -05:00
|
|
|
let clones = this._windows.slice();
|
|
|
|
clones.sort(function (a, b) { return stackIndices[a.metaWindow.get_stable_sequence()] - stackIndices[b.metaWindow.get_stable_sequence()]; });
|
2009-09-28 19:48:03 -04:00
|
|
|
|
2011-02-12 14:03:44 -05:00
|
|
|
for (let i = 0; i < clones.length; i++) {
|
|
|
|
let clone = clones[i];
|
2009-09-28 19:48:03 -04:00
|
|
|
let metaWindow = clone.metaWindow;
|
|
|
|
if (i == 0) {
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
clone.setStackAbove(this._dropRect);
|
2009-09-28 19:48:03 -04:00
|
|
|
} else {
|
2011-02-12 14:03:44 -05:00
|
|
|
let previousClone = clones[i - 1];
|
2009-09-28 19:48:03 -04:00
|
|
|
clone.setStackAbove(previousClone.actor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-12-04 15:40:40 -05:00
|
|
|
_animateClone: function(clone, overlay, x, y, scale, initialPositioning) {
|
|
|
|
Tweener.addTween(clone.actor,
|
2012-08-08 13:21:20 -04:00
|
|
|
{ x: x,
|
|
|
|
y: y,
|
|
|
|
scale_x: scale,
|
|
|
|
scale_y: scale,
|
|
|
|
time: Overview.ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
onComplete: Lang.bind(this, function() {
|
|
|
|
this._showWindowOverlay(clone, overlay, true);
|
|
|
|
})
|
|
|
|
});
|
2011-12-04 15:40:40 -05:00
|
|
|
|
2012-12-16 18:40:48 -05:00
|
|
|
clone.overlay.relayout(true);
|
2011-12-04 15:40:40 -05:00
|
|
|
},
|
|
|
|
|
2010-12-16 14:21:12 -05:00
|
|
|
_showWindowOverlay: function(clone, overlay, fade) {
|
2010-03-22 19:01:44 -04:00
|
|
|
if (clone.inDrag)
|
|
|
|
return;
|
|
|
|
|
2010-03-16 11:51:24 -04:00
|
|
|
if (overlay) {
|
2010-12-16 14:21:12 -05:00
|
|
|
if (fade)
|
|
|
|
overlay.fadeIn();
|
|
|
|
else
|
|
|
|
overlay.show();
|
2010-03-16 11:51:24 -04:00
|
|
|
}
|
2009-11-21 22:51:28 -05:00
|
|
|
},
|
|
|
|
|
2010-02-28 01:56:04 -05:00
|
|
|
_delayedWindowRepositioning: function() {
|
2010-03-21 14:33:52 -04:00
|
|
|
if (this._windowIsZooming)
|
|
|
|
return true;
|
|
|
|
|
2010-04-08 14:41:54 -04:00
|
|
|
let [x, y, mask] = global.get_pointer();
|
2010-02-28 01:56:04 -05:00
|
|
|
|
|
|
|
let pointerHasMoved = (this._cursorX != x && this._cursorY != y);
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
let inWorkspace = (this._x < x && x < this._x + this._width &&
|
|
|
|
this._y < y && y < this._y + this._height);
|
2010-02-28 01:56:04 -05:00
|
|
|
|
|
|
|
if (pointerHasMoved && inWorkspace) {
|
|
|
|
// store current cursor position
|
|
|
|
this._cursorX = x;
|
|
|
|
this._cursorY = y;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-08 04:58:00 -05:00
|
|
|
let actorUnderPointer = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, x, y);
|
|
|
|
for (let i = 0; i < this._windows.length; i++) {
|
|
|
|
if (this._windows[i].actor == actorUnderPointer)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-28 01:56:04 -05:00
|
|
|
this.positionWindows(WindowPositionFlags.ANIMATE);
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2011-03-01 03:14:56 -05:00
|
|
|
_doRemoveWindow : function(metaWin) {
|
2009-02-04 09:50:50 -05:00
|
|
|
let win = metaWin.get_compositor_private();
|
|
|
|
|
2009-01-23 14:21:20 -05:00
|
|
|
// find the position of the window in our list
|
2009-07-23 17:36:41 -04:00
|
|
|
let index = this._lookupIndex (metaWin);
|
2009-01-23 14:21:20 -05:00
|
|
|
|
|
|
|
if (index == -1)
|
|
|
|
return;
|
2009-02-10 11:15:59 -05:00
|
|
|
|
2011-03-01 03:14:56 -05:00
|
|
|
// Check if window still should be here
|
|
|
|
if (win && this._isMyWindow(win))
|
|
|
|
return;
|
|
|
|
|
2009-07-23 17:36:41 -04:00
|
|
|
let clone = this._windows[index];
|
|
|
|
|
2009-01-23 14:21:20 -05:00
|
|
|
this._windows.splice(index, 1);
|
2009-11-11 19:26:52 -05:00
|
|
|
this._windowOverlays.splice(index, 1);
|
2009-02-04 09:50:50 -05:00
|
|
|
|
|
|
|
// If metaWin.get_compositor_private() returned non-NULL, that
|
|
|
|
// means the window still exists (and is just being moved to
|
2009-08-11 07:46:10 -04:00
|
|
|
// another workspace or something), so set its overviewHint
|
2009-02-04 09:50:50 -05:00
|
|
|
// accordingly. (If it returned NULL, then the window is being
|
|
|
|
// destroyed; we'd like to animate this, but it's too late at
|
|
|
|
// this point.)
|
|
|
|
if (win) {
|
|
|
|
let [stageX, stageY] = clone.actor.get_transformed_position();
|
|
|
|
let [stageWidth, stageHeight] = clone.actor.get_transformed_size();
|
2009-08-11 07:46:10 -04:00
|
|
|
win._overviewHint = {
|
2009-02-04 09:50:50 -05:00
|
|
|
x: stageX,
|
|
|
|
y: stageY,
|
|
|
|
scale: stageWidth / clone.actor.width
|
|
|
|
};
|
|
|
|
}
|
2009-01-23 14:21:20 -05:00
|
|
|
clone.destroy();
|
|
|
|
|
2010-02-28 01:56:04 -05:00
|
|
|
|
|
|
|
// We need to reposition the windows; to avoid shuffling windows
|
|
|
|
// around while the user is interacting with the workspace, we delay
|
|
|
|
// the positioning until the pointer remains still for at least 750 ms
|
|
|
|
// or is moved outside the workspace
|
|
|
|
|
|
|
|
// remove old handler
|
|
|
|
if (this._repositionWindowsId > 0) {
|
|
|
|
Mainloop.source_remove(this._repositionWindowsId);
|
|
|
|
this._repositionWindowsId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup new handler
|
2010-04-08 14:41:54 -04:00
|
|
|
let [x, y, mask] = global.get_pointer();
|
2010-02-28 01:56:04 -05:00
|
|
|
this._cursorX = x;
|
|
|
|
this._cursorY = y;
|
|
|
|
|
2012-08-08 15:47:05 -04:00
|
|
|
this._currentLayout = null;
|
2010-02-28 01:56:04 -05:00
|
|
|
this._repositionWindowsId = Mainloop.timeout_add(750,
|
|
|
|
Lang.bind(this, this._delayedWindowRepositioning));
|
2009-01-23 14:21:20 -05:00
|
|
|
},
|
|
|
|
|
2011-03-01 03:14:56 -05:00
|
|
|
_doAddWindow : function(metaWin) {
|
2009-08-11 07:46:10 -04:00
|
|
|
if (this.leavingOverview)
|
2009-03-17 18:22:25 -04:00
|
|
|
return;
|
|
|
|
|
2009-02-04 09:50:50 -05:00
|
|
|
let win = metaWin.get_compositor_private();
|
|
|
|
|
|
|
|
if (!win) {
|
|
|
|
// Newly-created windows are added to a workspace before
|
|
|
|
// the compositor finds out about them...
|
|
|
|
Mainloop.idle_add(Lang.bind(this,
|
|
|
|
function () {
|
2011-04-20 16:04:03 -04:00
|
|
|
if (this.actor &&
|
|
|
|
metaWin.get_compositor_private() &&
|
|
|
|
metaWin.get_workspace() == this.metaWorkspace)
|
2011-03-01 03:14:56 -05:00
|
|
|
this._doAddWindow(metaWin);
|
2009-02-04 09:50:50 -05:00
|
|
|
return false;
|
|
|
|
}));
|
|
|
|
return;
|
|
|
|
}
|
2010-01-21 21:33:48 -05:00
|
|
|
|
2011-03-01 03:14:56 -05:00
|
|
|
// We might have the window in our list already if it was on all workspaces and
|
|
|
|
// now was moved to this workspace
|
|
|
|
if (this._lookupIndex (metaWin) != -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!this._isMyWindow(win) || !this._isOverviewWindow(win))
|
2010-01-21 21:33:48 -05:00
|
|
|
return;
|
2009-02-04 09:50:50 -05:00
|
|
|
|
2012-04-18 08:03:33 -04:00
|
|
|
let [clone, overlay] = this._addWindowClone(win);
|
2009-02-04 09:50:50 -05:00
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
if (win._overviewHint) {
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
let x = win._overviewHint.x - this.actor.x;
|
|
|
|
let y = win._overviewHint.y - this.actor.y;
|
|
|
|
let scale = win._overviewHint.scale;
|
2009-08-11 07:46:10 -04:00
|
|
|
delete win._overviewHint;
|
2009-02-04 09:50:50 -05:00
|
|
|
|
2012-12-16 18:40:48 -05:00
|
|
|
clone.slot = [x, y, clone.actor.width * scale, clone.actor.height * scale];
|
2009-02-04 09:50:50 -05:00
|
|
|
clone.actor.set_position (x, y);
|
|
|
|
clone.actor.set_scale (scale, scale);
|
2012-12-16 18:40:48 -05:00
|
|
|
clone.overlay.relayout(false);
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
} else {
|
|
|
|
// Position new windows at the top corner of the workspace rather
|
|
|
|
// than where they were placed for real to avoid the window
|
|
|
|
// being clipped to the workspaceView. Its not really more
|
|
|
|
// natural for the window to suddenly appear in the overview
|
|
|
|
// on some seemingly random location anyway.
|
|
|
|
clone.actor.set_position (this._x, this._y);
|
2009-02-04 09:50:50 -05:00
|
|
|
}
|
|
|
|
|
2012-08-08 15:47:05 -04:00
|
|
|
this._currentLayout = null;
|
2010-01-21 21:33:48 -05:00
|
|
|
this.positionWindows(WindowPositionFlags.ANIMATE);
|
2009-01-23 14:21:20 -05:00
|
|
|
},
|
|
|
|
|
2011-03-01 03:14:56 -05:00
|
|
|
_windowAdded : function(metaWorkspace, metaWin) {
|
|
|
|
this._doAddWindow(metaWin);
|
|
|
|
},
|
|
|
|
|
|
|
|
_windowRemoved : function(metaWorkspace, metaWin) {
|
|
|
|
this._doRemoveWindow(metaWin);
|
|
|
|
},
|
|
|
|
|
|
|
|
_windowEnteredMonitor : function(metaScreen, monitorIndex, metaWin) {
|
|
|
|
if (monitorIndex == this.monitorIndex) {
|
|
|
|
this._doAddWindow(metaWin);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_windowLeftMonitor : function(metaScreen, monitorIndex, metaWin) {
|
|
|
|
if (monitorIndex == this.monitorIndex) {
|
|
|
|
this._doRemoveWindow(metaWin);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-01-05 22:53:36 -05:00
|
|
|
// check for maximized windows on the workspace
|
2010-07-15 10:21:32 -04:00
|
|
|
hasMaximizedWindows: function() {
|
|
|
|
for (let i = 0; i < this._windows.length; i++) {
|
2010-01-05 22:53:36 -05:00
|
|
|
let metaWindow = this._windows[i].metaWindow;
|
|
|
|
if (metaWindow.showing_on_its_workspace() &&
|
|
|
|
metaWindow.maximized_horizontally &&
|
|
|
|
metaWindow.maximized_vertically)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
// Animate the full-screen to Overview transition.
|
2010-02-14 18:32:57 -05:00
|
|
|
zoomToOverview : function() {
|
2012-08-08 15:47:05 -04:00
|
|
|
this._currentLayout = null;
|
|
|
|
|
2009-08-10 18:31:39 -04:00
|
|
|
// Position and scale the windows.
|
2010-02-14 18:32:57 -05:00
|
|
|
if (Main.overview.animationInProgress)
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
this.positionWindows(WindowPositionFlags.ANIMATE | WindowPositionFlags.INITIAL);
|
2010-01-21 21:33:48 -05:00
|
|
|
else
|
Restructure the way we handle positioning zooming in Workspace
We currently show the workspace in the overview in a rectangle
with the same aspect ratio as the screen. Originally this was
probably done since it showed the desktop, but we don't do this
anymore, and the positioning of the windows in the overview is
strictly a grid, so its not in any way related to monitor geometry.
Additionally, in the multihead case the screen aspect ratio is
very different from the overview monitor geometry, so a lot of
space is lost.
So, instead we just fill the entire inner rectangle of the overview
with the workspace. However, the way the zoom into and out of the
workspace right now is by scaling the workspace so that it covers
the entire monitor. This cannot really work anymore when the workspace
is a different aspect ratio. Furthermore the coordinates of the
window clone actors are of two very different types in the "original
window" case and the "window in a slot case". One is screen relative,
the other is workspace relative. This makes it very hard to compute
the cost of window motion distance in computeWindowMotion.
In order to handle this we change the way workspace actor positioning
and scaling work. All workspace window clone actors are stored in
true screen coordingates, both the original window positions and the
in-a-slot ones. Global scaling of the workspace is never done, we
just reposition everything in both the initial zoom and when the
controls appear from the side.
There is one issue in the initial and final animations, which is that
the clip region we normally have for the workspacesView will limit the
animation of the clones to/from the original positions, so we disable
the clip region during these animations.
https://bugzilla.gnome.org/show_bug.cgi?id=643786
2011-03-02 11:04:03 -05:00
|
|
|
this.positionWindows(WindowPositionFlags.INITIAL);
|
2008-12-22 16:51:34 -05:00
|
|
|
},
|
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
// Animates the return from Overview mode
|
|
|
|
zoomFromOverview : function() {
|
2010-12-16 14:21:12 -05:00
|
|
|
let currentWorkspace = global.screen.get_active_workspace();
|
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
this.leavingOverview = true;
|
2009-07-23 17:36:41 -04:00
|
|
|
|
2012-04-18 07:54:06 -04:00
|
|
|
for (let i = 0; i < this._windows.length; i++) {
|
|
|
|
let clone = this._windows[i];
|
|
|
|
Tweener.removeTweens(clone.actor);
|
|
|
|
}
|
2009-07-23 17:36:41 -04:00
|
|
|
|
2010-03-14 10:47:42 -04:00
|
|
|
if (this._repositionWindowsId > 0) {
|
|
|
|
Mainloop.source_remove(this._repositionWindowsId);
|
|
|
|
this._repositionWindowsId = 0;
|
|
|
|
}
|
2010-03-17 18:23:32 -04:00
|
|
|
this._overviewHiddenId = Main.overview.connect('hidden', Lang.bind(this,
|
|
|
|
this._doneLeavingOverview));
|
2009-08-10 18:31:39 -04:00
|
|
|
|
2011-03-03 16:33:27 -05:00
|
|
|
if (this.metaWorkspace != null && this.metaWorkspace != currentWorkspace)
|
2010-12-16 14:21:12 -05:00
|
|
|
return;
|
|
|
|
|
2009-08-10 18:31:39 -04:00
|
|
|
// Position and scale the windows.
|
2010-07-15 10:21:32 -04:00
|
|
|
for (let i = 0; i < this._windows.length; i++) {
|
2009-01-29 16:21:50 -05:00
|
|
|
let clone = this._windows[i];
|
2012-06-15 09:52:47 -04:00
|
|
|
let overlay = this._windowOverlays[i];
|
|
|
|
|
|
|
|
if (overlay)
|
|
|
|
overlay.hide();
|
2010-01-23 02:37:34 -05:00
|
|
|
|
2010-02-15 17:11:09 -05:00
|
|
|
clone.zoomFromOverview();
|
|
|
|
|
2010-01-23 02:37:34 -05:00
|
|
|
if (clone.metaWindow.showing_on_its_workspace()) {
|
|
|
|
Tweener.addTween(clone.actor,
|
2011-07-19 19:45:53 -04:00
|
|
|
{ x: clone.origX,
|
|
|
|
y: clone.origY,
|
|
|
|
scale_x: 1.0,
|
|
|
|
scale_y: 1.0,
|
2010-01-23 02:37:34 -05:00
|
|
|
time: Overview.ANIMATION_TIME,
|
2011-07-19 19:45:53 -04:00
|
|
|
opacity: 255,
|
|
|
|
transition: 'easeOutQuad'
|
2010-01-23 02:37:34 -05:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// The window is hidden, make it shrink and fade it out
|
|
|
|
Tweener.addTween(clone.actor,
|
|
|
|
{ scale_x: 0,
|
|
|
|
scale_y: 0,
|
|
|
|
opacity: 0,
|
|
|
|
time: Overview.ANIMATION_TIME,
|
2010-05-13 15:46:04 -04:00
|
|
|
transition: 'easeOutQuad'
|
2010-01-23 02:37:34 -05:00
|
|
|
});
|
|
|
|
}
|
2008-12-22 16:51:34 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
destroy : function() {
|
|
|
|
this.actor.destroy();
|
2010-02-18 10:43:58 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onDestroy: function(actor) {
|
2010-03-17 18:23:32 -04:00
|
|
|
if (this._overviewHiddenId) {
|
|
|
|
Main.overview.disconnect(this._overviewHiddenId);
|
|
|
|
this._overviewHiddenId = 0;
|
|
|
|
}
|
2010-02-18 10:43:58 -05:00
|
|
|
Tweener.removeTweens(actor);
|
2009-02-04 09:50:50 -05:00
|
|
|
|
2011-03-03 16:33:27 -05:00
|
|
|
if (this.metaWorkspace) {
|
|
|
|
this.metaWorkspace.disconnect(this._windowAddedId);
|
|
|
|
this.metaWorkspace.disconnect(this._windowRemovedId);
|
|
|
|
}
|
2011-03-01 03:14:56 -05:00
|
|
|
global.screen.disconnect(this._windowEnteredMonitorId);
|
|
|
|
global.screen.disconnect(this._windowLeftMonitorId);
|
2010-02-07 09:25:16 -05:00
|
|
|
|
2010-02-28 01:56:04 -05:00
|
|
|
if (this._repositionWindowsId > 0)
|
|
|
|
Mainloop.source_remove(this._repositionWindowsId);
|
2012-08-08 13:16:28 -04:00
|
|
|
|
|
|
|
if (this._positionWindowsId > 0)
|
|
|
|
Meta.later_remove(this._positionWindowsId);
|
2010-02-28 01:56:04 -05:00
|
|
|
|
2010-02-07 09:25:16 -05:00
|
|
|
// Usually, the windows will be destroyed automatically with
|
|
|
|
// their parent (this.actor), but we might have a zoomed window
|
|
|
|
// which has been reparented to the stage - _windows[0] holds
|
|
|
|
// the desktop window, which is never reparented
|
2010-07-15 10:21:32 -04:00
|
|
|
for (let w = 0; w < this._windows.length; w++)
|
2010-02-07 09:25:16 -05:00
|
|
|
this._windows[w].destroy();
|
2010-03-17 18:23:32 -04:00
|
|
|
this._windows = [];
|
2008-12-22 16:51:34 -05:00
|
|
|
},
|
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
// Sets this.leavingOverview flag to false.
|
|
|
|
_doneLeavingOverview : function() {
|
|
|
|
this.leavingOverview = false;
|
2009-03-17 18:22:25 -04:00
|
|
|
},
|
|
|
|
|
2013-01-14 12:38:02 -05:00
|
|
|
// Tests if @actor belongs to this workspaces and monitor
|
2013-01-14 12:38:02 -05:00
|
|
|
_isMyWindow : function (actor) {
|
|
|
|
let win = actor.meta_window;
|
|
|
|
return (this.metaWorkspace == null || win.located_on_workspace(this.metaWorkspace)) &&
|
2013-01-14 12:38:02 -05:00
|
|
|
(win.get_monitor() == this.monitorIndex);
|
2008-12-22 16:51:34 -05:00
|
|
|
},
|
|
|
|
|
2009-08-11 07:46:10 -04:00
|
|
|
// Tests if @win should be shown in the Overview
|
|
|
|
_isOverviewWindow : function (win) {
|
2010-03-15 09:50:05 -04:00
|
|
|
let tracker = Shell.WindowTracker.get_default();
|
2009-10-15 19:28:29 -04:00
|
|
|
return tracker.is_window_interesting(win.get_meta_window());
|
2008-12-22 16:51:34 -05:00
|
|
|
},
|
|
|
|
|
2009-01-23 14:21:20 -05:00
|
|
|
// Create a clone of a (non-desktop) window and add it to the window list
|
|
|
|
_addWindowClone : function(win) {
|
2011-11-25 18:02:13 -05:00
|
|
|
let clone = new WindowClone(win, this);
|
2010-01-21 21:33:48 -05:00
|
|
|
let overlay = new WindowOverlay(clone, this._windowOverlaysGroup);
|
2012-10-19 12:38:20 -04:00
|
|
|
clone.overlay = overlay;
|
2009-11-11 19:26:52 -05:00
|
|
|
|
2009-01-29 16:21:50 -05:00
|
|
|
clone.connect('selected',
|
|
|
|
Lang.bind(this, this._onCloneSelected));
|
2009-07-23 17:36:41 -04:00
|
|
|
clone.connect('drag-begin',
|
2010-03-16 11:51:24 -04:00
|
|
|
Lang.bind(this, function(clone) {
|
2010-11-15 15:58:27 -05:00
|
|
|
Main.overview.beginWindowDrag();
|
2009-11-11 19:26:52 -05:00
|
|
|
overlay.hide();
|
2009-07-23 17:36:41 -04:00
|
|
|
}));
|
2011-03-08 08:44:47 -05:00
|
|
|
clone.connect('drag-cancelled',
|
|
|
|
Lang.bind(this, function(clone) {
|
|
|
|
Main.overview.cancelledWindowDrag();
|
|
|
|
}));
|
2009-07-23 17:36:41 -04:00
|
|
|
clone.connect('drag-end',
|
2010-03-16 11:51:24 -04:00
|
|
|
Lang.bind(this, function(clone) {
|
2010-11-15 15:58:27 -05:00
|
|
|
Main.overview.endWindowDrag();
|
2009-11-11 19:26:52 -05:00
|
|
|
overlay.show();
|
2009-07-23 17:36:41 -04:00
|
|
|
}));
|
2010-03-21 14:33:52 -04:00
|
|
|
clone.connect('zoom-start',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
this._windowIsZooming = true;
|
|
|
|
}));
|
|
|
|
clone.connect('zoom-end',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
this._windowIsZooming = false;
|
|
|
|
}));
|
2011-01-30 17:03:12 -05:00
|
|
|
clone.connect('size-changed',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
this.positionWindows(0);
|
|
|
|
}));
|
2009-01-23 14:21:20 -05:00
|
|
|
|
2009-01-29 16:21:50 -05:00
|
|
|
this.actor.add_actor(clone.actor);
|
2009-07-23 17:36:41 -04:00
|
|
|
|
2009-11-19 19:39:00 -05:00
|
|
|
overlay.connect('show-close-button', Lang.bind(this, this._onShowOverlayClose));
|
|
|
|
|
2009-01-23 14:21:20 -05:00
|
|
|
this._windows.push(clone);
|
2009-11-11 19:26:52 -05:00
|
|
|
this._windowOverlays.push(overlay);
|
2009-01-23 14:21:20 -05:00
|
|
|
|
2012-04-18 08:03:33 -04:00
|
|
|
return [clone, overlay];
|
2008-12-22 16:51:34 -05:00
|
|
|
},
|
|
|
|
|
2009-11-19 19:39:00 -05:00
|
|
|
_onShowOverlayClose: function (windowOverlay) {
|
2010-07-15 10:21:32 -04:00
|
|
|
for (let i = 0; i < this._windowOverlays.length; i++) {
|
2009-11-19 19:39:00 -05:00
|
|
|
let overlay = this._windowOverlays[i];
|
|
|
|
if (overlay == windowOverlay)
|
|
|
|
continue;
|
|
|
|
overlay.hideCloseButton();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
_isBetterLayout: function(oldLayout, newLayout) {
|
|
|
|
if (oldLayout.scale === undefined)
|
|
|
|
return true;
|
2008-12-22 16:51:34 -05:00
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
let spacePower = (newLayout.space - oldLayout.space) * LAYOUT_SPACE_WEIGHT;
|
|
|
|
let scalePower = (newLayout.scale - oldLayout.scale) * LAYOUT_SCALE_WEIGHT;
|
2009-03-31 17:40:18 -04:00
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
if (newLayout.scale > oldLayout.scale && newLayout.space > oldLayout.space) {
|
|
|
|
// Win win -- better scale and better space
|
|
|
|
return true;
|
|
|
|
} else if (newLayout.scale > oldLayout.scale && newLayout.space <= oldLayout.space) {
|
|
|
|
// Keep new layout only if scale gain outweights aspect space loss
|
|
|
|
return scalePower > spacePower;
|
|
|
|
} else if (newLayout.scale <= oldLayout.scale && newLayout.space > oldLayout.space) {
|
|
|
|
// Keep new layout only if aspect space gain outweights scale loss
|
|
|
|
return spacePower > scalePower;
|
|
|
|
} else {
|
|
|
|
// Lose -- worse scale and space
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-12-13 13:28:25 -05:00
|
|
|
_computeLayout: function(windows, area, rowSpacing, columnSpacing) {
|
2012-08-08 13:27:46 -04:00
|
|
|
// We look for the largest scale that allows us to fit the
|
|
|
|
// largest row/tallest column on the workspace.
|
|
|
|
|
|
|
|
let lastLayout = {};
|
|
|
|
|
|
|
|
for (let numRows = 1; ; numRows++) {
|
|
|
|
let numColumns = Math.ceil(windows.length / numRows);
|
2009-03-31 17:40:18 -04:00
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
// If adding a new row does not change column count just stop
|
|
|
|
// (for instance: 9 windows, with 3 rows -> 3 columns, 4 rows ->
|
|
|
|
// 3 columns as well => just use 3 rows then)
|
|
|
|
if (numColumns == lastLayout.numColumns)
|
|
|
|
break;
|
|
|
|
|
|
|
|
let strategyClass = numRows > 2 ? GridLayoutStrategy : UnalignedLayoutStrategy;
|
2012-12-13 13:28:25 -05:00
|
|
|
let strategy = new strategyClass(this._monitor, rowSpacing, columnSpacing);
|
2012-08-08 13:27:46 -04:00
|
|
|
|
|
|
|
let layout = { area: area, strategy: strategy, numRows: numRows, numColumns: numColumns };
|
|
|
|
strategy.computeLayout(windows, layout);
|
|
|
|
strategy.computeScaleAndSpace(layout);
|
|
|
|
|
|
|
|
if (!this._isBetterLayout(lastLayout, layout))
|
|
|
|
break;
|
|
|
|
|
|
|
|
lastLayout = layout;
|
|
|
|
}
|
2008-12-22 16:51:34 -05:00
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
return lastLayout;
|
2008-12-22 16:51:34 -05:00
|
|
|
},
|
2009-01-21 15:35:20 -05:00
|
|
|
|
2012-08-08 15:47:05 -04:00
|
|
|
_rectEqual: function(one, two) {
|
|
|
|
if (one == two)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return (one.x == two.x &&
|
|
|
|
one.y == two.y &&
|
|
|
|
one.width == two.width &&
|
|
|
|
one.height == two.height);
|
|
|
|
},
|
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
_computeAllWindowSlots: function(windows) {
|
|
|
|
let totalWindows = windows.length;
|
|
|
|
let node = this.actor.get_theme_node();
|
|
|
|
|
|
|
|
// Window grid spacing
|
|
|
|
let columnSpacing = node.get_length('-horizontal-spacing');
|
|
|
|
let rowSpacing = node.get_length('-vertical-spacing');
|
2012-12-13 13:28:25 -05:00
|
|
|
let padding = {
|
|
|
|
left: node.get_padding(St.Side.LEFT),
|
|
|
|
top: node.get_padding(St.Side.TOP),
|
|
|
|
bottom: node.get_padding(St.Side.BOTTOM),
|
|
|
|
right: node.get_padding(St.Side.RIGHT),
|
|
|
|
};
|
2012-08-08 13:27:46 -04:00
|
|
|
|
|
|
|
if (!totalWindows)
|
|
|
|
return [];
|
|
|
|
|
|
|
|
let closeButtonHeight, captionHeight;
|
2012-10-27 12:18:54 -04:00
|
|
|
let leftBorder, rightBorder;
|
2012-08-08 13:27:46 -04:00
|
|
|
if (this._windowOverlays.length) {
|
|
|
|
// All of the overlays have the same chrome sizes,
|
|
|
|
// so just pick the first one.
|
|
|
|
let overlay = this._windowOverlays[0];
|
|
|
|
[closeButtonHeight, captionHeight] = overlay.chromeHeights();
|
2012-10-27 12:18:54 -04:00
|
|
|
[leftBorder, rightBorder] = overlay.chromeWidths();
|
2012-08-08 13:27:46 -04:00
|
|
|
} else {
|
|
|
|
[closeButtonHeight, captionHeight] = [0, 0];
|
2012-12-13 13:28:25 -05:00
|
|
|
[leftBorder, rightBorder] = [0, 0];
|
2009-09-18 15:08:56 -04:00
|
|
|
}
|
2012-08-08 13:27:46 -04:00
|
|
|
|
|
|
|
rowSpacing += captionHeight;
|
2012-12-13 13:28:25 -05:00
|
|
|
columnSpacing += (rightBorder + leftBorder) / 2;
|
|
|
|
padding.top += closeButtonHeight;
|
|
|
|
padding.bottom += captionHeight;
|
|
|
|
padding.left += leftBorder;
|
|
|
|
padding.right += rightBorder;
|
|
|
|
|
|
|
|
let area = {
|
|
|
|
x: this._x + padding.left,
|
|
|
|
y: this._y + padding.top,
|
|
|
|
width: this._width - padding.left - padding.right,
|
|
|
|
height: this._height - padding.top - padding.bottom,
|
|
|
|
};
|
2012-08-08 13:27:46 -04:00
|
|
|
|
2012-08-08 15:47:05 -04:00
|
|
|
if (!this._currentLayout)
|
2012-12-13 13:28:25 -05:00
|
|
|
this._currentLayout = this._computeLayout(windows, area, rowSpacing, columnSpacing);
|
2012-08-08 15:47:05 -04:00
|
|
|
|
|
|
|
let layout = this._currentLayout;
|
2012-08-08 13:27:46 -04:00
|
|
|
let strategy = layout.strategy;
|
|
|
|
|
2012-08-08 15:47:05 -04:00
|
|
|
if (!this._rectEqual(area, layout.area)) {
|
|
|
|
layout.area = area;
|
|
|
|
strategy.computeScaleAndSpace(layout);
|
|
|
|
}
|
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
return strategy.computeWindowSlots(layout, area);
|
2009-09-18 15:08:56 -04:00
|
|
|
},
|
|
|
|
|
2009-01-29 16:21:50 -05:00
|
|
|
_onCloneSelected : function (clone, time) {
|
2011-03-03 16:33:27 -05:00
|
|
|
let wsIndex = undefined;
|
|
|
|
if (this.metaWorkspace)
|
|
|
|
wsIndex = this.metaWorkspace.index();
|
|
|
|
Main.activateWindow(clone.metaWindow, time, wsIndex);
|
2008-12-22 17:06:47 -05:00
|
|
|
},
|
|
|
|
|
2009-02-10 11:15:59 -05:00
|
|
|
// Draggable target interface
|
2010-09-09 22:00:28 -04:00
|
|
|
handleDragOver : function(source, actor, x, y, time) {
|
2011-02-14 17:13:25 -05:00
|
|
|
if (source.realWindow && !this._isMyWindow(source.realWindow))
|
2010-09-09 22:00:28 -04:00
|
|
|
return DND.DragMotionResult.MOVE_DROP;
|
|
|
|
if (source.shellWorkspaceLaunch)
|
|
|
|
return DND.DragMotionResult.COPY_DROP;
|
|
|
|
|
|
|
|
return DND.DragMotionResult.CONTINUE;
|
|
|
|
},
|
|
|
|
|
2009-02-10 11:15:59 -05:00
|
|
|
acceptDrop : function(source, actor, x, y, time) {
|
2011-01-30 20:25:00 -05:00
|
|
|
if (source.realWindow) {
|
2009-02-10 11:15:59 -05:00
|
|
|
let win = source.realWindow;
|
|
|
|
if (this._isMyWindow(win))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Set a hint on the Mutter.Window so its initial position
|
|
|
|
// in the new workspace will be correct
|
2009-08-11 07:46:10 -04:00
|
|
|
win._overviewHint = {
|
2009-02-10 11:15:59 -05:00
|
|
|
x: actor.x,
|
|
|
|
y: actor.y,
|
|
|
|
scale: actor.scale_x
|
|
|
|
};
|
|
|
|
|
|
|
|
let metaWindow = win.get_meta_window();
|
2011-03-03 16:33:27 -05:00
|
|
|
|
|
|
|
// We need to move the window before changing the workspace, because
|
|
|
|
// the move itself could cause a workspace change if the window enters
|
|
|
|
// the primary monitor
|
|
|
|
if (metaWindow.get_monitor() != this.monitorIndex)
|
2011-03-17 13:48:09 -04:00
|
|
|
metaWindow.move_to_monitor(this.monitorIndex);
|
2011-03-03 16:33:27 -05:00
|
|
|
|
|
|
|
let index = this.metaWorkspace ? this.metaWorkspace.index() : global.screen.get_active_workspace_index();
|
|
|
|
metaWindow.change_workspace_by_index(index,
|
2009-02-10 11:15:59 -05:00
|
|
|
false, // don't create workspace
|
|
|
|
time);
|
|
|
|
return true;
|
2009-08-17 20:29:54 -04:00
|
|
|
} else if (source.shellWorkspaceLaunch) {
|
2011-08-11 05:35:23 -04:00
|
|
|
source.shellWorkspaceLaunch({ workspace: this.metaWorkspace ? this.metaWorkspace.index() : -1,
|
2011-01-30 16:09:58 -05:00
|
|
|
timestamp: time });
|
2009-02-10 11:15:59 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2008-12-22 16:51:34 -05:00
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2008-12-22 16:51:34 -05:00
|
|
|
|
2009-01-23 14:21:20 -05:00
|
|
|
Signals.addSignalMethods(Workspace.prototype);
|