1

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

7
  • It works for me - I tried to launch Xnest + this script + xeyes and xeyes window is mapped Aug 17, 2012 at 0:05
  • @AndreySidorov Whether it is launched in Xephyr, or in a full blown X session, I still get the tiny window. I get the ConfigureRequestEvents before the window is mapped, is that what's supposed to happen? Aug 17, 2012 at 1:36
  • this probably reflects client's sequence: create window, configure, map. Since you are intercepting map and configure with SubstructureRedirect you are receiving these *RequestEvent events. Aug 17, 2012 at 1:53
  • I have implemented very simple reparenting window manager in JavaScript - maybe it could help you github.com/sidorares/node-x11/blob/master/examples/… Aug 17, 2012 at 1:55
  • Well, it might, but it uses libX, and I'm trying to use xcb. Frustrating this is. Interesting to see what can be done with javascript though. Aug 17, 2012 at 1:59

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.