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
* extension . js
*
* @ author GdH < G - dH @ github . com >
* @ copyright 2022 - 2023
* @ license GPL - 3.0
*
* /
'use strict' ;
2025-02-09 23:13:53 +01:00
const { GLib , Shell , St } = imports . gi ;
2025-02-09 23:09:13 +01:00
const Main = imports . ui . main ;
const Util = imports . misc . util ;
const Background = imports . ui . background ;
const ExtensionUtils = imports . misc . extensionUtils ;
const Me = ExtensionUtils . getCurrentExtension ( ) ;
2025-02-09 23:13:53 +01:00
const Settings = Me . imports . lib . settings ;
const _Util = Me . imports . lib . util ;
const WindowSearchProvider = Me . imports . lib . windowSearchProvider ;
const RecentFilesSearchProvider = Me . imports . lib . recentFilesSearchProvider ;
const LayoutOverride = Me . imports . lib . layout ;
const AppDisplayOverride = Me . imports . lib . appDisplay ;
const WorkspaceThumbnailOverride = Me . imports . lib . workspaceThumbnail ;
const WorkspaceOverride = Me . imports . lib . workspace ;
const WorkspacesViewOverride = Me . imports . lib . workspacesView ;
const WindowPreviewOverride = Me . imports . lib . windowPreview ;
const IconGridOverride = Me . imports . lib . iconGrid ;
const WorkspaceAnimationOverride = Me . imports . lib . workspaceAnimation ;
const WindowManagerOverride = Me . imports . lib . windowManager ;
const OverviewOverride = Me . imports . lib . overview ;
const OverviewControlsOverride = Me . imports . lib . overviewControls ;
const SwipeTrackerOverride = Me . imports . lib . swipeTracker ;
const WorkspaceSwitcherPopupOverride = Me . imports . lib . workspaceSwitcherPopup ;
const SearchOverride = Me . imports . lib . search ;
const PanelOverride = Me . imports . lib . panel ;
const DashOverride = Me . imports . lib . dash ;
const WindowAttentionHandlerOverride = Me . imports . lib . windowAttentionHandler ;
const AppFavoritesOverride = Me . imports . lib . appFavorites ;
const MessageTrayOverride = Me . imports . lib . messageTray ;
const OsdWindowOverride = Me . imports . lib . osdWindow ;
const OverlayKey = Me . imports . lib . overlayKey ;
let opt ;
2025-02-09 23:09:13 +01:00
let _bgManagers ;
let _enabled ;
let _resetExtensionIfEnabled ;
let _prevDash ;
let _showingOverviewConId ;
let _monitorsChangedSigId ;
2025-02-09 23:13:53 +01:00
let _loadingProfileTimeoutId ;
2025-02-09 23:09:13 +01:00
let _watchDockSigId ;
let _resetTimeoutId ;
let _enableTimeoutId = 0 ;
2025-02-09 23:13:53 +01:00
let _sessionLockActive = false ;
2025-02-09 23:09:13 +01:00
function init ( ) {
ExtensionUtils . initTranslations ( ) ;
}
function enable ( ) {
// globally readable flag for other extensions
global . verticalWorkspacesEnabled = true ;
_enableTimeoutId = GLib . timeout _add (
GLib . PRIORITY _DEFAULT ,
2025-02-09 23:13:53 +01:00
400 ,
2025-02-09 23:09:13 +01:00
( ) => {
2025-02-09 23:13:53 +01:00
activateVShell ( ) ;
// unlock after modules update to avoid unnecessary appGrid rebuild
_sessionLockActive = Main . sessionMode . isLocked ;
2025-02-09 23:09:13 +01:00
log ( ` ${ Me . metadata . name } : enabled ` ) ;
_enableTimeoutId = 0 ;
return GLib . SOURCE _REMOVE ;
}
) ;
}
function disable ( ) {
2025-02-09 23:13:53 +01:00
_sessionLockActive = Main . sessionMode . isLocked ;
2025-02-09 23:09:13 +01:00
if ( _enableTimeoutId ) {
GLib . source _remove ( _enableTimeoutId ) ;
_enableTimeoutId = 0 ;
} else {
2025-02-09 23:13:53 +01:00
resetVShell ( ) ;
2025-02-09 23:09:13 +01:00
}
2025-02-09 23:13:53 +01:00
2025-02-09 23:09:13 +01:00
global . verticalWorkspacesEnabled = undefined ;
2025-02-09 23:13:53 +01:00
log ( ` ${ Me . metadata . name } : ${ _sessionLockActive ? 'suspended' : 'disabled' } ` ) ;
2025-02-09 23:09:13 +01:00
}
2025-02-09 23:13:53 +01:00
// ------------------------------------------------------------------------------------------
2025-02-09 23:09:13 +01:00
2025-02-09 23:13:53 +01:00
function activateVShell ( ) {
2025-02-09 23:09:13 +01:00
_enabled = true ;
_bgManagers = [ ] ;
Settings . opt = new Settings . Options ( ) ;
opt = Settings . opt ;
_updateSettings ( ) ;
opt . connect ( 'changed' , _updateSettings ) ;
_updateOverrides ( ) ;
_prevDash = { } ;
const dash = Main . overview . dash ;
_prevDash . dash = dash ;
_prevDash . position = dash . position ;
2025-02-09 23:13:53 +01:00
_monitorsChangedSigId = Main . layoutManager . connect ( 'monitors-changed' , ( ) => _resetExtension ( 2000 ) ) ;
2025-02-09 23:09:13 +01:00
// static bg animations conflict with startup animation
// enable it on first hiding from the overview and disconnect the signal
_showingOverviewConId = Main . overview . connect ( 'showing' , _onShowingOverview ) ;
2025-02-09 23:13:53 +01:00
// switch PageUp/PageDown workspace switcher shortcuts
_switchPageShortcuts ( ) ;
_setStaticBackground ( ) ;
// fix for upstream bug - overview always shows workspace 1 instead of the active one after restart
Main . overview . _overview . controls . _workspaceAdjustment . set _value ( global . workspace _manager . get _active _workspace _index ( ) ) ;
2025-02-09 23:09:13 +01:00
// if Dash to Dock detected force enable "Fix for DtD" option
if ( _Util . dashIsDashToDock ( ) ) {
opt . set ( 'fixUbuntuDock' , true ) ;
_fixUbuntuDock ( true ) ;
} else {
_fixUbuntuDock ( opt . get ( 'fixUbuntuDock' ) ) ;
}
}
2025-02-09 23:13:53 +01:00
function resetVShell ( ) {
2025-02-09 23:09:13 +01:00
_enabled = 0 ;
_fixUbuntuDock ( false ) ;
const reset = true ;
_updateOverrides ( reset ) ;
if ( _monitorsChangedSigId ) {
Main . layoutManager . disconnect ( _monitorsChangedSigId ) ;
_monitorsChangedSigId = 0 ;
}
_prevDash = null ;
// switch PageUp/PageDown workspace switcher shortcuts
_switchPageShortcuts ( ) ;
_setStaticBackground ( reset ) ;
// remove any position offsets from dash and ws thumbnails
if ( ! _Util . dashNotDefault ( ) ) {
Main . overview . dash . translation _x = 0 ;
Main . overview . dash . translation _y = 0 ;
}
Main . overview . _overview . _controls . _thumbnailsBox . translation _x = 0 ;
Main . overview . _overview . _controls . _thumbnailsBox . translation _y = 0 ;
Main . overview . _overview . _controls . _searchEntryBin . translation _y = 0 ;
Main . overview . _overview . _controls . set _child _above _sibling ( Main . overview . _overview . _controls . _workspacesDisplay , null ) ;
if ( _showingOverviewConId ) {
Main . overview . disconnect ( _showingOverviewConId ) ;
_showingOverviewConId = 0 ;
}
2025-02-09 23:13:53 +01:00
if ( _loadingProfileTimeoutId ) {
GLib . source _remove ( _loadingProfileTimeoutId ) ;
_loadingProfileTimeoutId = 0 ;
}
2025-02-09 23:09:13 +01:00
St . Settings . get ( ) . slow _down _factor = 1 ;
Main . overview . dash . _background . set _style ( '' ) ;
opt . destroy ( ) ;
opt = null ;
}
function _updateOverrides ( reset = false ) {
WorkspacesViewOverride . update ( reset ) ;
WorkspaceThumbnailOverride . update ( reset ) ;
OverviewOverride . update ( reset ) ;
2025-02-09 23:13:53 +01:00
OverviewControlsOverride . update ( reset ) ;
2025-02-09 23:09:13 +01:00
WorkspaceOverride . update ( reset ) ;
WindowPreviewOverride . update ( reset ) ;
WindowManagerOverride . update ( reset ) ;
2025-02-09 23:13:53 +01:00
2025-02-09 23:09:13 +01:00
LayoutOverride . update ( reset ) ;
DashOverride . update ( reset ) ;
PanelOverride . update ( reset ) ;
WorkspaceAnimationOverride . update ( reset ) ;
WorkspaceSwitcherPopupOverride . update ( reset ) ;
SwipeTrackerOverride . update ( reset ) ;
SearchOverride . update ( reset ) ;
WindowSearchProvider . update ( reset ) ;
RecentFilesSearchProvider . update ( reset ) ;
2025-02-09 23:13:53 +01:00
// don't rebuild app grid on every screen lock
if ( ! _sessionLockActive ) {
// IconGrid needs to be patched before AppDisplay
IconGridOverride . update ( reset ) ;
AppDisplayOverride . update ( reset ) ;
}
WindowAttentionHandlerOverride . update ( reset ) ;
AppFavoritesOverride . update ( reset ) ;
MessageTrayOverride . update ( reset ) ;
OsdWindowOverride . update ( reset ) ;
OverlayKey . update ( reset ) ;
2025-02-09 23:09:13 +01:00
}
function _onShowingOverview ( ) {
// store pointer X coordinate for OVERVIEW_MODE 1 window spread - if mouse pointer is steady, don't spread
opt . showingPointerX = global . get _pointer ( ) [ 0 ] ;
if ( opt . FIX _UBUNTU _DOCK ) {
// workaround for Ubuntu Dock breaking overview allocations after changing position
const dash = Main . overview . dash ;
2025-02-09 23:13:53 +01:00
if ( _prevDash . dash !== dash || _prevDash . position !== dash . _position )
2025-02-09 23:09:13 +01:00
_resetExtensionIfEnabled ( 0 ) ;
}
}
function _resetExtension ( timeout = 200 ) {
if ( _resetTimeoutId )
GLib . source _remove ( _resetTimeoutId ) ;
_resetTimeoutId = GLib . timeout _add (
GLib . PRIORITY _DEFAULT ,
timeout ,
( ) => {
if ( ! _enabled )
2025-02-09 23:13:53 +01:00
return GLib . SOURCE _REMOVE ;
2025-02-09 23:09:13 +01:00
const dash = Main . overview . dash ;
if ( ! timeout && _prevDash . dash && dash !== _prevDash . dash ) { // !timeout means DtD workaround callback
_prevDash . dash = dash ;
log ( ` [ ${ Me . metadata . name } ]: Dash has been replaced, resetting extension... ` ) ;
2025-02-09 23:13:53 +01:00
resetVShell ( ) ;
activateVShell ( ) ;
2025-02-09 23:09:13 +01:00
} else if ( timeout ) {
log ( ` [ ${ Me . metadata . name } ]: resetting extension... ` ) ;
2025-02-09 23:13:53 +01:00
resetVShell ( ) ;
activateVShell ( ) ;
2025-02-09 23:09:13 +01:00
}
_resetTimeoutId = 0 ;
return GLib . SOURCE _REMOVE ;
}
) ;
}
function _fixUbuntuDock ( activate = true ) {
// Workaround for Ubuntu Dock breaking overview allocations after changing monitor configuration and deactivating dock
2025-02-09 23:13:53 +01:00
if ( _watchDockSigId ) {
global . settings . disconnect ( _watchDockSigId ) ;
2025-02-09 23:09:13 +01:00
_watchDockSigId = 0 ;
}
if ( _resetTimeoutId ) {
GLib . source _remove ( _resetTimeoutId ) ;
_resetTimeoutId = 0 ;
}
_resetExtensionIfEnabled = ( ) => { } ;
2025-02-09 23:13:53 +01:00
if ( ! activate )
2025-02-09 23:09:13 +01:00
return ;
2025-02-09 23:13:53 +01:00
_watchDockSigId = global . settings . connect ( 'changed::enabled-extensions' , ( ) => _resetExtension ( ) ) ;
2025-02-09 23:09:13 +01:00
_resetExtensionIfEnabled = _resetExtension ;
}
function _updateSettings ( settings , key ) {
2025-02-09 23:13:53 +01:00
if ( key ? . includes ( 'profile-data' ) ) {
const index = key . replace ( 'profile-data-' , '' ) ;
Main . notify ( ` ${ Me . metadata . name } ` , ` Profile ${ index } has been saved ` ) ;
}
// avoid overload while loading profile - update only once
// delayed gsettings writes are processed alphabetically
if ( key === 'aaa-loading-profile' ) {
Main . notify ( ` ${ Me . metadata . name } ` , 'Profile has been loaded' ) ;
if ( _loadingProfileTimeoutId )
GLib . source _remove ( _loadingProfileTimeoutId ) ;
_loadingProfileTimeoutId = GLib . timeout _add ( 100 , 0 , ( ) => {
_resetExtension ( ) ;
_loadingProfileTimeoutId = 0 ;
return GLib . SOURCE _REMOVE ;
} ) ;
}
if ( _loadingProfileTimeoutId )
return ;
2025-02-09 23:09:13 +01:00
opt . _updateSettings ( ) ;
opt . WORKSPACE _MIN _SPACING = Main . overview . _overview . _controls . _thumbnailsBox . get _theme _node ( ) . get _length ( 'spacing' ) ;
// update variables that cannot be processed within settings
const dash = Main . overview . dash ;
if ( _Util . dashIsDashToDock ( ) ) {
opt . DASH _POSITION = dash . _position ;
2025-02-09 23:13:53 +01:00
opt . DASH _TOP = opt . DASH _POSITION === 0 ;
opt . DASH _RIGHT = opt . DASH _POSITION === 1 ;
opt . DASH _BOTTOM = opt . DASH _POSITION === 2 ;
opt . DASH _LEFT = opt . DASH _POSITION === 3 ;
opt . DASH _VERTICAL = opt . DASH _LEFT || opt . DASH _RIGHT ;
2025-02-09 23:09:13 +01:00
}
2025-02-09 23:13:53 +01:00
opt . DASH _VISIBLE = opt . DASH _VISIBLE && ! _Util . getEnabledExtensions ( 'dash-to-panel@jderose9.github.com' ) . length ;
2025-02-09 23:09:13 +01:00
opt . MAX _ICON _SIZE = opt . get ( 'dashMaxIconSize' , true ) ;
if ( opt . MAX _ICON _SIZE < 16 ) {
opt . MAX _ICON _SIZE = 64 ;
opt . set ( 'dashMaxIconSize' , 64 ) ;
}
2025-02-09 23:13:53 +01:00
const monitorWidth = global . display . get _monitor _geometry ( global . display . get _primary _monitor ( ) ) . width ;
if ( monitorWidth < 1600 ) {
opt . APP _GRID _ICON _SIZE _DEFAULT = opt . APP _GRID _ACTIVE _PREVIEW ? 128 : 64 ;
opt . APP _GRID _FOLDER _ICON _SIZE _DEFAULT = 64 ;
}
imports . ui . workspace . WINDOW _PREVIEW _MAXIMUM _SCALE = opt . OVERVIEW _MODE === 1 ? 0.1 : 0.95 ;
2025-02-09 23:09:13 +01:00
2025-02-09 23:13:53 +01:00
if ( ! _Util . dashIsDashToDock ( ) ) { // DtD has its own opacity control
2025-02-09 23:09:13 +01:00
Main . overview . dash . _background . opacity = Math . round ( opt . get ( 'dashBgOpacity' , true ) * 2.5 ) ; // conversion % to 0-255
const radius = opt . get ( 'dashBgRadius' , true ) ;
if ( radius ) {
let style ;
switch ( opt . DASH _POSITION ) {
case 1 :
2025-02-09 23:13:53 +01:00
style = ` border-radius: ${ radius } px 0 0 ${ radius } px; ` ;
2025-02-09 23:09:13 +01:00
break ;
case 3 :
2025-02-09 23:13:53 +01:00
style = ` border-radius: 0 ${ radius } px ${ radius } px 0; ` ;
2025-02-09 23:09:13 +01:00
break ;
default :
2025-02-09 23:13:53 +01:00
style = ` border-radius: ${ radius } px; ` ;
2025-02-09 23:09:13 +01:00
}
Main . overview . dash . _background . set _style ( style ) ;
} else {
Main . overview . dash . _background . set _style ( '' ) ;
}
}
2025-02-09 23:13:53 +01:00
// adjust search entry style for OM2
if ( opt . OVERVIEW _MODE2 )
Main . overview . searchEntry . add _style _class _name ( 'search-entry-om2' ) ;
else
Main . overview . searchEntry . remove _style _class _name ( 'search-entry-om2' ) ;
2025-02-09 23:09:13 +01:00
Main . overview . searchEntry . visible = opt . SHOW _SEARCH _ENTRY ;
St . Settings . get ( ) . slow _down _factor = opt . ANIMATION _TIME _FACTOR ;
imports . ui . search . MAX _LIST _SEARCH _RESULTS _ROWS = opt . SEARCH _MAX _ROWS ;
2025-02-09 23:13:53 +01:00
opt . START _Y _OFFSET = ( opt . get ( 'panelModule' , true ) && opt . PANEL _OVERVIEW _ONLY && opt . PANEL _POSITION _TOP ) ||
// better to add unnecessary space than to have a panel overlapping other objects
_Util . getEnabledExtensions ( 'hidetopbar@mathieu.bidon.ca' ) . length
? Main . panel . height
: 0 ;
2025-02-09 23:09:13 +01:00
if ( settings )
_applySettings ( key ) ;
}
function _applySettings ( key ) {
2025-02-09 23:13:53 +01:00
if ( key ? . endsWith ( '-module' ) ) {
_updateOverrides ( ) ;
return ;
}
_setStaticBackground ( ) ;
2025-02-09 23:09:13 +01:00
_updateOverviewTranslations ( ) ;
_switchPageShortcuts ( ) ;
if ( key ? . includes ( 'app-grid' ) ) {
AppDisplayOverride . update ( ) ;
2025-02-09 23:13:53 +01:00
return ;
2025-02-09 23:09:13 +01:00
}
2025-02-09 23:13:53 +01:00
if ( key ? . includes ( 'panel' ) )
2025-02-09 23:09:13 +01:00
PanelOverride . update ( ) ;
2025-02-09 23:13:53 +01:00
if ( key ? . includes ( 'dash' ) || key ? . includes ( 'search' ) || key ? . includes ( 'icon' ) )
2025-02-09 23:09:13 +01:00
DashOverride . update ( ) ;
2025-02-09 23:13:53 +01:00
if ( key ? . includes ( 'hot-corner' ) || key ? . includes ( 'dash' ) )
LayoutOverride . update ( ) ;
switch ( key ) {
case 'fix-ubuntu-dock' :
_fixUbuntuDock ( opt . get ( 'fixUbuntuDock' , true ) ) ;
break ;
case 'ws-thumbnails-position' :
_updateOverrides ( ) ;
break ;
case 'workspace-switcher-animation' :
2025-02-09 23:09:13 +01:00
WorkspaceAnimationOverride . update ( ) ;
2025-02-09 23:13:53 +01:00
break ;
case 'search-width-scale' :
SearchOverride . update ( ) ;
break ;
case 'favorites-notify' :
AppFavoritesOverride . update ( ) ;
break ;
case 'window-attention-mode' :
WindowAttentionHandlerOverride . update ( ) ;
break ;
case 'show-ws-preview-bg' :
PanelOverride . update ( ) ;
break ;
case 'notification-position' :
MessageTrayOverride . update ( ) ;
break ;
case 'osd-position' :
OsdWindowOverride . update ( ) ;
break ;
case 'overlay-key' :
OverlayKey . update ( ) ;
2025-02-09 23:09:13 +01:00
}
}
function _switchPageShortcuts ( ) {
if ( ! opt . get ( 'enablePageShortcuts' , true ) )
return ;
const vertical = global . workspaceManager . layout _rows === - 1 ;
2025-02-09 23:13:53 +01:00
const schema = 'org.gnome.desktop.wm.keybindings' ;
2025-02-09 23:09:13 +01:00
const settings = ExtensionUtils . getSettings ( schema ) ;
const keyLeft = 'switch-to-workspace-left' ;
const keyRight = 'switch-to-workspace-right' ;
const keyUp = 'switch-to-workspace-up' ;
const keyDown = 'switch-to-workspace-down' ;
const keyMoveLeft = 'move-to-workspace-left' ;
const keyMoveRight = 'move-to-workspace-right' ;
const keyMoveUp = 'move-to-workspace-up' ;
const keyMoveDown = 'move-to-workspace-down' ;
const switchPrevSc = '<Super>Page_Up' ;
const switchNextSc = '<Super>Page_Down' ;
const movePrevSc = '<Super><Shift>Page_Up' ;
const moveNextSc = '<Super><Shift>Page_Down' ;
let switchLeft = settings . get _strv ( keyLeft ) ;
let switchRight = settings . get _strv ( keyRight ) ;
let switchUp = settings . get _strv ( keyUp ) ;
let switchDown = settings . get _strv ( keyDown ) ;
let moveLeft = settings . get _strv ( keyMoveLeft ) ;
let moveRight = settings . get _strv ( keyMoveRight ) ;
let moveUp = settings . get _strv ( keyMoveUp ) ;
let moveDown = settings . get _strv ( keyMoveDown ) ;
if ( vertical ) {
2025-02-09 23:13:53 +01:00
if ( switchLeft . includes ( switchPrevSc ) )
switchLeft . splice ( switchLeft . indexOf ( switchPrevSc ) , 1 ) ;
if ( switchRight . includes ( switchNextSc ) )
switchRight . splice ( switchRight . indexOf ( switchNextSc ) , 1 ) ;
if ( moveLeft . includes ( movePrevSc ) )
moveLeft . splice ( moveLeft . indexOf ( movePrevSc ) , 1 ) ;
if ( moveRight . includes ( moveNextSc ) )
moveRight . splice ( moveRight . indexOf ( moveNextSc ) , 1 ) ;
if ( ! switchUp . includes ( switchPrevSc ) )
switchUp . push ( switchPrevSc ) ;
if ( ! switchDown . includes ( switchNextSc ) )
switchDown . push ( switchNextSc ) ;
if ( ! moveUp . includes ( movePrevSc ) )
moveUp . push ( movePrevSc ) ;
if ( ! moveDown . includes ( moveNextSc ) )
moveDown . push ( moveNextSc ) ;
2025-02-09 23:09:13 +01:00
} else {
2025-02-09 23:13:53 +01:00
if ( ! switchLeft . includes ( switchPrevSc ) )
switchLeft . push ( switchPrevSc ) ;
if ( ! switchRight . includes ( switchNextSc ) )
switchRight . push ( switchNextSc ) ;
if ( ! moveLeft . includes ( movePrevSc ) )
moveLeft . push ( movePrevSc ) ;
if ( ! moveRight . includes ( moveNextSc ) )
moveRight . push ( moveNextSc ) ;
if ( switchUp . includes ( switchPrevSc ) )
switchUp . splice ( switchUp . indexOf ( switchPrevSc ) , 1 ) ;
if ( switchDown . includes ( switchNextSc ) )
switchDown . splice ( switchDown . indexOf ( switchNextSc ) , 1 ) ;
if ( moveUp . includes ( movePrevSc ) )
moveUp . splice ( moveUp . indexOf ( movePrevSc ) , 1 ) ;
if ( moveDown . includes ( moveNextSc ) )
moveDown . splice ( moveDown . indexOf ( moveNextSc ) , 1 ) ;
2025-02-09 23:09:13 +01:00
}
settings . set _strv ( keyLeft , switchLeft ) ;
settings . set _strv ( keyRight , switchRight ) ;
settings . set _strv ( keyUp , switchUp ) ;
settings . set _strv ( keyDown , switchDown ) ;
settings . set _strv ( keyMoveLeft , moveLeft ) ;
settings . set _strv ( keyMoveRight , moveRight ) ;
settings . set _strv ( keyMoveUp , moveUp ) ;
settings . set _strv ( keyMoveDown , moveDown ) ;
}
function _shouldAnimateOverview ( ) {
return ! opt . SHOW _WS _PREVIEW _BG || opt . OVERVIEW _MODE2 ;
}
function _updateOverviewTranslations ( dash = null , tmbBox = null , searchEntryBin = null ) {
dash = dash ? ? Main . overview . dash ;
tmbBox = tmbBox ? ? Main . overview . _overview . _controls . _thumbnailsBox ;
searchEntryBin = searchEntryBin ? ? Main . overview . _overview . _controls . _searchEntryBin ;
if ( ! _shouldAnimateOverview ( ) ) {
tmbBox . translation _x = 0 ;
tmbBox . translation _y = 0 ;
dash . translation _x = 0 ;
dash . translation _y = 0 ;
searchEntryBin . translation _x = 0 ;
searchEntryBin . translation _y = 0 ;
return ;
}
2025-02-09 23:13:53 +01:00
const [ tmbTranslationX , tmbTranslationY , dashTranslationX , dashTranslationY , searchTranslationY ] = _Util . getOverviewTranslations ( opt , dash , tmbBox , searchEntryBin ) ;
tmbBox . translation _x = tmbTranslationX ;
tmbBox . translation _y = tmbTranslationY ;
2025-02-09 23:09:13 +01:00
if ( ! _Util . dashNotDefault ( ) ) { // only if dash is not dash to dock
2025-02-09 23:13:53 +01:00
dash . translation _x = dashTranslationX ;
dash . translation _y = dashTranslationY ;
2025-02-09 23:09:13 +01:00
}
2025-02-09 23:13:53 +01:00
searchEntryBin . translation _y = searchTranslationY ;
2025-02-09 23:09:13 +01:00
}
function _setStaticBackground ( reset = false ) {
2025-02-09 23:13:53 +01:00
_bgManagers . forEach ( bg => {
2025-02-09 23:09:13 +01:00
Main . overview . _overview . _controls . _stateAdjustment . disconnect ( bg . _fadeSignal ) ;
bg . destroy ( ) ;
} ) ;
_bgManagers = [ ] ;
2025-02-09 23:13:53 +01:00
// if (!SHOW_BG_IN_OVERVIEW && !SHOW_WS_PREVIEW_BG) the background is used for static transition from wallpaper to empty bg in the overview
2025-02-09 23:09:13 +01:00
if ( reset || ( ! opt . SHOW _BG _IN _OVERVIEW && opt . SHOW _WS _PREVIEW _BG ) )
return ;
for ( const monitor of Main . layoutManager . monitors ) {
2025-02-09 23:13:53 +01:00
const bgManager = new Background . BackgroundManager ( {
monitorIndex : monitor . index ,
container : Main . layoutManager . overviewGroup ,
vignette : true ,
} ) ;
2025-02-09 23:09:13 +01:00
bgManager . backgroundActor . content . vignette _sharpness = 0 ;
bgManager . backgroundActor . content . brightness = 1 ;
2025-02-09 23:13:53 +01:00
bgManager . _fadeSignal = Main . overview . _overview . _controls . _stateAdjustment . connect ( 'notify::value' , v => {
2025-02-09 23:09:13 +01:00
_updateStaticBackground ( bgManager , v . value , v ) ;
2025-02-09 23:13:53 +01:00
} ) ;
2025-02-09 23:09:13 +01:00
if ( monitor . index === global . display . get _primary _monitor ( ) ) {
bgManager . _primary = true ;
_bgManagers . unshift ( bgManager ) ; // primary monitor first
} else {
bgManager . _primary = false ;
_bgManagers . push ( bgManager ) ;
}
}
}
function _updateStaticBackground ( bgManager , stateValue , stateAdjustment = null ) {
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 && stateAdjustment ? . getStateTransitionParams ( ) . 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 ;
2025-02-09 23:13:53 +01:00
BRIGHTNESS = opt . OVERVIEW _BG _BRIGHTNESS ;
if ( opt . OVERVIEW _MODE2 && stateValue > 1 && ! opt . WORKSPACE _MODE )
2025-02-09 23:09:13 +01:00
bgValue = stateValue - 1 ;
2025-02-09 23:13:53 +01:00
else
2025-02-09 23:09:13 +01:00
bgValue = stateValue ;
}
let blurEffect = bgManager . backgroundActor . get _effect ( 'blur' ) ;
if ( ! blurEffect ) {
blurEffect = new Shell . BlurEffect ( {
brightness : 1 ,
sigma : 0 ,
mode : Shell . BlurMode . ACTOR ,
2025-02-09 23:13:53 +01:00
} ) ;
2025-02-09 23:09:13 +01:00
bgManager . backgroundActor . add _effect _with _name ( 'blur' , blurEffect ) ;
}
bgManager . backgroundActor . content . vignette _sharpness = VIGNETTE ;
bgManager . backgroundActor . content . brightness = BRIGHTNESS ;
2025-02-09 23:13:53 +01:00
let vignetteInit , brightnessInit ; // , sigmaInit;
2025-02-09 23:09:13 +01:00
if ( opt . SHOW _BG _IN _OVERVIEW && opt . SHOW _WS _PREVIEW _BG ) {
vignetteInit = VIGNETTE ;
brightnessInit = BRIGHTNESS ;
2025-02-09 23:13:53 +01:00
// sigmaInit = opt.OVERVIEW_BG_BLUR_SIGMA;
2025-02-09 23:09:13 +01:00
} else {
vignetteInit = 0 ;
brightnessInit = 1 ;
2025-02-09 23:13:53 +01:00
// sigmaInit = 0;
2025-02-09 23:09:13 +01:00
}
if ( opt . OVERVIEW _MODE2 ) {
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 ;
2025-02-09 23:13:53 +01:00
const searchActive = Main . overview . _overview . controls . _searchController . searchActive ;
2025-02-09 23:09:13 +01:00
const progress = stateValue - ( stateValue % step ) ;
2025-02-09 23:13:53 +01:00
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
2025-02-09 23:09:13 +01:00
if ( blurEffect . sigma !== opt . OVERVIEW _BG _BLUR _SIGMA )
blurEffect . sigma = opt . OVERVIEW _BG _BLUR _SIGMA ;
2025-02-09 23:13:53 +01:00
} else if ( stateValue < 1 && ! searchActive ) {
2025-02-09 23:09:13 +01:00
const sigma = Math . round ( Util . lerp ( 0 , opt . OVERVIEW _BG _BLUR _SIGMA , progress ) ) ;
2025-02-09 23:13:53 +01:00
if ( sigma !== blurEffect . sigma )
2025-02-09 23:09:13 +01:00
blurEffect . sigma = sigma ;
2025-02-09 23:13:53 +01:00
} 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 )
2025-02-09 23:09:13 +01:00
blurEffect . sigma = sigma ;
} else if ( stateValue === 1 ) {
blurEffect . sigma = opt . OVERVIEW _BG _BLUR _SIGMA ;
} else if ( stateValue === 0 ) {
blurEffect . sigma = 0 ;
}
}
}
}
2025-02-09 23:13:53 +01:00