[gnome-shell] Switch to a vertical layout for workspaces
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Switch to a vertical layout for workspaces
- Date: Wed, 9 Feb 2011 01:00:37 +0000 (UTC)
commit 295d286161867a5e189e06e345dd6e136467e051
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Sun Jan 30 18:21:31 2011 -0500
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
js/ui/main.js | 8 ++++
js/ui/windowManager.js | 47 +++++++++++++++++-----
js/ui/workspacesView.js | 100 +++++++++++++++++++++--------------------------
3 files changed, 89 insertions(+), 66 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index 204ccd4..7e17873 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -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
// initiate logouts.
EndSessionDialog.init();
@@ -389,6 +391,12 @@ function _globalKeyPressHandler(actor, event) {
case Meta.KeyBindingAction.WORKSPACE_RIGHT:
wm.actionMoveWorkspaceRight();
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.COMMAND_2:
getRunDialog().open();
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index 447e479..51fd17d 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -525,23 +525,22 @@ WindowManager.prototype = {
},
_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)
return;
if (this._workspaceSwitcherPopup == null)
this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
- if (binding == 'switch_to_workspace_left') {
- this.actionMoveWorkspaceLeft();
- }
-
- if (binding == 'switch_to_workspace_right') {
- this.actionMoveWorkspaceRight();
- }
+ if (binding == 'switch_to_workspace_up')
+ this.actionMoveWorkspaceUp();
+ else if (binding == 'switch_to_workspace_down')
+ this.actionMoveWorkspaceDown();
+ // left/right would effectively act as synonyms for up/down if we enabled them;
+ // 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() {
@@ -574,5 +573,31 @@ WindowManager.prototype = {
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)
+ this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.RIGHT, indexToActivate);
}
};
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 2a6557b..dbc87e0 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -301,14 +301,9 @@ WorkspacesView.prototype = {
workspace.opacity = (this._inDrag && w != active) ? 200 : 255;
workspace.scale = scale;
- if (St.Widget.get_default_direction() == St.TextDirection.RTL) {
- workspace.x = this._x + this._activeWorkspaceX
- - (w - active) * (_width + this._spacing);
- } else {
- workspace.x = this._x + this._activeWorkspaceX
- + (w - active) * (_width + this._spacing);
- }
- workspace.y = this._y + this._activeWorkspaceY;
+ workspace.x = this._x + this._activeWorkspaceX;
+ workspace.y = this._y + this._activeWorkspaceY
+ + (w - active) * (_height + this._spacing);
}
},
@@ -325,9 +320,9 @@ WorkspacesView.prototype = {
// @showAnimation: iff %true, transition between states
_updateWorkspaceActors: function(showAnimation) {
let active = global.screen.get_active_workspace_index();
- let targetWorkspaceNewX = this._x + this._activeWorkspaceX;
- let targetWorkspaceCurrentX = this._workspaces[active].x;
- let dx = targetWorkspaceNewX - targetWorkspaceCurrentX;
+ let targetWorkspaceNewY = this._y + this._activeWorkspaceY;
+ let targetWorkspaceCurrentY = this._workspaces[active].y;
+ let dy = targetWorkspaceNewY - targetWorkspaceCurrentY;
this._animating = showAnimation;
@@ -336,7 +331,7 @@ WorkspacesView.prototype = {
Tweener.removeTweens(workspace.actor);
- workspace.x += dx;
+ workspace.y += dy;
if (showAnimation) {
let params = { x: workspace.x,
@@ -373,13 +368,13 @@ WorkspacesView.prototype = {
Tweener.removeTweens(workspace.actor);
- workspace.x += dx;
+ workspace.y += dy;
workspace.actor.show();
workspace.hideWindowsOverlays();
if (showAnimation) {
Tweener.addTween(workspace.actor,
- { x: workspace.x,
+ { y: workspace.x,
time: WORKSPACE_SWITCH_TIME,
transition: 'easeOutQuad',
onComplete: Lang.bind(this,
@@ -505,7 +500,7 @@ WorkspacesView.prototype = {
_onMappedChanged: function() {
if (this.actor.mapped) {
- let direction = Overview.SwipeScrollDirection.HORIZONTAL;
+ let direction = Overview.SwipeScrollDirection.VERTICAL;
Main.overview.setScrollAdjustment(this._scrollAdjustment,
direction);
this._swipeScrollBeginId = Main.overview.connect('swipe-scroll-begin',
@@ -539,56 +534,51 @@ WorkspacesView.prototype = {
let primary = global.get_primary_monitor();
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
- let leftWorkspace, rightWorkspace;
- if (St.Widget.get_default_direction() == St.TextDirection.RTL) {
- leftWorkspace = this._workspaces[activeWorkspaceIndex + 1];
- rightWorkspace = this._workspaces[activeWorkspaceIndex - 1];
- } else {
- leftWorkspace = this._workspaces[activeWorkspaceIndex - 1];
- rightWorkspace = this._workspaces[activeWorkspaceIndex + 1];
- }
+ let topWorkspace, bottomWorkspace;
+ topWorkspace = this._workspaces[activeWorkspaceIndex - 1];
+ bottomWorkspace = this._workspaces[activeWorkspaceIndex + 1];
let hoverWorkspace = null;
// reactive monitor edges
- let leftEdge = primary.x;
- let switchLeft = (dragEvent.x <= leftEdge && leftWorkspace);
- if (switchLeft && this._dragOverLastX != leftEdge) {
- leftWorkspace.metaWorkspace.activate(global.get_current_time());
- leftWorkspace.setReservedSlot(dragEvent.dragActor._delegate);
- this._dragOverLastX = leftEdge;
+ let topEdge = primary.y;
+ let switchTop = (dragEvent.y <= topEdge && topWorkspace);
+ if (switchTop && this._dragOverLastY != topEdge) {
+ topWorkspace.metaWorkspace.activate(global.get_current_time());
+ topWorkspace.setReservedSlot(dragEvent.dragActor._delegate);
+ this._dragOverLastY = topEdge;
return DND.DragMotionResult.CONTINUE;
}
- let rightEdge = primary.x + primary.width - 1;
- let switchRight = (dragEvent.x >= rightEdge && rightWorkspace);
- if (switchRight && this._dragOverLastX != rightEdge) {
- rightWorkspace.metaWorkspace.activate(global.get_current_time());
- rightWorkspace.setReservedSlot(dragEvent.dragActor._delegate);
- this._dragOverLastX = rightEdge;
+ let bottomEdge = primary.y + primary.height - 1;
+ let switchBottom = (dragEvent.y >= bottomEdge && bottomWorkspace);
+ if (switchBottom && this._dragOverLastY != bottomEdge) {
+ bottomWorkspace.metaWorkspace.activate(global.get_current_time());
+ bottomWorkspace.setReservedSlot(dragEvent.dragActor._delegate);
+ this._dragOverLastY = bottomEdge;
return DND.DragMotionResult.CONTINUE;
}
- this._dragOverLastX = dragEvent.x;
+ this._dragOverLastY = dragEvent.y;
let result = DND.DragMotionResult.CONTINUE;
// check hover state of new workspace area / inactive workspaces
- if (leftWorkspace) {
- if (leftWorkspace.actor.contains(dragEvent.targetActor)) {
- hoverWorkspace = leftWorkspace;
- leftWorkspace.opacity = leftWorkspace.actor.opacity = 255;
- result = leftWorkspace.handleDragOver(dragEvent.source, dragEvent.dragActor);
+ if (topWorkspace) {
+ if (topWorkspace.actor.contains(dragEvent.targetActor)) {
+ hoverWorkspace = topWorkspace;
+ topWorkspace.opacity = topWorkspace.actor.opacity = 255;
+ result = topWorkspace.handleDragOver(dragEvent.source, dragEvent.dragActor);
} else {
- leftWorkspace.opacity = leftWorkspace.actor.opacity = 200;
+ topWorkspace.opacity = topWorkspace.actor.opacity = 200;
}
}
- if (rightWorkspace) {
- if (rightWorkspace.actor.contains(dragEvent.targetActor)) {
- hoverWorkspace = rightWorkspace;
- rightWorkspace.opacity = rightWorkspace.actor.opacity = 255;
- result = rightWorkspace.handleDragOver(dragEvent.source, dragEvent.dragActor);
+ if (bottomWorkspace) {
+ if (bottomWorkspace.actor.contains(dragEvent.targetActor)) {
+ hoverWorkspace = bottomWorkspace;
+ bottomWorkspace.opacity = bottomWorkspace.actor.opacity = 255;
+ result = bottomWorkspace.handleDragOver(dragEvent.source, dragEvent.dragActor);
} 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 firstWorkspaceX = this._workspaces[0].actor.x;
- let lastWorkspaceX = this._workspaces[last].actor.x;
- let workspacesWidth = lastWorkspaceX - firstWorkspaceX;
+ let firstWorkspaceY = this._workspaces[0].actor.y;
+ let lastWorkspaceY = this._workspaces[last].actor.y;
+ let workspacesHeight = lastWorkspaceY - firstWorkspaceY;
if (adj.upper == 1)
return;
- let currentX = firstWorkspaceX;
- let newX = this._x - adj.value / (adj.upper - 1) * workspacesWidth;
+ let currentY = firstWorkspaceY;
+ 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++) {
this._workspaces[i]._hideAllOverlays();
this._workspaces[i].actor.visible = Math.abs(i - adj.value) <= 1;
- this._workspaces[i].actor.x += dx;
+ this._workspaces[i].actor.y += dy;
}
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]