GNOME Bugzilla – Bug 758238
[evdev] Add evdev-specific API to get event codes from ClutterEvents
Last modified: 2015-11-18 12:09:22 UTC
The places in mutter where we transform from ClutterEvent info to linux/input.h event codes is somewhat finicky atm :(, and will previsibly get worse when we add tablet/buttonset support, as the BTN_ keycode ranges to be expected vary more wildly there. It would be great to pass event codes along in input events. I'm attaching some patches to do that.
Created attachment 315768 [details] [review] device-manager: Add private interface to manipulate platform event data This normally belonged to the ClutterBackend, however there's device managers (eg. evdev) that are somewhat detached from the backend, so need to bridge this somehow. This allows device managers to implement these bits that were usually responsibility of the ClutterBackend.
Created attachment 315769 [details] [review] backend: Bridge platform-dependent event data creation to device managers Device managers can now implement the ClutterDeviceManagerPlatform interface that allows them to set their own data to events, make the backend call those implementations on the backends that don't provide their own.
Created attachment 315770 [details] [review] evdev: Implement the ClutterDeviceManagerPlatform interface This will allow the ClutterDeviceManagerEvdev to define evdev-specific event data.
Created attachment 315771 [details] [review] evdev: Allow to retrieve the input.h event code from ClutterEvents This is now stored as platform data in the ClutterEvent, so can be retrieved with the clutter_evdev_event_get_event_code() call that's been added to the evdev backend.
Created attachment 315772 [details] [review] evdev: Set event code on button/key events This will allow users to know the event code without strange calculations on event->key.hardware_keycode or event->button.button.
Review of attachment 315769 [details] [review]: ::: clutter/clutter-backend.c @@ +1008,3 @@ + else if (CLUTTER_IS_DEVICE_MANAGER_PLATFORM (backend->device_manager)) + { + iface = CLUTTER_DEVICE_MANAGER_PLATFORM_GET_IFACE (backend->device_manager); I'd actually flip the priority — i.e. use the ClutterBackend's mechanism as the fallback.
Review of attachment 315768 [details] [review]: ::: clutter/clutter-device-manager-private.h @@ +147,3 @@ +/* Platform-dependent interface */ +typedef struct _ClutterDeviceManagerPlatform ClutterDeviceManagerPlatform; Not really sold on the name, to be honest. :-/ We have ClutterEventTranslator, maybe we should have something under that same naming scheme — like ClutterEventExtender.
Review of attachment 315771 [details] [review]: Okay.
Review of attachment 315772 [details] [review]: Okay.
Review of attachment 315770 [details] [review]: Okay.
Would probably be nice to port some other DeviceManager subclasses to the new interface, instead of using the Backend.
(In reply to Emmanuele Bassi (:ebassi) from comment #7) > Review of attachment 315768 [details] [review] [review]: > > ::: clutter/clutter-device-manager-private.h > @@ +147,3 @@ > > +/* Platform-dependent interface */ > +typedef struct _ClutterDeviceManagerPlatform ClutterDeviceManagerPlatform; > > Not really sold on the name, to be honest. :-/ Yeah, me neither... Couldn't think of a better name though > > We have ClutterEventTranslator, maybe we should have something under that > same naming scheme — like ClutterEventExtender. Right :), I like that more than all the names I came up with, updating now the patches.
Created attachment 315778 [details] [review] device-manager: Add private interface to manipulate platform event data This normally belonged to the ClutterBackend, however there's device managers (eg. evdev) that are somewhat detached from the backend, so need to bridge this somehow. This allows device managers to implement these bits that were usually responsibility of the ClutterBackend.
Created attachment 315779 [details] [review] backend: Bridge platform-dependent event data creation to device managers Device managers can now implement the ClutterEventExtender interface that allows them to set their own data to events, make the backend call those implementations if the device manager implements the interface.
Created attachment 315780 [details] [review] evdev: Implement the ClutterEventExtender interface This will allow the ClutterDeviceManagerEvdev to define evdev-specific event data.
Created attachment 315781 [details] [review] x11: Implement ClutterEventExtender This lifts the responsibility off its ClutterBackend.
Created attachment 315782 [details] [review] gdk: Implement ClutterEventExtender This lifts the responsibility off its ClutterBackend.
Comment on attachment 315780 [details] [review] evdev: Implement the ClutterEventExtender interface This one just went through the ClutterEventExtender rename, setting tentatively as a-c-n as I mark the old one obsolete
Review of attachment 315778 [details] [review]: Okay.
Review of attachment 315779 [details] [review]: Okay.
Review of attachment 315780 [details] [review]: Okay.
Review of attachment 315781 [details] [review]: Okay.
Review of attachment 315782 [details] [review]: Okay.
Thanks! This will help me get rid of some finicky code in my tablet branches too :). Pushed now everything: Attachment 315771 [details] pushed as f1ad702 - evdev: Allow to retrieve the input.h event code from ClutterEvents Attachment 315772 [details] pushed as 8aeea7f - evdev: Set event code on button/key events Attachment 315778 [details] pushed as 5ea70bd - device-manager: Add private interface to manipulate platform event data Attachment 315779 [details] pushed as 4115f21 - backend: Bridge platform-dependent event data creation to device managers Attachment 315780 [details] pushed as dfc749e - evdev: Implement the ClutterEventExtender interface Attachment 315781 [details] pushed as 9215852 - x11: Implement ClutterEventExtender Attachment 315782 [details] pushed as a9b0715 - gdk: Implement ClutterEventExtender