2025-02-09 23:09:13 +01:00
/ * *
2025-02-09 23:13:53 +01:00
* V - Shell ( Vertical Workspaces )
2025-02-09 23:09:13 +01:00
* overviewControls . js
2025-02-09 23:13:53 +01:00
*
2025-02-09 23:09:13 +01:00
* @ author GdH < G - dH @ github . com >
* @ copyright 2022 - 2023
* @ license GPL - 3.0
*
* /
'use strict' ;
2025-02-09 23:16:18 +01:00
import GLib from 'gi://GLib' ;
import Clutter from 'gi://Clutter' ;
import St from 'gi://St' ;
import Meta from 'gi://Meta' ;
import Shell from 'gi://Shell' ;
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' ;
import * as Layout from 'resource:///org/gnome/shell/ui/layout.js' ;
import * as OverviewControls from 'resource:///org/gnome/shell/ui/overviewControls.js' ;
import * as WorkspacesView from 'resource:///org/gnome/shell/ui/workspacesView.js' ;
import * as Background from 'resource:///org/gnome/shell/ui/background.js' ;
import * as Util from 'resource:///org/gnome/shell/misc/util.js' ;
let Me ;
2025-02-09 23:13:53 +01:00
let opt ;
2025-02-09 23:16:18 +01:00
// gettext
let _ ;
const ControlsState = OverviewControls . ControlsState ;
const FitMode = WorkspacesView . FitMode ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:16:18 +01:00
const ANIMATION _TIME = Overview . ANIMATION _TIME ;
2025-02-09 23:13:53 +01:00
const DASH _MAX _SIZE _RATIO = 0.25 ;
2025-02-09 23:09:13 +01:00
let _originalSearchControllerSigId ;
let _searchControllerSigId ;
2025-02-09 23:13:53 +01:00
let _timeouts ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:16:18 +01:00
export const OverviewControlsModule = class {
constructor ( me ) {
Me = me ;
opt = Me . opt ;
_ = Me . gettext ;
2025-02-09 23:13:53 +01:00
2025-02-09 23:16:18 +01:00
this . _firstActivation = true ;
this . moduleEnabled = false ;
this . _overrides = null ;
2025-02-09 23:09:13 +01:00
}
2025-02-09 23:13:53 +01:00
2025-02-09 23:16:18 +01:00
cleanGlobals ( ) {
Me = null ;
2025-02-09 23:09:13 +01:00
opt = null ;
2025-02-09 23:16:18 +01:00
_ = null ;
2025-02-09 23:09:13 +01:00
}
2025-02-09 23:16:18 +01:00
update ( reset ) {
this . _removeTimeouts ( ) ;
this . moduleEnabled = true ;
const conflict = false ;
2025-02-09 23:13:53 +01:00
2025-02-09 23:16:18 +01:00
reset = reset || ! this . moduleEnabled || conflict ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:16:18 +01:00
// don't touch the original code if module disabled
if ( reset && ! this . _firstActivation ) {
this . _disableModule ( ) ;
} else if ( ! reset ) {
this . _firstActivation = false ;
this . _activateModule ( ) ;
}
if ( reset && this . _firstActivation )
console . debug ( ' OverviewControlsModule - Keeping untouched' ) ;
}
2025-02-09 23:13:53 +01:00
2025-02-09 23:16:18 +01:00
_activateModule ( ) {
if ( ! this . _overrides )
this . _overrides = new Me . Util . Overrides ( ) ;
_timeouts = { } ;
this . _replaceOnSearchChanged ( ) ;
this . _overrides . addOverride ( 'ControlsManager' , OverviewControls . ControlsManager . prototype , ControlsManagerCommon ) ;
if ( opt . ORIENTATION === Clutter . Orientation . VERTICAL )
this . _overrides . addOverride ( 'ControlsManagerLayout' , Main . overview . _overview . controls . layoutManager , ControlsManagerLayoutVertical ) ;
else
this . _overrides . addOverride ( 'ControlsManagerLayout' , Main . overview . _overview . controls . layoutManager , ControlsManagerLayoutHorizontal ) ;
this . _overrides . addOverride ( 'LayoutManager' , Layout . LayoutManager . prototype , LayoutManager ) ;
console . debug ( ' OverviewControlsModule - Activated' ) ;
}
_disableModule ( ) {
if ( this . _overrides )
this . _overrides . removeAll ( ) ;
this . _overrides = null ;
const reset = true ;
this . _replaceOnSearchChanged ( reset ) ;
Main . overview . _overview . _controls . _appDisplay . opacity = 255 ;
console . debug ( ' OverviewControlsModule - Disabled' ) ;
}
2025-02-09 23:09:13 +01:00
2025-02-09 23:16:18 +01:00
_removeTimeouts ( ) {
if ( _timeouts ) {
Object . values ( _timeouts ) . forEach ( t => {
if ( t )
GLib . source _remove ( t ) ;
} ) ;
_timeouts = null ;
2025-02-09 23:09:13 +01:00
}
2025-02-09 23:16:18 +01:00
}
_replaceOnSearchChanged ( reset ) {
const searchController = Main . overview . _overview . controls . _searchController ;
if ( reset ) {
if ( _searchControllerSigId ) {
searchController . disconnect ( _searchControllerSigId ) ;
_searchControllerSigId = 0 ;
}
if ( _originalSearchControllerSigId ) {
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)
if ( ! _originalSearchControllerSigId )
_originalSearchControllerSigId = GObject . signal _handler _find ( searchController , { signalId : 'notify' , detail : 'search-active' } ) ;
if ( _originalSearchControllerSigId )
searchController . block _signal _handler ( _originalSearchControllerSigId ) ;
if ( ! _searchControllerSigId )
_searchControllerSigId = searchController . connect ( 'notify::search-active' , ControlsManagerCommon . _onSearchChanged . bind ( Main . overview . _overview . controls ) ) ;
2025-02-09 23:09:13 +01:00
}
}
2025-02-09 23:16:18 +01:00
} ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:16:18 +01:00
const ControlsManagerCommon = {
2025-02-09 23:09:13 +01:00
// 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
2025-02-09 23:13:53 +01:00
/ * _ u p d a t e : f u n c t i o n ( ) {
2025-02-09 23:09:13 +01:00
...
} * /
// this function has duplicate in WorkspaceView so we use one function for both to avoid issues with syncing them
2025-02-09 23:13:53 +01:00
_getFitModeForState ( state ) {
2025-02-09 23:09:13 +01:00
return _getFitModeForState ( state ) ;
} ,
2025-02-09 23:13:53 +01:00
_updateThumbnailsBox ( ) {
2025-02-09 23:16:18 +01:00
const { currentState } = this . _stateAdjustment . getStateTransitionParams ( ) ;
2025-02-09 23:09:13 +01:00
const { shouldShow } = this . _thumbnailsBox ;
2025-02-09 23:16:18 +01:00
const thumbnailsBoxVisible = shouldShow &&
( ( currentState < ControlsState . APP _GRID && opt . SHOW _WS _TMB ) ||
( currentState > ControlsState . WINDOW _PICKER && opt . SHOW _WS _TMB _APPGRID ) ||
( currentState > ControlsState . WINDOW _PICKER && this . _searchController . searchActive && opt . SHOW _WS _TMB )
) ;
2025-02-09 23:09:13 +01:00
this . _thumbnailsBox . visible = thumbnailsBoxVisible ;
// this call should be directly in _update(), but it's used as a callback function and it would require to reconnect the signal
2025-02-09 23:16:18 +01:00
this . _updateOverview ( ) ;
2025-02-09 23:09:13 +01:00
} ,
// this function is pure addition to the original code and handles wsDisp transition to APP_GRID view
2025-02-09 23:16:18 +01:00
_updateOverview ( ) {
2025-02-09 23:09:13 +01:00
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 paramsForState = s => {
let opacity ;
switch ( s ) {
case ControlsState . HIDDEN :
case ControlsState . WINDOW _PICKER :
opacity = 255 ;
break ;
case ControlsState . APP _GRID :
opacity = 0 ;
break ;
default :
opacity = 255 ;
break ;
}
return { opacity } ;
} ;
let initialParams = paramsForState ( initialState ) ;
let finalParams = paramsForState ( finalState ) ;
let opacity = Math . round ( Util . lerp ( initialParams . opacity , finalParams . opacity , progress ) ) ;
2025-02-09 23:16:18 +01:00
let workspacesDisplayVisible = opacity !== 0 ;
2025-02-09 23:09:13 +01:00
// improve transition from search results to desktop
2025-02-09 23:13:53 +01:00
if ( finalState === 0 && this . _searchController . _searchResults . visible )
2025-02-09 23:09:13 +01:00
this . _searchController . hide ( ) ;
// reset Static Workspace window picker mode
2025-02-09 23:16:18 +01:00
if ( currentState === 0 && opt . OVERVIEW _MODE && opt . WORKSPACE _MODE )
2025-02-09 23:09:13 +01:00
opt . WORKSPACE _MODE = 0 ;
2025-02-09 23:13:53 +01:00
2025-02-09 23:09:13 +01:00
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
2025-02-09 23:13:53 +01:00
const ws = this . _workspacesDisplay . _workspacesViews [ global . display . get _primary _monitor ( ) ] ? . _workspaces [ this . _workspaceAdjustment . value ] ;
2025-02-09 23:09:13 +01:00
if ( ws )
ws . _background . opacity = opacity ;
}
// if ws preview background is disabled, animate tmb box and dash
const tmbBox = this . _thumbnailsBox ;
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)
2025-02-09 23:16:18 +01:00
const skipDash = Me . Util . dashNotDefault ( ) ;
2025-02-09 23:09:13 +01:00
// 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 ) ;
2025-02-09 23:13:53 +01:00
if ( ! Main . layoutManager . _startingUp && ( ( ! opt . SHOW _WS _PREVIEW _BG && ! opt . OVERVIEW _MODE2 ) || animateOverviewMode2 ) ) {
2025-02-09 23:09:13 +01:00
if ( ! tmbBox . _translationOriginal || Math . abs ( tmbBox . _translationOriginal [ 0 ] ) > 500 ) { // swipe gesture can call this calculation before tmbBox is finalized, giving nonsense width
2025-02-09 23:16:18 +01:00
const [ dashTranslationX , dashTranslationY , tmbTranslationX , tmbTranslationY , searchTranslationY ] = this . _getOverviewTranslations ( dash , tmbBox , searchEntryBin ) ;
2025-02-09 23:13:53 +01:00
tmbBox . _translationOriginal = [ tmbTranslationX , tmbTranslationY ] ;
dash . _translationOriginal = [ dashTranslationX , dashTranslationY ] ;
searchEntryBin . _translationOriginal = searchTranslationY ;
2025-02-09 23:09:13 +01:00
}
if ( finalState === 0 || initialState === 0 ) {
2025-02-09 23:13:53 +01:00
const prg = Math . abs ( ( finalState === 0 ? 0 : 1 ) - progress ) ;
2025-02-09 23:09:13 +01:00
tmbBox . translation _x = Math . round ( prg * tmbBox . _translationOriginal [ 0 ] ) ;
tmbBox . translation _y = Math . round ( prg * tmbBox . _translationOriginal [ 1 ] ) ;
if ( ! skipDash ) {
dash . translation _x = Math . round ( prg * dash . _translationOriginal [ 0 ] ) ;
dash . translation _y = Math . round ( prg * dash . _translationOriginal [ 1 ] ) ;
}
searchEntryBin . translation _y = Math . round ( prg * searchEntryBin . _translationOriginal ) ;
}
if ( progress === 1 ) {
tmbBox . _translationOriginal = 0 ;
2025-02-09 23:13:53 +01:00
if ( ! skipDash )
2025-02-09 23:09:13 +01:00
dash . _translationOriginal = 0 ;
2025-02-09 23:13:53 +01:00
2025-02-09 23:09:13 +01:00
searchEntryBin . _translationOriginal = 0 ;
}
} else if ( ! Main . layoutManager . _startingUp && ( tmbBox . translation _x || tmbBox . translation _y ) ) {
tmbBox . translation _x = 0 ;
tmbBox . translation _y = 0 ;
if ( ! skipDash ) {
dash . translation _x = 0 ;
dash . translation _y = 0 ;
}
searchEntryBin . translation _y = 0 ;
}
if ( ! Main . layoutManager . _startingUp ) {
2025-02-09 23:13:53 +01:00
if ( initialState === ControlsState . HIDDEN && finalState === ControlsState . APP _GRID )
2025-02-09 23:09:13 +01:00
this . _appDisplay . opacity = Math . round ( progress * 255 ) ;
2025-02-09 23:13:53 +01:00
else
2025-02-09 23:09:13 +01:00
this . _appDisplay . opacity = 255 - opacity ;
}
if ( currentState === ControlsState . APP _GRID ) {
// in app grid hide workspaces so they're not blocking app grid or ws thumbnails
this . _workspacesDisplay . scale _x = 0 ;
} else {
this . _workspacesDisplay . scale _x = 1 ;
}
this . _workspacesDisplay . setPrimaryWorkspaceVisible ( workspacesDisplayVisible ) ;
if ( ! this . dash . _isAbove && progress > 0 && opt . OVERVIEW _MODE2 ) {
// 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
2025-02-09 23:16:18 +01:00
if ( ! Me . Util . dashNotDefault ( ) )
2025-02-09 23:13:53 +01:00
this . set _child _above _sibling ( dash , null ) ;
2025-02-09 23:09:13 +01:00
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
2025-02-09 23:13:53 +01:00
this . set _child _above _sibling ( this . _thumbnailsBox , null ) ;
this . set _child _above _sibling ( this . _searchEntryBin , null ) ;
2025-02-09 23:16:18 +01:00
if ( ! Me . Util . dashNotDefault ( ) )
2025-02-09 23:09:13 +01:00
this . set _child _above _sibling ( this . dash , null ) ;
2025-02-09 23:13:53 +01:00
this . dash . _isAbove = true ;
2025-02-09 23:09:13 +01:00
} 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 ) ;
this . dash . _isAbove = false ;
}
} ,
// fix for upstream bug - appGrid.visible after transition from APP_GRID to HIDDEN
2025-02-09 23:13:53 +01:00
_updateAppDisplayVisibility ( stateTransitionParams = null ) {
2025-02-09 23:09:13 +01:00
if ( ! stateTransitionParams )
stateTransitionParams = this . _stateAdjustment . getStateTransitionParams ( ) ;
const { currentState } = stateTransitionParams ;
if ( this . dash . showAppsButton . checked )
this . _searchTransition = 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 =
currentState > ControlsState . HIDDEN &&
! this . _searchController . searchActive &&
! ( currentState === ControlsState . WINDOW _PICKER && ! opt . APP _GRID _ANIMATION ) &&
! this . _searchTransition ;
} ,
2025-02-09 23:13:53 +01:00
_onSearchChanged ( ) {
2025-02-09 23:09:13 +01:00
const { finalState , currentState } = this . _stateAdjustment . getStateTransitionParams ( ) ;
2025-02-09 23:13:53 +01:00
2025-02-09 23:09:13 +01:00
const { searchActive } = this . _searchController ;
const SIDE _CONTROLS _ANIMATION _TIME = 250 ; // OverviewControls.SIDE_CONTROLS_ANIMATION_TIME = Overview.ANIMATION_TIME = 250
2025-02-09 23:13:53 +01:00
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 ;
2025-02-09 23:09:13 +01:00
if ( ! searchActive ) {
this . _workspacesDisplay . reactive = true ;
this . _workspacesDisplay . setPrimaryWorkspaceVisible ( true ) ;
} else {
2025-02-09 23:16:18 +01:00
if ( opt . OVERVIEW _MODE2 && ! opt . WORKSPACE _MODE )
this . _searchController . _searchResults . _statusText . add _style _class _name ( 'search-statustext-om2' ) ;
else
this . _searchController . _searchResults . _statusText . remove _style _class _name ( 'search-statustext-om2' ) ;
2025-02-09 23:09:13 +01:00
this . _searchController . show ( ) ;
2025-02-09 23:13:53 +01:00
entry . visible = true ;
entry . opacity = 255 ;
2025-02-09 23:09:13 +01:00
}
2025-02-09 23:16:18 +01:00
if ( opt . SHOW _BG _IN _OVERVIEW && this . _bgManagers )
this . _updateBackground ( this . _bgManagers [ 0 ] ) ;
2025-02-09 23:09:13 +01:00
this . _searchTransition = true ;
this . _searchController . _searchResults . translation _x = 0 ;
this . _searchController . _searchResults . translation _y = 0 ;
2025-02-09 23:13:53 +01:00
this . _searchController . opacity = 255 ;
2025-02-09 23:09:13 +01:00
this . _searchController . visible = true ;
2025-02-09 23:16:18 +01:00
if ( opt . SEARCH _VIEW _ANIMATION && ! [ 4 , 8 ] . includes ( opt . WS _TMB _POSITION ) ) {
2025-02-09 23:09:13 +01:00
this . _updateAppDisplayVisibility ( ) ;
2025-02-09 23:16:18 +01:00
this . layoutManager . _searchController . _searchResults . _statusBin . opacity = 1 ;
2025-02-09 23:09:13 +01:00
this . _searchController . opacity = searchActive ? 255 : 0 ;
2025-02-09 23:13:53 +01:00
let translationX = 0 ;
let translationY = 0 ;
2025-02-09 23:09:13 +01:00
const geometry = global . display . get _monitor _geometry ( global . display . get _primary _monitor ( ) ) ;
2025-02-09 23:16:18 +01:00
switch ( opt . SEARCH _VIEW _ANIMATION ) {
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 ;
2025-02-09 23:09:13 +01:00
}
if ( searchActive ) {
2025-02-09 23:13:53 +01:00
this . _searchController . _searchResults . translation _x = translationX ;
this . _searchController . _searchResults . translation _y = translationY ;
2025-02-09 23:09:13 +01:00
} else {
this . _searchController . _searchResults . translation _x = 0 ;
this . _searchController . _searchResults . translation _y = 0 ;
}
this . _searchController . _searchResults . ease ( {
2025-02-09 23:13:53 +01:00
translation _x : searchActive ? 0 : translationX ,
translation _y : searchActive ? 0 : translationY ,
2025-02-09 23:09:13 +01:00
duration : SIDE _CONTROLS _ANIMATION _TIME ,
mode : Clutter . AnimationMode . EASE _OUT _QUAD ,
onComplete : ( ) => {
this . _searchController . visible = searchActive ;
this . _searchTransition = false ;
2025-02-09 23:16:18 +01:00
this . layoutManager . _searchController . _searchResults . _statusBin . opacity = 255 ;
2025-02-09 23:13:53 +01:00
} ,
2025-02-09 23:09:13 +01:00
} ) ;
this . _workspacesDisplay . opacity = 255 ;
} else {
this . _appDisplay . ease ( {
2025-02-09 23:13:53 +01:00
opacity : searchActive || currentState < 2 ? 0 : 255 ,
2025-02-09 23:09:13 +01:00
duration : SIDE _CONTROLS _ANIMATION _TIME / 2 ,
mode : Clutter . AnimationMode . EASE _OUT _QUAD ,
2025-02-09 23:16:18 +01:00
onComplete : ( ) => {
this . _updateAppDisplayVisibility ( ) ;
} ,
2025-02-09 23:09:13 +01:00
} ) ;
this . _workspacesDisplay . setPrimaryWorkspaceVisible ( true ) ;
2025-02-09 23:13:53 +01:00
this . _searchController . opacity = searchActive ? 0 : 255 ;
2025-02-09 23:09:13 +01:00
this . _searchController . ease ( {
opacity : searchActive ? 255 : 0 ,
2025-02-09 23:16:18 +01:00
duration : searchActive ? SIDE _CONTROLS _ANIMATION _TIME : 0 ,
2025-02-09 23:09:13 +01:00
mode : Clutter . AnimationMode . EASE _OUT _QUAD ,
onComplete : ( ) => ( this . _searchController . visible = searchActive ) ,
} ) ;
}
// reuse already tuned overview transition, just replace APP_GRID with the search view
2025-02-09 23:13:53 +01:00
if ( ! ( opt . OVERVIEW _MODE2 && ! opt . WORKSPACE _MODE ) && ! Main . overview . _animationInProgress && finalState !== ControlsState . HIDDEN && ! this . dash . showAppsButton . checked ) {
2025-02-09 23:16:18 +01:00
Main . overview . _overview . _controls . layoutManager . _searchController . _searchResults . _content . remove _style _class _name ( 'search-section-content-bg-om2' ) ;
Main . overview . _overview . _controls . layoutManager . _searchController . _searchResults . _content . add _style _class _name ( 'search-section-content-bg' ) ;
2025-02-09 23:13:53 +01:00
Main . overview . searchEntry . remove _style _class _name ( 'search-entry-om2' ) ;
2025-02-09 23:16:18 +01:00
const duration = opt . SEARCH _VIEW _ANIMATION ? 150 : 0 ;
2025-02-09 23:09:13 +01:00
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
2025-02-09 23:16:18 +01:00
duration : searchActive ? duration : SIDE _CONTROLS _ANIMATION _TIME ,
2025-02-09 23:09:13 +01:00
mode : Clutter . AnimationMode . EASE _OUT _QUAD ,
onComplete : ( ) => {
this . _workspacesDisplay . setPrimaryWorkspaceVisible ( ! searchActive ) ;
} ,
} ) ;
2025-02-09 23:13:53 +01:00
} 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
2025-02-09 23:16:18 +01:00
Main . overview . _overview . _controls . layoutManager . _searchController . _searchResults . _content . remove _style _class _name ( 'search-section-content-bg' ) ;
Main . overview . _overview . _controls . layoutManager . _searchController . _searchResults . _content . add _style _class _name ( 'search-section-content-bg-om2' ) ;
2025-02-09 23:13:53 +01:00
Main . overview . searchEntry . add _style _class _name ( 'search-entry-om2' ) ;
} else {
2025-02-09 23:16:18 +01:00
Main . overview . _overview . _controls . layoutManager . _searchController . _searchResults . _content . add _style _class _name ( 'search-section-content-bg' ) ;
Main . overview . _overview . _controls . layoutManager . _searchController . _searchResults . _content . remove _style _class _name ( 'search-section-content-bg-om2' ) ;
2025-02-09 23:13:53 +01:00
Main . overview . searchEntry . remove _style _class _name ( 'search-entry-om2' ) ;
2025-02-09 23:09:13 +01:00
}
} ,
2025-02-09 23:13:53 +01:00
async runStartupAnimation ( callback ) {
2025-02-09 23:09:13 +01:00
this . _ignoreShowAppsButtonToggle = true ;
2025-02-09 23:16:18 +01:00
this . prepareToEnterOverview ( ) ;
2025-02-09 23:09:13 +01:00
this . _stateAdjustment . value = ControlsState . HIDDEN ;
this . _stateAdjustment . ease ( ControlsState . WINDOW _PICKER , {
duration : ANIMATION _TIME ,
mode : Clutter . AnimationMode . EASE _OUT _QUAD ,
} ) ;
this . dash . showAppsButton . checked = false ;
this . _ignoreShowAppsButtonToggle = false ;
// Set the opacity here to avoid a 1-frame flicker
2025-02-09 23:16:18 +01:00
this . opacity = 1 ;
this . _appDisplay . opacity = 1 ;
2025-02-09 23:09:13 +01:00
// We can't run the animation before the first allocation happens
await this . layout _manager . ensureAllocation ( ) ;
2025-02-09 23:16:18 +01:00
this . _setBackground ( ) ;
Main . panel . opacity = 255 ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:16:18 +01:00
const STARTUP _ANIMATION _TIME = 500 ;
2025-02-09 23:09:13 +01:00
// Opacity
this . ease ( {
2025-02-09 23:16:18 +01:00
opacity : opt . STARTUP _STATE === 1 ? 0 : 255 ,
2025-02-09 23:09:13 +01:00
duration : STARTUP _ANIMATION _TIME ,
mode : Clutter . AnimationMode . LINEAR ,
onComplete : ( ) => {
// part of the workaround for stuttering first app grid animation
this . _appDisplay . visible = true ;
2025-02-09 23:13:53 +01:00
} ,
2025-02-09 23:09:13 +01:00
} ) ;
const dash = this . dash ;
const tmbBox = this . _thumbnailsBox ;
// Set the opacity here to avoid a 1-frame flicker
dash . opacity = 0 ;
for ( const view of this . _workspacesDisplay . _workspacesViews ) {
if ( view . _monitorIndex !== global . display . get _primary _monitor ( ) )
view . _thumbnails . opacity = 0 ;
}
const searchEntryBin = this . _searchEntryBin ;
2025-02-09 23:16:18 +01:00
const [ dashTranslationX , dashTranslationY , tmbTranslationX , tmbTranslationY , searchTranslationY ] =
this . _getOverviewTranslations ( dash , tmbBox , searchEntryBin ) ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:13:53 +01:00
const onComplete = function ( ) {
2025-02-09 23:09:13 +01:00
// running init callback again causes issues (multiple connections)
2025-02-09 23:16:18 +01:00
if ( ! Main . overview . _startupInitComplete )
2025-02-09 23:09:13 +01:00
callback ( ) ;
2025-02-09 23:16:18 +01:00
const appDisplayModule = Me . Modules . appDisplayModule ;
if ( ! appDisplayModule . moduleEnabled )
this . _finishStartupSequence ( ) ;
else
this . _realizeAppDisplayAndFinishSequence ( ) ;
Main . overview . _startupInitComplete = true ;
2025-02-09 23:09:13 +01:00
} . bind ( this ) ;
2025-02-09 23:16:18 +01:00
if ( dash . visible && ! Me . Util . dashNotDefault ( ) ) {
2025-02-09 23:13:53 +01:00
dash . translation _x = dashTranslationX ;
dash . translation _y = dashTranslationY ;
2025-02-09 23:09:13 +01:00
dash . opacity = 255 ;
dash . ease ( {
translation _x : 0 ,
translation _y : 0 ,
delay : STARTUP _ANIMATION _TIME / 2 ,
duration : STARTUP _ANIMATION _TIME ,
mode : Clutter . AnimationMode . EASE _OUT _QUAD ,
2025-02-09 23:16:18 +01:00
onComplete ,
2025-02-09 23:09:13 +01:00
} ) ;
} else {
// 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
2025-02-09 23:13:53 +01:00
_timeouts . startupAnim2 = GLib . timeout _add (
2025-02-09 23:09:13 +01:00
GLib . PRIORITY _DEFAULT ,
// delay + animation time
2025-02-09 23:13:53 +01:00
STARTUP _ANIMATION _TIME * 2 * St . Settings . get ( ) . slow _down _factor ,
2025-02-09 23:09:13 +01:00
( ) => {
onComplete ( ) ;
2025-02-09 23:16:18 +01:00
Main . overview . _startupInitComplete = true ;
2025-02-09 23:13:53 +01:00
_timeouts . startupAnim2 = 0 ;
2025-02-09 23:09:13 +01:00
return GLib . SOURCE _REMOVE ;
}
) ;
}
if ( searchEntryBin . visible ) {
2025-02-09 23:13:53 +01:00
searchEntryBin . translation _y = searchTranslationY ;
2025-02-09 23:09:13 +01:00
searchEntryBin . ease ( {
translation _y : 0 ,
delay : STARTUP _ANIMATION _TIME / 2 ,
duration : STARTUP _ANIMATION _TIME ,
mode : Clutter . AnimationMode . EASE _OUT _QUAD ,
} ) ;
}
if ( tmbBox . visible ) {
2025-02-09 23:13:53 +01:00
tmbBox . translation _x = tmbTranslationX ;
tmbBox . translation _y = tmbTranslationY ;
2025-02-09 23:09:13 +01:00
tmbBox . ease ( {
translation _x : 0 ,
translation _y : 0 ,
delay : STARTUP _ANIMATION _TIME / 2 ,
duration : STARTUP _ANIMATION _TIME ,
mode : Clutter . AnimationMode . EASE _OUT _QUAD ,
} ) ;
}
// upstream bug - following animation will be cancelled, don't know where
// needs further investigation
const workspacesViews = this . _workspacesDisplay . _workspacesViews ;
if ( workspacesViews . length > 1 ) {
for ( const view of workspacesViews ) {
if ( view . _monitorIndex !== global . display . get _primary _monitor ( ) && view . _thumbnails . visible ) {
2025-02-09 23:13:53 +01:00
const secTmbBox = view . _thumbnails ;
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 ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:13:53 +01:00
secTmbBox . opacity = 255 ;
secTmbBox . ease ( {
2025-02-09 23:09:13 +01:00
translation _y : 0 ,
delay : STARTUP _ANIMATION _TIME / 2 ,
duration : STARTUP _ANIMATION _TIME ,
mode : Clutter . AnimationMode . EASE _OUT _QUAD ,
} ) ;
}
}
}
} ,
2025-02-09 23:16:18 +01:00
_realizeAppDisplayAndFinishSequence ( ) {
const appDisplayModule = Me . Modules . appDisplayModule ;
// realize app grid for smoother first animation
appDisplayModule . _updateAppGrid ( false , this . _finishStartupSequence . bind ( this ) ) ;
} ,
_finishStartupSequence ( ) {
if ( ! this . _bgManagers )
this . _setBackground ( ) ;
/ * i f ( M e . U t i l . d a s h I s D a s h T o D o c k ( ) )
return ; * /
_timeouts . finishStartup = GLib . idle _add (
GLib . PRIORITY _LOW , ( ) => {
this . _appDisplay . opacity = 255 ;
if ( opt . STARTUP _STATE === 1 ) {
Main . overview . hide ( ) ;
} else if ( opt . STARTUP _STATE === 2 ) {
Main . overview . show ( 2 ) ; // just because of DtD, because we skipped startup animation
this . dash . showAppsButton . checked = true ;
} else if ( ! opt . STARTUP _STATE && Me . Util . dashNotDefault ( ) ) {
Main . overview . show ( ) ;
}
_timeouts . finishStartup = 0 ;
return GLib . SOURCE _REMOVE ;
}
) ;
} ,
setInitialTranslations ( ) {
const dash = this . dash ;
const tmbBox = this . _thumbnailsBox ;
const searchEntryBin = this . _searchEntryBin ;
const [ dashTranslationX , dashTranslationY , tmbTranslationX , tmbTranslationY , searchTranslationY ] =
this . _getOverviewTranslations ( dash , tmbBox , searchEntryBin ) ;
if ( ! Me . Util . dashNotDefault ( ) ) {
dash . translation _x = dashTranslationX ;
dash . translation _y = dashTranslationY ;
}
tmbBox . translation _x = tmbTranslationX ;
tmbBox . translation _y = tmbTranslationY ;
searchEntryBin . translation _y = searchTranslationY ;
} ,
_getOverviewTranslations ( dash , tmbBox , searchEntryBin ) {
// const tmbBox = Main.overview._overview._controls._thumbnailsBox;
const animationsDisabled = ! St . Settings . get ( ) . enable _animations || ( opt . SHOW _WS _PREVIEW _BG && ! opt . OVERVIEW _MODE2 ) ;
if ( animationsDisabled )
return [ 0 , 0 , 0 , 0 , 0 ] ;
let searchTranslationY = 0 ;
if ( searchEntryBin . visible ) {
const offset = ( dash . visible && ( ! opt . DASH _VERTICAL ? dash . height + 12 : 0 ) ) +
( opt . WS _TMB _TOP ? tmbBox . height + 12 : 0 ) ;
searchTranslationY = - searchEntryBin . height - offset - 30 ;
}
let tmbTranslationX = 0 ;
let tmbTranslationY = 0 ;
let offset ;
if ( tmbBox . visible ) {
const tmbWidth = tmbBox . width === Infinity ? 0 : tmbBox . width ;
const tmbHeight = tmbBox . height === Infinity ? 0 : tmbBox . height ;
switch ( opt . WS _TMB _POSITION ) {
case 3 : // left
offset = 10 + ( dash ? . visible && opt . DASH _LEFT ? dash . width : 0 ) ;
tmbTranslationX = - tmbWidth - offset ;
tmbTranslationY = 0 ;
break ;
case 1 : // right
offset = 10 + ( dash ? . visible && opt . DASH _RIGHT ? dash . width : 0 ) ;
tmbTranslationX = tmbWidth + offset ;
tmbTranslationY = 0 ;
break ;
case 0 : // top
offset = 10 + ( dash ? . visible && opt . DASH _TOP ? dash . height : 0 ) + Main . panel . height ;
tmbTranslationX = 0 ;
tmbTranslationY = - tmbHeight - offset ;
break ;
case 2 : // bottom
offset = 10 + ( dash ? . visible && opt . DASH _BOTTOM ? dash . height : 0 ) + Main . panel . height ; // just for case the panel is at bottom
tmbTranslationX = 0 ;
tmbTranslationY = tmbHeight + offset ;
break ;
}
}
let dashTranslationX = 0 ;
let dashTranslationY = 0 ;
let position = opt . DASH _POSITION ;
// if DtD replaced the original Dash, read its position
if ( Me . Util . dashIsDashToDock ( ) )
position = dash . _position ;
if ( dash ? . visible ) {
const dashWidth = dash . width === Infinity ? 0 : dash . width ;
const dashHeight = dash . height === Infinity ? 0 : dash . height ;
switch ( position ) {
case 0 : // top
dashTranslationX = 0 ;
dashTranslationY = - dashHeight - dash . margin _bottom - Main . panel . height ;
break ;
case 1 : // right
dashTranslationX = dashWidth ;
dashTranslationY = 0 ;
break ;
case 2 : // bottom
dashTranslationX = 0 ;
dashTranslationY = dashHeight + dash . margin _bottom + Main . panel . height ;
break ;
case 3 : // left
dashTranslationX = - dashWidth ;
dashTranslationY = 0 ;
break ;
}
}
return [ dashTranslationX , dashTranslationY , tmbTranslationX , tmbTranslationY , searchTranslationY ] ;
} ,
2025-02-09 23:13:53 +01:00
animateToOverview ( state , callback ) {
2025-02-09 23:09:13 +01:00
this . _ignoreShowAppsButtonToggle = true ;
this . _searchTransition = false ;
this . _stateAdjustment . value = ControlsState . HIDDEN ;
// building window thumbnails takes some time and with many windows on the workspace
// the time can be close to or longer than ANIMATION_TIME
// 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
2025-02-09 23:13:53 +01:00
let delay = 0 ;
if ( opt . DELAY _OVERVIEW _ANIMATION )
delay = global . display . get _tab _list ( 0 , global . workspace _manager . get _active _workspace ( ) ) . length * 3 ;
2025-02-09 23:09:13 +01:00
this . _stateAdjustment . ease ( state , {
delay ,
2025-02-09 23:13:53 +01:00
duration : 250 , // Overview.ANIMATION_TIME,
2025-02-09 23:09:13 +01:00
mode : Clutter . AnimationMode . EASE _OUT _QUAD ,
onStopped : ( ) => {
if ( callback )
callback ( ) ;
} ,
} ) ;
this . dash . showAppsButton . checked =
state === ControlsState . APP _GRID ;
this . _ignoreShowAppsButtonToggle = false ;
} ,
2025-02-09 23:16:18 +01:00
_setBackground ( reset = false ) {
if ( this . _bgManagers ) {
this . _bgManagers . forEach ( bg => {
Main . overview . _overview . _controls . _stateAdjustment . disconnect ( bg . _fadeSignal ) ;
bg . destroy ( ) ;
} ) ;
}
// if (!SHOW_BG_IN_OVERVIEW && !SHOW_WS_PREVIEW_BG) the background is used for static transition from wallpaper to empty bg in the overview
if ( reset || ( ! opt . SHOW _BG _IN _OVERVIEW && opt . SHOW _WS _PREVIEW _BG ) ) {
delete this . _bgManagers ;
return ;
}
this . _bgManagers = [ ] ;
for ( const monitor of Main . layoutManager . monitors ) {
const bgManager = new Background . BackgroundManager ( {
monitorIndex : monitor . index ,
container : Main . layoutManager . overviewGroup ,
vignette : true ,
} ) ;
bgManager . backgroundActor . content . vignette _sharpness = 0 ;
bgManager . backgroundActor . content . brightness = 1 ;
bgManager . _fadeSignal = Main . overview . _overview . _controls . _stateAdjustment . connect ( 'notify::value' , v => {
this . _updateBackground ( bgManager , v . value , v ) ;
} ) ;
if ( monitor . index === global . display . get _primary _monitor ( ) ) {
bgManager . _primary = true ;
this . _bgManagers . unshift ( bgManager ) ; // primary monitor first
} else {
bgManager . _primary = false ;
this . _bgManagers . push ( bgManager ) ;
}
}
} ,
_updateBackground ( bgManager , stateValue = 2 , stateAdjustment = null ) {
// Blur My Shell extension destroys all background actors in the overview and doesn't care about consequences
if ( this . _bgManagers [ 0 ] && ! Main . layoutManager . overviewGroup . get _children ( ) . includes ( this . _bgManagers [ 0 ] . backgroundActor ) ) {
Main . notifyError ( ` [ ${ Me . metadata . name } ] ` , _ ( 'Overview background crashed!\nIf you are using Blur My Shell, disable overview blur in its settings and re-enable V-Shell Overview Background to avoid visual glitches.' ) ) ;
// remove and disconnect our destroyed backgrounds to avoid more errors
this . _setBackground ( true ) ;
return ;
}
const finalState = stateAdjustment ? . getStateTransitionParams ( ) . finalState ;
if ( ! opt . SHOW _BG _IN _OVERVIEW && ! opt . SHOW _WS _PREVIEW _BG ) {
// if no bg shown in the overview, fade out the wallpaper
if ( ! ( opt . OVERVIEW _MODE2 && opt . WORKSPACE _MODE && finalState === 1 ) )
bgManager . backgroundActor . opacity = Util . lerp ( 255 , 0 , Math . min ( stateValue , 1 ) ) ;
} else {
let VIGNETTE , BRIGHTNESS , bgValue ;
if ( opt . OVERVIEW _MODE2 && stateValue <= 1 && ! opt . WORKSPACE _MODE ) {
VIGNETTE = 0 ;
BRIGHTNESS = 1 ;
bgValue = stateValue ;
} else {
VIGNETTE = 0.2 ;
BRIGHTNESS = opt . OVERVIEW _BG _BRIGHTNESS ;
if ( opt . OVERVIEW _MODE2 && stateValue > 1 && ! opt . WORKSPACE _MODE )
bgValue = stateValue - 1 ;
else
bgValue = stateValue ;
}
let blurEffect = bgManager . backgroundActor . get _effect ( 'blur' ) ;
if ( ! blurEffect ) {
blurEffect = new Shell . BlurEffect ( {
brightness : 1 ,
sigma : 0 ,
mode : Shell . BlurMode . ACTOR ,
} ) ;
bgManager . backgroundActor . add _effect _with _name ( 'blur' , blurEffect ) ;
}
const searchActive = Main . overview . _overview . controls . _searchController . searchActive ;
if ( searchActive )
BRIGHTNESS = opt . SEARCH _BG _BRIGHTNESS ;
bgManager . backgroundActor . content . vignette _sharpness = VIGNETTE ;
bgManager . backgroundActor . content . brightness = BRIGHTNESS ;
let vignetteInit , brightnessInit ; // , sigmaInit;
if ( opt . SHOW _BG _IN _OVERVIEW && opt . SHOW _WS _PREVIEW _BG ) {
vignetteInit = VIGNETTE ;
brightnessInit = BRIGHTNESS ;
// sigmaInit = opt.OVERVIEW_BG_BLUR_SIGMA;
} else {
vignetteInit = 0 ;
brightnessInit = 1 ;
// sigmaInit = 0;
}
if ( opt . OVERVIEW _MODE2 && ! opt . WORKSPACE _MODE ) {
bgManager . backgroundActor . content . vignette _sharpness = Util . lerp ( vignetteInit , VIGNETTE , bgValue ) ;
bgManager . backgroundActor . content . brightness = Util . lerp ( brightnessInit , BRIGHTNESS , bgValue ) ;
} else {
bgManager . backgroundActor . content . vignette _sharpness = Util . lerp ( vignetteInit , VIGNETTE , Math . min ( stateValue , 1 ) ) ;
bgManager . backgroundActor . content . brightness = Util . lerp ( brightnessInit , BRIGHTNESS , Math . min ( stateValue , 1 ) ) ;
}
if ( opt . OVERVIEW _BG _BLUR _SIGMA || opt . APP _GRID _BG _BLUR _SIGMA ) {
// reduce number of steps of blur transition to improve performance
const step = opt . SMOOTH _BLUR _TRANSITIONS ? 0.05 : 0.2 ;
const progress = stateValue - ( stateValue % step ) ;
if ( opt . SHOW _WS _PREVIEW _BG && stateValue < 1 && ! searchActive ) { // no need to animate transition, unless appGrid state is involved, static bg is covered by the ws preview bg
if ( blurEffect . sigma !== opt . OVERVIEW _BG _BLUR _SIGMA )
blurEffect . sigma = opt . OVERVIEW _BG _BLUR _SIGMA ;
} else if ( stateValue < 1 && ! searchActive && ! ( opt . OVERVIEW _MODE2 && ! opt . WORKSPACE _MODE ) ) {
const sigma = Math . round ( Util . lerp ( 0 , opt . OVERVIEW _BG _BLUR _SIGMA , progress ) ) ;
if ( sigma !== blurEffect . sigma )
blurEffect . sigma = sigma ;
} else if ( stateValue < 1 && ! searchActive && ( opt . OVERVIEW _MODE2 && ! opt . WORKSPACE _MODE && blurEffect . sigma ) ) {
const sigma = Math . round ( Util . lerp ( 0 , opt . OVERVIEW _BG _BLUR _SIGMA , progress ) ) ;
if ( sigma !== blurEffect . sigma )
blurEffect . sigma = sigma ;
} else if ( stateValue > 1 && ! searchActive && ( opt . OVERVIEW _MODE2 && ! opt . WORKSPACE _MODE && finalState === 1 ) ) {
const sigma = Math . round ( Util . lerp ( 0 , opt . OVERVIEW _BG _BLUR _SIGMA , progress % 1 ) ) ;
if ( sigma !== blurEffect . sigma )
blurEffect . sigma = sigma ;
} else if ( ( stateValue > 1 && bgManager . _primary ) || searchActive ) {
const sigma = Math . round ( Util . lerp ( opt . OVERVIEW _BG _BLUR _SIGMA , opt . APP _GRID _BG _BLUR _SIGMA , progress % 1 ) ) ;
if ( sigma !== blurEffect . sigma )
blurEffect . sigma = sigma ;
} else if ( stateValue === 1 && ! ( opt . OVERVIEW _MODE2 && ! opt . WORKSPACE _MODE ) ) {
blurEffect . sigma = opt . OVERVIEW _BG _BLUR _SIGMA ;
} else if ( stateValue === 0 || ( stateValue === 1 && ( opt . OVERVIEW _MODE2 && ! opt . WORKSPACE _MODE ) ) ) {
blurEffect . sigma = 0 ;
}
}
}
} ,
2025-02-09 23:13:53 +01:00
} ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:13:53 +01:00
const ControlsManagerLayoutVertical = {
2025-02-09 23:16:18 +01:00
_computeWorkspacesBoxForState ( state , box , workAreaBox , dashWidth , dashHeight , thumbnailsWidth , thumbnailsHeight , searchHeight , startY ) {
// in case the function is called from the DtD
if ( startY === undefined ) {
workAreaBox = box ;
}
2025-02-09 23:09:13 +01:00
const workspaceBox = box . copy ( ) ;
let [ width , height ] = workspaceBox . get _size ( ) ;
const { spacing } = this ;
const dash = Main . overview . dash ;
// including Dash to Dock and clones properties for compatibility
2025-02-09 23:16:18 +01:00
if ( Me . Util . dashIsDashToDock ( ) ) {
2025-02-09 23:09:13 +01:00
// Dash to Dock also always affects workAreaBox
2025-02-09 23:13:53 +01:00
Main . layoutManager . _trackedActors . forEach ( actor => {
2025-02-09 23:09:13 +01:00
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()
2025-02-09 23:13:53 +01:00
if ( dash . get _parent ( ) ? . get _parent ( ) ? . get _parent ( ) ? . _intellihideIsEnabled )
2025-02-09 23:09:13 +01:00
height += dash . height ;
} else {
width += dash . width ;
}
}
} ) ;
}
let wWidth ;
let wHeight ;
let wsBoxY ;
switch ( state ) {
case ControlsState . HIDDEN :
2025-02-09 23:13:53 +01:00
// if PANEL_OVERVIEW_ONLY, the affectStruts property is set to false to avoid stuttering
2025-02-09 23:09:13 +01:00
// therefore we added panel height to startY for the overview allocation,
2025-02-09 23:13:53 +01:00
// but here we need to remove the correction because the panel will be in the hidden state
2025-02-09 23:09:13 +01:00
if ( opt . START _Y _OFFSET ) {
let [ x , y ] = workAreaBox . get _origin ( ) ;
y -= opt . START _Y _OFFSET ;
workspaceBox . set _origin ( x , y ) ;
} else {
workspaceBox . set _origin ( ... workAreaBox . get _origin ( ) ) ;
}
workspaceBox . set _size ( ... workAreaBox . get _size ( ) ) ;
break ;
case ControlsState . WINDOW _PICKER :
case ControlsState . APP _GRID :
if ( opt . WS _ANIMATION && opt . SHOW _WS _TMB && state === ControlsState . APP _GRID ) {
workspaceBox . set _origin ( ... this . _workspacesThumbnails . get _position ( ) ) ;
2025-02-09 23:16:18 +01:00
workspaceBox . set _size ( thumbnailsWidth , thumbnailsHeight ) ;
2025-02-09 23:09:13 +01:00
} else if ( opt . OVERVIEW _MODE2 && ! opt . WORKSPACE _MODE ) {
if ( opt . START _Y _OFFSET ) {
let [ x , y ] = workAreaBox . get _origin ( ) ;
y -= opt . START _Y _OFFSET ;
workspaceBox . set _origin ( x , y ) ;
} else {
workspaceBox . set _origin ( ... workAreaBox . get _origin ( ) ) ;
}
workspaceBox . set _size ( ... workAreaBox . get _size ( ) ) ;
} else {
2025-02-09 23:13:53 +01:00
// if PANEL_OVERVIEW_ONLY, panel doesn't affect workArea height (affectStruts === false), it is necessary to compensate
2025-02-09 23:09:13 +01:00
height = opt . PANEL _POSITION _TOP ? height : height - Main . panel . height ;
searchHeight = opt . SHOW _SEARCH _ENTRY ? searchHeight : 0 ;
2025-02-09 23:13:53 +01:00
wWidth = width -
2025-02-09 23:16:18 +01:00
( opt . DASH _VERTICAL ? dashWidth : 0 ) -
2025-02-09 23:13:53 +01:00
thumbnailsWidth -
4 * spacing ;
wHeight = height -
( opt . DASH _VERTICAL ? 0 : dashHeight ) -
searchHeight -
4 * spacing ;
2025-02-09 23:09:13 +01:00
const ratio = width / height ;
let wRatio = wWidth / wHeight ;
let scale = ratio / wRatio ;
if ( scale > 1 ) {
2025-02-09 23:13:53 +01:00
wHeight /= scale ;
2025-02-09 23:09:13 +01:00
wWidth = wHeight * ratio ;
} else {
2025-02-09 23:13:53 +01:00
wWidth *= scale ;
2025-02-09 23:09:13 +01:00
wHeight = wWidth / ratio ;
}
// height decides the actual size, ratio is given by the workarea
wHeight *= opt . WS _PREVIEW _SCALE ;
wWidth *= opt . WS _PREVIEW _SCALE ;
let xOffset = 0 ;
let yOffset = 0 ;
const yOffsetT = ( opt . DASH _TOP ? dashHeight : 0 ) + searchHeight ;
2025-02-09 23:13:53 +01:00
const yOffsetB = opt . DASH _BOTTOM ? dashHeight : 0 ;
2025-02-09 23:09:13 +01:00
const yAvailableSpace = ( height - yOffsetT - wHeight - yOffsetB ) / 2 ;
yOffset = yOffsetT + yAvailableSpace ;
const centeredBoxX = ( width - wWidth ) / 2 ;
const xOffsetL = ( opt . DASH _LEFT ? dashWidth : 0 ) + ( opt . WS _TMB _LEFT ? thumbnailsWidth : 0 ) + 2 * spacing ;
const xOffsetR = ( opt . DASH _RIGHT ? dashWidth : 0 ) + ( opt . WS _TMB _RIGHT ? thumbnailsWidth : 0 ) + 2 * spacing ;
this . _xAlignCenter = false ;
if ( centeredBoxX < Math . max ( xOffsetL , xOffsetR ) ) {
xOffset = xOffsetL + spacing + ( width - xOffsetL - wWidth - xOffsetR - 2 * spacing ) / 2 ;
} else {
xOffset = centeredBoxX ;
this . _xAlignCenter = true ;
}
2025-02-09 23:13:53 +01:00
const wsBoxX = /* startX + */ xOffset ;
2025-02-09 23:16:18 +01:00
wsBoxY = startY + yOffset ;
2025-02-09 23:09:13 +01:00
workspaceBox . set _origin ( Math . round ( wsBoxX ) , Math . round ( wsBoxY ) ) ;
workspaceBox . set _size ( Math . round ( wWidth ) , Math . round ( wHeight ) ) ;
}
}
return workspaceBox ;
} ,
2025-02-09 23:13:53 +01:00
_getAppDisplayBoxForState ( state , box , workAreaBox , searchHeight , dashWidth , dashHeight , thumbnailsWidth , startY ) {
2025-02-09 23:16:18 +01:00
// in case the function is called from the DtD
if ( startY === undefined ) {
workAreaBox = box ;
}
2025-02-09 23:09:13 +01:00
const [ width ] = box . get _size ( ) ;
const { x1 : startX } = workAreaBox ;
2025-02-09 23:13:53 +01:00
// const { y1: startY } = workAreaBox;
2025-02-09 23:09:13 +01:00
let height = workAreaBox . get _height ( ) ;
const appDisplayBox = new Clutter . ActorBox ( ) ;
const { spacing } = this ;
searchHeight = opt . SHOW _SEARCH _ENTRY ? searchHeight : 0 ;
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 ) ;
2025-02-09 23:13:53 +01:00
const yOffsetB = opt . DASH _BOTTOM ? dashHeight : 0 ;
2025-02-09 23:16:18 +01:00
const adWidth = opt . CENTER _APP _GRID ? width - 2 * Math . max ( xOffsetL , xOffsetR ) - 2 * spacing : width - xOffsetL - xOffsetR - 2 * spacing ;
const adHeight = height - yOffsetT - yOffsetB ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:13:53 +01:00
const appDisplayX = opt . CENTER _APP _GRID ? ( width - adWidth ) / 2 : xOffsetL + 2 * spacing ;
2025-02-09 23:16:18 +01:00
const appDisplayY = startY + yOffsetT ;
2025-02-09 23:09:13 +01:00
switch ( state ) {
case ControlsState . HIDDEN :
case ControlsState . WINDOW _PICKER :
// 1 - left, 2 - right, 3 - bottom, 5 - top
switch ( opt . APP _GRID _ANIMATION ) {
case 0 :
2025-02-09 23:16:18 +01:00
appDisplayBox . set _origin ( Math . round ( appDisplayX ) , Math . round ( appDisplayY ) ) ;
2025-02-09 23:09:13 +01:00
break ;
case 1 :
2025-02-09 23:16:18 +01:00
appDisplayBox . set _origin ( Math . round ( startX + width ) , Math . round ( appDisplayY ) ) ;
2025-02-09 23:09:13 +01:00
break ;
case 2 :
2025-02-09 23:16:18 +01:00
appDisplayBox . set _origin ( Math . round ( startX - adWidth ) , Math . round ( appDisplayY ) ) ;
2025-02-09 23:09:13 +01:00
break ;
case 3 :
2025-02-09 23:16:18 +01:00
appDisplayBox . set _origin ( Math . round ( appDisplayX ) , Math . round ( workAreaBox . y2 ) ) ;
2025-02-09 23:09:13 +01:00
break ;
case 5 :
2025-02-09 23:16:18 +01:00
appDisplayBox . set _origin ( Math . round ( appDisplayX ) , Math . round ( workAreaBox . y1 - adHeight ) ) ;
2025-02-09 23:09:13 +01:00
break ;
}
break ;
case ControlsState . APP _GRID :
2025-02-09 23:16:18 +01:00
appDisplayBox . set _origin ( Math . round ( appDisplayX ) , Math . round ( appDisplayY ) ) ;
2025-02-09 23:09:13 +01:00
break ;
}
2025-02-09 23:16:18 +01:00
appDisplayBox . set _size ( Math . round ( adWidth ) , Math . round ( adHeight ) ) ;
2025-02-09 23:09:13 +01:00
return appDisplayBox ;
} ,
2025-02-09 23:13:53 +01:00
vfunc _allocate ( container , box ) {
2025-02-09 23:09:13 +01:00
const childBox = new Clutter . ActorBox ( ) ;
2025-02-09 23:16:18 +01:00
const transitionParams = this . _stateAdjustment . getStateTransitionParams ( ) ;
2025-02-09 23:09:13 +01:00
const { spacing } = this ;
2025-02-09 23:16:18 +01:00
const halfSpacing = spacing / 2 ;
2025-02-09 23:09:13 +01:00
const monitor = Main . layoutManager . findMonitorForActor ( this . _container ) ;
const workArea = Main . layoutManager . getWorkAreaForMonitor ( monitor . index ) ;
const startX = workArea . x - monitor . x ;
2025-02-09 23:13:53 +01:00
// if PANEL_OVERVIEW_ONLY, the affectStruts property is set to false to avoid stuttering
2025-02-09 23:09:13 +01:00
// therefore we need to add panel height to startY
let startY = workArea . y - monitor . y + opt . START _Y _OFFSET ;
const workAreaBox = new Clutter . ActorBox ( ) ;
workAreaBox . set _origin ( startX , startY ) ;
workAreaBox . set _size ( workArea . width , workArea . height ) ;
box . y1 += startY ;
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)
height = opt . PANEL _POSITION _TOP ? height : height - Main . panel . height ;
let availableHeight = height ;
// Dash
2025-02-09 23:16:18 +01:00
const maxDashHeight = box . get _height ( ) * DASH _MAX _SIZE _RATIO ;
2025-02-09 23:09:13 +01:00
const maxDashWidth = maxDashHeight * 0.8 ;
let dashHeight = 0 ;
let dashWidth = 0 ;
// dash cloud be overridden by the Dash to Dock clone
const dash = Main . overview . dash ;
2025-02-09 23:16:18 +01:00
if ( Me . Util . dashIsDashToDock ( ) ) {
// if Dash to Dock replaced the default dash and its inteli-hide is disabled we need to compensate for affected startY
2025-02-09 23:09:13 +01:00
if ( ! Main . overview . dash . get _parent ( ) ? . get _parent ( ) ? . get _parent ( ) ? . _intellihideIsEnabled ) {
if ( Main . panel . y === monitor . y )
startY = Main . panel . height + spacing ;
}
dashHeight = dash . height ;
dashWidth = dash . width ;
opt . DASH _VERTICAL = [ 1 , 3 ] . includes ( dash . _position ) ;
this . _dash . allocate ( childBox ) ;
} else if ( this . _dash . visible ) {
// default dock
if ( opt . DASH _VERTICAL ) {
this . _dash . setMaxSize ( maxDashWidth , height ) ;
[ , dashWidth ] = this . _dash . get _preferred _width ( height ) ;
[ , dashHeight ] = this . _dash . get _preferred _height ( dashWidth ) ;
dashWidth = Math . min ( dashWidth , maxDashWidth ) ;
dashHeight = Math . min ( dashHeight , height ) ;
} else if ( ! opt . WS _TMB _FULL ) {
2025-02-09 23:13:53 +01:00
this . _dash . setMaxSize ( width , maxDashHeight ) ;
2025-02-09 23:09:13 +01:00
[ , dashHeight ] = this . _dash . get _preferred _height ( width ) ;
[ , dashWidth ] = this . _dash . get _preferred _width ( dashHeight ) ;
dashHeight = Math . min ( dashHeight , maxDashHeight ) ;
dashWidth = Math . min ( dashWidth , width ) ;
}
}
// Workspace Thumbnails
let wsTmbWidth = 0 ;
let wsTmbHeight = 0 ;
2025-02-09 23:16:18 +01:00
let maxWsTmbScale = opt . MAX _THUMBNAIL _SCALE ;
if ( opt . SHOW _WS _TMB ) {
2025-02-09 23:13:53 +01:00
const dashHeightReservation = ! opt . WS _TMB _FULL && ! opt . DASH _VERTICAL ? dashHeight : 0 ;
2025-02-09 23:16:18 +01:00
const searchActive = this . _searchController . searchActive ;
if ( ! opt . MAX _THUMBNAIL _SCALE _STABLE && ! searchActive ) {
2025-02-09 23:13:53 +01:00
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 ;
2025-02-09 23:16:18 +01:00
maxWsTmbScale = Util . lerp ( initState , finalState , transitionParams . progress ) ;
2025-02-09 23:13:53 +01:00
}
2025-02-09 23:09:13 +01:00
2025-02-09 23:16:18 +01:00
wsTmbWidth = width * maxWsTmbScale ;
2025-02-09 23:13:53 +01:00
let totalTmbSpacing ;
2025-02-09 23:16:18 +01:00
[ totalTmbSpacing , wsTmbHeight ] = this . _workspacesThumbnails . get _preferred _height ( wsTmbWidth ) ;
2025-02-09 23:13:53 +01:00
wsTmbHeight += totalTmbSpacing ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:16:18 +01:00
const wsTmbHeightMax = opt . WS _TMB _FULL
? height - spacing
: height - dashHeightReservation - 2 * spacing ;
2025-02-09 23:13:53 +01:00
if ( wsTmbHeight > wsTmbHeightMax ) {
wsTmbHeight = wsTmbHeightMax ;
2025-02-09 23:16:18 +01:00
wsTmbWidth = Math . round ( this . _workspacesThumbnails . get _preferred _width ( wsTmbHeight ) [ 1 ] ) ;
2025-02-09 23:13:53 +01:00
}
2025-02-09 23:09:13 +01:00
let wsTmbX ;
2025-02-09 23:13:53 +01:00
if ( opt . WS _TMB _RIGHT )
2025-02-09 23:16:18 +01:00
wsTmbX = Math . round ( startX + width - ( opt . DASH _RIGHT ? dashWidth : 0 ) - wsTmbWidth /* - halfSpacing*/ ) ; // this halfSpacing is a part od dash style
2025-02-09 23:13:53 +01:00
else
2025-02-09 23:16:18 +01:00
wsTmbX = Math . round ( opt . DASH _LEFT ? dashWidth : 0 /* + halfSpacing*/ ) ; // this halfSpacing is a part od dash style
2025-02-09 23:09:13 +01:00
let wstOffset = ( height - wsTmbHeight - ( opt . DASH _VERTICAL ? 0 : dashHeightReservation ) ) / 2 ;
2025-02-09 23:16:18 +01:00
wstOffset -= opt . WS _TMB _POSITION _ADJUSTMENT * ( wstOffset - halfSpacing ) ;
2025-02-09 23:13:53 +01:00
let wsTmbY = Math . round ( startY + ( dashHeightReservation && opt . DASH _TOP ? dashHeight : 0 ) + wstOffset ) ;
2025-02-09 23:09:13 +01:00
childBox . set _origin ( wsTmbX , wsTmbY ) ;
2025-02-09 23:16:18 +01:00
childBox . set _size ( Math . max ( wsTmbWidth , 1 ) , Math . max ( wsTmbHeight , 1 ) ) ;
2025-02-09 23:09:13 +01:00
this . _workspacesThumbnails . allocate ( childBox ) ;
}
if ( this . _dash . visible ) {
const wMaxWidth = width - spacing - wsTmbWidth - 2 * spacing - ( opt . DASH _VERTICAL ? dashWidth + spacing : 0 ) ;
if ( opt . WS _TMB _FULL && ! opt . DASH _VERTICAL ) {
this . _dash . setMaxSize ( wMaxWidth , maxDashHeight ) ;
[ , dashHeight ] = this . _dash . get _preferred _height ( wMaxWidth ) ;
[ , dashWidth ] = this . _dash . get _preferred _width ( dashHeight ) ;
2025-02-09 23:16:18 +01:00
dashHeight = Math . min ( dashHeight , maxDashHeight ) ;
dashWidth = Math . min ( dashWidth , wMaxWidth ) ;
2025-02-09 23:09:13 +01:00
}
let dashX , dashY , offset ;
if ( opt . DASH _RIGHT )
dashX = width - dashWidth ;
2025-02-09 23:13:53 +01:00
else if ( opt . DASH _LEFT )
2025-02-09 23:09:13 +01:00
dashX = 0 ;
2025-02-09 23:13:53 +01:00
2025-02-09 23:09:13 +01:00
else if ( opt . DASH _TOP )
dashY = startY ;
else
dashY = startY + height - dashHeight ;
if ( ! opt . DASH _VERTICAL ) {
2025-02-09 23:13:53 +01:00
offset = ( width - ( ( opt . WS _TMB _FULL || opt . CENTER _DASH _WS ) && ! this . _xAlignCenter ? wsTmbWidth : 0 ) - dashWidth ) / 2 ;
2025-02-09 23:16:18 +01:00
offset -= opt . DASH _POSITION _ADJUSTMENT * ( offset - halfSpacing ) ;
2025-02-09 23:09:13 +01:00
dashX = offset ;
if ( ( opt . WS _TMB _FULL || opt . CENTER _DASH _WS ) && ! this . _xAlignCenter ) {
2025-02-09 23:13:53 +01:00
if ( ! opt . WS _TMB _RIGHT ) {
2025-02-09 23:09:13 +01:00
dashX = ( wsTmbWidth ? wsTmbWidth : 0 ) + offset ;
dashX = Math . max ( dashX , wsTmbWidth ? wsTmbWidth + spacing : 0 ) ;
dashX = Math . min ( dashX , width - dashWidth - spacing ) ;
}
}
if ( opt . WS _TMB _FULL && ! opt . CENTER _DASH _WS ) {
dashX = opt . WS _TMB _RIGHT
2025-02-09 23:13:53 +01:00
? 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 ) ) ) ;
2025-02-09 23:09:13 +01:00
}
} else {
2025-02-09 23:13:53 +01:00
offset = ( height - dashHeight ) / 2 ;
2025-02-09 23:16:18 +01:00
dashY = startY + ( offset - opt . DASH _POSITION _ADJUSTMENT * ( offset - halfSpacing ) ) ;
2025-02-09 23:09:13 +01:00
}
childBox . set _origin ( Math . round ( startX + dashX ) , Math . round ( dashY ) ) ;
2025-02-09 23:16:18 +01:00
childBox . set _size ( Math . round ( dashWidth ) , Math . round ( dashHeight ) ) ;
2025-02-09 23:09:13 +01:00
this . _dash . allocate ( childBox ) ;
}
2025-02-09 23:13:53 +01:00
availableHeight -= opt . DASH _VERTICAL ? 0 : dashHeight + spacing ;
2025-02-09 23:09:13 +01:00
let [ searchHeight ] = this . _searchEntry . get _preferred _height ( width - wsTmbWidth ) ;
// Workspaces
2025-02-09 23:16:18 +01:00
let params = [ box , workAreaBox , dashWidth , dashHeight , wsTmbWidth , wsTmbHeight , searchHeight , startY ] ;
2025-02-09 23:09:13 +01:00
// Update cached boxes
for ( const state of Object . values ( ControlsState ) ) {
this . _cachedWorkspaceBoxes . set (
state , this . _computeWorkspacesBoxForState ( state , ... params ) ) ;
}
let workspacesBox ;
2025-02-09 23:13:53 +01:00
if ( ! transitionParams . transitioning )
2025-02-09 23:09:13 +01:00
workspacesBox = this . _cachedWorkspaceBoxes . get ( transitionParams . currentState ) ;
2025-02-09 23:13:53 +01:00
2025-02-09 23:09:13 +01:00
if ( ! workspacesBox ) {
const initialBox = this . _cachedWorkspaceBoxes . get ( transitionParams . initialState ) ;
const finalBox = this . _cachedWorkspaceBoxes . get ( transitionParams . finalState ) ;
workspacesBox = initialBox . interpolate ( finalBox , transitionParams . progress ) ;
}
this . _workspacesDisplay . allocate ( workspacesBox ) ;
// Search entry
const searchXoffset = ( opt . DASH _LEFT ? dashWidth : 0 ) + spacing + ( opt . WS _TMB _RIGHT ? 0 : wsTmbWidth + spacing ) ;
// Y position under top Dash
let searchEntryX , searchEntryY ;
2025-02-09 23:13:53 +01:00
if ( opt . DASH _TOP )
2025-02-09 23:16:18 +01:00
searchEntryY = startY + dashHeight ;
2025-02-09 23:13:53 +01:00
else
2025-02-09 23:09:13 +01:00
searchEntryY = startY ;
2025-02-09 23:13:53 +01:00
2025-02-09 23:09:13 +01:00
searchEntryX = searchXoffset ;
let searchWidth = width - 2 * spacing - wsTmbWidth - ( opt . DASH _VERTICAL ? dashWidth : 0 ) ; // xAlignCenter is given by wsBox
searchWidth = this . _xAlignCenter ? width - 2 * ( wsTmbWidth + spacing ) : searchWidth ;
if ( opt . CENTER _SEARCH _VIEW ) {
2025-02-09 23:16:18 +01:00
childBox . set _origin ( 0 , Math . round ( searchEntryY ) ) ;
childBox . set _size ( Math . round ( width ) , Math . round ( searchHeight ) ) ;
2025-02-09 23:09:13 +01:00
} else {
2025-02-09 23:16:18 +01:00
childBox . set _origin ( Math . round ( this . _xAlignCenter ? 0 : searchEntryX ) , Math . round ( searchEntryY ) ) ;
childBox . set _size ( Math . round ( this . _xAlignCenter ? width : searchWidth - spacing ) , Math . round ( searchHeight ) ) ;
2025-02-09 23:09:13 +01:00
}
this . _searchEntry . allocate ( childBox ) ;
availableHeight -= searchHeight + spacing ;
2025-02-09 23:13:53 +01:00
// if (this._appDisplay.visible)... ? Can cause problems
2025-02-09 23:16:18 +01:00
// Calculate appDisplay always for AppGrid state WsTmb scale
let wsTmbWidthAppGrid = opt . MAX _THUMBNAIL _SCALE _APPGRID > 0
? wsTmbWidth / maxWsTmbScale * opt . MAX _THUMBNAIL _SCALE _APPGRID
: wsTmbWidth / maxWsTmbScale * opt . MAX _THUMBNAIL _SCALE ;
params = [ box , workAreaBox , searchHeight , dashWidth , dashHeight , wsTmbWidthAppGrid , startY ] ; // send startY, can be corrected
2025-02-09 23:13:53 +01:00
let appDisplayBox ;
if ( ! transitionParams . transitioning ) {
appDisplayBox =
2025-02-09 23:09:13 +01:00
this . _getAppDisplayBoxForState ( transitionParams . currentState , ... params ) ;
2025-02-09 23:13:53 +01:00
} else {
const initialBox =
2025-02-09 23:09:13 +01:00
this . _getAppDisplayBoxForState ( transitionParams . initialState , ... params ) ;
2025-02-09 23:13:53 +01:00
const finalBox =
2025-02-09 23:09:13 +01:00
this . _getAppDisplayBoxForState ( transitionParams . finalState , ... params ) ;
2025-02-09 23:13:53 +01:00
appDisplayBox = initialBox . interpolate ( finalBox , transitionParams . progress ) ;
}
this . _appDisplay . allocate ( appDisplayBox ) ;
2025-02-09 23:09:13 +01:00
// Search
if ( opt . CENTER _SEARCH _VIEW ) {
const dashW = ( opt . DASH _VERTICAL ? dashWidth : 0 ) + spacing ;
searchWidth = width - 2 * wsTmbWidth - 2 * dashW ;
2025-02-09 23:16:18 +01:00
childBox . set _origin ( Math . round ( wsTmbWidth + dashW ) , Math . round ( startY + ( opt . DASH _TOP ? dashHeight + spacing : spacing ) + searchHeight ) ) ;
2025-02-09 23:09:13 +01:00
} else {
2025-02-09 23:16:18 +01:00
childBox . set _origin ( Math . round ( this . _xAlignCenter ? wsTmbWidth + spacing : searchXoffset ) , Math . round ( startY + ( opt . DASH _TOP ? dashHeight + spacing : spacing ) + searchHeight ) ) ;
2025-02-09 23:09:13 +01:00
}
2025-02-09 23:16:18 +01:00
childBox . set _size ( Math . round ( searchWidth ) , Math . round ( availableHeight ) ) ;
2025-02-09 23:09:13 +01:00
this . _searchController . allocate ( childBox ) ;
this . _runPostAllocation ( ) ;
2025-02-09 23:13:53 +01:00
} ,
} ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:13:53 +01:00
const ControlsManagerLayoutHorizontal = {
2025-02-09 23:16:18 +01:00
_computeWorkspacesBoxForState ( state , box , workAreaBox , dashWidth , dashHeight , thumbnailWidth , thumbnailsHeight , searchHeight , startY ) {
// in case the function is called from the DtD
if ( startY === undefined ) {
workAreaBox = box ;
}
2025-02-09 23:09:13 +01:00
const workspaceBox = box . copy ( ) ;
let [ width , height ] = workspaceBox . get _size ( ) ;
const { spacing } = this ;
const dash = Main . overview . dash ;
// including Dash to Dock and clones properties for compatibility
2025-02-09 23:16:18 +01:00
if ( Me . Util . dashIsDashToDock ( ) ) {
2025-02-09 23:09:13 +01:00
// Dash to Dock always affects workAreaBox
2025-02-09 23:13:53 +01:00
Main . layoutManager . _trackedActors . forEach ( actor => {
2025-02-09 23:09:13 +01:00
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()
2025-02-09 23:13:53 +01:00
if ( dash . get _parent ( ) ? . get _parent ( ) ? . get _parent ( ) ? . _intellihideIsEnabled )
2025-02-09 23:09:13 +01:00
height += dash . height ;
2025-02-09 23:13:53 +01:00
else if ( opt . DASH _TOP )
2025-02-09 23:09:13 +01:00
height += dash . height ;
} else {
width += dash . width ;
}
}
} ) ;
}
let wWidth , wHeight , wsBoxY , wsBoxX ;
switch ( state ) {
case ControlsState . HIDDEN :
2025-02-09 23:13:53 +01:00
// if PANEL_OVERVIEW_ONLY, the affectStruts property is set to false to avoid stuttering
2025-02-09 23:09:13 +01:00
// 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 ) {
let [ x , y ] = workAreaBox . get _origin ( ) ;
y -= opt . START _Y _OFFSET ;
workspaceBox . set _origin ( x , y ) ;
} else {
workspaceBox . set _origin ( ... workAreaBox . get _origin ( ) ) ;
}
workspaceBox . set _size ( ... workAreaBox . get _size ( ) ) ;
break ;
case ControlsState . WINDOW _PICKER :
case ControlsState . APP _GRID :
if ( opt . WS _ANIMATION && opt . SHOW _WS _TMB && state === ControlsState . APP _GRID ) {
workspaceBox . set _origin ( ... this . _workspacesThumbnails . get _position ( ) ) ;
2025-02-09 23:16:18 +01:00
workspaceBox . set _size ( thumbnailWidth , thumbnailsHeight ) ;
2025-02-09 23:09:13 +01:00
} else if ( opt . OVERVIEW _MODE2 && ! opt . WORKSPACE _MODE ) {
if ( opt . START _Y _OFFSET ) {
let [ x , y ] = workAreaBox . get _origin ( ) ;
y -= opt . START _Y _OFFSET ;
workspaceBox . set _origin ( x , y ) ;
} else {
workspaceBox . set _origin ( ... workAreaBox . get _origin ( ) ) ;
}
workspaceBox . set _size ( ... workAreaBox . get _size ( ) ) ;
} else {
2025-02-09 23:13:53 +01:00
// if PANEL_OVERVIEW_ONLY, panel doesn't affect workArea height (affectStruts === false), it is necessary to compensate
2025-02-09 23:09:13 +01:00
height = opt . PANEL _POSITION _TOP ? height : height - Main . panel . height ;
searchHeight = opt . SHOW _SEARCH _ENTRY ? searchHeight : 0 ;
2025-02-09 23:13:53 +01:00
wWidth = width -
spacing -
( opt . DASH _VERTICAL ? dashWidth : 0 ) -
4 * spacing ;
wHeight = height -
( opt . DASH _VERTICAL ? spacing : dashHeight ) -
thumbnailsHeight -
searchHeight -
4 * spacing ;
2025-02-09 23:09:13 +01:00
const ratio = width / height ;
let wRatio = wWidth / wHeight ;
let scale = ratio / wRatio ;
if ( scale > 1 ) {
2025-02-09 23:13:53 +01:00
wHeight /= scale ;
2025-02-09 23:09:13 +01:00
wWidth = wHeight * ratio ;
} else {
2025-02-09 23:13:53 +01:00
wWidth *= scale ;
2025-02-09 23:09:13 +01:00
wHeight = wWidth / ratio ;
}
// height decides the actual size, ratio is given by the workarea
wHeight *= opt . WS _PREVIEW _SCALE ;
wWidth *= opt . WS _PREVIEW _SCALE ;
let xOffset = 0 ;
let yOffset = 0 ;
const yOffsetT = ( opt . DASH _TOP ? dashHeight : 0 ) + ( opt . WS _TMB _TOP ? thumbnailsHeight : 0 ) + searchHeight ;
const yOffsetB = ( opt . DASH _BOTTOM ? dashHeight : 0 ) + ( opt . WS _TMB _BOTTOM ? thumbnailsHeight : 0 ) ;
const yAvailableSpace = ( height - yOffsetT - wHeight - yOffsetB ) / 2 ;
yOffset = yOffsetT + yAvailableSpace ;
const xOffsetL = ( opt . DASH _LEFT ? dashWidth : 0 ) + spacing ;
const xOffsetR = ( opt . DASH _RIGHT ? dashWidth : 0 ) + spacing ;
const centeredBoxX = ( width - wWidth ) / 2 ;
this . _xAlignCenter = false ;
if ( centeredBoxX < Math . max ( xOffsetL , xOffsetR ) ) {
xOffset = xOffsetL + spacing + ( width - xOffsetL - wWidth - xOffsetR ) / 2 ;
} else {
xOffset = centeredBoxX ;
this . _xAlignCenter = true ;
}
2025-02-09 23:13:53 +01:00
wsBoxX = /* startX + */ xOffset ;
2025-02-09 23:16:18 +01:00
wsBoxY = startY + yOffset ;
2025-02-09 23:09:13 +01:00
workspaceBox . set _origin ( Math . round ( wsBoxX ) , Math . round ( wsBoxY ) ) ;
workspaceBox . set _size ( Math . round ( wWidth ) , Math . round ( wHeight ) ) ;
}
}
return workspaceBox ;
} ,
2025-02-09 23:13:53 +01:00
_getAppDisplayBoxForState ( state , box , workAreaBox , searchHeight , dashWidth , dashHeight , thumbnailsHeight , startY ) {
2025-02-09 23:16:18 +01:00
// in case the function is called from the DtD
if ( startY === undefined ) {
workAreaBox = box ;
}
2025-02-09 23:09:13 +01:00
const [ width ] = box . get _size ( ) ;
const { x1 : startX } = workAreaBox ;
2025-02-09 23:13:53 +01:00
// const { y1: startY } = workAreaBox;
2025-02-09 23:09:13 +01:00
let height = workAreaBox . get _height ( ) ;
const appDisplayBox = new Clutter . ActorBox ( ) ;
const { spacing } = this ;
2025-02-09 23:16:18 +01:00
const yOffsetT = ( opt . WS _TMB _TOP ? thumbnailsHeight + spacing : 0 ) + ( opt . DASH _TOP ? dashHeight : 0 ) + ( opt . SHOW _SEARCH _ENTRY ? searchHeight : 0 ) ;
const yOffsetB = ( opt . WS _TMB _BOTTOM ? thumbnailsHeight + spacing : 0 ) + ( opt . DASH _BOTTOM ? dashHeight : 0 ) ;
2025-02-09 23:13:53 +01:00
const xOffsetL = opt . DASH _LEFT ? dashWidth : 0 ;
const xOffsetR = opt . DASH _RIGHT ? dashWidth : 0 ;
2025-02-09 23:16:18 +01:00
const hSpacing = xOffsetL + xOffsetR ? spacing : 0 ;
2025-02-09 23:13:53 +01:00
const adWidth = opt . CENTER _APP _GRID ? width - 2 * Math . max ( xOffsetL , xOffsetR ) - 2 * hSpacing : width - xOffsetL - xOffsetR - 2 * hSpacing ;
2025-02-09 23:16:18 +01:00
const adHeight = height - yOffsetT - yOffsetB ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:13:53 +01:00
const appDisplayX = opt . CENTER _APP _GRID ? ( width - adWidth ) / 2 : xOffsetL + hSpacing ;
2025-02-09 23:16:18 +01:00
const appDisplayY = startY + yOffsetT ;
2025-02-09 23:09:13 +01:00
switch ( state ) {
case ControlsState . HIDDEN :
case ControlsState . WINDOW _PICKER :
// 1 - left, 2 - right, 3 - bottom, 5 - top
switch ( opt . APP _GRID _ANIMATION ) {
case 0 :
2025-02-09 23:16:18 +01:00
appDisplayBox . set _origin ( Math . round ( appDisplayX ) , Math . round ( appDisplayY ) ) ;
2025-02-09 23:09:13 +01:00
break ;
case 1 :
2025-02-09 23:16:18 +01:00
appDisplayBox . set _origin ( Math . round ( startX + width ) , Math . round ( appDisplayY ) ) ;
2025-02-09 23:09:13 +01:00
break ;
case 2 :
2025-02-09 23:16:18 +01:00
appDisplayBox . set _origin ( Math . round ( startX - adWidth ) , Math . round ( appDisplayY ) ) ;
2025-02-09 23:09:13 +01:00
break ;
case 3 :
2025-02-09 23:16:18 +01:00
appDisplayBox . set _origin ( Math . round ( appDisplayX ) , Math . round ( workAreaBox . y2 ) ) ;
2025-02-09 23:09:13 +01:00
break ;
case 5 :
2025-02-09 23:16:18 +01:00
appDisplayBox . set _origin ( Math . round ( appDisplayX ) , Math . round ( workAreaBox . y1 - adHeight ) ) ;
2025-02-09 23:09:13 +01:00
break ;
}
break ;
case ControlsState . APP _GRID :
2025-02-09 23:16:18 +01:00
appDisplayBox . set _origin ( Math . round ( appDisplayX ) , Math . round ( appDisplayY ) ) ;
2025-02-09 23:09:13 +01:00
break ;
}
2025-02-09 23:16:18 +01:00
appDisplayBox . set _size ( Math . round ( adWidth ) , Math . round ( adHeight ) ) ;
2025-02-09 23:09:13 +01:00
return appDisplayBox ;
} ,
2025-02-09 23:13:53 +01:00
vfunc _allocate ( container , box ) {
2025-02-09 23:16:18 +01:00
const transitionParams = this . _stateAdjustment . getStateTransitionParams ( ) ;
2025-02-09 23:09:13 +01:00
const childBox = new Clutter . ActorBox ( ) ;
const { spacing } = this ;
2025-02-09 23:16:18 +01:00
const halfSpacing = spacing / 2 ;
2025-02-09 23:09:13 +01:00
const monitor = Main . layoutManager . findMonitorForActor ( this . _container ) ;
const workArea = Main . layoutManager . getWorkAreaForMonitor ( monitor . index ) ;
const startX = workArea . x - monitor . x ;
2025-02-09 23:13:53 +01:00
// if PANEL_OVERVIEW_ONLY, the affectStruts property is set to false to avoid stuttering
2025-02-09 23:09:13 +01:00
// therefore we need to add panel height to startY
let startY = workArea . y - monitor . y + opt . START _Y _OFFSET ;
const workAreaBox = new Clutter . ActorBox ( ) ;
workAreaBox . set _origin ( startX , startY ) ;
workAreaBox . set _size ( workArea . width , workArea . height ) ;
box . y1 += startY ;
box . x1 += startX ;
let [ width , height ] = box . get _size ( ) ;
// if panel is at bottom position,
2025-02-09 23:13:53 +01:00
// compensate for the height of the available box (the box size is calculated for top panel)
2025-02-09 23:09:13 +01:00
height = opt . PANEL _POSITION _TOP ? height : height - Main . panel . height ;
let availableHeight = height ;
// Dash
2025-02-09 23:16:18 +01:00
const maxDashHeight = box . get _height ( ) * DASH _MAX _SIZE _RATIO ;
2025-02-09 23:09:13 +01:00
const maxDashWidth = maxDashHeight * 0.8 ;
let dashHeight = 0 ;
let dashWidth = 0 ;
// dash cloud be overridden by the Dash to Dock clone
const dash = Main . overview . dash ;
2025-02-09 23:16:18 +01:00
if ( Me . Util . dashIsDashToDock ( ) ) {
2025-02-09 23:09:13 +01:00
// 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 ) {
2025-02-09 23:13:53 +01:00
// if (Main.panel.y === monitor.y)
// startY = Main.panel.height + spacing;
2025-02-09 23:09:13 +01:00
}
dashHeight = dash . height ;
dashWidth = dash . width ;
opt . DASH _TOP = dash . _position === 0 ;
opt . DASH _VERTICAL = [ 1 , 3 ] . includes ( dash . _position ) ;
this . _dash . allocate ( childBox ) ;
} else if ( this . _dash . visible ) {
// default dock
if ( ! opt . DASH _VERTICAL ) {
this . _dash . setMaxSize ( width , maxDashHeight ) ;
[ , dashHeight ] = this . _dash . get _preferred _height ( width ) ;
[ , 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 ) ;
[ , dashHeight ] = this . _dash . get _preferred _height ( dashWidth ) ;
dashHeight = Math . min ( dashHeight , height - spacing ) ;
dashWidth = Math . min ( dashWidth , width ) ;
}
}
let [ searchHeight ] = this . _searchEntry . get _preferred _height ( width ) ;
2025-02-09 23:13:53 +01:00
// Workspace Thumbnails
2025-02-09 23:09:13 +01:00
let wsTmbWidth = 0 ;
let wsTmbHeight = 0 ;
2025-02-09 23:16:18 +01:00
let maxWsTmbScale = opt . MAX _THUMBNAIL _SCALE ;
if ( opt . SHOW _WS _TMB ) {
2025-02-09 23:13:53 +01:00
const dashWidthReservation = ! opt . WS _TMB _FULL && opt . DASH _VERTICAL ? dashWidth : 0 ;
2025-02-09 23:16:18 +01:00
const searchActive = this . _searchController . searchActive ;
if ( ! opt . MAX _THUMBNAIL _SCALE _STABLE && ! searchActive ) {
2025-02-09 23:13:53 +01:00
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 ;
2025-02-09 23:16:18 +01:00
maxWsTmbScale = Util . lerp ( initState , finalState , transitionParams . progress ) ;
2025-02-09 23:13:53 +01:00
}
2025-02-09 23:09:13 +01:00
2025-02-09 23:16:18 +01:00
wsTmbHeight = Math . round ( height * maxWsTmbScale ) ;
2025-02-09 23:13:53 +01:00
let totalTmbSpacing ;
2025-02-09 23:16:18 +01:00
[ totalTmbSpacing , wsTmbWidth ] = this . _workspacesThumbnails . get _preferred _width ( wsTmbHeight ) ;
2025-02-09 23:13:53 +01:00
wsTmbWidth += totalTmbSpacing ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:13:53 +01:00
const wsTmbWidthMax = opt . WS _TMB _FULL
2025-02-09 23:16:18 +01:00
? width - spacing
: width - dashWidthReservation - 2 * spacing ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:13:53 +01:00
if ( wsTmbWidth > wsTmbWidthMax ) {
wsTmbWidth = wsTmbWidthMax ;
2025-02-09 23:16:18 +01:00
wsTmbHeight = Math . round ( this . _workspacesThumbnails . get _preferred _height ( wsTmbWidth ) [ 1 ] ) ;
2025-02-09 23:13:53 +01:00
}
2025-02-09 23:09:13 +01:00
let wsTmbY ;
2025-02-09 23:13:53 +01:00
if ( opt . WS _TMB _TOP )
2025-02-09 23:16:18 +01:00
wsTmbY = Math . round ( startY + ( opt . DASH _TOP ? dashHeight : halfSpacing ) ) ;
2025-02-09 23:13:53 +01:00
else
2025-02-09 23:16:18 +01:00
wsTmbY = Math . round ( startY + height - ( opt . DASH _BOTTOM ? dashHeight : halfSpacing ) - wsTmbHeight ) ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:16:18 +01:00
let wstOffset = ( width - wsTmbWidth - dashWidthReservation ) / 2 ;
wstOffset -= opt . WS _TMB _POSITION _ADJUSTMENT * wstOffset ;
let wsTmbX = Math . round ( startX + ( opt . DASH _LEFT ? dashWidthReservation : 0 ) + wstOffset ) ;
2025-02-09 23:09:13 +01:00
childBox . set _origin ( wsTmbX , wsTmbY ) ;
2025-02-09 23:16:18 +01:00
childBox . set _size ( Math . max ( wsTmbWidth , 1 ) , Math . max ( wsTmbHeight , 1 ) ) ;
2025-02-09 23:09:13 +01:00
this . _workspacesThumbnails . allocate ( childBox ) ;
availableHeight -= wsTmbHeight + spacing ;
}
if ( this . _dash . visible ) {
if ( opt . WS _TMB _FULL && opt . DASH _VERTICAL ) {
const wMaxHeight = height - spacing - wsTmbHeight ;
this . _dash . setMaxSize ( maxDashWidth , wMaxHeight ) ;
[ , dashWidth ] = this . _dash . get _preferred _width ( wMaxHeight ) ;
[ , dashHeight ] = this . _dash . get _preferred _height ( dashWidth ) ;
2025-02-09 23:16:18 +01:00
dashWidth = Math . min ( dashWidth , maxDashWidth ) ;
dashHeight = Math . min ( dashHeight , wMaxHeight ) ;
2025-02-09 23:09:13 +01:00
}
let dashX , dashY , offset ;
2025-02-09 23:13:53 +01:00
if ( opt . DASH _RIGHT )
2025-02-09 23:09:13 +01:00
dashX = width - dashWidth ;
2025-02-09 23:13:53 +01:00
else if ( opt . DASH _LEFT )
2025-02-09 23:09:13 +01:00
dashX = 0 ;
2025-02-09 23:13:53 +01:00
else if ( opt . DASH _TOP )
2025-02-09 23:09:13 +01:00
dashY = startY ;
2025-02-09 23:13:53 +01:00
else
2025-02-09 23:09:13 +01:00
dashY = startY + height - dashHeight ;
2025-02-09 23:13:53 +01:00
2025-02-09 23:09:13 +01:00
if ( opt . DASH _VERTICAL ) {
if ( opt . WS _TMB _FULL ) {
offset = ( height - dashHeight - wsTmbHeight ) / 2 ;
if ( opt . WS _TMB _TOP ) {
2025-02-09 23:16:18 +01:00
offset -= opt . DASH _POSITION _ADJUSTMENT * ( offset - halfSpacing ) ;
2025-02-09 23:09:13 +01:00
dashY = startY + offset + wsTmbHeight ;
} else {
2025-02-09 23:16:18 +01:00
offset -= opt . DASH _POSITION _ADJUSTMENT * ( offset - halfSpacing ) ;
2025-02-09 23:09:13 +01:00
dashY = startY + offset ;
}
} else {
offset = ( height - dashHeight ) / 2 ;
2025-02-09 23:16:18 +01:00
offset -= opt . DASH _POSITION _ADJUSTMENT * ( offset - halfSpacing ) ;
2025-02-09 23:09:13 +01:00
dashY = startY + offset ;
}
} else {
offset = ( width - dashWidth ) / 2 ;
2025-02-09 23:16:18 +01:00
dashX = startX + ( offset - opt . DASH _POSITION _ADJUSTMENT * ( offset - halfSpacing ) ) ;
2025-02-09 23:09:13 +01:00
}
childBox . set _origin ( Math . round ( startX + dashX ) , Math . round ( dashY ) ) ;
2025-02-09 23:16:18 +01:00
childBox . set _size ( Math . round ( dashWidth ) , Math . round ( dashHeight ) ) ;
2025-02-09 23:09:13 +01:00
this . _dash . allocate ( childBox ) ;
}
2025-02-09 23:13:53 +01:00
availableHeight -= opt . DASH _VERTICAL ? 0 : dashHeight ;
2025-02-09 23:09:13 +01:00
// Workspaces
2025-02-09 23:16:18 +01:00
let params = [ box , workAreaBox , dashWidth , dashHeight , wsTmbWidth , wsTmbHeight , searchHeight , startY ] ;
2025-02-09 23:09:13 +01:00
// Update cached boxes
for ( const state of Object . values ( ControlsState ) ) {
this . _cachedWorkspaceBoxes . set (
state , this . _computeWorkspacesBoxForState ( state , ... params ) ) ;
}
let workspacesBox ;
2025-02-09 23:13:53 +01:00
if ( ! transitionParams . transitioning )
2025-02-09 23:09:13 +01:00
workspacesBox = this . _cachedWorkspaceBoxes . get ( transitionParams . currentState ) ;
2025-02-09 23:13:53 +01:00
2025-02-09 23:09:13 +01:00
if ( ! workspacesBox ) {
const initialBox = this . _cachedWorkspaceBoxes . get ( transitionParams . initialState ) ;
const finalBox = this . _cachedWorkspaceBoxes . get ( transitionParams . finalState ) ;
workspacesBox = initialBox . interpolate ( finalBox , transitionParams . progress ) ;
}
this . _workspacesDisplay . allocate ( workspacesBox ) ;
// Search entry
const searchXoffset = ( opt . DASH _LEFT ? dashWidth : 0 ) + spacing ;
// Y position under top Dash
let searchEntryX , searchEntryY ;
2025-02-09 23:13:53 +01:00
if ( opt . DASH _TOP )
2025-02-09 23:16:18 +01:00
searchEntryY = startY + ( opt . WS _TMB _TOP ? wsTmbHeight : 0 ) + dashHeight ;
2025-02-09 23:13:53 +01:00
else
2025-02-09 23:09:13 +01:00
searchEntryY = startY + ( opt . WS _TMB _TOP ? wsTmbHeight + spacing : 0 ) ;
2025-02-09 23:13:53 +01:00
2025-02-09 23:09:13 +01:00
searchEntryX = searchXoffset ;
let searchWidth = width - 2 * spacing - ( opt . DASH _VERTICAL ? dashWidth : 0 ) ; // xAlignCenter is given by wsBox
searchWidth = this . _xAlignCenter ? width : searchWidth ;
if ( opt . CENTER _SEARCH _VIEW ) {
2025-02-09 23:16:18 +01:00
childBox . set _origin ( 0 , Math . round ( searchEntryY ) ) ;
childBox . set _size ( width , Math . round ( searchHeight ) ) ;
2025-02-09 23:09:13 +01:00
} else {
2025-02-09 23:16:18 +01:00
childBox . set _origin ( Math . round ( this . _xAlignCenter ? 0 : searchEntryX ) , Math . round ( searchEntryY ) ) ;
childBox . set _size ( Math . round ( this . _xAlignCenter ? width : searchWidth - spacing ) , Math . round ( searchHeight ) ) ;
2025-02-09 23:09:13 +01:00
}
this . _searchEntry . allocate ( childBox ) ;
availableHeight -= searchHeight + spacing ;
2025-02-09 23:13:53 +01:00
// if (this._appDisplay.visible)... ? Can cause problems
2025-02-09 23:16:18 +01:00
// Calculate appDisplay always for AppGrid state WsTmb scale
let wsTmbHeightAppGrid = opt . MAX _THUMBNAIL _SCALE _APPGRID > 0
? wsTmbHeight / maxWsTmbScale * opt . MAX _THUMBNAIL _SCALE _APPGRID
: wsTmbHeight / maxWsTmbScale * opt . MAX _THUMBNAIL _SCALE ;
params = [ box , workAreaBox , searchHeight , dashWidth , dashHeight , wsTmbHeightAppGrid , startY ] ;
2025-02-09 23:13:53 +01:00
let appDisplayBox ;
if ( ! transitionParams . transitioning ) {
appDisplayBox =
2025-02-09 23:09:13 +01:00
this . _getAppDisplayBoxForState ( transitionParams . currentState , ... params ) ;
2025-02-09 23:13:53 +01:00
} else {
const initialBox =
2025-02-09 23:09:13 +01:00
this . _getAppDisplayBoxForState ( transitionParams . initialState , ... params ) ;
2025-02-09 23:13:53 +01:00
const finalBox =
2025-02-09 23:09:13 +01:00
this . _getAppDisplayBoxForState ( transitionParams . finalState , ... params ) ;
2025-02-09 23:13:53 +01:00
appDisplayBox = initialBox . interpolate ( finalBox , transitionParams . progress ) ;
}
this . _appDisplay . allocate ( appDisplayBox ) ;
2025-02-09 23:09:13 +01:00
// Search
if ( opt . CENTER _SEARCH _VIEW ) {
const dashW = ( opt . DASH _VERTICAL ? dashWidth : 0 ) + spacing ;
searchWidth = width - 2 * dashW ;
2025-02-09 23:16:18 +01:00
childBox . set _origin ( Math . round ( dashW ) , Math . round ( startY + ( opt . DASH _TOP ? dashHeight + spacing : spacing ) + ( opt . WS _TMB _TOP ? wsTmbHeight + spacing : 0 ) + searchHeight ) ) ;
2025-02-09 23:09:13 +01:00
} else {
2025-02-09 23:16:18 +01:00
childBox . set _origin ( Math . round ( this . _xAlignCenter ? spacing : searchXoffset ) , Math . round ( startY + ( opt . DASH _TOP ? dashHeight + spacing : spacing ) + ( opt . WS _TMB _TOP ? wsTmbHeight + spacing : 0 ) + searchHeight ) ) ;
2025-02-09 23:09:13 +01:00
}
2025-02-09 23:16:18 +01:00
childBox . set _size ( Math . round ( searchWidth ) , Math . round ( availableHeight ) ) ;
2025-02-09 23:09:13 +01:00
this . _searchController . allocate ( childBox ) ;
this . _runPostAllocation ( ) ;
2025-02-09 23:13:53 +01:00
} ,
} ;
2025-02-09 23:09:13 +01:00
// same copy of this function should be available in OverviewControls and WorkspacesView
function _getFitModeForState ( state ) {
switch ( state ) {
case ControlsState . HIDDEN :
case ControlsState . WINDOW _PICKER :
return FitMode . SINGLE ;
case ControlsState . APP _GRID :
if ( opt . WS _ANIMATION && opt . SHOW _WS _TMB )
return FitMode . ALL ;
else
return FitMode . SINGLE ;
default :
return FitMode . SINGLE ;
}
}
2025-02-09 23:16:18 +01:00
const LayoutManager = {
_startupAnimation ( ) {
if ( Me . Util . dashIsDashToDock ( ) && ! Meta . is _restart ( ) ) {
// DtD breaks overview on startup
// Skip animation to hide the mess
this . _startupAnimationComplete ( ) ;
Main . overview . _overview . controls . _finishStartupSequence ( ) ;
} else if ( Meta . is _restart ( ) ) {
this . _startupAnimationComplete ( ) ;
} else if ( Main . sessionMode . isGreeter ) {
this . _startupAnimationGreeter ( ) ;
} else {
this . _startupAnimationSession ( ) ;
}
} ,
} ;