From 920c0d7c250e882c9f308683aafdb0d04a861db3 Mon Sep 17 00:00:00 2001 From: Samuel Dudik Date: Thu, 30 Jul 2020 11:21:27 +0200 Subject: [PATCH] Add proper event loop, fix redrawing --- main.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index a55c5c4..8225e35 100644 --- a/main.c +++ b/main.c @@ -2,7 +2,6 @@ #include #include #include -#include #include "config.h" @@ -57,15 +56,23 @@ int main(int argc, char *argv[]) XftDraw *draw = XftDrawCreate(display, window, DefaultVisual(display, screen), DefaultColormap(display, screen)); XftColorAllocName(display, DefaultVisual(display, screen), DefaultColormap(display, screen), font_color, &color); - XMapWindow(display, window); + XSelectInput(display, window, ExposureMask | ButtonPress); - XftDrawString8(draw, &color, font, text_padding, height - text_padding, (XftChar8 *)argv[1], strlen(argv[1])); + XMapWindow(display, window); // TODO free xftcolor - XNextEvent(display, &event); + while (1) + { + XNextEvent(display, &event); - sleep(duration); + if (event.type == Expose) + { + XftDrawString8(draw, &color, font, text_padding, height - text_padding, (XftChar8 *)argv[1], strlen(argv[1])); + } + if (event.type == ButtonPress) + break; + } XCloseDisplay(display); return 0;