equal
deleted
inserted
replaced
|
1 /** |
|
2 * $Id: xdemo.c,v 1.1.1.1 2008-04-28 17:32:53 mbroeker Exp $ |
|
3 * $Source: /development/c/demos/xdemo.c,v $ |
|
4 * |
|
5 */ |
|
6 |
|
7 #include <stdio.h> |
|
8 #include <stdlib.h> |
|
9 #include <X11/Xlib.h> |
|
10 |
|
11 int main (int argc, char **argv) |
|
12 { |
|
13 Window w = 0; |
|
14 Display *dpy = XOpenDisplay (NULL); |
|
15 XEvent xev; |
|
16 int active; |
|
17 |
|
18 if (dpy == NULL) { |
|
19 printf ("Error opening localhost:0\n"); |
|
20 return EXIT_SUCCESS; |
|
21 } |
|
22 |
|
23 XSynchronize (dpy, 1); |
|
24 w = XCreateSimpleWindow (dpy, DefaultRootWindow (dpy), 0, 0, 640, 480, 1, 1, 1); |
|
25 |
|
26 if (w < 0) |
|
27 return EXIT_SUCCESS; |
|
28 |
|
29 printf ("WINDOW-ID: %ld\n", w); |
|
30 |
|
31 XRaiseWindow (dpy, w); |
|
32 XMapWindow (dpy, w); |
|
33 |
|
34 printf ("Press any key to quit\n"); |
|
35 |
|
36 active = 1; |
|
37 XSelectInput (dpy, w, KeyPressMask); |
|
38 |
|
39 while (active) { |
|
40 XNextEvent (dpy, &xev); |
|
41 switch (xev.type) { |
|
42 case KeyPress: |
|
43 active = 0; |
|
44 break; |
|
45 default: |
|
46 printf ("Unknown Event: %d\n", xev.type); |
|
47 } |
|
48 } |
|
49 |
|
50 XDestroyWindow (dpy, w); |
|
51 XCloseDisplay (dpy); |
|
52 return 0; |
|
53 } |