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
This commit is contained in:
Benjamin Berg 2019-03-02 16:49:55 +01:00 committed by Benjamin Berg
parent 60ccdc2deb
commit 561cecf383
2 changed files with 27 additions and 6 deletions

View File

@ -34,6 +34,10 @@
<arg type="u" direction="in" name="action"/> <arg type="u" direction="in" name="action"/>
<arg type="b" direction="out" name="success"/> <arg type="b" direction="out" name="success"/>
</method> </method>
<method name="UngrabAccelerators">
<arg type="au" direction="in" name="action"/>
<arg type="b" direction="out" name="success"/>
</method>
<signal name="AcceleratorActivated"> <signal name="AcceleratorActivated">
<arg name="action" type="u"/> <arg name="action" type="u"/>
<arg name="parameters" type="a{sv}"/> <arg name="parameters" type="a{sv}"/>

View File

@ -124,13 +124,20 @@ var GnomeShell = class {
UngrabAcceleratorAsync(params, invocation) { UngrabAcceleratorAsync(params, invocation) {
let [action] = params; let [action] = params;
let grabbedBy = this._grabbedAccelerators.get(action); let sender = invocation.get_sender();
if (invocation.get_sender() != grabbedBy) let ungrabSucceeded = this._ungrabAcceleratorForSender(action, sender);
return invocation.return_value(GLib.Variant.new('(b)', [false]));
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])); return invocation.return_value(GLib.Variant.new('(b)', [ungrabSucceeded]));
} }
@ -174,6 +181,16 @@ var GnomeShell = class {
let ungrabSucceeded = global.display.ungrab_accelerator(action); let ungrabSucceeded = global.display.ungrab_accelerator(action);
if (ungrabSucceeded) if (ungrabSucceeded)
this._grabbedAccelerators.delete(action); 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) { _onGrabberBusNameVanished(connection, name) {