0
|
1 ;;; Window management code for VM
|
|
2 ;;; Copyright (C) 1989, 1990, 1991, 1993, 1994, 1995 Kyle E. Jones
|
|
3 ;;;
|
|
4 ;;; This program is free software; you can redistribute it and/or modify
|
|
5 ;;; it under the terms of the GNU General Public License as published by
|
|
6 ;;; the Free Software Foundation; either version 1, or (at your option)
|
|
7 ;;; any later version.
|
|
8 ;;;
|
|
9 ;;; This program is distributed in the hope that it will be useful,
|
|
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 ;;; GNU General Public License for more details.
|
|
13 ;;;
|
|
14 ;;; You should have received a copy of the GNU General Public License
|
|
15 ;;; along with this program; if not, write to the Free Software
|
|
16 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
17
|
|
18 (provide 'vm-window)
|
|
19
|
|
20 (defun vm-display (buffer display commands configs)
|
|
21 ;; the clearinghouse VM display function.
|
|
22 ;;
|
|
23 ;; First arg BUFFER non-nil is a buffer to display or undisplay.
|
|
24 ;; nil means there is no request to display or undisplay a
|
|
25 ;; buffer.
|
|
26 ;;
|
|
27 ;; Second arg DISPLAY non-nil means to display the buffer, nil means
|
|
28 ;; to undisplay it. This function guarantees to display the
|
|
29 ;; buffer if requested. Undisplay is not guaranteed.
|
|
30 ;;
|
|
31 ;; Third arg COMMANDS is a list of symbols. this-command must
|
|
32 ;; match one of these symbols for a window configuration to be
|
|
33 ;; applied.
|
|
34 ;;
|
|
35 ;; Fourth arg CONFIGS is a list of window configurations to try.
|
|
36 ;; vm-set-window-configuration will step through the list looking
|
|
37 ;; for an existing configuration, and apply the one it finds.
|
|
38 ;;
|
|
39 ;; Display is done this way:
|
|
40 ;; 1. if the buffer is visible in an invisible frame, make that frame visible
|
|
41 ;; 2. if the buffer is already displayed, quit
|
|
42 ;; 3. if vm-display-buffer-hook in non-nil
|
|
43 ;; run the hooks
|
|
44 ;; use the selected window/frame to display the buffer
|
|
45 ;; quit
|
|
46 ;; 4. apply a window configuration
|
|
47 ;; if the buffer is displayed now, quit
|
|
48 ;; 5. call vm-display-buffer which will display the buffer.
|
|
49 ;;
|
|
50 ;; Undisplay is done this way:
|
|
51 ;; 1. if the buffer is not displayed, quit
|
|
52 ;; 2. if vm-undisplay-buffer-hook is non-nil
|
|
53 ;; run the hooks
|
|
54 ;; quit
|
|
55 ;; 3. apply a window configuration
|
|
56 ;; 4, if a window configuration was applied
|
|
57 ;; quit
|
|
58 ;; 5. call vm-undisplay-buffer which will make the buffer
|
|
59 ;; disappear from at least one window/frame.
|
|
60 ;;
|
|
61 ;; If display/undisplay is not requested, only window
|
|
62 ;; configuration is done, and only then if the value of
|
|
63 ;; this-command is found in the COMMANDS list.
|
|
64 (vm-save-buffer-excursion
|
|
65 (let ((w (and buffer (vm-get-buffer-window buffer))))
|
|
66 (and buffer (set-buffer buffer))
|
|
67 ; (and w display (vm-raise-frame (vm-window-frame w)))
|
|
68 (and w display (vm-window-frame w))
|
|
69 (and w display (not (eq (vm-selected-frame) (vm-window-frame w)))
|
|
70 (vm-select-frame (vm-window-frame w)))
|
|
71 (cond ((and buffer display)
|
|
72 (if (and vm-display-buffer-hook
|
|
73 (null (vm-get-visible-buffer-window buffer)))
|
|
74 (progn (run-hooks 'vm-display-buffer-hook)
|
|
75 (switch-to-buffer buffer)
|
|
76 (vm-record-current-window-configuration nil))
|
|
77 (if (not (and (memq this-command commands)
|
|
78 (apply 'vm-set-window-configuration configs)
|
|
79 (vm-get-visible-buffer-window buffer)))
|
|
80 (vm-display-buffer buffer))))
|
|
81 ((and buffer (not display))
|
|
82 (if (and vm-undisplay-buffer-hook
|
|
83 (vm-get-visible-buffer-window buffer))
|
|
84 (progn (run-hooks 'vm-undisplay-buffer-hook)
|
|
85 (vm-record-current-window-configuration nil))
|
|
86 (if (not (and (memq this-command commands)
|
|
87 (apply 'vm-set-window-configuration configs)))
|
|
88 (vm-undisplay-buffer buffer))))
|
|
89 ((memq this-command commands)
|
|
90 (apply 'vm-set-window-configuration configs))))))
|
|
91
|
|
92 (defun vm-display-buffer (buffer)
|
|
93 (let ((pop-up-windows (eq vm-mutable-windows t))
|
|
94 (pop-up-frames vm-mutable-frames))
|
|
95 (vm-record-current-window-configuration nil)
|
|
96 (if (or pop-up-frames
|
|
97 (and (eq vm-mutable-windows t)
|
|
98 (symbolp
|
|
99 (vm-buffer-to-label
|
|
100 (window-buffer
|
|
101 (selected-window))))))
|
|
102 (select-window (display-buffer buffer))
|
|
103 (switch-to-buffer buffer))))
|
|
104
|
|
105 (defun vm-undisplay-buffer (buffer)
|
|
106 (vm-save-buffer-excursion
|
|
107 (vm-delete-windows-or-frames-on buffer)
|
|
108 (let ((w (vm-get-buffer-window buffer)))
|
|
109 (and w (set-window-buffer w (other-buffer))))))
|
|
110
|
|
111 (defun vm-load-window-configurations (file)
|
|
112 (save-excursion
|
|
113 (let ((work-buffer nil))
|
|
114 (unwind-protect
|
|
115 (progn
|
|
116 (set-buffer (setq work-buffer (get-buffer-create "*vm-wconfig*")))
|
|
117 (erase-buffer)
|
|
118 (setq vm-window-configurations
|
|
119 (condition-case ()
|
|
120 (progn
|
|
121 (insert-file-contents file)
|
|
122 (read (current-buffer)))
|
|
123 (error nil))))
|
|
124 (and work-buffer (kill-buffer work-buffer))))))
|
|
125
|
|
126 (defun vm-store-window-configurations (file)
|
|
127 (save-excursion
|
|
128 (let ((work-buffer nil))
|
|
129 (unwind-protect
|
|
130 (progn
|
|
131 (set-buffer (setq work-buffer (get-buffer-create "*vm-wconfig*")))
|
|
132 (erase-buffer)
|
|
133 (print vm-window-configurations (current-buffer))
|
|
134 (write-region (point-min) (point-max) file nil 0))
|
|
135 (and work-buffer (kill-buffer work-buffer))))))
|
|
136
|
|
137 (defun vm-set-window-configuration (&rest tags)
|
|
138 (catch 'done
|
|
139 (if (not vm-mutable-windows)
|
|
140 (throw 'done nil))
|
|
141 (let ((nonexistent " *vm-nonexistent*")
|
|
142 (nonexistent-summary " *vm-nonexistent-summary*")
|
|
143 (selected-frame (vm-selected-frame))
|
|
144 summary message composition edit config)
|
|
145 (while (and tags (null config))
|
|
146 (setq config (assq (car tags) vm-window-configurations)
|
|
147 tags (cdr tags)))
|
|
148 (or config (setq config (assq 'default vm-window-configurations)))
|
|
149 (or config (throw 'done nil))
|
|
150 (setq config (vm-copy config))
|
|
151 (setq composition (vm-find-composition-buffer t))
|
|
152 (cond ((eq major-mode 'vm-summary-mode)
|
|
153 (if (or (null vm-mail-buffer) (null (buffer-name vm-mail-buffer)))
|
|
154 (throw 'done nil)
|
|
155 (setq summary (current-buffer))
|
|
156 (setq message vm-mail-buffer)))
|
|
157 ((eq major-mode 'vm-mode)
|
|
158 (setq message (current-buffer)))
|
|
159 ((eq major-mode 'vm-virtual-mode)
|
|
160 (setq message (current-buffer)))
|
|
161 ((eq major-mode 'mail-mode)
|
|
162 (if (or (null vm-mail-buffer) (null (buffer-name vm-mail-buffer)))
|
|
163 (throw 'done nil)
|
|
164 (setq message vm-mail-buffer)))
|
|
165 ((eq vm-system-state 'editing)
|
|
166 (if (or (null vm-mail-buffer) (null (buffer-name vm-mail-buffer)))
|
|
167 (throw 'done nil)
|
|
168 (setq edit (current-buffer))
|
|
169 (setq message vm-mail-buffer)))
|
|
170 ;; not in a VM related buffer, bail...
|
|
171 (t (throw 'done nil)))
|
|
172 (set-buffer message)
|
|
173 ;; if this configuration is already the current one, don't
|
|
174 ;; set it up again.
|
|
175 (if (or (and vm-mutable-frames (eq (car config) vm-window-configuration))
|
|
176 (and (not vm-mutable-frames)
|
|
177 (listp vm-window-configuration)
|
|
178 (eq (car config)
|
|
179 (cdr (assq selected-frame vm-window-configuration)))))
|
|
180 (throw 'done nil))
|
|
181 (vm-check-for-killed-summary)
|
|
182 (or summary (setq summary (or vm-summary-buffer nonexistent-summary)))
|
|
183 (or composition (setq composition nonexistent))
|
|
184 (or edit (setq edit nonexistent))
|
|
185 (tapestry-replace-tapestry-element (nth 1 config) 'buffer-name
|
|
186 (function
|
|
187 (lambda (x)
|
|
188 (if (symbolp x)
|
|
189 (symbol-value x)
|
|
190 x ))))
|
|
191 (set-tapestry (nth 1 config) 1)
|
|
192 (and (get-buffer nonexistent)
|
|
193 (vm-delete-windows-or-frames-on nonexistent))
|
|
194 (if (and (vm-get-buffer-window nonexistent-summary)
|
|
195 (not (vm-get-buffer-window message)))
|
|
196 ;; user asked for summary to be displayed but doesn't
|
|
197 ;; have one, nor is the folder buffer displayed. Help
|
|
198 ;; the user not to lose here.
|
|
199 (vm-replace-buffer-in-windows nonexistent-summary message)
|
|
200 (and (get-buffer nonexistent-summary)
|
|
201 (vm-delete-windows-or-frames-on nonexistent-summary)))
|
|
202 (vm-record-current-window-configuration config)
|
|
203 config )))
|
|
204
|
|
205 (defun vm-record-current-window-configuration (config)
|
|
206 ;; this function continues to be a no-op.
|
|
207 ;;
|
|
208 ;; the idea behind this function is that VM can remember what
|
|
209 ;; the current window configuration is and not rebuild the
|
|
210 ;; configuration for the next command if it matches what we
|
|
211 ;; have recorded.
|
|
212 ;;
|
|
213 ;; the problem with this idea is that the user can do things
|
|
214 ;; like C-x 0 and VM has no way of knowing. So VM thinks the
|
|
215 ;; right configuration is displayed when in fact it is not,
|
|
216 ;; which can cause incorrect displays.
|
|
217 '(let (cell)
|
|
218 (if (and (listp vm-window-configuration)
|
|
219 (setq cell (assq (vm-selected-frame) vm-window-configuration)))
|
|
220 (setcdr cell (car config))
|
|
221 (setq vm-window-configuration
|
|
222 (cons
|
|
223 (cons (vm-selected-frame) (car config))
|
|
224 vm-window-configuration)))))
|
|
225
|
|
226 (defun vm-save-window-configuration (tag)
|
|
227 "Name and save the current window configuration.
|
|
228 With this command you associate the current window setup with an
|
|
229 action. Each time you perform this action VM will duplicate this
|
|
230 window setup.
|
|
231
|
|
232 Nearly every VM command can have a window configuration
|
|
233 associated with it. VM also allows some category configurations,
|
|
234 `startup', `reading-message', `composing-message', `editing-message',
|
|
235 `marking-message' and `searching-message' for the commands that
|
|
236 do these things. There is also a `default' configuration that VM
|
|
237 will use if no other configuration is applicable. Command
|
|
238 specific configurations are searched for first, then the category
|
|
239 configurations and then the default configuration. The first
|
|
240 configuration found is the one that is applied.
|
|
241
|
|
242 The value of vm-mutable-windows must be non-nil for VM to use
|
|
243 window configurations.
|
|
244
|
|
245 If vm-mutable-frames is non-nil and Emacs is running under X
|
|
246 windows, then VM will use all existing frames. Otherwise VM will
|
|
247 restrict its changes to the frame in which it was started."
|
|
248 (interactive
|
|
249 (let ((last-command last-command)
|
|
250 (this-command this-command))
|
|
251 (if (null vm-window-configuration-file)
|
|
252 (error "Configurable windows not enabled. Set vm-window-configuration-file to enable."))
|
|
253 (list
|
|
254 (intern
|
|
255 (completing-read "Name this window configuration: "
|
|
256 vm-supported-window-configurations
|
|
257 'identity t)))))
|
|
258 (if (null vm-window-configuration-file)
|
|
259 (error "Configurable windows not enabled. Set vm-window-configuration-file to enable."))
|
|
260 (let (map p)
|
|
261 (setq map (tapestry (list (vm-selected-frame))))
|
|
262 ;; set frame map to nil since we don't use it. this prevents
|
|
263 ;; cursor objects and any other objects that have an
|
|
264 ;; "unreadable" read syntax appearing in the window
|
|
265 ;; configuration file by way of frame-parameters.
|
|
266 (setcar map nil)
|
|
267 (tapestry-replace-tapestry-element map 'buffer-name 'vm-buffer-to-label)
|
|
268 (tapestry-nullify-tapestry-elements map t nil t t t nil)
|
|
269 (setq p (assq tag vm-window-configurations))
|
|
270 (if p
|
|
271 (setcar (cdr p) map)
|
|
272 (setq vm-window-configurations
|
|
273 (cons (list tag map) vm-window-configurations)))
|
|
274 (vm-store-window-configurations vm-window-configuration-file)
|
|
275 (message "%s configuration recorded" tag)))
|
|
276
|
|
277 (defun vm-buffer-to-label (buf)
|
|
278 (save-excursion
|
|
279 (set-buffer buf)
|
|
280 (cond ((eq major-mode 'vm-summary-mode)
|
|
281 'summary)
|
|
282 ((eq major-mode 'mail-mode)
|
|
283 'composition)
|
|
284 ((eq major-mode 'vm-mode)
|
|
285 'message)
|
|
286 ((eq major-mode 'vm-virtual-mode)
|
|
287 'message)
|
|
288 ((eq vm-system-state 'editing)
|
|
289 'edit)
|
|
290 (t buf))))
|
|
291
|
|
292 (defun vm-delete-window-configuration (tag)
|
|
293 "Delete the configuration saved for a particular action.
|
|
294 This action will no longer have an associated window configuration.
|
|
295 The action will be read from the minibuffer."
|
|
296 (interactive
|
|
297 (let ((last-command last-command)
|
|
298 (this-command this-command))
|
|
299 (if (null vm-window-configuration-file)
|
|
300 (error "Configurable windows not enabled. Set vm-window-configuration-file to enable."))
|
|
301 (list
|
|
302 (intern
|
|
303 (completing-read "Delete window configuration: "
|
|
304 (mapcar (function
|
|
305 (lambda (x)
|
|
306 (list (symbol-name (car x)))))
|
|
307 vm-window-configurations)
|
|
308 'identity t)))))
|
|
309 (if (null vm-window-configuration-file)
|
|
310 (error "Configurable windows not enabled. Set vm-window-configuration-file to enable."))
|
|
311 (let (p)
|
|
312 (setq p (assq tag vm-window-configurations))
|
|
313 (if p
|
|
314 (if (eq p (car vm-window-configurations))
|
|
315 (setq vm-window-configurations (cdr vm-window-configurations))
|
|
316 (setq vm-window-configurations (delq p vm-window-configurations)))
|
|
317 (error "No window configuration set for %s" tag)))
|
|
318 (vm-store-window-configurations vm-window-configuration-file)
|
|
319 (message "%s configuration deleted" tag))
|
|
320
|
|
321 (defun vm-apply-window-configuration (tag)
|
|
322 "Change the current window configuration to be one
|
|
323 associated with a particular action. The action will be read
|
|
324 from the minibuffer."
|
|
325 (interactive
|
|
326 (let ((last-command last-command)
|
|
327 (this-command this-command))
|
|
328 (list
|
|
329 (intern
|
|
330 (completing-read "Apply window configuration: "
|
|
331 (mapcar (function
|
|
332 (lambda (x)
|
|
333 (list (symbol-name (car x)))))
|
|
334 vm-window-configurations)
|
|
335 'identity t)))))
|
|
336 (vm-set-window-configuration tag))
|
|
337
|
|
338 (defun vm-window-help ()
|
|
339 (interactive)
|
|
340 (message "WS = save configuration, WD = delete configuration, WW = apply configuration"))
|
|
341
|
|
342 (defun vm-iconify-frame ()
|
|
343 "Iconify the current frame.
|
|
344 Run the hooks in vm-iconify-frame-hook before doing so."
|
|
345 (interactive)
|
|
346 (vm-check-for-killed-summary)
|
|
347 (vm-select-folder-buffer)
|
|
348 (if (vm-multiple-frames-possible-p)
|
|
349 (progn
|
|
350 (run-hooks 'vm-iconify-frame-hook)
|
|
351 (vm-iconify-frame-xxx))))
|
|
352
|
|
353 (defun vm-window-loop (action obj-1 &optional obj-2)
|
|
354 (let ((delete-me nil)
|
|
355 (done nil)
|
|
356 (all-frames (if vm-mutable-frames t nil))
|
|
357 start w)
|
|
358 (setq start (next-window (selected-window) 'nomini all-frames)
|
|
359 w start)
|
|
360 (and obj-1 (setq obj-1 (get-buffer obj-1)))
|
|
361 (while (not done)
|
|
362 (if (and delete-me (not (eq delete-me (next-window delete-me 'nomini))))
|
|
363 (progn
|
|
364 (delete-window delete-me)
|
|
365 (if (eq delete-me start)
|
|
366 (setq start nil))
|
|
367 (setq delete-me nil)))
|
|
368 (cond ((and (eq action 'delete) (eq obj-1 (window-buffer w)))
|
|
369 ;; a deleted window has no next window, so we
|
|
370 ;; defer the deletion until after we've moved
|
|
371 ;; to the next window.
|
|
372 (setq delete-me w))
|
|
373 ((and (eq action 'replace) (eq obj-1 (window-buffer w)))
|
|
374 (set-window-buffer w obj-2)))
|
|
375 (setq done (eq start
|
|
376 (setq w
|
|
377 (condition-case nil
|
|
378 (next-window w 'nomini all-frames)
|
|
379 (wrong-number-of-arguments
|
|
380 (next-window w 'nomini))))))
|
|
381 (if (null start)
|
|
382 (setq start w)))
|
|
383 (if (and delete-me (not (eq delete-me (next-window delete-me 'nomini))))
|
|
384 (delete-window delete-me))))
|
|
385
|
|
386 (defun vm-frame-loop (action obj-1)
|
|
387 (if (fboundp 'vm-next-frame)
|
|
388 (let ((start (vm-next-frame (vm-selected-frame)))
|
|
389 (delete-me nil)
|
|
390 (done nil)
|
|
391 f)
|
|
392 (setq f start)
|
|
393 (and obj-1 (setq obj-1 (get-buffer obj-1)))
|
|
394 (while (not done)
|
|
395 (if delete-me
|
|
396 (progn
|
|
397 (condition-case nil
|
|
398 (progn
|
|
399 (vm-delete-frame delete-me)
|
|
400 (if (eq delete-me start)
|
|
401 (setq start nil)))
|
|
402 (error nil))
|
|
403 (setq delete-me nil)))
|
|
404 (cond ((and (eq action 'delete)
|
|
405 ;; one-window-p doesn't take a frame argument
|
|
406 (eq (next-window (vm-frame-selected-window f) 'nomini)
|
|
407 (previous-window (vm-frame-selected-window f)
|
|
408 'nomini))
|
|
409 ;; the next-window call is to avoid looking
|
|
410 ;; at the minibuffer window
|
|
411 (eq obj-1 (window-buffer
|
|
412 (next-window
|
|
413 (vm-frame-selected-window f)
|
|
414 'nomini))))
|
|
415 ;; a deleted frame has no next frame, so we
|
|
416 ;; defer the deletion until after we've moved
|
|
417 ;; to the next frame.
|
|
418 (setq delete-me f))
|
|
419 ((eq action 'bury)
|
|
420 (bury-buffer obj-1)))
|
|
421 (setq done (eq start (setq f (vm-next-frame f))))
|
|
422 (if (null start)
|
|
423 (setq start f)))
|
|
424 (if delete-me
|
|
425 (progn
|
|
426 (vm-error-free-call 'vm-delete-frame delete-me)
|
|
427 (setq delete-me nil))))))
|
|
428
|
|
429 (defun vm-delete-windows-or-frames-on (buffer)
|
|
430 (and (eq vm-mutable-windows t) (vm-window-loop 'delete buffer))
|
|
431 (and vm-mutable-frames (vm-frame-loop 'delete buffer)))
|
|
432
|
|
433 (defun vm-replace-buffer-in-windows (old new)
|
|
434 (vm-window-loop 'replace old new))
|
|
435
|
|
436 (defun vm-bury-buffer (&optional buffer)
|
|
437 (or buffer (setq buffer (current-buffer)))
|
|
438 (if (vm-xemacs-p)
|
|
439 (if (vm-multiple-frames-possible-p)
|
|
440 (vm-frame-loop 'bury buffer)
|
|
441 (bury-buffer buffer))
|
|
442 (bury-buffer buffer)))
|
|
443
|
|
444 (defun vm-unbury-buffer (buffer)
|
|
445 (save-excursion
|
|
446 (save-window-excursion
|
|
447 (switch-to-buffer buffer))))
|
|
448
|
|
449 (defun vm-get-buffer-window (buffer)
|
|
450 (condition-case nil
|
|
451 (or (get-buffer-window buffer nil nil)
|
|
452 (and vm-search-other-frames
|
|
453 (get-buffer-window buffer t t)))
|
|
454 (wrong-number-of-arguments
|
|
455 (condition-case nil
|
|
456 (or (get-buffer-window buffer nil)
|
|
457 (and vm-search-other-frames
|
|
458 (get-buffer-window buffer t)))
|
|
459 (wrong-number-of-arguments
|
|
460 (get-buffer-window buffer))))))
|
|
461
|
|
462 (defun vm-get-visible-buffer-window (buffer)
|
|
463 (condition-case nil
|
|
464 (or (get-buffer-window buffer nil nil)
|
|
465 (and vm-search-other-frames
|
|
466 (get-buffer-window buffer t nil)))
|
|
467 (wrong-number-of-arguments
|
|
468 (condition-case nil
|
|
469 (or (get-buffer-window buffer nil)
|
|
470 (and vm-search-other-frames
|
|
471 (get-buffer-window buffer 'visible)))
|
|
472 (wrong-number-of-arguments
|
|
473 (get-buffer-window buffer))))))
|
|
474
|
|
475 (defun vm-set-hooks-for-frame-deletion ()
|
|
476 (make-local-variable 'vm-undisplay-buffer-hook)
|
|
477 (make-local-variable 'kill-buffer-hook)
|
|
478 (add-hook 'vm-undisplay-buffer-hook 'vm-delete-buffer-frame)
|
|
479 (add-hook 'kill-buffer-hook 'vm-delete-buffer-frame))
|
|
480
|
|
481 (defun vm-delete-buffer-frame ()
|
|
482 (save-excursion
|
|
483 (let ((w (vm-get-visible-buffer-window (current-buffer)))
|
|
484 (b (current-buffer)))
|
|
485 (and w (eq (vm-selected-frame) (vm-window-frame w))
|
|
486 (vm-error-free-call 'vm-delete-frame (vm-window-frame w)))
|
|
487 (and w (let ((vm-mutable-frames t))
|
|
488 (vm-delete-windows-or-frames-on b)))))
|
|
489 ;; do it only once
|
|
490 (remove-hook 'vm-undisplay-buffer-hook 'vm-delete-buffer-frame)
|
|
491 (remove-hook 'kill-buffer-hook 'vm-delete-buffer-frame))
|
|
492
|
|
493 (defun vm-goto-new-frame (&rest types)
|
|
494 (let ((params nil))
|
|
495 (while (and types (null params))
|
|
496 (setq params (car (cdr (assq (car types) vm-frame-parameter-alist)))
|
|
497 types (cdr types)))
|
|
498 ;; these functions might be defined in an Emacs that isn't
|
|
499 ;; running under a window system, but VM always checks for
|
|
500 ;; multi-frame support before calling this function.
|
|
501 (cond ((fboundp 'make-frame)
|
|
502 (select-frame (make-frame params)))
|
|
503 ((fboundp 'make-screen)
|
|
504 (select-screen (make-screen params)))
|
|
505 ((fboundp 'new-screen)
|
|
506 (select-screen (new-screen params))))
|
|
507 (and vm-warp-mouse-to-new-frame
|
|
508 (vm-warp-mouse-to-frame-maybe (vm-selected-frame)))))
|
|
509
|
|
510 (defun vm-warp-mouse-to-frame-maybe (&optional frame)
|
|
511 (or frame (setq frame (vm-selected-frame)))
|
|
512 (if (vm-mouse-support-possible-p)
|
|
513 (cond ((vm-mouse-xemacs-mouse-p)
|
|
514 (cond ((fboundp 'mouse-position);; XEmacs 19.12
|
|
515 (let ((mp (mouse-position)))
|
|
516 (if (and (car mp)
|
|
517 (eq (window-frame (car mp)) (selected-frame)))
|
|
518 nil
|
|
519 (set-mouse-position (frame-highest-window frame)
|
|
520 (/ (frame-width frame) 2)
|
|
521 (/ (frame-height frame) 2)))))
|
|
522 (t ;; XEmacs 19.11
|
|
523 ;; use (apply 'screen-...) instead of
|
|
524 ;; (screen-...) to avoid stimulating a
|
|
525 ;; byte-compiler bug in Emacs 19.29 that
|
|
526 ;; happens when it encounters 'obsolete'
|
|
527 ;; functions. puke, puke, puke.
|
|
528 (let ((mp (read-mouse-position frame)))
|
|
529 (if (and (>= (car mp) 0)
|
|
530 (<= (car mp) (apply 'screen-width frame))
|
|
531 (>= (cdr mp) 0)
|
|
532 (<= (cdr mp) (apply 'screen-height frame)))
|
|
533 nil
|
|
534 (set-mouse-position frame
|
|
535 (/ (apply 'screen-width frame) 2)
|
|
536 (/ (apply 'screen-height frame) 2)))))))
|
|
537 ((vm-fsfemacs-19-p)
|
|
538 (let ((mp (mouse-position)))
|
|
539 (if (and (eq (car mp) frame)
|
|
540 ;; nil coordinates mean that the mouse
|
|
541 ;; pointer isn't really within the frame
|
|
542 (car (cdr mp)))
|
|
543 nil
|
|
544 (set-mouse-position frame
|
|
545 (/ (frame-width frame) 2)
|
|
546 (/ (frame-height frame) 2))
|
|
547 ;; doc for set-mouse-position says to do this
|
|
548 (unfocus-frame)))))))
|
|
549
|
|
550 (fset 'vm-selected-frame
|
|
551 (symbol-function
|
|
552 (cond ((fboundp 'selected-frame) 'selected-frame)
|
|
553 ((fboundp 'selected-screen) 'selected-screen)
|
|
554 (t 'ignore))))
|
|
555
|
|
556 (fset 'vm-delete-frame
|
|
557 (symbol-function
|
|
558 (cond ((fboundp 'delete-frame) 'delete-frame)
|
|
559 ((fboundp 'delete-screen) 'delete-screen)
|
|
560 (t 'ignore))))
|
|
561
|
|
562 ;; xxx because vm-iconify-frame is a command
|
|
563 (defun vm-iconify-frame-xxx (&optional frame)
|
|
564 (cond ((fboundp 'iconify-frame)
|
|
565 (iconify-frame frame))
|
|
566 ((fboundp 'iconify-screen)
|
|
567 (iconify-screen (or frame (selected-screen))))))
|
|
568
|
|
569 (fset 'vm-raise-frame
|
|
570 (symbol-function
|
|
571 (cond ((fboundp 'raise-frame) 'raise-frame)
|
|
572 ((fboundp 'raise-screen) 'raise-screen)
|
|
573 (t 'ignore))))
|
|
574
|
|
575 (fset 'vm-frame-visible-p
|
|
576 (symbol-function
|
|
577 (cond ((fboundp 'frame-visible-p) 'frame-visible-p)
|
|
578 ((fboundp 'screen-visible-p) 'screen-visible-p)
|
|
579 (t 'ignore))))
|
|
580
|
|
581 (fset 'vm-window-frame
|
|
582 (symbol-function
|
|
583 (cond ((fboundp 'window-frame) 'window-frame)
|
|
584 ((fboundp 'window-screen) 'window-screen)
|
|
585 (t 'ignore))))
|
|
586
|
|
587 (cond ((fboundp 'next-frame)
|
|
588 (fset 'vm-next-frame (symbol-function 'next-frame))
|
|
589 (fset 'vm-select-frame (symbol-function 'select-frame))
|
|
590 (fset 'vm-frame-selected-window
|
|
591 (symbol-function 'frame-selected-window)))
|
|
592 ((fboundp 'next-screen)
|
|
593 (fset 'vm-next-frame (symbol-function 'next-screen))
|
|
594 (fset 'vm-select-frame (symbol-function 'select-screen))
|
|
595 (fset 'vm-frame-selected-window
|
|
596 (if (fboundp 'epoch::selected-window)
|
|
597 (symbol-function 'epoch::selected-window)
|
|
598 (symbol-function 'screen-selected-window))))
|
|
599 (t
|
|
600 ;; it is useful for this to be a no-op, but don't bind the
|
|
601 ;; others.
|
|
602 (fset 'vm-select-frame 'ignore)))
|