summaryrefslogtreecommitdiffstats
path: root/extensions/vertical-workspaces/lib/workspacesView.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--extensions/vertical-workspaces/lib/workspacesView.js (renamed from extensions/vertical-workspaces/workspacesView.js)530
1 files changed, 300 insertions, 230 deletions
diff --git a/extensions/vertical-workspaces/workspacesView.js b/extensions/vertical-workspaces/lib/workspacesView.js
index 820ea6b..e3575f1 100644
--- a/extensions/vertical-workspaces/workspacesView.js
+++ b/extensions/vertical-workspaces/lib/workspacesView.js
@@ -1,7 +1,7 @@
/**
- * Vertical Workspaces
+ * V-Shell (Vertical Workspaces)
* workspacesView.js
- *
+ *
* @author GdH <G-dH@github.com>
* @copyright 2022 - 2023
* @license GPL-3.0
@@ -15,27 +15,30 @@ const { GObject, Clutter, Meta, St } = imports.gi;
const Main = imports.ui.main;
const Util = imports.misc.util;
const WorkspacesView = imports.ui.workspacesView;
-//const SecondaryMonitorDisplay = WorkspacesView.SecondaryMonitorDisplay;
-// first call of item defined using const in other module returns undefined
-WorkspacesView.SecondaryMonitorDisplay;
+// first reference to constant defined using const in other module returns undefined, the SecondaryMonitorDisplay const will remain empty and unused
+const SecondaryMonitorDisplay = WorkspacesView.SecondaryMonitorDisplay;
const ControlsState = imports.ui.overviewControls.ControlsState;
const FitMode = imports.ui.workspacesView.FitMode;
const SIDE_CONTROLS_ANIMATION_TIME = imports.ui.overview.ANIMATION_TIME;
const Me = imports.misc.extensionUtils.getCurrentExtension();
-const SEARCH_WINDOWS_PREFIX = Me.imports.windowSearchProvider.prefix;
-const SEARCH_RECENT_FILES_PREFIX = Me.imports.recentFilesSearchProvider.prefix;
+const SEARCH_WINDOWS_PREFIX = Me.imports.lib.windowSearchProvider.prefix;
+const SEARCH_RECENT_FILES_PREFIX = Me.imports.lib.recentFilesSearchProvider.prefix;
-const _Util = Me.imports.util;
+const _Util = Me.imports.lib.util;
let _overrides;
let opt;
-
function update(reset = false) {
- if (_overrides) {
+ opt = Me.imports.lib.settings.opt;
+ opt.DESKTOP_CUBE_ENABLED = Main.extensionManager._enabledExtensions.includes('desktop-cube@schneegans.github.com');
+ const cubeSupported = opt.DESKTOP_CUBE_ENABLED && !opt.ORIENTATION && !opt.OVERVIEW_MODE;
+
+ // if desktop cube extension is enabled while V-Shell is loaded, removeAll() would override its code
+ if (_overrides && !cubeSupported) {
_overrides.removeAll();
global.workspace_manager.override_workspace_layout(Meta.DisplayCorner.TOPLEFT, false, 1, -1);
}
@@ -46,12 +49,14 @@ function update(reset = false) {
return;
}
- opt = Me.imports.settings.opt;
_overrides = new _Util.Overrides();
- _overrides.addOverride('WorkspacesView', WorkspacesView.WorkspacesView.prototype, WorkspacesViewCommon);
+ if (!cubeSupported)
+ _overrides.addOverride('WorkspacesView', WorkspacesView.WorkspacesView.prototype, WorkspacesViewCommon);
+
_overrides.addOverride('WorkspacesDisplay', WorkspacesView.WorkspacesDisplay.prototype, WorkspacesDisplay);
+ _overrides.addOverride('ExtraWorkspaceView', WorkspacesView.ExtraWorkspaceView.prototype, ExtraWorkspaceView);
if (opt.ORIENTATION) {
// switch internal workspace orientation in GS
@@ -62,8 +67,8 @@ function update(reset = false) {
}
}
-var WorkspacesViewCommon = {
- _getFirstFitSingleWorkspaceBox: function(box, spacing, vertical) {
+const WorkspacesViewCommon = {
+ _getFirstFitSingleWorkspaceBox(box, spacing, vertical) {
let [width, height] = box.get_size();
const [workspace] = this._workspaces;
@@ -74,8 +79,8 @@ var WorkspacesViewCommon = {
// Single fit mode implies centered too
let [x1, y1] = box.get_origin();
- const [, workspaceWidth] = workspace ? workspace.get_preferred_width(Math.floor(height)) : [,width];
- const [, workspaceHeight] = workspace ? workspace.get_preferred_height(workspaceWidth) : [,height];
+ const [, workspaceWidth] = workspace ? workspace.get_preferred_width(Math.floor(height)) : [0, width];
+ const [, workspaceHeight] = workspace ? workspace.get_preferred_height(workspaceWidth) : [0, height];
if (vertical) {
x1 += (width - workspaceWidth) / 2;
@@ -85,7 +90,7 @@ var WorkspacesViewCommon = {
x1 -= currentWorkspace * (workspaceWidth + spacing);
}
- const fitSingleBox = new Clutter.ActorBox({x1, y1});
+ const fitSingleBox = new Clutter.ActorBox({ x1, y1 });
fitSingleBox.set_size(workspaceWidth, workspaceHeight);
@@ -93,11 +98,12 @@ var WorkspacesViewCommon = {
},
// set spacing between ws previews
- _getSpacing: function(box, fitMode, vertical) {
+ _getSpacing(box, fitMode, vertical) {
const [width, height] = box.get_size();
const [workspace] = this._workspaces;
- if (!workspace) return;
+ if (!workspace)
+ return 0;
let availableSpace;
let workspaceSize;
@@ -117,12 +123,12 @@ var WorkspacesViewCommon = {
},
// this function has duplicate in OverviewControls so we use one function for both to avoid issues with syncing them
- _getFitModeForState: function(state) {
+ _getFitModeForState(state) {
return _getFitModeForState(state);
},
// normal view 0, spread windows 1
- _getWorkspaceModeForOverviewState: function(state) {
+ _getWorkspaceModeForOverviewState(state) {
switch (state) {
case ControlsState.HIDDEN:
@@ -130,14 +136,15 @@ var WorkspacesViewCommon = {
case ControlsState.WINDOW_PICKER:
return opt.WORKSPACE_MODE;
case ControlsState.APP_GRID:
- return ((this._monitorIndex !== global.display.get_primary_monitor() || !opt.WS_ANIMATION) && !opt.OVERVIEW_MODE) ? 1 : 0;
+ return (this._monitorIndex !== global.display.get_primary_monitor() || !opt.WS_ANIMATION) && !opt.OVERVIEW_MODE ? 1 : 0;
}
return 0;
},
- _updateVisibility: function() {
- let workspaceManager = global.workspace_manager;
+ _updateVisibility() {
+ // replaced in _updateWorkspacesState
+ /* let workspaceManager = global.workspace_manager;
let active = workspaceManager.get_active_workspace_index();
const fitMode = this._fitModeAdjustment.value;
@@ -146,17 +153,15 @@ var WorkspacesViewCommon = {
for (let w = 0; w < this._workspaces.length; w++) {
let workspace = this._workspaces[w];
- if (this._animating || this._gestureActive || !singleFitMode) {
- //workspace.show();
- } else {
+ if (this._animating || this._gestureActive || !singleFitMode)
+ workspace.show();
+ else
workspace.visible = Math.abs(w - active) <= opt.NUMBER_OF_VISIBLE_NEIGHBORS;
- }
-
- }
+ }*/
},
// disable scaling and hide inactive workspaces
- _updateWorkspacesState: function() {
+ _updateWorkspacesState() {
const adj = this._scrollAdjustment;
const fitMode = this._fitModeAdjustment.value;
@@ -168,12 +173,11 @@ var WorkspacesViewCommon = {
this._getWorkspaceModeForOverviewState(finalState),
progress);
-
- const currentMonitor = Main.layoutManager.primaryMonitor.index;
+ const primaryMonitor = Main.layoutManager.primaryMonitor.index;
// define the transition values here to save time in each ws
let scaleX, scaleY;
- if (opt.ORIENTATION) { //vertical 1 / horizontal 0
+ if (opt.ORIENTATION) { // vertical 1 / horizontal 0
scaleX = 1;
scaleY = 0.1;
} else {
@@ -181,134 +185,143 @@ var WorkspacesViewCommon = {
scaleY = 1;
}
+ const wsScrollProgress = adj.value % 1;
const secondaryMonitor = this._monitorIndex !== global.display.get_primary_monitor();
- const blockSecondaryAppGrid = opt.OVERVIEW_MODE && currentState >= 1;
+ const blockSecondaryAppGrid = opt.OVERVIEW_MODE && currentState > 1;
// Hide inactive workspaces
this._workspaces.forEach((w, index) => {
if (!(blockSecondaryAppGrid && secondaryMonitor))
w.stateAdjustment.value = workspaceMode;
- //w.stateAdjustment.value = workspaceMode;
const distanceToCurrentWorkspace = Math.abs(adj.value - index);
const scaleProgress = 1 - Math.clamp(distanceToCurrentWorkspace, 0, 1);
// if we disable workspaces that we can't or don't need to see, transition animations will be noticeably smoother
-
// only the current ws needs to be visible during overview transition animations
// and only current and adjacent ws when switching ws
- if (opt.WORKSPACE_MAX_SPACING > 340) { // large spacing - only one workspace needs to be visible at once in the overview
- w.visible = scaleProgress || ((currentState % 1) && !distanceToCurrentWorkspace);
-
- // horizontal orientation - 2 adjacent workspaces can be visible on the screen with the current one
- // in order to keep animations as smooth as possible, hide all ws that cannot/shouldn't be visible at the given time
- } else {
- //
- w.visible = w.monitorIndex !== currentMonitor || scaleProgress || (!opt.WS_ANIMATION && distanceToCurrentWorkspace < opt.NUMBER_OF_VISIBLE_NEIGHBORS)
- || (distanceToCurrentWorkspace < opt.NUMBER_OF_VISIBLE_NEIGHBORS && currentState <= ControlsState.WINDOW_PICKER
- && ((initialState < ControlsState.APP_GRID && finalState < ControlsState.APP_GRID))
- );
-
- // after transition from APP_GRID to WINDOW_PICKER state,
- // adjacent workspaces are hidden and we need them to show up
- // make them visible during animation can impact smoothness of the animation
- // so we show them after the animation finished, scaling animation will make impression that they move in from outside the monitor
- if (!w.visible && distanceToCurrentWorkspace <= opt.NUMBER_OF_VISIBLE_NEIGHBORS && currentState === ControlsState.WINDOW_PICKER) {
- w.scale_x = scaleX;
- w.scale_y = scaleY;
- w.visible = true;
- w.ease({
- duration: 100,
- scale_x: 1,
- scale_y: 1,
- mode: Clutter.AnimationMode.EASE_OUT_QUAD,
- });
- }
+ w.visible = (this._animating && wsScrollProgress && distanceToCurrentWorkspace <= (opt.NUMBER_OF_VISIBLE_NEIGHBORS + 1)) || scaleProgress === 1 ||
+ (opt.WORKSPACE_MAX_SPACING > 340 && distanceToCurrentWorkspace <= opt.NUMBER_OF_VISIBLE_NEIGHBORS && currentState === ControlsState.WINDOW_PICKER) ||
+ (this._monitorIndex !== primaryMonitor && distanceToCurrentWorkspace <= opt.NUMBER_OF_VISIBLE_NEIGHBORS) || (!opt.WS_ANIMATION && distanceToCurrentWorkspace < opt.NUMBER_OF_VISIBLE_NEIGHBORS) ||
+ (opt.WORKSPACE_MAX_SPACING < 340 && distanceToCurrentWorkspace <= opt.NUMBER_OF_VISIBLE_NEIGHBORS && currentState <= ControlsState.WINDOW_PICKER &&
+ ((initialState < ControlsState.APP_GRID && finalState < ControlsState.APP_GRID))
+ );
+
+ // after transition from APP_GRID to WINDOW_PICKER state,
+ // adjacent workspaces are hidden and we need them to show up
+ // make them visible during animation can impact smoothness of the animation
+ // so we show them after the animation finished, scaling animation will make impression that they move in from outside the monitor
+ if (!w.visible && distanceToCurrentWorkspace === 1 && initialState === ControlsState.APP_GRID && currentState === ControlsState.WINDOW_PICKER) {
+ w.scale_x = scaleX;
+ w.scale_y = scaleY;
+ w.visible = true;
+ w.ease({
+ duration: 100,
+ scale_x: 1,
+ scale_y: 1,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ });
+ } else if (!w.visible && distanceToCurrentWorkspace <= opt.NUMBER_OF_VISIBLE_NEIGHBORS && currentState === ControlsState.WINDOW_PICKER) {
+ w.set({
+ scale_x: 1,
+ scale_y: 1,
+ });
}
// force ws preview bg corner radiuses where GS doesn't do it
- if (opt.SHOW_WS_PREVIEW_BG && opt.OVERVIEW_MODE === 1 && distanceToCurrentWorkspace < 2) {
+ if (opt.SHOW_WS_PREVIEW_BG && opt.OVERVIEW_MODE === 1 && distanceToCurrentWorkspace < 2)
w._background._updateBorderRadius(Math.min(1, w._overviewAdjustment.value));
- }
+
// hide workspace background
- if (!opt.SHOW_WS_PREVIEW_BG && w._background.opacity) {
+ if (!opt.SHOW_WS_PREVIEW_BG && w._background.opacity)
w._background.opacity = 0;
- }
});
- }
-}
+ },
+};
// SecondaryMonitorDisplay Vertical
-var SecondaryMonitorDisplayVertical = {
- _getThumbnailParamsForState: function(state) {
+const SecondaryMonitorDisplayVertical = {
+ _getThumbnailParamsForState(state) {
- let opacity, scale, translation_x;
+ let opacity, scale, translationX;
switch (state) {
case ControlsState.HIDDEN:
opacity = 255;
scale = 1;
- translation_x = 0;
- if (!Main.layoutManager._startingUp && (!opt.SHOW_WS_PREVIEW_BG || opt.OVERVIEW_MODE2)) {
- translation_x = this._thumbnails.width * (opt.SEC_WS_TMB_LEFT ? -1 : 1);
- }
+ translationX = 0;
+ if (!Main.layoutManager._startingUp && (!opt.SHOW_WS_PREVIEW_BG || opt.OVERVIEW_MODE2))
+ translationX = this._thumbnails.width * (opt.SEC_WS_TMB_LEFT ? -1 : 1);
+
break;
case ControlsState.WINDOW_PICKER:
case ControlsState.APP_GRID:
opacity = 255;
scale = 1;
- translation_x = 0;
+ translationX = 0;
break;
default:
opacity = 255;
scale = 1;
- translation_x = 0;
+ translationX = 0;
break;
}
- return { opacity, scale, translation_x };
+ return { opacity, scale, translationX };
},
- _getThumbnailsWidth: function(box, spacing) {
- if (!this._thumbnails.visible)
+ _getThumbnailsWidth(box, spacing) {
+ if (opt.SEC_WS_TMB_HIDDEN)
return 0;
const [width, height] = box.get_size();
const { expandFraction } = this._thumbnails;
const [, thumbnailsWidth] = this._thumbnails.get_preferred_custom_width(height - 2 * spacing);
+ let scaledWidth;
+ if (opt.SEC_WS_PREVIEW_SHIFT && !opt.PANEL_DISABLED)
+ scaledWidth = ((height - Main.panel.height) * opt.SEC_MAX_THUMBNAIL_SCALE) * (width / height);
+ else
+ scaledWidth = width * opt.SEC_MAX_THUMBNAIL_SCALE;
+
return Math.min(
thumbnailsWidth * expandFraction,
- width * opt.MAX_THUMBNAIL_SCALE);
+ Math.round(scaledWidth));
},
- _getWorkspacesBoxForState: function(state, box, padding, thumbnailsWidth, spacing) {
- //const { ControlsState } = OverviewControls;
+ _getWorkspacesBoxForState(state, box, padding, thumbnailsWidth, spacing) {
+ // const { ControlsState } = OverviewControls;
const workspaceBox = box.copy();
const [width, height] = workspaceBox.get_size();
+ let wWidth, wHeight, wsbX, wsbY, offset, yShift;
switch (state) {
case ControlsState.HIDDEN:
break;
case ControlsState.WINDOW_PICKER:
case ControlsState.APP_GRID:
- if (opt.OVERVIEW_MODE2 && !opt.WORKSPACE_MODE) {
+ if (opt.OVERVIEW_MODE2 && !opt.WORKSPACE_MODE)
break;
+
+ yShift = 0;
+ if (opt.SEC_WS_PREVIEW_SHIFT && !opt.PANEL_DISABLED) {
+ if (opt.PANEL_POSITION_TOP)
+ yShift = Main.panel.height;
+ else
+ yShift = -Main.panel.height;
}
- let wWidth = Math.round(width - thumbnailsWidth - 5 * spacing);
- let wHeight = Math.round(Math.min(wWidth / (width / height), height - 1.7 * padding));
- wWidth *= opt.WS_PREVIEW_SCALE;
- wHeight *= opt.WS_PREVIEW_SCALE;
+ wWidth = width - thumbnailsWidth - 5 * spacing;
+ wHeight = Math.min(wWidth / (width / height) - Math.abs(yShift), height - 4 * spacing);
+ wWidth = Math.round(wWidth * opt.SEC_WS_PREVIEW_SCALE);
+ wHeight = Math.round(wHeight * opt.SEC_WS_PREVIEW_SCALE);
- let wsbX;
- let offset = Math.round(width - thumbnailsWidth - wWidth) / 2;
- if (opt.SEC_WS_TMB_LEFT) {
+ offset = Math.round(width - thumbnailsWidth - wWidth) / 2;
+ if (opt.SEC_WS_TMB_LEFT)
wsbX = thumbnailsWidth + offset;
- } else {
+ else
wsbX = offset;
- }
- const wsbY = Math.round((height - wHeight) / 2);
+ wsbY = Math.round((height - wHeight - Math.abs(yShift)) / 2 + yShift);
workspaceBox.set_origin(wsbX, wsbY);
workspaceBox.set_size(wWidth, wHeight);
@@ -318,7 +331,7 @@ var SecondaryMonitorDisplayVertical = {
return workspaceBox;
},
- vfunc_allocate: function(box) {
+ vfunc_allocate(box) {
this.set_allocation(box);
const themeNode = this.get_theme_node();
@@ -332,7 +345,7 @@ var SecondaryMonitorDisplayVertical = {
let [, thumbnailsHeight] = this._thumbnails.get_preferred_custom_height(thumbnailsWidth);
thumbnailsHeight = Math.min(thumbnailsHeight, height - 2 * spacing);
- this._thumbnails.visible = opt.SHOW_WS_TMB;
+ this._thumbnails.visible = !opt.SEC_WS_TMB_HIDDEN;
if (this._thumbnails.visible) {
let wsTmbX;
if (opt.SEC_WS_TMB_LEFT) { // left
@@ -373,13 +386,12 @@ var SecondaryMonitorDisplayVertical = {
this._workspacesView.allocate(workspacesBox);
},
- _updateThumbnailVisibility: function() {
- if (opt.OVERVIEW_MODE2) {
+ _updateThumbnailVisibility() {
+ if (opt.OVERVIEW_MODE2)
this.set_child_above_sibling(this._thumbnails, null);
- }
- const visible = !(this._settings.get_boolean('workspaces-only-on-primary') ||
- opt.SEC_WS_TMB_POSITION === 3); // 3 - disabled
+
+ const visible = !opt.SEC_WS_TMB_HIDDEN;
if (this._thumbnails.visible === visible)
return;
@@ -396,15 +408,15 @@ var SecondaryMonitorDisplayVertical = {
});
},
- _updateThumbnailParams: function() {
+ _updateThumbnailParams() {
+ if (opt.SEC_WS_TMB_HIDDEN)
+ return;
+
// workaround for upstream bug - secondary thumbnails boxes don't catch 'showing' signal on the shell startup and don't populate the box with thumbnails
// the tmbBox contents is also destroyed when overview state adjustment gets above 1 when swiping gesture from window picker to app grid
- if (!this._thumbnails._thumbnails.length) {
+ if (!this._thumbnails._thumbnails.length)
this._thumbnails._createThumbnails();
- }
- if (!this._thumbnails.visible)
- return;
const { initialState, finalState, progress } =
this._overviewAdjustment.getStateTransitionParams();
@@ -412,113 +424,122 @@ var SecondaryMonitorDisplayVertical = {
const initialParams = this._getThumbnailParamsForState(initialState);
const finalParams = this._getThumbnailParamsForState(finalState);
- /*const opacity =
+ /* const opacity =
Util.lerp(initialParams.opacity, finalParams.opacity, progress);
const scale =
Util.lerp(initialParams.scale, finalParams.scale, progress);*/
// 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);
- const translation_x = (!Main.layoutManager._startingUp && ((!opt.SHOW_WS_PREVIEW_BG && !(opt.OVERVIEW_MODE2)) || animateOverviewMode2))
- ? Util.lerp(initialParams.translation_x, finalParams.translation_x, progress)
+ const translationX = !Main.layoutManager._startingUp && ((!opt.SHOW_WS_PREVIEW_BG && !opt.OVERVIEW_MODE2) || animateOverviewMode2)
+ ? Util.lerp(initialParams.translationX, finalParams.translationX, progress)
: 0;
this._thumbnails.set({
opacity: 255,
- //scale_x: scale,
- //scale_y: scale,
- translation_x,
+ // scale_x: scale,
+ // scale_y: scale,
+ translation_x: translationX,
});
},
- _updateWorkspacesView: function() {
+ _updateWorkspacesView() {
if (this._workspacesView)
this._workspacesView.destroy();
if (this._settings.get_boolean('workspaces-only-on-primary')) {
+ opt.SEC_WS_TMB_HIDDEN = true;
this._workspacesView = new WorkspacesView.ExtraWorkspaceView(
this._monitorIndex,
this._overviewAdjustment);
} else {
+ opt.SEC_WS_TMB_HIDDEN = !opt.SHOW_SEC_WS_TMB;
this._workspacesView = new WorkspacesView.WorkspacesView(
this._monitorIndex,
this._controls,
this._scrollAdjustment,
// Secondary monitors don't need FitMode.ALL since there is workspace switcher always visible
- //this._fitModeAdjustment,
+ // this._fitModeAdjustment,
new St.Adjustment({
actor: this,
- value: 0,//FitMode.SINGLE,
- lower: 0,//FitMode.SINGLE,
- upper: 0,//FitMode.SINGLE,
+ value: 0, // FitMode.SINGLE,
+ lower: 0, // FitMode.SINGLE,
+ upper: 0, // FitMode.SINGLE,
}),
- //secondaryOverviewAdjustment);
+ // secondaryOverviewAdjustment);
this._overviewAdjustment);
}
this.add_child(this._workspacesView);
this._thumbnails.opacity = 0;
- }
-}
+ },
+};
// SecondaryMonitorDisplay Horizontal
-var SecondaryMonitorDisplayHorizontal = {
- _getThumbnailParamsForState: function(state) {
- //const { ControlsState } = OverviewControls;
+const SecondaryMonitorDisplayHorizontal = {
+ _getThumbnailParamsForState(state) {
+ // const { ControlsState } = OverviewControls;
- let opacity, scale, translation_y;
+ let opacity, scale, translationY;
switch (state) {
case ControlsState.HIDDEN:
opacity = 255;
scale = 1;
- translation_y = 0;
- if (!Main.layoutManager._startingUp && (!opt.SHOW_WS_PREVIEW_BG || opt.OVERVIEW_MODE2)) {
- translation_y = this._thumbnails.height * (opt.SEC_WS_TMB_TOP ? -1 : 1);
- }
+ translationY = 0;
+ if (!Main.layoutManager._startingUp && (!opt.SHOW_WS_PREVIEW_BG || opt.OVERVIEW_MODE2))
+ translationY = this._thumbnails.height * (opt.SEC_WS_TMB_TOP ? -1 : 1);
+
break;
case ControlsState.WINDOW_PICKER:
case ControlsState.APP_GRID:
opacity = 255;
scale = 1;
- translation_y = 0;
+ translationY = 0;
break;
default:
opacity = 255;
scale = 1;
- translation_y = 0;
+ translationY = 0;
break;
}
- return { opacity, scale, translation_y };
+ return { opacity, scale, translationY };
},
- _getWorkspacesBoxForState: function(state, box, padding, thumbnailsHeight, spacing) {
- //const { ControlsState } = OverviewControls;
+ _getWorkspacesBoxForState(state, box, padding, thumbnailsHeight, spacing) {
+ // const { ControlsState } = OverviewControls;
const workspaceBox = box.copy();
const [width, height] = workspaceBox.get_size();
+ let wWidth, wHeight, wsbX, wsbY, offset, yShift;
switch (state) {
case ControlsState.HIDDEN:
break;
case ControlsState.WINDOW_PICKER:
case ControlsState.APP_GRID:
- if (opt.OVERVIEW_MODE2 && !opt.WORKSPACE_MODE) {
+ if (opt.OVERVIEW_MODE2 && !opt.WORKSPACE_MODE)
break;
+
+ yShift = 0;
+ if (opt.SEC_WS_PREVIEW_SHIFT && !opt.PANEL_DISABLED) {
+ if (opt.PANEL_POSITION_TOP)
+ yShift = Main.panel.height;
+ else
+ yShift = -Main.panel.height;
}
- let wHeight = Math.round(Math.min(height - thumbnailsHeight - 5 * spacing));
- let wWidth = Math.round(Math.min(wHeight * (width / height), width - 1.7 * padding));
- wWidth *= opt.WS_PREVIEW_SCALE;
- wHeight *= opt.WS_PREVIEW_SCALE;
+ wHeight = height - Math.abs(yShift) - (thumbnailsHeight ? thumbnailsHeight + 4 * spacing : padding);
+ wWidth = Math.min(wHeight * (width / height), width - 5 * spacing);
+ wWidth = Math.round(wWidth * opt.SEC_WS_PREVIEW_SCALE);
+ wHeight = Math.round(wHeight * opt.SEC_WS_PREVIEW_SCALE);
- let wsbY;
- let offset = Math.round((height - thumbnailsHeight - wHeight) / 2);
- if (opt.WS_TMB_TOP) {
+ offset = Math.round((height - thumbnailsHeight - wHeight - Math.abs(yShift)) / 2);
+ if (opt.SEC_WS_TMB_TOP)
wsbY = thumbnailsHeight + offset;
- } else {
+ else
wsbY = offset;
- }
- const wsbX = Math.round((width - wWidth) / 2);
+ wsbY += yShift;
+ wsbX = Math.round((width - wWidth) / 2);
workspaceBox.set_origin(wsbX, wsbY);
workspaceBox.set_size(wWidth, wHeight);
@@ -528,8 +549,8 @@ var SecondaryMonitorDisplayHorizontal = {
return workspaceBox;
},
- _getThumbnailsHeight: function(box) {
- if (!this._thumbnails.visible)
+ _getThumbnailsHeight(box) {
+ if (opt.SEC_WS_TMB_HIDDEN)
return 0;
const [width, height] = box.get_size();
@@ -537,10 +558,10 @@ var SecondaryMonitorDisplayHorizontal = {
const [thumbnailsHeight] = this._thumbnails.get_preferred_height(width);
return Math.min(
thumbnailsHeight * expandFraction,
- height * opt.MAX_THUMBNAIL_SCALE);
+ height * opt.SEC_MAX_THUMBNAIL_SCALE);
},
- vfunc_allocate: function(box) {
+ vfunc_allocate(box) {
this.set_allocation(box);
const themeNode = this.get_theme_node();
@@ -554,14 +575,14 @@ var SecondaryMonitorDisplayHorizontal = {
let [, thumbnailsWidth] = this._thumbnails.get_preferred_custom_width(thumbnailsHeight);
thumbnailsWidth = Math.min(thumbnailsWidth, width - 2 * spacing);
- this._thumbnails.visible = opt.SHOW_WS_TMB;
+ this._thumbnails.visible = !opt.SEC_WS_TMB_HIDDEN;
if (this._thumbnails.visible) {
let wsTmbY;
- if (opt.SEC_WS_TMB_TOP) {
+ if (opt.SEC_WS_TMB_TOP)
wsTmbY = Math.round(spacing / 4);
- } else {
+ else
wsTmbY = Math.round(height - spacing / 4 - thumbnailsHeight);
- }
+
const childBox = new Clutter.ActorBox();
const availSpace = width - thumbnailsWidth - 2 * spacing;
@@ -595,15 +616,15 @@ var SecondaryMonitorDisplayHorizontal = {
_updateThumbnailVisibility: SecondaryMonitorDisplayVertical._updateThumbnailVisibility,
- _updateThumbnailParams: function() {
+ _updateThumbnailParams() {
+ if (opt.SEC_WS_TMB_HIDDEN)
+ return;
+
// workaround for upstream bug - secondary thumbnails boxes don't catch 'showing' signal on the shell startup and don't populate the box with thumbnails
// the tmbBox contents is also destroyed when overview state adjustment gets above 1 when swiping gesture from window picker to app grid
- if (!this._thumbnails._thumbnails.length) {
+ if (!this._thumbnails._thumbnails.length)
this._thumbnails._createThumbnails();
- }
- if (!this._thumbnails.visible)
- return;
const { initialState, finalState, progress } =
this._overviewAdjustment.getStateTransitionParams();
@@ -611,56 +632,79 @@ var SecondaryMonitorDisplayHorizontal = {
const initialParams = this._getThumbnailParamsForState(initialState);
const finalParams = this._getThumbnailParamsForState(finalState);
- /*const opacity =
+ /* const opacity =
Util.lerp(initialParams.opacity, finalParams.opacity, progress);
const scale =
Util.lerp(initialParams.scale, finalParams.scale, progress);*/
// 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);
- const translation_y = (!Main.layoutManager._startingUp && ((!opt.SHOW_WS_PREVIEW_BG && !(opt.OVERVIEW_MODE2)) || animateOverviewMode2))
- ? Util.lerp(initialParams.translation_y, finalParams.translation_y, progress)
+ const translationY = !Main.layoutManager._startingUp && ((!opt.SHOW_WS_PREVIEW_BG && !opt.OVERVIEW_MODE2) || animateOverviewMode2)
+ ? Util.lerp(initialParams.translationY, finalParams.translationY, progress)
: 0;
this._thumbnails.set({
opacity: 255,
- //scale_x: scale,
- //scale_y: scale,
- translation_y,
+ // scale_x: scale,
+ // scale_y: scale,
+ translation_y: translationY,
});
},
- _updateWorkspacesView: function() {
+ _updateWorkspacesView() {
if (this._workspacesView)
this._workspacesView.destroy();
if (this._settings.get_boolean('workspaces-only-on-primary')) {
+ opt.SEC_WS_TMB_HIDDEN = true;
this._workspacesView = new WorkspacesView.ExtraWorkspaceView(
this._monitorIndex,
this._overviewAdjustment);
} else {
+ opt.SEC_WS_TMB_HIDDEN = !opt.SHOW_SEC_WS_TMB;
this._workspacesView = new WorkspacesView.WorkspacesView(
this._monitorIndex,
this._controls,
this._scrollAdjustment,
// Secondary monitors don't need FitMode.ALL since there is workspace switcher always visible
- //this._fitModeAdjustment,
+ // this._fitModeAdjustment,
new St.Adjustment({
actor: this,
- value: 0,//FitMode.SINGLE,
- lower: 0,//FitMode.SINGLE,
- upper: 0,//FitMode.SINGLE,
+ value: 0, // FitMode.SINGLE,
+ lower: 0, // FitMode.SINGLE,
+ upper: 0, // FitMode.SINGLE,
}),
- //secondaryOverviewAdjustment);
+ // secondaryOverviewAdjustment);
this._overviewAdjustment);
}
this.add_child(this._workspacesView);
this._thumbnails.opacity = 0;
- }
-}
+ },
+};
+
+const ExtraWorkspaceView = {
+ _updateWorkspaceMode() {
+ const overviewState = this._overviewAdjustment.value;
-var WorkspacesDisplay = {
- _updateWorkspacesViews: function() {
+ const progress = Math.clamp(overviewState,
+ ControlsState.HIDDEN,
+ opt.OVERVIEW_MODE && !opt.WORKSPACE_MODE ? ControlsState.HIDDEN : ControlsState.WINDOW_PICKER);
+
+ this._workspace.stateAdjustment.value = progress;
+
+ // force ws preview bg corner radiuses where GS doesn't do it
+ if (opt.SHOW_WS_PREVIEW_BG && opt.OVERVIEW_MODE === 1)
+ this._workspace._background._updateBorderRadius(Math.min(1, this._workspace._overviewAdjustment.value));
+
+
+ // hide workspace background
+ if (!opt.SHOW_WS_PREVIEW_BG && this._workspace._background.opacity)
+ this._workspace._background.opacity = 0;
+ },
+};
+
+const WorkspacesDisplay = {
+ _updateWorkspacesViews() {
for (let i = 0; i < this._workspacesViews.length; i++)
this._workspacesViews[i].destroy();
@@ -684,12 +728,12 @@ var WorkspacesDisplay = {
this._controls,
this._scrollAdjustment,
// Secondary monitors don't need FitMode.ALL since there is workspace switcher always visible
- //this._fitModeAdjustment,
+ // this._fitModeAdjustment,
new St.Adjustment({
actor: this,
- value: 0,//FitMode.SINGLE,
- lower: 0,//FitMode.SINGLE,
- upper: 0,//FitMode.SINGLE,
+ value: 0, // FitMode.SINGLE,
+ lower: 0, // FitMode.SINGLE,
+ upper: 0, // FitMode.SINGLE,
}),
this._overviewAdjustment);
Main.layoutManager.overviewGroup.add_actor(view);
@@ -699,7 +743,7 @@ var WorkspacesDisplay = {
}
},
- _onScrollEvent: function(actor, event) {
+ _onScrollEvent(actor, event) {
if (this._swipeTracker.canHandleScrollEvent(event))
return Clutter.EVENT_PROPAGATE;
@@ -707,35 +751,37 @@ var WorkspacesDisplay = {
return Clutter.EVENT_PROPAGATE;
if (this._workspacesOnlyOnPrimary &&
- this._getMonitorIndexForEvent(event) != this._primaryIndex)
+ this._getMonitorIndexForEvent(event) !== this._primaryIndex)
return Clutter.EVENT_PROPAGATE;
- const isShiftPressed = (event.get_state() & Clutter.ModifierType.SHIFT_MASK) != 0;
- /*const isCtrlPressed = (event.get_state() & Clutter.ModifierType.CONTROL_MASK) != 0;
- const isAltPressed = (event.get_state() & Clutter.ModifierType.MOD1_MASK) != 0;
- const noModifiersPressed = !(isCtrlPressed && isShiftPressed && isAltPressed);
-
- if (OVERVIEW_MODE2 && noModifiersPressed) {
- Main.overview.hide();
- return Clutter.EVENT_STOP;
- }*/
+ if (opt.PANEL_MODE === 1) {
+ const panelBox = Main.layoutManager.panelBox;
+ const [, y] = global.get_pointer();
+ if (y > panelBox.allocation.y1 && y < panelBox.allocation.y2)
+ return Clutter.EVENT_STOP;
+ }
- let direction = event.get_scroll_direction();
+ if (_Util.isShiftPressed()) {
+ let direction = _Util.getScrollDirection(event);
+ if (direction === null || (Date.now() - this._lastScrollTime) < 150)
+ return Clutter.EVENT_STOP;
+ this._lastScrollTime = Date.now();
- if (/*SHIFT_REORDERS_WS && */isShiftPressed) {
- if (direction === Clutter.ScrollDirection.UP) {
+ if (direction === Clutter.ScrollDirection.UP)
direction = -1;
- }
- else if (direction === Clutter.ScrollDirection.DOWN) {
+
+ else if (direction === Clutter.ScrollDirection.DOWN)
direction = 1;
- } else {
+ else
direction = 0;
- }
+
if (direction) {
- _reorderWorkspace(direction);
+ _Util.reorderWorkspace(direction);
// make all workspaces on primary monitor visible for case the new position is hidden
- Main.overview._overview._controls._workspacesDisplay._workspacesViews[0]._workspaces.forEach(w => w.visible = true);
+ Main.overview._overview._controls._workspacesDisplay._workspacesViews[0]._workspaces.forEach(w => {
+ w.visible = true;
+ });
return Clutter.EVENT_STOP;
}
}
@@ -743,24 +789,30 @@ var WorkspacesDisplay = {
return Main.wm.handleWorkspaceScroll(event);
},
- _onKeyPressEvent: function(actor, event) {
+ _onKeyPressEvent(actor, event) {
const symbol = event.get_key_symbol();
- /*const { ControlsState } = OverviewControls;
+ /* const { ControlsState } = OverviewControls;
if (this._overviewAdjustment.value !== ControlsState.WINDOW_PICKER && symbol !== Clutter.KEY_space)
return Clutter.EVENT_PROPAGATE;*/
- /*if (!this.reactive)
- return Clutter.EVENT_PROPAGATE;**/
- const isCtrlPressed = (event.get_state() & Clutter.ModifierType.CONTROL_MASK) != 0;
- const isShiftPressed = (event.get_state() & Clutter.ModifierType.SHIFT_MASK) != 0;
- const isAltPressed = (event.get_state() & Clutter.ModifierType.MOD1_MASK) != 0;
+ /* if (!this.reactive)
+ return Clutter.EVENT_PROPAGATE; */
const { workspaceManager } = global;
const vertical = workspaceManager.layout_rows === -1;
const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
+ const state = this._overviewAdjustment.value;
let which;
switch (symbol) {
- /*case Clutter.KEY_Return:*/
+ case Clutter.KEY_Return:
+ case Clutter.KEY_KP_Enter:
+ if (_Util.isCtrlPressed()) {
+ Main.ctrlAltTabManager._items.forEach(i => {
+ if (i.sortGroup === 1 && i.name === 'Dash')
+ Main.ctrlAltTabManager.focusGroup(i);
+ });
+ }
+ return Clutter.EVENT_STOP;
case Clutter.KEY_Page_Up:
if (vertical)
which = Meta.MotionDirection.UP;
@@ -784,30 +836,57 @@ var WorkspacesDisplay = {
which = workspaceManager.n_workspaces - 1;
break;
case Clutter.KEY_space:
- if (isCtrlPressed && isShiftPressed) {
+ if (_Util.isCtrlPressed() && _Util.isShiftPressed()) {
_Util.openPreferences();
- } else if (isAltPressed) {
- Main.ctrlAltTabManager._items.forEach(i => {if (i.sortGroup === 1 && i.name === 'Dash') Main.ctrlAltTabManager.focusGroup(i)});
- } else if (opt.RECENT_FILES_SEARCH_PROVIDER_ENABLED && isCtrlPressed) {
+ } else if (_Util.isAltPressed()) {
+ Main.ctrlAltTabManager._items.forEach(i => {
+ if (i.sortGroup === 1 && i.name === 'Dash')
+ Main.ctrlAltTabManager.focusGroup(i);
+ });
+ } else if (opt.RECENT_FILES_SEARCH_PROVIDER_ENABLED && _Util.isCtrlPressed()) {
_Util.activateSearchProvider(SEARCH_RECENT_FILES_PREFIX);
- } else if (opt.WINDOW_SEARCH_PROVIDER_ENABLED/* && SEARCH_WINDOWS_SPACE*/) {
+ } else if (opt.WINDOW_SEARCH_PROVIDER_ENABLED) {
_Util.activateSearchProvider(SEARCH_WINDOWS_PREFIX);
}
+
return Clutter.EVENT_STOP;
case Clutter.KEY_Down:
case Clutter.KEY_Left:
case Clutter.KEY_Right:
case Clutter.KEY_Up:
+ case Clutter.KEY_Tab:
if (Main.overview._overview._controls._searchController.searchActive) {
Main.overview.searchEntry.grab_key_focus();
- } else /*if (OVERVIEW_MODE && !WORKSPACE_MODE)*/ {
- Main.ctrlAltTabManager._items.forEach(i => {if (i.sortGroup === 1 && i.name === 'Dash') Main.ctrlAltTabManager.focusGroup(i)});
+ } else if (opt.OVERVIEW_MODE2 && !opt.WORKSPACE_MODE && state === 1) {
+ // expose windows by "clicking" on ws thumbnail
+ // in this case overview stateAdjustment will be used for transition
+ Main.overview._overview.controls._thumbnailsBox._activateThumbnailAtPoint(0, 0, global.get_current_time(), true);
+ Main.ctrlAltTabManager._items.forEach(i => {
+ if (i.sortGroup === 1 && i.name === 'Windows')
+ Main.ctrlAltTabManager.focusGroup(i);
+ });
+ } else if (opt.OVERVIEW_MODE && !opt.WORKSPACE_MODE && state === 1) {
+ // expose windows for OVERVIEW_MODE 1
+ const adjustment = this._workspacesViews[0]._workspaces[global.workspace_manager.get_active_workspace().index()]._background._stateAdjustment;
+ opt.WORKSPACE_MODE = 1;
+ _Util.exposeWindows(adjustment, true);
+ } else {
+ if (state === 2)
+ return Clutter.EVENT_PROPAGATE;
+ Main.ctrlAltTabManager._items.forEach(i => {
+ if (i.sortGroup === 1 && i.name === 'Windows')
+ Main.ctrlAltTabManager.focusGroup(i);
+ });
}
+
return Clutter.EVENT_STOP;
default:
return Clutter.EVENT_PROPAGATE;
}
+ if (state === 2)
+ return Clutter.EVENT_PROPAGATE;
+
let ws;
if (which < 0)
// Negative workspace numbers are directions
@@ -816,17 +895,19 @@ var WorkspacesDisplay = {
// Otherwise it is a workspace index
ws = workspaceManager.get_workspace_by_index(which);
- if (/*SHIFT_REORDERS_WS && */isShiftPressed) {
+ if (_Util.isShiftPressed()) {
let direction;
if (which === Meta.MotionDirection.UP || which === Meta.MotionDirection.LEFT)
direction = -1;
else if (which === Meta.MotionDirection.DOWN || which === Meta.MotionDirection.RIGHT)
direction = 1;
if (direction)
- _reorderWorkspace(direction);
+ _Util.reorderWorkspace(direction);
// make all workspaces on primary monitor visible for case the new position is hidden
- Main.overview._overview._controls._workspacesDisplay._workspacesViews[0]._workspaces.forEach(w => w.visible = true);
- return Clutter.EVENT_STOP;
+ Main.overview._overview._controls._workspacesDisplay._workspacesViews[0]._workspaces.forEach(w => {
+ w.visible = true;
+ });
+ return Clutter.EVENT_STOP;
}
if (ws)
@@ -834,7 +915,7 @@ var WorkspacesDisplay = {
return Clutter.EVENT_STOP;
},
-}
+};
// same copy of this function should be available in OverviewControls and WorkspacesView
function _getFitModeForState(state) {
@@ -851,14 +932,3 @@ function _getFitModeForState(state) {
return FitMode.SINGLE;
}
}
-
-// ------------------ Reorder Workspaces - callback for Dash and workspacesDisplay -----------------------------------
-
-function _reorderWorkspace(direction = 0) {
- let activeWs = global.workspace_manager.get_active_workspace();
- let activeWsIdx = activeWs.index();
- let targetIdx = activeWsIdx + direction;
- if (targetIdx > -1 && targetIdx < (global.workspace_manager.get_n_workspaces())) {
- global.workspace_manager.reorder_workspace(activeWs, targetIdx);
- }
-}