Skip to content

Commit

Permalink
Merge pull request #15 from Airblader/feature-13
Browse files Browse the repository at this point in the history
Added new option --ignore-scrolling.
  • Loading branch information
Airblader authored Aug 2, 2016
2 parents 7e341bb + f9d71fc commit 7745a48
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ typedef struct Config {
long timeout;
long jitter;
bool exclude_root;
bool ignore_scrolling;
bool fork;
bool debug;
} Config;
Expand Down
6 changes: 5 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 <n>] [--jitter <radius>] [--exclude-root] [--fork|-b] [--help|-h] [--version|-v]
unclutter [--timeout <n>] [--jitter <radius>] [--exclude-root] [--ignore-scrolling] [--fork|-b] [--help|-h] [--version|-v]

== OPTIONS

Expand All @@ -24,6 +24,10 @@ Don't hide the mouse cursor if it is idling over the root window and not an
actual window since in this case it isn't obscuring anything important, but
rather just the desktop background.

--ignore-scrolling::
Ignore mouse scroll events (buttons 4 and 5) so that scrolling doesn't unhide
the cursor.

--fork|-b::
Fork unclutter to the background.

Expand Down
9 changes: 8 additions & 1 deletion src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ static void x_check_cb(EV_P_ ev_check *w, int revents) {
continue;
}

/* We don't actually need the data, so get rid of it. */
if (config.ignore_scrolling && cookie->evtype == XI_RawButtonPress) {
const XIRawEvent *data = (const XIRawEvent *) cookie->data;
if (data->detail == 4 || data->detail == 5) {
XFreeEventData(display, cookie);
continue;
}
}

XFreeEventData(display, cookie);

if (config.jitter > 0 && cookie->evtype == XI_RawMotion) {
Expand Down
7 changes: 6 additions & 1 deletion src/unclutter.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Config config = {
.timeout = 5,
.jitter = 0,
.exclude_root = false,
.ignore_scrolling = false,
.fork = false,
.debug = false
};
Expand Down Expand Up @@ -64,6 +65,7 @@ static void parse_args(int argc, char *argv[]) {
{ "timeout", required_argument, 0, 0 },
{ "jitter", required_argument, 0, 0 },
{ "exclude-root", no_argument, 0, 0 },
{ "ignore-scrolling", no_argument, 0, 0 },
{ "fork", no_argument, 0, 'b' },
{ "version", no_argument, 0, 'v' },
{ "help", no_argument, 0, 'h' },
Expand Down Expand Up @@ -94,6 +96,9 @@ static void parse_args(int argc, char *argv[]) {
} else if (strcmp(long_options[opt_index].name, "exclude-root") == 0) {
config.exclude_root = true;
break;
} else if (strcmp(long_options[opt_index].name, "ignore-scrolling") == 0) {
config.ignore_scrolling = true;
break;
}

print_usage(argv);
Expand All @@ -118,7 +123,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] [-b|--fork] [-v|--version] [-h|--help]", argv[0]);
fprintf(stderr, "Usage: %s [--timeout <n>] [--jitter <radius>] [--exclude-root] [--ignore-scrolling] [-b|--fork] [-v|--version] [-h|--help]", argv[0]);
fprintf(stderr, "\n");
exit(EXIT_FAILURE);
}
Expand Down

0 comments on commit 7745a48

Please sign in to comment.