wavexx / screenkey

A screencast tool to display your keys inspired by Screenflick
https://www.thregr.org/~wavexx/software/screenkey/
GNU General Public License v3.0
757 stars 66 forks source link

internal: target window ID for the source event is 0 #48

Closed wavexx closed 5 years ago

wavexx commented 7 years ago

xlib.xKeyButtonPointer.event/child are 0 when read from the event stream. Bad decoding/packing, or missing info from XRecord?

See https://github.com/wavexx/screenkey/issues/44#issuecomment-313881370 and following comments.

Foxboron commented 7 years ago

Looked over the Window values for the Focus changes and they all report 0

Foxboron commented 7 years ago

Also tried implementing XPropertyChange to watch for _NET_ACTIVE_WINDOW. But doesn't seem like it gets used.

+++ b/Screenkey/xlib.py
@@ -28,6 +28,16 @@ class Display(Structure):
 class Visual(Structure):
     pass

+class XPropertyEvent(Structure):
+    _fields_ = [('type', c_int),
+                ('serial', c_ulong),
+                ('send_event', Bool),
+                ('display', POINTER(Display)),
+                ('window', Window),
+                ('Atom', Atom),
+                ('time', Time),
+                ('state', c_uint)]
+
 class XKeyEvent(Structure):
     _fields_ = [('type', c_int),
                 ('serial', c_ulong),
@@ -98,6 +108,7 @@ class XEvent(Union):
                 ('xbutton', XButtonEvent),
                 ('xmotion', XMotionEvent),
                 ('xclient', XClientMessageEvent),
+                ('xproperty', XPropertyEvent),
                 ('pad', c_long * 24)]