gpt4 book ai didi

linux - 如何在 python 中使用 xcb ConfigureWindow 正确配置窗口

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:07:01 27 4
gpt4 key购买 nike

我正在开发一个 X11 窗口管理器,它是用 Python 编写的。我遇到了一个问题,我在哪里处理 ConfigureWindowEvents。但是,即便如此,当一个窗口被映射时,它仍显示为一个两像素高、一像素宽的窗口。我整理了以下示例代码,以便其他人可以对其进行测试,并告诉我我是否做错了。我的 ConfigureEvent 处理代码基于 qtile 的

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]

然后世界又恢复正常了。

关于linux - 如何在 python 中使用 xcb ConfigureWindow 正确配置窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11979888/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com