[gnome-shell/benzea/accelerator-api-improvements: 18/18] shellDBus: Add UngrabAccelerators
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/benzea/accelerator-api-improvements: 18/18] shellDBus: Add UngrabAccelerators
- Date: Mon, 4 Mar 2019 14:25:31 +0000 (UTC)
commit 64feed4a3edc4f382b9cc43e92e5d8f94523d37f
Author: Benjamin Berg <bberg redhat com>
Date: Sat Mar 2 16:49:55 2019 +0100
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 @@
<arg type="u" direction="in" name="action"/>
<arg type="b" direction="out" name="success"/>
</method>
+ <method name="UngrabAccelerators">
+ <arg type="au" direction="in" name="action"/>
+ <arg type="b" direction="out" name="success"/>
+ </method>
<signal name="AcceleratorActivated">
<arg name="action" type="u"/>
<arg name="parameters" type="a{sv}"/>
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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]