diff --git a/Settings.ui b/Settings.ui
index 551441297..6734a4508 100644
--- a/Settings.ui
+++ b/Settings.ui
@@ -40,6 +40,11 @@
1
10
+
+
+
+
False
diff --git a/prefs.js b/prefs.js
index 56aac30b5..77bff0f63 100644
--- a/prefs.js
+++ b/prefs.js
@@ -113,6 +113,12 @@ var SettingsWidget = class SettingsWidget {
this._settings.set_int('vertical-margin-bottom', bottomMargin.get_value());
});
+ let tilingEdgeMargin = this.builder.get_object('tiling_edge_margin_spinner');
+ tilingEdgeMargin.set_value(this._settings.get_int('tiling-edge-margin'));
+ tilingEdgeMargin.connect('value-changed', () => {
+ this._settings.set_int('tiling-edge-margin', tilingEdgeMargin.get_value());
+ });
+
// processing function for cycle values
let cycleProcessor = (elementName, settingName, resetElementName) => {
let element = this.builder.get_object(elementName);
diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled
index 4cfa6a878..9682eaa38 100644
Binary files a/schemas/gschemas.compiled and b/schemas/gschemas.compiled differ
diff --git a/schemas/org.gnome.shell.extensions.paperwm.gschema.xml b/schemas/org.gnome.shell.extensions.paperwm.gschema.xml
index 8fde372fa..70e82f6df 100644
--- a/schemas/org.gnome.shell.extensions.paperwm.gschema.xml
+++ b/schemas/org.gnome.shell.extensions.paperwm.gschema.xml
@@ -286,6 +286,11 @@
Minimum margin from windows bottom edge
+
+ 0
+ Minimum margin from the screen edge to the left and right tiling edge
+
+
20
Minimum gap between windows
diff --git a/settings.js b/settings.js
index 1b1ec6af0..c70f37e65 100644
--- a/settings.js
+++ b/settings.js
@@ -32,9 +32,10 @@ var META_KEY_ABOVE_TAB = 0x2f7259c9;
var prefs = {};
['window-gap', 'vertical-margin', 'vertical-margin-bottom', 'horizontal-margin',
- 'workspace-colors', 'default-background', 'animation-time', 'use-workspace-name',
- 'pressure-barrier', 'default-show-top-bar', 'swipe-sensitivity', 'swipe-friction',
- 'cycle-width-steps', 'cycle-height-steps', 'topbar-follow-focus', 'minimap-scale', 'winprops']
+'tiling-edge-margin', 'workspace-colors', 'default-background', 'animation-time',
+'use-workspace-name', 'pressure-barrier', 'default-show-top-bar', 'swipe-sensitivity',
+'swipe-friction', 'cycle-width-steps', 'cycle-height-steps', 'topbar-follow-focus',
+'minimap-scale', 'winprops']
.forEach((k) => setState(null, k));
prefs.__defineGetter__("minimum_margin", function() { return Math.min(15, this.horizontal_margin) });
@@ -47,8 +48,9 @@ function setVerticalMargin() {
let timerId;
function onWindowGapChanged() {
setVerticalMargin();
- if (timerId)
+ if (timerId) {
imports.mainloop.source_remove(timerId);
+ }
timerId = imports.mainloop.timeout_add(500, () => {
Extension.imports.tiling.spaces.mru().forEach(space => {
space.layout();
@@ -57,6 +59,29 @@ function onWindowGapChanged() {
});
}
+/**
+ * Moves the last window to the edge of the screen so users
+ * can visualise edge tiling margin changes.
+ */
+function onEdgeTilingChanged() {
+ if (timerId) {
+ imports.mainloop.source_remove(timerId);
+ }
+ timerId = imports.mainloop.timeout_add(500, () => {
+ let ws = global.workspace_manager.get_active_workspace();
+ let tiling = Extension.imports.tiling;
+ let space = tiling.spaces.spaceOf(ws);
+ let mw = space.getWindows()[space.getWindows().length - 1];
+ if (mw) {
+ tiling.move_to(space, mw, {
+ x:space.workArea().width
+ });
+ tiling.ensureViewport(mw);
+ }
+ timerId = null;
+ });
+}
+
function setState($, key) {
let value = settings.get_value(key);
let name = key.replace(/-/g, '_');
@@ -89,6 +114,7 @@ function init() {
settings.connect('changed', setState);
settings.connect('changed::vertical-margin', onWindowGapChanged);
settings.connect('changed::vertical-margin-bottom', onWindowGapChanged);
+ settings.connect('changed::tiling-edge-margin', onEdgeTilingChanged);
settings.connect('changed::window-gap', onWindowGapChanged);
setVerticalMargin();
diff --git a/tiling.js b/tiling.js
index bad88e4ef..c61ef8655 100644
--- a/tiling.js
+++ b/tiling.js
@@ -2690,10 +2690,10 @@ function ensuredX(meta_window, space) {
x = 0;
} else if (index == 0 && x <= min) {
// Always align the first window to the display's left edge
- x = min;
+ x = min + prefs.tiling_edge_margin;
} else if (index == space.length-1 && x + frame.width >= max) {
// Always align the first window to the display's right edge
- x = max - frame.width;
+ x = max - frame.width - prefs.tiling_edge_margin;
} else if (frame.width > workArea.width*0.9 - 2*(prefs.horizontal_margin + prefs.window_gap)) {
// Consider the window to be wide and center it
x = min + Math.round((workArea.width - frame.width)/2);
@@ -2716,7 +2716,6 @@ function ensuredX(meta_window, space) {
return x;
}
-
/**
Make sure that `meta_window` is in view, scrolling the space if needed.
*/