]> icculus.org git repositories - mikachu/openbox.git/blob - render/test.c
include Xlib.h for Pixmap
[mikachu/openbox.git] / render / test.c
1 #include <stdio.h>
2 #include <X11/Xlib.h>
3 #include <X11/extensions/shape.h>
4 #include <GL/glx.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         GC gc;
26         Pixmap pm;
27         Appearance *look;
28
29         int grabbed = 0;
30         Window root;
31         XGCValues values;
32         XEvent report;
33         int h = 500, w = 500, tmp;
34         XVisualInfo *vi;
35         int i;
36
37         ob_display = XOpenDisplay(NULL);
38         XSetErrorHandler(x_error_handler);
39         ob_screen = DefaultScreen(ob_display);
40         ob_root = RootWindow(ob_display, ob_screen);
41         win =
42             XCreateWindow(ob_display, RootWindow(ob_display, 0)
43                           , 10, 10, w, h, 10, 
44                           CopyFromParent,       // depth
45                           CopyFromParent,       // class
46                           CopyFromParent,       // visual
47                           0,    // valuemask
48                           0);   // attributes
49         XMapWindow(ob_display, win);
50         XSelectInput(ob_display, win, ExposureMask | StructureNotifyMask);
51         root = RootWindow (ob_display, DefaultScreen (ob_display));
52         render_startup();
53
54         look = appearance_new(Surface_Planar, 0);
55         look->surface.data.planar.grad = Background_Solid;
56         look->surface.data.planar.secondary = color_new(0xFF, 0xFF, 0xFF);
57         look->surface.data.planar.primary = color_parse("Red");
58         look->surface.data.planar.interlaced = FALSE;
59         if (ob_display == NULL) {
60                 fprintf(stderr, "couldn't connect to X server :0\n");
61                 return 0;
62         }
63
64         paint(win, look, 500, 500);
65         while (1) {
66                 XNextEvent(ob_display, &report);
67                 switch (report.type) {
68                 case Expose:
69                 break;
70                 case ConfigureNotify:
71                         w = report.xconfigure.width;
72                         h = report.xconfigure.height;
73                         paint(win, look, w, h);
74                         printf("confignotify %i:%i\n", w, h);
75                 break;
76                 }
77
78         }
79
80         return 1;
81 }