xdemo.c
changeset 4 236f8f747073
parent 0 af501b0c1716
child 8 96d16dfe787a
equal deleted inserted replaced
3:820ed7fb9314 4:236f8f747073
    19         printf ("Error opening localhost:0\n");
    19         printf ("Error opening localhost:0\n");
    20         return EXIT_SUCCESS;
    20         return EXIT_SUCCESS;
    21     }
    21     }
    22 
    22 
    23     XSynchronize (dpy, 1);
    23     XSynchronize (dpy, 1);
    24     w = XCreateSimpleWindow (dpy, DefaultRootWindow (dpy), 0, 0, 640, 480, 1, 1, 1);
    24     w = XCreateSimpleWindow (dpy, DefaultRootWindow (dpy), 0, 0, 240, 60, 1, 1, 1);
    25 
    25 
    26     if (w < 0)
    26     if (w < 0)
    27         return EXIT_SUCCESS;
    27         return EXIT_SUCCESS;
    28 
    28 
    29     printf ("WINDOW-ID: %ld\n", w);
    29     printf ("WINDOW-ID: %ld\n", w);
    30 
    30 
    31     XRaiseWindow (dpy, w);
    31     XRaiseWindow (dpy, w);
    32     XMapWindow (dpy, w);
    32     XMapWindow (dpy, w);
    33 
    33 
    34     printf ("Press any key to quit\n");
    34     printf ("Press ESC to quit\n");
    35 
    35 
    36     active = 1;
    36     active = 1;
    37     XSelectInput (dpy, w, KeyPressMask);
    37     XSelectInput (dpy, w, KeyPressMask);
    38 
    38 
    39     while (active) {
    39     while (active) {
    40         XNextEvent (dpy, &xev);
    40         XNextEvent (dpy, &xev);
    41         switch (xev.type) {
    41         switch (xev.type) {
    42         case KeyPress:
    42         case KeyPress:
    43             active = 0;
    43 			if(xev.xkey.keycode == 9)
       
    44 	            active = 0;
       
    45 			printf("Keycode = %2u\n", xev.xkey.keycode);
    44             break;
    46             break;
    45         default:
    47         default:
    46             printf ("Unknown Event: %d\n", xev.type);
    48             printf ("Unknown Event: %d\n", xev.type);
    47         }
    49         }
    48     }
    50     }