Hello community,

here is the log from the commit of package xbanish for openSUSE:Factory checked 
in at 2020-08-18 12:01:49
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/xbanish (Old)
 and      /work/SRC/openSUSE:Factory/.xbanish.new.3399 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "xbanish"

Tue Aug 18 12:01:49 2020 rev:5 rq:827497 version:1.7

Changes:
--------
--- /work/SRC/openSUSE:Factory/xbanish/xbanish.changes  2018-11-13 
17:53:45.031329957 +0100
+++ /work/SRC/openSUSE:Factory/.xbanish.new.3399/xbanish.changes        
2020-08-18 12:03:14.315425072 +0200
@@ -1,0 +2,7 @@
+Mon Aug 17 15:33:56 UTC 2020 - Dirk Mueller <[email protected]>
+
+- update to 1.7:
+  * build system fixes
+  * various new options added 
+
+-------------------------------------------------------------------

Old:
----
  xbanish-1.6.tar.gz

New:
----
  xbanish-1.7.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ xbanish.spec ++++++
--- /var/tmp/diff_new_pack.kUoxAC/_old  2020-08-18 12:03:15.827425278 +0200
+++ /var/tmp/diff_new_pack.kUoxAC/_new  2020-08-18 12:03:15.831425279 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package xbanish
 #
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
 
 
 Name:           xbanish
-Version:        1.6
+Version:        1.7
 Release:        0
 Summary:        Program to hide the mouse cursor when typing
 License:        BSD-3-Clause

++++++ xbanish-1.6.tar.gz -> xbanish-1.7.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xbanish-1.6/Makefile new/xbanish-1.7/Makefile
--- old/xbanish-1.6/Makefile    2018-08-31 17:34:12.000000000 +0200
+++ new/xbanish-1.7/Makefile    2020-05-09 04:56:59.000000000 +0200
@@ -1,9 +1,8 @@
 # vim:ts=8
 
-VERS   := 1.6
-
 CC     ?= cc
-CFLAGS ?= -O2 -Wall -Wunused -Wmissing-prototypes -Wstrict-prototypes
+CFLAGS ?= -O2
+CFLAGS += -Wall -Wunused -Wmissing-prototypes -Wstrict-prototypes -Wunused
 
 PREFIX ?= /usr/local
 BINDIR ?= $(PREFIX)/bin
@@ -37,11 +36,4 @@
 clean:
        rm -f $(PROG) $(OBJS)
 
-release: all
-       @mkdir $(PROG)-${VERS}
-       @cp Makefile *.c $(PROG)-$(VERS)/
-       @tar -czf ../$(PROG)-$(VERS).tar.gz $(PROG)-$(VERS)
-       @rm -rf $(PROG)-$(VERS)/
-       @echo "made release ${VERS}"
-
 .PHONY: all install clean
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xbanish-1.6/xbanish.1 new/xbanish-1.7/xbanish.1
--- old/xbanish-1.6/xbanish.1   2018-08-31 17:34:12.000000000 +0200
+++ new/xbanish-1.7/xbanish.1   2020-05-09 04:56:59.000000000 +0200
@@ -1,4 +1,4 @@
-.Dd $Mdocdate: June 10 2015$
+.Dd $Mdocdate: September 16 2019$
 .Dt XBANISH 1
 .Os
 .Sh NAME
@@ -6,8 +6,10 @@
 .Nd hide the X11 mouse cursor when a key is pressed
 .Sh SYNOPSIS
 .Nm
+.Op Fl a
 .Op Fl d
 .Op Fl i Ar modifier
+.Op Fl m Ar nw|ne|sw|se
 .Sh DESCRIPTION
 .Nm
 hides the X11 mouse cursor when a key is pressed.
@@ -19,6 +21,10 @@
 but the effect is global in the X11 session.
 .Sh OPTIONS
 .Bl -tag -width Ds
+.It Fl a
+Always keep mouse cursor hidden while
+.Nm
+is running.
 .It Fl d
 Print debugging messages to stdout.
 .It Fl i Ar modifier
@@ -40,6 +46,9 @@
 (Super, Windows, or Command), and
 .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.
 .El
 .Sh SEE ALSO
 .Xr XFixes 3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xbanish-1.6/xbanish.c new/xbanish-1.7/xbanish.c
--- old/xbanish-1.6/xbanish.c   2018-08-31 17:34:12.000000000 +0200
+++ new/xbanish-1.7/xbanish.c   2020-05-09 04:56:59.000000000 +0200
@@ -41,9 +41,10 @@
 
 void hide_cursor(void);
 void show_cursor(void);
+void snoop_root(void);
 int snoop_xinput(Window);
 void snoop_legacy(Window);
-void usage(void);
+void usage(char *);
 int swallow_error(Display *, XErrorEvent *);
 
 /* xinput event type ids to be filled in later */
@@ -52,13 +53,24 @@
 static int key_press_type = -1;
 static int key_release_type = -1;
 static int motion_type = -1;
-
-extern char *__progname;
+static int device_change_type = -1;
+static long last_device_change = -1;
 
 static Display *dpy;
-static int debug = 0, hiding = 0, legacy = 0;
+static int hiding = 0, legacy = 0, always_hide = 0;
 static unsigned char ignored;
 
+static int debug = 0;
+#define DPRINTF(x) { if (debug) { printf x; } };
+
+static int move = 0, move_x, move_y;
+enum move_types {
+       MOVE_NW = 1,
+       MOVE_NE,
+       MOVE_SW,
+       MOVE_SE,
+};
+
 int
 main(int argc, char *argv[])
 {
@@ -76,8 +88,11 @@
                {"mod4", Mod4Mask}, {"mod5", Mod5Mask}
        };
 
-       while ((ch = getopt(argc, argv, "di:")) != -1)
+       while ((ch = getopt(argc, argv, "adi:m:")) != -1)
                switch (ch) {
+               case 'a':
+                       always_hide = 1;
+                       break;
                case 'd':
                        debug = 1;
                        break;
@@ -88,8 +103,22 @@
                                        ignored |= mods[i].mask;
 
                        break;
+               case 'm':
+                       if (strcmp(optarg, "nw") == 0)
+                               move = MOVE_NW;
+                       else if (strcmp(optarg, "ne") == 0)
+                               move = MOVE_NE;
+                       else if (strcmp(optarg, "sw") == 0)
+                               move = MOVE_SW;
+                       else if (strcmp(optarg, "se") == 0)
+                               move = MOVE_SE;
+                       else {
+                               warnx("invalid '-m' argument");
+                               usage(argv[0]);
+                       }
+                       break;
                default:
-                       usage();
+                       usage(argv[0]);
                }
 
        argc -= optind;
@@ -105,14 +134,10 @@
 
        XSetErrorHandler(swallow_error);
 
-       if (snoop_xinput(DefaultRootWindow(dpy)) == 0) {
-               if (debug)
-                       warn("no XInput devices found, using legacy "
-                           "snooping");
+       snoop_root();
 
-               legacy = 1;
-               snoop_legacy(DefaultRootWindow(dpy));
-       }
+       if (always_hide)
+               hide_cursor();
 
        for (;;) {
                cookie = &e.xcookie;
@@ -127,6 +152,15 @@
                else if (e.type == button_press_type ||
                    e.type == button_release_type)
                        etype = ButtonRelease;
+               else if (e.type == device_change_type) {
+                       XDevicePresenceNotifyEvent *xdpe =
+                           (XDevicePresenceNotifyEvent *)&e;
+                       if (last_device_change == xdpe->serial)
+                               continue;
+                       snoop_root();
+                       last_device_change = xdpe->serial;
+                       continue;
+               }
 
                switch (etype) {
                case KeyRelease:
@@ -152,10 +186,7 @@
                                }
 
                                if (state & ignored) {
-                                       if (debug) {
-                                               printf("ignoring key %d\n",
-                                                   state);
-                                       }
+                                       DPRINTF(("ignoring key %d\n", state));
                                        break;
                                }
                        }
@@ -165,14 +196,13 @@
 
                case ButtonRelease:
                case MotionNotify:
-                       show_cursor();
+                       if (!always_hide)
+                               show_cursor();
                        break;
 
                case CreateNotify:
                        if (legacy) {
-                               if (debug)
-                                       printf("created new window, "
-                                           "snooping on it\n");
+                               DPRINTF(("new window, snooping on it\n"));
 
                                /* not sure why snooping directly on the window
                                 * doesn't work, so snoop on all windows from
@@ -189,24 +219,23 @@
                        switch (xie->evtype) {
                        case XI_RawMotion:
                        case XI_RawButtonPress:
-                               show_cursor();
+                               if (!always_hide)
+                                       show_cursor();
                                break;
 
                        case XI_RawButtonRelease:
                                break;
 
                        default:
-                               if (debug)
-                                       printf("unknown XI event type %d\n",
-                                           xie->evtype);
+                               DPRINTF(("unknown XI event type %d\n",
+                                   xie->evtype));
                        }
 
                        XFreeEventData(dpy, cookie);
                        break;
 
                default:
-                       if (debug)
-                               printf("unknown event type %d\n", e.type);
+                       DPRINTF(("unknown event type %d\n", e.type));
                }
        }
 }
@@ -214,26 +243,80 @@
 void
 hide_cursor(void)
 {
-       if (debug)
-               printf("keystroke, %shiding cursor\n",
-                   (hiding ? "already " : ""));
-
-       if (!hiding) {
-               XFixesHideCursor(dpy, DefaultRootWindow(dpy));
-               hiding = 1;
+       Window win;
+       int x, y, h, w, junk;
+       unsigned int ujunk;
+
+       DPRINTF(("keystroke, %shiding cursor\n", (hiding ? "already " : "")));
+
+       if (hiding)
+               return;
+
+       if (move) {
+               if (XQueryPointer(dpy, DefaultRootWindow(dpy),
+                   &win, &win, &x, &y, &junk, &junk, &ujunk)) {
+                       move_x = x;
+                       move_y = y;
+
+                       h = XHeightOfScreen(DefaultScreenOfDisplay(dpy));
+                       w = XWidthOfScreen(DefaultScreenOfDisplay(dpy));
+
+                       switch (move) {
+                       case MOVE_NW:
+                               x = 0;
+                               y = 0;
+                               break;
+                       case MOVE_NE:
+                               x = w;
+                               y = 0;
+                               break;
+                       case MOVE_SW:
+                               x = 0;
+                               y = h;
+                               break;
+                       case MOVE_SE:
+                               x = w;
+                               y = h;
+                               break;
+                       }
+
+                       XWarpPointer(dpy, None, DefaultRootWindow(dpy),
+                           0, 0, 0, 0, x, y);
+               } else {
+                       move_x = -1;
+                       move_y = -1;
+                       warn("failed finding cursor coordinates");
+               }
        }
+
+       XFixesHideCursor(dpy, DefaultRootWindow(dpy));
+       hiding = 1;
 }
 
 void
 show_cursor(void)
 {
-       if (debug)
-               printf("mouse moved, %sunhiding cursor\n",
-                   (hiding ? "" : "already "));
-
-       if (hiding) {
-               XFixesShowCursor(dpy, DefaultRootWindow(dpy));
-               hiding = 0;
+       DPRINTF(("mouse moved, %sunhiding cursor\n",
+           (hiding ? "" : "already ")));
+
+       if (!hiding)
+               return;
+
+       if (move && move_x != -1 && move_y != -1)
+               XWarpPointer(dpy, None, DefaultRootWindow(dpy), 0, 0, 0, 0,
+                   move_x, move_y);
+
+       XFixesShowCursor(dpy, DefaultRootWindow(dpy));
+       hiding = 0;
+}
+
+void
+snoop_root(void)
+{
+       if (snoop_xinput(DefaultRootWindow(dpy)) == 0) {
+               DPRINTF(("no XInput devices found, using legacy snooping"));
+               legacy = 1;
+               snoop_legacy(DefaultRootWindow(dpy));
        }
 }
 
@@ -244,16 +327,15 @@
        int major, minor, rc, rawmotion = 0;
        int ev = 0;
        unsigned char mask[(XI_LASTEVENT + 7)/8];
-       XDeviceInfo *devinfo;
+       XDeviceInfo *devinfo = NULL;
        XInputClassInfo *ici;
        XDevice *device;
        XIEventMask evmasks[1];
+       XEventClass class_presence;
 
        if (!XQueryExtension(dpy, "XInputExtension", &opcode, &event, &error)) {
-               if (debug)
-                       warn("XInput extension not available");
-
-               return (0);
+               DPRINTF(("XInput extension not available"));
+               return 0;
        }
 
        /*
@@ -279,8 +361,7 @@
 
                rawmotion = 1;
 
-               if (debug)
-                       printf("using xinput2 raw motion events\n");
+               DPRINTF(("using xinput2 raw motion events\n"));
        }
 
        devinfo = XListInputDevices(dpy, &numdevs);
@@ -297,10 +378,9 @@
                ici++, j++) {
                        switch (ici->input_class) {
                        case KeyClass:
-                               if (debug)
-                                       printf("attaching to keyboard device "
-                                           "%s (use %d)\n", devinfo[i].name,
-                                           devinfo[i].use);
+                               DPRINTF(("attaching to keyboard device %s "
+                                   "(use %d)\n", devinfo[i].name,
+                                   devinfo[i].use));
 
                                DeviceKeyPress(device, key_press_type,
                                    event_list[ev]); ev++;
@@ -312,10 +392,9 @@
                                if (rawmotion)
                                        continue;
 
-                               if (debug)
-                                       printf("attaching to buttoned device "
-                                           "%s (use %d)\n", devinfo[i].name,
-                                           devinfo[i].use);
+                               DPRINTF(("attaching to buttoned device %s "
+                                   "(use %d)\n", devinfo[i].name,
+                                   devinfo[i].use));
 
                                DeviceButtonPress(device, button_press_type,
                                    event_list[ev]); ev++;
@@ -327,10 +406,9 @@
                                if (rawmotion)
                                        continue;
 
-                               if (debug)
-                                       printf("attaching to pointing device "
-                                           "%s (use %d)\n", devinfo[i].name,
-                                           devinfo[i].use);
+                               DPRINTF(("attaching to pointing device %s "
+                                   "(use %d)\n", devinfo[i].name,
+                                   devinfo[i].use));
 
                                DeviceMotionNotify(device, motion_type,
                                    event_list[ev]); ev++;
@@ -338,13 +416,27 @@
                        }
                }
 
+               XCloseDevice(dpy, device);
+
                if (XSelectExtensionEvent(dpy, win, event_list, ev)) {
                        warn("error selecting extension events");
-                       return (0);
+                       ev = 0;
+                       goto done;
                }
        }
 
-       return (ev);
+       DevicePresence(dpy, device_change_type, class_presence);
+       if (XSelectExtensionEvent(dpy, win, &class_presence, 1)) {
+               warn("error selecting extension events");
+               ev = 0;
+               goto done;
+       }
+
+done:
+       if (devinfo != NULL)
+          XFreeDeviceList(devinfo);
+
+       return ev;
 }
 
 void
@@ -384,9 +476,10 @@
 }
 
 void
-usage(void)
+usage(char *progname)
 {
-       fprintf(stderr, "usage: %s [-d] [-i mod]\n", __progname);
+       fprintf(stderr, "usage: %s [-a] [-d] [-i mod] [-m nw|ne|sw|se]\n",
+           progname);
        exit(1);
 }
 


Reply via email to