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