diff options
author | David Rosca <nowrep@gmail.com> | 2019-03-01 18:14:56 +0100 |
---|---|---|
committer | David Rosca <nowrep@gmail.com> | 2019-09-19 12:15:12 +0200 |
commit | 13d674284c46ff86459a8e7ac2e11f216cd44112 (patch) | |
tree | 4e2e1957b93a9b9a6dfea0d99553831ad2bd2ead | |
parent | b450d78b45979b6306c3372bb855aca6076befd0 (diff) |
Add touch option to hide cursor on any touch input
-rw-r--r-- | include/types.h | 1 | ||||
-rw-r--r-- | man/unclutter-xfixes.man | 5 | ||||
-rw-r--r-- | src/event.c | 12 | ||||
-rw-r--r-- | src/unclutter.c | 7 |
4 files changed, 21 insertions, 4 deletions
diff --git a/include/types.h b/include/types.h index 5994d7d..1cfc414 100644 --- a/include/types.h +++ b/include/types.h @@ -17,6 +17,7 @@ typedef struct Config { bool exclude_root; bool ignore_scrolling; ignore_buttons_t ignore_buttons; + bool hide_on_touch; bool fork; bool debug; bool onescreen; diff --git a/man/unclutter-xfixes.man b/man/unclutter-xfixes.man index 98808f7..4c6a929 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_] [*--jitter* _radius_] [*--exclude-root*] [*--ignore-scrolling*] [*--ignore-buttons* _buttons_] [*--fork*|*-b*] [*--help*|*-h*] [*--version*|*-v*] +unclutter [*--timeout* _seconds_] [*--jitter* _radius_] [*--exclude-root*] [*--ignore-scrolling*] [*--ignore-buttons* _buttons_] [*--hide-on-touch*] [*--fork*|*-b*] [*--help*|*-h*] [*--version*|*-v*] Compatibility arguments: @@ -36,6 +36,9 @@ the cursor. This is a shortcut for *--ignore-buttons* '4,5'. Defines the mouse buttons which do not unhide the cursor when clicked. You can pass multiple button numbers by separating them with ','. +*--hide-on-touch*:: +Hides the mouse cursor on touch events. + *--fork*|*-b*:: Fork unclutter to the background. diff --git a/src/event.c b/src/event.c index 19dee37..13ee773 100644 --- a/src/event.c +++ b/src/event.c @@ -96,8 +96,12 @@ static void x_check_cb(EV_P_ ev_check *w, int revents) { last_cursor_pos.y = root_y; } - /* We don't bother checking the exact event since we only select events that interest us. */ - cursor_show(); + if (config.hide_on_touch && (cookie->evtype == XI_RawTouchBegin || cookie->evtype == XI_RawTouchUpdate)) { + cursor_hide(); + } else { + /* We don't bother checking the exact event since we only select events that interest us. */ + cursor_show(); + } ev_timer_again(loop, idle_watcher); } } @@ -178,6 +182,10 @@ static void event_select_xi(void) { XISetMask(mask, XI_RawMotion); XISetMask(mask, XI_RawButtonPress); XISetMask(mask, XI_RawTouchUpdate); + if (config.hide_on_touch) { + XISetMask(mask, XI_RawTouchBegin); + XISetMask(mask, XI_RawTouchUpdate); + } masks[0].deviceid = XIAllMasterDevices; masks[0].mask_len = sizeof(mask); diff --git a/src/unclutter.c b/src/unclutter.c index a3c7aa5..b810633 100644 --- a/src/unclutter.c +++ b/src/unclutter.c @@ -38,6 +38,7 @@ Config config = { .ignore_scrolling = false, .ignore_buttons.count = 0, .ignore_buttons.buttons = NULL, + .hide_on_touch = false, .fork = false, .debug = false, .onescreen = false, @@ -96,6 +97,7 @@ static void parse_args(int argc, char *argv[]) { { "exclude-root", no_argument, 0, 0 }, { "ignore-scrolling", no_argument, 0, 0 }, { "ignore-buttons", required_argument, 0, 0 }, + { "hide-on-touch", no_argument, 0, 0 }, { "fork", no_argument, 0, 'b' }, { "version", no_argument, 0, 'v' }, { "help", no_argument, 0, 'h' }, @@ -133,6 +135,9 @@ static void parse_args(int argc, char *argv[]) { } else if (OPT_NAME_IS("exclude-root")) { config.exclude_root = true; break; + } else if (OPT_NAME_IS("hide-on-touch")) { + config.hide_on_touch = true; + break; } else if (OPT_NAME_IS("root")) { config.exclude_root = false; break; @@ -191,7 +196,7 @@ static void parse_args(int argc, char *argv[]) { } static void print_usage(char *argv[]) { - fprintf(stderr, "Usage: %s [--timeout <n>] [--jitter <radius>] [--exclude-root] [--ignore-scrolling] [--ignore-buttons <buttons>] [-b|--fork] [-v|--version] [-h|--help]", argv[0]); + fprintf(stderr, "Usage: %s [--timeout <n>] [--jitter <radius>] [--exclude-root] [--ignore-scrolling] [--ignore-buttons <buttons>] [--hide-on-touch] [-b|--fork] [-v|--version] [-h|--help]", argv[0]); fprintf(stderr, "\n"); exit(EXIT_FAILURE); } |