From e575676d7df6e3fd3a1701afa1d0db18b31000e3 Mon Sep 17 00:00:00 2001 From: Leleat Date: Wed, 21 Feb 2024 02:20:45 +0100 Subject: [PATCH] moveHandler: Handle change of window action key Currently, a conflict of the window action key (Alt or Super) with a movement mode modifier of T-A is only checked and handled during enable time. But users may change the window action key while T-A is already enabled. Handle that case now as well. Previously, the modifier for the conflicting move mode was switched to the non-window-action-modifier. But that can be an issue, if that modifier is already taken by a different mode. So simply disable the modifier for the conflicting mode. Closes https://github.com/Leleat/Tiling-Assistant/issues/313 --- .../src/extension/moveHandler.js | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/tiling-assistant@leleat-on-github/src/extension/moveHandler.js b/tiling-assistant@leleat-on-github/src/extension/moveHandler.js index 43d3c96..6bdb166 100644 --- a/tiling-assistant@leleat-on-github/src/extension/moveHandler.js +++ b/tiling-assistant@leleat-on-github/src/extension/moveHandler.js @@ -44,20 +44,44 @@ export default class TilingMoveHandler { // The mouse button mod to move/resize a window may be changed to Alt. // So switch Alt and Super in our own prefs, if the user switched from // Super to Alt. - const wmPrefs = new Gio.Settings({ + const modKeys = [ + Settings.ADAPTIVE_TILING_MOD, + Settings.FAVORITE_LAYOUT_MOD, + Settings.IGNORE_TA_MOD + ]; + const handleWindowActionKeyConflict = () => { + const currMod = this._wmPrefs.get_string('mouse-button-modifier'); + + if (currMod === '') { + for (const key of modKeys) { + const mod = Settings.getInt(key); + if (mod === 2) // Alt + Settings.setInt(key, 0); + } + } else if (currMod === '') { + for (const key of modKeys) { + const mod = Settings.getInt(key); + if (mod === 4) // Super + Settings.setInt(key, 0); + } + } + }; + + this._wmPrefs = new Gio.Settings({ schema_id: 'org.gnome.desktop.wm.preferences' }); - const altAsMod = wmPrefs.get_string('mouse-button-modifier') === ''; - if (altAsMod) { - for (const s of [Settings.ADAPTIVE_TILING_MOD, Settings.FAVORITE_LAYOUT_MOD]) { - const mod = Settings.getInt(s); - if (mod === 1) // 1 -> Alt; see settings ui - Settings.setInt(s, 3); // 3 -> Super; see settings ui - } - } + this._wmPrefs.connectObject( + 'changed::mouse-button-modifier', + () => handleWindowActionKeyConflict(), + this + ); + handleWindowActionKeyConflict(); } destroy() { + this._wmPrefs.disconnectObject(this); + this._wmPrefs = null; + this._displaySignals.forEach(sId => global.display.disconnect(sId)); this._tilePreview.destroy();