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"
35 /* These help us bind and responding to switch-frame events. */
39 Lisp_Object Vemacs_iconified
;
40 Lisp_Object Vframe_list
;
41 Lisp_Object Vterminal_frame
;
42 Lisp_Object Vdefault_minibuffer_frame
;
43 Lisp_Object Vdefault_frame_alist
;
45 /* Evaluate this expression to rebuild the section of syms_of_frame
46 that initializes and staticpros the symbols declared below. Note
47 that Emacs 18 has a bug that keeps C-x C-e from being able to
48 evaluate this expression.
51 ;; Accumulate a list of the symbols we want to initialize from the
52 ;; declarations at the top of the file.
53 (goto-char (point-min))
54 (search-forward "/\*&&& symbols declared here &&&*\/\n")
56 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
58 (cons (buffer-substring (match-beginning 1) (match-end 1))
61 (setq symbol-list (nreverse symbol-list))
62 ;; Delete the section of syms_of_... where we initialize the symbols.
63 (search-forward "\n /\*&&& init symbols here &&&*\/\n")
64 (let ((start (point)))
65 (while (looking-at "^ Q")
67 (kill-region start (point)))
68 ;; Write a new symbol initialization section.
70 (insert (format " %s = intern (\"" (car symbol-list)))
71 (let ((start (point)))
72 (insert (substring (car symbol-list) 1))
73 (subst-char-in-region start (point) ?_ ?-))
74 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
75 (setq symbol-list (cdr symbol-list)))))
78 /*&&& symbols declared here &&&*/
80 Lisp_Object Qframe_live_p
;
83 Lisp_Object Qminibuffer
;
84 Lisp_Object Qmodeline
;
87 Lisp_Object Qunsplittable
;
88 Lisp_Object Qmenu_bar_lines
;
92 Lisp_Object Qbuffer_predicate
;
94 extern Lisp_Object Vminibuffer_list
;
95 extern Lisp_Object
get_minibuffer ();
96 extern Lisp_Object
Fhandle_switch_frame ();
97 extern Lisp_Object
Fredirect_frame_focus ();
99 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
100 "Return non-nil if OBJECT is a frame.\n\
101 Value is t for a termcap frame (a character-only terminal),\n\
102 `x' for an Emacs frame that is really an X window,\n\
103 `pc' for a direct-write MS-DOS frame.\n\
104 Also see `live-frame-p'.")
108 if (!FRAMEP (object
))
110 switch (XFRAME (object
)->output_method
)
114 case output_x_window
:
116 /* The `pc' case is in the Fframep below. */
122 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
123 "Return non-nil if OBJECT is a frame which has not been deleted.\n\
124 Value is nil if OBJECT is not a live frame. If object is a live\n\
125 frame, the return value indicates what sort of output device it is\n\
126 displayed on. Value is t for a termcap frame (a character-only\n\
127 terminal), `x' for an Emacs frame being displayed in an X window.")
131 return ((FRAMEP (object
)
132 && FRAME_LIVE_P (XFRAME (object
)))
142 register struct frame
*f
;
143 register Lisp_Object root_window
;
144 register Lisp_Object mini_window
;
145 register struct Lisp_Vector
*vec
;
148 vec
= allocate_vectorlike ((EMACS_INT
) VECSIZE (struct frame
));
149 for (i
= 0; i
< VECSIZE (struct frame
); i
++)
150 XSETFASTINT (vec
->contents
[i
], 0);
151 vec
->size
= VECSIZE (struct frame
);
152 f
= (struct frame
*)vec
;
153 XSETFRAME (frame
, f
);
157 f
->current_glyphs
= 0;
158 f
->desired_glyphs
= 0;
160 f
->async_visible
= 0;
161 f
->display
.nothing
= 0;
163 f
->async_iconified
= 0;
164 f
->wants_modeline
= 1;
169 f
->has_minibuffer
= mini_p
;
170 f
->focus_frame
= Qnil
;
171 f
->explicit_name
= 0;
172 f
->can_have_scroll_bars
= 0;
173 f
->has_vertical_scroll_bars
= 0;
174 f
->param_alist
= Qnil
;
175 f
->scroll_bars
= Qnil
;
176 f
->condemned_scroll_bars
= Qnil
;
177 f
->face_alist
= Qnil
;
178 f
->menu_bar_items
= Qnil
;
179 f
->menu_bar_vector
= Qnil
;
180 f
->menu_bar_items_used
= 0;
181 f
->buffer_predicate
= Qnil
;
183 root_window
= make_window ();
186 mini_window
= make_window ();
187 XWINDOW (root_window
)->next
= mini_window
;
188 XWINDOW (mini_window
)->prev
= root_window
;
189 XWINDOW (mini_window
)->mini_p
= Qt
;
190 XWINDOW (mini_window
)->frame
= frame
;
191 f
->minibuffer_window
= mini_window
;
196 XWINDOW (root_window
)->next
= Qnil
;
197 f
->minibuffer_window
= Qnil
;
200 XWINDOW (root_window
)->frame
= frame
;
203 just so that there is "something there."
204 Correct size will be set up later with change_frame_size. */
209 XSETFASTINT (XWINDOW (root_window
)->width
, 10);
210 XSETFASTINT (XWINDOW (root_window
)->height
, (mini_p
? 9 : 10));
214 XSETFASTINT (XWINDOW (mini_window
)->width
, 10);
215 XSETFASTINT (XWINDOW (mini_window
)->top
, 9);
216 XSETFASTINT (XWINDOW (mini_window
)->height
, 1);
219 /* Choose a buffer for the frame's root window. */
223 XWINDOW (root_window
)->buffer
= Qt
;
224 buf
= Fcurrent_buffer ();
225 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
226 a space), try to find another one. */
227 if (XSTRING (Fbuffer_name (buf
))->data
[0] == ' ')
228 buf
= Fother_buffer (buf
, Qnil
);
229 Fset_window_buffer (root_window
, buf
);
234 XWINDOW (mini_window
)->buffer
= Qt
;
235 Fset_window_buffer (mini_window
,
236 (NILP (Vminibuffer_list
)
238 : Fcar (Vminibuffer_list
)));
241 f
->root_window
= root_window
;
242 f
->selected_window
= root_window
;
243 /* Make sure this window seems more recently used than
244 a newly-created, never-selected window. */
245 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, ++window_select_count
);
250 /* Make a frame using a separate minibuffer window on another frame.
251 MINI_WINDOW is the minibuffer window to use. nil means use the
252 default (the global minibuffer). */
255 make_frame_without_minibuffer (mini_window
)
256 register Lisp_Object mini_window
;
258 register struct frame
*f
;
260 /* Choose the minibuffer window to use. */
261 if (NILP (mini_window
))
263 if (!FRAMEP (Vdefault_minibuffer_frame
))
264 error ("default-minibuffer-frame must be set when creating minibufferless frames");
265 if (! FRAME_LIVE_P (XFRAME (Vdefault_minibuffer_frame
)))
266 error ("default-minibuffer-frame must be a live frame");
267 mini_window
= XFRAME (Vdefault_minibuffer_frame
)->minibuffer_window
;
271 CHECK_LIVE_WINDOW (mini_window
, 0);
274 /* Make a frame containing just a root window. */
277 /* Install the chosen minibuffer window, with proper buffer. */
278 f
->minibuffer_window
= mini_window
;
279 Fset_window_buffer (mini_window
,
280 (NILP (Vminibuffer_list
)
282 : Fcar (Vminibuffer_list
)));
286 /* Make a frame containing only a minibuffer window. */
289 make_minibuffer_frame ()
291 /* First make a frame containing just a root window, no minibuffer. */
293 register struct frame
*f
= make_frame (0);
294 register Lisp_Object mini_window
;
295 register Lisp_Object frame
;
297 XSETFRAME (frame
, f
);
302 f
->wants_modeline
= 0;
303 f
->has_minibuffer
= 1;
305 /* Now label the root window as also being the minibuffer.
306 Avoid infinite looping on the window chain by marking next pointer
309 mini_window
= f
->minibuffer_window
= f
->root_window
;
310 XWINDOW (mini_window
)->mini_p
= Qt
;
311 XWINDOW (mini_window
)->next
= Qnil
;
312 XWINDOW (mini_window
)->prev
= Qnil
;
313 XWINDOW (mini_window
)->frame
= frame
;
315 /* Put the proper buffer in that window. */
317 Fset_window_buffer (mini_window
,
318 (NILP (Vminibuffer_list
)
320 : Fcar (Vminibuffer_list
)));
324 /* Construct a frame that refers to the terminal (stdin and stdout). */
327 make_terminal_frame ()
329 register struct frame
*f
;
335 XSETFRAME (frame
, f
);
336 Vframe_list
= Fcons (frame
, Vframe_list
);
338 f
->name
= build_string ("terminal");
339 FRAME_SET_VISIBLE (f
, 1);
340 f
->display
.nothing
= 1; /* Nonzero means frame isn't deleted. */
341 XSETFRAME (Vterminal_frame
, f
);
346 do_switch_frame (frame
, no_enter
, track
)
347 Lisp_Object frame
, no_enter
;
350 /* If FRAME is a switch-frame event, extract the frame we should
353 && EQ (XCONS (frame
)->car
, Qswitch_frame
)
354 && CONSP (XCONS (frame
)->cdr
))
355 frame
= XCONS (XCONS (frame
)->cdr
)->car
;
357 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
358 a switch-frame event to arrive after a frame is no longer live,
359 especially when deleting the initial frame during startup. */
360 CHECK_FRAME (frame
, 0);
361 if (! FRAME_LIVE_P (XFRAME (frame
)))
364 if (selected_frame
== XFRAME (frame
))
367 /* This is too greedy; it causes inappropriate focus redirection
368 that's hard to get rid of. */
370 /* If a frame's focus has been redirected toward the currently
371 selected frame, we should change the redirection to point to the
372 newly selected frame. This means that if the focus is redirected
373 from a minibufferless frame to a surrogate minibuffer frame, we
374 can use `other-window' to switch between all the frames using
375 that minibuffer frame, and the focus redirection will follow us
381 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
385 if (!FRAMEP (XCONS (tail
)->car
))
388 focus
= FRAME_FOCUS_FRAME (XFRAME (XCONS (tail
)->car
));
390 if (FRAMEP (focus
) && XFRAME (focus
) == selected_frame
)
391 Fredirect_frame_focus (XCONS (tail
)->car
, frame
);
395 /* Instead, apply it only to the frame we're pointing to. */
396 #ifdef HAVE_X_WINDOWS
399 Lisp_Object focus
, xfocus
;
401 xfocus
= x_get_focus_frame ();
404 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
405 if (FRAMEP (focus
) && XFRAME (focus
) == selected_frame
)
406 Fredirect_frame_focus (xfocus
, frame
);
409 #endif /* HAVE_X_WINDOWS */
412 selected_frame
= XFRAME (frame
);
413 if (! FRAME_MINIBUF_ONLY_P (selected_frame
))
414 last_nonminibuf_frame
= selected_frame
;
416 Fselect_window (XFRAME (frame
)->selected_window
);
417 choose_minibuf_frame ();
419 /* We want to make sure that the next event generates a frame-switch
420 event to the appropriate frame. This seems kludgy to me, but
421 before you take it out, make sure that evaluating something like
422 (select-window (frame-root-window (new-frame))) doesn't end up
423 with your typing being interpreted in the new frame instead of
424 the one you're actually typing in. */
425 internal_last_event_frame
= Qnil
;
430 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
431 "Select the frame FRAME.\n\
432 Subsequent editing commands apply to its selected window.\n\
433 The selection of FRAME lasts until the next time the user does\n\
434 something to select a different frame, or until the next time this\n\
435 function is called.")
437 Lisp_Object frame
, no_enter
;
439 return do_switch_frame (frame
, no_enter
, 1);
443 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 2, "e",
444 "Handle a switch-frame event EVENT.\n\
445 Switch-frame events are usually bound to this function.\n\
446 A switch-frame event tells Emacs that the window manager has requested\n\
447 that the user's events be directed to the frame mentioned in the event.\n\
448 This function selects the selected window of the frame of EVENT.\n\
450 If EVENT is frame object, handle it as if it were a switch-frame event\n\
453 Lisp_Object frame
, no_enter
;
455 return do_switch_frame (frame
, no_enter
, 0);
459 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
460 "Return the frame that is now selected.")
464 XSETFRAME (tem
, selected_frame
);
468 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
469 "Return the frame object that window WINDOW is on.")
473 CHECK_LIVE_WINDOW (window
, 0);
474 return XWINDOW (window
)->frame
;
477 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
478 "Returns the topmost, leftmost window of FRAME.\n\
479 If omitted, FRAME defaults to the currently selected frame.")
486 w
= selected_frame
->root_window
;
489 CHECK_LIVE_FRAME (frame
, 0);
490 w
= XFRAME (frame
)->root_window
;
492 while (NILP (XWINDOW (w
)->buffer
))
494 if (! NILP (XWINDOW (w
)->hchild
))
495 w
= XWINDOW (w
)->hchild
;
496 else if (! NILP (XWINDOW (w
)->vchild
))
497 w
= XWINDOW (w
)->vchild
;
504 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
505 "Returns the root-window of FRAME.\n\
506 If omitted, FRAME defaults to the currently selected frame.")
511 XSETFRAME (frame
, selected_frame
);
513 CHECK_LIVE_FRAME (frame
, 0);
515 return XFRAME (frame
)->root_window
;
518 DEFUN ("frame-selected-window", Fframe_selected_window
,
519 Sframe_selected_window
, 0, 1, 0,
520 "Return the selected window of frame object FRAME.\n\
521 If omitted, FRAME defaults to the currently selected frame.")
526 XSETFRAME (frame
, selected_frame
);
528 CHECK_LIVE_FRAME (frame
, 0);
530 return XFRAME (frame
)->selected_window
;
533 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
534 Sset_frame_selected_window
, 2, 2, 0,
535 "Set the selected window of frame object FRAME to WINDOW.\n\
536 If FRAME is nil, the selected frame is used.\n\
537 If FRAME is the selected frame, this makes WINDOW the selected window.")
539 Lisp_Object frame
, window
;
542 XSETFRAME (frame
, selected_frame
);
544 CHECK_LIVE_FRAME (frame
, 0);
546 CHECK_LIVE_WINDOW (window
, 1);
548 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
549 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
551 if (XFRAME (frame
) == selected_frame
)
552 return Fselect_window (window
);
554 return XFRAME (frame
)->selected_window
= window
;
557 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
559 "Return a list of all frames.")
562 return Fcopy_sequence (Vframe_list
);
565 /* Return the next frame in the frame list after FRAME.
566 If MINIBUF is nil, exclude minibuffer-only frames.
567 If MINIBUF is a window, include only its own frame
568 and any frame now using that window as the minibuffer.
569 If MINIBUF is `visible', include all visible frames.
570 If MINIBUF is 0, include all visible and iconified frames.
571 Otherwise, include all frames. */
574 next_frame (frame
, minibuf
)
581 /* There must always be at least one frame in Vframe_list. */
582 if (! CONSP (Vframe_list
))
585 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
586 forever. Forestall that. */
587 CHECK_LIVE_FRAME (frame
, 0);
590 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
594 f
= XCONS (tail
)->car
;
597 /* Decide whether this frame is eligible to be returned. */
599 /* If we've looped all the way around without finding any
600 eligible frames, return the original frame. */
604 /* Let minibuf decide if this frame is acceptable. */
607 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
610 else if (EQ (minibuf
, Qvisible
))
612 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
613 if (FRAME_VISIBLE_P (XFRAME (f
)))
616 else if (XFASTINT (minibuf
) == 0)
618 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
619 if (FRAME_VISIBLE_P (XFRAME (f
))
620 || FRAME_ICONIFIED_P (XFRAME (f
)))
623 else if (WINDOWP (minibuf
))
625 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
626 /* Check that F either is, or has forwarded its focus to,
628 && (EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
629 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
630 FRAME_FOCUS_FRAME (XFRAME (f
)))))
642 /* Return the previous frame in the frame list before FRAME.
643 If MINIBUF is nil, exclude minibuffer-only frames.
644 If MINIBUF is a window, include only its own frame
645 and any frame now using that window as the minibuffer.
646 If MINIBUF is `visible', include all visible frames.
647 If MINIBUF is 0, include all visible and iconified frames.
648 Otherwise, include all frames. */
651 prev_frame (frame
, minibuf
)
658 /* There must always be at least one frame in Vframe_list. */
659 if (! CONSP (Vframe_list
))
663 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
667 f
= XCONS (tail
)->car
;
671 if (EQ (frame
, f
) && !NILP (prev
))
674 /* Decide whether this frame is eligible to be returned,
675 according to minibuf. */
678 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
681 else if (WINDOWP (minibuf
))
683 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
684 /* Check that F either is, or has forwarded its focus to,
686 && (EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
687 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
688 FRAME_FOCUS_FRAME (XFRAME (f
)))))
691 else if (EQ (minibuf
, Qvisible
))
693 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
694 if (FRAME_VISIBLE_P (XFRAME (f
)))
697 else if (XFASTINT (minibuf
) == 0)
699 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
700 if (FRAME_VISIBLE_P (XFRAME (f
))
701 || FRAME_ICONIFIED_P (XFRAME (f
)))
708 /* We've scanned the entire list. */
710 /* We went through the whole frame list without finding a single
711 acceptable frame. Return the original frame. */
714 /* There were no acceptable frames in the list before FRAME; otherwise,
715 we would have returned directly from the loop. Since PREV is the last
716 acceptable frame in the list, return it. */
721 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
722 "Return the next frame in the frame list after FRAME.\n\
723 By default, skip minibuffer-only frames.\n\
724 If omitted, FRAME defaults to the selected frame.\n\
725 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
726 If MINIBUF is a window, include only its own frame\n\
727 and any frame now using that window as the minibuffer.\n\
728 If MINIFRAME is `visible', include all visible frames.\n\
729 If MINIBUF is 0, include all visible and iconified frames.\n\
730 Otherwise, include all frames.")
732 Lisp_Object frame
, miniframe
;
737 XSETFRAME (frame
, selected_frame
);
739 CHECK_LIVE_FRAME (frame
, 0);
741 return next_frame (frame
, miniframe
);
744 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
745 "Return the previous frame in the frame list before FRAME.\n\
746 By default, skip minibuffer-only frames.\n\
747 If omitted, FRAME defaults to the selected frame.\n\
748 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
749 If MINIBUF is a window, include only its own frame\n\
750 and any frame now using that window as the minibuffer.\n\
751 If MINIFRAME is `visible', include all visible frames.\n\
752 If MINIBUF is 0, include all visible and iconified frames.\n\
753 Otherwise, include all frames.")
755 Lisp_Object frame
, miniframe
;
760 XSETFRAME (frame
, selected_frame
);
762 CHECK_LIVE_FRAME (frame
, 0);
764 return prev_frame (frame
, miniframe
);
767 /* Return 1 if it is ok to delete frame F;
768 0 if all frames aside from F are invisible.
769 (Exception: if F is the terminal frame, and we are using X, return 1.) */
772 other_visible_frames (f
)
775 /* We know the selected frame is visible,
776 so if F is some other frame, it can't be the sole visible one. */
777 if (f
== selected_frame
)
782 for (frames
= Vframe_list
;
784 frames
= XCONS (frames
)->cdr
)
788 this = XCONS (frames
)->car
;
789 /* Verify that the frame's window still exists
790 and we can still talk to it. And note any recent change
792 #ifdef HAVE_X_WINDOWS
793 if (FRAME_X_P (XFRAME (this)))
795 x_sync (XFRAME (this));
796 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
800 if (FRAME_VISIBLE_P (XFRAME (this))
801 || FRAME_ICONIFIED_P (XFRAME (this))
802 /* Allow deleting the terminal frame when at least
803 one X frame exists! */
804 || (FRAME_X_P (XFRAME (this)) && !FRAME_X_P (f
)))
812 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
813 "Delete FRAME, permanently eliminating it from use.\n\
814 If omitted, FRAME defaults to the selected frame.\n\
815 A frame may not be deleted if its minibuffer is used by other frames.\n\
816 Normally, you may not delete a frame if all other frames are invisible,\n\
817 but if the second optional argument FORCE is non-nil, you may do so.")
819 Lisp_Object frame
, force
;
823 if (EQ (frame
, Qnil
))
826 XSETFRAME (frame
, f
);
830 CHECK_FRAME (frame
, 0);
834 if (! FRAME_LIVE_P (f
))
837 if (NILP (force
) && !other_visible_frames (f
))
838 error ("Attempt to delete the sole visible or iconified frame");
840 /* Does this frame have a minibuffer, and is it the surrogate
841 minibuffer for any other frame? */
842 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
846 for (frames
= Vframe_list
;
848 frames
= XCONS (frames
)->cdr
)
851 this = XCONS (frames
)->car
;
853 if (! EQ (this, frame
)
855 WINDOW_FRAME (XWINDOW
856 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
857 error ("Attempt to delete a surrogate minibuffer frame");
861 /* Don't let the frame remain selected. */
862 if (f
== selected_frame
)
863 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
865 /* Don't allow minibuf_window to remain on a deleted frame. */
866 if (EQ (f
->minibuffer_window
, minibuf_window
))
868 Fset_window_buffer (selected_frame
->minibuffer_window
,
869 XWINDOW (minibuf_window
)->buffer
);
870 minibuf_window
= selected_frame
->minibuffer_window
;
873 /* Clear any X selections for this frame. */
874 #ifdef HAVE_X_WINDOWS
876 x_clear_frame_selections (f
);
879 /* Mark all the windows that used to be on FRAME as deleted, and then
880 remove the reference to them. */
881 delete_all_subwindows (XWINDOW (f
->root_window
));
882 f
->root_window
= Qnil
;
884 Vframe_list
= Fdelq (frame
, Vframe_list
);
885 FRAME_SET_VISIBLE (f
, 0);
887 if (FRAME_CURRENT_GLYPHS (f
))
888 free_frame_glyphs (f
, FRAME_CURRENT_GLYPHS (f
));
889 if (FRAME_DESIRED_GLYPHS (f
))
890 free_frame_glyphs (f
, FRAME_DESIRED_GLYPHS (f
));
891 if (FRAME_TEMP_GLYPHS (f
))
892 free_frame_glyphs (f
, FRAME_TEMP_GLYPHS (f
));
893 if (FRAME_INSERT_COST (f
))
894 free (FRAME_INSERT_COST (f
));
895 if (FRAME_DELETEN_COST (f
))
896 free (FRAME_DELETEN_COST (f
));
897 if (FRAME_INSERTN_COST (f
))
898 free (FRAME_INSERTN_COST (f
));
899 if (FRAME_DELETE_COST (f
))
900 free (FRAME_DELETE_COST (f
));
902 /* Since some events are handled at the interrupt level, we may get
903 an event for f at any time; if we zero out the frame's display
904 now, then we may trip up the event-handling code. Instead, we'll
905 promise that the display of the frame must be valid until we have
906 called the window-system-dependent frame destruction routine. */
908 /* I think this should be done with a hook. */
909 #ifdef HAVE_X_WINDOWS
911 x_destroy_window (f
);
914 f
->display
.nothing
= 0;
916 /* If we've deleted the last_nonminibuf_frame, then try to find
918 if (f
== last_nonminibuf_frame
)
922 last_nonminibuf_frame
= 0;
924 for (frames
= Vframe_list
;
926 frames
= XCONS (frames
)->cdr
)
928 f
= XFRAME (XCONS (frames
)->car
);
929 if (!FRAME_MINIBUF_ONLY_P (f
))
931 last_nonminibuf_frame
= f
;
937 /* If we've deleted Vdefault_minibuffer_frame, try to find another
938 one. Prefer minibuffer-only frames, but also notice frames
939 with other windows. */
940 if (EQ (frame
, Vdefault_minibuffer_frame
))
944 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
945 Lisp_Object frame_with_minibuf
;
947 frame_with_minibuf
= Qnil
;
948 for (frames
= Vframe_list
;
950 frames
= XCONS (frames
)->cdr
)
954 this = XCONS (frames
)->car
;
959 if (FRAME_HAS_MINIBUF_P (f
))
961 frame_with_minibuf
= this;
962 if (FRAME_MINIBUF_ONLY_P (f
))
967 /* We know that there must be some frame with a minibuffer out
968 there. If this were not true, all of the frames present
969 would have to be minibufferless, which implies that at some
970 point their minibuffer frames must have been deleted, but
971 that is prohibited at the top; you can't delete surrogate
972 minibuffer frames. */
973 if (NILP (frame_with_minibuf
))
976 Vdefault_minibuffer_frame
= frame_with_minibuf
;
982 /* Return mouse position in character cell units. */
984 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
985 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
986 The position is given in character cells, where (0, 0) is the\n\
987 upper-left corner.\n\
988 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
989 to read the mouse position, it returns the selected frame for FRAME\n\
990 and nil for X and Y.")
994 Lisp_Object lispy_dummy
;
995 enum scroll_bar_part party_dummy
;
998 unsigned long long_dummy
;
1003 /* It's okay for the hook to refrain from storing anything. */
1004 if (mouse_position_hook
)
1005 (*mouse_position_hook
) (&f
,
1006 &lispy_dummy
, &party_dummy
,
1013 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, 0, 1);
1017 XSETFRAME (lispy_dummy
, f
);
1018 return Fcons (lispy_dummy
, Fcons (x
, y
));
1021 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1022 Smouse_pixel_position
, 0, 0, 0,
1023 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
1024 The position is given in pixel units, where (0, 0) is the\n\
1025 upper-left corner.\n\
1026 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
1027 to read the mouse position, it returns the selected frame for FRAME\n\
1028 and nil for X and Y.")
1032 Lisp_Object lispy_dummy
;
1033 enum scroll_bar_part party_dummy
;
1036 unsigned long long_dummy
;
1041 /* It's okay for the hook to refrain from storing anything. */
1042 if (mouse_position_hook
)
1043 (*mouse_position_hook
) (&f
,
1044 &lispy_dummy
, &party_dummy
,
1047 XSETFRAME (lispy_dummy
, f
);
1048 return Fcons (lispy_dummy
, Fcons (x
, y
));
1051 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1052 "Move the mouse pointer to the center of character cell (X,Y) in FRAME.\n\
1053 WARNING: If you use this under X windows,\n\
1054 you should call `unfocus-frame' afterwards.")
1056 Lisp_Object frame
, x
, y
;
1058 CHECK_LIVE_FRAME (frame
, 0);
1059 CHECK_NUMBER (x
, 2);
1060 CHECK_NUMBER (y
, 1);
1062 /* I think this should be done with a hook. */
1063 #ifdef HAVE_X_WINDOWS
1064 if (FRAME_X_P (XFRAME (frame
)))
1065 /* Warping the mouse will cause enternotify and focus events. */
1066 x_set_mouse_position (XFRAME (frame
), x
, y
);
1072 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1073 Sset_mouse_pixel_position
, 3, 3, 0,
1074 "Move the mouse pointer to pixel position (X,Y) in FRAME.\n\
1075 WARNING: If you use this under X windows,\n\
1076 you should call `unfocus-frame' afterwards.")
1078 Lisp_Object frame
, x
, y
;
1080 CHECK_LIVE_FRAME (frame
, 0);
1081 CHECK_NUMBER (x
, 2);
1082 CHECK_NUMBER (y
, 1);
1084 /* I think this should be done with a hook. */
1085 #ifdef HAVE_X_WINDOWS
1086 if (FRAME_X_P (XFRAME (frame
)))
1087 /* Warping the mouse will cause enternotify and focus events. */
1088 x_set_mouse_pixel_position (XFRAME (frame
), x
, y
);
1094 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1096 "Make the frame FRAME visible (assuming it is an X-window).\n\
1097 If omitted, FRAME defaults to the currently selected frame.")
1102 XSETFRAME (frame
, selected_frame
);
1104 CHECK_LIVE_FRAME (frame
, 0);
1106 /* I think this should be done with a hook. */
1107 #ifdef HAVE_X_WINDOWS
1108 if (FRAME_X_P (XFRAME (frame
)))
1110 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1111 x_make_frame_visible (XFRAME (frame
));
1115 /* Make menu bar update for the Buffers and Frams menus. */
1116 windows_or_buffers_changed
++;
1121 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1123 "Make the frame FRAME invisible (assuming it is an X-window).\n\
1124 If omitted, FRAME defaults to the currently selected frame.\n\
1125 Normally you may not make FRAME invisible if all other frames are invisible,\n\
1126 but if the second optional argument FORCE is non-nil, you may do so.")
1128 Lisp_Object frame
, force
;
1131 XSETFRAME (frame
, selected_frame
);
1133 CHECK_LIVE_FRAME (frame
, 0);
1135 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1136 error ("Attempt to make invisible the sole visible or iconified frame");
1138 #if 0 /* This isn't logically necessary, and it can do GC. */
1139 /* Don't let the frame remain selected. */
1140 if (XFRAME (frame
) == selected_frame
)
1141 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1144 /* Don't allow minibuf_window to remain on a deleted frame. */
1145 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1147 Fset_window_buffer (selected_frame
->minibuffer_window
,
1148 XWINDOW (minibuf_window
)->buffer
);
1149 minibuf_window
= selected_frame
->minibuffer_window
;
1152 /* I think this should be done with a hook. */
1153 #ifdef HAVE_X_WINDOWS
1154 if (FRAME_X_P (XFRAME (frame
)))
1155 x_make_frame_invisible (XFRAME (frame
));
1158 /* Make menu bar update for the Buffers and Frams menus. */
1159 windows_or_buffers_changed
++;
1164 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1166 "Make the frame FRAME into an icon.\n\
1167 If omitted, FRAME defaults to the currently selected frame.")
1172 XSETFRAME (frame
, selected_frame
);
1174 CHECK_LIVE_FRAME (frame
, 0);
1176 #if 0 /* This isn't logically necessary, and it can do GC. */
1177 /* Don't let the frame remain selected. */
1178 if (XFRAME (frame
) == selected_frame
)
1179 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1182 /* Don't allow minibuf_window to remain on a deleted frame. */
1183 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1185 Fset_window_buffer (selected_frame
->minibuffer_window
,
1186 XWINDOW (minibuf_window
)->buffer
);
1187 minibuf_window
= selected_frame
->minibuffer_window
;
1190 /* I think this should be done with a hook. */
1191 #ifdef HAVE_X_WINDOWS
1192 if (FRAME_X_P (XFRAME (frame
)))
1193 x_iconify_frame (XFRAME (frame
));
1196 /* Make menu bar update for the Buffers and Frams menus. */
1197 windows_or_buffers_changed
++;
1202 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1204 "Return t if FRAME is now \"visible\" (actually in use for display).\n\
1205 A frame that is not \"visible\" is not updated and, if it works through\n\
1206 a window system, it may not show at all.\n\
1207 Return the symbol `icon' if frame is visible only as an icon.")
1211 CHECK_LIVE_FRAME (frame
, 0);
1213 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1215 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1217 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1222 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1224 "Return a list of all frames now \"visible\" (being updated).")
1227 Lisp_Object tail
, frame
;
1232 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
1234 frame
= XCONS (tail
)->car
;
1235 if (!FRAMEP (frame
))
1238 if (FRAME_VISIBLE_P (f
))
1239 value
= Fcons (frame
, value
);
1245 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 1, 1, 0,
1246 "Bring FRAME to the front, so it occludes any frames it overlaps.\n\
1247 If FRAME is invisible, make it visible.\n\
1248 If Emacs is displaying on an ordinary terminal or some other device which\n\
1249 doesn't support multiple overlapping frames, this function does nothing.")
1253 CHECK_LIVE_FRAME (frame
, 0);
1255 /* Do like the documentation says. */
1256 Fmake_frame_visible (frame
);
1258 if (frame_raise_lower_hook
)
1259 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1264 /* Should we have a corresponding function called Flower_Power? */
1265 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 1, 1, 0,
1266 "Send FRAME to the back, so it is occluded by any frames that overlap it.\n\
1267 If Emacs is displaying on an ordinary terminal or some other device which\n\
1268 doesn't support multiple overlapping frames, this function does nothing.")
1272 CHECK_LIVE_FRAME (frame
, 0);
1274 if (frame_raise_lower_hook
)
1275 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1281 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1283 "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
1284 In other words, switch-frame events caused by events in FRAME will\n\
1285 request a switch to FOCUS-FRAME, and `last-event-frame' will be\n\
1286 FOCUS-FRAME after reading an event typed at FRAME.\n\
1288 If FOCUS-FRAME is omitted or nil, any existing redirection is\n\
1289 cancelled, and the frame again receives its own keystrokes.\n\
1291 Focus redirection is useful for temporarily redirecting keystrokes to\n\
1292 a surrogate minibuffer frame when a frame doesn't have its own\n\
1293 minibuffer window.\n\
1295 A frame's focus redirection can be changed by select-frame. If frame\n\
1296 FOO is selected, and then a different frame BAR is selected, any\n\
1297 frames redirecting their focus to FOO are shifted to redirect their\n\
1298 focus to BAR. This allows focus redirection to work properly when the\n\
1299 user switches from one frame to another using `select-window'.\n\
1301 This means that a frame whose focus is redirected to itself is treated\n\
1302 differently from a frame whose focus is redirected to nil; the former\n\
1303 is affected by select-frame, while the latter is not.\n\
1305 The redirection lasts until `redirect-frame-focus' is called to change it.")
1306 (frame
, focus_frame
)
1307 Lisp_Object frame
, focus_frame
;
1309 /* Note that we don't check for a live frame here. It's reasonable
1310 to redirect the focus of a frame you're about to delete, if you
1311 know what other frame should receive those keystrokes. */
1312 CHECK_FRAME (frame
, 0);
1314 if (! NILP (focus_frame
))
1315 CHECK_LIVE_FRAME (focus_frame
, 1);
1317 XFRAME (frame
)->focus_frame
= focus_frame
;
1319 /* I think this should be done with a hook. */
1320 #ifdef HAVE_X_WINDOWS
1321 if (!NILP (focus_frame
) && ! EQ (focus_frame
, frame
)
1322 && FRAME_X_P (XFRAME (focus_frame
)))
1323 Ffocus_frame (focus_frame
);
1326 if (frame_rehighlight_hook
)
1327 (*frame_rehighlight_hook
) ();
1333 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1334 "Return the frame to which FRAME's keystrokes are currently being sent.\n\
1335 This returns nil if FRAME's focus is not redirected.\n\
1336 See `redirect-frame-focus'.")
1340 CHECK_LIVE_FRAME (frame
, 0);
1342 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1347 /* Return the value of frame parameter PROP in frame FRAME. */
1350 get_frame_param (frame
, prop
)
1351 register struct frame
*frame
;
1354 register Lisp_Object tem
;
1356 tem
= Fassq (prop
, frame
->param_alist
);
1362 /* Return the buffer-predicate of the selected frame. */
1365 frame_buffer_predicate ()
1367 return selected_frame
->buffer_predicate
;
1370 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1371 If the alist already has an element for PROP, we change it. */
1374 store_in_alist (alistptr
, prop
, val
)
1375 Lisp_Object
*alistptr
, val
;
1378 register Lisp_Object tem
;
1380 tem
= Fassq (prop
, *alistptr
);
1382 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1388 store_frame_param (f
, prop
, val
)
1390 Lisp_Object prop
, val
;
1392 register Lisp_Object tem
;
1394 tem
= Fassq (prop
, f
->param_alist
);
1396 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
1400 if (EQ (prop
, Qbuffer_predicate
))
1401 f
->buffer_predicate
= val
;
1403 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
1405 if (! MINI_WINDOW_P (XWINDOW (val
)))
1406 error ("Surrogate minibuffer windows must be minibuffer windows.");
1408 if (FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
1409 error ("can't change the surrogate minibuffer of a frame with its own minibuffer");
1411 /* Install the chosen minibuffer window, with proper buffer. */
1412 f
->minibuffer_window
= val
;
1416 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
1417 "Return the parameters-alist of frame FRAME.\n\
1418 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
1419 The meaningful PARMs depend on the kind of frame.\n\
1420 If FRAME is omitted, return information on the currently selected frame.")
1427 if (EQ (frame
, Qnil
))
1431 CHECK_FRAME (frame
, 0);
1435 if (!FRAME_LIVE_P (f
))
1438 alist
= Fcopy_alist (f
->param_alist
);
1439 store_in_alist (&alist
, Qname
, f
->name
);
1440 store_in_alist (&alist
, Qheight
, make_number (FRAME_HEIGHT (f
)));
1441 store_in_alist (&alist
, Qwidth
, make_number (FRAME_WIDTH (f
)));
1442 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
1443 store_in_alist (&alist
, Qminibuffer
,
1444 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
1445 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
1446 : FRAME_MINIBUF_WINDOW (f
)));
1447 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
1449 /* I think this should be done with a hook. */
1450 #ifdef HAVE_X_WINDOWS
1452 x_report_frame_params (f
, &alist
);
1456 /* This ought to be correct in f->param_alist for an X frame. */
1458 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
1459 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
1464 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
1465 Smodify_frame_parameters
, 2, 2, 0,
1466 "Modify the parameters of frame FRAME according to ALIST.\n\
1467 ALIST is an alist of parameters to change and their new values.\n\
1468 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
1469 The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
1471 Lisp_Object frame
, alist
;
1474 register Lisp_Object tail
, elt
, prop
, val
;
1476 if (EQ (frame
, Qnil
))
1480 CHECK_LIVE_FRAME (frame
, 0);
1484 /* I think this should be done with a hook. */
1485 #ifdef HAVE_X_WINDOWS
1487 x_set_frame_parameters (f
, alist
);
1490 for (tail
= alist
; !EQ (tail
, Qnil
); tail
= Fcdr (tail
))
1495 store_frame_param (f
, prop
, val
);
1501 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
1503 "Height in pixels of a line in the font in frame FRAME.\n\
1504 If FRAME is omitted, the selected frame is used.\n\
1505 For a terminal frame, the value is always 1.")
1515 CHECK_FRAME (frame
, 0);
1519 #ifdef HAVE_X_WINDOWS
1521 return make_number (x_char_height (f
));
1524 return make_number (1);
1528 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
1530 "Width in pixels of characters in the font in frame FRAME.\n\
1531 If FRAME is omitted, the selected frame is used.\n\
1532 The width is the same for all characters, because\n\
1533 currently Emacs supports only fixed-width fonts.\n\
1534 For a terminal screen, the value is always 1.")
1544 CHECK_FRAME (frame
, 0);
1548 #ifdef HAVE_X_WINDOWS
1550 return make_number (x_char_width (f
));
1553 return make_number (1);
1556 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
1557 Sframe_pixel_height
, 0, 1, 0,
1558 "Return a FRAME's height in pixels.\n\
1559 For a terminal frame, the result really gives the height in characters.\n\
1560 If FRAME is omitted, the selected frame is used.")
1570 CHECK_FRAME (frame
, 0);
1574 #ifdef HAVE_X_WINDOWS
1576 return make_number (x_pixel_height (f
));
1579 return make_number (FRAME_HEIGHT (f
));
1582 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
1583 Sframe_pixel_width
, 0, 1, 0,
1584 "Return FRAME's width in pixels.\n\
1585 For a terminal frame, the result really gives the width in characters.\n\
1586 If FRAME is omitted, the selected frame is used.")
1596 CHECK_FRAME (frame
, 0);
1600 #ifdef HAVE_X_WINDOWS
1602 return make_number (x_pixel_width (f
));
1605 return make_number (FRAME_WIDTH (f
));
1608 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1609 "Specify that the frame FRAME has LINES lines.\n\
1610 Optional third arg non-nil means that redisplay should use LINES lines\n\
1611 but that the idea of the actual height of the frame should not be changed.")
1612 (frame
, rows
, pretend
)
1613 Lisp_Object frame
, rows
, pretend
;
1615 register struct frame
*f
;
1617 CHECK_NUMBER (rows
, 0);
1622 CHECK_LIVE_FRAME (frame
, 0);
1626 /* I think this should be done with a hook. */
1627 #ifdef HAVE_X_WINDOWS
1630 if (XINT (rows
) != f
->height
)
1631 x_set_window_size (f
, 1, f
->width
, XINT (rows
));
1635 change_frame_size (f
, XINT (rows
), 0, !NILP (pretend
), 0);
1639 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1640 "Specify that the frame FRAME has COLS columns.\n\
1641 Optional third arg non-nil means that redisplay should use COLS columns\n\
1642 but that the idea of the actual width of the frame should not be changed.")
1643 (frame
, cols
, pretend
)
1644 Lisp_Object frame
, cols
, pretend
;
1646 register struct frame
*f
;
1647 CHECK_NUMBER (cols
, 0);
1652 CHECK_LIVE_FRAME (frame
, 0);
1656 /* I think this should be done with a hook. */
1657 #ifdef HAVE_X_WINDOWS
1660 if (XINT (cols
) != f
->width
)
1661 x_set_window_size (f
, 1, XINT (cols
), f
->height
);
1665 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0);
1669 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1670 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1672 Lisp_Object frame
, cols
, rows
;
1674 register struct frame
*f
;
1677 CHECK_LIVE_FRAME (frame
, 0);
1678 CHECK_NUMBER (cols
, 2);
1679 CHECK_NUMBER (rows
, 1);
1682 /* I think this should be done with a hook. */
1683 #ifdef HAVE_X_WINDOWS
1686 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
)
1687 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
1691 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0);
1696 DEFUN ("set-frame-position", Fset_frame_position
,
1697 Sset_frame_position
, 3, 3, 0,
1698 "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
1699 This is actually the position of the upper left corner of the frame.\n\
1700 Negative values for XOFFSET or YOFFSET are interpreted relative to\n\
1701 the rightmost or bottommost possible position (that stays within the screen).")
1702 (frame
, xoffset
, yoffset
)
1703 Lisp_Object frame
, xoffset
, yoffset
;
1705 register struct frame
*f
;
1708 CHECK_LIVE_FRAME (frame
, 0);
1709 CHECK_NUMBER (xoffset
, 1);
1710 CHECK_NUMBER (yoffset
, 2);
1713 /* I think this should be done with a hook. */
1714 #ifdef HAVE_X_WINDOWS
1716 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
1723 choose_minibuf_frame ()
1725 /* For lowest-level minibuf, put it on currently selected frame
1726 if frame has a minibuffer. */
1728 if (minibuf_level
== 0
1729 && selected_frame
!= 0
1730 && !EQ (minibuf_window
, selected_frame
->minibuffer_window
))
1732 /* I don't think that any frames may validly have a null minibuffer
1734 if (NILP (selected_frame
->minibuffer_window
))
1737 Fset_window_buffer (selected_frame
->minibuffer_window
,
1738 XWINDOW (minibuf_window
)->buffer
);
1739 minibuf_window
= selected_frame
->minibuffer_window
;
1745 /*&&& init symbols here &&&*/
1746 Qframep
= intern ("framep");
1747 staticpro (&Qframep
);
1748 Qframe_live_p
= intern ("frame-live-p");
1749 staticpro (&Qframe_live_p
);
1750 Qheight
= intern ("height");
1751 staticpro (&Qheight
);
1752 Qicon
= intern ("icon");
1754 Qminibuffer
= intern ("minibuffer");
1755 staticpro (&Qminibuffer
);
1756 Qmodeline
= intern ("modeline");
1757 staticpro (&Qmodeline
);
1758 Qname
= intern ("name");
1760 Qonly
= intern ("only");
1762 Qunsplittable
= intern ("unsplittable");
1763 staticpro (&Qunsplittable
);
1764 Qmenu_bar_lines
= intern ("menu-bar-lines");
1765 staticpro (&Qmenu_bar_lines
);
1766 Qwidth
= intern ("width");
1767 staticpro (&Qwidth
);
1770 Qvisible
= intern ("visible");
1771 staticpro (&Qvisible
);
1772 Qbuffer_predicate
= intern ("buffer-predicate");
1773 staticpro (&Qbuffer_predicate
);
1775 staticpro (&Vframe_list
);
1777 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
1778 "The initial frame-object, which represents Emacs's stdout.");
1780 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
1781 "Non-nil if all of emacs is iconified and frame updates are not needed.");
1782 Vemacs_iconified
= Qnil
;
1784 DEFVAR_LISP ("default-minibuffer-frame", &Vdefault_minibuffer_frame
,
1785 "Minibufferless frames use this frame's minibuffer.\n\
1787 Emacs cannot create minibufferless frames unless this is set to an\n\
1788 appropriate surrogate.\n\
1790 Emacs consults this variable only when creating minibufferless\n\
1791 frames; once the frame is created, it sticks with its assigned\n\
1792 minibuffer, no matter what this variable is set to. This means that\n\
1793 this variable doesn't necessarily say anything meaningful about the\n\
1794 current set of frames, or where the minibuffer is currently being\n\
1796 Vdefault_minibuffer_frame
= Qnil
;
1798 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
1799 "Alist of default values for frame creation.\n\
1800 These may be set in your init file, like this:\n\
1801 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))\n\
1802 These override values given in window system configuration data,\n\
1803 including X Windows' defaults database.\n\
1804 For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
1805 For values specific to the separate minibuffer frame, see\n\
1806 `minibuffer-frame-alist'.\n\
1807 The `menu-bar-lines' element of the list controls whether new frames\n\
1808 have menu bars; `menu-bar-mode' works by altering this element.");
1809 Vdefault_frame_alist
= Qnil
;
1812 defsubr (&Sframe_live_p
);
1813 defsubr (&Shandle_switch_frame
);
1814 defsubr (&Sselect_frame
);
1815 defsubr (&Sselected_frame
);
1816 defsubr (&Swindow_frame
);
1817 defsubr (&Sframe_root_window
);
1818 defsubr (&Sframe_first_window
);
1819 defsubr (&Sframe_selected_window
);
1820 defsubr (&Sset_frame_selected_window
);
1821 defsubr (&Sframe_list
);
1822 defsubr (&Snext_frame
);
1823 defsubr (&Sprevious_frame
);
1824 defsubr (&Sdelete_frame
);
1825 defsubr (&Smouse_position
);
1826 defsubr (&Smouse_pixel_position
);
1827 defsubr (&Sset_mouse_position
);
1828 defsubr (&Sset_mouse_pixel_position
);
1830 defsubr (&Sframe_configuration
);
1831 defsubr (&Srestore_frame_configuration
);
1833 defsubr (&Smake_frame_visible
);
1834 defsubr (&Smake_frame_invisible
);
1835 defsubr (&Siconify_frame
);
1836 defsubr (&Sframe_visible_p
);
1837 defsubr (&Svisible_frame_list
);
1838 defsubr (&Sraise_frame
);
1839 defsubr (&Slower_frame
);
1840 defsubr (&Sredirect_frame_focus
);
1841 defsubr (&Sframe_focus
);
1842 defsubr (&Sframe_parameters
);
1843 defsubr (&Smodify_frame_parameters
);
1844 defsubr (&Sframe_char_height
);
1845 defsubr (&Sframe_char_width
);
1846 defsubr (&Sframe_pixel_height
);
1847 defsubr (&Sframe_pixel_width
);
1848 defsubr (&Sset_frame_height
);
1849 defsubr (&Sset_frame_width
);
1850 defsubr (&Sset_frame_size
);
1851 defsubr (&Sset_frame_position
);
1856 initial_define_lispy_key (global_map
, "switch-frame", "handle-switch-frame");
1857 initial_define_lispy_key (global_map
, "delete-frame", "handle-delete-frame");
1858 initial_define_lispy_key (global_map
, "iconify-frame", "ignore");
1859 initial_define_lispy_key (global_map
, "make-frame-visible", "ignore");
1862 #else /* not MULTI_FRAME */
1864 /* If we're not using multi-frame stuff, we still need to provide some
1865 support functions. */
1867 Lisp_Object Qheight
;
1868 Lisp_Object Qminibuffer
;
1869 Lisp_Object Qmodeline
;
1871 Lisp_Object Qunsplittable
;
1872 Lisp_Object Qmenu_bar_lines
;
1875 Lisp_Object Vterminal_frame
;
1877 /* Unless this function is defined, providing set-frame-height and
1878 set-frame-width doesn't help compatibility any, since they both
1879 want this as their first argument. */
1880 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1881 /* Don't confuse make-docfile by having two doc strings for this function.
1882 make-docfile does not pay attention to #if, for good reason! */
1886 /* For your possible information, this code is unfolded into the
1887 second WINDOW_FRAME in frame.h. */
1889 XSETFASTINT (tem
, 0);
1893 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
1894 /* Don't confuse make-docfile by having two doc strings for this function.
1895 make-docfile does not pay attention to #if, for good reason! */
1900 /* For your possible information, this code is unfolded into the
1901 second WINDOW_FRAME in frame.h. */
1903 XSETFASTINT (tem
, 0);
1907 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
1914 w
= FRAME_ROOT_WINDOW (selected_frame
);
1916 while (NILP (XWINDOW (w
)->buffer
))
1918 if (! NILP (XWINDOW (w
)->hchild
))
1919 w
= XWINDOW (w
)->hchild
;
1920 else if (! NILP (XWINDOW (w
)->vchild
))
1921 w
= XWINDOW (w
)->vchild
;
1928 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
1929 /* Don't confuse make-docfile by having two doc strings for this function.
1930 make-docfile does not pay attention to #if, for good reason! */
1936 if (FRAME_X_P (object
))
1937 return intern ("pc");
1942 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1943 /* Don't confuse make-docfile by having two doc strings for this function.
1944 make-docfile does not pay attention to #if, for good reason! */
1946 (frame
, rows
, pretend
)
1947 Lisp_Object frame
, rows
, pretend
;
1949 CHECK_NUMBER (rows
, 0);
1951 change_frame_size (0, XINT (rows
), 0, !NILP (pretend
), 0);
1955 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1956 /* Don't confuse make-docfile by having two doc strings for this function.
1957 make-docfile does not pay attention to #if, for good reason! */
1959 (frame
, cols
, pretend
)
1960 Lisp_Object frame
, cols
, pretend
;
1962 CHECK_NUMBER (cols
, 0);
1964 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1968 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1969 /* Don't confuse make-docfile by having two doc strings for this function.
1970 make-docfile does not pay attention to #if, for good reason! */
1973 Lisp_Object frame
, cols
, rows
;
1975 CHECK_NUMBER (cols
, 2);
1976 CHECK_NUMBER (rows
, 1);
1978 change_frame_size (0, XINT (rows
), XINT (cols
), 0, 0);
1983 DEFUN ("frame-height", Fframe_height
, Sframe_height
, 0, 1, 0,
1984 "Return number of lines available for display on FRAME.\n\
1985 If FRAME is omitted, describe the currently selected frame.")
1989 return make_number (FRAME_HEIGHT (selected_frame
));
1992 DEFUN ("frame-width", Fframe_width
, Sframe_width
, 0, 1, 0,
1993 "Return number of columns available for display on FRAME.\n\
1994 If FRAME is omitted, describe the currently selected frame.")
1998 return make_number (FRAME_WIDTH (selected_frame
));
2001 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2003 /* Don't confuse make-docfile by having two doc strings for this function.
2004 make-docfile does not pay attention to #if, for good reason! */
2009 return make_number (1);
2013 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2015 /* Don't confuse make-docfile by having two doc strings for this function.
2016 make-docfile does not pay attention to #if, for good reason! */
2021 return make_number (1);
2024 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2025 Sframe_pixel_height
, 0, 1, 0,
2026 /* Don't confuse make-docfile by having two doc strings for this function.
2027 make-docfile does not pay attention to #if, for good reason! */
2032 return make_number (FRAME_HEIGHT (f
));
2035 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2036 Sframe_pixel_width
, 0, 1, 0,
2037 /* Don't confuse make-docfile by having two doc strings for this function.
2038 make-docfile does not pay attention to #if, for good reason! */
2043 return make_number (FRAME_WIDTH (f
));
2046 /* These are for backward compatibility with Emacs 18. */
2048 DEFUN ("set-screen-height", Fset_screen_height
, Sset_screen_height
, 1, 2, 0,
2049 "Tell redisplay that the screen has LINES lines.\n\
2050 Optional second arg non-nil means that redisplay should use LINES lines\n\
2051 but that the idea of the actual height of the screen should not be changed.")
2053 Lisp_Object lines
, pretend
;
2055 CHECK_NUMBER (lines
, 0);
2057 change_frame_size (0, XINT (lines
), 0, !NILP (pretend
), 0);
2061 DEFUN ("set-screen-width", Fset_screen_width
, Sset_screen_width
, 1, 2, 0,
2062 "Tell redisplay that the screen has COLS columns.\n\
2063 Optional second arg non-nil means that redisplay should use COLS columns\n\
2064 but that the idea of the actual width of the screen should not be changed.")
2066 Lisp_Object cols
, pretend
;
2068 CHECK_NUMBER (cols
, 0);
2070 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
2074 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
2075 /* Don't confuse make-docfile by having two doc strings for this function.
2076 make-docfile does not pay attention to #if, for good reason! */
2081 if (mouse_position_hook
)
2084 Lisp_Object lispy_dummy
;
2085 enum scroll_bar_part party_dummy
;
2087 unsigned long long_dummy
;
2089 (*mouse_position_hook
) (&f
,
2090 &lispy_dummy
, &party_dummy
,
2093 return Fcons (Fselected_frame (), Fcons (x
, y
));
2096 return Fcons (Qnil
, Fcons (Qnil
, Qnil
));
2100 store_in_alist (alistptr
, prop
, val
)
2101 Lisp_Object
*alistptr
, val
;
2104 register Lisp_Object tem
;
2106 tem
= Fassq (prop
, *alistptr
);
2108 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2113 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2114 /* Don't confuse make-docfile by having two doc strings for this function.
2115 make-docfile does not pay attention to #if, for good reason! */
2123 if (EQ (frame
, Qnil
))
2127 CHECK_FRAME (frame
, 0);
2131 if (!FRAME_LIVE_P (f
))
2138 static char *colornames
[16] =
2140 "black", "blue", "green", "cyan", "red", "magenta", "brown",
2141 "lightgray", "darkgray", "lightblue", "lightgreen", "lightcyan",
2142 "lightred", "lightmagenta", "yellow", "white"
2144 store_in_alist (&alist
, intern ("foreground-color"),
2145 build_string (colornames
[FRAME_FOREGROUND_PIXEL (f
)]));
2146 store_in_alist (&alist
, intern ("background-color"),
2147 build_string (colornames
[FRAME_BACKGROUND_PIXEL (f
)]));
2150 store_in_alist (&alist
, intern ("font"), build_string ("default"));
2151 store_in_alist (&alist
, Qname
, build_string ("emacs"));
2152 store_in_alist (&alist
, Qheight
, make_number (FRAME_HEIGHT (f
)));
2153 store_in_alist (&alist
, Qwidth
, make_number (FRAME_WIDTH (f
)));
2154 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2155 store_in_alist (&alist
, Qminibuffer
, FRAME_MINIBUF_WINDOW (f
));
2156 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2157 store_in_alist (&alist
, Qmenu_bar_lines
, (FRAME_MENU_BAR_LINES (f
)));
2162 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2163 Smodify_frame_parameters
, 2, 2, 0,
2164 /* Don't confuse make-docfile by having two doc strings for this function.
2165 make-docfile does not pay attention to #if, for good reason! */
2168 Lisp_Object frame
, alist
;
2171 if (FRAME_X_P (frame
))
2172 IT_set_frame_parameters (XFRAME (frame
), alist
);
2177 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
2178 /* Don't confuse make-docfile by having two doc strings for this function.
2179 make-docfile does not pay attention to #if, for good reason! */
2187 DEFUN ("frame-list", Fframe_list
, Sframe_list
, 0, 0, 0,
2188 /* Don't confuse make-docfile by having two doc strings for this function.
2189 make-docfile does not pay attention to #if, for good reason! */
2193 return Fcons (Fselected_frame (), Qnil
);
2198 Qheight
= intern ("height");
2199 staticpro (&Qheight
);
2200 Qminibuffer
= intern ("minibuffer");
2201 staticpro (&Qminibuffer
);
2202 Qmodeline
= intern ("modeline");
2203 staticpro (&Qmodeline
);
2204 Qname
= intern ("name");
2206 Qunsplittable
= intern ("unsplittable");
2207 staticpro (&Qunsplittable
);
2208 Qmenu_bar_lines
= intern ("menu-bar-lines");
2209 staticpro (&Qmenu_bar_lines
);
2210 Qwidth
= intern ("width");
2211 staticpro (&Qwidth
);
2213 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
2214 "The initial frame-object, which represents Emacs's stdout.");
2215 XSETFASTINT (Vterminal_frame
, 0);
2217 defsubr (&Sselected_frame
);
2218 defsubr (&Swindow_frame
);
2219 defsubr (&Sframe_first_window
);
2221 defsubr (&Sframe_char_height
);
2222 defsubr (&Sframe_char_width
);
2223 defsubr (&Sframe_pixel_height
);
2224 defsubr (&Sframe_pixel_width
);
2225 defsubr (&Sset_frame_height
);
2226 defsubr (&Sset_frame_width
);
2227 defsubr (&Sset_frame_size
);
2228 defsubr (&Sset_screen_height
);
2229 defsubr (&Sset_screen_width
);
2230 defsubr (&Sframe_height
);
2231 Ffset (intern ("screen-height"), intern ("frame-height"));
2232 defsubr (&Sframe_width
);
2233 Ffset (intern ("screen-width"), intern ("frame-width"));
2234 defsubr (&Smouse_position
);
2235 defsubr (&Sframe_parameters
);
2236 defsubr (&Smodify_frame_parameters
);
2237 defsubr (&Sframe_live_p
);
2238 defsubr (&Sframe_list
);
2241 /* A comment in dispnew.c says the_only_frame is not protected. */
2242 the_only_frame
.face_alist
= Qnil
;
2243 staticpro (&the_only_frame
.face_alist
);
2244 the_only_frame
.menu_bar_items
= Qnil
;
2245 staticpro (&the_only_frame
.menu_bar_items
);
2246 the_only_frame
.menu_bar_vector
= Qnil
;
2247 staticpro (&the_only_frame
.menu_bar_vector
);
2248 the_only_frame
.menu_bar_items
= menu_bar_items (Qnil
);
2256 #endif /* not MULTI_FRAME */