diff options
Diffstat (limited to '')
-rw-r--r-- | extensions/vertical-workspaces/lib/overviewControls.js (renamed from extensions/vertical-workspaces/overviewControls.js) | 732 |
1 files changed, 366 insertions, 366 deletions
diff --git a/extensions/vertical-workspaces/overviewControls.js b/extensions/vertical-workspaces/lib/overviewControls.js index ffe0f89..4959b83 100644 --- a/extensions/vertical-workspaces/overviewControls.js +++ b/extensions/vertical-workspaces/lib/overviewControls.js @@ -1,7 +1,7 @@ /** - * Vertical Workspaces + * V-Shell (Vertical Workspaces) * overviewControls.js - * + * * @author GdH <G-dH@github.com> * @copyright 2022 - 2023 * @license GPL-3.0 @@ -10,7 +10,7 @@ 'use strict'; -const { Clutter, GLib, GObject, Graphene, Meta, Shell, St } = imports.gi; +const { Clutter, GLib, GObject, St } = imports.gi; const Main = imports.ui.main; const Util = imports.misc.util; const OverviewControls = imports.ui.overviewControls; @@ -22,55 +22,50 @@ const FitMode = imports.ui.workspacesView.FitMode; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); -const _Util = Me.imports.util; +const _Util = Me.imports.lib.util; + let _overrides; +let opt; const ANIMATION_TIME = imports.ui.overview.ANIMATION_TIME; -const DASH_MAX_SIZE_RATIO = 0.15; +const DASH_MAX_SIZE_RATIO = 0.25; let _originalSearchControllerSigId; let _searchControllerSigId; -let _startupAnimTimeoutId1; -let _startupAnimTimeoutId2; -let _updateAppGridTimeoutId; +let _timeouts; let _startupInitComplete = false; -let opt; - - function update(reset = false) { - - if (_overrides) { + if (_overrides) _overrides.removeAll(); + + if (_timeouts) { + Object.values(_timeouts).forEach(id => { + if (id) + GLib.source_remove(id); + }); } - + _replaceOnSearchChanged(reset); - + if (reset) { _overrides = null; opt = null; + _timeouts = null; return; } - - opt = Me.imports.settings.opt; + _timeouts = {}; + + opt = Me.imports.lib.settings.opt; _overrides = new _Util.Overrides(); _overrides.addOverride('ControlsManager', OverviewControls.ControlsManager.prototype, ControlsManager); - - if (opt.ORIENTATION === Clutter.Orientation.VERTICAL) { + + if (opt.ORIENTATION === Clutter.Orientation.VERTICAL) _overrides.addOverride('ControlsManagerLayout', OverviewControls.ControlsManagerLayout.prototype, ControlsManagerLayoutVertical); - } else { + else _overrides.addOverride('ControlsManagerLayout', OverviewControls.ControlsManagerLayout.prototype, ControlsManagerLayoutHorizontal); - } -} - -function _dashNotDefault() { - return Main.overview.dash !== Main.overview._overview._controls.layoutManager._dash; -} - -function _dashIsDashToDock() { - return Main.overview.dash._isHorizontal !== undefined; } function _replaceOnSearchChanged(reset = false) { @@ -84,29 +79,32 @@ function _replaceOnSearchChanged(reset = false) { searchController.unblock_signal_handler(_originalSearchControllerSigId); _originalSearchControllerSigId = 0; } + Main.overview._overview._controls.layoutManager._searchController._searchResults.translation_x = 0; + Main.overview._overview._controls.layoutManager._searchController._searchResults.translation_y = 0; + Main.overview.searchEntry.visible = true; + Main.overview.searchEntry.opacity = 255; } else { // reconnect signal to use custom function (callbacks cannot be overridden in class prototype, they are already in memory as a copy for the given callback) _originalSearchControllerSigId = GObject.signal_handler_find(searchController, { signalId: 'notify', detail: 'search-active' }); - if (_originalSearchControllerSigId) { + if (_originalSearchControllerSigId) searchController.block_signal_handler(_originalSearchControllerSigId); - } + _searchControllerSigId = searchController.connect('notify::search-active', ControlsManager._onSearchChanged.bind(Main.overview._overview.controls)); } - } -var ControlsManager = { +const ControlsManager = { // this function is used as a callback by a signal handler, needs to be reconnected after modification as the original callback uses a copy of the original function - /*_update: function() { + /* _update: function() { ... }*/ // this function has duplicate in WorkspaceView so we use one function for both to avoid issues with syncing them - _getFitModeForState: function(state) { + _getFitModeForState(state) { return _getFitModeForState(state); }, - _updateThumbnailsBox: function() { + _updateThumbnailsBox() { const { shouldShow } = this._thumbnailsBox; const thumbnailsBoxVisible = shouldShow; this._thumbnailsBox.visible = thumbnailsBoxVisible; @@ -116,13 +114,12 @@ var ControlsManager = { }, // this function is pure addition to the original code and handles wsDisp transition to APP_GRID view - _updateWorkspacesDisplay: function() { + _updateWorkspacesDisplay() { this._workspacesDisplay.translation_x = 0; this._workspacesDisplay.translation_y = 0; this._workspacesDisplay.scale_x = 1; this._workspacesDisplay.scale_y = 1; const { initialState, finalState, progress, currentState } = this._stateAdjustment.getStateTransitionParams(); - const { searchActive } = this._searchController; const paramsForState = s => { let opacity; @@ -146,23 +143,26 @@ var ControlsManager = { let opacity = Math.round(Util.lerp(initialParams.opacity, finalParams.opacity, progress)); - let workspacesDisplayVisible = (opacity != 0)/* && !(searchActive)*/; + let workspacesDisplayVisible = opacity !== 0/* && !(searchActive)*/; // improve transition from search results to desktop - if (finalState === 0 && this._searchController._searchResults.visible) { + if (finalState === 0 && this._searchController._searchResults.visible) this._searchController.hide(); - } // reset Static Workspace window picker mode - if (currentState === 0/*finalState === 0 && progress === 1*/ && opt.OVERVIEW_MODE && opt.WORKSPACE_MODE) { + if (currentState === 0/* finalState === 0 && progress === 1*/ && opt.OVERVIEW_MODE && opt.WORKSPACE_MODE) opt.WORKSPACE_MODE = 0; - } + + if (currentState < 2 && currentState > 1) + WorkspaceThumbnail.RESCALE_ANIMATION_TIME = 0; + else + WorkspaceThumbnail.RESCALE_ANIMATION_TIME = 200; if (!opt.WS_ANIMATION || !opt.SHOW_WS_TMB) { this._workspacesDisplay.opacity = opacity; } else if (!opt.SHOW_WS_TMB_BG) { // fade out ws wallpaper during transition to ws switcher if ws switcher background disabled - const ws = this._workspacesDisplay._workspacesViews[global.display.get_primary_monitor()]._workspaces[this._workspaceAdjustment.value]; + const ws = this._workspacesDisplay._workspacesViews[global.display.get_primary_monitor()]?._workspaces[this._workspaceAdjustment.value]; if (ws) ws._background.opacity = opacity; } @@ -172,19 +172,19 @@ var ControlsManager = { const dash = this.dash; const searchEntryBin = this._searchEntryBin; // this dash transition collides with startup animation and freezes GS for good, needs to be delayed (first Main.overview 'hiding' event enables it) - const skipDash = _dashNotDefault(); + const skipDash = _Util.dashNotDefault(); // OVERVIEW_MODE 2 should animate dash and wsTmbBox only if WORKSPACE_MODE === 0 (windows not spread) const animateOverviewMode2 = opt.OVERVIEW_MODE2 && !(finalState === 1 && opt.WORKSPACE_MODE); - if (!Main.layoutManager._startingUp && ((!opt.SHOW_WS_PREVIEW_BG && !(opt.OVERVIEW_MODE2)) || animateOverviewMode2)) { + if (!Main.layoutManager._startingUp && ((!opt.SHOW_WS_PREVIEW_BG && !opt.OVERVIEW_MODE2) || animateOverviewMode2)) { if (!tmbBox._translationOriginal || Math.abs(tmbBox._translationOriginal[0]) > 500) { // swipe gesture can call this calculation before tmbBox is finalized, giving nonsense width - const [tmbTranslation_x, tmbTranslation_y, dashTranslation_x, dashTranslation_y, searchTranslation_y] = _Util.getOverviewTranslations(opt, dash, tmbBox, searchEntryBin); - tmbBox._translationOriginal = [tmbTranslation_x, tmbTranslation_y]; - dash._translationOriginal = [dashTranslation_x, dashTranslation_y]; - searchEntryBin._translationOriginal = searchTranslation_y; + const [tmbTranslationX, tmbTranslationY, dashTranslationX, dashTranslationY, searchTranslationY] = _Util.getOverviewTranslations(opt, dash, tmbBox, searchEntryBin); + tmbBox._translationOriginal = [tmbTranslationX, tmbTranslationY]; + dash._translationOriginal = [dashTranslationX, dashTranslationY]; + searchEntryBin._translationOriginal = searchTranslationY; } if (finalState === 0 || initialState === 0) { - const prg = Math.abs((finalState == 0 ? 0 : 1) - progress); + const prg = Math.abs((finalState === 0 ? 0 : 1) - progress); tmbBox.translation_x = Math.round(prg * tmbBox._translationOriginal[0]); tmbBox.translation_y = Math.round(prg * tmbBox._translationOriginal[1]); if (!skipDash) { @@ -195,9 +195,9 @@ var ControlsManager = { } if (progress === 1) { tmbBox._translationOriginal = 0; - if (!skipDash) { + if (!skipDash) dash._translationOriginal = 0; - } + searchEntryBin._translationOriginal = 0; } } else if (!Main.layoutManager._startingUp && (tmbBox.translation_x || tmbBox.translation_y)) { @@ -211,11 +211,10 @@ var ControlsManager = { } if (!Main.layoutManager._startingUp) { - if (initialState === ControlsState.HIDDEN && finalState === ControlsState.APP_GRID) { + if (initialState === ControlsState.HIDDEN && finalState === ControlsState.APP_GRID) this._appDisplay.opacity = Math.round(progress * 255); - } else { + else this._appDisplay.opacity = 255 - opacity; - } } if (currentState === ControlsState.APP_GRID) { @@ -230,22 +229,19 @@ var ControlsManager = { // set searchEntry above appDisplay this.set_child_above_sibling(this._searchEntryBin, null); // move dash above wsTmb for case that dash and wsTmb animate from the same side - this.set_child_above_sibling(dash, null); + if (!_Util.dashNotDefault()) + this.set_child_above_sibling(dash, null); this.set_child_below_sibling(this._thumbnailsBox, null); this.set_child_below_sibling(this._workspacesDisplay, null); this.set_child_below_sibling(this._appDisplay, null); } else if (!this.dash._isAbove && progress === 1 && finalState > ControlsState.HIDDEN) { // set dash above workspace in the overview - if (!_dashNotDefault()) { - this.set_child_above_sibling(this._thumbnailsBox, null); - this.set_child_above_sibling(this._searchEntryBin, null); + this.set_child_above_sibling(this._thumbnailsBox, null); + this.set_child_above_sibling(this._searchEntryBin, null); + if (!_Util.dashNotDefault()) this.set_child_above_sibling(this.dash, null); - this.dash._isAbove = true; - } - - // update max tmb scale in case some other extension changed it - WorkspaceThumbnail.MAX_THUMBNAIL_SCALE = opt.MAX_THUMBNAIL_SCALE; + this.dash._isAbove = true; } else if (this.dash._isAbove && progress < 1) { // keep dash below for ws transition between the overview and hidden state this.set_child_above_sibling(this._workspacesDisplay, null); @@ -254,7 +250,7 @@ var ControlsManager = { }, // fix for upstream bug - appGrid.visible after transition from APP_GRID to HIDDEN - _updateAppDisplayVisibility: function(stateTransitionParams = null) { + _updateAppDisplayVisibility(stateTransitionParams = null) { if (!stateTransitionParams) stateTransitionParams = this._stateAdjustment.getStateTransitionParams(); @@ -262,6 +258,12 @@ var ControlsManager = { if (this.dash.showAppsButton.checked) this._searchTransition = false; + // update App Grid after settings changed + // only if the App Grid is currently visible on the screen, the paging updates correctly + if (currentState === ControlsState.APP_GRID && this._appDisplay.visible && opt._appGridNeedsRedisplay) { + Me.imports.lib.appDisplay._updateAppGridProperties(); + opt._appGridNeedsRedisplay = false; + } // if !APP_GRID_ANIMATION, appGrid needs to be hidden in WINDOW_PICKER mode (1) // but needs to be visible for transition from HIDDEN (0) to APP_GRID (2) this._appDisplay.visible = @@ -271,150 +273,156 @@ var ControlsManager = { !this._searchTransition; }, - _onSearchChanged: function() { - // if user start typing or activated search provider during overview animation, this switcher will be called again after animation ends - if (opt.SEARCH_VIEW_ANIMATION && Main.overview._animationInProgress) return; - + _onSearchChanged() { const { finalState, currentState } = this._stateAdjustment.getStateTransitionParams(); + const { searchActive } = this._searchController; const SIDE_CONTROLS_ANIMATION_TIME = 250; // OverviewControls.SIDE_CONTROLS_ANIMATION_TIME = Overview.ANIMATION_TIME = 250 + const entry = this._searchEntry; + if (opt.SHOW_SEARCH_ENTRY) { + entry.visible = true; + entry.opacity = 255; + } else if (!(searchActive && entry.visible)) { + entry.visible = true; + entry.opacity = searchActive ? 0 : 255; + // show search entry only if the user starts typing, and hide it when leaving the search mode + entry.ease({ + opacity: searchActive ? 255 : 0, + duration: SIDE_CONTROLS_ANIMATION_TIME / 2, + mode: Clutter.AnimationMode.EASE_OUT_QUAD, + onComplete: () => { + entry.visible = searchActive; + }, + }); + } + + // if user start typing or activated search provider during overview animation, this switcher will be called again after animation ends + if (opt.SEARCH_VIEW_ANIMATION && Main.overview._animationInProgress && finalState !== ControlsState.HIDDEN) + return; + if (!searchActive) { this._workspacesDisplay.reactive = true; this._workspacesDisplay.setPrimaryWorkspaceVisible(true); } else { this._searchController.show(); + entry.visible = true; + entry.opacity = 255; } this._searchTransition = true; this._searchController._searchResults.translation_x = 0; this._searchController._searchResults.translation_y = 0; + this._searchController.opacity = 255; this._searchController.visible = true; - if (opt.SEARCH_VIEW_ANIMATION && !this.dash.showAppsButton.checked && ![4, 8].includes(opt.WS_TMB_POSITION) /*&& !opt.OVERVIEW_MODE2*/) { + if (opt.SEARCH_VIEW_ANIMATION && !this.dash.showAppsButton.checked && ![4, 8].includes(opt.WS_TMB_POSITION) /* && !opt.OVERVIEW_MODE2*/) { this._updateAppDisplayVisibility(); this._searchController.opacity = searchActive ? 255 : 0; - let translation_x = 0; - let translation_y = 0; + let translationX = 0; + let translationY = 0; const geometry = global.display.get_monitor_geometry(global.display.get_primary_monitor()); - if (currentState < ControlsState.APP_GRID) { switch (opt.SEARCH_VIEW_ANIMATION) { - case 0: - translation_x = 0; - translation_y = 0; - break; - case 1: - // make it longer to cover the delay before results appears - translation_x = geometry.x + geometry.width - this._searchController.x + this._workspacesDisplay.width; - translation_y = 0; - break; - case 2: - translation_x = - this._searchController.x - 2 * this._workspacesDisplay.width; - translation_y = 0; - break; - case 3: - translation_x = 0; - translation_y = geometry.y + geometry.height + this._searchController.y + this._workspacesDisplay.height; - break; - case 5: - translation_x = 0; - translation_y = - this._searchController.y - 2 * this._workspacesDisplay.height; - break; + case 1: + // make it longer to cover the delay before results appears + translationX = geometry.width; + translationY = 0; + break; + case 2: + translationX = -geometry.width; + translationY = 0; + break; + case 3: + translationX = 0; + translationY = geometry.height; + break; + case 5: + translationX = 0; + translationY = -geometry.height; + break; } } if (searchActive) { - this._searchController._searchResults.translation_x = translation_x; - this._searchController._searchResults.translation_y = translation_y; + this._searchController._searchResults.translation_x = translationX; + this._searchController._searchResults.translation_y = translationY; } else { this._searchController._searchResults.translation_x = 0; this._searchController._searchResults.translation_y = 0; } this._searchController._searchResults.ease({ - //opacity: searchActive ? 255 : 0, - translation_x: searchActive ? 0 : translation_x, - translation_y: searchActive ? 0 : translation_y, + translation_x: searchActive ? 0 : translationX, + translation_y: searchActive ? 0 : translationY, duration: SIDE_CONTROLS_ANIMATION_TIME, mode: Clutter.AnimationMode.EASE_OUT_QUAD, onComplete: () => { this._searchController.visible = searchActive; this._searchTransition = false; - } + }, }); this._workspacesDisplay.opacity = 255; } else { this._appDisplay.ease({ - opacity: (searchActive || currentState < 2) ? 0 : 255, + opacity: searchActive || currentState < 2 ? 0 : 255, duration: SIDE_CONTROLS_ANIMATION_TIME / 2, mode: Clutter.AnimationMode.EASE_OUT_QUAD, onComplete: () => this._updateAppDisplayVisibility(), }); - //this._updateAppDisplayVisibility(); + // this._updateAppDisplayVisibility(); this._workspacesDisplay.setPrimaryWorkspaceVisible(true); - this._workspacesDisplay.ease({ + /* this._workspacesDisplay.ease({ opacity: searchActive ? 0 : 255, - duration: SIDE_CONTROLS_ANIMATION_TIME / 2, + duration: searchActive ? SIDE_CONTROLS_ANIMATION_TIME / 2 : 0, mode: Clutter.AnimationMode.EASE_OUT_QUAD, onComplete: () => { this._workspacesDisplay.reactive = !searchActive; this._workspacesDisplay.setPrimaryWorkspaceVisible(!searchActive); }, - }); + });*/ + this._searchController.opacity = searchActive ? 0 : 255; this._searchController.ease({ opacity: searchActive ? 255 : 0, - duration: SIDE_CONTROLS_ANIMATION_TIME / 2, + duration: searchActive ? SIDE_CONTROLS_ANIMATION_TIME * 2 : 0, mode: Clutter.AnimationMode.EASE_OUT_QUAD, onComplete: () => (this._searchController.visible = searchActive), }); } // reuse already tuned overview transition, just replace APP_GRID with the search view - if (!Main.overview._animationInProgress && finalState !== ControlsState.HIDDEN && !this.dash.showAppsButton.checked) { + if (!(opt.OVERVIEW_MODE2 && !opt.WORKSPACE_MODE) && !Main.overview._animationInProgress && finalState !== ControlsState.HIDDEN && !this.dash.showAppsButton.checked) { + Main.overview._overview._controls.layoutManager._searchController._searchResults._content.remove_style_class_name('search-section-content-om2'); + Main.overview.searchEntry.remove_style_class_name('search-entry-om2'); this._stateAdjustment.ease(searchActive ? ControlsState.APP_GRID : ControlsState.WINDOW_PICKER, { // shorter animation time when entering search view can avoid stuttering in transition // collecting search results take some time and the problematic part is the realization of the object on the screen // if the ws animation ends before this event, the whole transition is smoother // removing the ws transition (duration: 0) seems like the best solution here - duration: searchActive ? 0 : SIDE_CONTROLS_ANIMATION_TIME, + duration: searchActive || (opt.OVERVIEW_MODE && !opt.WORKSPACE_MODE) ? 80 : SIDE_CONTROLS_ANIMATION_TIME, mode: Clutter.AnimationMode.EASE_OUT_QUAD, onComplete: () => { this._workspacesDisplay.setPrimaryWorkspaceVisible(!searchActive); - } - }); - } - - const entry = this._searchEntry; - if (opt.SHOW_SEARCH_ENTRY) { - entry.visible = true; - entry.opacity = 255; - } else { - entry.visible = true; - entry.opacity = searchActive ? 0 : 255; - // show search entry only if the user starts typing, and hide it when leaving the search mode - entry.ease({ - opacity: searchActive ? 255 : 0, - duration: SIDE_CONTROLS_ANIMATION_TIME / 2, - mode: Clutter.AnimationMode.EASE_OUT_QUAD, - onComplete: () => { - entry.visible = searchActive; }, }); + } else if (opt.OVERVIEW_MODE2 && !(opt.WORKSPACE_MODE || this.dash.showAppsButton.checked)) { + // add background to search results and make searchEntry border thicker for better visibility + Main.overview._overview._controls.layoutManager._searchController._searchResults._content.add_style_class_name('search-section-content-om2'); + Main.overview.searchEntry.add_style_class_name('search-entry-om2'); + } else { + Main.overview._overview._controls.layoutManager._searchController._searchResults._content.remove_style_class_name('search-section-content-om2'); + Main.overview.searchEntry.remove_style_class_name('search-entry-om2'); } }, - runStartupAnimation: async function(callback) { - // fix for upstream bug - overview always shows workspace 1 instead of the active one after restart - this._workspaceAdjustment.set_value(global.workspace_manager.get_active_workspace_index()); + async runStartupAnimation(callback) { this._ignoreShowAppsButtonToggle = true; - this._searchController.prepareToEnterOverview(); this._workspacesDisplay.prepareToEnterOverview(); @@ -443,7 +451,7 @@ var ControlsManager = { onComplete: () => { // part of the workaround for stuttering first app grid animation this._appDisplay.visible = true; - } + }, }); const dash = this.dash; @@ -457,10 +465,10 @@ var ControlsManager = { } const searchEntryBin = this._searchEntryBin; - const [tmbTranslation_x, tmbTranslation_y, dashTranslation_x, dashTranslation_y, searchTranslation_y] = + const [tmbTranslationX, tmbTranslationY, dashTranslationX, dashTranslationY, searchTranslationY] = _Util.getOverviewTranslations(opt, dash, tmbBox, searchEntryBin); - const onComplete = function() { + const onComplete = function () { // running init callback again causes issues (multiple connections) if (!_startupInitComplete) callback(); @@ -470,16 +478,24 @@ var ControlsManager = { this._appDisplay.opacity = 1; const [x, y] = this._appDisplay.get_position(); - const translation_x = - x; - const translation_y = - y; - this._appDisplay.translation_x = translation_x; - this._appDisplay.translation_y = translation_y; + const translationX = -x; + const translationY = -y; + this._appDisplay.translation_x = translationX; + this._appDisplay.translation_y = translationY; + GLib.idle_add(0, () => { + this._appDisplay._removeItem(this._appDisplay._orderedItems[0]); + this._appDisplay._redisplay(); + }); // let the main loop realize previous changes before continuing - _startupAnimTimeoutId1 = GLib.timeout_add( + _timeouts.startupAnim1 = GLib.timeout_add( GLib.PRIORITY_DEFAULT, 10, () => { + GLib.idle_add(0, () => { + this._appDisplay._removeItem(this._appDisplay._orderedItems[0]); + this._appDisplay._redisplay(); + }); this._appDisplay.translation_x = 0; this._appDisplay.translation_y = 0; this._appDisplay.visible = false; @@ -489,15 +505,15 @@ var ControlsManager = { this._appDisplay.opacity = 255; this.dash.showAppsButton.checked = true; } - _startupAnimTimeoutId1 = 0; + _timeouts.startupAnim1 = 0; return GLib.SOURCE_REMOVE; } ); }.bind(this); - if (dash.visible && !_dashNotDefault()) { - dash.translation_x = dashTranslation_x; - dash.translation_y = dashTranslation_y; + if (dash.visible && !_Util.dashNotDefault()) { + dash.translation_x = dashTranslationX; + dash.translation_y = dashTranslationY; dash.opacity = 255; dash.ease({ translation_x: 0, @@ -513,20 +529,20 @@ var ControlsManager = { // set dash opacity to make it visible if user enable it later dash.opacity = 255; // if dash is hidden, substitute the ease timeout with GLib.timeout - _startupAnimTimeoutId2 = GLib.timeout_add( + _timeouts.startupAnim2 = GLib.timeout_add( GLib.PRIORITY_DEFAULT, // delay + animation time - STARTUP_ANIMATION_TIME * 2 * opt.ANIMATION_TIME_FACTOR, + STARTUP_ANIMATION_TIME * 2 * St.Settings.get().slow_down_factor, () => { onComplete(); - _startupAnimTimeoutId2 = 0; + _timeouts.startupAnim2 = 0; return GLib.SOURCE_REMOVE; } ); } if (searchEntryBin.visible) { - searchEntryBin.translation_y = searchTranslation_y; + searchEntryBin.translation_y = searchTranslationY; searchEntryBin.ease({ translation_y: 0, delay: STARTUP_ANIMATION_TIME / 2, @@ -536,8 +552,8 @@ var ControlsManager = { } if (tmbBox.visible) { - tmbBox.translation_x = tmbTranslation_x; - tmbBox.translation_y = tmbTranslation_y; + tmbBox.translation_x = tmbTranslationX; + tmbBox.translation_y = tmbTranslationY; tmbBox.ease({ translation_x: 0, translation_y: 0, @@ -553,21 +569,21 @@ var ControlsManager = { if (workspacesViews.length > 1) { for (const view of workspacesViews) { if (view._monitorIndex !== global.display.get_primary_monitor() && view._thumbnails.visible) { - const tmbBox = view._thumbnails; - - _Util.getOverviewTranslations(opt, dash, tmbBox, searchEntryBin); - if (opt.SEC_WS_TMB_LEFT) { - tmbBox.translation_x = - (tmbBox.width + 12); // compensate for padding - } else if (opt.SEC_WS_TMB_RIGHT) { - tmbBox.translation_x = (tmbBox.width + 12); - } else if (opt.SEC_WS_TMB_TOP) { - tmbBox.translation_y = - (tmbBox.height + 12); - } else if (opt.SEC_WS_TMB_BOTTOM) { - tmbBox.translation_y = (tmbBox.height + 12); - } - tmbBox.opacity = 255; + const secTmbBox = view._thumbnails; + + _Util.getOverviewTranslations(opt, dash, secTmbBox, searchEntryBin); + if (opt.SEC_WS_TMB_LEFT) + secTmbBox.translation_x = -(secTmbBox.width + 12); // compensate for padding + else if (opt.SEC_WS_TMB_RIGHT) + secTmbBox.translation_x = secTmbBox.width + 12; + else if (opt.SEC_WS_TMB_TOP) + secTmbBox.translation_y = -(secTmbBox.height + 12); + else if (opt.SEC_WS_TMB_BOTTOM) + secTmbBox.translation_y = secTmbBox.height + 12; - tmbBox.ease({ + secTmbBox.opacity = 255; + + secTmbBox.ease({ translation_y: 0, delay: STARTUP_ANIMATION_TIME / 2, duration: STARTUP_ANIMATION_TIME, @@ -578,10 +594,7 @@ var ControlsManager = { } }, - animateToOverview: function(state, callback) { - // don't enter overview during updating appDisplay properties - if (_updateAppGridTimeoutId) - Main.overview.hide(); + animateToOverview(state, callback) { this._ignoreShowAppsButtonToggle = true; this._searchTransition = false; @@ -595,10 +608,13 @@ var ControlsManager = { // in which case the the animation is greatly delayed, stuttering, or even skipped // for user it is more acceptable to watch delayed smooth animation, // even if it takes little more time, than jumping frames - const delay = global.display.get_tab_list(0, global.workspace_manager.get_active_workspace()).length * 3; + let delay = 0; + if (opt.DELAY_OVERVIEW_ANIMATION) + delay = global.display.get_tab_list(0, global.workspace_manager.get_active_workspace()).length * 3; + this._stateAdjustment.ease(state, { delay, - duration: 250, //Overview.ANIMATION_TIME, + duration: 250, // Overview.ANIMATION_TIME, mode: Clutter.AnimationMode.EASE_OUT_QUAD, onStopped: () => { if (callback) @@ -611,29 +627,28 @@ var ControlsManager = { this._ignoreShowAppsButtonToggle = false; }, -} +}; -var ControlsManagerLayoutVertical = { - _computeWorkspacesBoxForState: function(state, box, workAreaBox, dashWidth, dashHeight, thumbnailsWidth, searchHeight, startY) { +const ControlsManagerLayoutVertical = { + _computeWorkspacesBoxForState(state, box, workAreaBox, dashWidth, dashHeight, thumbnailsWidth, searchHeight, startY) { const workspaceBox = box.copy(); let [width, height] = workspaceBox.get_size(); - const { x1: startX,/* y1: startY*/ } = workAreaBox; + // const { x1: startX/* y1: startY*/ } = workAreaBox; const { spacing } = this; - //const { expandFraction } = this._workspacesThumbnails; + // const { expandFraction } = this._workspacesThumbnails; const dash = Main.overview.dash; // including Dash to Dock and clones properties for compatibility - if (_dashIsDashToDock()) { + if (_Util.dashIsDashToDock()) { // Dash to Dock also always affects workAreaBox - Main.layoutManager._trackedActors.forEach((actor) => { + Main.layoutManager._trackedActors.forEach(actor => { if (actor.affectsStruts && actor.actor.width === dash.width) { if (dash._isHorizontal) { // disabled inteli-hide don't needs compensation // startY needs to be corrected in allocate() - if (dash.get_parent()?.get_parent()?.get_parent()?._intellihideIsEnabled) { + if (dash.get_parent()?.get_parent()?.get_parent()?._intellihideIsEnabled) height += dash.height; - } } else { width += dash.width; } @@ -647,9 +662,9 @@ var ControlsManagerLayoutVertical = { switch (state) { case ControlsState.HIDDEN: - // if PANEL_MODE == 2 (overview only) the affectStruts property stays on false to avoid stuttering + // if PANEL_OVERVIEW_ONLY, the affectStruts property is set to false to avoid stuttering // therefore we added panel height to startY for the overview allocation, - // but here we need to remove the correction since the panel will be in the hidden state + // but here we need to remove the correction because the panel will be in the hidden state if (opt.START_Y_OFFSET) { let [x, y] = workAreaBox.get_origin(); y -= opt.START_Y_OFFSET; @@ -674,27 +689,27 @@ var ControlsManagerLayoutVertical = { } workspaceBox.set_size(...workAreaBox.get_size()); } else { - // in PANEL_MODE 2 panel don't affects workArea height (affectStruts === false), it needs to be compensated + // if PANEL_OVERVIEW_ONLY, panel doesn't affect workArea height (affectStruts === false), it is necessary to compensate height = opt.PANEL_POSITION_TOP ? height : height - Main.panel.height; searchHeight = opt.SHOW_SEARCH_ENTRY ? searchHeight : 0; - wWidth = width - - (opt.DASH_VERTICAL ? dash.width : 0) - - (thumbnailsWidth) - - 4 * spacing - wHeight = height - - (opt.DASH_VERTICAL ? 0 : dashHeight) - - searchHeight - - 4 * spacing; + wWidth = width - + (opt.DASH_VERTICAL ? dash.width : 0) - + thumbnailsWidth - + 4 * spacing; + wHeight = height - + (opt.DASH_VERTICAL ? 0 : dashHeight) - + searchHeight - + 4 * spacing; const ratio = width / height; let wRatio = wWidth / wHeight; let scale = ratio / wRatio; if (scale > 1) { - wHeight = wHeight / scale; + wHeight /= scale; wWidth = wHeight * ratio; } else { - wWidth = wWidth * scale; + wWidth *= scale; wHeight = wWidth / ratio; } @@ -706,7 +721,7 @@ var ControlsManagerLayoutVertical = { let yOffset = 0; const yOffsetT = (opt.DASH_TOP ? dashHeight : 0) + searchHeight; - const yOffsetB = (opt.DASH_BOTTOM ? dashHeight : 0); + const yOffsetB = opt.DASH_BOTTOM ? dashHeight : 0; const yAvailableSpace = (height - yOffsetT - wHeight - yOffsetB) / 2; yOffset = yOffsetT + yAvailableSpace; @@ -723,7 +738,7 @@ var ControlsManagerLayoutVertical = { this._xAlignCenter = true; } - const wsBoxX = /*startX + */xOffset; + const wsBoxX = /* startX + */xOffset; wsBoxY = Math.round(startY + yOffset); workspaceBox.set_origin(Math.round(wsBoxX), Math.round(wsBoxY)); workspaceBox.set_size(Math.round(wWidth), Math.round(wHeight)); @@ -733,13 +748,11 @@ var ControlsManagerLayoutVertical = { return workspaceBox; }, - _getAppDisplayBoxForState: function(state, box, workAreaBox, searchHeight, dashWidth, dashHeight, thumbnailsWidth, startY) { + _getAppDisplayBoxForState(state, box, workAreaBox, searchHeight, dashWidth, dashHeight, thumbnailsWidth, startY) { const [width] = box.get_size(); const { x1: startX } = workAreaBox; - //const { y1: startY } = workAreaBox; + // const { y1: startY } = workAreaBox; let height = workAreaBox.get_height(); - // in PANEL_MODE 2 panel don't affects workArea height (affectStruts === false), it needs to be compensated - height = opt.PANEL_MODE === 2 ? height - Main.panel.height : height; const appDisplayBox = new Clutter.ActorBox(); const { spacing } = this; @@ -748,11 +761,11 @@ var ControlsManagerLayoutVertical = { const xOffsetL = (opt.WS_TMB_LEFT ? thumbnailsWidth : 0) + (opt.DASH_LEFT ? dashWidth : 0); const xOffsetR = (opt.WS_TMB_RIGHT ? thumbnailsWidth : 0) + (opt.DASH_RIGHT ? dashWidth : 0); const yOffsetT = (opt.DASH_TOP ? dashHeight : 0) + (opt.SHOW_SEARCH_ENTRY ? searchHeight : 0); - const yOffsetB = (opt.DASH_BOTTOM ? dashHeight : 0); - const adWidth = opt.CENTER_APP_GRID ? (width - 2 * Math.max (xOffsetL, xOffsetR) - 4 * spacing) : (width - xOffsetL - xOffsetR - 4 * spacing); + const yOffsetB = opt.DASH_BOTTOM ? dashHeight : 0; + const adWidth = opt.CENTER_APP_GRID ? width - 2 * Math.max(xOffsetL, xOffsetR) - 4 * spacing : width - xOffsetL - xOffsetR - 4 * spacing; const adHeight = height - yOffsetT - yOffsetB - 4 * spacing; - const appDisplayX = opt.CENTER_APP_GRID ? ((width - adWidth) / 2) : (xOffsetL + 2 * spacing); + const appDisplayX = opt.CENTER_APP_GRID ? (width - adWidth) / 2 : xOffsetL + 2 * spacing; const appDisplayY = startY + yOffsetT + 2 * spacing; switch (state) { @@ -786,7 +799,7 @@ var ControlsManagerLayoutVertical = { return appDisplayBox; }, - vfunc_allocate: function(container, box) { + vfunc_allocate(container, box) { const childBox = new Clutter.ActorBox(); const { spacing } = this; @@ -794,7 +807,7 @@ var ControlsManagerLayoutVertical = { const monitor = Main.layoutManager.findMonitorForActor(this._container); const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor.index); const startX = workArea.x - monitor.x; - // if PANEL_MODE == 2 (overview only) the affectStruts property stays on false to avoid stuttering + // if PANEL_OVERVIEW_ONLY, the affectStruts property is set to false to avoid stuttering // therefore we need to add panel height to startY let startY = workArea.y - monitor.y + opt.START_Y_OFFSET; @@ -817,7 +830,7 @@ var ControlsManagerLayoutVertical = { // dash cloud be overridden by the Dash to Dock clone const dash = Main.overview.dash; - if (_dashIsDashToDock()) { + if (_Util.dashIsDashToDock()) { // if Dash to Dock replaced the default dash and its inteli-hide id disabled we need to compensate for affected startY if (!Main.overview.dash.get_parent()?.get_parent()?.get_parent()?._intellihideIsEnabled) { if (Main.panel.y === monitor.y) @@ -835,9 +848,8 @@ var ControlsManagerLayoutVertical = { [, dashHeight] = this._dash.get_preferred_height(dashWidth); dashWidth = Math.min(dashWidth, maxDashWidth); dashHeight = Math.min(dashHeight, height); - } else if (!opt.WS_TMB_FULL) { - this._dash.setMaxSize(width, maxDashHeight); + this._dash.setMaxSize(width, maxDashHeight); [, dashHeight] = this._dash.get_preferred_height(width); [, dashWidth] = this._dash.get_preferred_width(dashHeight); dashHeight = Math.min(dashHeight, maxDashHeight); @@ -845,46 +857,48 @@ var ControlsManagerLayoutVertical = { } } + const transitionParams = this._stateAdjustment.getStateTransitionParams(); + // Workspace Thumbnails let wsTmbWidth = 0; let wsTmbHeight = 0; if (this._workspacesThumbnails.visible) { - //const REDUCE_WS_TMB_IF_NEEDED = (this._searchController._searchActive && opt.CENTER_SEARCH_VIEW) || opt.CENTER_APP_GRID; - - const { expandFraction } = this._workspacesThumbnails; - const dashHeightReservation = (!opt.WS_TMB_FULL && !opt.DASH_VERTICAL) ? dashHeight : 0; - wsTmbHeight = opt.WS_TMB_FULL - ? height - spacing - : height - (opt.DASH_VERTICAL ? 0 : dashHeightReservation) - spacing; - - wsTmbWidth = this._workspacesThumbnails.get_preferred_custom_width(wsTmbHeight)[0]; - wsTmbWidth = Math.round(Math.min( - wsTmbWidth * expandFraction, - width * opt.MAX_THUMBNAIL_SCALE - )); + // const { expandFraction } = this._workspacesThumbnails; + const dashHeightReservation = !opt.WS_TMB_FULL && !opt.DASH_VERTICAL ? dashHeight : 0; + + let maxScale = opt.MAX_THUMBNAIL_SCALE; + if (!opt.MAX_THUMBNAIL_SCALE_STABLE) { + const initState = transitionParams.initialState === ControlsState.APP_GRID ? opt.MAX_THUMBNAIL_SCALE_APPGRID : opt.MAX_THUMBNAIL_SCALE; + const finalState = transitionParams.finalState === ControlsState.APP_GRID ? opt.MAX_THUMBNAIL_SCALE_APPGRID : opt.MAX_THUMBNAIL_SCALE; + maxScale = Util.lerp(initState, finalState, transitionParams.progress); + } - /*if (opt.REDUCE_WS_TMB_IF_NEEDED) { - const searchAllocation = this._searchController._searchResults._content.allocation; - const searchWidth = searchAllocation.x2 - searchAllocation.x1; - wsTmbWidth = Math.clamp((width - searchWidth) / 2 - spacing, width * 0.05, wsTmbWidth); - }*/ + wsTmbWidth = width * maxScale; + let totalTmbSpacing; + [totalTmbSpacing, wsTmbHeight] = this._workspacesThumbnails.get_preferred_custom_height(wsTmbWidth); + wsTmbHeight += totalTmbSpacing; - wsTmbHeight = Math.round(Math.min(this._workspacesThumbnails.get_preferred_custom_height(wsTmbWidth)[1], wsTmbHeight)); + const wsTmbHeightMax = height - dashHeightReservation; + + if (wsTmbHeight > wsTmbHeightMax) { + wsTmbHeight = wsTmbHeightMax; + wsTmbWidth = this._workspacesThumbnails.get_preferred_custom_width(wsTmbHeight)[1]; + } let wsTmbX; - if (opt.WS_TMB_RIGHT) { + if (opt.WS_TMB_RIGHT) wsTmbX = Math.round(startX + width - (opt.DASH_RIGHT ? dashWidth : 0) - wsTmbWidth - spacing / 2); - } else { + else wsTmbX = Math.round((opt.DASH_LEFT ? dashWidth : 0) + spacing / 2); - } + let wstOffset = (height - wsTmbHeight - (opt.DASH_VERTICAL ? 0 : dashHeightReservation)) / 2; - wstOffset = wstOffset - opt.WS_TMB_POSITION_ADJUSTMENT * (wstOffset - spacing / 2); - let wsTmbY = Math.round(startY + ((dashHeightReservation && opt.DASH_TOP) ? dashHeight : 0) + wstOffset); + wstOffset -= opt.WS_TMB_POSITION_ADJUSTMENT * (wstOffset - spacing / 2); + let wsTmbY = Math.round(startY + (dashHeightReservation && opt.DASH_TOP ? dashHeight : 0) + wstOffset); childBox.set_origin(wsTmbX, wsTmbY); - childBox.set_size(wsTmbWidth, wsTmbHeight); + childBox.set_size(Math.round(wsTmbWidth), Math.round(wsTmbHeight)); this._workspacesThumbnails.allocate(childBox); } @@ -903,23 +917,21 @@ var ControlsManagerLayoutVertical = { let dashX, dashY, offset; if (opt.DASH_RIGHT) dashX = width - dashWidth; - else if (opt.DASH_LEFT) { + else if (opt.DASH_LEFT) dashX = 0; - } + else if (opt.DASH_TOP) dashY = startY; else dashY = startY + height - dashHeight; if (!opt.DASH_VERTICAL) { - offset = (width - (((opt.WS_TMB_FULL || opt.CENTER_DASH_WS) && !this._xAlignCenter) ? wsTmbWidth : 0) - dashWidth) / 2; - offset = offset - opt.DASH_POSITION_ADJUSTMENT * (offset - spacing / 2); + offset = (width - ((opt.WS_TMB_FULL || opt.CENTER_DASH_WS) && !this._xAlignCenter ? wsTmbWidth : 0) - dashWidth) / 2; + offset -= opt.DASH_POSITION_ADJUSTMENT * (offset - spacing / 2); dashX = offset; if ((opt.WS_TMB_FULL || opt.CENTER_DASH_WS) && !this._xAlignCenter) { - if (opt.WS_TMB_RIGHT) { - //dashX = Math.min(dashX, width - dashWidth - (wsTmbWidth ? wsTmbWidth : 0)); - } else { + if (!opt.WS_TMB_RIGHT) { dashX = (wsTmbWidth ? wsTmbWidth : 0) + offset; dashX = Math.max(dashX, wsTmbWidth ? wsTmbWidth + spacing : 0); dashX = Math.min(dashX, width - dashWidth - spacing); @@ -927,11 +939,11 @@ var ControlsManagerLayoutVertical = { } if (opt.WS_TMB_FULL && !opt.CENTER_DASH_WS) { dashX = opt.WS_TMB_RIGHT - ? Math.min(width - wsTmbWidth - dashWidth, dashX + (wsTmbWidth) / 2 * (1 - Math.abs(opt.DASH_POSITION_ADJUSTMENT))) - : Math.max(wsTmbWidth, dashX - (wsTmbWidth) / 2 * (1 - Math.abs(opt.DASH_POSITION_ADJUSTMENT))); + ? Math.min(width - wsTmbWidth - dashWidth, dashX + wsTmbWidth / 2 * (1 - Math.abs(opt.DASH_POSITION_ADJUSTMENT))) + : Math.max(wsTmbWidth, dashX - wsTmbWidth / 2 * (1 - Math.abs(opt.DASH_POSITION_ADJUSTMENT))); } } else { - const offset = (height - dashHeight) / 2; + offset = (height - dashHeight) / 2; dashY = startY + (offset - opt.DASH_POSITION_ADJUSTMENT * offset); } @@ -940,13 +952,12 @@ var ControlsManagerLayoutVertical = { this._dash.allocate(childBox); } - availableHeight -= (opt.DASH_VERTICAL ? 0 : dashHeight + spacing); + availableHeight -= opt.DASH_VERTICAL ? 0 : dashHeight + spacing; let [searchHeight] = this._searchEntry.get_preferred_height(width - wsTmbWidth); // Workspaces let params = [box, workAreaBox, dashWidth, dashHeight, wsTmbWidth, searchHeight, startY]; - const transitionParams = this._stateAdjustment.getStateTransitionParams(); // Update cached boxes for (const state of Object.values(ControlsState)) { @@ -955,9 +966,9 @@ var ControlsManagerLayoutVertical = { } let workspacesBox; - if (!transitionParams.transitioning) { + if (!transitionParams.transitioning) workspacesBox = this._cachedWorkspaceBoxes.get(transitionParams.currentState); - } + if (!workspacesBox) { const initialBox = this._cachedWorkspaceBoxes.get(transitionParams.initialState); const finalBox = this._cachedWorkspaceBoxes.get(transitionParams.finalState); @@ -968,17 +979,14 @@ var ControlsManagerLayoutVertical = { // Search entry const searchXoffset = (opt.DASH_LEFT ? dashWidth : 0) + spacing + (opt.WS_TMB_RIGHT ? 0 : wsTmbWidth + spacing); - //let [searchHeight] = this._searchEntry.get_preferred_height(width - wsTmbWidth); // Y position under top Dash let searchEntryX, searchEntryY; - /*if (opt.OVERVIEW_MODE2 && !opt.DASH_TOP && !opt.WS_TMB_TOP) { - searchEntryY = 7; - } else*/ if (opt.DASH_TOP) { + if (opt.DASH_TOP) searchEntryY = startY + dashHeight - spacing; - } else { + else searchEntryY = startY; - } + searchEntryX = searchXoffset; let searchWidth = width - 2 * spacing - wsTmbWidth - (opt.DASH_VERTICAL ? dashWidth : 0); // xAlignCenter is given by wsBox @@ -996,24 +1004,21 @@ var ControlsManagerLayoutVertical = { availableHeight -= searchHeight + spacing; - // AppDisplay - state, box, workAreaBox, searchHeight, dashHeight, appGridBox, wsTmbWidth - //if (this._appDisplay.visible) { - - params = [box, workAreaBox, searchHeight, dashWidth, dashHeight, wsTmbWidth, startY]; // send startY, can be compensated - let appDisplayBox; - if (!transitionParams.transitioning) { - appDisplayBox = + // if (this._appDisplay.visible)... ? Can cause problems + params = [box, workAreaBox, searchHeight, dashWidth, dashHeight, wsTmbWidth, startY]; // send startY, can be corrected + let appDisplayBox; + if (!transitionParams.transitioning) { + appDisplayBox = this._getAppDisplayBoxForState(transitionParams.currentState, ...params); - } else { - const initialBox = + } else { + const initialBox = this._getAppDisplayBoxForState(transitionParams.initialState, ...params); - const finalBox = + const finalBox = this._getAppDisplayBoxForState(transitionParams.finalState, ...params); - appDisplayBox = initialBox.interpolate(finalBox, transitionParams.progress); - } - this._appDisplay.allocate(appDisplayBox); - //} + appDisplayBox = initialBox.interpolate(finalBox, transitionParams.progress); + } + this._appDisplay.allocate(appDisplayBox); // Search if (opt.CENTER_SEARCH_VIEW) { @@ -1028,31 +1033,30 @@ var ControlsManagerLayoutVertical = { this._searchController.allocate(childBox); this._runPostAllocation(); - } -} + }, +}; -var ControlsManagerLayoutHorizontal = { - _computeWorkspacesBoxForState: function(state, box, workAreaBox, dashWidth, dashHeight, thumbnailsHeight, searchHeight, startY) { +const ControlsManagerLayoutHorizontal = { + _computeWorkspacesBoxForState(state, box, workAreaBox, dashWidth, dashHeight, thumbnailsHeight, searchHeight, startY) { const workspaceBox = box.copy(); let [width, height] = workspaceBox.get_size(); - let { x1: startX/*, y1: startY*/ } = workAreaBox; + // let { x1: startX/* , y1: startY*/ } = workAreaBox; const { spacing } = this; - //const { expandFraction } = this._workspacesThumbnails; + // const { expandFraction } = this._workspacesThumbnails; const dash = Main.overview.dash; // including Dash to Dock and clones properties for compatibility - if (_dashIsDashToDock()) { + if (_Util.dashIsDashToDock()) { // Dash to Dock always affects workAreaBox - Main.layoutManager._trackedActors.forEach((actor) => { + Main.layoutManager._trackedActors.forEach(actor => { if (actor.affectsStruts && actor.actor.width === dash.width) { if (dash._isHorizontal) { // disabled inteli-hide don't need compensation // startY needs to be corrected in allocate() - if (dash.get_parent()?.get_parent()?.get_parent()?._intellihideIsEnabled) { + if (dash.get_parent()?.get_parent()?.get_parent()?._intellihideIsEnabled) height += dash.height; - } else if (opt.DASH_TOP) { + else if (opt.DASH_TOP) height += dash.height; - } } else { width += dash.width; } @@ -1064,7 +1068,7 @@ var ControlsManagerLayoutHorizontal = { switch (state) { case ControlsState.HIDDEN: - // if PANEL_MODE == 2 (overview only) the affectStruts property stays on false to avoid stuttering + // if PANEL_OVERVIEW_ONLY, the affectStruts property is set to false to avoid stuttering // therefore we added panel height to startY for the overview allocation, // but here we need to remove the correction since the panel will be in the hidden state if (opt.START_Y_OFFSET) { @@ -1091,28 +1095,28 @@ var ControlsManagerLayoutHorizontal = { } workspaceBox.set_size(...workAreaBox.get_size()); } else { - // in PANEL_MODE 2 panel don't affects workArea height (affectStruts === false), it needs to be compensated + // if PANEL_OVERVIEW_ONLY, panel doesn't affect workArea height (affectStruts === false), it is necessary to compensate height = opt.PANEL_POSITION_TOP ? height : height - Main.panel.height; searchHeight = opt.SHOW_SEARCH_ENTRY ? searchHeight : 0; - wWidth = width - - spacing - - (opt.DASH_VERTICAL ? dashWidth : 0) - - 4 * spacing; - wHeight = height - - (opt.DASH_VERTICAL ? spacing : (dashHeight ? dashHeight : 0)) - - (thumbnailsHeight ? thumbnailsHeight : 0) - - searchHeight - - 4 * spacing; + wWidth = width - + spacing - + (opt.DASH_VERTICAL ? dashWidth : 0) - + 4 * spacing; + wHeight = height - + (opt.DASH_VERTICAL ? spacing : dashHeight) - + thumbnailsHeight - + searchHeight - + 4 * spacing; const ratio = width / height; let wRatio = wWidth / wHeight; let scale = ratio / wRatio; if (scale > 1) { - wHeight = wHeight / scale; + wHeight /= scale; wWidth = wHeight * ratio; } else { - wWidth = wWidth * scale; + wWidth *= scale; wHeight = wWidth / ratio; } @@ -1141,8 +1145,8 @@ var ControlsManagerLayoutHorizontal = { this._xAlignCenter = true; } - wsBoxX = /*startX + */xOffset; - wsBoxY = Math.round(startY + yOffset) + wsBoxX = /* startX + */xOffset; + wsBoxY = Math.round(startY + yOffset); workspaceBox.set_origin(Math.round(wsBoxX), Math.round(wsBoxY)); workspaceBox.set_size(Math.round(wWidth), Math.round(wHeight)); } @@ -1151,25 +1155,24 @@ var ControlsManagerLayoutHorizontal = { return workspaceBox; }, - _getAppDisplayBoxForState: function(state, box, workAreaBox, searchHeight, dashWidth, dashHeight, thumbnailsHeight, startY) { + _getAppDisplayBoxForState(state, box, workAreaBox, searchHeight, dashWidth, dashHeight, thumbnailsHeight, startY) { const [width] = box.get_size(); const { x1: startX } = workAreaBox; - //const { y1: startY } = workAreaBox; + // const { y1: startY } = workAreaBox; let height = workAreaBox.get_height(); - // in PANEL_MODE 2 panel don't affects workArea height (affectStruts === false), it needs to be compensated - height = opt.PANEL_MODE === 2 ? height - Main.panel.height : height; const appDisplayBox = new Clutter.ActorBox(); const { spacing } = this; - const yOffsetT = (opt.WS_TMB_TOP ? thumbnailsHeight : 0) + (opt.DASH_TOP ? dashHeight : 0) + (opt.SHOW_SEARCH_ENTRY ? searchHeight : 0); + const yOffsetT = (opt.WS_TMB_TOP ? thumbnailsHeight : 0) + (opt.DASH_TOP ? dashHeight : 0) + (opt.SHOW_SEARCH_ENTRY ? searchHeight : 0) + 2 * spacing; const yOffsetB = (opt.WS_TMB_BOTTOM ? thumbnailsHeight : 0) + (opt.DASH_BOTTOM ? dashHeight : 0); - const xOffsetL = (opt.DASH_LEFT ? dashWidth : 0); - const xOffsetR = (opt.DASH_RIGHT ? dashWidth : 0); - const adWidth = opt.CENTER_APP_GRID ? (width - 2 * Math.max (xOffsetL, xOffsetR) - 4 * spacing) : (width - xOffsetL - xOffsetR - 4 * spacing); + const xOffsetL = opt.DASH_LEFT ? dashWidth : 0; + const xOffsetR = opt.DASH_RIGHT ? dashWidth : 0; + const hSpacing = xOffsetL + xOffsetR ? 2 * spacing : 0; + const adWidth = opt.CENTER_APP_GRID ? width - 2 * Math.max(xOffsetL, xOffsetR) - 2 * hSpacing : width - xOffsetL - xOffsetR - 2 * hSpacing; const adHeight = height - yOffsetT - yOffsetB - 4 * spacing; - const appDisplayX = opt.CENTER_APP_GRID ? ((width - adWidth) / 2) : (xOffsetL + 2 * spacing); - const appDisplayY = startY + yOffsetT + 2 * spacing; + const appDisplayX = opt.CENTER_APP_GRID ? (width - adWidth) / 2 : xOffsetL + hSpacing; + const appDisplayY = startY + yOffsetT + hSpacing; switch (state) { case ControlsState.HIDDEN: @@ -1202,7 +1205,7 @@ var ControlsManagerLayoutHorizontal = { return appDisplayBox; }, - vfunc_allocate: function(container, box) { + vfunc_allocate(container, box) { const childBox = new Clutter.ActorBox(); const { spacing } = this; @@ -1210,7 +1213,7 @@ var ControlsManagerLayoutHorizontal = { const monitor = Main.layoutManager.findMonitorForActor(this._container); const workArea = Main.layoutManager.getWorkAreaForMonitor(monitor.index); const startX = workArea.x - monitor.x; - // if PANEL_MODE == 2 (overview only) the affectStruts property stays on false to avoid stuttering + // if PANEL_OVERVIEW_ONLY, the affectStruts property is set to false to avoid stuttering // therefore we need to add panel height to startY let startY = workArea.y - monitor.y + opt.START_Y_OFFSET; const workAreaBox = new Clutter.ActorBox(); @@ -1220,7 +1223,7 @@ var ControlsManagerLayoutHorizontal = { box.x1 += startX; let [width, height] = box.get_size(); // if panel is at bottom position, - // compensate the height of the available box (the box size is calculated for top panel) + // compensate for the height of the available box (the box size is calculated for top panel) height = opt.PANEL_POSITION_TOP ? height : height - Main.panel.height; let availableHeight = height; @@ -1232,11 +1235,11 @@ var ControlsManagerLayoutHorizontal = { // dash cloud be overridden by the Dash to Dock clone const dash = Main.overview.dash; - if (_dashIsDashToDock()) { + if (_Util.dashIsDashToDock()) { // if Dash to Dock replaced the default dash and its inteli-hide is disabled we need to compensate for affected startY if (!Main.overview.dash.get_parent()?.get_parent()?.get_parent()?._intellihideIsEnabled) { - if (Main.panel.y === monitor.y) - startY = Main.panel.height + spacing; + // if (Main.panel.y === monitor.y) + // startY = Main.panel.height + spacing; } dashHeight = dash.height; dashWidth = dash.width; @@ -1251,7 +1254,6 @@ var ControlsManagerLayoutHorizontal = { [, dashWidth] = this._dash.get_preferred_width(dashHeight); dashHeight = Math.min(dashHeight, maxDashHeight); dashWidth = Math.min(dashWidth, width - spacing); - } else if (!opt.WS_TMB_FULL) { this._dash.setMaxSize(maxDashWidth, height); [, dashWidth] = this._dash.get_preferred_width(height); @@ -1263,44 +1265,53 @@ var ControlsManagerLayoutHorizontal = { let [searchHeight] = this._searchEntry.get_preferred_height(width); + const transitionParams = this._stateAdjustment.getStateTransitionParams(); + + // Workspace Thumbnails let wsTmbWidth = 0; let wsTmbHeight = 0; if (this._workspacesThumbnails.visible) { - const { expandFraction } = this._workspacesThumbnails; - const dashWidthReservation = (!opt.WS_TMB_FULL && opt.DASH_VERTICAL) ? dashWidth : 0; + // const { expandFraction } = this._workspacesThumbnails; + const dashWidthReservation = !opt.WS_TMB_FULL && opt.DASH_VERTICAL ? dashWidth : 0; + + let maxScale = opt.MAX_THUMBNAIL_SCALE; + if (!opt.MAX_THUMBNAIL_SCALE_STABLE) { + const initState = transitionParams.initialState === ControlsState.APP_GRID ? opt.MAX_THUMBNAIL_SCALE_APPGRID : opt.MAX_THUMBNAIL_SCALE; + const finalState = transitionParams.finalState === ControlsState.APP_GRID ? opt.MAX_THUMBNAIL_SCALE_APPGRID : opt.MAX_THUMBNAIL_SCALE; + maxScale = Util.lerp(initState, finalState, transitionParams.progress); + } - wsTmbWidth = opt.WS_TMB_FULL - ? width - : width - (opt.DASH_VERTICAL ? 0 : dashWidthReservation); + wsTmbHeight = height * maxScale; + let totalTmbSpacing; + [totalTmbSpacing, wsTmbWidth] = this._workspacesThumbnails.get_preferred_custom_width(wsTmbHeight); + wsTmbWidth += totalTmbSpacing; - wsTmbHeight = this._workspacesThumbnails.get_preferred_height(wsTmbWidth)[0]; - wsTmbHeight = Math.round(Math.min( - wsTmbHeight * expandFraction, - height * opt.MAX_THUMBNAIL_SCALE - )); + const wsTmbWidthMax = opt.WS_TMB_FULL + ? width + : width - (opt.DASH_VERTICAL ? 0 : dashWidthReservation); - wsTmbWidth = Math.round(Math.min(this._workspacesThumbnails.get_preferred_custom_width(wsTmbHeight)[1], wsTmbWidth)); + if (wsTmbWidth > wsTmbWidthMax) { + wsTmbWidth = wsTmbWidthMax; + wsTmbHeight = this._workspacesThumbnails.get_preferred_custom_height(wsTmbWidth)[1]; + } let wsTmbY; - if (opt.WS_TMB_TOP) { - wsTmbY = Math.round(startY + /*searchHeight + */(opt.DASH_TOP ? dashHeight : spacing / 2)); - } else { - //const boxY = workArea.y - monitor.y; // startY might be compensated - //wsTmbY = Math.round(boxY + height - (DASH_BOTTOM ? dashHeight : 0) - wsTmbHeight); + if (opt.WS_TMB_TOP) + wsTmbY = Math.round(startY + /* searchHeight + */(opt.DASH_TOP ? dashHeight : spacing / 2)); + else wsTmbY = Math.round(startY + height - (opt.DASH_BOTTOM ? dashHeight : 0) - wsTmbHeight); - } let wstOffset = (width - wsTmbWidth) / 2; - wstOffset = wstOffset - opt.WS_TMB_POSITION_ADJUSTMENT * wstOffset; + wstOffset -= opt.WS_TMB_POSITION_ADJUSTMENT * (wstOffset - spacing / 2); let wsTmbX = Math.round(Math.clamp( startX + wstOffset, - startX + (opt.DASH_LEFT ? dashWidthReservation + spacing / 2 : spacing / 2), - width - wsTmbWidth - startX - (opt.DASH_RIGHT ? dashWidthReservation + spacing / 2 : spacing / 2) + startX + (opt.DASH_LEFT ? dashWidthReservation : 0), + width - wsTmbWidth - startX - (opt.DASH_RIGHT ? dashWidthReservation : 0) )); childBox.set_origin(wsTmbX, wsTmbY); - childBox.set_size(wsTmbWidth, wsTmbHeight); + childBox.set_size(Math.round(wsTmbWidth), Math.round(wsTmbHeight)); this._workspacesThumbnails.allocate(childBox); @@ -1309,7 +1320,6 @@ var ControlsManagerLayoutHorizontal = { if (this._dash.visible) { - //const wMaxHeight = height - spacing - wsTmbHeight - 2 * spacing - (DASH_VERTICAL ? 0 : dashHeight + spacing); if (opt.WS_TMB_FULL && opt.DASH_VERTICAL) { const wMaxHeight = height - spacing - wsTmbHeight; this._dash.setMaxSize(maxDashWidth, wMaxHeight); @@ -1320,31 +1330,29 @@ var ControlsManagerLayoutHorizontal = { } let dashX, dashY, offset; - if (opt.DASH_RIGHT) { + if (opt.DASH_RIGHT) dashX = width - dashWidth; - } else if (opt.DASH_LEFT) { + else if (opt.DASH_LEFT) dashX = 0; - } else if (opt.DASH_TOP) { + else if (opt.DASH_TOP) dashY = startY; - } else { + else dashY = startY + height - dashHeight; - } + if (opt.DASH_VERTICAL) { if (opt.WS_TMB_FULL) { offset = (height - dashHeight - wsTmbHeight) / 2; if (opt.WS_TMB_TOP) { - offset = offset - opt.DASH_POSITION_ADJUSTMENT * (offset - spacing / 2); + offset -= opt.DASH_POSITION_ADJUSTMENT * (offset - spacing / 2); dashY = startY + offset + wsTmbHeight; - //dashY = Math.max(dashY, startY + wsTmbHeight); } else { - offset = offset - opt.DASH_POSITION_ADJUSTMENT * (offset - spacing / 2); + offset -= opt.DASH_POSITION_ADJUSTMENT * (offset - spacing / 2); dashY = startY + offset; - //dashY = Math.max(dashY, height - wsTmbHeight - dashHeight - 3 * spacing); } } else { offset = (height - dashHeight) / 2; - offset = offset - opt.DASH_POSITION_ADJUSTMENT * (offset - spacing / 2); + offset -= opt.DASH_POSITION_ADJUSTMENT * (offset - spacing / 2); dashY = startY + offset; } } else { @@ -1357,13 +1365,10 @@ var ControlsManagerLayoutHorizontal = { this._dash.allocate(childBox); } - availableHeight -= (opt.DASH_VERTICAL ? 0 : dashHeight); - - /*let [searchHeight] = this._searchEntry.get_preferred_height(width);*/ + availableHeight -= opt.DASH_VERTICAL ? 0 : dashHeight; // Workspaces let params = [box, workAreaBox, dashWidth, dashHeight, wsTmbHeight, searchHeight, startY]; - const transitionParams = this._stateAdjustment.getStateTransitionParams(); // Update cached boxes for (const state of Object.values(ControlsState)) { @@ -1372,9 +1377,9 @@ var ControlsManagerLayoutHorizontal = { } let workspacesBox; - if (!transitionParams.transitioning) { + if (!transitionParams.transitioning) workspacesBox = this._cachedWorkspaceBoxes.get(transitionParams.currentState); - } + if (!workspacesBox) { const initialBox = this._cachedWorkspaceBoxes.get(transitionParams.initialState); const finalBox = this._cachedWorkspaceBoxes.get(transitionParams.finalState); @@ -1385,17 +1390,14 @@ var ControlsManagerLayoutHorizontal = { // Search entry const searchXoffset = (opt.DASH_LEFT ? dashWidth : 0) + spacing; - //let [searchHeight] = this._searchEntry.get_preferred_height(width - wsTmbWidth); // Y position under top Dash let searchEntryX, searchEntryY; - /*if (opt.OVERVIEW_MODE2 && !opt.DASH_TOP && !opt.WS_TMB_TOP) { - searchEntryY = 7; - } else */if (opt.DASH_TOP) { + if (opt.DASH_TOP) searchEntryY = startY + (opt.WS_TMB_TOP ? wsTmbHeight : 0) + dashHeight - spacing; - } else { + else searchEntryY = startY + (opt.WS_TMB_TOP ? wsTmbHeight + spacing : 0); - } + searchEntryX = searchXoffset; let searchWidth = width - 2 * spacing - (opt.DASH_VERTICAL ? dashWidth : 0); // xAlignCenter is given by wsBox @@ -1413,23 +1415,21 @@ var ControlsManagerLayoutHorizontal = { availableHeight -= searchHeight + spacing; - // AppDisplay - state, box, workAreaBox, searchHeight, dashHeight, appGridBox, wsTmbWidth - //if (this._appDisplay.visible) { - params = [box, workAreaBox, searchHeight, dashWidth, dashHeight, wsTmbHeight, startY]; - let appDisplayBox; - if (!transitionParams.transitioning) { - appDisplayBox = + // if (this._appDisplay.visible)... ? Can cause problems + params = [box, workAreaBox, searchHeight, dashWidth, dashHeight, wsTmbHeight, startY]; + let appDisplayBox; + if (!transitionParams.transitioning) { + appDisplayBox = this._getAppDisplayBoxForState(transitionParams.currentState, ...params); - } else { - const initialBox = + } else { + const initialBox = this._getAppDisplayBoxForState(transitionParams.initialState, ...params); - const finalBox = + const finalBox = this._getAppDisplayBoxForState(transitionParams.finalState, ...params); - appDisplayBox = initialBox.interpolate(finalBox, transitionParams.progress); - } - this._appDisplay.allocate(appDisplayBox); - //} + appDisplayBox = initialBox.interpolate(finalBox, transitionParams.progress); + } + this._appDisplay.allocate(appDisplayBox); // Search if (opt.CENTER_SEARCH_VIEW) { @@ -1444,8 +1444,8 @@ var ControlsManagerLayoutHorizontal = { this._searchController.allocate(childBox); this._runPostAllocation(); - } -} + }, +}; // same copy of this function should be available in OverviewControls and WorkspacesView function _getFitModeForState(state) { |