Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.2:Update
budgie-desktop.13725
Rework-grab-and-ungrab-keys.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File Rework-grab-and-ungrab-keys.patch of Package budgie-desktop.13725
From 05b4694887fd072316470c570fbe4b4257a5f4f3 Mon Sep 17 00:00:00 2001 From: David Mohammed <fossfreedom@ubuntu.com> Date: Sun, 3 Nov 2019 21:37:34 +0000 Subject: [PATCH 1/3] Rework grab and ungrab keys --- src/wm/shim.vala | 96 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 91 insertions(+), 5 deletions(-) diff --git a/src/wm/shim.vala b/src/wm/shim.vala index 4cdfa0b0..44d6fc60 100644 --- a/src/wm/shim.vala +++ b/src/wm/shim.vala @@ -138,7 +138,7 @@ public interface BudgieOSD : GLib.Object public class ShellShim : GLib.Object { - HashTable<uint,string> grabs; + HashTable<string, uint?> grabs; HashTable<string,uint> watches; unowned Meta.Display? display; @@ -150,7 +150,7 @@ public class ShellShim : GLib.Object [DBus (visible = false)] public ShellShim(Budgie.BudgieWM? wm) { - grabs = new HashTable<uint,string>(direct_hash, direct_equal); + grabs = new HashTable<string, uint?> (str_hash, str_equal); watches = new HashTable<string,uint>(str_hash, str_equal); display = wm.get_display(); @@ -193,6 +193,7 @@ public class ShellShim : GLib.Object osd_proxy = null; } +/* #if HAVE_MUTTER_5 private void on_accelerator_activated(uint action, Clutter.InputDevice dev, uint device_id) #else @@ -207,8 +208,30 @@ public class ShellShim : GLib.Object this.accelerator_activated(action, params); } +*/ + +#if HAVE_MUTTER_5 + private void on_accelerator_activated(uint action, Clutter.InputDevice dev, uint device_id) +#else + private void on_accelerator_activated(uint action, uint device_id, timestamp) +#endif + { + print("on accelerator activated"); + foreach (string accelerator in grabs.get_keys ()) { + if (grabs[accelerator] == action) { + var params = new GLib.HashTable<string, Variant> (null, null); + params.set ("device-id", new Variant.uint32 (device_id)); +#if HAV_MUTTER_5 + params.set ("timestamp", new Variant.uint32 (timestamp)); +#else + params.set ("timestamp", new Variant.uint32 (0)); +#endif + this.accelerator_activated (action, params); + } + } + } - void on_disappeared(DBusConnection conn, string name) + /*void on_disappeared(DBusConnection conn, string name) { unowned string val; unowned uint key; @@ -226,10 +249,55 @@ public class ShellShim : GLib.Object continue; } display.ungrab_accelerator(key); - grabs.remove(key); + iter.remove(); } } + */ + public uint grab_accelerator (string accelerator, Meta.KeyBindingFlags flags) throws DBusError, IOError + { + print("grab accelertor"); + uint? action = grabs[accelerator]; + + if (action == null) { + action = display.grab_accelerator (accelerator, flags); + if (action > 0) { + grabs[accelerator] = action; + } + } + + return action; + } + + public uint[] grab_accelerators (GsdAccel[] accelerators) throws DBusError, IOError + { + print("grab accelerators"); + uint[] actions = {}; + + foreach (unowned GsdAccel? accelerator in accelerators) { + actions += grab_accelerator (accelerator.accelerator, accelerator.grab_flags); + } + + return actions; + } + + public bool ungrab_accelerator (uint action) throws DBusError, IOError + { + print("ungrab accelerator"); + bool ret = false; + + foreach (unowned string accelerator in grabs.get_keys ()) { + if (grabs[accelerator] == action) { + ret = display.ungrab_accelerator (action); + grabs.remove (accelerator); + break; + } + } + + return ret; + } + +/* #if HAVE_GSD_332 private uint _grab(string sender, string seq, uint flag, Meta.KeyBindingFlags grab_flags) { @@ -254,7 +322,7 @@ public class ShellShim : GLib.Object return ret; } - +*/ void on_bus_acquired(DBusConnection conn) { try { @@ -273,6 +341,22 @@ public class ShellShim : GLib.Object on_bus_acquired, null, null); } + public uint GrabAccelerator(BusName sender, string accelerator, uint flags, Meta.KeyBindingFlags grab_flags) + { + return grab_accelerator(accelerator, grab_flags); + } + + public uint[] GrabAccelerators(BusName sender, GsdAccel[] accelerators) + { + return grab_accelerators(accelerators); + } + + public bool UngrabAccelerator(BusName sender, uint action) + { + return ungrab_accelerator (action); + } + +/* #if HAVE_GSD_332 public uint GrabAccelerator(BusName sender, string accelerator, uint flags, Meta.KeyBindingFlags grab_flags) { @@ -302,6 +386,7 @@ public class ShellShim : GLib.Object return t; } #endif + public bool ungrab_accelerator(BusName sender, uint action) { if (display.ungrab_accelerator(action)) { @@ -310,6 +395,7 @@ public class ShellShim : GLib.Object } return false; } + */ /** * Show the OSD when requested. From 59febfcc48d82ff40c2e0fc9bcf909c3380a5351 Mon Sep 17 00:00:00 2001 From: David Mohammed <fossfreedom@ubuntu.com> Date: Thu, 28 Nov 2019 20:58:21 +0000 Subject: [PATCH 2/3] Cleanup code, remove unneeded watches --- src/wm/shim.vala | 117 +---------------------------------------------- 1 file changed, 2 insertions(+), 115 deletions(-) diff --git a/src/wm/shim.vala b/src/wm/shim.vala index 44d6fc60..432458ca 100644 --- a/src/wm/shim.vala +++ b/src/wm/shim.vala @@ -139,7 +139,6 @@ public class ShellShim : GLib.Object { HashTable<string, uint?> grabs; - HashTable<string,uint> watches; unowned Meta.Display? display; private SessionHandler? handler = null; @@ -151,7 +150,6 @@ public class ShellShim : GLib.Object public ShellShim(Budgie.BudgieWM? wm) { grabs = new HashTable<string, uint?> (str_hash, str_equal); - watches = new HashTable<string,uint>(str_hash, str_equal); display = wm.get_display(); display.accelerator_activated.connect(on_accelerator_activated); @@ -193,30 +191,12 @@ public class ShellShim : GLib.Object osd_proxy = null; } -/* -#if HAVE_MUTTER_5 - private void on_accelerator_activated(uint action, Clutter.InputDevice dev, uint device_id) -#else - private void on_accelerator_activated(uint action, uint device_id) -#endif - { - HashTable<string,Variant> params = new HashTable<string,Variant>(str_hash, str_equal); - - params.insert("device-id", device_id); - params.insert("timestamp", new Variant.uint32(0)); - params.insert("action-mode", new Variant.uint32(0)); - - this.accelerator_activated(action, params); - } -*/ - #if HAVE_MUTTER_5 private void on_accelerator_activated(uint action, Clutter.InputDevice dev, uint device_id) #else private void on_accelerator_activated(uint action, uint device_id, timestamp) #endif { - print("on accelerator activated"); foreach (string accelerator in grabs.get_keys ()) { if (grabs[accelerator] == action) { var params = new GLib.HashTable<string, Variant> (null, null); @@ -231,32 +211,8 @@ public class ShellShim : GLib.Object } } - /*void on_disappeared(DBusConnection conn, string name) - { - unowned string val; - unowned uint key; - - if (!watches.contains(name)) { - return; - } - - uint id = watches.lookup(name); - Bus.unwatch_name(id); - - var iter = HashTableIter<uint,string>(grabs); - while (iter.next(out key, out val)) { - if (val != name) { - continue; - } - display.ungrab_accelerator(key); - iter.remove(); - } - } - */ - public uint grab_accelerator (string accelerator, Meta.KeyBindingFlags flags) throws DBusError, IOError { - print("grab accelertor"); uint? action = grabs[accelerator]; if (action == null) { @@ -271,7 +227,6 @@ public class ShellShim : GLib.Object public uint[] grab_accelerators (GsdAccel[] accelerators) throws DBusError, IOError { - print("grab accelerators"); uint[] actions = {}; foreach (unowned GsdAccel? accelerator in accelerators) { @@ -283,10 +238,9 @@ public class ShellShim : GLib.Object public bool ungrab_accelerator (uint action) throws DBusError, IOError { - print("ungrab accelerator"); bool ret = false; - - foreach (unowned string accelerator in grabs.get_keys ()) { + var keys = grabs.get_keys(); + foreach (unowned string accelerator in keys) { if (grabs[accelerator] == action) { ret = display.ungrab_accelerator (action); grabs.remove (accelerator); @@ -297,32 +251,6 @@ public class ShellShim : GLib.Object return ret; } -/* -#if HAVE_GSD_332 - private uint _grab(string sender, string seq, uint flag, Meta.KeyBindingFlags grab_flags) - { - var ret = display.grab_accelerator(seq, grab_flags); -#else - private uint _grab(string sender, string seq, uint flag) - { - var ret = display.grab_accelerator(seq); -#endif - - if (ret == Meta.KeyBindingAction.NONE) { - return ret; - } - - grabs.insert(ret, sender); - - if (!watches.contains(sender)) { - var id = Bus.watch_name(BusType.SESSION, sender, BusNameWatcherFlags.NONE, - null, on_disappeared); - watches.insert(sender, id); - } - - return ret; - } -*/ void on_bus_acquired(DBusConnection conn) { try { @@ -356,47 +284,6 @@ public class ShellShim : GLib.Object return ungrab_accelerator (action); } -/* -#if HAVE_GSD_332 - public uint GrabAccelerator(BusName sender, string accelerator, uint flags, Meta.KeyBindingFlags grab_flags) - { - return _grab(sender, accelerator, flags, grab_flags); - } - - public uint[] GrabAccelerators(BusName sender, GsdAccel[] accelerators) - { - uint[] t = { }; - foreach (var a in accelerators) { - t += _grab(sender, a.accelerator, a.flags, a.grab_flags); - } - return t; - } -#else - public uint GrabAccelerator(BusName sender, string accelerator, uint flags) - { - return _grab(sender, accelerator, flags); - } - - public uint[] GrabAccelerators(BusName sender, GsdAccel[] accelerators) - { - uint[] t = { }; - foreach (var a in accelerators) { - t += _grab(sender, a.accelerator, a.flags); - } - return t; - } -#endif - - public bool ungrab_accelerator(BusName sender, uint action) - { - if (display.ungrab_accelerator(action)) { - grabs.remove(action); - return true; - } - return false; - } - */ - /** * Show the OSD when requested. */ From b812847a898193d475ab68738d78bfb75b6a3692 Mon Sep 17 00:00:00 2001 From: David Mohammed <fossfreedom@ubuntu.com> Date: Mon, 30 Dec 2019 15:32:10 +0000 Subject: [PATCH 3/3] Implement UngrabAccelerators This is a specific mutter-5 dbus call that needs to be implemented to ensure shortcuts can be set/unset and reset again Additionally add missing mutter-5 parameters for calling this meta accelerator_activated signal --- src/wm/shim.vala | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/wm/shim.vala b/src/wm/shim.vala index 432458ca..d465d469 100644 --- a/src/wm/shim.vala +++ b/src/wm/shim.vala @@ -192,7 +192,7 @@ public class ShellShim : GLib.Object } #if HAVE_MUTTER_5 - private void on_accelerator_activated(uint action, Clutter.InputDevice dev, uint device_id) + private void on_accelerator_activated(uint action, Clutter.InputDevice dev, uint timestamp) #else private void on_accelerator_activated(uint action, uint device_id, timestamp) #endif @@ -200,12 +200,14 @@ public class ShellShim : GLib.Object foreach (string accelerator in grabs.get_keys ()) { if (grabs[accelerator] == action) { var params = new GLib.HashTable<string, Variant> (null, null); - params.set ("device-id", new Variant.uint32 (device_id)); -#if HAV_MUTTER_5 - params.set ("timestamp", new Variant.uint32 (timestamp)); +#if HAVE_MUTTER_5 + params.set ("device-id", new Variant.uint32 (dev.id)); + params.set ("action-mode", new Variant.uint32 (action)); + params.set ("device-mode", new Variant.string (dev.get_device_node())); #else - params.set ("timestamp", new Variant.uint32 (0)); + params.set ("device-id", new Variant.uint32 (device_id)); #endif + params.set ("timestamp", new Variant.uint32 (timestamp)); this.accelerator_activated (action, params); } } @@ -284,6 +286,16 @@ public class ShellShim : GLib.Object return ungrab_accelerator (action); } +#if HAVE_MUTTER_5 + public bool UngrabAccelerators(BusName sender, uint[] actions) + { + foreach (uint action in actions) { + ungrab_accelerator (action); + } + return true; + } +#endif + /** * Show the OSD when requested. */
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor