如何使用xcb python为X11窗口管理器在根窗口上设置SubstructureRedirect事件掩码

时间:2012-08-13 15:56:19

标签: python x11 xcb

我有这个代码没有给出任何异常,但我似乎没有接收像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测试这个。

我做错了吗?如果是这样,我该如何解决?

1 个答案:

答案 0 :(得分: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