Skip to content

Commit

Permalink
Add options to isolate monitors and hide empty spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Lübbemeier committed Dec 22, 2020
1 parent a69df7a commit 90dd89b
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 9 deletions.
80 changes: 80 additions & 0 deletions Settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,86 @@
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">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="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Isolate monitors when switching workspaces</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="isolate-monitors">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">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="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Show empty workspaces when switching workspaces</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="show-empty-spaces">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
Expand Down
16 changes: 16 additions & 0 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ class SettingsWidget {
state);
});

let isolateMonitors = this.builder.get_object('isolate-monitors');
isolateMonitors.state =
this._settings.get_boolean('isolate-monitors');
isolateMonitors.connect('state-set', (obj, state) => {
this._settings.set_boolean('isolate-monitors',
state);
});

let showEmptySpaces = this.builder.get_object('show-empty-spaces');
showEmptySpaces.state =
this._settings.get_boolean('show-empty-spaces');
showEmptySpaces.connect('state-set', (obj, state) => {
this._settings.set_boolean('show-empty-spaces',
state);
});


// Workspaces

Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
10 changes: 10 additions & 0 deletions schemas/org.gnome.shell.extensions.org-scrollwm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,16 @@
<summary>Make the top bar follow the focused monitor</summary>
</key>

<key type="b" name="isolate-monitors">
<default>false</default>
<summary>Isolate monitors when switching workspaces</summary>
</key>

<key type="b" name="show-empty-spaces">
<default>true</default>
<summary>Show empty workspaces when switching workspaces</summary>
</key>

<key type="d" name="animation-time">
<default>0.25</default>
<summary>Duration of animations in seconds</summary>
Expand Down
3 changes: 2 additions & 1 deletion settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ 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']
'cycle-width-steps', 'cycle-height-steps', 'topbar-follow-focus',
'isolate-monitors', 'show-empty-spaces']
.forEach((k) => setState(null, k));

function setVerticalMargin() {
Expand Down
26 changes: 18 additions & 8 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -1776,9 +1776,7 @@ class Spaces extends Map {
TopBar.fixTopBar();
const scale = 0.9;
let space = this.spaceOf(workspaceManager.get_active_workspace());
let mru = [...this.stack];
this.monitors.forEach(space => mru.splice(mru.indexOf(space), 1));
mru = [space, ...mru];
let mru = this._getMru();

if (Main.panel.statusArea.appMenu)
Main.panel.statusArea.appMenu.container.hide();
Expand Down Expand Up @@ -1848,6 +1846,22 @@ class Spaces extends Map {
}
}

_getMru() {
let mru = [...this.stack];
let activeSpace = this.spaceOf(workspaceManager.get_active_workspace());
if (prefs.isolate_monitors) {
mru = mru.filter(
(space) => space !== activeSpace && space.monitor === activeSpace.monitor,
);
} else {
this.monitors.forEach((space) => mru.splice(mru.indexOf(space), 1));
}
if (!prefs.show_empty_spaces) {
mru = mru.filter((space) => space.length > 0);
}
return [activeSpace, ...mru];
}

selectStackSpace(direction, move) {

// if in sequence preview do not run stack preview
Expand All @@ -1856,11 +1870,7 @@ class Spaces extends Map {
}

const scale = 0.9;
let space = this.spaceOf(workspaceManager.get_active_workspace());
let mru = [...this.stack];

this.monitors.forEach(space => mru.splice(mru.indexOf(space), 1));
mru = [space, ...mru];
let mru = this._getMru()

if (!inPreview) {
this._initWorkspaceStack();
Expand Down

0 comments on commit 90dd89b

Please sign in to comment.