home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / alt / lucidem / help / 388 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  23.2 KB

  1. Path: sparky!uunet!mcsun!uknet!edcastle!edcogsci!cogsci!rjc
  2. From: rjc@cogsci.ed.ac.uk (Richard Caley)
  3. Newsgroups: alt.lucid-emacs.help
  4. Subject: Patch to get TWM to understand lemacs
  5. Message-ID: <RJC.92Sep7215854@daiches.cogsci.ed.ac.uk>
  6. Date: 7 Sep 92 20:58:54 GMT
  7. Sender: rjc@cogsci.ed.ac.uk
  8. Distribution: alt
  9. Organization: Human Communication Research Center
  10. Lines: 795
  11.  
  12.  
  13. This shar contains patches to the R4 and R5 TWM window managers which
  14. gives them the ability to cope with lucid emacs' handling of the
  15. keyboard focus. 
  16.  
  17. MOre details in the ReadMe.
  18.  
  19. --
  20. rjc@cogsci.ed.ac.uk            _O_
  21.                      |<
  22.  
  23. #! /bin/sh
  24. # This is a shell archive.  Remove anything before this line, then unpack
  25. # it by saving it into a file and typing "sh file".  To overwrite existing
  26. # files, type "sh file -c".  You can also feed this as standard input via
  27. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  28. # will see the following message at the end:
  29. #        "End of shell archive."
  30. # Contents:  twm_focus_patch twm_focus_patch/ReadMe
  31. #   twm_focus_patch/twm_focus_patch.r4
  32. #   twm_focus_patch/twm_focus_patch.r5
  33. # Wrapped by rjc@daiches on Mon Sep  7 21:50:27 1992
  34. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  35. if test ! -d twm_focus_patch ; then
  36.     echo shar: Creating directory \"twm_focus_patch\"
  37.     mkdir twm_focus_patch
  38. fi
  39. if test -f twm_focus_patch/ReadMe -a "${1}" != "-c" ; then 
  40.   echo shar: Will not over-write existing file \"twm_focus_patch/ReadMe\"
  41. else
  42. echo shar: Extracting \"twm_focus_patch/ReadMe\" \(2227 characters\)
  43. sed "s/^X//" >twm_focus_patch/ReadMe <<'END_OF_twm_focus_patch/ReadMe'
  44. X
  45. X                Focus Patch for TWM
  46. X            ===================
  47. X
  48. X          Richard Caley (R.Caley@ed.ac.uk)
  49. X         ----------------------------------
  50. X            7th September 1992
  51. X
  52. X
  53. XThis patch changes the focus handling behaviour of TWM so that it can
  54. Xcope with clients like Lucid Emacs which juggle the keyboard focus. 
  55. X
  56. XWhat Does it Do?
  57. X----------------
  58. XThe normal TWM focus handling behaviour is rather dim. It does not
  59. Xnotice when another client changes the focus window and so the
  60. Xkeyboard focus and TWM's highlighting can end up on different windows.
  61. XThis patch adds code to track focus in and out events and move the
  62. Xhighlighting with them.
  63. X
  64. XIt seems to handle local and globally active focus models, as defined
  65. Xin the ICCCM. Clients which claim they do not want input, such as xev
  66. Xand xjuggle, do get highlighted when the cursor enters the client
  67. Xwindow. This should stop users who don't wish to know about such
  68. Xthings from getting confused.
  69. X
  70. XVisable Changes
  71. X---------------
  72. XWith this patch in place, TWM no longer lies about where the focus is
  73. Xwhen the cursor moves over an icon manager. A window which is unmapped
  74. Xcan not get the focus, but the normal TWM behaviour is to highlight
  75. Xany icon manager entry which the cursor moves into. With this patch in
  76. Xplace, only windows which actually have the focus have their entries
  77. Xhighlighted. This may or may not be a good feature, but I prefer to
  78. Xknow where I stand.
  79. X
  80. XA few more events travel over the network, so it is possible that the
  81. Xresultant TWM might be a touch slower on slow machines/networks.
  82. X
  83. XSupport, What's That?
  84. X---------------------
  85. XThis patch is, as they say, supplied as-is. No guarantees, no
  86. Xpromises. If it changes your TWM executable so that it checksums to
  87. X666 and so launches armageddon, don't blame me. 
  88. X
  89. XI've used TVTWM versions of this patch for a while and am reasonably
  90. Xconfident that it works in all normal circumstances. I have only done
  91. Xa brief test of the TWM behaviour, it seems to work on all the obvious
  92. Xhard cases I could think up.
  93. X
  94. XIf you email me some bizzare behaviour I'll be interested since it
  95. Xwill probably exist in tvtwm too.
  96. X
  97. XWhat You Get
  98. X------------
  99. XAlong with this readme, you should have gotten two patches, one for
  100. Xrelease 4 TWM and one for release 5. 
  101. END_OF_twm_focus_patch/ReadMe
  102. if test 2227 -ne `wc -c <twm_focus_patch/ReadMe`; then
  103.     echo shar: \"twm_focus_patch/ReadMe\" unpacked with wrong size!
  104. fi
  105. # end of overwriting check
  106. fi
  107. if test -f twm_focus_patch/twm_focus_patch.r4 -a "${1}" != "-c" ; then 
  108.   echo shar: Will not over-write existing file \"twm_focus_patch/twm_focus_patch.r4\"
  109. else
  110. echo shar: Extracting \"twm_focus_patch/twm_focus_patch.r4\" \(8157 characters\)
  111. sed "s/^X//" >twm_focus_patch/twm_focus_patch.r4 <<'END_OF_twm_focus_patch/twm_focus_patch.r4'
  112. X*** add_window.c~    Fri Sep  4 18:27:57 1992
  113. X--- add_window.c    Mon Sep  7 18:30:54 1992
  114. X***************
  115. X*** 686,691 ****
  116. X--- 686,692 ----
  117. X      valuemask = (CWEventMask | CWDontPropagate);
  118. X      attributes.event_mask = (StructureNotifyMask | PropertyChangeMask |
  119. X                   ColormapChangeMask | VisibilityChangeMask |
  120. X+                  FocusChangeMask |
  121. X                   EnterWindowMask | LeaveWindowMask);
  122. X      attributes.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask;
  123. X      XChangeWindowAttributes (dpy, tmp_win->w, valuemask, &attributes);
  124. X*** events.c.orig    Fri Sep  4 18:27:58 1992
  125. X--- events.c    Mon Sep  7 19:14:54 1992
  126. X***************
  127. X*** 86,91 ****
  128. X--- 86,92 ----
  129. X  int Cancel = FALSE;
  130. X  
  131. X  void HandleCreateNotify();
  132. X+ void HandleFocusChange ();
  133. X  
  134. X  #ifdef SHAPE
  135. X  void HandleShapeNotify ();
  136. X***************
  137. X*** 151,156 ****
  138. X--- 152,159 ----
  139. X      EventHandler[KeyPress] = HandleKeyPress;
  140. X      EventHandler[ColormapNotify] = HandleColormapNotify;
  141. X      EventHandler[VisibilityNotify] = HandleVisibilityNotify;
  142. X+     EventHandler[FocusIn] = HandleFocusChange;
  143. X+     EventHandler[FocusOut] = HandleFocusChange;
  144. X  #ifdef SHAPE
  145. X      if (HasShape)
  146. X      EventHandler[ShapeEventBase+ShapeNotify] = HandleShapeNotify;
  147. X***************
  148. X*** 645,650 ****
  149. X--- 648,818 ----
  150. X      }
  151. X  }
  152. X  
  153. X+ /*
  154. X+  * LastFocusEvent -- skip over focus in/out events for this
  155. X+  *        window.
  156. X+  */
  157. X+ 
  158. X+ 
  159. X+ 
  160. X+ static XEvent *
  161. X+ LastFocusEvent(w, first)
  162. X+ 
  163. X+ Window *w;
  164. X+ XEvent *first;
  165. X+ 
  166. X+ 
  167. X+ {
  168. X+ static XEvent current;
  169. X+ XEvent *last, new;
  170. X+ 
  171. X+ new= *first;
  172. X+ last=NULL;
  173. X+ 
  174. X+ do {
  175. X+    if ( (new.type == FocusIn || new.type == FocusOut) 
  176. X+        && new.xfocus.mode == NotifyNormal 
  177. X+        && (new.xfocus.detail == NotifyNonlinear 
  178. X+        || new.xfocus.detail == NotifyPointer
  179. X+        || new.xfocus.detail == NotifyAncestor
  180. X+        || (new.xfocus.detail == NotifyNonlinearVirtual)
  181. X+        ))
  182. X+        {
  183. X+        current=new;
  184. X+        last= ¤t;
  185. X+ #ifdef TRACE_FOCUS
  186. X+        printf("! %s 0x%x mode=%d, detail=%d\n", new.xfocus.type == FocusIn?"in":"out",Tmp_win,new.xfocus.mode, new.xfocus.detail);
  187. X+ #endif       
  188. X+        }
  189. X+ else
  190. X+     {
  191. X+ #ifdef TRACE_FOCUS
  192. X+     printf("~ %s 0x%x mode=%d, detail=%d\n", new.xfocus.type == FocusIn?"in":"out",Tmp_win,new.xfocus.mode, new.xfocus.detail);
  193. X+ #endif
  194. X+        }
  195. X+    } while (XCheckWindowEvent(dpy, w, FocusChangeMask, &new));
  196. X+ 
  197. X+ return last;
  198. X+ }
  199. X+ 
  200. X+ /*
  201. X+  * HandleFocusIn -- deal with the focus moving under us.
  202. X+  */
  203. X+ 
  204. X+ void
  205. X+ HandleFocusIn(event)
  206. X+ 
  207. X+ XFocusInEvent *event;
  208. X+ 
  209. X+ {
  210. X+ 
  211. X+ #ifdef TRACE_FOCUS
  212. X+ printf("+0x%x mode=%d, detail=%d\n", Tmp_win, event->mode, event->detail);
  213. X+ #endif
  214. X+ 
  215. X+ 
  216. X+ if (Tmp_win->hilite_w)    
  217. X+     XMapWindow (dpy, Tmp_win->hilite_w);
  218. X+ 
  219. X+ SetBorder (Tmp_win, True);    
  220. X+ 
  221. X+ if (Tmp_win->list) ActiveIconManager(Tmp_win->list);
  222. X+ 
  223. X+ /*
  224. X+    if (Scr->Focus && Scr->Focus->w != Tmp_win->w)
  225. X+    {
  226. X+    int root_x, root_y, x, y;
  227. X+    Window root, child, mask;
  228. X+    
  229. X+    if (XQueryPointer(dpy, Scr->Focus->w, 
  230. X+    &root, &child, 
  231. X+    &root_x, &root_y, &x, &y, &mask))
  232. X+    {
  233. X+    XWarpPointer(dpy, Scr->Focus->w, Tmp_win->w,
  234. X+    0, 0, 0, 0, x, y);
  235. X+    } 
  236. X+    }
  237. X+    */
  238. X+ 
  239. X+ Scr->Focus = Tmp_win;
  240. X+ }
  241. X+ 
  242. X+ void
  243. X+ HandleFocusOut(event)
  244. X+ 
  245. X+ XFocusOutEvent *event;
  246. X+ 
  247. X+ {
  248. X+ 
  249. X+ #ifdef TRACE_FOCUS
  250. X+ printf("-0x%x mode=%d, detail=%d\n", Tmp_win, event->mode, event->detail);
  251. X+ #endif
  252. X+ 
  253. X+ SetBorder(Tmp_win, False);
  254. X+ if (Tmp_win->hilite_w)
  255. X+     XUnmapWindow(dpy, Tmp_win->hilite_w);
  256. X+ 
  257. X+ if (Tmp_win->list) NotActiveIconManager(Tmp_win->list);
  258. X+ 
  259. X+ if (Scr->Focus == Tmp_win)
  260. X+     Scr->Focus= NULL;
  261. X+ 
  262. X+ }
  263. X+ 
  264. X+ void
  265. X+ HandleFocusChange()
  266. X+ 
  267. X+ {
  268. X+  XEvent *event;
  269. X+ 
  270. X+  if (Tmp_win)
  271. X+      {
  272. X+      event = LastFocusEvent(Event.xany.window,&Event);
  273. X+ 
  274. X+      if ( event != NULL)
  275. X+      {
  276. X+      if (event->type == FocusIn)
  277. X+          HandleFocusIn(event);
  278. X+      else
  279. X+          HandleFocusOut(event);
  280. X+      }
  281. X+      }
  282. X+ }
  283. X+ 
  284. X+ void
  285. X+ SynthesiseFocusOut(w)
  286. X+ 
  287. X+ Window w;
  288. X+ 
  289. X+ {
  290. X+ XEvent event;
  291. X+ 
  292. X+ event.type=FocusOut;
  293. X+ event.xfocus.window=w;
  294. X+ event.xfocus.mode=NotifyNormal;
  295. X+ event.xfocus.detail=NotifyPointer;
  296. X+ 
  297. X+ XPutBackEvent(dpy, &event);
  298. X+ 
  299. X+ }
  300. X+ void
  301. X+ SynthesiseFocusIn(w)
  302. X+ 
  303. X+ Window w;
  304. X+ 
  305. X+ {
  306. X+ XEvent event;
  307. X+ 
  308. X+ event.type=FocusIn;
  309. X+ event.xfocus.window=w;
  310. X+ event.xfocus.mode=NotifyNormal;
  311. X+ event.xfocus.detail=NotifyPointer;
  312. X+ 
  313. X+ XPutBackEvent(dpy, &event);
  314. X+ 
  315. X+ }
  316. X+ 
  317. X+ 
  318. X  /***********************************************************************
  319. X   *
  320. X   *  Procedure:
  321. X***************
  322. X*** 1888,1901 ****
  323. X           * focus on this window
  324. X           */
  325. X          if (Scr->FocusRoot && (!scanArgs.leaves || scanArgs.inferior)) {
  326. X!         if (Tmp_win->list) ActiveIconManager(Tmp_win->list);
  327. X          if (Tmp_win->mapped) {
  328. X-             /*
  329. X-              * unhighlight old focus window
  330. X-              */
  331. X-             if (Scr->Focus &&
  332. X-             Scr->Focus != Tmp_win && Tmp_win->hilite_w)
  333. X-               XUnmapWindow(dpy, Scr->Focus->hilite_w);
  334. X  
  335. X              /*
  336. X               * If entering the frame or the icon manager, then do 
  337. X--- 2056,2063 ----
  338. X           * focus on this window
  339. X           */
  340. X          if (Scr->FocusRoot && (!scanArgs.leaves || scanArgs.inferior)) {
  341. X! /*        if (Tmp_win->list) ActiveIconManager(Tmp_win->list); */
  342. X          if (Tmp_win->mapped) {
  343. X  
  344. X              /*
  345. X               * If entering the frame or the icon manager, then do 
  346. X***************
  347. X*** 1909,1925 ****
  348. X               */
  349. X              if (ewp->window == Tmp_win->frame ||
  350. X              (Tmp_win->list && ewp->window == Tmp_win->list->w)) {
  351. X-             if (Tmp_win->hilite_w)                /* 1 */
  352. X-               XMapWindow (dpy, Tmp_win->hilite_w);
  353. X              if (!scanArgs.leaves && !scanArgs.enters)
  354. X                  InstallWindowColormaps (EnterNotify,    /* 2 */
  355. X                              &Scr->TwmRoot);
  356. X-             SetBorder (Tmp_win, True);            /* 3 */
  357. X              if (Tmp_win->title_w && Scr->TitleFocus)    /* 4 */
  358. X                SetFocus (Tmp_win);
  359. X              if (Tmp_win->protocols & DoesWmTakeFocus)    /* 5 */
  360. X                SendTakeFocusMessage (Tmp_win, ewp->time);
  361. X!             Scr->Focus = Tmp_win;
  362. X              } else if (ewp->window == Tmp_win->w) {
  363. X              /*
  364. X               * If we are entering the application window, install
  365. X--- 2071,2088 ----
  366. X               */
  367. X              if (ewp->window == Tmp_win->frame ||
  368. X              (Tmp_win->list && ewp->window == Tmp_win->list->w)) {
  369. X              if (!scanArgs.leaves && !scanArgs.enters)
  370. X                  InstallWindowColormaps (EnterNotify,    /* 2 */
  371. X                              &Scr->TwmRoot);
  372. X              if (Tmp_win->title_w && Scr->TitleFocus)    /* 4 */
  373. X                SetFocus (Tmp_win);
  374. X              if (Tmp_win->protocols & DoesWmTakeFocus)    /* 5 */
  375. X                SendTakeFocusMessage (Tmp_win, ewp->time);
  376. X!             else if (!Scr->TitleFocus 
  377. X!                  && Tmp_win->wmhints 
  378. X!                  && Tmp_win->wmhints->input
  379. X!                  && Event.xcrossing.focus)
  380. X!                 SynthesiseFocusIn(Tmp_win->w);
  381. X              } else if (ewp->window == Tmp_win->w) {
  382. X              /*
  383. X               * If we are entering the application window, install
  384. X***************
  385. X*** 1927,1932 ****
  386. X--- 2090,2099 ----
  387. X               */
  388. X              if (!scanArgs.leaves || scanArgs.inferior)
  389. X                  InstallWindowColormaps(EnterNotify, Tmp_win);
  390. X+ 
  391. X+             if (Event.xcrossing.focus)
  392. X+                                 SynthesiseFocusIn(Tmp_win->w);
  393. X+ 
  394. X              }
  395. X          }            /* end if Tmp_win->mapped */
  396. X          }                /* end if FocusRoot */
  397. X***************
  398. X*** 2061,2074 ****
  399. X  
  400. X          if ((Event.xcrossing.window == Tmp_win->frame &&
  401. X              !scanArgs.matches) || inicon) {
  402. X-             if (Tmp_win->list) NotActiveIconManager(Tmp_win->list);
  403. X-             if (Tmp_win->hilite_w)
  404. X-               XUnmapWindow (dpy, Tmp_win->hilite_w);
  405. X-             SetBorder (Tmp_win, False);
  406. X              if (Scr->TitleFocus ||
  407. X              Tmp_win->protocols & DoesWmTakeFocus)
  408. X!               SetFocus ((TwmWindow *) NULL);
  409. X!             Scr->Focus = NULL;
  410. X          } else if (Event.xcrossing.window == Tmp_win->w &&
  411. X                  !scanArgs.enters) {
  412. X              InstallWindowColormaps (LeaveNotify, &Scr->TwmRoot);
  413. X--- 2228,2240 ----
  414. X  
  415. X          if ((Event.xcrossing.window == Tmp_win->frame &&
  416. X              !scanArgs.matches) || inicon) {
  417. X              if (Scr->TitleFocus ||
  418. X              Tmp_win->protocols & DoesWmTakeFocus)
  419. X!             SetFocus ((TwmWindow *) NULL);
  420. X!             /* pretend there was a focus out as sometimes 
  421. X!                we don't get one. */
  422. X!             if ( Event.xcrossing.focus)
  423. X!             SynthesiseFocusOut(Tmp_win->w);
  424. X          } else if (Event.xcrossing.window == Tmp_win->w &&
  425. X                  !scanArgs.enters) {
  426. X              InstallWindowColormaps (LeaveNotify, &Scr->TwmRoot);
  427. END_OF_twm_focus_patch/twm_focus_patch.r4
  428. if test 8157 -ne `wc -c <twm_focus_patch/twm_focus_patch.r4`; then
  429.     echo shar: \"twm_focus_patch/twm_focus_patch.r4\" unpacked with wrong size!
  430. fi
  431. # end of overwriting check
  432. fi
  433. if test -f twm_focus_patch/twm_focus_patch.r5 -a "${1}" != "-c" ; then 
  434.   echo shar: Will not over-write existing file \"twm_focus_patch/twm_focus_patch.r5\"
  435. else
  436. echo shar: Extracting \"twm_focus_patch/twm_focus_patch.r5\" \(9695 characters\)
  437. sed "s/^X//" >twm_focus_patch/twm_focus_patch.r5 <<'END_OF_twm_focus_patch/twm_focus_patch.r5'
  438. X*** add_window.c.orig    Mon Sep  7 18:41:41 1992
  439. X--- add_window.c    Mon Sep  7 18:42:15 1992
  440. X***************
  441. X*** 754,759 ****
  442. X--- 754,760 ----
  443. X      valuemask = (CWEventMask | CWDontPropagate);
  444. X      attributes.event_mask = (StructureNotifyMask | PropertyChangeMask |
  445. X                   ColormapChangeMask | VisibilityChangeMask |
  446. X+                  FocusChangeMask |
  447. X                   EnterWindowMask | LeaveWindowMask);
  448. X      attributes.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask;
  449. X      XChangeWindowAttributes (dpy, tmp_win->w, valuemask, &attributes);
  450. X*** events.c.orig    Mon Sep  7 18:40:57 1992
  451. X--- events.c    Mon Sep  7 19:11:56 1992
  452. X***************
  453. X*** 63,73 ****
  454. X  XEvent Event;            /* the current event */
  455. X  TwmWindow *Tmp_win;        /* the current twm window */
  456. X  
  457. X- /* Used in HandleEnterNotify to remove border highlight from a window 
  458. X-  * that has not recieved a LeaveNotify event because of a pointer grab 
  459. X-  */
  460. X- TwmWindow *UnHighLight_win = NULL;
  461. X- 
  462. X  Window DragWindow;        /* variables used in moving windows */
  463. X  int origDragX;
  464. X  int origDragY;
  465. X--- 63,68 ----
  466. X***************
  467. X*** 93,98 ****
  468. X--- 88,94 ----
  469. X  void HandleCreateNotify();
  470. X  
  471. X  void HandleShapeNotify ();
  472. X+ void HandleFocusChange ();
  473. X  extern int ShapeEventBase, ShapeErrorBase;
  474. X  
  475. X  void AutoRaiseWindow (tmp)
  476. X***************
  477. X*** 155,160 ****
  478. X--- 151,158 ----
  479. X      EventHandler[KeyPress] = HandleKeyPress;
  480. X      EventHandler[ColormapNotify] = HandleColormapNotify;
  481. X      EventHandler[VisibilityNotify] = HandleVisibilityNotify;
  482. X+     EventHandler[FocusIn] = HandleFocusChange;
  483. X+     EventHandler[FocusOut] = HandleFocusChange;
  484. X      if (HasShape)
  485. X      EventHandler[ShapeEventBase+ShapeNotify] = HandleShapeNotify;
  486. X  }
  487. X***************
  488. X*** 545,550 ****
  489. X--- 543,713 ----
  490. X  
  491. X  
  492. X  
  493. X+ /*
  494. X+  * LastFocusEvent -- skip over focus in/out events for this
  495. X+  *        window.
  496. X+  */
  497. X+ 
  498. X+ 
  499. X+ 
  500. X+ static XEvent *
  501. X+ LastFocusEvent(w, first)
  502. X+ 
  503. X+ Window *w;
  504. X+ XEvent *first;
  505. X+ 
  506. X+ 
  507. X+ {
  508. X+ static XEvent current;
  509. X+ XEvent *last, new;
  510. X+ 
  511. X+ new= *first;
  512. X+ last=NULL;
  513. X+ 
  514. X+ do {
  515. X+    if ( (new.type == FocusIn || new.type == FocusOut) 
  516. X+        && new.xfocus.mode == NotifyNormal 
  517. X+        && (new.xfocus.detail == NotifyNonlinear 
  518. X+        || new.xfocus.detail == NotifyPointer
  519. X+        || new.xfocus.detail == NotifyAncestor
  520. X+        || (new.xfocus.detail == NotifyNonlinearVirtual)
  521. X+        ))
  522. X+        {
  523. X+        current=new;
  524. X+        last= ¤t;
  525. X+ #ifdef TRACE_FOCUS
  526. X+        printf("! %s 0x%x mode=%d, detail=%d\n", new.xfocus.type == FocusIn?"in":"out",Tmp_win,new.xfocus.mode, new.xfocus.detail);
  527. X+ #endif       
  528. X+        }
  529. X+ else
  530. X+     {
  531. X+ #ifdef TRACE_FOCUS
  532. X+     printf("~ %s 0x%x mode=%d, detail=%d\n", new.xfocus.type == FocusIn?"in":"out",Tmp_win,new.xfocus.mode, new.xfocus.detail);
  533. X+ #endif
  534. X+        }
  535. X+    } while (XCheckWindowEvent(dpy, w, FocusChangeMask, &new));
  536. X+ 
  537. X+ return last;
  538. X+ }
  539. X+ 
  540. X+ /*
  541. X+  * HandleFocusIn -- deal with the focus moving under us.
  542. X+  */
  543. X+ 
  544. X+ void
  545. X+ HandleFocusIn(event)
  546. X+ 
  547. X+ XFocusInEvent *event;
  548. X+ 
  549. X+ {
  550. X+ 
  551. X+ #ifdef TRACE_FOCUS
  552. X+ printf("+0x%x mode=%d, detail=%d\n", Tmp_win, event->mode, event->detail);
  553. X+ #endif
  554. X+ 
  555. X+ 
  556. X+ if (Tmp_win->hilite_w)    
  557. X+     XMapWindow (dpy, Tmp_win->hilite_w);
  558. X+ 
  559. X+ SetBorder (Tmp_win, True);    
  560. X+ 
  561. X+ if (Tmp_win->list) ActiveIconManager(Tmp_win->list);
  562. X+ 
  563. X+ /*
  564. X+    if (Scr->Focus && Scr->Focus->w != Tmp_win->w)
  565. X+    {
  566. X+    int root_x, root_y, x, y;
  567. X+    Window root, child, mask;
  568. X+    
  569. X+    if (XQueryPointer(dpy, Scr->Focus->w, 
  570. X+    &root, &child, 
  571. X+    &root_x, &root_y, &x, &y, &mask))
  572. X+    {
  573. X+    XWarpPointer(dpy, Scr->Focus->w, Tmp_win->w,
  574. X+    0, 0, 0, 0, x, y);
  575. X+    } 
  576. X+    }
  577. X+    */
  578. X+ 
  579. X+ Scr->Focus = Tmp_win;
  580. X+ }
  581. X+ 
  582. X+ void
  583. X+ HandleFocusOut(event)
  584. X+ 
  585. X+ XFocusOutEvent *event;
  586. X+ 
  587. X+ {
  588. X+ 
  589. X+ #ifdef TRACE_FOCUS
  590. X+ printf("-0x%x mode=%d, detail=%d\n", Tmp_win, event->mode, event->detail);
  591. X+ #endif
  592. X+ 
  593. X+ SetBorder(Tmp_win, False);
  594. X+ if (Tmp_win->hilite_w)
  595. X+     XUnmapWindow(dpy, Tmp_win->hilite_w);
  596. X+ 
  597. X+ if (Tmp_win->list) NotActiveIconManager(Tmp_win->list);
  598. X+ 
  599. X+ if (Scr->Focus == Tmp_win)
  600. X+     Scr->Focus= NULL;
  601. X+ 
  602. X+ }
  603. X+ 
  604. X+ void
  605. X+ HandleFocusChange()
  606. X+ 
  607. X+ {
  608. X+  XEvent *event;
  609. X+ 
  610. X+  if (Tmp_win)
  611. X+      {
  612. X+      event = LastFocusEvent(Event.xany.window,&Event);
  613. X+ 
  614. X+      if ( event != NULL)
  615. X+      {
  616. X+      if (event->type == FocusIn)
  617. X+          HandleFocusIn(event);
  618. X+      else
  619. X+          HandleFocusOut(event);
  620. X+      }
  621. X+      }
  622. X+ }
  623. X+ 
  624. X+ void
  625. X+ SynthesiseFocusOut(w)
  626. X+ 
  627. X+ Window w;
  628. X+ 
  629. X+ {
  630. X+ XEvent event;
  631. X+ 
  632. X+ event.type=FocusOut;
  633. X+ event.xfocus.window=w;
  634. X+ event.xfocus.mode=NotifyNormal;
  635. X+ event.xfocus.detail=NotifyPointer;
  636. X+ 
  637. X+ XPutBackEvent(dpy, &event);
  638. X+ 
  639. X+ }
  640. X+ void
  641. X+ SynthesiseFocusIn(w)
  642. X+ 
  643. X+ Window w;
  644. X+ 
  645. X+ {
  646. X+ XEvent event;
  647. X+ 
  648. X+ event.type=FocusIn;
  649. X+ event.xfocus.window=w;
  650. X+ event.xfocus.mode=NotifyNormal;
  651. X+ event.xfocus.detail=NotifyPointer;
  652. X+ 
  653. X+ XPutBackEvent(dpy, &event);
  654. X+ 
  655. X+ }
  656. X+ 
  657. X+ 
  658. X  /***********************************************************************
  659. X   *
  660. X   *  Procedure:
  661. X***************
  662. X*** 2014,2033 ****
  663. X      XEvent dummy;
  664. X      
  665. X      /*
  666. X-      * Save the id of the window entered.  This will be used to remove
  667. X-      * border highlight on entering the next application window.
  668. X-      */
  669. X-     if (UnHighLight_win && ewp->window != UnHighLight_win->w) {
  670. X-       SetBorder (UnHighLight_win, False);    /* application window */
  671. X-       if (UnHighLight_win->list) /* in the icon box */
  672. X-     NotActiveIconManager(UnHighLight_win->list);
  673. X-     }
  674. X-     if (ewp->window == Scr->Root)
  675. X-       UnHighLight_win = NULL;
  676. X-     else if (Tmp_win)
  677. X-       UnHighLight_win = Tmp_win;
  678. X- 
  679. X-     /*
  680. X       * if we aren't in the middle of menu processing
  681. X       */
  682. X      if (!ActiveMenu) {
  683. X--- 2177,2182 ----
  684. X***************
  685. X*** 2065,2078 ****
  686. X           * focus on this window
  687. X           */
  688. X          if (Scr->FocusRoot && (!scanArgs.leaves || scanArgs.inferior)) {
  689. X!         if (Tmp_win->list) ActiveIconManager(Tmp_win->list);
  690. X          if (Tmp_win->mapped) {
  691. X-             /*
  692. X-              * unhighlight old focus window
  693. X-              */
  694. X-             if (Scr->Focus &&
  695. X-             Scr->Focus != Tmp_win && Tmp_win->hilite_w)
  696. X-               XUnmapWindow(dpy, Scr->Focus->hilite_w);
  697. X  
  698. X              /*
  699. X               * If entering the frame or the icon manager, then do 
  700. X--- 2214,2221 ----
  701. X           * focus on this window
  702. X           */
  703. X          if (Scr->FocusRoot && (!scanArgs.leaves || scanArgs.inferior)) {
  704. X! /*        if (Tmp_win->list) ActiveIconManager(Tmp_win->list); */
  705. X          if (Tmp_win->mapped) {
  706. X  
  707. X              /*
  708. X               * If entering the frame or the icon manager, then do 
  709. X***************
  710. X*** 2087,2106 ****
  711. X               */
  712. X              if (ewp->window == Tmp_win->frame ||
  713. X              (Tmp_win->list && ewp->window == Tmp_win->list->w)) {
  714. X-             if (Tmp_win->hilite_w)                /* 1 */
  715. X-               XMapWindow (dpy, Tmp_win->hilite_w);
  716. X              if (!scanArgs.leaves && !scanArgs.enters)
  717. X                  InstallWindowColormaps (EnterNotify,    /* 2 */
  718. X                              &Scr->TwmRoot);
  719. X-             SetBorder (Tmp_win, True);            /* 3 */
  720. X              if (Tmp_win->title_w && Scr->TitleFocus &&    /* 4 */
  721. X                  Tmp_win->wmhints && Tmp_win->wmhints->input)
  722. X                SetFocus (Tmp_win, ewp->time);
  723. X!             if (Scr->NoTitlebar && Scr->TitleFocus &&    /*4a */
  724. X                  Tmp_win->wmhints && Tmp_win->wmhints->input)
  725. X                SetFocus (Tmp_win, ewp->time);
  726. X              if (Tmp_win->protocols & DoesWmTakeFocus)    /* 5 */
  727. X                SendTakeFocusMessage (Tmp_win, ewp->time);
  728. X              Scr->Focus = Tmp_win;
  729. X              } else if (ewp->window == Tmp_win->w) {
  730. X              /*
  731. X--- 2230,2251 ----
  732. X               */
  733. X              if (ewp->window == Tmp_win->frame ||
  734. X              (Tmp_win->list && ewp->window == Tmp_win->list->w)) {
  735. X              if (!scanArgs.leaves && !scanArgs.enters)
  736. X                  InstallWindowColormaps (EnterNotify,    /* 2 */
  737. X                              &Scr->TwmRoot);
  738. X              if (Tmp_win->title_w && Scr->TitleFocus &&    /* 4 */
  739. X                  Tmp_win->wmhints && Tmp_win->wmhints->input)
  740. X                SetFocus (Tmp_win, ewp->time);
  741. X!             else if (Scr->NoTitlebar && Scr->TitleFocus &&    /*4a */
  742. X                  Tmp_win->wmhints && Tmp_win->wmhints->input)
  743. X                SetFocus (Tmp_win, ewp->time);
  744. X              if (Tmp_win->protocols & DoesWmTakeFocus)    /* 5 */
  745. X                SendTakeFocusMessage (Tmp_win, ewp->time);
  746. X+             else if (!Scr->TitleFocus 
  747. X+                  && Tmp_win->wmhints 
  748. X+                  && Tmp_win->wmhints->input
  749. X+                  && Event.xcrossing.focus)
  750. X+                 SynthesiseFocusIn(Tmp_win->w);
  751. X              Scr->Focus = Tmp_win;
  752. X              } else if (ewp->window == Tmp_win->w) {
  753. X              /*
  754. X***************
  755. X*** 2109,2114 ****
  756. X--- 2254,2262 ----
  757. X               */
  758. X              if (!scanArgs.leaves || scanArgs.inferior)
  759. X                  InstallWindowColormaps(EnterNotify, Tmp_win);
  760. X+ 
  761. X+             if (Event.xcrossing.focus)
  762. X+                 SynthesiseFocusIn(Tmp_win->w);
  763. X              }
  764. X          }            /* end if Tmp_win->mapped */
  765. X          if (Tmp_win->wmhints != NULL &&
  766. X***************
  767. X*** 2253,2266 ****
  768. X  
  769. X          if ((Event.xcrossing.window == Tmp_win->frame &&
  770. X              !scanArgs.matches) || inicon) {
  771. X!             if (Tmp_win->list) NotActiveIconManager(Tmp_win->list);
  772. X!             if (Tmp_win->hilite_w)
  773. X!               XUnmapWindow (dpy, Tmp_win->hilite_w);
  774. X!             SetBorder (Tmp_win, False);
  775. X              if (Scr->TitleFocus ||
  776. X              Tmp_win->protocols & DoesWmTakeFocus)
  777. X!               SetFocus ((TwmWindow *) NULL, Event.xcrossing.time);
  778. X!             Scr->Focus = NULL;
  779. X          } else if (Event.xcrossing.window == Tmp_win->w &&
  780. X                  !scanArgs.enters) {
  781. X              InstallWindowColormaps (LeaveNotify, &Scr->TwmRoot);
  782. X--- 2401,2416 ----
  783. X  
  784. X          if ((Event.xcrossing.window == Tmp_win->frame &&
  785. X              !scanArgs.matches) || inicon) {
  786. X! 
  787. X              if (Scr->TitleFocus ||
  788. X              Tmp_win->protocols & DoesWmTakeFocus)
  789. X!             SetFocus ((TwmWindow *) NULL, Event.xcrossing.time);
  790. X! 
  791. X!             /* pretend there was a focus out as sometimes 
  792. X!                we don't get one. */
  793. X!             if ( Event.xcrossing.focus)
  794. X!             SynthesiseFocusOut(Tmp_win->w);
  795. X! 
  796. X          } else if (Event.xcrossing.window == Tmp_win->w &&
  797. X                  !scanArgs.enters) {
  798. X              InstallWindowColormaps (LeaveNotify, &Scr->TwmRoot);
  799. END_OF_twm_focus_patch/twm_focus_patch.r5
  800. if test 9695 -ne `wc -c <twm_focus_patch/twm_focus_patch.r5`; then
  801.     echo shar: \"twm_focus_patch/twm_focus_patch.r5\" unpacked with wrong size!
  802. fi
  803. # end of overwriting check
  804. fi
  805. echo shar: End of shell archive.
  806. exit 0
  807.