[英]How to properly configure windows using xcb ConfigureWindow in python
我正在使用X11窗口管理器,用python編寫。 我在哪里遇到問題並處理ConfigureWindowEvents。 但是,即使那樣,在映射窗口時,它仍顯示為兩像素高,一像素寬的窗口。 我整理了以下示例代碼,以便其他人可以對其進行測試,並告訴我是否做錯了。 我基於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
我正在使用Checked函數,希望能發現錯誤
我從xcb郵件列表中得到了答案,速度非常快:
values = {cw.X: x, cw.Y: y, cw.Width: w, cw.Height: h, cw.BorderWidth: bw}
應該
values = [x, y, w, h, bw]
然后,世界再次一切正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.