You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support X11 through the XInputExtension version 2.2 interface.
Some attempts have been made to introduce this into octotablet - as of now, I have some rudimentary tablet device capabilities listing - however I have repeatedly run into a fundamental issue: xlib and xcb are extraordinarily stateful. Snooping on and snatching events from a given windowing interface (i.e. winit, sdl2) through their Display pointer is a deeply fragile process due to this shared and unsynchronized state. Often times, winit will unpredictably panic (understandably!) due to the tiniest meddling.
The two solutions I have thought of are:
Snoop events through XCheckMaskEvent. This requires octotablet to have priority control over the shared state than the windowing API that actually owns it, and could break some things. (E.g., winit would no longer send DeviceEvents.) It also ends up being super fragile on account of that shared state, like event masks and error messages, which would need to be repeatedly context-switched by octotablet unbeknownst to the window owner. If the window owner is multi-threaded (though I can't think of any that are), this is a total nonstarter.
Have octotablet manage it's own connection to the same server, snooping on the user window's (or possibly the root window's) events - similar to what the Wayland integration does. As far as I know, this is allowable under X. This also allows octotablet to be asynchronous in relation to the window and agnostic across Xcb or Xlib client implementations. Trouble here is I do not know of any way to reliably duplicate and Xlib or Xcb server connection in this way - just assuming the display comes from the default environment is a 99% solution but still not technically correct.
The text was updated successfully, but these errors were encountered:
After some more tinkering, a two-client system works great, and basic stylus events are printed out in my tests. Xorg does indeed allow several clients to listen to events on the same window, but contrary to the cursed display-sharing technique attempted before, each client gets it's own event queue and no thrashing of global state occurs. The problem of correctly duplicating a connection to the same server as another display pointer remains, but I suppose that will just have to remain a limitation. As far as I know, there does not exist a windowing abstraction API that allows anything other than the default display anyway, so I suppose it should be fine!
Following more experiments to ensure every part of the API that I will need to touch is working as expected under this less-than-normal circumstance, I will begin to work on a PR :3
An unfortunate roadblock was hit a few hundred lines into the implementation, in that Xlib uses global variables for the error handling state and thus it is not possible to soundly maintain two independent clients in the same process unless they coordinate in some way. I probably shoulda spotted this sooner before pouring a good number of hours into it!
I suppose a rewrite in x11rb is needed as the usual alternative, xcb, does not support the xinput2 extension (or at least, I cannot figure how to configure it to generate the necessary glue code).
Support X11 through the
XInputExtension
version 2.2 interface.Some attempts have been made to introduce this into
octotablet
- as of now, I have some rudimentary tablet device capabilities listing - however I have repeatedly run into a fundamental issue:xlib
andxcb
are extraordinarily stateful. Snooping on and snatching events from a given windowing interface (i.e. winit, sdl2) through theirDisplay
pointer is a deeply fragile process due to this shared and unsynchronized state. Often times,winit
will unpredictably panic (understandably!) due to the tiniest meddling.The two solutions I have thought of are:
Snoop events through
XCheckMaskEvent
. This requires octotablet to have priority control over the shared state than the windowing API that actually owns it, and could break some things. (E.g., winit would no longer sendDeviceEvent
s.) It also ends up being super fragile on account of that shared state, like event masks and error messages, which would need to be repeatedly context-switched by octotablet unbeknownst to the window owner. If the window owner is multi-threaded (though I can't think of any that are), this is a total nonstarter.Have octotablet manage it's own connection to the same server, snooping on the user window's (or possibly the root window's) events - similar to what the Wayland integration does. As far as I know, this is allowable under X. This also allows octotablet to be asynchronous in relation to the window and agnostic across Xcb or Xlib client implementations. Trouble here is I do not know of any way to reliably duplicate and Xlib or Xcb server connection in this way - just assuming the display comes from the default environment is a 99% solution but still not technically correct.
The text was updated successfully, but these errors were encountered: