Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
xinput: implemented XIChangeHierarchy #57
First of all, thanks very much for this library and all the work you have invested in this project!
I'm getting more into xinput at the moment and I saw that the implementation of this extension isn't complete in python-xlib. I saw the chance to start contributing and so I implemented xlib's XIChangeHierarchy function in xinput.py ;)
dpy.xinput_add_master(name, send_core=True, enable=True) dpy.xinput_remove_master(deviceid, return_mode=2, return_pointer=0, return_keyboard=0) dpy.xinput_attach_slave(deviceid, new_master) dpy.xinput_detach_slave(deviceid)
It's also possible to send multiple changes in a single request:
from Xlib.ext.xinput import ChangeHierarchyContext with ChangeHierarchyContext(dpy) as c: c.add_master(...) c.remove_master(...) c.attach_slave(...) c.detach_slave(...)
You can use the
Unfortunately, I had to modify
Ok, that's it. What do you think?
Current coverage is 80.96% (diff: 59.18%)
@@ master #57 diff @@ ========================================== Files 39 39 Lines 4396 4445 +49 Methods 0 0 Messages 0 0 Branches 0 0 ========================================== + Hits 3570 3599 +29 - Misses 826 846 +20 Partials 0 0
I honestly would prefer to wait for my changes for generating the extensions code, to avoid non-backward compatible API changes.
Regarding this particular implementation, I'm against changing the protocol for a bug in a version of the X11 server: the code works fine with
Ok, I just tried the sample again and it also worked on my machine when using "test". I also tried earlier versions of the code and found out that the crash was in fact caused by something else that I fixed in a later version. I'm sorry for the confusion. I will roll back the changes I did in rq.py in the next commit.
@benoit-pierre what do you mean by "generating the extensions code"? I'm just curious ;)
@drzraf: script here: https://gist.github.com/de5beb2cfb1a60abe78f83619796edea.
I have not updated it in some time, so it won't work with the latest version of xcb-proto, you'll need to use version 1.11:
$ git clone git://anongit.freedesktop.org/git/xcb/proto $ git -C proto checkout 1.11 $ PYTHONPATH="$PWD/proto" python3 ./gen_xlib.py proto/src/xinput.xml
This will output the generated code on stdout. Note that this might generate some code that is not compatible with the current python-xlib master: I have an (old) branch with a lot of changes to support things like unions, switches, variable length fields with complex length calculation, etc...