Skip to content

Commit

Permalink
add -s option to ignore scrolling events (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ckath authored Feb 18, 2022
1 parent 991d198 commit 3dcc448
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions xbanish.1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
.Op Fl i Ar modifier
.Op Fl m Oo Ar w Oc Ns Ar nw|ne|sw|se
.Op Fl t Ar seconds
.Op Fl s
.Sh DESCRIPTION
.Nm
hides the X11 mouse cursor when a key is pressed.
Expand Down Expand Up @@ -55,6 +56,8 @@ or current window, then move it back when showing the cursor.
Hide the mouse cursor after
.Ic seconds
have passed without mouse movement.
.It Fl s
Ignore scrolling events.
.El
.Sh SEE ALSO
.Xr XFixes 3
Expand Down
11 changes: 8 additions & 3 deletions xbanish.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static int device_change_type = -1;
static long last_device_change = -1;

static Display *dpy;
static int hiding = 0, legacy = 0, always_hide = 0;
static int hiding = 0, legacy = 0, always_hide = 0, ignore_scroll = 0;
static unsigned timeout = 0;
static unsigned char ignored;
static XSyncCounter idler_counter = 0;
Expand Down Expand Up @@ -92,7 +92,7 @@ main(int argc, char *argv[])
{"all", -1},
};

while ((ch = getopt(argc, argv, "adi:m:t:")) != -1)
while ((ch = getopt(argc, argv, "adi:m:t:s")) != -1)
switch (ch) {
case 'a':
always_hide = 1;
Expand Down Expand Up @@ -131,6 +131,8 @@ main(int argc, char *argv[])
break;
case 't':
timeout = strtoul(optarg, NULL, 0);
case 's':
ignore_scroll = 1;
break;
default:
usage(argv[0]);
Expand Down Expand Up @@ -254,6 +256,9 @@ main(int argc, char *argv[])
switch (xie->evtype) {
case XI_RawMotion:
case XI_RawButtonPress:
if (ignore_scroll && ((xie->detail >= 4 && xie->detail <= 7) ||
xie->event_x == xie->event_y))
break;
if (!always_hide)
show_cursor();
break;
Expand Down Expand Up @@ -574,7 +579,7 @@ void
usage(char *progname)
{
fprintf(stderr, "usage: %s [-a] [-d] [-i mod] [-m [w]nw|ne|sw|se] "
"[-t seconds]\n", progname);
"[-t seconds] [-s]\n", progname);
exit(1);
}

Expand Down

0 comments on commit 3dcc448

Please sign in to comment.