#include <stdio.h>
#include <X11/Xlib.h>
+#include <X11/Xatom.h>
#include <X11/extensions/shape.h>
#include <string.h>
#include <stdlib.h>
struct RrInstance *inst;
XEvent report;
XClassHint chint;
+ Atom delete_win, protocols;
+ int quit;
if (!(display = XOpenDisplay(NULL))) {
fprintf(stderr, "couldn't connect to X server in DISPLAY\n");
chint.res_class = "Rendertest";
XSetClassHint(display, win, &chint);
+ delete_win = XInternAtom(display, "WM_DELETE_WINDOW", False);
+ protocols = XInternAtom(display, "WM_PROTOCOLS", False);
+ XSetWMProtocols(display, win, &delete_win, 1);
+
/* init Render */
if (!(inst = RrInit(display, DefaultScreen(display)))) {
fprintf(stderr, "couldn't initialize the Render library "
}
/*paint(win, look);*/
- while (1) {
+ quit = 0;
+ while (!quit) {
XNextEvent(display, &report);
switch (report.type) {
+ case ClientMessage:
+ if ((Atom)report.xclient.message_type == protocols)
+ if ((Atom)report.xclient.data.l[0] == delete_win)
+ quit = 1;
case Expose:
break;
case ConfigureNotify:
}
+ RrDestroy(inst);
+
return 1;
}