diff --git a/README.md b/README.md index 348c23daa..ea77011e2 100644 --- a/README.md +++ b/README.md @@ -290,7 +290,7 @@ 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. @@ -298,7 +298,26 @@ Focus modes can be toggled by user-settable keybinding (default is `Super`+`Shif ![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 diff --git a/Settings.ui b/Settings.ui index c6732a86b..39bbf2b5e 100644 --- a/Settings.ui +++ b/Settings.ui @@ -662,7 +662,7 @@ - + 1 0 diff --git a/prefs.js b/prefs.js index 86542df82..476f82750 100644 --- a/prefs.js +++ b/prefs.js @@ -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); diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index 0318cc7ae..f488473fc 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 34adfc3df..55de128d8 100644 --- a/schemas/org.gnome.shell.extensions.paperwm.gschema.xml +++ b/schemas/org.gnome.shell.extensions.paperwm.gschema.xml @@ -267,7 +267,6 @@ - @@ -369,6 +368,11 @@ Show the top bar on workspaces by default + + 0 + Set the default focus mode. 0:DEFAULT 1:CENTER + + true Make the top bar follow the focused monitor diff --git a/settings.js b/settings.js index 473f0258e..aaae3b3ba 100644 --- a/settings.js +++ b/settings.js @@ -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) }); @@ -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) { diff --git a/stackoverlay.js b/stackoverlay.js index 5e68065f4..25567f2fd 100644 --- a/stackoverlay.js +++ b/stackoverlay.js @@ -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) { diff --git a/tiling.js b/tiling.js index b5e8ec125..6df1382ff 100644 --- a/tiling.js +++ b/tiling.js @@ -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(); @@ -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); }) @@ -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); }); @@ -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() {