home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / x / volume13 / unclutter / patch1 / patches.3
Text File  |  1991-07-16  |  13KB  |  411 lines

  1. diff -r -c old/README unclutter/README
  2. *** old/README    Tue Jun 18 18:15:51 1991
  3. --- unclutter/README    Thu May 30 12:30:29 1991
  4. ***************
  5. *** 16,22 ****
  6.   will apparently leave the window, even though its x y position doesnt change.
  7.   
  8.   The first version of this program used a grab to remove the cursor.
  9. ! This methid is still available with a "-grab" option to the program.
  10.   
  11.   The program is released into the public domain.  Only the considerate
  12.   will leave credit for the author.
  13. --- 16,31 ----
  14.   will apparently leave the window, even though its x y position doesnt change.
  15.   
  16.   The first version of this program used a grab to remove the cursor.
  17. ! This method is still available with a "-grab" option to the program.
  18. ! Thanks for their help with "remote debugging" with xscope of various servers to
  19. !     dave edsall@iastate.edu
  20. !     Roland McGrath <roland@geech.gnu.ai.mit.edu>
  21. !     Rainer Sinkwitz <sinkwitz@ifi.unizh.ch>
  22. !     Michael L. Brown astroatc!ftms!brown@cs.wisc.edu
  23. !     patti@hosehead.hf.intel.com
  24. ! and, for vroot.h, Andreas Stolcke <stolcke@ICSI.Berkeley.EDU>
  25. ! and to all those who tested various development versions sent by mail.
  26.   
  27.   The program is released into the public domain.  Only the considerate
  28.   will leave credit for the author.
  29. diff -r -c old/patchlevel.h unclutter/patchlevel.h
  30. *** old/patchlevel.h    Tue Jun 18 18:15:53 1991
  31. --- unclutter/patchlevel.h    Tue Jun 18 18:11:50 1991
  32. ***************
  33. *** 4,8 ****
  34.    * level 1: -grab option to use old method, new method creates small input
  35.    * only sub-window. (distributed by mail only, not posted)
  36.    * level 2: use Andreas Stolcke's vroot.h for tvtwm and similar winmans.
  37.    */
  38. ! #define PATCHLEVEL 2
  39. --- 4,10 ----
  40.    * level 1: -grab option to use old method, new method creates small input
  41.    * only sub-window. (distributed by mail only, not posted)
  42.    * level 2: use Andreas Stolcke's vroot.h for tvtwm and similar winmans.
  43. +  * level 3: -not option takes list of windows to avoid and -visible ignores
  44. +  *        visibility events for some servers.
  45.    */
  46. ! #define PATCHLEVEL 3
  47. diff -r -c old/unclutter.c unclutter/unclutter.c
  48. *** old/unclutter.c    Tue Jun 18 18:15:47 1991
  49. --- unclutter/unclutter.c    Tue Jun 18 18:11:50 1991
  50. ***************
  51. *** 8,13 ****
  52. --- 8,16 ----
  53.    * shapes depending on whether they have pointer focus or not.
  54.    * Whereas version 1 did a grab cursor, version 2 creates a small subwindow.
  55.    * This may work better with some window managers.
  56. +  * Some servers return a Visibility event when the subwindow is mapped.
  57. +  * Sometimes this is Unobscured, or even FullyObscured. Ignore these and
  58. +  * rely on LeaveNotify events.
  59.    * Mark M Martin. cetia 1991  mmm@cetia.fr
  60.    */
  61.   #include <X11/Xos.h>
  62. ***************
  63. *** 30,36 ****
  64.       -grab            use grabpointer method not createwindow\n\
  65.       -reset            reset the timer whenever cursor becomes\n\
  66.                       visible even if it hasn't moved\n\
  67. !      -root                   apply to cursor on root window too");
  68.   }
  69.   
  70.   #define ALMOSTEQUAL(a,b) (abs(a-b)<=jitter)
  71. --- 33,42 ----
  72.       -grab            use grabpointer method not createwindow\n\
  73.       -reset            reset the timer whenever cursor becomes\n\
  74.                       visible even if it hasn't moved\n\
  75. !      -root                   apply to cursor on root window too\n\
  76. !      -visible               ignore visibility events\n\
  77. !     -not names...        dont apply to windows whose wm-name begins.\n\
  78. !                 (must be last argument)");
  79.   }
  80.   
  81.   #define ALMOSTEQUAL(a,b) (abs(a-b)<=jitter)
  82. ***************
  83. *** 51,61 ****
  84.       (*defaulthandler)(display,error);
  85.   }
  86.   
  87.   main(argc,argv)char **argv;{
  88.       Display *display;
  89.       Cursor cursor;
  90.       int screen,oldx,oldy = -99;
  91. !     int doroot = 0, jitter = 0, idletime = 5, usegrabmethod = 0, waitagain = 0;
  92.       Window root;
  93.       Pixmap cursormask;
  94.       XGCValues xgc;
  95. --- 57,93 ----
  96.       (*defaulthandler)(display,error);
  97.   }
  98.   
  99. + char **names;    /* -> argv list of names to avoid */
  100. + /*
  101. +  * return true if window has a wm_name and the start of it matches
  102. +  * one of the given names to avoid
  103. +  */
  104. + nameinlist(display,window)
  105. + Display *display;
  106. + Window window;
  107. + {
  108. +     char **cpp;
  109. +     char *name;
  110. +     if(names==0)return 0;
  111. +     if(XFetchName (display, window, &name)){
  112. +     for(cpp = names;*cpp!=0;cpp++){
  113. +         if(strncmp(*cpp,name,strlen(*cpp))==0)
  114. +         break;
  115. +     }
  116. +     XFree(name);
  117. +     return(*cpp!=0);
  118. +     }
  119. +     return 0;
  120. + }    
  121.   main(argc,argv)char **argv;{
  122.       Display *display;
  123.       Cursor cursor;
  124.       int screen,oldx,oldy = -99;
  125. !     int doroot = 0, jitter = 0, idletime = 5, usegrabmethod = 0, waitagain = 0,
  126. !     dovisible = 1;
  127.       Window root;
  128.       Pixmap cursormask;
  129.       XGCValues xgc;
  130. ***************
  131. *** 80,85 ****
  132. --- 112,124 ----
  133.           usegrabmethod = 1;
  134.       }else if(strcmp(*argv,"-reset")==0){
  135.           waitagain = 1;
  136. +     }else if(strcmp(*argv,"-visible")==0){
  137. +         dovisible = 0;
  138. +     }else if(strcmp(*argv,"-not")==0){
  139. +         /* take rest of srg list */
  140. +         names = ++argv;
  141. +         if(*names==0)names = 0;    /* no args follow */
  142. +         argc = 0;
  143.       }else if(strcmp(*argv,"-display")==0){
  144.           argc--,argv++;
  145.           if(argc<0)usage();
  146. ***************
  147. *** 110,115 ****
  148. --- 149,155 ----
  149.       Window dummywin,windowin;
  150.       int rootx,rooty,winx,winy;
  151.       unsigned int modifs;
  152. +     Window lastwindowavoided = None;
  153.       
  154.       /* wait for pointer to not move and no buttons down */
  155.       while(1){
  156. ***************
  157. *** 120,126 ****
  158.           }else if((!doroot && windowin==None) || (modifs & ANYBUTTON) ||
  159.                !(ALMOSTEQUAL(rootx,oldx) && ALMOSTEQUAL(rooty,oldy))){
  160.           oldx = rootx, oldy = rooty;
  161. !         }else break;
  162.           sleep(idletime);
  163.       }
  164.       /* wait again next time */
  165. --- 160,187 ----
  166.           }else if((!doroot && windowin==None) || (modifs & ANYBUTTON) ||
  167.                !(ALMOSTEQUAL(rootx,oldx) && ALMOSTEQUAL(rooty,oldy))){
  168.           oldx = rootx, oldy = rooty;
  169. !         }else if(windowin==None){
  170. !         windowin = root;
  171. !         break;
  172. !         }else if(windowin!=lastwindowavoided){
  173. !         /* descend tree of windows under cursor to bottommost */
  174. !         Window childin;
  175. !         int toavoid = xFalse;
  176. !         lastwindowavoided = childin = windowin;
  177. !         do{
  178. !             windowin = childin;
  179. !             if(nameinlist (display, windowin)){
  180. !             toavoid = xTrue;
  181. !             break;
  182. !             }
  183. !         }while(XQueryPointer(display, windowin, &dummywin,
  184. !              &childin, &rootx, &rooty, &winx, &winy, &modifs)
  185. !                && childin!=None);
  186. !         if(!toavoid){
  187. !             lastwindowavoided = None;
  188. !             break;
  189. !         }
  190. !         }
  191.           sleep(idletime);
  192.       }
  193.       /* wait again next time */
  194. ***************
  195. *** 146,165 ****
  196.           Window cursorwindow;
  197.           Window childin;
  198.           
  199. -         /* descend tree of windows under cursor to bottommost */
  200. -         if(windowin!=None)
  201. -         while(XQueryPointer(display, windowin, &dummywin, &childin,
  202. -                     &rootx, &rooty, &winx, &winy, &modifs)
  203. -               && childin!=None)
  204. -             windowin = childin;
  205. -         else windowin = root;
  206.           /* create small input-only window under cursor
  207.            * as a sub window of the window currently under the cursor
  208.            */
  209.           attributes.event_mask = LeaveWindowMask |
  210. -             VisibilityChangeMask |
  211.               StructureNotifyMask |
  212.               FocusChangeMask;
  213.           attributes.override_redirect = True;
  214.           attributes.cursor = cursor;
  215.           cursorwindow = XCreateWindow
  216. --- 207,220 ----
  217.           Window cursorwindow;
  218.           Window childin;
  219.           
  220.           /* create small input-only window under cursor
  221.            * as a sub window of the window currently under the cursor
  222.            */
  223.           attributes.event_mask = LeaveWindowMask |
  224.               StructureNotifyMask |
  225.               FocusChangeMask;
  226. +         if(dovisible)
  227. +         attributes.event_mask |= VisibilityChangeMask;
  228.           attributes.override_redirect = True;
  229.           attributes.cursor = cursor;
  230.           cursorwindow = XCreateWindow
  231. ***************
  232. *** 187,193 ****
  233.                  event.type!=CirculateNotify &&
  234.                  event.type!=ReparentNotify &&
  235.                  event.type!=DestroyNotify &&
  236. !                event.type!=VisibilityNotify);
  237.           /* check if a second unclutter is running cos they thrash */
  238.           if(event.type==LeaveNotify &&
  239.              event.xcrossing.window==cursorwindow &&
  240. --- 242,250 ----
  241.                  event.type!=CirculateNotify &&
  242.                  event.type!=ReparentNotify &&
  243.                  event.type!=DestroyNotify &&
  244. !                (event.type!=VisibilityNotify ||
  245. !             event.xvisibility.state==VisibilityUnobscured)
  246. !                );
  247.           /* check if a second unclutter is running cos they thrash */
  248.           if(event.type==LeaveNotify &&
  249.              event.xcrossing.window==cursorwindow &&
  250. diff -r -c old/unclutter.man unclutter/unclutter.man
  251. *** old/unclutter.man    Tue Jun 18 18:15:48 1991
  252. --- unclutter/unclutter.man    Fri May 24 19:13:55 1991
  253. ***************
  254. *** 14,19 ****
  255. --- 14,21 ----
  256.   .RB [ -grab ]
  257.   .RB [ -reset ]
  258.   .RB [ -root ]
  259. + .RB [ -not ]
  260. + .I "name ...
  261.   .SH DESCRIPTION
  262.   .B unclutter
  263.   removes the cursor image from the screen so that it does not
  264. ***************
  265. *** 50,55 ****
  266. --- 52,64 ----
  267.   -root
  268.   means remove the cursor even if it is on the root background, where in
  269.   principle it should not be obscuring anything useful.
  270. + .TP
  271. + -not
  272. + is followed by a list of window names where the cursor should not be
  273. + removed.
  274. + The first few characters of the WM_NAME property on the window need
  275. + to match one the listed names.
  276. + This argument must be the last on the command line.
  277.   .SH LIMITATIONS
  278.   Unfortunately, clients like emacs set different text cursor
  279.   shapes depending on whether they have pointer focus or not,
  280. ***************
  281. *** 67,70 ****
  282.   This situation quickly deteriorates into a fight no one can win, so
  283.   it is detected when possible and the program gives up.
  284.   .SH AUTHOR
  285. ! Mark M Martin. cetia 1991. mmm@cetia.fr
  286. --- 76,79 ----
  287.   This situation quickly deteriorates into a fight no one can win, so
  288.   it is detected when possible and the program gives up.
  289.   .SH AUTHOR
  290. ! Mark M Martin. cetia 24may1991. mmm@cetia.fr
  291. diff -r -c old/vroot.h unclutter/vroot.h
  292. *** old/vroot.h    Tue Jun 18 18:15:49 1991
  293. --- unclutter/vroot.h    Fri May 24 19:13:55 1991
  294. ***************
  295. *** 28,35 ****
  296.    * after all the X11 header files.  It has been tested on such popular
  297.    * X clients as xphoon, xfroot, xloadimage, and xaqua.
  298.    *
  299. !  * Andreas Stolcke (stolcke@ICSI.Berkeley.EDU), 9/7/90
  300. !  * minor mods signalled with: mmm and DONTOPTIMISE.
  301.    */
  302.   #define DONTOPTIMISE    /* unclutter needs to search from scratch each time */
  303.   
  304. --- 28,36 ----
  305.    * after all the X11 header files.  It has been tested on such popular
  306.    * X clients as xphoon, xfroot, xloadimage, and xaqua.
  307.    *
  308. !  * Andreas Stolcke <stolcke@ICSI.Berkeley.EDU>, 9/7/90
  309. !  * - replaced all NULL's with properly cast 0's, 5/6/91
  310. !  * - free children list (suggested by Mark Martin <mmm@cetia.fr>), 5/16/91
  311.    */
  312.   #define DONTOPTIMISE    /* unclutter needs to search from scratch each time */
  313.   
  314. ***************
  315. *** 40,83 ****
  316.   VirtualRootWindow(dpy, screen)
  317.   Display *dpy;
  318.   {
  319. !     static Display *save_dpy = (Display *)NULL;
  320.       static int save_screen = -1;
  321. !     static Window root = (Window)NULL;
  322.   
  323. -     Atom __SWM_VROOT = None;
  324. -     int i;
  325. -     Window rootReturn, parentReturn, *children;
  326. -     unsigned int numChildren;
  327.   #ifdef DONTOPTIMISE
  328.       {
  329.   #else
  330. !     if ( dpy != save_dpy || screen != save_screen ) {
  331.   #endif
  332.           root = RootWindow(dpy, screen);
  333.   
  334.           /* go look for a virtual root */
  335.           __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
  336. !         if(XQueryTree(dpy, root, &rootReturn, &parentReturn,
  337. !                  &children, &numChildren)){    /* mmm */
  338. !             for (i = 0; i < numChildren; i++) {
  339. !             Atom actual_type;
  340. !             int actual_format;
  341. !             unsigned long nitems, bytesafter;    /* mmm */
  342. !             Window *newRoot = NULL;
  343.   
  344. !             if (XGetWindowProperty(dpy, children[i], __SWM_VROOT,
  345. !                 0, 1, False, XA_WINDOW,
  346. !                 &actual_type, &actual_format,
  347. !                 &nitems, &bytesafter,
  348. !                 (unsigned char **) &newRoot) == Success
  349. !                 && newRoot) {
  350. !                 root = *newRoot;
  351. !                 break;
  352.               }
  353. !             }
  354. !             if(children)XFree((char *)children);    /* mmm */
  355.           }
  356.           save_dpy = dpy;
  357.           save_screen = screen;
  358.       }
  359. --- 41,86 ----
  360.   VirtualRootWindow(dpy, screen)
  361.   Display *dpy;
  362.   {
  363. !     static Display *save_dpy = (Display *)0;
  364.       static int save_screen = -1;
  365. !     static Window root = (Window)0;
  366.   
  367.   #ifdef DONTOPTIMISE
  368.       {
  369.   #else
  370. !     if (dpy != save_dpy || screen != save_screen) {
  371.   #endif
  372. +         Atom __SWM_VROOT = None;
  373. +         int i;
  374. +         Window rootReturn, parentReturn, *children;
  375. +         unsigned int numChildren;
  376.           root = RootWindow(dpy, screen);
  377.   
  378.           /* go look for a virtual root */
  379.           __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
  380. !         if (XQueryTree(dpy, root, &rootReturn, &parentReturn,
  381. !                  &children, &numChildren)) {
  382. !             for (i = 0; i < numChildren; i++) {
  383. !                 Atom actual_type;
  384. !                 int actual_format;
  385. !                 unsigned long nitems, bytesafter;
  386. !                 Window *newRoot = (Window *)0;
  387.   
  388. !                 if (XGetWindowProperty(dpy, children[i],
  389. !                     __SWM_VROOT, 0, 1, False, XA_WINDOW,
  390. !                     &actual_type, &actual_format,
  391. !                     &nitems, &bytesafter,
  392. !                     (unsigned char **) &newRoot) == Success
  393. !                     && newRoot) {
  394. !                     root = *newRoot;
  395. !                     break;
  396. !                 }
  397.               }
  398. !             if (children)
  399. !                 XFree((char *)children);
  400.           }
  401.           save_dpy = dpy;
  402.           save_screen = screen;
  403.       }
  404.