sxhkd-rc

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

commit 49918e7163d6c65a869a1ac5974d9f101f8405fc
parent e94452a2a0f40909e31d7b0b4ee83e05a4bd5e68
Author: Bastien Dejean <nihilhill@gmail.com>
Date:   Sat,  9 Aug 2014 09:45:42 +0200

Ignore mapping notify events by default

Diffstat:
Mdoc/sxhkd.1 | 10++++++----
Mdoc/sxhkd.1.txt | 4++--
Msxhkd.c | 15+++++++++------
Msxhkd.h | 2+-
4 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/doc/sxhkd.1 b/doc/sxhkd.1 @@ -2,12 +2,12 @@ .\" Title: sxhkd .\" Author: [see the "Author" section] .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/> -.\" Date: 07/30/2014 +.\" Date: 08/09/2014 .\" Manual: Sxhkd Manual .\" Source: Sxhkd 0.5.4 .\" Language: English .\" -.TH "SXHKD" "1" "07/30/2014" "Sxhkd 0\&.5\&.4" "Sxhkd Manual" +.TH "SXHKD" "1" "08/09/2014" "Sxhkd 0\&.5\&.4" "Sxhkd Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -47,9 +47,11 @@ Print the synopsis to standard output and exit\&. Print the version information to standard output and exit\&. .RE .PP -\fB\-n\fR +\fB\-m\fR \fICOUNT\fR .RS 4 -Ignore mapping notify events\&. +Handle the first +\fICOUNT\fR +mapping notify events\&. .RE .PP \fB\-t\fR \fITIMEOUT\fR diff --git a/doc/sxhkd.1.txt b/doc/sxhkd.1.txt @@ -30,8 +30,8 @@ Options *-v*:: Print the version information to standard output and exit. -*-n*:: - Ignore mapping notify events. +*-m* _COUNT_:: + Handle the first _COUNT_ mapping notify events. *-t* _TIMEOUT_:: Timeout in seconds for the recording of chord chains. diff --git a/sxhkd.c b/sxhkd.c @@ -46,25 +46,26 @@ int main(int argc, char *argv[]) char *fifo_path = NULL; status_fifo = NULL; config_path = NULL; - ignore_mapping = false; + mapping_count = 0; timeout = TIMEOUT; unsigned int max_freq = 0; motion_interval = 0; last_motion_time = 0; redir_fd = -1; - while ((opt = getopt(argc, argv, "vhnt:c:r:s:f:")) != (char)-1) { + while ((opt = getopt(argc, argv, "vhm:t:c:r:s:f:")) != (char)-1) { switch (opt) { case 'v': printf("%s\n", VERSION); exit(EXIT_SUCCESS); break; case 'h': - printf("sxhkd [-h|-v|-t TIMEOUT|-c CONFIG_FILE|-r REDIR_FILE|-s STATUS_FIFO] [EXTRA_CONFIG ...]\n"); + printf("sxhkd [-h|-v|-m COUNT|-t TIMEOUT|-c CONFIG_FILE|-r REDIR_FILE|-s STATUS_FIFO] [EXTRA_CONFIG ...]\n"); exit(EXIT_SUCCESS); break; - case 'n': - ignore_mapping = true; + case 'm': + if (sscanf(optarg, "%i", &mapping_count) != 1) + warn("Can't parse mapping count.\n"); break; case 't': timeout = atoi(optarg); @@ -258,7 +259,7 @@ void motion_notify(xcb_generic_event_t *evt, uint8_t event_type) void mapping_notify(xcb_generic_event_t *evt) { - if (ignore_mapping || !running || chained) + if (!mapping_count) return; xcb_mapping_notify_event_t *e = (xcb_mapping_notify_event_t *) evt; PRINTF("mapping notify %u %u\n", e->request, e->count); @@ -269,6 +270,8 @@ void mapping_notify(xcb_generic_event_t *evt) get_lock_fields(); reload_cmd(); escape_chord = make_chord(ESCAPE_KEYSYM, XCB_NONE, 0, XCB_KEY_PRESS, false, false); + if (mapping_count > 0) + mapping_count--; } } diff --git a/sxhkd.h b/sxhkd.h @@ -56,7 +56,7 @@ int num_extra_confs; int redir_fd; FILE *status_fifo; char progress[3 * MAXLEN]; -bool ignore_mapping; +int mapping_count; int timeout; double motion_interval; xcb_timestamp_t last_motion_time;