summaryrefslogtreecommitdiffstats
path: root/extensions/46/vertical-workspaces/lib/workspacesView.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/46/vertical-workspaces/lib/workspacesView.js')
-rw-r--r--extensions/46/vertical-workspaces/lib/workspacesView.js299
1 files changed, 154 insertions, 145 deletions
diff --git a/extensions/46/vertical-workspaces/lib/workspacesView.js b/extensions/46/vertical-workspaces/lib/workspacesView.js
index 8e20db3..5c0d36b 100644
--- a/extensions/46/vertical-workspaces/lib/workspacesView.js
+++ b/extensions/46/vertical-workspaces/lib/workspacesView.js
@@ -69,6 +69,8 @@ export const WorkspacesViewModule = class {
if (!desktopCubeConflict)
this._overrides.addOverride('WorkspacesView', WorkspacesView.WorkspacesView.prototype, WorkspacesViewCommon);
+ else
+ this._overrides.removeOverride('WorkspacesView');
this._overrides.addOverride('WorkspacesDisplay', WorkspacesView.WorkspacesDisplay.prototype, WorkspacesDisplayCommon);
this._overrides.addOverride('ExtraWorkspaceView', WorkspacesView.ExtraWorkspaceView.prototype, ExtraWorkspaceViewCommon);
@@ -208,18 +210,26 @@ const WorkspacesViewCommon = {
// 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
- 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))
- );
+ w.visible =
+ (this._animating && wsScrollProgress && distanceToCurrentWorkspace <= (opt.NUMBER_OF_VISIBLE_NEIGHBORS + 1)) ||
+ scaleProgress === 1 ||
+ (opt.WORKSPACE_MAX_SPACING >= opt.WS_MAX_SPACING_OFF_SCREEN &&
+ 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) ||
+ (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, move them to their position from outside of the monitor
- if (!w.visible && distanceToCurrentWorkspace === 1 && initialState === ControlsState.APP_GRID && currentState === ControlsState.WINDOW_PICKER) {
+ if (currentState === ControlsState.WINDOW_PICKER && !w.visible && distanceToCurrentWorkspace <= opt.NUMBER_OF_VISIBLE_NEIGHBORS && initialState === ControlsState.APP_GRID) {
+ w.remove_all_transitions();
w.visible = true;
const directionNext = distance > 0;
if (!opt.ORIENTATION) {
@@ -315,115 +325,103 @@ const SecondaryMonitorDisplayVertical = {
return { opacity, scale, translationX };
},
- _getThumbnailsWidth(box, spacing) {
- if (opt.SEC_WS_TMB_HIDDEN)
- return 0;
+ _getWorkspacesBoxForState(state, box, workArea, wsTmbWidth, spacing) {
+ let workspaceBox = box.copy();
- const [width, height] = box.get_size();
- const { expandFraction } = this._thumbnails;
- const [, thumbnailsWidth] = this._thumbnails.get_preferred_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;
+ if (
+ (state === ControlsState.WINDOW_PICKER || state === ControlsState.APP_GRID) &&
+ !(opt.OVERVIEW_MODE2 && !opt.WORKSPACE_MODE)
+ ) {
+ workspaceBox = workArea.copy();
+ const [startX, startY] = workspaceBox.get_origin();
+ let [width, height] = workspaceBox.get_size();
- return Math.min(
- thumbnailsWidth * expandFraction,
- Math.round(scaledWidth));
- },
+ let wsBoxWidth = width - (wsTmbWidth ? wsTmbWidth + spacing : 0) - 2 * spacing;
+ let wsBoxHeight = height - 2 * spacing;
- _getWorkspacesBoxForState(state, box, thumbnailsWidth, spacing, startY, panelHeight) {
- // const { ControlsState } = OverviewControls;
- const workspaceBox = box.copy();
- let [width, height] = workspaceBox.get_size();
- height -= panelHeight;
+ const ratio = width / height;
+ let wRatio = wsBoxWidth / wsBoxHeight;
+ let scale = ratio / wRatio;
- let wWidth, wHeight, wsbX, wsbY, offset;
- switch (state) {
- case ControlsState.HIDDEN:
- break;
- case ControlsState.WINDOW_PICKER:
- case ControlsState.APP_GRID:
- if (opt.OVERVIEW_MODE2 && !opt.WORKSPACE_MODE)
- break;
+ if (scale > 1) {
+ wsBoxHeight /= scale;
+ wsBoxWidth = wsBoxHeight * ratio;
+ } else {
+ wsBoxWidth *= scale;
+ wsBoxHeight = wsBoxWidth / ratio;
+ }
- wWidth = width - thumbnailsWidth - 5 * spacing;
- wHeight = Math.min(wWidth / (width / height), height - 4 * spacing);
- wWidth = Math.round(wWidth * opt.SEC_WS_PREVIEW_SCALE);
- wHeight = Math.round(wHeight * opt.SEC_WS_PREVIEW_SCALE);
+ // height decides the actual size, ratio is given by the workArea
+ wsBoxHeight = Math.round(wsBoxHeight * opt.SEC_WS_PREVIEW_SCALE);
+ wsBoxWidth = Math.round(wsBoxWidth * opt.SEC_WS_PREVIEW_SCALE);
- offset = Math.round(width - thumbnailsWidth - wWidth) / 2;
- if (opt.SEC_WS_TMB_LEFT)
- wsbX = thumbnailsWidth + offset;
- else
- wsbX = offset;
+ let offset = Math.round(width - wsTmbWidth - wsBoxWidth - spacing) / 2;
- wsbY = Math.round((startY + height - wHeight) / 2);
+ const wsbX = startX + opt.SEC_WS_TMB_LEFT
+ ? wsTmbWidth + spacing + offset
+ : offset;
+
+ const wsbY = Math.round((startY + height - wsBoxHeight) / 2);
workspaceBox.set_origin(wsbX, wsbY);
- workspaceBox.set_size(wWidth, wHeight);
- break;
+ workspaceBox.set_size(wsBoxWidth, wsBoxHeight);
}
return workspaceBox;
},
+ _getWorkAreaBox(box) {
+ if (!opt.SEC_WS_PREVIEW_SHIFT || !Main.panel.visible)
+ return box;
+
+ const workArea = box.copy();
+ const panelHeight = Main.panel.height;
+ workArea.y1 += opt.PANEL_POSITION_TOP ? panelHeight : 0;
+ workArea.y2 -= opt.PANEL_POSITION_BOTTOM ? panelHeight : 0;
+
+ return workArea;
+ },
+
vfunc_allocate(box) {
this.set_allocation(box);
const themeNode = this.get_theme_node();
const contentBox = themeNode.get_content_box(box);
- let [width, height] = contentBox.get_size();
- let [, startY] = contentBox.get_origin();
- // Save some resources
- if (this._startY === undefined) {
- this._panelHeight = opt.SEC_WS_PREVIEW_SHIFT && Main.panel.visible ? Main.panel.height : 0;
- startY += opt.SEC_WS_PREVIEW_SHIFT && opt.PANEL_POSITION_TOP ? this._panelHeight : 0;
- this._startY = startY;
- }
- startY = this._startY;
- height -= this._panelHeight;
- const { expandFraction } = this._thumbnails;
- const spacing = themeNode.get_length('spacing') * expandFraction;
+ const workArea = this._getWorkAreaBox(contentBox);
+
+ let [width, height] = workArea.get_size();
+ let [startX, startY] = workArea.get_origin();
+
+ const spacing = opt.SPACING;
- let thumbnailsWidth = 0;
- let thumbnailsHeight = 0;
+ let wsTmbWidth = 0;
+ let wsTmbHeight = 0;
this._thumbnails.visible = !opt.SEC_WS_TMB_HIDDEN;
if (this._thumbnails.visible) {
- thumbnailsWidth = Math.round(width * opt.SEC_MAX_THUMBNAIL_SCALE);
+ wsTmbWidth = Math.round(width * opt.SEC_MAX_THUMBNAIL_SCALE);
let totalTmbSpacing;
- [totalTmbSpacing, thumbnailsHeight] = this._thumbnails.get_preferred_height(thumbnailsWidth);
- thumbnailsHeight = Math.round(thumbnailsHeight + totalTmbSpacing);
+ [totalTmbSpacing, wsTmbHeight] = this._thumbnails.get_preferred_height(wsTmbWidth);
+ wsTmbHeight += totalTmbSpacing;
const thumbnailsHeightMax = height - spacing;
- if (thumbnailsHeight > thumbnailsHeightMax) {
- thumbnailsHeight = thumbnailsHeightMax;
- thumbnailsWidth = Math.round(this._thumbnails.get_preferred_width(thumbnailsHeight)[1]);
+ if (wsTmbHeight > thumbnailsHeightMax) {
+ wsTmbHeight = thumbnailsHeightMax;
+ wsTmbWidth = Math.round(this._thumbnails.get_preferred_width(wsTmbHeight)[1]);
}
- let wsTmbX;
- if (opt.SEC_WS_TMB_LEFT) {
- wsTmbX = 0;
- this._thumbnails._positionLeft = true;
- } else {
- wsTmbX = width - thumbnailsWidth;
- this._thumbnails._positionLeft = false;
- }
+ let wsTmbX = opt.SEC_WS_TMB_LEFT
+ ? startX + spacing
+ : startX + width - wsTmbWidth - spacing;
- const childBox = new Clutter.ActorBox();
- const availSpace = height - thumbnailsHeight;
+ let offset = (height - wsTmbHeight) / 2;
+ const wsTmbY = startY + Math.round(offset - opt.SEC_WS_TMB_POSITION_ADJUSTMENT * (offset - spacing));
- let wsTmbY = availSpace / 2;
-
- wsTmbY -= opt.SEC_WS_TMB_POSITION_ADJUSTMENT * (wsTmbY - spacing / 2);
- wsTmbY += startY;
-
- childBox.set_origin(Math.round(wsTmbX), Math.round(wsTmbY));
- childBox.set_size(thumbnailsWidth, thumbnailsHeight);
+ const childBox = new Clutter.ActorBox();
+ childBox.set_origin(wsTmbX, wsTmbY);
+ childBox.set_size(wsTmbWidth, wsTmbHeight);
this._thumbnails.allocate(childBox);
}
@@ -432,7 +430,7 @@ const SecondaryMonitorDisplayVertical = {
} = this._overviewAdjustment.getStateTransitionParams();
let workspacesBox;
- const workspaceParams = [contentBox, thumbnailsWidth, spacing, startY, this._panelHeight];
+ const workspaceParams = [contentBox, workArea, wsTmbWidth, spacing];
if (!transitioning) {
workspacesBox =
this._getWorkspacesBoxForState(currentState, ...workspaceParams);
@@ -562,93 +560,93 @@ const SecondaryMonitorDisplayHorizontal = {
return { opacity, scale, translationY };
},
- _getWorkspacesBoxForState(state, box, thumbnailsHeight, spacing, startY, panelHeight) {
- // const { ControlsState } = OverviewControls;
- const workspaceBox = box.copy();
- let [width, height] = workspaceBox.get_size();
- height -= panelHeight;
+ _getWorkspacesBoxForState(state, box, workArea, wsTmbHeight, spacing) {
+ let workspaceBox = box.copy();
- let wWidth, wHeight, wsbX, wsbY, offset;
- switch (state) {
- case ControlsState.HIDDEN:
- break;
- case ControlsState.WINDOW_PICKER:
- case ControlsState.APP_GRID:
- if (opt.OVERVIEW_MODE2 && !opt.WORKSPACE_MODE)
- break;
+ if (
+ (state === ControlsState.WINDOW_PICKER || state === ControlsState.APP_GRID) &&
+ !(opt.OVERVIEW_MODE2 && !opt.WORKSPACE_MODE)
+ ) {
+ workspaceBox = workArea.copy();
+ const [startX, startY] = workspaceBox.get_origin();
+ let [width, height] = workspaceBox.get_size();
- wHeight = height - (thumbnailsHeight ? thumbnailsHeight + 4 * spacing : 4 * spacing);
- 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 wsBoxWidth = width - 2 * spacing;
+ let wsBoxHeight = height - (wsTmbHeight ? wsTmbHeight + spacing : 0) - 2 * spacing;
- offset = Math.round((height - thumbnailsHeight - wHeight) / 2);
- if (opt.SEC_WS_TMB_TOP)
- wsbY = thumbnailsHeight + offset;
- else
- wsbY = offset;
+ const ratio = width / height;
+ let wRatio = wsBoxWidth / wsBoxHeight;
+ let scale = ratio / wRatio;
+
+ if (scale > 1) {
+ wsBoxHeight /= scale;
+ wsBoxWidth = wsBoxHeight * ratio;
+ } else {
+ wsBoxWidth *= scale;
+ wsBoxHeight = wsBoxWidth / ratio;
+ }
+
+ // height decides the actual size, ratio is given by the workArea
+ wsBoxHeight = Math.round(wsBoxHeight * opt.SEC_WS_PREVIEW_SCALE);
+ wsBoxWidth = Math.round(wsBoxWidth * opt.SEC_WS_PREVIEW_SCALE);
- wsbY += startY;
- wsbX = Math.round((width - wWidth) / 2);
+ let offset = Math.round(height - wsTmbHeight - wsBoxHeight - spacing) / 2;
+
+ const wsbX = Math.round((startX + width - wsBoxWidth) / 2);
+
+ const wsbY = startY + opt.SEC_WS_TMB_TOP
+ ? wsTmbHeight + spacing + offset
+ : offset;
workspaceBox.set_origin(wsbX, wsbY);
- workspaceBox.set_size(wWidth, wHeight);
- break;
+ workspaceBox.set_size(wsBoxWidth, wsBoxHeight);
}
return workspaceBox;
},
+ _getWorkAreaBox: SecondaryMonitorDisplayVertical._getWorkAreaBox,
+
vfunc_allocate(box) {
this.set_allocation(box);
const themeNode = this.get_theme_node();
const contentBox = themeNode.get_content_box(box);
- let [width, height] = contentBox.get_size();
- let [, startY] = contentBox.get_origin();
- // Save some resources
- if (this._startY === undefined) {
- this._panelHeight = opt.SEC_WS_PREVIEW_SHIFT && Main.panel.visible ? Main.panel.height : 0;
- startY += opt.SEC_WS_PREVIEW_SHIFT && opt.PANEL_POSITION_TOP ? this._panelHeight : 0;
- this._startY = startY;
- }
- startY = this._startY;
- height -= this._panelHeight;
- const { expandFraction } = this._thumbnails;
- const spacing = themeNode.get_length('spacing') * expandFraction;
+ const workArea = this._getWorkAreaBox(contentBox);
+
+ let [width, height] = workArea.get_size();
+ let [startX, startY] = workArea.get_origin();
+
+ const spacing = opt.SPACING;
- let thumbnailsWidth = 0;
- let thumbnailsHeight = 0;
+ let wsTmbWidth = 0;
+ let wsTmbHeight = 0;
this._thumbnails.visible = !opt.SEC_WS_TMB_HIDDEN;
if (this._thumbnails.visible) {
- thumbnailsHeight = height * opt.SEC_MAX_THUMBNAIL_SCALE;
+ wsTmbHeight = Math.round(height * opt.SEC_MAX_THUMBNAIL_SCALE);
let totalTmbSpacing;
- [totalTmbSpacing, thumbnailsWidth] = this._thumbnails.get_preferred_width(thumbnailsHeight);
- thumbnailsWidth = Math.round(thumbnailsWidth + totalTmbSpacing);
+ [totalTmbSpacing, wsTmbWidth] = this._thumbnails.get_preferred_width(wsTmbHeight);
+ wsTmbWidth += totalTmbSpacing;
- const thumbnailsWidthMax = width - spacing;
+ const thumbnailsWidthMax = width - 2 * spacing;
- if (thumbnailsWidth > thumbnailsWidthMax) {
- thumbnailsWidth = thumbnailsWidthMax;
- thumbnailsHeight = Math.round(this._thumbnails.get_preferred_height(thumbnailsWidth)[1]);
+ if (wsTmbWidth > thumbnailsWidthMax) {
+ wsTmbWidth = thumbnailsWidthMax;
+ wsTmbHeight = Math.round(this._thumbnails.get_preferred_height(wsTmbWidth)[1]);
}
- let wsTmbY;
- if (opt.SEC_WS_TMB_TOP)
- wsTmbY = spacing / 2 + startY;
- else
- wsTmbY = height - spacing / 2 - thumbnailsHeight + startY;
-
- const childBox = new Clutter.ActorBox();
- const availSpace = width - thumbnailsWidth;
+ let wsTmbY = opt.SEC_WS_TMB_TOP
+ ? startY + spacing
+ : startY + height - wsTmbHeight - spacing;
- let wsTmbX = availSpace / 2;
- wsTmbX -= opt.SEC_WS_TMB_POSITION_ADJUSTMENT * wsTmbX;
+ let offset = (width - wsTmbWidth) / 2;
+ const wsTmbX = startX + Math.round(offset - opt.SEC_WS_TMB_POSITION_ADJUSTMENT * (offset - spacing));
- childBox.set_origin(Math.round(wsTmbX), Math.round(wsTmbY));
- childBox.set_size(thumbnailsWidth, thumbnailsHeight);
+ const childBox = new Clutter.ActorBox();
+ childBox.set_origin(wsTmbX, wsTmbY);
+ childBox.set_size(wsTmbWidth, wsTmbHeight);
this._thumbnails.allocate(childBox);
}
@@ -657,7 +655,7 @@ const SecondaryMonitorDisplayHorizontal = {
} = this._overviewAdjustment.getStateTransitionParams();
let workspacesBox;
- const workspaceParams = [contentBox, thumbnailsHeight, spacing, startY, this._panelHeight];
+ const workspaceParams = [contentBox, workArea, wsTmbHeight, spacing];
if (!transitioning) {
workspacesBox =
this._getWorkspacesBoxForState(currentState, ...workspaceParams);
@@ -805,6 +803,17 @@ const WorkspacesDisplayCommon = {
}),
this._overviewAdjustment);
Main.layoutManager.overviewGroup.add_child(view);
+
+ if (opt.CLICK_EMPTY_CLOSE) {
+ // Allow users to close the overview by clicking on an empty space on the secondary monitor
+ // The primary monitor overview is handled in the overviewControls
+ const clickAction = new Clutter.ClickAction();
+ clickAction.connect('clicked', () => {
+ Main.overview.hide();
+ });
+ view.reactive = true;
+ view.add_action(clickAction);
+ }
}
this._workspacesViews.push(view);