diff --git a/include/types.h b/include/types.h index 76f06bb..3e66c29 100644 --- a/include/types.h +++ b/include/types.h @@ -24,6 +24,7 @@ typedef struct Config { bool ignore_matches; match_t *matches; bool start_hidden; + bool hide_on_kbd; } Config; typedef struct coordinates_t { diff --git a/man/unclutter-xfixes.man b/man/unclutter-xfixes.man index d967b97..64b1f2f 100644 --- a/man/unclutter-xfixes.man +++ b/man/unclutter-xfixes.man @@ -8,7 +8,7 @@ unclutter-xfixes - rewrite of unclutter using the X11-Xfixes extension == SYNOPSIS -unclutter [*--timeout* _seconds_] [*--no-timeout*] [*--jitter* _radius_] [*--exclude-root*] [*--ignore-scrolling*] [*--ignore-buttons* _buttons_] [*--hide-on-touch*] [*--fork*|*-b*] [*--help*|*-h*] [*--version*|*-v*] [*--start-hidden*] +unclutter [*--timeout* _seconds_] [*--no-timeout*] [*--jitter* _radius_] [*--exclude-root*] [*--ignore-scrolling*] [*--ignore-buttons* _buttons_] [*--hide-on-touch*] [*--hide-on-key-press*] [*--fork*|*-b*] [*--help*|*-h*] [*--version*|*-v*] [*--start-hidden*] Compatibility arguments: @@ -53,6 +53,9 @@ pass multiple button numbers by separating them with ','. *--hide-on-touch*:: Hides the mouse cursor on touch events. +*--hide-on-key-press*:: +Hides the mouse cursor on (keyboard) key press events. + *--start-hidden*:: Starts the cursor hidden. diff --git a/src/event.c b/src/event.c index 256fa17..44eadb3 100644 --- a/src/event.c +++ b/src/event.c @@ -100,7 +100,11 @@ static void x_check_cb(EV_P_ ev_check *w, int revents) { last_cursor_pos.y = root_y; } - if (config.hide_on_touch && (cookie->evtype == XI_RawTouchBegin || cookie->evtype == XI_RawTouchUpdate)) { + bool should_hide = false; + should_hide |= config.hide_on_touch && (cookie->evtype == XI_RawTouchBegin || cookie->evtype == XI_RawTouchUpdate); + should_hide |= config.hide_on_kbd && cookie->evtype == XI_RawKeyPress; + + if (should_hide) { cursor_hide(); } else { /* We don't bother checking the exact event since we only select events that interest us. */ @@ -193,6 +197,9 @@ static void event_select_xi(void) { XISetMask(mask, XI_RawTouchBegin); XISetMask(mask, XI_RawTouchUpdate); } + if (config.hide_on_kbd) { + XISetMask(mask, XI_RawKeyPress); + } masks[0].deviceid = XIAllMasterDevices; masks[0].mask_len = sizeof(mask); diff --git a/src/unclutter.c b/src/unclutter.c index f7979a4..d287806 100644 --- a/src/unclutter.c +++ b/src/unclutter.c @@ -39,6 +39,7 @@ Config config = { .ignore_buttons.count = 0, .ignore_buttons.buttons = NULL, .hide_on_touch = false, + .hide_on_kbd = false, .fork = false, .debug = false, .onescreen = false, @@ -102,6 +103,7 @@ static void parse_args(int argc, char *argv[]) { { "ignore-scrolling", no_argument, 0, 0 }, { "ignore-buttons", required_argument, 0, 0 }, { "hide-on-touch", no_argument, 0, 0 }, + { "hide-on-key-press", no_argument, 0, 0}, { "fork", no_argument, 0, 'b' }, { "version", no_argument, 0, 'v' }, { "help", no_argument, 0, 'h' }, @@ -147,6 +149,9 @@ static void parse_args(int argc, char *argv[]) { } else if (OPT_NAME_IS("hide-on-touch")) { config.hide_on_touch = true; break; + } else if (OPT_NAME_IS("hide-on-key-press")) { + config.hide_on_kbd = true; + break; } else if (OPT_NAME_IS("root")) { config.exclude_root = false; break; @@ -208,7 +213,7 @@ static void parse_args(int argc, char *argv[]) { } static void print_usage(char *argv[]) { - fprintf(stderr, "Usage: %s [--timeout ] [--no-timeout] [--jitter ] [--exclude-root] [--ignore-scrolling] [--ignore-buttons ] [--hide-on-touch] [-b|--fork] [-v|--version] [-h|--help] [--start-hidden]", argv[0]); + fprintf(stderr, "Usage: %s [--timeout ] [--no-timeout] [--jitter ] [--exclude-root] [--ignore-scrolling] [--ignore-buttons ] [--hide-on-touch] [-b|--fork] [-v|--version] [-h|--help] [--start-hidden] [--hide-on-key-press]", argv[0]); fprintf(stderr, "\n"); exit(EXIT_FAILURE); }