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