GNOME Bugzilla – Bug 720563
MetaIdleMonitor: Don't make assumptions about input device ids
Last modified: 2014-12-29 05:37:17 UTC
Store virtual 'core' monitor separately and don't associate it with some input device. Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Created attachment 264331 [details] [review] MetaIdleMonitor: Don't make assumptions about input device ids
Review of attachment 264331 [details] [review]: Input device ids are part of the XInput 2 protocol. We can make assumptions until the protocol is broken in the next major revision of the extensions.
This change is related to https://bugzilla.gnome.org/show_bug.cgi?id=720566 which doesn't adhere to XInput 2.
What's wrong with using the integer part of the sysfs basename (plus some offset to account for virtual devices) as the device ID? It's a small integer, and allows us to keep the assumptions and keep the code small and fast (and that's a very hot path - invoked for every input event)
The patch in bug 720566 takes multi seat setups into consideration, thus it does not have "core devices" (right now core devices are just mapped to the virtual devices of the first seat created). Because of this, the I just changed the ids to be global_id_next++ for every new device for simplicity. There is no particular reason for not keep having it generated from the sysfs basename I guess, I just couldn't see the need. I don't think it's a performance problem though, as the hash table wont grow very large and, I assume, look up is O(1).
We should probably rewrite this code with a hash table at some point given how many bugs we found in the custom sparse array, but this patch doesn't apply anymore.