From: Michael D. Lowis Date: Tue, 16 Apr 2019 19:20:43 +0000 (-0400) Subject: draw the pick window before loading results. This gives visual indication that it... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=c8ec9bdf0ae0258a0289ac4b30db6e498296bf82;p=projs%2Ftide.git draw the pick window before loading results. This gives visual indication that it is working without adding complexity to the code --- diff --git a/src/pick.c b/src/pick.c index 5afd0ae..c098f1b 100644 --- a/src/pick.c +++ b/src/pick.c @@ -197,37 +197,38 @@ static void redraw(XConf* x) { x11_flip(x); } -static void filter(void) { - XConf x = {0}; - x11_init(&x); - x11_mkdialog(&x, 640, 480, 0 +static void xinit(XConf* x) { + x11_init(x); + x11_mkdialog(x, 640, 480, 0 | StructureNotifyMask | KeyPressMask | ButtonPressMask | ExposureMask ); - x11_init_gc(&x); - x11_centerwin(&x); - if (!(x.font = x11_font_load(&x, Fonts[0]))) { + x11_init_gc(x); + x11_centerwin(x); + if (!(x->font = x11_font_load(x, Fonts[0]))) { perror("unable to load base font"); exit(EXIT_FAILURE); } - x11_show(&x); - x.eventfns[KeyPress] = xkeypress; - x.eventfns[ButtonPress] = xbtnpress; - x11_event_loop(&x, redraw); + x11_show(x); + x->eventfns[KeyPress] = xkeypress; + x->eventfns[ButtonPress] = xbtnpress; + redraw(x); } int main(int argc, char** argv) { + XConf x = {0}; if (argc >= 2) { size_t sz = min(strlen(argv[1]), sizeof(Query)-1); strncpy(Query, argv[1], sz); QueryIdx = sz; } + xinit(&x); load_choices(); score(); if (vec_size(&Choices) > 1) - filter(); + x11_event_loop(&x, redraw); Choice* choice = (Choice*)vec_at(&Choices, ChoiceIdx); if (vec_size(&Choices) && ChoiceIdx != SIZE_MAX) printf("%s\n", choice->string);