Replace metaWindow.destinationX with moving windows pre-animation

Had to reorder setting the click overlay targets after calling `move`.
This commit is contained in:
Tor Hedin Brønner
2018-05-01 15:40:11 +02:00
parent bd76ebcf35
commit 4297c8a6e2
3 changed files with 25 additions and 34 deletions
+1 -1
View File
@@ -276,7 +276,7 @@ var PreviewedWindowNavigator = new Lang.Class({
action.handler(null, null, metaWindow);
let minimap = this._switcherList.getSelected();
minimap.layout();
minimap.sync(metaWindow.destinationX);
minimap.sync(metaWindow.get_frame_rect().x);
this._switcherList.highlight(this._selectedIndex);
return true;
}
+10 -14
View File
@@ -118,6 +118,10 @@ var StackOverlay = new Lang.Class({
let overlay = new Clutter.Actor({ reactive: true
, name: "stack-overlay" });
// Uncomment to debug the overlays
// overlay.background_color = Clutter.color_from_string('green')[1];
// overlay.opacity = 100;
this.monitor = monitor;
let panelBox = Main.layoutManager.panelBox;
@@ -182,7 +186,6 @@ var StackOverlay = new Lang.Class({
let overlay = this.overlay;
let actor = metaWindow.get_compositor_private();
let frame = metaWindow.get_frame_rect();
let space = Tiling.spaces.spaceOfWindow(metaWindow);
overlay.y = this.monitor.y + Main.layoutManager.panelBox.height + Tiling.margin_tb;
@@ -192,27 +195,20 @@ var StackOverlay = new Lang.Class({
// positions (icon) (since we don't track the y destination)
// We also assume window widths are are unchanging.
if (this._direction === Meta.MotionDirection.LEFT) {
let neighbour = space[space.indexOf(metaWindow) + 1]
let neighbour = space[space.indexOf(metaWindow) + 1];
if (!neighbour)
return bail(); // Should normally have a neighbour. Bail!
let neighbourX = neighbour.destinationX;
if (neighbourX === undefined)
neighbourX = neighbour.get_frame_rect().x;
let frame = neighbour.get_frame_rect();
overlay.x = this.monitor.x;
overlay.width = Math.max(0, neighbourX - Tiling.window_gap);
overlay.width = Math.max(0, frame.x - Tiling.window_gap);
} else {
let neighbour = space[space.indexOf(metaWindow) - 1]
let neighbour = space[space.indexOf(metaWindow) - 1];
if (!neighbour)
return bail(); // Should normally have a neighbour. Bail!
let neighbourFrame = neighbour.get_frame_rect();
let neighbourX = neighbour.destinationX;
if (neighbourX === undefined)
neighbourX = neighbourFrame.x;
overlay.x = neighbourX + neighbourFrame.width + Tiling.window_gap;
let frame = neighbour.get_frame_rect();
overlay.x = frame.x + frame.width + Tiling.window_gap;
overlay.width = Math.max(0, this.monitor.width - overlay.x);
}
+14 -19
View File
@@ -896,9 +896,6 @@ function ensureViewport(meta_window, space, force) {
frame.x -= monitor.x;
frame.y -= monitor.y;
if (meta_window.destinationX !== undefined)
// Use the destination of the window if available
frame.x = meta_window.destinationX;
let x = frame.x;
let y = panelBox.height + margin_tb;
let required_width = space.reduce((length, meta_window) => {
@@ -981,9 +978,14 @@ function move(meta_window, space,
clone.show();
actor.hide();
// Move the frame before animation to indicate where it's actually going.
// The animation being purely cosmetic.
meta_window.move_frame(true,
x + monitor.x,
y + monitor.y);
let x_offset = frame.x - buffer.x;
let y_offset = frame.y - buffer.y;
meta_window.destinationX = x;
Tweener.addTween(clone, {x: x - x_offset
, y: y - y_offset
, time: 0.25 - delay
@@ -997,13 +999,7 @@ function move(meta_window, space,
// process of closing
if(!meta_window.get_compositor_private())
return;
meta_window.destinationX = undefined;
let monitor = space.monitor;
meta_window.move_frame(true,
x + monitor.x,
y + monitor.y);
if (!stack && !Navigator.navigating) {
clone.hide();
actor.show();
@@ -1047,9 +1043,6 @@ function propagateForward(space, n, x, gap) {
if (x + frame.width > space.width
|| meta_window.fullscreen
|| meta_window.get_maximized() === Meta.MaximizeFlags.BOTH) {
if (x < space.width) {
space.monitor.clickOverlay.right.setTarget(meta_window);
}
stack = true;
meta_window._isStacked = true;
} else {
@@ -1062,6 +1055,9 @@ function propagateForward(space, n, x, gap) {
move(meta_window, space,
{ x, y: panelBox.height + margin_tb, stack });
if (stack && x < space.width) {
space.monitor.clickOverlay.right.setTarget(meta_window);
}
propagateForward(space, n+1, x+frame.width + gap, gap);
} else {
// If the window doesn't have an actor we should just skip it
@@ -1082,9 +1078,6 @@ function propagateBackward(space, n, x, gap) {
let stack = false;
if (x - frame.width < 0 || meta_window.fullscreen
|| meta_window.get_maximized() === Meta.MaximizeFlags.BOTH) {
if (x > 0) {
space.monitor.clickOverlay.left.setTarget(meta_window);
}
stack = true;
meta_window._isStacked = true;
} else {
@@ -1093,11 +1086,13 @@ function propagateBackward(space, n, x, gap) {
let actor = meta_window.get_compositor_private();
if (actor) {
x = x - frame.width;
// Anchor on the right edge for windows positioned to the left.
move(meta_window, space,
{ x, y: panelBox.height + margin_tb, stack });
propagateBackward(space, n-1, x - gap, gap);
{ x: x - frame.width, y: panelBox.height + margin_tb, stack });
if (stack && x > 0) {
space.monitor.clickOverlay.left.setTarget(meta_window);
}
propagateBackward(space, n-1, x - frame.width - gap, gap);
} else {
// If the window doesn't have an actor we should just skip it
propagateBackward(space, n-1, x, gap);