Skip to content

Commit

Permalink
Add ability to destroy switcher instantly (without animating), and
Browse files Browse the repository at this point in the history
destroy on disable.
  • Loading branch information
dsheeler committed Nov 11, 2023
1 parent d090b3b commit ca8776d
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 124 deletions.
18 changes: 1 addition & 17 deletions src/coverflowSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function appendParams(base, extra) {
}
}

export const CoverflowSwitcher = class CoverflowSwitcher extends BaseSwitcher {
export class CoverflowSwitcher extends BaseSwitcher {
constructor(...args) {
super(...args);
}
Expand Down Expand Up @@ -223,22 +223,6 @@ export const CoverflowSwitcher = class CoverflowSwitcher extends BaseSwitcher {
//this._looping = false;
//this._updatePreviews(false);
return;
preview.make_top_layer(this.previewActor);
if (index == this._currentIndex) {
preview.make_top_layer(this.previewActor);
let extraParams = preview._cfIsLast ? lastExtraParams : {transition: 'userChoice'};
this._animatePreviewToMid(preview, extraParams);
} else {
let extraParams = {
rotation_angle_y: angleEnd,
time: animation_time,
transition: 'userChoice'
};
if (preview._cfIsLast)
appendParams(extraParams, lastExtraParams);
this._animatePreviewToSide(preview, index, xOffsetEnd, extraParams);
}
super._updatePreviews();
}

_onFlipComplete(direction) {
Expand Down
9 changes: 6 additions & 3 deletions src/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

import * as Main from 'resource:///org/gnome/shell/ui/main.js';

import {CoverflowSwitcher} from './coverflowSwitcher.js'

function sortWindowsByUserTime(win1, win2) {
let t1 = win1.get_user_time();
let t2 = win2.get_user_time();
Expand All @@ -50,7 +52,7 @@ export const Manager = class Manager {
constructor(platform, keybinder) {
this.platform = platform;
this.keybinder = keybinder;

this.switcher = null;
if (global.workspace_manager && global.workspace_manager.get_active_workspace)
this.workspace_manager = global.workspace_manager;
else
Expand All @@ -68,6 +70,8 @@ export const Manager = class Manager {
}

disable() {
if (this.switcher != null)
this.switcher.destroy();
this.platform.disable();
this.keybinder.disable();
}
Expand Down Expand Up @@ -140,8 +144,7 @@ export const Manager = class Manager {
let mask = binding.get_mask();
let currentIndex = windows.indexOf(display.focus_window);

let switcher_class = this.platform.getSettings().switcher_class;
let switcher = new switcher_class(windows, mask, currentIndex, this, null, isApplicationSwitcher, null);
this.switcher = new CoverflowSwitcher(windows, mask, currentIndex, this, null, isApplicationSwitcher, null);
}
}
}
30 changes: 20 additions & 10 deletions src/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export class PlatformGnomeShell extends AbstractPlatform {
}

disable() {
this.showPanels(0);
if (this._connections) {
for (let connection of this._connections) {
this._extensionSettings.disconnect(connection);
Expand Down Expand Up @@ -481,25 +482,28 @@ export class PlatformGnomeShell extends AbstractPlatform {
}
}

dimBackground() {
hidePanels() {
let panels = this.getPanels();
for (let panel of panels) {
try {
let panelActor = (panel instanceof Clutter.Actor) ? panel : panel.actor;
panelActor.set_reactive(false);
if (this._settings.hide_panel) {
this.tween(panelActor, {
opacity: 0,
time: this._settings.animation_time,
transition: 'easeInOutQuint'
});
}
this.tween(panelActor, {
opacity: 0,
time: this._settings.animation_time,
transition: 'easeInOutQuint'
});
} catch (e) {
log(e);
// ignore fake panels
}
}
}

dimBackground() {
if (this._settings.hide_panel) {
this.hidePanels();
}
// hide gnome-shell legacy tray
try {
if (Main.legacyTray) {
Expand All @@ -516,7 +520,7 @@ export class PlatformGnomeShell extends AbstractPlatform {
});
}

lightenBackground() {
showPanels(time) {
// panels
let panels = this.getPanels();
for (let panel of panels){
Expand All @@ -527,14 +531,20 @@ export class PlatformGnomeShell extends AbstractPlatform {
this.removeTweens(panelActor);
this.tween(panelActor, {
opacity: 255,
time: this._settings.animation_time,
time: time,
transition: 'easeInOutQuint'
});
}
} catch (e) {
//ignore fake panels
}
}
}

lightenBackground() {
if (this._settings.hide_panel) {
this.showPanels(this._settings.animation_time);
}
// show gnome-shell legacy trayconn
try {
if (Main.legacyTray) {
Expand Down
1 change: 0 additions & 1 deletion src/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ 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.")));
Expand Down
4 changes: 2 additions & 2 deletions src/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export const Preview = GObject.registerClass({
}

vfunc_enter_event(crossingEvent) {
if (this.switcher._destroying || this._entered == true) {
if (this.switcher._animatingClosed || this._entered == true) {
return Clutter.EVENT_PROPAGATE;
}
this._entered = true;
Expand Down Expand Up @@ -255,7 +255,7 @@ export const Preview = GObject.registerClass({
vfunc_leave_event(crossingEvent) {
this.remove_highlight();
this._entered = false;
if (this.switcher._settings.raise_mouse_over && !this.switcher._destroying) this.switcher._updatePreviews(true, 0);
if (this.switcher._settings.raise_mouse_over && !this.switcher._animatingClosed) this.switcher._updatePreviews(true, 0);
return Clutter.EVENT_PROPAGATE;
}

Expand Down
Loading

0 comments on commit ca8776d

Please sign in to comment.