Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add touch option to hide cursor on any touch input #52

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion man/unclutter-xfixes.man
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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.

Expand Down
12 changes: 10 additions & 2 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion src/unclutter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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' },
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down