summaryrefslogtreecommitdiffstats
path: root/extensions/44/vertical-workspaces/lib/workspaceAnimation.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/44/vertical-workspaces/lib/workspaceAnimation.js')
-rw-r--r--extensions/44/vertical-workspaces/lib/workspaceAnimation.js234
1 files changed, 128 insertions, 106 deletions
diff --git a/extensions/44/vertical-workspaces/lib/workspaceAnimation.js b/extensions/44/vertical-workspaces/lib/workspaceAnimation.js
index 07008c6..d790895 100644
--- a/extensions/44/vertical-workspaces/lib/workspaceAnimation.js
+++ b/extensions/44/vertical-workspaces/lib/workspaceAnimation.js
@@ -9,81 +9,147 @@
*/
'use strict';
+
const Main = imports.ui.main;
-const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup;
const WorkspaceAnimation = imports.ui.workspaceAnimation;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const _Util = Me.imports.lib.util;
+const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup;
+
+let Me;
+let opt;
-// first reference to constant defined using const in other module returns undefined, the MonitorGroup const will remain empty and unused
-let MonitorGroupDummy = WorkspaceAnimation.MonitorGroup;
-MonitorGroupDummy = null;
+var WorkspaceAnimationModule = class {
+ constructor(me) {
+ Me = me;
+ opt = Me.opt;
+
+ // first reference to constant defined using const in other module returns undefined, the MonitorGroup const will remain empty and unused
+ this.dummy = WorkspaceAnimation.MonitorGroup;
+
+ this._firstActivation = true;
+ this.moduleEnabled = false;
+ this._overrides = null;
+ this._origBaseDistance = null;
+ this._wsAnimationSwipeBeginId = 0;
+ this._wsAnimationSwipeUpdateId = 0;
+ this._wsAnimationSwipeEndId = 0;
+ }
-let _origBaseDistance;
-let _wsAnimationSwipeBeginId;
-let _wsAnimationSwipeUpdateId;
-let _wsAnimationSwipeEndId;
+ cleanGlobals() {
+ Me = null;
+ opt = null;
+ }
-let _overrides;
-let opt;
-let _firstRun = true;
+ update(reset) {
+ this.moduleEnabled = opt.get('workspaceAnimationModule');
+ const conflict = false;
+
+ reset = reset || !this.moduleEnabled || conflict;
-function update(reset = false) {
- opt = Me.imports.lib.settings.opt;
- const moduleEnabled = opt.get('workspaceAnimationModule', true);
- reset = reset || !moduleEnabled;
+ // don't touch the original code if module disabled
+ if (reset && !this._firstActivation) {
+ this._disableModule();
+ } else if (!reset) {
+ this._firstActivation = false;
+ this._activateModule();
+ }
+ if (reset && this._firstActivation)
+ console.debug(' WorkspaceAnimationModule - Keeping untouched');
+ }
- // don't even touch this module if disabled
- if (_firstRun && reset)
- return;
+ _activateModule() {
+ if (!this._overrides)
+ this._overrides = new Me.Util.Overrides();
- _firstRun = false;
+ if (opt.STATIC_WS_SWITCHER_BG) {
+ this._overrideMonitorGroupProperty();
+ this._overrides.addOverride('WorkspaceAnimationMonitorGroup', WorkspaceAnimation.MonitorGroup.prototype, MonitorGroup);
+ }
- if (_overrides)
- _overrides.removeAll();
+ this._connectWsAnimationSwipeTracker();
+ console.debug(' WorkspaceAnimationModule - Activated');
+ }
- if (reset || !moduleEnabled) {
- _connectWsAnimationSwipeTracker(true);
- _overrideMonitorGroupProperty(true);
- _overrides = null;
- opt = null;
- return;
+ _disableModule() {
+ if (this._overrides)
+ this._overrides.removeAll();
+ this._overrides = null;
+ const reset = true;
+ this._connectWsAnimationSwipeTracker(reset);
+ this._overrideMonitorGroupProperty(reset);
+ console.debug(' WorkspaceAnimationModule - Disabled');
}
- if (opt.STATIC_WS_SWITCHER_BG) {
- _overrides = new _Util.Overrides();
- _overrideMonitorGroupProperty();
- _overrides.addOverride('WorkspaceAnimationMonitorGroup', WorkspaceAnimation.MonitorGroup.prototype, MonitorGroup);
+ _overrideMonitorGroupProperty(reset = false) {
+ if (!this._origBaseDistance)
+ this._origBaseDistance = Object.getOwnPropertyDescriptor(WorkspaceAnimation.MonitorGroup.prototype, 'baseDistance').get;
+
+ let getter;
+ if (reset) {
+ if (this._origBaseDistance)
+ getter = { get: this._origBaseDistance };
+ } else {
+ getter = {
+ get() {
+ // const spacing = 100 * imports.gi.St.ThemeContext.get_for_stage(global.stage).scale_factor;
+ const spacing = 0;
+ if (global.workspace_manager.layout_rows === -1)
+ return this._monitor.height + spacing + (opt.PANEL_MODE ? Main.panel.height : 0); // compensation for hidden panel
+ else
+ return this._monitor.width + spacing;
+ },
+ };
+ }
+
+ if (getter)
+ Object.defineProperty(WorkspaceAnimation.MonitorGroup.prototype, 'baseDistance', getter);
+ }
+
+ _connectWsAnimationSwipeTracker(reset = false) {
+ if (reset) {
+ if (this._wsAnimationSwipeBeginId) {
+ Main.wm._workspaceAnimation._swipeTracker.disconnect(this._wsAnimationSwipeBeginId);
+ this._wsAnimationSwipeBeginId = 0;
+ }
+ if (this._wsAnimationSwipeEndId) {
+ Main.wm._workspaceAnimation._swipeTracker.disconnect(this._wsAnimationSwipeEndId);
+ this._wsAnimationSwipeEndId = 0;
+ }
+ } else if (!this._wsAnimationSwipeBeginId) {
+ // display ws switcher popup when gesture begins and connect progress
+ this._wsAnimationSwipeBeginId = Main.wm._workspaceAnimation._swipeTracker.connect('begin', () => this._connectWsAnimationProgress(true));
+ // we want to be sure that popup with the final ws index show up when gesture ends
+ this._wsAnimationSwipeEndId = Main.wm._workspaceAnimation._swipeTracker.connect('end', (tracker, duration, endProgress) => this._connectWsAnimationProgress(false, endProgress));
+ }
}
- _connectWsAnimationSwipeTracker();
-}
-
-// remove spacing between workspaces during transition to remove flashing wallpaper between workspaces with maximized windows
-function _overrideMonitorGroupProperty(reset = false) {
- if (!_origBaseDistance)
- _origBaseDistance = Object.getOwnPropertyDescriptor(WorkspaceAnimation.MonitorGroup.prototype, 'baseDistance').get;
-
- let getter;
- if (reset) {
- if (_origBaseDistance)
- getter = { get: _origBaseDistance };
- } else {
- getter = {
- get() {
- // const spacing = 100 * imports.gi.St.ThemeContext.get_for_stage(global.stage).scale_factor;
- const spacing = 0;
- if (global.workspace_manager.layout_rows === -1)
- return this._monitor.height + spacing + (opt.PANEL_MODE ? Main.panel.height : 0); // compensation for hidden panel
- else
- return this._monitor.width + spacing;
- },
- };
+ _connectWsAnimationProgress(connect, endProgress = null) {
+ if (Main.overview.visible)
+ return;
+
+ if (connect && !this._wsAnimationSwipeUpdateId) {
+ this._wsAnimationSwipeUpdateId = Main.wm._workspaceAnimation._swipeTracker.connect('update', (tracker, progress) => this._showWsSwitcherPopup(progress));
+ } else if (!connect && this._wsAnimationSwipeUpdateId) {
+ Main.wm._workspaceAnimation._swipeTracker.disconnect(this._wsAnimationSwipeUpdateId);
+ this._wsAnimationSwipeUpdateId = 0;
+ this._showWsSwitcherPopup(Math.round(endProgress));
+ }
}
- if (getter)
- Object.defineProperty(WorkspaceAnimation.MonitorGroup.prototype, 'baseDistance', getter);
-}
+ _showWsSwitcherPopup(progress) {
+ if (Main.overview.visible)
+ return;
+
+ const wsIndex = Math.round(progress);
+ if (Main.wm._workspaceSwitcherPopup === null) {
+ Main.wm._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
+ Main.wm._workspaceSwitcherPopup.connect('destroy', () => {
+ Main.wm._workspaceSwitcherPopup = null;
+ });
+ }
+
+ Main.wm._workspaceSwitcherPopup.display(wsIndex);
+ }
+};
const MonitorGroup = {
// injection to _init()
@@ -119,7 +185,9 @@ const MonitorGroup = {
// hide (scale to 0) all non-sticky windows, their clones will be animated
global.get_window_actors().forEach(actor => {
const metaWin = actor.metaWindow;
- if (metaWin?.get_monitor() === this._monitor.index && !(metaWin?.wm_class === 'conky' && metaWin?.is_on_all_workspaces())) { //* && !w.is_on_all_workspaces()*/) {
+ if (metaWin?.get_monitor() === this._monitor.index &&
+ !(metaWin?.wm_class === 'conky' && metaWin?.is_on_all_workspaces()) &&
+ !(metaWin?.wm_class === 'Gjs' && metaWin?.is_on_all_workspaces())) { // DING extension uses window with Gjs class
// hide original window. we cannot use opacity since it also affects clones.
// scaling them to 0 works well
actor.scale_x = 0;
@@ -136,49 +204,3 @@ const MonitorGroup = {
});
},
};
-
-function _connectWsAnimationSwipeTracker(reset = false) {
- if (reset) {
- if (_wsAnimationSwipeBeginId) {
- Main.wm._workspaceAnimation._swipeTracker.disconnect(_wsAnimationSwipeBeginId);
- _wsAnimationSwipeBeginId = 0;
- }
- if (_wsAnimationSwipeEndId) {
- Main.wm._workspaceAnimation._swipeTracker.disconnect(_wsAnimationSwipeEndId);
- _wsAnimationSwipeEndId = 0;
- }
- } else if (!_wsAnimationSwipeBeginId) {
- // display ws switcher popup when gesture begins and connect progress
- _wsAnimationSwipeBeginId = Main.wm._workspaceAnimation._swipeTracker.connect('begin', () => _connectWsAnimationProgress(true));
- // we want to be sure that popup with the final ws index show up when gesture ends
- _wsAnimationSwipeEndId = Main.wm._workspaceAnimation._swipeTracker.connect('end', (tracker, duration, endProgress) => _connectWsAnimationProgress(false, endProgress));
- }
-}
-
-function _connectWsAnimationProgress(connect, endProgress = null) {
- if (Main.overview.visible)
- return;
-
- if (connect && !_wsAnimationSwipeUpdateId) {
- _wsAnimationSwipeUpdateId = Main.wm._workspaceAnimation._swipeTracker.connect('update', (tracker, progress) => _showWsSwitcherPopup(progress));
- } else if (!connect && _wsAnimationSwipeUpdateId) {
- Main.wm._workspaceAnimation._swipeTracker.disconnect(_wsAnimationSwipeUpdateId);
- _wsAnimationSwipeUpdateId = 0;
- _showWsSwitcherPopup(Math.round(endProgress));
- }
-}
-
-function _showWsSwitcherPopup(progress) {
- if (Main.overview.visible)
- return;
-
- const wsIndex = Math.round(progress);
- if (Main.wm._workspaceSwitcherPopup === null) {
- Main.wm._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
- Main.wm._workspaceSwitcherPopup.connect('destroy', () => {
- Main.wm._workspaceSwitcherPopup = null;
- });
- }
-
- Main.wm._workspaceSwitcherPopup.display(wsIndex);
-}