diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-08 16:02:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-08 16:02:14 +0000 |
commit | 52f118cd4c2fbdd81a6ef463835a20cb3d6a3667 (patch) | |
tree | 0904907fa04c7c1fe36fe8cdefab7e27b477723a /extensions/vertical-workspaces/lib/workspace.js | |
parent | Updating multi-monitors-add-on to version 26 [d8ea040]. (diff) | |
download | gnome-shell-extensions-extra-52f118cd4c2fbdd81a6ef463835a20cb3d6a3667.tar.xz gnome-shell-extensions-extra-52f118cd4c2fbdd81a6ef463835a20cb3d6a3667.zip |
Updating vertical-workspaces to version 28 [891a8df].
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | extensions/vertical-workspaces/lib/workspace.js (renamed from extensions/vertical-workspaces/workspace.js) | 108 |
1 files changed, 57 insertions, 51 deletions
diff --git a/extensions/vertical-workspaces/workspace.js b/extensions/vertical-workspaces/lib/workspace.js index 84ca696..3b61a6d 100644 --- a/extensions/vertical-workspaces/workspace.js +++ b/extensions/vertical-workspaces/lib/workspace.js @@ -1,7 +1,7 @@ /** - * Vertical Workspaces + * V-Shell (Vertical Workspaces) * workspace.js - * + * * @author GdH <G-dH@github.com> * @copyright 2022 - 2023 * @license GPL-3.0 @@ -10,7 +10,7 @@ 'use strict'; -const { Clutter, St, Graphene } = imports.gi; +const { St, Graphene } = imports.gi; const Main = imports.ui.main; const Util = imports.misc.util; @@ -19,33 +19,37 @@ const Workspace = imports.ui.workspace; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); -const _Util = Me.imports.util; -let _overrides; +const _Util = Me.imports.lib.util; +let _overrides; let opt; +let _firstRun = true; -const BACKGROUND_CORNER_RADIUS_PIXELS = 40; +function update(reset = false) { + opt = Me.imports.lib.settings.opt; + const moduleEnabled = opt.get('workspaceModule', true); + reset = reset || !moduleEnabled; + // don't even touch this module if disabled + if (_firstRun && reset) + return; -function update(reset = false) { - if (_overrides) { + _firstRun = false; + + if (_overrides) _overrides.removeAll(); - } + if (reset) { - imports.ui.workspace.WINDOW_PREVIEW_MAXIMUM_SCALE = 0.95; + Workspace.WINDOW_PREVIEW_MAXIMUM_SCALE = 0.95; _overrides = null; opt = null; return; } - opt = Me.imports.settings.opt; - _overrides = new _Util.Overrides(); _overrides.addOverride('WorkspaceBackground', Workspace.WorkspaceBackground.prototype, WorkspaceBackground); - // fix window scaling in workspace state 0 - _overrides.addInjection('WorkspaceLayout', Workspace.WorkspaceLayout.prototype, WorkspaceLayoutInjections); // fix overlay base for Vertical Workspaces _overrides.addOverride('WorkspaceLayout', Workspace.WorkspaceLayout.prototype, WorkspaceLayout); @@ -54,32 +58,35 @@ function update(reset = false) { // workaround for upstream bug (that is not that invisible in default shell) // smaller window cannot be scaled below 0.95 (WINDOW_PREVIEW_MAXIMUM_SCALE) -// when its target scale for spread windows view (workspace state 1) is bigger than the scale needed for ws state 0. +// when its target scale for exposed windows view (workspace state 1) is bigger than the scale needed for ws state 0. // in workspace state 0 where windows are not spread and window scale should follow workspace scale, // this window follows proper top left corner position, but doesn't scale with the workspace // so it looks bad and the window can exceed border of the workspace // extremely annoying in OVERVIEW_MODE 1 with single smaller window on the workspace, also affects appGrid transition animation -var WorkspaceLayoutInjections = { - _init: function() { - this._stateAdjustment.connect('notify::value', () => { - if (opt.OVERVIEW_MODE !== 1) return; - // scale 0.1 for window state 0 just needs to be smaller then possible scale of any window in spread view - const scale = this._stateAdjustment.value ? 0.95 : 0.1; - if (scale !== Workspace.WINDOW_PREVIEW_MAXIMUM_SCALE || this._stateAdjustment.value === 1) { - // when transition to ws state 1 begins, replace the constant with the original one - // disadvantage - the value changes for all workspaces, so one affects others - // that can be visible in certain situations but not a big deal. - Workspace.WINDOW_PREVIEW_MAXIMUM_SCALE = scale; - // and force recalculation of the target layout, so the transition will be smooth - this._needsLayout = true; - } - }); - } -} -var WorkspaceLayout = { +// disadvantage of following workaround - the WINDOW_PREVIEW_MAXIMUM_SCALE value is common for every workspace, +// on multi-monitor system can be visible unwanted scaling of windows on workspace in WORKSPACE_MODE 0 (windows not spread) +// when leaving overview while any other workspace is in the WORKSPACE_MODE 1. +const WorkspaceLayout = { + // injection to _init() + after__init() { + if (opt.OVERVIEW_MODE === 1) { + this._stateAdjustment.connect('notify::value', () => { + // scale 0.1 for window state 0 just needs to be smaller then possible scale of any window in spread view + const scale = this._stateAdjustment.value ? 0.95 : 0.1; + if (scale !== this.WINDOW_PREVIEW_MAXIMUM_SCALE) { + this.WINDOW_PREVIEW_MAXIMUM_SCALE = scale; + // when transition to ws state 1 (WINDOW_PICKER) begins, replace the constant with the original one + Workspace.WINDOW_PREVIEW_MAXIMUM_SCALE = scale; + // and force recalculation of the target layout, so the transition will be smooth + this._needsLayout = true; + } + }); + } + }, + // this fixes wrong size and position calculation of window clones while moving overview to the next (+1) workspace if vertical ws orientation is enabled in GS - _adjustSpacingAndPadding: function(rowSpacing, colSpacing, containerBox) { + _adjustSpacingAndPadding(rowSpacing, colSpacing, containerBox) { if (this._sortedWindows.length === 0) return [rowSpacing, colSpacing, containerBox]; @@ -103,11 +110,11 @@ var WorkspaceLayout = { const monitor = Main.layoutManager.monitors[this._monitorIndex]; const bottomPoint = new Graphene.Point3D(); - if (vertical) { + if (vertical) bottomPoint.x = containerBox.x2; - } else { + else bottomPoint.y = containerBox.y2; - } + const transformedBottomPoint = this._container.apply_transform_to_point(bottomPoint); @@ -117,30 +124,29 @@ var WorkspaceLayout = { const [, bottomOverlap] = window.overlapHeights(); - if ((bottomOverlap + oversize) > bottomFreeSpace && !vertical) { + if ((bottomOverlap + oversize) > bottomFreeSpace && !vertical) containerBox.y2 -= (bottomOverlap + oversize) - bottomFreeSpace; - } } return [rowSpacing, colSpacing, containerBox]; - } -} + }, +}; -var WorkspaceBackground = { - _updateBorderRadius: function(value = false) { +const WorkspaceBackground = { + _updateBorderRadius(value = false) { // don't round already rounded corners during exposing windows - if (value === false && opt.OVERVIEW_MODE === 1) { + if (value === false && opt.OVERVIEW_MODE === 1) return; - } + const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage); - const cornerRadius = scaleFactor * BACKGROUND_CORNER_RADIUS_PIXELS; + const cornerRadius = scaleFactor * opt.WS_PREVIEW_BG_RADIUS; const backgroundContent = this._bgManager.backgroundActor.content; - value = (value !==false) - ? value - : this._stateAdjustment.value; + value = value !== false + ? value + : this._stateAdjustment.value; backgroundContent.rounded_clip_radius = Util.lerp(0, cornerRadius, value); - } -} + }, +}; |