Krolyxon
Commit 3bc7082

Branches

Refs →

nsxiv3bc7082

fix: send implicit_mod to process_bindings (#176)

* fix: send implicit_mod to process_bindings

this solves the edge case where someone might have `ShiftMask + A` in
their keybindings compared to a plain `A`.

Closes: https://github.com/nsxiv/nsxiv/pull/166#issuecomment-978853136

* code-style: smuggle small style fix in

win_draw_bar now mimics autoreload_nop.c functions
Author
N-R-K
Date
2021-12-01 05:41 +0600
Committer
GitHub · 2021-12-01 05:41 +0600
Parent
68ddbe2
Commit
3bc7082f4e08e71fb40944bb085fafbb65f6c8cf

+10 −7

3 files changed

  1. M autoreload_nop.c +1 −1
  2. M main.c +5 −5
  3. M window.c +4 −1
M autoreload_nop.c View
@@ -35,7 +35,7 @@ void arl_setup(arl_t *arl, const char *filepath)
3535 }
3636
3737 bool arl_handle(arl_t *arl)
38−{
38+{
3939 (void) arl;
4040 return false;
4141 }
M main.c View
@@ -605,15 +605,15 @@ end:
605605 redraw();
606606 }
607607
608−static bool process_bindings(const keymap_t *keys, unsigned int len,
609− KeySym ksym_or_button, unsigned int state)
608+static bool process_bindings(const keymap_t *keys, unsigned int len, KeySym ksym_or_button,
609+ unsigned int state, unsigned int implicit_mod)
610610 {
611611 unsigned int i;
612612 bool dirty = false;
613613
614614 for (i = 0; i < len; i++) {
615615 if (keys[i].ksym_or_button == ksym_or_button &&
616− MODMASK(keys[i].mask) == MODMASK(state) &&
616+ MODMASK(keys[i].mask | implicit_mod) == MODMASK(state) &&
617617 keys[i].cmd.func &&
618618 (keys[i].cmd.mode == MODE_ALL || keys[i].cmd.mode == mode))
619619 {
@@ -652,7 +652,7 @@ static void on_keypress(XKeyEvent *kev)
652652 prefix = prefix * 10 + (int) (key - '0');
653653 return;
654654 } else {
655− dirty = process_bindings(keys, ARRLEN(keys), ksym, kev->state & ~sh);
655+ dirty = process_bindings(keys, ARRLEN(keys), ksym, kev->state, sh);
656656 }
657657 if (dirty)
658658 redraw();
@@ -668,7 +668,7 @@ static void on_buttonpress(XButtonEvent *bev)
668668 if (mode == MODE_IMAGE) {
669669 set_timeout(reset_cursor, TO_CURSOR_HIDE, true);
670670 reset_cursor();
671− dirty = process_bindings(buttons, ARRLEN(buttons), bev->button, bev->state);
671+ dirty = process_bindings(buttons, ARRLEN(buttons), bev->button, bev->state, 0);
672672 if (dirty)
673673 redraw();
674674 } else {
M window.c View
@@ -466,7 +466,10 @@ static void win_draw_bar(win_t *win)
466466 XftDrawDestroy(d);
467467 }
468468 #else
469−static void win_draw_bar(win_t *win){}
469+static void win_draw_bar(win_t *win)
470+{
471+ (void) win;
472+}
470473 #endif /* HAVE_LIBFONTS */
471474
472475 void win_draw(win_t *win)