]> code.delx.au - gnu-emacs/blob - src/frame.c
* frame.c (Fdelete_frame): Clear the frame's display after calling
[gnu-emacs] / src / frame.c
1 /* Generic frame functions.
2 Copyright (C) 1989, 1992, 1993 Free Software Foundation.
3
4 This file is part of GNU Emacs.
5
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #include <stdio.h>
21
22 #include "config.h"
23 #include "lisp.h"
24 #include "frame.h"
25
26 #ifdef MULTI_FRAME
27
28 #include "buffer.h"
29 #include "window.h"
30 #include "termhooks.h"
31
32 /* These help us bind and responding to switch-frame events. */
33 #include "commands.h"
34 #include "keyboard.h"
35
36 Lisp_Object Vemacs_iconified;
37 Lisp_Object Vframe_list;
38 Lisp_Object Vterminal_frame;
39 Lisp_Object Vdefault_minibuffer_frame;
40 Lisp_Object Vdefault_frame_alist;
41
42 /* Evaluate this expression to rebuild the section of syms_of_frame
43 that initializes and staticpros the symbols declared below. Note
44 that Emacs 18 has a bug that keeps C-x C-e from being able to
45 evaluate this expression.
46
47 (progn
48 ;; Accumulate a list of the symbols we want to initialize from the
49 ;; declarations at the top of the file.
50 (goto-char (point-min))
51 (search-forward "/\*&&& symbols declared here &&&*\/\n")
52 (let (symbol-list)
53 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
54 (setq symbol-list
55 (cons (buffer-substring (match-beginning 1) (match-end 1))
56 symbol-list))
57 (forward-line 1))
58 (setq symbol-list (nreverse symbol-list))
59 ;; Delete the section of syms_of_... where we initialize the symbols.
60 (search-forward "\n /\*&&& init symbols here &&&*\/\n")
61 (let ((start (point)))
62 (while (looking-at "^ Q")
63 (forward-line 2))
64 (kill-region start (point)))
65 ;; Write a new symbol initialization section.
66 (while symbol-list
67 (insert (format " %s = intern (\"" (car symbol-list)))
68 (let ((start (point)))
69 (insert (substring (car symbol-list) 1))
70 (subst-char-in-region start (point) ?_ ?-))
71 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
72 (setq symbol-list (cdr symbol-list)))))
73 */
74
75 /*&&& symbols declared here &&&*/
76 Lisp_Object Qframep;
77 Lisp_Object Qlive_frame_p;
78 Lisp_Object Qheight;
79 Lisp_Object Qicon;
80 Lisp_Object Qminibuffer;
81 Lisp_Object Qmodeline;
82 Lisp_Object Qname;
83 Lisp_Object Qnone;
84 Lisp_Object Qonly;
85 Lisp_Object Qunsplittable;
86 Lisp_Object Qwidth;
87 Lisp_Object Qx;
88
89 extern Lisp_Object Vminibuffer_list;
90 extern Lisp_Object get_minibuffer ();
91 \f
92 DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
93 "Return non-nil if OBJECT is a frame.\n\
94 Value is t for a termcap frame (a character-only terminal),\n\
95 `x' for an Emacs frame that is really an X window.\n\
96 Also see `live-frame-p'.")
97 (object)
98 Lisp_Object object;
99 {
100 if (XTYPE (object) != Lisp_Frame)
101 return Qnil;
102 switch (XFRAME (object)->output_method)
103 {
104 case output_termcap:
105 return Qt;
106 case output_x_window:
107 return Qx;
108 default:
109 abort ();
110 }
111 }
112
113 DEFUN ("live-frame-p", Flive_frame_p, Slive_frame_p, 1, 1, 0,
114 "Return non-nil if OBJECT is a frame which has not been deleted.\n\
115 Value is nil if OBJECT is not a live frame. If object is a live\n\
116 frame, the return value indicates what sort of output device it is\n\
117 displayed on. Value is t for a termcap frame (a character-only\n\
118 terminal), `x' for an Emacs frame being displayed in an X window.")
119 (object)
120 Lisp_Object object;
121 {
122 return ((FRAMEP (object)
123 && FRAME_LIVE_P (XFRAME (object)))
124 ? Fframep (object)
125 : Qnil);
126 }
127
128 struct frame *
129 make_frame (mini_p)
130 int mini_p;
131 {
132 Lisp_Object frame;
133 register struct frame *f;
134 register Lisp_Object root_window;
135 register Lisp_Object mini_window;
136
137 frame = Fmake_vector (((sizeof (struct frame) - (sizeof (Lisp_Vector)
138 - sizeof (Lisp_Object)))
139 / sizeof (Lisp_Object)),
140 make_number (0));
141 XSETTYPE (frame, Lisp_Frame);
142 f = XFRAME (frame);
143
144 f->cursor_x = 0;
145 f->cursor_y = 0;
146 f->current_glyphs = 0;
147 f->desired_glyphs = 0;
148 f->visible = 0;
149 f->async_visible = 0;
150 f->display.nothing = 0;
151 f->iconified = 0;
152 f->async_iconified = 0;
153 f->wants_modeline = 1;
154 f->auto_raise = 0;
155 f->auto_lower = 0;
156 f->no_split = 0;
157 f->garbaged = 0;
158 f->has_minibuffer = mini_p;
159 f->focus_frame = Qnil;
160 f->explicit_name = 0;
161 f->can_have_scrollbars = 0;
162 f->has_vertical_scrollbars = 0;
163 f->param_alist = Qnil;
164 f->scrollbars = Qnil;
165 f->condemned_scrollbars = Qnil;
166
167 root_window = make_window ();
168 if (mini_p)
169 {
170 mini_window = make_window ();
171 XWINDOW (root_window)->next = mini_window;
172 XWINDOW (mini_window)->prev = root_window;
173 XWINDOW (mini_window)->mini_p = Qt;
174 XWINDOW (mini_window)->frame = frame;
175 f->minibuffer_window = mini_window;
176 }
177 else
178 {
179 mini_window = Qnil;
180 XWINDOW (root_window)->next = Qnil;
181 f->minibuffer_window = Qnil;
182 }
183
184 XWINDOW (root_window)->frame = frame;
185
186 /* 10 is arbitrary,
187 just so that there is "something there."
188 Correct size will be set up later with change_frame_size. */
189
190 f->width = 10;
191 f->height = 10;
192
193 XFASTINT (XWINDOW (root_window)->width) = 10;
194 XFASTINT (XWINDOW (root_window)->height) = (mini_p ? 9 : 10);
195
196 if (mini_p)
197 {
198 XFASTINT (XWINDOW (mini_window)->width) = 10;
199 XFASTINT (XWINDOW (mini_window)->top) = 9;
200 XFASTINT (XWINDOW (mini_window)->height) = 1;
201 }
202
203 /* Choose a buffer for the frame's root window. */
204 {
205 Lisp_Object buf;
206
207 XWINDOW (root_window)->buffer = Qt;
208 buf = Fcurrent_buffer ();
209 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
210 a space), try to find another one. */
211 if (XSTRING (Fbuffer_name (buf))->data[0] == ' ')
212 buf = Fother_buffer (buf, Qnil);
213 Fset_window_buffer (root_window, buf);
214 }
215
216 if (mini_p)
217 {
218 XWINDOW (mini_window)->buffer = Qt;
219 Fset_window_buffer (mini_window,
220 (NILP (Vminibuffer_list)
221 ? get_minibuffer (0)
222 : Fcar (Vminibuffer_list)));
223 }
224
225 f->root_window = root_window;
226 f->selected_window = root_window;
227 /* Make sure this window seems more recently used than
228 a newly-created, never-selected window. */
229 XFASTINT (XWINDOW (f->selected_window)->use_time) = ++window_select_count;
230
231 Vframe_list = Fcons (frame, Vframe_list);
232
233 return f;
234 }
235 \f
236 /* Make a frame using a separate minibuffer window on another frame.
237 MINI_WINDOW is the minibuffer window to use. nil means use the
238 default (the global minibuffer). */
239
240 struct frame *
241 make_frame_without_minibuffer (mini_window)
242 register Lisp_Object mini_window;
243 {
244 register struct frame *f;
245
246 /* Choose the minibuffer window to use. */
247 if (NILP (mini_window))
248 {
249 if (XTYPE (Vdefault_minibuffer_frame) != Lisp_Frame)
250 error ("default-minibuffer-frame must be set when creating minibufferless frames");
251 if (! FRAME_LIVE_P (XFRAME (Vdefault_minibuffer_frame)))
252 error ("default-minibuffer-frame must be a live frame");
253 mini_window = XFRAME (Vdefault_minibuffer_frame)->minibuffer_window;
254 }
255 else
256 {
257 CHECK_LIVE_WINDOW (mini_window, 0);
258 }
259
260 /* Make a frame containing just a root window. */
261 f = make_frame (0);
262
263 /* Install the chosen minibuffer window, with proper buffer. */
264 f->minibuffer_window = mini_window;
265 Fset_window_buffer (mini_window,
266 (NILP (Vminibuffer_list)
267 ? get_minibuffer (0)
268 : Fcar (Vminibuffer_list)));
269 return f;
270 }
271
272 /* Make a frame containing only a minibuffer window. */
273
274 struct frame *
275 make_minibuffer_frame ()
276 {
277 /* First make a frame containing just a root window, no minibuffer. */
278
279 register struct frame *f = make_frame (0);
280 register Lisp_Object mini_window;
281 register Lisp_Object frame;
282
283 XSET (frame, Lisp_Frame, f);
284
285 f->auto_raise = 0;
286 f->auto_lower = 0;
287 f->no_split = 1;
288 f->wants_modeline = 0;
289 f->has_minibuffer = 1;
290
291 /* Now label the root window as also being the minibuffer.
292 Avoid infinite looping on the window chain by marking next pointer
293 as nil. */
294
295 mini_window = f->minibuffer_window = f->root_window;
296 XWINDOW (mini_window)->mini_p = Qt;
297 XWINDOW (mini_window)->next = Qnil;
298 XWINDOW (mini_window)->prev = Qnil;
299 XWINDOW (mini_window)->frame = frame;
300
301 /* Put the proper buffer in that window. */
302
303 Fset_window_buffer (mini_window,
304 (NILP (Vminibuffer_list)
305 ? get_minibuffer (0)
306 : Fcar (Vminibuffer_list)));
307 return f;
308 }
309 \f
310 /* Construct a frame that refers to the terminal (stdin and stdout). */
311
312 struct frame *
313 make_terminal_frame ()
314 {
315 register struct frame *f;
316
317 Vframe_list = Qnil;
318 f = make_frame (1);
319 f->name = build_string ("terminal");
320 FRAME_SET_VISIBLE (f, 1);
321 f->display.nothing = 1; /* Nonzero means frame isn't deleted. */
322 XSET (Vterminal_frame, Lisp_Frame, f);
323 return f;
324 }
325 \f
326 DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e",
327 "Select the frame FRAME. FRAME's selected window becomes \"the\"\n\
328 selected window. If the optional parameter NO-ENTER is non-nil, don't\n\
329 focus on that frame.\n\
330 \n\
331 This function is interactive, and may be bound to the ``switch-frame''\n\
332 event; when invoked this way, it switches to the frame named in the\n\
333 event. When called from lisp, FRAME may be a ``switch-frame'' event;\n\
334 if it is, select the frame named in the event.\n\
335 \n\
336 Changing the selected frame can change focus redirections. See\n\
337 `redirect-frame-focus' for details.")
338 (frame, no_enter)
339 Lisp_Object frame, no_enter;
340 {
341 /* If FRAME is a switch-frame event, extract the frame we should
342 switch to. */
343 if (CONSP (frame)
344 && EQ (XCONS (frame)->car, Qswitch_frame)
345 && CONSP (XCONS (frame)->cdr))
346 frame = XCONS (XCONS (frame)->cdr)->car;
347
348 CHECK_LIVE_FRAME (frame, 0);
349
350 if (selected_frame == XFRAME (frame))
351 return frame;
352
353 /* If a frame's focus has been redirected toward the currently
354 selected frame, we should change the redirection to point to the
355 newly selected frame. This means that if the focus is redirected
356 from a minibufferless frame to a surrogate minibuffer frame, we
357 can use `other-window' to switch between all the frames using
358 that minibuffer frame, and the focus redirection will follow us
359 around. */
360 {
361 Lisp_Object tail;
362
363 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
364 {
365 Lisp_Object focus;
366
367 if (XTYPE (XCONS (tail)->car) != Lisp_Frame)
368 abort ();
369
370 focus = FRAME_FOCUS_FRAME (XFRAME (XCONS (tail)->car));
371
372 if (XTYPE (focus) == Lisp_Frame
373 && XFRAME (focus) == selected_frame)
374 Fredirect_frame_focus (XCONS (tail)->car, frame);
375 }
376 }
377
378 selected_frame = XFRAME (frame);
379 if (! FRAME_MINIBUF_ONLY_P (selected_frame))
380 last_nonminibuf_frame = selected_frame;
381
382 Fselect_window (XFRAME (frame)->selected_window);
383
384 #ifdef HAVE_X_WINDOWS
385 #ifdef MULTI_FRAME
386 if (FRAME_X_P (XFRAME (frame))
387 && NILP (no_enter))
388 {
389 Ffocus_frame (frame);
390 }
391 #endif
392 #endif
393 choose_minibuf_frame ();
394
395 return frame;
396 }
397
398 DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
399 "Return the frame that is now selected.")
400 ()
401 {
402 Lisp_Object tem;
403 XSET (tem, Lisp_Frame, selected_frame);
404 return tem;
405 }
406
407 DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
408 "Return the frame object that window WINDOW is on.")
409 (window)
410 Lisp_Object window;
411 {
412 CHECK_LIVE_WINDOW (window, 0);
413 return XWINDOW (window)->frame;
414 }
415
416 DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0,
417 "Returns the root-window of FRAME.\n\
418 If omitted, FRAME defaults to the currently selected frame.")
419 (frame)
420 Lisp_Object frame;
421 {
422 if (NILP (frame))
423 XSET (frame, Lisp_Frame, selected_frame);
424 else
425 CHECK_LIVE_FRAME (frame, 0);
426
427 return XFRAME (frame)->root_window;
428 }
429
430 DEFUN ("frame-selected-window", Fframe_selected_window,
431 Sframe_selected_window, 0, 1, 0,
432 "Return the selected window of frame object FRAME.\n\
433 If omitted, FRAME defaults to the currently selected frame.")
434 (frame)
435 Lisp_Object frame;
436 {
437 if (NILP (frame))
438 XSET (frame, Lisp_Frame, selected_frame);
439 else
440 CHECK_LIVE_FRAME (frame, 0);
441
442 return XFRAME (frame)->selected_window;
443 }
444
445 DEFUN ("frame-list", Fframe_list, Sframe_list,
446 0, 0, 0,
447 "Return a list of all frames.")
448 ()
449 {
450 return Fcopy_sequence (Vframe_list);
451 }
452
453 #ifdef MULTI_FRAME
454
455 /* Return the next frame in the frame list after FRAME.
456 If MINIBUF is nil, exclude minibuffer-only frames.
457 If MINIBUF is a window, include only frames using that window for
458 their minibuffer.
459 If MINIBUF is non-nil, and not a window, include all frames. */
460 Lisp_Object
461 next_frame (frame, minibuf)
462 Lisp_Object frame;
463 Lisp_Object minibuf;
464 {
465 Lisp_Object tail;
466 int passed = 0;
467
468 /* There must always be at least one frame in Vframe_list. */
469 if (! CONSP (Vframe_list))
470 abort ();
471
472 while (1)
473 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
474 {
475 Lisp_Object f = XCONS (tail)->car;
476
477 if (passed)
478 {
479 /* Decide whether this frame is eligible to be returned. */
480
481 /* If we've looped all the way around without finding any
482 eligible frames, return the original frame. */
483 if (EQ (f, frame))
484 return f;
485
486 /* Let minibuf decide if this frame is acceptable. */
487 if (NILP (minibuf))
488 {
489 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
490 return f;
491 }
492 else if (XTYPE (minibuf) == Lisp_Window)
493 {
494 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf))
495 return f;
496 }
497 else
498 return f;
499 }
500
501 if (EQ (frame, f))
502 passed++;
503 }
504 }
505
506 #if 0
507 /* Nobody seems to be using this code right now. */
508
509 /* Return the previous frame in the frame list before FRAME.
510 If MINIBUF is nil, exclude minibuffer-only frames.
511 If MINIBUF is a window, include only frames using that window for
512 their minibuffer.
513 If MINIBUF is non-nil and not a window, include all frames. */
514 Lisp_Object
515 prev_frame (frame, minibuf)
516 Lisp_Object frame;
517 Lisp_Object minibuf;
518 {
519 Lisp_Object tail;
520 Lisp_Object prev;
521
522 /* There must always be at least one frame in Vframe_list. */
523 if (! CONSP (Vframe_list))
524 abort ();
525
526 prev = Qnil;
527 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
528 {
529 Lisp_Object f = XCONS (tail)->car;
530
531 if (XTYPE (f) != Lisp_Frame)
532 abort ();
533
534 if (EQ (frame, f) && !NILP (prev))
535 return prev;
536
537 /* Decide whether this frame is eligible to be returned,
538 according to minibuf. */
539 if (NILP (minibuf))
540 {
541 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
542 prev = f;
543 }
544 else if (XTYPE (minibuf) == Lisp_Window)
545 {
546 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf))
547 prev = f;
548 }
549 else
550 prev = f;
551 }
552
553 /* We've scanned the entire list. */
554 if (NILP (prev))
555 /* We went through the whole frame list without finding a single
556 acceptable frame. Return the original frame. */
557 return frame;
558 else
559 /* There were no acceptable frames in the list before FRAME; otherwise,
560 we would have returned directly from the loop. Since PREV is the last
561 acceptable frame in the list, return it. */
562 return prev;
563 }
564 #endif
565
566 DEFUN ("next-frame", Fnext_frame, Snext_frame, 0, 2, 0,
567 "Return the next frame in the frame list after FRAME.\n\
568 By default, skip minibuffer-only frames.\n\
569 If omitted, FRAME defaults to the selected frame.\n\
570 If optional argument MINIFRAME is non-nil, include minibuffer-only frames.\n\
571 If MINIFRAME is a window, include only frames using that window for their\n\
572 minibuffer.\n\
573 If MINIFRAME is non-nil and not a window, include all frames.")
574 (frame, miniframe)
575 Lisp_Object frame, miniframe;
576 {
577 Lisp_Object tail;
578
579 if (NILP (frame))
580 XSET (frame, Lisp_Frame, selected_frame);
581 else
582 CHECK_LIVE_FRAME (frame, 0);
583
584 return next_frame (frame, miniframe);
585 }
586 #endif /* MULTI_FRAME */
587 \f
588 DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 1, "",
589 "Delete FRAME, permanently eliminating it from use.\n\
590 If omitted, FRAME defaults to the selected frame.\n\
591 A frame may not be deleted if its minibuffer is used by other frames.")
592 (frame)
593 Lisp_Object frame;
594 {
595 struct frame *f;
596
597 if (EQ (frame, Qnil))
598 {
599 f = selected_frame;
600 XSET (frame, Lisp_Frame, f);
601 }
602 else
603 {
604 CHECK_FRAME (frame, 0);
605 f = XFRAME (frame);
606 }
607
608 if (! FRAME_LIVE_P (f))
609 return;
610
611 /* Are there any other frames besides this one? */
612 if (f == selected_frame && EQ (next_frame (frame, Qt), frame))
613 error ("Attempt to delete the only frame");
614
615 /* Does this frame have a minibuffer, and is it the surrogate
616 minibuffer for any other frame? */
617 if (FRAME_HAS_MINIBUF_P (XFRAME (frame)))
618 {
619 Lisp_Object frames;
620
621 for (frames = Vframe_list;
622 CONSP (frames);
623 frames = XCONS (frames)->cdr)
624 {
625 Lisp_Object this = XCONS (frames)->car;
626
627 if (! EQ (this, frame)
628 && EQ (frame,
629 (WINDOW_FRAME
630 (XWINDOW
631 (FRAME_MINIBUF_WINDOW
632 (XFRAME (this)))))))
633 error ("Attempt to delete a surrogate minibuffer frame");
634 }
635 }
636
637 /* Don't let the frame remain selected. */
638 if (f == selected_frame)
639 Fselect_frame (next_frame (frame, Qt), Qnil);
640
641 /* Don't allow minibuf_window to remain on a deleted frame. */
642 if (EQ (f->minibuffer_window, minibuf_window))
643 {
644 Fset_window_buffer (selected_frame->minibuffer_window,
645 XWINDOW (minibuf_window)->buffer);
646 minibuf_window = selected_frame->minibuffer_window;
647 }
648
649 /* Mark all the windows that used to be on FRAME as deleted, and then
650 remove the reference to them. */
651 delete_all_subwindows (XWINDOW (f->root_window));
652 f->root_window = Qnil;
653
654 Vframe_list = Fdelq (frame, Vframe_list);
655 FRAME_SET_VISIBLE (f, 0);
656
657 /* Since some events are handled at the interrupt level, we may get
658 an event for f at any time; if we zero out the frame's display
659 now, then we may trip up the event-handling code. Instead, we'll
660 promise that the display of the frame must be valid until we have
661 called the window-system-dependent frame destruction routine. */
662 #ifdef HAVE_X_WINDOWS
663 if (FRAME_X_P (f))
664 x_destroy_window (f);
665 #endif
666
667 f->display.nothing = 0;
668
669 /* If we've deleted the last_nonminibuf_frame, then try to find
670 another one. */
671 if (f == last_nonminibuf_frame)
672 {
673 Lisp_Object frames;
674
675 last_nonminibuf_frame = 0;
676
677 for (frames = Vframe_list;
678 CONSP (frames);
679 frames = XCONS (frames)->cdr)
680 {
681 f = XFRAME (XCONS (frames)->car);
682 if (!FRAME_MINIBUF_ONLY_P (f))
683 {
684 last_nonminibuf_frame = f;
685 break;
686 }
687 }
688 }
689
690 /* If we've deleted Vdefault_minibuffer_frame, try to find another
691 one. Prefer minibuffer-only frames, but also notice frames
692 with other windows. */
693 if (EQ (frame, Vdefault_minibuffer_frame))
694 {
695 Lisp_Object frames;
696
697 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
698 Lisp_Object frame_with_minibuf = Qnil;
699
700 for (frames = Vframe_list;
701 CONSP (frames);
702 frames = XCONS (frames)->cdr)
703 {
704 Lisp_Object this = XCONS (frames)->car;
705
706 if (XTYPE (this) != Lisp_Frame)
707 abort ();
708 f = XFRAME (this);
709
710 if (FRAME_HAS_MINIBUF_P (f))
711 {
712 frame_with_minibuf = this;
713 if (FRAME_MINIBUF_ONLY_P (f))
714 break;
715 }
716 }
717
718 /* We know that there must be some frame with a minibuffer out
719 there. If this were not true, all of the frames present
720 would have to be minibufferless, which implies that at some
721 point their minibuffer frames must have been deleted, but
722 that is prohibited at the top; you can't delete surrogate
723 minibuffer frames. */
724 if (NILP (frame_with_minibuf))
725 abort ();
726
727 Vdefault_minibuffer_frame = frame_with_minibuf;
728 }
729
730 return Qnil;
731 }
732 \f
733 /* Return mouse position in character cell units. */
734
735 DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0,
736 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
737 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
738 to read the mouse position, it returns the selected frame for FRAME\n\
739 and nil for X and Y.")
740 ()
741 {
742 Lisp_Object x, y, dummy;
743 FRAME_PTR f;
744
745 if (mouse_position_hook)
746 (*mouse_position_hook) (&f, &x, &y, &dummy);
747 else
748 {
749 f = selected_frame;
750 x = y = Qnil;
751 }
752
753 XSET (dummy, Lisp_Frame, f);
754 return Fcons (dummy, Fcons (make_number (x), make_number (y)));
755 }
756
757 DEFUN ("set-mouse-position", Fset_mouse_position, Sset_mouse_position, 3, 3, 0,
758 "Move the mouse pointer to the center of cell (X,Y) in FRAME.\n\
759 WARNING: If you use this under X, you should do `unfocus-frame' afterwards.")
760 (frame, x, y)
761 Lisp_Object frame, x, y;
762 {
763 CHECK_LIVE_FRAME (frame, 0);
764 CHECK_NUMBER (x, 2);
765 CHECK_NUMBER (y, 1);
766
767 #ifdef HAVE_X_WINDOWS
768 if (FRAME_X_P (XFRAME (frame)))
769 /* Warping the mouse will cause enternotify and focus events. */
770 x_set_mouse_position (XFRAME (frame), x, y);
771 #endif
772
773 return Qnil;
774 }
775 \f
776 #if 0
777 /* ??? Can this be replaced with a Lisp function?
778 It is used in minibuf.c. Can we get rid of that?
779 Yes. All uses in minibuf.c are gone, and parallels to these
780 functions have been defined in frame.el. */
781
782 DEFUN ("frame-configuration", Fframe_configuration, Sframe_configuration,
783 0, 0, 0,
784 "Return object describing current frame configuration.\n\
785 The frame configuration is the current mouse position and selected frame.\n\
786 This object can be given to `restore-frame-configuration'\n\
787 to restore this frame configuration.")
788 ()
789 {
790 Lisp_Object c, time;
791
792 c = Fmake_vector (make_number(4), Qnil);
793 XVECTOR (c)->contents[0] = Fselected_frame();
794 if (mouse_position_hook)
795 (*mouse_position_hook) (&XVECTOR (c)->contents[1]
796 &XVECTOR (c)->contents[2],
797 &XVECTOR (c)->contents[3],
798 &time);
799 return c;
800 }
801
802 DEFUN ("restore-frame-configuration", Frestore_frame_configuration,
803 Srestore_frame_configuration,
804 1, 1, 0,
805 "Restores frame configuration CONFIGURATION.")
806 (config)
807 Lisp_Object config;
808 {
809 Lisp_Object x_pos, y_pos, frame;
810
811 CHECK_VECTOR (config, 0);
812 if (XVECTOR (config)->size != 3)
813 {
814 error ("Wrong size vector passed to restore-frame-configuration");
815 }
816 frame = XVECTOR (config)->contents[0];
817 CHECK_LIVE_FRAME (frame, 0);
818
819 Fselect_frame (frame, Qnil);
820
821 #if 0
822 /* This seems to interfere with the frame selection mechanism. jla */
823 x_pos = XVECTOR (config)->contents[2];
824 y_pos = XVECTOR (config)->contents[3];
825 set_mouse_position (frame, XINT (x_pos), XINT (y_pos));
826 #endif
827
828 return frame;
829 }
830 #endif
831 \f
832 DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
833 0, 1, 0,
834 "Make the frame FRAME visible (assuming it is an X-window).\n\
835 Also raises the frame so that nothing obscures it.\n\
836 If omitted, FRAME defaults to the currently selected frame.")
837 (frame)
838 Lisp_Object frame;
839 {
840 if (NILP (frame))
841 XSET (frame, Lisp_Frame, selected_frame);
842
843 CHECK_LIVE_FRAME (frame, 0);
844
845 #ifdef HAVE_X_WINDOWS
846 if (FRAME_X_P (XFRAME (frame)))
847 x_make_frame_visible (XFRAME (frame));
848 #endif
849
850 return frame;
851 }
852
853 DEFUN ("make-frame-invisible", Fmake_frame_invisible, Smake_frame_invisible,
854 0, 1, "",
855 "Make the frame FRAME invisible (assuming it is an X-window).\n\
856 If omitted, FRAME defaults to the currently selected frame.")
857 (frame)
858 Lisp_Object frame;
859 {
860 if (NILP (frame))
861 XSET (frame, Lisp_Frame, selected_frame);
862
863 CHECK_LIVE_FRAME (frame, 0);
864
865 #ifdef HAVE_X_WINDOWS
866 if (FRAME_X_P (XFRAME (frame)))
867 x_make_frame_invisible (XFRAME (frame));
868 #endif
869
870 return Qnil;
871 }
872
873 DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame,
874 0, 1, "",
875 "Make the frame FRAME into an icon.\n\
876 If omitted, FRAME defaults to the currently selected frame.")
877 (frame)
878 Lisp_Object frame;
879 {
880 if (NILP (frame))
881 XSET (frame, Lisp_Frame, selected_frame);
882
883 CHECK_LIVE_FRAME (frame, 0);
884
885 #ifdef HAVE_X_WINDOWS
886 if (FRAME_X_P (XFRAME (frame)))
887 x_iconify_frame (XFRAME (frame));
888 #endif
889
890 return Qnil;
891 }
892
893 DEFUN ("frame-visible-p", Fframe_visible_p, Sframe_visible_p,
894 1, 1, 0,
895 "Return t if FRAME is now \"visible\" (actually in use for display).\n\
896 A frame that is not \"visible\" is not updated and, if it works through\n\
897 a window system, it may not show at all.\n\
898 Return the symbol `icon' if frame is visible only as an icon.")
899 (frame)
900 Lisp_Object frame;
901 {
902 CHECK_LIVE_FRAME (frame, 0);
903
904 if (FRAME_VISIBLE_P (XFRAME (frame)))
905 return Qt;
906 if (FRAME_ICONIFIED_P (XFRAME (frame)))
907 return Qicon;
908 return Qnil;
909 }
910
911 DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list,
912 0, 0, 0,
913 "Return a list of all frames now \"visible\" (being updated).")
914 ()
915 {
916 Lisp_Object tail, frame;
917 struct frame *f;
918 Lisp_Object value;
919
920 value = Qnil;
921 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
922 {
923 frame = XCONS (tail)->car;
924 if (XTYPE (frame) != Lisp_Frame)
925 continue;
926 f = XFRAME (frame);
927 if (FRAME_VISIBLE_P (f))
928 value = Fcons (frame, value);
929 }
930 return value;
931 }
932
933
934 \f
935 DEFUN ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus,
936 1, 2, 0,
937 "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
938 In other words, switch-frame events caused by events in FRAME will\n\
939 request a switch to FOCUS-FRAME, and `last-event-frame' will be\n\
940 FOCUS-FRAME after reading an event typed at FRAME.\n\
941 \n\
942 If FOCUS-FRAME is omitted or nil, any existing redirection is\n\
943 cancelled, and the frame again receives its own keystrokes.\n\
944 \n\
945 Focus redirection is useful for temporarily redirecting keystrokes to\n\
946 a surrogate minibuffer frame when a frame doesn't have its own\n\
947 minibuffer window.\n\
948 \n\
949 A frame's focus redirection can be changed by select-frame. If frame\n\
950 FOO is selected, and then a different frame BAR is selected, any\n\
951 frames redirecting their focus to FOO are shifted to redirect their\n\
952 focus to BAR. This allows focus redirection to work properly when the\n\
953 user switches from one frame to another using `select-window'.\n\
954 \n\
955 This means that a frame whose focus is redirected to itself is treated\n\
956 differently from a frame whose focus is redirected to nil; the former\n\
957 is affected by select-frame, while the latter is not.\n\
958 \n\
959 The redirection lasts until `redirect-frame-focus' is called to change it.")
960 (frame, focus_frame)
961 Lisp_Object frame, focus_frame;
962 {
963 CHECK_LIVE_FRAME (frame, 0);
964
965 if (! NILP (focus_frame))
966 CHECK_LIVE_FRAME (focus_frame, 1);
967
968 XFRAME (frame)->focus_frame = focus_frame;
969
970 if (frame_rehighlight_hook)
971 (*frame_rehighlight_hook) ();
972
973 return Qnil;
974 }
975
976
977 DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0,
978 "Return the frame to which FRAME's keystrokes are currently being sent.\n\
979 This returns nil if FRAME's focus is not redirected.\n\
980 See `redirect-frame-focus'.")
981 (frame)
982 Lisp_Object frame;
983 {
984 CHECK_LIVE_FRAME (frame, 0);
985
986 return FRAME_FOCUS_FRAME (XFRAME (frame));
987 }
988
989
990 \f
991 Lisp_Object
992 get_frame_param (frame, prop)
993 register struct frame *frame;
994 Lisp_Object prop;
995 {
996 register Lisp_Object tem;
997
998 tem = Fassq (prop, frame->param_alist);
999 if (EQ (tem, Qnil))
1000 return tem;
1001 return Fcdr (tem);
1002 }
1003
1004 void
1005 store_in_alist (alistptr, prop, val)
1006 Lisp_Object *alistptr, val;
1007 Lisp_Object prop;
1008 {
1009 register Lisp_Object tem;
1010
1011 tem = Fassq (prop, *alistptr);
1012 if (EQ (tem, Qnil))
1013 *alistptr = Fcons (Fcons (prop, val), *alistptr);
1014 else
1015 Fsetcdr (tem, val);
1016 }
1017
1018 void
1019 store_frame_param (f, prop, val)
1020 struct frame *f;
1021 Lisp_Object prop, val;
1022 {
1023 register Lisp_Object tem;
1024
1025 tem = Fassq (prop, f->param_alist);
1026 if (EQ (tem, Qnil))
1027 f->param_alist = Fcons (Fcons (prop, val), f->param_alist);
1028 else
1029 Fsetcdr (tem, val);
1030
1031 if (EQ (prop, Qminibuffer)
1032 && XTYPE (val) == Lisp_Window)
1033 {
1034 if (! MINI_WINDOW_P (XWINDOW (val)))
1035 error ("Surrogate minibuffer windows must be minibuffer windows.");
1036
1037 if (FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f))
1038 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer.");
1039
1040 /* Install the chosen minibuffer window, with proper buffer. */
1041 f->minibuffer_window = val;
1042 }
1043 }
1044
1045 DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0,
1046 "Return the parameters-alist of frame FRAME.\n\
1047 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
1048 The meaningful PARMs depend on the kind of frame.\n\
1049 If FRAME is omitted, return information on the currently selected frame.")
1050 (frame)
1051 Lisp_Object frame;
1052 {
1053 Lisp_Object alist;
1054 struct frame *f;
1055
1056 if (EQ (frame, Qnil))
1057 f = selected_frame;
1058 else
1059 {
1060 CHECK_FRAME (frame, 0);
1061 f = XFRAME (frame);
1062 }
1063
1064 if (f->display.nothing == 0)
1065 return Qnil;
1066
1067 alist = Fcopy_alist (f->param_alist);
1068 store_in_alist (&alist, Qname, f->name);
1069 store_in_alist (&alist, Qheight, make_number (f->height));
1070 store_in_alist (&alist, Qwidth, make_number (f->width));
1071 store_in_alist (&alist, Qmodeline, (f->wants_modeline ? Qt : Qnil));
1072 store_in_alist (&alist, Qminibuffer,
1073 (! FRAME_HAS_MINIBUF_P (f) ? Qnone
1074 : (FRAME_MINIBUF_ONLY_P (f) ? Qonly
1075 : FRAME_MINIBUF_WINDOW (f))));
1076 store_in_alist (&alist, Qunsplittable, (f->no_split ? Qt : Qnil));
1077
1078 #ifdef HAVE_X_WINDOWS
1079 if (FRAME_X_P (f))
1080 x_report_frame_params (f, &alist);
1081 #endif
1082 return alist;
1083 }
1084
1085 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters,
1086 Smodify_frame_parameters, 2, 2, 0,
1087 "Modify the parameters of frame FRAME according to ALIST.\n\
1088 ALIST is an alist of parameters to change and their new values.\n\
1089 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
1090 The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
1091 (frame, alist)
1092 Lisp_Object frame, alist;
1093 {
1094 FRAME_PTR f;
1095 register Lisp_Object tail, elt, prop, val;
1096
1097 if (EQ (frame, Qnil))
1098 f = selected_frame;
1099 else
1100 {
1101 CHECK_LIVE_FRAME (frame, 0);
1102 f = XFRAME (frame);
1103 }
1104
1105 #ifdef HAVE_X_WINDOWS
1106 if (FRAME_X_P (f))
1107 #if 1
1108 x_set_frame_parameters (f, alist);
1109 #else
1110 for (tail = alist; !EQ (tail, Qnil); tail = Fcdr (tail))
1111 {
1112 elt = Fcar (tail);
1113 prop = Fcar (elt);
1114 val = Fcdr (elt);
1115 x_set_frame_param (f, prop, val, get_frame_param (f, prop));
1116 store_frame_param (f, prop, val);
1117 }
1118 #endif
1119 #endif
1120
1121 return Qnil;
1122 }
1123 \f
1124
1125 #if 0
1126 /* This function isn't useful enough by itself to include; we need to
1127 add functions to allow the user to find the size of a font before
1128 this is actually useful. */
1129
1130 DEFUN ("frame-pixel-size", Fframe_pixel_size,
1131 Sframe_pixel_size, 1, 1, 0,
1132 "Return a cons (width . height) of FRAME's size in pixels.")
1133 (frame)
1134 Lisp_Object frame;
1135 {
1136 register struct frame *f;
1137 int width, height;
1138
1139 CHECK_LIVE_FRAME (frame, 0);
1140 f = XFRAME (frame);
1141
1142 return Fcons (make_number (x_pixel_width (f)),
1143 make_number (x_pixel_height (f)));
1144 }
1145 #endif
1146
1147 #if 0
1148 /* These functions have no C callers, and can be written nicely in lisp. */
1149
1150 DEFUN ("frame-height", Fframe_height, Sframe_height, 0, 0, 0,
1151 "Return number of lines available for display on selected frame.")
1152 ()
1153 {
1154 return make_number (FRAME_HEIGHT (selected_frame));
1155 }
1156
1157 DEFUN ("frame-width", Fframe_width, Sframe_width, 0, 0, 0,
1158 "Return number of columns available for display on selected frame.")
1159 ()
1160 {
1161 return make_number (FRAME_WIDTH (selected_frame));
1162 }
1163 #endif
1164
1165 DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
1166 "Specify that the frame FRAME has LINES lines.\n\
1167 Optional third arg non-nil means that redisplay should use LINES lines\n\
1168 but that the idea of the actual height of the frame should not be changed.")
1169 (frame, rows, pretend)
1170 Lisp_Object frame, rows, pretend;
1171 {
1172 register struct frame *f;
1173
1174 CHECK_NUMBER (rows, 0);
1175 if (NILP (frame))
1176 f = selected_frame;
1177 else
1178 {
1179 CHECK_LIVE_FRAME (frame, 0);
1180 f = XFRAME (frame);
1181 }
1182
1183 #ifdef HAVE_X_WINDOWS
1184 if (FRAME_X_P (f))
1185 {
1186 if (XINT (rows) != f->width)
1187 x_set_window_size (f, f->width, XINT (rows));
1188 }
1189 else
1190 #endif
1191 change_frame_size (f, XINT (rows), 0, !NILP (pretend), 0);
1192 return Qnil;
1193 }
1194
1195 DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 3, 0,
1196 "Specify that the frame FRAME has COLS columns.\n\
1197 Optional third arg non-nil means that redisplay should use COLS columns\n\
1198 but that the idea of the actual width of the frame should not be changed.")
1199 (frame, cols, pretend)
1200 Lisp_Object frame, cols, pretend;
1201 {
1202 register struct frame *f;
1203 CHECK_NUMBER (cols, 0);
1204 if (NILP (frame))
1205 f = selected_frame;
1206 else
1207 {
1208 CHECK_LIVE_FRAME (frame, 0);
1209 f = XFRAME (frame);
1210 }
1211
1212 #ifdef HAVE_X_WINDOWS
1213 if (FRAME_X_P (f))
1214 {
1215 if (XINT (cols) != f->width)
1216 x_set_window_size (f, XINT (cols), f->height);
1217 }
1218 else
1219 #endif
1220 change_frame_size (f, 0, XINT (cols), !NILP (pretend), 0);
1221 return Qnil;
1222 }
1223
1224 DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0,
1225 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1226 (frame, cols, rows)
1227 Lisp_Object frame, cols, rows;
1228 {
1229 register struct frame *f;
1230 int mask;
1231
1232 CHECK_LIVE_FRAME (frame, 0);
1233 CHECK_NUMBER (cols, 2);
1234 CHECK_NUMBER (rows, 1);
1235 f = XFRAME (frame);
1236
1237 #ifdef HAVE_X_WINDOWS
1238 if (FRAME_X_P (f))
1239 {
1240 if (XINT (rows) != f->height || XINT (cols) != f->width)
1241 x_set_window_size (f, XINT (cols), XINT (rows));
1242 }
1243 else
1244 #endif
1245 change_frame_size (f, XINT (rows), XINT (cols), 0, 0);
1246
1247 return Qnil;
1248 }
1249
1250 DEFUN ("set-frame-position", Fset_frame_position,
1251 Sset_frame_position, 3, 3, 0,
1252 "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
1253 If XOFFSET or YOFFSET are negative, they are interpreted relative to\n\
1254 the leftmost or bottommost position FRAME could occupy without going\n\
1255 off the screen.")
1256 (frame, xoffset, yoffset)
1257 Lisp_Object frame, xoffset, yoffset;
1258 {
1259 register struct frame *f;
1260 int mask;
1261
1262 CHECK_LIVE_FRAME (frame, 0);
1263 CHECK_NUMBER (xoffset, 1);
1264 CHECK_NUMBER (yoffset, 2);
1265 f = XFRAME (frame);
1266
1267 #ifdef HAVE_X_WINDOWS
1268 if (FRAME_X_P (f))
1269 x_set_offset (f, XINT (xoffset), XINT (yoffset));
1270 #endif
1271
1272 return Qt;
1273 }
1274
1275 \f
1276 #ifndef HAVE_X11
1277 DEFUN ("rubber-band-rectangle", Frubber_band_rectangle, Srubber_band_rectangle,
1278 3, 3, "",
1279 "Ask user to specify a window position and size on FRAME with the mouse.\n\
1280 Arguments are FRAME, NAME and GEO. NAME is a name to be displayed as\n\
1281 the purpose of this rectangle. GEO is an X-windows size spec that can\n\
1282 specify defaults for some sizes/positions. If GEO specifies everything,\n\
1283 the mouse is not used.\n\
1284 Returns a list of five values: (FRAME LEFT TOP WIDTH HEIGHT).")
1285 (frame, name, geo)
1286 Lisp_Object frame;
1287 Lisp_Object name;
1288 Lisp_Object geo;
1289 {
1290 int vals[4];
1291 Lisp_Object nums[4];
1292 int i;
1293
1294 CHECK_FRAME (frame, 0);
1295 CHECK_STRING (name, 1);
1296 CHECK_STRING (geo, 2);
1297
1298 switch (XFRAME (frame)->output_method)
1299 {
1300 case output_x_window:
1301 x_rubber_band (XFRAME (frame), &vals[0], &vals[1], &vals[2], &vals[3],
1302 XSTRING (geo)->data, XSTRING (name)->data);
1303 break;
1304
1305 default:
1306 return Qnil;
1307 }
1308
1309 for (i = 0; i < 4; i++)
1310 XFASTINT (nums[i]) = vals[i];
1311 return Fcons (frame, Flist (4, nums));
1312 return Qnil;
1313 }
1314 #endif /* not HAVE_X11 */
1315 \f
1316 choose_minibuf_frame ()
1317 {
1318 /* For lowest-level minibuf, put it on currently selected frame
1319 if frame has a minibuffer. */
1320
1321 if (minibuf_level == 0
1322 && selected_frame != 0
1323 && !EQ (minibuf_window, selected_frame->minibuffer_window))
1324 {
1325 /* I don't think that any frames may validly have a null minibuffer
1326 window anymore. */
1327 if (NILP (selected_frame->minibuffer_window))
1328 abort ();
1329
1330 Fset_window_buffer (selected_frame->minibuffer_window,
1331 XWINDOW (minibuf_window)->buffer);
1332 minibuf_window = selected_frame->minibuffer_window;
1333 }
1334 }
1335 \f
1336 syms_of_frame ()
1337 {
1338 /*&&& init symbols here &&&*/
1339 Qframep = intern ("framep");
1340 staticpro (&Qframep);
1341 Qlive_frame_p = intern ("live-frame-p");
1342 staticpro (&Qlive_frame_p);
1343 Qheight = intern ("height");
1344 staticpro (&Qheight);
1345 Qicon = intern ("icon");
1346 staticpro (&Qicon);
1347 Qminibuffer = intern ("minibuffer");
1348 staticpro (&Qminibuffer);
1349 Qmodeline = intern ("modeline");
1350 staticpro (&Qmodeline);
1351 Qname = intern ("name");
1352 staticpro (&Qname);
1353 Qnone = intern ("none");
1354 staticpro (&Qnone);
1355 Qonly = intern ("only");
1356 staticpro (&Qonly);
1357 Qunsplittable = intern ("unsplittable");
1358 staticpro (&Qunsplittable);
1359 Qwidth = intern ("width");
1360 staticpro (&Qwidth);
1361 Qx = intern ("x");
1362 staticpro (&Qx);
1363
1364 staticpro (&Vframe_list);
1365
1366 DEFVAR_LISP ("terminal-frame", &Vterminal_frame,
1367 "The initial frame-object, which represents Emacs's stdout.");
1368
1369 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified,
1370 "Non-nil if all of emacs is iconified and frame updates are not needed.");
1371 Vemacs_iconified = Qnil;
1372
1373 DEFVAR_LISP ("default-minibuffer-frame", &Vdefault_minibuffer_frame,
1374 "Minibufferless frames use this frame's minibuffer.\n\
1375 \n\
1376 Emacs cannot create minibufferless frames unless this is set to an\n\
1377 appropriate surrogate.\n\
1378 \n\
1379 Emacs consults this variable only when creating minibufferless\n\
1380 frames; once the frame is created, it sticks with its assigned\n\
1381 minibuffer, no matter what this variable is set to. This means that\n\
1382 this variable doesn't necessarily say anything meaningful about the\n\
1383 current set of frames, or where the minibuffer is currently being\n\
1384 displayed.");
1385 Vdefault_minibuffer_frame = Qnil;
1386
1387 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
1388 "Alist of default values for frame creation.\n\
1389 These may be set in your init file, like this:\n\
1390 (setq default-frame-alist '((width . 80) (height . 55)))\n\
1391 These override values given in window system configuration data, like\n\
1392 X Windows' defaults database.\n\
1393 For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
1394 For values specific to the separate minibuffer frame, see\n\
1395 `minibuffer-frame-alist'.");
1396 Vdefault_frame_alist = Qnil;
1397
1398 defsubr (&Sframep);
1399 defsubr (&Slive_frame_p);
1400 defsubr (&Sselect_frame);
1401 defsubr (&Sselected_frame);
1402 defsubr (&Swindow_frame);
1403 defsubr (&Sframe_root_window);
1404 defsubr (&Sframe_selected_window);
1405 defsubr (&Sframe_list);
1406 defsubr (&Snext_frame);
1407 defsubr (&Sdelete_frame);
1408 defsubr (&Smouse_position);
1409 defsubr (&Sset_mouse_position);
1410 #if 0
1411 defsubr (&Sframe_configuration);
1412 defsubr (&Srestore_frame_configuration);
1413 #endif
1414 defsubr (&Smake_frame_visible);
1415 defsubr (&Smake_frame_invisible);
1416 defsubr (&Siconify_frame);
1417 defsubr (&Sframe_visible_p);
1418 defsubr (&Svisible_frame_list);
1419 defsubr (&Sredirect_frame_focus);
1420 defsubr (&Sframe_focus);
1421 defsubr (&Sframe_parameters);
1422 defsubr (&Smodify_frame_parameters);
1423 #if 0
1424 defsubr (&Sframe_pixel_size);
1425 defsubr (&Sframe_height);
1426 defsubr (&Sframe_width);
1427 #endif
1428 defsubr (&Sset_frame_height);
1429 defsubr (&Sset_frame_width);
1430 defsubr (&Sset_frame_size);
1431 defsubr (&Sset_frame_position);
1432 #ifndef HAVE_X11
1433 defsubr (&Srubber_band_rectangle);
1434 #endif /* HAVE_X11 */
1435 }
1436
1437 keys_of_frame ()
1438 {
1439 initial_define_lispy_key (global_map, "switch-frame", "select-frame");
1440 }
1441
1442 #else /* not MULTI_FRAME */
1443
1444 /* If we're not using multi-frame stuff, we still need to provide some
1445 support functions. */
1446
1447 /* Unless this function is defined, providing set-frame-height and
1448 set-frame-width doesn't help compatibility any, since they both
1449 want this as their first argument. */
1450 DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
1451 "Return the frame that is now selected.")
1452 ()
1453 {
1454 Lisp_Object tem;
1455 XFASTINT (tem) = 0;
1456 return tem;
1457 }
1458
1459 DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
1460 "Specify that the frame FRAME has LINES lines.\n\
1461 Optional third arg non-nil means that redisplay should use LINES lines\n\
1462 but that the idea of the actual height of the frame should not be changed.")
1463 (frame, rows, pretend)
1464 Lisp_Object frame, rows, pretend;
1465 {
1466 CHECK_NUMBER (rows, 0);
1467
1468 change_frame_size (0, XINT (rows), 0, !NILP (pretend), 0);
1469 return Qnil;
1470 }
1471
1472 DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 3, 0,
1473 "Specify that the frame FRAME has COLS columns.\n\
1474 Optional third arg non-nil means that redisplay should use COLS columns\n\
1475 but that the idea of the actual width of the frame should not be changed.")
1476 (frame, cols, pretend)
1477 Lisp_Object frame, cols, pretend;
1478 {
1479 CHECK_NUMBER (cols, 0);
1480
1481 change_frame_size (0, 0, XINT (cols), !NILP (pretend), 0);
1482 return Qnil;
1483 }
1484
1485 DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0,
1486 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1487 (frame, cols, rows)
1488 Lisp_Object frame, cols, rows;
1489 {
1490 CHECK_NUMBER (cols, 2);
1491 CHECK_NUMBER (rows, 1);
1492
1493 change_frame_size (0, XINT (rows), XINT (cols), 0, 0);
1494
1495 return Qnil;
1496 }
1497
1498 DEFUN ("frame-height", Fframe_height, Sframe_height, 0, 0, 0,
1499 "Return number of lines available for display on selected frame.")
1500 ()
1501 {
1502 return make_number (FRAME_HEIGHT (selected_frame));
1503 }
1504
1505 DEFUN ("frame-width", Fframe_width, Sframe_width, 0, 0, 0,
1506 "Return number of columns available for display on selected frame.")
1507 ()
1508 {
1509 return make_number (FRAME_WIDTH (selected_frame));
1510 }
1511
1512 /* These are for backward compatibility with Emacs 18. */
1513
1514 DEFUN ("set-screen-height", Fset_screen_height, Sset_screen_height, 1, 2, 0,
1515 "Tell redisplay that the screen has LINES lines.\n\
1516 Optional second arg non-nil means that redisplay should use LINES lines\n\
1517 but that the idea of the actual height of the screen should not be changed.")
1518 (lines, pretend)
1519 Lisp_Object lines, pretend;
1520 {
1521 CHECK_NUMBER (lines, 0);
1522
1523 change_frame_size (0, XINT (lines), 0, !NILP (pretend), 0);
1524 return Qnil;
1525 }
1526
1527 DEFUN ("set-screen-width", Fset_screen_width, Sset_screen_width, 1, 2, 0,
1528 "Tell redisplay that the screen has COLS columns.\n\
1529 Optional second arg non-nil means that redisplay should use COLS columns\n\
1530 but that the idea of the actual width of the screen should not be changed.")
1531 (cols, pretend)
1532 Lisp_Object cols, pretend;
1533 {
1534 CHECK_NUMBER (cols, 0);
1535
1536 change_frame_size (0, 0, XINT (cols), !NILP (pretend), 0);
1537 return Qnil;
1538 }
1539
1540 syms_of_frame ()
1541 {
1542 defsubr (&Sset_frame_height);
1543 defsubr (&Sset_frame_width);
1544 defsubr (&Sset_frame_size);
1545 defsubr (&Sset_screen_height);
1546 defsubr (&Sset_screen_width);
1547 defsubr (&Sframe_height);
1548 Ffset (intern ("screen-height"), intern ("frame-height"));
1549 defsubr (&Sframe_width);
1550 Ffset (intern ("screen-width"), intern ("frame-width"));
1551 }
1552
1553 keys_of_frame ()
1554 {
1555 }
1556
1557 #endif /* not MULTI_FRAME */
1558
1559
1560
1561