Skip to content

Commit 7745a48

Browse files
authored
Merge pull request #15 from Airblader/feature-13
Added new option --ignore-scrolling.
2 parents 7e341bb + f9d71fc commit 7745a48

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

include/types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ typedef struct Config {
55
long timeout;
66
long jitter;
77
bool exclude_root;
8+
bool ignore_scrolling;
89
bool fork;
910
bool debug;
1011
} Config;

man/unclutter-xfixes.man

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ unclutter-xfixes - rewrite of unclutter using the X11-Xfixes extension
88

99
== SYNOPSIS
1010

11-
unclutter [--timeout <n>] [--jitter <radius>] [--exclude-root] [--fork|-b] [--help|-h] [--version|-v]
11+
unclutter [--timeout <n>] [--jitter <radius>] [--exclude-root] [--ignore-scrolling] [--fork|-b] [--help|-h] [--version|-v]
1212

1313
== OPTIONS
1414

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

27+
--ignore-scrolling::
28+
Ignore mouse scroll events (buttons 4 and 5) so that scrolling doesn't unhide
29+
the cursor.
30+
2731
--fork|-b::
2832
Fork unclutter to the background.
2933

src/event.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@ static void x_check_cb(EV_P_ ev_check *w, int revents) {
5656
continue;
5757
}
5858

59-
/* We don't actually need the data, so get rid of it. */
59+
if (config.ignore_scrolling && cookie->evtype == XI_RawButtonPress) {
60+
const XIRawEvent *data = (const XIRawEvent *) cookie->data;
61+
if (data->detail == 4 || data->detail == 5) {
62+
XFreeEventData(display, cookie);
63+
continue;
64+
}
65+
}
66+
6067
XFreeEventData(display, cookie);
6168

6269
if (config.jitter > 0 && cookie->evtype == XI_RawMotion) {

src/unclutter.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Config config = {
2424
.timeout = 5,
2525
.jitter = 0,
2626
.exclude_root = false,
27+
.ignore_scrolling = false,
2728
.fork = false,
2829
.debug = false
2930
};
@@ -64,6 +65,7 @@ static void parse_args(int argc, char *argv[]) {
6465
{ "timeout", required_argument, 0, 0 },
6566
{ "jitter", required_argument, 0, 0 },
6667
{ "exclude-root", no_argument, 0, 0 },
68+
{ "ignore-scrolling", no_argument, 0, 0 },
6769
{ "fork", no_argument, 0, 'b' },
6870
{ "version", no_argument, 0, 'v' },
6971
{ "help", no_argument, 0, 'h' },
@@ -94,6 +96,9 @@ static void parse_args(int argc, char *argv[]) {
9496
} else if (strcmp(long_options[opt_index].name, "exclude-root") == 0) {
9597
config.exclude_root = true;
9698
break;
99+
} else if (strcmp(long_options[opt_index].name, "ignore-scrolling") == 0) {
100+
config.ignore_scrolling = true;
101+
break;
97102
}
98103

99104
print_usage(argv);
@@ -118,7 +123,7 @@ static void parse_args(int argc, char *argv[]) {
118123
}
119124

120125
static void print_usage(char *argv[]) {
121-
fprintf(stderr, "Usage: %s [--timeout <n>] [--jitter <radius>] [--exclude-root] [-b|--fork] [-v|--version] [-h|--help]", argv[0]);
126+
fprintf(stderr, "Usage: %s [--timeout <n>] [--jitter <radius>] [--exclude-root] [--ignore-scrolling] [-b|--fork] [-v|--version] [-h|--help]", argv[0]);
122127
fprintf(stderr, "\n");
123128
exit(EXIT_FAILURE);
124129
}

0 commit comments

Comments
 (0)