Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions Settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="tiling_edge_margin">
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="window_gap">
<property name="upper">99</property>
<property name="step_increment">1</property>
Expand Down Expand Up @@ -255,6 +260,50 @@
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="activatable">False</property>
<property name="focusable">False</property>
<property name="tooltip_text" translatable="yes">Minimum margin from screen edges to the leftmost and rightmost window edges</property>
<child>
<object class="GtkGrid">
<property name="focusable">False</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkLabel">
<property name="focusable">False</property>
<property name="hexpand">1</property>
<property name="label" translatable="yes">Tiling edge margin</property>
<property name="xalign">0</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="tiling_edge_margin_spinner">
<property name="width_chars">2</property>
<property name="max_width_chars">2</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">tiling_edge_margin</property>
<property name="snap_to_ticks">1</property>
<property name="numeric">1</property>
<property name="update_policy">if-valid</property>
<layout>
<property name="column">1</property>
<property name="row">0</property>
</layout>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="general_row_4">
<property name="activatable">False</property>
Expand Down
6 changes: 6 additions & 0 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
5 changes: 5 additions & 0 deletions schemas/org.gnome.shell.extensions.paperwm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@
<summary>Minimum margin from windows bottom edge</summary>
</key>

<key type="i" name="tiling-edge-margin">
<default>0</default>
<summary>Minimum margin from the screen edge to the left and right tiling edge</summary>
</key>

<key type="i" name="window-gap">
<default>20</default>
<summary>Minimum gap between windows</summary>
Expand Down
34 changes: 30 additions & 4 deletions settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) });
Expand All @@ -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();
Expand All @@ -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, '_');
Expand Down Expand Up @@ -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();

Expand Down
5 changes: 2 additions & 3 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -2716,7 +2716,6 @@ function ensuredX(meta_window, space) {
return x;
}


/**
Make sure that `meta_window` is in view, scrolling the space if needed.
*/
Expand Down