1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995 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 See also `frame-live-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 f
->kboard
= initial_kboard
;
187 root_window
= make_window ();
190 mini_window
= make_window ();
191 XWINDOW (root_window
)->next
= mini_window
;
192 XWINDOW (mini_window
)->prev
= root_window
;
193 XWINDOW (mini_window
)->mini_p
= Qt
;
194 XWINDOW (mini_window
)->frame
= frame
;
195 f
->minibuffer_window
= mini_window
;
200 XWINDOW (root_window
)->next
= Qnil
;
201 f
->minibuffer_window
= Qnil
;
204 XWINDOW (root_window
)->frame
= frame
;
207 just so that there is "something there."
208 Correct size will be set up later with change_frame_size. */
213 XSETFASTINT (XWINDOW (root_window
)->width
, 10);
214 XSETFASTINT (XWINDOW (root_window
)->height
, (mini_p
? 9 : 10));
218 XSETFASTINT (XWINDOW (mini_window
)->width
, 10);
219 XSETFASTINT (XWINDOW (mini_window
)->top
, 9);
220 XSETFASTINT (XWINDOW (mini_window
)->height
, 1);
223 /* Choose a buffer for the frame's root window. */
227 XWINDOW (root_window
)->buffer
= Qt
;
228 buf
= Fcurrent_buffer ();
229 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
230 a space), try to find another one. */
231 if (XSTRING (Fbuffer_name (buf
))->data
[0] == ' ')
232 buf
= Fother_buffer (buf
, Qnil
);
233 Fset_window_buffer (root_window
, buf
);
238 XWINDOW (mini_window
)->buffer
= Qt
;
239 Fset_window_buffer (mini_window
,
240 (NILP (Vminibuffer_list
)
242 : Fcar (Vminibuffer_list
)));
245 f
->root_window
= root_window
;
246 f
->selected_window
= root_window
;
247 /* Make sure this window seems more recently used than
248 a newly-created, never-selected window. */
249 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, ++window_select_count
);
254 /* Make a frame using a separate minibuffer window on another frame.
255 MINI_WINDOW is the minibuffer window to use. nil means use the
256 default (the global minibuffer). */
259 make_frame_without_minibuffer (mini_window
)
260 register Lisp_Object mini_window
;
262 register struct frame
*f
;
264 /* Choose the minibuffer window to use. */
265 if (NILP (mini_window
))
267 if (!FRAMEP (Vdefault_minibuffer_frame
))
268 error ("default-minibuffer-frame must be set when creating minibufferless frames");
269 if (! FRAME_LIVE_P (XFRAME (Vdefault_minibuffer_frame
)))
270 error ("default-minibuffer-frame must be a live frame");
271 mini_window
= XFRAME (Vdefault_minibuffer_frame
)->minibuffer_window
;
275 CHECK_LIVE_WINDOW (mini_window
, 0);
278 /* Make a frame containing just a root window. */
281 /* Install the chosen minibuffer window, with proper buffer. */
282 f
->minibuffer_window
= mini_window
;
283 Fset_window_buffer (mini_window
,
284 (NILP (Vminibuffer_list
)
286 : Fcar (Vminibuffer_list
)));
290 /* Make a frame containing only a minibuffer window. */
293 make_minibuffer_frame ()
295 /* First make a frame containing just a root window, no minibuffer. */
297 register struct frame
*f
= make_frame (0);
298 register Lisp_Object mini_window
;
299 register Lisp_Object frame
;
301 XSETFRAME (frame
, f
);
306 f
->wants_modeline
= 0;
307 f
->has_minibuffer
= 1;
309 /* Now label the root window as also being the minibuffer.
310 Avoid infinite looping on the window chain by marking next pointer
313 mini_window
= f
->minibuffer_window
= f
->root_window
;
314 XWINDOW (mini_window
)->mini_p
= Qt
;
315 XWINDOW (mini_window
)->next
= Qnil
;
316 XWINDOW (mini_window
)->prev
= Qnil
;
317 XWINDOW (mini_window
)->frame
= frame
;
319 /* Put the proper buffer in that window. */
321 Fset_window_buffer (mini_window
,
322 (NILP (Vminibuffer_list
)
324 : Fcar (Vminibuffer_list
)));
328 /* Construct a frame that refers to the terminal (stdin and stdout). */
330 static int terminal_frame_count
;
333 make_terminal_frame ()
335 register struct frame
*f
;
342 initial_kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
343 init_kboard (initial_kboard
);
344 initial_kboard
->next_kboard
= all_kboards
;
345 all_kboards
= initial_kboard
;
349 /* The first call must initialize Vframe_list. */
350 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
355 XSETFRAME (frame
, f
);
356 Vframe_list
= Fcons (frame
, Vframe_list
);
358 terminal_frame_count
++;
359 if (terminal_frame_count
== 1)
361 f
->name
= build_string ("Emacs");
365 sprintf (name
, "Emacs-%d", terminal_frame_count
);
366 f
->name
= build_string (name
);
369 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
370 f
->async_visible
= 1; /* Don't let visible be cleared later. */
371 f
->display
.nothing
= 1; /* Nonzero means frame isn't deleted. */
372 XSETFRAME (Vterminal_frame
, f
);
376 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
377 1, 1, 0, "Create an additional terminal frame.\n\
378 You can create multiple frames on a text-only terminal in this way.\n\
379 Only the selected terminal frame is actually displayed.\n\
380 This function takes one argument, an alist specifying frame parameters.\n\
381 In practice, generally you don't need to specify any parameters.\n\
382 Note that changing the size of one terminal frame automatically affects all.")
389 if (selected_frame
->output_method
!= output_termcap
)
390 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
392 f
= make_terminal_frame ();
393 change_frame_size (f
, FRAME_HEIGHT (selected_frame
),
394 FRAME_WIDTH (selected_frame
), 0, 0);
395 remake_frame_glyphs (f
);
397 XSETFRAME (frame
, f
);
398 Fmodify_frame_parameters (frame
, parms
);
403 do_switch_frame (frame
, no_enter
, track
)
404 Lisp_Object frame
, no_enter
;
407 /* If FRAME is a switch-frame event, extract the frame we should
410 && EQ (XCONS (frame
)->car
, Qswitch_frame
)
411 && CONSP (XCONS (frame
)->cdr
))
412 frame
= XCONS (XCONS (frame
)->cdr
)->car
;
414 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
415 a switch-frame event to arrive after a frame is no longer live,
416 especially when deleting the initial frame during startup. */
417 CHECK_FRAME (frame
, 0);
418 if (! FRAME_LIVE_P (XFRAME (frame
)))
421 if (selected_frame
== XFRAME (frame
))
424 /* This is too greedy; it causes inappropriate focus redirection
425 that's hard to get rid of. */
427 /* If a frame's focus has been redirected toward the currently
428 selected frame, we should change the redirection to point to the
429 newly selected frame. This means that if the focus is redirected
430 from a minibufferless frame to a surrogate minibuffer frame, we
431 can use `other-window' to switch between all the frames using
432 that minibuffer frame, and the focus redirection will follow us
438 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
442 if (!FRAMEP (XCONS (tail
)->car
))
445 focus
= FRAME_FOCUS_FRAME (XFRAME (XCONS (tail
)->car
));
447 if (FRAMEP (focus
) && XFRAME (focus
) == selected_frame
)
448 Fredirect_frame_focus (XCONS (tail
)->car
, frame
);
452 /* Instead, apply it only to the frame we're pointing to. */
453 #ifdef HAVE_X_WINDOWS
456 Lisp_Object focus
, xfocus
;
458 xfocus
= x_get_focus_frame ();
461 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
462 if (FRAMEP (focus
) && XFRAME (focus
) == selected_frame
)
463 Fredirect_frame_focus (xfocus
, frame
);
466 #endif /* HAVE_X_WINDOWS */
469 if (FRAME_TERMCAP_P (XFRAME (frame
)))
471 /* Since frames on an ASCII terminal share the same display area,
472 switching means we must redisplay the whole thing. */
473 windows_or_buffers_changed
++;
474 SET_FRAME_GARBAGED (XFRAME (frame
));
477 selected_frame
= XFRAME (frame
);
478 if (! FRAME_MINIBUF_ONLY_P (selected_frame
))
479 last_nonminibuf_frame
= selected_frame
;
481 Fselect_window (XFRAME (frame
)->selected_window
);
482 choose_minibuf_frame ();
484 /* We want to make sure that the next event generates a frame-switch
485 event to the appropriate frame. This seems kludgy to me, but
486 before you take it out, make sure that evaluating something like
487 (select-window (frame-root-window (new-frame))) doesn't end up
488 with your typing being interpreted in the new frame instead of
489 the one you're actually typing in. */
490 internal_last_event_frame
= Qnil
;
495 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
496 "Select the frame FRAME.\n\
497 Subsequent editing commands apply to its selected window.\n\
498 The selection of FRAME lasts until the next time the user does\n\
499 something to select a different frame, or until the next time this\n\
500 function is called.")
502 Lisp_Object frame
, no_enter
;
504 return do_switch_frame (frame
, no_enter
, 1);
508 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 2, "e",
509 "Handle a switch-frame event EVENT.\n\
510 Switch-frame events are usually bound to this function.\n\
511 A switch-frame event tells Emacs that the window manager has requested\n\
512 that the user's events be directed to the frame mentioned in the event.\n\
513 This function selects the selected window of the frame of EVENT.\n\
515 If EVENT is frame object, handle it as if it were a switch-frame event\n\
518 Lisp_Object frame
, no_enter
;
520 return do_switch_frame (frame
, no_enter
, 0);
524 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
525 "Return the frame that is now selected.")
529 XSETFRAME (tem
, selected_frame
);
533 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
534 "Return the frame object that window WINDOW is on.")
538 CHECK_LIVE_WINDOW (window
, 0);
539 return XWINDOW (window
)->frame
;
542 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
543 "Returns the topmost, leftmost window of FRAME.\n\
544 If omitted, FRAME defaults to the currently selected frame.")
551 w
= selected_frame
->root_window
;
554 CHECK_LIVE_FRAME (frame
, 0);
555 w
= XFRAME (frame
)->root_window
;
557 while (NILP (XWINDOW (w
)->buffer
))
559 if (! NILP (XWINDOW (w
)->hchild
))
560 w
= XWINDOW (w
)->hchild
;
561 else if (! NILP (XWINDOW (w
)->vchild
))
562 w
= XWINDOW (w
)->vchild
;
569 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
570 Sactive_minibuffer_window
, 0, 0, 0,
571 "Return the currently active minibuffer window, or nil if none.")
574 return minibuf_level
? minibuf_window
: Qnil
;
577 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
578 "Returns the root-window of FRAME.\n\
579 If omitted, FRAME defaults to the currently selected frame.")
584 XSETFRAME (frame
, selected_frame
);
586 CHECK_LIVE_FRAME (frame
, 0);
588 return XFRAME (frame
)->root_window
;
591 DEFUN ("frame-selected-window", Fframe_selected_window
,
592 Sframe_selected_window
, 0, 1, 0,
593 "Return the selected window of frame object FRAME.\n\
594 If omitted, FRAME defaults to the currently selected frame.")
599 XSETFRAME (frame
, selected_frame
);
601 CHECK_LIVE_FRAME (frame
, 0);
603 return XFRAME (frame
)->selected_window
;
606 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
607 Sset_frame_selected_window
, 2, 2, 0,
608 "Set the selected window of frame object FRAME to WINDOW.\n\
609 If FRAME is nil, the selected frame is used.\n\
610 If FRAME is the selected frame, this makes WINDOW the selected window.")
612 Lisp_Object frame
, window
;
615 XSETFRAME (frame
, selected_frame
);
617 CHECK_LIVE_FRAME (frame
, 0);
619 CHECK_LIVE_WINDOW (window
, 1);
621 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
622 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
624 if (XFRAME (frame
) == selected_frame
)
625 return Fselect_window (window
);
627 return XFRAME (frame
)->selected_window
= window
;
630 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
632 "Return a list of all frames.")
635 return Fcopy_sequence (Vframe_list
);
638 /* Return the next frame in the frame list after FRAME.
639 If MINIBUF is nil, exclude minibuffer-only frames.
640 If MINIBUF is a window, include only its own frame
641 and any frame now using that window as the minibuffer.
642 If MINIBUF is `visible', include all visible frames.
643 If MINIBUF is 0, include all visible and iconified frames.
644 Otherwise, include all frames. */
647 next_frame (frame
, minibuf
)
654 /* There must always be at least one frame in Vframe_list. */
655 if (! CONSP (Vframe_list
))
658 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
659 forever. Forestall that. */
660 CHECK_LIVE_FRAME (frame
, 0);
663 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
667 f
= XCONS (tail
)->car
;
670 /* Decide whether this frame is eligible to be returned. */
672 /* If we've looped all the way around without finding any
673 eligible frames, return the original frame. */
677 /* Let minibuf decide if this frame is acceptable. */
680 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
683 else if (EQ (minibuf
, Qvisible
))
685 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
686 if (FRAME_VISIBLE_P (XFRAME (f
)))
689 else if (XFASTINT (minibuf
) == 0)
691 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
692 if (FRAME_VISIBLE_P (XFRAME (f
))
693 || FRAME_ICONIFIED_P (XFRAME (f
)))
696 else if (WINDOWP (minibuf
))
698 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
699 /* Check that F either is, or has forwarded its focus to,
701 && (EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
702 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
703 FRAME_FOCUS_FRAME (XFRAME (f
)))))
715 /* Return the previous frame in the frame list before FRAME.
716 If MINIBUF is nil, exclude minibuffer-only frames.
717 If MINIBUF is a window, include only its own frame
718 and any frame now using that window as the minibuffer.
719 If MINIBUF is `visible', include all visible frames.
720 If MINIBUF is 0, include all visible and iconified frames.
721 Otherwise, include all frames. */
724 prev_frame (frame
, minibuf
)
731 /* There must always be at least one frame in Vframe_list. */
732 if (! CONSP (Vframe_list
))
736 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
740 f
= XCONS (tail
)->car
;
744 if (EQ (frame
, f
) && !NILP (prev
))
747 /* Decide whether this frame is eligible to be returned,
748 according to minibuf. */
751 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
754 else if (WINDOWP (minibuf
))
756 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
757 /* Check that F either is, or has forwarded its focus to,
759 && (EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
760 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
761 FRAME_FOCUS_FRAME (XFRAME (f
)))))
764 else if (EQ (minibuf
, Qvisible
))
766 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
767 if (FRAME_VISIBLE_P (XFRAME (f
)))
770 else if (XFASTINT (minibuf
) == 0)
772 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
773 if (FRAME_VISIBLE_P (XFRAME (f
))
774 || FRAME_ICONIFIED_P (XFRAME (f
)))
781 /* We've scanned the entire list. */
783 /* We went through the whole frame list without finding a single
784 acceptable frame. Return the original frame. */
787 /* There were no acceptable frames in the list before FRAME; otherwise,
788 we would have returned directly from the loop. Since PREV is the last
789 acceptable frame in the list, return it. */
794 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
795 "Return the next frame in the frame list after FRAME.\n\
796 By default, skip minibuffer-only frames.\n\
797 If omitted, FRAME defaults to the selected frame.\n\
798 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
799 If MINIBUF is a window, include only its own frame\n\
800 and any frame now using that window as the minibuffer.\n\
801 If MINIFRAME is `visible', include all visible frames.\n\
802 If MINIBUF is 0, include all visible and iconified frames.\n\
803 Otherwise, include all frames.")
805 Lisp_Object frame
, miniframe
;
810 XSETFRAME (frame
, selected_frame
);
812 CHECK_LIVE_FRAME (frame
, 0);
814 return next_frame (frame
, miniframe
);
817 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
818 "Return the previous frame in the frame list before FRAME.\n\
819 By default, skip minibuffer-only frames.\n\
820 If omitted, FRAME defaults to the selected frame.\n\
821 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
822 If MINIBUF is a window, include only its own frame\n\
823 and any frame now using that window as the minibuffer.\n\
824 If MINIFRAME is `visible', include all visible frames.\n\
825 If MINIBUF is 0, include all visible and iconified frames.\n\
826 Otherwise, include all frames.")
828 Lisp_Object frame
, miniframe
;
833 XSETFRAME (frame
, selected_frame
);
835 CHECK_LIVE_FRAME (frame
, 0);
837 return prev_frame (frame
, miniframe
);
840 /* Return 1 if it is ok to delete frame F;
841 0 if all frames aside from F are invisible.
842 (Exception: if F is the terminal frame, and we are using X, return 1.) */
845 other_visible_frames (f
)
848 /* We know the selected frame is visible,
849 so if F is some other frame, it can't be the sole visible one. */
850 if (f
== selected_frame
)
855 for (frames
= Vframe_list
;
857 frames
= XCONS (frames
)->cdr
)
861 this = XCONS (frames
)->car
;
862 /* Verify that the frame's window still exists
863 and we can still talk to it. And note any recent change
865 #ifdef HAVE_X_WINDOWS
866 if (FRAME_X_P (XFRAME (this)))
868 x_sync (XFRAME (this));
869 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
873 if (FRAME_VISIBLE_P (XFRAME (this))
874 || FRAME_ICONIFIED_P (XFRAME (this))
875 /* Allow deleting the terminal frame when at least
876 one X frame exists! */
877 || (FRAME_X_P (XFRAME (this)) && !FRAME_X_P (f
)))
885 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
886 "Delete FRAME, permanently eliminating it from use.\n\
887 If omitted, FRAME defaults to the selected frame.\n\
888 A frame may not be deleted if its minibuffer is used by other frames.\n\
889 Normally, you may not delete a frame if all other frames are invisible,\n\
890 but if the second optional argument FORCE is non-nil, you may do so.")
892 Lisp_Object frame
, force
;
896 if (EQ (frame
, Qnil
))
899 XSETFRAME (frame
, f
);
903 CHECK_FRAME (frame
, 0);
907 if (! FRAME_LIVE_P (f
))
910 if (NILP (force
) && !other_visible_frames (f
))
911 error ("Attempt to delete the sole visible or iconified frame");
913 /* Does this frame have a minibuffer, and is it the surrogate
914 minibuffer for any other frame? */
915 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
919 for (frames
= Vframe_list
;
921 frames
= XCONS (frames
)->cdr
)
924 this = XCONS (frames
)->car
;
926 if (! EQ (this, frame
)
928 WINDOW_FRAME (XWINDOW
929 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
930 error ("Attempt to delete a surrogate minibuffer frame");
934 /* Don't let the frame remain selected. */
935 if (f
== selected_frame
)
936 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
938 /* Don't allow minibuf_window to remain on a deleted frame. */
939 if (EQ (f
->minibuffer_window
, minibuf_window
))
941 Fset_window_buffer (selected_frame
->minibuffer_window
,
942 XWINDOW (minibuf_window
)->buffer
);
943 minibuf_window
= selected_frame
->minibuffer_window
;
946 /* Clear any X selections for this frame. */
947 #ifdef HAVE_X_WINDOWS
949 x_clear_frame_selections (f
);
952 /* Mark all the windows that used to be on FRAME as deleted, and then
953 remove the reference to them. */
954 delete_all_subwindows (XWINDOW (f
->root_window
));
955 f
->root_window
= Qnil
;
957 Vframe_list
= Fdelq (frame
, Vframe_list
);
958 FRAME_SET_VISIBLE (f
, 0);
962 if (FRAME_CURRENT_GLYPHS (f
))
963 free_frame_glyphs (f
, FRAME_CURRENT_GLYPHS (f
));
964 if (FRAME_DESIRED_GLYPHS (f
))
965 free_frame_glyphs (f
, FRAME_DESIRED_GLYPHS (f
));
966 if (FRAME_TEMP_GLYPHS (f
))
967 free_frame_glyphs (f
, FRAME_TEMP_GLYPHS (f
));
968 if (FRAME_INSERT_COST (f
))
969 free (FRAME_INSERT_COST (f
));
970 if (FRAME_DELETEN_COST (f
))
971 free (FRAME_DELETEN_COST (f
));
972 if (FRAME_INSERTN_COST (f
))
973 free (FRAME_INSERTN_COST (f
));
974 if (FRAME_DELETE_COST (f
))
975 free (FRAME_DELETE_COST (f
));
977 /* Since some events are handled at the interrupt level, we may get
978 an event for f at any time; if we zero out the frame's display
979 now, then we may trip up the event-handling code. Instead, we'll
980 promise that the display of the frame must be valid until we have
981 called the window-system-dependent frame destruction routine. */
983 /* I think this should be done with a hook. */
984 #ifdef HAVE_X_WINDOWS
986 x_destroy_window (f
);
989 f
->display
.nothing
= 0;
991 /* If we've deleted the last_nonminibuf_frame, then try to find
993 if (f
== last_nonminibuf_frame
)
997 last_nonminibuf_frame
= 0;
999 for (frames
= Vframe_list
;
1001 frames
= XCONS (frames
)->cdr
)
1003 f
= XFRAME (XCONS (frames
)->car
);
1004 if (!FRAME_MINIBUF_ONLY_P (f
))
1006 last_nonminibuf_frame
= f
;
1012 /* If we've deleted Vdefault_minibuffer_frame, try to find another
1013 one. Prefer minibuffer-only frames, but also notice frames
1014 with other windows. */
1015 if (EQ (frame
, Vdefault_minibuffer_frame
))
1019 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1020 Lisp_Object frame_with_minibuf
;
1022 frame_with_minibuf
= Qnil
;
1023 for (frames
= Vframe_list
;
1025 frames
= XCONS (frames
)->cdr
)
1029 this = XCONS (frames
)->car
;
1034 if (FRAME_HAS_MINIBUF_P (f
))
1036 frame_with_minibuf
= this;
1037 if (FRAME_MINIBUF_ONLY_P (f
))
1042 /* We know that there must be some frame with a minibuffer out
1043 there. If this were not true, all of the frames present
1044 would have to be minibufferless, which implies that at some
1045 point their minibuffer frames must have been deleted, but
1046 that is prohibited at the top; you can't delete surrogate
1047 minibuffer frames. */
1048 if (NILP (frame_with_minibuf
))
1051 Vdefault_minibuffer_frame
= frame_with_minibuf
;
1057 /* Return mouse position in character cell units. */
1059 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1060 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
1061 The position is given in character cells, where (0, 0) is the\n\
1062 upper-left corner.\n\
1063 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
1064 to read the mouse position, it returns the selected frame for FRAME\n\
1065 and nil for X and Y.")
1069 Lisp_Object lispy_dummy
;
1070 enum scroll_bar_part party_dummy
;
1073 unsigned long long_dummy
;
1079 /* It's okay for the hook to refrain from storing anything. */
1080 if (mouse_position_hook
)
1081 (*mouse_position_hook
) (&f
, 0,
1082 &lispy_dummy
, &party_dummy
,
1089 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, 0, 1);
1094 XSETFRAME (lispy_dummy
, f
);
1095 return Fcons (lispy_dummy
, Fcons (x
, y
));
1098 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1099 Smouse_pixel_position
, 0, 0, 0,
1100 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
1101 The position is given in pixel units, where (0, 0) is the\n\
1102 upper-left corner.\n\
1103 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
1104 to read the mouse position, it returns the selected frame for FRAME\n\
1105 and nil for X and Y.")
1109 Lisp_Object lispy_dummy
;
1110 enum scroll_bar_part party_dummy
;
1113 unsigned long long_dummy
;
1119 /* It's okay for the hook to refrain from storing anything. */
1120 if (mouse_position_hook
)
1121 (*mouse_position_hook
) (&f
, 0,
1122 &lispy_dummy
, &party_dummy
,
1126 XSETFRAME (lispy_dummy
, f
);
1127 return Fcons (lispy_dummy
, Fcons (x
, y
));
1130 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1131 "Move the mouse pointer to the center of character cell (X,Y) in FRAME.\n\
1132 WARNING: If you use this under X windows,\n\
1133 you should call `unfocus-frame' afterwards.")
1135 Lisp_Object frame
, x
, y
;
1137 CHECK_LIVE_FRAME (frame
, 0);
1138 CHECK_NUMBER (x
, 2);
1139 CHECK_NUMBER (y
, 1);
1141 /* I think this should be done with a hook. */
1142 #ifdef HAVE_X_WINDOWS
1143 if (FRAME_X_P (XFRAME (frame
)))
1144 /* Warping the mouse will cause enternotify and focus events. */
1145 x_set_mouse_position (XFRAME (frame
), x
, y
);
1151 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1152 Sset_mouse_pixel_position
, 3, 3, 0,
1153 "Move the mouse pointer to pixel position (X,Y) in FRAME.\n\
1154 WARNING: If you use this under X windows,\n\
1155 you should call `unfocus-frame' afterwards.")
1157 Lisp_Object frame
, x
, y
;
1159 CHECK_LIVE_FRAME (frame
, 0);
1160 CHECK_NUMBER (x
, 2);
1161 CHECK_NUMBER (y
, 1);
1163 /* I think this should be done with a hook. */
1164 #ifdef HAVE_X_WINDOWS
1165 if (FRAME_X_P (XFRAME (frame
)))
1166 /* Warping the mouse will cause enternotify and focus events. */
1167 x_set_mouse_pixel_position (XFRAME (frame
), x
, y
);
1173 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1175 "Make the frame FRAME visible (assuming it is an X-window).\n\
1176 If omitted, FRAME defaults to the currently selected frame.")
1181 XSETFRAME (frame
, selected_frame
);
1183 CHECK_LIVE_FRAME (frame
, 0);
1185 /* I think this should be done with a hook. */
1186 #ifdef HAVE_X_WINDOWS
1187 if (FRAME_X_P (XFRAME (frame
)))
1189 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1190 x_make_frame_visible (XFRAME (frame
));
1194 /* Make menu bar update for the Buffers and Frams menus. */
1195 windows_or_buffers_changed
++;
1200 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1202 "Make the frame FRAME invisible (assuming it is an X-window).\n\
1203 If omitted, FRAME defaults to the currently selected frame.\n\
1204 Normally you may not make FRAME invisible if all other frames are invisible,\n\
1205 but if the second optional argument FORCE is non-nil, you may do so.")
1207 Lisp_Object frame
, force
;
1210 XSETFRAME (frame
, selected_frame
);
1212 CHECK_LIVE_FRAME (frame
, 0);
1214 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1215 error ("Attempt to make invisible the sole visible or iconified frame");
1217 #if 0 /* This isn't logically necessary, and it can do GC. */
1218 /* Don't let the frame remain selected. */
1219 if (XFRAME (frame
) == selected_frame
)
1220 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1223 /* Don't allow minibuf_window to remain on a deleted frame. */
1224 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1226 Fset_window_buffer (selected_frame
->minibuffer_window
,
1227 XWINDOW (minibuf_window
)->buffer
);
1228 minibuf_window
= selected_frame
->minibuffer_window
;
1231 /* I think this should be done with a hook. */
1232 #ifdef HAVE_X_WINDOWS
1233 if (FRAME_X_P (XFRAME (frame
)))
1234 x_make_frame_invisible (XFRAME (frame
));
1237 /* Make menu bar update for the Buffers and Frams menus. */
1238 windows_or_buffers_changed
++;
1243 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1245 "Make the frame FRAME into an icon.\n\
1246 If omitted, FRAME defaults to the currently selected frame.")
1251 XSETFRAME (frame
, selected_frame
);
1253 CHECK_LIVE_FRAME (frame
, 0);
1255 #if 0 /* This isn't logically necessary, and it can do GC. */
1256 /* Don't let the frame remain selected. */
1257 if (XFRAME (frame
) == selected_frame
)
1258 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1261 /* Don't allow minibuf_window to remain on a deleted frame. */
1262 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1264 Fset_window_buffer (selected_frame
->minibuffer_window
,
1265 XWINDOW (minibuf_window
)->buffer
);
1266 minibuf_window
= selected_frame
->minibuffer_window
;
1269 /* I think this should be done with a hook. */
1270 #ifdef HAVE_X_WINDOWS
1271 if (FRAME_X_P (XFRAME (frame
)))
1272 x_iconify_frame (XFRAME (frame
));
1275 /* Make menu bar update for the Buffers and Frams menus. */
1276 windows_or_buffers_changed
++;
1281 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1283 "Return t if FRAME is now \"visible\" (actually in use for display).\n\
1284 A frame that is not \"visible\" is not updated and, if it works through\n\
1285 a window system, it may not show at all.\n\
1286 Return the symbol `icon' if frame is visible only as an icon.")
1290 CHECK_LIVE_FRAME (frame
, 0);
1292 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1294 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1296 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1301 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1303 "Return a list of all frames now \"visible\" (being updated).")
1306 Lisp_Object tail
, frame
;
1311 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
1313 frame
= XCONS (tail
)->car
;
1314 if (!FRAMEP (frame
))
1317 if (FRAME_VISIBLE_P (f
))
1318 value
= Fcons (frame
, value
);
1324 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 1, 1, "",
1325 "Bring FRAME to the front, so it occludes any frames it overlaps.\n\
1326 If FRAME is invisible, make it visible.\n\
1327 If you don't specify a frame, the selected frame is used.\n\
1328 If Emacs is displaying on an ordinary terminal or some other device which\n\
1329 doesn't support multiple overlapping frames, this function does nothing.")
1334 XSETFRAME (frame
, selected_frame
);
1336 CHECK_LIVE_FRAME (frame
, 0);
1338 /* Do like the documentation says. */
1339 Fmake_frame_visible (frame
);
1341 if (frame_raise_lower_hook
)
1342 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1347 /* Should we have a corresponding function called Flower_Power? */
1348 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 1, 1, "",
1349 "Send FRAME to the back, so it is occluded by any frames that overlap it.\n\
1350 If you don't specify a frame, the selected frame is used.\n\
1351 If Emacs is displaying on an ordinary terminal or some other device which\n\
1352 doesn't support multiple overlapping frames, this function does nothing.")
1357 XSETFRAME (frame
, selected_frame
);
1359 CHECK_LIVE_FRAME (frame
, 0);
1361 if (frame_raise_lower_hook
)
1362 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1368 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1370 "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
1371 In other words, switch-frame events caused by events in FRAME will\n\
1372 request a switch to FOCUS-FRAME, and `last-event-frame' will be\n\
1373 FOCUS-FRAME after reading an event typed at FRAME.\n\
1375 If FOCUS-FRAME is omitted or nil, any existing redirection is\n\
1376 cancelled, and the frame again receives its own keystrokes.\n\
1378 Focus redirection is useful for temporarily redirecting keystrokes to\n\
1379 a surrogate minibuffer frame when a frame doesn't have its own\n\
1380 minibuffer window.\n\
1382 A frame's focus redirection can be changed by select-frame. If frame\n\
1383 FOO is selected, and then a different frame BAR is selected, any\n\
1384 frames redirecting their focus to FOO are shifted to redirect their\n\
1385 focus to BAR. This allows focus redirection to work properly when the\n\
1386 user switches from one frame to another using `select-window'.\n\
1388 This means that a frame whose focus is redirected to itself is treated\n\
1389 differently from a frame whose focus is redirected to nil; the former\n\
1390 is affected by select-frame, while the latter is not.\n\
1392 The redirection lasts until `redirect-frame-focus' is called to change it.")
1393 (frame
, focus_frame
)
1394 Lisp_Object frame
, focus_frame
;
1396 /* Note that we don't check for a live frame here. It's reasonable
1397 to redirect the focus of a frame you're about to delete, if you
1398 know what other frame should receive those keystrokes. */
1399 CHECK_FRAME (frame
, 0);
1401 if (! NILP (focus_frame
))
1402 CHECK_LIVE_FRAME (focus_frame
, 1);
1404 XFRAME (frame
)->focus_frame
= focus_frame
;
1406 /* I think this should be done with a hook. */
1407 #ifdef HAVE_X_WINDOWS
1408 if (!NILP (focus_frame
) && ! EQ (focus_frame
, frame
)
1409 && FRAME_X_P (XFRAME (focus_frame
)))
1410 Ffocus_frame (focus_frame
);
1413 if (frame_rehighlight_hook
)
1414 (*frame_rehighlight_hook
) ();
1420 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1421 "Return the frame to which FRAME's keystrokes are currently being sent.\n\
1422 This returns nil if FRAME's focus is not redirected.\n\
1423 See `redirect-frame-focus'.")
1427 CHECK_LIVE_FRAME (frame
, 0);
1429 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1434 /* Return the value of frame parameter PROP in frame FRAME. */
1437 get_frame_param (frame
, prop
)
1438 register struct frame
*frame
;
1441 register Lisp_Object tem
;
1443 tem
= Fassq (prop
, frame
->param_alist
);
1449 /* Return the buffer-predicate of the selected frame. */
1452 frame_buffer_predicate ()
1454 return selected_frame
->buffer_predicate
;
1457 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1458 If the alist already has an element for PROP, we change it. */
1461 store_in_alist (alistptr
, prop
, val
)
1462 Lisp_Object
*alistptr
, val
;
1465 register Lisp_Object tem
;
1467 tem
= Fassq (prop
, *alistptr
);
1469 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1475 store_frame_param (f
, prop
, val
)
1477 Lisp_Object prop
, val
;
1479 register Lisp_Object tem
;
1481 tem
= Fassq (prop
, f
->param_alist
);
1483 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
1487 if (EQ (prop
, Qbuffer_predicate
))
1488 f
->buffer_predicate
= val
;
1490 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
1492 if (! MINI_WINDOW_P (XWINDOW (val
)))
1493 error ("Surrogate minibuffer windows must be minibuffer windows.");
1495 if (FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
1496 error ("can't change the surrogate minibuffer of a frame with its own minibuffer");
1498 /* Install the chosen minibuffer window, with proper buffer. */
1499 f
->minibuffer_window
= val
;
1503 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
1504 "Return the parameters-alist of frame FRAME.\n\
1505 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
1506 The meaningful PARMs depend on the kind of frame.\n\
1507 If FRAME is omitted, return information on the currently selected frame.")
1514 if (EQ (frame
, Qnil
))
1518 CHECK_FRAME (frame
, 0);
1522 if (!FRAME_LIVE_P (f
))
1525 alist
= Fcopy_alist (f
->param_alist
);
1526 store_in_alist (&alist
, Qname
, f
->name
);
1527 store_in_alist (&alist
, Qheight
, make_number (FRAME_HEIGHT (f
)));
1528 store_in_alist (&alist
, Qwidth
, make_number (FRAME_WIDTH (f
)));
1529 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
1530 store_in_alist (&alist
, Qminibuffer
,
1531 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
1532 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
1533 : FRAME_MINIBUF_WINDOW (f
)));
1534 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
1536 /* I think this should be done with a hook. */
1537 #ifdef HAVE_X_WINDOWS
1539 x_report_frame_params (f
, &alist
);
1543 /* This ought to be correct in f->param_alist for an X frame. */
1545 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
1546 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
1551 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
1552 Smodify_frame_parameters
, 2, 2, 0,
1553 "Modify the parameters of frame FRAME according to ALIST.\n\
1554 ALIST is an alist of parameters to change and their new values.\n\
1555 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
1556 The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
1558 Lisp_Object frame
, alist
;
1561 register Lisp_Object tail
, elt
, prop
, val
;
1563 if (EQ (frame
, Qnil
))
1567 CHECK_LIVE_FRAME (frame
, 0);
1571 /* I think this should be done with a hook. */
1572 #ifdef HAVE_X_WINDOWS
1574 x_set_frame_parameters (f
, alist
);
1577 for (tail
= alist
; !EQ (tail
, Qnil
); tail
= Fcdr (tail
))
1582 store_frame_param (f
, prop
, val
);
1588 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
1590 "Height in pixels of a line in the font in frame FRAME.\n\
1591 If FRAME is omitted, the selected frame is used.\n\
1592 For a terminal frame, the value is always 1.")
1602 CHECK_FRAME (frame
, 0);
1606 #ifdef HAVE_X_WINDOWS
1608 return make_number (x_char_height (f
));
1611 return make_number (1);
1615 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
1617 "Width in pixels of characters in the font in frame FRAME.\n\
1618 If FRAME is omitted, the selected frame is used.\n\
1619 The width is the same for all characters, because\n\
1620 currently Emacs supports only fixed-width fonts.\n\
1621 For a terminal screen, the value is always 1.")
1631 CHECK_FRAME (frame
, 0);
1635 #ifdef HAVE_X_WINDOWS
1637 return make_number (x_char_width (f
));
1640 return make_number (1);
1643 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
1644 Sframe_pixel_height
, 0, 1, 0,
1645 "Return a FRAME's height in pixels.\n\
1646 For a terminal frame, the result really gives the height in characters.\n\
1647 If FRAME is omitted, the selected frame is used.")
1657 CHECK_FRAME (frame
, 0);
1661 #ifdef HAVE_X_WINDOWS
1663 return make_number (x_pixel_height (f
));
1666 return make_number (FRAME_HEIGHT (f
));
1669 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
1670 Sframe_pixel_width
, 0, 1, 0,
1671 "Return FRAME's width in pixels.\n\
1672 For a terminal frame, the result really gives the width in characters.\n\
1673 If FRAME is omitted, the selected frame is used.")
1683 CHECK_FRAME (frame
, 0);
1687 #ifdef HAVE_X_WINDOWS
1689 return make_number (x_pixel_width (f
));
1692 return make_number (FRAME_WIDTH (f
));
1695 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1696 "Specify that the frame FRAME has LINES lines.\n\
1697 Optional third arg non-nil means that redisplay should use LINES lines\n\
1698 but that the idea of the actual height of the frame should not be changed.")
1699 (frame
, rows
, pretend
)
1700 Lisp_Object frame
, rows
, pretend
;
1702 register struct frame
*f
;
1704 CHECK_NUMBER (rows
, 0);
1709 CHECK_LIVE_FRAME (frame
, 0);
1713 /* I think this should be done with a hook. */
1714 #ifdef HAVE_X_WINDOWS
1717 if (XINT (rows
) != f
->height
)
1718 x_set_window_size (f
, 1, f
->width
, XINT (rows
));
1722 change_frame_size (f
, XINT (rows
), 0, !NILP (pretend
), 0);
1726 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1727 "Specify that the frame FRAME has COLS columns.\n\
1728 Optional third arg non-nil means that redisplay should use COLS columns\n\
1729 but that the idea of the actual width of the frame should not be changed.")
1730 (frame
, cols
, pretend
)
1731 Lisp_Object frame
, cols
, pretend
;
1733 register struct frame
*f
;
1734 CHECK_NUMBER (cols
, 0);
1739 CHECK_LIVE_FRAME (frame
, 0);
1743 /* I think this should be done with a hook. */
1744 #ifdef HAVE_X_WINDOWS
1747 if (XINT (cols
) != f
->width
)
1748 x_set_window_size (f
, 1, XINT (cols
), f
->height
);
1752 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0);
1756 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1757 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1759 Lisp_Object frame
, cols
, rows
;
1761 register struct frame
*f
;
1764 CHECK_LIVE_FRAME (frame
, 0);
1765 CHECK_NUMBER (cols
, 2);
1766 CHECK_NUMBER (rows
, 1);
1769 /* I think this should be done with a hook. */
1770 #ifdef HAVE_X_WINDOWS
1773 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
)
1774 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
1778 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0);
1783 DEFUN ("set-frame-position", Fset_frame_position
,
1784 Sset_frame_position
, 3, 3, 0,
1785 "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
1786 This is actually the position of the upper left corner of the frame.\n\
1787 Negative values for XOFFSET or YOFFSET are interpreted relative to\n\
1788 the rightmost or bottommost possible position (that stays within the screen).")
1789 (frame
, xoffset
, yoffset
)
1790 Lisp_Object frame
, xoffset
, yoffset
;
1792 register struct frame
*f
;
1795 CHECK_LIVE_FRAME (frame
, 0);
1796 CHECK_NUMBER (xoffset
, 1);
1797 CHECK_NUMBER (yoffset
, 2);
1800 /* I think this should be done with a hook. */
1801 #ifdef HAVE_X_WINDOWS
1803 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
1810 choose_minibuf_frame ()
1812 /* For lowest-level minibuf, put it on currently selected frame
1813 if frame has a minibuffer. */
1815 if (minibuf_level
== 0
1816 && selected_frame
!= 0
1817 && !EQ (minibuf_window
, selected_frame
->minibuffer_window
))
1819 /* I don't think that any frames may validly have a null minibuffer
1821 if (NILP (selected_frame
->minibuffer_window
))
1824 Fset_window_buffer (selected_frame
->minibuffer_window
,
1825 XWINDOW (minibuf_window
)->buffer
);
1826 minibuf_window
= selected_frame
->minibuffer_window
;
1832 /*&&& init symbols here &&&*/
1833 Qframep
= intern ("framep");
1834 staticpro (&Qframep
);
1835 Qframe_live_p
= intern ("frame-live-p");
1836 staticpro (&Qframe_live_p
);
1837 Qheight
= intern ("height");
1838 staticpro (&Qheight
);
1839 Qicon
= intern ("icon");
1841 Qminibuffer
= intern ("minibuffer");
1842 staticpro (&Qminibuffer
);
1843 Qmodeline
= intern ("modeline");
1844 staticpro (&Qmodeline
);
1845 Qname
= intern ("name");
1847 Qonly
= intern ("only");
1849 Qunsplittable
= intern ("unsplittable");
1850 staticpro (&Qunsplittable
);
1851 Qmenu_bar_lines
= intern ("menu-bar-lines");
1852 staticpro (&Qmenu_bar_lines
);
1853 Qwidth
= intern ("width");
1854 staticpro (&Qwidth
);
1857 Qvisible
= intern ("visible");
1858 staticpro (&Qvisible
);
1859 Qbuffer_predicate
= intern ("buffer-predicate");
1860 staticpro (&Qbuffer_predicate
);
1862 staticpro (&Vframe_list
);
1864 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
1865 "The initial frame-object, which represents Emacs's stdout.");
1867 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
1868 "Non-nil if all of emacs is iconified and frame updates are not needed.");
1869 Vemacs_iconified
= Qnil
;
1871 DEFVAR_LISP ("default-minibuffer-frame", &Vdefault_minibuffer_frame
,
1872 "Minibufferless frames use this frame's minibuffer.\n\
1874 Emacs cannot create minibufferless frames unless this is set to an\n\
1875 appropriate surrogate.\n\
1877 Emacs consults this variable only when creating minibufferless\n\
1878 frames; once the frame is created, it sticks with its assigned\n\
1879 minibuffer, no matter what this variable is set to. This means that\n\
1880 this variable doesn't necessarily say anything meaningful about the\n\
1881 current set of frames, or where the minibuffer is currently being\n\
1883 Vdefault_minibuffer_frame
= Qnil
;
1885 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
1886 "Alist of default values for frame creation.\n\
1887 These may be set in your init file, like this:\n\
1888 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))\n\
1889 These override values given in window system configuration data,\n\
1890 including X Windows' defaults database.\n\
1891 For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
1892 For values specific to the separate minibuffer frame, see\n\
1893 `minibuffer-frame-alist'.\n\
1894 The `menu-bar-lines' element of the list controls whether new frames\n\
1895 have menu bars; `menu-bar-mode' works by altering this element.");
1896 Vdefault_frame_alist
= Qnil
;
1898 defsubr (&Sactive_minibuffer_window
);
1900 defsubr (&Sframe_live_p
);
1901 defsubr (&Smake_terminal_frame
);
1902 defsubr (&Shandle_switch_frame
);
1903 defsubr (&Sselect_frame
);
1904 defsubr (&Sselected_frame
);
1905 defsubr (&Swindow_frame
);
1906 defsubr (&Sframe_root_window
);
1907 defsubr (&Sframe_first_window
);
1908 defsubr (&Sframe_selected_window
);
1909 defsubr (&Sset_frame_selected_window
);
1910 defsubr (&Sframe_list
);
1911 defsubr (&Snext_frame
);
1912 defsubr (&Sprevious_frame
);
1913 defsubr (&Sdelete_frame
);
1914 defsubr (&Smouse_position
);
1915 defsubr (&Smouse_pixel_position
);
1916 defsubr (&Sset_mouse_position
);
1917 defsubr (&Sset_mouse_pixel_position
);
1919 defsubr (&Sframe_configuration
);
1920 defsubr (&Srestore_frame_configuration
);
1922 defsubr (&Smake_frame_visible
);
1923 defsubr (&Smake_frame_invisible
);
1924 defsubr (&Siconify_frame
);
1925 defsubr (&Sframe_visible_p
);
1926 defsubr (&Svisible_frame_list
);
1927 defsubr (&Sraise_frame
);
1928 defsubr (&Slower_frame
);
1929 defsubr (&Sredirect_frame_focus
);
1930 defsubr (&Sframe_focus
);
1931 defsubr (&Sframe_parameters
);
1932 defsubr (&Smodify_frame_parameters
);
1933 defsubr (&Sframe_char_height
);
1934 defsubr (&Sframe_char_width
);
1935 defsubr (&Sframe_pixel_height
);
1936 defsubr (&Sframe_pixel_width
);
1937 defsubr (&Sset_frame_height
);
1938 defsubr (&Sset_frame_width
);
1939 defsubr (&Sset_frame_size
);
1940 defsubr (&Sset_frame_position
);
1945 initial_define_lispy_key (global_map
, "switch-frame", "handle-switch-frame");
1946 initial_define_lispy_key (global_map
, "delete-frame", "handle-delete-frame");
1947 initial_define_lispy_key (global_map
, "iconify-frame", "ignore");
1948 initial_define_lispy_key (global_map
, "make-frame-visible", "ignore");
1951 #else /* not MULTI_FRAME */
1953 /* If we're not using multi-frame stuff, we still need to provide some
1954 support functions. */
1956 Lisp_Object Qheight
;
1957 Lisp_Object Qminibuffer
;
1958 Lisp_Object Qmodeline
;
1960 Lisp_Object Qunsplittable
;
1961 Lisp_Object Qmenu_bar_lines
;
1964 Lisp_Object Vterminal_frame
;
1966 /* Unless this function is defined, providing set-frame-height and
1967 set-frame-width doesn't help compatibility any, since they both
1968 want this as their first argument. */
1969 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 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! */
1975 /* For your possible information, this code is unfolded into the
1976 second WINDOW_FRAME in frame.h. */
1978 XSETFASTINT (tem
, 0);
1982 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
1983 /* Don't confuse make-docfile by having two doc strings for this function.
1984 make-docfile does not pay attention to #if, for good reason! */
1989 /* For your possible information, this code is unfolded into the
1990 second WINDOW_FRAME in frame.h. */
1992 XSETFASTINT (tem
, 0);
1996 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
2003 w
= FRAME_ROOT_WINDOW (selected_frame
);
2005 while (NILP (XWINDOW (w
)->buffer
))
2007 if (! NILP (XWINDOW (w
)->hchild
))
2008 w
= XWINDOW (w
)->hchild
;
2009 else if (! NILP (XWINDOW (w
)->vchild
))
2010 w
= XWINDOW (w
)->vchild
;
2017 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
2018 /* Don't confuse make-docfile by having two doc strings for this function.
2019 make-docfile does not pay attention to #if, for good reason! */
2025 if (FRAME_X_P (object
))
2026 return intern ("pc");
2031 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2032 /* Don't confuse make-docfile by having two doc strings for this function.
2033 make-docfile does not pay attention to #if, for good reason! */
2035 (frame
, rows
, pretend
)
2036 Lisp_Object frame
, rows
, pretend
;
2038 CHECK_NUMBER (rows
, 0);
2040 change_frame_size (0, XINT (rows
), 0, !NILP (pretend
), 0);
2044 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2045 /* Don't confuse make-docfile by having two doc strings for this function.
2046 make-docfile does not pay attention to #if, for good reason! */
2048 (frame
, cols
, pretend
)
2049 Lisp_Object frame
, cols
, pretend
;
2051 CHECK_NUMBER (cols
, 0);
2053 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
2057 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2058 /* Don't confuse make-docfile by having two doc strings for this function.
2059 make-docfile does not pay attention to #if, for good reason! */
2062 Lisp_Object frame
, cols
, rows
;
2064 CHECK_NUMBER (cols
, 2);
2065 CHECK_NUMBER (rows
, 1);
2067 change_frame_size (0, XINT (rows
), XINT (cols
), 0, 0);
2072 DEFUN ("frame-height", Fframe_height
, Sframe_height
, 0, 1, 0,
2073 "Return number of lines available for display on FRAME.\n\
2074 If FRAME is omitted, describe the currently selected frame.")
2078 return make_number (FRAME_HEIGHT (selected_frame
));
2081 DEFUN ("frame-width", Fframe_width
, Sframe_width
, 0, 1, 0,
2082 "Return number of columns available for display on FRAME.\n\
2083 If FRAME is omitted, describe the currently selected frame.")
2087 return make_number (FRAME_WIDTH (selected_frame
));
2090 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2092 /* Don't confuse make-docfile by having two doc strings for this function.
2093 make-docfile does not pay attention to #if, for good reason! */
2098 return make_number (1);
2102 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2104 /* Don't confuse make-docfile by having two doc strings for this function.
2105 make-docfile does not pay attention to #if, for good reason! */
2110 return make_number (1);
2113 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2114 Sframe_pixel_height
, 0, 1, 0,
2115 /* Don't confuse make-docfile by having two doc strings for this function.
2116 make-docfile does not pay attention to #if, for good reason! */
2121 return make_number (FRAME_HEIGHT (f
));
2124 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2125 Sframe_pixel_width
, 0, 1, 0,
2126 /* Don't confuse make-docfile by having two doc strings for this function.
2127 make-docfile does not pay attention to #if, for good reason! */
2132 return make_number (FRAME_WIDTH (f
));
2135 /* These are for backward compatibility with Emacs 18. */
2137 DEFUN ("set-screen-height", Fset_screen_height
, Sset_screen_height
, 1, 2, 0,
2138 "Tell redisplay that the screen has LINES lines.\n\
2139 Optional second arg non-nil means that redisplay should use LINES lines\n\
2140 but that the idea of the actual height of the screen should not be changed.")
2142 Lisp_Object lines
, pretend
;
2144 CHECK_NUMBER (lines
, 0);
2146 change_frame_size (0, XINT (lines
), 0, !NILP (pretend
), 0);
2150 DEFUN ("set-screen-width", Fset_screen_width
, Sset_screen_width
, 1, 2, 0,
2151 "Tell redisplay that the screen has COLS columns.\n\
2152 Optional second arg non-nil means that redisplay should use COLS columns\n\
2153 but that the idea of the actual width of the screen should not be changed.")
2155 Lisp_Object cols
, pretend
;
2157 CHECK_NUMBER (cols
, 0);
2159 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
2163 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 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! */
2170 if (mouse_position_hook
)
2173 Lisp_Object lispy_dummy
;
2174 enum scroll_bar_part party_dummy
;
2176 unsigned long long_dummy
;
2178 (*mouse_position_hook
) (&f
, 0,
2179 &lispy_dummy
, &party_dummy
,
2182 return Fcons (Fselected_frame (), Fcons (x
, y
));
2185 return Fcons (Qnil
, Fcons (Qnil
, Qnil
));
2189 store_in_alist (alistptr
, prop
, val
)
2190 Lisp_Object
*alistptr
, val
;
2193 register Lisp_Object tem
;
2195 tem
= Fassq (prop
, *alistptr
);
2197 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2202 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2203 /* Don't confuse make-docfile by having two doc strings for this function.
2204 make-docfile does not pay attention to #if, for good reason! */
2212 if (EQ (frame
, Qnil
))
2216 CHECK_FRAME (frame
, 0);
2220 if (!FRAME_LIVE_P (f
))
2227 static char *colornames
[16] =
2229 "black", "blue", "green", "cyan", "red", "magenta", "brown",
2230 "lightgray", "darkgray", "lightblue", "lightgreen", "lightcyan",
2231 "lightred", "lightmagenta", "yellow", "white"
2233 store_in_alist (&alist
, intern ("foreground-color"),
2234 build_string (colornames
[FRAME_FOREGROUND_PIXEL (f
)]));
2235 store_in_alist (&alist
, intern ("background-color"),
2236 build_string (colornames
[FRAME_BACKGROUND_PIXEL (f
)]));
2239 store_in_alist (&alist
, intern ("font"), build_string ("default"));
2240 store_in_alist (&alist
, Qname
, build_string ("emacs"));
2241 store_in_alist (&alist
, Qheight
, make_number (FRAME_HEIGHT (f
)));
2242 store_in_alist (&alist
, Qwidth
, make_number (FRAME_WIDTH (f
)));
2243 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2244 store_in_alist (&alist
, Qminibuffer
, FRAME_MINIBUF_WINDOW (f
));
2245 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2246 store_in_alist (&alist
, Qmenu_bar_lines
, (FRAME_MENU_BAR_LINES (f
)));
2251 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2252 Smodify_frame_parameters
, 2, 2, 0,
2253 /* Don't confuse make-docfile by having two doc strings for this function.
2254 make-docfile does not pay attention to #if, for good reason! */
2257 Lisp_Object frame
, alist
;
2260 if (FRAME_X_P (frame
))
2261 IT_set_frame_parameters (XFRAME (frame
), alist
);
2266 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
2267 /* Don't confuse make-docfile by having two doc strings for this function.
2268 make-docfile does not pay attention to #if, for good reason! */
2276 DEFUN ("frame-list", Fframe_list
, Sframe_list
, 0, 0, 0,
2277 /* Don't confuse make-docfile by having two doc strings for this function.
2278 make-docfile does not pay attention to #if, for good reason! */
2282 return Fcons (Fselected_frame (), Qnil
);
2287 Qheight
= intern ("height");
2288 staticpro (&Qheight
);
2289 Qminibuffer
= intern ("minibuffer");
2290 staticpro (&Qminibuffer
);
2291 Qmodeline
= intern ("modeline");
2292 staticpro (&Qmodeline
);
2293 Qname
= intern ("name");
2295 Qunsplittable
= intern ("unsplittable");
2296 staticpro (&Qunsplittable
);
2297 Qmenu_bar_lines
= intern ("menu-bar-lines");
2298 staticpro (&Qmenu_bar_lines
);
2299 Qwidth
= intern ("width");
2300 staticpro (&Qwidth
);
2302 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
2303 "The initial frame-object, which represents Emacs's stdout.");
2304 XSETFASTINT (Vterminal_frame
, 0);
2306 defsubr (&Sselected_frame
);
2307 defsubr (&Swindow_frame
);
2308 defsubr (&Sframe_first_window
);
2310 defsubr (&Sframe_char_height
);
2311 defsubr (&Sframe_char_width
);
2312 defsubr (&Sframe_pixel_height
);
2313 defsubr (&Sframe_pixel_width
);
2314 defsubr (&Sset_frame_height
);
2315 defsubr (&Sset_frame_width
);
2316 defsubr (&Sset_frame_size
);
2317 defsubr (&Sset_screen_height
);
2318 defsubr (&Sset_screen_width
);
2319 defsubr (&Sframe_height
);
2320 Ffset (intern ("screen-height"), intern ("frame-height"));
2321 defsubr (&Sframe_width
);
2322 Ffset (intern ("screen-width"), intern ("frame-width"));
2323 defsubr (&Smouse_position
);
2324 defsubr (&Sframe_parameters
);
2325 defsubr (&Smodify_frame_parameters
);
2326 defsubr (&Sframe_live_p
);
2327 defsubr (&Sframe_list
);
2330 /* A comment in dispnew.c says the_only_frame is not protected. */
2331 the_only_frame
.face_alist
= Qnil
;
2332 staticpro (&the_only_frame
.face_alist
);
2333 the_only_frame
.menu_bar_items
= Qnil
;
2334 staticpro (&the_only_frame
.menu_bar_items
);
2335 the_only_frame
.menu_bar_vector
= Qnil
;
2336 staticpro (&the_only_frame
.menu_bar_vector
);
2337 the_only_frame
.menu_bar_items
= menu_bar_items (Qnil
);
2345 #endif /* not MULTI_FRAME */