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;
|
2013-11-28 19:45:39 -05:00
|
|
|
const GLib = imports.gi.GLib;
|
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;
|
2014-03-21 07:49:51 -04:00
|
|
|
const Atk = imports.gi.Atk;
|
|
|
|
|
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;
|
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;
|
2009-02-10 11:12:58 -05:00
|
|
|
const Tweener = imports.ui.tweener;
|
2012-08-29 18:51:53 -04:00
|
|
|
const WindowManager = imports.ui.windowManager;
|
2008-12-02 11:15:00 -05:00
|
|
|
|
2017-07-18 13:47:27 -04:00
|
|
|
var WINDOW_DND_SIZE = 256;
|
2010-03-09 17:31:06 -05:00
|
|
|
|
2017-06-01 23:35:08 -04:00
|
|
|
var WINDOW_CLONE_MAXIMUM_SCALE = 1.0;
|
2012-01-15 09:30:59 -05:00
|
|
|
|
2017-07-18 13:47:27 -04:00
|
|
|
var CLOSE_BUTTON_FADE_TIME = 0.1;
|
2009-09-04 15:25:17 -04:00
|
|
|
|
2017-07-18 13:47:27 -04:00
|
|
|
var DRAGGING_WINDOW_OPACITY = 100;
|
2010-03-09 17:31:06 -05:00
|
|
|
|
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.
|
2017-07-18 13:47:27 -04:00
|
|
|
var LAYOUT_SCALE_WEIGHT = 1;
|
|
|
|
var LAYOUT_SPACE_WEIGHT = 0.1;
|
2009-09-04 15:25:17 -04:00
|
|
|
|
2017-07-18 13:47:27 -04:00
|
|
|
var WINDOW_ANIMATION_MAX_NUMBER_BLENDING = 3;
|
2014-07-14 13:06:08 -04:00
|
|
|
|
2009-09-04 15:25:17 -04:00
|
|
|
function _interpolate(start, end, step) {
|
|
|
|
return start + (end - start) * step;
|
|
|
|
}
|
|
|
|
|
2017-07-18 13:41:25 -04:00
|
|
|
var WindowCloneLayout = new Lang.Class({
|
2012-08-29 18:51:53 -04:00
|
|
|
Name: 'WindowCloneLayout',
|
|
|
|
Extends: Clutter.LayoutManager,
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init(boundingBox) {
|
2012-08-29 18:51:53 -04:00
|
|
|
this.parent();
|
|
|
|
|
|
|
|
this._boundingBox = boundingBox;
|
|
|
|
},
|
|
|
|
|
|
|
|
get boundingBox() {
|
|
|
|
return this._boundingBox;
|
|
|
|
},
|
|
|
|
|
|
|
|
set boundingBox(b) {
|
|
|
|
this._boundingBox = b;
|
|
|
|
this.layout_changed();
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_makeBoxForWindow(window) {
|
2012-08-29 18:51:53 -04:00
|
|
|
// 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 (from which we compute the bounding box)
|
|
|
|
// paradoxically is the smaller rectangle, containing the positions
|
|
|
|
// of the visible frame. The input rect contains everything,
|
|
|
|
// including the invisible border padding.
|
2014-06-17 11:11:47 -04:00
|
|
|
let inputRect = window.get_buffer_rect();
|
2012-08-29 18:51:53 -04:00
|
|
|
|
|
|
|
let box = new Clutter.ActorBox();
|
|
|
|
|
|
|
|
box.set_origin(inputRect.x - this._boundingBox.x,
|
|
|
|
inputRect.y - this._boundingBox.y);
|
|
|
|
box.set_size(inputRect.width, inputRect.height);
|
|
|
|
|
|
|
|
return box;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_get_preferred_height(container, forWidth) {
|
2012-08-29 18:51:53 -04:00
|
|
|
return [this._boundingBox.height, this._boundingBox.height];
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_get_preferred_width(container, forHeight) {
|
2012-08-29 18:51:53 -04:00
|
|
|
return [this._boundingBox.width, this._boundingBox.width];
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_allocate(container, box, flags) {
|
2017-10-30 20:38:18 -04:00
|
|
|
container.get_children().forEach(child => {
|
2012-08-29 18:51:53 -04:00
|
|
|
let realWindow;
|
|
|
|
if (child == container._delegate._windowClone)
|
|
|
|
realWindow = container._delegate.realWindow;
|
|
|
|
else
|
|
|
|
realWindow = child.source;
|
|
|
|
|
|
|
|
child.allocate(this._makeBoxForWindow(realWindow.meta_window),
|
|
|
|
flags);
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2014-07-17 18:59:06 -04:00
|
|
|
}
|
2012-08-29 18:51:53 -04:00
|
|
|
});
|
|
|
|
|
2017-07-18 13:41:25 -04:00
|
|
|
var WindowClone = new Lang.Class({
|
2011-11-20 12:56:27 -05:00
|
|
|
Name: 'WindowClone',
|
2009-01-29 16:21:50 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init(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
|
|
|
|
2017-02-01 13:01:47 -05:00
|
|
|
this._windowClone = new Clutter.Clone({ source: realWindow });
|
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
|
|
|
|
|
|
|
// The MetaShapedTexture that we clone has a size that includes
|
|
|
|
// the invisible border; this is inconvenient; rather than trying
|
2013-02-22 06:23:56 -05:00
|
|
|
// to compensate all over the place we insert a ClutterActor into
|
2011-08-29 12:25:11 -04:00
|
|
|
// the hierarchy that is sized to only the visible portion.
|
2013-11-04 17:23:44 -05:00
|
|
|
this.actor = new St.Widget({ reactive: true,
|
|
|
|
can_focus: true,
|
2014-03-21 07:49:51 -04:00
|
|
|
accessible_role: Atk.Role.PUSH_BUTTON,
|
2012-08-29 18:51:53 -04:00
|
|
|
layout_manager: new WindowCloneLayout() });
|
2011-08-29 12:25:11 -04:00
|
|
|
|
2013-02-22 06:23:56 -05:00
|
|
|
this.actor.add_child(this._windowClone);
|
2011-08-29 12:25:11 -04:00
|
|
|
|
|
|
|
this.actor._delegate = this;
|
2009-01-29 16:21:50 -05:00
|
|
|
|
2017-08-20 05:19:39 -04:00
|
|
|
this.slotId = 0;
|
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;
|
|
|
|
|
2014-01-31 17:57:20 -05:00
|
|
|
this._windowClone._updateId = this.metaWindow.connect('size-changed',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onRealWindowSizeChanged.bind(this));
|
2017-10-30 20:38:18 -04:00
|
|
|
this._windowClone._destroyId =
|
|
|
|
this.realWindow.connect('destroy', () => {
|
|
|
|
// First destroy the clone and then destroy everything
|
|
|
|
// This will ensure that we never see it in the
|
|
|
|
// _disconnectSignals loop
|
|
|
|
this._windowClone.destroy();
|
|
|
|
this.destroy();
|
|
|
|
});
|
2012-08-29 18:51:53 -04:00
|
|
|
|
|
|
|
this._updateAttachedDialogs();
|
|
|
|
this._computeBoundingBox();
|
|
|
|
this.actor.x = this._boundingBox.x;
|
|
|
|
this.actor.y = this._boundingBox.y;
|
2011-01-30 17:03:12 -05:00
|
|
|
|
2011-09-20 20:54:06 -04:00
|
|
|
let clickAction = new Clutter.ClickAction();
|
2017-12-01 19:27:35 -05:00
|
|
|
clickAction.connect('clicked', this._onClicked.bind(this));
|
|
|
|
clickAction.connect('long-press', this._onLongPress.bind(this));
|
2011-09-20 20:54:06 -04:00
|
|
|
this.actor.add_action(clickAction);
|
2017-12-01 19:27:35 -05:00
|
|
|
this.actor.connect('destroy', this._onDestroy.bind(this));
|
|
|
|
this.actor.connect('key-press-event', this._onKeyPress.bind(this));
|
2009-02-10 11:15:59 -05:00
|
|
|
|
2017-07-18 20:29:16 -04:00
|
|
|
this.actor.connect('enter-event', () => { this.emit('show-chrome'); });
|
|
|
|
this.actor.connect('key-focus-in', () => { this.emit('show-chrome'); });
|
|
|
|
|
|
|
|
this.actor.connect('leave-event', () => { this.emit('hide-chrome'); });
|
|
|
|
this.actor.connect('key-focus-out', () => { this.emit('hide-chrome'); });
|
|
|
|
|
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 });
|
2017-12-01 19:27:35 -05:00
|
|
|
this._draggable.connect('drag-begin', this._onDragBegin.bind(this));
|
|
|
|
this._draggable.connect('drag-cancelled', this._onDragCancelled.bind(this));
|
|
|
|
this._draggable.connect('drag-end', this._onDragEnd.bind(this));
|
2010-03-19 16:46:08 -04:00
|
|
|
this.inDrag = false;
|
2009-09-28 19:48:03 -04:00
|
|
|
|
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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
deleteAll() {
|
2012-08-29 18:51:53 -04:00
|
|
|
// Delete all windows, starting from the bottom-most (most-modal) one
|
|
|
|
|
|
|
|
let windows = this.actor.get_children();
|
|
|
|
for (let i = windows.length - 1; i >= 1; i--) {
|
|
|
|
let realWindow = windows[i].source;
|
|
|
|
let metaWindow = realWindow.meta_window;
|
|
|
|
|
|
|
|
metaWindow.delete(global.get_current_time());
|
|
|
|
}
|
|
|
|
|
|
|
|
this.metaWindow.delete(global.get_current_time());
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
addAttachedDialog(win) {
|
2012-08-29 18:51:53 -04:00
|
|
|
this._doAddAttachedDialog(win, win.get_compositor_private());
|
|
|
|
this._computeBoundingBox();
|
|
|
|
this.emit('size-changed');
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
hasAttachedDialogs() {
|
2014-05-08 05:21:34 -04:00
|
|
|
return this.actor.get_n_children() > 1;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_doAddAttachedDialog(metaWin, realWin) {
|
2012-08-29 18:51:53 -04:00
|
|
|
let clone = new Clutter.Clone({ source: realWin });
|
2017-10-30 20:38:18 -04:00
|
|
|
clone._updateId = metaWin.connect('size-changed', () => {
|
2012-08-29 18:51:53 -04:00
|
|
|
this._computeBoundingBox();
|
|
|
|
this.emit('size-changed');
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
|
|
|
clone._destroyId = realWin.connect('destroy', () => {
|
2012-08-29 18:51:53 -04:00
|
|
|
clone.destroy();
|
|
|
|
|
|
|
|
this._computeBoundingBox();
|
|
|
|
this.emit('size-changed');
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2012-08-29 18:51:53 -04:00
|
|
|
this.actor.add_child(clone);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateAttachedDialogs() {
|
2017-10-30 20:38:18 -04:00
|
|
|
let iter = win => {
|
2012-08-29 18:51:53 -04:00
|
|
|
let actor = win.get_compositor_private();
|
|
|
|
|
|
|
|
if (!actor)
|
|
|
|
return false;
|
|
|
|
if (!win.is_attached_dialog())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
this._doAddAttachedDialog(win, actor);
|
|
|
|
win.foreach_transient(iter);
|
|
|
|
return true;
|
2017-10-30 20:38:18 -04:00
|
|
|
};
|
2012-08-29 18:51:53 -04:00
|
|
|
this.metaWindow.foreach_transient(iter);
|
|
|
|
},
|
|
|
|
|
|
|
|
get boundingBox() {
|
|
|
|
return this._boundingBox;
|
|
|
|
},
|
|
|
|
|
2014-05-08 12:13:32 -04:00
|
|
|
get width() {
|
|
|
|
return this._boundingBox.width;
|
|
|
|
},
|
|
|
|
|
|
|
|
get height() {
|
|
|
|
return this._boundingBox.height;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
getOriginalPosition() {
|
2012-08-29 18:51:53 -04:00
|
|
|
return [this._boundingBox.x, this._boundingBox.y];
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_computeBoundingBox() {
|
2014-09-18 17:02:45 -04:00
|
|
|
let rect = this.metaWindow.get_frame_rect();
|
2012-08-29 18:51:53 -04:00
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
this.actor.get_children().forEach(child => {
|
2012-08-29 18:51:53 -04:00
|
|
|
let realWindow;
|
|
|
|
if (child == this._windowClone)
|
|
|
|
realWindow = this.realWindow;
|
|
|
|
else
|
|
|
|
realWindow = child.source;
|
|
|
|
|
|
|
|
let metaWindow = realWindow.meta_window;
|
2014-09-18 17:02:45 -04:00
|
|
|
rect = rect.union(metaWindow.get_frame_rect());
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2012-08-29 18:51:53 -04:00
|
|
|
|
2014-05-08 12:13:32 -04:00
|
|
|
// Convert from a MetaRectangle to a native JS object
|
|
|
|
this._boundingBox = { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
|
2012-08-29 18:51:53 -04:00
|
|
|
this.actor.layout_manager.boundingBox = rect;
|
|
|
|
},
|
|
|
|
|
2013-01-18 20:22:15 -05:00
|
|
|
// Find the actor just below us, respecting reparenting done
|
|
|
|
// by DND code
|
2017-10-30 20:03:21 -04:00
|
|
|
getActualStackAbove() {
|
2013-01-18 20:22:15 -05:00
|
|
|
if (this._stackAbove == null)
|
|
|
|
return null;
|
|
|
|
|
2013-06-29 05:47:59 -04:00
|
|
|
if (this.inDrag) {
|
2013-01-18 20:22:15 -05:00
|
|
|
if (this._stackAbove._delegate)
|
|
|
|
return this._stackAbove._delegate.getActualStackAbove();
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
} else {
|
|
|
|
return this._stackAbove;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setStackAbove(actor) {
|
2009-09-28 19:48:03 -04:00
|
|
|
this._stackAbove = actor;
|
2012-10-22 10:46:36 -04:00
|
|
|
if (this.inDrag)
|
|
|
|
// We'll fix up the stack after the drag
|
2009-09-28 19:48:03 -04:00
|
|
|
return;
|
2013-01-18 20:22:15 -05:00
|
|
|
|
|
|
|
let actualAbove = this.getActualStackAbove();
|
|
|
|
if (actualAbove == null)
|
2010-07-15 10:21:32 -04:00
|
|
|
this.actor.lower_bottom();
|
|
|
|
else
|
2013-01-18 20:22:15 -05:00
|
|
|
this.actor.raise(actualAbove);
|
2009-09-28 19:48:03 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
destroy() {
|
2009-01-29 16:21:50 -05:00
|
|
|
this.actor.destroy();
|
|
|
|
},
|
2009-02-10 11:15:59 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_disconnectSignals() {
|
2017-10-30 20:38:18 -04:00
|
|
|
this.actor.get_children().forEach(child => {
|
2012-08-29 18:51:53 -04:00
|
|
|
let realWindow;
|
|
|
|
if (child == this._windowClone)
|
|
|
|
realWindow = this.realWindow;
|
|
|
|
else
|
|
|
|
realWindow = child.source;
|
2011-08-29 12:25:11 -04:00
|
|
|
|
2014-02-15 07:05:46 -05:00
|
|
|
realWindow.meta_window.disconnect(child._updateId);
|
2012-08-29 18:51:53 -04:00
|
|
|
realWindow.disconnect(child._destroyId);
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2011-08-29 12:25:11 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onRealWindowSizeChanged() {
|
2012-08-29 18:51:53 -04:00
|
|
|
this._computeBoundingBox();
|
2011-08-29 12:25:11 -04:00
|
|
|
this.emit('size-changed');
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onDestroy() {
|
2012-08-29 18:51:53 -04:00
|
|
|
this._disconnectSignals();
|
2011-02-03 13:25:59 -05:00
|
|
|
|
2010-03-17 18:23:32 -04:00
|
|
|
this.metaWindow._delegate = null;
|
|
|
|
this.actor._delegate = null;
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_activate() {
|
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());
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onKeyPress(actor, event) {
|
2013-11-04 17:23:44 -05:00
|
|
|
let symbol = event.get_key_symbol();
|
|
|
|
let isEnter = (symbol == Clutter.KEY_Return || symbol == Clutter.KEY_KP_Enter);
|
|
|
|
if (isEnter) {
|
|
|
|
this._activate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onClicked(action, actor) {
|
2013-11-04 17:23:44 -05:00
|
|
|
this._activate();
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onLongPress(action, actor, state) {
|
2011-09-20 20:54:06 -04:00
|
|
|
// 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) {
|
2015-10-16 12:32:42 -04:00
|
|
|
let event = Clutter.get_current_event();
|
|
|
|
this._dragTouchSequence = event.get_event_sequence();
|
|
|
|
|
2011-09-20 20:54:06 -04:00
|
|
|
// A click cancels a long-press before any click handler is
|
|
|
|
// run - make sure to not start a drag in that case
|
2017-10-30 20:38:18 -04:00
|
|
|
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
|
|
|
|
if (this._selected)
|
|
|
|
return;
|
|
|
|
let [x, y] = action.get_coords();
|
|
|
|
action.release();
|
|
|
|
this._draggable.startDrag(x, y, global.get_current_time(), this._dragTouchSequence);
|
|
|
|
});
|
2017-07-18 20:31:04 -04:00
|
|
|
} else {
|
|
|
|
this.emit('show-chrome');
|
2011-09-20 20:54:06 -04:00
|
|
|
}
|
|
|
|
return true;
|
2009-01-29 16:21:50 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onDragBegin(draggable, time) {
|
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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
handleDragOver(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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
acceptDrop(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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onDragCancelled(draggable, time) {
|
2011-03-08 08:44:47 -05:00
|
|
|
this.emit('drag-cancelled');
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onDragEnd(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
|
|
|
|
*/
|
2017-07-18 13:41:25 -04:00
|
|
|
var WindowOverlay = new Lang.Class({
|
2011-11-20 12:56:27 -05:00
|
|
|
Name: 'WindowOverlay',
|
2009-11-11 19:26:52 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init(windowClone, parentActor) {
|
2009-11-11 19:26:52 -05:00
|
|
|
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;
|
2014-03-21 07:49:51 -04:00
|
|
|
windowClone.actor.label_actor = title;
|
2009-11-11 19:26:52 -05:00
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
this._updateCaptionId = metaWindow.connect('notify::title', w => {
|
|
|
|
this.title.text = w.title;
|
|
|
|
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;
|
2017-12-01 19:27:35 -05:00
|
|
|
button.connect('clicked', this._closeWindow.bind(this));
|
2010-02-17 23:15:10 -05:00
|
|
|
|
2017-12-01 19:27:35 -05:00
|
|
|
windowClone.actor.connect('destroy', this._onDestroy.bind(this));
|
|
|
|
windowClone.connect('show-chrome', this._onShowChrome.bind(this));
|
|
|
|
windowClone.connect('hide-chrome', this._onHideChrome.bind(this));
|
2009-11-11 19:26:52 -05:00
|
|
|
|
2009-11-21 00:46:02 -05:00
|
|
|
this._windowAddedId = 0;
|
2009-11-11 19:26:52 -05:00
|
|
|
|
|
|
|
button.hide();
|
2017-06-01 10:11:56 -04:00
|
|
|
title.hide();
|
2009-11-11 19:26:52 -05:00
|
|
|
|
|
|
|
this.title = title;
|
|
|
|
this.closeButton = button;
|
|
|
|
|
2017-03-14 19:36:26 -04:00
|
|
|
// Don't block drop targets
|
|
|
|
Shell.util_set_hidden_from_pick(this.title, true);
|
|
|
|
Shell.util_set_hidden_from_pick(this.border, true);
|
|
|
|
|
2012-10-27 12:18:54 -04:00
|
|
|
parentActor.add_actor(this.border);
|
2017-06-01 10:32:45 -04:00
|
|
|
parentActor.add_actor(this.title);
|
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',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onStyleChanged.bind(this));
|
2010-02-17 23:15:28 -05:00
|
|
|
button.connect('style-changed',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onStyleChanged.bind(this));
|
|
|
|
this.border.connect('style-changed', this._onStyleChanged.bind(this));
|
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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
hide() {
|
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;
|
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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
show() {
|
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
|
|
|
|
2017-07-22 05:47:20 -04:00
|
|
|
if (this._windowClone.actor['has-pointer'])
|
2012-10-27 12:18:54 -04:00
|
|
|
this._animateVisible();
|
2009-11-11 19:26:52 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
chromeHeights() {
|
2012-10-27 12:18:54 -04:00
|
|
|
return [Math.max(this.borderSize, this.closeButton.height - this.closeButton._overlap),
|
2017-06-01 10:32:45 -04:00
|
|
|
(this.title.height - this.borderSize) / 2];
|
2009-11-11 19:26:52 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
chromeWidths() {
|
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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
relayout(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(border);
|
2014-08-26 13:10:02 -04:00
|
|
|
Tweener.removeTweens(title);
|
2013-02-16 11:26:28 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
2017-06-01 10:36:10 -04:00
|
|
|
let titleX = cloneX + (cloneWidth - title.width) / 2;
|
2017-06-01 10:32:45 -04:00
|
|
|
let titleY = cloneY + cloneHeight - (title.height - this.borderSize) / 2;
|
2011-12-04 15:40:40 -05:00
|
|
|
|
2017-06-01 10:36:10 -04:00
|
|
|
if (animate) {
|
|
|
|
this._animateOverlayActor(title, Math.floor(titleX), Math.floor(titleY), title.width);
|
|
|
|
} else {
|
|
|
|
title.width = title.width;
|
2011-12-04 15:40:40 -05:00
|
|
|
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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_animateOverlayActor(actor, x, y, width, height) {
|
2012-10-27 12:18:54 -04:00
|
|
|
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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_closeWindow(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',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onWindowAdded.bind(this));
|
2009-11-21 00:46:02 -05:00
|
|
|
|
2012-08-29 18:51:53 -04:00
|
|
|
this._windowClone.deleteAll();
|
2009-11-21 00:46:02 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_windowCanClose() {
|
2014-05-08 05:21:34 -04:00
|
|
|
return this._windowClone.metaWindow.can_close() &&
|
|
|
|
!this._windowClone.hasAttachedDialogs();
|
2013-04-26 11:32:40 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onWindowAdded(workspace, win) {
|
2009-11-21 00:46:02 -05:00
|
|
|
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
|
2017-10-30 20:38:18 -04:00
|
|
|
let id = Mainloop.idle_add(() => {
|
|
|
|
this._windowClone.emit('selected');
|
|
|
|
return GLib.SOURCE_REMOVE;
|
|
|
|
});
|
2014-04-10 13:26:52 -04:00
|
|
|
GLib.Source.set_name_by_id(id, '[gnome-shell] this._windowClone.emit');
|
2009-11-21 00:46:02 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onDestroy() {
|
2009-11-21 00:46:02 -05:00
|
|
|
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();
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_animateVisible() {
|
2012-10-27 12:18:54 -04:00
|
|
|
this._parentActor.raise_top();
|
2012-11-23 22:04:38 -05:00
|
|
|
|
2017-06-01 10:11:56 -04:00
|
|
|
let toAnimate = [this.border, this.title];
|
|
|
|
if (this._windowCanClose())
|
|
|
|
toAnimate.push(this.closeButton);
|
|
|
|
|
|
|
|
toAnimate.forEach(a => {
|
|
|
|
a.show();
|
|
|
|
a.opacity = 0;
|
|
|
|
Tweener.addTween(a,
|
2013-04-26 11:32:40 -04:00
|
|
|
{ opacity: 255,
|
|
|
|
time: CLOSE_BUTTON_FADE_TIME,
|
|
|
|
transition: 'easeOutQuad' });
|
2017-06-01 10:11:56 -04:00
|
|
|
});
|
2009-11-21 00:46:02 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_animateInvisible() {
|
2017-06-01 10:11:56 -04:00
|
|
|
[this.closeButton, this.border, this.title].forEach(a => {
|
|
|
|
a.opacity = 255;
|
|
|
|
Tweener.addTween(a,
|
|
|
|
{ opacity: 0,
|
|
|
|
time: CLOSE_BUTTON_FADE_TIME,
|
|
|
|
transition: 'easeInQuad' });
|
|
|
|
});
|
2012-11-23 22:04:38 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onShowChrome() {
|
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)
|
2017-07-18 20:29:16 -04:00
|
|
|
return;
|
2012-10-27 12:18:54 -04:00
|
|
|
|
2017-08-20 11:53:41 -04:00
|
|
|
this._windowClone.actor.grab_key_focus();
|
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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onHideChrome() {
|
2014-04-10 13:26:52 -04:00
|
|
|
if (this._idleToggleCloseId == 0) {
|
2017-12-01 19:27:35 -05:00
|
|
|
this._idleToggleCloseId = Mainloop.timeout_add(750, this._idleToggleCloseButton.bind(this));
|
2014-04-10 13:26:52 -04:00
|
|
|
GLib.Source.set_name_by_id(this._idleToggleCloseId, '[gnome-shell] this._idleToggleCloseButton');
|
|
|
|
}
|
2009-11-19 19:39:00 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_idleToggleCloseButton() {
|
2009-11-19 19:39:00 -05:00
|
|
|
this._idleToggleCloseId = 0;
|
2012-10-27 12:18:54 -04:00
|
|
|
|
2017-07-22 05:47:20 -04:00
|
|
|
if (!this._windowClone.actor['has-pointer'] &&
|
|
|
|
!this.closeButton['has-pointer'])
|
2012-11-23 22:04:38 -05:00
|
|
|
this._animateInvisible();
|
2012-10-27 12:18:54 -04:00
|
|
|
|
2013-11-28 19:45:39 -05:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2009-11-19 19:39:00 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
hideCloseButton() {
|
2009-11-19 19:39:00 -05:00
|
|
|
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();
|
2017-06-01 10:11:56 -04:00
|
|
|
this.title.hide();
|
2009-11-11 19:26:52 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onStyleChanged() {
|
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);
|
|
|
|
|
2017-07-18 13:47:27 -04:00
|
|
|
var 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
|
|
|
|
2013-02-28 15:50:57 -05:00
|
|
|
// Window Thumbnail Layout Algorithm
|
|
|
|
// =================================
|
|
|
|
//
|
|
|
|
// General overview
|
|
|
|
// ----------------
|
|
|
|
//
|
|
|
|
// The window thumbnail layout algorithm calculates some optimal layout
|
|
|
|
// by computing layouts with some number of rows, calculating how good
|
|
|
|
// each layout is, and stopping iterating when it finds one that is worse
|
|
|
|
// than the previous layout. A layout consists of which windows are in
|
|
|
|
// which rows, row sizes and other general state tracking that would make
|
|
|
|
// calculating window positions from this information fairly easy.
|
|
|
|
//
|
|
|
|
// We don't compute some global order of windows right now for optimal
|
|
|
|
// travel when animating into the overview; windows are assumed to be
|
|
|
|
// in some stable order.
|
|
|
|
//
|
|
|
|
// After a layout is computed that's considered the best layout, we
|
|
|
|
// compute the layout scale to fit it in the area, and then compute
|
|
|
|
// slots (sizes and positions) for each thumbnail.
|
|
|
|
//
|
|
|
|
// Layout generation
|
|
|
|
// -----------------
|
|
|
|
//
|
|
|
|
// Layout generation is naive and simple: we simply add windows to a row
|
|
|
|
// until we've added too many windows to a row, and then make a new row,
|
|
|
|
// until we have our required N rows. The potential issue with this strategy
|
|
|
|
// is that we may have too many windows at the bottom in some pathological
|
|
|
|
// cases, which tends to make the thumbnails have the shape of a pile of
|
|
|
|
// sand with a peak, with one window at the top.
|
|
|
|
//
|
|
|
|
// Scaling factors
|
|
|
|
// ---------------
|
|
|
|
//
|
|
|
|
// Thumbnail position is mostly straightforward -- the main issue is
|
|
|
|
// computing an optimal scale for each window that fits the constraints,
|
|
|
|
// and doesn't make the thumbnail too small to see. There are two factors
|
|
|
|
// involved in thumbnail scale to make sure that these two goals are met:
|
|
|
|
// the window scale (calculated by _computeWindowScale) and the layout
|
|
|
|
// scale (calculated by computeSizeAndScale).
|
|
|
|
//
|
|
|
|
// The calculation logic becomes slightly more complicated because row
|
|
|
|
// and column spacing are not scaled, they're constant, so we can't
|
|
|
|
// simply generate a bunch of window positions and then scale it. In
|
|
|
|
// practice, it's not too bad -- we can simply try to fit the layout
|
|
|
|
// in the input area minus whatever spacing we have, and then add
|
|
|
|
// it back afterwards.
|
|
|
|
//
|
|
|
|
// The window scale is constant for the window's size regardless of the
|
|
|
|
// input area or the layout scale or rows or anything else, and right
|
|
|
|
// now just enlarges the window if it's too small. The fact that this
|
|
|
|
// factor is stable makes it easy to calculate, so there's no sense
|
|
|
|
// in not applying it in most calculations.
|
|
|
|
//
|
|
|
|
// The layout scale depends on the input area, the rows, etc, but is the
|
|
|
|
// same for the entire layout, rather than being per-window. After
|
|
|
|
// generating the rows of windows, we basically do some basic math to
|
|
|
|
// fit the full, unscaled layout to the input area, as described above.
|
|
|
|
//
|
|
|
|
// With these two factors combined, the final scale of each thumbnail is
|
|
|
|
// simply windowScale * layoutScale... almost.
|
|
|
|
//
|
|
|
|
// There's one additional constraint: the thumbnail scale must never be
|
|
|
|
// larger than WINDOW_CLONE_MAXIMUM_SCALE, which means that the inequality:
|
|
|
|
//
|
|
|
|
// windowScale * layoutScale <= WINDOW_CLONE_MAXIMUM_SCALE
|
|
|
|
//
|
|
|
|
// must always be true. This is for each individual window -- while we
|
|
|
|
// could adjust layoutScale to make the largest thumbnail smaller than
|
|
|
|
// WINDOW_CLONE_MAXIMUM_SCALE, it would shrink windows which are already
|
2013-02-28 16:08:19 -05:00
|
|
|
// under the inequality. To solve this, we simply cheat: we simply keep
|
|
|
|
// each window's "cell" area to be the same, but we shrink the thumbnail
|
|
|
|
// and center it horizontally, and align it to the bottom vertically.
|
2013-02-28 15:50:57 -05:00
|
|
|
|
2017-07-18 13:41:25 -04:00
|
|
|
var LayoutStrategy = new Lang.Class({
|
2012-08-08 13:27:46 -04:00
|
|
|
Name: 'LayoutStrategy',
|
|
|
|
Abstract: true,
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init(monitor, rowSpacing, columnSpacing) {
|
2012-08-08 13:27:46 -04:00
|
|
|
this._monitor = monitor;
|
|
|
|
this._rowSpacing = rowSpacing;
|
|
|
|
this._columnSpacing = columnSpacing;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_newRow() {
|
2012-08-08 13:27:46 -04:00
|
|
|
// 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
|
|
|
|
return { x: 0, y: 0,
|
|
|
|
width: 0, height: 0,
|
|
|
|
fullWidth: 0, fullHeight: 0,
|
|
|
|
windows: [] };
|
|
|
|
},
|
|
|
|
|
2013-02-28 15:00:59 -05:00
|
|
|
// Computes and returns an individual scaling factor for @window,
|
|
|
|
// to be applied in addition to the overal layout scale.
|
2017-10-30 20:03:21 -04:00
|
|
|
_computeWindowScale(window) {
|
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.
|
2014-05-08 12:13:32 -04:00
|
|
|
let ratio = window.height / this._monitor.height;
|
2012-10-26 11:43:38 -04:00
|
|
|
|
|
|
|
// 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]
|
2013-02-28 15:00:59 -05:00
|
|
|
return _interpolate(1.5, 1, ratio);
|
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
|
2013-02-25 19:23:39 -05:00
|
|
|
// (optionally) for each row in @layout.rows. This method is
|
|
|
|
// intended to be called by subclasses.
|
2017-10-30 20:03:21 -04:00
|
|
|
_computeRowSizes(layout) {
|
2012-08-08 13:27:46 -04:00
|
|
|
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.
|
2017-10-30 20:03:21 -04:00
|
|
|
computeLayout(windows, layout) {
|
2012-08-08 13:27:46 -04:00
|
|
|
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.
|
2017-10-30 20:03:21 -04:00
|
|
|
computeScaleAndSpace(layout) {
|
2012-08-08 13:27:46 -04:00
|
|
|
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;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
computeWindowSlots(layout, area) {
|
2012-08-08 13:27:46 -04:00
|
|
|
this._computeRowSizes(layout);
|
|
|
|
|
2013-02-28 14:23:19 -05:00
|
|
|
let { rows: rows, scale: scale } = layout;
|
2012-08-08 13:27:46 -04:00
|
|
|
|
|
|
|
let slots = [];
|
|
|
|
|
2013-02-25 21:40:13 -05:00
|
|
|
// Do this in three parts.
|
2015-03-03 14:07:22 -05:00
|
|
|
let heightWithoutSpacing = 0;
|
2013-02-25 21:40:13 -05:00
|
|
|
for (let i = 0; i < rows.length; i++) {
|
|
|
|
let row = rows[i];
|
2015-03-03 14:07:22 -05:00
|
|
|
heightWithoutSpacing += row.height;
|
2013-02-25 21:40:13 -05:00
|
|
|
}
|
|
|
|
|
2015-03-03 14:07:22 -05:00
|
|
|
let verticalSpacing = (rows.length - 1) * this._rowSpacing;
|
|
|
|
let additionalVerticalScale = Math.min(1, (area.height - verticalSpacing) / heightWithoutSpacing);
|
2013-02-25 21:40:13 -05:00
|
|
|
|
2015-03-03 14:07:22 -05:00
|
|
|
// keep track how much smaller the grid becomes due to scaling
|
|
|
|
// so it can be centered again
|
|
|
|
let compensation = 0
|
2012-08-08 13:27:46 -04:00
|
|
|
let y = 0;
|
2013-02-25 21:40:13 -05:00
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
for (let i = 0; i < rows.length; i++) {
|
|
|
|
let row = rows[i];
|
2013-04-22 18:04:56 -04:00
|
|
|
|
|
|
|
// If this window layout row doesn't fit in the actual
|
|
|
|
// geometry, then apply an additional scale to it.
|
2015-03-03 14:07:22 -05:00
|
|
|
let horizontalSpacing = (row.windows.length - 1) * this._columnSpacing;
|
|
|
|
let widthWithoutSpacing = row.width - horizontalSpacing;
|
|
|
|
let additionalHorizontalScale = Math.min(1, (area.width - horizontalSpacing) / widthWithoutSpacing);
|
|
|
|
|
|
|
|
if (additionalHorizontalScale < additionalVerticalScale) {
|
|
|
|
row.additionalScale = additionalHorizontalScale;
|
|
|
|
// Only consider the scaling in addition to the vertical scaling for centering.
|
|
|
|
compensation += (additionalVerticalScale - additionalHorizontalScale) * row.height;
|
|
|
|
} else {
|
|
|
|
row.additionalScale = additionalVerticalScale;
|
|
|
|
// No compensation when scaling vertically since centering based on a too large
|
|
|
|
// height would undo what vertical scaling is trying to achieve.
|
|
|
|
}
|
2013-04-22 18:04:56 -04:00
|
|
|
|
2015-03-03 14:07:22 -05:00
|
|
|
row.x = area.x + (Math.max(area.width - (widthWithoutSpacing * row.additionalScale + horizontalSpacing), 0) / 2)
|
|
|
|
row.y = area.y + (Math.max(area.height - (heightWithoutSpacing + verticalSpacing), 0) / 2) + y;
|
|
|
|
y += row.height * row.additionalScale + this._rowSpacing;
|
2012-08-08 13:27:46 -04:00
|
|
|
}
|
|
|
|
|
2015-03-03 14:07:22 -05:00
|
|
|
compensation = compensation / 2;
|
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
for (let i = 0; i < rows.length; i++) {
|
|
|
|
let row = rows[i];
|
2013-02-25 19:23:39 -05:00
|
|
|
let x = row.x;
|
2012-08-08 13:27:46 -04:00
|
|
|
for (let j = 0; j < row.windows.length; j++) {
|
|
|
|
let window = row.windows[j];
|
|
|
|
|
2013-04-22 18:04:56 -04:00
|
|
|
let s = scale * this._computeWindowScale(window) * row.additionalScale;
|
2014-05-08 12:13:32 -04:00
|
|
|
let cellWidth = window.width * s;
|
|
|
|
let cellHeight = window.height * s;
|
2013-02-28 16:08:19 -05:00
|
|
|
|
2012-10-27 22:46:27 -04:00
|
|
|
s = Math.min(s, WINDOW_CLONE_MAXIMUM_SCALE);
|
2014-05-08 12:13:32 -04:00
|
|
|
let cloneWidth = window.width * s;
|
2013-02-28 16:08:19 -05:00
|
|
|
|
|
|
|
let cloneX = x + (cellWidth - cloneWidth) / 2;
|
2015-03-03 14:07:22 -05:00
|
|
|
let cloneY = row.y + row.height * row.additionalScale - cellHeight + compensation;
|
2012-08-08 13:27:46 -04:00
|
|
|
|
2017-08-22 13:05:11 -04:00
|
|
|
// Align with the pixel grid to prevent blurry windows at scale = 1
|
|
|
|
cloneX = Math.floor(cloneX);
|
|
|
|
cloneY = Math.floor(cloneY);
|
|
|
|
|
2013-02-28 16:08:19 -05:00
|
|
|
slots.push([cloneX, cloneY, s, window]);
|
|
|
|
x += cellWidth + this._columnSpacing;
|
2012-08-08 13:27:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return slots;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-07-18 13:41:25 -04:00
|
|
|
var UnalignedLayoutStrategy = new Lang.Class({
|
2012-08-08 13:27:46 -04:00
|
|
|
Name: 'UnalignedLayoutStrategy',
|
|
|
|
Extends: LayoutStrategy,
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_computeRowSizes(layout) {
|
2012-08-08 13:27:46 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_keepSameRow(row, window, width, idealRowWidth) {
|
2012-08-08 13:27:46 -04:00
|
|
|
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;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_sortRow(row) {
|
2013-04-24 13:53:11 -04:00
|
|
|
// Sort windows horizontally to minimize travel distance
|
2017-10-30 20:38:18 -04:00
|
|
|
row.windows.sort((a, b) => a.realWindow.x - b.realWindow.x);
|
2013-04-24 13:53:11 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
computeLayout(windows, layout) {
|
2012-08-08 13:27:46 -04:00
|
|
|
let numRows = layout.numRows;
|
|
|
|
|
|
|
|
let rows = [];
|
|
|
|
let totalWidth = 0;
|
|
|
|
for (let i = 0; i < windows.length; i++) {
|
2013-02-28 16:01:15 -05:00
|
|
|
let window = windows[i];
|
|
|
|
let s = this._computeWindowScale(window);
|
2014-05-08 12:13:32 -04:00
|
|
|
totalWidth += window.width * s;
|
2012-08-08 13:27:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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];
|
2013-02-28 15:00:59 -05:00
|
|
|
let s = this._computeWindowScale(window);
|
2014-05-08 12:13:32 -04:00
|
|
|
let width = window.width * s;
|
|
|
|
let height = window.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];
|
2013-08-31 16:57:41 -04:00
|
|
|
this._sortRow(row);
|
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-02-25 22:38:30 -05:00
|
|
|
function padArea(area, padding) {
|
|
|
|
return {
|
|
|
|
x: area.x + padding.left,
|
|
|
|
y: area.y + padding.top,
|
|
|
|
width: area.width - padding.left - padding.right,
|
|
|
|
height: area.height - padding.top - padding.bottom,
|
|
|
|
};
|
|
|
|
}
|
2012-08-08 13:27:46 -04:00
|
|
|
|
2013-09-11 10:41:54 -04:00
|
|
|
function rectEqual(one, two) {
|
|
|
|
if (one == two)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!one || !two)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return (one.x == two.x &&
|
|
|
|
one.y == two.y &&
|
|
|
|
one.width == two.width &&
|
|
|
|
one.height == two.height);
|
|
|
|
}
|
|
|
|
|
2017-08-20 05:19:39 -04:00
|
|
|
const WorkspaceActor = new Lang.Class({
|
|
|
|
Name: 'WorkspaceActor',
|
|
|
|
Extends: St.Widget,
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
vfunc_get_focus_chain() {
|
2017-08-20 05:19:39 -04:00
|
|
|
return this.get_children().filter(c => c.visible).sort((a,b) => {
|
|
|
|
let cloneA = (a._delegate && a._delegate instanceof WindowClone) ? a._delegate: null;
|
|
|
|
let cloneB = (b._delegate && b._delegate instanceof WindowClone) ? b._delegate: null;
|
|
|
|
if (cloneA && cloneB)
|
|
|
|
return cloneA.slotId - cloneB.slotId;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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
|
|
|
*/
|
2017-07-18 13:41:25 -04:00
|
|
|
var Workspace = new Lang.Class({
|
2011-11-20 12:56:27 -05:00
|
|
|
Name: 'Workspace',
|
2008-12-22 16:51:34 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init(metaWorkspace, monitorIndex) {
|
2010-03-16 11:51:24 -04:00
|
|
|
// When dragging a window, we use this slot for reserve space.
|
|
|
|
this._reservedSlot = null;
|
2017-06-12 22:24:12 -04:00
|
|
|
this._reservedSlotWindow = null;
|
2010-02-14 18:32:57 -05:00
|
|
|
this.metaWorkspace = metaWorkspace;
|
2013-02-25 18:25:27 -05:00
|
|
|
|
|
|
|
// The full geometry is the geometry we should try and position
|
|
|
|
// windows for. The actual geometry we allocate may be less than
|
|
|
|
// this, like if the workspace switcher is slid out.
|
|
|
|
this._fullGeometry = null;
|
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
|
|
|
|
2013-02-25 18:34:17 -05:00
|
|
|
// The actual geometry is the geometry we need to arrange windows
|
|
|
|
// in. If this is a smaller area than the full geometry, we'll
|
|
|
|
// do some simple aspect ratio like math to fit the layout calculated
|
|
|
|
// for the full geometry into this area.
|
|
|
|
this._actualGeometry = null;
|
2017-09-17 04:37:17 -04:00
|
|
|
this._actualGeometryLater = 0;
|
2013-02-25 18:34:17 -05:00
|
|
|
|
|
|
|
this._currentLayout = null;
|
|
|
|
|
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];
|
2013-02-22 06:23:56 -05:00
|
|
|
this._windowOverlaysGroup = new Clutter.Actor();
|
2010-01-21 21:33:48 -05:00
|
|
|
// Without this the drop area will be overlapped.
|
|
|
|
this._windowOverlaysGroup.set_size(0, 0);
|
|
|
|
|
2017-08-20 05:19:39 -04:00
|
|
|
this.actor = new WorkspaceActor({ 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
|
|
|
|
2013-05-08 21:53:20 -04:00
|
|
|
this._dropRect = new Clutter.Actor({ opacity: 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
|
|
|
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
|
|
|
|
2017-12-01 19:27:35 -05:00
|
|
|
this.actor.connect('destroy', this._onDestroy.bind(this));
|
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])) {
|
2013-03-10 14:42:47 -04:00
|
|
|
this._addWindowClone(windows[i], true);
|
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',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._windowAdded.bind(this));
|
2011-03-03 16:33:27 -05:00
|
|
|
this._windowRemovedId = this.metaWorkspace.connect('window-removed',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._windowRemoved.bind(this));
|
2011-03-03 16:33:27 -05:00
|
|
|
}
|
2011-03-01 03:14:56 -05:00
|
|
|
this._windowEnteredMonitorId = global.screen.connect('window-entered-monitor',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._windowEnteredMonitor.bind(this));
|
2011-03-01 03:14:56 -05:00
|
|
|
this._windowLeftMonitorId = global.screen.connect('window-left-monitor',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._windowLeftMonitor.bind(this));
|
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;
|
2014-05-08 13:16:10 -04:00
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
this.actor.connect('notify::mapped', () => {
|
2014-05-08 13:16:10 -04:00
|
|
|
if (this.actor.mapped)
|
|
|
|
this._syncActualGeometry();
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2008-12-22 17:06:47 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setFullGeometry(geom) {
|
2013-09-11 10:41:54 -04:00
|
|
|
if (rectEqual(this._fullGeometry, geom))
|
|
|
|
return;
|
|
|
|
|
2013-02-25 18:25:27 -05:00
|
|
|
this._fullGeometry = geom;
|
2014-05-08 13:16:10 -04:00
|
|
|
|
|
|
|
if (this.actor.mapped)
|
|
|
|
this._recalculateWindowPositions(WindowPositionFlags.NONE);
|
2013-02-25 18:34:17 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setActualGeometry(geom) {
|
2013-09-11 10:41:54 -04:00
|
|
|
if (rectEqual(this._actualGeometry, geom))
|
|
|
|
return;
|
|
|
|
|
2013-02-25 18:34:17 -05:00
|
|
|
this._actualGeometry = geom;
|
2014-05-08 13:16:10 -04:00
|
|
|
this._actualGeometryDirty = true;
|
|
|
|
|
|
|
|
if (this.actor.mapped)
|
|
|
|
this._syncActualGeometry();
|
|
|
|
},
|
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
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_syncActualGeometry() {
|
2014-05-08 13:16:10 -04:00
|
|
|
if (this._actualGeometryLater || !this._actualGeometryDirty)
|
|
|
|
return;
|
|
|
|
if (!this._actualGeometry)
|
2013-05-22 13:27:17 -04:00
|
|
|
return;
|
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
this._actualGeometryLater = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
|
2014-05-08 13:16:10 -04:00
|
|
|
this._actualGeometryLater = 0;
|
|
|
|
if (!this.actor.mapped)
|
|
|
|
return false;
|
|
|
|
|
2013-05-22 13:27:17 -04:00
|
|
|
let geom = this._actualGeometry;
|
|
|
|
|
2013-02-25 17:05:51 -05:00
|
|
|
this._dropRect.set_position(geom.x, geom.y);
|
|
|
|
this._dropRect.set_size(geom.width, geom.height);
|
2013-06-26 05:12:35 -04:00
|
|
|
this._updateWindowPositions(Main.overview.animationInProgress ? WindowPositionFlags.ANIMATE : WindowPositionFlags.NONE);
|
2013-05-22 13:27:17 -04:00
|
|
|
|
2012-08-08 13:16:28 -04:00
|
|
|
return false;
|
2017-10-30 20:38:18 -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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_lookupIndex(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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
containsMetaWindow(metaWindow) {
|
2009-09-01 14:15:29 -04:00
|
|
|
return this._lookupIndex(metaWindow) >= 0;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
isEmpty() {
|
2011-01-21 13:47:54 -05:00
|
|
|
return this._windows.length == 0;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setReservedSlot(metaWindow) {
|
2014-09-03 10:03:24 -04:00
|
|
|
if (this._reservedSlotWindow == metaWindow)
|
2011-02-09 19:42:01 -05:00
|
|
|
return;
|
|
|
|
|
2014-09-03 10:03:24 -04:00
|
|
|
if (!metaWindow || this.containsMetaWindow(metaWindow)) {
|
|
|
|
this._reservedSlotWindow = null;
|
|
|
|
this._reservedSlot = null;
|
|
|
|
} else {
|
|
|
|
this._reservedSlotWindow = metaWindow;
|
|
|
|
this._reservedSlot = this._windows[this._lookupIndex(metaWindow)];
|
|
|
|
}
|
2012-08-23 22:33:35 -04:00
|
|
|
|
2013-02-25 22:43:36 -05:00
|
|
|
this._recalculateWindowPositions(WindowPositionFlags.ANIMATE);
|
2010-03-16 11:51:24 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_recalculateWindowPositions(flags) {
|
2012-08-08 13:16:28 -04:00
|
|
|
this._positionWindowsFlags |= flags;
|
|
|
|
|
|
|
|
if (this._positionWindowsId > 0)
|
|
|
|
return;
|
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
this._positionWindowsId = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
|
2013-02-25 22:43:36 -05:00
|
|
|
this._realRecalculateWindowPositions(this._positionWindowsFlags);
|
2012-08-08 13:16:28 -04:00
|
|
|
this._positionWindowsFlags = 0;
|
|
|
|
this._positionWindowsId = 0;
|
|
|
|
return false;
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2012-08-08 13:16:28 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_realRecalculateWindowPositions(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();
|
2013-02-25 19:42:19 -05:00
|
|
|
if (clones.length == 0)
|
|
|
|
return;
|
2012-08-08 13:27:46 -04:00
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
clones.sort((a, b) => {
|
2012-08-08 13:27:46 -04:00
|
|
|
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
|
|
|
|
2013-02-25 22:43:36 -05:00
|
|
|
this._currentLayout = this._computeLayout(clones);
|
|
|
|
this._updateWindowPositions(flags);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateWindowPositions(flags) {
|
2013-04-22 18:14:02 -04:00
|
|
|
if (this._currentLayout == null) {
|
|
|
|
this._recalculateWindowPositions(flags);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-14 13:06:08 -04:00
|
|
|
// We will reposition windows anyway when enter again overview or when ending the windows
|
|
|
|
// animations whith fade animation.
|
2014-07-07 11:26:37 -04:00
|
|
|
// In this way we avoid unwanted animations of windows repositioning while
|
2014-07-14 13:06:08 -04:00
|
|
|
// animating overview.
|
|
|
|
if (this.leavingOverview || this._animatingWindowsFade)
|
2014-07-07 11:26:37 -04:00
|
|
|
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
|
|
|
let initialPositioning = flags & WindowPositionFlags.INITIAL;
|
2010-01-21 21:33:48 -05:00
|
|
|
let animate = flags & WindowPositionFlags.ANIMATE;
|
|
|
|
|
2013-02-25 22:43:36 -05:00
|
|
|
let layout = this._currentLayout;
|
2013-02-25 22:41:40 -05:00
|
|
|
let strategy = layout.strategy;
|
|
|
|
|
|
|
|
let [, , padding] = this._getSpacingAndPadding();
|
2013-02-25 18:34:17 -05:00
|
|
|
let area = padArea(this._actualGeometry, padding);
|
2013-02-25 22:41:40 -05:00
|
|
|
let slots = strategy.computeWindowSlots(layout, area);
|
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;
|
|
|
|
|
2013-03-10 14:42:47 -04:00
|
|
|
let cloneWidth = clone.actor.width * scale;
|
|
|
|
let cloneHeight = clone.actor.height * scale;
|
|
|
|
clone.slot = [x, y, cloneWidth, cloneHeight];
|
2009-01-23 14:21:20 -05:00
|
|
|
|
2013-03-10 14:42:47 -04:00
|
|
|
if (overlay && (initialPositioning || !clone.positioned))
|
2010-03-16 11:51:24 -04:00
|
|
|
overlay.hide();
|
2012-08-08 13:27:46 -04:00
|
|
|
|
2013-03-10 14:42:47 -04:00
|
|
|
if (!clone.positioned) {
|
|
|
|
// This window appeared after the overview was already up
|
|
|
|
// Grow the clone from the center of the slot
|
|
|
|
clone.actor.x = x + cloneWidth / 2;
|
|
|
|
clone.actor.y = y + cloneHeight / 2;
|
|
|
|
clone.actor.scale_x = 0;
|
|
|
|
clone.actor.scale_y = 0;
|
|
|
|
clone.positioned = true;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-07-17 18:52:15 -04:00
|
|
|
this._animateClone(clone, overlay, x, y, scale);
|
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);
|
2013-08-04 05:35:35 -04:00
|
|
|
clone.actor.set_opacity(255);
|
2012-12-16 18:40:48 -05:00
|
|
|
clone.overlay.relayout(false);
|
2013-10-03 17:08:59 -04:00
|
|
|
this._showWindowOverlay(clone, overlay);
|
2010-01-21 21:33:48 -05:00
|
|
|
}
|
2009-01-23 14:21:20 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
syncStacking(stackIndices) {
|
2011-02-12 14:03:44 -05:00
|
|
|
let clones = this._windows.slice();
|
2017-10-30 20:38:18 -04:00
|
|
|
clones.sort((a, b) => {
|
|
|
|
let indexA = stackIndices[a.metaWindow.get_stable_sequence()];
|
|
|
|
let indexB = stackIndices[b.metaWindow.get_stable_sequence()];
|
|
|
|
return indexA - indexB;
|
|
|
|
});
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_animateClone(clone, overlay, x, y, scale) {
|
2011-12-04 15:40:40 -05:00
|
|
|
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',
|
2017-10-30 20:38:18 -04:00
|
|
|
onComplete: () => {
|
2013-10-03 17:08:59 -04:00
|
|
|
this._showWindowOverlay(clone, overlay);
|
2017-10-30 20:38:18 -04:00
|
|
|
}
|
2012-08-08 13:21:20 -04:00
|
|
|
});
|
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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_showWindowOverlay(clone, overlay) {
|
2010-03-22 19:01:44 -04:00
|
|
|
if (clone.inDrag)
|
|
|
|
return;
|
|
|
|
|
2013-10-03 17:08:59 -04:00
|
|
|
if (overlay && overlay._hidden)
|
2010-12-16 14:21:12 -05:00
|
|
|
overlay.show();
|
2009-11-21 22:51:28 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_delayedWindowRepositioning() {
|
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);
|
2013-02-25 18:25:27 -05:00
|
|
|
let inWorkspace = (this._fullGeometry.x < x && x < this._fullGeometry.x + this._fullGeometry.width &&
|
|
|
|
this._fullGeometry.y < y && y < this._fullGeometry.y + this._fullGeometry.height);
|
2010-02-28 01:56:04 -05:00
|
|
|
|
|
|
|
if (pointerHasMoved && inWorkspace) {
|
|
|
|
// store current cursor position
|
|
|
|
this._cursorX = x;
|
|
|
|
this._cursorY = y;
|
2013-11-28 19:45:39 -05:00
|
|
|
return GLib.SOURCE_CONTINUE;
|
2010-02-28 01:56:04 -05:00
|
|
|
}
|
|
|
|
|
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)
|
2013-11-28 19:45:39 -05:00
|
|
|
return GLib.SOURCE_CONTINUE;
|
2012-01-08 04:58:00 -05:00
|
|
|
}
|
|
|
|
|
2013-02-25 22:43:36 -05:00
|
|
|
this._recalculateWindowPositions(WindowPositionFlags.ANIMATE);
|
2013-11-07 22:48:51 -05:00
|
|
|
this._repositionWindowsId = 0;
|
2013-11-28 19:45:39 -05:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2010-02-28 01:56:04 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_doRemoveWindow(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
|
|
|
|
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;
|
|
|
|
|
2013-04-22 18:20:11 -04:00
|
|
|
this._currentLayout = null;
|
2010-02-28 01:56:04 -05:00
|
|
|
this._repositionWindowsId = Mainloop.timeout_add(750,
|
2017-12-01 19:27:35 -05:00
|
|
|
this._delayedWindowRepositioning.bind(this));
|
2014-04-10 13:26:52 -04:00
|
|
|
GLib.Source.set_name_by_id(this._repositionWindowsId, '[gnome-shell] this._delayedWindowRepositioning');
|
2009-01-23 14:21:20 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_doAddWindow(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...
|
2017-10-30 20:38:18 -04:00
|
|
|
let id = Mainloop.idle_add(() => {
|
|
|
|
if (this.actor &&
|
|
|
|
metaWin.get_compositor_private() &&
|
|
|
|
metaWin.get_workspace() == this.metaWorkspace)
|
|
|
|
this._doAddWindow(metaWin);
|
|
|
|
return GLib.SOURCE_REMOVE;
|
|
|
|
});
|
2014-04-10 13:26:52 -04:00
|
|
|
GLib.Source.set_name_by_id(id, '[gnome-shell] this._doAddWindow');
|
2009-02-04 09:50:50 -05:00
|
|
|
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;
|
|
|
|
|
2012-08-29 18:51:53 -04:00
|
|
|
if (!this._isMyWindow(win))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!this._isOverviewWindow(win)) {
|
|
|
|
if (metaWin.is_attached_dialog()) {
|
|
|
|
let parent = metaWin.get_transient_for();
|
|
|
|
while (parent.is_attached_dialog())
|
|
|
|
parent = metaWin.get_transient_for();
|
|
|
|
|
|
|
|
let idx = this._lookupIndex (parent);
|
|
|
|
if (idx < 0) {
|
|
|
|
// parent was not created yet, it will take care
|
|
|
|
// of the dialog when created
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let clone = this._windows[idx];
|
|
|
|
clone.addAttachedDialog(metaWin);
|
|
|
|
}
|
|
|
|
|
2010-01-21 21:33:48 -05:00
|
|
|
return;
|
2012-08-29 18:51:53 -04:00
|
|
|
}
|
2009-02-04 09:50:50 -05:00
|
|
|
|
2013-03-10 14:42:47 -04:00
|
|
|
let [clone, overlay] = this._addWindowClone(win, false);
|
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];
|
2013-03-10 14:42:47 -04:00
|
|
|
clone.positioned = true;
|
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);
|
2009-02-04 09:50:50 -05:00
|
|
|
}
|
|
|
|
|
2013-04-22 18:20:11 -04:00
|
|
|
this._currentLayout = null;
|
2013-02-25 22:43:36 -05:00
|
|
|
this._recalculateWindowPositions(WindowPositionFlags.ANIMATE);
|
2009-01-23 14:21:20 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_windowAdded(metaWorkspace, metaWin) {
|
2011-03-01 03:14:56 -05:00
|
|
|
this._doAddWindow(metaWin);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_windowRemoved(metaWorkspace, metaWin) {
|
2011-03-01 03:14:56 -05:00
|
|
|
this._doRemoveWindow(metaWin);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_windowEnteredMonitor(metaScreen, monitorIndex, metaWin) {
|
2011-03-01 03:14:56 -05:00
|
|
|
if (monitorIndex == this.monitorIndex) {
|
|
|
|
this._doAddWindow(metaWin);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_windowLeftMonitor(metaScreen, monitorIndex, metaWin) {
|
2011-03-01 03:14:56 -05:00
|
|
|
if (monitorIndex == this.monitorIndex) {
|
|
|
|
this._doRemoveWindow(metaWin);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-01-05 22:53:36 -05:00
|
|
|
// check for maximized windows on the workspace
|
2017-10-30 20:03:21 -04:00
|
|
|
hasMaximizedWindows() {
|
2010-07-15 10:21:32 -04:00
|
|
|
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;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
fadeToOverview() {
|
2014-07-14 13:06:08 -04:00
|
|
|
// We don't want to reposition windows while animating in this way.
|
|
|
|
this._animatingWindowsFade = true;
|
2017-12-01 19:27:35 -05:00
|
|
|
this._overviewShownId = Main.overview.connect('shown', this._doneShowingOverview.bind(this));
|
2014-07-14 13:06:08 -04:00
|
|
|
if (this._windows.length == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (this.metaWorkspace != null && this.metaWorkspace != global.screen.get_active_workspace())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Special case maximized windows, since it doesn't make sense
|
|
|
|
// to animate windows below in the stack
|
|
|
|
let topMaximizedWindow;
|
|
|
|
// It is ok to treat the case where there is no maximized
|
|
|
|
// window as if the bottom-most window was maximized given that
|
|
|
|
// it won't affect the result of the animation
|
|
|
|
for (topMaximizedWindow = this._windows.length - 1; topMaximizedWindow > 0; topMaximizedWindow--) {
|
|
|
|
let metaWindow = this._windows[topMaximizedWindow].metaWindow;
|
|
|
|
if (metaWindow.maximized_horizontally && metaWindow.maximized_vertically)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
let nTimeSlots = Math.min(WINDOW_ANIMATION_MAX_NUMBER_BLENDING + 1, this._windows.length - topMaximizedWindow);
|
|
|
|
let windowBaseTime = Overview.ANIMATION_TIME / nTimeSlots;
|
|
|
|
|
|
|
|
let topIndex = this._windows.length - 1;
|
|
|
|
for (let i = 0; i < this._windows.length; i++) {
|
|
|
|
if (i < topMaximizedWindow) {
|
|
|
|
// below top-most maximized window, don't animate
|
|
|
|
let overlay = this._windowOverlays[i];
|
|
|
|
if (overlay)
|
|
|
|
overlay.hide();
|
|
|
|
this._windows[i].actor.opacity = 0;
|
|
|
|
} else {
|
|
|
|
let fromTop = topIndex - i;
|
|
|
|
let time;
|
|
|
|
if (fromTop < nTimeSlots) // animate top-most windows gradually
|
|
|
|
time = windowBaseTime * (nTimeSlots - fromTop);
|
|
|
|
else
|
|
|
|
time = windowBaseTime;
|
|
|
|
|
|
|
|
this._windows[i].actor.opacity = 255;
|
|
|
|
this._fadeWindow(i, time, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
fadeFromOverview() {
|
2014-07-14 13:06:08 -04:00
|
|
|
this.leavingOverview = true;
|
2017-12-01 19:27:35 -05:00
|
|
|
this._overviewHiddenId = Main.overview.connect('hidden', this._doneLeavingOverview.bind(this));
|
2014-07-14 13:06:08 -04:00
|
|
|
if (this._windows.length == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (let i = 0; i < this._windows.length; i++) {
|
|
|
|
let clone = this._windows[i];
|
|
|
|
Tweener.removeTweens(clone.actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._repositionWindowsId > 0) {
|
|
|
|
Mainloop.source_remove(this._repositionWindowsId);
|
|
|
|
this._repositionWindowsId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.metaWorkspace != null && this.metaWorkspace != global.screen.get_active_workspace())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Special case maximized windows, since it doesn't make sense
|
|
|
|
// to animate windows below in the stack
|
|
|
|
let topMaximizedWindow;
|
|
|
|
// It is ok to treat the case where there is no maximized
|
|
|
|
// window as if the bottom-most window was maximized given that
|
|
|
|
// it won't affect the result of the animation
|
|
|
|
for (topMaximizedWindow = this._windows.length - 1; topMaximizedWindow > 0; topMaximizedWindow--) {
|
|
|
|
let metaWindow = this._windows[topMaximizedWindow].metaWindow;
|
|
|
|
if (metaWindow.maximized_horizontally && metaWindow.maximized_vertically)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
let nTimeSlots = Math.min(WINDOW_ANIMATION_MAX_NUMBER_BLENDING + 1, this._windows.length - topMaximizedWindow);
|
|
|
|
let windowBaseTime = Overview.ANIMATION_TIME / nTimeSlots;
|
|
|
|
|
|
|
|
let topIndex = this._windows.length - 1;
|
|
|
|
for (let i = 0; i < this._windows.length; i++) {
|
|
|
|
if (i < topMaximizedWindow) {
|
|
|
|
// below top-most maximized window, don't animate
|
|
|
|
let overlay = this._windowOverlays[i];
|
|
|
|
if (overlay)
|
|
|
|
overlay.hide();
|
|
|
|
this._windows[i].actor.opacity = 0;
|
|
|
|
} else {
|
|
|
|
let fromTop = topIndex - i;
|
|
|
|
let time;
|
|
|
|
if (fromTop < nTimeSlots) // animate top-most windows gradually
|
|
|
|
time = windowBaseTime * (fromTop + 1);
|
|
|
|
else
|
|
|
|
time = windowBaseTime * nTimeSlots;
|
|
|
|
|
|
|
|
this._windows[i].actor.opacity = 0;
|
|
|
|
this._fadeWindow(i, time, 255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_fadeWindow(index, time, opacity) {
|
2014-07-14 13:06:08 -04:00
|
|
|
let clone = this._windows[index];
|
|
|
|
let overlay = this._windowOverlays[index];
|
|
|
|
|
|
|
|
if (overlay)
|
|
|
|
overlay.hide();
|
|
|
|
|
|
|
|
if (clone.metaWindow.showing_on_its_workspace()) {
|
|
|
|
let [origX, origY] = clone.getOriginalPosition();
|
|
|
|
clone.actor.scale_x = 1;
|
|
|
|
clone.actor.scale_y = 1;
|
|
|
|
clone.actor.x = origX;
|
|
|
|
clone.actor.y = origY;
|
|
|
|
Tweener.addTween(clone.actor,
|
|
|
|
{ time: time,
|
|
|
|
opacity: opacity,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// The window is hidden
|
|
|
|
clone.actor.opacity = 0;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
zoomToOverview() {
|
2009-08-10 18:31:39 -04:00
|
|
|
// Position and scale the windows.
|
2013-02-25 22:43:36 -05:00
|
|
|
this._recalculateWindowPositions(WindowPositionFlags.ANIMATE | WindowPositionFlags.INITIAL);
|
2008-12-22 16:51:34 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
zoomFromOverview() {
|
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;
|
|
|
|
}
|
2017-12-01 19:27:35 -05:00
|
|
|
this._overviewHiddenId = Main.overview.connect('hidden', this._doneLeavingOverview.bind(this));
|
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.
|
2014-07-14 13:06:08 -04:00
|
|
|
for (let i = 0; i < this._windows.length; i++)
|
|
|
|
this._zoomWindowFromOverview(i);
|
|
|
|
},
|
2010-01-23 02:37:34 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_zoomWindowFromOverview(index) {
|
2014-07-14 13:06:08 -04:00
|
|
|
let clone = this._windows[index];
|
|
|
|
let overlay = this._windowOverlays[index];
|
|
|
|
|
|
|
|
if (overlay)
|
|
|
|
overlay.hide();
|
|
|
|
|
|
|
|
if (clone.metaWindow.showing_on_its_workspace()) {
|
|
|
|
let [origX, origY] = clone.getOriginalPosition();
|
|
|
|
Tweener.addTween(clone.actor,
|
|
|
|
{ x: origX,
|
|
|
|
y: origY,
|
|
|
|
scale_x: 1.0,
|
|
|
|
scale_y: 1.0,
|
|
|
|
time: Overview.ANIMATION_TIME,
|
|
|
|
opacity: 255,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
|
|
|
} 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,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
2008-12-22 16:51:34 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
destroy() {
|
2008-12-22 16:51:34 -05:00
|
|
|
this.actor.destroy();
|
2010-02-18 10:43:58 -05:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onDestroy(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
|
|
|
|
2017-06-27 05:09:16 -04:00
|
|
|
if (this._repositionWindowsId > 0) {
|
2010-02-28 01:56:04 -05:00
|
|
|
Mainloop.source_remove(this._repositionWindowsId);
|
2017-06-27 05:09:16 -04:00
|
|
|
this._repositionWindowsId = 0;
|
|
|
|
}
|
2012-08-08 13:16:28 -04:00
|
|
|
|
2017-06-27 05:09:16 -04:00
|
|
|
if (this._positionWindowsId > 0) {
|
2012-08-08 13:16:28 -04:00
|
|
|
Meta.later_remove(this._positionWindowsId);
|
2017-06-27 05:09:16 -04:00
|
|
|
this._positionWindowsId = 0;
|
|
|
|
}
|
2013-09-10 20:42:11 -04:00
|
|
|
|
2017-06-27 05:09:16 -04:00
|
|
|
if (this._actualGeometryLater > 0) {
|
2013-09-10 20:42:11 -04:00
|
|
|
Meta.later_remove(this._actualGeometryLater);
|
2017-06-27 05:09:16 -04:00
|
|
|
this._actualGeometryLater = 0;
|
|
|
|
}
|
2013-09-10 20:42:11 -04:00
|
|
|
|
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.
|
2017-10-30 20:03:21 -04:00
|
|
|
_doneLeavingOverview() {
|
2009-08-11 07:46:10 -04:00
|
|
|
this.leavingOverview = false;
|
2009-03-17 18:22:25 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_doneShowingOverview() {
|
2014-07-14 13:06:08 -04:00
|
|
|
this._animatingWindowsFade = false;
|
|
|
|
this._recalculateWindowPositions(WindowPositionFlags.INITIAL);
|
|
|
|
},
|
|
|
|
|
2013-01-14 12:38:02 -05:00
|
|
|
// Tests if @actor belongs to this workspaces and monitor
|
2017-10-30 20:03:21 -04:00
|
|
|
_isMyWindow(actor) {
|
2013-01-14 12:38:02 -05:00
|
|
|
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
|
2017-10-30 20:03:21 -04:00
|
|
|
_isOverviewWindow(win) {
|
2014-01-30 12:04:18 -05:00
|
|
|
return !win.get_meta_window().skip_taskbar;
|
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
|
2017-10-30 20:03:21 -04:00
|
|
|
_addWindowClone(win, positioned) {
|
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;
|
2013-03-10 14:42:47 -04:00
|
|
|
clone.positioned = positioned;
|
2009-11-11 19:26:52 -05:00
|
|
|
|
2009-01-29 16:21:50 -05:00
|
|
|
clone.connect('selected',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onCloneSelected.bind(this));
|
2017-10-30 20:38:18 -04:00
|
|
|
clone.connect('drag-begin', () => {
|
|
|
|
Main.overview.beginWindowDrag(clone.metaWindow);
|
|
|
|
overlay.hide();
|
|
|
|
});
|
|
|
|
clone.connect('drag-cancelled', () => {
|
|
|
|
Main.overview.cancelledWindowDrag(clone.metaWindow);
|
|
|
|
});
|
|
|
|
clone.connect('drag-end', () => {
|
|
|
|
Main.overview.endWindowDrag(clone.metaWindow);
|
|
|
|
overlay.show();
|
|
|
|
});
|
|
|
|
clone.connect('size-changed', () => {
|
|
|
|
this._recalculateWindowPositions(WindowPositionFlags.NONE);
|
|
|
|
});
|
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
|
|
|
|
2017-12-01 19:27:35 -05:00
|
|
|
overlay.connect('show-close-button', this._onShowOverlayClose.bind(this));
|
2009-11-19 19:39:00 -05:00
|
|
|
|
2013-02-20 13:33:29 -05:00
|
|
|
if (this._windows.length == 0)
|
|
|
|
clone.setStackAbove(null);
|
|
|
|
else
|
|
|
|
clone.setStackAbove(this._windows[this._windows.length - 1].actor);
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onShowOverlayClose(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();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_isBetterLayout(oldLayout, newLayout) {
|
2012-08-08 13:27:46 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_getBestLayout(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 = {};
|
|
|
|
|
2013-02-25 19:31:03 -05:00
|
|
|
let strategy = new UnalignedLayoutStrategy(this._monitor, rowSpacing, columnSpacing);
|
|
|
|
|
2012-08-08 13:27:46 -04:00
|
|
|
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 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
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_getSpacingAndPadding() {
|
2012-08-08 13:27:46 -04:00
|
|
|
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
|
|
|
|
2013-02-25 19:42:19 -05:00
|
|
|
// All of the overlays have the same chrome sizes,
|
|
|
|
// so just pick the first one.
|
|
|
|
let overlay = this._windowOverlays[0];
|
2017-06-01 10:32:45 -04:00
|
|
|
let [topBorder, bottomBorder] = overlay.chromeHeights();
|
|
|
|
let [leftBorder, rightBorder] = overlay.chromeWidths();
|
2012-08-08 13:27:46 -04:00
|
|
|
|
2017-06-01 10:32:45 -04:00
|
|
|
rowSpacing += (topBorder + bottomBorder) / 2;
|
2012-12-13 13:28:25 -05:00
|
|
|
columnSpacing += (rightBorder + leftBorder) / 2;
|
2017-06-01 10:32:45 -04:00
|
|
|
padding.top += topBorder;
|
|
|
|
padding.bottom += bottomBorder;
|
2012-12-13 13:28:25 -05:00
|
|
|
padding.left += leftBorder;
|
|
|
|
padding.right += rightBorder;
|
|
|
|
|
2013-02-25 22:38:30 -05:00
|
|
|
return [rowSpacing, columnSpacing, padding];
|
|
|
|
},
|
2012-08-08 13:27:46 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_computeLayout(windows) {
|
2013-02-25 22:38:30 -05:00
|
|
|
let [rowSpacing, columnSpacing, padding] = this._getSpacingAndPadding();
|
|
|
|
let area = padArea(this._fullGeometry, padding);
|
2013-02-25 22:41:40 -05:00
|
|
|
return this._getBestLayout(windows, area, rowSpacing, columnSpacing);
|
2009-09-18 15:08:56 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onCloneSelected(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
|
2017-10-30 20:03:21 -04:00
|
|
|
handleDragOver(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;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
acceptDrop(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();
|
2013-10-09 18:10:01 -04:00
|
|
|
metaWindow.change_workspace_by_index(index, false);
|
2009-02-10 11:15:59 -05:00
|
|
|
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);
|