From 561cecf38345cd43c1140e05d9342c2b8be5b3e5 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Sat, 2 Mar 2019 16:49:55 +0100 Subject: [PATCH] shellDBus: Add UngrabAccelerators While it is possible to register accelerators in-bulk, there is no proper way to unregister them again. This adds the corresponding call for UngrabAccelerator to allow ungrabbing multiple accelerators at the same time. The idea is that g-s-d can use this in the future to simplify the keybinding reload logic. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/429 --- data/dbus-interfaces/org.gnome.Shell.xml | 4 ++++ js/ui/shellDBus.js | 29 +++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/data/dbus-interfaces/org.gnome.Shell.xml b/data/dbus-interfaces/org.gnome.Shell.xml index b5b44af7a..1fef302b3 100644 --- a/data/dbus-interfaces/org.gnome.Shell.xml +++ b/data/dbus-interfaces/org.gnome.Shell.xml @@ -34,6 +34,10 @@ + + + + diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js index 9238b7c35..469a6c706 100644 --- a/js/ui/shellDBus.js +++ b/js/ui/shellDBus.js @@ -124,13 +124,20 @@ var GnomeShell = class { UngrabAcceleratorAsync(params, invocation) { let [action] = params; - let grabbedBy = this._grabbedAccelerators.get(action); - if (invocation.get_sender() != grabbedBy) - return invocation.return_value(GLib.Variant.new('(b)', [false])); + let sender = invocation.get_sender(); + let ungrabSucceeded = this._ungrabAcceleratorForSender(action, sender); + + return invocation.return_value(GLib.Variant.new('(b)', [ungrabSucceeded])); + } + + UngrabAcceleratorsAsync(params, invocation) { + let [actions] = params; + let sender = invocation.get_sender(); + let ungrabSucceeded = true; + + for (let i = 0; i < actions.length; i++) + ungrabSucceeded &= this._ungrabAcceleratorForSender(actions[i], sender); - let ungrabSucceeded = global.display.ungrab_accelerator(action); - if (ungrabSucceeded) - this._grabbedAccelerators.delete(action); return invocation.return_value(GLib.Variant.new('(b)', [ungrabSucceeded])); } @@ -174,6 +181,16 @@ var GnomeShell = class { let ungrabSucceeded = global.display.ungrab_accelerator(action); if (ungrabSucceeded) this._grabbedAccelerators.delete(action); + + return ungrabSucceeded; + } + + _ungrabAcceleratorForSender(action, sender) { + let grabbedBy = this._grabbedAccelerators.get(action); + if (sender != grabbedBy) + return false; + + return this._ungrabAccelerator(action); } _onGrabberBusNameVanished(connection, name) {