]> icculus.org git repositories - dana/openbox.git/blob - render/test.c
add Xutil includes for these badboys on older X versions/solaris
[dana/openbox.git] / render / test.c
1 #include <stdio.h>
2 #include <X11/Xlib.h>
3 #include <X11/Xutil.h>
4 #include <X11/extensions/shape.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include "render.h"
8 #include <glib.h>
9
10 static int x_error_handler(Display * disp, XErrorEvent * error)
11 {
12         char buf[1024];
13         XGetErrorText(disp, error->error_code, buf, 1024);
14         printf("%s\n", buf);
15         return 0;
16 }
17
18 Display *ob_display;
19 int ob_screen;
20 Window ob_root;
21
22 int main()
23 {
24         Window win;
25         RrInstance *inst;
26         RrAppearance *look;
27
28         Window root;
29         XEvent report;
30         int h = 500, w = 500;
31
32         ob_display = XOpenDisplay(NULL);
33         XSetErrorHandler(x_error_handler);
34         ob_screen = DefaultScreen(ob_display);
35         ob_root = RootWindow(ob_display, ob_screen);
36         win =
37             XCreateWindow(ob_display, RootWindow(ob_display, 0),
38                           10, 10, w, h, 10, 
39                           CopyFromParent,       /* depth */
40                           CopyFromParent,       /* class */
41                           CopyFromParent,       /* visual */
42                           0,                    /* valuemask */
43                           0);                   /* attributes */
44         XMapWindow(ob_display, win);
45         XSelectInput(ob_display, win, ExposureMask | StructureNotifyMask);
46         root = RootWindow (ob_display, DefaultScreen (ob_display));
47         inst = RrInstanceNew(ob_display, ob_screen);
48
49         look = RrAppearanceNew(inst, 0);
50         look->surface.grad = RR_SURFACE_PYRAMID;
51         look->surface.secondary = RrColorParse(inst, "Yellow");
52         look->surface.primary = RrColorParse(inst, "Blue");
53         look->surface.interlaced = FALSE;
54         if (ob_display == NULL) {
55                 fprintf(stderr, "couldn't connect to X server :0\n");
56                 return 0;
57         }
58
59         RrPaint(look, win, w, h);
60         while (1) {
61                 XNextEvent(ob_display, &report);
62                 switch (report.type) {
63                 case Expose:
64                 break;
65                 case ConfigureNotify:
66                     RrPaint(look, win,
67                             report.xconfigure.width,
68                             report.xconfigure.height);
69                 break;
70                 }
71
72         }
73
74         RrAppearanceFree (look);
75         RrInstanceFree (inst);
76
77         return 1;
78 }