(auto-mode-alist): added pairs for .ms, .man, .mk, [Mm]akefile, .lex.
[emacs.git] / src / frame.c
blob8eea8d43ca25b3e7ab8ca6a3ab7460bc6db1db67
1 /* Generic frame functions.
2 Copyright (C) 1989, 1992, 1993 Free Software Foundation.
4 This file is part of GNU Emacs.
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.
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.
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. */
20 #include <stdio.h>
22 #include "config.h"
23 #include "lisp.h"
24 #include "frame.h"
26 #ifdef MULTI_FRAME
28 #include "buffer.h"
29 #include "window.h"
30 #include "termhooks.h"
32 /* These help us bind and responding to switch-frame events. */
33 #include "commands.h"
34 #include "keyboard.h"
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;
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.
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 */
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 Qmenu_bar_lines;
86 Lisp_Object Qwidth;
87 Lisp_Object Qx;
89 extern Lisp_Object Vminibuffer_list;
90 extern Lisp_Object get_minibuffer ();
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;
100 if (XTYPE (object) != Lisp_Frame)
101 return Qnil;
102 switch (XFRAME (object)->output_method)
104 case output_termcap:
105 return Qt;
106 case output_x_window:
107 return Qx;
108 default:
109 abort ();
113 DEFUN ("frame-live-p", Fframe_live_p, Sframe_live_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;
122 return ((FRAMEP (object)
123 && FRAME_LIVE_P (XFRAME (object)))
124 ? Fframep (object)
125 : Qnil);
128 struct frame *
129 make_frame (mini_p)
130 int mini_p;
132 Lisp_Object frame;
133 register struct frame *f;
134 register Lisp_Object root_window;
135 register Lisp_Object mini_window;
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);
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_scroll_bars = 0;
162 f->has_vertical_scroll_bars = 0;
163 f->param_alist = Qnil;
164 f->scroll_bars = Qnil;
165 f->condemned_scroll_bars = Qnil;
167 root_window = make_window ();
168 if (mini_p)
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;
177 else
179 mini_window = Qnil;
180 XWINDOW (root_window)->next = Qnil;
181 f->minibuffer_window = Qnil;
184 XWINDOW (root_window)->frame = frame;
186 /* 10 is arbitrary,
187 just so that there is "something there."
188 Correct size will be set up later with change_frame_size. */
190 f->width = 10;
191 f->height = 10;
193 XFASTINT (XWINDOW (root_window)->width) = 10;
194 XFASTINT (XWINDOW (root_window)->height) = (mini_p ? 9 : 10);
196 if (mini_p)
198 XFASTINT (XWINDOW (mini_window)->width) = 10;
199 XFASTINT (XWINDOW (mini_window)->top) = 9;
200 XFASTINT (XWINDOW (mini_window)->height) = 1;
203 /* Choose a buffer for the frame's root window. */
205 Lisp_Object buf;
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);
216 if (mini_p)
218 XWINDOW (mini_window)->buffer = Qt;
219 Fset_window_buffer (mini_window,
220 (NILP (Vminibuffer_list)
221 ? get_minibuffer (0)
222 : Fcar (Vminibuffer_list)));
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;
231 Vframe_list = Fcons (frame, Vframe_list);
233 return 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). */
240 struct frame *
241 make_frame_without_minibuffer (mini_window)
242 register Lisp_Object mini_window;
244 register struct frame *f;
246 /* Choose the minibuffer window to use. */
247 if (NILP (mini_window))
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;
255 else
257 CHECK_LIVE_WINDOW (mini_window, 0);
260 /* Make a frame containing just a root window. */
261 f = make_frame (0);
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;
272 /* Make a frame containing only a minibuffer window. */
274 struct frame *
275 make_minibuffer_frame ()
277 /* First make a frame containing just a root window, no minibuffer. */
279 register struct frame *f = make_frame (0);
280 register Lisp_Object mini_window;
281 register Lisp_Object frame;
283 XSET (frame, Lisp_Frame, f);
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;
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. */
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;
301 /* Put the proper buffer in that window. */
303 Fset_window_buffer (mini_window,
304 (NILP (Vminibuffer_list)
305 ? get_minibuffer (0)
306 : Fcar (Vminibuffer_list)));
307 return f;
310 /* Construct a frame that refers to the terminal (stdin and stdout). */
312 struct frame *
313 make_terminal_frame ()
315 register struct frame *f;
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;
326 DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e",
327 "Select the frame FRAME.\n\
328 Subseqent editing commands apply to its selected window.\n\
329 The selection of FRAME lasts until the next time the user does\n\
330 something to select a different frame, or until the next time this\n\
331 function is called.")
332 (frame, no_enter)
333 Lisp_Object frame, no_enter;
335 return Fhandle_switch_frame (frame, no_enter);
339 DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 2, "e",
340 "Handle a switch-frame event EVENT.\n\
341 Switch-frame events is usually bound to this function.\n\
342 A switch-frame event tells Emacs that the window manager has requested\n\
343 that the user's events be directed to the frame mentioned in the event.\n\
344 This function selects the selected window of the frame of EVENT.\n\
346 If EVENT is frame object, handle it as if it were a switch-frame event\n\
347 to that frame.")
348 (frame, no_enter)
349 Lisp_Object frame, no_enter;
351 /* If FRAME is a switch-frame event, extract the frame we should
352 switch to. */
353 if (CONSP (frame)
354 && EQ (XCONS (frame)->car, Qswitch_frame)
355 && CONSP (XCONS (frame)->cdr))
356 frame = XCONS (XCONS (frame)->cdr)->car;
358 CHECK_LIVE_FRAME (frame, 0);
360 if (selected_frame == XFRAME (frame))
361 return frame;
363 /* If a frame's focus has been redirected toward the currently
364 selected frame, we should change the redirection to point to the
365 newly selected frame. This means that if the focus is redirected
366 from a minibufferless frame to a surrogate minibuffer frame, we
367 can use `other-window' to switch between all the frames using
368 that minibuffer frame, and the focus redirection will follow us
369 around. */
371 Lisp_Object tail;
373 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
375 Lisp_Object focus;
377 if (XTYPE (XCONS (tail)->car) != Lisp_Frame)
378 abort ();
380 focus = FRAME_FOCUS_FRAME (XFRAME (XCONS (tail)->car));
382 if (XTYPE (focus) == Lisp_Frame
383 && XFRAME (focus) == selected_frame)
384 Fredirect_frame_focus (XCONS (tail)->car, frame);
388 selected_frame = XFRAME (frame);
389 if (! FRAME_MINIBUF_ONLY_P (selected_frame))
390 last_nonminibuf_frame = selected_frame;
392 Fselect_window (XFRAME (frame)->selected_window);
394 /* I think this should be done with a hook. */
395 #ifdef HAVE_X_WINDOWS
396 if (FRAME_X_P (XFRAME (frame))
397 && NILP (no_enter))
399 Ffocus_frame (frame);
401 #endif
402 choose_minibuf_frame ();
404 /* We want to make sure that the next event generates a frame-switch
405 event to the appropriate frame. This seems kludgey to me, but
406 before you take it out, make sure that evaluating something like
407 (select-window (frame-root-window (new-frame))) doesn't end up
408 with your typing being interpreted in the new frame instead of
409 the one you're actually typing in. */
410 internal_last_event_frame = Qnil;
412 return frame;
415 DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
416 "Return the frame that is now selected.")
419 Lisp_Object tem;
420 XSET (tem, Lisp_Frame, selected_frame);
421 return tem;
424 DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
425 "Return the frame object that window WINDOW is on.")
426 (window)
427 Lisp_Object window;
429 CHECK_LIVE_WINDOW (window, 0);
430 return XWINDOW (window)->frame;
433 DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0,
434 "Returns the root-window of FRAME.\n\
435 If omitted, FRAME defaults to the currently selected frame.")
436 (frame)
437 Lisp_Object frame;
439 if (NILP (frame))
440 XSET (frame, Lisp_Frame, selected_frame);
441 else
442 CHECK_LIVE_FRAME (frame, 0);
444 return XFRAME (frame)->root_window;
447 DEFUN ("frame-selected-window", Fframe_selected_window,
448 Sframe_selected_window, 0, 1, 0,
449 "Return the selected window of frame object FRAME.\n\
450 If omitted, FRAME defaults to the currently selected frame.")
451 (frame)
452 Lisp_Object frame;
454 if (NILP (frame))
455 XSET (frame, Lisp_Frame, selected_frame);
456 else
457 CHECK_LIVE_FRAME (frame, 0);
459 return XFRAME (frame)->selected_window;
462 DEFUN ("frame-list", Fframe_list, Sframe_list,
463 0, 0, 0,
464 "Return a list of all frames.")
467 return Fcopy_sequence (Vframe_list);
470 /* Return the next frame in the frame list after FRAME.
471 If MINIBUF is nil, exclude minibuffer-only frames.
472 If MINIBUF is a window, include only frames using that window for
473 their minibuffer.
474 If MINIBUF is non-nil, and not a window, include all frames. */
475 Lisp_Object
476 next_frame (frame, minibuf)
477 Lisp_Object frame;
478 Lisp_Object minibuf;
480 Lisp_Object tail;
481 int passed = 0;
483 /* There must always be at least one frame in Vframe_list. */
484 if (! CONSP (Vframe_list))
485 abort ();
487 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
488 forever. Forestall that. */
489 CHECK_LIVE_FRAME (frame, 0);
491 while (1)
492 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
494 Lisp_Object f = XCONS (tail)->car;
496 if (passed)
498 /* Decide whether this frame is eligible to be returned. */
500 /* If we've looped all the way around without finding any
501 eligible frames, return the original frame. */
502 if (EQ (f, frame))
503 return f;
505 /* Let minibuf decide if this frame is acceptable. */
506 if (NILP (minibuf))
508 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
509 return f;
511 else if (XTYPE (minibuf) == Lisp_Window)
513 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf))
514 return f;
516 else
517 return f;
520 if (EQ (frame, f))
521 passed++;
525 /* Return the previous frame in the frame list before FRAME.
526 If MINIBUF is nil, exclude minibuffer-only frames.
527 If MINIBUF is a window, include only frames using that window for
528 their minibuffer.
529 If MINIBUF is non-nil and not a window, include all frames. */
530 Lisp_Object
531 prev_frame (frame, minibuf)
532 Lisp_Object frame;
533 Lisp_Object minibuf;
535 Lisp_Object tail;
536 Lisp_Object prev;
538 /* There must always be at least one frame in Vframe_list. */
539 if (! CONSP (Vframe_list))
540 abort ();
542 prev = Qnil;
543 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
545 Lisp_Object f = XCONS (tail)->car;
547 if (XTYPE (f) != Lisp_Frame)
548 abort ();
550 if (EQ (frame, f) && !NILP (prev))
551 return prev;
553 /* Decide whether this frame is eligible to be returned,
554 according to minibuf. */
555 if (NILP (minibuf))
557 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
558 prev = f;
560 else if (XTYPE (minibuf) == Lisp_Window)
562 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf))
563 prev = f;
565 else
566 prev = f;
569 /* We've scanned the entire list. */
570 if (NILP (prev))
571 /* We went through the whole frame list without finding a single
572 acceptable frame. Return the original frame. */
573 return frame;
574 else
575 /* There were no acceptable frames in the list before FRAME; otherwise,
576 we would have returned directly from the loop. Since PREV is the last
577 acceptable frame in the list, return it. */
578 return prev;
581 DEFUN ("next-frame", Fnext_frame, Snext_frame, 0, 2, 0,
582 "Return the next frame in the frame list after FRAME.\n\
583 By default, skip minibuffer-only frames.\n\
584 If omitted, FRAME defaults to the selected frame.\n\
585 If optional argument MINIFRAME is non-nil, include minibuffer-only frames.\n\
586 If MINIFRAME is a window, include only frames using that window for their\n\
587 minibuffer.\n\
588 If MINIFRAME is non-nil and not a window, include all frames.")
589 (frame, miniframe)
590 Lisp_Object frame, miniframe;
592 Lisp_Object tail;
594 if (NILP (frame))
595 XSET (frame, Lisp_Frame, selected_frame);
596 else
597 CHECK_LIVE_FRAME (frame, 0);
599 return next_frame (frame, miniframe);
603 DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 1, "",
604 "Delete FRAME, permanently eliminating it from use.\n\
605 If omitted, FRAME defaults to the selected frame.\n\
606 A frame may not be deleted if its minibuffer is used by other frames.")
607 (frame)
608 Lisp_Object frame;
610 struct frame *f;
612 if (EQ (frame, Qnil))
614 f = selected_frame;
615 XSET (frame, Lisp_Frame, f);
617 else
619 CHECK_FRAME (frame, 0);
620 f = XFRAME (frame);
623 if (! FRAME_LIVE_P (f))
624 return Qnil;
626 /* Are there any other frames besides this one? */
627 if (f == selected_frame && EQ (next_frame (frame, Qt), frame))
628 error ("Attempt to delete the only frame");
630 /* Does this frame have a minibuffer, and is it the surrogate
631 minibuffer for any other frame? */
632 if (FRAME_HAS_MINIBUF_P (XFRAME (frame)))
634 Lisp_Object frames;
636 for (frames = Vframe_list;
637 CONSP (frames);
638 frames = XCONS (frames)->cdr)
640 Lisp_Object this = XCONS (frames)->car;
642 if (! EQ (this, frame)
643 && EQ (frame,
644 (WINDOW_FRAME
645 (XWINDOW
646 (FRAME_MINIBUF_WINDOW
647 (XFRAME (this)))))))
648 error ("Attempt to delete a surrogate minibuffer frame");
652 /* Don't let the frame remain selected. */
653 if (f == selected_frame)
654 Fhandle_switch_frame (next_frame (frame, Qt), Qnil);
656 /* Don't allow minibuf_window to remain on a deleted frame. */
657 if (EQ (f->minibuffer_window, minibuf_window))
659 Fset_window_buffer (selected_frame->minibuffer_window,
660 XWINDOW (minibuf_window)->buffer);
661 minibuf_window = selected_frame->minibuffer_window;
664 /* Mark all the windows that used to be on FRAME as deleted, and then
665 remove the reference to them. */
666 delete_all_subwindows (XWINDOW (f->root_window));
667 f->root_window = Qnil;
669 Vframe_list = Fdelq (frame, Vframe_list);
670 FRAME_SET_VISIBLE (f, 0);
672 /* Since some events are handled at the interrupt level, we may get
673 an event for f at any time; if we zero out the frame's display
674 now, then we may trip up the event-handling code. Instead, we'll
675 promise that the display of the frame must be valid until we have
676 called the window-system-dependent frame destruction routine. */
678 /* I think this should be done with a hook. */
679 #ifdef HAVE_X_WINDOWS
680 if (FRAME_X_P (f))
681 x_destroy_window (f);
682 #endif
684 f->display.nothing = 0;
686 /* If we've deleted the last_nonminibuf_frame, then try to find
687 another one. */
688 if (f == last_nonminibuf_frame)
690 Lisp_Object frames;
692 last_nonminibuf_frame = 0;
694 for (frames = Vframe_list;
695 CONSP (frames);
696 frames = XCONS (frames)->cdr)
698 f = XFRAME (XCONS (frames)->car);
699 if (!FRAME_MINIBUF_ONLY_P (f))
701 last_nonminibuf_frame = f;
702 break;
707 /* If we've deleted Vdefault_minibuffer_frame, try to find another
708 one. Prefer minibuffer-only frames, but also notice frames
709 with other windows. */
710 if (EQ (frame, Vdefault_minibuffer_frame))
712 Lisp_Object frames;
714 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
715 Lisp_Object frame_with_minibuf = Qnil;
717 for (frames = Vframe_list;
718 CONSP (frames);
719 frames = XCONS (frames)->cdr)
721 Lisp_Object this = XCONS (frames)->car;
723 if (XTYPE (this) != Lisp_Frame)
724 abort ();
725 f = XFRAME (this);
727 if (FRAME_HAS_MINIBUF_P (f))
729 frame_with_minibuf = this;
730 if (FRAME_MINIBUF_ONLY_P (f))
731 break;
735 /* We know that there must be some frame with a minibuffer out
736 there. If this were not true, all of the frames present
737 would have to be minibufferless, which implies that at some
738 point their minibuffer frames must have been deleted, but
739 that is prohibited at the top; you can't delete surrogate
740 minibuffer frames. */
741 if (NILP (frame_with_minibuf))
742 abort ();
744 Vdefault_minibuffer_frame = frame_with_minibuf;
747 return Qnil;
750 /* Return mouse position in character cell units. */
752 DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0,
753 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
754 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
755 to read the mouse position, it returns the selected frame for FRAME\n\
756 and nil for X and Y.")
759 FRAME_PTR f;
760 Lisp_Object lispy_dummy;
761 enum scroll_bar_part party_dummy;
762 Lisp_Object x, y;
763 unsigned long long_dummy;
765 if (mouse_position_hook)
766 (*mouse_position_hook) (&f,
767 &lispy_dummy, &party_dummy,
768 &x, &y,
769 &long_dummy);
770 else
772 f = selected_frame;
773 x = y = Qnil;
776 XSET (lispy_dummy, Lisp_Frame, f);
777 return Fcons (lispy_dummy, Fcons (make_number (x), make_number (y)));
780 DEFUN ("set-mouse-position", Fset_mouse_position, Sset_mouse_position, 3, 3, 0,
781 "Move the mouse pointer to the center of cell (X,Y) in FRAME.\n\
782 WARNING: If you use this under X, you should do `unfocus-frame' afterwards.")
783 (frame, x, y)
784 Lisp_Object frame, x, y;
786 CHECK_LIVE_FRAME (frame, 0);
787 CHECK_NUMBER (x, 2);
788 CHECK_NUMBER (y, 1);
790 /* I think this should be done with a hook. */
791 #ifdef HAVE_X_WINDOWS
792 if (FRAME_X_P (XFRAME (frame)))
793 /* Warping the mouse will cause enternotify and focus events. */
794 x_set_mouse_position (XFRAME (frame), x, y);
795 #endif
797 return Qnil;
800 DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
801 0, 1, 0,
802 "Make the frame FRAME visible (assuming it is an X-window).\n\
803 Also raises the frame so that nothing obscures it.\n\
804 If omitted, FRAME defaults to the currently selected frame.")
805 (frame)
806 Lisp_Object frame;
808 if (NILP (frame))
809 XSET (frame, Lisp_Frame, selected_frame);
811 CHECK_LIVE_FRAME (frame, 0);
813 /* I think this should be done with a hook. */
814 #ifdef HAVE_X_WINDOWS
815 if (FRAME_X_P (XFRAME (frame)))
816 x_make_frame_visible (XFRAME (frame));
817 #endif
819 return frame;
822 DEFUN ("make-frame-invisible", Fmake_frame_invisible, Smake_frame_invisible,
823 0, 1, "",
824 "Make the frame FRAME invisible (assuming it is an X-window).\n\
825 If omitted, FRAME defaults to the currently selected frame.")
826 (frame)
827 Lisp_Object frame;
829 if (NILP (frame))
830 XSET (frame, Lisp_Frame, selected_frame);
832 CHECK_LIVE_FRAME (frame, 0);
834 /* I think this should be done with a hook. */
835 #ifdef HAVE_X_WINDOWS
836 if (FRAME_X_P (XFRAME (frame)))
837 x_make_frame_invisible (XFRAME (frame));
838 #endif
840 return Qnil;
843 DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame,
844 0, 1, "",
845 "Make the frame FRAME into an icon.\n\
846 If omitted, FRAME defaults to the currently selected frame.")
847 (frame)
848 Lisp_Object frame;
850 if (NILP (frame))
851 XSET (frame, Lisp_Frame, selected_frame);
853 CHECK_LIVE_FRAME (frame, 0);
855 /* I think this should be done with a hook. */
856 #ifdef HAVE_X_WINDOWS
857 if (FRAME_X_P (XFRAME (frame)))
858 x_iconify_frame (XFRAME (frame));
859 #endif
861 return Qnil;
864 DEFUN ("frame-visible-p", Fframe_visible_p, Sframe_visible_p,
865 1, 1, 0,
866 "Return t if FRAME is now \"visible\" (actually in use for display).\n\
867 A frame that is not \"visible\" is not updated and, if it works through\n\
868 a window system, it may not show at all.\n\
869 Return the symbol `icon' if frame is visible only as an icon.")
870 (frame)
871 Lisp_Object frame;
873 CHECK_LIVE_FRAME (frame, 0);
875 if (FRAME_VISIBLE_P (XFRAME (frame)))
876 return Qt;
877 if (FRAME_ICONIFIED_P (XFRAME (frame)))
878 return Qicon;
879 return Qnil;
882 DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list,
883 0, 0, 0,
884 "Return a list of all frames now \"visible\" (being updated).")
887 Lisp_Object tail, frame;
888 struct frame *f;
889 Lisp_Object value;
891 value = Qnil;
892 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
894 frame = XCONS (tail)->car;
895 if (XTYPE (frame) != Lisp_Frame)
896 continue;
897 f = XFRAME (frame);
898 if (FRAME_VISIBLE_P (f))
899 value = Fcons (frame, value);
901 return value;
905 DEFUN ("raise-frame", Fraise_frame, Sraise_frame, 1, 1, 0,
906 "Bring FRAME to the front, so it occludes any frames it overlaps.\n\
907 If FRAME is invisible, make it visible.\n\
908 If Emacs is displaying on an ordinary terminal or some other device which\n\
909 doesn't support multiple overlapping frames, this function does nothing.")
910 (frame)
911 Lisp_Object frame;
913 CHECK_LIVE_FRAME (frame, 0);
915 if (frame_raise_lower_hook)
916 (*frame_raise_lower_hook) (XFRAME (frame), 1);
918 return Qnil;
921 /* Should we have a corresponding function called Flower_Power? */
922 DEFUN ("lower-frame", Flower_frame, Slower_frame, 1, 1, 0,
923 "Send FRAME to the back, so it is occluded by any frames that overlap it.\n\
924 If Emacs is displaying on an ordinary terminal or some other device which\n\
925 doesn't support multiple overlapping frames, this function does nothing.")
926 (frame)
927 Lisp_Object frame;
929 CHECK_LIVE_FRAME (frame, 0);
931 if (frame_raise_lower_hook)
932 (*frame_raise_lower_hook) (XFRAME (frame), 0);
934 return Qnil;
938 DEFUN ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus,
939 1, 2, 0,
940 "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
941 In other words, switch-frame events caused by events in FRAME will\n\
942 request a switch to FOCUS-FRAME, and `last-event-frame' will be\n\
943 FOCUS-FRAME after reading an event typed at FRAME.\n\
945 If FOCUS-FRAME is omitted or nil, any existing redirection is\n\
946 cancelled, and the frame again receives its own keystrokes.\n\
948 Focus redirection is useful for temporarily redirecting keystrokes to\n\
949 a surrogate minibuffer frame when a frame doesn't have its own\n\
950 minibuffer window.\n\
952 A frame's focus redirection can be changed by select-frame. If frame\n\
953 FOO is selected, and then a different frame BAR is selected, any\n\
954 frames redirecting their focus to FOO are shifted to redirect their\n\
955 focus to BAR. This allows focus redirection to work properly when the\n\
956 user switches from one frame to another using `select-window'.\n\
958 This means that a frame whose focus is redirected to itself is treated\n\
959 differently from a frame whose focus is redirected to nil; the former\n\
960 is affected by select-frame, while the latter is not.\n\
962 The redirection lasts until `redirect-frame-focus' is called to change it.")
963 (frame, focus_frame)
964 Lisp_Object frame, focus_frame;
966 CHECK_LIVE_FRAME (frame, 0);
968 if (! NILP (focus_frame))
969 CHECK_LIVE_FRAME (focus_frame, 1);
971 XFRAME (frame)->focus_frame = focus_frame;
973 if (frame_rehighlight_hook)
974 (*frame_rehighlight_hook) ();
976 return Qnil;
980 DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0,
981 "Return the frame to which FRAME's keystrokes are currently being sent.\n\
982 This returns nil if FRAME's focus is not redirected.\n\
983 See `redirect-frame-focus'.")
984 (frame)
985 Lisp_Object frame;
987 CHECK_LIVE_FRAME (frame, 0);
989 return FRAME_FOCUS_FRAME (XFRAME (frame));
994 Lisp_Object
995 get_frame_param (frame, prop)
996 register struct frame *frame;
997 Lisp_Object prop;
999 register Lisp_Object tem;
1001 tem = Fassq (prop, frame->param_alist);
1002 if (EQ (tem, Qnil))
1003 return tem;
1004 return Fcdr (tem);
1007 void
1008 store_in_alist (alistptr, prop, val)
1009 Lisp_Object *alistptr, val;
1010 Lisp_Object prop;
1012 register Lisp_Object tem;
1014 tem = Fassq (prop, *alistptr);
1015 if (EQ (tem, Qnil))
1016 *alistptr = Fcons (Fcons (prop, val), *alistptr);
1017 else
1018 Fsetcdr (tem, val);
1021 void
1022 store_frame_param (f, prop, val)
1023 struct frame *f;
1024 Lisp_Object prop, val;
1026 register Lisp_Object tem;
1028 tem = Fassq (prop, f->param_alist);
1029 if (EQ (tem, Qnil))
1030 f->param_alist = Fcons (Fcons (prop, val), f->param_alist);
1031 else
1032 Fsetcdr (tem, val);
1034 if (EQ (prop, Qminibuffer)
1035 && XTYPE (val) == Lisp_Window)
1037 if (! MINI_WINDOW_P (XWINDOW (val)))
1038 error ("Surrogate minibuffer windows must be minibuffer windows.");
1040 if (FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f))
1041 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer.");
1043 /* Install the chosen minibuffer window, with proper buffer. */
1044 f->minibuffer_window = val;
1048 DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0,
1049 "Return the parameters-alist of frame FRAME.\n\
1050 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
1051 The meaningful PARMs depend on the kind of frame.\n\
1052 If FRAME is omitted, return information on the currently selected frame.")
1053 (frame)
1054 Lisp_Object frame;
1056 Lisp_Object alist;
1057 struct frame *f;
1059 if (EQ (frame, Qnil))
1060 f = selected_frame;
1061 else
1063 CHECK_FRAME (frame, 0);
1064 f = XFRAME (frame);
1067 if (f->display.nothing == 0)
1068 return Qnil;
1070 alist = Fcopy_alist (f->param_alist);
1071 store_in_alist (&alist, Qname, f->name);
1072 store_in_alist (&alist, Qheight, make_number (f->height));
1073 store_in_alist (&alist, Qwidth, make_number (f->width));
1074 store_in_alist (&alist, Qmodeline, (f->wants_modeline ? Qt : Qnil));
1075 store_in_alist (&alist, Qminibuffer,
1076 (! FRAME_HAS_MINIBUF_P (f) ? Qnil
1077 : (FRAME_MINIBUF_ONLY_P (f) ? Qonly
1078 : FRAME_MINIBUF_WINDOW (f))));
1079 store_in_alist (&alist, Qunsplittable, (f->no_split ? Qt : Qnil));
1080 store_in_alist (&alist, Qmenu_bar_lines, (FRAME_MENU_BAR_LINES (f)));
1082 /* I think this should be done with a hook. */
1083 #ifdef HAVE_X_WINDOWS
1084 if (FRAME_X_P (f))
1085 x_report_frame_params (f, &alist);
1086 #endif
1087 return alist;
1090 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters,
1091 Smodify_frame_parameters, 2, 2, 0,
1092 "Modify the parameters of frame FRAME according to ALIST.\n\
1093 ALIST is an alist of parameters to change and their new values.\n\
1094 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
1095 The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
1096 (frame, alist)
1097 Lisp_Object frame, alist;
1099 FRAME_PTR f;
1100 register Lisp_Object tail, elt, prop, val;
1102 if (EQ (frame, Qnil))
1103 f = selected_frame;
1104 else
1106 CHECK_LIVE_FRAME (frame, 0);
1107 f = XFRAME (frame);
1110 /* I think this should be done with a hook. */
1111 #ifdef HAVE_X_WINDOWS
1112 if (FRAME_X_P (f))
1113 #if 1
1114 x_set_frame_parameters (f, alist);
1115 #else
1116 for (tail = alist; !EQ (tail, Qnil); tail = Fcdr (tail))
1118 elt = Fcar (tail);
1119 prop = Fcar (elt);
1120 val = Fcdr (elt);
1121 x_set_frame_param (f, prop, val, get_frame_param (f, prop));
1122 store_frame_param (f, prop, val);
1124 #endif
1125 #endif
1127 return Qnil;
1130 DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
1131 0, 1, 0,
1132 "Height in pixels of a line in the font in frame FRAME.\n\
1133 If FRAME is omitted, the selected frame is used.\n\
1134 For a terminal frame, the value is always 1.")
1135 (frame)
1136 Lisp_Object frame;
1138 struct frame *f;
1140 if (NILP (frame))
1141 f = selected_frame;
1142 else
1144 CHECK_FRAME (frame, 0);
1145 f = XFRAME (frame);
1148 #ifdef HAVE_X_WINDOWS
1149 if (FRAME_X_P (f))
1150 return make_number (x_char_height (f));
1151 else
1152 #endif
1153 return make_number (1);
1157 DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
1158 0, 1, 0,
1159 "Width in pixels of characters in the font in frame FRAME.\n\
1160 If FRAME is omitted, the selected frame is used.\n\
1161 The width is the same for all characters, because\n\
1162 currently Emacs supports only fixed-width fonts.\n\
1163 For a terminal screen, the value is always 1.")
1164 (frame)
1165 Lisp_Object frame;
1167 struct frame *f;
1169 if (NILP (frame))
1170 f = selected_frame;
1171 else
1173 CHECK_FRAME (frame, 0);
1174 f = XFRAME (frame);
1177 #ifdef HAVE_X_WINDOWS
1178 if (FRAME_X_P (f))
1179 return make_number (x_char_width (f));
1180 else
1181 #endif
1182 return make_number (1);
1185 DEFUN ("frame-pixel-height", Fframe_pixel_height,
1186 Sframe_pixel_height, 0, 1, 0,
1187 "Return a FRAME's heightin pixels.\n\
1188 For a terminal frame, the result really gives the sizes in characters.\n\
1189 If FRAME is omitted, the selected frame is used.")
1190 (frame)
1191 Lisp_Object frame;
1193 struct frame *f;
1195 if (NILP (frame))
1196 f = selected_frame;
1197 else
1199 CHECK_FRAME (frame, 0);
1200 f = XFRAME (frame);
1203 #ifdef HAVE_X_WINDOWS
1204 if (FRAME_X_P (f))
1205 return make_number (x_pixel_height (f));
1206 else
1207 #endif
1208 return make_number (FRAME_HEIGHT (f));
1211 DEFUN ("frame-pixel-width", Fframe_pixel_width,
1212 Sframe_pixel_width, 0, 1, 0,
1213 "Return FRAME's width in pixels.\n\
1214 For a terminal frame, the result really gives the sizes in characters.\n\
1215 If FRAME is omitted, the selected frame is used.")
1216 (frame)
1217 Lisp_Object frame;
1219 struct frame *f;
1221 if (NILP (frame))
1222 f = selected_frame;
1223 else
1225 CHECK_FRAME (frame, 0);
1226 f = XFRAME (frame);
1229 #ifdef HAVE_X_WINDOWS
1230 if (FRAME_X_P (f))
1231 return make_number (x_pixel_width (f));
1232 else
1233 #endif
1234 return make_number (FRAME_WIDTH (f));
1237 DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
1238 "Specify that the frame FRAME has LINES lines.\n\
1239 Optional third arg non-nil means that redisplay should use LINES lines\n\
1240 but that the idea of the actual height of the frame should not be changed.")
1241 (frame, rows, pretend)
1242 Lisp_Object frame, rows, pretend;
1244 register struct frame *f;
1246 CHECK_NUMBER (rows, 0);
1247 if (NILP (frame))
1248 f = selected_frame;
1249 else
1251 CHECK_LIVE_FRAME (frame, 0);
1252 f = XFRAME (frame);
1255 /* I think this should be done with a hook. */
1256 #ifdef HAVE_X_WINDOWS
1257 if (FRAME_X_P (f))
1259 if (XINT (rows) != f->width)
1260 x_set_window_size (f, f->width, XINT (rows));
1262 else
1263 #endif
1264 change_frame_size (f, XINT (rows), 0, !NILP (pretend), 0);
1265 return Qnil;
1268 DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 3, 0,
1269 "Specify that the frame FRAME has COLS columns.\n\
1270 Optional third arg non-nil means that redisplay should use COLS columns\n\
1271 but that the idea of the actual width of the frame should not be changed.")
1272 (frame, cols, pretend)
1273 Lisp_Object frame, cols, pretend;
1275 register struct frame *f;
1276 CHECK_NUMBER (cols, 0);
1277 if (NILP (frame))
1278 f = selected_frame;
1279 else
1281 CHECK_LIVE_FRAME (frame, 0);
1282 f = XFRAME (frame);
1285 /* I think this should be done with a hook. */
1286 #ifdef HAVE_X_WINDOWS
1287 if (FRAME_X_P (f))
1289 if (XINT (cols) != f->width)
1290 x_set_window_size (f, XINT (cols), f->height);
1292 else
1293 #endif
1294 change_frame_size (f, 0, XINT (cols), !NILP (pretend), 0);
1295 return Qnil;
1298 DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0,
1299 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1300 (frame, cols, rows)
1301 Lisp_Object frame, cols, rows;
1303 register struct frame *f;
1304 int mask;
1306 CHECK_LIVE_FRAME (frame, 0);
1307 CHECK_NUMBER (cols, 2);
1308 CHECK_NUMBER (rows, 1);
1309 f = XFRAME (frame);
1311 /* I think this should be done with a hook. */
1312 #ifdef HAVE_X_WINDOWS
1313 if (FRAME_X_P (f))
1315 if (XINT (rows) != f->height || XINT (cols) != f->width)
1316 x_set_window_size (f, XINT (cols), XINT (rows));
1318 else
1319 #endif
1320 change_frame_size (f, XINT (rows), XINT (cols), 0, 0);
1322 return Qnil;
1325 DEFUN ("set-frame-position", Fset_frame_position,
1326 Sset_frame_position, 3, 3, 0,
1327 "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
1328 If XOFFSET or YOFFSET are negative, they are interpreted relative to\n\
1329 the leftmost or bottommost position FRAME could occupy without going\n\
1330 off the screen.")
1331 (frame, xoffset, yoffset)
1332 Lisp_Object frame, xoffset, yoffset;
1334 register struct frame *f;
1335 int mask;
1337 CHECK_LIVE_FRAME (frame, 0);
1338 CHECK_NUMBER (xoffset, 1);
1339 CHECK_NUMBER (yoffset, 2);
1340 f = XFRAME (frame);
1342 /* I think this should be done with a hook. */
1343 #ifdef HAVE_X_WINDOWS
1344 if (FRAME_X_P (f))
1345 x_set_offset (f, XINT (xoffset), XINT (yoffset));
1346 #endif
1348 return Qt;
1352 #ifndef HAVE_X11
1353 DEFUN ("rubber-band-rectangle", Frubber_band_rectangle, Srubber_band_rectangle,
1354 3, 3, "",
1355 "Ask user to specify a window position and size on FRAME with the mouse.\n\
1356 Arguments are FRAME, NAME and GEO. NAME is a name to be displayed as\n\
1357 the purpose of this rectangle. GEO is an X-windows size spec that can\n\
1358 specify defaults for some sizes/positions. If GEO specifies everything,\n\
1359 the mouse is not used.\n\
1360 Returns a list of five values: (FRAME LEFT TOP WIDTH HEIGHT).")
1361 (frame, name, geo)
1362 Lisp_Object frame;
1363 Lisp_Object name;
1364 Lisp_Object geo;
1366 int vals[4];
1367 Lisp_Object nums[4];
1368 int i;
1370 CHECK_FRAME (frame, 0);
1371 CHECK_STRING (name, 1);
1372 CHECK_STRING (geo, 2);
1374 switch (XFRAME (frame)->output_method)
1376 case output_x_window:
1377 x_rubber_band (XFRAME (frame), &vals[0], &vals[1], &vals[2], &vals[3],
1378 XSTRING (geo)->data, XSTRING (name)->data);
1379 break;
1381 default:
1382 return Qnil;
1385 for (i = 0; i < 4; i++)
1386 XFASTINT (nums[i]) = vals[i];
1387 return Fcons (frame, Flist (4, nums));
1388 return Qnil;
1390 #endif /* not HAVE_X11 */
1392 choose_minibuf_frame ()
1394 /* For lowest-level minibuf, put it on currently selected frame
1395 if frame has a minibuffer. */
1397 if (minibuf_level == 0
1398 && selected_frame != 0
1399 && !EQ (minibuf_window, selected_frame->minibuffer_window))
1401 /* I don't think that any frames may validly have a null minibuffer
1402 window anymore. */
1403 if (NILP (selected_frame->minibuffer_window))
1404 abort ();
1406 Fset_window_buffer (selected_frame->minibuffer_window,
1407 XWINDOW (minibuf_window)->buffer);
1408 minibuf_window = selected_frame->minibuffer_window;
1412 syms_of_frame ()
1414 /*&&& init symbols here &&&*/
1415 Qframep = intern ("framep");
1416 staticpro (&Qframep);
1417 Qframe_live_p = intern ("frame-live-p");
1418 staticpro (&Qframe_live_p);
1419 Qheight = intern ("height");
1420 staticpro (&Qheight);
1421 Qicon = intern ("icon");
1422 staticpro (&Qicon);
1423 Qminibuffer = intern ("minibuffer");
1424 staticpro (&Qminibuffer);
1425 Qmodeline = intern ("modeline");
1426 staticpro (&Qmodeline);
1427 Qname = intern ("name");
1428 staticpro (&Qname);
1429 Qonly = intern ("only");
1430 staticpro (&Qonly);
1431 Qunsplittable = intern ("unsplittable");
1432 staticpro (&Qunsplittable);
1433 Qwidth = intern ("width");
1434 staticpro (&Qwidth);
1435 Qx = intern ("x");
1436 staticpro (&Qx);
1437 Qmenu_bar_lines = intern ("menu-bar-lines");
1438 staticpro (&Qmenu_bar_lines);
1440 staticpro (&Vframe_list);
1442 DEFVAR_LISP ("terminal-frame", &Vterminal_frame,
1443 "The initial frame-object, which represents Emacs's stdout.");
1445 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified,
1446 "Non-nil if all of emacs is iconified and frame updates are not needed.");
1447 Vemacs_iconified = Qnil;
1449 DEFVAR_LISP ("default-minibuffer-frame", &Vdefault_minibuffer_frame,
1450 "Minibufferless frames use this frame's minibuffer.\n\
1452 Emacs cannot create minibufferless frames unless this is set to an\n\
1453 appropriate surrogate.\n\
1455 Emacs consults this variable only when creating minibufferless\n\
1456 frames; once the frame is created, it sticks with its assigned\n\
1457 minibuffer, no matter what this variable is set to. This means that\n\
1458 this variable doesn't necessarily say anything meaningful about the\n\
1459 current set of frames, or where the minibuffer is currently being\n\
1460 displayed.");
1461 Vdefault_minibuffer_frame = Qnil;
1463 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
1464 "Alist of default values for frame creation.\n\
1465 These may be set in your init file, like this:\n\
1466 (setq default-frame-alist '((width . 80) (height . 55)))\n\
1467 These override values given in window system configuration data, like\n\
1468 X Windows' defaults database.\n\
1469 For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
1470 For values specific to the separate minibuffer frame, see\n\
1471 `minibuffer-frame-alist'.");
1472 Vdefault_frame_alist = Qnil;
1474 defsubr (&Sframep);
1475 defsubr (&Sframe_live_p);
1476 defsubr (&Shandle_switch_frame);
1477 defsubr (&Sselect_frame);
1478 defsubr (&Sselected_frame);
1479 defsubr (&Swindow_frame);
1480 defsubr (&Sframe_root_window);
1481 defsubr (&Sframe_selected_window);
1482 defsubr (&Sframe_list);
1483 defsubr (&Snext_frame);
1484 defsubr (&Sdelete_frame);
1485 defsubr (&Smouse_position);
1486 defsubr (&Sset_mouse_position);
1487 #if 0
1488 defsubr (&Sframe_configuration);
1489 defsubr (&Srestore_frame_configuration);
1490 #endif
1491 defsubr (&Smake_frame_visible);
1492 defsubr (&Smake_frame_invisible);
1493 defsubr (&Siconify_frame);
1494 defsubr (&Sframe_visible_p);
1495 defsubr (&Svisible_frame_list);
1496 defsubr (&Sraise_frame);
1497 defsubr (&Slower_frame);
1498 defsubr (&Sredirect_frame_focus);
1499 defsubr (&Sframe_focus);
1500 defsubr (&Sframe_parameters);
1501 defsubr (&Smodify_frame_parameters);
1502 defsubr (&Sframe_char_height);
1503 defsubr (&Sframe_char_width);
1504 defsubr (&Sframe_pixel_height);
1505 defsubr (&Sframe_pixel_width);
1506 defsubr (&Sset_frame_height);
1507 defsubr (&Sset_frame_width);
1508 defsubr (&Sset_frame_size);
1509 defsubr (&Sset_frame_position);
1510 #ifndef HAVE_X11
1511 defsubr (&Srubber_band_rectangle);
1512 #endif /* HAVE_X11 */
1515 keys_of_frame ()
1517 initial_define_lispy_key (global_map, "switch-frame", "handle-switch-frame");
1520 #else /* not MULTI_FRAME */
1522 /* If we're not using multi-frame stuff, we still need to provide some
1523 support functions. */
1525 /* Unless this function is defined, providing set-frame-height and
1526 set-frame-width doesn't help compatibility any, since they both
1527 want this as their first argument. */
1528 DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
1529 "Return the frame that is now selected.")
1532 Lisp_Object tem;
1533 XFASTINT (tem) = 0;
1534 return tem;
1537 DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
1538 "Specify that the frame FRAME has LINES lines.\n\
1539 Optional third arg non-nil means that redisplay should use LINES lines\n\
1540 but that the idea of the actual height of the frame should not be changed.")
1541 (frame, rows, pretend)
1542 Lisp_Object frame, rows, pretend;
1544 CHECK_NUMBER (rows, 0);
1546 change_frame_size (0, XINT (rows), 0, !NILP (pretend), 0);
1547 return Qnil;
1550 DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 3, 0,
1551 "Specify that the frame FRAME has COLS columns.\n\
1552 Optional third arg non-nil means that redisplay should use COLS columns\n\
1553 but that the idea of the actual width of the frame should not be changed.")
1554 (frame, cols, pretend)
1555 Lisp_Object frame, cols, pretend;
1557 CHECK_NUMBER (cols, 0);
1559 change_frame_size (0, 0, XINT (cols), !NILP (pretend), 0);
1560 return Qnil;
1563 DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0,
1564 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1565 (frame, cols, rows)
1566 Lisp_Object frame, cols, rows;
1568 CHECK_NUMBER (cols, 2);
1569 CHECK_NUMBER (rows, 1);
1571 change_frame_size (0, XINT (rows), XINT (cols), 0, 0);
1573 return Qnil;
1576 DEFUN ("frame-height", Fframe_height, Sframe_height, 0, 1, 0,
1577 "Return number of lines available for display on FRAME.\n\
1578 If FRAME is omitted, describe the currently selected frame.")
1579 (frame)
1580 Lisp_Object frame;
1582 return make_number (FRAME_HEIGHT (selected_frame));
1585 DEFUN ("frame-width", Fframe_width, Sframe_width, 0, 1, 0,
1586 "Return number of columns available for display on FRAME.\n\
1587 If FRAME is omitted, describe the currently selected frame.")
1588 (frame)
1589 Lisp_Object frame;
1591 return make_number (FRAME_WIDTH (selected_frame));
1594 DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
1595 0, 1, 0,
1596 "Height in pixels of a line in the font in frame FRAME.\n\
1597 If FRAME is omitted, the selected frame is used.\n\
1598 For a terminal frame, the value is always 1.")
1599 (frame)
1600 Lisp_Object frame;
1602 return make_number (1);
1606 DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
1607 0, 1, 0,
1608 "Width in pixels of characters in the font in frame FRAME.\n\
1609 If FRAME is omitted, the selected frame is used.\n\
1610 The width is the same for all characters, because\n\
1611 currently Emacs supports only fixed-width fonts.\n\
1612 For a terminal screen, the value is always 1.")
1613 (frame)
1614 Lisp_Object frame;
1616 return make_number (1);
1619 DEFUN ("frame-pixel-height", Fframe_pixel_height,
1620 Sframe_pixel_height, 0, 1, 0,
1621 "Return FRAME's height in pixels.\n\
1622 For a terminal frame, the result really gives the height in characters.\n\
1623 If FRAME is omitted, the selected frame is used.")
1624 (frame)
1625 Lisp_Object frame;
1627 return make_number (FRAME_HEIGHT (f));
1630 DEFUN ("frame-pixel-width", Fframe_pixel_width,
1631 Sframe_pixel_width, 0, 1, 0,
1632 "Return FRAME's width in pixels.\n\
1633 For a terminal frame, the result really gives the width in characters.\n\
1634 If FRAME is omitted, the selected frame is used.")
1635 (frame)
1636 Lisp_Object frame;
1638 return make_number (FRAME_WIDTH (f));
1641 /* These are for backward compatibility with Emacs 18. */
1643 DEFUN ("set-screen-height", Fset_screen_height, Sset_screen_height, 1, 2, 0,
1644 "Tell redisplay that the screen has LINES lines.\n\
1645 Optional second arg non-nil means that redisplay should use LINES lines\n\
1646 but that the idea of the actual height of the screen should not be changed.")
1647 (lines, pretend)
1648 Lisp_Object lines, pretend;
1650 CHECK_NUMBER (lines, 0);
1652 change_frame_size (0, XINT (lines), 0, !NILP (pretend), 0);
1653 return Qnil;
1656 DEFUN ("set-screen-width", Fset_screen_width, Sset_screen_width, 1, 2, 0,
1657 "Tell redisplay that the screen has COLS columns.\n\
1658 Optional second arg non-nil means that redisplay should use COLS columns\n\
1659 but that the idea of the actual width of the screen should not be changed.")
1660 (cols, pretend)
1661 Lisp_Object cols, pretend;
1663 CHECK_NUMBER (cols, 0);
1665 change_frame_size (0, 0, XINT (cols), !NILP (pretend), 0);
1666 return Qnil;
1669 syms_of_frame ()
1671 defsubr (&Sselected_frame);
1672 defsubr (&Sframe_char_height);
1673 defsubr (&Sframe_char_width);
1674 defsubr (&Sframe_pixel_height);
1675 defsubr (&Sframe_pixel_width);
1676 defsubr (&Sset_frame_height);
1677 defsubr (&Sset_frame_width);
1678 defsubr (&Sset_frame_size);
1679 defsubr (&Sset_screen_height);
1680 defsubr (&Sset_screen_width);
1681 defsubr (&Sframe_height);
1682 Ffset (intern ("screen-height"), intern ("frame-height"));
1683 defsubr (&Sframe_width);
1684 Ffset (intern ("screen-width"), intern ("frame-width"));
1687 keys_of_frame ()
1691 #endif /* not MULTI_FRAME */