[gnome-shell] window-manager: Swap workspace order for RTL locales
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] window-manager: Swap workspace order for RTL locales
- Date: Fri, 3 Dec 2010 17:26:13 +0000 (UTC)
commit 1efb0213c5b746ac3286fc528999815d5479cd3c
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Nov 12 16:22:05 2010 +0100
window-manager: Swap workspace order for RTL locales
Workspaces should be aligned from right to left in RTL locales, so
take the text direction into account when switching workspaces.
https://bugzilla.gnome.org/show_bug.cgi?id=634691
js/ui/windowManager.js | 38 ++++++++++++++++++++++++--------------
js/ui/workspaceSwitcherPopup.js | 6 ++++++
2 files changed, 30 insertions(+), 14 deletions(-)
---
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index 0418912..5bd14e4 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -543,24 +543,34 @@ WindowManager.prototype = {
},
actionMoveWorkspaceLeft: function() {
+ let rtl = (St.Widget.get_default_direction() == St.TextDirection.RTL);
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
- if (activeWorkspaceIndex > 0) {
- global.screen.get_workspace_by_index(activeWorkspaceIndex - 1).activate(global.get_current_time());
- if (!Main.overview.visible)
- this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.LEFT, activeWorkspaceIndex - 1);
- } else if (!Main.overview.visible) {
- this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.LEFT, activeWorkspaceIndex);
- }
+ let indexToActivate = activeWorkspaceIndex;
+ if (rtl && activeWorkspaceIndex < global.screen.n_workspaces - 1)
+ indexToActivate++;
+ else if (!rtl && 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);
},
actionMoveWorkspaceRight: function() {
+ let rtl = (St.Widget.get_default_direction() == St.TextDirection.RTL);
let activeWorkspaceIndex = global.screen.get_active_workspace_index();
- if (activeWorkspaceIndex < global.screen.n_workspaces - 1) {
- global.screen.get_workspace_by_index(activeWorkspaceIndex + 1).activate(global.get_current_time());
- if (!Main.overview.visible)
- this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.RIGHT, activeWorkspaceIndex + 1);
- } else if (!Main.overview.visible) {
- this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.RIGHT, activeWorkspaceIndex);
- }
+ let indexToActivate = activeWorkspaceIndex;
+ if (rtl && activeWorkspaceIndex > 0)
+ indexToActivate--;
+ else if (!rtl && 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/workspaceSwitcherPopup.js b/js/ui/workspaceSwitcherPopup.js
index b474377..afa9477 100644
--- a/js/ui/workspaceSwitcherPopup.js
+++ b/js/ui/workspaceSwitcherPopup.js
@@ -89,6 +89,7 @@ WorkspaceSwitcherPopup.prototype = {
let children = this._list.get_children();
let childBox = new Clutter.ActorBox();
+ let rtl = (St.Widget.get_default_direction() == St.TextDirection.RTL);
let x = box.x1;
let prevChildBoxX2 = box.x1 - this._itemSpacing;
for (let i = 0; i < children.length; i++) {
@@ -98,6 +99,11 @@ WorkspaceSwitcherPopup.prototype = {
childBox.y2 = box.y1 + this._childHeight;
x += this._childWidth + this._itemSpacing;
prevChildBoxX2 = childBox.x2;
+ if (rtl) {
+ let ltrChildBoxX1 = childBox.x1;
+ childBox.x1 = box.x2 - (childBox.x2 - box.x1);
+ childBox.x2 = box.x2 - (ltrChildBoxX1 - box.x1);
+ }
children[i].allocate(childBox, flags);
}
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]