1 /* Generic frame functions.
2 Copyright (C) 1989, 1992 Free Software Foundation.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
29 #include "termhooks.h"
31 Lisp_Object Vemacs_iconified
;
32 Lisp_Object Vframe_list
;
33 Lisp_Object Vterminal_frame
;
34 Lisp_Object Vdefault_minibuffer_frame
;
35 Lisp_Object Vdefault_frame_alist
;
37 /* Evaluate this expression to rebuild the section of syms_of_frame
38 that initializes and staticpros the symbols declared below. Note
39 that Emacs 18 has a bug that keeps C-x C-e from being able to
40 evaluate this expression.
43 ;; Accumulate a list of the symbols we want to initialize from the
44 ;; declarations at the top of the file.
45 (goto-char (point-min))
46 (search-forward "/\*&&& symbols declared here &&&*\/\n")
48 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
50 (cons (buffer-substring (match-beginning 1) (match-end 1))
53 (setq symbol-list (nreverse symbol-list))
54 ;; Delete the section of syms_of_... where we initialize the symbols.
55 (search-forward "\n /\*&&& init symbols here &&&*\/\n")
56 (let ((start (point)))
57 (while (looking-at "^ Q")
59 (kill-region start (point)))
60 ;; Write a new symbol initialization section.
62 (insert (format " %s = intern (\"" (car symbol-list)))
63 (let ((start (point)))
64 (insert (substring (car symbol-list) 1))
65 (subst-char-in-region start (point) ?_ ?-))
66 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
67 (setq symbol-list (cdr symbol-list)))))
70 /*&&& symbols declared here &&&*/
72 Lisp_Object Qlive_frame_p
;
75 Lisp_Object Qminibuffer
;
76 Lisp_Object Qmodeline
;
80 Lisp_Object Qunsplittable
;
84 extern Lisp_Object Vminibuffer_list
;
85 extern Lisp_Object
get_minibuffer ();
87 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
88 "Return non-nil if OBJECT is a frame.\n\
89 Value is t for a termcap frame (a character-only terminal),\n\
90 `x' for an Emacs frame that is really an X window.\n\
91 Also see `live-frame-p'.")
95 if (XTYPE (object
) != Lisp_Frame
)
97 switch (XFRAME (object
)->output_method
)
101 case output_x_window
:
108 DEFUN ("live-frame-p", Flive_frame_p
, Slive_frame_p
, 1, 1, 0,
109 "Return non-nil if OBJECT is a frame which has not been deleted.\n\
110 Value is nil if OBJECT is not a live frame. If object is a live\n\
111 frame, the return value indicates what sort of output device it is\n\
112 displayed on. Value is t for a termcap frame (a character-only\n\
113 terminal), `x' for an Emacs frame being displayed in an X window.")
117 return ((FRAMEP (object
)
118 && FRAME_LIVE_P (XFRAME (object
)))
128 register struct frame
*f
;
129 register Lisp_Object root_window
;
130 register Lisp_Object mini_window
;
132 frame
= Fmake_vector (((sizeof (struct frame
) - (sizeof (Lisp_Vector
)
133 - sizeof (Lisp_Object
)))
134 / sizeof (Lisp_Object
)),
136 XSETTYPE (frame
, Lisp_Frame
);
141 f
->current_glyphs
= 0;
142 f
->desired_glyphs
= 0;
144 f
->display
.nothing
= 0;
146 f
->wants_modeline
= 1;
151 f
->has_minibuffer
= mini_p
;
152 f
->focus_frame
= frame
;
154 f
->param_alist
= Qnil
;
156 root_window
= make_window ();
159 mini_window
= make_window ();
160 XWINDOW (root_window
)->next
= mini_window
;
161 XWINDOW (mini_window
)->prev
= root_window
;
162 XWINDOW (mini_window
)->mini_p
= Qt
;
163 XWINDOW (mini_window
)->frame
= frame
;
164 f
->minibuffer_window
= mini_window
;
169 XWINDOW (root_window
)->next
= Qnil
;
170 f
->minibuffer_window
= Qnil
;
173 XWINDOW (root_window
)->frame
= frame
;
176 just so that there is "something there."
177 Correct size will be set up later with change_frame_size. */
182 XFASTINT (XWINDOW (root_window
)->width
) = 10;
183 XFASTINT (XWINDOW (root_window
)->height
) = (mini_p
? 9 : 10);
187 XFASTINT (XWINDOW (mini_window
)->width
) = 10;
188 XFASTINT (XWINDOW (mini_window
)->top
) = 9;
189 XFASTINT (XWINDOW (mini_window
)->height
) = 1;
192 /* Choose a buffer for the frame's root window. */
196 XWINDOW (root_window
)->buffer
= Qt
;
197 buf
= Fcurrent_buffer ();
198 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
199 a space), try to find another one. */
200 if (XSTRING (Fbuffer_name (buf
))->data
[0] == ' ')
201 buf
= Fother_buffer (buf
);
202 Fset_window_buffer (root_window
, buf
);
207 XWINDOW (mini_window
)->buffer
= Qt
;
208 Fset_window_buffer (mini_window
,
209 (NILP (Vminibuffer_list
)
211 : Fcar (Vminibuffer_list
)));
214 f
->root_window
= root_window
;
215 f
->selected_window
= root_window
;
216 /* Make sure this window seems more recently used than
217 a newly-created, never-selected window. */
218 XFASTINT (XWINDOW (f
->selected_window
)->use_time
) = ++window_select_count
;
220 Vframe_list
= Fcons (frame
, Vframe_list
);
225 /* Make a frame using a separate minibuffer window on another frame.
226 MINI_WINDOW is the minibuffer window to use. nil means use the
227 default (the global minibuffer). */
230 make_frame_without_minibuffer (mini_window
)
231 register Lisp_Object mini_window
;
233 register struct frame
*f
;
235 /* Choose the minibuffer window to use. */
236 if (NILP (mini_window
))
238 if (XTYPE (Vdefault_minibuffer_frame
) != Lisp_Frame
)
239 error ("default-minibuffer-frame must be set when creating minibufferless frames");
240 if (! FRAME_LIVE_P (XFRAME (Vdefault_minibuffer_frame
)))
241 error ("default-minibuffer-frame must be a live frame");
242 mini_window
= XFRAME (Vdefault_minibuffer_frame
)->minibuffer_window
;
246 CHECK_WINDOW (mini_window
, 0);
249 /* Make a frame containing just a root window. */
252 /* Install the chosen minibuffer window, with proper buffer. */
253 f
->minibuffer_window
= mini_window
;
254 Fset_window_buffer (mini_window
,
255 (NILP (Vminibuffer_list
)
257 : Fcar (Vminibuffer_list
)));
261 /* Make a frame containing only a minibuffer window. */
264 make_minibuffer_frame ()
266 /* First make a frame containing just a root window, no minibuffer. */
268 register struct frame
*f
= make_frame (0);
269 register Lisp_Object mini_window
;
270 register Lisp_Object frame
;
272 XSET (frame
, Lisp_Frame
, f
);
274 /* ??? Perhaps leave it to the user program to set auto_raise. */
278 f
->wants_modeline
= 0;
279 f
->has_minibuffer
= 1;
281 /* Now label the root window as also being the minibuffer.
282 Avoid infinite looping on the window chain by marking next pointer
285 mini_window
= f
->minibuffer_window
= f
->root_window
;
286 XWINDOW (mini_window
)->mini_p
= Qt
;
287 XWINDOW (mini_window
)->next
= Qnil
;
288 XWINDOW (mini_window
)->prev
= mini_window
;
289 XWINDOW (mini_window
)->frame
= frame
;
291 /* Put the proper buffer in that window. */
293 Fset_window_buffer (mini_window
,
294 (NILP (Vminibuffer_list
)
296 : Fcar (Vminibuffer_list
)));
300 /* Construct a frame that refers to the terminal (stdin and stdout). */
303 make_terminal_frame ()
305 register struct frame
*f
;
309 f
->name
= build_string ("terminal");
311 f
->display
.nothing
= 1; /* Nonzero means frame isn't deleted. */
312 XSET (Vterminal_frame
, Lisp_Frame
, f
);
316 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, 0,
317 "Select the frame FRAME. FRAMES's selected window becomes \"the\"\n\
318 selected window. If the optional parameter NO-ENTER is non-nil, don't\n\
319 focus on that frame.")
321 Lisp_Object frame
, no_enter
;
323 CHECK_LIVE_FRAME (frame
, 0);
325 if (selected_frame
== XFRAME (frame
))
328 selected_frame
= XFRAME (frame
);
329 if (! FRAME_MINIBUF_ONLY_P (selected_frame
))
330 last_nonminibuf_frame
= selected_frame
;
332 Fselect_window (XFRAME (frame
)->selected_window
);
334 #ifdef HAVE_X_WINDOWS
336 if (FRAME_X_P (XFRAME (frame
))
339 Ffocus_frame (frame
);
343 choose_minibuf_frame ();
348 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
349 "Return the frame that is now selected.")
353 XSET (tem
, Lisp_Frame
, selected_frame
);
357 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
358 "Return the frame object that window WINDOW is on.")
362 CHECK_WINDOW (window
, 0);
363 return XWINDOW (window
)->frame
;
366 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
367 "Returns the root-window of FRAME.")
372 XSET (frame
, Lisp_Frame
, selected_frame
);
374 CHECK_LIVE_FRAME (frame
, 0);
376 return XFRAME (frame
)->root_window
;
379 DEFUN ("frame-selected-window", Fframe_selected_window
,
380 Sframe_selected_window
, 0, 1, 0,
381 "Return the selected window of frame object FRAME.")
386 XSET (frame
, Lisp_Frame
, selected_frame
);
388 CHECK_LIVE_FRAME (frame
, 0);
390 return XFRAME (frame
)->selected_window
;
393 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
395 "Return a list of all frames.")
398 return Fcopy_sequence (Vframe_list
);
403 /* Return the next frame in the frame list after FRAME.
404 If MINIBUF is non-nil, include all frames.
405 If MINIBUF is nil, exclude minibuffer-only frames.
406 If MINIBUF is a window, include only frames using that window for
409 next_frame (frame
, minibuf
)
416 /* There must always be at least one frame in Vframe_list. */
417 if (! CONSP (Vframe_list
))
421 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
425 Lisp_Object f
= XCONS (tail
)->car
;
427 /* Decide whether this frame is eligible to be returned,
428 according to minibuf. */
429 if ((NILP (minibuf
) && ! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
430 || XTYPE (minibuf
) != Lisp_Window
431 || EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
436 if (EQ (frame
, XCONS (tail
)->car
))
441 /* Return the previous frame in the frame list before FRAME.
442 If MINIBUF is non-nil, include all frames.
443 If MINIBUF is nil, exclude minibuffer-only frames.
444 If MINIBUF is a window, include only frames using that window for
447 prev_frame (frame
, minibuf
)
454 /* There must always be at least one frame in Vframe_list. */
455 if (! CONSP (Vframe_list
))
461 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
463 Lisp_Object scr
= XCONS (tail
)->car
;
465 if (XTYPE (scr
) != Lisp_Frame
)
468 if (EQ (frame
, scr
) && !NILP (prev
))
471 /* Decide whether this frame is eligible to be returned,
472 according to minibuf. */
473 if ((NILP (minibuf
) && ! FRAME_MINIBUF_ONLY_P (XFRAME (scr
)))
474 || XTYPE (minibuf
) != Lisp_Window
475 || EQ (FRAME_MINIBUF_WINDOW (XFRAME (scr
)), minibuf
))
480 /* We went through the whole frame list without finding a single
481 acceptable frame. Return the original frame. */
487 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
488 "Return the next frame in the frame list after FRAME.\n\
489 If optional argument MINIBUF is non-nil, include all frames. If\n\
490 MINIBUF is nil or omitted, exclude minibuffer-only frames. If\n\
491 MINIBUF is a window, include only frames using that window for their\n\
494 Lisp_Object frame
, miniframe
;
499 XSET (frame
, Lisp_Frame
, selected_frame
);
501 CHECK_LIVE_FRAME (frame
, 0);
503 return next_frame (frame
, miniframe
);
505 #endif /* MULTI_FRAME */
507 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 1, "",
508 "Delete FRAME, permanently eliminating it from use.\n\
509 If omitted, FRAME defaults to the selected frame.\n\
510 A frame may not be deleted if its minibuffer is used by other frames.")
517 if (EQ (frame
, Qnil
))
520 XSET (frame
, Lisp_Frame
, f
);
524 CHECK_FRAME (frame
, 0);
528 if (! FRAME_LIVE_P (f
))
531 /* Are there any other frames besides this one? */
532 if (f
== selected_frame
&& EQ (next_frame (frame
, Qt
), frame
))
533 error ("Attempt to delete the only frame");
535 /* Does this frame have a minibuffer, and is it the surrogate
536 minibuffer for any other frame? */
537 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
541 for (frames
= Vframe_list
;
543 frames
= XCONS (frames
)->cdr
)
545 Lisp_Object
this = XCONS (frames
)->car
;
547 if (! EQ (this, frame
)
551 (FRAME_MINIBUF_WINDOW
553 error ("Attempt to delete a surrogate minibuffer frame");
557 /* Don't let the frame remain selected. */
558 if (f
== selected_frame
)
559 Fselect_frame (next_frame (frame
, Qt
));
561 /* Don't allow minibuf_window to remain on a deleted frame. */
562 if (EQ (f
->minibuffer_window
, minibuf_window
))
564 Fset_window_buffer (selected_frame
->minibuffer_window
,
565 XWINDOW (minibuf_window
)->buffer
);
566 minibuf_window
= selected_frame
->minibuffer_window
;
569 Vframe_list
= Fdelq (frame
, Vframe_list
);
572 f
->display
.nothing
= 0;
574 #ifdef HAVE_X_WINDOWS
576 x_destroy_window (f
, displ
);
579 /* If we've deleted the last_nonminibuf_frame, then try to find
581 if (f
== last_nonminibuf_frame
)
585 last_nonminibuf_frame
= 0;
587 for (frames
= Vframe_list
;
589 frames
= XCONS (frames
)->cdr
)
591 f
= XFRAME (XCONS (frames
)->car
);
592 if (!FRAME_MINIBUF_ONLY_P (f
))
594 last_nonminibuf_frame
= f
;
600 /* If we've deleted Vdefault_minibuffer_frame, try to find another
601 one. Prefer minibuffer-only frames, but also notice frames
602 with other windows. */
603 if (EQ (frame
, Vdefault_minibuffer_frame
))
607 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
608 Lisp_Object frame_with_minibuf
= Qnil
;
610 for (frames
= Vframe_list
;
612 frames
= XCONS (frames
)->cdr
)
614 Lisp_Object
this = XCONS (frames
)->car
;
616 if (XTYPE (this) != Lisp_Frame
)
620 if (FRAME_HAS_MINIBUF_P (f
))
622 frame_with_minibuf
= this;
623 if (FRAME_MINIBUF_ONLY_P (f
))
628 /* We know that there must be some frame with a minibuffer out
629 there. If this were not true, all of the frames present
630 would have to be minibufferless, which implies that at some
631 point their minibuffer frames must have been deleted, but
632 that is prohibited at the top; you can't delete surrogate
633 minibuffer frames. */
634 if (NILP (frame_with_minibuf
))
637 Vdefault_minibuffer_frame
= frame_with_minibuf
;
643 /* Return mouse position in character cell units. */
645 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
646 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
647 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
648 to read the mouse position, it returns the selected frame for FRAME\n\
649 and nil for X and Y.")
652 Lisp_Object x
, y
, dummy
;
655 if (mouse_position_hook
)
656 (*mouse_position_hook
) (&f
, &x
, &y
, &dummy
);
663 XSET (dummy
, Lisp_Frame
, f
);
664 return Fcons (dummy
, Fcons (make_number (x
), make_number (y
)));
667 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
668 "Move the mouse pointer to the center of cell (X,Y) in FRAME.\n\
669 WARNING: If you use this under X, you should do `unfocus-frame' afterwards.")
671 Lisp_Object frame
, x
, y
;
673 CHECK_LIVE_FRAME (frame
, 0);
677 #ifdef HAVE_X_WINDOWS
678 if (FRAME_X_P (XFRAME (frame
)))
679 /* Warping the mouse will cause enternotify and focus events. */
680 x_set_mouse_position (XFRAME (frame
), x
, y
);
687 /* ??? Can this be replaced with a Lisp function?
688 It is used in minibuf.c. Can we get rid of that?
689 Yes. All uses in minibuf.c are gone, and parallels to these
690 functions have been defined in frame.el. */
692 DEFUN ("frame-configuration", Fframe_configuration
, Sframe_configuration
,
694 "Return object describing current frame configuration.\n\
695 The frame configuration is the current mouse position and selected frame.\n\
696 This object can be given to `restore-frame-configuration'\n\
697 to restore this frame configuration.")
702 c
= Fmake_vector (make_number(4), Qnil
);
703 XVECTOR (c
)->contents
[0] = Fselected_frame();
704 if (mouse_position_hook
)
705 (*mouse_position_hook
) (&XVECTOR (c
)->contents
[1]
706 &XVECTOR (c
)->contents
[2],
707 &XVECTOR (c
)->contents
[3],
712 DEFUN ("restore-frame-configuration", Frestore_frame_configuration
,
713 Srestore_frame_configuration
,
715 "Restores frame configuration CONFIGURATION.")
719 Lisp_Object x_pos
, y_pos
, frame
;
721 CHECK_VECTOR (config
, 0);
722 if (XVECTOR (config
)->size
!= 3)
724 error ("Wrong size vector passed to restore-frame-configuration");
726 frame
= XVECTOR (config
)->contents
[0];
727 CHECK_LIVE_FRAME (frame
, 0);
729 Fselect_frame (frame
, Qnil
);
732 /* This seems to interfere with the frame selection mechanism. jla */
733 x_pos
= XVECTOR (config
)->contents
[2];
734 y_pos
= XVECTOR (config
)->contents
[3];
735 set_mouse_position (frame
, XINT (x_pos
), XINT (y_pos
));
742 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
744 "Make the frame FRAME visible (assuming it is an X-window).\n\
745 Also raises the frame so that nothing obscures it.")
750 XSET (frame
, Lisp_Frame
, selected_frame
);
752 CHECK_LIVE_FRAME (frame
, 0);
754 #ifdef HAVE_X_WINDOWS
755 if (FRAME_X_P (XFRAME (frame
)))
756 x_make_frame_visible (XFRAME (frame
));
762 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
764 "Make the frame FRAME invisible (assuming it is an X-window).")
769 XSET (frame
, Lisp_Frame
, selected_frame
);
771 CHECK_LIVE_FRAME (frame
, 0);
773 #ifdef HAVE_X_WINDOWS
774 if (FRAME_X_P (XFRAME (frame
)))
775 x_make_frame_invisible (XFRAME (frame
));
781 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
783 "Make the frame FRAME into an icon.")
788 XSET (frame
, Lisp_Frame
, selected_frame
);
790 CHECK_LIVE_FRAME (frame
, 0);
792 #ifdef HAVE_X_WINDOWS
793 if (FRAME_X_P (XFRAME (frame
)))
794 x_iconify_frame (XFRAME (frame
));
800 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
802 "Return t if FRAME is now \"visible\" (actually in use for display).\n\
803 A frame that is not \"visible\" is not updated and, if it works through\n\
804 a window system, it may not show at all.\n\
805 Return the symbol `icon' if frame is visible only as an icon.")
809 CHECK_LIVE_FRAME (frame
, 0);
811 if (XFRAME (frame
)->visible
)
813 if (XFRAME (frame
)->iconified
)
818 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
820 "Return a list of all frames now \"visible\" (being updated).")
823 Lisp_Object tail
, frame
;
828 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
830 frame
= XCONS (tail
)->car
;
831 if (XTYPE (frame
) != Lisp_Frame
)
835 value
= Fcons (frame
, value
);
842 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
844 "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
845 This means that, after reading a keystroke typed at FRAME,\n\
846 `last-event-frame' will be FOCUS-FRAME.\n\
848 If FOCUS-FRAME is omitted or eq to FRAME, any existing redirection is\n\
849 cancelled, and the frame again receives its own keystrokes.\n\
851 The redirection lasts until the next call to `redirect-frame-focus'\n\
852 or `select-frame'.\n\
854 This is useful for temporarily redirecting keystrokes to the minibuffer\n\
855 window when a frame doesn't have its own minibuffer.")
857 Lisp_Object frame
, focus_frame
;
859 CHECK_LIVE_FRAME (frame
, 0);
861 if (NILP (focus_frame
))
864 CHECK_LIVE_FRAME (focus_frame
, 1);
866 XFRAME (frame
)->focus_frame
= focus_frame
;
868 if (frame_rehighlight_hook
)
869 (*frame_rehighlight_hook
) ();
875 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
876 "Return the frame to which FRAME's keystrokes are currently being sent.\n\
877 See `redirect-frame-focus'.")
881 CHECK_LIVE_FRAME (frame
, 0);
882 return FRAME_FOCUS_FRAME (XFRAME (frame
));
888 get_frame_param (frame
, prop
)
889 register struct frame
*frame
;
892 register Lisp_Object tem
;
894 tem
= Fassq (prop
, frame
->param_alist
);
901 store_in_alist (alistptr
, prop
, val
)
902 Lisp_Object
*alistptr
, val
;
905 register Lisp_Object tem
;
907 tem
= Fassq (prop
, *alistptr
);
909 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
915 store_frame_param (f
, prop
, val
)
917 Lisp_Object prop
, val
;
919 register Lisp_Object tem
;
921 tem
= Fassq (prop
, f
->param_alist
);
923 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
927 if (EQ (prop
, Qminibuffer
)
928 && XTYPE (val
) == Lisp_Window
)
930 if (! MINI_WINDOW_P (XWINDOW (val
)))
931 error ("Surrogate minibuffer windows must be minibuffer windows.");
933 if (FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
934 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer.");
936 /* Install the chosen minibuffer window, with proper buffer. */
937 f
->minibuffer_window
= val
;
941 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
942 "Return the parameters-alist of frame FRAME.\n\
943 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
944 The meaningful PARMs depend on the kind of frame.\n\
945 If FRAME is omitted, return information on the currently selected frame.")
952 if (EQ (frame
, Qnil
))
956 CHECK_FRAME (frame
, 0);
960 if (f
->display
.nothing
== 0)
963 alist
= Fcopy_alist (f
->param_alist
);
964 store_in_alist (&alist
, Qname
, f
->name
);
965 store_in_alist (&alist
, Qheight
, make_number (f
->height
));
966 store_in_alist (&alist
, Qwidth
, make_number (f
->width
));
967 store_in_alist (&alist
, Qmodeline
, (f
->wants_modeline
? Qt
: Qnil
));
968 store_in_alist (&alist
, Qminibuffer
,
969 (! FRAME_HAS_MINIBUF_P (f
) ? Qnone
970 : (FRAME_MINIBUF_ONLY_P (f
) ? Qonly
971 : FRAME_MINIBUF_WINDOW (f
))));
972 store_in_alist (&alist
, Qunsplittable
, (f
->no_split
? Qt
: Qnil
));
974 #ifdef HAVE_X_WINDOWS
976 x_report_frame_params (f
, &alist
);
981 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
982 Smodify_frame_parameters
, 2, 2, 0,
983 "Modify the parameters of frame FRAME according to ALIST.\n\
984 ALIST is an alist of parameters to change and their new values.\n\
985 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
986 The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
988 Lisp_Object frame
, alist
;
991 register Lisp_Object tail
, elt
, prop
, val
;
993 if (EQ (frame
, Qnil
))
997 CHECK_LIVE_FRAME (frame
, 0);
1001 #ifdef HAVE_X_WINDOWS
1004 x_set_frame_parameters (f
, alist
);
1006 for (tail
= alist
; !EQ (tail
, Qnil
); tail
= Fcdr (tail
))
1011 x_set_frame_param (f
, prop
, val
, get_frame_param (f
, prop
));
1012 store_frame_param (f
, prop
, val
);
1022 /* This function isn't useful enough by itself to include; we need to
1023 add functions to allow the user to find the size of a font before
1024 this is actually useful. */
1026 DEFUN ("frame-pixel-size", Fframe_pixel_size
,
1027 Sframe_pixel_size
, 1, 1, 0,
1028 "Return a cons (width . height) of FRAME's size in pixels.")
1032 register struct frame
*f
;
1035 CHECK_LIVE_FRAME (frame
, 0);
1038 return Fcons (make_number (x_pixel_width (f
)),
1039 make_number (x_pixel_height (f
)));
1044 /* These functions have no C callers, and can be written nicely in lisp. */
1046 DEFUN ("frame-height", Fframe_height
, Sframe_height
, 0, 0, 0,
1047 "Return number of lines available for display on selected frame.")
1050 return make_number (FRAME_HEIGHT (selected_frame
));
1053 DEFUN ("frame-width", Fframe_width
, Sframe_width
, 0, 0, 0,
1054 "Return number of columns available for display on selected frame.")
1057 return make_number (FRAME_WIDTH (selected_frame
));
1061 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1062 "Specify that the frame FRAME has LINES lines.\n\
1063 Optional third arg non-nil means that redisplay should use LINES lines\n\
1064 but that the idea of the actual height of the frame should not be changed.")
1065 (frame
, rows
, pretend
)
1066 Lisp_Object frame
, rows
, pretend
;
1068 register struct frame
*f
;
1070 CHECK_NUMBER (rows
, 0);
1075 CHECK_LIVE_FRAME (frame
, 0);
1079 #ifdef HAVE_X_WINDOWS
1082 if (XINT (rows
) != f
->width
)
1083 x_set_window_size (f
, f
->width
, XINT (rows
));
1087 change_frame_size (f
, XINT (rows
), 0, !NILP (pretend
), 0);
1091 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1092 "Specify that the frame FRAME has COLS columns.\n\
1093 Optional third arg non-nil means that redisplay should use COLS columns\n\
1094 but that the idea of the actual width of the frame should not be changed.")
1095 (frame
, cols
, pretend
)
1096 Lisp_Object frame
, cols
, pretend
;
1098 register struct frame
*f
;
1099 CHECK_NUMBER (cols
, 0);
1104 CHECK_LIVE_FRAME (frame
, 0);
1108 #ifdef HAVE_X_WINDOWS
1111 if (XINT (cols
) != f
->width
)
1112 x_set_window_size (f
, XINT (cols
), f
->height
);
1116 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0);
1120 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1121 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1123 Lisp_Object frame
, cols
, rows
;
1125 register struct frame
*f
;
1128 CHECK_LIVE_FRAME (frame
, 0);
1129 CHECK_NUMBER (cols
, 2);
1130 CHECK_NUMBER (rows
, 1);
1133 #ifdef HAVE_X_WINDOWS
1136 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
)
1137 x_set_window_size (f
, XINT (cols
), XINT (rows
));
1141 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0);
1146 DEFUN ("set-frame-position", Fset_frame_position
,
1147 Sset_frame_position
, 3, 3, 0,
1148 "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
1149 If XOFFSET or YOFFSET are negative, they are interpreted relative to\n\
1150 the leftmost or bottommost position FRAME could occupy without going\n\
1152 (frame
, xoffset
, yoffset
)
1153 Lisp_Object frame
, xoffset
, yoffset
;
1155 register struct frame
*f
;
1158 CHECK_LIVE_FRAME (frame
, 0);
1159 CHECK_NUMBER (xoffset
, 1);
1160 CHECK_NUMBER (yoffset
, 2);
1163 #ifdef HAVE_X_WINDOWS
1165 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
));
1173 DEFUN ("rubber-band-rectangle", Frubber_band_rectangle
, Srubber_band_rectangle
,
1175 "Ask user to specify a window position and size on FRAME with the mouse.\n\
1176 Arguments are FRAME, NAME and GEO. NAME is a name to be displayed as\n\
1177 the purpose of this rectangle. GEO is an X-windows size spec that can\n\
1178 specify defaults for some sizes/positions. If GEO specifies everything,\n\
1179 the mouse is not used.\n\
1180 Returns a list of five values: (FRAME LEFT TOP WIDTH HEIGHT).")
1187 Lisp_Object nums
[4];
1190 CHECK_FRAME (frame
, 0);
1191 CHECK_STRING (name
, 1);
1192 CHECK_STRING (geo
, 2);
1194 switch (XFRAME (frame
)->output_method
)
1196 case output_x_window
:
1197 x_rubber_band (XFRAME (frame
), &vals
[0], &vals
[1], &vals
[2], &vals
[3],
1198 XSTRING (geo
)->data
, XSTRING (name
)->data
);
1205 for (i
= 0; i
< 4; i
++)
1206 XFASTINT (nums
[i
]) = vals
[i
];
1207 return Fcons (frame
, Flist (4, nums
));
1210 #endif /* not HAVE_X11 */
1212 choose_minibuf_frame ()
1214 /* For lowest-level minibuf, put it on currently selected frame
1215 if frame has a minibuffer. */
1216 if (minibuf_level
== 0
1217 && selected_frame
!= 0
1218 && !EQ (minibuf_window
, selected_frame
->minibuffer_window
)
1219 && !EQ (Qnil
, selected_frame
->minibuffer_window
))
1221 Fset_window_buffer (selected_frame
->minibuffer_window
,
1222 XWINDOW (minibuf_window
)->buffer
);
1223 minibuf_window
= selected_frame
->minibuffer_window
;
1229 /*&&& init symbols here &&&*/
1230 Qframep
= intern ("framep");
1231 staticpro (&Qframep
);
1232 Qlive_frame_p
= intern ("live-frame-p");
1233 staticpro (&Qlive_frame_p
);
1234 Qheight
= intern ("height");
1235 staticpro (&Qheight
);
1236 Qicon
= intern ("icon");
1238 Qminibuffer
= intern ("minibuffer");
1239 staticpro (&Qminibuffer
);
1240 Qmodeline
= intern ("modeline");
1241 staticpro (&Qmodeline
);
1242 Qname
= intern ("name");
1244 Qnone
= intern ("none");
1246 Qonly
= intern ("only");
1248 Qunsplittable
= intern ("unsplittable");
1249 staticpro (&Qunsplittable
);
1250 Qwidth
= intern ("width");
1251 staticpro (&Qwidth
);
1255 staticpro (&Vframe_list
);
1257 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
1258 "The initial frame-object, which represents Emacs's stdout.");
1260 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
1261 "Non-nil if all of emacs is iconified and frame updates are not needed.");
1262 Vemacs_iconified
= Qnil
;
1264 DEFVAR_LISP ("default-minibuffer-frame", &Vdefault_minibuffer_frame
,
1265 "Minibufferless frames use this frame's minibuffer.\n\
1267 Emacs cannot create minibufferless frames unless this is set to an\n\
1268 appropriate surrogate.\n\
1270 Emacs consults this variable only when creating minibufferless\n\
1271 frames; once the frame is created, it sticks with its assigned\n\
1272 minibuffer, no matter what this variable is set to. This means that\n\
1273 this variable doesn't necessarily say anything meaningful about the\n\
1274 current set of frames, or where the minibuffer is currently being\n\
1276 Vdefault_minibuffer_frame
= Qnil
;
1278 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
1279 "Alist of default values for frame creation.\n\
1280 These may be set in your init file, like this:\n\
1281 (setq default-frame-alist '((width . 80) (height . 55)))\n\
1282 These override values given in window system configuration data, like\n\
1283 X Windows' defaults database.\n\
1284 For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
1285 For values specific to the separate minibuffer frame, see\n\
1286 `minibuffer-frame-alist'.");
1287 Vdefault_frame_alist
= Qnil
;
1290 defsubr (&Slive_frame_p
);
1291 defsubr (&Sselect_frame
);
1292 defsubr (&Sselected_frame
);
1293 defsubr (&Swindow_frame
);
1294 defsubr (&Sframe_root_window
);
1295 defsubr (&Sframe_selected_window
);
1296 defsubr (&Sframe_list
);
1297 defsubr (&Snext_frame
);
1298 defsubr (&Sdelete_frame
);
1299 defsubr (&Smouse_position
);
1300 defsubr (&Sset_mouse_position
);
1302 defsubr (&Sframe_configuration
);
1303 defsubr (&Srestore_frame_configuration
);
1305 defsubr (&Smake_frame_visible
);
1306 defsubr (&Smake_frame_invisible
);
1307 defsubr (&Siconify_frame
);
1308 defsubr (&Sframe_visible_p
);
1309 defsubr (&Svisible_frame_list
);
1310 defsubr (&Sredirect_frame_focus
);
1311 defsubr (&Sframe_focus
);
1312 defsubr (&Sframe_parameters
);
1313 defsubr (&Smodify_frame_parameters
);
1315 defsubr (&Sframe_pixel_size
);
1316 defsubr (&Sframe_height
);
1317 defsubr (&Sframe_width
);
1319 defsubr (&Sset_frame_height
);
1320 defsubr (&Sset_frame_width
);
1321 defsubr (&Sset_frame_size
);
1322 defsubr (&Sset_frame_position
);
1324 defsubr (&Srubber_band_rectangle
);
1325 #endif /* HAVE_X11 */
1328 #else /* not MULTI_SCREEN */
1330 /* If we're not using multi-frame stuff, we still need to provide some
1331 support functions. */
1333 /* Unless this function is defined, providing set-frame-height and
1334 set-frame-width doesn't help compatibility any, since they both
1335 want this as their first argument. */
1336 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1337 "Return the frame that is now selected.")
1345 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1346 "Specify that the frame FRAME has LINES lines.\n\
1347 Optional third arg non-nil means that redisplay should use LINES lines\n\
1348 but that the idea of the actual height of the frame should not be changed.")
1349 (frame
, rows
, pretend
)
1350 Lisp_Object frame
, rows
, pretend
;
1352 CHECK_NUMBER (rows
, 0);
1354 change_frame_size (0, XINT (rows
), 0, !NILP (pretend
), 0);
1358 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1359 "Specify that the frame FRAME has COLS columns.\n\
1360 Optional third arg non-nil means that redisplay should use COLS columns\n\
1361 but that the idea of the actual width of the frame should not be changed.")
1362 (frame
, cols
, pretend
)
1363 Lisp_Object frame
, cols
, pretend
;
1365 CHECK_NUMBER (cols
, 0);
1367 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1371 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1372 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1374 Lisp_Object frame
, cols
, rows
;
1376 CHECK_NUMBER (cols
, 2);
1377 CHECK_NUMBER (rows
, 1);
1379 change_frame_size (0, XINT (rows
), XINT (cols
), 0, 0);
1384 DEFUN ("frame-height", Fframe_height
, Sframe_height
, 0, 0, 0,
1385 "Return number of lines available for display on selected frame.")
1388 return make_number (FRAME_HEIGHT (selected_frame
));
1391 DEFUN ("frame-width", Fframe_width
, Sframe_width
, 0, 0, 0,
1392 "Return number of columns available for display on selected frame.")
1395 return make_number (FRAME_WIDTH (selected_frame
));
1398 /* These are for backward compatibility with Emacs 18. */
1400 DEFUN ("set-screen-height", Fset_screen_height
, Sset_screen_height
, 1, 2, 0,
1401 "Tell redisplay that the screen has LINES lines.\n\
1402 Optional second arg non-nil means that redisplay should use LINES lines\n\
1403 but that the idea of the actual height of the screen should not be changed.")
1405 Lisp_Object lines
, pretend
;
1407 CHECK_NUMBER (lines
, 0);
1409 change_frame_size (0, XINT (lines
), 0, !NILP (pretend
), 0);
1413 DEFUN ("set-screen-width", Fset_screen_width
, Sset_screen_width
, 1, 2, 0,
1414 "Tell redisplay that the screen has COLS columns.\n\
1415 Optional second arg non-nil means that redisplay should use COLS columns\n\
1416 but that the idea of the actual width of the screen should not be changed.")
1418 Lisp_Object cols
, pretend
;
1420 CHECK_NUMBER (cols
, 0);
1422 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1428 defsubr (&Sset_frame_height
);
1429 defsubr (&Sset_frame_width
);
1430 defsubr (&Sset_frame_size
);
1431 defsubr (&Sset_screen_height
);
1432 defsubr (&Sset_screen_width
);
1433 defsubr (&Sframe_height
);
1434 Ffset (intern ("screen-height"), intern ("frame-height"));
1435 defsubr (&Sframe_width
);
1436 Ffset (intern ("screen-width"), intern ("frame-width"));
1439 #endif /* not MULTI_FRAME */