]> git.mdlowis.com Git - projs/tide.git/commitdiff
draw the pick window before loading results. This gives visual indication that it...
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 16 Apr 2019 19:20:43 +0000 (15:20 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 16 Apr 2019 19:20:43 +0000 (15:20 -0400)
src/pick.c

index 5afd0aecba75b67a311ae26e8f230c456bd51a53..c098f1b7ddd4d59bad4dbba4952559479ac548a7 100644 (file)
@@ -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);