summaryrefslogtreecommitdiffstats
path: root/extensions/45/vertical-workspaces/lib/overlayKey.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 06:15:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 06:15:40 +0000
commita7253052777df3bcf4b2abe9367de244cbc35da1 (patch)
tree1168b662d8028f172d12c2eb4efc62bf8408434b /extensions/45/vertical-workspaces/lib/overlayKey.js
parentAdding upstream version 20231210. (diff)
downloadgnome-shell-extensions-extra-a7253052777df3bcf4b2abe9367de244cbc35da1.tar.xz
gnome-shell-extensions-extra-a7253052777df3bcf4b2abe9367de244cbc35da1.zip
Adding upstream version 20240414.upstream/20240414upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'extensions/45/vertical-workspaces/lib/overlayKey.js')
-rw-r--r--extensions/45/vertical-workspaces/lib/overlayKey.js168
1 files changed, 0 insertions, 168 deletions
diff --git a/extensions/45/vertical-workspaces/lib/overlayKey.js b/extensions/45/vertical-workspaces/lib/overlayKey.js
deleted file mode 100644
index 77264c1..0000000
--- a/extensions/45/vertical-workspaces/lib/overlayKey.js
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- * V-Shell (Vertical Workspaces)
- * overlayKey.js
- *
- * @author GdH <G-dH@github.com>
- * @copyright 2022 - 2023
- * @license GPL-3.0
- *
- */
-
-'use strict';
-
-import GLib from 'gi://GLib';
-import St from 'gi://St';
-import Meta from 'gi://Meta';
-import GObject from 'gi://GObject';
-
-import * as Main from 'resource:///org/gnome/shell/ui/main.js';
-import * as Overview from 'resource:///org/gnome/shell/ui/overview.js';
-
-let Me;
-let opt;
-
-export const OverlayKeyModule = class {
- constructor(me) {
- Me = me;
- opt = Me.opt;
-
- this._firstActivation = true;
- this.moduleEnabled = false;
- this._originalOverlayKeyHandlerId = 0;
- this._overlayKeyHandlerId = 0;
- }
-
- cleanGlobals() {
- Me = null;
- opt = null;
- }
-
- update(reset) {
- this.moduleEnabled = opt.get('overlayKeyModule');
- const conflict = false;
-
- 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');
- }
-
- _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');
- }
-
- _disableModule() {
- this._restoreOverlayKeyHandler();
-
- 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();
-
- const time = GLib.get_monotonic_time() / 1000;
- const timeDiff = time - this._lastOverlayKeyTime;
- this._lastOverlayKeyTime = time;
-
- const shouldShift = St.Settings.get().enable_animations
- ? transitioning && finalState > initialState
- : Main.overview.visible && timeDiff < Overview.ANIMATION_TIME;
-
- const mode = opt.OVERLAY_KEY_SECONDARY;
- if (shouldShift) {
- Me.Util.activateSearchProvider('');
- if (mode === 1) {
- this._shiftState(Meta.MotionDirection.UP);
- } 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 {
- 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);
- }
- }
-};