summaryrefslogtreecommitdiffstats
path: root/tools/aewm-drakx/aewm-drakx.c
blob: f550271c7321cfa375a0b2555d7abc4566b5a440 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* aewm - a minimalistic X11 window manager. ------- vim:sw=4:et
 * Copyright (c) 1998-2001 Decklin Foster <decklin@red-bean.com>
 * Free software! Please see README for details and license.  */

#include "aewm.h"


Display *dpy;
Window root;
Atom wm_state;

static void scan_wins(void)
{
    unsigned int nwins, i;
    Window dummyw1, dummyw2, *wins;
    XWindowAttributes attr;

    XQueryTree(dpy, root, &dummyw1, &dummyw2, &wins, &nwins);
    for (i = 0; i < nwins; i++) {
        XGetWindowAttributes(dpy, wins[i], &attr);
        if (!attr.override_redirect && attr.map_state == IsViewable)
            make_new_client(wins[i]);
    }
    XFree(wins);
}

static void setup_display(void)
{
    XSetWindowAttributes sattr;

    dpy = XOpenDisplay(NULL);

    if (!dpy) {
        err("can't open display! check your DISPLAY variable.");
        exit(1);
    }

    XSetErrorHandler(handle_xerror);
    root = RootWindow(dpy, DefaultScreen(dpy));

    wm_state = XInternAtom(dpy, "WM_STATE", False);

    sattr.event_mask = SubstructureRedirectMask|SubstructureNotifyMask;
    XChangeWindowAttributes(dpy, root, CWEventMask, &sattr);
}


int main()
{
    setup_display();
    scan_wins();
    do_event_loop();
}