1

我有这段代码没有给出任何异常,但我似乎没有收到像 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 中对此进行测试。

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

4

1 回答 1

3

编辑:问题在于参数数量不正确: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
于 2012-08-14T23:48:33.257 回答