pipecross
[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         GC gc;
25         Pixmap pm;
26         Appearance *look;
27
28         int grabbed = 0;
29         Window root;
30         XGCValues values;
31         XEvent report;
32         int h = 500, w = 500, tmp;
33         XVisualInfo *vi;
34         int i;
35
36         ob_display = XOpenDisplay(NULL);
37         XSetErrorHandler(x_error_handler);
38         ob_screen = DefaultScreen(ob_display);
39         ob_root = RootWindow(ob_display, ob_screen);
40         win =
41             XCreateWindow(ob_display, RootWindow(ob_display, 0)
42                           , 10, 10, w, h, 10, 
43                           CopyFromParent,       /* depth */
44                           CopyFromParent,       /* class */
45                           CopyFromParent,       /* visual */
46                           0,                    /* valuemask */
47                           0);                   /* attributes */
48         XMapWindow(ob_display, win);
49         XSelectInput(ob_display, win, ExposureMask | StructureNotifyMask);
50         root = RootWindow (ob_display, DefaultScreen (ob_display));
51         render_startup();
52
53         look = appearance_new(Surface_Planar, 0);
54         look->surface.data.planar.grad = Background_PipeCross;
55         look->surface.data.planar.secondary = color_parse("Yellow");
56         look->surface.data.planar.primary = color_parse("Blue");
57         look->surface.data.planar.interlaced = FALSE;
58         look->area.x = 0;
59         look->area.y = 0;
60         look->area.width = 500;
61         look->area.height = 500;
62         if (ob_display == NULL) {
63                 fprintf(stderr, "couldn't connect to X server :0\n");
64                 return 0;
65         }
66
67         paint(win, look);
68         while (1) {
69                 XNextEvent(ob_display, &report);
70                 switch (report.type) {
71                 case Expose:
72                 break;
73                 case ConfigureNotify:
74                         look->area.width = report.xconfigure.width;
75                         look->area.height = report.xconfigure.height;
76                         paint(win, look);
77                 break;
78                 }
79
80         }
81
82         return 1;
83 }