From e82d467276ee1190767e9f19d0ccb6cc463c555d Mon Sep 17 00:00:00 2001 From: Yigit Colakoglu Date: Sun, 11 Apr 2021 09:31:31 +0300 Subject: [PATCH] Grammarous added to vim --- .config/vim/plugin/grammarous.vim | 15 ++ .config/vim/plugin/languagetool.vim | 1 - .config/vim/plugin/plugins.vim | 2 +- .config/zsh/aliases | 2 + .local/src/xbanish/.gitignore | 2 + .local/src/xbanish/LICENSE | 14 -- .local/src/xbanish/Makefile | 12 +- .local/src/xbanish/xbanish | Bin 27016 -> 22504 bytes .local/src/xbanish/xbanish.1 | 41 ++-- .local/src/xbanish/xbanish.c | 306 ++++++++++++---------------- 10 files changed, 169 insertions(+), 226 deletions(-) create mode 100644 .config/vim/plugin/grammarous.vim delete mode 100644 .config/vim/plugin/languagetool.vim create mode 100644 .local/src/xbanish/.gitignore delete mode 100644 .local/src/xbanish/LICENSE diff --git a/.config/vim/plugin/grammarous.vim b/.config/vim/plugin/grammarous.vim new file mode 100644 index 00000000..097c7ab9 --- /dev/null +++ b/.config/vim/plugin/grammarous.vim @@ -0,0 +1,15 @@ +let g:languagetool_cmd='/usr/bin/languagetool' +let g:grammarous#default_comments_only_filetypes = { + \ '*' : 1, 'help' : 0, 'markdown' : 0, 'latex': 0, + \ } + +let g:grammarous#enabled_categories = {'latex' : ['PUNCTUATION', + \'COLLOQUIALISMS', 'COMPOUNDING', 'CONFUSED_WORDS', 'FALSE_FRIENDS', + \ 'GENDER_NEUTRALITY', 'GRAMMAR', 'MISC', 'PLAIN_ENGLISH', + \ 'PUNCTUATION', 'REDUNDANCY', 'REGIONALISMS', 'REPETITIONS', + \ 'SEMANTICS', 'STYLE', 'TYPOGRAPHY', + \ 'TYPOS', 'WIKIPEDIA'], 'markdown' : ['PUNCTUATION', + \'COLLOQUIALISMS', 'COMPOUNDING', 'CONFUSED_WORDS', 'FALSE_FRIENDS', + \ 'GENDER_NEUTRALITY', 'GRAMMAR', 'MISC', 'PLAIN_ENGLISH', + \ 'PUNCTUATION', 'REDUNDANCY', 'REGIONALISMS', 'REPETITIONS', + \ 'SEMANTICS', 'STYLE', 'TYPOGRAPHY',]} diff --git a/.config/vim/plugin/languagetool.vim b/.config/vim/plugin/languagetool.vim deleted file mode 100644 index 4ba64592..00000000 --- a/.config/vim/plugin/languagetool.vim +++ /dev/null @@ -1 +0,0 @@ -let g:languagetool_cmd='/usr/bin/languagetool' diff --git a/.config/vim/plugin/plugins.vim b/.config/vim/plugin/plugins.vim index 62c85902..cd20626c 100644 --- a/.config/vim/plugin/plugins.vim +++ b/.config/vim/plugin/plugins.vim @@ -23,7 +23,7 @@ Plug 'blarghmatey/split-expander' Plug 'farmergreg/vim-lastplace' Plug 'jlanzarotta/bufexplorer' Plug 'jeffkreeftmeijer/vim-numbertoggle' -Plug 'dpelle/vim-LanguageTool' +Plug 'rhysd/vim-grammarous' "Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } Plug 'sheerun/vim-polyglot' diff --git a/.config/zsh/aliases b/.config/zsh/aliases index 9f3a2513..80c21cfc 100755 --- a/.config/zsh/aliases +++ b/.config/zsh/aliases @@ -50,3 +50,5 @@ alias abook="abook --config \"$XDG_CONFIG_HOME\"/abook/abookrc --datafile \"$XDG alias dots="git --git-dir=$HOME/.dotfiles.git/ --work-tree=$HOME" alias dpall="dots remote | xargs -I R git --git-dir=$HOME/.dotfiles.git/ --work-tree=$HOME push R" alias dignore="dots update-index --assume-unchanged {pkg.list,install.sh,README.md}" +alias da="dots add -u" +alias dcm="dots commit" diff --git a/.local/src/xbanish/.gitignore b/.local/src/xbanish/.gitignore new file mode 100644 index 00000000..ac905b06 --- /dev/null +++ b/.local/src/xbanish/.gitignore @@ -0,0 +1,2 @@ +*.o +xbanish diff --git a/.local/src/xbanish/LICENSE b/.local/src/xbanish/LICENSE deleted file mode 100644 index 884c6fca..00000000 --- a/.local/src/xbanish/LICENSE +++ /dev/null @@ -1,14 +0,0 @@ -xbanish -Copyright (c) 2013-2021 joshua stein - -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 --git a/.local/src/xbanish/Makefile b/.local/src/xbanish/Makefile index fcd0f4f9..b3c9a406 100644 --- a/.local/src/xbanish/Makefile +++ b/.local/src/xbanish/Makefile @@ -1,8 +1,9 @@ # vim:ts=8 +VERS := 1.52 + CC ?= cc -CFLAGS ?= -O2 -CFLAGS += -Wall -Wunused -Wmissing-prototypes -Wstrict-prototypes -Wunused +CFLAGS ?= -O2 -Wall -Wunused -Wmissing-prototypes -Wstrict-prototypes -Wno-misleading-indentation PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin @@ -36,4 +37,11 @@ install: all 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 --git a/.local/src/xbanish/xbanish b/.local/src/xbanish/xbanish index 8733f7222076293fde76f96eacfa467a2c142a24..2cd95a8eca64789768c4b70c0a3a59e6f41198f2 100755 GIT binary patch literal 22504 zcmeHP4Rl+@l^*{naS~!VA)zJ^BESJdiDT!lb{d0~Sk4obgGpj=p{XKEvaMoEMtbs3 z3#~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lXHvAd%#*&af-ye`Np7=}j?PWK^#v1AA5KJU zGHcq>)#tq#j^P~l;n{3Z)UFzKc>T;4wY*=ZpRspN?_8vLz5}NDTFB{vDuNT&KM<$M*q_u?Bt#?};QE zVsZSsAg&D=pdHCD_Ja=x1>|b=E~ATl1Bv(gu`h5#a43Q*bgISmlAU4;T`ndVAIfl{ z^^=0g#ribX!27a6!^3mdKo>uhMfn-q5b70|yWSvlC8ulX*F9ZB=3&_19}d6;oUe3f z;1%e`uVNA4+f`zN1 z|8kvD(k>w^{g?GfO5ek14OH@S9aK`e&Smyrm}OaHsEJZvuEResG-;N4!VLSKNnd`SmQ=3iOL_D7|AEjiy4fNm1^xfU0v(s}7gFqp$dLb1 zOs=O$x=RWQYOepNNxx&gE+}b>G%WPZ_5T<+{pLrUHpO)w`F}sm@{*VI4d^-y`f^=q zd?P?4DW`MOyu?qTfX0rjU#>sN|KlS6UkiWeu;|IVfeo|lV%YEWzlGcBxqv!Oa z)R**Qz(#%6C8Rra+CqhfB=sb%M7dF4t}C?ALM>9GPKrmVCjnZ2Bux4**9T%kpVoDa zNij0W(?%IozquZ%ZyNqwmQ0WiC8DMw!tn=1{o}Ja%YUP^1X=07yna%#^j(+KkLv9@ ceH`EWj7iojvGb6bN&nq0UE)HMf{A7S3ilP7#Q*>R diff --git a/.local/src/xbanish/xbanish.1 b/.local/src/xbanish/xbanish.1 index 894cd5f2..02404b1f 100644 --- a/.local/src/xbanish/xbanish.1 +++ b/.local/src/xbanish/xbanish.1 @@ -1,15 +1,16 @@ -.Dd $Mdocdate: September 16 2019$ +.Dd $Mdocdate: Mar 31 2018$ .Dt XBANISH 1 .Os .Sh NAME .Nm xbanish -.Nd hide the X11 mouse cursor when a key is pressed +.Nd hide the X11 mouse cursor when a key is pressed or mouse isn't moved for some time. .Sh SYNOPSIS .Nm -.Op Fl a +.Op Fl b .Op Fl d .Op Fl i Ar modifier -.Op Fl m Ar nw|ne|sw|se +.Op Fl s +.Op Fl t Ar timeout .Sh DESCRIPTION .Nm hides the X11 mouse cursor when a key is pressed. @@ -21,36 +22,20 @@ setting 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 b +Run daemonized. .It Fl d Print debugging messages to stdout. .It Fl i Ar modifier Ignore pressed key if .Ar modifier is used. -Modifiers are: -.Ic shift , -.Ic lock -(CapsLock), -.Ic control , -.Ic mod1 -(Alt or Meta), -.Ic mod2 -(NumLock), -.Ic mod3 -(Hyper), -.Ic mod4 -(Super, Windows, or Command), -.Ic mod5 -(ISO Level 3 Shift), and -.Ic all -(All of the above). -.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. +.It Fl s +Ignore scrolling +.It Fl t Ar timeout +Hide cursor after +.Ar timeout +ms. .El .Sh SEE ALSO .Xr XFixes 3 diff --git a/.local/src/xbanish/xbanish.c b/.local/src/xbanish/xbanish.c index d64e61ba..08b4ec2f 100644 --- a/.local/src/xbanish/xbanish.c +++ b/.local/src/xbanish/xbanish.c @@ -1,18 +1,29 @@ /* * xbanish - * Copyright (c) 2013-2021 joshua stein + * Copyright (c) 2013-2015 joshua stein * - * 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. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 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. + * 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. */ #include @@ -20,6 +31,7 @@ #include #include #include +#include #include #include @@ -30,10 +42,9 @@ void hide_cursor(void); void show_cursor(void); -void snoop_root(void); int snoop_xinput(Window); void snoop_legacy(Window); -void usage(char *); +void usage(void); int swallow_error(Display *, XErrorEvent *); /* xinput event type ids to be filled in later */ @@ -42,28 +53,18 @@ static int button_release_type = -1; static int key_press_type = -1; static int key_release_type = -1; static int motion_type = -1; -static int device_change_type = -1; -static long last_device_change = -1; + +extern char *__progname; static Display *dpy; -static int hiding = 0, legacy = 0, always_hide = 0; +static int debug = 0, hiding = 0, legacy = 0, movebuf = 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, -}; +unsigned timeout = 0; int main(int argc, char *argv[]) { - int ch, i; + int ch, i, noscroll = 0; XEvent e; XGenericEventCookie *cookie; @@ -74,41 +75,33 @@ main(int argc, char *argv[]) {"shift", ShiftMask}, {"lock", LockMask}, {"control", ControlMask}, {"mod1", Mod1Mask}, {"mod2", Mod2Mask}, {"mod3", Mod3Mask}, - {"mod4", Mod4Mask}, {"mod5", Mod5Mask}, - {"all", -1}, + {"mod4", Mod4Mask}, {"mod5", Mod5Mask} }; - while ((ch = getopt(argc, argv, "adi:m:")) != -1) + while ((ch = getopt(argc, argv, "bdi:st:")) != -1) switch (ch) { - case 'a': - always_hide = 1; + case 'b': + if (daemon(1, 1) < 0) + err(1, "daemon"); break; case 'd': debug = 1; break; case 'i': for (i = 0; - i < sizeof(mods) / sizeof(struct mod_lookup); i++) + i < sizeof(mods) / sizeof(struct mod_lookup); i++) if (strcasecmp(optarg, mods[i].name) == 0) 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]); - } + case 's': + noscroll = 1; + break; + case 't': + timeout = (unsigned) atoi(optarg); break; default: - usage(argv[0]); + usage(); } argc -= optind; @@ -124,10 +117,17 @@ main(int argc, char *argv[]) XSetErrorHandler(swallow_error); - snoop_root(); + if (snoop_xinput(DefaultRootWindow(dpy)) == 0) { + if (debug) + warn("no XInput devices found, using legacy " + "snooping"); + + legacy = 1; + snoop_legacy(DefaultRootWindow(dpy)); + } - if (always_hide) - hide_cursor(); + /* signal handling */ + signal(SIGALRM, (void *) hide_cursor); for (;;) { cookie = &e.xcookie; @@ -137,20 +137,11 @@ main(int argc, char *argv[]) if (e.type == motion_type) etype = MotionNotify; else if (e.type == key_press_type || - e.type == key_release_type) + e.type == key_release_type) etype = KeyRelease; else if (e.type == button_press_type || - e.type == button_release_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: @@ -168,15 +159,17 @@ main(int argc, char *argv[]) if (e.type == key_release_type) { /* xinput device event */ XDeviceKeyEvent *key = - (XDeviceKeyEvent *) &e; + (XDeviceKeyEvent *) &e; state = key->state; } else if (e.type == KeyRelease) { /* legacy event */ state = e.xkey.state; } - if (state & ignored) { - DPRINTF(("ignoring key %d\n", state)); + if (debug) { + printf("ignoring key %d\n", + state); + } break; } } @@ -186,13 +179,14 @@ main(int argc, char *argv[]) case ButtonRelease: case MotionNotify: - if (!always_hide) - show_cursor(); + show_cursor(); break; case CreateNotify: if (legacy) { - DPRINTF(("new window, snooping on it\n")); + if (debug) + printf("created new window, " + "snooping on it\n"); /* not sure why snooping directly on the window * doesn't work, so snoop on all windows from @@ -207,25 +201,33 @@ main(int argc, char *argv[]) XIDeviceEvent *xie = (XIDeviceEvent *)cookie->data; switch (xie->evtype) { - case XI_RawMotion: case XI_RawButtonPress: - if (!always_hide) + movebuf = 0; + if (noscroll && (xie->detail == 4 || xie->detail == 5)) + break; + show_cursor(); + break; + case XI_RawMotion: + if (++movebuf > 2) { + movebuf = 0; show_cursor(); + } break; - case XI_RawButtonRelease: break; default: - DPRINTF(("unknown XI event type %d\n", - xie->evtype)); + if (debug) + printf("unknown XI event type %d\n", + xie->evtype); } XFreeEventData(dpy, cookie); break; default: - DPRINTF(("unknown event type %d\n", e.type)); + if (debug) + printf("unknown event type %d\n", e.type); } } } @@ -233,80 +235,34 @@ main(int argc, char *argv[]) void hide_cursor(void) { - Window win; - int x, y, h, w, junk; - unsigned int ujunk; - - DPRINTF(("keystroke, %shiding cursor\n", (hiding ? "already " : ""))); - - if (hiding) - return; + if (debug) + printf("%shiding cursor\n", + (hiding ? "already " : "")); - 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"); - } + if (!hiding) { + XFixesHideCursor(dpy, DefaultRootWindow(dpy)); + XFlush(dpy); + hiding = 1; } - - XFixesHideCursor(dpy, DefaultRootWindow(dpy)); - hiding = 1; + movebuf = 0; } void show_cursor(void) { - 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)); + if (debug) + printf("mouse moved, %sunhiding cursor\n", + (hiding ? "" : "already ")); + + if (hiding) { + /* reset timer */ + if (timeout > 0 && timeout < 1000) + ualarm(timeout*1000, 0); + else if (timeout > 0) + alarm(timeout/1000); + + XFixesShowCursor(dpy, DefaultRootWindow(dpy)); + hiding = 0; } } @@ -317,15 +273,16 @@ snoop_xinput(Window win) int major, minor, rc, rawmotion = 0; int ev = 0; unsigned char mask[(XI_LASTEVENT + 7)/8]; - XDeviceInfo *devinfo = NULL; + XDeviceInfo *devinfo; XInputClassInfo *ici; XDevice *device; XIEventMask evmasks[1]; - XEventClass class_presence; if (!XQueryExtension(dpy, "XInputExtension", &opcode, &event, &error)) { - DPRINTF(("XInput extension not available")); - return 0; + if (debug) + warn("XInput extension not available"); + + return (0); } /* @@ -351,14 +308,15 @@ snoop_xinput(Window win) rawmotion = 1; - DPRINTF(("using xinput2 raw motion events\n")); + if (debug) + printf("using xinput2 raw motion events\n"); } devinfo = XListInputDevices(dpy, &numdevs); XEventClass event_list[numdevs * 2]; for (i = 0; i < numdevs; i++) { if (devinfo[i].use != IsXExtensionKeyboard && - devinfo[i].use != IsXExtensionPointer) + devinfo[i].use != IsXExtensionPointer) continue; if (!(device = XOpenDevice(dpy, devinfo[i].id))) @@ -368,65 +326,54 @@ snoop_xinput(Window win) ici++, j++) { switch (ici->input_class) { case KeyClass: - DPRINTF(("attaching to keyboard device %s " - "(use %d)\n", devinfo[i].name, - devinfo[i].use)); + if (debug) + printf("attaching to keyboard device " + "%s (use %d)\n", devinfo[i].name, + devinfo[i].use); DeviceKeyPress(device, key_press_type, - event_list[ev]); ev++; + event_list[ev]); ev++; DeviceKeyRelease(device, key_release_type, - event_list[ev]); ev++; + event_list[ev]); ev++; break; case ButtonClass: if (rawmotion) continue; - DPRINTF(("attaching to buttoned device %s " - "(use %d)\n", devinfo[i].name, - devinfo[i].use)); + if (debug) + printf("attaching to buttoned device " + "%s (use %d)\n", devinfo[i].name, + devinfo[i].use); DeviceButtonPress(device, button_press_type, - event_list[ev]); ev++; + event_list[ev]); ev++; DeviceButtonRelease(device, - button_release_type, event_list[ev]); ev++; + button_release_type, event_list[ev]); ev++; break; case ValuatorClass: if (rawmotion) continue; - DPRINTF(("attaching to pointing device %s " - "(use %d)\n", devinfo[i].name, - devinfo[i].use)); + if (debug) + printf("attaching to pointing device " + "%s (use %d)\n", devinfo[i].name, + devinfo[i].use); DeviceMotionNotify(device, motion_type, - event_list[ev]); ev++; + event_list[ev]); ev++; break; } } - XCloseDevice(dpy, device); - if (XSelectExtensionEvent(dpy, win, event_list, ev)) { warn("error selecting extension events"); - ev = 0; - goto done; + return (0); } } - 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; + return (ev); } void @@ -466,10 +413,9 @@ done: } void -usage(char *progname) +usage(void) { - fprintf(stderr, "usage: %s [-a] [-d] [-i mod] [-m nw|ne|sw|se]\n", - progname); + fprintf(stderr, "usage: %s [-b] [-d] [-i mod] [-s] [-t timeout(ms)]\n", __progname); exit(1); }