2

For my sins (and for fun the learning experience) I am writing a window manager (I know, I know).

I'm using python and XCB (python-xpyb).

So far I have figured out that I need to use a SubStructureRedirect mask on the root window(s), and I am successfully being passed events related to applications' top-level windows. I'm testing this by launching xterm.

I get a ConfigureRequestEvent, followed by a pause, followed by another ConfigureRequestEvent, and then a MapRequestEvent.

When I get the MapRequestEvent I call connection.core.MapWindowChecked(e.window), which works, but maps a window that is only a pixel or two wide/tall.

My question, then, is what should I do with the ConfigureRequestEvent to make the window the correct size (assuming thats what I'm missing)?

More accurately, what exactly do i call? MapWindowChecked was an obvious choice, but I can't seem to find how to actually configure the width/height. I'm guessing it is ConfigureWindow, but the arguments that accepts seem obscure to me. Last time I called it I used xcb.xproto.CW.EventMask, but none of the flags in CW seem to be related to width/height.

PS The documentation on all of this seems quite elusive to me. I've looked at a couple of python window managers that supposedly use xcb, and they seem to use their own custom versions with extra functionality. Also, Examining/debugging a running window manager (which is also responsible for mapping your debugger's window) is a PITA, hence my asking here. probably would be better to use two machines or a VM or something.

Thanks.

DaedalusFall
  • 8,335
  • 6
  • 30
  • 43
  • The way you debug a window manager is to use a nested X server like Xephyr or Xnest. Write yourself a script to launch your WM for testing inside a nested X server with a single command after you make each change. If you look at the metacity source there is or used to be such a script. – Havoc P May 02 '11 at 14:36
  • I'm in almost the same situation. My little WM manages to map windows at fixed positions and sizes, but like you I get two ConfigureRequest events, with a pretty long delay between them. Did you ever figure out why you get two event or why there is such a delay between them? – Some programmer dude Oct 06 '11 at 12:45

1 Answers1

1

The short answer is configure the window (size, stacking, etc.) by calling ConfigureWindow. The long answer is here you impose policy and honor specs such as XSizeHints. Best to have a look at some existing WMs' source and get a sense of what they do. Exactly what you do depends on your desired UI.

The simplest thing to get it working is to just ConfigureWindow exactly as the request asks with no policy or hint overrides. But you'll probably see lots of usability problems quickly and have to add some more smarts.

Havoc P
  • 8,365
  • 1
  • 31
  • 46
  • Thanks. Should have been clearer in what I was asking. I mean function do i call to actually configure the window. I had the impression that I was supposed to modify the event and pass it along, but I'm not sure now. I understand in the abstract what a WM should be doing, and for want of a better term what I'm trying to write to start with is a 'Pass Through' WM. I've clarified my question. – DaedalusFall May 02 '11 at 13:00
  • Right, the protocol request is ConfigureWindow, which is XConfigureWindow() in Xlib and xcb_configure_window() in XCB. I assume Python calls it something analogous. If you look at some existing WM source you can see the idea. The fields in ConfigureWindow match exactly to those in the ConfigureRequestEvent so to pass through you just copy them over. – Havoc P May 02 '11 at 14:34
  • look at "man XConfigureWindow" and "man XConfigureRequestEvent" for a lot of good detail. – Havoc P May 02 '11 at 14:36