nsxiv6ce94e3
add statusbar message upon key-hander activation (#98)
Currently when running the key-handler the statusbar shows a "Running key-handler..." message, but there's no indication of the prefix key being pressed. There's a slight functional benefit of this patch in the sense that users can visually tell if the key-handler is listening on input or if the key-handler has been aborted or not.
+19 −2
2 files changed
- M commands.c +2 −1
- M main.c +17 −1
| @@ -37,6 +37,7 @@ void animate(void); | |||
| 37 | 37 | void slideshow(void); | |
| 38 | 38 | void set_timeout(timeout_f, int, bool); | |
| 39 | 39 | void reset_timeout(timeout_f); | |
| 40 | + | void handle_key_handler(bool); | |
| 40 | 41 | ||
| 41 | 42 | extern appmode_t mode; | |
| 42 | 43 | extern img_t img; | |
| @@ -114,7 +115,7 @@ bool cg_toggle_bar(arg_t _) | |||
| 114 | 115 | ||
| 115 | 116 | bool cg_prefix_external(arg_t _) | |
| 116 | 117 | { | |
| 117 | − | extprefix = true; | |
| 118 | + | handle_key_handler(true); | |
| 118 | 119 | return false; | |
| 119 | 120 | } | |
| 120 | 121 | ||
| @@ -469,6 +469,22 @@ Bool is_input_ev(Display *dpy, XEvent *ev, XPointer arg) | |||
| 469 | 469 | return ev->type == ButtonPress || ev->type == KeyPress; | |
| 470 | 470 | } | |
| 471 | 471 | ||
| 472 | + | void handle_key_handler(bool init) | |
| 473 | + | { | |
| 474 | + | extprefix = init; | |
| 475 | + | if (win.bar.h == 0) | |
| 476 | + | return; | |
| 477 | + | if (init) { | |
| 478 | + | close_info(); | |
| 479 | + | snprintf(win.bar.l.buf, win.bar.l.size, "Getting key handler input " | |
| 480 | + | "(%s to abort)...", XKeysymToString(keyhandler_abort)); | |
| 481 | + | } else { /* abort */ | |
| 482 | + | open_info(); | |
| 483 | + | update_info(); | |
| 484 | + | } | |
| 485 | + | win_draw(&win); | |
| 486 | + | } | |
| 487 | + | ||
| 472 | 488 | void run_key_handler(const char *key, unsigned int mask) | |
| 473 | 489 | { | |
| 474 | 490 | pid_t pid; | |
| @@ -588,7 +604,7 @@ void on_keypress(XKeyEvent *kev) | |||
| 588 | 604 | if (IsModifierKey(ksym)) | |
| 589 | 605 | return; | |
| 590 | 606 | if (extprefix && ksym == keyhandler_abort && MODMASK(kev->state) == 0) { | |
| 591 | − | extprefix = False; | |
| 607 | + | handle_key_handler(false); | |
| 592 | 608 | } else if (extprefix) { | |
| 593 | 609 | run_key_handler(XKeysymToString(ksym), kev->state & ~sh); | |
| 594 | 610 | extprefix = False; | |