From 3f3a794e837f752a9b17c206d9ff51e0ada95496 Mon Sep 17 00:00:00 2001 From: Daniel Sheeler Date: Wed, 22 Nov 2023 15:50:58 -0600 Subject: [PATCH] Bring back timeline and add icons attached to windows in app switcher --- ...ell.extensions.coverflowalttab.gschema.xml | 22 +++++++- src/manager.js | 4 +- src/platform.js | 11 +++- src/prefs.js | 56 +++++++++++++------ src/preview.js | 11 +++- src/switcher.js | 14 ++--- 6 files changed, 83 insertions(+), 35 deletions(-) diff --git a/schemas/org.gnome.shell.extensions.coverflowalttab.gschema.xml b/schemas/org.gnome.shell.extensions.coverflowalttab.gschema.xml index 737d9af..f58c776 100644 --- a/schemas/org.gnome.shell.extensions.coverflowalttab.gschema.xml +++ b/schemas/org.gnome.shell.extensions.coverflowalttab.gschema.xml @@ -19,9 +19,9 @@ - 0 + 1 Dim factor for background - Define dimming of the background. Smaller means darker. + Define dimming of the background. Bigger means darker. @@ -59,6 +59,22 @@ The opacity of the overlay icon Define the opacity of the overlay icon. + + true + Use application switcher icons + Whether to place icons over the application switcher windows. + + + + 1 + The opacity of icons on application switcher previews. + + + + 0.9 + The ratio of the icon size to the preview size. + How relatively big is the icon covering previews in the application switcher. + @@ -125,7 +141,7 @@ false Icon has shadow switch - Whether or not the icon has a drop shadow. + Whether or not the icons have a drop shadow. false diff --git a/src/manager.js b/src/manager.js index 58d6d79..e21e328 100644 --- a/src/manager.js +++ b/src/manager.js @@ -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); } } } diff --git a/src/platform.js b/src/platform.js index ef65cae..f578e32 100644 --- a/src/platform.js +++ b/src/platform.js @@ -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, }; } @@ -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 = [ @@ -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); @@ -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); diff --git a/src/prefs.js b/src/prefs.js index 3f8a0a6..dd9922b 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -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'), @@ -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") @@ -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); @@ -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'), @@ -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") @@ -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'), @@ -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, }); @@ -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); diff --git a/src/preview.js b/src/preview.js index 1945483..d126dae 100644 --- a/src/preview.js +++ b/src/preview.js @@ -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', @@ -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, }); diff --git a/src/switcher.js b/src/switcher.js index a3f2fb6..dae4cf5 100644 --- a/src/switcher.js +++ b/src/switcher.js @@ -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)); @@ -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 { @@ -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, @@ -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, @@ -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;