diff options
| author | davidovski <david@sendula.com> | 2021-04-13 00:01:43 +0100 |
|---|---|---|
| committer | davidovski <david@sendula.com> | 2021-04-13 00:01:43 +0100 |
| commit | dc1db3a1f58b1bd7004153b2f04e85e719489209 (patch) | |
| tree | a5b35e17ae97c2dee7fa4c83d4aeaea80ec5f53b /window.c | |
| parent | fc9fa1e4a2bf3ac0094eae7b40453631a9fae50e (diff) | |
added second thread
Diffstat (limited to 'window.c')
| -rw-r--r-- | window.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/window.c b/window.c new file mode 100644 index 0000000..0d55011 --- /dev/null +++ b/window.c @@ -0,0 +1,32 @@ +#include <X11/Xlib.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int main(int argc, const char **argv) { + Display *d; + XEvent e; + const char *message = "do you see the fun in gcc?"; + + d = XOpenDisplay(NULL); + if (d == NULL) { + fprintf(stderr, "error opening display\n"); + exit(1); + } + + int s = DefaultScreen(d); + Window w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 100, 100, 1, BlackPixel(d, s), WhitePixel(d, s)); + + XSelectInput(d, w, ExposureMask | KeyPressMask); + XMapWindow(d, w); + + while (1) { + XNextEvent(d, &e); + if (e.type == Expose) { + XDrawString(d, w, DefaultGC(d, s), 10, 50, message, strlen(message)); + } + } + + XCloseDisplay(d); + return 0; +} |
