Code update for Window Maker version 0.50.0
[wmaker-crm.git] / wrlib / view.c
blob6cf18171998f395dd763ffec8adf78573c6a1091
2 #include <X11/Xlib.h>
3 #include "wraster.h"
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include "tile.xpm"
7 Display *dpy;
8 Window win;
9 RContext *ctx;
10 RImage *img;
11 Pixmap pix;
13 void main(int argc, char **argv)
15 RContextAttributes attr;
17 dpy = XOpenDisplay("");
18 if (!dpy) {
19 puts("cant open display");
20 exit(1);
22 attr.flags = RC_RenderMode | RC_ColorsPerChannel;
23 attr.render_mode = RM_DITHER;
24 attr.colors_per_channel = 4;
25 ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
27 if (argc<2)
28 img = RGetImageFromXPMData(ctx, image_name);
29 else
30 img = RLoadImage(ctx, argv[1], argc>2 ? atol(argv[2]) : 0);
32 if (!img) {
33 puts(RMessageForError(RErrorCode));
34 exit(1);
36 if (!RConvertImage(ctx, img, &pix)) {
37 puts(RMessageForError(RErrorCode));
38 exit(1);
41 win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, img->width,
42 img->height, 0, 0, 0);
43 XSelectInput(dpy, win, ExposureMask);
44 XMapRaised(dpy, win);
45 XSync(dpy, False);
46 XCopyArea(dpy, pix, win, ctx->copy_gc, 0, 0, img->width, img->height,
47 0, 0);
49 XSync(dpy, False);
50 while (1) {
51 XEvent ev;
52 XNextEvent(dpy, &ev);
53 if (ev.type==Expose)
54 XCopyArea(dpy, pix, win, ctx->copy_gc, 0, 0, img->width, img->height,
55 0, 0);
57 XFlush(dpy);
59 getchar();