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
= frame
;
160 f
->explicit_name
= 0;
162 f
->param_alist
= Qnil
;
164 root_window
= make_window ();
167 mini_window
= make_window ();
168 XWINDOW (root_window
)->next
= mini_window
;
169 XWINDOW (mini_window
)->prev
= root_window
;
170 XWINDOW (mini_window
)->mini_p
= Qt
;
171 XWINDOW (mini_window
)->frame
= frame
;
172 f
->minibuffer_window
= mini_window
;
177 XWINDOW (root_window
)->next
= Qnil
;
178 f
->minibuffer_window
= Qnil
;
181 XWINDOW (root_window
)->frame
= frame
;
184 just so that there is "something there."
185 Correct size will be set up later with change_frame_size. */
190 XFASTINT (XWINDOW (root_window
)->width
) = 10;
191 XFASTINT (XWINDOW (root_window
)->height
) = (mini_p
? 9 : 10);
195 XFASTINT (XWINDOW (mini_window
)->width
) = 10;
196 XFASTINT (XWINDOW (mini_window
)->top
) = 9;
197 XFASTINT (XWINDOW (mini_window
)->height
) = 1;
200 /* Choose a buffer for the frame's root window. */
204 XWINDOW (root_window
)->buffer
= Qt
;
205 buf
= Fcurrent_buffer ();
206 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
207 a space), try to find another one. */
208 if (XSTRING (Fbuffer_name (buf
))->data
[0] == ' ')
209 buf
= Fother_buffer (buf
, Qnil
);
210 Fset_window_buffer (root_window
, buf
);
215 XWINDOW (mini_window
)->buffer
= Qt
;
216 Fset_window_buffer (mini_window
,
217 (NILP (Vminibuffer_list
)
219 : Fcar (Vminibuffer_list
)));
222 f
->root_window
= root_window
;
223 f
->selected_window
= root_window
;
224 /* Make sure this window seems more recently used than
225 a newly-created, never-selected window. */
226 XFASTINT (XWINDOW (f
->selected_window
)->use_time
) = ++window_select_count
;
228 Vframe_list
= Fcons (frame
, Vframe_list
);
233 /* Make a frame using a separate minibuffer window on another frame.
234 MINI_WINDOW is the minibuffer window to use. nil means use the
235 default (the global minibuffer). */
238 make_frame_without_minibuffer (mini_window
)
239 register Lisp_Object mini_window
;
241 register struct frame
*f
;
243 /* Choose the minibuffer window to use. */
244 if (NILP (mini_window
))
246 if (XTYPE (Vdefault_minibuffer_frame
) != Lisp_Frame
)
247 error ("default-minibuffer-frame must be set when creating minibufferless frames");
248 if (! FRAME_LIVE_P (XFRAME (Vdefault_minibuffer_frame
)))
249 error ("default-minibuffer-frame must be a live frame");
250 mini_window
= XFRAME (Vdefault_minibuffer_frame
)->minibuffer_window
;
254 CHECK_LIVE_WINDOW (mini_window
, 0);
257 /* Make a frame containing just a root window. */
260 /* Install the chosen minibuffer window, with proper buffer. */
261 f
->minibuffer_window
= mini_window
;
262 Fset_window_buffer (mini_window
,
263 (NILP (Vminibuffer_list
)
265 : Fcar (Vminibuffer_list
)));
269 /* Make a frame containing only a minibuffer window. */
272 make_minibuffer_frame ()
274 /* First make a frame containing just a root window, no minibuffer. */
276 register struct frame
*f
= make_frame (0);
277 register Lisp_Object mini_window
;
278 register Lisp_Object frame
;
280 XSET (frame
, Lisp_Frame
, f
);
285 f
->wants_modeline
= 0;
286 f
->has_minibuffer
= 1;
288 /* Now label the root window as also being the minibuffer.
289 Avoid infinite looping on the window chain by marking next pointer
292 mini_window
= f
->minibuffer_window
= f
->root_window
;
293 XWINDOW (mini_window
)->mini_p
= Qt
;
294 XWINDOW (mini_window
)->next
= Qnil
;
295 XWINDOW (mini_window
)->prev
= Qnil
;
296 XWINDOW (mini_window
)->frame
= frame
;
298 /* Put the proper buffer in that window. */
300 Fset_window_buffer (mini_window
,
301 (NILP (Vminibuffer_list
)
303 : Fcar (Vminibuffer_list
)));
307 /* Construct a frame that refers to the terminal (stdin and stdout). */
310 make_terminal_frame ()
312 register struct frame
*f
;
316 f
->name
= build_string ("terminal");
318 f
->display
.nothing
= 1; /* Nonzero means frame isn't deleted. */
319 XSET (Vterminal_frame
, Lisp_Frame
, f
);
323 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
324 "Select the frame FRAME. FRAME's selected window becomes \"the\"\n\
325 selected window. If the optional parameter NO-ENTER is non-nil, don't\n\
326 focus on that frame.\n\
328 This function is interactive, and may be bound to the ``switch-frame''\n\
329 event; when invoked this way, it switches to the frame named in the\n\
330 event. When called from lisp, FRAME may be a ``switch-frame'' event;\n\
331 if it is, select the frame named in the event.")
333 Lisp_Object frame
, no_enter
;
335 /* If FRAME is a switch-frame event, extract the frame we should
338 && EQ (XCONS (frame
)->car
, Qswitch_frame
)
339 && CONSP (XCONS (frame
)->cdr
))
340 frame
= XCONS (XCONS (frame
)->cdr
)->car
;
342 CHECK_LIVE_FRAME (frame
, 0);
344 if (selected_frame
== XFRAME (frame
))
347 selected_frame
= XFRAME (frame
);
348 if (! FRAME_MINIBUF_ONLY_P (selected_frame
))
349 last_nonminibuf_frame
= selected_frame
;
351 Fselect_window (XFRAME (frame
)->selected_window
);
353 #ifdef HAVE_X_WINDOWS
355 if (FRAME_X_P (XFRAME (frame
))
358 Ffocus_frame (frame
);
362 choose_minibuf_frame ();
367 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
368 "Return the frame that is now selected.")
372 XSET (tem
, Lisp_Frame
, selected_frame
);
376 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
377 "Return the frame object that window WINDOW is on.")
381 CHECK_LIVE_WINDOW (window
, 0);
382 return XWINDOW (window
)->frame
;
385 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
386 "Returns the root-window of FRAME.\n\
387 If omitted, FRAME defaults to the currently selected frame.")
392 XSET (frame
, Lisp_Frame
, selected_frame
);
394 CHECK_LIVE_FRAME (frame
, 0);
396 return XFRAME (frame
)->root_window
;
399 DEFUN ("frame-selected-window", Fframe_selected_window
,
400 Sframe_selected_window
, 0, 1, 0,
401 "Return the selected window of frame object FRAME.\n\
402 If omitted, FRAME defaults to the currently selected frame.")
407 XSET (frame
, Lisp_Frame
, selected_frame
);
409 CHECK_LIVE_FRAME (frame
, 0);
411 return XFRAME (frame
)->selected_window
;
414 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
416 "Return a list of all frames.")
419 return Fcopy_sequence (Vframe_list
);
424 /* Return the next frame in the frame list after FRAME.
425 If MINIBUF is nil, exclude minibuffer-only frames.
426 If MINIBUF is a window, include only frames using that window for
428 If MINIBUF is non-nil, and not a window, include all frames. */
430 next_frame (frame
, minibuf
)
437 /* There must always be at least one frame in Vframe_list. */
438 if (! CONSP (Vframe_list
))
442 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
444 Lisp_Object f
= XCONS (tail
)->car
;
448 /* Decide whether this frame is eligible to be returned. */
450 /* If we've looped all the way around without finding any
451 eligible frames, return the original frame. */
455 /* Let minibuf decide if this frame is acceptable. */
458 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
461 else if (XTYPE (minibuf
) == Lisp_Window
)
463 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
))
476 /* Nobody seems to be using this code right now. */
478 /* Return the previous frame in the frame list before FRAME.
479 If MINIBUF is nil, exclude minibuffer-only frames.
480 If MINIBUF is a window, include only frames using that window for
482 If MINIBUF is non-nil and not a window, include all frames. */
484 prev_frame (frame
, minibuf
)
491 /* There must always be at least one frame in Vframe_list. */
492 if (! CONSP (Vframe_list
))
496 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
498 Lisp_Object f
= XCONS (tail
)->car
;
500 if (XTYPE (f
) != Lisp_Frame
)
503 if (EQ (frame
, f
) && !NILP (prev
))
506 /* Decide whether this frame is eligible to be returned,
507 according to minibuf. */
510 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
513 else if (XTYPE (minibuf
) == Lisp_Window
)
515 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
))
522 /* We've scanned the entire list. */
524 /* We went through the whole frame list without finding a single
525 acceptable frame. Return the original frame. */
528 /* There were no acceptable frames in the list before FRAME; otherwise,
529 we would have returned directly from the loop. Since PREV is the last
530 acceptable frame in the list, return it. */
535 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
536 "Return the next frame in the frame list after FRAME.\n\
537 By default, skip minibuffer-only frames.
538 If omitted, FRAME defaults to the selected frame.\n\
539 If optional argument MINIFRAME is non-nil, include minibuffer-only frames.\n\
540 If MINIFRAME is a window, include only frames using that window for their\n\
542 If MINIFRAME is non-nil and not a window, include all frames.")
544 Lisp_Object frame
, miniframe
;
549 XSET (frame
, Lisp_Frame
, selected_frame
);
551 CHECK_LIVE_FRAME (frame
, 0);
553 return next_frame (frame
, miniframe
);
555 #endif /* MULTI_FRAME */
557 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 1, "",
558 "Delete FRAME, permanently eliminating it from use.\n\
559 If omitted, FRAME defaults to the selected frame.\n\
560 A frame may not be deleted if its minibuffer is used by other frames.")
567 if (EQ (frame
, Qnil
))
570 XSET (frame
, Lisp_Frame
, f
);
574 CHECK_FRAME (frame
, 0);
578 if (! FRAME_LIVE_P (f
))
581 /* Are there any other frames besides this one? */
582 if (f
== selected_frame
&& EQ (next_frame (frame
, Qt
), frame
))
583 error ("Attempt to delete the only frame");
585 /* Does this frame have a minibuffer, and is it the surrogate
586 minibuffer for any other frame? */
587 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
591 for (frames
= Vframe_list
;
593 frames
= XCONS (frames
)->cdr
)
595 Lisp_Object
this = XCONS (frames
)->car
;
597 if (! EQ (this, frame
)
601 (FRAME_MINIBUF_WINDOW
603 error ("Attempt to delete a surrogate minibuffer frame");
607 /* Don't let the frame remain selected. */
608 if (f
== selected_frame
)
609 Fselect_frame (next_frame (frame
, Qt
), Qnil
);
611 /* Don't allow minibuf_window to remain on a deleted frame. */
612 if (EQ (f
->minibuffer_window
, minibuf_window
))
614 Fset_window_buffer (selected_frame
->minibuffer_window
,
615 XWINDOW (minibuf_window
)->buffer
);
616 minibuf_window
= selected_frame
->minibuffer_window
;
619 Vframe_list
= Fdelq (frame
, Vframe_list
);
622 f
->display
.nothing
= 0;
624 #ifdef HAVE_X_WINDOWS
626 x_destroy_window (f
, displ
);
629 /* If we've deleted the last_nonminibuf_frame, then try to find
631 if (f
== last_nonminibuf_frame
)
635 last_nonminibuf_frame
= 0;
637 for (frames
= Vframe_list
;
639 frames
= XCONS (frames
)->cdr
)
641 f
= XFRAME (XCONS (frames
)->car
);
642 if (!FRAME_MINIBUF_ONLY_P (f
))
644 last_nonminibuf_frame
= f
;
650 /* If we've deleted Vdefault_minibuffer_frame, try to find another
651 one. Prefer minibuffer-only frames, but also notice frames
652 with other windows. */
653 if (EQ (frame
, Vdefault_minibuffer_frame
))
657 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
658 Lisp_Object frame_with_minibuf
= Qnil
;
660 for (frames
= Vframe_list
;
662 frames
= XCONS (frames
)->cdr
)
664 Lisp_Object
this = XCONS (frames
)->car
;
666 if (XTYPE (this) != Lisp_Frame
)
670 if (FRAME_HAS_MINIBUF_P (f
))
672 frame_with_minibuf
= this;
673 if (FRAME_MINIBUF_ONLY_P (f
))
678 /* We know that there must be some frame with a minibuffer out
679 there. If this were not true, all of the frames present
680 would have to be minibufferless, which implies that at some
681 point their minibuffer frames must have been deleted, but
682 that is prohibited at the top; you can't delete surrogate
683 minibuffer frames. */
684 if (NILP (frame_with_minibuf
))
687 Vdefault_minibuffer_frame
= frame_with_minibuf
;
693 /* Return mouse position in character cell units. */
695 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
696 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
697 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
698 to read the mouse position, it returns the selected frame for FRAME\n\
699 and nil for X and Y.")
702 Lisp_Object x
, y
, dummy
;
705 if (mouse_position_hook
)
706 (*mouse_position_hook
) (&f
, &x
, &y
, &dummy
);
713 XSET (dummy
, Lisp_Frame
, f
);
714 return Fcons (dummy
, Fcons (make_number (x
), make_number (y
)));
717 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
718 "Move the mouse pointer to the center of cell (X,Y) in FRAME.\n\
719 WARNING: If you use this under X, you should do `unfocus-frame' afterwards.")
721 Lisp_Object frame
, x
, y
;
723 CHECK_LIVE_FRAME (frame
, 0);
727 #ifdef HAVE_X_WINDOWS
728 if (FRAME_X_P (XFRAME (frame
)))
729 /* Warping the mouse will cause enternotify and focus events. */
730 x_set_mouse_position (XFRAME (frame
), x
, y
);
737 /* ??? Can this be replaced with a Lisp function?
738 It is used in minibuf.c. Can we get rid of that?
739 Yes. All uses in minibuf.c are gone, and parallels to these
740 functions have been defined in frame.el. */
742 DEFUN ("frame-configuration", Fframe_configuration
, Sframe_configuration
,
744 "Return object describing current frame configuration.\n\
745 The frame configuration is the current mouse position and selected frame.\n\
746 This object can be given to `restore-frame-configuration'\n\
747 to restore this frame configuration.")
752 c
= Fmake_vector (make_number(4), Qnil
);
753 XVECTOR (c
)->contents
[0] = Fselected_frame();
754 if (mouse_position_hook
)
755 (*mouse_position_hook
) (&XVECTOR (c
)->contents
[1]
756 &XVECTOR (c
)->contents
[2],
757 &XVECTOR (c
)->contents
[3],
762 DEFUN ("restore-frame-configuration", Frestore_frame_configuration
,
763 Srestore_frame_configuration
,
765 "Restores frame configuration CONFIGURATION.")
769 Lisp_Object x_pos
, y_pos
, frame
;
771 CHECK_VECTOR (config
, 0);
772 if (XVECTOR (config
)->size
!= 3)
774 error ("Wrong size vector passed to restore-frame-configuration");
776 frame
= XVECTOR (config
)->contents
[0];
777 CHECK_LIVE_FRAME (frame
, 0);
779 Fselect_frame (frame
, Qnil
);
782 /* This seems to interfere with the frame selection mechanism. jla */
783 x_pos
= XVECTOR (config
)->contents
[2];
784 y_pos
= XVECTOR (config
)->contents
[3];
785 set_mouse_position (frame
, XINT (x_pos
), XINT (y_pos
));
792 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
794 "Make the frame FRAME visible (assuming it is an X-window).\n\
795 Also raises the frame so that nothing obscures it.\n\
796 If omitted, FRAME defaults to the currently selected frame.")
801 XSET (frame
, Lisp_Frame
, selected_frame
);
803 CHECK_LIVE_FRAME (frame
, 0);
805 #ifdef HAVE_X_WINDOWS
806 if (FRAME_X_P (XFRAME (frame
)))
807 x_make_frame_visible (XFRAME (frame
));
813 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
815 "Make the frame FRAME invisible (assuming it is an X-window).\n\
816 If omitted, FRAME defaults to the currently selected frame.")
821 XSET (frame
, Lisp_Frame
, selected_frame
);
823 CHECK_LIVE_FRAME (frame
, 0);
825 #ifdef HAVE_X_WINDOWS
826 if (FRAME_X_P (XFRAME (frame
)))
827 x_make_frame_invisible (XFRAME (frame
));
833 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
835 "Make the frame FRAME into an icon.\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_iconify_frame (XFRAME (frame
));
853 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
855 "Return t if FRAME is now \"visible\" (actually in use for display).\n\
856 A frame that is not \"visible\" is not updated and, if it works through\n\
857 a window system, it may not show at all.\n\
858 Return the symbol `icon' if frame is visible only as an icon.")
862 CHECK_LIVE_FRAME (frame
, 0);
864 if (XFRAME (frame
)->visible
)
866 if (XFRAME (frame
)->iconified
)
871 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
873 "Return a list of all frames now \"visible\" (being updated).")
876 Lisp_Object tail
, frame
;
881 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
883 frame
= XCONS (tail
)->car
;
884 if (XTYPE (frame
) != Lisp_Frame
)
888 value
= Fcons (frame
, value
);
895 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
897 "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
898 This means that, after reading a keystroke typed at FRAME,\n\
899 `last-event-frame' will be FOCUS-FRAME.\n\
901 If FOCUS-FRAME is omitted or eq to FRAME, any existing redirection is\n\
902 cancelled, and the frame again receives its own keystrokes.\n\
904 The redirection lasts until the next call to `redirect-frame-focus'\n\
905 or `select-frame'.\n\
907 This is useful for temporarily redirecting keystrokes to the minibuffer\n\
908 window when a frame doesn't have its own minibuffer.")
910 Lisp_Object frame
, focus_frame
;
912 CHECK_LIVE_FRAME (frame
, 0);
914 if (NILP (focus_frame
))
917 CHECK_LIVE_FRAME (focus_frame
, 1);
919 XFRAME (frame
)->focus_frame
= focus_frame
;
921 if (frame_rehighlight_hook
)
922 (*frame_rehighlight_hook
) ();
928 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
929 "Return the frame to which FRAME's keystrokes are currently being sent.\n\
930 See `redirect-frame-focus'.")
934 CHECK_LIVE_FRAME (frame
, 0);
935 return FRAME_FOCUS_FRAME (XFRAME (frame
));
941 get_frame_param (frame
, prop
)
942 register struct frame
*frame
;
945 register Lisp_Object tem
;
947 tem
= Fassq (prop
, frame
->param_alist
);
954 store_in_alist (alistptr
, prop
, val
)
955 Lisp_Object
*alistptr
, val
;
958 register Lisp_Object tem
;
960 tem
= Fassq (prop
, *alistptr
);
962 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
968 store_frame_param (f
, prop
, val
)
970 Lisp_Object prop
, val
;
972 register Lisp_Object tem
;
974 tem
= Fassq (prop
, f
->param_alist
);
976 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
980 if (EQ (prop
, Qminibuffer
)
981 && XTYPE (val
) == Lisp_Window
)
983 if (! MINI_WINDOW_P (XWINDOW (val
)))
984 error ("Surrogate minibuffer windows must be minibuffer windows.");
986 if (FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
987 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer.");
989 /* Install the chosen minibuffer window, with proper buffer. */
990 f
->minibuffer_window
= val
;
994 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
995 "Return the parameters-alist of frame FRAME.\n\
996 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
997 The meaningful PARMs depend on the kind of frame.\n\
998 If FRAME is omitted, return information on the currently selected frame.")
1005 if (EQ (frame
, Qnil
))
1009 CHECK_FRAME (frame
, 0);
1013 if (f
->display
.nothing
== 0)
1016 alist
= Fcopy_alist (f
->param_alist
);
1017 store_in_alist (&alist
, Qname
, f
->name
);
1018 store_in_alist (&alist
, Qheight
, make_number (f
->height
));
1019 store_in_alist (&alist
, Qwidth
, make_number (f
->width
));
1020 store_in_alist (&alist
, Qmodeline
, (f
->wants_modeline
? Qt
: Qnil
));
1021 store_in_alist (&alist
, Qminibuffer
,
1022 (! FRAME_HAS_MINIBUF_P (f
) ? Qnone
1023 : (FRAME_MINIBUF_ONLY_P (f
) ? Qonly
1024 : FRAME_MINIBUF_WINDOW (f
))));
1025 store_in_alist (&alist
, Qunsplittable
, (f
->no_split
? Qt
: Qnil
));
1027 #ifdef HAVE_X_WINDOWS
1029 x_report_frame_params (f
, &alist
);
1034 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
1035 Smodify_frame_parameters
, 2, 2, 0,
1036 "Modify the parameters of frame FRAME according to ALIST.\n\
1037 ALIST is an alist of parameters to change and their new values.\n\
1038 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
1039 The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
1041 Lisp_Object frame
, alist
;
1044 register Lisp_Object tail
, elt
, prop
, val
;
1046 if (EQ (frame
, Qnil
))
1050 CHECK_LIVE_FRAME (frame
, 0);
1054 #ifdef HAVE_X_WINDOWS
1057 x_set_frame_parameters (f
, alist
);
1059 for (tail
= alist
; !EQ (tail
, Qnil
); tail
= Fcdr (tail
))
1064 x_set_frame_param (f
, prop
, val
, get_frame_param (f
, prop
));
1065 store_frame_param (f
, prop
, val
);
1075 /* This function isn't useful enough by itself to include; we need to
1076 add functions to allow the user to find the size of a font before
1077 this is actually useful. */
1079 DEFUN ("frame-pixel-size", Fframe_pixel_size
,
1080 Sframe_pixel_size
, 1, 1, 0,
1081 "Return a cons (width . height) of FRAME's size in pixels.")
1085 register struct frame
*f
;
1088 CHECK_LIVE_FRAME (frame
, 0);
1091 return Fcons (make_number (x_pixel_width (f
)),
1092 make_number (x_pixel_height (f
)));
1097 /* These functions have no C callers, and can be written nicely in lisp. */
1099 DEFUN ("frame-height", Fframe_height
, Sframe_height
, 0, 0, 0,
1100 "Return number of lines available for display on selected frame.")
1103 return make_number (FRAME_HEIGHT (selected_frame
));
1106 DEFUN ("frame-width", Fframe_width
, Sframe_width
, 0, 0, 0,
1107 "Return number of columns available for display on selected frame.")
1110 return make_number (FRAME_WIDTH (selected_frame
));
1114 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1115 "Specify that the frame FRAME has LINES lines.\n\
1116 Optional third arg non-nil means that redisplay should use LINES lines\n\
1117 but that the idea of the actual height of the frame should not be changed.")
1118 (frame
, rows
, pretend
)
1119 Lisp_Object frame
, rows
, pretend
;
1121 register struct frame
*f
;
1123 CHECK_NUMBER (rows
, 0);
1128 CHECK_LIVE_FRAME (frame
, 0);
1132 #ifdef HAVE_X_WINDOWS
1135 if (XINT (rows
) != f
->width
)
1136 x_set_window_size (f
, f
->width
, XINT (rows
));
1140 change_frame_size (f
, XINT (rows
), 0, !NILP (pretend
), 0);
1144 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1145 "Specify that the frame FRAME has COLS columns.\n\
1146 Optional third arg non-nil means that redisplay should use COLS columns\n\
1147 but that the idea of the actual width of the frame should not be changed.")
1148 (frame
, cols
, pretend
)
1149 Lisp_Object frame
, cols
, pretend
;
1151 register struct frame
*f
;
1152 CHECK_NUMBER (cols
, 0);
1157 CHECK_LIVE_FRAME (frame
, 0);
1161 #ifdef HAVE_X_WINDOWS
1164 if (XINT (cols
) != f
->width
)
1165 x_set_window_size (f
, XINT (cols
), f
->height
);
1169 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0);
1173 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1174 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1176 Lisp_Object frame
, cols
, rows
;
1178 register struct frame
*f
;
1181 CHECK_LIVE_FRAME (frame
, 0);
1182 CHECK_NUMBER (cols
, 2);
1183 CHECK_NUMBER (rows
, 1);
1186 #ifdef HAVE_X_WINDOWS
1189 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
)
1190 x_set_window_size (f
, XINT (cols
), XINT (rows
));
1194 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0);
1199 DEFUN ("set-frame-position", Fset_frame_position
,
1200 Sset_frame_position
, 3, 3, 0,
1201 "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
1202 If XOFFSET or YOFFSET are negative, they are interpreted relative to\n\
1203 the leftmost or bottommost position FRAME could occupy without going\n\
1205 (frame
, xoffset
, yoffset
)
1206 Lisp_Object frame
, xoffset
, yoffset
;
1208 register struct frame
*f
;
1211 CHECK_LIVE_FRAME (frame
, 0);
1212 CHECK_NUMBER (xoffset
, 1);
1213 CHECK_NUMBER (yoffset
, 2);
1216 #ifdef HAVE_X_WINDOWS
1218 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
));
1226 DEFUN ("rubber-band-rectangle", Frubber_band_rectangle
, Srubber_band_rectangle
,
1228 "Ask user to specify a window position and size on FRAME with the mouse.\n\
1229 Arguments are FRAME, NAME and GEO. NAME is a name to be displayed as\n\
1230 the purpose of this rectangle. GEO is an X-windows size spec that can\n\
1231 specify defaults for some sizes/positions. If GEO specifies everything,\n\
1232 the mouse is not used.\n\
1233 Returns a list of five values: (FRAME LEFT TOP WIDTH HEIGHT).")
1240 Lisp_Object nums
[4];
1243 CHECK_FRAME (frame
, 0);
1244 CHECK_STRING (name
, 1);
1245 CHECK_STRING (geo
, 2);
1247 switch (XFRAME (frame
)->output_method
)
1249 case output_x_window
:
1250 x_rubber_band (XFRAME (frame
), &vals
[0], &vals
[1], &vals
[2], &vals
[3],
1251 XSTRING (geo
)->data
, XSTRING (name
)->data
);
1258 for (i
= 0; i
< 4; i
++)
1259 XFASTINT (nums
[i
]) = vals
[i
];
1260 return Fcons (frame
, Flist (4, nums
));
1263 #endif /* not HAVE_X11 */
1265 choose_minibuf_frame ()
1267 /* For lowest-level minibuf, put it on currently selected frame
1268 if frame has a minibuffer. */
1270 if (minibuf_level
== 0
1271 && selected_frame
!= 0
1272 && !EQ (minibuf_window
, selected_frame
->minibuffer_window
))
1274 /* I don't think that any frames may validly have a null minibuffer
1276 if (NILP (selected_frame
->minibuffer_window
))
1279 Fset_window_buffer (selected_frame
->minibuffer_window
,
1280 XWINDOW (minibuf_window
)->buffer
);
1281 minibuf_window
= selected_frame
->minibuffer_window
;
1287 /*&&& init symbols here &&&*/
1288 Qframep
= intern ("framep");
1289 staticpro (&Qframep
);
1290 Qlive_frame_p
= intern ("live-frame-p");
1291 staticpro (&Qlive_frame_p
);
1292 Qheight
= intern ("height");
1293 staticpro (&Qheight
);
1294 Qicon
= intern ("icon");
1296 Qminibuffer
= intern ("minibuffer");
1297 staticpro (&Qminibuffer
);
1298 Qmodeline
= intern ("modeline");
1299 staticpro (&Qmodeline
);
1300 Qname
= intern ("name");
1302 Qnone
= intern ("none");
1304 Qonly
= intern ("only");
1306 Qunsplittable
= intern ("unsplittable");
1307 staticpro (&Qunsplittable
);
1308 Qwidth
= intern ("width");
1309 staticpro (&Qwidth
);
1313 staticpro (&Vframe_list
);
1315 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
1316 "The initial frame-object, which represents Emacs's stdout.");
1318 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
1319 "Non-nil if all of emacs is iconified and frame updates are not needed.");
1320 Vemacs_iconified
= Qnil
;
1322 DEFVAR_LISP ("default-minibuffer-frame", &Vdefault_minibuffer_frame
,
1323 "Minibufferless frames use this frame's minibuffer.\n\
1325 Emacs cannot create minibufferless frames unless this is set to an\n\
1326 appropriate surrogate.\n\
1328 Emacs consults this variable only when creating minibufferless\n\
1329 frames; once the frame is created, it sticks with its assigned\n\
1330 minibuffer, no matter what this variable is set to. This means that\n\
1331 this variable doesn't necessarily say anything meaningful about the\n\
1332 current set of frames, or where the minibuffer is currently being\n\
1334 Vdefault_minibuffer_frame
= Qnil
;
1336 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
1337 "Alist of default values for frame creation.\n\
1338 These may be set in your init file, like this:\n\
1339 (setq default-frame-alist '((width . 80) (height . 55)))\n\
1340 These override values given in window system configuration data, like\n\
1341 X Windows' defaults database.\n\
1342 For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
1343 For values specific to the separate minibuffer frame, see\n\
1344 `minibuffer-frame-alist'.");
1345 Vdefault_frame_alist
= Qnil
;
1348 defsubr (&Slive_frame_p
);
1349 defsubr (&Sselect_frame
);
1350 defsubr (&Sselected_frame
);
1351 defsubr (&Swindow_frame
);
1352 defsubr (&Sframe_root_window
);
1353 defsubr (&Sframe_selected_window
);
1354 defsubr (&Sframe_list
);
1355 defsubr (&Snext_frame
);
1356 defsubr (&Sdelete_frame
);
1357 defsubr (&Smouse_position
);
1358 defsubr (&Sset_mouse_position
);
1360 defsubr (&Sframe_configuration
);
1361 defsubr (&Srestore_frame_configuration
);
1363 defsubr (&Smake_frame_visible
);
1364 defsubr (&Smake_frame_invisible
);
1365 defsubr (&Siconify_frame
);
1366 defsubr (&Sframe_visible_p
);
1367 defsubr (&Svisible_frame_list
);
1368 defsubr (&Sredirect_frame_focus
);
1369 defsubr (&Sframe_focus
);
1370 defsubr (&Sframe_parameters
);
1371 defsubr (&Smodify_frame_parameters
);
1373 defsubr (&Sframe_pixel_size
);
1374 defsubr (&Sframe_height
);
1375 defsubr (&Sframe_width
);
1377 defsubr (&Sset_frame_height
);
1378 defsubr (&Sset_frame_width
);
1379 defsubr (&Sset_frame_size
);
1380 defsubr (&Sset_frame_position
);
1382 defsubr (&Srubber_band_rectangle
);
1383 #endif /* HAVE_X11 */
1388 initial_define_lispy_key (global_map
, "switch-frame", "select-frame");
1391 #else /* not MULTI_FRAME */
1393 /* If we're not using multi-frame stuff, we still need to provide some
1394 support functions. */
1396 /* Unless this function is defined, providing set-frame-height and
1397 set-frame-width doesn't help compatibility any, since they both
1398 want this as their first argument. */
1399 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1400 "Return the frame that is now selected.")
1408 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1409 "Specify that the frame FRAME has LINES lines.\n\
1410 Optional third arg non-nil means that redisplay should use LINES lines\n\
1411 but that the idea of the actual height of the frame should not be changed.")
1412 (frame
, rows
, pretend
)
1413 Lisp_Object frame
, rows
, pretend
;
1415 CHECK_NUMBER (rows
, 0);
1417 change_frame_size (0, XINT (rows
), 0, !NILP (pretend
), 0);
1421 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1422 "Specify that the frame FRAME has COLS columns.\n\
1423 Optional third arg non-nil means that redisplay should use COLS columns\n\
1424 but that the idea of the actual width of the frame should not be changed.")
1425 (frame
, cols
, pretend
)
1426 Lisp_Object frame
, cols
, pretend
;
1428 CHECK_NUMBER (cols
, 0);
1430 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1434 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1435 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1437 Lisp_Object frame
, cols
, rows
;
1439 CHECK_NUMBER (cols
, 2);
1440 CHECK_NUMBER (rows
, 1);
1442 change_frame_size (0, XINT (rows
), XINT (cols
), 0, 0);
1447 DEFUN ("frame-height", Fframe_height
, Sframe_height
, 0, 0, 0,
1448 "Return number of lines available for display on selected frame.")
1451 return make_number (FRAME_HEIGHT (selected_frame
));
1454 DEFUN ("frame-width", Fframe_width
, Sframe_width
, 0, 0, 0,
1455 "Return number of columns available for display on selected frame.")
1458 return make_number (FRAME_WIDTH (selected_frame
));
1461 /* These are for backward compatibility with Emacs 18. */
1463 DEFUN ("set-screen-height", Fset_screen_height
, Sset_screen_height
, 1, 2, 0,
1464 "Tell redisplay that the screen has LINES lines.\n\
1465 Optional second arg non-nil means that redisplay should use LINES lines\n\
1466 but that the idea of the actual height of the screen should not be changed.")
1468 Lisp_Object lines
, pretend
;
1470 CHECK_NUMBER (lines
, 0);
1472 change_frame_size (0, XINT (lines
), 0, !NILP (pretend
), 0);
1476 DEFUN ("set-screen-width", Fset_screen_width
, Sset_screen_width
, 1, 2, 0,
1477 "Tell redisplay that the screen has COLS columns.\n\
1478 Optional second arg non-nil means that redisplay should use COLS columns\n\
1479 but that the idea of the actual width of the screen should not be changed.")
1481 Lisp_Object cols
, pretend
;
1483 CHECK_NUMBER (cols
, 0);
1485 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1491 defsubr (&Sset_frame_height
);
1492 defsubr (&Sset_frame_width
);
1493 defsubr (&Sset_frame_size
);
1494 defsubr (&Sset_screen_height
);
1495 defsubr (&Sset_screen_width
);
1496 defsubr (&Sframe_height
);
1497 Ffset (intern ("screen-height"), intern ("frame-height"));
1498 defsubr (&Sframe_width
);
1499 Ffset (intern ("screen-width"), intern ("frame-width"));
1506 #endif /* not MULTI_FRAME */