1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
|
/**
* V-Shell (Vertical Workspaces)
* extension.js
*
* @author GdH <G-dH@github.com>
* @copyright 2022 - 2023
* @license GPL-3.0
*
*/
'use strict';
const { GLib, Shell, St } = imports.gi;
const Main = imports.ui.main;
const Util = imports.misc.util;
const Background = imports.ui.background;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
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;
let _bgManagers;
let _enabled;
let _resetExtensionIfEnabled;
let _prevDash;
let _showingOverviewConId;
let _monitorsChangedSigId;
let _loadingProfileTimeoutId;
let _watchDockSigId;
let _resetTimeoutId;
let _enableTimeoutId = 0;
let _sessionLockActive = false;
function init() {
ExtensionUtils.initTranslations();
}
function enable() {
// globally readable flag for other extensions
global.verticalWorkspacesEnabled = true;
_enableTimeoutId = GLib.timeout_add(
GLib.PRIORITY_DEFAULT,
400,
() => {
activateVShell();
// unlock after modules update to avoid unnecessary appGrid rebuild
_sessionLockActive = Main.sessionMode.isLocked;
log(`${Me.metadata.name}: enabled`);
_enableTimeoutId = 0;
return GLib.SOURCE_REMOVE;
}
);
}
function disable() {
_sessionLockActive = Main.sessionMode.isLocked;
if (_enableTimeoutId) {
GLib.source_remove(_enableTimeoutId);
_enableTimeoutId = 0;
} else {
resetVShell();
}
global.verticalWorkspacesEnabled = undefined;
log(`${Me.metadata.name}: ${_sessionLockActive ? 'suspended' : 'disabled'}`);
}
// ------------------------------------------------------------------------------------------
function activateVShell() {
_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;
_monitorsChangedSigId = Main.layoutManager.connect('monitors-changed', () => _resetExtension(2000));
// 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);
// 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());
// 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'));
}
}
function resetVShell() {
_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;
}
if (_loadingProfileTimeoutId) {
GLib.source_remove(_loadingProfileTimeoutId);
_loadingProfileTimeoutId = 0;
}
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);
OverviewControlsOverride.update(reset);
WorkspaceOverride.update(reset);
WindowPreviewOverride.update(reset);
WindowManagerOverride.update(reset);
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);
// 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);
}
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;
if (_prevDash.dash !== dash || _prevDash.position !== dash._position)
_resetExtensionIfEnabled(0);
}
}
function _resetExtension(timeout = 200) {
if (_resetTimeoutId)
GLib.source_remove(_resetTimeoutId);
_resetTimeoutId = GLib.timeout_add(
GLib.PRIORITY_DEFAULT,
timeout,
() => {
if (!_enabled)
return GLib.SOURCE_REMOVE;
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...`);
resetVShell();
activateVShell();
} else if (timeout) {
log(`[${Me.metadata.name}]: resetting extension...`);
resetVShell();
activateVShell();
}
_resetTimeoutId = 0;
return GLib.SOURCE_REMOVE;
}
);
}
function _fixUbuntuDock(activate = true) {
// Workaround for Ubuntu Dock breaking overview allocations after changing monitor configuration and deactivating dock
if (_watchDockSigId) {
global.settings.disconnect(_watchDockSigId);
_watchDockSigId = 0;
}
if (_resetTimeoutId) {
GLib.source_remove(_resetTimeoutId);
_resetTimeoutId = 0;
}
_resetExtensionIfEnabled = () => {};
if (!activate)
return;
_watchDockSigId = global.settings.connect('changed::enabled-extensions', () => _resetExtension());
_resetExtensionIfEnabled = _resetExtension;
}
function _updateSettings(settings, key) {
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;
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;
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;
}
opt.DASH_VISIBLE = opt.DASH_VISIBLE && !_Util.getEnabledExtensions('dash-to-panel@jderose9.github.com').length;
opt.MAX_ICON_SIZE = opt.get('dashMaxIconSize', true);
if (opt.MAX_ICON_SIZE < 16) {
opt.MAX_ICON_SIZE = 64;
opt.set('dashMaxIconSize', 64);
}
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;
if (!_Util.dashIsDashToDock()) { // DtD has its own opacity control
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:
style = `border-radius: ${radius}px 0 0 ${radius}px;`;
break;
case 3:
style = `border-radius: 0 ${radius}px ${radius}px 0;`;
break;
default:
style = `border-radius: ${radius}px;`;
}
Main.overview.dash._background.set_style(style);
} else {
Main.overview.dash._background.set_style('');
}
}
// 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');
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;
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;
if (settings)
_applySettings(key);
}
function _applySettings(key) {
if (key?.endsWith('-module')) {
_updateOverrides();
return;
}
_setStaticBackground();
_updateOverviewTranslations();
_switchPageShortcuts();
if (key?.includes('app-grid')) {
AppDisplayOverride.update();
return;
}
if (key?.includes('panel'))
PanelOverride.update();
if (key?.includes('dash') || key?.includes('search') || key?.includes('icon'))
DashOverride.update();
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':
WorkspaceAnimationOverride.update();
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();
}
}
function _switchPageShortcuts() {
if (!opt.get('enablePageShortcuts', true))
return;
const vertical = global.workspaceManager.layout_rows === -1;
const schema = 'org.gnome.desktop.wm.keybindings';
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) {
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);
} else {
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);
}
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;
}
const [tmbTranslationX, tmbTranslationY, dashTranslationX, dashTranslationY, searchTranslationY] = _Util.getOverviewTranslations(opt, dash, tmbBox, searchEntryBin);
tmbBox.translation_x = tmbTranslationX;
tmbBox.translation_y = tmbTranslationY;
if (!_Util.dashNotDefault()) { // only if dash is not dash to dock
dash.translation_x = dashTranslationX;
dash.translation_y = dashTranslationY;
}
searchEntryBin.translation_y = searchTranslationY;
}
function _setStaticBackground(reset = false) {
_bgManagers.forEach(bg => {
Main.overview._overview._controls._stateAdjustment.disconnect(bg._fadeSignal);
bg.destroy();
});
_bgManagers = [];
// 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))
return;
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 => {
_updateStaticBackground(bgManager, v.value, v);
});
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;
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);
}
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) {
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 searchActive = Main.overview._overview.controls._searchController.searchActive;
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) {
const sigma = Math.round(Util.lerp(0, opt.OVERVIEW_BG_BLUR_SIGMA, progress));
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) {
blurEffect.sigma = opt.OVERVIEW_BG_BLUR_SIGMA;
} else if (stateValue === 0) {
blurEffect.sigma = 0;
}
}
}
}
|