1 /* Generic frame functions.
2 Copyright (C) 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. */
25 #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 Qframe_live_p
;
80 Lisp_Object Qminibuffer
;
81 Lisp_Object Qmodeline
;
84 Lisp_Object Qunsplittable
;
85 Lisp_Object Qmenu_bar_lines
;
90 extern Lisp_Object Vminibuffer_list
;
91 extern Lisp_Object
get_minibuffer ();
92 extern Lisp_Object
Fhandle_switch_frame ();
93 extern Lisp_Object
Fredirect_frame_focus ();
95 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
96 "Return non-nil if OBJECT is a frame.\n\
97 Value is t for a termcap frame (a character-only terminal),\n\
98 `x' for an Emacs frame that is really an X window.\n\
99 Also see `live-frame-p'.")
103 if (XTYPE (object
) != Lisp_Frame
)
105 switch (XFRAME (object
)->output_method
)
109 case output_x_window
:
116 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
117 "Return non-nil if OBJECT is a frame which has not been deleted.\n\
118 Value is nil if OBJECT is not a live frame. If object is a live\n\
119 frame, the return value indicates what sort of output device it is\n\
120 displayed on. Value is t for a termcap frame (a character-only\n\
121 terminal), `x' for an Emacs frame being displayed in an X window.")
125 return ((FRAMEP (object
)
126 && FRAME_LIVE_P (XFRAME (object
)))
136 register struct frame
*f
;
137 register Lisp_Object root_window
;
138 register Lisp_Object mini_window
;
140 frame
= Fmake_vector (((sizeof (struct frame
) - (sizeof (Lisp_Vector
)
141 - sizeof (Lisp_Object
)))
142 / sizeof (Lisp_Object
)),
144 XSETTYPE (frame
, Lisp_Frame
);
149 f
->current_glyphs
= 0;
150 f
->desired_glyphs
= 0;
152 f
->async_visible
= 0;
153 f
->display
.nothing
= 0;
155 f
->async_iconified
= 0;
156 f
->wants_modeline
= 1;
161 f
->has_minibuffer
= mini_p
;
162 f
->focus_frame
= Qnil
;
163 f
->explicit_name
= 0;
164 f
->can_have_scroll_bars
= 0;
165 f
->has_vertical_scroll_bars
= 0;
166 f
->param_alist
= Qnil
;
167 f
->scroll_bars
= Qnil
;
168 f
->condemned_scroll_bars
= Qnil
;
169 f
->face_alist
= Qnil
;
170 f
->menu_bar_items
= Qnil
;
172 root_window
= make_window ();
175 mini_window
= make_window ();
176 XWINDOW (root_window
)->next
= mini_window
;
177 XWINDOW (mini_window
)->prev
= root_window
;
178 XWINDOW (mini_window
)->mini_p
= Qt
;
179 XWINDOW (mini_window
)->frame
= frame
;
180 f
->minibuffer_window
= mini_window
;
185 XWINDOW (root_window
)->next
= Qnil
;
186 f
->minibuffer_window
= Qnil
;
189 XWINDOW (root_window
)->frame
= frame
;
192 just so that there is "something there."
193 Correct size will be set up later with change_frame_size. */
198 XFASTINT (XWINDOW (root_window
)->width
) = 10;
199 XFASTINT (XWINDOW (root_window
)->height
) = (mini_p
? 9 : 10);
203 XFASTINT (XWINDOW (mini_window
)->width
) = 10;
204 XFASTINT (XWINDOW (mini_window
)->top
) = 9;
205 XFASTINT (XWINDOW (mini_window
)->height
) = 1;
208 /* Choose a buffer for the frame's root window. */
212 XWINDOW (root_window
)->buffer
= Qt
;
213 buf
= Fcurrent_buffer ();
214 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
215 a space), try to find another one. */
216 if (XSTRING (Fbuffer_name (buf
))->data
[0] == ' ')
217 buf
= Fother_buffer (buf
, Qnil
);
218 Fset_window_buffer (root_window
, buf
);
223 XWINDOW (mini_window
)->buffer
= Qt
;
224 Fset_window_buffer (mini_window
,
225 (NILP (Vminibuffer_list
)
227 : Fcar (Vminibuffer_list
)));
230 f
->root_window
= root_window
;
231 f
->selected_window
= root_window
;
232 /* Make sure this window seems more recently used than
233 a newly-created, never-selected window. */
234 XFASTINT (XWINDOW (f
->selected_window
)->use_time
) = ++window_select_count
;
239 /* Make a frame using a separate minibuffer window on another frame.
240 MINI_WINDOW is the minibuffer window to use. nil means use the
241 default (the global minibuffer). */
244 make_frame_without_minibuffer (mini_window
)
245 register Lisp_Object mini_window
;
247 register struct frame
*f
;
249 /* Choose the minibuffer window to use. */
250 if (NILP (mini_window
))
252 if (XTYPE (Vdefault_minibuffer_frame
) != Lisp_Frame
)
253 error ("default-minibuffer-frame must be set when creating minibufferless frames");
254 if (! FRAME_LIVE_P (XFRAME (Vdefault_minibuffer_frame
)))
255 error ("default-minibuffer-frame must be a live frame");
256 mini_window
= XFRAME (Vdefault_minibuffer_frame
)->minibuffer_window
;
260 CHECK_LIVE_WINDOW (mini_window
, 0);
263 /* Make a frame containing just a root window. */
266 /* Install the chosen minibuffer window, with proper buffer. */
267 f
->minibuffer_window
= mini_window
;
268 Fset_window_buffer (mini_window
,
269 (NILP (Vminibuffer_list
)
271 : Fcar (Vminibuffer_list
)));
275 /* Make a frame containing only a minibuffer window. */
278 make_minibuffer_frame ()
280 /* First make a frame containing just a root window, no minibuffer. */
282 register struct frame
*f
= make_frame (0);
283 register Lisp_Object mini_window
;
284 register Lisp_Object frame
;
286 XSET (frame
, Lisp_Frame
, f
);
291 f
->wants_modeline
= 0;
292 f
->has_minibuffer
= 1;
294 /* Now label the root window as also being the minibuffer.
295 Avoid infinite looping on the window chain by marking next pointer
298 mini_window
= f
->minibuffer_window
= f
->root_window
;
299 XWINDOW (mini_window
)->mini_p
= Qt
;
300 XWINDOW (mini_window
)->next
= Qnil
;
301 XWINDOW (mini_window
)->prev
= Qnil
;
302 XWINDOW (mini_window
)->frame
= frame
;
304 /* Put the proper buffer in that window. */
306 Fset_window_buffer (mini_window
,
307 (NILP (Vminibuffer_list
)
309 : Fcar (Vminibuffer_list
)));
313 /* Construct a frame that refers to the terminal (stdin and stdout). */
316 make_terminal_frame ()
318 register struct frame
*f
;
324 XSET (frame
, Lisp_Frame
, f
);
325 Vframe_list
= Fcons (frame
, Vframe_list
);
327 f
->name
= build_string ("terminal");
328 FRAME_SET_VISIBLE (f
, 1);
329 f
->display
.nothing
= 1; /* Nonzero means frame isn't deleted. */
330 XSET (Vterminal_frame
, Lisp_Frame
, f
);
335 do_switch_frame (frame
, no_enter
, track
)
336 Lisp_Object frame
, no_enter
;
339 /* If FRAME is a switch-frame event, extract the frame we should
342 && EQ (XCONS (frame
)->car
, Qswitch_frame
)
343 && CONSP (XCONS (frame
)->cdr
))
344 frame
= XCONS (XCONS (frame
)->cdr
)->car
;
346 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
347 a switch-frame event to arrive after a frame is no longer live,
348 especially when deleting the initial frame during startup. */
349 CHECK_FRAME (frame
, 0);
350 if (! FRAME_LIVE_P (XFRAME (frame
)))
353 if (selected_frame
== XFRAME (frame
))
356 /* This is too greedy; it causes inappropriate focus redirection
357 that's hard to get rid of. */
359 /* If a frame's focus has been redirected toward the currently
360 selected frame, we should change the redirection to point to the
361 newly selected frame. This means that if the focus is redirected
362 from a minibufferless frame to a surrogate minibuffer frame, we
363 can use `other-window' to switch between all the frames using
364 that minibuffer frame, and the focus redirection will follow us
370 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
374 if (XTYPE (XCONS (tail
)->car
) != Lisp_Frame
)
377 focus
= FRAME_FOCUS_FRAME (XFRAME (XCONS (tail
)->car
));
379 if (XTYPE (focus
) == Lisp_Frame
380 && XFRAME (focus
) == selected_frame
)
381 Fredirect_frame_focus (XCONS (tail
)->car
, frame
);
385 /* Instead, apply it only to the frame we're pointing to. */
386 #ifdef HAVE_X_WINDOWS
389 Lisp_Object focus
, xfocus
;
391 xfocus
= x_get_focus_frame ();
394 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
395 if (FRAMEP (focus
) && XFRAME (focus
) == selected_frame
)
396 Fredirect_frame_focus (xfocus
, frame
);
399 #endif /* HAVE_X_WINDOWS */
402 selected_frame
= XFRAME (frame
);
403 if (! FRAME_MINIBUF_ONLY_P (selected_frame
))
404 last_nonminibuf_frame
= selected_frame
;
406 Fselect_window (XFRAME (frame
)->selected_window
);
407 choose_minibuf_frame ();
409 /* We want to make sure that the next event generates a frame-switch
410 event to the appropriate frame. This seems kludgy to me, but
411 before you take it out, make sure that evaluating something like
412 (select-window (frame-root-window (new-frame))) doesn't end up
413 with your typing being interpreted in the new frame instead of
414 the one you're actually typing in. */
415 internal_last_event_frame
= Qnil
;
420 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
421 "Select the frame FRAME.\n\
422 Subsequent editing commands apply to its selected window.\n\
423 The selection of FRAME lasts until the next time the user does\n\
424 something to select a different frame, or until the next time this\n\
425 function is called.")
427 Lisp_Object frame
, no_enter
;
429 return do_switch_frame (frame
, no_enter
, 1);
433 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 2, "e",
434 "Handle a switch-frame event EVENT.\n\
435 Switch-frame events are usually bound to this function.\n\
436 A switch-frame event tells Emacs that the window manager has requested\n\
437 that the user's events be directed to the frame mentioned in the event.\n\
438 This function selects the selected window of the frame of EVENT.\n\
440 If EVENT is frame object, handle it as if it were a switch-frame event\n\
443 Lisp_Object frame
, no_enter
;
445 return do_switch_frame (frame
, no_enter
, 0);
449 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
450 "Return the frame that is now selected.")
454 XSET (tem
, Lisp_Frame
, selected_frame
);
458 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
459 "Return the frame object that window WINDOW is on.")
463 CHECK_LIVE_WINDOW (window
, 0);
464 return XWINDOW (window
)->frame
;
467 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
468 "Returns the topmost, leftmost window of FRAME.\n\
469 If omitted, FRAME defaults to the currently selected frame.")
476 w
= selected_frame
->root_window
;
479 CHECK_LIVE_FRAME (frame
, 0);
480 w
= XFRAME (frame
)->root_window
;
482 while (NILP (XWINDOW (w
)->buffer
))
484 if (! NILP (XWINDOW (w
)->hchild
))
485 w
= XWINDOW (w
)->hchild
;
486 else if (! NILP (XWINDOW (w
)->vchild
))
487 w
= XWINDOW (w
)->vchild
;
494 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
495 "Returns the root-window of FRAME.\n\
496 If omitted, FRAME defaults to the currently selected frame.")
501 XSET (frame
, Lisp_Frame
, selected_frame
);
503 CHECK_LIVE_FRAME (frame
, 0);
505 return XFRAME (frame
)->root_window
;
508 DEFUN ("frame-selected-window", Fframe_selected_window
,
509 Sframe_selected_window
, 0, 1, 0,
510 "Return the selected window of frame object FRAME.\n\
511 If omitted, FRAME defaults to the currently selected frame.")
516 XSET (frame
, Lisp_Frame
, selected_frame
);
518 CHECK_LIVE_FRAME (frame
, 0);
520 return XFRAME (frame
)->selected_window
;
523 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
525 "Return a list of all frames.")
528 return Fcopy_sequence (Vframe_list
);
531 /* Return the next frame in the frame list after FRAME.
532 If MINIBUF is nil, exclude minibuffer-only frames.
533 If MINIBUF is a window, include only frames using that window for
535 If MINIBUF is `visible', include all visible frames.
536 Otherwise, include all frames. */
539 next_frame (frame
, minibuf
)
546 /* There must always be at least one frame in Vframe_list. */
547 if (! CONSP (Vframe_list
))
550 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
551 forever. Forestall that. */
552 CHECK_LIVE_FRAME (frame
, 0);
555 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
559 f
= XCONS (tail
)->car
;
562 /* Decide whether this frame is eligible to be returned. */
564 /* If we've looped all the way around without finding any
565 eligible frames, return the original frame. */
569 /* Let minibuf decide if this frame is acceptable. */
572 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
575 else if (EQ (minibuf
, Qvisible
))
577 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
578 if (FRAME_VISIBLE_P (XFRAME (f
)))
581 else if (WINDOWP (minibuf
))
583 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
))
595 /* Return the previous frame in the frame list before FRAME.
596 If MINIBUF is nil, exclude minibuffer-only frames.
597 If MINIBUF is a window, include only frames using that window for
599 If MINIBUF is `visible', include all visible frames.
600 Otherwise, include all frames. */
603 prev_frame (frame
, minibuf
)
610 /* There must always be at least one frame in Vframe_list. */
611 if (! CONSP (Vframe_list
))
615 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
619 f
= XCONS (tail
)->car
;
620 if (XTYPE (f
) != Lisp_Frame
)
623 if (EQ (frame
, f
) && !NILP (prev
))
626 /* Decide whether this frame is eligible to be returned,
627 according to minibuf. */
630 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
633 else if (XTYPE (minibuf
) == Lisp_Window
)
635 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
))
638 else if (EQ (minibuf
, Qvisible
))
640 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
641 if (FRAME_VISIBLE_P (XFRAME (f
)))
648 /* We've scanned the entire list. */
650 /* We went through the whole frame list without finding a single
651 acceptable frame. Return the original frame. */
654 /* There were no acceptable frames in the list before FRAME; otherwise,
655 we would have returned directly from the loop. Since PREV is the last
656 acceptable frame in the list, return it. */
661 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
662 "Return the next frame in the frame list after FRAME.\n\
663 By default, skip minibuffer-only frames.\n\
664 If omitted, FRAME defaults to the selected frame.\n\
665 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
666 If MINIFRAME is a window, include only frames using that window for their\n\
668 If MINIFRAME is `visible', include all visible frames.\n\
669 Otherwise, include all frames.")
671 Lisp_Object frame
, miniframe
;
676 XSET (frame
, Lisp_Frame
, selected_frame
);
678 CHECK_LIVE_FRAME (frame
, 0);
680 return next_frame (frame
, miniframe
);
683 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
684 "Return the previous frame in the frame list before FRAME.\n\
685 By default, skip minibuffer-only frames.\n\
686 If omitted, FRAME defaults to the selected frame.\n\
687 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
688 If MINIFRAME is a window, include only frames using that window for their\n\
690 If MINIFRAME is `visible', include all visible frames.\n\
691 Otherwise, include all frames.")
693 Lisp_Object frame
, miniframe
;
698 XSET (frame
, Lisp_Frame
, selected_frame
);
700 CHECK_LIVE_FRAME (frame
, 0);
702 return prev_frame (frame
, miniframe
);
705 /* Return 1 if it is ok to delete frame F;
706 0 if all frames aside from F are invisible.
707 (Exception: if F is the terminal frame, and we are using X, return 1.) */
710 other_visible_frames (f
)
713 /* We know the selected frame is visible,
714 so if F is some other frame, it can't be the sole visible one. */
715 if (f
== selected_frame
)
720 for (frames
= Vframe_list
;
722 frames
= XCONS (frames
)->cdr
)
726 this = XCONS (frames
)->car
;
727 /* Verify that the frame's window still exists
728 and we can still talk to it. And note any recent change
730 #ifdef HAVE_X_WINDOWS
731 if (FRAME_X_P (XFRAME (this)))
734 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
738 if (FRAME_VISIBLE_P (XFRAME (this))
739 || FRAME_ICONIFIED_P (XFRAME (this))
740 /* Allow deleting the terminal frame when at least
741 one X frame exists! */
742 || (FRAME_X_P (XFRAME (this)) && !FRAME_X_P (f
)))
750 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
751 "Delete FRAME, permanently eliminating it from use.\n\
752 If omitted, FRAME defaults to the selected frame.\n\
753 A frame may not be deleted if its minibuffer is used by other frames.\n\
754 Normally, you may not delete a frame if all other frames are invisible,\n\
755 but if the second optional argument FORCE is non-nil, you may do so.")
757 Lisp_Object frame
, force
;
761 if (EQ (frame
, Qnil
))
764 XSET (frame
, Lisp_Frame
, f
);
768 CHECK_FRAME (frame
, 0);
772 if (! FRAME_LIVE_P (f
))
775 if (NILP (force
) && !other_visible_frames (f
))
776 error ("Attempt to delete the sole visible or iconified frame");
778 /* Does this frame have a minibuffer, and is it the surrogate
779 minibuffer for any other frame? */
780 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
784 for (frames
= Vframe_list
;
786 frames
= XCONS (frames
)->cdr
)
789 this = XCONS (frames
)->car
;
791 if (! EQ (this, frame
)
793 WINDOW_FRAME (XWINDOW
794 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
795 error ("Attempt to delete a surrogate minibuffer frame");
799 /* Don't let the frame remain selected. */
800 if (f
== selected_frame
)
801 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
803 /* Don't allow minibuf_window to remain on a deleted frame. */
804 if (EQ (f
->minibuffer_window
, minibuf_window
))
806 Fset_window_buffer (selected_frame
->minibuffer_window
,
807 XWINDOW (minibuf_window
)->buffer
);
808 minibuf_window
= selected_frame
->minibuffer_window
;
811 /* Mark all the windows that used to be on FRAME as deleted, and then
812 remove the reference to them. */
813 delete_all_subwindows (XWINDOW (f
->root_window
));
814 f
->root_window
= Qnil
;
816 Vframe_list
= Fdelq (frame
, Vframe_list
);
817 FRAME_SET_VISIBLE (f
, 0);
819 /* Since some events are handled at the interrupt level, we may get
820 an event for f at any time; if we zero out the frame's display
821 now, then we may trip up the event-handling code. Instead, we'll
822 promise that the display of the frame must be valid until we have
823 called the window-system-dependent frame destruction routine. */
825 /* I think this should be done with a hook. */
826 #ifdef HAVE_X_WINDOWS
828 x_destroy_window (f
);
831 f
->display
.nothing
= 0;
833 /* If we've deleted the last_nonminibuf_frame, then try to find
835 if (f
== last_nonminibuf_frame
)
839 last_nonminibuf_frame
= 0;
841 for (frames
= Vframe_list
;
843 frames
= XCONS (frames
)->cdr
)
845 f
= XFRAME (XCONS (frames
)->car
);
846 if (!FRAME_MINIBUF_ONLY_P (f
))
848 last_nonminibuf_frame
= f
;
854 /* If we've deleted Vdefault_minibuffer_frame, try to find another
855 one. Prefer minibuffer-only frames, but also notice frames
856 with other windows. */
857 if (EQ (frame
, Vdefault_minibuffer_frame
))
861 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
862 Lisp_Object frame_with_minibuf
;
864 frame_with_minibuf
= Qnil
;
865 for (frames
= Vframe_list
;
867 frames
= XCONS (frames
)->cdr
)
871 this = XCONS (frames
)->car
;
872 if (XTYPE (this) != Lisp_Frame
)
876 if (FRAME_HAS_MINIBUF_P (f
))
878 frame_with_minibuf
= this;
879 if (FRAME_MINIBUF_ONLY_P (f
))
884 /* We know that there must be some frame with a minibuffer out
885 there. If this were not true, all of the frames present
886 would have to be minibufferless, which implies that at some
887 point their minibuffer frames must have been deleted, but
888 that is prohibited at the top; you can't delete surrogate
889 minibuffer frames. */
890 if (NILP (frame_with_minibuf
))
893 Vdefault_minibuffer_frame
= frame_with_minibuf
;
899 /* Return mouse position in character cell units. */
901 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
902 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
903 The position is given in character cells, where (0, 0) is the\n\
904 upper-left corner.\n\
905 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
906 to read the mouse position, it returns the selected frame for FRAME\n\
907 and nil for X and Y.")
911 Lisp_Object lispy_dummy
;
912 enum scroll_bar_part party_dummy
;
915 unsigned long long_dummy
;
920 /* It's okay for the hook to refrain from storing anything. */
921 if (mouse_position_hook
)
922 (*mouse_position_hook
) (&f
,
923 &lispy_dummy
, &party_dummy
,
930 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, 0, 1);
934 XSET (lispy_dummy
, Lisp_Frame
, f
);
935 return Fcons (lispy_dummy
, Fcons (x
, y
));
938 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
939 Smouse_pixel_position
, 0, 0, 0,
940 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
941 The position is given in pixel units, where (0, 0) is the\n\
942 upper-left corner.\n\
943 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
944 to read the mouse position, it returns the selected frame for FRAME\n\
945 and nil for X and Y.")
949 Lisp_Object lispy_dummy
;
950 enum scroll_bar_part party_dummy
;
953 unsigned long long_dummy
;
958 /* It's okay for the hook to refrain from storing anything. */
959 if (mouse_position_hook
)
960 (*mouse_position_hook
) (&f
,
961 &lispy_dummy
, &party_dummy
,
964 XSET (lispy_dummy
, Lisp_Frame
, f
);
965 return Fcons (lispy_dummy
, Fcons (x
, y
));
968 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
969 "Move the mouse pointer to the center of character cell (X,Y) in FRAME.\n\
970 WARNING: If you use this under X windows,\n\
971 you should call `unfocus-frame' afterwards.")
973 Lisp_Object frame
, x
, y
;
975 CHECK_LIVE_FRAME (frame
, 0);
979 /* I think this should be done with a hook. */
980 #ifdef HAVE_X_WINDOWS
981 if (FRAME_X_P (XFRAME (frame
)))
982 /* Warping the mouse will cause enternotify and focus events. */
983 x_set_mouse_position (XFRAME (frame
), x
, y
);
989 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
990 Sset_mouse_pixel_position
, 3, 3, 0,
991 "Move the mouse pointer to pixel position (X,Y) in FRAME.\n\
992 WARNING: If you use this under X windows,\n\
993 you should call `unfocus-frame' afterwards.")
995 Lisp_Object frame
, x
, y
;
997 CHECK_LIVE_FRAME (frame
, 0);
1001 /* I think this should be done with a hook. */
1002 #ifdef HAVE_X_WINDOWS
1003 if (FRAME_X_P (XFRAME (frame
)))
1004 /* Warping the mouse will cause enternotify and focus events. */
1005 x_set_mouse_pixel_position (XFRAME (frame
), x
, y
);
1011 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1013 "Make the frame FRAME visible (assuming it is an X-window).\n\
1014 If omitted, FRAME defaults to the currently selected frame.")
1019 XSET (frame
, Lisp_Frame
, selected_frame
);
1021 CHECK_LIVE_FRAME (frame
, 0);
1023 /* I think this should be done with a hook. */
1024 #ifdef HAVE_X_WINDOWS
1025 if (FRAME_X_P (XFRAME (frame
)))
1027 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1028 x_make_frame_visible (XFRAME (frame
));
1035 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1037 "Make the frame FRAME invisible (assuming it is an X-window).\n\
1038 If omitted, FRAME defaults to the currently selected frame.\n\
1039 Normally you may not make FRAME invisible if all other frames are invisible,\n\
1040 but if the second optional argument FORCE is non-nil, you may do so.")
1042 Lisp_Object frame
, force
;
1045 XSET (frame
, Lisp_Frame
, selected_frame
);
1047 CHECK_LIVE_FRAME (frame
, 0);
1049 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1050 error ("Attempt to make invisible the sole visible or iconified frame");
1052 /* Don't let the frame remain selected. */
1053 if (XFRAME (frame
) == selected_frame
)
1054 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1056 /* Don't allow minibuf_window to remain on a deleted frame. */
1057 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1059 Fset_window_buffer (selected_frame
->minibuffer_window
,
1060 XWINDOW (minibuf_window
)->buffer
);
1061 minibuf_window
= selected_frame
->minibuffer_window
;
1064 /* I think this should be done with a hook. */
1065 #ifdef HAVE_X_WINDOWS
1066 if (FRAME_X_P (XFRAME (frame
)))
1067 x_make_frame_invisible (XFRAME (frame
));
1073 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1075 "Make the frame FRAME into an icon.\n\
1076 If omitted, FRAME defaults to the currently selected frame.")
1081 XSET (frame
, Lisp_Frame
, selected_frame
);
1083 CHECK_LIVE_FRAME (frame
, 0);
1085 /* Don't let the frame remain selected. */
1086 if (XFRAME (frame
) == selected_frame
)
1087 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1089 /* Don't allow minibuf_window to remain on a deleted frame. */
1090 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1092 Fset_window_buffer (selected_frame
->minibuffer_window
,
1093 XWINDOW (minibuf_window
)->buffer
);
1094 minibuf_window
= selected_frame
->minibuffer_window
;
1097 /* I think this should be done with a hook. */
1098 #ifdef HAVE_X_WINDOWS
1099 if (FRAME_X_P (XFRAME (frame
)))
1100 x_iconify_frame (XFRAME (frame
));
1106 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1108 "Return t if FRAME is now \"visible\" (actually in use for display).\n\
1109 A frame that is not \"visible\" is not updated and, if it works through\n\
1110 a window system, it may not show at all.\n\
1111 Return the symbol `icon' if frame is visible only as an icon.")
1115 CHECK_LIVE_FRAME (frame
, 0);
1117 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1119 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1121 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1126 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1128 "Return a list of all frames now \"visible\" (being updated).")
1131 Lisp_Object tail
, frame
;
1136 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
1138 frame
= XCONS (tail
)->car
;
1139 if (XTYPE (frame
) != Lisp_Frame
)
1142 if (FRAME_VISIBLE_P (f
))
1143 value
= Fcons (frame
, value
);
1149 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 1, 1, 0,
1150 "Bring FRAME to the front, so it occludes any frames it overlaps.\n\
1151 If FRAME is invisible, make it visible.\n\
1152 If Emacs is displaying on an ordinary terminal or some other device which\n\
1153 doesn't support multiple overlapping frames, this function does nothing.")
1157 CHECK_LIVE_FRAME (frame
, 0);
1159 /* Do like the documentation says. */
1160 Fmake_frame_visible (frame
);
1162 if (frame_raise_lower_hook
)
1163 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1168 /* Should we have a corresponding function called Flower_Power? */
1169 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 1, 1, 0,
1170 "Send FRAME to the back, so it is occluded by any frames that overlap it.\n\
1171 If Emacs is displaying on an ordinary terminal or some other device which\n\
1172 doesn't support multiple overlapping frames, this function does nothing.")
1176 CHECK_LIVE_FRAME (frame
, 0);
1178 if (frame_raise_lower_hook
)
1179 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1185 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1187 "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
1188 In other words, switch-frame events caused by events in FRAME will\n\
1189 request a switch to FOCUS-FRAME, and `last-event-frame' will be\n\
1190 FOCUS-FRAME after reading an event typed at FRAME.\n\
1192 If FOCUS-FRAME is omitted or nil, any existing redirection is\n\
1193 cancelled, and the frame again receives its own keystrokes.\n\
1195 Focus redirection is useful for temporarily redirecting keystrokes to\n\
1196 a surrogate minibuffer frame when a frame doesn't have its own\n\
1197 minibuffer window.\n\
1199 A frame's focus redirection can be changed by select-frame. If frame\n\
1200 FOO is selected, and then a different frame BAR is selected, any\n\
1201 frames redirecting their focus to FOO are shifted to redirect their\n\
1202 focus to BAR. This allows focus redirection to work properly when the\n\
1203 user switches from one frame to another using `select-window'.\n\
1205 This means that a frame whose focus is redirected to itself is treated\n\
1206 differently from a frame whose focus is redirected to nil; the former\n\
1207 is affected by select-frame, while the latter is not.\n\
1209 The redirection lasts until `redirect-frame-focus' is called to change it.")
1210 (frame
, focus_frame
)
1211 Lisp_Object frame
, focus_frame
;
1213 /* Note that we don't check for a live frame here. It's reasonable
1214 to redirect the focus of a frame you're about to delete, if you
1215 know what other frame should receive those keystrokes. */
1216 CHECK_FRAME (frame
, 0);
1218 if (! NILP (focus_frame
))
1219 CHECK_LIVE_FRAME (focus_frame
, 1);
1221 XFRAME (frame
)->focus_frame
= focus_frame
;
1223 /* I think this should be done with a hook. */
1224 #ifdef HAVE_X_WINDOWS
1225 if (!NILP (focus_frame
) && ! EQ (focus_frame
, frame
)
1226 && FRAME_X_P (XFRAME (focus_frame
)))
1227 Ffocus_frame (focus_frame
);
1230 if (frame_rehighlight_hook
)
1231 (*frame_rehighlight_hook
) ();
1237 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1238 "Return the frame to which FRAME's keystrokes are currently being sent.\n\
1239 This returns nil if FRAME's focus is not redirected.\n\
1240 See `redirect-frame-focus'.")
1244 CHECK_LIVE_FRAME (frame
, 0);
1246 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1252 get_frame_param (frame
, prop
)
1253 register struct frame
*frame
;
1256 register Lisp_Object tem
;
1258 tem
= Fassq (prop
, frame
->param_alist
);
1265 store_in_alist (alistptr
, prop
, val
)
1266 Lisp_Object
*alistptr
, val
;
1269 register Lisp_Object tem
;
1271 tem
= Fassq (prop
, *alistptr
);
1273 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1279 store_frame_param (f
, prop
, val
)
1281 Lisp_Object prop
, val
;
1283 register Lisp_Object tem
;
1285 tem
= Fassq (prop
, f
->param_alist
);
1287 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
1291 if (EQ (prop
, Qminibuffer
)
1292 && XTYPE (val
) == Lisp_Window
)
1294 if (! MINI_WINDOW_P (XWINDOW (val
)))
1295 error ("Surrogate minibuffer windows must be minibuffer windows.");
1297 if (FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
1298 error ("can't change the surrogate minibuffer of a frame with its own minibuffer");
1300 /* Install the chosen minibuffer window, with proper buffer. */
1301 f
->minibuffer_window
= val
;
1305 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
1306 "Return the parameters-alist of frame FRAME.\n\
1307 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
1308 The meaningful PARMs depend on the kind of frame.\n\
1309 If FRAME is omitted, return information on the currently selected frame.")
1316 if (EQ (frame
, Qnil
))
1320 CHECK_FRAME (frame
, 0);
1324 if (f
->display
.nothing
== 0)
1327 alist
= Fcopy_alist (f
->param_alist
);
1328 store_in_alist (&alist
, Qname
, f
->name
);
1329 store_in_alist (&alist
, Qheight
, make_number (f
->height
));
1330 store_in_alist (&alist
, Qwidth
, make_number (f
->width
));
1331 store_in_alist (&alist
, Qmodeline
, (f
->wants_modeline
? Qt
: Qnil
));
1332 store_in_alist (&alist
, Qminibuffer
,
1333 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
1334 : (FRAME_MINIBUF_ONLY_P (f
) ? Qonly
1335 : FRAME_MINIBUF_WINDOW (f
))));
1336 store_in_alist (&alist
, Qunsplittable
, (f
->no_split
? Qt
: Qnil
));
1337 store_in_alist (&alist
, Qmenu_bar_lines
, (FRAME_MENU_BAR_LINES (f
)));
1339 /* I think this should be done with a hook. */
1340 #ifdef HAVE_X_WINDOWS
1342 x_report_frame_params (f
, &alist
);
1347 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
1348 Smodify_frame_parameters
, 2, 2, 0,
1349 "Modify the parameters of frame FRAME according to ALIST.\n\
1350 ALIST is an alist of parameters to change and their new values.\n\
1351 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
1352 The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
1354 Lisp_Object frame
, alist
;
1357 register Lisp_Object tail
, elt
, prop
, val
;
1359 if (EQ (frame
, Qnil
))
1363 CHECK_LIVE_FRAME (frame
, 0);
1367 /* I think this should be done with a hook. */
1368 #ifdef HAVE_X_WINDOWS
1371 x_set_frame_parameters (f
, alist
);
1373 for (tail
= alist
; !EQ (tail
, Qnil
); tail
= Fcdr (tail
))
1378 x_set_frame_param (f
, prop
, val
, get_frame_param (f
, prop
));
1379 store_frame_param (f
, prop
, val
);
1387 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
1389 "Height in pixels of a line in the font in frame FRAME.\n\
1390 If FRAME is omitted, the selected frame is used.\n\
1391 For a terminal frame, the value is always 1.")
1401 CHECK_FRAME (frame
, 0);
1405 #ifdef HAVE_X_WINDOWS
1407 return make_number (x_char_height (f
));
1410 return make_number (1);
1414 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
1416 "Width in pixels of characters in the font in frame FRAME.\n\
1417 If FRAME is omitted, the selected frame is used.\n\
1418 The width is the same for all characters, because\n\
1419 currently Emacs supports only fixed-width fonts.\n\
1420 For a terminal screen, the value is always 1.")
1430 CHECK_FRAME (frame
, 0);
1434 #ifdef HAVE_X_WINDOWS
1436 return make_number (x_char_width (f
));
1439 return make_number (1);
1442 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
1443 Sframe_pixel_height
, 0, 1, 0,
1444 "Return a FRAME's height in pixels.\n\
1445 For a terminal frame, the result really gives the height in characters.\n\
1446 If FRAME is omitted, the selected frame is used.")
1456 CHECK_FRAME (frame
, 0);
1460 #ifdef HAVE_X_WINDOWS
1462 return make_number (x_pixel_height (f
));
1465 return make_number (FRAME_HEIGHT (f
));
1468 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
1469 Sframe_pixel_width
, 0, 1, 0,
1470 "Return FRAME's width in pixels.\n\
1471 For a terminal frame, the result really gives the width in characters.\n\
1472 If FRAME is omitted, the selected frame is used.")
1482 CHECK_FRAME (frame
, 0);
1486 #ifdef HAVE_X_WINDOWS
1488 return make_number (x_pixel_width (f
));
1491 return make_number (FRAME_WIDTH (f
));
1494 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1495 "Specify that the frame FRAME has LINES lines.\n\
1496 Optional third arg non-nil means that redisplay should use LINES lines\n\
1497 but that the idea of the actual height of the frame should not be changed.")
1498 (frame
, rows
, pretend
)
1499 Lisp_Object frame
, rows
, pretend
;
1501 register struct frame
*f
;
1503 CHECK_NUMBER (rows
, 0);
1508 CHECK_LIVE_FRAME (frame
, 0);
1512 /* I think this should be done with a hook. */
1513 #ifdef HAVE_X_WINDOWS
1516 if (XINT (rows
) != f
->width
)
1517 x_set_window_size (f
, 1, f
->width
, XINT (rows
));
1521 change_frame_size (f
, XINT (rows
), 0, !NILP (pretend
), 0);
1525 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1526 "Specify that the frame FRAME has COLS columns.\n\
1527 Optional third arg non-nil means that redisplay should use COLS columns\n\
1528 but that the idea of the actual width of the frame should not be changed.")
1529 (frame
, cols
, pretend
)
1530 Lisp_Object frame
, cols
, pretend
;
1532 register struct frame
*f
;
1533 CHECK_NUMBER (cols
, 0);
1538 CHECK_LIVE_FRAME (frame
, 0);
1542 /* I think this should be done with a hook. */
1543 #ifdef HAVE_X_WINDOWS
1546 if (XINT (cols
) != f
->width
)
1547 x_set_window_size (f
, 1, XINT (cols
), f
->height
);
1551 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0);
1555 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1556 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1558 Lisp_Object frame
, cols
, rows
;
1560 register struct frame
*f
;
1563 CHECK_LIVE_FRAME (frame
, 0);
1564 CHECK_NUMBER (cols
, 2);
1565 CHECK_NUMBER (rows
, 1);
1568 /* I think this should be done with a hook. */
1569 #ifdef HAVE_X_WINDOWS
1572 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
)
1573 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
1577 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0);
1582 DEFUN ("set-frame-position", Fset_frame_position
,
1583 Sset_frame_position
, 3, 3, 0,
1584 "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
1585 This is actually the position of the upper left corner of the frame.\n\
1586 Negative values for XOFFSET or YOFFSET are interpreted relative to\n\
1587 the rightmost or bottommost possible position (that stays within the screen).")
1588 (frame
, xoffset
, yoffset
)
1589 Lisp_Object frame
, xoffset
, yoffset
;
1591 register struct frame
*f
;
1594 CHECK_LIVE_FRAME (frame
, 0);
1595 CHECK_NUMBER (xoffset
, 1);
1596 CHECK_NUMBER (yoffset
, 2);
1599 /* I think this should be done with a hook. */
1600 #ifdef HAVE_X_WINDOWS
1602 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
1609 choose_minibuf_frame ()
1611 /* For lowest-level minibuf, put it on currently selected frame
1612 if frame has a minibuffer. */
1614 if (minibuf_level
== 0
1615 && selected_frame
!= 0
1616 && !EQ (minibuf_window
, selected_frame
->minibuffer_window
))
1618 /* I don't think that any frames may validly have a null minibuffer
1620 if (NILP (selected_frame
->minibuffer_window
))
1623 Fset_window_buffer (selected_frame
->minibuffer_window
,
1624 XWINDOW (minibuf_window
)->buffer
);
1625 minibuf_window
= selected_frame
->minibuffer_window
;
1631 /*&&& init symbols here &&&*/
1632 Qframep
= intern ("framep");
1633 staticpro (&Qframep
);
1634 Qframe_live_p
= intern ("frame-live-p");
1635 staticpro (&Qframe_live_p
);
1636 Qheight
= intern ("height");
1637 staticpro (&Qheight
);
1638 Qicon
= intern ("icon");
1640 Qminibuffer
= intern ("minibuffer");
1641 staticpro (&Qminibuffer
);
1642 Qmodeline
= intern ("modeline");
1643 staticpro (&Qmodeline
);
1644 Qname
= intern ("name");
1646 Qonly
= intern ("only");
1648 Qunsplittable
= intern ("unsplittable");
1649 staticpro (&Qunsplittable
);
1650 Qmenu_bar_lines
= intern ("menu-bar-lines");
1651 staticpro (&Qmenu_bar_lines
);
1652 Qwidth
= intern ("width");
1653 staticpro (&Qwidth
);
1656 Qvisible
= intern ("visible");
1657 staticpro (&Qvisible
);
1659 staticpro (&Vframe_list
);
1661 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
1662 "The initial frame-object, which represents Emacs's stdout.");
1664 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
1665 "Non-nil if all of emacs is iconified and frame updates are not needed.");
1666 Vemacs_iconified
= Qnil
;
1668 DEFVAR_LISP ("default-minibuffer-frame", &Vdefault_minibuffer_frame
,
1669 "Minibufferless frames use this frame's minibuffer.\n\
1671 Emacs cannot create minibufferless frames unless this is set to an\n\
1672 appropriate surrogate.\n\
1674 Emacs consults this variable only when creating minibufferless\n\
1675 frames; once the frame is created, it sticks with its assigned\n\
1676 minibuffer, no matter what this variable is set to. This means that\n\
1677 this variable doesn't necessarily say anything meaningful about the\n\
1678 current set of frames, or where the minibuffer is currently being\n\
1680 Vdefault_minibuffer_frame
= Qnil
;
1682 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
1683 "Alist of default values for frame creation.\n\
1684 These may be set in your init file, like this:\n\
1685 (setq default-frame-alist '((width . 80) (height . 55)))\n\
1686 These override values given in window system configuration data, like\n\
1687 X Windows' defaults database.\n\
1688 For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
1689 For values specific to the separate minibuffer frame, see\n\
1690 `minibuffer-frame-alist'.");
1691 Vdefault_frame_alist
= Qnil
;
1694 defsubr (&Sframe_live_p
);
1695 defsubr (&Shandle_switch_frame
);
1696 defsubr (&Sselect_frame
);
1697 defsubr (&Sselected_frame
);
1698 defsubr (&Swindow_frame
);
1699 defsubr (&Sframe_root_window
);
1700 defsubr (&Sframe_selected_window
);
1701 defsubr (&Sframe_list
);
1702 defsubr (&Snext_frame
);
1703 defsubr (&Sprevious_frame
);
1704 defsubr (&Sdelete_frame
);
1705 defsubr (&Smouse_position
);
1706 defsubr (&Smouse_pixel_position
);
1707 defsubr (&Sset_mouse_position
);
1708 defsubr (&Sset_mouse_pixel_position
);
1710 defsubr (&Sframe_configuration
);
1711 defsubr (&Srestore_frame_configuration
);
1713 defsubr (&Smake_frame_visible
);
1714 defsubr (&Smake_frame_invisible
);
1715 defsubr (&Siconify_frame
);
1716 defsubr (&Sframe_visible_p
);
1717 defsubr (&Svisible_frame_list
);
1718 defsubr (&Sraise_frame
);
1719 defsubr (&Slower_frame
);
1720 defsubr (&Sredirect_frame_focus
);
1721 defsubr (&Sframe_focus
);
1722 defsubr (&Sframe_parameters
);
1723 defsubr (&Smodify_frame_parameters
);
1724 defsubr (&Sframe_char_height
);
1725 defsubr (&Sframe_char_width
);
1726 defsubr (&Sframe_pixel_height
);
1727 defsubr (&Sframe_pixel_width
);
1728 defsubr (&Sset_frame_height
);
1729 defsubr (&Sset_frame_width
);
1730 defsubr (&Sset_frame_size
);
1731 defsubr (&Sset_frame_position
);
1736 initial_define_lispy_key (global_map
, "switch-frame", "handle-switch-frame");
1739 #else /* not MULTI_FRAME */
1741 /* If we're not using multi-frame stuff, we still need to provide some
1742 support functions. */
1744 Lisp_Object Vterminal_frame
;
1746 /* Unless this function is defined, providing set-frame-height and
1747 set-frame-width doesn't help compatibility any, since they both
1748 want this as their first argument. */
1749 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1750 /* Don't confuse make-docfile by having two doc strings for this function.
1751 make-docfile does not pay attention to #if, for good reason! */
1759 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
1760 /* Don't confuse make-docfile by having two doc strings for this function.
1761 make-docfile does not pay attention to #if, for good reason! */
1769 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1770 /* Don't confuse make-docfile by having two doc strings for this function.
1771 make-docfile does not pay attention to #if, for good reason! */
1773 (frame
, rows
, pretend
)
1774 Lisp_Object frame
, rows
, pretend
;
1776 CHECK_NUMBER (rows
, 0);
1778 change_frame_size (0, XINT (rows
), 0, !NILP (pretend
), 0);
1782 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1783 /* Don't confuse make-docfile by having two doc strings for this function.
1784 make-docfile does not pay attention to #if, for good reason! */
1786 (frame
, cols
, pretend
)
1787 Lisp_Object frame
, cols
, pretend
;
1789 CHECK_NUMBER (cols
, 0);
1791 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1795 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1796 /* Don't confuse make-docfile by having two doc strings for this function.
1797 make-docfile does not pay attention to #if, for good reason! */
1800 Lisp_Object frame
, cols
, rows
;
1802 CHECK_NUMBER (cols
, 2);
1803 CHECK_NUMBER (rows
, 1);
1805 change_frame_size (0, XINT (rows
), XINT (cols
), 0, 0);
1810 DEFUN ("frame-height", Fframe_height
, Sframe_height
, 0, 1, 0,
1811 "Return number of lines available for display on FRAME.\n\
1812 If FRAME is omitted, describe the currently selected frame.")
1816 return make_number (FRAME_HEIGHT (selected_frame
));
1819 DEFUN ("frame-width", Fframe_width
, Sframe_width
, 0, 1, 0,
1820 "Return number of columns available for display on FRAME.\n\
1821 If FRAME is omitted, describe the currently selected frame.")
1825 return make_number (FRAME_WIDTH (selected_frame
));
1828 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
1830 /* Don't confuse make-docfile by having two doc strings for this function.
1831 make-docfile does not pay attention to #if, for good reason! */
1836 return make_number (1);
1840 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
1842 /* Don't confuse make-docfile by having two doc strings for this function.
1843 make-docfile does not pay attention to #if, for good reason! */
1848 return make_number (1);
1851 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
1852 Sframe_pixel_height
, 0, 1, 0,
1853 /* Don't confuse make-docfile by having two doc strings for this function.
1854 make-docfile does not pay attention to #if, for good reason! */
1859 return make_number (FRAME_HEIGHT (f
));
1862 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
1863 Sframe_pixel_width
, 0, 1, 0,
1864 /* Don't confuse make-docfile by having two doc strings for this function.
1865 make-docfile does not pay attention to #if, for good reason! */
1870 return make_number (FRAME_WIDTH (f
));
1873 /* These are for backward compatibility with Emacs 18. */
1875 DEFUN ("set-screen-height", Fset_screen_height
, Sset_screen_height
, 1, 2, 0,
1876 "Tell redisplay that the screen has LINES lines.\n\
1877 Optional second arg non-nil means that redisplay should use LINES lines\n\
1878 but that the idea of the actual height of the screen should not be changed.")
1880 Lisp_Object lines
, pretend
;
1882 CHECK_NUMBER (lines
, 0);
1884 change_frame_size (0, XINT (lines
), 0, !NILP (pretend
), 0);
1888 DEFUN ("set-screen-width", Fset_screen_width
, Sset_screen_width
, 1, 2, 0,
1889 "Tell redisplay that the screen has COLS columns.\n\
1890 Optional second arg non-nil means that redisplay should use COLS columns\n\
1891 but that the idea of the actual width of the screen should not be changed.")
1893 Lisp_Object cols
, pretend
;
1895 CHECK_NUMBER (cols
, 0);
1897 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1901 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1902 /* Don't confuse make-docfile by having two doc strings for this function.
1903 make-docfile does not pay attention to #if, for good reason! */
1907 return Fcons (Qnil
, Fcons (Qnil
, Qnil
));
1910 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
1911 "Return the parameters-alist of frame FRAME.\n\
1912 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
1913 The meaningful PARMs depend on the kind of frame.\n\
1914 If FRAME is omitted, return information on the currently selected frame.")
1921 if (EQ (frame
, Qnil
))
1925 CHECK_FRAME (frame
, 0);
1929 if (f
->display
.nothing
== 0)
1932 alist
= Fcopy_alist (f
->param_alist
);
1933 store_in_alist (&alist
, Qname
, f
->name
);
1934 store_in_alist (&alist
, Qheight
, make_number (f
->height
));
1935 store_in_alist (&alist
, Qwidth
, make_number (f
->width
));
1936 store_in_alist (&alist
, Qmodeline
, (f
->wants_modeline
? Qt
: Qnil
));
1937 store_in_alist (&alist
, Qminibuffer
,
1938 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
1939 : (FRAME_MINIBUF_ONLY_P (f
) ? Qonly
1940 : FRAME_MINIBUF_WINDOW (f
))));
1941 store_in_alist (&alist
, Qunsplittable
, (f
->no_split
? Qt
: Qnil
));
1942 store_in_alist (&alist
, Qmenu_bar_lines
, (FRAME_MENU_BAR_LINES (f
)));
1947 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
1948 Smodify_frame_parameters
, 2, 2, 0,
1949 "Modify the parameters of frame FRAME according to ALIST.\n\
1950 ALIST is an alist of parameters to change and their new values.\n\
1951 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
1952 The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
1954 Lisp_Object frame
, alist
;
1961 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
1962 "The initial frame-object, which represents Emacs's stdout.");
1963 XFASTINT (Vterminal_frame
) = 0;
1965 defsubr (&Sselected_frame
);
1967 defsubr (&Sframe_char_height
);
1968 defsubr (&Sframe_char_width
);
1969 defsubr (&Sframe_pixel_height
);
1970 defsubr (&Sframe_pixel_width
);
1971 defsubr (&Sset_frame_height
);
1972 defsubr (&Sset_frame_width
);
1973 defsubr (&Sset_frame_size
);
1974 defsubr (&Sset_screen_height
);
1975 defsubr (&Sset_screen_width
);
1976 defsubr (&Sframe_height
);
1977 Ffset (intern ("screen-height"), intern ("frame-height"));
1978 defsubr (&Sframe_width
);
1979 Ffset (intern ("screen-width"), intern ("frame-width"));
1980 defsubr (&Smouse_position
);
1981 defsubr (&Sframe_parameters
);
1982 defsubr (&Smodify_frame_parameters
);
1989 #endif /* not MULTI_FRAME */