[gnome-shell-extensions] native-window-placement: respect button layout
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] native-window-placement: respect button layout
- Date: Mon, 6 Feb 2012 20:33:58 +0000 (UTC)
commit 29b0d0d96b86d921978f4b66fb625f70fb7c01d7
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Mon Feb 6 17:35:51 2012 +0100
native-window-placement: respect button layout
If the user configures the window buttons on the left, the X button
in the overview should be moved accordingly.
extensions/native-window-placement/extension.js | 28 +++++++++++++++++-----
1 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/extensions/native-window-placement/extension.js b/extensions/native-window-placement/extension.js
index 17910d7..105e728 100644
--- a/extensions/native-window-placement/extension.js
+++ b/extensions/native-window-placement/extension.js
@@ -31,6 +31,9 @@ const WINDOW_PLACEMENT_NATURAL_MAX_TRANSLATIONS = 5000; // safety li
const PLACE_WINDOW_CAPTIONS_ON_TOP = true; // place window titles in overview on top of windows with overlap parameter
+const BUTTON_LAYOUT_SCHEMA = 'org.gnome.shell.overrides';
+const BUTTON_LAYOUT_KEY = 'button-layout';
+
function injectToFunction(parent, name, func) {
let origin = parent[name];
parent[name] = function() {
@@ -426,27 +429,38 @@ function enable() {
let button = this.closeButton;
let title = this.title;
+ let settings = new Gio.Settings({ schema: BUTTON_LAYOUT_SCHEMA });
+ let layout = settings.get_string(BUTTON_LAYOUT_KEY);
+ let rtl = St.Widget.get_default_direction() == St.TextDirection.RTL;
+
+ let split = layout.split(":");
+ let side;
+ if (split[0].indexOf("close") > -1)
+ side = rtl ? St.Side.RIGHT : St.Side.LEFT;
+ else
+ side = rtl ? St.Side.LEFT : St.Side.RIGHT;
+
let buttonX;
let buttonY = cloneY - (button.height - button._overlap);
- if (St.Widget.get_default_direction() == St.TextDirection.RTL)
- buttonX = cloneX - (button.width - button._overlap);
+ if (side == St.Side.LEFT)
+ buttonX = cloneX - (button.width - button._overlap);
else
- buttonX = cloneX + (cloneWidth - button._overlap);
+ buttonX = cloneX + (cloneWidth - button._overlap);
if (animate)
- this._animateOverlayActor(button, Math.floor(buttonX), Math.floor(buttonY));
+ this._animateOverlayActor(button, Math.floor(buttonX), Math.floor(buttonY), button.width);
else
button.set_position(Math.floor(buttonX), Math.floor(buttonY));
if (!title.fullWidth)
- title.fullWidth = title.width;
+ title.fullWidth = title.width;
let titleWidth = Math.min(title.fullWidth, cloneWidth);
let titleX = cloneX + (cloneWidth - titleWidth) / 2;
- let titleY = cloneY - title.height + title._overlap;
+ let titleY = cloneY - title.height + title._overlap;
if (animate)
- this._animateOverlayActor(title, Math.floor(titleX), Math.floor(titleY));
+ this._animateOverlayActor(title, Math.floor(titleX), Math.floor(titleY), titleWidth);
else {
title.width = titleWidth;
title.set_position(Math.floor(titleX), Math.floor(titleY));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]