herbe

[fork] notifications
Log | Files | Refs | README | LICENSE

commit 920c0d7c250e882c9f308683aafdb0d04a861db3
parent 792444a3319047b9fad97b1a3388439125de0c83
Author: Samuel Dudik <samuel.dudik@gmail.com>
Date:   Thu, 30 Jul 2020 11:21:27 +0200

Add proper event loop, fix redrawing

Diffstat:
Mmain.c | 17++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/main.c b/main.c @@ -2,7 +2,6 @@ #include <X11/Xft/Xft.h> #include <stdio.h> #include <stdlib.h> -#include <unistd.h> #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;