author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Fri, 27 Dec 2013 16:00:09 +0100 | |
changeset 167 | 7c6b221900bf |
parent 77 | 49e0babccb23 |
permissions | -rw-r--r-- |
0 | 1 |
/** |
77 | 2 |
* xdemo.c |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
8
diff
changeset
|
3 |
* Copyright (C) 2008 Markus Broeker |
0 | 4 |
*/ |
5 |
||
6 |
#include <stdio.h> |
|
7 |
#include <stdlib.h> |
|
8 |
#include <X11/Xlib.h> |
|
9 |
||
10 |
int main (int argc, char **argv) |
|
11 |
{ |
|
12 |
Window w = 0; |
|
27
81a574d60c15
typo in min2time format string
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
9
diff
changeset
|
13 |
|
0 | 14 |
Display *dpy = XOpenDisplay (NULL); |
27
81a574d60c15
typo in min2time format string
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
9
diff
changeset
|
15 |
|
0 | 16 |
XEvent xev; |
27
81a574d60c15
typo in min2time format string
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
9
diff
changeset
|
17 |
|
0 | 18 |
int active; |
19 |
||
20 |
if (dpy == NULL) { |
|
21 |
printf ("Error opening localhost:0\n"); |
|
48
b94d657a9acb
Policy Inonsistency on many files
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
27
diff
changeset
|
22 |
return EXIT_FAILURE; |
0 | 23 |
} |
24 |
||
25 |
XSynchronize (dpy, 1); |
|
4
236f8f747073
pimp my code, a small xdemo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
26 |
w = XCreateSimpleWindow (dpy, DefaultRootWindow (dpy), 0, 0, 240, 60, 1, 1, 1); |
0 | 27 |
|
28 |
if (w < 0) |
|
48
b94d657a9acb
Policy Inonsistency on many files
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
27
diff
changeset
|
29 |
return EXIT_FAILURE; |
0 | 30 |
|
31 |
printf ("WINDOW-ID: %ld\n", w); |
|
32 |
||
33 |
XRaiseWindow (dpy, w); |
|
34 |
XMapWindow (dpy, w); |
|
35 |
||
4
236f8f747073
pimp my code, a small xdemo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
36 |
printf ("Press ESC to quit\n"); |
0 | 37 |
|
38 |
active = 1; |
|
39 |
XSelectInput (dpy, w, KeyPressMask); |
|
40 |
||
41 |
while (active) { |
|
42 |
XNextEvent (dpy, &xev); |
|
43 |
switch (xev.type) { |
|
44 |
case KeyPress: |
|
8
96d16dfe787a
We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
4
diff
changeset
|
45 |
if (xev.xkey.keycode == 9) |
96d16dfe787a
We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
4
diff
changeset
|
46 |
active = 0; |
96d16dfe787a
We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
4
diff
changeset
|
47 |
printf ("Keycode = %2u\n", xev.xkey.keycode); |
0 | 48 |
break; |
49 |
default: |
|
50 |
printf ("Unknown Event: %d\n", xev.type); |
|
51 |
} |
|
52 |
} |
|
53 |
||
54 |
XDestroyWindow (dpy, w); |
|
55 |
XCloseDisplay (dpy); |
|
8
96d16dfe787a
We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
4
diff
changeset
|
56 |
|
96d16dfe787a
We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
4
diff
changeset
|
57 |
return EXIT_SUCCESS; |
0 | 58 |
} |