Profil supprimé | cai bon!
Code :
- #include <stdio.h>
- #include <stdlib.h>
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- #include <X11/Xatom.h>
- #include <X11/keysym.h>
- int main() {
- int screen;
- Display *display;
- Window root, window;
- long fgcolor, bgcolor;
- XEvent event;
- long eventmask = KeyPressMask;
- GC draw;
- //XColor color;
- Colormap colormap;
- display = XOpenDisplay(NULL);
- root = RootWindow(display, screen = DefaultScreen(display));
- fgcolor = BlackPixel(display, screen);
- bgcolor = WhitePixel(display, screen);
- window = XCreateSimpleWindow(display, root, 1, 1, 200, 200, 0,
- fgcolor, bgcolor);
- XSelectInput(display, window, eventmask);
- XMapWindow(display, window);
- colormap = DefaultColormap(display, screen);
- draw = XCreateGC(display, window, fgcolor,0);
- for(;;) {
- XWindowEvent(display, window, eventmask, &event );
- switch( event.type ) {
- case Expose:
- XDrawRectangle(display,window,draw,10,10, 180, 180);
- printf("expose\n" );
- XFlush(display);
- break;
- case KeyPress:
- XDrawRectangle(display,window,draw,10,10, 180, 180);
- XDrawLine(display,window,draw,10,10,190,190);
- XDrawLine(display,window,draw,10,190,190,10);
- XFlush(display);
- sleep(3);
- exit(0);
- }
- }
- return(0);
- }
|
|