Skip to content
Merged
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
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,34 @@ You can style both the coloured position bar and the dimmed "position bar backdr

_Note: PaperWM overrides the default Gnome Top Bar style to be completely transparent so that the dimmed `window-position-bar-backdrop` and`window-position-bar` elements are visible._

## Window Focus Mode ##
## Window Focus Mode

[#482](https://github.com/paperwm/PaperWM/pull/482) added the concept of `window focus modes` to PaperWM. A `focus mode` controls how windows are "focused". For example, the `CENTER` focus mode causes all windows to be centered horizontally on selection, whereas the `DEFAULT` focus mode is the traditional PaperWM behaviour.

Focus modes can be toggled by user-settable keybinding (default is `Super`+`Shift`+`c`), or by clicking the new focus-mode button in the topbar:

![Focus mode button](media/focus-mode-button.png)

You may prefer to hide the focus mode icon. You can do so by executing the following command in a terminal:

### Setting the default focus mode

The default focus mode is the standard PaperWM focus mode (i.e. not centered). This can be changed according to preference by changing the `default-focus-mode` setting via `dconf` or `gsettings`.

To set the default focus mode to `CENTER`, execute the following from a terminal:
```
dconf write /org/gnome/shell/extensions/paperwm/default-focus-mode 1
```

To undo, or revert to the original PaperWM behaviour, execute the following:
```
dconf write /org/gnome/shell/extensions/paperwm/default-focus-mode 0
```

_Note: changing this setting during a PaperWM session will set all spaces to the new default focus mode._

### Hiding the focus mode icon

Users may also prefer to hide the focus mode icon. You can do so by executing the following command in a terminal:

```
dconf write /org/gnome/shell/extensions/paperwm/show-focus-mode-icon false
Expand Down
2 changes: 1 addition & 1 deletion Settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@
</object>
</child>
<child>
<object class="GtkSwitch" id="enable-window-position-bar">
<object class="GtkSwitch" id="show-window-position-bar">
<layout>
<property name="column">1</property>
<property name="row">0</property>
Expand Down
26 changes: 9 additions & 17 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,38 +220,30 @@ var SettingsWidget = class SettingsWidget {
this._settings.set_boolean('only-scratch-in-overview', false);
this._settings.set_boolean('disable-scratch-in-overview', false);
}

});

let enableWindowPositionBar = this.builder.get_object('enable-window-position-bar');
enableWindowPositionBar.state =
this._settings.get_boolean('show-window-position-bar');
enableWindowPositionBar.connect('state-set', (obj, state) => {
this._settings.set_boolean('show-window-position-bar',
state);
let enableWindowPositionBar = this.builder.get_object('show-window-position-bar');
enableWindowPositionBar.active = this._settings.get_boolean('show-window-position-bar');
enableWindowPositionBar.connect('state-set', (obj, state) => {
this._settings.set_boolean('show-window-position-bar', state);
});

let disableCorner = this.builder.get_object('override-hot-corner');
disableCorner.state =
this._settings.get_boolean('override-hot-corner');
disableCorner.active = this._settings.get_boolean('override-hot-corner');
disableCorner.connect('state-set', (obj, state) => {
this._settings.set_boolean('override-hot-corner',
state);
this._settings.set_boolean('override-hot-corner', state);
});

let topbarFollowFocus = this.builder.get_object('topbar-follow-focus');
topbarFollowFocus.state =
this._settings.get_boolean('topbar-follow-focus');
topbarFollowFocus.active = this._settings.get_boolean('topbar-follow-focus');
topbarFollowFocus.connect('state-set', (obj, state) => {
this._settings.set_boolean('topbar-follow-focus',
state);
this._settings.set_boolean('topbar-follow-focus', state);
});

// Workspaces

const defaultBackgroundSwitch = this.builder.get_object('use-default-background');
defaultBackgroundSwitch.state =
this._settings.get_boolean('use-default-background');
defaultBackgroundSwitch.active = this._settings.get_boolean('use-default-background');
defaultBackgroundSwitch.connect('state-set', (obj, state) => {
this._settings.set_boolean('use-default-background',
state);
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
6 changes: 5 additions & 1 deletion schemas/org.gnome.shell.extensions.paperwm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@
</key>
</schema>


<schema id="org.gnome.Shell.Extensions.PaperWM" path="/org/gnome/shell/extensions/paperwm/">

<key type="b" name="has-installed-config-template">
Expand Down Expand Up @@ -369,6 +368,11 @@
<summary>Show the top bar on workspaces by default</summary>
</key>

<key type="i" name="default-focus-mode">
<default>0</default>
<summary>Set the default focus mode. 0:DEFAULT 1:CENTER</summary>
</key>

<key type="b" name="topbar-follow-focus">
<default>true</default>
<summary>Make the top bar follow the focused monitor</summary>
Expand Down
25 changes: 24 additions & 1 deletion settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ var prefs = {};
'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', 'show-window-position-bar', 'show-focus-mode-icon', 'disable-topbar-styling']
'winprops', 'show-window-position-bar', 'show-focus-mode-icon', 'disable-topbar-styling',
'default-focus-mode']
.forEach((k) => setState(null, k));

prefs.__defineGetter__("minimum_margin", function() { return Math.min(15, this.horizontal_margin) });
Expand Down Expand Up @@ -118,6 +119,28 @@ function disable() {
workspaceSettingsCache = {};
}

/**
* Returns the default focus mode (can be user-defined).
*/
function getDefaultFocusMode() {
// find matching focus mode
const mode = prefs.default_focus_mode;
const modes = Extension.imports.tiling.FocusModes;
let result = null;
Object.entries(modes).forEach(([k,v]) => {
if (v === mode) {
result = k;
}
});

// if found return, otherwise return default
if (result) {
return modes[result];
} else {
return modes.DEFAULT;
}
}

/// Workspaces

function getWorkspaceSettings(index) {
Expand Down
2 changes: 2 additions & 0 deletions stackoverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ var StackOverlay = class StackOverlay {
triggerPreview() {
if ("_previewId" in this)
return;
if (!this.target)
return;
this._previewId = Mainloop.timeout_add(100, () => {
delete this._previewId;
if (this.clone) {
Expand Down
25 changes: 13 additions & 12 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ var inPreview = PreviewMode.NONE;
// DEFAULT mode is normal/original PaperWM window focus behaviour
var FocusModes = {DEFAULT: 0, CENTER: 1};

var signals, oldSpaces, backgroundGroup, oldMonitors, WindowCloneLayout,
grabSignals;
var signals, oldSpaces, backgroundGroup, oldMonitors, WindowCloneLayout, grabSignals;
function init() {
// Symbol to retrieve the focus handler id
signals = new utils.Signals();
Expand Down Expand Up @@ -151,8 +150,7 @@ var Space = class Space extends Array {
this.focusModeIcon = new TopBar.FocusIcon({
name: 'panel',
style_class: 'space-focus-mode-icon',
})
.setMode(this.focusMode)
})
.setClickFunction(() => {
switchToNextFocusMode(this);
})
Expand Down Expand Up @@ -261,7 +259,10 @@ var Space = class Space extends Array {
this.windowPositionBarBackdrop.width = this.monitor.width;
this.windowPositionBarBackdrop.height = TopBar.panelBox.height;
this.setSpaceTopbarElementsVisible(false);


// apply default focus mode
setFocusMode(Settings.getDefaultFocusMode(), this);

this.getWindows().forEach(w => {
animateWindow(w);
});
Expand All @@ -278,19 +279,19 @@ var Space = class Space extends Array {
// after moveDone, ensureViewport on display.focus_window (see moveDone function)
ensureViewport(window, this, { force: true })
}));

this.signals.connect(Settings.settings, 'changed::default-focus-mode', () => {
setFocusMode(Settings.getDefaultFocusMode(), this);
});

const Convenience = Extension.imports.convenience;
const settings = Convenience.getSettings();
this.signals.connect(
interfaceSettings,
"changed::color-scheme",
this.updateBackground.bind(this)
);
this.signals.connect(interfaceSettings, "changed::color-scheme", this.updateBackground.bind(this));

this.signals.connect(settings, 'changed::default-background', this.updateBackground.bind(this));
this.signals.connect(settings, 'changed::use-default-background', this.updateBackground.bind(this));
this.signals.connect(backgroundSettings, 'changed::picture-uri', this.updateBackground.bind(this));
this.signals.connect(backgroundSettings, "changed::picture-uri-dark", this.updateBackground.bind(this)
);
this.signals.connect(backgroundSettings, "changed::picture-uri-dark", this.updateBackground.bind(this));
}

show() {
Expand Down