workspace: Scale down background

Scale down the background to 0.94 when in floating mode.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1691>
This commit is contained in:
Georges Basile Stavracas Neto 2021-02-17 11:36:10 -03:00 committed by Marge Bot
parent b1970b95b8
commit adc5f2d81f

View File

@ -24,6 +24,7 @@ var LAYOUT_SCALE_WEIGHT = 1;
var LAYOUT_SPACE_WEIGHT = 0.1; var LAYOUT_SPACE_WEIGHT = 0.1;
const BACKGROUND_CORNER_RADIUS_PIXELS = 30; const BACKGROUND_CORNER_RADIUS_PIXELS = 30;
const BACKGROUND_SCALE = 0.94;
// Window Thumbnail Layout Algorithm // Window Thumbnail Layout Algorithm
// ================================= // =================================
@ -868,7 +869,10 @@ class WorkspaceBackground extends St.Widget {
this._workarea = Main.layoutManager.getWorkAreaForMonitor(monitorIndex); this._workarea = Main.layoutManager.getWorkAreaForMonitor(monitorIndex);
this._stateAdjustment = stateAdjustment; this._stateAdjustment = stateAdjustment;
stateAdjustment.connect('notify::value', () => this._updateBorderRadius()); stateAdjustment.connect('notify::value', () => {
this._updateBorderRadius();
this.queue_relayout();
});
this._bin = new Clutter.Actor({ this._bin = new Clutter.Actor({
layout_manager: new Clutter.BinLayout(), layout_manager: new Clutter.BinLayout(),
@ -923,6 +927,21 @@ class WorkspaceBackground extends St.Widget {
} }
vfunc_allocate(box) { vfunc_allocate(box) {
const scaledBox = box.copy();
scaledBox.scale(BACKGROUND_SCALE);
const [scaledWidth, scaledHeight] = scaledBox.get_size();
scaledBox.set_origin(
box.x1 + (box.get_width() - scaledWidth) / 2,
box.y1 + (box.get_height() - scaledHeight) / 2);
const progress = this._stateAdjustment.value;
if (progress === 1)
box = scaledBox;
else if (progress !== 0)
box = box.interpolate(scaledBox, progress);
this.set_allocation(box); this.set_allocation(box);
const themeNode = this.get_theme_node(); const themeNode = this.get_theme_node();
@ -937,8 +956,7 @@ class WorkspaceBackground extends St.Widget {
const yOff = (contentHeight / this._workarea.height) * const yOff = (contentHeight / this._workarea.height) *
(this._workarea.y - monitor.y); (this._workarea.y - monitor.y);
contentBox.x1 -= xOff; contentBox.set_origin(-xOff, -yOff);
contentBox.y1 -= yOff;
contentBox.set_size(xOff + contentWidth, yOff + contentHeight); contentBox.set_size(xOff + contentWidth, yOff + contentHeight);
this._backgroundGroup.allocate(contentBox); this._backgroundGroup.allocate(contentBox);
} }