sxhkd-rc

[fork] simple X hotkey daemon (but for the rc shell)
Log | Files | Refs | README | LICENSE

commit d4b3680fb04d1a78c69a814f1942fcb1b9f226bc
parent c785c2fbdf280d8476dc4011d8155002f931bdd3
Author: Bastien Dejean <nihilhill@gmail.com>
Date:   Sun, 23 Jun 2013 20:00:26 +0200

The `hits` variable is redundant

Diffstat:
Mtypes.c | 39+++++++++++++++++++--------------------
1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/types.c b/types.c @@ -7,8 +7,7 @@ hotkey_t *find_hotkey(xcb_keysym_t keysym, xcb_button_t button, uint16_t modfield, uint8_t event_type, bool *replay_event) { - int hits = 0; - int num_waiters = 0; + int num_active = 0; for (hotkey_t *hk = hotkeys; hk != NULL; hk = hk->next) { chain_t *c = hk->chain; @@ -23,35 +22,35 @@ hotkey_t *find_hotkey(xcb_keysym_t keysym, xcb_button_t button, uint16_t modfiel return hk; } else { c->state = c->state->next; - num_waiters++; + num_active++; } - hits++; } else if (chained) { if (c->state->event_type == event_type) c->state = c->head; else - num_waiters++; + num_active++; } } - if (hits > 0) { - chained = true; - if (timeout > 0) - alarm(timeout); - } else if (!chained) { - *replay_event = true; - for (hotkey_t *hk = hotkeys; *replay_event && hk != NULL; hk = hk->next) { - chord_t *c = hk->chain->head; - for (chord_t *cc = c; cc != NULL; cc = cc->more) - if (cc->keysym == keysym && cc->button == button && cc->modfield == modfield) - *replay_event = false; + if (!chained) { + if (num_active > 0) { + chained = true; + if (timeout > 0) + alarm(timeout); + } else { + *replay_event = true; + for (hotkey_t *hk = hotkeys; *replay_event && hk != NULL; hk = hk->next) { + chord_t *c = hk->chain->head; + for (chord_t *cc = c; cc != NULL; cc = cc->more) + if (cc->keysym == keysym && cc->button == button && cc->modfield == modfield) + *replay_event = false; + } } + } else if (num_active == 0) { + abort_chain(); } - PRINTF("num waiters %i\n", num_waiters); - - if (chained && num_waiters == 0) - abort_chain(); + PRINTF("num active %i\n", num_active); return NULL; }