Open qoobar opened 10 years ago
This is interesting, I will do some testing on it shortly to try to resolve it.
I had the same bug while capturing under linux/x11. I was able to solve it with the following sequence of calls:
c = SomeClassThatExtendsPyMouseEvent()
c.start()
# [....]
from Xlib.display import Display
display = Display()
display.record_disable_context(c.ctx)
display.close()
c.stop()
Maybe related to #55? So probably we're not cleaning up the listener properly. Sadly, documentation is a little sparse.
not quite sure they are related, have you tried XInitThreads yet? a few years ago i needed to call that to prevent random crashes in a multi-threaded opengl program. As for the display thing, why are there two instances of display created in x11.py's PyMouseEvent?
import ctypes
from ctypes.util import find_library
try:
libpath = find_library("X11")
from ctypes import *
x11 = cdll.LoadLibrary(libpath)
x11.XInitThreads()
print "XInitThreads() called"
except BaseException, e:
print "Error occured while trying to call XInitThreads:\n" , e
This is what I used back then, but I guess python-xlib offers something nicer now
Not tried.
There are two displays because... I can't remember, but it did not work with one. I think you can't listen and send to the same display or something.
You seem to know a lot more about it than I do, or did. The Mac code is the only part where I kinda knew what I was doing.
I'll continue to look into it, if I come up with something reliable I'll come back to you... Also, X11 never stops baffling me either, it's a huge mess...
PyMouseEvent
stop()
method works only when called inside theclick()
handler. The listener is not stopped whenstop()
method is called from outside (e.g. by another module). In such situation it still keeps listening for all mouse events - thestop()
methods doesn't seem to work. Surprisingly it's not the case with the PyKeyboardEvent - thestop()
methods works fine there.