1
0
Fork 0

Updating 44/vertical-workspaces to version 37+20231208 [0d82192].

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-03-24 19:42:07 +01:00
parent 975b88c6bb
commit 07381ac119
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
37 changed files with 9559 additions and 4338 deletions

View file

@ -10,67 +10,107 @@
'use strict';
const { Meta, GLib, Shell, Clutter, GObject } = imports.gi;
const GLib = imports.gi.GLib;
const Meta = imports.gi.Meta;
const Gio = imports.gi.Gio;
const Main = imports.ui.main;
const Layout = imports.ui.layout;
const Ripples = imports.ui.ripples;
const DND = imports.ui.dnd;
const Main = imports.ui.main;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const _Util = Me.imports.lib.util;
let _overrides;
let _timeouts;
let Me;
let opt;
let _firstRun = true;
let _originalUpdateHotCorners;
function update(reset = false) {
opt = Me.imports.lib.settings.opt;
const moduleEnabled = opt.get('layoutModule', true);
const conflict = _Util.getEnabledExtensions('custom-hot-corners').length ||
_Util.getEnabledExtensions('dash-to-panel').length;
reset = reset || !moduleEnabled;
let _timeouts;
// don't even touch this module if disabled or in conflict
if (_firstRun && (reset || conflict))
return;
var LayoutModule = class {
constructor(me) {
Me = me;
opt = Me.opt;
_timeouts = {};
_firstRun = false;
if (!_originalUpdateHotCorners)
_originalUpdateHotCorners = Layout.LayoutManager.prototype._updateHotCorners;
if (_overrides)
_overrides.removeAll();
if (_timeouts) {
Object.values(_timeouts).forEach(t => {
if (t)
GLib.source_remove(t);
});
this._firstActivation = true;
this.moduleEnabled = false;
this._overrides = null;
this._originalUpdateHotCorners = null;
}
if (reset) {
_overrides = null;
cleanGlobals() {
Me = null;
opt = null;
_timeouts = null;
Main.layoutManager._updateHotCorners = _originalUpdateHotCorners;
Main.layoutManager._updateHotCorners();
return;
}
_timeouts = {};
update(reset) {
this._removeTimeouts();
_overrides = new _Util.Overrides();
_overrides.addOverride('LayoutManager', Layout.LayoutManager.prototype, LayoutManagerCommon);
this.moduleEnabled = opt.get('layoutModule');
const conflict = Me.Util.getEnabledExtensions('custom-hot-corners').length ||
Me.Util.getEnabledExtensions('dash-to-panel').length;
Main.layoutManager._updateHotCorners = LayoutManagerCommon._updateHotCorners.bind(Main.layoutManager);
if (conflict && !reset)
console.warn(`[${Me.metadata.name}] Warning: "Layout" module disabled due to potential conflict with another extension`);
Main.layoutManager._updatePanelBarrier();
Main.layoutManager._updateHotCorners();
}
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(' LayoutModule - Keeping untouched');
}
_activateModule() {
if (!this._overrides)
this._overrides = new Me.Util.Overrides();
_timeouts = {};
this._overrides.addOverride('LayoutManager', Main.layoutManager, LayoutManagerCommon);
this._overrides.addOverride('HotCorner', Layout.HotCorner.prototype, HotCornerCommon);
Main.layoutManager._updatePanelBarrier();
Main.layoutManager._updateHotCorners();
if (!this._hotCornersEnabledConId) {
this._interfaceSettings = new Gio.Settings({
schema_id: 'org.gnome.desktop.interface',
});
this._hotCornersEnabledConId = this._interfaceSettings.connect('changed::enable-hot-corners',
() => Main.layoutManager._updateHotCorners());
}
console.debug(' LayoutModule - Activated');
}
_disableModule() {
if (this._overrides)
this._overrides.removeAll();
this._overrides = null;
Main.layoutManager._updateHotCorners();
if (this._hotCornersEnabledConId) {
this._interfaceSettings.disconnect(this._hotCornersEnabledConId);
this._hotCornersEnabledConId = 0;
this._interfaceSettings = null;
}
console.debug(' LayoutModule - Disabled');
}
_removeTimeouts() {
if (_timeouts) {
Object.values(_timeouts).forEach(t => {
if (t)
GLib.source_remove(t);
});
_timeouts = null;
}
}
};
const LayoutManagerCommon = {
_updatePanelBarrier() {
@ -84,7 +124,7 @@ const LayoutManagerCommon = {
this._leftPanelBarrier = null;
}
if (!this.primaryMonitor || !opt)
if (!this.primaryMonitor || !opt || Me.Util.getEnabledExtensions('hidetopbar'))
return;
if (this.panelBox.height) {
@ -113,6 +153,7 @@ const LayoutManagerCommon = {
// avoid errors if called from foreign override
if (!opt)
return;
// destroy old hot corners
this.hotCorners.forEach(corner => corner?.destroy());
this.hotCorners = [];
@ -122,7 +163,7 @@ const LayoutManagerCommon = {
return;
}
let size = this.panelBox.height;
let size = this.panelBox.height ? this.panelBox.height : 27;
// position 0 - default, 1-TL, 2-TR, 3-BL, 4-BR
const position = opt.HOT_CORNER_POSITION;
@ -181,8 +222,8 @@ const LayoutManagerCommon = {
}
if (haveCorner) {
let corner = new HotCorner(this, monitor, cornerX, cornerY);
corner.setBarrierSize(size);
let corner = new Layout.HotCorner(this, monitor, cornerX, cornerY);
corner.setBarrierSize(size, false);
this.hotCorners.push(corner);
} else {
this.hotCorners.push(null);
@ -193,11 +234,8 @@ const LayoutManagerCommon = {
},
};
var HotCorner = GObject.registerClass(
class HotCorner extends Layout.HotCorner {
_init(layoutManager, monitor, x, y) {
super._init(layoutManager, monitor, x, y);
const HotCornerCommon = {
after__init() {
let angle = 0;
switch (opt.HOT_CORNER_POSITION) {
case 2:
@ -214,9 +252,14 @@ class HotCorner extends Layout.HotCorner {
this._ripples._ripple1.rotation_angle_z = angle;
this._ripples._ripple2.rotation_angle_z = angle;
this._ripples._ripple3.rotation_angle_z = angle;
}
},
setBarrierSize(size, notMyCall = true) {
// ignore calls from the original _updateHotCorners() callback to avoid building barriers outside screen
if (notMyCall && size > 0) {
return;
}
setBarrierSize(size) {
if (this._verticalBarrier) {
this._pressureBarrier.removeBarrier(this._verticalBarrier);
this._verticalBarrier.destroy();
@ -232,8 +275,8 @@ class HotCorner extends Layout.HotCorner {
if (size > 0) {
const primaryMonitor = global.display.get_primary_monitor();
const monitor = this._monitor;
const extendV = opt && opt.HOT_CORNER_EDGE && opt.DASH_VERTICAL && monitor.index === primaryMonitor;
const extendH = opt && opt.HOT_CORNER_EDGE && !opt.DASH_VERTICAL && monitor.index === primaryMonitor;
const extendV = opt && opt.HOT_CORNER_ACTION && opt.HOT_CORNER_EDGE && opt.DASH_VERTICAL && monitor.index === primaryMonitor;
const extendH = opt && opt.HOT_CORNER_ACTION && opt.HOT_CORNER_EDGE && !opt.DASH_VERTICAL && monitor.index === primaryMonitor;
if (opt.HOT_CORNER_POSITION <= 1) {
this._verticalBarrier = new Meta.Barrier({
@ -284,25 +327,52 @@ class HotCorner extends Layout.HotCorner {
this._pressureBarrier.addBarrier(this._verticalBarrier);
this._pressureBarrier.addBarrier(this._horizontalBarrier);
}
}
},
_toggleOverview() {
if (!opt.HOT_CORNER_ACTION || (!opt.HOT_CORNER_FULLSCREEN && this._monitor.inFullscreen && !Main.overview.visible))
return;
if (Main.overview.shouldToggleByCornerOrButton()) {
if ((opt.HOT_CORNER_ACTION === 1 && !_Util.isCtrlPressed()) || (opt.HOT_CORNER_ACTION === 2 && _Util.isCtrlPressed()))
if (Main.overview._shown) {
this._toggleWindowPicker(true);
else if ((opt.HOT_CORNER_ACTION === 2 && !_Util.isCtrlPressed()) || (opt.HOT_CORNER_ACTION === 1 && _Util.isCtrlPressed()) || (opt.HOT_CORNER_ACTION === 3 && _Util.isCtrlPressed()))
} else if ((opt.HOT_CORNER_ACTION === 2 && !Me.Util.isCtrlPressed()) || ([3, 4, 5, 6].includes(opt.HOT_CORNER_ACTION) && Me.Util.isCtrlPressed())) {
// Default overview
opt.OVERVIEW_MODE = 0;
opt.OVERVIEW_MODE2 = false;
opt.WORKSPACE_MODE = 1;
this._toggleWindowPicker(true, true);
} else if (opt.HOT_CORNER_ACTION === 1) {
Main.overview.resetOverviewMode();
this._toggleWindowPicker(true, true);
} else if ((opt.HOT_CORNER_ACTION === 3 && !Me.Util.isCtrlPressed()) || (opt.HOT_CORNER_ACTION === 2 && Me.Util.isCtrlPressed()) || (opt.HOT_CORNER_ACTION === 6 && Me.Util.isCtrlPressed())) {
// Applications
this._toggleApplications(true);
else if (opt.HOT_CORNER_ACTION === 3 && !_Util.isCtrlPressed())
} else if (opt.HOT_CORNER_ACTION === 4 && !Me.Util.isCtrlPressed()) {
// Overview - static ws preview
opt.OVERVIEW_MODE = 1;
opt.OVERVIEW_MODE2 = false;
opt.WORKSPACE_MODE = 0;
this._toggleWindowPicker(true, true);
} else if (opt.HOT_CORNER_ACTION === 5 && !Me.Util.isCtrlPressed()) {
// Overview - static ws
opt.OVERVIEW_MODE = 2;
opt.OVERVIEW_MODE2 = true;
opt.WORKSPACE_MODE = 0;
this._toggleWindowPicker(true, true);
} else if (opt.HOT_CORNER_ACTION === 6 && !Me.Util.isCtrlPressed()) {
// Window search provider
opt.OVERVIEW_MODE = 2;
opt.OVERVIEW_MODE2 = true;
opt.WORKSPACE_MODE = 0;
this._toggleWindowSearchProvider();
}
if (opt.HOT_CORNER_RIPPLES && Main.overview.animationInProgress)
this._ripples.playAnimation(this._x, this._y);
}
}
},
_toggleWindowPicker(leaveOverview = false) {
_toggleWindowPicker(leaveOverview = false, customOverviewMode = false) {
if (Main.overview._shown && (leaveOverview || !Main.overview.dash.showAppsButton.checked)) {
Main.overview.hide();
} else if (Main.overview.dash.showAppsButton.checked) {
@ -320,17 +390,17 @@ class HotCorner extends Layout.HotCorner {
// delay cannot be too short
200,
() => {
Main.overview.show();
Main.overview.show(1, customOverviewMode);
_timeouts.releaseKeyboardTimeoutId = 0;
return GLib.SOURCE_REMOVE;
}
);
} else {
Main.overview.show();
Main.overview.show(1, customOverviewMode);
}
}
}
},
_toggleApplications(leaveOverview = false) {
if ((leaveOverview && Main.overview._shown) || Main.overview.dash.showAppsButton.checked) {
@ -360,12 +430,15 @@ class HotCorner extends Layout.HotCorner {
Main.overview.show(2); // 2 for App Grid
}
}
}
},
_toggleWindowSearchProvider() {
if (!Main.overview._overview._controls._searchController._searchActive) {
this._toggleWindowPicker();
const prefix = 'wq// ';
opt.OVERVIEW_MODE = 2;
opt.OVERVIEW_MODE2 = true;
opt.WORKSPACE_MODE = 0;
this._toggleWindowPicker(false, true);
const prefix = Me.WSP_PREFIX;
const position = prefix.length;
const searchEntry = Main.overview.searchEntry;
searchEntry.set_text(prefix);
@ -376,5 +449,5 @@ class HotCorner extends Layout.HotCorner {
// Main.overview.searchEntry.text = '';
Main.overview.hide();
}
}
});
},
};