From b331eecc662697bc4b32d8fe8319d5ac93c665a3 Mon Sep 17 00:00:00 2001 From: Maycon Date: Wed, 29 Apr 2026 13:53:37 -0300 Subject: [PATCH] cleanup: remove deprecated accelerator-grabber API Five `@deprecated` symbols in keybindings.js predate the move to Main.wm.addKeybinding (which is what enable()/disable() actually use). None of them have callers anywhere in the codebase, and one of them (`enableListenForBindings`) references an undefined `windowConfig` identifier and would throw if invoked. Removing: - _acceleratorActivate - _bindSignals - enableListenForBindings (referenced undefined `windowConfig`) - disableListenForBindings - listenFor - the unused `_grabbers` Map field - the commented-out `// this._bindSignals();` call in the constructor This is purely a deletion; no behaviour change. 77 lines removed. --- lib/extension/keybindings.js | 77 ------------------------------------ 1 file changed, 77 deletions(-) diff --git a/lib/extension/keybindings.js b/lib/extension/keybindings.js index cd5dba0b..60fb13b9 100644 --- a/lib/extension/keybindings.js +++ b/lib/extension/keybindings.js @@ -38,8 +38,6 @@ export class Keybindings extends GObject.Object { constructor(ext) { super(); Logger.debug(`created keybindings`); - this._grabbers = new Map(); - // this._bindSignals(); this.ext = ext; this.extWm = ext.extWm; this.kbdSettings = ext.kbdSettings; @@ -47,24 +45,6 @@ export class Keybindings extends GObject.Object { this.buildBindingDefinitions(); } - // @deprecated - _acceleratorActivate(action) { - let grabber = this._grabbers.get(action); - if (grabber) { - Logger.debug(`Firing accelerator ${grabber.accelerator} : ${grabber.name}`); - grabber.callback(); - } else { - Logger.error(`No listeners [action={${action}}]`); - } - } - - // @deprecated - _bindSignals() { - global.display.connect("accelerator-activated", (_display, action, _deviceId, _timestamp) => { - this._acceleratorActivate(action); - }); - } - enable() { let keybindings = this._bindings; @@ -91,63 +71,6 @@ export class Keybindings extends GObject.Object { Logger.debug(`keybindings:disable`); } - // @deprecated - enableListenForBindings() { - windowConfig.forEach((config) => { - config.shortcut.forEach((shortcut) => { - this.listenFor(shortcut, () => { - config.actions.forEach((action) => { - this.extWm.command(action); - }); - }); - }); - }); - } - - // @deprecated - disableListenForBindings() { - // The existing grabber items are from the custom config by - // this extension. - this._grabbers.forEach((grabber) => { - global.display.ungrab_accelerator(grabber.action); - Main.wm.allowKeybinding(grabber.name, Shell.ActionMode.NONE); - }); - - this._grabbers.clear(); - } - - /** - * API for quick binding of keys to function. This is going to be useful with SpaceMode - * - * @param {String} accelerator - keybinding combinations - * @param {Function} callback - function to call when the accelerator is invoked - * - * Credits: - * - https://superuser.com/a/1182899 - * - Adapted based on current Gnome-shell API or syntax - */ - listenFor(accelerator, callback) { - let grabFlags = Meta.KeyBindingFlags.NONE; - let action = global.display.grab_accelerator(accelerator, grabFlags); - - if (action == Meta.KeyBindingAction.NONE) { - Logger.error(`Unable to grab accelerator [binding={${accelerator}}]`); - // TODO - check the gnome keybindings for conflicts and notify the user - } else { - let name = Meta.external_binding_name_for_action(action); - - Logger.debug(`Requesting WM to allow binding [name={${name}}]`); - Main.wm.allowKeybinding(name, Shell.ActionMode.ALL); - - this._grabbers.set(action, { - name: name, - accelerator: accelerator, - callback: callback, - action: action, - }); - } - } - get modifierState() { const [_x, _y, state] = this.extWm.getPointer(); return state;