[英]How to properly configure windows using xcb ConfigureWindow in python
I am working on an X11 window manager, writing it in python. 我正在使用X11窗口管理器,用python编写。 I am encountering a problem, where I get, and handle ConfigureWindowEvents.
我在哪里遇到问题并处理ConfigureWindowEvents。 But, even then, when a window is mapped, it shows up as a two pixel high, one pixel wide window.
但是,即使那样,在映射窗口时,它仍显示为两像素高,一像素宽的窗口。 I have put together the following example code so that others may test it, and tell me if I am doing this wrong.
我整理了以下示例代码,以便其他人可以对其进行测试,并告诉我是否做错了。 I based my ConfigureEvent handling code on qtile's
我基于qtile的ConfigureEvent处理代码
import xcb
import xcb.xproto as xproto
from xcb.xproto import ConfigWindow as cw
conn = xcb.connect()
root = conn.get_setup().roots[0].root
eventmask = [xproto.EventMask.SubstructureRedirect]
err =conn.core.ChangeWindowAttributesChecked(root, xproto.CW.EventMask, eventmask)
check = err.check()
if check:
print check
while True:
e = conn.wait_for_event()
if isinstance(e, xproto.MapRequestEvent):
conn.core.MapWindow(e.window)
if isinstance(e, xproto.ConfigureRequestEvent):
y = x = w = h = bw = 0
if e.value_mask & cw.X:
x = e.x
print "x:", x
if e.value_mask & cw.Y:
y = e.y
print "y:", y
if e.value_mask & cw.Height:
h = e.height
print "h:", h
if e.value_mask & cw.Width:
w = e.width
print 'w:', w
if e.value_mask & cw.BorderWidth:
bw = e.border_width
print 'bw:', bw
mask = cw.X | cw.Y | cw.Width | cw.Height | cw.BorderWidth
values = {cw.X: x, cw.Y: y, cw.Width: w, cw.Height: h, cw.BorderWidth: bw}
err = conn.core.ConfigureWindowChecked(e.window, mask, values)
err.check()
conn.flush()
print e
I'm using the Checked functions in hope of catching errors 我正在使用Checked函数,希望能发现错误
I got my answer from the xcb mailing list, it was quite fast: 我从xcb邮件列表中得到了答案,速度非常快:
values = {cw.X: x, cw.Y: y, cw.Width: w, cw.Height: h, cw.BorderWidth: bw}
should be 应该
values = [x, y, w, h, bw]
Then all was right with the world again. 然后,世界再次一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.