1 /* Generic frame functions.
2 Copyright (C) 1993, 1994 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
;
171 f
->menu_bar_vector
= Qnil
;
172 f
->menu_bar_items_used
= 0;
174 root_window
= make_window ();
177 mini_window
= make_window ();
178 XWINDOW (root_window
)->next
= mini_window
;
179 XWINDOW (mini_window
)->prev
= root_window
;
180 XWINDOW (mini_window
)->mini_p
= Qt
;
181 XWINDOW (mini_window
)->frame
= frame
;
182 f
->minibuffer_window
= mini_window
;
187 XWINDOW (root_window
)->next
= Qnil
;
188 f
->minibuffer_window
= Qnil
;
191 XWINDOW (root_window
)->frame
= frame
;
194 just so that there is "something there."
195 Correct size will be set up later with change_frame_size. */
200 XFASTINT (XWINDOW (root_window
)->width
) = 10;
201 XFASTINT (XWINDOW (root_window
)->height
) = (mini_p
? 9 : 10);
205 XFASTINT (XWINDOW (mini_window
)->width
) = 10;
206 XFASTINT (XWINDOW (mini_window
)->top
) = 9;
207 XFASTINT (XWINDOW (mini_window
)->height
) = 1;
210 /* Choose a buffer for the frame's root window. */
214 XWINDOW (root_window
)->buffer
= Qt
;
215 buf
= Fcurrent_buffer ();
216 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
217 a space), try to find another one. */
218 if (XSTRING (Fbuffer_name (buf
))->data
[0] == ' ')
219 buf
= Fother_buffer (buf
, Qnil
);
220 Fset_window_buffer (root_window
, buf
);
225 XWINDOW (mini_window
)->buffer
= Qt
;
226 Fset_window_buffer (mini_window
,
227 (NILP (Vminibuffer_list
)
229 : Fcar (Vminibuffer_list
)));
232 f
->root_window
= root_window
;
233 f
->selected_window
= root_window
;
234 /* Make sure this window seems more recently used than
235 a newly-created, never-selected window. */
236 XFASTINT (XWINDOW (f
->selected_window
)->use_time
) = ++window_select_count
;
241 /* Make a frame using a separate minibuffer window on another frame.
242 MINI_WINDOW is the minibuffer window to use. nil means use the
243 default (the global minibuffer). */
246 make_frame_without_minibuffer (mini_window
)
247 register Lisp_Object mini_window
;
249 register struct frame
*f
;
251 /* Choose the minibuffer window to use. */
252 if (NILP (mini_window
))
254 if (XTYPE (Vdefault_minibuffer_frame
) != Lisp_Frame
)
255 error ("default-minibuffer-frame must be set when creating minibufferless frames");
256 if (! FRAME_LIVE_P (XFRAME (Vdefault_minibuffer_frame
)))
257 error ("default-minibuffer-frame must be a live frame");
258 mini_window
= XFRAME (Vdefault_minibuffer_frame
)->minibuffer_window
;
262 CHECK_LIVE_WINDOW (mini_window
, 0);
265 /* Make a frame containing just a root window. */
268 /* Install the chosen minibuffer window, with proper buffer. */
269 f
->minibuffer_window
= mini_window
;
270 Fset_window_buffer (mini_window
,
271 (NILP (Vminibuffer_list
)
273 : Fcar (Vminibuffer_list
)));
277 /* Make a frame containing only a minibuffer window. */
280 make_minibuffer_frame ()
282 /* First make a frame containing just a root window, no minibuffer. */
284 register struct frame
*f
= make_frame (0);
285 register Lisp_Object mini_window
;
286 register Lisp_Object frame
;
288 XSET (frame
, Lisp_Frame
, f
);
293 f
->wants_modeline
= 0;
294 f
->has_minibuffer
= 1;
296 /* Now label the root window as also being the minibuffer.
297 Avoid infinite looping on the window chain by marking next pointer
300 mini_window
= f
->minibuffer_window
= f
->root_window
;
301 XWINDOW (mini_window
)->mini_p
= Qt
;
302 XWINDOW (mini_window
)->next
= Qnil
;
303 XWINDOW (mini_window
)->prev
= Qnil
;
304 XWINDOW (mini_window
)->frame
= frame
;
306 /* Put the proper buffer in that window. */
308 Fset_window_buffer (mini_window
,
309 (NILP (Vminibuffer_list
)
311 : Fcar (Vminibuffer_list
)));
315 /* Construct a frame that refers to the terminal (stdin and stdout). */
318 make_terminal_frame ()
320 register struct frame
*f
;
326 XSET (frame
, Lisp_Frame
, f
);
327 Vframe_list
= Fcons (frame
, Vframe_list
);
329 f
->name
= build_string ("terminal");
330 FRAME_SET_VISIBLE (f
, 1);
331 f
->display
.nothing
= 1; /* Nonzero means frame isn't deleted. */
332 XSET (Vterminal_frame
, Lisp_Frame
, f
);
337 do_switch_frame (frame
, no_enter
, track
)
338 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 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
349 a switch-frame event to arrive after a frame is no longer live,
350 especially when deleting the initial frame during startup. */
351 CHECK_FRAME (frame
, 0);
352 if (! FRAME_LIVE_P (XFRAME (frame
)))
355 if (selected_frame
== XFRAME (frame
))
358 /* This is too greedy; it causes inappropriate focus redirection
359 that's hard to get rid of. */
361 /* If a frame's focus has been redirected toward the currently
362 selected frame, we should change the redirection to point to the
363 newly selected frame. This means that if the focus is redirected
364 from a minibufferless frame to a surrogate minibuffer frame, we
365 can use `other-window' to switch between all the frames using
366 that minibuffer frame, and the focus redirection will follow us
372 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
376 if (XTYPE (XCONS (tail
)->car
) != Lisp_Frame
)
379 focus
= FRAME_FOCUS_FRAME (XFRAME (XCONS (tail
)->car
));
381 if (XTYPE (focus
) == Lisp_Frame
382 && XFRAME (focus
) == selected_frame
)
383 Fredirect_frame_focus (XCONS (tail
)->car
, frame
);
387 /* Instead, apply it only to the frame we're pointing to. */
388 #ifdef HAVE_X_WINDOWS
391 Lisp_Object focus
, xfocus
;
393 xfocus
= x_get_focus_frame ();
396 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
397 if (FRAMEP (focus
) && XFRAME (focus
) == selected_frame
)
398 Fredirect_frame_focus (xfocus
, frame
);
401 #endif /* HAVE_X_WINDOWS */
404 selected_frame
= XFRAME (frame
);
405 if (! FRAME_MINIBUF_ONLY_P (selected_frame
))
406 last_nonminibuf_frame
= selected_frame
;
408 Fselect_window (XFRAME (frame
)->selected_window
);
409 choose_minibuf_frame ();
411 /* We want to make sure that the next event generates a frame-switch
412 event to the appropriate frame. This seems kludgy to me, but
413 before you take it out, make sure that evaluating something like
414 (select-window (frame-root-window (new-frame))) doesn't end up
415 with your typing being interpreted in the new frame instead of
416 the one you're actually typing in. */
417 internal_last_event_frame
= Qnil
;
422 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
423 "Select the frame FRAME.\n\
424 Subsequent editing commands apply to its selected window.\n\
425 The selection of FRAME lasts until the next time the user does\n\
426 something to select a different frame, or until the next time this\n\
427 function is called.")
429 Lisp_Object frame
, no_enter
;
431 return do_switch_frame (frame
, no_enter
, 1);
435 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 2, "e",
436 "Handle a switch-frame event EVENT.\n\
437 Switch-frame events are usually bound to this function.\n\
438 A switch-frame event tells Emacs that the window manager has requested\n\
439 that the user's events be directed to the frame mentioned in the event.\n\
440 This function selects the selected window of the frame of EVENT.\n\
442 If EVENT is frame object, handle it as if it were a switch-frame event\n\
445 Lisp_Object frame
, no_enter
;
447 return do_switch_frame (frame
, no_enter
, 0);
451 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
452 "Return the frame that is now selected.")
456 XSET (tem
, Lisp_Frame
, selected_frame
);
460 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
461 "Return the frame object that window WINDOW is on.")
465 CHECK_LIVE_WINDOW (window
, 0);
466 return XWINDOW (window
)->frame
;
469 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
470 "Returns the topmost, leftmost window of FRAME.\n\
471 If omitted, FRAME defaults to the currently selected frame.")
478 w
= selected_frame
->root_window
;
481 CHECK_LIVE_FRAME (frame
, 0);
482 w
= XFRAME (frame
)->root_window
;
484 while (NILP (XWINDOW (w
)->buffer
))
486 if (! NILP (XWINDOW (w
)->hchild
))
487 w
= XWINDOW (w
)->hchild
;
488 else if (! NILP (XWINDOW (w
)->vchild
))
489 w
= XWINDOW (w
)->vchild
;
496 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
497 "Returns the root-window of FRAME.\n\
498 If omitted, FRAME defaults to the currently selected frame.")
503 XSET (frame
, Lisp_Frame
, selected_frame
);
505 CHECK_LIVE_FRAME (frame
, 0);
507 return XFRAME (frame
)->root_window
;
510 DEFUN ("frame-selected-window", Fframe_selected_window
,
511 Sframe_selected_window
, 0, 1, 0,
512 "Return the selected window of frame object FRAME.\n\
513 If omitted, FRAME defaults to the currently selected frame.")
518 XSET (frame
, Lisp_Frame
, selected_frame
);
520 CHECK_LIVE_FRAME (frame
, 0);
522 return XFRAME (frame
)->selected_window
;
525 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
526 Sset_frame_selected_window
, 2, 2, 0,
527 "Set the selected window of frame object FRAME to WINDOW.\n\
528 If FRAME is nil, the selected frame is used.\n\
529 If FRAME is the selected frame, this makes WINDOW the selected window.")
531 Lisp_Object frame
, window
;
534 XSET (frame
, Lisp_Frame
, selected_frame
);
536 CHECK_LIVE_FRAME (frame
, 0);
538 CHECK_LIVE_WINDOW (window
, 1);
540 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
541 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
543 if (XFRAME (frame
) == selected_frame
)
544 return Fselect_window (window
);
546 return XFRAME (frame
)->selected_window
= window
;
549 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
551 "Return a list of all frames.")
554 return Fcopy_sequence (Vframe_list
);
557 /* Return the next frame in the frame list after FRAME.
558 If MINIBUF is nil, exclude minibuffer-only frames.
559 If MINIBUF is a window, include only frames using that window for
561 If MINIBUF is `visible', include all visible frames.
562 Otherwise, include all frames. */
565 next_frame (frame
, minibuf
)
572 /* There must always be at least one frame in Vframe_list. */
573 if (! CONSP (Vframe_list
))
576 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
577 forever. Forestall that. */
578 CHECK_LIVE_FRAME (frame
, 0);
581 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
585 f
= XCONS (tail
)->car
;
588 /* Decide whether this frame is eligible to be returned. */
590 /* If we've looped all the way around without finding any
591 eligible frames, return the original frame. */
595 /* Let minibuf decide if this frame is acceptable. */
598 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
601 else if (EQ (minibuf
, Qvisible
))
603 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
604 if (FRAME_VISIBLE_P (XFRAME (f
)))
607 else if (WINDOWP (minibuf
))
609 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
))
621 /* Return the previous frame in the frame list before FRAME.
622 If MINIBUF is nil, exclude minibuffer-only frames.
623 If MINIBUF is a window, include only frames using that window for
625 If MINIBUF is `visible', include all visible frames.
626 Otherwise, include all frames. */
629 prev_frame (frame
, minibuf
)
636 /* There must always be at least one frame in Vframe_list. */
637 if (! CONSP (Vframe_list
))
641 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
645 f
= XCONS (tail
)->car
;
646 if (XTYPE (f
) != Lisp_Frame
)
649 if (EQ (frame
, f
) && !NILP (prev
))
652 /* Decide whether this frame is eligible to be returned,
653 according to minibuf. */
656 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
659 else if (XTYPE (minibuf
) == Lisp_Window
)
661 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
))
664 else if (EQ (minibuf
, Qvisible
))
666 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
667 if (FRAME_VISIBLE_P (XFRAME (f
)))
674 /* We've scanned the entire list. */
676 /* We went through the whole frame list without finding a single
677 acceptable frame. Return the original frame. */
680 /* There were no acceptable frames in the list before FRAME; otherwise,
681 we would have returned directly from the loop. Since PREV is the last
682 acceptable frame in the list, return it. */
687 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
688 "Return the next frame in the frame list after FRAME.\n\
689 By default, skip minibuffer-only frames.\n\
690 If omitted, FRAME defaults to the selected frame.\n\
691 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
692 If MINIFRAME is a window, include only frames using that window for their\n\
694 If MINIFRAME is `visible', include all visible frames.\n\
695 Otherwise, include all frames.")
697 Lisp_Object frame
, miniframe
;
702 XSET (frame
, Lisp_Frame
, selected_frame
);
704 CHECK_LIVE_FRAME (frame
, 0);
706 return next_frame (frame
, miniframe
);
709 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
710 "Return the previous frame in the frame list before FRAME.\n\
711 By default, skip minibuffer-only frames.\n\
712 If omitted, FRAME defaults to the selected frame.\n\
713 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
714 If MINIFRAME is a window, include only frames using that window for their\n\
716 If MINIFRAME is `visible', include all visible frames.\n\
717 Otherwise, include all frames.")
719 Lisp_Object frame
, miniframe
;
724 XSET (frame
, Lisp_Frame
, selected_frame
);
726 CHECK_LIVE_FRAME (frame
, 0);
728 return prev_frame (frame
, miniframe
);
731 /* Return 1 if it is ok to delete frame F;
732 0 if all frames aside from F are invisible.
733 (Exception: if F is the terminal frame, and we are using X, return 1.) */
736 other_visible_frames (f
)
739 /* We know the selected frame is visible,
740 so if F is some other frame, it can't be the sole visible one. */
741 if (f
== selected_frame
)
746 for (frames
= Vframe_list
;
748 frames
= XCONS (frames
)->cdr
)
752 this = XCONS (frames
)->car
;
753 /* Verify that the frame's window still exists
754 and we can still talk to it. And note any recent change
756 #ifdef HAVE_X_WINDOWS
757 if (FRAME_X_P (XFRAME (this)))
760 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
764 if (FRAME_VISIBLE_P (XFRAME (this))
765 || FRAME_ICONIFIED_P (XFRAME (this))
766 /* Allow deleting the terminal frame when at least
767 one X frame exists! */
768 || (FRAME_X_P (XFRAME (this)) && !FRAME_X_P (f
)))
776 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
777 "Delete FRAME, permanently eliminating it from use.\n\
778 If omitted, FRAME defaults to the selected frame.\n\
779 A frame may not be deleted if its minibuffer is used by other frames.\n\
780 Normally, you may not delete a frame if all other frames are invisible,\n\
781 but if the second optional argument FORCE is non-nil, you may do so.")
783 Lisp_Object frame
, force
;
787 if (EQ (frame
, Qnil
))
790 XSET (frame
, Lisp_Frame
, f
);
794 CHECK_FRAME (frame
, 0);
798 if (! FRAME_LIVE_P (f
))
801 if (NILP (force
) && !other_visible_frames (f
))
802 error ("Attempt to delete the sole visible or iconified frame");
804 /* Does this frame have a minibuffer, and is it the surrogate
805 minibuffer for any other frame? */
806 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
810 for (frames
= Vframe_list
;
812 frames
= XCONS (frames
)->cdr
)
815 this = XCONS (frames
)->car
;
817 if (! EQ (this, frame
)
819 WINDOW_FRAME (XWINDOW
820 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
821 error ("Attempt to delete a surrogate minibuffer frame");
825 /* Don't let the frame remain selected. */
826 if (f
== selected_frame
)
827 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
829 /* Don't allow minibuf_window to remain on a deleted frame. */
830 if (EQ (f
->minibuffer_window
, minibuf_window
))
832 Fset_window_buffer (selected_frame
->minibuffer_window
,
833 XWINDOW (minibuf_window
)->buffer
);
834 minibuf_window
= selected_frame
->minibuffer_window
;
837 /* Mark all the windows that used to be on FRAME as deleted, and then
838 remove the reference to them. */
839 delete_all_subwindows (XWINDOW (f
->root_window
));
840 f
->root_window
= Qnil
;
842 Vframe_list
= Fdelq (frame
, Vframe_list
);
843 FRAME_SET_VISIBLE (f
, 0);
845 /* Since some events are handled at the interrupt level, we may get
846 an event for f at any time; if we zero out the frame's display
847 now, then we may trip up the event-handling code. Instead, we'll
848 promise that the display of the frame must be valid until we have
849 called the window-system-dependent frame destruction routine. */
851 /* I think this should be done with a hook. */
852 #ifdef HAVE_X_WINDOWS
854 x_destroy_window (f
);
857 f
->display
.nothing
= 0;
859 /* If we've deleted the last_nonminibuf_frame, then try to find
861 if (f
== last_nonminibuf_frame
)
865 last_nonminibuf_frame
= 0;
867 for (frames
= Vframe_list
;
869 frames
= XCONS (frames
)->cdr
)
871 f
= XFRAME (XCONS (frames
)->car
);
872 if (!FRAME_MINIBUF_ONLY_P (f
))
874 last_nonminibuf_frame
= f
;
880 /* If we've deleted Vdefault_minibuffer_frame, try to find another
881 one. Prefer minibuffer-only frames, but also notice frames
882 with other windows. */
883 if (EQ (frame
, Vdefault_minibuffer_frame
))
887 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
888 Lisp_Object frame_with_minibuf
;
890 frame_with_minibuf
= Qnil
;
891 for (frames
= Vframe_list
;
893 frames
= XCONS (frames
)->cdr
)
897 this = XCONS (frames
)->car
;
898 if (XTYPE (this) != Lisp_Frame
)
902 if (FRAME_HAS_MINIBUF_P (f
))
904 frame_with_minibuf
= this;
905 if (FRAME_MINIBUF_ONLY_P (f
))
910 /* We know that there must be some frame with a minibuffer out
911 there. If this were not true, all of the frames present
912 would have to be minibufferless, which implies that at some
913 point their minibuffer frames must have been deleted, but
914 that is prohibited at the top; you can't delete surrogate
915 minibuffer frames. */
916 if (NILP (frame_with_minibuf
))
919 Vdefault_minibuffer_frame
= frame_with_minibuf
;
925 /* Return mouse position in character cell units. */
927 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
928 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
929 The position is given in character cells, where (0, 0) is the\n\
930 upper-left corner.\n\
931 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
932 to read the mouse position, it returns the selected frame for FRAME\n\
933 and nil for X and Y.")
937 Lisp_Object lispy_dummy
;
938 enum scroll_bar_part party_dummy
;
941 unsigned long long_dummy
;
946 /* It's okay for the hook to refrain from storing anything. */
947 if (mouse_position_hook
)
948 (*mouse_position_hook
) (&f
,
949 &lispy_dummy
, &party_dummy
,
956 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, 0, 1);
960 XSET (lispy_dummy
, Lisp_Frame
, f
);
961 return Fcons (lispy_dummy
, Fcons (x
, y
));
964 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
965 Smouse_pixel_position
, 0, 0, 0,
966 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
967 The position is given in pixel units, where (0, 0) is the\n\
968 upper-left corner.\n\
969 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
970 to read the mouse position, it returns the selected frame for FRAME\n\
971 and nil for X and Y.")
975 Lisp_Object lispy_dummy
;
976 enum scroll_bar_part party_dummy
;
979 unsigned long long_dummy
;
984 /* It's okay for the hook to refrain from storing anything. */
985 if (mouse_position_hook
)
986 (*mouse_position_hook
) (&f
,
987 &lispy_dummy
, &party_dummy
,
990 XSET (lispy_dummy
, Lisp_Frame
, f
);
991 return Fcons (lispy_dummy
, Fcons (x
, y
));
994 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
995 "Move the mouse pointer to the center of character cell (X,Y) in FRAME.\n\
996 WARNING: If you use this under X windows,\n\
997 you should call `unfocus-frame' afterwards.")
999 Lisp_Object frame
, x
, y
;
1001 CHECK_LIVE_FRAME (frame
, 0);
1002 CHECK_NUMBER (x
, 2);
1003 CHECK_NUMBER (y
, 1);
1005 /* I think this should be done with a hook. */
1006 #ifdef HAVE_X_WINDOWS
1007 if (FRAME_X_P (XFRAME (frame
)))
1008 /* Warping the mouse will cause enternotify and focus events. */
1009 x_set_mouse_position (XFRAME (frame
), x
, y
);
1015 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1016 Sset_mouse_pixel_position
, 3, 3, 0,
1017 "Move the mouse pointer to pixel position (X,Y) in FRAME.\n\
1018 WARNING: If you use this under X windows,\n\
1019 you should call `unfocus-frame' afterwards.")
1021 Lisp_Object frame
, x
, y
;
1023 CHECK_LIVE_FRAME (frame
, 0);
1024 CHECK_NUMBER (x
, 2);
1025 CHECK_NUMBER (y
, 1);
1027 /* I think this should be done with a hook. */
1028 #ifdef HAVE_X_WINDOWS
1029 if (FRAME_X_P (XFRAME (frame
)))
1030 /* Warping the mouse will cause enternotify and focus events. */
1031 x_set_mouse_pixel_position (XFRAME (frame
), x
, y
);
1037 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1039 "Make the frame FRAME visible (assuming it is an X-window).\n\
1040 If omitted, FRAME defaults to the currently selected frame.")
1045 XSET (frame
, Lisp_Frame
, selected_frame
);
1047 CHECK_LIVE_FRAME (frame
, 0);
1049 /* I think this should be done with a hook. */
1050 #ifdef HAVE_X_WINDOWS
1051 if (FRAME_X_P (XFRAME (frame
)))
1053 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1054 x_make_frame_visible (XFRAME (frame
));
1058 /* Make menu bar update for the Buffers and Frams menus. */
1059 windows_or_buffers_changed
++;
1064 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1066 "Make the frame FRAME invisible (assuming it is an X-window).\n\
1067 If omitted, FRAME defaults to the currently selected frame.\n\
1068 Normally you may not make FRAME invisible if all other frames are invisible,\n\
1069 but if the second optional argument FORCE is non-nil, you may do so.")
1071 Lisp_Object frame
, force
;
1074 XSET (frame
, Lisp_Frame
, selected_frame
);
1076 CHECK_LIVE_FRAME (frame
, 0);
1078 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1079 error ("Attempt to make invisible the sole visible or iconified frame");
1081 /* Don't let the frame remain selected. */
1082 if (XFRAME (frame
) == selected_frame
)
1083 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1085 /* Don't allow minibuf_window to remain on a deleted frame. */
1086 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1088 Fset_window_buffer (selected_frame
->minibuffer_window
,
1089 XWINDOW (minibuf_window
)->buffer
);
1090 minibuf_window
= selected_frame
->minibuffer_window
;
1093 /* I think this should be done with a hook. */
1094 #ifdef HAVE_X_WINDOWS
1095 if (FRAME_X_P (XFRAME (frame
)))
1096 x_make_frame_invisible (XFRAME (frame
));
1099 /* Make menu bar update for the Buffers and Frams menus. */
1100 windows_or_buffers_changed
++;
1105 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1107 "Make the frame FRAME into an icon.\n\
1108 If omitted, FRAME defaults to the currently selected frame.")
1113 XSET (frame
, Lisp_Frame
, selected_frame
);
1115 CHECK_LIVE_FRAME (frame
, 0);
1117 /* Don't let the frame remain selected. */
1118 if (XFRAME (frame
) == selected_frame
)
1119 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1121 /* Don't allow minibuf_window to remain on a deleted frame. */
1122 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1124 Fset_window_buffer (selected_frame
->minibuffer_window
,
1125 XWINDOW (minibuf_window
)->buffer
);
1126 minibuf_window
= selected_frame
->minibuffer_window
;
1129 /* I think this should be done with a hook. */
1130 #ifdef HAVE_X_WINDOWS
1131 if (FRAME_X_P (XFRAME (frame
)))
1132 x_iconify_frame (XFRAME (frame
));
1135 /* Make menu bar update for the Buffers and Frams menus. */
1136 windows_or_buffers_changed
++;
1141 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1143 "Return t if FRAME is now \"visible\" (actually in use for display).\n\
1144 A frame that is not \"visible\" is not updated and, if it works through\n\
1145 a window system, it may not show at all.\n\
1146 Return the symbol `icon' if frame is visible only as an icon.")
1150 CHECK_LIVE_FRAME (frame
, 0);
1152 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1154 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1156 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1161 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1163 "Return a list of all frames now \"visible\" (being updated).")
1166 Lisp_Object tail
, frame
;
1171 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
1173 frame
= XCONS (tail
)->car
;
1174 if (XTYPE (frame
) != Lisp_Frame
)
1177 if (FRAME_VISIBLE_P (f
))
1178 value
= Fcons (frame
, value
);
1184 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 1, 1, 0,
1185 "Bring FRAME to the front, so it occludes any frames it overlaps.\n\
1186 If FRAME is invisible, make it visible.\n\
1187 If Emacs is displaying on an ordinary terminal or some other device which\n\
1188 doesn't support multiple overlapping frames, this function does nothing.")
1192 CHECK_LIVE_FRAME (frame
, 0);
1194 /* Do like the documentation says. */
1195 Fmake_frame_visible (frame
);
1197 if (frame_raise_lower_hook
)
1198 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1203 /* Should we have a corresponding function called Flower_Power? */
1204 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 1, 1, 0,
1205 "Send FRAME to the back, so it is occluded by any frames that overlap it.\n\
1206 If Emacs is displaying on an ordinary terminal or some other device which\n\
1207 doesn't support multiple overlapping frames, this function does nothing.")
1211 CHECK_LIVE_FRAME (frame
, 0);
1213 if (frame_raise_lower_hook
)
1214 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1220 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1222 "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
1223 In other words, switch-frame events caused by events in FRAME will\n\
1224 request a switch to FOCUS-FRAME, and `last-event-frame' will be\n\
1225 FOCUS-FRAME after reading an event typed at FRAME.\n\
1227 If FOCUS-FRAME is omitted or nil, any existing redirection is\n\
1228 cancelled, and the frame again receives its own keystrokes.\n\
1230 Focus redirection is useful for temporarily redirecting keystrokes to\n\
1231 a surrogate minibuffer frame when a frame doesn't have its own\n\
1232 minibuffer window.\n\
1234 A frame's focus redirection can be changed by select-frame. If frame\n\
1235 FOO is selected, and then a different frame BAR is selected, any\n\
1236 frames redirecting their focus to FOO are shifted to redirect their\n\
1237 focus to BAR. This allows focus redirection to work properly when the\n\
1238 user switches from one frame to another using `select-window'.\n\
1240 This means that a frame whose focus is redirected to itself is treated\n\
1241 differently from a frame whose focus is redirected to nil; the former\n\
1242 is affected by select-frame, while the latter is not.\n\
1244 The redirection lasts until `redirect-frame-focus' is called to change it.")
1245 (frame
, focus_frame
)
1246 Lisp_Object frame
, focus_frame
;
1248 /* Note that we don't check for a live frame here. It's reasonable
1249 to redirect the focus of a frame you're about to delete, if you
1250 know what other frame should receive those keystrokes. */
1251 CHECK_FRAME (frame
, 0);
1253 if (! NILP (focus_frame
))
1254 CHECK_LIVE_FRAME (focus_frame
, 1);
1256 XFRAME (frame
)->focus_frame
= focus_frame
;
1258 /* I think this should be done with a hook. */
1259 #ifdef HAVE_X_WINDOWS
1260 if (!NILP (focus_frame
) && ! EQ (focus_frame
, frame
)
1261 && FRAME_X_P (XFRAME (focus_frame
)))
1262 Ffocus_frame (focus_frame
);
1265 if (frame_rehighlight_hook
)
1266 (*frame_rehighlight_hook
) ();
1272 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1273 "Return the frame to which FRAME's keystrokes are currently being sent.\n\
1274 This returns nil if FRAME's focus is not redirected.\n\
1275 See `redirect-frame-focus'.")
1279 CHECK_LIVE_FRAME (frame
, 0);
1281 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1287 get_frame_param (frame
, prop
)
1288 register struct frame
*frame
;
1291 register Lisp_Object tem
;
1293 tem
= Fassq (prop
, frame
->param_alist
);
1300 store_in_alist (alistptr
, prop
, val
)
1301 Lisp_Object
*alistptr
, val
;
1304 register Lisp_Object tem
;
1306 tem
= Fassq (prop
, *alistptr
);
1308 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1314 store_frame_param (f
, prop
, val
)
1316 Lisp_Object prop
, val
;
1318 register Lisp_Object tem
;
1320 tem
= Fassq (prop
, f
->param_alist
);
1322 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
1326 if (EQ (prop
, Qminibuffer
)
1327 && XTYPE (val
) == Lisp_Window
)
1329 if (! MINI_WINDOW_P (XWINDOW (val
)))
1330 error ("Surrogate minibuffer windows must be minibuffer windows.");
1332 if (FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
1333 error ("can't change the surrogate minibuffer of a frame with its own minibuffer");
1335 /* Install the chosen minibuffer window, with proper buffer. */
1336 f
->minibuffer_window
= val
;
1340 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
1341 "Return the parameters-alist of frame FRAME.\n\
1342 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
1343 The meaningful PARMs depend on the kind of frame.\n\
1344 If FRAME is omitted, return information on the currently selected frame.")
1351 if (EQ (frame
, Qnil
))
1355 CHECK_FRAME (frame
, 0);
1359 if (!FRAME_LIVE_P (f
))
1362 alist
= Fcopy_alist (f
->param_alist
);
1363 store_in_alist (&alist
, Qname
, f
->name
);
1364 store_in_alist (&alist
, Qheight
, make_number (FRAME_HEIGHT (f
)));
1365 store_in_alist (&alist
, Qwidth
, make_number (FRAME_WIDTH (f
)));
1366 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
1367 store_in_alist (&alist
, Qminibuffer
,
1368 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
1369 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
1370 : FRAME_MINIBUF_WINDOW (f
)));
1371 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
1372 store_in_alist (&alist
, Qmenu_bar_lines
, (FRAME_MENU_BAR_LINES (f
)));
1374 /* I think this should be done with a hook. */
1375 #ifdef HAVE_X_WINDOWS
1377 x_report_frame_params (f
, &alist
);
1382 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
1383 Smodify_frame_parameters
, 2, 2, 0,
1384 "Modify the parameters of frame FRAME according to ALIST.\n\
1385 ALIST is an alist of parameters to change and their new values.\n\
1386 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
1387 The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
1389 Lisp_Object frame
, alist
;
1392 register Lisp_Object tail
, elt
, prop
, val
;
1394 if (EQ (frame
, Qnil
))
1398 CHECK_LIVE_FRAME (frame
, 0);
1402 /* I think this should be done with a hook. */
1403 #ifdef HAVE_X_WINDOWS
1406 x_set_frame_parameters (f
, alist
);
1408 for (tail
= alist
; !EQ (tail
, Qnil
); tail
= Fcdr (tail
))
1413 x_set_frame_param (f
, prop
, val
, get_frame_param (f
, prop
));
1414 store_frame_param (f
, prop
, val
);
1422 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
1424 "Height in pixels of a line in the font in frame FRAME.\n\
1425 If FRAME is omitted, the selected frame is used.\n\
1426 For a terminal frame, the value is always 1.")
1436 CHECK_FRAME (frame
, 0);
1440 #ifdef HAVE_X_WINDOWS
1442 return make_number (x_char_height (f
));
1445 return make_number (1);
1449 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
1451 "Width in pixels of characters in the font in frame FRAME.\n\
1452 If FRAME is omitted, the selected frame is used.\n\
1453 The width is the same for all characters, because\n\
1454 currently Emacs supports only fixed-width fonts.\n\
1455 For a terminal screen, the value is always 1.")
1465 CHECK_FRAME (frame
, 0);
1469 #ifdef HAVE_X_WINDOWS
1471 return make_number (x_char_width (f
));
1474 return make_number (1);
1477 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
1478 Sframe_pixel_height
, 0, 1, 0,
1479 "Return a FRAME's height in pixels.\n\
1480 For a terminal frame, the result really gives the height in characters.\n\
1481 If FRAME is omitted, the selected frame is used.")
1491 CHECK_FRAME (frame
, 0);
1495 #ifdef HAVE_X_WINDOWS
1497 return make_number (x_pixel_height (f
));
1500 return make_number (FRAME_HEIGHT (f
));
1503 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
1504 Sframe_pixel_width
, 0, 1, 0,
1505 "Return FRAME's width in pixels.\n\
1506 For a terminal frame, the result really gives the width in characters.\n\
1507 If FRAME is omitted, the selected frame is used.")
1517 CHECK_FRAME (frame
, 0);
1521 #ifdef HAVE_X_WINDOWS
1523 return make_number (x_pixel_width (f
));
1526 return make_number (FRAME_WIDTH (f
));
1529 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1530 "Specify that the frame FRAME has LINES lines.\n\
1531 Optional third arg non-nil means that redisplay should use LINES lines\n\
1532 but that the idea of the actual height of the frame should not be changed.")
1533 (frame
, rows
, pretend
)
1534 Lisp_Object frame
, rows
, pretend
;
1536 register struct frame
*f
;
1538 CHECK_NUMBER (rows
, 0);
1543 CHECK_LIVE_FRAME (frame
, 0);
1547 /* I think this should be done with a hook. */
1548 #ifdef HAVE_X_WINDOWS
1551 if (XINT (rows
) != f
->width
)
1552 x_set_window_size (f
, 1, f
->width
, XINT (rows
));
1556 change_frame_size (f
, XINT (rows
), 0, !NILP (pretend
), 0);
1560 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1561 "Specify that the frame FRAME has COLS columns.\n\
1562 Optional third arg non-nil means that redisplay should use COLS columns\n\
1563 but that the idea of the actual width of the frame should not be changed.")
1564 (frame
, cols
, pretend
)
1565 Lisp_Object frame
, cols
, pretend
;
1567 register struct frame
*f
;
1568 CHECK_NUMBER (cols
, 0);
1573 CHECK_LIVE_FRAME (frame
, 0);
1577 /* I think this should be done with a hook. */
1578 #ifdef HAVE_X_WINDOWS
1581 if (XINT (cols
) != f
->width
)
1582 x_set_window_size (f
, 1, XINT (cols
), f
->height
);
1586 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0);
1590 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1591 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1593 Lisp_Object frame
, cols
, rows
;
1595 register struct frame
*f
;
1598 CHECK_LIVE_FRAME (frame
, 0);
1599 CHECK_NUMBER (cols
, 2);
1600 CHECK_NUMBER (rows
, 1);
1603 /* I think this should be done with a hook. */
1604 #ifdef HAVE_X_WINDOWS
1607 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
)
1608 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
1612 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0);
1617 DEFUN ("set-frame-position", Fset_frame_position
,
1618 Sset_frame_position
, 3, 3, 0,
1619 "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
1620 This is actually the position of the upper left corner of the frame.\n\
1621 Negative values for XOFFSET or YOFFSET are interpreted relative to\n\
1622 the rightmost or bottommost possible position (that stays within the screen).")
1623 (frame
, xoffset
, yoffset
)
1624 Lisp_Object frame
, xoffset
, yoffset
;
1626 register struct frame
*f
;
1629 CHECK_LIVE_FRAME (frame
, 0);
1630 CHECK_NUMBER (xoffset
, 1);
1631 CHECK_NUMBER (yoffset
, 2);
1634 /* I think this should be done with a hook. */
1635 #ifdef HAVE_X_WINDOWS
1637 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
1644 choose_minibuf_frame ()
1646 /* For lowest-level minibuf, put it on currently selected frame
1647 if frame has a minibuffer. */
1649 if (minibuf_level
== 0
1650 && selected_frame
!= 0
1651 && !EQ (minibuf_window
, selected_frame
->minibuffer_window
))
1653 /* I don't think that any frames may validly have a null minibuffer
1655 if (NILP (selected_frame
->minibuffer_window
))
1658 Fset_window_buffer (selected_frame
->minibuffer_window
,
1659 XWINDOW (minibuf_window
)->buffer
);
1660 minibuf_window
= selected_frame
->minibuffer_window
;
1666 /*&&& init symbols here &&&*/
1667 Qframep
= intern ("framep");
1668 staticpro (&Qframep
);
1669 Qframe_live_p
= intern ("frame-live-p");
1670 staticpro (&Qframe_live_p
);
1671 Qheight
= intern ("height");
1672 staticpro (&Qheight
);
1673 Qicon
= intern ("icon");
1675 Qminibuffer
= intern ("minibuffer");
1676 staticpro (&Qminibuffer
);
1677 Qmodeline
= intern ("modeline");
1678 staticpro (&Qmodeline
);
1679 Qname
= intern ("name");
1681 Qonly
= intern ("only");
1683 Qunsplittable
= intern ("unsplittable");
1684 staticpro (&Qunsplittable
);
1685 Qmenu_bar_lines
= intern ("menu-bar-lines");
1686 staticpro (&Qmenu_bar_lines
);
1687 Qwidth
= intern ("width");
1688 staticpro (&Qwidth
);
1691 Qvisible
= intern ("visible");
1692 staticpro (&Qvisible
);
1694 staticpro (&Vframe_list
);
1696 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
1697 "The initial frame-object, which represents Emacs's stdout.");
1699 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
1700 "Non-nil if all of emacs is iconified and frame updates are not needed.");
1701 Vemacs_iconified
= Qnil
;
1703 DEFVAR_LISP ("default-minibuffer-frame", &Vdefault_minibuffer_frame
,
1704 "Minibufferless frames use this frame's minibuffer.\n\
1706 Emacs cannot create minibufferless frames unless this is set to an\n\
1707 appropriate surrogate.\n\
1709 Emacs consults this variable only when creating minibufferless\n\
1710 frames; once the frame is created, it sticks with its assigned\n\
1711 minibuffer, no matter what this variable is set to. This means that\n\
1712 this variable doesn't necessarily say anything meaningful about the\n\
1713 current set of frames, or where the minibuffer is currently being\n\
1715 Vdefault_minibuffer_frame
= Qnil
;
1717 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
1718 "Alist of default values for frame creation.\n\
1719 These may be set in your init file, like this:\n\
1720 (setq default-frame-alist '((width . 80) (height . 55)))\n\
1721 These override values given in window system configuration data, like\n\
1722 X Windows' defaults database.\n\
1723 For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
1724 For values specific to the separate minibuffer frame, see\n\
1725 `minibuffer-frame-alist'.");
1726 Vdefault_frame_alist
= Qnil
;
1729 defsubr (&Sframe_live_p
);
1730 defsubr (&Shandle_switch_frame
);
1731 defsubr (&Sselect_frame
);
1732 defsubr (&Sselected_frame
);
1733 defsubr (&Swindow_frame
);
1734 defsubr (&Sframe_root_window
);
1735 defsubr (&Sframe_first_window
);
1736 defsubr (&Sframe_selected_window
);
1737 defsubr (&Sset_frame_selected_window
);
1738 defsubr (&Sframe_list
);
1739 defsubr (&Snext_frame
);
1740 defsubr (&Sprevious_frame
);
1741 defsubr (&Sdelete_frame
);
1742 defsubr (&Smouse_position
);
1743 defsubr (&Smouse_pixel_position
);
1744 defsubr (&Sset_mouse_position
);
1745 defsubr (&Sset_mouse_pixel_position
);
1747 defsubr (&Sframe_configuration
);
1748 defsubr (&Srestore_frame_configuration
);
1750 defsubr (&Smake_frame_visible
);
1751 defsubr (&Smake_frame_invisible
);
1752 defsubr (&Siconify_frame
);
1753 defsubr (&Sframe_visible_p
);
1754 defsubr (&Svisible_frame_list
);
1755 defsubr (&Sraise_frame
);
1756 defsubr (&Slower_frame
);
1757 defsubr (&Sredirect_frame_focus
);
1758 defsubr (&Sframe_focus
);
1759 defsubr (&Sframe_parameters
);
1760 defsubr (&Smodify_frame_parameters
);
1761 defsubr (&Sframe_char_height
);
1762 defsubr (&Sframe_char_width
);
1763 defsubr (&Sframe_pixel_height
);
1764 defsubr (&Sframe_pixel_width
);
1765 defsubr (&Sset_frame_height
);
1766 defsubr (&Sset_frame_width
);
1767 defsubr (&Sset_frame_size
);
1768 defsubr (&Sset_frame_position
);
1773 initial_define_lispy_key (global_map
, "switch-frame", "handle-switch-frame");
1776 #else /* not MULTI_FRAME */
1778 /* If we're not using multi-frame stuff, we still need to provide some
1779 support functions. */
1781 Lisp_Object Qheight
;
1782 Lisp_Object Qminibuffer
;
1783 Lisp_Object Qmodeline
;
1785 Lisp_Object Qunsplittable
;
1786 Lisp_Object Qmenu_bar_lines
;
1789 Lisp_Object Vterminal_frame
;
1791 /* Unless this function is defined, providing set-frame-height and
1792 set-frame-width doesn't help compatibility any, since they both
1793 want this as their first argument. */
1794 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1795 /* Don't confuse make-docfile by having two doc strings for this function.
1796 make-docfile does not pay attention to #if, for good reason! */
1804 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
1805 /* Don't confuse make-docfile by having two doc strings for this function.
1806 make-docfile does not pay attention to #if, for good reason! */
1814 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1815 /* Don't confuse make-docfile by having two doc strings for this function.
1816 make-docfile does not pay attention to #if, for good reason! */
1818 (frame
, rows
, pretend
)
1819 Lisp_Object frame
, rows
, pretend
;
1821 CHECK_NUMBER (rows
, 0);
1823 change_frame_size (0, XINT (rows
), 0, !NILP (pretend
), 0);
1827 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1828 /* Don't confuse make-docfile by having two doc strings for this function.
1829 make-docfile does not pay attention to #if, for good reason! */
1831 (frame
, cols
, pretend
)
1832 Lisp_Object frame
, cols
, pretend
;
1834 CHECK_NUMBER (cols
, 0);
1836 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1840 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1841 /* Don't confuse make-docfile by having two doc strings for this function.
1842 make-docfile does not pay attention to #if, for good reason! */
1845 Lisp_Object frame
, cols
, rows
;
1847 CHECK_NUMBER (cols
, 2);
1848 CHECK_NUMBER (rows
, 1);
1850 change_frame_size (0, XINT (rows
), XINT (cols
), 0, 0);
1855 DEFUN ("frame-height", Fframe_height
, Sframe_height
, 0, 1, 0,
1856 "Return number of lines available for display on FRAME.\n\
1857 If FRAME is omitted, describe the currently selected frame.")
1861 return make_number (FRAME_HEIGHT (selected_frame
));
1864 DEFUN ("frame-width", Fframe_width
, Sframe_width
, 0, 1, 0,
1865 "Return number of columns available for display on FRAME.\n\
1866 If FRAME is omitted, describe the currently selected frame.")
1870 return make_number (FRAME_WIDTH (selected_frame
));
1873 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
1875 /* Don't confuse make-docfile by having two doc strings for this function.
1876 make-docfile does not pay attention to #if, for good reason! */
1881 return make_number (1);
1885 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
1887 /* Don't confuse make-docfile by having two doc strings for this function.
1888 make-docfile does not pay attention to #if, for good reason! */
1893 return make_number (1);
1896 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
1897 Sframe_pixel_height
, 0, 1, 0,
1898 /* Don't confuse make-docfile by having two doc strings for this function.
1899 make-docfile does not pay attention to #if, for good reason! */
1904 return make_number (FRAME_HEIGHT (f
));
1907 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
1908 Sframe_pixel_width
, 0, 1, 0,
1909 /* Don't confuse make-docfile by having two doc strings for this function.
1910 make-docfile does not pay attention to #if, for good reason! */
1915 return make_number (FRAME_WIDTH (f
));
1918 /* These are for backward compatibility with Emacs 18. */
1920 DEFUN ("set-screen-height", Fset_screen_height
, Sset_screen_height
, 1, 2, 0,
1921 "Tell redisplay that the screen has LINES lines.\n\
1922 Optional second arg non-nil means that redisplay should use LINES lines\n\
1923 but that the idea of the actual height of the screen should not be changed.")
1925 Lisp_Object lines
, pretend
;
1927 CHECK_NUMBER (lines
, 0);
1929 change_frame_size (0, XINT (lines
), 0, !NILP (pretend
), 0);
1933 DEFUN ("set-screen-width", Fset_screen_width
, Sset_screen_width
, 1, 2, 0,
1934 "Tell redisplay that the screen has COLS columns.\n\
1935 Optional second arg non-nil means that redisplay should use COLS columns\n\
1936 but that the idea of the actual width of the screen should not be changed.")
1938 Lisp_Object cols
, pretend
;
1940 CHECK_NUMBER (cols
, 0);
1942 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1946 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1947 /* Don't confuse make-docfile by having two doc strings for this function.
1948 make-docfile does not pay attention to #if, for good reason! */
1952 return Fcons (Qnil
, Fcons (Qnil
, Qnil
));
1956 store_in_alist (alistptr
, prop
, val
)
1957 Lisp_Object
*alistptr
, val
;
1960 register Lisp_Object tem
;
1962 tem
= Fassq (prop
, *alistptr
);
1964 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1969 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
1970 /* Don't confuse make-docfile by having two doc strings for this function.
1971 make-docfile does not pay attention to #if, for good reason! */
1979 if (EQ (frame
, Qnil
))
1983 CHECK_FRAME (frame
, 0);
1987 if (!FRAME_LIVE_P (f
))
1991 store_in_alist (&alist
, Qname
, build_string ("emacs"));
1992 store_in_alist (&alist
, Qheight
, make_number (FRAME_HEIGHT (f
)));
1993 store_in_alist (&alist
, Qwidth
, make_number (FRAME_WIDTH (f
)));
1994 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
1995 store_in_alist (&alist
, Qminibuffer
, FRAME_MINIBUF_WINDOW (f
));
1996 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
1997 store_in_alist (&alist
, Qmenu_bar_lines
, (FRAME_MENU_BAR_LINES (f
)));
2002 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2003 Smodify_frame_parameters
, 2, 2, 0,
2004 /* Don't confuse make-docfile by having two doc strings for this function.
2005 make-docfile does not pay attention to #if, for good reason! */
2008 Lisp_Object frame
, alist
;
2013 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
2014 /* Don't confuse make-docfile by having two doc strings for this function.
2015 make-docfile does not pay attention to #if, for good reason! */
2025 Qheight
= intern ("height");
2026 staticpro (&Qheight
);
2027 Qminibuffer
= intern ("minibuffer");
2028 staticpro (&Qminibuffer
);
2029 Qmodeline
= intern ("modeline");
2030 staticpro (&Qmodeline
);
2031 Qname
= intern ("name");
2033 Qunsplittable
= intern ("unsplittable");
2034 staticpro (&Qunsplittable
);
2035 Qmenu_bar_lines
= intern ("menu-bar-lines");
2036 staticpro (&Qmenu_bar_lines
);
2037 Qwidth
= intern ("width");
2038 staticpro (&Qwidth
);
2040 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
2041 "The initial frame-object, which represents Emacs's stdout.");
2042 XFASTINT (Vterminal_frame
) = 0;
2044 defsubr (&Sselected_frame
);
2046 defsubr (&Sframe_char_height
);
2047 defsubr (&Sframe_char_width
);
2048 defsubr (&Sframe_pixel_height
);
2049 defsubr (&Sframe_pixel_width
);
2050 defsubr (&Sset_frame_height
);
2051 defsubr (&Sset_frame_width
);
2052 defsubr (&Sset_frame_size
);
2053 defsubr (&Sset_screen_height
);
2054 defsubr (&Sset_screen_width
);
2055 defsubr (&Sframe_height
);
2056 Ffset (intern ("screen-height"), intern ("frame-height"));
2057 defsubr (&Sframe_width
);
2058 Ffset (intern ("screen-width"), intern ("frame-width"));
2059 defsubr (&Smouse_position
);
2060 defsubr (&Sframe_parameters
);
2061 defsubr (&Smodify_frame_parameters
);
2062 defsubr (&Sframe_live_p
);
2069 #endif /* not MULTI_FRAME */