From 5ad137d1f985e0633e7bf5d3d3bc3c8e04f0137e Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Fri, 21 Jan 2022 19:20:07 +0800 Subject: [PATCH] workspace: Use the original overviewAdjustment on WorkspaceBackground Using `layoutManager.stateAdjustment` would treat `ControlsState.HIDDEN` the same as `ControlsState.APP_GRID`: | `ControlsState` | `stateAdjustment` | Rounded corners | | --------------- | ----------------- | ---------------- | | HIDDEN:0 | 0.0 | No | | WINDOW_PICKER:1 | 1.0 | Yes | | APP_GRID:2 | 0.0 | No (issue #4096) | and so rounded corners were accidentally lost for `ControlsState.APP_GRID` (issue #4096). But it's not as simple as treating `ControlsState.APP_GRID` the same as `ControlsState.WINDOW_PICKER` because that would break `allocate` which only needs its downscaling algorithm enabled for `ControlsState.WINDOW_PICKER` (because `ControlsState.APP_GRID` is already downscaled by the parent allocation). So we now map those two problems separately: | `ControlsState` | Rounded corners | Downscale from parent | | --------------- | ---------------- | --------------------- | | HIDDEN:0 | No | No | | WINDOW_PICKER:1 | Yes | Yes | | APP_GRID:2 | Yes | No | Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4096 --- js/ui/workspace.js | 8 ++++++-- src/shell-workspace-background.c | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/js/ui/workspace.js b/js/ui/workspace.js index 4787cdf0e..6aec58588 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -1005,8 +1005,12 @@ class WorkspaceBackground extends Shell.WorkspaceBackground { const cornerRadius = scaleFactor * BACKGROUND_CORNER_RADIUS_PIXELS; const backgroundContent = this._bgManager.backgroundActor.content; + + // Map ControlsState {0, 1, 2} to progress {0.0, 1.0, 1.0} + const roundedCornerProgress = + Math.clamp(this._stateAdjustment.value, 0, 1); backgroundContent.rounded_clip_radius = - Util.lerp(0, cornerRadius, this._stateAdjustment.value); + Util.lerp(0, cornerRadius, roundedCornerProgress); } _updateRoundedClipBounds() { @@ -1048,7 +1052,7 @@ class Workspace extends St.Widget { // Background this._background = - new WorkspaceBackground(monitorIndex, layoutManager.stateAdjustment); + new WorkspaceBackground(monitorIndex, overviewAdjustment); this.add_child(this._background); // Window previews diff --git a/src/shell-workspace-background.c b/src/shell-workspace-background.c index 290441ac8..d99911929 100644 --- a/src/shell-workspace-background.c +++ b/src/shell-workspace-background.c @@ -70,6 +70,7 @@ shell_workspace_background_allocate (ClutterActor *actor, int left_offset, right_offset; int top_offset, bottom_offset; int scale_factor; + float progress; scale_factor = st_theme_context_get_scale_factor (context); @@ -81,8 +82,9 @@ shell_workspace_background_allocate (ClutterActor *actor, scaled_box.y1 = box->y1 + (height - scaled_height) / 2; clutter_actor_box_set_size (&scaled_box, scaled_width, scaled_height); - clutter_actor_box_interpolate(box, &scaled_box, - self->state_adjustment_value, &my_box); + // Map ControlsState {0, 1, 2} to progress {0.0, 1.0, 0.0} + progress = 1.f - fabs (1.f - self->state_adjustment_value); + clutter_actor_box_interpolate(box, &scaled_box, progress, &my_box); clutter_actor_set_allocation (actor, &my_box);