Question

I am working on an X11 window manager, writing it in python. I am encountering a problem, where I get, and handle 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

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

Was it helpful?

Solution

I got my answer from the xcb mailing list, it was quite fast:

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top