workspace: Rename WindowClone to WindowPreview

Since ClutterClones are going to be removed, let's switch the
terminology here to something that's more understandable and rename the
WindowClone class and its layout manager to
WindowPreview/WindowPreviewLayout.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1307
This commit is contained in:
Jonas Dreßler 2020-06-08 09:23:08 +02:00
parent dd8e1aef51
commit cadbf7cd8b

View File

@ -10,7 +10,7 @@ const Overview = imports.ui.overview;
var WINDOW_DND_SIZE = 256;
var WINDOW_CLONE_MAXIMUM_SCALE = 1.0;
var WINDOW_PREVIEW_MAXIMUM_SCALE = 1.0;
var WINDOW_OVERLAY_IDLE_HIDE_TIMEOUT = 750;
var WINDOW_OVERLAY_FADE_TIME = 200;
@ -33,14 +33,14 @@ function _interpolate(start, end, step) {
return start + (end - start) * step;
}
var WindowCloneLayout = GObject.registerClass({
var WindowPreviewLayout = GObject.registerClass({
Properties: {
'bounding-box': GObject.ParamSpec.boxed(
'bounding-box', 'Bounding box', 'Bounding box',
GObject.ParamFlags.READABLE,
Clutter.ActorBox.$gtype),
},
}, class WindowCloneLayout extends Clutter.LayoutManager {
}, class WindowPreviewLayout extends Clutter.LayoutManager {
_init() {
super._init();
@ -194,7 +194,7 @@ var WindowCloneLayout = GObject.registerClass({
}
});
var WindowClone = GObject.registerClass({
var WindowPreview = GObject.registerClass({
Signals: {
'drag-begin': {},
'drag-cancelled': {},
@ -203,7 +203,7 @@ var WindowClone = GObject.registerClass({
'show-chrome': {},
'size-changed': {},
},
}, class WindowClone extends St.Widget {
}, class WindowPreview extends St.Widget {
_init(realWindow, workspace) {
this.realWindow = realWindow;
this.metaWindow = realWindow.meta_window;
@ -221,7 +221,7 @@ var WindowClone = GObject.registerClass({
// the initialization of the actor if that layout manager keeps track
// of its container, so set the layout manager after creating the
// container
this._windowContainer.layout_manager = new WindowCloneLayout();
this._windowContainer.layout_manager = new WindowPreviewLayout();
this.add_child(this._windowContainer);
this.set_offscreen_redirect(Clutter.OffscreenRedirect.AUTOMATIC_FOR_OPACITY);
@ -836,13 +836,13 @@ var WindowPositionFlags = {
// 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:
// larger than WINDOW_PREVIEW_MAXIMUM_SCALE, which means that the inequality:
//
// windowScale * layoutScale <= WINDOW_CLONE_MAXIMUM_SCALE
// windowScale * layoutScale <= WINDOW_PREVIEW_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
// WINDOW_PREVIEW_MAXIMUM_SCALE, it would shrink windows which are already
// 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.
@ -937,7 +937,8 @@ var LayoutStrategy = class {
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 scale = Math.min(
horizontalScale, verticalScale, WINDOW_PREVIEW_MAXIMUM_SCALE);
let scaledLayoutWidth = layout.gridWidth * scale + hspacing;
let scaledLayoutHeight = layout.gridHeight * scale + vspacing;
@ -1005,7 +1006,7 @@ var LayoutStrategy = class {
let cellWidth = window.boundingBox.width * s;
let cellHeight = window.boundingBox.height * s;
s = Math.min(s, WINDOW_CLONE_MAXIMUM_SCALE);
s = Math.min(s, WINDOW_PREVIEW_MAXIMUM_SCALE);
let cloneWidth = window.boundingBox.width * s;
const cloneHeight = window.boundingBox.height * s;
@ -1210,7 +1211,7 @@ class Workspace extends St.Widget {
vfunc_get_focus_chain() {
return this.get_children().filter(c => c.visible).sort((a, b) => {
if (a instanceof WindowClone && b instanceof WindowClone)
if (a instanceof WindowPreview && b instanceof WindowPreview)
return a.slotId - b.slotId;
return 0;
@ -1829,7 +1830,7 @@ class Workspace extends St.Widget {
// Create a clone of a (non-desktop) window and add it to the window list
_addWindowClone(win, positioned) {
let clone = new WindowClone(win, this);
let clone = new WindowPreview(win, this);
clone.positioned = positioned;
clone.connect('selected',