From 291a94173c5ea022f75b4eee07e6e0c97a04ff7a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 08:06:59 +0200 Subject: Adding 45/vertical-workspaces version 37+20240412 [9b05a79]. Signed-off-by: Daniel Baumann --- extensions/45/vertical-workspaces/extension.js | 158 ++++++++++++++++++------- 1 file changed, 112 insertions(+), 46 deletions(-) (limited to 'extensions/45/vertical-workspaces/extension.js') diff --git a/extensions/45/vertical-workspaces/extension.js b/extensions/45/vertical-workspaces/extension.js index 44ea42b..0378e0b 100644 --- a/extensions/45/vertical-workspaces/extension.js +++ b/extensions/45/vertical-workspaces/extension.js @@ -3,7 +3,7 @@ * extension.js * * @author GdH - * @copyright 2022 - 2023 + * @copyright 2022 - 2024 * @license GPL-3.0 * */ @@ -50,10 +50,6 @@ import { WindowPreviewModule } from './lib/windowPreview.js'; import { WorkspaceAnimationModule } from './lib/workspaceAnimation.js'; import { WorkspaceModule } from './lib/workspace.js'; import { WorkspaceSwitcherPopupModule } from './lib/workspaceSwitcherPopup.js'; -import { WindowSearchProviderModule } from './lib/windowSearchProvider.js'; -import { RecentFilesSearchProviderModule } from './lib/recentFilesSearchProvider.js'; -import { ExtensionsSearchProviderModule } from './lib/extensionsSearchProvider.js'; -import { WinTmbModule } from './lib/winTmb.js'; let Me; // gettext @@ -73,9 +69,10 @@ export default class VShell extends Extension.Extension { Me.gettext = this.gettext.bind(this); _ = Me.gettext; - Me.WSP_PREFIX = WindowSearchProviderModule._PREFIX; - Me.RFSP_PREFIX = RecentFilesSearchProviderModule._PREFIX; - Me.ESP_PREFIX = ExtensionsSearchProviderModule._PREFIX; + // search prefixes for supported search providers + Me.WSP_PREFIX = 'wq//'; + Me.RFSP_PREFIX = 'fq//'; + Me.ESP_PREFIX = 'eq//'; Me.opt = new Me.Settings.Options(Me); @@ -108,11 +105,7 @@ export default class VShell extends Extension.Extension { this.removeVShell(); this._disposeModules(); - // If Dash to Dock is enabled, disabling V-Shell can end in broken overview - Main.overview.hide(); - console.debug(`${Me.metadata.name}: disabled`); - this._cleanGlobals(); } @@ -144,10 +137,6 @@ export default class VShell extends Extension.Extension { Me.Modules.workspaceSwitcherPopupModule = new WorkspaceSwitcherPopupModule(Me); Me.Modules.workspaceThumbnailModule = new WorkspaceThumbnailModule(Me); Me.Modules.workspacesViewModule = new WorkspacesViewModule(Me); - Me.Modules.windowSearchProviderModule = new WindowSearchProviderModule(Me); - Me.Modules.recentFilesSearchProviderModule = new RecentFilesSearchProviderModule(Me); - Me.Modules.extensionsSearchProviderModule = new ExtensionsSearchProviderModule(Me); - Me.Modules.winTmbModule = new WinTmbModule(Me); } _disposeModules() { @@ -160,9 +149,7 @@ export default class VShell extends Extension.Extension { } Me.Util.cleanGlobals(); - Me.Modules = null; - opt = null; } activateVShell() { @@ -173,6 +160,8 @@ export default class VShell extends Extension.Extension { this._removeTimeouts(); this._timeouts = {}; + this._ensureOverviewIsHidden(); + // load VShell configuration this._updateSettings(); @@ -200,9 +189,16 @@ export default class VShell extends Extension.Extension { // workaround for upstream bug - overview always shows workspace 1 instead of the active one after restart this._setInitialWsIndex(); + + this._resetShellProperties(); } removeVShell() { + // Rebasing V-Shell when overview is open causes problems + // also if Dash to Dock is enabled, disabling V-Shell can result in a broken overview + this._ensureOverviewIsHidden(); + this._resetShellProperties(); + this._enabled = false; const reset = true; @@ -217,27 +213,53 @@ export default class VShell extends Extension.Extension { // switch PageUp/PageDown workspace switcher shortcuts this._switchPageShortcuts(); - // remove any position offsets from dash and ws thumbnails - if (!Me.Util.dashNotDefault()) { - Main.overview.dash.translation_x = 0; - Main.overview.dash.translation_y = 0; - } - Main.overview._overview._controls._thumbnailsBox.translation_x = 0; - Main.overview._overview._controls._thumbnailsBox.translation_y = 0; - Main.overview._overview._controls._searchEntryBin.translation_y = 0; - Main.overview._overview._controls.set_child_above_sibling(Main.overview._overview._controls._workspacesDisplay, null); - // restore default animation speed - St.Settings.get().slow_down_factor = 1; - - // restore default dash background style - Main.overview.dash._background.set_style(''); // hide status message if shown this._showStatusMessage(false); this._prevDash = null; + // restore default animation speed + St.Settings.get().slow_down_factor = 1; + Meta.Workspace.prototype.get_neighbor = this._originalGetNeighbor; } + _ensureOverviewIsHidden() { + if (Main.overview._shown) { + Main.overview._shown = false; + // Main.overview._animationInProgress = true; + Main.overview._visibleTarget = false; + Main.overview._overview.prepareToLeaveOverview(); + Main.overview._changeShownState('HIDING'); + Main.overview._hideDone(); + Main.overview.dash.showAppsButton.checked = false; + } + } + + _resetShellProperties() { + const controls = Main.overview._overview.controls; + // remove any position offsets from dash and ws thumbnails + if (!Me.Util.dashNotDefault()) { + controls.dash.translation_x = 0; + controls.dash.translation_y = 0; + } + controls._thumbnailsBox.translation_x = 0; + controls._thumbnailsBox.translation_y = 0; + controls._searchEntryBin.translation_y = 0; + controls._workspacesDisplay.scale_x = 1; + controls.set_child_above_sibling(controls._workspacesDisplay, null); + + // following properties may be reduced if extensions are rebased while the overview is open + controls._thumbnailsBox.remove_all_transitions(); + controls._thumbnailsBox.scale_x = 1; + controls._thumbnailsBox.scale_y = 1; + controls._thumbnailsBox.opacity = 255; + + controls._searchController._searchResults.opacity = 255; + + // restore default dash background style + controls.dash._background.set_style(''); + } + _removeTimeouts() { if (this._timeouts) { Object.values(this._timeouts).forEach(id => { @@ -270,7 +292,7 @@ export default class VShell extends Extension.Extension { Me.Util.getEnabledExtensions('ubuntu-dock').length); // force enable Fix Dash to Dock option if DtD detected - opt._watchDashToDock = dtdEnabled; + this._watchDashToDock = dtdEnabled; } _updateConnections() { @@ -289,7 +311,6 @@ export default class VShell extends Extension.Extension { () => { Me.Modules.panelModule.update(); Me.Modules.overviewControlsModule.update(); - Me.Modules.winTmbModule.showThumbnails(); this._timeouts.unlock = 0; return GLib.SOURCE_REMOVE; @@ -297,7 +318,6 @@ export default class VShell extends Extension.Extension { ); } else if (session.currentMode === 'unlock-dialog') { Me.Modules.panelModule.update(true); - Me.Modules.winTmbModule.hideThumbnails(); } }); } @@ -326,12 +346,46 @@ export default class VShell extends Extension.Extension { const reset = [1, 2].includes(extension.state); const dashReplacement = uuid.includes('dash-to-dock') || uuid.includes('ubuntu-dock') || uuid.includes('dash-to-panel'); if (dashReplacement && reset) - opt._watchDashToDock = true; + this._watchDashToDock = true; if (!Main.layoutManager._startingUp && reset && dashReplacement) this._updateVShell(1999); } ); } + + this._updateNewWindowConnection(); + } + + _updateNewWindowConnection() { + const nMonitors = global.display.get_n_monitors(); + if (nMonitors > 1 && opt.FIX_NEW_WINDOW_MONITOR && !this._newWindowCreatedConId) { + this._newWindowCreatedConId = global.display.connect_after('window-created', (w, win) => { + if (Main.layoutManager._startingUp || win.get_window_type() !== Meta.WindowType.NORMAL) + return; + const winActor = win.get_compositor_private(); + const _moveWinToMonitor = () => { + const currentMonitor = global.display.get_current_monitor(); + if (win.get_monitor() !== currentMonitor) { + // some windows ignore this action if executed immediately + GLib.idle_add(GLib.PRIORITY_LOW, () => { + win.move_to_monitor(currentMonitor); + return GLib.SOURCE_REMOVE; + }); + } + }; + if (!winActor.realized) { + const realizeId = winActor.connect('realize', () => { + winActor.disconnect(realizeId); + _moveWinToMonitor(); + }); + } else { + _moveWinToMonitor(); + } + }); + } else if ((nMonitors.length === 1 || !opt.FIX_NEW_WINDOW_MONITOR) && this._newWindowCreatedConId) { + global.display.disconnect(this._newWindowCreatedConId); + this._newWindowCreatedConId = 0; + } } _removeConnections() { @@ -354,6 +408,11 @@ export default class VShell extends Extension.Extension { Main.extensionManager.disconnect(this._watchDockSigId); this._watchDockSigId = 0; } + + if (this._newWindowCreatedConId) { + global.display.disconnect(this._newWindowCreatedConId); + this._newWindowCreatedConId = 0; + } } _updateOverrides(reset = false) { @@ -387,10 +446,6 @@ export default class VShell extends Extension.Extension { Me.Modules.searchModule.update(reset); - Me.Modules.windowSearchProviderModule.update(reset); - Me.Modules.recentFilesSearchProviderModule.update(reset); - Me.Modules.extensionsSearchProviderModule.update(reset); - // don't rebuild app grid on any screen lock // even if the extension includes unlock-screen session mode // disable/enable is called at least once even on GS44 @@ -423,7 +478,6 @@ export default class VShell extends Extension.Extension { Me.Modules.osdWindowModule.update(reset); Me.Modules.overlayKeyModule.update(reset); Me.Modules.searchControllerModule.update(reset); - Me.Modules.winTmbModule.update(reset); if (!reset && !Main.layoutManager._startingUp) Main.overview._overview.controls.setInitialTranslations(); @@ -441,7 +495,7 @@ export default class VShell extends Extension.Extension { if (!Main.overview._overview.controls._bgManagers && (opt.SHOW_BG_IN_OVERVIEW || opt.SHOW_WS_PREVIEW_BG) && !Me.Util.getEnabledExtensions('blur-my-shell').length) Main.overview._overview.controls._setBackground(); - if (opt._watchDashToDock) { + if (this._watchDashToDock) { // workaround for Dash to Dock (Ubuntu Dock) breaking overview allocations after enabled and changed position // DtD replaces dock and its _workId on every position change const dash = Main.overview.dash; @@ -573,6 +627,12 @@ export default class VShell extends Extension.Extension { else Meta.Workspace.prototype.get_neighbor = this._originalGetNeighbor; + // delay search so it doesn't make the search view transition stuttering + // 150 is the default value in GNOME Shell, but the search feels laggy + // Of course there is some overload for fast keyboard typist + if (opt.SEARCH_VIEW_ANIMATION) + opt.SEARCH_DELAY = 150; + if (settings) this._applySettings(key); } @@ -601,6 +661,9 @@ export default class VShell extends Extension.Extension { if (key?.includes('hot-corner') || key?.includes('dash')) Me.Modules.layoutModule.update(); + if (key?.includes('overlay-key')) + Me.Modules.overlayKeyModule.update(); + switch (key) { case 'ws-thumbnails-position': this._updateOverrides(); @@ -626,12 +689,15 @@ export default class VShell extends Extension.Extension { case 'osd-position': Me.Modules.osdWindowModule.update(); break; - case 'overlay-key': - Me.Modules.overlayKeyModule.update(); - break; case 'always-activate-selected-window': Me.Modules.windowPreviewModule.update(); break; + case 'ws-switcher-mode': + Me.Modules.windowManagerModule.update(); + break; + case 'new-window-monitor-fix': + this._updateNewWindowConnection(); + break; } if (key?.includes('app-grid') || @@ -775,7 +841,7 @@ export default class VShell extends Extension.Extension { _getNeighbor(direction) { // workspace matrix is supported const activeIndex = this.index(); - const ignoreLast = opt.WS_IGNORE_LAST && !Main.overview._shown ? 1 : 0; + const ignoreLast = opt.WS_IGNORE_LAST && Meta.prefs_get_dynamic_workspaces() && !Main.overview._shown ? 1 : 0; const wraparound = opt.WS_WRAPAROUND; const nWorkspaces = global.workspace_manager.n_workspaces; const lastIndex = nWorkspaces - 1 - ignoreLast; -- cgit v1.2.3