Switch to a vertical layout for workspaces
The new plans for a row of workspace thumbnails on the right side of the overview means that the mental model we present to the user will be vertical, so switch the Metacity workspace layout to be vertical and adjust the keybinding handling, animations, and workspace layout in the overview to match. (This commit does not change the workspace switching indicator pending finalization of what we want to do with that - it still shows workspaces arranged vertically.) https://bugzilla.gnome.org/show_bug.cgi?id=640996
This commit is contained in:
parent
6011dd6bc9
commit
295d286161
@ -177,6 +177,8 @@ function start() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
global.screen.override_workspace_layout(Meta.ScreenCorner.TOPLEFT, false, -1, 1);
|
||||||
|
|
||||||
// Provide the bus object for gnome-session to
|
// Provide the bus object for gnome-session to
|
||||||
// initiate logouts.
|
// initiate logouts.
|
||||||
EndSessionDialog.init();
|
EndSessionDialog.init();
|
||||||
@ -389,6 +391,12 @@ function _globalKeyPressHandler(actor, event) {
|
|||||||
case Meta.KeyBindingAction.WORKSPACE_RIGHT:
|
case Meta.KeyBindingAction.WORKSPACE_RIGHT:
|
||||||
wm.actionMoveWorkspaceRight();
|
wm.actionMoveWorkspaceRight();
|
||||||
return true;
|
return true;
|
||||||
|
case Meta.KeyBindingAction.WORKSPACE_UP:
|
||||||
|
wm.actionMoveWorkspaceUp();
|
||||||
|
return true;
|
||||||
|
case Meta.KeyBindingAction.WORKSPACE_DOWN:
|
||||||
|
wm.actionMoveWorkspaceDown();
|
||||||
|
return true;
|
||||||
case Meta.KeyBindingAction.PANEL_RUN_DIALOG:
|
case Meta.KeyBindingAction.PANEL_RUN_DIALOG:
|
||||||
case Meta.KeyBindingAction.COMMAND_2:
|
case Meta.KeyBindingAction.COMMAND_2:
|
||||||
getRunDialog().open();
|
getRunDialog().open();
|
||||||
|
@ -525,23 +525,22 @@ WindowManager.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_showWorkspaceSwitcher : function(shellwm, binding, window, backwards) {
|
_showWorkspaceSwitcher : function(shellwm, binding, window, backwards) {
|
||||||
/* We don't support this kind of layout */
|
|
||||||
if (binding == 'switch_to_workspace_up' || binding == 'switch_to_workspace_down')
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (global.screen.n_workspaces == 1)
|
if (global.screen.n_workspaces == 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this._workspaceSwitcherPopup == null)
|
if (this._workspaceSwitcherPopup == null)
|
||||||
this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
|
this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
|
||||||
|
|
||||||
if (binding == 'switch_to_workspace_left') {
|
if (binding == 'switch_to_workspace_up')
|
||||||
this.actionMoveWorkspaceLeft();
|
this.actionMoveWorkspaceUp();
|
||||||
}
|
else if (binding == 'switch_to_workspace_down')
|
||||||
|
this.actionMoveWorkspaceDown();
|
||||||
if (binding == 'switch_to_workspace_right') {
|
// left/right would effectively act as synonyms for up/down if we enabled them;
|
||||||
this.actionMoveWorkspaceRight();
|
// but that could be considered confusing.
|
||||||
}
|
// else if (binding == 'switch_to_workspace_left')
|
||||||
|
// this.actionMoveWorkspaceLeft();
|
||||||
|
// else if (binding == 'switch_to_workspace_right')
|
||||||
|
// this.actionMoveWorkspaceRight();
|
||||||
},
|
},
|
||||||
|
|
||||||
actionMoveWorkspaceLeft: function() {
|
actionMoveWorkspaceLeft: function() {
|
||||||
@ -572,6 +571,32 @@ WindowManager.prototype = {
|
|||||||
if (indexToActivate != activeWorkspaceIndex)
|
if (indexToActivate != activeWorkspaceIndex)
|
||||||
global.screen.get_workspace_by_index(indexToActivate).activate(global.get_current_time());
|
global.screen.get_workspace_by_index(indexToActivate).activate(global.get_current_time());
|
||||||
|
|
||||||
|
if (!Main.overview.visible)
|
||||||
|
this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.RIGHT, indexToActivate);
|
||||||
|
},
|
||||||
|
|
||||||
|
actionMoveWorkspaceUp: function() {
|
||||||
|
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
|
||||||
|
let indexToActivate = activeWorkspaceIndex;
|
||||||
|
if (activeWorkspaceIndex > 0)
|
||||||
|
indexToActivate--;
|
||||||
|
|
||||||
|
if (indexToActivate != activeWorkspaceIndex)
|
||||||
|
global.screen.get_workspace_by_index(indexToActivate).activate(global.get_current_time());
|
||||||
|
|
||||||
|
if (!Main.overview.visible)
|
||||||
|
this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.LEFT, indexToActivate);
|
||||||
|
},
|
||||||
|
|
||||||
|
actionMoveWorkspaceDown: function() {
|
||||||
|
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
|
||||||
|
let indexToActivate = activeWorkspaceIndex;
|
||||||
|
if (activeWorkspaceIndex < global.screen.n_workspaces - 1)
|
||||||
|
indexToActivate++;
|
||||||
|
|
||||||
|
if (indexToActivate != activeWorkspaceIndex)
|
||||||
|
global.screen.get_workspace_by_index(indexToActivate).activate(global.get_current_time());
|
||||||
|
|
||||||
if (!Main.overview.visible)
|
if (!Main.overview.visible)
|
||||||
this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.RIGHT, indexToActivate);
|
this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.RIGHT, indexToActivate);
|
||||||
}
|
}
|
||||||
|
@ -301,14 +301,9 @@ WorkspacesView.prototype = {
|
|||||||
workspace.opacity = (this._inDrag && w != active) ? 200 : 255;
|
workspace.opacity = (this._inDrag && w != active) ? 200 : 255;
|
||||||
|
|
||||||
workspace.scale = scale;
|
workspace.scale = scale;
|
||||||
if (St.Widget.get_default_direction() == St.TextDirection.RTL) {
|
workspace.x = this._x + this._activeWorkspaceX;
|
||||||
workspace.x = this._x + this._activeWorkspaceX
|
workspace.y = this._y + this._activeWorkspaceY
|
||||||
- (w - active) * (_width + this._spacing);
|
+ (w - active) * (_height + this._spacing);
|
||||||
} else {
|
|
||||||
workspace.x = this._x + this._activeWorkspaceX
|
|
||||||
+ (w - active) * (_width + this._spacing);
|
|
||||||
}
|
|
||||||
workspace.y = this._y + this._activeWorkspaceY;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -325,9 +320,9 @@ WorkspacesView.prototype = {
|
|||||||
// @showAnimation: iff %true, transition between states
|
// @showAnimation: iff %true, transition between states
|
||||||
_updateWorkspaceActors: function(showAnimation) {
|
_updateWorkspaceActors: function(showAnimation) {
|
||||||
let active = global.screen.get_active_workspace_index();
|
let active = global.screen.get_active_workspace_index();
|
||||||
let targetWorkspaceNewX = this._x + this._activeWorkspaceX;
|
let targetWorkspaceNewY = this._y + this._activeWorkspaceY;
|
||||||
let targetWorkspaceCurrentX = this._workspaces[active].x;
|
let targetWorkspaceCurrentY = this._workspaces[active].y;
|
||||||
let dx = targetWorkspaceNewX - targetWorkspaceCurrentX;
|
let dy = targetWorkspaceNewY - targetWorkspaceCurrentY;
|
||||||
|
|
||||||
this._animating = showAnimation;
|
this._animating = showAnimation;
|
||||||
|
|
||||||
@ -336,7 +331,7 @@ WorkspacesView.prototype = {
|
|||||||
|
|
||||||
Tweener.removeTweens(workspace.actor);
|
Tweener.removeTweens(workspace.actor);
|
||||||
|
|
||||||
workspace.x += dx;
|
workspace.y += dy;
|
||||||
|
|
||||||
if (showAnimation) {
|
if (showAnimation) {
|
||||||
let params = { x: workspace.x,
|
let params = { x: workspace.x,
|
||||||
@ -373,13 +368,13 @@ WorkspacesView.prototype = {
|
|||||||
|
|
||||||
Tweener.removeTweens(workspace.actor);
|
Tweener.removeTweens(workspace.actor);
|
||||||
|
|
||||||
workspace.x += dx;
|
workspace.y += dy;
|
||||||
workspace.actor.show();
|
workspace.actor.show();
|
||||||
workspace.hideWindowsOverlays();
|
workspace.hideWindowsOverlays();
|
||||||
|
|
||||||
if (showAnimation) {
|
if (showAnimation) {
|
||||||
Tweener.addTween(workspace.actor,
|
Tweener.addTween(workspace.actor,
|
||||||
{ x: workspace.x,
|
{ y: workspace.x,
|
||||||
time: WORKSPACE_SWITCH_TIME,
|
time: WORKSPACE_SWITCH_TIME,
|
||||||
transition: 'easeOutQuad',
|
transition: 'easeOutQuad',
|
||||||
onComplete: Lang.bind(this,
|
onComplete: Lang.bind(this,
|
||||||
@ -505,7 +500,7 @@ WorkspacesView.prototype = {
|
|||||||
|
|
||||||
_onMappedChanged: function() {
|
_onMappedChanged: function() {
|
||||||
if (this.actor.mapped) {
|
if (this.actor.mapped) {
|
||||||
let direction = Overview.SwipeScrollDirection.HORIZONTAL;
|
let direction = Overview.SwipeScrollDirection.VERTICAL;
|
||||||
Main.overview.setScrollAdjustment(this._scrollAdjustment,
|
Main.overview.setScrollAdjustment(this._scrollAdjustment,
|
||||||
direction);
|
direction);
|
||||||
this._swipeScrollBeginId = Main.overview.connect('swipe-scroll-begin',
|
this._swipeScrollBeginId = Main.overview.connect('swipe-scroll-begin',
|
||||||
@ -539,56 +534,51 @@ WorkspacesView.prototype = {
|
|||||||
let primary = global.get_primary_monitor();
|
let primary = global.get_primary_monitor();
|
||||||
|
|
||||||
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
|
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
|
||||||
let leftWorkspace, rightWorkspace;
|
let topWorkspace, bottomWorkspace;
|
||||||
if (St.Widget.get_default_direction() == St.TextDirection.RTL) {
|
topWorkspace = this._workspaces[activeWorkspaceIndex - 1];
|
||||||
leftWorkspace = this._workspaces[activeWorkspaceIndex + 1];
|
bottomWorkspace = this._workspaces[activeWorkspaceIndex + 1];
|
||||||
rightWorkspace = this._workspaces[activeWorkspaceIndex - 1];
|
|
||||||
} else {
|
|
||||||
leftWorkspace = this._workspaces[activeWorkspaceIndex - 1];
|
|
||||||
rightWorkspace = this._workspaces[activeWorkspaceIndex + 1];
|
|
||||||
}
|
|
||||||
let hoverWorkspace = null;
|
let hoverWorkspace = null;
|
||||||
|
|
||||||
// reactive monitor edges
|
// reactive monitor edges
|
||||||
let leftEdge = primary.x;
|
let topEdge = primary.y;
|
||||||
let switchLeft = (dragEvent.x <= leftEdge && leftWorkspace);
|
let switchTop = (dragEvent.y <= topEdge && topWorkspace);
|
||||||
if (switchLeft && this._dragOverLastX != leftEdge) {
|
if (switchTop && this._dragOverLastY != topEdge) {
|
||||||
leftWorkspace.metaWorkspace.activate(global.get_current_time());
|
topWorkspace.metaWorkspace.activate(global.get_current_time());
|
||||||
leftWorkspace.setReservedSlot(dragEvent.dragActor._delegate);
|
topWorkspace.setReservedSlot(dragEvent.dragActor._delegate);
|
||||||
this._dragOverLastX = leftEdge;
|
this._dragOverLastY = topEdge;
|
||||||
|
|
||||||
return DND.DragMotionResult.CONTINUE;
|
return DND.DragMotionResult.CONTINUE;
|
||||||
}
|
}
|
||||||
let rightEdge = primary.x + primary.width - 1;
|
let bottomEdge = primary.y + primary.height - 1;
|
||||||
let switchRight = (dragEvent.x >= rightEdge && rightWorkspace);
|
let switchBottom = (dragEvent.y >= bottomEdge && bottomWorkspace);
|
||||||
if (switchRight && this._dragOverLastX != rightEdge) {
|
if (switchBottom && this._dragOverLastY != bottomEdge) {
|
||||||
rightWorkspace.metaWorkspace.activate(global.get_current_time());
|
bottomWorkspace.metaWorkspace.activate(global.get_current_time());
|
||||||
rightWorkspace.setReservedSlot(dragEvent.dragActor._delegate);
|
bottomWorkspace.setReservedSlot(dragEvent.dragActor._delegate);
|
||||||
this._dragOverLastX = rightEdge;
|
this._dragOverLastY = bottomEdge;
|
||||||
|
|
||||||
return DND.DragMotionResult.CONTINUE;
|
return DND.DragMotionResult.CONTINUE;
|
||||||
}
|
}
|
||||||
this._dragOverLastX = dragEvent.x;
|
this._dragOverLastY = dragEvent.y;
|
||||||
let result = DND.DragMotionResult.CONTINUE;
|
let result = DND.DragMotionResult.CONTINUE;
|
||||||
|
|
||||||
// check hover state of new workspace area / inactive workspaces
|
// check hover state of new workspace area / inactive workspaces
|
||||||
if (leftWorkspace) {
|
if (topWorkspace) {
|
||||||
if (leftWorkspace.actor.contains(dragEvent.targetActor)) {
|
if (topWorkspace.actor.contains(dragEvent.targetActor)) {
|
||||||
hoverWorkspace = leftWorkspace;
|
hoverWorkspace = topWorkspace;
|
||||||
leftWorkspace.opacity = leftWorkspace.actor.opacity = 255;
|
topWorkspace.opacity = topWorkspace.actor.opacity = 255;
|
||||||
result = leftWorkspace.handleDragOver(dragEvent.source, dragEvent.dragActor);
|
result = topWorkspace.handleDragOver(dragEvent.source, dragEvent.dragActor);
|
||||||
} else {
|
} else {
|
||||||
leftWorkspace.opacity = leftWorkspace.actor.opacity = 200;
|
topWorkspace.opacity = topWorkspace.actor.opacity = 200;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rightWorkspace) {
|
if (bottomWorkspace) {
|
||||||
if (rightWorkspace.actor.contains(dragEvent.targetActor)) {
|
if (bottomWorkspace.actor.contains(dragEvent.targetActor)) {
|
||||||
hoverWorkspace = rightWorkspace;
|
hoverWorkspace = bottomWorkspace;
|
||||||
rightWorkspace.opacity = rightWorkspace.actor.opacity = 255;
|
bottomWorkspace.opacity = bottomWorkspace.actor.opacity = 255;
|
||||||
result = rightWorkspace.handleDragOver(dragEvent.source, dragEvent.dragActor);
|
result = bottomWorkspace.handleDragOver(dragEvent.source, dragEvent.dragActor);
|
||||||
} else {
|
} else {
|
||||||
rightWorkspace.opacity = rightWorkspace.actor.opacity = 200;
|
bottomWorkspace.opacity = bottomWorkspace.actor.opacity = 200;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,22 +661,22 @@ WorkspacesView.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let last = this._workspaces.length - 1;
|
let last = this._workspaces.length - 1;
|
||||||
let firstWorkspaceX = this._workspaces[0].actor.x;
|
let firstWorkspaceY = this._workspaces[0].actor.y;
|
||||||
let lastWorkspaceX = this._workspaces[last].actor.x;
|
let lastWorkspaceY = this._workspaces[last].actor.y;
|
||||||
let workspacesWidth = lastWorkspaceX - firstWorkspaceX;
|
let workspacesHeight = lastWorkspaceY - firstWorkspaceY;
|
||||||
|
|
||||||
if (adj.upper == 1)
|
if (adj.upper == 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let currentX = firstWorkspaceX;
|
let currentY = firstWorkspaceY;
|
||||||
let newX = this._x - adj.value / (adj.upper - 1) * workspacesWidth;
|
let newY = this._y - adj.value / (adj.upper - 1) * workspacesHeight;
|
||||||
|
|
||||||
let dx = newX - currentX;
|
let dy = newY - currentY;
|
||||||
|
|
||||||
for (let i = 0; i < this._workspaces.length; i++) {
|
for (let i = 0; i < this._workspaces.length; i++) {
|
||||||
this._workspaces[i]._hideAllOverlays();
|
this._workspaces[i]._hideAllOverlays();
|
||||||
this._workspaces[i].actor.visible = Math.abs(i - adj.value) <= 1;
|
this._workspaces[i].actor.visible = Math.abs(i - adj.value) <= 1;
|
||||||
this._workspaces[i].actor.x += dx;
|
this._workspaces[i].actor.y += dy;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user