GNOME Bugzilla – Bug 735388
xi2 device manager gets a "0" client pointer if queried very early in app lifetime
Last modified: 2014-08-25 15:08:48 UTC
(Note: Still wondering if this is actually an xserver bug) Normally the device manager is created implicitly after some messaging with the server, so the XIGetClientPointer() call done on xi2 device manager construction successfully returns the client pointer (most normally the VCP). However, if the device manager is created very early during app lifetime, and queried for the client pointer, the call happens at a time when the server still hasn't allocated a client pointer for this client, so 0 is returned as the client pointer (which is actually not a device id), as a result that first attempt to get the client pointer returns NULL. This is visible with current mutter --wayland master, the client pointer is queried/stored early, and several misbehaviors/warnings can be seen in result. I'm attaching a patch that does XSync before that attempt to get the client pointer, so it is ensured to be non-NULL on all situations.
Created attachment 284406 [details] [review] xi2: XSync before getting the client pointer on construction If the device manager is created and queried for the client pointer at a very early stage in application lifetime, the device_id returned would be 0 as the server hasn't apparently decided yet about the client pointer. For these situations, doing XSync prior to fetching the client pointer gets the server to device about the client pointer before we query it.
Review of attachment 284406 [details] [review]: sounds reasonable.
Attachment 284406 [details] pushed as 591d31c - xi2: XSync before getting the client pointer on construction