From f8363d7d0400627ce342577e70d764bcb4a3effb Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Mon, 3 Apr 2023 21:28:05 +1000 Subject: [PATCH 1/6] Added guard against exception sometimes seen in gnome logs. --- stackoverlay.js | 2 ++ 1 file changed, 2 insertions(+) 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) { From 42972912c35510f79b1aaa2e26f725f9e060f406 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Mon, 3 Apr 2023 22:49:59 +1000 Subject: [PATCH 2/6] Moved to numeral value setting (0:DEFAULT, 1:CENTER). --- prefs.js | 10 ++-- schemas/gschemas.compiled | Bin 6752 -> 6792 bytes ...gnome.shell.extensions.paperwm.gschema.xml | 6 ++- settings.js | 26 ++++++++++- tiling.js | 44 +++++++----------- 5 files changed, 51 insertions(+), 35 deletions(-) diff --git a/prefs.js b/prefs.js index 86542df82..f138cd015 100644 --- a/prefs.js +++ b/prefs.js @@ -220,31 +220,27 @@ 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); + 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.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.connect('state-set', (obj, state) => { - this._settings.set_boolean('topbar-follow-focus', - state); + this._settings.set_boolean('topbar-follow-focus', state); }); // Workspaces diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index 0318cc7aed79341c58840cf8104e1f192335dc43..f488473fcc48da4d5ddca9523756fb9fd31aa927 100644 GIT binary patch delta 1701 zcmZuxUuauZ96s$5_oqpd=1|)gfN^?)RPV zcmALAJBtrb^iIC~^xm)#-l!0N;Y+j#e9sDUH*jdlIa?2hx?5z#0C-2M5G}i=9-w~) zIt_mjygM#`jwWXpl7aml>;>P3|GaSI#S18xR53>BnH4$z_%lLnm%aLJ$9NuN3d{~Y*JVD8n?25thi7ycah zhp?!L<^231Hb6lH5%?W^JR-#G=l9>BPt5@?f-eJSZ+~gir*46N6MPH!ZO_3HeQFN8 z1pXBmTDZPUpSlfx5T_9ZoC{x+{TSaZgb_%=Q~>Wg9uFH(bKng40PyEF<9Yhj5%@*0 z0bDrwL_2+I4m<`v2CN@DHIMxSIM^)2YubE>^{E?cXs{Kc8+h|Q&rJrXeefRz>%g_? z$M?~v<`Im6j{@}v+iLWwx4=IEo&mn@4+ZE`x5J+YUkCQ@Oy8kT&5168Yq#-xzy93` z2B^6c0++%IytJpMN}rl5-U?0v)1Q6vBYo;k@YCR4;Pm-?mOga=eg@nReBAfb75daX zvLe_328`L7!vG772#kS`0)H$|uh6IFif6#*0K4x6i#|2)${hF_(EQO=cS6(+@Na-O zAe)kJrQ98&_QMZ?nSHsDTuD=g^?b!wRGf-dcF?I1ax`|Y9FKM;st%%-J?NCxoTiwn zp}BEUCsJ9Nh^KKyoqyvwt7O@Zd?Y;cA{*wl!)mouQL<`ouwYwNGw(J|WxJfBHH=Zs zJg96rdPTQPRI?Fh&t3o9G9{mhZI|PbUGhWB?)&C6uB@BOzSTL2jbKbj@R~92w*Vm^ z4lv)D#aOfZ9<+fQfO`ODeGouixbFs^9PAsW!cFJh7lLmJUj)_E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DyriBu9GTK) z@_MbP*Gl$tUfev0AFKx2Y2DrdL%{u?uQN zYjz#-t~b9o*zx0|~Z4Kph zl}=Samu8D+{X+s|%|Ls}QTwGhi?9flkl^Seddc zQFt%j#nQC%BJyfss$?1UT9HjzTUKJv%cc0U7)U$`(+sNlKiMW?LTj%M0I zy0Nqzi}m$1G|SQP$e%oj=Cb%GWGLP%dy{3CWp)?7jSg%q0Ls>*U$|C!7NkCC2JD;? zdY+OjbOfAyAs6KR^gRBf&@u38=cgB#)BBK*L(hYS*caaY^teAQ$}lFFPt2Csfu03s nj+yN5`Z>pn&moe~6xgXa^qevaJxAX<$n;#|1awj!?SAb)tw%uN 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..7c6cf4df1 100644 --- a/settings.js +++ b/settings.js @@ -21,6 +21,7 @@ var Gtk = imports.gi.Gtk; var Convenience = Extension.imports.convenience; var settings = Convenience.getSettings(); +var Tiling = Extension.imports.tiling; var workspaceSettingsCache = {}; var WORKSPACE_KEY = 'org.gnome.Shell.Extensions.PaperWM.Workspace'; @@ -35,7 +36,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 +120,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 = 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/tiling.js b/tiling.js index 65cf58de4..f4181d0d5 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(); @@ -147,12 +146,11 @@ var Space = class Space extends Array { this._populated = false; // default focusMode (can be overriden by saved user pref in Space.init method) - this.focusMode = FocusModes.DEFAULT; + this.focusMode = Settings.getDefaultFocusMode(); this.focusModeIcon = new TopBar.FocusIcon({ name: 'panel', style_class: 'space-focus-mode-icon', }) - .setMode(this.focusMode) .setClickFunction(() => { switchToNextFocusMode(this); }) @@ -262,6 +260,9 @@ var Space = class Space extends Array { this.windowPositionBarBackdrop.height = TopBar.panelBox.height; this.setSpaceTopbarElementsVisible(false); + // apply default focus mode + setFocusMode(this.focusMode, this); + this.getWindows().forEach(w => { animateWindow(w); }); @@ -271,32 +272,23 @@ var Space = class Space extends Array { ensureViewport(selected, this, true); } - this.signals.connect(workspace, "window-added", - utils.dynamic_function_ref("add_handler", Me)); - this.signals.connect(workspace, "window-removed", - utils.dynamic_function_ref("remove_handler", Me)); - this.signals.connect(Main.overview, 'showing', - this.startAnimate.bind(this)); + this.signals.connect(workspace, "window-added", utils.dynamic_function_ref("add_handler", Me)); + this.signals.connect(workspace, "window-removed", utils.dynamic_function_ref("remove_handler", Me)); + this.signals.connect(Main.overview, 'showing', this.startAnimate.bind(this)); this.signals.connect(Main.overview, 'hidden', this.moveDone.bind(this)); + + 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(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(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)); } show() { From cdfa0ab6835f22ad8664b28de57a97c2ac66fbdf Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Tue, 4 Apr 2023 09:04:14 +1000 Subject: [PATCH 3/6] FIX: preferences GtkSwitch element should be using `active` property (not `state`) when rendering (otherwise slider position will be off/left). Signal connect should change on `state-set` though (as is currently). --- Settings.ui | 2 +- prefs.js | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) 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 f138cd015..476f82750 100644 --- a/prefs.js +++ b/prefs.js @@ -222,23 +222,20 @@ var SettingsWidget = class SettingsWidget { } }); - 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) => { + 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); }); 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); }); @@ -246,8 +243,7 @@ var SettingsWidget = class SettingsWidget { // 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); From 9fd87a782a4e98c5526fb54f2441e6cec9c89f2f Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Tue, 4 Apr 2023 09:06:04 +1000 Subject: [PATCH 4/6] Now setting default focus mode on Space init. --- settings.js | 3 +-- tiling.js | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/settings.js b/settings.js index 7c6cf4df1..aaae3b3ba 100644 --- a/settings.js +++ b/settings.js @@ -21,7 +21,6 @@ var Gtk = imports.gi.Gtk; var Convenience = Extension.imports.convenience; var settings = Convenience.getSettings(); -var Tiling = Extension.imports.tiling; var workspaceSettingsCache = {}; var WORKSPACE_KEY = 'org.gnome.Shell.Extensions.PaperWM.Workspace'; @@ -126,7 +125,7 @@ function disable() { function getDefaultFocusMode() { // find matching focus mode const mode = prefs.default_focus_mode; - const modes = Tiling.FocusModes; + const modes = Extension.imports.tiling.FocusModes; let result = null; Object.entries(modes).forEach(([k,v]) => { if (v === mode) { diff --git a/tiling.js b/tiling.js index f4181d0d5..5dc91536c 100644 --- a/tiling.js +++ b/tiling.js @@ -146,11 +146,11 @@ var Space = class Space extends Array { this._populated = false; // default focusMode (can be overriden by saved user pref in Space.init method) - this.focusMode = Settings.getDefaultFocusMode(); + this.focusMode = FocusModes.DEFAULT; this.focusModeIcon = new TopBar.FocusIcon({ name: 'panel', style_class: 'space-focus-mode-icon', - }) + }) .setClickFunction(() => { switchToNextFocusMode(this); }) @@ -259,9 +259,9 @@ 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(this.focusMode, this); + setFocusMode(Settings.getDefaultFocusMode(), this); this.getWindows().forEach(w => { animateWindow(w); From 2bc3ea508faa172c4e210a909e8cf4309aade6c6 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Tue, 4 Apr 2023 09:15:55 +1000 Subject: [PATCH 5/6] Updated README.md with commands to set the default focus mode. --- README.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 348c23daa..74e9b800a 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 setting 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 to, or revert to the original PaperWM behaviour (by default), 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 From 89b48948ca867a2203187b7183e3b8ffee11b867 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Tue, 4 Apr 2023 09:51:39 +1000 Subject: [PATCH 6/6] Correct typos in README.md. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 74e9b800a..ea77011e2 100644 --- a/README.md +++ b/README.md @@ -301,14 +301,14 @@ Focus modes can be toggled by user-settable keybinding (default is `Super`+`Shif ### 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 setting the `default-focus-mode` setting via `dconf` or `gsettings`. +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 to, or revert to the original PaperWM behaviour (by default), execute the following: +To undo, or revert to the original PaperWM behaviour, execute the following: ``` dconf write /org/gnome/shell/extensions/paperwm/default-focus-mode 0 ```