我的这段代码没有给出任何异常,但是我似乎没有收到诸如MapRequests或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


我正在Xephyr中对此进行测试。

难道我做错了什么?如果是这样,我该如何解决?

最佳答案

编辑:
  问题在于参数数量不正确:xproto.CW.EventMask表示您有一个值,并且正在传递两个作为[xproto.EventMask.SubstructureRedirect, xproto.EventMask.SubstructureNotify]的值,应为[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

关于python - 如何在X11窗口管理器中使用xcb python在根窗口上设置SubstructureRedirect事件掩码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11937935/

10-11 04:10