1 /* Generic frame functions.
2 Copyright (C) 1989, 1992 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)
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. */
30 #include "termhooks.h"
32 /* These help us bind and responding to switch-frame events. */
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.
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")
53 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
55 (cons (buffer-substring (match-beginning 1) (match-end 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")
64 (kill-region start (point)))
65 ;; Write a new symbol initialization section.
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)))))
75 /*&&& symbols declared here &&&*/
77 Lisp_Object Qlive_frame_p
;
80 Lisp_Object Qminibuffer
;
81 Lisp_Object Qmodeline
;
85 Lisp_Object Qunsplittable
;
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'.")
100 if (XTYPE (object
) != Lisp_Frame
)
102 switch (XFRAME (object
)->output_method
)
106 case output_x_window
:
113 DEFUN ("live-frame-p", Flive_frame_p
, Slive_frame_p
, 1, 1, 0,
114 "Return non-nil if OBJECT is a frame which has not been deleted.\n\
115 Value is nil if OBJECT is not a live frame. If object is a live\n\
116 frame, the return value indicates what sort of output device it is\n\
117 displayed on. Value is t for a termcap frame (a character-only\n\
118 terminal), `x' for an Emacs frame being displayed in an X window.")
122 return ((FRAMEP (object
)
123 && FRAME_LIVE_P (XFRAME (object
)))
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
)),
141 XSETTYPE (frame
, Lisp_Frame
);
146 f
->current_glyphs
= 0;
147 f
->desired_glyphs
= 0;
149 f
->async_visible
= 0;
150 f
->display
.nothing
= 0;
152 f
->async_iconified
= 0;
153 f
->wants_modeline
= 1;
158 f
->has_minibuffer
= mini_p
;
159 f
->focus_frame
= Qnil
;
160 f
->explicit_name
= 0;
161 f
->can_have_scrollbars
= 0;
162 f
->has_vertical_scrollbars
= 0;
164 f
->param_alist
= Qnil
;
166 root_window
= make_window ();
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
;
179 XWINDOW (root_window
)->next
= Qnil
;
180 f
->minibuffer_window
= Qnil
;
183 XWINDOW (root_window
)->frame
= frame
;
186 just so that there is "something there."
187 Correct size will be set up later with change_frame_size. */
192 XFASTINT (XWINDOW (root_window
)->width
) = 10;
193 XFASTINT (XWINDOW (root_window
)->height
) = (mini_p
? 9 : 10);
197 XFASTINT (XWINDOW (mini_window
)->width
) = 10;
198 XFASTINT (XWINDOW (mini_window
)->top
) = 9;
199 XFASTINT (XWINDOW (mini_window
)->height
) = 1;
202 /* Choose a buffer for the frame's root window. */
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
);
217 XWINDOW (mini_window
)->buffer
= Qt
;
218 Fset_window_buffer (mini_window
,
219 (NILP (Vminibuffer_list
)
221 : Fcar (Vminibuffer_list
)));
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
;
230 Vframe_list
= Fcons (frame
, Vframe_list
);
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). */
240 make_frame_without_minibuffer (mini_window
)
241 register Lisp_Object mini_window
;
243 register struct frame
*f
;
245 /* Choose the minibuffer window to use. */
246 if (NILP (mini_window
))
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
;
256 CHECK_LIVE_WINDOW (mini_window
, 0);
259 /* Make a frame containing just a root window. */
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
)
267 : Fcar (Vminibuffer_list
)));
271 /* Make a frame containing only a minibuffer window. */
274 make_minibuffer_frame ()
276 /* First make a frame containing just a root window, no minibuffer. */
278 register struct frame
*f
= make_frame (0);
279 register Lisp_Object mini_window
;
280 register Lisp_Object frame
;
282 XSET (frame
, Lisp_Frame
, f
);
287 f
->wants_modeline
= 0;
288 f
->has_minibuffer
= 1;
290 /* Now label the root window as also being the minibuffer.
291 Avoid infinite looping on the window chain by marking next pointer
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
;
300 /* Put the proper buffer in that window. */
302 Fset_window_buffer (mini_window
,
303 (NILP (Vminibuffer_list
)
305 : Fcar (Vminibuffer_list
)));
309 /* Construct a frame that refers to the terminal (stdin and stdout). */
312 make_terminal_frame ()
314 register struct frame
*f
;
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
);
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\
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\
335 Changing the selected frame can change focus redirections. See\n\
336 `redirect-frame-focus' for details.")
338 Lisp_Object frame
, no_enter
;
340 /* If FRAME is a switch-frame event, extract the frame we should
343 && EQ (XCONS (frame
)->car
, Qswitch_frame
)
344 && CONSP (XCONS (frame
)->cdr
))
345 frame
= XCONS (XCONS (frame
)->cdr
)->car
;
347 CHECK_LIVE_FRAME (frame
, 0);
349 if (selected_frame
== XFRAME (frame
))
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
362 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
366 if (XTYPE (XCONS (tail
)->car
) != Lisp_Frame
)
369 focus
= FRAME_FOCUS_FRAME (XFRAME (XCONS (tail
)->car
));
371 if (XTYPE (focus
) == Lisp_Frame
372 && XFRAME (focus
) == selected_frame
)
373 Fredirect_frame_focus (XCONS (tail
)->car
, frame
);
377 selected_frame
= XFRAME (frame
);
378 if (! FRAME_MINIBUF_ONLY_P (selected_frame
))
379 last_nonminibuf_frame
= selected_frame
;
381 Fselect_window (XFRAME (frame
)->selected_window
);
383 #ifdef HAVE_X_WINDOWS
385 if (FRAME_X_P (XFRAME (frame
))
388 Ffocus_frame (frame
);
392 choose_minibuf_frame ();
397 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
398 "Return the frame that is now selected.")
402 XSET (tem
, Lisp_Frame
, selected_frame
);
406 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
407 "Return the frame object that window WINDOW is on.")
411 CHECK_LIVE_WINDOW (window
, 0);
412 return XWINDOW (window
)->frame
;
415 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
416 "Returns the root-window of FRAME.\n\
417 If omitted, FRAME defaults to the currently selected frame.")
422 XSET (frame
, Lisp_Frame
, selected_frame
);
424 CHECK_LIVE_FRAME (frame
, 0);
426 return XFRAME (frame
)->root_window
;
429 DEFUN ("frame-selected-window", Fframe_selected_window
,
430 Sframe_selected_window
, 0, 1, 0,
431 "Return the selected window of frame object FRAME.\n\
432 If omitted, FRAME defaults to the currently selected frame.")
437 XSET (frame
, Lisp_Frame
, selected_frame
);
439 CHECK_LIVE_FRAME (frame
, 0);
441 return XFRAME (frame
)->selected_window
;
444 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
446 "Return a list of all frames.")
449 return Fcopy_sequence (Vframe_list
);
454 /* Return the next frame in the frame list after FRAME.
455 If MINIBUF is nil, exclude minibuffer-only frames.
456 If MINIBUF is a window, include only frames using that window for
458 If MINIBUF is non-nil, and not a window, include all frames. */
460 next_frame (frame
, minibuf
)
467 /* There must always be at least one frame in Vframe_list. */
468 if (! CONSP (Vframe_list
))
472 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
474 Lisp_Object f
= XCONS (tail
)->car
;
478 /* Decide whether this frame is eligible to be returned. */
480 /* If we've looped all the way around without finding any
481 eligible frames, return the original frame. */
485 /* Let minibuf decide if this frame is acceptable. */
488 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
491 else if (XTYPE (minibuf
) == Lisp_Window
)
493 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
))
506 /* Nobody seems to be using this code right now. */
508 /* Return the previous frame in the frame list before FRAME.
509 If MINIBUF is nil, exclude minibuffer-only frames.
510 If MINIBUF is a window, include only frames using that window for
512 If MINIBUF is non-nil and not a window, include all frames. */
514 prev_frame (frame
, minibuf
)
521 /* There must always be at least one frame in Vframe_list. */
522 if (! CONSP (Vframe_list
))
526 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
528 Lisp_Object f
= XCONS (tail
)->car
;
530 if (XTYPE (f
) != Lisp_Frame
)
533 if (EQ (frame
, f
) && !NILP (prev
))
536 /* Decide whether this frame is eligible to be returned,
537 according to minibuf. */
540 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
543 else if (XTYPE (minibuf
) == Lisp_Window
)
545 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
))
552 /* We've scanned the entire list. */
554 /* We went through the whole frame list without finding a single
555 acceptable frame. Return the original frame. */
558 /* There were no acceptable frames in the list before FRAME; otherwise,
559 we would have returned directly from the loop. Since PREV is the last
560 acceptable frame in the list, return it. */
565 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
566 "Return the next frame in the frame list after FRAME.\n\
567 By default, skip minibuffer-only frames.\n\
568 If omitted, FRAME defaults to the selected frame.\n\
569 If optional argument MINIFRAME is non-nil, include minibuffer-only frames.\n\
570 If MINIFRAME is a window, include only frames using that window for their\n\
572 If MINIFRAME is non-nil and not a window, include all frames.")
574 Lisp_Object frame
, miniframe
;
579 XSET (frame
, Lisp_Frame
, selected_frame
);
581 CHECK_LIVE_FRAME (frame
, 0);
583 return next_frame (frame
, miniframe
);
585 #endif /* MULTI_FRAME */
587 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 1, "",
588 "Delete FRAME, permanently eliminating it from use.\n\
589 If omitted, FRAME defaults to the selected frame.\n\
590 A frame may not be deleted if its minibuffer is used by other frames.")
597 if (EQ (frame
, Qnil
))
600 XSET (frame
, Lisp_Frame
, f
);
604 CHECK_FRAME (frame
, 0);
608 if (! FRAME_LIVE_P (f
))
611 /* Are there any other frames besides this one? */
612 if (f
== selected_frame
&& EQ (next_frame (frame
, Qt
), frame
))
613 error ("Attempt to delete the only frame");
615 /* Does this frame have a minibuffer, and is it the surrogate
616 minibuffer for any other frame? */
617 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
621 for (frames
= Vframe_list
;
623 frames
= XCONS (frames
)->cdr
)
625 Lisp_Object
this = XCONS (frames
)->car
;
627 if (! EQ (this, frame
)
631 (FRAME_MINIBUF_WINDOW
633 error ("Attempt to delete a surrogate minibuffer frame");
637 /* Don't let the frame remain selected. */
638 if (f
== selected_frame
)
639 Fselect_frame (next_frame (frame
, Qt
), Qnil
);
641 /* Don't allow minibuf_window to remain on a deleted frame. */
642 if (EQ (f
->minibuffer_window
, minibuf_window
))
644 Fset_window_buffer (selected_frame
->minibuffer_window
,
645 XWINDOW (minibuf_window
)->buffer
);
646 minibuf_window
= selected_frame
->minibuffer_window
;
649 /* Mark all the windows that used to be on FRAME as deleted, and then
650 remove the reference to them. */
651 delete_all_subwindows (XWINDOW (f
->root_window
));
652 f
->root_window
= Qnil
;
654 Vframe_list
= Fdelq (frame
, Vframe_list
);
655 FRAME_SET_VISIBLE (f
, 0);
657 f
->display
.nothing
= 0;
659 #ifdef HAVE_X_WINDOWS
661 x_destroy_window (f
, displ
);
664 /* If we've deleted the last_nonminibuf_frame, then try to find
666 if (f
== last_nonminibuf_frame
)
670 last_nonminibuf_frame
= 0;
672 for (frames
= Vframe_list
;
674 frames
= XCONS (frames
)->cdr
)
676 f
= XFRAME (XCONS (frames
)->car
);
677 if (!FRAME_MINIBUF_ONLY_P (f
))
679 last_nonminibuf_frame
= f
;
685 /* If we've deleted Vdefault_minibuffer_frame, try to find another
686 one. Prefer minibuffer-only frames, but also notice frames
687 with other windows. */
688 if (EQ (frame
, Vdefault_minibuffer_frame
))
692 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
693 Lisp_Object frame_with_minibuf
= Qnil
;
695 for (frames
= Vframe_list
;
697 frames
= XCONS (frames
)->cdr
)
699 Lisp_Object
this = XCONS (frames
)->car
;
701 if (XTYPE (this) != Lisp_Frame
)
705 if (FRAME_HAS_MINIBUF_P (f
))
707 frame_with_minibuf
= this;
708 if (FRAME_MINIBUF_ONLY_P (f
))
713 /* We know that there must be some frame with a minibuffer out
714 there. If this were not true, all of the frames present
715 would have to be minibufferless, which implies that at some
716 point their minibuffer frames must have been deleted, but
717 that is prohibited at the top; you can't delete surrogate
718 minibuffer frames. */
719 if (NILP (frame_with_minibuf
))
722 Vdefault_minibuffer_frame
= frame_with_minibuf
;
728 /* Return mouse position in character cell units. */
730 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
731 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
732 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
733 to read the mouse position, it returns the selected frame for FRAME\n\
734 and nil for X and Y.")
737 Lisp_Object x
, y
, dummy
;
740 if (mouse_position_hook
)
741 (*mouse_position_hook
) (&f
, &x
, &y
, &dummy
);
748 XSET (dummy
, Lisp_Frame
, f
);
749 return Fcons (dummy
, Fcons (make_number (x
), make_number (y
)));
752 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
753 "Move the mouse pointer to the center of cell (X,Y) in FRAME.\n\
754 WARNING: If you use this under X, you should do `unfocus-frame' afterwards.")
756 Lisp_Object frame
, x
, y
;
758 CHECK_LIVE_FRAME (frame
, 0);
762 #ifdef HAVE_X_WINDOWS
763 if (FRAME_X_P (XFRAME (frame
)))
764 /* Warping the mouse will cause enternotify and focus events. */
765 x_set_mouse_position (XFRAME (frame
), x
, y
);
772 /* ??? Can this be replaced with a Lisp function?
773 It is used in minibuf.c. Can we get rid of that?
774 Yes. All uses in minibuf.c are gone, and parallels to these
775 functions have been defined in frame.el. */
777 DEFUN ("frame-configuration", Fframe_configuration
, Sframe_configuration
,
779 "Return object describing current frame configuration.\n\
780 The frame configuration is the current mouse position and selected frame.\n\
781 This object can be given to `restore-frame-configuration'\n\
782 to restore this frame configuration.")
787 c
= Fmake_vector (make_number(4), Qnil
);
788 XVECTOR (c
)->contents
[0] = Fselected_frame();
789 if (mouse_position_hook
)
790 (*mouse_position_hook
) (&XVECTOR (c
)->contents
[1]
791 &XVECTOR (c
)->contents
[2],
792 &XVECTOR (c
)->contents
[3],
797 DEFUN ("restore-frame-configuration", Frestore_frame_configuration
,
798 Srestore_frame_configuration
,
800 "Restores frame configuration CONFIGURATION.")
804 Lisp_Object x_pos
, y_pos
, frame
;
806 CHECK_VECTOR (config
, 0);
807 if (XVECTOR (config
)->size
!= 3)
809 error ("Wrong size vector passed to restore-frame-configuration");
811 frame
= XVECTOR (config
)->contents
[0];
812 CHECK_LIVE_FRAME (frame
, 0);
814 Fselect_frame (frame
, Qnil
);
817 /* This seems to interfere with the frame selection mechanism. jla */
818 x_pos
= XVECTOR (config
)->contents
[2];
819 y_pos
= XVECTOR (config
)->contents
[3];
820 set_mouse_position (frame
, XINT (x_pos
), XINT (y_pos
));
827 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
829 "Make the frame FRAME visible (assuming it is an X-window).\n\
830 Also raises the frame so that nothing obscures it.\n\
831 If omitted, FRAME defaults to the currently selected frame.")
836 XSET (frame
, Lisp_Frame
, selected_frame
);
838 CHECK_LIVE_FRAME (frame
, 0);
840 #ifdef HAVE_X_WINDOWS
841 if (FRAME_X_P (XFRAME (frame
)))
842 x_make_frame_visible (XFRAME (frame
));
848 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
850 "Make the frame FRAME invisible (assuming it is an X-window).\n\
851 If omitted, FRAME defaults to the currently selected frame.")
856 XSET (frame
, Lisp_Frame
, selected_frame
);
858 CHECK_LIVE_FRAME (frame
, 0);
860 #ifdef HAVE_X_WINDOWS
861 if (FRAME_X_P (XFRAME (frame
)))
862 x_make_frame_invisible (XFRAME (frame
));
868 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
870 "Make the frame FRAME into an icon.\n\
871 If omitted, FRAME defaults to the currently selected frame.")
876 XSET (frame
, Lisp_Frame
, selected_frame
);
878 CHECK_LIVE_FRAME (frame
, 0);
880 #ifdef HAVE_X_WINDOWS
881 if (FRAME_X_P (XFRAME (frame
)))
882 x_iconify_frame (XFRAME (frame
));
888 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
890 "Return t if FRAME is now \"visible\" (actually in use for display).\n\
891 A frame that is not \"visible\" is not updated and, if it works through\n\
892 a window system, it may not show at all.\n\
893 Return the symbol `icon' if frame is visible only as an icon.")
897 CHECK_LIVE_FRAME (frame
, 0);
899 if (FRAME_VISIBLE_P (XFRAME (frame
)))
901 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
906 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
908 "Return a list of all frames now \"visible\" (being updated).")
911 Lisp_Object tail
, frame
;
916 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
918 frame
= XCONS (tail
)->car
;
919 if (XTYPE (frame
) != Lisp_Frame
)
922 if (FRAME_VISIBLE_P (f
))
923 value
= Fcons (frame
, value
);
930 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
932 "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
933 In other words, switch-frame events caused by events in FRAME will\n\
934 request a switch to FOCUS-FRAME, and `last-event-frame' will be\n\
935 FOCUS-FRAME after reading an event typed at FRAME.\n\
937 If FOCUS-FRAME is omitted or nil, any existing redirection is\n\
938 cancelled, and the frame again receives its own keystrokes.\n\
940 Focus redirection is useful for temporarily redirecting keystrokes to\n\
941 a surrogate minibuffer frame when a frame doesn't have its own\n\
942 minibuffer window.\n\
944 A frame's focus redirection can be changed by select-frame. If frame\n\
945 FOO is selected, and then a different frame BAR is selected, any\n\
946 frames redirecting their focus to FOO are shifted to redirect their\n\
947 focus to BAR. This allows focus redirection to work properly when the\n\
948 user switches from one frame to another using `select-window'.\n\
950 This means that a frame whose focus is redirected to itself is treated\n\
951 differently from a frame whose focus is redirected to nil; the former\n\
952 is affected by select-frame, while the latter is not.\n\
954 The redirection lasts until `redirect-frame-focus' is called to change it.")
956 Lisp_Object frame
, focus_frame
;
958 CHECK_LIVE_FRAME (frame
, 0);
960 if (! NILP (focus_frame
))
961 CHECK_LIVE_FRAME (focus_frame
, 1);
963 XFRAME (frame
)->focus_frame
= focus_frame
;
965 if (frame_rehighlight_hook
)
966 (*frame_rehighlight_hook
) ();
972 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
973 "Return the frame to which FRAME's keystrokes are currently being sent.\n\
974 This returns nil if FRAME's focus is not redirected.\n\
975 See `redirect-frame-focus'.")
979 CHECK_LIVE_FRAME (frame
, 0);
981 return FRAME_FOCUS_FRAME (XFRAME (frame
));
987 get_frame_param (frame
, prop
)
988 register struct frame
*frame
;
991 register Lisp_Object tem
;
993 tem
= Fassq (prop
, frame
->param_alist
);
1000 store_in_alist (alistptr
, prop
, val
)
1001 Lisp_Object
*alistptr
, val
;
1004 register Lisp_Object tem
;
1006 tem
= Fassq (prop
, *alistptr
);
1008 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1014 store_frame_param (f
, prop
, val
)
1016 Lisp_Object prop
, val
;
1018 register Lisp_Object tem
;
1020 tem
= Fassq (prop
, f
->param_alist
);
1022 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
1026 if (EQ (prop
, Qminibuffer
)
1027 && XTYPE (val
) == Lisp_Window
)
1029 if (! MINI_WINDOW_P (XWINDOW (val
)))
1030 error ("Surrogate minibuffer windows must be minibuffer windows.");
1032 if (FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
1033 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer.");
1035 /* Install the chosen minibuffer window, with proper buffer. */
1036 f
->minibuffer_window
= val
;
1040 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
1041 "Return the parameters-alist of frame FRAME.\n\
1042 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
1043 The meaningful PARMs depend on the kind of frame.\n\
1044 If FRAME is omitted, return information on the currently selected frame.")
1051 if (EQ (frame
, Qnil
))
1055 CHECK_FRAME (frame
, 0);
1059 if (f
->display
.nothing
== 0)
1062 alist
= Fcopy_alist (f
->param_alist
);
1063 store_in_alist (&alist
, Qname
, f
->name
);
1064 store_in_alist (&alist
, Qheight
, make_number (f
->height
));
1065 store_in_alist (&alist
, Qwidth
, make_number (f
->width
));
1066 store_in_alist (&alist
, Qmodeline
, (f
->wants_modeline
? Qt
: Qnil
));
1067 store_in_alist (&alist
, Qminibuffer
,
1068 (! FRAME_HAS_MINIBUF_P (f
) ? Qnone
1069 : (FRAME_MINIBUF_ONLY_P (f
) ? Qonly
1070 : FRAME_MINIBUF_WINDOW (f
))));
1071 store_in_alist (&alist
, Qunsplittable
, (f
->no_split
? Qt
: Qnil
));
1073 #ifdef HAVE_X_WINDOWS
1075 x_report_frame_params (f
, &alist
);
1080 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
1081 Smodify_frame_parameters
, 2, 2, 0,
1082 "Modify the parameters of frame FRAME according to ALIST.\n\
1083 ALIST is an alist of parameters to change and their new values.\n\
1084 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
1085 The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
1087 Lisp_Object frame
, alist
;
1090 register Lisp_Object tail
, elt
, prop
, val
;
1092 if (EQ (frame
, Qnil
))
1096 CHECK_LIVE_FRAME (frame
, 0);
1100 #ifdef HAVE_X_WINDOWS
1103 x_set_frame_parameters (f
, alist
);
1105 for (tail
= alist
; !EQ (tail
, Qnil
); tail
= Fcdr (tail
))
1110 x_set_frame_param (f
, prop
, val
, get_frame_param (f
, prop
));
1111 store_frame_param (f
, prop
, val
);
1121 /* This function isn't useful enough by itself to include; we need to
1122 add functions to allow the user to find the size of a font before
1123 this is actually useful. */
1125 DEFUN ("frame-pixel-size", Fframe_pixel_size
,
1126 Sframe_pixel_size
, 1, 1, 0,
1127 "Return a cons (width . height) of FRAME's size in pixels.")
1131 register struct frame
*f
;
1134 CHECK_LIVE_FRAME (frame
, 0);
1137 return Fcons (make_number (x_pixel_width (f
)),
1138 make_number (x_pixel_height (f
)));
1143 /* These functions have no C callers, and can be written nicely in lisp. */
1145 DEFUN ("frame-height", Fframe_height
, Sframe_height
, 0, 0, 0,
1146 "Return number of lines available for display on selected frame.")
1149 return make_number (FRAME_HEIGHT (selected_frame
));
1152 DEFUN ("frame-width", Fframe_width
, Sframe_width
, 0, 0, 0,
1153 "Return number of columns available for display on selected frame.")
1156 return make_number (FRAME_WIDTH (selected_frame
));
1160 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1161 "Specify that the frame FRAME has LINES lines.\n\
1162 Optional third arg non-nil means that redisplay should use LINES lines\n\
1163 but that the idea of the actual height of the frame should not be changed.")
1164 (frame
, rows
, pretend
)
1165 Lisp_Object frame
, rows
, pretend
;
1167 register struct frame
*f
;
1169 CHECK_NUMBER (rows
, 0);
1174 CHECK_LIVE_FRAME (frame
, 0);
1178 #ifdef HAVE_X_WINDOWS
1181 if (XINT (rows
) != f
->width
)
1182 x_set_window_size (f
, f
->width
, XINT (rows
));
1186 change_frame_size (f
, XINT (rows
), 0, !NILP (pretend
), 0);
1190 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1191 "Specify that the frame FRAME has COLS columns.\n\
1192 Optional third arg non-nil means that redisplay should use COLS columns\n\
1193 but that the idea of the actual width of the frame should not be changed.")
1194 (frame
, cols
, pretend
)
1195 Lisp_Object frame
, cols
, pretend
;
1197 register struct frame
*f
;
1198 CHECK_NUMBER (cols
, 0);
1203 CHECK_LIVE_FRAME (frame
, 0);
1207 #ifdef HAVE_X_WINDOWS
1210 if (XINT (cols
) != f
->width
)
1211 x_set_window_size (f
, XINT (cols
), f
->height
);
1215 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0);
1219 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1220 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1222 Lisp_Object frame
, cols
, rows
;
1224 register struct frame
*f
;
1227 CHECK_LIVE_FRAME (frame
, 0);
1228 CHECK_NUMBER (cols
, 2);
1229 CHECK_NUMBER (rows
, 1);
1232 #ifdef HAVE_X_WINDOWS
1235 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
)
1236 x_set_window_size (f
, XINT (cols
), XINT (rows
));
1240 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0);
1245 DEFUN ("set-frame-position", Fset_frame_position
,
1246 Sset_frame_position
, 3, 3, 0,
1247 "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
1248 If XOFFSET or YOFFSET are negative, they are interpreted relative to\n\
1249 the leftmost or bottommost position FRAME could occupy without going\n\
1251 (frame
, xoffset
, yoffset
)
1252 Lisp_Object frame
, xoffset
, yoffset
;
1254 register struct frame
*f
;
1257 CHECK_LIVE_FRAME (frame
, 0);
1258 CHECK_NUMBER (xoffset
, 1);
1259 CHECK_NUMBER (yoffset
, 2);
1262 #ifdef HAVE_X_WINDOWS
1264 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
));
1272 DEFUN ("rubber-band-rectangle", Frubber_band_rectangle
, Srubber_band_rectangle
,
1274 "Ask user to specify a window position and size on FRAME with the mouse.\n\
1275 Arguments are FRAME, NAME and GEO. NAME is a name to be displayed as\n\
1276 the purpose of this rectangle. GEO is an X-windows size spec that can\n\
1277 specify defaults for some sizes/positions. If GEO specifies everything,\n\
1278 the mouse is not used.\n\
1279 Returns a list of five values: (FRAME LEFT TOP WIDTH HEIGHT).")
1286 Lisp_Object nums
[4];
1289 CHECK_FRAME (frame
, 0);
1290 CHECK_STRING (name
, 1);
1291 CHECK_STRING (geo
, 2);
1293 switch (XFRAME (frame
)->output_method
)
1295 case output_x_window
:
1296 x_rubber_band (XFRAME (frame
), &vals
[0], &vals
[1], &vals
[2], &vals
[3],
1297 XSTRING (geo
)->data
, XSTRING (name
)->data
);
1304 for (i
= 0; i
< 4; i
++)
1305 XFASTINT (nums
[i
]) = vals
[i
];
1306 return Fcons (frame
, Flist (4, nums
));
1309 #endif /* not HAVE_X11 */
1311 choose_minibuf_frame ()
1313 /* For lowest-level minibuf, put it on currently selected frame
1314 if frame has a minibuffer. */
1316 if (minibuf_level
== 0
1317 && selected_frame
!= 0
1318 && !EQ (minibuf_window
, selected_frame
->minibuffer_window
))
1320 /* I don't think that any frames may validly have a null minibuffer
1322 if (NILP (selected_frame
->minibuffer_window
))
1325 Fset_window_buffer (selected_frame
->minibuffer_window
,
1326 XWINDOW (minibuf_window
)->buffer
);
1327 minibuf_window
= selected_frame
->minibuffer_window
;
1333 /*&&& init symbols here &&&*/
1334 Qframep
= intern ("framep");
1335 staticpro (&Qframep
);
1336 Qlive_frame_p
= intern ("live-frame-p");
1337 staticpro (&Qlive_frame_p
);
1338 Qheight
= intern ("height");
1339 staticpro (&Qheight
);
1340 Qicon
= intern ("icon");
1342 Qminibuffer
= intern ("minibuffer");
1343 staticpro (&Qminibuffer
);
1344 Qmodeline
= intern ("modeline");
1345 staticpro (&Qmodeline
);
1346 Qname
= intern ("name");
1348 Qnone
= intern ("none");
1350 Qonly
= intern ("only");
1352 Qunsplittable
= intern ("unsplittable");
1353 staticpro (&Qunsplittable
);
1354 Qwidth
= intern ("width");
1355 staticpro (&Qwidth
);
1359 staticpro (&Vframe_list
);
1361 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
1362 "The initial frame-object, which represents Emacs's stdout.");
1364 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
1365 "Non-nil if all of emacs is iconified and frame updates are not needed.");
1366 Vemacs_iconified
= Qnil
;
1368 DEFVAR_LISP ("default-minibuffer-frame", &Vdefault_minibuffer_frame
,
1369 "Minibufferless frames use this frame's minibuffer.\n\
1371 Emacs cannot create minibufferless frames unless this is set to an\n\
1372 appropriate surrogate.\n\
1374 Emacs consults this variable only when creating minibufferless\n\
1375 frames; once the frame is created, it sticks with its assigned\n\
1376 minibuffer, no matter what this variable is set to. This means that\n\
1377 this variable doesn't necessarily say anything meaningful about the\n\
1378 current set of frames, or where the minibuffer is currently being\n\
1380 Vdefault_minibuffer_frame
= Qnil
;
1382 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
1383 "Alist of default values for frame creation.\n\
1384 These may be set in your init file, like this:\n\
1385 (setq default-frame-alist '((width . 80) (height . 55)))\n\
1386 These override values given in window system configuration data, like\n\
1387 X Windows' defaults database.\n\
1388 For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
1389 For values specific to the separate minibuffer frame, see\n\
1390 `minibuffer-frame-alist'.");
1391 Vdefault_frame_alist
= Qnil
;
1394 defsubr (&Slive_frame_p
);
1395 defsubr (&Sselect_frame
);
1396 defsubr (&Sselected_frame
);
1397 defsubr (&Swindow_frame
);
1398 defsubr (&Sframe_root_window
);
1399 defsubr (&Sframe_selected_window
);
1400 defsubr (&Sframe_list
);
1401 defsubr (&Snext_frame
);
1402 defsubr (&Sdelete_frame
);
1403 defsubr (&Smouse_position
);
1404 defsubr (&Sset_mouse_position
);
1406 defsubr (&Sframe_configuration
);
1407 defsubr (&Srestore_frame_configuration
);
1409 defsubr (&Smake_frame_visible
);
1410 defsubr (&Smake_frame_invisible
);
1411 defsubr (&Siconify_frame
);
1412 defsubr (&Sframe_visible_p
);
1413 defsubr (&Svisible_frame_list
);
1414 defsubr (&Sredirect_frame_focus
);
1415 defsubr (&Sframe_focus
);
1416 defsubr (&Sframe_parameters
);
1417 defsubr (&Smodify_frame_parameters
);
1419 defsubr (&Sframe_pixel_size
);
1420 defsubr (&Sframe_height
);
1421 defsubr (&Sframe_width
);
1423 defsubr (&Sset_frame_height
);
1424 defsubr (&Sset_frame_width
);
1425 defsubr (&Sset_frame_size
);
1426 defsubr (&Sset_frame_position
);
1428 defsubr (&Srubber_band_rectangle
);
1429 #endif /* HAVE_X11 */
1434 initial_define_lispy_key (global_map
, "switch-frame", "select-frame");
1437 #else /* not MULTI_FRAME */
1439 /* If we're not using multi-frame stuff, we still need to provide some
1440 support functions. */
1442 /* Unless this function is defined, providing set-frame-height and
1443 set-frame-width doesn't help compatibility any, since they both
1444 want this as their first argument. */
1445 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1446 "Return the frame that is now selected.")
1454 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1455 "Specify that the frame FRAME has LINES lines.\n\
1456 Optional third arg non-nil means that redisplay should use LINES lines\n\
1457 but that the idea of the actual height of the frame should not be changed.")
1458 (frame
, rows
, pretend
)
1459 Lisp_Object frame
, rows
, pretend
;
1461 CHECK_NUMBER (rows
, 0);
1463 change_frame_size (0, XINT (rows
), 0, !NILP (pretend
), 0);
1467 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1468 "Specify that the frame FRAME has COLS columns.\n\
1469 Optional third arg non-nil means that redisplay should use COLS columns\n\
1470 but that the idea of the actual width of the frame should not be changed.")
1471 (frame
, cols
, pretend
)
1472 Lisp_Object frame
, cols
, pretend
;
1474 CHECK_NUMBER (cols
, 0);
1476 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1480 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1481 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1483 Lisp_Object frame
, cols
, rows
;
1485 CHECK_NUMBER (cols
, 2);
1486 CHECK_NUMBER (rows
, 1);
1488 change_frame_size (0, XINT (rows
), XINT (cols
), 0, 0);
1493 DEFUN ("frame-height", Fframe_height
, Sframe_height
, 0, 0, 0,
1494 "Return number of lines available for display on selected frame.")
1497 return make_number (FRAME_HEIGHT (selected_frame
));
1500 DEFUN ("frame-width", Fframe_width
, Sframe_width
, 0, 0, 0,
1501 "Return number of columns available for display on selected frame.")
1504 return make_number (FRAME_WIDTH (selected_frame
));
1507 /* These are for backward compatibility with Emacs 18. */
1509 DEFUN ("set-screen-height", Fset_screen_height
, Sset_screen_height
, 1, 2, 0,
1510 "Tell redisplay that the screen has LINES lines.\n\
1511 Optional second arg non-nil means that redisplay should use LINES lines\n\
1512 but that the idea of the actual height of the screen should not be changed.")
1514 Lisp_Object lines
, pretend
;
1516 CHECK_NUMBER (lines
, 0);
1518 change_frame_size (0, XINT (lines
), 0, !NILP (pretend
), 0);
1522 DEFUN ("set-screen-width", Fset_screen_width
, Sset_screen_width
, 1, 2, 0,
1523 "Tell redisplay that the screen has COLS columns.\n\
1524 Optional second arg non-nil means that redisplay should use COLS columns\n\
1525 but that the idea of the actual width of the screen should not be changed.")
1527 Lisp_Object cols
, pretend
;
1529 CHECK_NUMBER (cols
, 0);
1531 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1537 defsubr (&Sset_frame_height
);
1538 defsubr (&Sset_frame_width
);
1539 defsubr (&Sset_frame_size
);
1540 defsubr (&Sset_screen_height
);
1541 defsubr (&Sset_screen_width
);
1542 defsubr (&Sframe_height
);
1543 Ffset (intern ("screen-height"), intern ("frame-height"));
1544 defsubr (&Sframe_width
);
1545 Ffset (intern ("screen-width"), intern ("frame-width"));
1552 #endif /* not MULTI_FRAME */