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

@ -9,81 +9,94 @@
*/
'use strict';
const { GObject, Gio, GLib, Meta, St } = imports.gi;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Meta = imports.gi.Meta;
const St = imports.gi.St;
const Main = imports.ui.main;
const Overview = imports.ui.overview;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const _Util = Me.imports.lib.util;
const _ = Me.imports.lib.settings._;
const shellVersion = _Util.shellVersion;
const WIN_SEARCH_PREFIX = Me.imports.lib.windowSearchProvider.prefix;
const RECENT_FILES_PREFIX = Me.imports.lib.recentFilesSearchProvider.prefix;
const A11Y_SCHEMA = 'org.gnome.desktop.a11y.keyboard';
let Me;
let opt;
let _firstRun = true;
let _originalOverlayKeyHandlerId;
let _overlayKeyHandlerId;
var OverlayKeyModule = class {
constructor(me) {
Me = me;
opt = Me.opt;
function update(reset = false) {
opt = Me.imports.lib.settings.opt;
const moduleEnabled = opt.get('overlayKeyModule', true);
reset = reset || (!_firstRun && !moduleEnabled);
this._firstActivation = true;
this.moduleEnabled = false;
this._originalOverlayKeyHandlerId = 0;
this._overlayKeyHandlerId = 0;
}
// don't even touch this module if disabled
if (_firstRun && !moduleEnabled)
return;
_firstRun = false;
if (reset) {
_updateOverlayKey(reset);
cleanGlobals() {
Me = null;
opt = null;
return;
}
_updateOverlayKey();
}
update(reset) {
this.moduleEnabled = opt.get('overlayKeyModule');
const conflict = false;
function _updateOverlayKey(reset = false) {
if (reset) {
_restoreOverlayKeyHandler();
} else if (!_originalOverlayKeyHandlerId) {
_originalOverlayKeyHandlerId = GObject.signal_handler_find(global.display, { signalId: 'overlay-key' });
if (_originalOverlayKeyHandlerId !== null)
global.display.block_signal_handler(_originalOverlayKeyHandlerId);
_connectOverlayKey.bind(Main.overview._overview.controls)();
}
}
reset = reset || !this.moduleEnabled || conflict;
function _restoreOverlayKeyHandler() {
// Disconnect modified overlay key handler
if (_overlayKeyHandlerId !== null) {
global.display.disconnect(_overlayKeyHandlerId);
_overlayKeyHandlerId = null;
if (reset && !this._firstActivation) {
this._disableModule();
} else if (!reset) {
this._firstActivation = false;
this._activateModule();
}
if (reset && this._firstActivation)
console.debug(' OverlayKeyModule - Keeping untouched');
}
// Unblock original overlay key handler
if (_originalOverlayKeyHandlerId !== null) {
global.display.unblock_signal_handler(_originalOverlayKeyHandlerId);
_originalOverlayKeyHandlerId = null;
_activateModule() {
if (!this._originalOverlayKeyHandlerId) {
this._originalOverlayKeyHandlerId = GObject.signal_handler_find(global.display, { signalId: 'overlay-key' });
if (this._originalOverlayKeyHandlerId !== null) {
global.display.block_signal_handler(this._originalOverlayKeyHandlerId);
this._connectOverlayKey();
}
}
console.debug(' OverlayKeyModule - Activated');
}
}
function _connectOverlayKey() {
this._a11ySettings = new Gio.Settings({ schema_id: A11Y_SCHEMA });
_disableModule() {
this._restoreOverlayKeyHandler();
this._lastOverlayKeyTime = 0;
_overlayKeyHandlerId = global.display.connect('overlay-key', () => {
console.debug(' OverlayKeyModule - Disabled');
}
_restoreOverlayKeyHandler() {
// Disconnect modified overlay key handler
if (this._overlayKeyHandlerId) {
global.display.disconnect(this._overlayKeyHandlerId);
this._overlayKeyHandlerId = 0;
}
// Unblock original overlay key handler
if (this._originalOverlayKeyHandlerId) {
global.display.unblock_signal_handler(this._originalOverlayKeyHandlerId);
this._originalOverlayKeyHandlerId = 0;
}
}
_connectOverlayKey() {
if (this._overlayKeyHandlerId)
return;
this._overlayKeyHandlerId = global.display.connect('overlay-key', this._onOverlayKeyPressed.bind(Main.overview._overview.controls));
}
_onOverlayKeyPressed() {
if (this._a11ySettings.get_boolean('stickykeys-enable'))
return;
const { initialState, finalState, transitioning } =
this._stateAdjustment.getStateTransitionParams();
this._stateAdjustment.getStateTransitionParams();
const time = GLib.get_monotonic_time() / 1000;
const timeDiff = time - this._lastOverlayKeyTime;
@ -95,14 +108,61 @@ function _connectOverlayKey() {
const mode = opt.OVERLAY_KEY_SECONDARY;
if (shouldShift) {
if (mode === 1)
Me.Util.activateSearchProvider('');
if (mode === 1) {
this._shiftState(Meta.MotionDirection.UP);
else if (mode === 2)
_Util.activateSearchProvider(WIN_SEARCH_PREFIX);
else if (mode === 3)
_Util.activateSearchProvider(RECENT_FILES_PREFIX);
} else if (mode === 2) {
Me.Util.activateSearchProvider(Me.WSP_PREFIX);
} else if (mode === 3) {
// Changing the overview mode automatically changes the overview transition
opt.OVERVIEW_MODE = 0;
opt.OVERVIEW_MODE2 = false;
opt.WORKSPACE_MODE = 1;
}
} else {
Main.overview.toggle();
if (Main.overview._shown) {
Main.overview.hide();
return;
}
switch (opt.OVERLAY_KEY_PRIMARY) {
case 0: // Disabled
return;
case 1: // Follow global overview mode
Main.overview.resetOverviewMode();
break;
case 2: // Default overview
opt.OVERVIEW_MODE = 0;
opt.OVERVIEW_MODE2 = false;
opt.WORKSPACE_MODE = 1;
break;
case 3: // Default overview
if (Main.overview._shown)
Main.overview.hide();
else
Main.overview.show(2);
return;
case 4: // Static WS preview
opt.OVERVIEW_MODE = 1;
opt.OVERVIEW_MODE2 = false;
if (!Main.overview._shown)
opt.WORKSPACE_MODE = 0;
break;
case 5: // Static WS
opt.OVERVIEW_MODE = 2;
opt.OVERVIEW_MODE2 = true;
opt.WORKSPACE_MODE = 0;
break;
case 6: // Window Search
opt.OVERVIEW_MODE = 2;
opt.OVERVIEW_MODE2 = true;
if (!Main.overview._shown)
opt.WORKSPACE_MODE = 0;
break;
}
const customOverviewMode = !Main.overview._shown;
Main.overview.toggle(customOverviewMode);
if (opt.OVERLAY_KEY_PRIMARY === 6)
Me.Util.activateSearchProvider(Me.WSP_PREFIX);
}
});
}
}
};