Updating 44/vertical-workspaces to version 37+20231208 [0d82192].
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
975b88c6bb
commit
07381ac119
37 changed files with 9559 additions and 4338 deletions
|
@ -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;
|
||||
|
||||
// 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;
|
||||
|
||||
let _origBaseDistance;
|
||||
let _wsAnimationSwipeBeginId;
|
||||
let _wsAnimationSwipeUpdateId;
|
||||
let _wsAnimationSwipeEndId;
|
||||
|
||||
let _overrides;
|
||||
let Me;
|
||||
let opt;
|
||||
let _firstRun = true;
|
||||
|
||||
function update(reset = false) {
|
||||
opt = Me.imports.lib.settings.opt;
|
||||
const moduleEnabled = opt.get('workspaceAnimationModule', true);
|
||||
reset = reset || !moduleEnabled;
|
||||
var WorkspaceAnimationModule = class {
|
||||
constructor(me) {
|
||||
Me = me;
|
||||
opt = Me.opt;
|
||||
|
||||
// don't even touch this module if disabled
|
||||
if (_firstRun && reset)
|
||||
return;
|
||||
// first reference to constant defined using const in other module returns undefined, the MonitorGroup const will remain empty and unused
|
||||
this.dummy = WorkspaceAnimation.MonitorGroup;
|
||||
|
||||
_firstRun = false;
|
||||
this._firstActivation = true;
|
||||
this.moduleEnabled = false;
|
||||
this._overrides = null;
|
||||
this._origBaseDistance = null;
|
||||
this._wsAnimationSwipeBeginId = 0;
|
||||
this._wsAnimationSwipeUpdateId = 0;
|
||||
this._wsAnimationSwipeEndId = 0;
|
||||
}
|
||||
|
||||
if (_overrides)
|
||||
_overrides.removeAll();
|
||||
|
||||
if (reset || !moduleEnabled) {
|
||||
_connectWsAnimationSwipeTracker(true);
|
||||
_overrideMonitorGroupProperty(true);
|
||||
_overrides = null;
|
||||
cleanGlobals() {
|
||||
Me = null;
|
||||
opt = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (opt.STATIC_WS_SWITCHER_BG) {
|
||||
_overrides = new _Util.Overrides();
|
||||
_overrideMonitorGroupProperty();
|
||||
_overrides.addOverride('WorkspaceAnimationMonitorGroup', WorkspaceAnimation.MonitorGroup.prototype, MonitorGroup);
|
||||
update(reset) {
|
||||
this.moduleEnabled = opt.get('workspaceAnimationModule');
|
||||
const conflict = false;
|
||||
|
||||
reset = reset || !this.moduleEnabled || conflict;
|
||||
|
||||
// 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');
|
||||
}
|
||||
|
||||
_connectWsAnimationSwipeTracker();
|
||||
}
|
||||
_activateModule() {
|
||||
if (!this._overrides)
|
||||
this._overrides = new Me.Util.Overrides();
|
||||
|
||||
// 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;
|
||||
if (opt.STATIC_WS_SWITCHER_BG) {
|
||||
this._overrideMonitorGroupProperty();
|
||||
this._overrides.addOverride('WorkspaceAnimationMonitorGroup', WorkspaceAnimation.MonitorGroup.prototype, MonitorGroup);
|
||||
}
|
||||
|
||||
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;
|
||||
},
|
||||
};
|
||||
this._connectWsAnimationSwipeTracker();
|
||||
console.debug(' WorkspaceAnimationModule - Activated');
|
||||
}
|
||||
|
||||
if (getter)
|
||||
Object.defineProperty(WorkspaceAnimation.MonitorGroup.prototype, 'baseDistance', getter);
|
||||
}
|
||||
_disableModule() {
|
||||
if (this._overrides)
|
||||
this._overrides.removeAll();
|
||||
this._overrides = null;
|
||||
const reset = true;
|
||||
this._connectWsAnimationSwipeTracker(reset);
|
||||
this._overrideMonitorGroupProperty(reset);
|
||||
console.debug(' WorkspaceAnimationModule - Disabled');
|
||||
}
|
||||
|
||||
_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));
|
||||
}
|
||||
}
|
||||
|
||||
_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));
|
||||
}
|
||||
}
|
||||
|
||||
_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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue