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
;
186 root_window
= make_window ();
189 mini_window
= make_window ();
190 XWINDOW (root_window
)->next
= mini_window
;
191 XWINDOW (mini_window
)->prev
= root_window
;
192 XWINDOW (mini_window
)->mini_p
= Qt
;
193 XWINDOW (mini_window
)->frame
= frame
;
194 f
->minibuffer_window
= mini_window
;
199 XWINDOW (root_window
)->next
= Qnil
;
200 f
->minibuffer_window
= Qnil
;
203 XWINDOW (root_window
)->frame
= frame
;
206 just so that there is "something there."
207 Correct size will be set up later with change_frame_size. */
212 XSETFASTINT (XWINDOW (root_window
)->width
, 10);
213 XSETFASTINT (XWINDOW (root_window
)->height
, (mini_p
? 9 : 10));
217 XSETFASTINT (XWINDOW (mini_window
)->width
, 10);
218 XSETFASTINT (XWINDOW (mini_window
)->top
, 9);
219 XSETFASTINT (XWINDOW (mini_window
)->height
, 1);
222 /* Choose a buffer for the frame's root window. */
226 XWINDOW (root_window
)->buffer
= Qt
;
227 buf
= Fcurrent_buffer ();
228 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
229 a space), try to find another one. */
230 if (XSTRING (Fbuffer_name (buf
))->data
[0] == ' ')
231 buf
= Fother_buffer (buf
, Qnil
);
232 Fset_window_buffer (root_window
, buf
);
237 XWINDOW (mini_window
)->buffer
= Qt
;
238 Fset_window_buffer (mini_window
,
239 (NILP (Vminibuffer_list
)
241 : Fcar (Vminibuffer_list
)));
244 f
->root_window
= root_window
;
245 f
->selected_window
= root_window
;
246 /* Make sure this window seems more recently used than
247 a newly-created, never-selected window. */
248 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, ++window_select_count
);
253 /* Make a frame using a separate minibuffer window on another frame.
254 MINI_WINDOW is the minibuffer window to use. nil means use the
255 default (the global minibuffer). */
258 make_frame_without_minibuffer (mini_window
)
259 register Lisp_Object mini_window
;
261 register struct frame
*f
;
263 /* Choose the minibuffer window to use. */
264 if (NILP (mini_window
))
266 if (!FRAMEP (Vdefault_minibuffer_frame
))
267 error ("default-minibuffer-frame must be set when creating minibufferless frames");
268 if (! FRAME_LIVE_P (XFRAME (Vdefault_minibuffer_frame
)))
269 error ("default-minibuffer-frame must be a live frame");
270 mini_window
= XFRAME (Vdefault_minibuffer_frame
)->minibuffer_window
;
274 CHECK_LIVE_WINDOW (mini_window
, 0);
277 /* Make a frame containing just a root window. */
280 /* Install the chosen minibuffer window, with proper buffer. */
281 f
->minibuffer_window
= mini_window
;
282 Fset_window_buffer (mini_window
,
283 (NILP (Vminibuffer_list
)
285 : Fcar (Vminibuffer_list
)));
289 /* Make a frame containing only a minibuffer window. */
292 make_minibuffer_frame ()
294 /* First make a frame containing just a root window, no minibuffer. */
296 register struct frame
*f
= make_frame (0);
297 register Lisp_Object mini_window
;
298 register Lisp_Object frame
;
300 XSETFRAME (frame
, f
);
305 f
->wants_modeline
= 0;
306 f
->has_minibuffer
= 1;
308 /* Now label the root window as also being the minibuffer.
309 Avoid infinite looping on the window chain by marking next pointer
312 mini_window
= f
->minibuffer_window
= f
->root_window
;
313 XWINDOW (mini_window
)->mini_p
= Qt
;
314 XWINDOW (mini_window
)->next
= Qnil
;
315 XWINDOW (mini_window
)->prev
= Qnil
;
316 XWINDOW (mini_window
)->frame
= frame
;
318 /* Put the proper buffer in that window. */
320 Fset_window_buffer (mini_window
,
321 (NILP (Vminibuffer_list
)
323 : Fcar (Vminibuffer_list
)));
327 /* Construct a frame that refers to the terminal (stdin and stdout). */
329 static int terminal_frame_count
;
332 make_terminal_frame ()
334 register struct frame
*f
;
341 initial_kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
342 init_kboard (initial_kboard
);
346 /* The first call must initialize Vframe_list. */
347 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
352 XSETFRAME (frame
, f
);
353 Vframe_list
= Fcons (frame
, Vframe_list
);
355 terminal_frame_count
++;
356 if (terminal_frame_count
== 1)
358 f
->name
= build_string ("Emacs");
362 sprintf (name
, "Emacs-%d", terminal_frame_count
);
363 f
->name
= build_string (name
);
366 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
367 f
->async_visible
= 1; /* Don't let visible be cleared later. */
368 f
->display
.nothing
= 1; /* Nonzero means frame isn't deleted. */
369 XSETFRAME (Vterminal_frame
, f
);
373 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
374 1, 1, 0, "Create an additional terminal frame.\n\
375 You can create multiple frames on a text-only terminal in this way.\n\
376 Only the selected terminal frame is actually displayed.\n\
377 This function takes one argument, an alist specifying frame parameters.\n\
378 In practice, generally you don't need to specify any parameters.\n\
379 Note that changing the size of one terminal frame automatically affects all.")
386 if (selected_frame
->output_method
!= output_termcap
)
387 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
389 f
= make_terminal_frame ();
390 change_frame_size (f
, FRAME_HEIGHT (selected_frame
),
391 FRAME_WIDTH (selected_frame
), 0, 0);
392 remake_frame_glyphs (f
);
394 XSETFRAME (frame
, f
);
395 Fmodify_frame_parameters (frame
, parms
);
400 do_switch_frame (frame
, no_enter
, track
)
401 Lisp_Object frame
, no_enter
;
404 /* If FRAME is a switch-frame event, extract the frame we should
407 && EQ (XCONS (frame
)->car
, Qswitch_frame
)
408 && CONSP (XCONS (frame
)->cdr
))
409 frame
= XCONS (XCONS (frame
)->cdr
)->car
;
411 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
412 a switch-frame event to arrive after a frame is no longer live,
413 especially when deleting the initial frame during startup. */
414 CHECK_FRAME (frame
, 0);
415 if (! FRAME_LIVE_P (XFRAME (frame
)))
418 if (selected_frame
== XFRAME (frame
))
421 /* This is too greedy; it causes inappropriate focus redirection
422 that's hard to get rid of. */
424 /* If a frame's focus has been redirected toward the currently
425 selected frame, we should change the redirection to point to the
426 newly selected frame. This means that if the focus is redirected
427 from a minibufferless frame to a surrogate minibuffer frame, we
428 can use `other-window' to switch between all the frames using
429 that minibuffer frame, and the focus redirection will follow us
435 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
439 if (!FRAMEP (XCONS (tail
)->car
))
442 focus
= FRAME_FOCUS_FRAME (XFRAME (XCONS (tail
)->car
));
444 if (FRAMEP (focus
) && XFRAME (focus
) == selected_frame
)
445 Fredirect_frame_focus (XCONS (tail
)->car
, frame
);
449 /* Instead, apply it only to the frame we're pointing to. */
450 #ifdef HAVE_X_WINDOWS
453 Lisp_Object focus
, xfocus
;
455 xfocus
= x_get_focus_frame ();
458 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
459 if (FRAMEP (focus
) && XFRAME (focus
) == selected_frame
)
460 Fredirect_frame_focus (xfocus
, frame
);
463 #endif /* HAVE_X_WINDOWS */
466 if (FRAME_TERMCAP_P (XFRAME (frame
)))
468 /* Since frames on an ASCII terminal share the same display area,
469 switching means we must redisplay the whole thing. */
470 windows_or_buffers_changed
++;
471 SET_FRAME_GARBAGED (XFRAME (frame
));
474 selected_frame
= XFRAME (frame
);
475 if (! FRAME_MINIBUF_ONLY_P (selected_frame
))
476 last_nonminibuf_frame
= selected_frame
;
478 Fselect_window (XFRAME (frame
)->selected_window
);
479 choose_minibuf_frame ();
481 /* We want to make sure that the next event generates a frame-switch
482 event to the appropriate frame. This seems kludgy to me, but
483 before you take it out, make sure that evaluating something like
484 (select-window (frame-root-window (new-frame))) doesn't end up
485 with your typing being interpreted in the new frame instead of
486 the one you're actually typing in. */
487 internal_last_event_frame
= Qnil
;
492 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
493 "Select the frame FRAME.\n\
494 Subsequent editing commands apply to its selected window.\n\
495 The selection of FRAME lasts until the next time the user does\n\
496 something to select a different frame, or until the next time this\n\
497 function is called.")
499 Lisp_Object frame
, no_enter
;
501 return do_switch_frame (frame
, no_enter
, 1);
505 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 2, "e",
506 "Handle a switch-frame event EVENT.\n\
507 Switch-frame events are usually bound to this function.\n\
508 A switch-frame event tells Emacs that the window manager has requested\n\
509 that the user's events be directed to the frame mentioned in the event.\n\
510 This function selects the selected window of the frame of EVENT.\n\
512 If EVENT is frame object, handle it as if it were a switch-frame event\n\
515 Lisp_Object frame
, no_enter
;
517 return do_switch_frame (frame
, no_enter
, 0);
521 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
522 "Return the frame that is now selected.")
526 XSETFRAME (tem
, selected_frame
);
530 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
531 "Return the frame object that window WINDOW is on.")
535 CHECK_LIVE_WINDOW (window
, 0);
536 return XWINDOW (window
)->frame
;
539 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
540 "Returns the topmost, leftmost window of FRAME.\n\
541 If omitted, FRAME defaults to the currently selected frame.")
548 w
= selected_frame
->root_window
;
551 CHECK_LIVE_FRAME (frame
, 0);
552 w
= XFRAME (frame
)->root_window
;
554 while (NILP (XWINDOW (w
)->buffer
))
556 if (! NILP (XWINDOW (w
)->hchild
))
557 w
= XWINDOW (w
)->hchild
;
558 else if (! NILP (XWINDOW (w
)->vchild
))
559 w
= XWINDOW (w
)->vchild
;
566 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
567 Sactive_minibuffer_window
, 0, 0, 0,
568 "Return the currently active minibuffer window, or nil if none.")
571 return minibuf_level
? minibuf_window
: Qnil
;
574 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
575 "Returns the root-window of FRAME.\n\
576 If omitted, FRAME defaults to the currently selected frame.")
581 XSETFRAME (frame
, selected_frame
);
583 CHECK_LIVE_FRAME (frame
, 0);
585 return XFRAME (frame
)->root_window
;
588 DEFUN ("frame-selected-window", Fframe_selected_window
,
589 Sframe_selected_window
, 0, 1, 0,
590 "Return the selected window of frame object FRAME.\n\
591 If omitted, FRAME defaults to the currently selected frame.")
596 XSETFRAME (frame
, selected_frame
);
598 CHECK_LIVE_FRAME (frame
, 0);
600 return XFRAME (frame
)->selected_window
;
603 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
604 Sset_frame_selected_window
, 2, 2, 0,
605 "Set the selected window of frame object FRAME to WINDOW.\n\
606 If FRAME is nil, the selected frame is used.\n\
607 If FRAME is the selected frame, this makes WINDOW the selected window.")
609 Lisp_Object frame
, window
;
612 XSETFRAME (frame
, selected_frame
);
614 CHECK_LIVE_FRAME (frame
, 0);
616 CHECK_LIVE_WINDOW (window
, 1);
618 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
619 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
621 if (XFRAME (frame
) == selected_frame
)
622 return Fselect_window (window
);
624 return XFRAME (frame
)->selected_window
= window
;
627 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
629 "Return a list of all frames.")
632 return Fcopy_sequence (Vframe_list
);
635 /* Return the next frame in the frame list after FRAME.
636 If MINIBUF is nil, exclude minibuffer-only frames.
637 If MINIBUF is a window, include only its own frame
638 and any frame now using that window as the minibuffer.
639 If MINIBUF is `visible', include all visible frames.
640 If MINIBUF is 0, include all visible and iconified frames.
641 Otherwise, include all frames. */
644 next_frame (frame
, minibuf
)
651 /* There must always be at least one frame in Vframe_list. */
652 if (! CONSP (Vframe_list
))
655 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
656 forever. Forestall that. */
657 CHECK_LIVE_FRAME (frame
, 0);
660 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
664 f
= XCONS (tail
)->car
;
667 /* Decide whether this frame is eligible to be returned. */
669 /* If we've looped all the way around without finding any
670 eligible frames, return the original frame. */
674 /* Let minibuf decide if this frame is acceptable. */
677 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
680 else if (EQ (minibuf
, Qvisible
))
682 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
683 if (FRAME_VISIBLE_P (XFRAME (f
)))
686 else if (XFASTINT (minibuf
) == 0)
688 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
689 if (FRAME_VISIBLE_P (XFRAME (f
))
690 || FRAME_ICONIFIED_P (XFRAME (f
)))
693 else if (WINDOWP (minibuf
))
695 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
696 /* Check that F either is, or has forwarded its focus to,
698 && (EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
699 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
700 FRAME_FOCUS_FRAME (XFRAME (f
)))))
712 /* Return the previous frame in the frame list before FRAME.
713 If MINIBUF is nil, exclude minibuffer-only frames.
714 If MINIBUF is a window, include only its own frame
715 and any frame now using that window as the minibuffer.
716 If MINIBUF is `visible', include all visible frames.
717 If MINIBUF is 0, include all visible and iconified frames.
718 Otherwise, include all frames. */
721 prev_frame (frame
, minibuf
)
728 /* There must always be at least one frame in Vframe_list. */
729 if (! CONSP (Vframe_list
))
733 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
737 f
= XCONS (tail
)->car
;
741 if (EQ (frame
, f
) && !NILP (prev
))
744 /* Decide whether this frame is eligible to be returned,
745 according to minibuf. */
748 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
751 else if (WINDOWP (minibuf
))
753 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
754 /* Check that F either is, or has forwarded its focus to,
756 && (EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
757 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
758 FRAME_FOCUS_FRAME (XFRAME (f
)))))
761 else if (EQ (minibuf
, Qvisible
))
763 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
764 if (FRAME_VISIBLE_P (XFRAME (f
)))
767 else if (XFASTINT (minibuf
) == 0)
769 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
770 if (FRAME_VISIBLE_P (XFRAME (f
))
771 || FRAME_ICONIFIED_P (XFRAME (f
)))
778 /* We've scanned the entire list. */
780 /* We went through the whole frame list without finding a single
781 acceptable frame. Return the original frame. */
784 /* There were no acceptable frames in the list before FRAME; otherwise,
785 we would have returned directly from the loop. Since PREV is the last
786 acceptable frame in the list, return it. */
791 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
792 "Return the next frame in the frame list after FRAME.\n\
793 By default, skip minibuffer-only frames.\n\
794 If omitted, FRAME defaults to the selected frame.\n\
795 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
796 If MINIBUF is a window, include only its own frame\n\
797 and any frame now using that window as the minibuffer.\n\
798 If MINIFRAME is `visible', include all visible frames.\n\
799 If MINIBUF is 0, include all visible and iconified frames.\n\
800 Otherwise, include all frames.")
802 Lisp_Object frame
, miniframe
;
807 XSETFRAME (frame
, selected_frame
);
809 CHECK_LIVE_FRAME (frame
, 0);
811 return next_frame (frame
, miniframe
);
814 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
815 "Return the previous frame in the frame list before FRAME.\n\
816 By default, skip minibuffer-only frames.\n\
817 If omitted, FRAME defaults to the selected frame.\n\
818 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
819 If MINIBUF is a window, include only its own frame\n\
820 and any frame now using that window as the minibuffer.\n\
821 If MINIFRAME is `visible', include all visible frames.\n\
822 If MINIBUF is 0, include all visible and iconified frames.\n\
823 Otherwise, include all frames.")
825 Lisp_Object frame
, miniframe
;
830 XSETFRAME (frame
, selected_frame
);
832 CHECK_LIVE_FRAME (frame
, 0);
834 return prev_frame (frame
, miniframe
);
837 /* Return 1 if it is ok to delete frame F;
838 0 if all frames aside from F are invisible.
839 (Exception: if F is the terminal frame, and we are using X, return 1.) */
842 other_visible_frames (f
)
845 /* We know the selected frame is visible,
846 so if F is some other frame, it can't be the sole visible one. */
847 if (f
== selected_frame
)
852 for (frames
= Vframe_list
;
854 frames
= XCONS (frames
)->cdr
)
858 this = XCONS (frames
)->car
;
859 /* Verify that the frame's window still exists
860 and we can still talk to it. And note any recent change
862 #ifdef HAVE_X_WINDOWS
863 if (FRAME_X_P (XFRAME (this)))
865 x_sync (XFRAME (this));
866 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
870 if (FRAME_VISIBLE_P (XFRAME (this))
871 || FRAME_ICONIFIED_P (XFRAME (this))
872 /* Allow deleting the terminal frame when at least
873 one X frame exists! */
874 || (FRAME_X_P (XFRAME (this)) && !FRAME_X_P (f
)))
882 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
883 "Delete FRAME, permanently eliminating it from use.\n\
884 If omitted, FRAME defaults to the selected frame.\n\
885 A frame may not be deleted if its minibuffer is used by other frames.\n\
886 Normally, you may not delete a frame if all other frames are invisible,\n\
887 but if the second optional argument FORCE is non-nil, you may do so.")
889 Lisp_Object frame
, force
;
893 if (EQ (frame
, Qnil
))
896 XSETFRAME (frame
, f
);
900 CHECK_FRAME (frame
, 0);
904 if (! FRAME_LIVE_P (f
))
907 if (NILP (force
) && !other_visible_frames (f
))
908 error ("Attempt to delete the sole visible or iconified frame");
910 /* Does this frame have a minibuffer, and is it the surrogate
911 minibuffer for any other frame? */
912 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
916 for (frames
= Vframe_list
;
918 frames
= XCONS (frames
)->cdr
)
921 this = XCONS (frames
)->car
;
923 if (! EQ (this, frame
)
925 WINDOW_FRAME (XWINDOW
926 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
927 error ("Attempt to delete a surrogate minibuffer frame");
931 /* Don't let the frame remain selected. */
932 if (f
== selected_frame
)
933 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
935 /* Don't allow minibuf_window to remain on a deleted frame. */
936 if (EQ (f
->minibuffer_window
, minibuf_window
))
938 Fset_window_buffer (selected_frame
->minibuffer_window
,
939 XWINDOW (minibuf_window
)->buffer
);
940 minibuf_window
= selected_frame
->minibuffer_window
;
943 /* Clear any X selections for this frame. */
944 #ifdef HAVE_X_WINDOWS
946 x_clear_frame_selections (f
);
949 /* Mark all the windows that used to be on FRAME as deleted, and then
950 remove the reference to them. */
951 delete_all_subwindows (XWINDOW (f
->root_window
));
952 f
->root_window
= Qnil
;
954 Vframe_list
= Fdelq (frame
, Vframe_list
);
955 FRAME_SET_VISIBLE (f
, 0);
957 if (FRAME_CURRENT_GLYPHS (f
))
958 free_frame_glyphs (f
, FRAME_CURRENT_GLYPHS (f
));
959 if (FRAME_DESIRED_GLYPHS (f
))
960 free_frame_glyphs (f
, FRAME_DESIRED_GLYPHS (f
));
961 if (FRAME_TEMP_GLYPHS (f
))
962 free_frame_glyphs (f
, FRAME_TEMP_GLYPHS (f
));
963 if (FRAME_INSERT_COST (f
))
964 free (FRAME_INSERT_COST (f
));
965 if (FRAME_DELETEN_COST (f
))
966 free (FRAME_DELETEN_COST (f
));
967 if (FRAME_INSERTN_COST (f
))
968 free (FRAME_INSERTN_COST (f
));
969 if (FRAME_DELETE_COST (f
))
970 free (FRAME_DELETE_COST (f
));
972 /* Since some events are handled at the interrupt level, we may get
973 an event for f at any time; if we zero out the frame's display
974 now, then we may trip up the event-handling code. Instead, we'll
975 promise that the display of the frame must be valid until we have
976 called the window-system-dependent frame destruction routine. */
978 /* I think this should be done with a hook. */
979 #ifdef HAVE_X_WINDOWS
981 x_destroy_window (f
);
984 f
->display
.nothing
= 0;
986 /* If we've deleted the last_nonminibuf_frame, then try to find
988 if (f
== last_nonminibuf_frame
)
992 last_nonminibuf_frame
= 0;
994 for (frames
= Vframe_list
;
996 frames
= XCONS (frames
)->cdr
)
998 f
= XFRAME (XCONS (frames
)->car
);
999 if (!FRAME_MINIBUF_ONLY_P (f
))
1001 last_nonminibuf_frame
= f
;
1007 /* If we've deleted Vdefault_minibuffer_frame, try to find another
1008 one. Prefer minibuffer-only frames, but also notice frames
1009 with other windows. */
1010 if (EQ (frame
, Vdefault_minibuffer_frame
))
1014 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1015 Lisp_Object frame_with_minibuf
;
1017 frame_with_minibuf
= Qnil
;
1018 for (frames
= Vframe_list
;
1020 frames
= XCONS (frames
)->cdr
)
1024 this = XCONS (frames
)->car
;
1029 if (FRAME_HAS_MINIBUF_P (f
))
1031 frame_with_minibuf
= this;
1032 if (FRAME_MINIBUF_ONLY_P (f
))
1037 /* We know that there must be some frame with a minibuffer out
1038 there. If this were not true, all of the frames present
1039 would have to be minibufferless, which implies that at some
1040 point their minibuffer frames must have been deleted, but
1041 that is prohibited at the top; you can't delete surrogate
1042 minibuffer frames. */
1043 if (NILP (frame_with_minibuf
))
1046 Vdefault_minibuffer_frame
= frame_with_minibuf
;
1052 /* Return mouse position in character cell units. */
1054 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1055 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
1056 The position is given in character cells, where (0, 0) is the\n\
1057 upper-left corner.\n\
1058 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
1059 to read the mouse position, it returns the selected frame for FRAME\n\
1060 and nil for X and Y.")
1064 Lisp_Object lispy_dummy
;
1065 enum scroll_bar_part party_dummy
;
1068 unsigned long long_dummy
;
1074 /* It's okay for the hook to refrain from storing anything. */
1075 if (mouse_position_hook
)
1076 (*mouse_position_hook
) (&f
, 0,
1077 &lispy_dummy
, &party_dummy
,
1084 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, 0, 1);
1089 XSETFRAME (lispy_dummy
, f
);
1090 return Fcons (lispy_dummy
, Fcons (x
, y
));
1093 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1094 Smouse_pixel_position
, 0, 0, 0,
1095 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
1096 The position is given in pixel units, where (0, 0) is the\n\
1097 upper-left corner.\n\
1098 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
1099 to read the mouse position, it returns the selected frame for FRAME\n\
1100 and nil for X and Y.")
1104 Lisp_Object lispy_dummy
;
1105 enum scroll_bar_part party_dummy
;
1108 unsigned long long_dummy
;
1114 /* It's okay for the hook to refrain from storing anything. */
1115 if (mouse_position_hook
)
1116 (*mouse_position_hook
) (&f
, 0,
1117 &lispy_dummy
, &party_dummy
,
1121 XSETFRAME (lispy_dummy
, f
);
1122 return Fcons (lispy_dummy
, Fcons (x
, y
));
1125 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1126 "Move the mouse pointer to the center of character cell (X,Y) in FRAME.\n\
1127 WARNING: If you use this under X windows,\n\
1128 you should call `unfocus-frame' afterwards.")
1130 Lisp_Object frame
, x
, y
;
1132 CHECK_LIVE_FRAME (frame
, 0);
1133 CHECK_NUMBER (x
, 2);
1134 CHECK_NUMBER (y
, 1);
1136 /* I think this should be done with a hook. */
1137 #ifdef HAVE_X_WINDOWS
1138 if (FRAME_X_P (XFRAME (frame
)))
1139 /* Warping the mouse will cause enternotify and focus events. */
1140 x_set_mouse_position (XFRAME (frame
), x
, y
);
1146 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1147 Sset_mouse_pixel_position
, 3, 3, 0,
1148 "Move the mouse pointer to pixel position (X,Y) in FRAME.\n\
1149 WARNING: If you use this under X windows,\n\
1150 you should call `unfocus-frame' afterwards.")
1152 Lisp_Object frame
, x
, y
;
1154 CHECK_LIVE_FRAME (frame
, 0);
1155 CHECK_NUMBER (x
, 2);
1156 CHECK_NUMBER (y
, 1);
1158 /* I think this should be done with a hook. */
1159 #ifdef HAVE_X_WINDOWS
1160 if (FRAME_X_P (XFRAME (frame
)))
1161 /* Warping the mouse will cause enternotify and focus events. */
1162 x_set_mouse_pixel_position (XFRAME (frame
), x
, y
);
1168 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1170 "Make the frame FRAME visible (assuming it is an X-window).\n\
1171 If omitted, FRAME defaults to the currently selected frame.")
1176 XSETFRAME (frame
, selected_frame
);
1178 CHECK_LIVE_FRAME (frame
, 0);
1180 /* I think this should be done with a hook. */
1181 #ifdef HAVE_X_WINDOWS
1182 if (FRAME_X_P (XFRAME (frame
)))
1184 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1185 x_make_frame_visible (XFRAME (frame
));
1189 /* Make menu bar update for the Buffers and Frams menus. */
1190 windows_or_buffers_changed
++;
1195 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1197 "Make the frame FRAME invisible (assuming it is an X-window).\n\
1198 If omitted, FRAME defaults to the currently selected frame.\n\
1199 Normally you may not make FRAME invisible if all other frames are invisible,\n\
1200 but if the second optional argument FORCE is non-nil, you may do so.")
1202 Lisp_Object frame
, force
;
1205 XSETFRAME (frame
, selected_frame
);
1207 CHECK_LIVE_FRAME (frame
, 0);
1209 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1210 error ("Attempt to make invisible the sole visible or iconified frame");
1212 #if 0 /* This isn't logically necessary, and it can do GC. */
1213 /* Don't let the frame remain selected. */
1214 if (XFRAME (frame
) == selected_frame
)
1215 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1218 /* Don't allow minibuf_window to remain on a deleted frame. */
1219 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1221 Fset_window_buffer (selected_frame
->minibuffer_window
,
1222 XWINDOW (minibuf_window
)->buffer
);
1223 minibuf_window
= selected_frame
->minibuffer_window
;
1226 /* I think this should be done with a hook. */
1227 #ifdef HAVE_X_WINDOWS
1228 if (FRAME_X_P (XFRAME (frame
)))
1229 x_make_frame_invisible (XFRAME (frame
));
1232 /* Make menu bar update for the Buffers and Frams menus. */
1233 windows_or_buffers_changed
++;
1238 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1240 "Make the frame FRAME into an icon.\n\
1241 If omitted, FRAME defaults to the currently selected frame.")
1246 XSETFRAME (frame
, selected_frame
);
1248 CHECK_LIVE_FRAME (frame
, 0);
1250 #if 0 /* This isn't logically necessary, and it can do GC. */
1251 /* Don't let the frame remain selected. */
1252 if (XFRAME (frame
) == selected_frame
)
1253 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1256 /* Don't allow minibuf_window to remain on a deleted frame. */
1257 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1259 Fset_window_buffer (selected_frame
->minibuffer_window
,
1260 XWINDOW (minibuf_window
)->buffer
);
1261 minibuf_window
= selected_frame
->minibuffer_window
;
1264 /* I think this should be done with a hook. */
1265 #ifdef HAVE_X_WINDOWS
1266 if (FRAME_X_P (XFRAME (frame
)))
1267 x_iconify_frame (XFRAME (frame
));
1270 /* Make menu bar update for the Buffers and Frams menus. */
1271 windows_or_buffers_changed
++;
1276 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1278 "Return t if FRAME is now \"visible\" (actually in use for display).\n\
1279 A frame that is not \"visible\" is not updated and, if it works through\n\
1280 a window system, it may not show at all.\n\
1281 Return the symbol `icon' if frame is visible only as an icon.")
1285 CHECK_LIVE_FRAME (frame
, 0);
1287 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1289 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1291 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1296 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1298 "Return a list of all frames now \"visible\" (being updated).")
1301 Lisp_Object tail
, frame
;
1306 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
1308 frame
= XCONS (tail
)->car
;
1309 if (!FRAMEP (frame
))
1312 if (FRAME_VISIBLE_P (f
))
1313 value
= Fcons (frame
, value
);
1319 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 1, 1, "",
1320 "Bring FRAME to the front, so it occludes any frames it overlaps.\n\
1321 If FRAME is invisible, make it visible.\n\
1322 If you don't specify a frame, the selected frame is used.\n\
1323 If Emacs is displaying on an ordinary terminal or some other device which\n\
1324 doesn't support multiple overlapping frames, this function does nothing.")
1329 XSETFRAME (frame
, selected_frame
);
1331 CHECK_LIVE_FRAME (frame
, 0);
1333 /* Do like the documentation says. */
1334 Fmake_frame_visible (frame
);
1336 if (frame_raise_lower_hook
)
1337 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1342 /* Should we have a corresponding function called Flower_Power? */
1343 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 1, 1, "",
1344 "Send FRAME to the back, so it is occluded by any frames that overlap it.\n\
1345 If you don't specify a frame, the selected frame is used.\n\
1346 If Emacs is displaying on an ordinary terminal or some other device which\n\
1347 doesn't support multiple overlapping frames, this function does nothing.")
1352 XSETFRAME (frame
, selected_frame
);
1354 CHECK_LIVE_FRAME (frame
, 0);
1356 if (frame_raise_lower_hook
)
1357 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1363 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1365 "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
1366 In other words, switch-frame events caused by events in FRAME will\n\
1367 request a switch to FOCUS-FRAME, and `last-event-frame' will be\n\
1368 FOCUS-FRAME after reading an event typed at FRAME.\n\
1370 If FOCUS-FRAME is omitted or nil, any existing redirection is\n\
1371 cancelled, and the frame again receives its own keystrokes.\n\
1373 Focus redirection is useful for temporarily redirecting keystrokes to\n\
1374 a surrogate minibuffer frame when a frame doesn't have its own\n\
1375 minibuffer window.\n\
1377 A frame's focus redirection can be changed by select-frame. If frame\n\
1378 FOO is selected, and then a different frame BAR is selected, any\n\
1379 frames redirecting their focus to FOO are shifted to redirect their\n\
1380 focus to BAR. This allows focus redirection to work properly when the\n\
1381 user switches from one frame to another using `select-window'.\n\
1383 This means that a frame whose focus is redirected to itself is treated\n\
1384 differently from a frame whose focus is redirected to nil; the former\n\
1385 is affected by select-frame, while the latter is not.\n\
1387 The redirection lasts until `redirect-frame-focus' is called to change it.")
1388 (frame
, focus_frame
)
1389 Lisp_Object frame
, focus_frame
;
1391 /* Note that we don't check for a live frame here. It's reasonable
1392 to redirect the focus of a frame you're about to delete, if you
1393 know what other frame should receive those keystrokes. */
1394 CHECK_FRAME (frame
, 0);
1396 if (! NILP (focus_frame
))
1397 CHECK_LIVE_FRAME (focus_frame
, 1);
1399 XFRAME (frame
)->focus_frame
= focus_frame
;
1401 /* I think this should be done with a hook. */
1402 #ifdef HAVE_X_WINDOWS
1403 if (!NILP (focus_frame
) && ! EQ (focus_frame
, frame
)
1404 && FRAME_X_P (XFRAME (focus_frame
)))
1405 Ffocus_frame (focus_frame
);
1408 if (frame_rehighlight_hook
)
1409 (*frame_rehighlight_hook
) ();
1415 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1416 "Return the frame to which FRAME's keystrokes are currently being sent.\n\
1417 This returns nil if FRAME's focus is not redirected.\n\
1418 See `redirect-frame-focus'.")
1422 CHECK_LIVE_FRAME (frame
, 0);
1424 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1429 /* Return the value of frame parameter PROP in frame FRAME. */
1432 get_frame_param (frame
, prop
)
1433 register struct frame
*frame
;
1436 register Lisp_Object tem
;
1438 tem
= Fassq (prop
, frame
->param_alist
);
1444 /* Return the buffer-predicate of the selected frame. */
1447 frame_buffer_predicate ()
1449 return selected_frame
->buffer_predicate
;
1452 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1453 If the alist already has an element for PROP, we change it. */
1456 store_in_alist (alistptr
, prop
, val
)
1457 Lisp_Object
*alistptr
, val
;
1460 register Lisp_Object tem
;
1462 tem
= Fassq (prop
, *alistptr
);
1464 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1470 store_frame_param (f
, prop
, val
)
1472 Lisp_Object prop
, val
;
1474 register Lisp_Object tem
;
1476 tem
= Fassq (prop
, f
->param_alist
);
1478 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
1482 if (EQ (prop
, Qbuffer_predicate
))
1483 f
->buffer_predicate
= val
;
1485 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
1487 if (! MINI_WINDOW_P (XWINDOW (val
)))
1488 error ("Surrogate minibuffer windows must be minibuffer windows.");
1490 if (FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
1491 error ("can't change the surrogate minibuffer of a frame with its own minibuffer");
1493 /* Install the chosen minibuffer window, with proper buffer. */
1494 f
->minibuffer_window
= val
;
1498 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
1499 "Return the parameters-alist of frame FRAME.\n\
1500 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
1501 The meaningful PARMs depend on the kind of frame.\n\
1502 If FRAME is omitted, return information on the currently selected frame.")
1509 if (EQ (frame
, Qnil
))
1513 CHECK_FRAME (frame
, 0);
1517 if (!FRAME_LIVE_P (f
))
1520 alist
= Fcopy_alist (f
->param_alist
);
1521 store_in_alist (&alist
, Qname
, f
->name
);
1522 store_in_alist (&alist
, Qheight
, make_number (FRAME_HEIGHT (f
)));
1523 store_in_alist (&alist
, Qwidth
, make_number (FRAME_WIDTH (f
)));
1524 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
1525 store_in_alist (&alist
, Qminibuffer
,
1526 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
1527 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
1528 : FRAME_MINIBUF_WINDOW (f
)));
1529 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
1531 /* I think this should be done with a hook. */
1532 #ifdef HAVE_X_WINDOWS
1534 x_report_frame_params (f
, &alist
);
1538 /* This ought to be correct in f->param_alist for an X frame. */
1540 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
1541 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
1546 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
1547 Smodify_frame_parameters
, 2, 2, 0,
1548 "Modify the parameters of frame FRAME according to ALIST.\n\
1549 ALIST is an alist of parameters to change and their new values.\n\
1550 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
1551 The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
1553 Lisp_Object frame
, alist
;
1556 register Lisp_Object tail
, elt
, prop
, val
;
1558 if (EQ (frame
, Qnil
))
1562 CHECK_LIVE_FRAME (frame
, 0);
1566 /* I think this should be done with a hook. */
1567 #ifdef HAVE_X_WINDOWS
1569 x_set_frame_parameters (f
, alist
);
1572 for (tail
= alist
; !EQ (tail
, Qnil
); tail
= Fcdr (tail
))
1577 store_frame_param (f
, prop
, val
);
1583 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
1585 "Height in pixels of a line in the font in frame FRAME.\n\
1586 If FRAME is omitted, the selected frame is used.\n\
1587 For a terminal frame, the value is always 1.")
1597 CHECK_FRAME (frame
, 0);
1601 #ifdef HAVE_X_WINDOWS
1603 return make_number (x_char_height (f
));
1606 return make_number (1);
1610 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
1612 "Width in pixels of characters in the font in frame FRAME.\n\
1613 If FRAME is omitted, the selected frame is used.\n\
1614 The width is the same for all characters, because\n\
1615 currently Emacs supports only fixed-width fonts.\n\
1616 For a terminal screen, the value is always 1.")
1626 CHECK_FRAME (frame
, 0);
1630 #ifdef HAVE_X_WINDOWS
1632 return make_number (x_char_width (f
));
1635 return make_number (1);
1638 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
1639 Sframe_pixel_height
, 0, 1, 0,
1640 "Return a FRAME's height in pixels.\n\
1641 For a terminal frame, the result really gives the height in characters.\n\
1642 If FRAME is omitted, the selected frame is used.")
1652 CHECK_FRAME (frame
, 0);
1656 #ifdef HAVE_X_WINDOWS
1658 return make_number (x_pixel_height (f
));
1661 return make_number (FRAME_HEIGHT (f
));
1664 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
1665 Sframe_pixel_width
, 0, 1, 0,
1666 "Return FRAME's width in pixels.\n\
1667 For a terminal frame, the result really gives the width in characters.\n\
1668 If FRAME is omitted, the selected frame is used.")
1678 CHECK_FRAME (frame
, 0);
1682 #ifdef HAVE_X_WINDOWS
1684 return make_number (x_pixel_width (f
));
1687 return make_number (FRAME_WIDTH (f
));
1690 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1691 "Specify that the frame FRAME has LINES lines.\n\
1692 Optional third arg non-nil means that redisplay should use LINES lines\n\
1693 but that the idea of the actual height of the frame should not be changed.")
1694 (frame
, rows
, pretend
)
1695 Lisp_Object frame
, rows
, pretend
;
1697 register struct frame
*f
;
1699 CHECK_NUMBER (rows
, 0);
1704 CHECK_LIVE_FRAME (frame
, 0);
1708 /* I think this should be done with a hook. */
1709 #ifdef HAVE_X_WINDOWS
1712 if (XINT (rows
) != f
->height
)
1713 x_set_window_size (f
, 1, f
->width
, XINT (rows
));
1717 change_frame_size (f
, XINT (rows
), 0, !NILP (pretend
), 0);
1721 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1722 "Specify that the frame FRAME has COLS columns.\n\
1723 Optional third arg non-nil means that redisplay should use COLS columns\n\
1724 but that the idea of the actual width of the frame should not be changed.")
1725 (frame
, cols
, pretend
)
1726 Lisp_Object frame
, cols
, pretend
;
1728 register struct frame
*f
;
1729 CHECK_NUMBER (cols
, 0);
1734 CHECK_LIVE_FRAME (frame
, 0);
1738 /* I think this should be done with a hook. */
1739 #ifdef HAVE_X_WINDOWS
1742 if (XINT (cols
) != f
->width
)
1743 x_set_window_size (f
, 1, XINT (cols
), f
->height
);
1747 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0);
1751 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1752 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1754 Lisp_Object frame
, cols
, rows
;
1756 register struct frame
*f
;
1759 CHECK_LIVE_FRAME (frame
, 0);
1760 CHECK_NUMBER (cols
, 2);
1761 CHECK_NUMBER (rows
, 1);
1764 /* I think this should be done with a hook. */
1765 #ifdef HAVE_X_WINDOWS
1768 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
)
1769 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
1773 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0);
1778 DEFUN ("set-frame-position", Fset_frame_position
,
1779 Sset_frame_position
, 3, 3, 0,
1780 "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
1781 This is actually the position of the upper left corner of the frame.\n\
1782 Negative values for XOFFSET or YOFFSET are interpreted relative to\n\
1783 the rightmost or bottommost possible position (that stays within the screen).")
1784 (frame
, xoffset
, yoffset
)
1785 Lisp_Object frame
, xoffset
, yoffset
;
1787 register struct frame
*f
;
1790 CHECK_LIVE_FRAME (frame
, 0);
1791 CHECK_NUMBER (xoffset
, 1);
1792 CHECK_NUMBER (yoffset
, 2);
1795 /* I think this should be done with a hook. */
1796 #ifdef HAVE_X_WINDOWS
1798 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
1805 choose_minibuf_frame ()
1807 /* For lowest-level minibuf, put it on currently selected frame
1808 if frame has a minibuffer. */
1810 if (minibuf_level
== 0
1811 && selected_frame
!= 0
1812 && !EQ (minibuf_window
, selected_frame
->minibuffer_window
))
1814 /* I don't think that any frames may validly have a null minibuffer
1816 if (NILP (selected_frame
->minibuffer_window
))
1819 Fset_window_buffer (selected_frame
->minibuffer_window
,
1820 XWINDOW (minibuf_window
)->buffer
);
1821 minibuf_window
= selected_frame
->minibuffer_window
;
1827 /*&&& init symbols here &&&*/
1828 Qframep
= intern ("framep");
1829 staticpro (&Qframep
);
1830 Qframe_live_p
= intern ("frame-live-p");
1831 staticpro (&Qframe_live_p
);
1832 Qheight
= intern ("height");
1833 staticpro (&Qheight
);
1834 Qicon
= intern ("icon");
1836 Qminibuffer
= intern ("minibuffer");
1837 staticpro (&Qminibuffer
);
1838 Qmodeline
= intern ("modeline");
1839 staticpro (&Qmodeline
);
1840 Qname
= intern ("name");
1842 Qonly
= intern ("only");
1844 Qunsplittable
= intern ("unsplittable");
1845 staticpro (&Qunsplittable
);
1846 Qmenu_bar_lines
= intern ("menu-bar-lines");
1847 staticpro (&Qmenu_bar_lines
);
1848 Qwidth
= intern ("width");
1849 staticpro (&Qwidth
);
1852 Qvisible
= intern ("visible");
1853 staticpro (&Qvisible
);
1854 Qbuffer_predicate
= intern ("buffer-predicate");
1855 staticpro (&Qbuffer_predicate
);
1857 staticpro (&Vframe_list
);
1859 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
1860 "The initial frame-object, which represents Emacs's stdout.");
1862 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
1863 "Non-nil if all of emacs is iconified and frame updates are not needed.");
1864 Vemacs_iconified
= Qnil
;
1866 DEFVAR_LISP ("default-minibuffer-frame", &Vdefault_minibuffer_frame
,
1867 "Minibufferless frames use this frame's minibuffer.\n\
1869 Emacs cannot create minibufferless frames unless this is set to an\n\
1870 appropriate surrogate.\n\
1872 Emacs consults this variable only when creating minibufferless\n\
1873 frames; once the frame is created, it sticks with its assigned\n\
1874 minibuffer, no matter what this variable is set to. This means that\n\
1875 this variable doesn't necessarily say anything meaningful about the\n\
1876 current set of frames, or where the minibuffer is currently being\n\
1878 Vdefault_minibuffer_frame
= Qnil
;
1880 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
1881 "Alist of default values for frame creation.\n\
1882 These may be set in your init file, like this:\n\
1883 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))\n\
1884 These override values given in window system configuration data,\n\
1885 including X Windows' defaults database.\n\
1886 For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
1887 For values specific to the separate minibuffer frame, see\n\
1888 `minibuffer-frame-alist'.\n\
1889 The `menu-bar-lines' element of the list controls whether new frames\n\
1890 have menu bars; `menu-bar-mode' works by altering this element.");
1891 Vdefault_frame_alist
= Qnil
;
1893 defsubr (&Sactive_minibuffer_window
);
1895 defsubr (&Sframe_live_p
);
1896 defsubr (&Smake_terminal_frame
);
1897 defsubr (&Shandle_switch_frame
);
1898 defsubr (&Sselect_frame
);
1899 defsubr (&Sselected_frame
);
1900 defsubr (&Swindow_frame
);
1901 defsubr (&Sframe_root_window
);
1902 defsubr (&Sframe_first_window
);
1903 defsubr (&Sframe_selected_window
);
1904 defsubr (&Sset_frame_selected_window
);
1905 defsubr (&Sframe_list
);
1906 defsubr (&Snext_frame
);
1907 defsubr (&Sprevious_frame
);
1908 defsubr (&Sdelete_frame
);
1909 defsubr (&Smouse_position
);
1910 defsubr (&Smouse_pixel_position
);
1911 defsubr (&Sset_mouse_position
);
1912 defsubr (&Sset_mouse_pixel_position
);
1914 defsubr (&Sframe_configuration
);
1915 defsubr (&Srestore_frame_configuration
);
1917 defsubr (&Smake_frame_visible
);
1918 defsubr (&Smake_frame_invisible
);
1919 defsubr (&Siconify_frame
);
1920 defsubr (&Sframe_visible_p
);
1921 defsubr (&Svisible_frame_list
);
1922 defsubr (&Sraise_frame
);
1923 defsubr (&Slower_frame
);
1924 defsubr (&Sredirect_frame_focus
);
1925 defsubr (&Sframe_focus
);
1926 defsubr (&Sframe_parameters
);
1927 defsubr (&Smodify_frame_parameters
);
1928 defsubr (&Sframe_char_height
);
1929 defsubr (&Sframe_char_width
);
1930 defsubr (&Sframe_pixel_height
);
1931 defsubr (&Sframe_pixel_width
);
1932 defsubr (&Sset_frame_height
);
1933 defsubr (&Sset_frame_width
);
1934 defsubr (&Sset_frame_size
);
1935 defsubr (&Sset_frame_position
);
1940 initial_define_lispy_key (global_map
, "switch-frame", "handle-switch-frame");
1941 initial_define_lispy_key (global_map
, "delete-frame", "handle-delete-frame");
1942 initial_define_lispy_key (global_map
, "iconify-frame", "ignore");
1943 initial_define_lispy_key (global_map
, "make-frame-visible", "ignore");
1946 #else /* not MULTI_FRAME */
1948 /* If we're not using multi-frame stuff, we still need to provide some
1949 support functions. */
1951 Lisp_Object Qheight
;
1952 Lisp_Object Qminibuffer
;
1953 Lisp_Object Qmodeline
;
1955 Lisp_Object Qunsplittable
;
1956 Lisp_Object Qmenu_bar_lines
;
1959 Lisp_Object Vterminal_frame
;
1961 /* Unless this function is defined, providing set-frame-height and
1962 set-frame-width doesn't help compatibility any, since they both
1963 want this as their first argument. */
1964 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1965 /* Don't confuse make-docfile by having two doc strings for this function.
1966 make-docfile does not pay attention to #if, for good reason! */
1970 /* For your possible information, this code is unfolded into the
1971 second WINDOW_FRAME in frame.h. */
1973 XSETFASTINT (tem
, 0);
1977 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
1978 /* Don't confuse make-docfile by having two doc strings for this function.
1979 make-docfile does not pay attention to #if, for good reason! */
1984 /* For your possible information, this code is unfolded into the
1985 second WINDOW_FRAME in frame.h. */
1987 XSETFASTINT (tem
, 0);
1991 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
1998 w
= FRAME_ROOT_WINDOW (selected_frame
);
2000 while (NILP (XWINDOW (w
)->buffer
))
2002 if (! NILP (XWINDOW (w
)->hchild
))
2003 w
= XWINDOW (w
)->hchild
;
2004 else if (! NILP (XWINDOW (w
)->vchild
))
2005 w
= XWINDOW (w
)->vchild
;
2012 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
2013 /* Don't confuse make-docfile by having two doc strings for this function.
2014 make-docfile does not pay attention to #if, for good reason! */
2020 if (FRAME_X_P (object
))
2021 return intern ("pc");
2026 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2027 /* Don't confuse make-docfile by having two doc strings for this function.
2028 make-docfile does not pay attention to #if, for good reason! */
2030 (frame
, rows
, pretend
)
2031 Lisp_Object frame
, rows
, pretend
;
2033 CHECK_NUMBER (rows
, 0);
2035 change_frame_size (0, XINT (rows
), 0, !NILP (pretend
), 0);
2039 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2040 /* Don't confuse make-docfile by having two doc strings for this function.
2041 make-docfile does not pay attention to #if, for good reason! */
2043 (frame
, cols
, pretend
)
2044 Lisp_Object frame
, cols
, pretend
;
2046 CHECK_NUMBER (cols
, 0);
2048 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
2052 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2053 /* Don't confuse make-docfile by having two doc strings for this function.
2054 make-docfile does not pay attention to #if, for good reason! */
2057 Lisp_Object frame
, cols
, rows
;
2059 CHECK_NUMBER (cols
, 2);
2060 CHECK_NUMBER (rows
, 1);
2062 change_frame_size (0, XINT (rows
), XINT (cols
), 0, 0);
2067 DEFUN ("frame-height", Fframe_height
, Sframe_height
, 0, 1, 0,
2068 "Return number of lines available for display on FRAME.\n\
2069 If FRAME is omitted, describe the currently selected frame.")
2073 return make_number (FRAME_HEIGHT (selected_frame
));
2076 DEFUN ("frame-width", Fframe_width
, Sframe_width
, 0, 1, 0,
2077 "Return number of columns available for display on FRAME.\n\
2078 If FRAME is omitted, describe the currently selected frame.")
2082 return make_number (FRAME_WIDTH (selected_frame
));
2085 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2087 /* Don't confuse make-docfile by having two doc strings for this function.
2088 make-docfile does not pay attention to #if, for good reason! */
2093 return make_number (1);
2097 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2099 /* Don't confuse make-docfile by having two doc strings for this function.
2100 make-docfile does not pay attention to #if, for good reason! */
2105 return make_number (1);
2108 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2109 Sframe_pixel_height
, 0, 1, 0,
2110 /* Don't confuse make-docfile by having two doc strings for this function.
2111 make-docfile does not pay attention to #if, for good reason! */
2116 return make_number (FRAME_HEIGHT (f
));
2119 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2120 Sframe_pixel_width
, 0, 1, 0,
2121 /* Don't confuse make-docfile by having two doc strings for this function.
2122 make-docfile does not pay attention to #if, for good reason! */
2127 return make_number (FRAME_WIDTH (f
));
2130 /* These are for backward compatibility with Emacs 18. */
2132 DEFUN ("set-screen-height", Fset_screen_height
, Sset_screen_height
, 1, 2, 0,
2133 "Tell redisplay that the screen has LINES lines.\n\
2134 Optional second arg non-nil means that redisplay should use LINES lines\n\
2135 but that the idea of the actual height of the screen should not be changed.")
2137 Lisp_Object lines
, pretend
;
2139 CHECK_NUMBER (lines
, 0);
2141 change_frame_size (0, XINT (lines
), 0, !NILP (pretend
), 0);
2145 DEFUN ("set-screen-width", Fset_screen_width
, Sset_screen_width
, 1, 2, 0,
2146 "Tell redisplay that the screen has COLS columns.\n\
2147 Optional second arg non-nil means that redisplay should use COLS columns\n\
2148 but that the idea of the actual width of the screen should not be changed.")
2150 Lisp_Object cols
, pretend
;
2152 CHECK_NUMBER (cols
, 0);
2154 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
2158 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
2159 /* Don't confuse make-docfile by having two doc strings for this function.
2160 make-docfile does not pay attention to #if, for good reason! */
2165 if (mouse_position_hook
)
2168 Lisp_Object lispy_dummy
;
2169 enum scroll_bar_part party_dummy
;
2171 unsigned long long_dummy
;
2173 (*mouse_position_hook
) (&f
, 0,
2174 &lispy_dummy
, &party_dummy
,
2177 return Fcons (Fselected_frame (), Fcons (x
, y
));
2180 return Fcons (Qnil
, Fcons (Qnil
, Qnil
));
2184 store_in_alist (alistptr
, prop
, val
)
2185 Lisp_Object
*alistptr
, val
;
2188 register Lisp_Object tem
;
2190 tem
= Fassq (prop
, *alistptr
);
2192 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2197 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2198 /* Don't confuse make-docfile by having two doc strings for this function.
2199 make-docfile does not pay attention to #if, for good reason! */
2207 if (EQ (frame
, Qnil
))
2211 CHECK_FRAME (frame
, 0);
2215 if (!FRAME_LIVE_P (f
))
2222 static char *colornames
[16] =
2224 "black", "blue", "green", "cyan", "red", "magenta", "brown",
2225 "lightgray", "darkgray", "lightblue", "lightgreen", "lightcyan",
2226 "lightred", "lightmagenta", "yellow", "white"
2228 store_in_alist (&alist
, intern ("foreground-color"),
2229 build_string (colornames
[FRAME_FOREGROUND_PIXEL (f
)]));
2230 store_in_alist (&alist
, intern ("background-color"),
2231 build_string (colornames
[FRAME_BACKGROUND_PIXEL (f
)]));
2234 store_in_alist (&alist
, intern ("font"), build_string ("default"));
2235 store_in_alist (&alist
, Qname
, build_string ("emacs"));
2236 store_in_alist (&alist
, Qheight
, make_number (FRAME_HEIGHT (f
)));
2237 store_in_alist (&alist
, Qwidth
, make_number (FRAME_WIDTH (f
)));
2238 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2239 store_in_alist (&alist
, Qminibuffer
, FRAME_MINIBUF_WINDOW (f
));
2240 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2241 store_in_alist (&alist
, Qmenu_bar_lines
, (FRAME_MENU_BAR_LINES (f
)));
2246 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2247 Smodify_frame_parameters
, 2, 2, 0,
2248 /* Don't confuse make-docfile by having two doc strings for this function.
2249 make-docfile does not pay attention to #if, for good reason! */
2252 Lisp_Object frame
, alist
;
2255 if (FRAME_X_P (frame
))
2256 IT_set_frame_parameters (XFRAME (frame
), alist
);
2261 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
2262 /* Don't confuse make-docfile by having two doc strings for this function.
2263 make-docfile does not pay attention to #if, for good reason! */
2271 DEFUN ("frame-list", Fframe_list
, Sframe_list
, 0, 0, 0,
2272 /* Don't confuse make-docfile by having two doc strings for this function.
2273 make-docfile does not pay attention to #if, for good reason! */
2277 return Fcons (Fselected_frame (), Qnil
);
2282 Qheight
= intern ("height");
2283 staticpro (&Qheight
);
2284 Qminibuffer
= intern ("minibuffer");
2285 staticpro (&Qminibuffer
);
2286 Qmodeline
= intern ("modeline");
2287 staticpro (&Qmodeline
);
2288 Qname
= intern ("name");
2290 Qunsplittable
= intern ("unsplittable");
2291 staticpro (&Qunsplittable
);
2292 Qmenu_bar_lines
= intern ("menu-bar-lines");
2293 staticpro (&Qmenu_bar_lines
);
2294 Qwidth
= intern ("width");
2295 staticpro (&Qwidth
);
2297 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
2298 "The initial frame-object, which represents Emacs's stdout.");
2299 XSETFASTINT (Vterminal_frame
, 0);
2301 defsubr (&Sselected_frame
);
2302 defsubr (&Swindow_frame
);
2303 defsubr (&Sframe_first_window
);
2305 defsubr (&Sframe_char_height
);
2306 defsubr (&Sframe_char_width
);
2307 defsubr (&Sframe_pixel_height
);
2308 defsubr (&Sframe_pixel_width
);
2309 defsubr (&Sset_frame_height
);
2310 defsubr (&Sset_frame_width
);
2311 defsubr (&Sset_frame_size
);
2312 defsubr (&Sset_screen_height
);
2313 defsubr (&Sset_screen_width
);
2314 defsubr (&Sframe_height
);
2315 Ffset (intern ("screen-height"), intern ("frame-height"));
2316 defsubr (&Sframe_width
);
2317 Ffset (intern ("screen-width"), intern ("frame-width"));
2318 defsubr (&Smouse_position
);
2319 defsubr (&Sframe_parameters
);
2320 defsubr (&Smodify_frame_parameters
);
2321 defsubr (&Sframe_live_p
);
2322 defsubr (&Sframe_list
);
2325 /* A comment in dispnew.c says the_only_frame is not protected. */
2326 the_only_frame
.face_alist
= Qnil
;
2327 staticpro (&the_only_frame
.face_alist
);
2328 the_only_frame
.menu_bar_items
= Qnil
;
2329 staticpro (&the_only_frame
.menu_bar_items
);
2330 the_only_frame
.menu_bar_vector
= Qnil
;
2331 staticpro (&the_only_frame
.menu_bar_vector
);
2332 the_only_frame
.menu_bar_items
= menu_bar_items (Qnil
);
2340 #endif /* not MULTI_FRAME */