27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
"""X11 test only: inject 32 alternating left/right clicks into the bench window."""
|
|
import ctypes
|
|
|
|
x11 = ctypes.CDLL("libX11.so.6")
|
|
xtest = ctypes.CDLL("libXtst.so.6")
|
|
x11.XOpenDisplay.argtypes = [ctypes.c_char_p]
|
|
x11.XOpenDisplay.restype = ctypes.c_void_p
|
|
x11.XFlush.argtypes = [ctypes.c_void_p]
|
|
x11.XCloseDisplay.argtypes = [ctypes.c_void_p]
|
|
xtest.XTestFakeMotionEvent.argtypes = [ctypes.c_void_p, ctypes.c_int,
|
|
ctypes.c_int, ctypes.c_int, ctypes.c_ulong]
|
|
xtest.XTestFakeButtonEvent.argtypes = [ctypes.c_void_p, ctypes.c_uint,
|
|
ctypes.c_int, ctypes.c_ulong]
|
|
display = x11.XOpenDisplay(None)
|
|
if not display:
|
|
raise RuntimeError("X11 unavailable")
|
|
try:
|
|
for index in range(32):
|
|
x = 640 if index % 2 == 0 else 1920
|
|
assert xtest.XTestFakeMotionEvent(display, -1, x, 600, 0)
|
|
assert xtest.XTestFakeButtonEvent(display, 1, 1, 0)
|
|
assert xtest.XTestFakeButtonEvent(display, 1, 0, 0)
|
|
x11.XFlush(display)
|
|
finally:
|
|
x11.XCloseDisplay(display)
|
|
print("Injected 32 clicks, expected L,R alternating; final pointer on R")
|