diff options
author | EliteTK <tomasz.kramkowski@gmail.com> | 2014-10-07 23:35:09 +0100 |
---|---|---|
committer | EliteTK <tomasz.kramkowski@gmail.com> | 2014-10-07 23:35:09 +0100 |
commit | bf4148f4351584bc97b26d8efc7bea74c2ab1b8a (patch) | |
tree | b4aac44a189f0bb911541dc24c4c3d2cf0ee410a /xlibtest.c | |
parent | ef043cbc02c3c55ef175b83e7c5e4d2b82d0007b (diff) | |
download | c-stuff-bf4148f4351584bc97b26d8efc7bea74c2ab1b8a.tar.gz c-stuff-bf4148f4351584bc97b26d8efc7bea74c2ab1b8a.tar.xz c-stuff-bf4148f4351584bc97b26d8efc7bea74c2ab1b8a.zip |
Added GPL header to files (which I'm mostly sure I wrote) Resolves #1
Diffstat (limited to 'xlibtest.c')
-rw-r--r-- | xlibtest.c | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/xlibtest.c b/xlibtest.c deleted file mode 100644 index adcbd26..0000000 --- a/xlibtest.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Simple Xlib application drawing a box in a window. - * gcc input.c -o output -lX11 - */ - -#include <X11/Xlib.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -int main(int argc, char **argv) -{ - Display *display; - Window window; - XEvent event; - char *msg = "Hello, World!"; - int s; - - /* open connection with the server */ - display = XOpenDisplay(NULL); - if (display == NULL) - { - fprintf(stderr, "Cannot open display\n"); - exit(1); - } - - s = DefaultScreen(display); - - /* create window */ - window = XCreateSimpleWindow(display, RootWindow(display, s), 10, 10, 200, 200, 1, - BlackPixel(display, s), WhitePixel(display, s)); - - /* select kind of events we are interested in */ - XSelectInput(display, window, ExposureMask | KeyPressMask); - - /* map (show) the window */ - XMapWindow(display, window); - - /* event loop */ - for (;;) - { - XNextEvent(display, &event); - - /* draw or redraw the window */ - if (event.type == Expose) - { - XFillRectangle(display, window, DefaultGC(display, s), 20, 20, 10, 10); - XDrawString(display, window, DefaultGC(display, s), 50, 50, msg, strlen(msg)); - } - /* exit on key press */ - if (event.type == KeyPress) - break; - } - - /* close connection to server */ - XCloseDisplay(display); - - return 0; -} |