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.
This commit is contained in:
N-R-K 2021-10-07 06:37:34 +06:00 committed by GitHub
parent e8d08ba67e
commit 6ce94e3e3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View file

@ -37,6 +37,7 @@ void animate(void);
void slideshow(void); void slideshow(void);
void set_timeout(timeout_f, int, bool); void set_timeout(timeout_f, int, bool);
void reset_timeout(timeout_f); void reset_timeout(timeout_f);
void handle_key_handler(bool);
extern appmode_t mode; extern appmode_t mode;
extern img_t img; extern img_t img;
@ -114,7 +115,7 @@ bool cg_toggle_bar(arg_t _)
bool cg_prefix_external(arg_t _) bool cg_prefix_external(arg_t _)
{ {
extprefix = true; handle_key_handler(true);
return false; return false;
} }

18
main.c
View file

@ -469,6 +469,22 @@ Bool is_input_ev(Display *dpy, XEvent *ev, XPointer arg)
return ev->type == ButtonPress || ev->type == KeyPress; return ev->type == ButtonPress || ev->type == KeyPress;
} }
void handle_key_handler(bool init)
{
extprefix = init;
if (win.bar.h == 0)
return;
if (init) {
close_info();
snprintf(win.bar.l.buf, win.bar.l.size, "Getting key handler input "
"(%s to abort)...", XKeysymToString(keyhandler_abort));
} else { /* abort */
open_info();
update_info();
}
win_draw(&win);
}
void run_key_handler(const char *key, unsigned int mask) void run_key_handler(const char *key, unsigned int mask)
{ {
pid_t pid; pid_t pid;
@ -588,7 +604,7 @@ void on_keypress(XKeyEvent *kev)
if (IsModifierKey(ksym)) if (IsModifierKey(ksym))
return; return;
if (extprefix && ksym == keyhandler_abort && MODMASK(kev->state) == 0) { if (extprefix && ksym == keyhandler_abort && MODMASK(kev->state) == 0) {
extprefix = False; handle_key_handler(false);
} else if (extprefix) { } else if (extprefix) {
run_key_handler(XKeysymToString(ksym), kev->state & ~sh); run_key_handler(XKeysymToString(ksym), kev->state & ~sh);
extprefix = False; extprefix = False;