Skip to content

Commit

Permalink
Bring back timeline and add icons attached to windows in app switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
dsheeler committed Nov 22, 2023
1 parent 818ce6a commit 3f3a794
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 35 deletions.
22 changes: 19 additions & 3 deletions schemas/org.gnome.shell.extensions.coverflowalttab.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
</key>
<key type="d" name="dim-factor">
<range min="0" max="1"/>
<default>0</default>
<default>1</default>
<summary>Dim factor for background</summary>
<description>Define dimming of the background. Smaller means darker. </description>
<description>Define dimming of the background. Bigger means darker. </description>
</key>
<key type="s" name="position">
<choices>
Expand Down Expand Up @@ -59,6 +59,22 @@
<summary>The opacity of the overlay icon</summary>
<description>Define the opacity of the overlay icon.</description>
</key>
<key type="b" name="use-application-switcher-icons">
<default>true</default>
<summary>Use application switcher icons</summary>
<description>Whether to place icons over the application switcher windows.</description>
</key>
<key type="d" name="app-switcher-icon-opacity">
<range min="0.1" max="1"/>
<default>1</default>
<summary>The opacity of icons on application switcher previews.</summary>
</key>
<key type="d" name="app-switcher-icon-size-ratio">
<range min="0.1" max="5"/>
<default>0.9</default>
<summary>The ratio of the icon size to the preview size.</summary>
<description>How relatively big is the icon covering previews in the application switcher.</description>
</key>
<key type="s" name="switcher-style">
<choices>
<choice value="Coverflow"/>
Expand Down Expand Up @@ -125,7 +141,7 @@
<key type="b" name="icon-has-shadow">
<default>false</default>
<summary>Icon has shadow switch</summary>
<description>Whether or not the icon has a drop shadow.</description>
<description>Whether or not the icons have a drop shadow.</description>
</key>
<key type="b" name="randomize-animation-times">
<default>false</default>
Expand Down
4 changes: 2 additions & 2 deletions src/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ export const Manager = class Manager {
if (windows.length) {
let mask = binding.get_mask();
let currentIndex = windows.indexOf(display.focus_window);

this.switcher = new CoverflowSwitcher(windows, mask, currentIndex, this, null, isApplicationSwitcher, null);
let switcher_class = this.platform.getSettings().switcher_class;
this.switcher = new switcher_class(windows, mask, currentIndex, this, null, isApplicationSwitcher, null);
}
}
}
11 changes: 10 additions & 1 deletion src/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ class AbstractPlatform {
use_glitch_effect: false,
use_tint: false,
invert_swipes: false,
use_application_switcher_icons: true,
app_switcher_icon_opacity: 1,
app_switcher_icon_size_ratio: 0.9,
};
}

Expand Down Expand Up @@ -202,6 +205,9 @@ export class PlatformGnomeShell extends AbstractPlatform {
"use-theme-color-for-tint-color",
"use-glitch-effect",
"invert-swipes",
"use-application-switcher-icons",
"app-switcher-icon-opacity",
"app-switcher-icon-size-ratio",
];

let dkeys = [
Expand Down Expand Up @@ -318,6 +324,9 @@ export class PlatformGnomeShell extends AbstractPlatform {
use_glitch_effect: settings.get_boolean("use-glitch-effect"),
use_tint: settings.get_boolean("use-tint"),
invert_swipes: settings.get_boolean("invert-swipes"),
use_application_switcher_icons: settings.get_boolean("use-application-switcher-icons"),
app_switcher_icon_opacity: settings.get_double("app-switcher-icon-opacity"),
app_switcher_icon_size_ratio: settings.get_double("app-switcher-icon-size-ratio"),
};
} catch (e) {
global.log(e);
Expand Down Expand Up @@ -465,7 +474,7 @@ export class PlatformGnomeShell extends AbstractPlatform {

let shade = new MyRadialShaderEffect({name: 'shade'});
shade.brightness = 1;
shade.sharpness = 1 - this._settings.dim_factor;
shade.sharpness = this._settings.dim_factor;

this._backgroundShade.add_effect(shade);

Expand Down
56 changes: 39 additions & 17 deletions src/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,21 @@ export default class CoverflowAltTabPreferences extends ExtensionPreferences {
let switcher_looping_method_buttons = new Map([ [_("Flip Stack"), []], [_("Carousel"), []]]);

let switcher_looping_method_row = buildRadioAdw(settings, "switcher-looping-method", switcher_looping_method_buttons, _("Looping Method"), _("How to cycle through windows."));
switcher_pref_group.add(buildRadioAdw(settings, "switcher-style", new Map([ [_("Coverflow"), [switcher_looping_method_row]], [_("Timeline"), []] ]), _("Style"), _("Pick the type of switcher.")))
switcher_pref_group.add(buildSpinAdw(settings, "offset", [-500, 500, 1, 10], _("Vertical Offset"), _("Positive value moves everything down, negative up.")));
switcher_pref_group.add(buildRadioAdw(settings, "position", new Map([ [_("Bottom"), []], [_("Top"), []]]), _("Window Title Position"), _("Place window title above or below the switcher.")));
switcher_pref_group.add(buildSwitcherAdw(settings, "enforce-primary-monitor", [], _("Enforce Primary Monitor"), _("Always show on the primary monitor, otherwise, show on the active monitor.")));
switcher_pref_group.add(buildSwitcherAdw(settings, "enforce-primary-monitor", [], [], _("Enforce Primary Monitor"), _("Always show on the primary monitor, otherwise, show on the active monitor.")));

switcher_pref_group.add(switcher_looping_method_row);
switcher_pref_group.add(buildSwitcherAdw(settings, "hide-panel", [], _("Hide Panel"), _("Hide panel when switching windows.")));
switcher_pref_group.add(buildSwitcherAdw(settings, "invert-swipes", [], _("Invert Swipes"), _("Swipe content instead of view.")));
switcher_pref_group.add(buildSwitcherAdw(settings, "hide-panel", [], [], _("Hide Panel"), _("Hide panel when switching windows.")));
switcher_pref_group.add(buildSwitcherAdw(settings, "invert-swipes", [], [], _("Invert Swipes"), _("Swipe content instead of view.")));
let animation_pref_group = new Adw.PreferencesGroup({
title: _('Animation'),
});

animation_pref_group.add(buildDropDownAdw(settings, "easing-function", easing_options, "Easing Function", "Determine how windows move."));
animation_pref_group.add(buildRangeAdw(settings, "animation-time", [0.01, 20, 0.001, [0.5, 1, 1.5]], _("Duration [s]"), "", true));
animation_pref_group.add(buildSwitcherAdw(settings, "randomize-animation-times", [], _("Randomize Durations"), _("Each animation duration assigned randomly between 0 and configured duration.")));
animation_pref_group.add(buildSwitcherAdw(settings, "randomize-animation-times", [], [], _("Randomize Durations"), _("Each animation duration assigned randomly between 0 and configured duration.")));

let windows_pref_group = new Adw.PreferencesGroup({
title: _('Switcher Windows'),
Expand All @@ -175,19 +176,28 @@ export default class CoverflowAltTabPreferences extends ExtensionPreferences {
id: 'all-currentfirst', name: _("All workspaces, current first")
}];
windows_pref_group.add(buildDropDownAdw(settings, "current-workspace-only", options, _("Workspaces"), _("Switch between windows on current or on all workspaces.")));
windows_pref_group.add(buildSwitcherAdw(settings, "switch-per-monitor", [], _("Current Monitor"), _("Switch between windows on current monitor.")));
windows_pref_group.add(buildSwitcherAdw(settings, "switch-per-monitor", [], [], _("Current Monitor"), _("Switch between windows on current monitor.")));

let icon_pref_group = new Adw.PreferencesGroup({
title: _("Icon"),
});
let size_row = buildRangeAdw(settings, "overlay-icon-size", [0, 1024, 1, [32, 64, 128, 256, 512]], _("Overlay Icon Size"), _("Set the overlay icon size in pixels."), true);


let size_row = buildRangeAdw(settings, "overlay-icon-size", [0, 1024, 1, [32, 64, 128, 256, 512]], _("Overlay Icon Size"), _("Set the overlay icon size in pixels."), true);
let opacity_row = buildRangeAdw(settings, "overlay-icon-opacity", [0, 1, 0.001, [0.25, 0.5, 0.75]], _("Overlay Icon Opacity"), _("Set the overlay icon opacity."), true);
let buttons = new Map([[_("Classic"), []], [_("Overlay"), [size_row, opacity_row]]]);
let style_row = buildRadioAdw(settings, "icon-style", buttons, _("Application Icon Style"));
let app_switcher_icon_size_row = buildRangeAdw(settings, "app-switcher-icon-size-ratio", [0.1, 5, 0.005, []], _("Application Switcher Icon Size Ratio"), _("Set the ratio of the size of application switcher icons to the size of their respective windows."), true);
let app_switcher_icon_opacity_row = buildRangeAdw(settings, "app-switcher-icon-opacity", [0.1, 1, 0.001, []], _("Application Switcher Icon Opacity"), _("Set the application switcher icons opacity."), true);

let buttons = new Map([[_("Classic"), []], [_("Overlay"), [size_row, opacity_row]]]);
icon_pref_group.add(buildRadioAdw(settings, "icon-style", buttons, _("Application Icon Style")));
icon_pref_group.add(style_row);
icon_pref_group.add(size_row);
icon_pref_group.add(opacity_row);
icon_pref_group.add(buildSwitcherAdw(settings, "icon-has-shadow", [], _("Icon Shadow")));
icon_pref_group.add(buildSwitcherAdw(settings, "icon-has-shadow", [], [], _("Icon Shadow")));

icon_pref_group.add(buildSwitcherAdw(settings, "use-application-switcher-icons", [app_switcher_icon_size_row, app_switcher_icon_opacity_row], [], _("Use Application Switcher Icons"), _("Whether to place icons over the application switcher windows.")))
icon_pref_group.add(app_switcher_icon_size_row);
icon_pref_group.add(app_switcher_icon_opacity_row);

let window_size_pref_group = new Adw.PreferencesGroup({
title: _("Windows")
Expand All @@ -198,13 +208,13 @@ export default class CoverflowAltTabPreferences extends ExtensionPreferences {
let background_application_switcher_pref_group = new Adw.PreferencesGroup({
title: _('Application Switcher'),
});
background_application_switcher_pref_group.add(buildSwitcherAdw(settings, "switch-application-behaves-like-switch-windows", [], _("Make the Application Switcher Behave Like the Window Switcher"), _("Don't group windows of the same application in a subswitcher.")));
background_application_switcher_pref_group.add(buildSwitcherAdw(settings, "switch-application-behaves-like-switch-windows", [], [], _("Make the Application Switcher Behave Like the Window Switcher"), _("Don't group windows of the same application in a subswitcher.")));
background_application_switcher_pref_group.add(buildRangeAdw(settings, "desaturate-factor", [0, 1, 0.001, [0.25, 0.5, 0.75]], _("Desaturate"), _("Larger means more desaturation."), true));
background_application_switcher_pref_group.add(buildSpinAdw(settings, "blur-sigma", [0, 20, 1, 1], _("Blur"), _("Larger means more blurry.")));

let color_row = new Adw.ActionRow({
title: _("Tint"),
subtitle: _("The opacity of the color controls how much it is blended. The theme color is blended at 0.75."),
subtitle: _("The opacity of the color controls how much it is blended. The theme color is blended at 0.666."),
});
background_application_switcher_pref_group.add(color_row);

Expand Down Expand Up @@ -264,7 +274,7 @@ export default class CoverflowAltTabPreferences extends ExtensionPreferences {
});
color_row.add_suffix(reset_button);

background_application_switcher_pref_group.add(buildSwitcherAdw(settings, "use-glitch-effect", [], _("Glitch")));
background_application_switcher_pref_group.add(buildSwitcherAdw(settings, "use-glitch-effect", [], [], _("Glitch")));

let background_pref_group = new Adw.PreferencesGroup({
title: _('Background'),
Expand All @@ -274,8 +284,8 @@ export default class CoverflowAltTabPreferences extends ExtensionPreferences {
let keybinding_pref_group = new Adw.PreferencesGroup({
title: _("Keybindings"),
});
keybinding_pref_group.add(buildSwitcherAdw(settings, "bind-to-switch-windows", [], _("Bind to 'switch-windows'")));
keybinding_pref_group.add(buildSwitcherAdw(settings, "bind-to-switch-applications", [background_application_switcher_pref_group], _("Bind to 'switch-applications'")));
keybinding_pref_group.add(buildSwitcherAdw(settings, "bind-to-switch-windows", [], [], _("Bind to 'switch-windows'")));
keybinding_pref_group.add(buildSwitcherAdw(settings, "bind-to-switch-applications", [background_application_switcher_pref_group], [], _("Bind to 'switch-applications'")));

let pcorrection_pref_group = new Adw.PreferencesGroup({
title: _("Perspective Correction")
Expand All @@ -289,8 +299,8 @@ export default class CoverflowAltTabPreferences extends ExtensionPreferences {
let highlight_mouse_over_pref_group = new Adw.PreferencesGroup({
title: _("Highlight Window Under Mouse"),
});
window_size_pref_group.add(buildSwitcherAdw(settings, "highlight-mouse-over", [], _("Highlight Window Under Mouse"), _("Draw embelishment on window under the mouse to know the effects of clicking.")));
window_size_pref_group.add(buildSwitcherAdw(settings, "raise-mouse-over", [], _("Raise Window Under Mouse"), _("Raise the window under the mouse above all others.")));
window_size_pref_group.add(buildSwitcherAdw(settings, "highlight-mouse-over", [], [], _("Highlight Window Under Mouse"), _("Draw embelishment on window under the mouse to know the effects of clicking.")));
window_size_pref_group.add(buildSwitcherAdw(settings, "raise-mouse-over", [], [], _("Raise Window Under Mouse"), _("Raise the window under the mouse above all others.")));

/*let tweaks_page = new Adw.PreferencesPage({
title: _('Tweaks'),
Expand Down Expand Up @@ -385,7 +395,7 @@ export default class CoverflowAltTabPreferences extends ExtensionPreferences {
}
}

function buildSwitcherAdw(settings, key, dependant_widgets, title, subtitle=null) {
function buildSwitcherAdw(settings, key, dependant_widgets, inverse_dependant_widgets, title, subtitle=null) {
let pref = new Adw.ActionRow({
title: title,
});
Expand All @@ -412,10 +422,22 @@ function buildSwitcherAdw(settings, key, dependant_widgets, title, subtitle=null
}
});



for (let widget of dependant_widgets) {
widget.set_sensitive(switcher.get_active());
}

switcher.connect('notify::active', function(widget) {
for (let inv_dep of inverse_dependant_widgets) {
inv_dep.set_sensitive(!widget.get_active());
}
});

for (let widget of inverse_dependant_widgets) {
widget.set_sensitive(!switcher.get_active());
}

let reset_button = makeResetButton();
reset_button.connect("clicked", function(widget) {
settings.reset(key);
Expand Down
11 changes: 8 additions & 3 deletions src/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,16 @@ export const Preview = GObject.registerClass({
}

addIcon() {
let window_actor = this.metaWin.get_compositor_private();
let app = this.switcher._tracker.get_window_app(this.metaWin);
this._icon = app ? app.create_icon_texture(Math.min(this.width, this.height) * 0.9) : null;
this._icon = app ? app.create_icon_texture(Math.min(this.width, this.height) * this.switcher._settings.app_switcher_icon_size_ratio) : null;

if (this._icon == null) {
this._icon = new St.Icon({
icon_name: 'applications-other',
});
}
/*this.bind_property_full('x', this._icon, 'x',
GObject.BindingFlags.SYNC_CREATE),zZ*/
let constraint = Clutter.BindConstraint.new(this, Clutter.BindCoordinate.ALL, 0);
this._icon.add_constraint(constraint);
this.bind_property('rotation_angle_y', this._icon, 'rotation_angle_y',
Expand All @@ -287,8 +288,12 @@ export const Preview = GObject.registerClass({
this.switcher.previewActor.add_actor(this._icon);
this._icon.opacity = 0;

if (this.switcher._settings.icon_has_shadow) {
this._icon.add_style_class_name("icon-dropshadow");
}

this._icon.ease({
opacity: 255,
opacity: 255 * this.switcher._settings.app_switcher_icon_opacity,
duration: 5000,
mode: Clutter.AnimationMode.EASE_IN_OUT_QUINT,
});
Expand Down
14 changes: 5 additions & 9 deletions src/switcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export class Switcher {

for (let preview of this._allPreviews) {
preview.set_reactive(false);
if (this._isAppSwitcher && this._previews.includes(preview)) {
if (this._isAppSwitcher && this._settings.use_application_switcher_icons && this._previews.includes(preview)) {
preview.addIcon();
}
preview.connect('button-press-event', this._previewButtonPressEvent.bind(this, preview));
Expand Down Expand Up @@ -407,7 +407,7 @@ export class Switcher {
this._toSubSwitcher._setCurrentIndex(current_index);
this._toSubSwitcher._updateWindowTitle();
this._toSubSwitcher._updatePreviews(false);
if (!this._adjustment.gestureInProgress) {
if (!this.gestureInProgress) {
this._toSubSwitcher._grabModal();
}
} else {
Expand Down Expand Up @@ -651,14 +651,10 @@ export class Switcher {
}

_updateWindowTitle() {
let animation_time = this._settings.animation_time;
let overlay_icon_size = this._settings.overlay_icon_size;

let idx_low = Math.floor(this._currentIndex);
let idx_high = Math.ceil(this._currentIndex);

if (idx_low == idx_high) {

for (let window_title of this._windowTitles) {
this._manager.platform.tween(window_title, {
opacity: 0,
Expand All @@ -683,14 +679,14 @@ export class Switcher {
}
let alpha = 1;
if (this._settings.icon_style !== "Classic") {
if (this._isAppSwitcher) {
if (this._isAppSwitcher && this._settings.use_application_switcher_icons) {
alpha = 0;
} else {
alpha = this._settings.overlay_icon_opacity;
}
}

if (this._parent == null && !this._isAppSwitcher) {
if ((this._parent == null && !this._isAppSwitcher) || (!this._settings.use_application_switcher_icons && this._parent == null)) {
let icon_box = this._windowIconBoxes[idx_low];
this._manager.platform.tween(icon_box, {
opacity: alpha * 255,
Expand All @@ -712,7 +708,7 @@ export class Switcher {

let alpha = 1;
if (this._settings.icon_style !== "Classic") {
if (this._isAppSwitcher || this._parent != null) {
if ((this._isAppSwitcher || this._parent != null) && this._settings.use_application_switcher_icons) {
alpha = 0;
} else {
alpha = this._settings.overlay_icon_opacity;
Expand Down

0 comments on commit 3f3a794

Please sign in to comment.