Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package xbanish for openSUSE:Factory checked in at 2022-04-22 21:55:02 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/xbanish (Old) and /work/SRC/openSUSE:Factory/.xbanish.new.1538 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "xbanish" Fri Apr 22 21:55:02 2022 rev:6 rq:972172 version:1.8 Changes: -------- --- /work/SRC/openSUSE:Factory/xbanish/xbanish.changes 2020-08-18 12:03:14.315425072 +0200 +++ /work/SRC/openSUSE:Factory/.xbanish.new.1538/xbanish.changes 2022-04-22 21:56:15.886943453 +0200 @@ -1,0 +2,11 @@ +Fri Apr 22 01:47:54 UTC 2022 - Ferdinand Thiessen <[email protected]> + +- Update to 1.8 + * Switch to ISC license + * add -s option to ignore scrolling events + * add -t option to hide the mouse cursor after x seconds have + passed without mouse movement. + * add -m w* options to move the cursor in the current window + * add 'all' modifier to -i option to ignore all modifiers + +------------------------------------------------------------------- Old: ---- xbanish-1.7.tar.gz New: ---- xbanish-1.8.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ xbanish.spec ++++++ --- /var/tmp/diff_new_pack.eyxR7w/_old 2022-04-22 21:56:16.370944005 +0200 +++ /var/tmp/diff_new_pack.eyxR7w/_new 2022-04-22 21:56:16.378944014 +0200 @@ -1,7 +1,7 @@ # # spec file for package xbanish # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,10 +17,10 @@ Name: xbanish -Version: 1.7 +Version: 1.8 Release: 0 Summary: Program to hide the mouse cursor when typing -License: BSD-3-Clause +License: ISC Group: System/X11/Utilities URL: https://github.com/jcs/xbanish Source: https://github.com/jcs/xbanish/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz @@ -47,12 +47,13 @@ %build export CFLAGS="%{optflags}" -make %{?_smp_mflags} +%make_build %install %make_install PREFIX="%{_prefix}" MANDIR="%{_mandir}/man1" %files +%license LICENSE %doc README.md %{_bindir}/%{name} %{_mandir}/man1/%{name}.1%{?ext_man} ++++++ xbanish-1.7.tar.gz -> xbanish-1.8.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xbanish-1.7/LICENSE new/xbanish-1.8/LICENSE --- old/xbanish-1.7/LICENSE 1970-01-01 01:00:00.000000000 +0100 +++ new/xbanish-1.8/LICENSE 2022-02-18 16:02:34.000000000 +0100 @@ -0,0 +1,14 @@ +xbanish +Copyright (c) 2013-2021 joshua stein <[email protected]> + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xbanish-1.7/Makefile new/xbanish-1.8/Makefile --- old/xbanish-1.7/Makefile 2020-05-09 04:56:59.000000000 +0200 +++ new/xbanish-1.8/Makefile 2022-02-18 16:02:34.000000000 +0100 @@ -14,7 +14,7 @@ X11BASE ?= /usr/X11R6 INCLUDES?= -I$(X11BASE)/include LDPATH ?= -L$(X11BASE)/lib -LIBS += -lX11 -lXfixes -lXi +LIBS += -lX11 -lXfixes -lXi -lXext PROG = xbanish OBJS = xbanish.o diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xbanish-1.7/README.md new/xbanish-1.8/README.md --- old/xbanish-1.7/README.md 2020-05-09 04:56:59.000000000 +0200 +++ new/xbanish-1.8/README.md 2022-02-18 16:02:34.000000000 +0100 @@ -7,8 +7,7 @@ unclutter's -keystroke mode is supposed to do this, but it's [broken](https://bugs.launchpad.net/ubuntu/+source/unclutter/+bug/54148). -I looked into fixing it, but the unclutter source code is terrible, so I wrote -xbanish. +I looked into fixing it, but unclutter was abandoned so I wrote xbanish. The name comes from [ratpoison's](https://www.nongnu.org/ratpoison/) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xbanish-1.7/xbanish.1 new/xbanish-1.8/xbanish.1 --- old/xbanish-1.7/xbanish.1 2020-05-09 04:56:59.000000000 +0200 +++ new/xbanish-1.8/xbanish.1 2022-02-18 16:02:34.000000000 +0100 @@ -1,4 +1,4 @@ -.Dd $Mdocdate: September 16 2019$ +.Dd $Mdocdate: March 13 2020$ .Dt XBANISH 1 .Os .Sh NAME @@ -9,7 +9,9 @@ .Op Fl a .Op Fl d .Op Fl i Ar modifier -.Op Fl m Ar nw|ne|sw|se +.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. @@ -43,12 +45,19 @@ .Ic mod3 (Hyper), .Ic mod4 -(Super, Windows, or Command), and +(Super, Windows, or Command), .Ic mod5 -(ISO Level 3 Shift). -.It Fl m Ar nw|ne|sw|se -When hiding the mouse cursor, move it to this corner of the screen, -then move it back when showing the cursor. +(ISO Level 3 Shift), and +.Ic all +.It Fl m Oo Ar w Oc Ns Ar nw|ne|sw|se +When hiding the mouse cursor, move it to this corner of the screen +or current window, then move it back when showing the cursor. +.It Fl t Ar seconds +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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xbanish-1.7/xbanish.c new/xbanish-1.8/xbanish.c --- old/xbanish-1.7/xbanish.c 2020-05-09 04:56:59.000000000 +0200 +++ new/xbanish-1.8/xbanish.c 2022-02-18 16:02:34.000000000 +0100 @@ -1,32 +1,22 @@ /* * xbanish - * Copyright (c) 2013-2015 joshua stein <[email protected]> + * Copyright (c) 2013-2021 joshua stein <[email protected]> * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <err.h> +#include <signal.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -35,6 +25,7 @@ #include <X11/X.h> #include <X11/Xlib.h> #include <X11/Intrinsic.h> +#include <X11/extensions/sync.h> #include <X11/extensions/Xfixes.h> #include <X11/extensions/XInput.h> #include <X11/extensions/XInput2.h> @@ -44,6 +35,7 @@ void snoop_root(void); int snoop_xinput(Window); void snoop_legacy(Window); +void set_alarm(XSyncAlarm *, XSyncTestType); void usage(char *); int swallow_error(Display *, XErrorEvent *); @@ -57,8 +49,11 @@ 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; +static XSyncAlarm idle_alarm = None; static int debug = 0; #define DPRINTF(x) { if (debug) { printf x; } }; @@ -69,6 +64,10 @@ MOVE_NE, MOVE_SW, MOVE_SE, + MOVE_WIN_NW, + MOVE_WIN_NE, + MOVE_WIN_SW, + MOVE_WIN_SE, }; int @@ -76,7 +75,11 @@ { int ch, i; XEvent e; + XSyncAlarmNotifyEvent *alarm_e; XGenericEventCookie *cookie; + XSyncSystemCounter *counters; + int sync_event, error; + int major, minor, ncounters; struct mod_lookup { char *name; @@ -85,10 +88,11 @@ {"shift", ShiftMask}, {"lock", LockMask}, {"control", ControlMask}, {"mod1", Mod1Mask}, {"mod2", Mod2Mask}, {"mod3", Mod3Mask}, - {"mod4", Mod4Mask}, {"mod5", Mod5Mask} + {"mod4", Mod4Mask}, {"mod5", Mod5Mask}, + {"all", -1}, }; - while ((ch = getopt(argc, argv, "adi:m:")) != -1) + while ((ch = getopt(argc, argv, "adi:m:t:s")) != -1) switch (ch) { case 'a': always_hide = 1; @@ -112,11 +116,24 @@ move = MOVE_SW; else if (strcmp(optarg, "se") == 0) move = MOVE_SE; + else if (strcmp(optarg, "wnw") == 0) + move = MOVE_WIN_NW; + else if (strcmp(optarg, "wne") == 0) + move = MOVE_WIN_NE; + else if (strcmp(optarg, "wsw") == 0) + move = MOVE_WIN_SW; + else if (strcmp(optarg, "wse") == 0) + move = MOVE_WIN_SE; else { warnx("invalid '-m' argument"); usage(argv[0]); } break; + case 't': + timeout = strtoul(optarg, NULL, 0); + case 's': + ignore_scroll = 1; + break; default: usage(argv[0]); } @@ -139,6 +156,26 @@ if (always_hide) hide_cursor(); + /* required setup for the xsync alarms used by timeout */ + if (timeout) { + if (XSyncQueryExtension(dpy, &sync_event, &error) != True) + errx(1, "no sync extension available"); + + XSyncInitialize(dpy, &major, &minor); + + counters = XSyncListSystemCounters(dpy, &ncounters); + for (i = 0; i < ncounters; i++) { + if (!strcmp(counters[i].name, "IDLETIME")) { + idler_counter = counters[i].counter; + break; + } + } + XSyncFreeSystemCounterList(counters); + + if (!idler_counter) + errx(1, "no idle counter"); + } + for (;;) { cookie = &e.xcookie; XNextEvent(dpy, &e); @@ -219,6 +256,9 @@ 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; @@ -235,7 +275,19 @@ break; default: - DPRINTF(("unknown event type %d\n", e.type)); + if (!timeout || + e.type != (sync_event + XSyncAlarmNotify)) { + DPRINTF(("unknown event type %d\n", e.type)); + break; + } + + alarm_e = (XSyncAlarmNotifyEvent *)&e; + if (alarm_e->alarm == idle_alarm) { + DPRINTF(("idle counter reached %dms, hiding " + "cursor\n", + XSyncValueLow32(alarm_e->counter_value))); + hide_cursor(); + } } } } @@ -244,6 +296,7 @@ hide_cursor(void) { Window win; + XWindowAttributes attrs; int x, y, h, w, junk; unsigned int ujunk; @@ -258,6 +311,8 @@ move_x = x; move_y = y; + XGetWindowAttributes(dpy, win, &attrs); + h = XHeightOfScreen(DefaultScreenOfDisplay(dpy)); w = XWidthOfScreen(DefaultScreenOfDisplay(dpy)); @@ -278,6 +333,22 @@ x = w; y = h; break; + case MOVE_WIN_NW: + x = attrs.x; + y = attrs.y; + break; + case MOVE_WIN_NE: + x = attrs.x + attrs.width; + y = attrs.y; + break; + case MOVE_WIN_SW: + x = attrs.x; + y = attrs.x + attrs.height; + break; + case MOVE_WIN_SE: + x = attrs.x + attrs.width; + y = attrs.x + attrs.height; + break; } XWarpPointer(dpy, None, DefaultRootWindow(dpy), @@ -299,6 +370,11 @@ DPRINTF(("mouse moved, %sunhiding cursor\n", (hiding ? "" : "already "))); + if (timeout) { + DPRINTF(("(re)setting timeout of %us\n", timeout)); + set_alarm(&idle_alarm, XSyncPositiveComparison); + } + if (!hiding) return; @@ -476,10 +552,34 @@ } void +set_alarm(XSyncAlarm *alarm, XSyncTestType test) +{ + XSyncAlarmAttributes attr; + XSyncValue value; + unsigned int flags; + + XSyncQueryCounter(dpy, idler_counter, &value); + + attr.trigger.counter = idler_counter; + attr.trigger.test_type = test; + attr.trigger.value_type = XSyncRelative; + XSyncIntsToValue(&attr.trigger.wait_value, timeout * 1000, + (unsigned long)(timeout * 1000) >> 32); + XSyncIntToValue(&attr.delta, 0); + + flags = XSyncCACounter | XSyncCATestType | XSyncCAValue | XSyncCADelta; + + if (*alarm) + XSyncDestroyAlarm(dpy, *alarm); + + *alarm = XSyncCreateAlarm(dpy, flags, &attr); +} + +void usage(char *progname) { - fprintf(stderr, "usage: %s [-a] [-d] [-i mod] [-m nw|ne|sw|se]\n", - progname); + fprintf(stderr, "usage: %s [-a] [-d] [-i mod] [-m [w]nw|ne|sw|se] " + "[-t seconds] [-s]\n", progname); exit(1); } @@ -489,9 +589,10 @@ if (e->error_code == BadWindow) /* no biggie */ return 0; - else if (e->error_code & FirstExtensionError) + + if (e->error_code & FirstExtensionError) /* error requesting input on a particular xinput device */ return 0; - else - errx(1, "got X error %d", e->error_code); + + errx(1, "got X error %d", e->error_code); }
