// Build me with: gcc test.c -lX11 -o test
// Run me in X session with gnome-shell, gnome-shell will crash.

#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
    Display *d = XOpenDisplay(NULL);
    if (d == NULL) {
        fprintf(stderr, "Cannot open display\n");
        exit(1);
    }

    int s = DefaultScreen(d);

    int delay;
    for (delay = 0; delay < 400; delay += 10) {
        Window w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 100, 100, 1, BlackPixel(d, s), WhitePixel(d, s));
        XMapWindow(d, w);
        XFlush(d);

        usleep(delay * 1000);

        XDestroyWindow(d, w);
        XFlush(d);

        usleep(delay * 1000);
    }

    XCloseDisplay(d);
    return 0;
}
