home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gwm18a.zip / data / en-recover.gwm < prev    next >
Lisp/Scheme  |  1995-07-03  |  3KB  |  94 lines

  1. ;;From: Eyvind Ness <eyvind@hrp.no>
  2. ;;Date: Wed, 22 Jan 92 13:30 GMT
  3. ;;Reply-To: Eyvind.Ness@hrp.no
  4. ;;To: gwm-talk@mirsa.inria.fr
  5. ;;Subject: lost windows and how to recover them
  6.  
  7. ;; Here is a little GWM code to recover from major window lossage.
  8.  
  9. ;; I have experienced that Xclients suddenly become out of GWM's reach due
  10. ;; to corrupted values for window co-ordinates, size, mapped-status etc. In
  11. ;; case some of you have seen similar problems, you may find the follwing
  12. ;; code-fragments of interest.
  13. ;; 
  14. ;; Eyvind.
  15. ;; 
  16. ;; 
  17. ;; +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  18. ;;  Eyvind Ness                    Internet Email: eyvind@hrp.no
  19. ;;  Research Scientist             Phone: +47 9 183100
  20. ;;  Control Room Systems Division  Fax: +47 9 187109
  21. ;;  OECD Halden Reactor Project    Surface Mail: P.O. Box 173, N-1751 Halden
  22. ;;  Norway
  23. ;; +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  24.  
  25. ;;;
  26. ;;; Put this at the bottom of your ~/.profile.gwm
  27.  
  28. (require 'dvrooms)     ; or remove the call to (dvroom-reattach) below
  29.  
  30. ;;; make a new menu entry, or modify standard-behaviour, if you prefer.
  31. (if (not (boundp 'en-recover.menu-added)) (progn
  32.     (setq en-recover.menu-added t)
  33.     
  34.     (insert-at
  35.       '(item-make "Recover lost windows" (recover-lost-windows))
  36.       root-pop-items 1)
  37. ))
  38.  
  39. (defun recover-lost-windows ()
  40.   (progn
  41.     (print "\nRecovering lost windows...\n")
  42.     (setq ix 20) (setq iy 100)
  43.     (setq window-list (list-of-windows 'window))
  44.     
  45.     ;; Now, sort all windows ordered by their width:
  46.     (setq
  47.      window-list
  48.      (sort
  49.       window-list
  50.       '(lambda (w1 w2)
  51.     (compare (with (window w2) window-width)
  52.      (with (window w1) window-width)))))
  53.     
  54.     ;; Then, arrange potential patological cases from top-left to
  55.     ;; bottom-right. Patology is suspected in the following situations:
  56.     ;;        - the window is unmapped
  57.     ;;         - current position is outside the screen
  58.     ;;        - the window width > the screen width, or < 5 pixels
  59.     ;;        - the window height > the screen height, or < 5 pixels
  60.     (for window window-list
  61.      (if (or 
  62.           (not window-is-mapped)
  63.           (< window-width 5)
  64.           (> window-width screen-width)
  65.           (< window-height 5)
  66.           (> window-height screen-height)
  67.           (< window-x 0)
  68.           (> window-x screen-width)
  69.           (< window-y 0)
  70.           (> window-y screen-height))
  71.          (progn
  72.            (map-window window)
  73.            (move-window window ix iy)
  74.            (raise-window)
  75.            (if (or
  76.             (< window-width 5) (< window-height 5)
  77.             (> window-width screen-width)
  78.             (> window-height screen-height))
  79.            ;; restore the corrupted values to some arbitrary,
  80.            ;; though not totally absurd, value:
  81.            (resize-window 100 100))
  82.            (print window-status
  83.               " " window-name
  84.               "(" window ") moved to (" ix ", " iy ")\n")
  85.            (setq ix (+ ix 20)) (setq iy (+ iy 20)))))
  86.     ;; Strictly speaking, this could be defined as a separate item in
  87.     ;; the main menu. Added here for convenience only:
  88.     (dvroom-reattach)
  89.     ;; Typically, you dont't want the icons to be stacked, so re-pack
  90.     ;; them if disturbed by the procedure above:
  91.     (rows.pack)
  92.     (print "\nRecovering lost windows... done.\n")))
  93.  
  94.