workspace: Position clones using width and height instead of scale
Since we now have a layout manager for the WindowClone that allows allocating it a size that isn't the absolute size of the window, we can now give the WindowClone an artificial size and it will get scaled accordingly. So make use of that and stop positioning WindowClones using fixed position and scale and use a fixed position and fixed size instead. This will make it easier to use a ClutterLayoutManager to allocate the WindowClones, because layout managers should only set the allocation of their children, not the scale. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1294
This commit is contained in:
parent
bf40d96a83
commit
7bbce1d5ad
@ -984,6 +984,7 @@ var LayoutStrategy = class {
|
|||||||
|
|
||||||
s = Math.min(s, WINDOW_CLONE_MAXIMUM_SCALE);
|
s = Math.min(s, WINDOW_CLONE_MAXIMUM_SCALE);
|
||||||
let cloneWidth = window.boundingBox.width * s;
|
let cloneWidth = window.boundingBox.width * s;
|
||||||
|
const cloneHeight = window.boundingBox.height * s;
|
||||||
|
|
||||||
let cloneX = x + (cellWidth - cloneWidth) / 2;
|
let cloneX = x + (cellWidth - cloneWidth) / 2;
|
||||||
let cloneY = row.y + row.height * row.additionalScale - cellHeight + compensation;
|
let cloneY = row.y + row.height * row.additionalScale - cellHeight + compensation;
|
||||||
@ -992,7 +993,7 @@ var LayoutStrategy = class {
|
|||||||
cloneX = Math.floor(cloneX);
|
cloneX = Math.floor(cloneX);
|
||||||
cloneY = Math.floor(cloneY);
|
cloneY = Math.floor(cloneY);
|
||||||
|
|
||||||
slots.push([cloneX, cloneY, s, window]);
|
slots.push([cloneX, cloneY, cloneWidth, cloneHeight, window]);
|
||||||
x += cellWidth + this._columnSpacing;
|
x += cellWidth + this._columnSpacing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1331,7 +1332,7 @@ class Workspace extends St.Widget {
|
|||||||
|
|
||||||
for (let i = 0; i < slots.length; i++) {
|
for (let i = 0; i < slots.length; i++) {
|
||||||
let slot = slots[i];
|
let slot = slots[i];
|
||||||
let [x, y, scale, clone] = slot;
|
const [x, y, cellWidth, cellHeight, clone] = slot;
|
||||||
|
|
||||||
clone.slotId = i;
|
clone.slotId = i;
|
||||||
|
|
||||||
@ -1340,8 +1341,8 @@ class Workspace extends St.Widget {
|
|||||||
if (clone.inDrag)
|
if (clone.inDrag)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
let cloneWidth = clone.boundingBox.width * scale;
|
const cloneWidth = cellWidth;
|
||||||
let cloneHeight = clone.boundingBox.height * scale;
|
const cloneHeight = cellHeight;
|
||||||
clone.slot = [x, y, cloneWidth, cloneHeight];
|
clone.slot = [x, y, cloneWidth, cloneHeight];
|
||||||
|
|
||||||
let cloneCenter = x + cloneWidth / 2;
|
let cloneCenter = x + cloneWidth / 2;
|
||||||
@ -1358,8 +1359,8 @@ class Workspace extends St.Widget {
|
|||||||
// Grow the clone from the center of the slot
|
// Grow the clone from the center of the slot
|
||||||
clone.x = x + cloneWidth / 2;
|
clone.x = x + cloneWidth / 2;
|
||||||
clone.y = y + cloneHeight / 2;
|
clone.y = y + cloneHeight / 2;
|
||||||
clone.scale_x = 0;
|
clone.width = 0;
|
||||||
clone.scale_y = 0;
|
clone.height = 0;
|
||||||
clone.positioned = true;
|
clone.positioned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1370,10 +1371,10 @@ class Workspace extends St.Widget {
|
|||||||
* can be scaled up later */
|
* can be scaled up later */
|
||||||
if (initialPositioning) {
|
if (initialPositioning) {
|
||||||
clone.opacity = 0;
|
clone.opacity = 0;
|
||||||
clone.scale_x = 0;
|
|
||||||
clone.scale_y = 0;
|
|
||||||
clone.x = x;
|
clone.x = x;
|
||||||
clone.y = y;
|
clone.y = y;
|
||||||
|
clone.width = cloneWidth;
|
||||||
|
clone.height = cloneHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
clone.ease({
|
clone.ease({
|
||||||
@ -1383,12 +1384,12 @@ class Workspace extends St.Widget {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this._animateClone(clone, clone.overlay, x, y, scale);
|
this._animateClone(clone, clone.overlay, x, y, cloneWidth, cloneHeight);
|
||||||
} else {
|
} else {
|
||||||
// cancel any active tweens (otherwise they might override our changes)
|
// cancel any active tweens (otherwise they might override our changes)
|
||||||
clone.remove_all_transitions();
|
clone.remove_all_transitions();
|
||||||
clone.set_position(x, y);
|
clone.set_position(x, y);
|
||||||
clone.set_scale(scale, scale);
|
clone.set_size(cloneWidth, cloneHeight);
|
||||||
clone.set_opacity(255);
|
clone.set_opacity(255);
|
||||||
clone.overlay.relayout(false);
|
clone.overlay.relayout(false);
|
||||||
this._showWindowOverlay(clone, clone.overlay);
|
this._showWindowOverlay(clone, clone.overlay);
|
||||||
@ -1415,11 +1416,10 @@ class Workspace extends St.Widget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_animateClone(clone, overlay, x, y, scale) {
|
_animateClone(clone, overlay, x, y, width, height) {
|
||||||
clone.ease({
|
clone.ease({
|
||||||
x, y,
|
x, y,
|
||||||
scale_x: scale,
|
width, height,
|
||||||
scale_y: scale,
|
|
||||||
duration: Overview.ANIMATION_TIME,
|
duration: Overview.ANIMATION_TIME,
|
||||||
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
@ -1476,11 +1476,14 @@ class Workspace extends St.Widget {
|
|||||||
// this point.)
|
// this point.)
|
||||||
if (win) {
|
if (win) {
|
||||||
let [stageX, stageY] = clone.get_transformed_position();
|
let [stageX, stageY] = clone.get_transformed_position();
|
||||||
let [stageWidth] = clone.get_transformed_size();
|
const [transformedWidth, transformedHeight] =
|
||||||
|
clone.get_transformed_size();
|
||||||
|
|
||||||
win._overviewHint = {
|
win._overviewHint = {
|
||||||
x: stageX,
|
x: stageX,
|
||||||
y: stageY,
|
y: stageY,
|
||||||
scale: stageWidth / clone.boundingBox.width,
|
width: transformedWidth,
|
||||||
|
height: transformedHeight,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
clone.destroy();
|
clone.destroy();
|
||||||
@ -1556,14 +1559,15 @@ class Workspace extends St.Widget {
|
|||||||
if (win._overviewHint) {
|
if (win._overviewHint) {
|
||||||
let x = win._overviewHint.x - this.x;
|
let x = win._overviewHint.x - this.x;
|
||||||
let y = win._overviewHint.y - this.y;
|
let y = win._overviewHint.y - this.y;
|
||||||
let scale = win._overviewHint.scale;
|
const width = win._overviewHint.width;
|
||||||
|
const height = win._overviewHint.height;
|
||||||
delete win._overviewHint;
|
delete win._overviewHint;
|
||||||
|
|
||||||
clone.slot = [x, y, clone.boundingBox.width * scale, clone.boundingBox.height * scale];
|
clone.slot = [x, y, width, height];
|
||||||
clone.positioned = true;
|
clone.positioned = true;
|
||||||
|
|
||||||
clone.set_position(x, y);
|
clone.set_position(x, y);
|
||||||
clone.set_scale(scale, scale);
|
clone.set_size(width, height);
|
||||||
clone.overlay.relayout(false);
|
clone.overlay.relayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1714,10 +1718,10 @@ class Workspace extends St.Widget {
|
|||||||
overlay.hide();
|
overlay.hide();
|
||||||
|
|
||||||
if (clone.metaWindow.showing_on_its_workspace()) {
|
if (clone.metaWindow.showing_on_its_workspace()) {
|
||||||
clone.scale_x = 1;
|
|
||||||
clone.scale_y = 1;
|
|
||||||
clone.x = clone.boundingBox.x;
|
clone.x = clone.boundingBox.x;
|
||||||
clone.y = clone.boundingBox.y;
|
clone.y = clone.boundingBox.y;
|
||||||
|
clone.width = clone.boundingBox.width;
|
||||||
|
clone.height = clone.boundingBox.height;
|
||||||
clone.ease({
|
clone.ease({
|
||||||
opacity,
|
opacity,
|
||||||
duration,
|
duration,
|
||||||
@ -1768,8 +1772,8 @@ class Workspace extends St.Widget {
|
|||||||
clone.ease({
|
clone.ease({
|
||||||
x: clone.boundingBox.x,
|
x: clone.boundingBox.x,
|
||||||
y: clone.boundingBox.y,
|
y: clone.boundingBox.y,
|
||||||
scale_x: 1,
|
width: clone.boundingBox.width,
|
||||||
scale_y: 1,
|
height: clone.boundingBox.height,
|
||||||
opacity: 255,
|
opacity: 255,
|
||||||
duration: Overview.ANIMATION_TIME,
|
duration: Overview.ANIMATION_TIME,
|
||||||
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
||||||
@ -1777,8 +1781,8 @@ class Workspace extends St.Widget {
|
|||||||
} else {
|
} else {
|
||||||
// The window is hidden, make it shrink and fade it out
|
// The window is hidden, make it shrink and fade it out
|
||||||
clone.ease({
|
clone.ease({
|
||||||
scale_x: 0,
|
width: 0,
|
||||||
scale_y: 0,
|
height: 0,
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
duration: Overview.ANIMATION_TIME,
|
duration: Overview.ANIMATION_TIME,
|
||||||
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
||||||
@ -2023,7 +2027,8 @@ class Workspace extends St.Widget {
|
|||||||
win._overviewHint = {
|
win._overviewHint = {
|
||||||
x: actor.x,
|
x: actor.x,
|
||||||
y: actor.y,
|
y: actor.y,
|
||||||
scale: actor.scale_x,
|
width: actor.width,
|
||||||
|
heigth: actor.height,
|
||||||
};
|
};
|
||||||
|
|
||||||
let metaWindow = win.get_meta_window();
|
let metaWindow = win.get_meta_window();
|
||||||
|
Loading…
Reference in New Issue
Block a user