Skip to content

Commit

Permalink
Add option to spread out coverflow windows and change their angles
Browse files Browse the repository at this point in the history
  • Loading branch information
dsheeler committed Feb 6, 2025
1 parent 99941c6 commit c9958ad
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
10 changes: 10 additions & 0 deletions schemas/org.gnome.shell.extensions.coverflowalttab.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@
<summary>In Coverflow Switcher, scales the previews as they spread out to the sides in </summary>
<description>Define the scale factor successively applied each step away from the current preview.</description>
</key>
<key type="d" name="coverflow-window-angle">
<range min="0" max="360"/>
<default>90</default>
<summary>In Coverflow switcher, angle of off-center windows</summary>
</key>
<key type="d" name="coverflow-window-offset-width">
<range min="0" max="1000"/>
<default>50</default>
<summary>In Coverflow switcher, distance from center of off-center windows</summary>
</key>
<key type="b" name="bind-to-switch-applications">
<default>true</default>
<summary>Bind to 'switch-applications' keybinding</summary>
Expand Down
18 changes: 10 additions & 8 deletions src/coverflowSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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()) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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), {
Expand All @@ -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), {
Expand Down
6 changes: 6 additions & 0 deletions src/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c9958ad

Please sign in to comment.