mmm@cetia.fr (Mark Martin) (05/13/91)
Submitted-by: Mark Martin <mmm@cetia.fr> Posting-number: Volume 13, Issue 5 Archive-name: unclutter/part01 unclutter: remove idle cursor image from screen so that it doesnt obstruct the area you are looking at. doesn't do it if cursor is in root window or a button is down. Tries to cope with jitter if you have a mouse that twitches. (Could be a little fancier and only do it in particular clients.) Unfortunately, clients like xterm and emacs set different text cursor shapes depending on whether they have pointer focus or not. Mark M Martin. cetia 1991 mmm@cetia.fr #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # unclutter/unclutter.c unclutter/Makefile unclutter/unclutter.man unclutter/Imakefile unclutter/README unclutter/patchlevel.h # This archive created: Tue May 7 15:44:29 FDT 1991 # By: mmm # Part 1 of 1 PATH=/bin:$PATH export PATH mkdir unclutter if test -f 'unclutter/unclutter.c' then echo "shar: will not overwrite existing file unclutter/unclutter.c" else echo "shar: extracting unclutter/unclutter.c (3216 chars)" sed 's/^X//' <<\END-OF-FILE! >'unclutter/unclutter.c' X/* X * unclutter: remove idle cursor image from screen so that it doesnt X * obstruct the area you are looking at. X * doesn't do it if cursor is in root window or a button is down. X * Tries to cope with jitter if you have a mouse that twitches. X * (Could be a little fancier and only do it in particular clients.) X * Unfortunately, clients like xterm and emacs set different text cursor X * shapes depending on whether they have pointer focus or not. X * Mark M Martin. cetia 1991 mmm@cetia.fr X */ X#include <X11/Xos.h> X#include <X11/Xlib.h> X#include <X11/Xutil.h> X#include <stdio.h> X Xchar *progname; Xpexit(str)char *str;{ X fprintf(stderr,"%s: %s\n",progname,str); X exit(1); X} Xusage(){ X pexit("usage:\n\ X -display <display>\n\ X -idle <seconds> time between polls to detect idleness.\n\ X -jitter <pixels> pixels mouse can twitch without moving\n\ X -root apply to cursor on root window too"); X} X X#define ALMOSTEQUAL(a,b) (abs(a-b)<=jitter) X#define ANYBUTTON (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask) X Xmain(argc,argv)char **argv;{ X Display *display; X Cursor cursor; X int status,screen,oldx,oldy = -99; X int doroot = 0, jitter = 0, idletime = 5; X Window root; X Pixmap cursormask; X XGCValues xgc; X GC gc; X XColor dummycolour; X char *displayname = 0; X X progname = *argv; X argc--; X while(argv++,argc-->0){ X if(strcmp(*argv,"-idle")==0){ X argc--,argv++; X if(argc<0)usage(); X idletime = atoi(*argv); X }else if(strcmp(*argv,"-jitter")==0){ X argc--,argv++; X if(argc<0)usage(); X jitter = atoi(*argv); X }else if(strcmp(*argv,"-root")==0){ X doroot = 1; X }else if(strcmp(*argv,"-display")==0){ X argc--,argv++; X if(argc<0)usage(); X displayname = *argv; X }else usage(); X } X display = XOpenDisplay(displayname); X if(display==0)pexit("could not open display"); X screen = DefaultScreen(display); X root = RootWindow(display,screen); X X cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/); X xgc.function = GXclear; X gc = XCreateGC(display, cursormask, GCFunction, &xgc); X XFillRectangle(display, cursormask, gc, 0, 0, 1, 1); X dummycolour.pixel = 0; X dummycolour.red = 0; X dummycolour.flags = 04; X cursor = XCreatePixmapCursor(display, cursormask, cursormask, X &dummycolour,&dummycolour, 0,0); X XFreePixmap(display,cursormask); X XFreeGC(display,gc); X X while(1){ X Window dummywin,windowin; X int x,y,dummyxy; X unsigned int modifs; X X if(XQueryPointer(display, root, &dummywin, &windowin, X &x, &y, &dummyxy, &dummyxy, &modifs)){ X if((!doroot && windowin==None) || (modifs & ANYBUTTON) || X !(ALMOSTEQUAL(x,oldx) && ALMOSTEQUAL(y,oldy))){ X oldx = x, oldy = y; X sleep(idletime); X X X }else{ X status = XGrabPointer(display, root, 0, X PointerMotionMask|ButtonPressMask|ButtonReleaseMask, X GrabModeAsync, GrabModeAsync, None, cursor, X CurrentTime); X if(status==GrabSuccess){ X XEvent event; X do{ X XNextEvent(display,&event); X }while(event.type==MotionNotify && X ALMOSTEQUAL(x,event.xmotion.x) && X ALMOSTEQUAL(y,event.xmotion.y)); X XUngrabPointer(display, CurrentTime); X } X } X } X } X} END-OF-FILE! if test 3216 -ne "`wc -c <'unclutter/unclutter.c'`" then echo "shar: error transmitting unclutter/unclutter.c (3216 characters)" fi fi if test -f 'unclutter/Makefile' then echo "shar: will not overwrite existing file unclutter/Makefile" else echo "shar: extracting unclutter/Makefile (1996 chars)" sed 's/^X//' <<\END-OF-FILE! >'unclutter/Makefile' X# Makefile for unclutter. Throw this away and use the Imakefile if you can. X TOP = . X CURRENT_DIR = . X CC = gcc X LKED = $(CC) X INSTALL = install X MAKE = make X MV = mv X RM = rm -f X TAGS = ctags X MFLAGS = -$(MAKEFLAGS) X INSTPGMFLAGS = -c -s X INSTMANFLAGS = -c X TOP_INCLUDES = -I$(INCROOT) X CDEBUGFLAGS = -O X ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES) X ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS) X CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) X LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) X LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) X RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut X IRULESRC = $(CONFIGDIR) X IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES) X BINDIR = $(DESTDIR)/usr/bin/X11 X INCROOT = $(DESTDIR)/usr/include X MANPATH = $(DESTDIR)/usr/catman/x11_man X MANSOURCEPATH = $(MANPATH)/man X MANDIR = $(MANSOURCEPATH)1 X IMAKE = imake X XLIB = $(EXTENSIONLIB) -lX11 X X LOCAL_LIBRARIES = $(XLIB) X X OBJS = unclutter.o X SRCS = unclutter.c X X PROGRAM = unclutter X Xall:: unclutter X Xunclutter: $(OBJS) $(DEPLIBS) X $(RM) $@ X $(LKED) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X Xinstall:: unclutter X $(INSTALL) -c $(INSTPGMFLAGS) unclutter $(BINDIR) Xinstall.man:: unclutter.man X $(INSTALL) -c $(INSTMANFLAGS) unclutter.man $(MANDIR)/unclutter.1 Xclean:: X $(RM) $(PROGRAM) X $(RM_CMD) \#* XMakefile:: X -@if [ -f Makefile ]; then \ X echo " $(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \ X $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ X else exit 0; fi X $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) Xtags:: X $(TAGS) -w *.[ch] X $(TAGS) -xw *.[ch] > TAGS END-OF-FILE! if test 1996 -ne "`wc -c <'unclutter/Makefile'`" then echo "shar: error transmitting unclutter/Makefile (1996 characters)" fi fi if test -f 'unclutter/unclutter.man' then echo "shar: will not overwrite existing file unclutter/unclutter.man" else echo "shar: extracting unclutter/unclutter.man (1254 chars)" sed 's/^X//' <<\END-OF-FILE! >'unclutter/unclutter.man' X.\"unclutter man X.TH UNCLUTTER 1X X.SH NAME Xunclutter \- remove idle cursor image from screen X.SH SYNOPSIS X.B Xunclutter X.RB [ -display X.IR display ] X.RB [ -idle X.IR seconds ] X.RB [ -jitter X.IR pixels ] X.RB [ -root ] X.SH DESCRIPTION X.B unclutter Xremoves the cursor image from the screen so that it does not Xobstruct the area you are looking at after it has not moved for Xa given time. XIt does not do this if the cursor is in the root window or a button is down. XIt tries to ignore jitter (small movements due to noise) Xif you have a mouse that twitches. X.SH OPTIONS X.TP X-display Xis followed by the display to open. X.TP X-idle Xis followed by the number of seconds between polls for idleness. XThe default is 5. X.TP X-jitter Xis followed by the amount of movement of the pointer that is to be ignored Xand considered as random noise. XThe default is 0. X.TP X-root Xmeans remove the cursor even if it is on the root background, where in Xprinciple it should not be obscuring anything useful. X.SH LIMITATIONS XUnfortunately, clients like xterm and emacs set different text cursor Xshapes depending on whether they have pointer focus or not, Xand so not only does the cursor pixture go, but the text cursor image changes. X.SH AUTHOR XMark M Martin. cetia 1991. mmm@cetia.fr END-OF-FILE! if test 1254 -ne "`wc -c <'unclutter/unclutter.man'`" then echo "shar: error transmitting unclutter/unclutter.man (1254 characters)" fi fi if test -f 'unclutter/Imakefile' then echo "shar: will not overwrite existing file unclutter/Imakefile" else echo "shar: extracting unclutter/Imakefile (59 chars)" sed 's/^X//' <<\END-OF-FILE! >'unclutter/Imakefile' XLOCAL_LIBRARIES = $(XLIB) X XSimpleProgramTarget(unclutter) X END-OF-FILE! if test 59 -ne "`wc -c <'unclutter/Imakefile'`" then echo "shar: error transmitting unclutter/Imakefile (59 characters)" fi fi if test -f 'unclutter/README' then echo "shar: will not overwrite existing file unclutter/README" else echo "shar: extracting unclutter/README (797 chars)" sed 's/^X//' <<\END-OF-FILE! >'unclutter/README' Xunclutter is a program which runs permanently in the background of an X11 Xsession. It checks on the X11 pointer (cursor) position every few Xseconds, and when if finds it has not moved (and no buttons Xare pressed on the mouse, and the cursor is not in the root window) Xit grabs the cursor and replaces it with one of size 1x1 but a mask of Xall 0, ie an invisible cursor. This allows you to see all the text in Xan xterm or xedit, for example. The human factors crowd would agree it Xshould make things less distracting. XOnce grabbed, the program waits for any pointer movement or button press Xand lets go again, restoring the original cursor image. X XThe program is released into the public domain. Only the considerate Xwill leave credit for the author. X X Mark M Martin. mmm@cetia.fr april 1991. END-OF-FILE! if test 797 -ne "`wc -c <'unclutter/README'`" then echo "shar: error transmitting unclutter/README (797 characters)" fi fi if test -f 'unclutter/patchlevel.h' then echo "shar: will not overwrite existing file unclutter/patchlevel.h" else echo "shar: extracting unclutter/patchlevel.h (73 chars)" sed 's/^X//' <<\END-OF-FILE! >'unclutter/patchlevel.h' X/* X * unclutter: patch level 0: initial release X */ X#define PATCHLEVEL 0 END-OF-FILE! if test 73 -ne "`wc -c <'unclutter/patchlevel.h'`" then echo "shar: error transmitting unclutter/patchlevel.h (73 characters)" fi fi echo 'end of shar part 1 of 1' exit 0 -- Dan Heller O'Reilly && Associates Z-Code Software Comp-sources-x: Senior Writer President comp-sources.x@uunet.uu.net argv@ora.com argv@zipcode.com