PyUserInput icon indicating copy to clipboard operation
PyUserInput copied to clipboard

PyMouseEvent stop method bug

Open qoobar opened this issue 10 years ago • 7 comments

PyMouseEvent stop() method works only when called inside the click() handler. The listener is not stopped when stop() method is called from outside (e.g. by another module). In such situation it still keeps listening for all mouse events - the stop() methods doesn't seem to work. Surprisingly it's not the case with the PyKeyboardEvent - the stop() methods works fine there.

qoobar avatar Jul 03 '14 21:07 qoobar

This is interesting, I will do some testing on it shortly to try to resolve it.

SavinaRoja avatar Aug 18 '14 14:08 SavinaRoja

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()

Ilmarinen100 avatar Nov 23 '14 17:11 Ilmarinen100

Maybe related to #55? So probably we're not cleaning up the listener properly. Sadly, documentation is a little sparse.

pepijndevos avatar Nov 23 '14 21:11 pepijndevos

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?

Ilmarinen100 avatar Nov 23 '14 22:11 Ilmarinen100

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

Ilmarinen100 avatar Nov 23 '14 22:11 Ilmarinen100

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.

pepijndevos avatar Nov 23 '14 22:11 pepijndevos

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...

Ilmarinen100 avatar Nov 23 '14 22:11 Ilmarinen100