diff --git a/sowm.c b/sowm.c index 6b9f794..a5bad10 100644 --- a/sowm.c +++ b/sowm.c @@ -28,6 +28,7 @@ typedef struct client { Window w; } client; +static void init(); static void button_press(XEvent *e); static void button_release(); static void configure_request(XEvent *e); @@ -76,6 +77,18 @@ static void (*events[LASTEvent])(XEvent *e) = { XGetGeometry(d, W, &(Window){0}, gx, gy, gw, gh, \ &(unsigned int){0}, &(unsigned int){0}) +void init() { + Window *child; + unsigned int nchild; + XQueryTree(d, RootWindow(d, DefaultScreen(d)), &(Window){0}, + &(Window){0}, &child, &nchild); + for(unsigned int i = 0; i < nchild; i++) { + XSelectInput(d, child[i], StructureNotifyMask|EnterWindowMask); + XMapWindow(d, child[i]); + win_add(child[i]); + } +} + void win_focus(client *c) { cur = c; XSetInputFocus(d, cur->w, RevertToParent, CurrentTime); @@ -290,6 +303,8 @@ int main(void) { XSelectInput(d, root, SubstructureRedirectMask); XDefineCursor(d, root, XCreateFontCursor(d, 68)); + init(); + for (unsigned int i=0; i < sizeof(keys)/sizeof(*keys); ++i) XGrabKey(d, XKeysymToKeycode(d, keys[i].keysym), keys[i].mod, root, True, GrabModeAsync, GrabModeAsync);