summaryrefslogtreecommitdiffstats
path: root/extensions/44/vertical-workspaces/lib/overlayKey.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 16:02:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 16:02:53 +0000
commit4d8b071804d73b7a733f2b7696fde40caf8800bb (patch)
tree86aefc1c0ea9c596bab0ecbc0c054a2378d6cd13 /extensions/44/vertical-workspaces/lib/overlayKey.js
parentUpdating 44/no-overview to version 44 [68db01d]. (diff)
downloadgnome-shell-extensions-extra-4d8b071804d73b7a733f2b7696fde40caf8800bb.tar.xz
gnome-shell-extensions-extra-4d8b071804d73b7a733f2b7696fde40caf8800bb.zip
Updating 44/vertical-workspaces to version 37+20231208 [0d82192].
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'extensions/44/vertical-workspaces/lib/overlayKey.js')
-rw-r--r--extensions/44/vertical-workspaces/lib/overlayKey.js180
1 files changed, 120 insertions, 60 deletions
diff --git a/extensions/44/vertical-workspaces/lib/overlayKey.js b/extensions/44/vertical-workspaces/lib/overlayKey.js
index e0fc11d..815abaa 100644
--- a/extensions/44/vertical-workspaces/lib/overlayKey.js
+++ b/extensions/44/vertical-workspaces/lib/overlayKey.js
@@ -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;
+ cleanGlobals() {
+ Me = null;
+ opt = null;
+ }
- _firstRun = false;
+ update(reset) {
+ this.moduleEnabled = opt.get('overlayKeyModule');
+ const conflict = false;
- if (reset) {
- _updateOverlayKey(reset);
- opt = null;
- return;
+ reset = reset || !this.moduleEnabled || conflict;
+
+ if (reset && !this._firstActivation) {
+ this._disableModule();
+ } else if (!reset) {
+ this._firstActivation = false;
+ this._activateModule();
+ }
+ if (reset && this._firstActivation)
+ console.debug(' OverlayKeyModule - Keeping untouched');
}
- _updateOverlayKey();
-}
-
-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)();
+ _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 _restoreOverlayKeyHandler() {
- // Disconnect modified overlay key handler
- if (_overlayKeyHandlerId !== null) {
- global.display.disconnect(_overlayKeyHandlerId);
- _overlayKeyHandlerId = null;
+ _disableModule() {
+ this._restoreOverlayKeyHandler();
+
+ console.debug(' OverlayKeyModule - Disabled');
}
- // Unblock original overlay key handler
- if (_originalOverlayKeyHandlerId !== null) {
- global.display.unblock_signal_handler(_originalOverlayKeyHandlerId);
- _originalOverlayKeyHandlerId = null;
+ _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;
+ }
}
-}
-function _connectOverlayKey() {
- this._a11ySettings = new Gio.Settings({ schema_id: A11Y_SCHEMA });
+ _connectOverlayKey() {
+ if (this._overlayKeyHandlerId)
+ return;
+
+ this._overlayKeyHandlerId = global.display.connect('overlay-key', this._onOverlayKeyPressed.bind(Main.overview._overview.controls));
+ }
- this._lastOverlayKeyTime = 0;
- _overlayKeyHandlerId = global.display.connect('overlay-key', () => {
+ _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);
}
- });
-}
+ }
+};