4 #include <X11/extensions/shape.h>
10 static int x_error_handler(Display * disp, XErrorEvent * error)
13 XGetErrorText(disp, error->error_code, buf, 1024);
27 XEvent report, report2;
29 Atom delete_win, protocols;
32 struct RrInstance *inst;
33 struct RrSurface *sur;
34 struct RrColor pri, sec;
36 if (!(display = XOpenDisplay(NULL))) {
37 fprintf(stderr, "couldn't connect to X server in DISPLAY\n");
40 XSetErrorHandler(x_error_handler);
41 win = XCreateWindow(display, RootWindow(display, DefaultScreen(display)),
43 CopyFromParent, /* depth */
44 CopyFromParent, /* class */
45 CopyFromParent, /* visual */
48 XMapWindow(display, win);
49 XSelectInput(display, win, ExposureMask | StructureNotifyMask);
51 chint.res_name = "rendertest";
52 chint.res_class = "Rendertest";
53 XSetClassHint(display, win, &chint);
55 delete_win = XInternAtom(display, "WM_DELETE_WINDOW", False);
56 protocols = XInternAtom(display, "WM_PROTOCOLS", False);
57 XSetWMProtocols(display, win, &delete_win, 1);
60 if (!(inst = RrInstanceNew(display, DefaultScreen(display)))) {
61 fprintf(stderr, "couldn't initialize the Render library "
62 "(no suitable GL support found)\n");
66 sur = RrSurfaceNew(inst, RR_SURFACE_PLANAR, win, 0);
67 RrSurfaceSetArea(sur, X, Y, W, H);
68 RrColorSet(&pri, 0, 0, 0, 0);
69 RrColorSet(&sec, 1, 1, 1, 0);
70 RrPlanarSet(sur, RR_PLANAR_PIPECROSS, &pri, &sec);
74 XNextEvent(display, &report);
75 switch (report.type) {
77 if ((Atom)report.xclient.message_type == protocols)
78 if ((Atom)report.xclient.data.l[0] == delete_win)
81 if (XCheckTypedWindowEvent(display, win, ConfigureNotify,
83 XPutBackEvent(display, &report);
84 XPutBackEvent(display, &report2);
85 /* fall through ... */
87 while (XCheckTypedWindowEvent(display, win, Expose, &report));
88 RrPaintArea(sur, report.xexpose.x, report.xexpose.y,
89 report.xexpose.width, report.xexpose.height);
93 while (XCheckTypedWindowEvent(display, win, ConfigureNotify,
98 report.xconfigure.width,
99 report.xconfigure.height);
105 RrInstanceFree(inst);