Krolyxon
Commit 6ce94e3

Branches

Refs →

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.
Author
N-R-K
Date
2021-10-07 06:37 +0600
Committer
GitHub · 2021-10-07 00:37 +0000
Parent
e8d08ba
Commit
6ce94e3e3b8cccab0a5cc23c7538ad19626c1c1d

+19 −2

2 files changed

  1. M commands.c +2 −1
  2. M main.c +17 −1
M commands.c View
@@ -37,6 +37,7 @@ void animate(void);
3737 void slideshow(void);
3838 void set_timeout(timeout_f, int, bool);
3939 void reset_timeout(timeout_f);
40+void handle_key_handler(bool);
4041
4142 extern appmode_t mode;
4243 extern img_t img;
@@ -114,7 +115,7 @@ bool cg_toggle_bar(arg_t _)
114115
115116 bool cg_prefix_external(arg_t _)
116117 {
117− extprefix = true;
118+ handle_key_handler(true);
118119 return false;
119120 }
120121
M main.c View
@@ -469,6 +469,22 @@ Bool is_input_ev(Display *dpy, XEvent *ev, XPointer arg)
469469 return ev->type == ButtonPress || ev->type == KeyPress;
470470 }
471471
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+
472488 void run_key_handler(const char *key, unsigned int mask)
473489 {
474490 pid_t pid;
@@ -588,7 +604,7 @@ void on_keypress(XKeyEvent *kev)
588604 if (IsModifierKey(ksym))
589605 return;
590606 if (extprefix && ksym == keyhandler_abort && MODMASK(kev->state) == 0) {
591− extprefix = False;
607+ handle_key_handler(false);
592608 } else if (extprefix) {
593609 run_key_handler(XKeysymToString(ksym), kev->state & ~sh);
594610 extprefix = False;