jezek / xgb

The X Go Binding is a low-level API to communicate with the X server. It is modeled on XCB and supports many X extensions.
Other
128 stars 13 forks source link

xcb_warp_pointer #22

Open 0sm1les opened 2 months ago

0sm1les commented 2 months ago

is it possible to create a new event for xcb_warp_pointer, i want to be able to move the mouse cursor, also is it possible to provide some examples on creating new key press events. thanks in advance.

jezek commented 2 months ago
  1. Moving the mouse cursor with xcb_warp_pointer: This functionality is implemented as a WarpPointer in the XGB library here: https://github.com/jezek/xgb/blob/master/xproto/xproto.go#L14874C6-L14874C17

    I don't really know if it works. In the past, I've used the XTEST extension for simulating mouse movements. You can see how I used it in my xgo project (I did as exercise to learn more about xgb): https://github.com/jezek/xgo/blob/master/pointer.go#L117

    But it won't work under wayland + xwayland.

  2. Creating new key press events: I've done it using the XTEST extension too. You can see an example of how I handled this in xgo for key press simulations here: https://github.com/jezek/xgo/blob/master/keyboard.go#L141

    Creating key press events is a bit more tricky, if you need to simulate keys that aren't currently mapped. I've tried to solve it in the file linked above, but it wasn't 100% reliable, if I recall correctly.

    Again, this won't work under wayland + xwayland.


If you get something working and feel free to report and maybe add some examples yourself. I'd be happy to merge them.