How to set SubstructureRedirect event mask on the root window using xcb python for a X11 window manager

StackOverflow https://stackoverflow.com/questions/11937935

  •  26-06-2021
  •  | 
  •  

Question

I have this code that does not give any exception, but I do not seem to be receiving events like MapRequests, or ConfigureNotifys:

import xcb
import xcb.xproto as xproto
conn = xcb.connect()
root = conn.get_setup().roots[0].root
eventmask = [xproto.EventMask.SubstructureRedirect, xproto.EventMask.SubstructureNotify]
conn.core.ChangeWindowAttributesChecked(self.root, xproto.CW.EventMask, eventmask)
while True:
    e = conn.wait_for_event()
    print e

I am testing this in Xephyr.

Am I doing something wrong? And if so, how do I fix it?

Was it helpful?

Solution

edit: the problem is in incorrect number of parameters: xproto.CW.EventMask indicates that you have one value and you are passing two as [xproto.EventMask.SubstructureRedirect, xproto.EventMask.SubstructureNotify] which should be [xproto.EventMask.SubstructureRedirect|xproto.EventMask.SubstructureNotify]

import xcb
import xcb.xproto as xproto
conn = xcb.connect()
root = conn.get_setup().roots[0].root
conn.core.ChangeWindowAttributesChecked(self.root, xproto.CW.EventMask, [xproto.EventMask.SubstructureRedirect|xproto.EventMask.SubstructureNotify])
while True:
    e = conn.wait_for_event()
    print e
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top