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)
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;
163 f
->param_alist
= Qnil
;
164 f
->scrollbars
= Qnil
;
165 f
->condemned_scrollbars
= Qnil
;
167 root_window
= make_window ();
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
;
180 XWINDOW (root_window
)->next
= Qnil
;
181 f
->minibuffer_window
= Qnil
;
184 XWINDOW (root_window
)->frame
= frame
;
187 just so that there is "something there."
188 Correct size will be set up later with change_frame_size. */
193 XFASTINT (XWINDOW (root_window
)->width
) = 10;
194 XFASTINT (XWINDOW (root_window
)->height
) = (mini_p
? 9 : 10);
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. */
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
);
218 XWINDOW (mini_window
)->buffer
= Qt
;
219 Fset_window_buffer (mini_window
,
220 (NILP (Vminibuffer_list
)
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
);
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). */
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
;
257 CHECK_LIVE_WINDOW (mini_window
, 0);
260 /* Make a frame containing just a root window. */
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
)
268 : Fcar (Vminibuffer_list
)));
272 /* Make a frame containing only a minibuffer window. */
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
);
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
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
)
306 : Fcar (Vminibuffer_list
)));
310 /* Construct a frame that refers to the terminal (stdin and stdout). */
313 make_terminal_frame ()
315 register struct frame
*f
;
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
);
326 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
327 "Select the frame FRAME. FRAME's selected window becomes \"the\"\n\
328 selected window. If the optional parameter NO-ENTER is non-nil, don't\n\
329 focus on that frame.\n\
331 This function is interactive, and may be bound to the ``switch-frame''\n\
332 event; when invoked this way, it switches to the frame named in the\n\
333 event. When called from lisp, FRAME may be a ``switch-frame'' event;\n\
334 if it is, select the frame named in the event.\n\
336 Changing the selected frame can change focus redirections. See\n\
337 `redirect-frame-focus' for details.")
339 Lisp_Object frame
, no_enter
;
341 /* If FRAME is a switch-frame event, extract the frame we should
344 && EQ (XCONS (frame
)->car
, Qswitch_frame
)
345 && CONSP (XCONS (frame
)->cdr
))
346 frame
= XCONS (XCONS (frame
)->cdr
)->car
;
348 CHECK_LIVE_FRAME (frame
, 0);
350 if (selected_frame
== XFRAME (frame
))
353 /* If a frame's focus has been redirected toward the currently
354 selected frame, we should change the redirection to point to the
355 newly selected frame. This means that if the focus is redirected
356 from a minibufferless frame to a surrogate minibuffer frame, we
357 can use `other-window' to switch between all the frames using
358 that minibuffer frame, and the focus redirection will follow us
363 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
367 if (XTYPE (XCONS (tail
)->car
) != Lisp_Frame
)
370 focus
= FRAME_FOCUS_FRAME (XFRAME (XCONS (tail
)->car
));
372 if (XTYPE (focus
) == Lisp_Frame
373 && XFRAME (focus
) == selected_frame
)
374 Fredirect_frame_focus (XCONS (tail
)->car
, frame
);
378 selected_frame
= XFRAME (frame
);
379 if (! FRAME_MINIBUF_ONLY_P (selected_frame
))
380 last_nonminibuf_frame
= selected_frame
;
382 Fselect_window (XFRAME (frame
)->selected_window
);
384 #ifdef HAVE_X_WINDOWS
386 if (FRAME_X_P (XFRAME (frame
))
389 Ffocus_frame (frame
);
393 choose_minibuf_frame ();
398 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
399 "Return the frame that is now selected.")
403 XSET (tem
, Lisp_Frame
, selected_frame
);
407 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
408 "Return the frame object that window WINDOW is on.")
412 CHECK_LIVE_WINDOW (window
, 0);
413 return XWINDOW (window
)->frame
;
416 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
417 "Returns the root-window of FRAME.\n\
418 If omitted, FRAME defaults to the currently selected frame.")
423 XSET (frame
, Lisp_Frame
, selected_frame
);
425 CHECK_LIVE_FRAME (frame
, 0);
427 return XFRAME (frame
)->root_window
;
430 DEFUN ("frame-selected-window", Fframe_selected_window
,
431 Sframe_selected_window
, 0, 1, 0,
432 "Return the selected window of frame object FRAME.\n\
433 If omitted, FRAME defaults to the currently selected frame.")
438 XSET (frame
, Lisp_Frame
, selected_frame
);
440 CHECK_LIVE_FRAME (frame
, 0);
442 return XFRAME (frame
)->selected_window
;
445 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
447 "Return a list of all frames.")
450 return Fcopy_sequence (Vframe_list
);
455 /* Return the next frame in the frame list after FRAME.
456 If MINIBUF is nil, exclude minibuffer-only frames.
457 If MINIBUF is a window, include only frames using that window for
459 If MINIBUF is non-nil, and not a window, include all frames. */
461 next_frame (frame
, minibuf
)
468 /* There must always be at least one frame in Vframe_list. */
469 if (! CONSP (Vframe_list
))
473 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
475 Lisp_Object f
= XCONS (tail
)->car
;
479 /* Decide whether this frame is eligible to be returned. */
481 /* If we've looped all the way around without finding any
482 eligible frames, return the original frame. */
486 /* Let minibuf decide if this frame is acceptable. */
489 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
492 else if (XTYPE (minibuf
) == Lisp_Window
)
494 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
))
507 /* Nobody seems to be using this code right now. */
509 /* Return the previous frame in the frame list before FRAME.
510 If MINIBUF is nil, exclude minibuffer-only frames.
511 If MINIBUF is a window, include only frames using that window for
513 If MINIBUF is non-nil and not a window, include all frames. */
515 prev_frame (frame
, minibuf
)
522 /* There must always be at least one frame in Vframe_list. */
523 if (! CONSP (Vframe_list
))
527 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
529 Lisp_Object f
= XCONS (tail
)->car
;
531 if (XTYPE (f
) != Lisp_Frame
)
534 if (EQ (frame
, f
) && !NILP (prev
))
537 /* Decide whether this frame is eligible to be returned,
538 according to minibuf. */
541 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
544 else if (XTYPE (minibuf
) == Lisp_Window
)
546 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
))
553 /* We've scanned the entire list. */
555 /* We went through the whole frame list without finding a single
556 acceptable frame. Return the original frame. */
559 /* There were no acceptable frames in the list before FRAME; otherwise,
560 we would have returned directly from the loop. Since PREV is the last
561 acceptable frame in the list, return it. */
566 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
567 "Return the next frame in the frame list after FRAME.\n\
568 By default, skip minibuffer-only frames.\n\
569 If omitted, FRAME defaults to the selected frame.\n\
570 If optional argument MINIFRAME is non-nil, include minibuffer-only frames.\n\
571 If MINIFRAME is a window, include only frames using that window for their\n\
573 If MINIFRAME is non-nil and not a window, include all frames.")
575 Lisp_Object frame
, miniframe
;
580 XSET (frame
, Lisp_Frame
, selected_frame
);
582 CHECK_LIVE_FRAME (frame
, 0);
584 return next_frame (frame
, miniframe
);
586 #endif /* MULTI_FRAME */
588 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 1, "",
589 "Delete FRAME, permanently eliminating it from use.\n\
590 If omitted, FRAME defaults to the selected frame.\n\
591 A frame may not be deleted if its minibuffer is used by other frames.")
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 /* Since some events are handled at the interrupt level, we may get
658 an event for f at any time; if we zero out the frame's display
659 now, then we may trip up the event-handling code. Instead, we'll
660 promise that the display of the frame must be valid until we have
661 called the window-system-dependent frame destruction routine. */
662 #ifdef HAVE_X_WINDOWS
664 x_destroy_window (f
);
667 f
->display
.nothing
= 0;
669 /* If we've deleted the last_nonminibuf_frame, then try to find
671 if (f
== last_nonminibuf_frame
)
675 last_nonminibuf_frame
= 0;
677 for (frames
= Vframe_list
;
679 frames
= XCONS (frames
)->cdr
)
681 f
= XFRAME (XCONS (frames
)->car
);
682 if (!FRAME_MINIBUF_ONLY_P (f
))
684 last_nonminibuf_frame
= f
;
690 /* If we've deleted Vdefault_minibuffer_frame, try to find another
691 one. Prefer minibuffer-only frames, but also notice frames
692 with other windows. */
693 if (EQ (frame
, Vdefault_minibuffer_frame
))
697 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
698 Lisp_Object frame_with_minibuf
= Qnil
;
700 for (frames
= Vframe_list
;
702 frames
= XCONS (frames
)->cdr
)
704 Lisp_Object
this = XCONS (frames
)->car
;
706 if (XTYPE (this) != Lisp_Frame
)
710 if (FRAME_HAS_MINIBUF_P (f
))
712 frame_with_minibuf
= this;
713 if (FRAME_MINIBUF_ONLY_P (f
))
718 /* We know that there must be some frame with a minibuffer out
719 there. If this were not true, all of the frames present
720 would have to be minibufferless, which implies that at some
721 point their minibuffer frames must have been deleted, but
722 that is prohibited at the top; you can't delete surrogate
723 minibuffer frames. */
724 if (NILP (frame_with_minibuf
))
727 Vdefault_minibuffer_frame
= frame_with_minibuf
;
733 /* Return mouse position in character cell units. */
735 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
736 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
737 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
738 to read the mouse position, it returns the selected frame for FRAME\n\
739 and nil for X and Y.")
742 Lisp_Object x
, y
, dummy
;
745 if (mouse_position_hook
)
746 (*mouse_position_hook
) (&f
, &x
, &y
, &dummy
);
753 XSET (dummy
, Lisp_Frame
, f
);
754 return Fcons (dummy
, Fcons (make_number (x
), make_number (y
)));
757 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
758 "Move the mouse pointer to the center of cell (X,Y) in FRAME.\n\
759 WARNING: If you use this under X, you should do `unfocus-frame' afterwards.")
761 Lisp_Object frame
, x
, y
;
763 CHECK_LIVE_FRAME (frame
, 0);
767 #ifdef HAVE_X_WINDOWS
768 if (FRAME_X_P (XFRAME (frame
)))
769 /* Warping the mouse will cause enternotify and focus events. */
770 x_set_mouse_position (XFRAME (frame
), x
, y
);
777 /* ??? Can this be replaced with a Lisp function?
778 It is used in minibuf.c. Can we get rid of that?
779 Yes. All uses in minibuf.c are gone, and parallels to these
780 functions have been defined in frame.el. */
782 DEFUN ("frame-configuration", Fframe_configuration
, Sframe_configuration
,
784 "Return object describing current frame configuration.\n\
785 The frame configuration is the current mouse position and selected frame.\n\
786 This object can be given to `restore-frame-configuration'\n\
787 to restore this frame configuration.")
792 c
= Fmake_vector (make_number(4), Qnil
);
793 XVECTOR (c
)->contents
[0] = Fselected_frame();
794 if (mouse_position_hook
)
795 (*mouse_position_hook
) (&XVECTOR (c
)->contents
[1]
796 &XVECTOR (c
)->contents
[2],
797 &XVECTOR (c
)->contents
[3],
802 DEFUN ("restore-frame-configuration", Frestore_frame_configuration
,
803 Srestore_frame_configuration
,
805 "Restores frame configuration CONFIGURATION.")
809 Lisp_Object x_pos
, y_pos
, frame
;
811 CHECK_VECTOR (config
, 0);
812 if (XVECTOR (config
)->size
!= 3)
814 error ("Wrong size vector passed to restore-frame-configuration");
816 frame
= XVECTOR (config
)->contents
[0];
817 CHECK_LIVE_FRAME (frame
, 0);
819 Fselect_frame (frame
, Qnil
);
822 /* This seems to interfere with the frame selection mechanism. jla */
823 x_pos
= XVECTOR (config
)->contents
[2];
824 y_pos
= XVECTOR (config
)->contents
[3];
825 set_mouse_position (frame
, XINT (x_pos
), XINT (y_pos
));
832 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
834 "Make the frame FRAME visible (assuming it is an X-window).\n\
835 Also raises the frame so that nothing obscures it.\n\
836 If omitted, FRAME defaults to the currently selected frame.")
841 XSET (frame
, Lisp_Frame
, selected_frame
);
843 CHECK_LIVE_FRAME (frame
, 0);
845 #ifdef HAVE_X_WINDOWS
846 if (FRAME_X_P (XFRAME (frame
)))
847 x_make_frame_visible (XFRAME (frame
));
853 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
855 "Make the frame FRAME invisible (assuming it is an X-window).\n\
856 If omitted, FRAME defaults to the currently selected frame.")
861 XSET (frame
, Lisp_Frame
, selected_frame
);
863 CHECK_LIVE_FRAME (frame
, 0);
865 #ifdef HAVE_X_WINDOWS
866 if (FRAME_X_P (XFRAME (frame
)))
867 x_make_frame_invisible (XFRAME (frame
));
873 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
875 "Make the frame FRAME into an icon.\n\
876 If omitted, FRAME defaults to the currently selected frame.")
881 XSET (frame
, Lisp_Frame
, selected_frame
);
883 CHECK_LIVE_FRAME (frame
, 0);
885 #ifdef HAVE_X_WINDOWS
886 if (FRAME_X_P (XFRAME (frame
)))
887 x_iconify_frame (XFRAME (frame
));
893 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
895 "Return t if FRAME is now \"visible\" (actually in use for display).\n\
896 A frame that is not \"visible\" is not updated and, if it works through\n\
897 a window system, it may not show at all.\n\
898 Return the symbol `icon' if frame is visible only as an icon.")
902 CHECK_LIVE_FRAME (frame
, 0);
904 if (FRAME_VISIBLE_P (XFRAME (frame
)))
906 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
911 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
913 "Return a list of all frames now \"visible\" (being updated).")
916 Lisp_Object tail
, frame
;
921 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
923 frame
= XCONS (tail
)->car
;
924 if (XTYPE (frame
) != Lisp_Frame
)
927 if (FRAME_VISIBLE_P (f
))
928 value
= Fcons (frame
, value
);
935 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
937 "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
938 In other words, switch-frame events caused by events in FRAME will\n\
939 request a switch to FOCUS-FRAME, and `last-event-frame' will be\n\
940 FOCUS-FRAME after reading an event typed at FRAME.\n\
942 If FOCUS-FRAME is omitted or nil, any existing redirection is\n\
943 cancelled, and the frame again receives its own keystrokes.\n\
945 Focus redirection is useful for temporarily redirecting keystrokes to\n\
946 a surrogate minibuffer frame when a frame doesn't have its own\n\
947 minibuffer window.\n\
949 A frame's focus redirection can be changed by select-frame. If frame\n\
950 FOO is selected, and then a different frame BAR is selected, any\n\
951 frames redirecting their focus to FOO are shifted to redirect their\n\
952 focus to BAR. This allows focus redirection to work properly when the\n\
953 user switches from one frame to another using `select-window'.\n\
955 This means that a frame whose focus is redirected to itself is treated\n\
956 differently from a frame whose focus is redirected to nil; the former\n\
957 is affected by select-frame, while the latter is not.\n\
959 The redirection lasts until `redirect-frame-focus' is called to change it.")
961 Lisp_Object frame
, focus_frame
;
963 CHECK_LIVE_FRAME (frame
, 0);
965 if (! NILP (focus_frame
))
966 CHECK_LIVE_FRAME (focus_frame
, 1);
968 XFRAME (frame
)->focus_frame
= focus_frame
;
970 if (frame_rehighlight_hook
)
971 (*frame_rehighlight_hook
) ();
977 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
978 "Return the frame to which FRAME's keystrokes are currently being sent.\n\
979 This returns nil if FRAME's focus is not redirected.\n\
980 See `redirect-frame-focus'.")
984 CHECK_LIVE_FRAME (frame
, 0);
986 return FRAME_FOCUS_FRAME (XFRAME (frame
));
992 get_frame_param (frame
, prop
)
993 register struct frame
*frame
;
996 register Lisp_Object tem
;
998 tem
= Fassq (prop
, frame
->param_alist
);
1005 store_in_alist (alistptr
, prop
, val
)
1006 Lisp_Object
*alistptr
, val
;
1009 register Lisp_Object tem
;
1011 tem
= Fassq (prop
, *alistptr
);
1013 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1019 store_frame_param (f
, prop
, val
)
1021 Lisp_Object prop
, val
;
1023 register Lisp_Object tem
;
1025 tem
= Fassq (prop
, f
->param_alist
);
1027 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
1031 if (EQ (prop
, Qminibuffer
)
1032 && XTYPE (val
) == Lisp_Window
)
1034 if (! MINI_WINDOW_P (XWINDOW (val
)))
1035 error ("Surrogate minibuffer windows must be minibuffer windows.");
1037 if (FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
1038 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer.");
1040 /* Install the chosen minibuffer window, with proper buffer. */
1041 f
->minibuffer_window
= val
;
1045 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
1046 "Return the parameters-alist of frame FRAME.\n\
1047 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
1048 The meaningful PARMs depend on the kind of frame.\n\
1049 If FRAME is omitted, return information on the currently selected frame.")
1056 if (EQ (frame
, Qnil
))
1060 CHECK_FRAME (frame
, 0);
1064 if (f
->display
.nothing
== 0)
1067 alist
= Fcopy_alist (f
->param_alist
);
1068 store_in_alist (&alist
, Qname
, f
->name
);
1069 store_in_alist (&alist
, Qheight
, make_number (f
->height
));
1070 store_in_alist (&alist
, Qwidth
, make_number (f
->width
));
1071 store_in_alist (&alist
, Qmodeline
, (f
->wants_modeline
? Qt
: Qnil
));
1072 store_in_alist (&alist
, Qminibuffer
,
1073 (! FRAME_HAS_MINIBUF_P (f
) ? Qnone
1074 : (FRAME_MINIBUF_ONLY_P (f
) ? Qonly
1075 : FRAME_MINIBUF_WINDOW (f
))));
1076 store_in_alist (&alist
, Qunsplittable
, (f
->no_split
? Qt
: Qnil
));
1078 #ifdef HAVE_X_WINDOWS
1080 x_report_frame_params (f
, &alist
);
1085 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
1086 Smodify_frame_parameters
, 2, 2, 0,
1087 "Modify the parameters of frame FRAME according to ALIST.\n\
1088 ALIST is an alist of parameters to change and their new values.\n\
1089 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
1090 The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
1092 Lisp_Object frame
, alist
;
1095 register Lisp_Object tail
, elt
, prop
, val
;
1097 if (EQ (frame
, Qnil
))
1101 CHECK_LIVE_FRAME (frame
, 0);
1105 #ifdef HAVE_X_WINDOWS
1108 x_set_frame_parameters (f
, alist
);
1110 for (tail
= alist
; !EQ (tail
, Qnil
); tail
= Fcdr (tail
))
1115 x_set_frame_param (f
, prop
, val
, get_frame_param (f
, prop
));
1116 store_frame_param (f
, prop
, val
);
1126 /* This function isn't useful enough by itself to include; we need to
1127 add functions to allow the user to find the size of a font before
1128 this is actually useful. */
1130 DEFUN ("frame-pixel-size", Fframe_pixel_size
,
1131 Sframe_pixel_size
, 1, 1, 0,
1132 "Return a cons (width . height) of FRAME's size in pixels.")
1136 register struct frame
*f
;
1139 CHECK_LIVE_FRAME (frame
, 0);
1142 return Fcons (make_number (x_pixel_width (f
)),
1143 make_number (x_pixel_height (f
)));
1148 /* These functions have no C callers, and can be written nicely in lisp. */
1150 DEFUN ("frame-height", Fframe_height
, Sframe_height
, 0, 0, 0,
1151 "Return number of lines available for display on selected frame.")
1154 return make_number (FRAME_HEIGHT (selected_frame
));
1157 DEFUN ("frame-width", Fframe_width
, Sframe_width
, 0, 0, 0,
1158 "Return number of columns available for display on selected frame.")
1161 return make_number (FRAME_WIDTH (selected_frame
));
1165 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1166 "Specify that the frame FRAME has LINES lines.\n\
1167 Optional third arg non-nil means that redisplay should use LINES lines\n\
1168 but that the idea of the actual height of the frame should not be changed.")
1169 (frame
, rows
, pretend
)
1170 Lisp_Object frame
, rows
, pretend
;
1172 register struct frame
*f
;
1174 CHECK_NUMBER (rows
, 0);
1179 CHECK_LIVE_FRAME (frame
, 0);
1183 #ifdef HAVE_X_WINDOWS
1186 if (XINT (rows
) != f
->width
)
1187 x_set_window_size (f
, f
->width
, XINT (rows
));
1191 change_frame_size (f
, XINT (rows
), 0, !NILP (pretend
), 0);
1195 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1196 "Specify that the frame FRAME has COLS columns.\n\
1197 Optional third arg non-nil means that redisplay should use COLS columns\n\
1198 but that the idea of the actual width of the frame should not be changed.")
1199 (frame
, cols
, pretend
)
1200 Lisp_Object frame
, cols
, pretend
;
1202 register struct frame
*f
;
1203 CHECK_NUMBER (cols
, 0);
1208 CHECK_LIVE_FRAME (frame
, 0);
1212 #ifdef HAVE_X_WINDOWS
1215 if (XINT (cols
) != f
->width
)
1216 x_set_window_size (f
, XINT (cols
), f
->height
);
1220 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0);
1224 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1225 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1227 Lisp_Object frame
, cols
, rows
;
1229 register struct frame
*f
;
1232 CHECK_LIVE_FRAME (frame
, 0);
1233 CHECK_NUMBER (cols
, 2);
1234 CHECK_NUMBER (rows
, 1);
1237 #ifdef HAVE_X_WINDOWS
1240 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
)
1241 x_set_window_size (f
, XINT (cols
), XINT (rows
));
1245 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0);
1250 DEFUN ("set-frame-position", Fset_frame_position
,
1251 Sset_frame_position
, 3, 3, 0,
1252 "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
1253 If XOFFSET or YOFFSET are negative, they are interpreted relative to\n\
1254 the leftmost or bottommost position FRAME could occupy without going\n\
1256 (frame
, xoffset
, yoffset
)
1257 Lisp_Object frame
, xoffset
, yoffset
;
1259 register struct frame
*f
;
1262 CHECK_LIVE_FRAME (frame
, 0);
1263 CHECK_NUMBER (xoffset
, 1);
1264 CHECK_NUMBER (yoffset
, 2);
1267 #ifdef HAVE_X_WINDOWS
1269 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
));
1277 DEFUN ("rubber-band-rectangle", Frubber_band_rectangle
, Srubber_band_rectangle
,
1279 "Ask user to specify a window position and size on FRAME with the mouse.\n\
1280 Arguments are FRAME, NAME and GEO. NAME is a name to be displayed as\n\
1281 the purpose of this rectangle. GEO is an X-windows size spec that can\n\
1282 specify defaults for some sizes/positions. If GEO specifies everything,\n\
1283 the mouse is not used.\n\
1284 Returns a list of five values: (FRAME LEFT TOP WIDTH HEIGHT).")
1291 Lisp_Object nums
[4];
1294 CHECK_FRAME (frame
, 0);
1295 CHECK_STRING (name
, 1);
1296 CHECK_STRING (geo
, 2);
1298 switch (XFRAME (frame
)->output_method
)
1300 case output_x_window
:
1301 x_rubber_band (XFRAME (frame
), &vals
[0], &vals
[1], &vals
[2], &vals
[3],
1302 XSTRING (geo
)->data
, XSTRING (name
)->data
);
1309 for (i
= 0; i
< 4; i
++)
1310 XFASTINT (nums
[i
]) = vals
[i
];
1311 return Fcons (frame
, Flist (4, nums
));
1314 #endif /* not HAVE_X11 */
1316 choose_minibuf_frame ()
1318 /* For lowest-level minibuf, put it on currently selected frame
1319 if frame has a minibuffer. */
1321 if (minibuf_level
== 0
1322 && selected_frame
!= 0
1323 && !EQ (minibuf_window
, selected_frame
->minibuffer_window
))
1325 /* I don't think that any frames may validly have a null minibuffer
1327 if (NILP (selected_frame
->minibuffer_window
))
1330 Fset_window_buffer (selected_frame
->minibuffer_window
,
1331 XWINDOW (minibuf_window
)->buffer
);
1332 minibuf_window
= selected_frame
->minibuffer_window
;
1338 /*&&& init symbols here &&&*/
1339 Qframep
= intern ("framep");
1340 staticpro (&Qframep
);
1341 Qlive_frame_p
= intern ("live-frame-p");
1342 staticpro (&Qlive_frame_p
);
1343 Qheight
= intern ("height");
1344 staticpro (&Qheight
);
1345 Qicon
= intern ("icon");
1347 Qminibuffer
= intern ("minibuffer");
1348 staticpro (&Qminibuffer
);
1349 Qmodeline
= intern ("modeline");
1350 staticpro (&Qmodeline
);
1351 Qname
= intern ("name");
1353 Qnone
= intern ("none");
1355 Qonly
= intern ("only");
1357 Qunsplittable
= intern ("unsplittable");
1358 staticpro (&Qunsplittable
);
1359 Qwidth
= intern ("width");
1360 staticpro (&Qwidth
);
1364 staticpro (&Vframe_list
);
1366 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
1367 "The initial frame-object, which represents Emacs's stdout.");
1369 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
1370 "Non-nil if all of emacs is iconified and frame updates are not needed.");
1371 Vemacs_iconified
= Qnil
;
1373 DEFVAR_LISP ("default-minibuffer-frame", &Vdefault_minibuffer_frame
,
1374 "Minibufferless frames use this frame's minibuffer.\n\
1376 Emacs cannot create minibufferless frames unless this is set to an\n\
1377 appropriate surrogate.\n\
1379 Emacs consults this variable only when creating minibufferless\n\
1380 frames; once the frame is created, it sticks with its assigned\n\
1381 minibuffer, no matter what this variable is set to. This means that\n\
1382 this variable doesn't necessarily say anything meaningful about the\n\
1383 current set of frames, or where the minibuffer is currently being\n\
1385 Vdefault_minibuffer_frame
= Qnil
;
1387 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
1388 "Alist of default values for frame creation.\n\
1389 These may be set in your init file, like this:\n\
1390 (setq default-frame-alist '((width . 80) (height . 55)))\n\
1391 These override values given in window system configuration data, like\n\
1392 X Windows' defaults database.\n\
1393 For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
1394 For values specific to the separate minibuffer frame, see\n\
1395 `minibuffer-frame-alist'.");
1396 Vdefault_frame_alist
= Qnil
;
1399 defsubr (&Slive_frame_p
);
1400 defsubr (&Sselect_frame
);
1401 defsubr (&Sselected_frame
);
1402 defsubr (&Swindow_frame
);
1403 defsubr (&Sframe_root_window
);
1404 defsubr (&Sframe_selected_window
);
1405 defsubr (&Sframe_list
);
1406 defsubr (&Snext_frame
);
1407 defsubr (&Sdelete_frame
);
1408 defsubr (&Smouse_position
);
1409 defsubr (&Sset_mouse_position
);
1411 defsubr (&Sframe_configuration
);
1412 defsubr (&Srestore_frame_configuration
);
1414 defsubr (&Smake_frame_visible
);
1415 defsubr (&Smake_frame_invisible
);
1416 defsubr (&Siconify_frame
);
1417 defsubr (&Sframe_visible_p
);
1418 defsubr (&Svisible_frame_list
);
1419 defsubr (&Sredirect_frame_focus
);
1420 defsubr (&Sframe_focus
);
1421 defsubr (&Sframe_parameters
);
1422 defsubr (&Smodify_frame_parameters
);
1424 defsubr (&Sframe_pixel_size
);
1425 defsubr (&Sframe_height
);
1426 defsubr (&Sframe_width
);
1428 defsubr (&Sset_frame_height
);
1429 defsubr (&Sset_frame_width
);
1430 defsubr (&Sset_frame_size
);
1431 defsubr (&Sset_frame_position
);
1433 defsubr (&Srubber_band_rectangle
);
1434 #endif /* HAVE_X11 */
1439 initial_define_lispy_key (global_map
, "switch-frame", "select-frame");
1442 #else /* not MULTI_FRAME */
1444 /* If we're not using multi-frame stuff, we still need to provide some
1445 support functions. */
1447 /* Unless this function is defined, providing set-frame-height and
1448 set-frame-width doesn't help compatibility any, since they both
1449 want this as their first argument. */
1450 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1451 "Return the frame that is now selected.")
1459 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1460 "Specify that the frame FRAME has LINES lines.\n\
1461 Optional third arg non-nil means that redisplay should use LINES lines\n\
1462 but that the idea of the actual height of the frame should not be changed.")
1463 (frame
, rows
, pretend
)
1464 Lisp_Object frame
, rows
, pretend
;
1466 CHECK_NUMBER (rows
, 0);
1468 change_frame_size (0, XINT (rows
), 0, !NILP (pretend
), 0);
1472 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1473 "Specify that the frame FRAME has COLS columns.\n\
1474 Optional third arg non-nil means that redisplay should use COLS columns\n\
1475 but that the idea of the actual width of the frame should not be changed.")
1476 (frame
, cols
, pretend
)
1477 Lisp_Object frame
, cols
, pretend
;
1479 CHECK_NUMBER (cols
, 0);
1481 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1485 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1486 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1488 Lisp_Object frame
, cols
, rows
;
1490 CHECK_NUMBER (cols
, 2);
1491 CHECK_NUMBER (rows
, 1);
1493 change_frame_size (0, XINT (rows
), XINT (cols
), 0, 0);
1498 DEFUN ("frame-height", Fframe_height
, Sframe_height
, 0, 0, 0,
1499 "Return number of lines available for display on selected frame.")
1502 return make_number (FRAME_HEIGHT (selected_frame
));
1505 DEFUN ("frame-width", Fframe_width
, Sframe_width
, 0, 0, 0,
1506 "Return number of columns available for display on selected frame.")
1509 return make_number (FRAME_WIDTH (selected_frame
));
1512 /* These are for backward compatibility with Emacs 18. */
1514 DEFUN ("set-screen-height", Fset_screen_height
, Sset_screen_height
, 1, 2, 0,
1515 "Tell redisplay that the screen has LINES lines.\n\
1516 Optional second arg non-nil means that redisplay should use LINES lines\n\
1517 but that the idea of the actual height of the screen should not be changed.")
1519 Lisp_Object lines
, pretend
;
1521 CHECK_NUMBER (lines
, 0);
1523 change_frame_size (0, XINT (lines
), 0, !NILP (pretend
), 0);
1527 DEFUN ("set-screen-width", Fset_screen_width
, Sset_screen_width
, 1, 2, 0,
1528 "Tell redisplay that the screen has COLS columns.\n\
1529 Optional second arg non-nil means that redisplay should use COLS columns\n\
1530 but that the idea of the actual width of the screen should not be changed.")
1532 Lisp_Object cols
, pretend
;
1534 CHECK_NUMBER (cols
, 0);
1536 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1542 defsubr (&Sset_frame_height
);
1543 defsubr (&Sset_frame_width
);
1544 defsubr (&Sset_frame_size
);
1545 defsubr (&Sset_screen_height
);
1546 defsubr (&Sset_screen_width
);
1547 defsubr (&Sframe_height
);
1548 Ffset (intern ("screen-height"), intern ("frame-height"));
1549 defsubr (&Sframe_width
);
1550 Ffset (intern ("screen-width"), intern ("frame-width"));
1557 #endif /* not MULTI_FRAME */