]> code.delx.au - gnu-emacs/blob - lisp/frame.el
(frame-notice-user-settings): If we change the frame's font,
[gnu-emacs] / lisp / frame.el
1 ;;; frame.el --- multi-frame management independent of window systems.
2
3 ;;;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
4
5 ;; Maintainer: FSF
6 ;; Keywords: internal
7
8 ;;; This file is part of GNU Emacs.
9 ;;;
10 ;;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;;; it under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 2, or (at your option)
13 ;;; any later version.
14 ;;;
15 ;;; GNU Emacs is distributed in the hope that it will be useful,
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 ;;; Code:
25
26 (defvar frame-creation-function nil
27 "Window-system dependent function to call to create a new frame.
28 The window system startup file should set this to its frame creation
29 function, which should take an alist of parameters as its argument.")
30
31 ;;; The initial value given here for this must ask for a minibuffer.
32 ;;; There must always exist a frame with a minibuffer, and after we
33 ;;; delete the terminal frame, this will be the only frame.
34 (defvar initial-frame-alist '((minibuffer . t))
35 "Alist of frame parameters for creating the initial X window frame.
36 You can set this in your `.emacs' file; for example,
37 (setq initial-frame-alist '((top . 1) (left . 1) (width . 80) (height . 55)))
38 Parameters specified here supersede the values given in `default-frame-alist'.
39
40 If the value calls for a frame without a minibuffer, and you have not created
41 a minibuffer frame on your own, one is created according to
42 `minibuffer-frame-alist'.
43
44 You can specify geometry-related options for just the initial frame
45 by setting this variable in your `.emacs' file; however, they won't
46 take affect until Emacs reads `.emacs', which happens after first creating
47 the frame. If you want the frame to have the proper geometry as soon
48 as it appears, you need to use this three-step process:
49 * Specify X resources to give the geometry you want.
50 * Set `default-frame-alist' to override these options so that they
51 don't affect subsequent frames.
52 * Set `initial-frame-alist' in a way that matches the X resources,
53 to override what you put in `default-frame-alist'.")
54
55 (defvar minibuffer-frame-alist '((width . 80) (height . 2))
56 "Alist of frame parameters for initially creating a minibuffer frame.
57 You can set this in your `.emacs' file; for example,
58 (setq minibuffer-frame-alist
59 '((top . 1) (left . 1) (width . 80) (height . 2)))
60 Parameters specified here supersede the values given in
61 `default-frame-alist'.")
62
63 (defvar pop-up-frame-alist nil
64 "Alist of frame parameters used when creating pop-up frames.
65 Pop-up frames are used for completions, help, and the like.
66 This variable can be set in your init file, like this:
67 (setq pop-up-frame-alist '((width . 80) (height . 20)))
68 These supersede the values given in `default-frame-alist'.")
69
70 (setq pop-up-frame-function
71 (function (lambda ()
72 (make-frame pop-up-frame-alist))))
73
74 (defvar special-display-frame-alist
75 '((height . 14) (width . 80) (unsplittable . t))
76 "*Alist of frame parameters used when creating special frames.
77 Special frames are used for buffers whose names are in
78 `special-display-buffer-names' and for buffers whose names match
79 one of the regular expressions in `special-display-regexps'.
80 This variable can be set in your init file, like this:
81 (setq special-display-frame-alist '((width . 80) (height . 20)))
82 These supersede the values given in `default-frame-alist'.")
83
84 ;; Display BUFFER in its own frame, reusing an existing window if any.
85 ;; Return the window chosen.
86 ;; Currently we do not insist on selecting the window within its frame.
87 (defun special-display-popup-frame (buffer)
88 (let ((window (get-buffer-window buffer t)))
89 (if window
90 ;; If we have a window already, make it visible.
91 (let ((frame (window-frame window)))
92 (make-frame-visible frame)
93 (raise-frame frame)
94 window)
95 ;; If no window yet, make one in a new frame.
96 (let ((frame (make-frame special-display-frame-alist)))
97 (set-window-buffer (frame-selected-window frame) buffer)
98 (set-window-dedicated-p (frame-selected-window frame) t)
99 (frame-selected-window frame)))))
100
101 (setq special-display-function 'special-display-popup-frame)
102 \f
103 ;;;; Arrangement of frames at startup
104
105 ;;; 1) Load the window system startup file from the lisp library and read the
106 ;;; high-priority arguments (-q and the like). The window system startup
107 ;;; file should create any frames specified in the window system defaults.
108 ;;;
109 ;;; 2) If no frames have been opened, we open an initial text frame.
110 ;;;
111 ;;; 3) Once the init file is done, we apply any newly set parameters
112 ;;; in initial-frame-alist to the frame.
113
114 ;; These are now called explicitly at the proper times,
115 ;; since that is easier to understand.
116 ;; Actually using hooks within Emacs is bad for future maintenance. --rms.
117 ;; (add-hook 'before-init-hook 'frame-initialize)
118 ;; (add-hook 'window-setup-hook 'frame-notice-user-settings)
119
120 ;;; If we create the initial frame, this is it.
121 (defvar frame-initial-frame nil)
122
123 ;; Record the parameters used in frame-initialize to make the initial frame.
124 (defvar frame-initial-frame-alist)
125
126 (defvar frame-initial-geometry-arguments nil)
127
128 ;;; startup.el calls this function before loading the user's init
129 ;;; file - if there is no frame with a minibuffer open now, create
130 ;;; one to display messages while loading the init file.
131 (defun frame-initialize ()
132
133 ;; Are we actually running under a window system at all?
134 (if (and window-system (not noninteractive))
135 (progn
136 ;; If there is no frame with a minibuffer besides the terminal
137 ;; frame, then we need to create the opening frame. Make sure
138 ;; it has a minibuffer, but let initial-frame-alist omit the
139 ;; minibuffer spec.
140 (or (delq terminal-frame (minibuffer-frame-list))
141 (progn
142 (setq frame-initial-frame-alist
143 (append initial-frame-alist default-frame-alist))
144 ;; Record these with their default values
145 ;; if they don't have any values explicitly.
146 (or (assq 'vertical-scroll-bars frame-initial-frame-alist)
147 (setq frame-initial-frame-alist
148 (cons '(vertical-scroll-bars . t)
149 frame-initial-frame-alist)))
150 (or (assq 'horizontal-scroll-bars frame-initial-frame-alist)
151 (setq frame-initial-frame-alist
152 (cons '(horizontal-scroll-bars . t)
153 frame-initial-frame-alist)))
154 (setq default-minibuffer-frame
155 (setq frame-initial-frame
156 (make-frame initial-frame-alist)))
157 ;; Delete any specifications for window geometry parameters
158 ;; so that we won't reapply them in frame-notice-user-settings.
159 ;; It would be wrong to reapply them then,
160 ;; because that would override explicit user resizing.
161 (setq initial-frame-alist
162 (frame-remove-geometry-params initial-frame-alist))))
163 ;; At this point, we know that we have a frame open, so we
164 ;; can delete the terminal frame.
165 (delete-frame terminal-frame)
166 (setq terminal-frame nil))
167
168 ;; No, we're not running a window system. Arrange to cause errors.
169 (setq frame-creation-function
170 (function
171 (lambda (parameters)
172 (error
173 "Can't create multiple frames without a window system"))))))
174
175 ;;; startup.el calls this function after loading the user's init
176 ;;; file. Now default-frame-alist and initial-frame-alist contain
177 ;;; information to which we must react; do what needs to be done.
178 (defun frame-notice-user-settings ()
179
180 ;; Make menu-bar-mode and default-frame-alist consistent.
181 (let ((default (assq 'menu-bar-lines default-frame-alist)))
182 (if default
183 (setq menu-bar-mode (not (eq (cdr default) 0)))
184 (setq default-frame-alist
185 (cons (cons 'menu-bar-lines (if menu-bar-mode 1 0))
186 default-frame-alist))))
187
188 ;; Creating and deleting frames may shift the selected frame around,
189 ;; and thus the current buffer. Protect against that. We don't
190 ;; want to use save-excursion here, because that may also try to set
191 ;; the buffer of the selected window, which fails when the selected
192 ;; window is the minibuffer.
193 (let ((old-buffer (current-buffer)))
194
195 ;; If the initial frame is still around, apply initial-frame-alist
196 ;; and default-frame-alist to it.
197 (if (frame-live-p frame-initial-frame)
198
199 ;; The initial frame we create above always has a minibuffer.
200 ;; If the user wants to remove it, or make it a minibuffer-only
201 ;; frame, then we'll have to delete the current frame and make a
202 ;; new one; you can't remove or add a root window to/from an
203 ;; existing frame.
204 ;;
205 ;; NOTE: default-frame-alist was nil when we created the
206 ;; existing frame. We need to explicitly include
207 ;; default-frame-alist in the parameters of the screen we
208 ;; create here, so that its new value, gleaned from the user's
209 ;; .emacs file, will be applied to the existing screen.
210 (if (not (eq (cdr (or (assq 'minibuffer initial-frame-alist)
211 (assq 'minibuffer default-frame-alist)
212 '(minibuffer . t)))
213 t))
214 ;; Create the new frame.
215 (let (parms new)
216 ;; If the frame isn't visible yet, wait till it is.
217 ;; If the user has to position the window,
218 ;; Emacs doesn't know its real position until
219 ;; the frame is seen to be visible.
220 (while (not (cdr (assq 'visibility
221 (frame-parameters frame-initial-frame))))
222 (sleep-for 1))
223 (setq parms (append initial-frame-alist
224 default-frame-alist
225 (frame-parameters frame-initial-frame)
226 nil))
227 ;; Get rid of `reverse', because that was handled
228 ;; when we first made the frame.
229 (setq parms (cons '(reverse) (delq (assq 'reverse parms) parms)))
230 (if (assq 'height frame-initial-geometry-arguments)
231 (setq parms (frame-delete-all 'height parms)))
232 (if (assq 'width frame-initial-geometry-arguments)
233 (setq parms (frame-delete-all 'width parms)))
234 (if (assq 'left frame-initial-geometry-arguments)
235 (setq parms (frame-delete-all 'left parms)))
236 (if (assq 'top frame-initial-geometry-arguments)
237 (setq parms (frame-delete-all 'top parms)))
238 (setq new
239 (make-frame
240 ;; Use the geometry args that created the existing
241 ;; frame, rather than the parms we get for it.
242 (append frame-initial-geometry-arguments parms)))
243 ;; The initial frame, which we are about to delete, may be
244 ;; the only frame with a minibuffer. If it is, create a
245 ;; new one.
246 (or (delq frame-initial-frame (minibuffer-frame-list))
247 (make-frame (append minibuffer-frame-alist
248 '((minibuffer . only)))))
249
250 ;; If the initial frame is serving as a surrogate
251 ;; minibuffer frame for any frames, we need to wean them
252 ;; onto a new frame. The default-minibuffer-frame
253 ;; variable must be handled similarly.
254 (let ((users-of-initial
255 (filtered-frame-list
256 (function (lambda (frame)
257 (and (not (eq frame frame-initial-frame))
258 (eq (window-frame
259 (minibuffer-window frame))
260 frame-initial-frame)))))))
261 (if (or users-of-initial
262 (eq default-minibuffer-frame frame-initial-frame))
263
264 ;; Choose an appropriate frame. Prefer frames which
265 ;; are only minibuffers.
266 (let* ((new-surrogate
267 (car
268 (or (filtered-frame-list
269 (function
270 (lambda (frame)
271 (eq (cdr (assq 'minibuffer
272 (frame-parameters frame)))
273 'only))))
274 (minibuffer-frame-list))))
275 (new-minibuffer (minibuffer-window new-surrogate)))
276
277 (if (eq default-minibuffer-frame frame-initial-frame)
278 (setq default-minibuffer-frame new-surrogate))
279
280 ;; Wean the frames using frame-initial-frame as
281 ;; their minibuffer frame.
282 (mapcar
283 (function
284 (lambda (frame)
285 (modify-frame-parameters
286 frame (list (cons 'minibuffer new-minibuffer)))))
287 users-of-initial))))
288
289 ;; Redirect events enqueued at this frame to the new frame.
290 ;; Is this a good idea?
291 (redirect-frame-focus frame-initial-frame new)
292
293 ;; Finally, get rid of the old frame.
294 (delete-frame frame-initial-frame t))
295
296 ;; Otherwise, we don't need all that rigamarole; just apply
297 ;; the new parameters.
298 (let (newparms allparms tail)
299 (setq allparms (append initial-frame-alist
300 default-frame-alist))
301 (if (assq 'height frame-initial-geometry-arguments)
302 (setq allparms (frame-delete-all 'height allparms)))
303 (if (assq 'width frame-initial-geometry-arguments)
304 (setq allparms (frame-delete-all 'width allparms)))
305 (if (assq 'left frame-initial-geometry-arguments)
306 (setq allparms (frame-delete-all 'left allparms)))
307 (if (assq 'top frame-initial-geometry-arguments)
308 (setq allparms (frame-delete-all 'top allparms)))
309 (setq tail allparms)
310 ;; Find just the parms that have changed since we first
311 ;; made this frame. Those are the ones actually set by
312 ;; the init file. For those parms whose values we already knew
313 ;; (such as those spec'd by command line options)
314 ;; it is undesirable to specify the parm again
315 ;; once the user has seen the frame and been able to alter it
316 ;; manually.
317 (while tail
318 (let (newval oldval)
319 (setq oldval (cdr (assq (car (car tail))
320 frame-initial-frame-alist)))
321 (setq newval (cdr (assq (car (car tail)) allparms)))
322 (or (eq oldval newval)
323 (setq newparms
324 (cons (cons (car (car tail)) newval) newparms))))
325 (setq tail (cdr tail)))
326 (setq newparms (nreverse newparms))
327 (modify-frame-parameters frame-initial-frame
328 newparms)
329 (if (assq 'font newparms)
330 (frame-update-faces frame-initial-frame)))))
331
332 ;; Restore the original buffer.
333 (set-buffer old-buffer)
334
335 ;; Make sure the initial frame can be GC'd if it is ever deleted.
336 ;; Make sure frame-notice-user-settings does nothing if called twice.
337 (setq frame-initial-frame nil)))
338
339 ;; Delete from ALIST all elements whose car is KEY.
340 ;; Return the modified alist.
341 (defun frame-delete-all (key alist)
342 (setq alist (copy-sequence alist))
343 (let ((tail alist))
344 (while tail
345 (if (eq (car (car tail)) key)
346 (setq alist (delq (car tail) alist)))
347 (setq tail (cdr tail)))
348 alist))
349 \f
350 ;;;; Creation of additional frames, and other frame miscellanea
351
352 ;;; Return some frame other than the current frame, creating one if
353 ;;; necessary. Note that the minibuffer frame, if separate, is not
354 ;;; considered (see next-frame).
355 (defun get-other-frame ()
356 (let ((s (if (equal (next-frame (selected-frame)) (selected-frame))
357 (make-frame)
358 (next-frame (selected-frame)))))
359 s))
360
361 (defun next-multiframe-window ()
362 "Select the next window, regardless of which frame it is on."
363 (interactive)
364 (select-window (next-window (selected-window)
365 (> (minibuffer-depth) 0)
366 t)))
367
368 (defun previous-multiframe-window ()
369 "Select the previous window, regardless of which frame it is on."
370 (interactive)
371 (select-window (previous-window (selected-window)
372 (> (minibuffer-depth) 0)
373 t)))
374
375 ;; Alias, kept temporarily.
376 (defalias 'new-frame 'make-frame)
377 (defun make-frame (&optional parameters)
378 "Create a new frame, displaying the current buffer.
379
380 Optional argument PARAMETERS is an alist of parameters for the new
381 frame. Specifically, PARAMETERS is a list of pairs, each having one
382 of the following forms:
383
384 \(name . STRING) - The frame should be named STRING.
385
386 \(height . NUMBER) - The frame should be NUMBER text lines high. If
387 this parameter is present, the width parameter must also be
388 given.
389
390 \(width . NUMBER) - The frame should be NUMBER characters in width.
391 If this parameter is present, the height parameter must also
392 be given.
393
394 \(minibuffer . t) - the frame should have a minibuffer
395 \(minibuffer . nil) - the frame should have no minibuffer
396 \(minibuffer . only) - the frame should contain only a minibuffer
397 \(minibuffer . WINDOW) - the frame should use WINDOW as its minibuffer window."
398 (interactive)
399 (let ((nframe))
400 (run-hooks 'before-make-frame-hook)
401 (setq nframe (funcall frame-creation-function parameters))
402 (run-hooks 'after-make-frame-hook)
403 nframe))
404
405 (defun filtered-frame-list (predicate)
406 "Return a list of all live frames which satisfy PREDICATE."
407 (let ((frames (frame-list))
408 good-frames)
409 (while (consp frames)
410 (if (funcall predicate (car frames))
411 (setq good-frames (cons (car frames) good-frames)))
412 (setq frames (cdr frames)))
413 good-frames))
414
415 (defun minibuffer-frame-list ()
416 "Return a list of all frames with their own minibuffers."
417 (filtered-frame-list
418 (function (lambda (frame)
419 (eq frame (window-frame (minibuffer-window frame)))))))
420
421 (defun frame-remove-geometry-params (param-list)
422 "Return the parameter list PARAM-LIST, but with geometry specs removed.
423 This deletes all bindings in PARAM-LIST for `top', `left', `width',
424 `height', `user-size' and `user-position' parameters.
425 Emacs uses this to avoid overriding explicit moves and resizings from
426 the user during startup."
427 (setq param-list (cons nil param-list))
428 (let ((tail param-list))
429 (while (consp (cdr tail))
430 (if (and (consp (car (cdr tail)))
431 (memq (car (car (cdr tail)))
432 '(height width top left user-position user-size)))
433 (progn
434 (setq frame-initial-geometry-arguments
435 (cons (car (cdr tail)) frame-initial-geometry-arguments))
436 (setcdr tail (cdr (cdr tail))))
437 (setq tail (cdr tail)))))
438 (setq frame-initial-geometry-arguments
439 (nreverse frame-initial-geometry-arguments))
440 (cdr param-list))
441
442
443 (defun other-frame (arg)
444 "Select the ARG'th different visible frame, and raise it.
445 All frames are arranged in a cyclic order.
446 This command selects the frame ARG steps away in that order.
447 A negative ARG moves in the opposite order."
448 (interactive "p")
449 (let ((frame (selected-frame)))
450 (while (> arg 0)
451 (setq frame (next-frame frame))
452 (while (not (eq (frame-visible-p frame) t))
453 (setq frame (next-frame frame)))
454 (setq arg (1- arg)))
455 (while (< arg 0)
456 (setq frame (previous-frame frame))
457 (while (not (eq (frame-visible-p frame) t))
458 (setq frame (previous-frame frame)))
459 (setq arg (1+ arg)))
460 (raise-frame frame)
461 (select-frame frame)
462 (set-mouse-position (selected-frame) (1- (frame-width)) 0)
463 (unfocus-frame)))
464 \f
465 ;;;; Frame configurations
466
467 (defun current-frame-configuration ()
468 "Return a list describing the positions and states of all frames.
469 Its car is `frame-configuration'.
470 Each element of the cdr is a list of the form (FRAME ALIST WINDOW-CONFIG),
471 where
472 FRAME is a frame object,
473 ALIST is an association list specifying some of FRAME's parameters, and
474 WINDOW-CONFIG is a window configuration object for FRAME."
475 (cons 'frame-configuration
476 (mapcar (function
477 (lambda (frame)
478 (list frame
479 (frame-parameters frame)
480 (current-window-configuration frame))))
481 (frame-list))))
482
483 (defun set-frame-configuration (configuration &optional nodelete)
484 "Restore the frames to the state described by CONFIGURATION.
485 Each frame listed in CONFIGURATION has its position, size, window
486 configuration, and other parameters set as specified in CONFIGURATION.
487 Ordinarily, this function deletes all existing frames not
488 listed in CONFIGURATION. But if optional second argument NODELETE
489 is given and non-nil, the unwanted frames are iconified instead."
490 (or (frame-configuration-p configuration)
491 (signal 'wrong-type-argument
492 (list 'frame-configuration-p configuration)))
493 (let ((config-alist (cdr configuration))
494 frames-to-delete)
495 (mapcar (function
496 (lambda (frame)
497 (let ((parameters (assq frame config-alist)))
498 (if parameters
499 (progn
500 (modify-frame-parameters
501 frame
502 ;; Since we can't set a frame's minibuffer status,
503 ;; we might as well omit the parameter altogether.
504 (let* ((parms (nth 1 parameters))
505 (mini (assq 'minibuffer parms)))
506 (if mini (setq parms (delq mini parms)))
507 parms))
508 (set-window-configuration (nth 2 parameters)))
509 (setq frames-to-delete (cons frame frames-to-delete))))))
510 (frame-list))
511 (if nodelete
512 ;; Note: making frames invisible here was tried
513 ;; but led to some strange behavior--each time the frame
514 ;; was made visible again, the window manager asked afresh
515 ;; for where to put it.
516 (mapcar 'iconify-frame frames-to-delete)
517 (mapcar 'delete-frame frames-to-delete))))
518
519 (defun frame-configuration-p (object)
520 "Return non-nil if OBJECT seems to be a frame configuration.
521 Any list whose car is `frame-configuration' is assumed to be a frame
522 configuration."
523 (and (consp object)
524 (eq (car object) 'frame-configuration)))
525
526 \f
527 ;;;; Convenience functions for accessing and interactively changing
528 ;;;; frame parameters.
529
530 (defun frame-height (&optional frame)
531 "Return number of lines available for display on FRAME.
532 If FRAME is omitted, describe the currently selected frame."
533 (cdr (assq 'height (frame-parameters frame))))
534
535 (defun frame-width (&optional frame)
536 "Return number of columns available for display on FRAME.
537 If FRAME is omitted, describe the currently selected frame."
538 (cdr (assq 'width (frame-parameters frame))))
539
540 (defun set-default-font (font-name)
541 "Set the font of the selected frame to FONT.
542 When called interactively, prompt for the name of the font to use."
543 (interactive "sFont name: ")
544 (modify-frame-parameters (selected-frame)
545 (list (cons 'font font-name)))
546 ;; Update faces that want a bold or italic version of the default font.
547 (frame-update-faces (selected-frame)))
548
549 (defun set-background-color (color-name)
550 "Set the background color of the selected frame to COLOR.
551 When called interactively, prompt for the name of the color to use."
552 (interactive "sColor: ")
553 (modify-frame-parameters (selected-frame)
554 (list (cons 'background-color color-name))))
555
556 (defun set-foreground-color (color-name)
557 "Set the foreground color of the selected frame to COLOR.
558 When called interactively, prompt for the name of the color to use."
559 (interactive "sColor: ")
560 (modify-frame-parameters (selected-frame)
561 (list (cons 'foreground-color color-name))))
562
563 (defun set-cursor-color (color-name)
564 "Set the text cursor color of the selected frame to COLOR.
565 When called interactively, prompt for the name of the color to use."
566 (interactive "sColor: ")
567 (modify-frame-parameters (selected-frame)
568 (list (cons 'cursor-color color-name))))
569
570 (defun set-mouse-color (color-name)
571 "Set the color of the mouse pointer of the selected frame to COLOR.
572 When called interactively, prompt for the name of the color to use."
573 (interactive "sColor: ")
574 (modify-frame-parameters (selected-frame)
575 (list (cons 'mouse-color color-name))))
576
577 (defun set-border-color (color-name)
578 "Set the color of the border of the selected frame to COLOR.
579 When called interactively, prompt for the name of the color to use."
580 (interactive "sColor: ")
581 (modify-frame-parameters (selected-frame)
582 (list (cons 'border-color color-name))))
583
584 (defun auto-raise-mode (arg)
585 "Toggle whether or not the selected frame should auto-raise.
586 With arg, turn auto-raise mode on if and only if arg is positive.
587 Note that this controls Emacs's own auto-raise feature.
588 Some window managers allow you to enable auto-raise for certain windows.
589 You can use that for Emacs windows if you wish, but if you do,
590 that is beyond the control of Emacs and this command has no effect on it."
591 (interactive "P")
592 (if (null arg)
593 (setq arg
594 (if (cdr (assq 'auto-raise (frame-parameters (selected-frame))))
595 -1 1)))
596 (modify-frame-parameters (selected-frame)
597 (list (cons 'auto-raise (> arg 0)))))
598
599 (defun auto-lower-mode (arg)
600 "Toggle whether or not the selected frame should auto-lower.
601 With arg, turn auto-lower mode on if and only if arg is positive.
602 Note that this controls Emacs's own auto-lower feature.
603 Some window managers allow you to enable auto-lower for certain windows.
604 You can use that for Emacs windows if you wish, but if you do,
605 that is beyond the control of Emacs and this command has no effect on it."
606 (interactive "P")
607 (if (null arg)
608 (setq arg
609 (if (cdr (assq 'auto-lower (frame-parameters (selected-frame))))
610 -1 1)))
611 (modify-frame-parameters (selected-frame)
612 (list (cons 'auto-lower (> arg 0)))))
613
614 (defun toggle-scroll-bar (arg)
615 "Toggle whether or not the selected frame has vertical scroll bars.
616 With arg, turn vertical scroll bars on if and only if arg is positive."
617 (interactive "P")
618 (if (null arg)
619 (setq arg
620 (if (cdr (assq 'vertical-scroll-bars
621 (frame-parameters (selected-frame))))
622 -1 1)))
623 (modify-frame-parameters (selected-frame)
624 (list (cons 'vertical-scroll-bars (> arg 0)))))
625
626 (defun toggle-horizontal-scroll-bar (arg)
627 "Toggle whether or not the selected frame has horizontal scroll bars.
628 With arg, turn horizontal scroll bars on if and only if arg is positive.
629 Horizontal scroll bars aren't implemented yet."
630 (interactive "P")
631 (error "Horizontal scroll bars aren't implemented yet"))
632
633 \f
634 ;;;; Aliases for backward compatibility with Emacs 18.
635 (defalias 'screen-height 'frame-height)
636 (defalias 'screen-width 'frame-width)
637
638 (defun set-screen-width (cols &optional pretend)
639 "Obsolete function to change the size of the screen to COLS columns.\n\
640 Optional second arg non-nil means that redisplay should use COLS columns\n\
641 but that the idea of the actual width of the frame should not be changed.\n\
642 This function is provided only for compatibility with Emacs 18; new code\n\
643 should use `set-frame-width instead'."
644 (set-frame-width (selected-frame) cols pretend))
645
646 (defun set-screen-height (lines &optional pretend)
647 "Obsolete function to change the height of the screen to LINES lines.\n\
648 Optional second arg non-nil means that redisplay should use LINES lines\n\
649 but that the idea of the actual height of the screen should not be changed.\n\
650 This function is provided only for compatibility with Emacs 18; new code\n\
651 should use `set-frame-width' instead."
652 (set-frame-height (selected-frame) lines pretend))
653
654 (make-obsolete 'screen-height 'frame-height)
655 (make-obsolete 'screen-width 'frame-width)
656 (make-obsolete 'set-screen-width 'set-frame-width)
657 (make-obsolete 'set-screen-height 'set-frame-height)
658
659 \f
660 ;;;; Key bindings
661 (defvar ctl-x-5-map (make-sparse-keymap)
662 "Keymap for frame commands.")
663 (defalias 'ctl-x-5-prefix ctl-x-5-map)
664 (define-key ctl-x-map "5" 'ctl-x-5-prefix)
665
666 (define-key ctl-x-5-map "2" 'make-frame)
667 (define-key ctl-x-5-map "0" 'delete-frame)
668 (define-key ctl-x-5-map "o" 'other-frame)
669
670 (provide 'frame)
671
672 ;;; frame.el ends here