From c9958ad7fea8b320501b0fded549fd7678a44123 Mon Sep 17 00:00:00 2001 From: Daniel Sheeler Date: Wed, 5 Feb 2025 16:14:56 -0600 Subject: [PATCH] Add option to spread out coverflow windows and change their angles --- ...hell.extensions.coverflowalttab.gschema.xml | 10 ++++++++++ src/coverflowSwitcher.js | 18 ++++++++++-------- src/platform.js | 6 ++++++ src/prefs.js | 3 ++- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/schemas/org.gnome.shell.extensions.coverflowalttab.gschema.xml b/schemas/org.gnome.shell.extensions.coverflowalttab.gschema.xml index 897cc61..44bcd11 100644 --- a/schemas/org.gnome.shell.extensions.coverflowalttab.gschema.xml +++ b/schemas/org.gnome.shell.extensions.coverflowalttab.gschema.xml @@ -145,6 +145,16 @@ In Coverflow Switcher, scales the previews as they spread out to the sides in Define the scale factor successively applied each step away from the current preview. + + + 90 + In Coverflow switcher, angle of off-center windows + + + + 50 + In Coverflow switcher, distance from center of off-center windows + true Bind to 'switch-applications' keybinding diff --git a/src/coverflowSwitcher.js b/src/coverflowSwitcher.js index 2671094..df87bbf 100644 --- a/src/coverflowSwitcher.js +++ b/src/coverflowSwitcher.js @@ -27,7 +27,6 @@ import {Switcher} from './switcher.js'; const BaseSwitcher = Switcher; import {Preview, Placement, Direction, findUpperLeftFromCenter} from './preview.js' -const SIDE_ANGLE = 90; const ALPHA = 1; function appendParams(base, extra) { @@ -51,7 +50,7 @@ export class CoverflowSwitcher extends BaseSwitcher { y: this.actor.height / 2 + this._settings.offset }; let ratio = this._settings.preview_to_monitor_ratio; - this._xOffsetLeft = this.actor.width * (0.5 * (1 - ratio) - 0.1 * ratio) + this._xOffsetLeft = this.actor.width * (0.5 * (1 - ratio) - 0.1 * ratio); this._xOffsetRight = this.actor.width - this._xOffsetLeft; for (let windowActor of global.get_window_actors()) { @@ -212,12 +211,13 @@ export class CoverflowSwitcher extends BaseSwitcher { scale_z: scale, pivot_point: pivot_point, }; + const window_offset_width = this._settings.coverflow_window_offset_width; if (index < pivot_index) { - tweenParams.translation_x = xOffset - (this._previewsCenterPosition.x - - preview.width / 2) + 50 * (index - pivot_index); + tweenParams.translation_x = (xOffset - (this._previewsCenterPosition.x + - preview.width / 2) + window_offset_width * (index - pivot_index)); } else { - tweenParams.translation_x = xOffset - (this._previewsCenterPosition.x - + preview.width / 2) + 50 * (index - pivot_index); + tweenParams.translation_x = (xOffset - (this._previewsCenterPosition.x + + preview.width / 2) + window_offset_width * (index - pivot_index)); } appendParams(tweenParams, extraParams); this._manager.platform.tween(preview, tweenParams); @@ -282,6 +282,8 @@ export class CoverflowSwitcher extends BaseSwitcher { } _updatePreview(idx, zeroIndexPreview, preview, i, reorder_only, animation_time) { + const side_angle = this._settings.coverflow_window_angle; + let half_length = Math.floor(this._previews.length / 2); let pivot_index = (this._usingCarousel()) ? half_length : this._currentIndex; @@ -296,7 +298,7 @@ export class CoverflowSwitcher extends BaseSwitcher { } else if (idx < pivot_index) { preview.make_top_layer(this.previewActor); if (!reorder_only) { - let final_angle = SIDE_ANGLE + this._getPerspectiveCorrectionAngle(0); + let final_angle = side_angle + this._getPerspectiveCorrectionAngle(0); let progress = pivot_index - idx < 1 ? pivot_index - idx : 1; let center_offset = (this._xOffsetLeft + this._xOffsetRight) / 2; this._animatePreviewToSide(preview, idx, center_offset - preview.width / 2 - progress * (center_offset - preview.width / 2 - this._xOffsetLeft), { @@ -308,7 +310,7 @@ export class CoverflowSwitcher extends BaseSwitcher { } else /* i > this._currentIndex */ { preview.make_bottom_layer(this.previewActor); if (!reorder_only) { - let final_angle = -SIDE_ANGLE + this._getPerspectiveCorrectionAngle(1); + let final_angle = -side_angle + this._getPerspectiveCorrectionAngle(1); let progress = idx - pivot_index < 1 ? idx - pivot_index : 1; let center_offset = (this._xOffsetLeft + this._xOffsetRight) / 2; this._animatePreviewToSide(preview, idx, center_offset + preview.width / 2 + progress * (this._xOffsetRight - center_offset - preview.width / 2), { diff --git a/src/platform.js b/src/platform.js index af60fd6..de4b6fa 100644 --- a/src/platform.js +++ b/src/platform.js @@ -144,6 +144,8 @@ class AbstractPlatform { verbose_logging: false, natural_scrolling: true, icon_add_remove_effects: "Fade Only", + coverflow_window_angle: 90, + coverflow_window_offset_width: 50, }; } @@ -257,6 +259,8 @@ export class PlatformGnomeShell extends AbstractPlatform { "prefs-default-height", "verbose-logging", "icon-add-remove-effects", + "coverflow-window-angle", + "coverflow-window-offset-width", ]; let dkeys = [ @@ -409,6 +413,8 @@ export class PlatformGnomeShell extends AbstractPlatform { verbose_logging: settings.get_boolean("verbose-logging"), natural_scrolling: touchpadSettings.get_boolean(KEY_NATURAL_SCROLL), icon_add_remove_effects: settings.get_string("icon-add-remove-effects"), + coverflow_window_angle: settings.get_double("coverflow-window-angle"), + coverflow_window_offset_width: settings.get_double("coverflow-window-offset-width"), }; } catch (e) { this._logger.log(e); diff --git a/src/prefs.js b/src/prefs.js index c7dc264..4390975 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -289,7 +289,8 @@ export default class CoverflowAltTabPreferences extends ExtensionPreferences { window_size_page.add(windows_pref_group); window_size_pref_group.add(buildRangeAdw(settings, "preview-to-monitor-ratio", [0, 1, 0.001, [0.250, 0.500, 0.750]], _("Window Preview Size to Monitor Size Ratio"), _("Maximum ratio of window preview size to monitor size."), true)); window_size_pref_group.add(buildRangeAdw(settings, "preview-scaling-factor", [0, 1, 0.001, [0.250, 0.500, 0.800]], _("Off-center Size Factor"), _("Factor by which to successively shrink previews off to the side."), true)); - + window_size_pref_group.add(buildRangeAdw(settings, "coverflow-window-angle", [0, 360, 0.5, [0, 90, 180, 270]], _("Coverflow Window Angle"), _("Angle of off-center windows in coverflow mode."), true)); + window_size_pref_group.add(buildRangeAdw(settings, "coverflow-window-offset-width", [0, 1000, 1, [0, 50,]], _("Coverflow Window Offset Width"), _("How far windows are off to the side in coverflow mode."), true)); let background_application_page = new Adw.PreferencesPage({ title: _("AppSwitcher"), icon_name: "appswitcher-symbolic"