shellDBus: Add grabFlags parameter

Add an grabFlags parameter to the GrabAccelerator and GrabAccelerators dbus
methods. This will allow e.g. Gnome Settings Daemon to create shortcuts that
should discard key-repeated events.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/156

Fixes: https://gitlab.gnome.org/GNOME/gnome-settings-daemon/issues/68
This commit is contained in:
Andrea Azzarone 2018-07-18 20:26:44 +02:00 committed by Andrea Azzarone
parent be06101e9a
commit f3168d22a6
2 changed files with 10 additions and 9 deletions

View File

@ -22,11 +22,12 @@
<method name="ShowApplications"/> <method name="ShowApplications"/>
<method name="GrabAccelerator"> <method name="GrabAccelerator">
<arg type="s" direction="in" name="accelerator"/> <arg type="s" direction="in" name="accelerator"/>
<arg type="u" direction="in" name="flags"/> <arg type="u" direction="in" name="modeFlags"/>
<arg type="u" direction="in" name="grabFlags"/>
<arg type="u" direction="out" name="action"/> <arg type="u" direction="out" name="action"/>
</method> </method>
<method name="GrabAccelerators"> <method name="GrabAccelerators">
<arg type="a(su)" direction="in" name="accelerators"/> <arg type="a(suu)" direction="in" name="accelerators"/>
<arg type="au" direction="out" name="actions"/> <arg type="au" direction="out" name="actions"/>
</method> </method>
<method name="UngrabAccelerator"> <method name="UngrabAccelerator">

View File

@ -105,9 +105,9 @@ var GnomeShell = class {
} }
GrabAcceleratorAsync(params, invocation) { GrabAcceleratorAsync(params, invocation) {
let [accel, flags] = params; let [accel, modeFlags, grabFlags] = params;
let sender = invocation.get_sender(); let sender = invocation.get_sender();
let bindingAction = this._grabAcceleratorForSender(accel, flags, sender); let bindingAction = this._grabAcceleratorForSender(accel, modeFlags, grabFlags, sender);
return invocation.return_value(GLib.Variant.new('(u)', [bindingAction])); return invocation.return_value(GLib.Variant.new('(u)', [bindingAction]));
} }
@ -116,8 +116,8 @@ var GnomeShell = class {
let sender = invocation.get_sender(); let sender = invocation.get_sender();
let bindingActions = []; let bindingActions = [];
for (let i = 0; i < accels.length; i++) { for (let i = 0; i < accels.length; i++) {
let [accel, flags] = accels[i]; let [accel, modeFlags, grabFlags] = accels[i];
bindingActions.push(this._grabAcceleratorForSender(accel, flags, sender)); bindingActions.push(this._grabAcceleratorForSender(accel, modeFlags, grabFlags, sender));
} }
return invocation.return_value(GLib.Variant.new('(au)', [bindingActions])); return invocation.return_value(GLib.Variant.new('(au)', [bindingActions]));
} }
@ -151,13 +151,13 @@ var GnomeShell = class {
GLib.Variant.new('(ua{sv})', [action, params])); GLib.Variant.new('(ua{sv})', [action, params]));
} }
_grabAcceleratorForSender(accelerator, flags, sender) { _grabAcceleratorForSender(accelerator, modeFlags, grabFlags, sender) {
let bindingAction = global.display.grab_accelerator(accelerator); let bindingAction = global.display.grab_accelerator(accelerator, grabFlags);
if (bindingAction == Meta.KeyBindingAction.NONE) if (bindingAction == Meta.KeyBindingAction.NONE)
return Meta.KeyBindingAction.NONE; return Meta.KeyBindingAction.NONE;
let bindingName = Meta.external_binding_name_for_action(bindingAction); let bindingName = Meta.external_binding_name_for_action(bindingAction);
Main.wm.allowKeybinding(bindingName, flags); Main.wm.allowKeybinding(bindingName, modeFlags);
this._grabbedAccelerators.set(bindingAction, sender); this._grabbedAccelerators.set(bindingAction, sender);