[gnome-shell/workspace-thumbnails: 2/13] Switch to a vertical layout for workspaces
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/workspace-thumbnails: 2/13] Switch to a vertical layout for workspaces
- Date: Mon, 31 Jan 2011 04:13:46 +0000 (UTC)
commit 219be21d1996e59ecbfadcb6c4abf79cef22fc5c
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.)
js/ui/main.js | 8 ++++
js/ui/windowManager.js | 41 +++++++++++++++----
js/ui/workspacesView.js | 101 +++++++++++++++++++++-------------------------
3 files changed, 86 insertions(+), 64 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index 572709c..77d9ab0 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -175,6 +175,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();
@@ -365,6 +367,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..a6c6ffc 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -525,23 +525,20 @@ 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') {
+ if (binding == 'switch_to_workspace_left')
this.actionMoveWorkspaceLeft();
- }
-
- if (binding == 'switch_to_workspace_right') {
+ else if (binding == 'switch_to_workspace_right')
this.actionMoveWorkspaceRight();
- }
+ else if (binding == 'switch_to_workspace_up')
+ this.actionMoveWorkspaceUp();
+ else if (binding == 'switch_to_workspace_down')
+ this.actionMoveWorkspaceDown();
},
actionMoveWorkspaceLeft: function() {
@@ -574,5 +571,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 40b7320..e39f282 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -301,14 +301,10 @@ 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 +321,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 +332,7 @@ WorkspacesView.prototype = {
Tweener.removeTweens(workspace.actor);
- workspace.x += dx;
+ workspace.y += dy;
if (showAnimation) {
let params = { x: workspace.x,
@@ -373,13 +369,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,
@@ -504,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',
@@ -538,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;
}
}
@@ -670,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]