Skip to content

Commit

Permalink
Added Adw preferences page and new preferences and capabilities.
Browse files Browse the repository at this point in the history
1) Can raise the window under the mouse
2) Can highlight the window under the mouse
3) Can choose perspective correction method
4) Added the PC method that moves the camera over the off-center monitor
5) Introduced linear transition
  • Loading branch information
dsheeler committed Dec 24, 2022
1 parent 617b6d2 commit a6d48de
Show file tree
Hide file tree
Showing 12 changed files with 839 additions and 110 deletions.
43 changes: 25 additions & 18 deletions [email protected]/coverflowSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var CoverflowSwitcher = class CoverflowSwitcher extends BaseSwitcher {
if (width > previewWidth || height > previewHeight)
scale = Math.min(previewWidth / width, previewHeight / height);

let preview = new Preview({
let preview = new Preview(metaWin, {
name: metaWin.title,
opacity: ALPHA * (!metaWin.minimized && metaWin.get_workspace() == currentWorkspace || metaWin.is_on_all_workspaces()) ? 255 : 0,
source: texture.get_size ? texture : compositor,
Expand All @@ -99,7 +99,6 @@ var CoverflowSwitcher = class CoverflowSwitcher extends BaseSwitcher {
scale_z: metaWin.minimized ? 0 : 1,
rotation_angle_y: 0,
});

preview.scale = scale;
preview.set_pivot_point_placement(Placement.CENTER);
preview.center_position = {
Expand All @@ -121,7 +120,7 @@ var CoverflowSwitcher = class CoverflowSwitcher extends BaseSwitcher {
this._flipStack(Direction.TO_LEFT);
} else {
this._currentIndex = this._currentIndex + 1;
this._updatePreviews();
this._updatePreviews(false);
}
}

Expand All @@ -131,7 +130,7 @@ var CoverflowSwitcher = class CoverflowSwitcher extends BaseSwitcher {
this._flipStack(Direction.TO_RIGHT);
} else {
this._currentIndex = this._currentIndex - 1;
this._updatePreviews();
this._updatePreviews(false);
}
}

Expand Down Expand Up @@ -229,13 +228,12 @@ var CoverflowSwitcher = class CoverflowSwitcher extends BaseSwitcher {
this._looping = false;
if (this._requiresUpdate === true) {
this._requiresUpdate = false;
this._updatePreviews();
this._updatePreviews(false);
}
}

// TODO: Remove unused direction variable
_animatePreviewToMid(preview, animation_time, extraParams = []) {
preview.make_top_layer(this.previewActor);
let pivot_point = preview.get_pivot_point_placement(Placement.CENTER);
let tweenParams = {
x: findUpperLeftFromCenter(preview.width, this._previewsCenterPosition.x),
Expand Down Expand Up @@ -286,6 +284,7 @@ var CoverflowSwitcher = class CoverflowSwitcher extends BaseSwitcher {
}

_getPerspectiveCorrectionAngle(side) {
if (this._settings.perspective_correction_method != "Adjust Angles") return 0;
if (this.num_monitors == 1) {
return 0;
} else if (this.num_monitors == 2) {
Expand All @@ -309,7 +308,7 @@ var CoverflowSwitcher = class CoverflowSwitcher extends BaseSwitcher {
}
}

_updatePreviews() {
_updatePreviews(reorder_only=false) {
if(this._looping) {
this._requiresUpdate = true;
return;
Expand All @@ -318,24 +317,32 @@ var CoverflowSwitcher = class CoverflowSwitcher extends BaseSwitcher {
this._updateActiveMonitor();

// preview windows
if (this._previews == null) return;
for (let [i, preview] of this._previews.entries()) {
let animation_time = this._settings.animation_time * (this._settings.randomize_animation_times ? this._getRandomArbitrary(0.0001, 1) : 1);
if (i === this._currentIndex) {
this._animatePreviewToMid(preview, this._settings.animation_time);
preview.make_top_layer(this.previewActor);
if (!reorder_only) {
this._animatePreviewToMid(preview, this._settings.animation_time);
}
} else if (i < this._currentIndex) {
preview.make_top_layer(this.previewActor);
this._animatePreviewToSide(preview, i, this._xOffsetLeft, {
rotation_angle_y: SIDE_ANGLE + this._getPerspectiveCorrectionAngle(0),
time: animation_time,
transition: 'userChoice',
});
if (!reorder_only) {
this._animatePreviewToSide(preview, i, this._xOffsetLeft, {
rotation_angle_y: SIDE_ANGLE + this._getPerspectiveCorrectionAngle(0),
time: animation_time,
transition: 'userChoice',
});
}
} else /* i > this._currentIndex */ {
preview.make_bottom_layer(this.previewActor);
this._animatePreviewToSide(preview, i, this._xOffsetRight, {
rotation_angle_y: -SIDE_ANGLE + this._getPerspectiveCorrectionAngle(1),
time: animation_time,
transition: 'userChoice',
});
if (!reorder_only) {
this._animatePreviewToSide(preview, i, this._xOffsetRight, {
rotation_angle_y: -SIDE_ANGLE + this._getPerspectiveCorrectionAngle(1),
time: animation_time,
transition: 'userChoice',
});
}
}
this._manager.platform.tween(preview, {
opacity: ALPHA * 255,
Expand Down
Binary file modified [email protected]/locale/fr/LC_MESSAGES/coverflow.mo
Binary file not shown.
24 changes: 17 additions & 7 deletions [email protected]/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class AbstractPlatform {
preview_scaling_factor: 0.75,
bind_to_switch_applications: true,
bind_to_switch_windows: true,
perspective_correction_method: "None",
highlight_mouse_over: false,
raise_mouse_over: true,
};
}

Expand Down Expand Up @@ -185,6 +188,9 @@ var PlatformGnomeShell = class PlatformGnomeShell extends AbstractPlatform {
"preview-scaling-factor",
"bind-to-switch-applications",
"bind-to-switch-windows",
"perspective-correction-method",
"highlight-mouse-over",
"raise-mouse-over",
];

let dkeys = [
Expand Down Expand Up @@ -257,14 +263,14 @@ var PlatformGnomeShell = class PlatformGnomeShell extends AbstractPlatform {
let settings = this._extensionSettings;
let dsettings = this._desktopSettings;
return {
animation_time: clamp(settings.get_int("animation-time") / 1000, 0.01, 8),
animation_time: settings.get_double("animation-time"),
randomize_animation_times: settings.get_boolean("randomize-animation-times"),
dim_factor: clamp(settings.get_int("dim-factor") / 1000, 0, 1),
dim_factor: clamp(settings.get_double("dim-factor"), 0, 1),
title_position: (settings.get_string("position") == 'Top' ? POSITION_TOP : POSITION_BOTTOM),
icon_style: (settings.get_string("icon-style") == 'Overlay' ? 'Overlay' : 'Classic'),
icon_has_shadow: settings.get_boolean("icon-has-shadow"),
overlay_icon_size: clamp(settings.get_int("overlay-icon-size"), 0, 1024),
overlay_icon_opacity: clamp(settings.get_int("overlay-icon-opacity") / 1000, 0, 1),
overlay_icon_size: clamp(settings.get_double("overlay-icon-size"), 0, 1024),
overlay_icon_opacity: clamp(settings.get_double("overlay-icon-opacity"), 0, 1),
text_scaling_factor: dsettings.get_double(KEY_TEXT_SCALING_FACTOR),
offset: settings.get_int("offset"),
hide_panel: settings.get_boolean("hide-panel"),
Expand All @@ -274,10 +280,13 @@ var PlatformGnomeShell = class PlatformGnomeShell extends AbstractPlatform {
? TimelineSwitcher : CoverflowSwitcher,
current_workspace_only: settings.get_string("current-workspace-only"),
switch_per_monitor: settings.get_boolean("switch-per-monitor"),
preview_to_monitor_ratio: clamp(settings.get_int("preview-to-monitor-ratio") / 1000, 0, 1),
preview_scaling_factor: clamp(settings.get_int("preview-scaling-factor") / 1000, 0, 1),
preview_to_monitor_ratio: clamp(settings.get_double("preview-to-monitor-ratio"), 0, 1),
preview_scaling_factor: clamp(settings.get_double("preview-scaling-factor"), 0, 1),
bind_to_switch_applications: settings.get_boolean("bind-to-switch-applications"),
bind_to_switch_windows: settings.get_boolean("bind-to-switch-windows"),
perspective_correction_method: settings.get_string("perspective-correction-method"),
highlight_mouse_over: settings.get_boolean("highlight-mouse-over"),
raise_mouse_over: settings.get_boolean("raise-mouse-over"),
};
} catch (e) {
global.log(e);
Expand Down Expand Up @@ -381,7 +390,8 @@ var PlatformGnomeShell = class PlatformGnomeShell extends AbstractPlatform {
} else if (params.transition == 'userChoice' && this.getSettings().easing_function == "ease-in-out-circ" ||
params.transition == 'easeInOutCirc') {
params.mode = Clutter.AnimationMode.EASE_IN_OUT_CIRC;
} else if (params.transition == 'easeLinear') {
} else if (params.transition == 'userChoice' && this.getSettings().easing_function == "ease-linear" ||
params.transition == 'easeLinear') {
params.mode = Clutter.AnimationMode.LINEAR;
} else {
global.log("Could not find Clutter AnimationMode", params.transition, this.getSettings().easing_function);
Expand Down
Loading

0 comments on commit a6d48de

Please sign in to comment.