Permalink
Browse files

Merge pull request #27 from vvzh/linux-64bit-segfault-fix

Linux 64 bit segfault fix
  • Loading branch information...
boppreh committed Sep 2, 2018
2 parents c6a316f + 7f91115 commit f59fdc8128a8ee912dfdcc2144faf55bb937c51b
Showing with 5 additions and 4 deletions.
  1. +5 −4 mouse/_nixmouse.py
@@ -7,7 +7,7 @@
import ctypes
import ctypes.util
from ctypes import c_uint32, c_uint, c_int, byref
from ctypes import c_uint32, c_uint, c_int, c_void_p, byref
display = None
window = None
@@ -19,14 +19,15 @@ def build_display():
# Required because we will have multiple threads calling x11,
# such as the listener thread and then main using "move_to".
x11.XInitThreads()
display = x11.XOpenDisplay(None)
# Known to cause segfault in Fedora 23 64bits, no known workarounds.
# Explicitly set XOpenDisplay.restype to avoid segfault on 64 bit OS.
# http://stackoverflow.com/questions/35137007/get-mouse-position-on-linux-pure-python
x11.XOpenDisplay.restype = c_void_p
display = c_void_p(x11.XOpenDisplay(0))
window = x11.XDefaultRootWindow(display)
def get_position():
build_display()
root_id, child_id = c_uint32(), c_uint32()
root_id, child_id = c_void_p(), c_void_p()
root_x, root_y, win_x, win_y = c_int(), c_int(), c_int(), c_int()
mask = c_uint()
ret = x11.XQueryPointer(display, c_uint32(window), byref(root_id), byref(child_id),

0 comments on commit f59fdc8

Please sign in to comment.