Article View: gnu.epoch.misc
Article #1613map.el: Fix iconification of screens & minibuffer
From: Gillmer J. Derge
Date: Fri, 03 Jan 1992 20:42
Date: Fri, 03 Jan 1992 20:42
136 lines
6253 bytes
6253 bytes
Enclosed is an el file that corrects what I consider a problem with the
way epoch screens are iconified and de-iconified via the minibuffer. Really,
it's a window manager problem, not an epoch problem, but it's easier to fix
through epoch.
Unfortunately, it's much easier to demonstrate the problem than it is to
describe it, but I've made an attempt in the comments at the beginning of the
file. If it's not clear what I'm talking about, then you probably aren't
bothered by it.
Read the beginning comments for brief documentation. Installation is
simply a matter of adding a (load "map") to your .emacs. This has only been
tested on a Sparc using twm, but it should work on any architecture that runs
epoch. It may be somewhat window manager specific, I don't know.
Please let me
know about any problems or enhancements.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Gill Derge <derge@crd.ge.com>
P.O. Box 8
Schenectady, NY 12301 (518) 387-6382
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;;------------------------------CUT HERE-------------------------------
;; Fix a problem with epoch iconification
;;
;; Copying is permitted under those conditions described by the GNU
;; General Public License.
;;
;; Copyright (C) 1991 Gillmer J. Derge
;;
;; Author: Gillmer J. Derge (derge@crd.ge.com) 12/91
;;
;; Purpose:
;; Under normal circumstances, all epoch screens are in the window
;; group of the minibuffer. Twm, and perhaps other window managers,
;; thus iconify and de-iconify all epoch screens when the minibuffer
;; is iconified or de-iconified.
;;
;; As a result, a strange, and sometimes annoying effect is produced.
;; Suppose, for example, that you have 3 epoch screens and the minibuffer.
;; You iconify screen1, because you don't want to work with it for now.
;; Some time later, you iconify the minibuffer, then still later you
;; de-iconify it. Now screen1 has been re-opened.
;;
;; It's my opinion that a more desireable behaviour would be to
;; only re-open those screens that were open when the minibuffer
;; is iconified. This .el file implements that behaviour. A screen
;; that is iconified by itself will stay closed until it is explicitly
;; de-iconified. Those screens closed indirectly by iconifying the
;; minibuffer will likewise be re-opened indirectly when the minibuffer
;; is de-iconified.
;;
;; Bugs:
;; This will install an event handler for map and unmap events.
;; Thus, if you already have a handler installed (check with ^Z-e),
;; it will be overridden. If desired, this can be corrected by
;; adding a call to the original handler either before or after the
;; processing in map::event-handler.
;;
;; Please notify me of any others (enhancements & comments) welcome
;; too. Send to derge@crd.ge.com.
;;
;; Algorithm:
;; As mentioned above, the cause of the problem is that all screens
;; are in the minibuffer's window group. Thus, the first step is
;; to put them all in their own group by default. As a side-effect
;; of this step, the window manager will no longer iconify all open
;; screens when the minibuffer is iconified.
;;
;; Thus, this process must be performed manually. Furthermore,
;; in order to guarantee that those windows will be re-opened,
;; they must be temporarily placed in the minibuffer's window
;; group. Once they are re-opened, the window group should be
;; restored to its original value.
;;
(defun map::singleton-group (screen)
"Put SCREEN into its own window group."
(let* ((wm-hints (get-property "WM_HINTS" screen))
(type (car wm-hints)))
(setf (nth 8 wm-hints)
(string-to-resource (resource-to-string (xid-of-screen screen))
(resource-to-type type)))
(set-property "WM_HINTS" wm-hints screen)
)
)
(defun map::minibuf-group (screen)
"Put SCREEN into the minibuffer's window group."
(let* ((wm-hints (get-property "WM_HINTS" screen))
(type (car wm-hints)))
(setf (nth 8 wm-hints)
(string-to-resource (resource-to-string
(xid-of-screen (minibuf-screen)))
(resource-to-type type)))
(set-property "WM_HINTS" wm-hints screen)
)
)
(defun map::event-handler (type value screen)
"Handler for map events. This is how we catch iconification and
de-iconification."
(if (equal screen (minibuf-screen))
(if (not value) ; iconify minibuffer
(progn
;; Put all open screens into the minibuffer's group
(mapcar 'map::minibuf-group (screen-list))
;; Close the open screens (DO NOT USE UNMAP-SCREEN HERE)
(mapcar 'iconify-screen (screen-list))
)
)
;; Check for de-iconify other screen; make sure it's in its own group
(if value (map::singleton-group screen))
)
)
;; Redefine create screen, so screens are created in their own window group
(defvar map::orig-create-screen (symbol-function 'create-screen)
"Value of the create-screen function before loading mapping.el")
(defun create-screen (&optional buffer alist)
(let ((screen (funcall map::orig-create-screen buffer alist)))
(map::singleton-group screen)
screen
)
)
;; Make sure all current screens are in their own group now. If the minibuffer
;; is closed now, then leave them alone, or else the screens could be lost.
(if (screen-mapped-p (minibuf-screen))
(mapcar 'map::singleton-group (screen-list t)))
;; Install the new event handler now that all the prep work is done
(push-event 'map 'map::event-handler)
Technical Details
Message-ID:
<26159@crdgw1.crd.ge.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!crdgw1!visa!dergeShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc7ee,dde8d6526182e46b,start X-Google-Attributes: gidfc7ee,public X-Google-ArrivalTime: 1992-01-03 14:12:17 PST Path: arc1-ca.pugleaf.net!sparky!uunet!crdgw1!visa!derge From: derge@visa.crd.ge.com (Gillmer J. Derge) Newsgroups: gnu.epoch.misc Subject: map.el: Fix iconification of screens & minibuffer Message-ID: <26159@crdgw1.crd.ge.com> Date: 3 Jan 92 20:42:38 GMT Sender: news@crdgw1.crd.ge.com Reply-To: derge@crd.ge.com Organization: GE Corporate R&D Center, Schenectady, NY Lines: 136