1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997 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, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
29 #ifdef HAVE_WINDOW_SYSTEM
33 #include "termhooks.h"
39 /* Evaluate this expression to rebuild the section of syms_of_frame
40 that initializes and staticpros the symbols declared below. Note
41 that Emacs 18 has a bug that keeps C-x C-e from being able to
42 evaluate this expression.
45 ;; Accumulate a list of the symbols we want to initialize from the
46 ;; declarations at the top of the file.
47 (goto-char (point-min))
48 (search-forward "/\*&&& symbols declared here &&&*\/\n")
50 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
52 (cons (buffer-substring (match-beginning 1) (match-end 1))
55 (setq symbol-list (nreverse symbol-list))
56 ;; Delete the section of syms_of_... where we initialize the symbols.
57 (search-forward "\n /\*&&& init symbols here &&&*\/\n")
58 (let ((start (point)))
59 (while (looking-at "^ Q")
61 (kill-region start (point)))
62 ;; Write a new symbol initialization section.
64 (insert (format " %s = intern (\"" (car symbol-list)))
65 (let ((start (point)))
66 (insert (substring (car symbol-list) 1))
67 (subst-char-in-region start (point) ?_ ?-))
68 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
69 (setq symbol-list (cdr symbol-list)))))
72 /*&&& symbols declared here &&&*/
74 Lisp_Object Qframe_live_p
;
77 Lisp_Object Qminibuffer
;
78 Lisp_Object Qmodeline
;
81 Lisp_Object Qunsplittable
;
82 Lisp_Object Qmenu_bar_lines
;
88 Lisp_Object Qbuffer_predicate
;
89 Lisp_Object Qbuffer_list
;
92 Lisp_Object Vterminal_frame
;
93 Lisp_Object Vdefault_frame_alist
;
98 /*&&& init symbols here &&&*/
99 Qframep
= intern ("framep");
100 staticpro (&Qframep
);
101 Qframe_live_p
= intern ("frame-live-p");
102 staticpro (&Qframe_live_p
);
103 Qheight
= intern ("height");
104 staticpro (&Qheight
);
105 Qicon
= intern ("icon");
107 Qminibuffer
= intern ("minibuffer");
108 staticpro (&Qminibuffer
);
109 Qmodeline
= intern ("modeline");
110 staticpro (&Qmodeline
);
111 Qname
= intern ("name");
113 Qonly
= intern ("only");
115 Qunsplittable
= intern ("unsplittable");
116 staticpro (&Qunsplittable
);
117 Qmenu_bar_lines
= intern ("menu-bar-lines");
118 staticpro (&Qmenu_bar_lines
);
119 Qwidth
= intern ("width");
123 Qw32
= intern ("w32");
127 Qvisible
= intern ("visible");
128 staticpro (&Qvisible
);
129 Qbuffer_predicate
= intern ("buffer-predicate");
130 staticpro (&Qbuffer_predicate
);
131 Qbuffer_list
= intern ("buffer-list");
132 staticpro (&Qbuffer_list
);
133 Qtitle
= intern ("title");
136 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
137 "Alist of default values for frame creation.\n\
138 These may be set in your init file, like this:\n\
139 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))\n\
140 These override values given in window system configuration data,\n\
141 including X Windows' defaults database.\n\
142 For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
143 For values specific to the separate minibuffer frame, see\n\
144 `minibuffer-frame-alist'.\n\
145 The `menu-bar-lines' element of the list controls whether new frames\n\
146 have menu bars; `menu-bar-mode' works by altering this element.");
147 Vdefault_frame_alist
= Qnil
;
151 set_menu_bar_lines_1 (window
, n
)
155 struct window
*w
= XWINDOW (window
);
157 XSETFASTINT (w
->last_modified
, 0);
158 XSETFASTINT (w
->top
, XFASTINT (w
->top
) + n
);
159 XSETFASTINT (w
->height
, XFASTINT (w
->height
) - n
);
161 /* Handle just the top child in a vertical split. */
162 if (!NILP (w
->vchild
))
163 set_menu_bar_lines_1 (w
->vchild
, n
);
165 /* Adjust all children in a horizontal split. */
166 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
168 w
= XWINDOW (window
);
169 set_menu_bar_lines_1 (window
, n
);
174 set_menu_bar_lines (f
, value
, oldval
)
176 Lisp_Object value
, oldval
;
179 int olines
= FRAME_MENU_BAR_LINES (f
);
181 /* Right now, menu bars don't work properly in minibuf-only frames;
182 most of the commands try to apply themselves to the minibuffer
183 frame itself, and get an error because you can't switch buffers
184 in or split the minibuffer window. */
185 if (FRAME_MINIBUF_ONLY_P (f
))
188 if (INTEGERP (value
))
189 nlines
= XINT (value
);
193 if (nlines
!= olines
)
195 windows_or_buffers_changed
++;
196 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
197 FRAME_MENU_BAR_LINES (f
) = nlines
;
198 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
204 /* These help us bind and responding to switch-frame events. */
205 #include "commands.h"
206 #include "keyboard.h"
208 Lisp_Object Vemacs_iconified
;
209 Lisp_Object Vframe_list
;
211 extern Lisp_Object Vminibuffer_list
;
212 extern Lisp_Object
get_minibuffer ();
213 extern Lisp_Object
Fhandle_switch_frame ();
214 extern Lisp_Object
Fredirect_frame_focus ();
215 extern Lisp_Object
x_get_focus_frame ();
217 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
218 "Return non-nil if OBJECT is a frame.\n\
219 Value is t for a termcap frame (a character-only terminal),\n\
220 `x' for an Emacs frame that is really an X window,\n\
221 `pc' for a direct-write MS-DOS frame.\n\
222 See also `frame-live-p'.")
226 if (!FRAMEP (object
))
228 switch (XFRAME (object
)->output_method
)
232 case output_x_window
:
236 case output_msdos_raw
:
243 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
244 "Return non-nil if OBJECT is a frame which has not been deleted.\n\
245 Value is nil if OBJECT is not a live frame. If object is a live\n\
246 frame, the return value indicates what sort of output device it is\n\
247 displayed on. Value is t for a termcap frame (a character-only\n\
248 terminal), `x' for an Emacs frame being displayed in an X window.")
252 return ((FRAMEP (object
)
253 && FRAME_LIVE_P (XFRAME (object
)))
263 register struct frame
*f
;
264 register Lisp_Object root_window
;
265 register Lisp_Object mini_window
;
266 register struct Lisp_Vector
*vec
;
269 vec
= allocate_vectorlike ((EMACS_INT
) VECSIZE (struct frame
));
270 for (i
= 0; i
< VECSIZE (struct frame
); i
++)
271 XSETFASTINT (vec
->contents
[i
], 0);
272 vec
->size
= VECSIZE (struct frame
);
273 f
= (struct frame
*)vec
;
274 XSETFRAME (frame
, f
);
278 f
->current_glyphs
= 0;
279 f
->desired_glyphs
= 0;
281 f
->async_visible
= 0;
282 f
->output_data
.nothing
= 0;
284 f
->async_iconified
= 0;
285 f
->wants_modeline
= 1;
290 f
->has_minibuffer
= mini_p
;
291 f
->focus_frame
= Qnil
;
292 f
->explicit_name
= 0;
293 f
->can_have_scroll_bars
= 0;
294 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
295 f
->param_alist
= Qnil
;
296 f
->scroll_bars
= Qnil
;
297 f
->condemned_scroll_bars
= Qnil
;
298 f
->face_alist
= Qnil
;
299 f
->menu_bar_items
= Qnil
;
300 f
->menu_bar_vector
= Qnil
;
301 f
->menu_bar_items_used
= 0;
302 f
->buffer_predicate
= Qnil
;
303 f
->buffer_list
= Qnil
;
305 f
->kboard
= initial_kboard
;
310 root_window
= make_window ();
313 mini_window
= make_window ();
314 XWINDOW (root_window
)->next
= mini_window
;
315 XWINDOW (mini_window
)->prev
= root_window
;
316 XWINDOW (mini_window
)->mini_p
= Qt
;
317 XWINDOW (mini_window
)->frame
= frame
;
318 f
->minibuffer_window
= mini_window
;
323 XWINDOW (root_window
)->next
= Qnil
;
324 f
->minibuffer_window
= Qnil
;
327 XWINDOW (root_window
)->frame
= frame
;
330 just so that there is "something there."
331 Correct size will be set up later with change_frame_size. */
333 SET_FRAME_WIDTH (f
, 10);
336 XSETFASTINT (XWINDOW (root_window
)->width
, 10);
337 XSETFASTINT (XWINDOW (root_window
)->height
, (mini_p
? 9 : 10));
341 XSETFASTINT (XWINDOW (mini_window
)->width
, 10);
342 XSETFASTINT (XWINDOW (mini_window
)->top
, 9);
343 XSETFASTINT (XWINDOW (mini_window
)->height
, 1);
346 /* Choose a buffer for the frame's root window. */
350 XWINDOW (root_window
)->buffer
= Qt
;
351 buf
= Fcurrent_buffer ();
352 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
353 a space), try to find another one. */
354 if (XSTRING (Fbuffer_name (buf
))->data
[0] == ' ')
355 buf
= Fother_buffer (buf
, Qnil
);
356 Fset_window_buffer (root_window
, buf
);
358 f
->buffer_list
= Fcons (buf
, Qnil
);
363 XWINDOW (mini_window
)->buffer
= Qt
;
364 Fset_window_buffer (mini_window
,
365 (NILP (Vminibuffer_list
)
367 : Fcar (Vminibuffer_list
)));
370 f
->root_window
= root_window
;
371 f
->selected_window
= root_window
;
372 /* Make sure this window seems more recently used than
373 a newly-created, never-selected window. */
374 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, ++window_select_count
);
376 #ifdef HAVE_WINDOW_SYSTEM
377 f
->fontset_data
= alloc_fontset_data ();
383 /* Make a frame using a separate minibuffer window on another frame.
384 MINI_WINDOW is the minibuffer window to use. nil means use the
385 default (the global minibuffer). */
388 make_frame_without_minibuffer (mini_window
, kb
, display
)
389 register Lisp_Object mini_window
;
393 register struct frame
*f
;
396 if (!NILP (mini_window
))
397 CHECK_LIVE_WINDOW (mini_window
, 0);
400 if (!NILP (mini_window
)
401 && XFRAME (XWINDOW (mini_window
)->frame
)->kboard
!= kb
)
402 error ("frame and minibuffer must be on the same display");
405 /* Make a frame containing just a root window. */
408 if (NILP (mini_window
))
410 /* Use default-minibuffer-frame if possible. */
411 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
412 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
414 Lisp_Object frame_dummy
;
416 XSETFRAME (frame_dummy
, f
);
417 GCPRO1 (frame_dummy
);
418 /* If there's no minibuffer frame to use, create one. */
419 kb
->Vdefault_minibuffer_frame
=
420 call1 (intern ("make-initial-minibuffer-frame"), display
);
424 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
427 f
->minibuffer_window
= mini_window
;
429 /* Make the chosen minibuffer window display the proper minibuffer,
430 unless it is already showing a minibuffer. */
431 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
432 Fset_window_buffer (mini_window
,
433 (NILP (Vminibuffer_list
)
435 : Fcar (Vminibuffer_list
)));
439 /* Make a frame containing only a minibuffer window. */
442 make_minibuffer_frame ()
444 /* First make a frame containing just a root window, no minibuffer. */
446 register struct frame
*f
= make_frame (0);
447 register Lisp_Object mini_window
;
448 register Lisp_Object frame
;
450 XSETFRAME (frame
, f
);
455 f
->wants_modeline
= 0;
456 f
->has_minibuffer
= 1;
458 /* Now label the root window as also being the minibuffer.
459 Avoid infinite looping on the window chain by marking next pointer
462 mini_window
= f
->minibuffer_window
= f
->root_window
;
463 XWINDOW (mini_window
)->mini_p
= Qt
;
464 XWINDOW (mini_window
)->next
= Qnil
;
465 XWINDOW (mini_window
)->prev
= Qnil
;
466 XWINDOW (mini_window
)->frame
= frame
;
468 /* Put the proper buffer in that window. */
470 Fset_window_buffer (mini_window
,
471 (NILP (Vminibuffer_list
)
473 : Fcar (Vminibuffer_list
)));
477 /* Construct a frame that refers to the terminal (stdin and stdout). */
479 static int terminal_frame_count
;
482 make_terminal_frame ()
484 register struct frame
*f
;
491 initial_kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
492 init_kboard (initial_kboard
);
493 initial_kboard
->next_kboard
= all_kboards
;
494 all_kboards
= initial_kboard
;
498 /* The first call must initialize Vframe_list. */
499 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
504 XSETFRAME (frame
, f
);
505 Vframe_list
= Fcons (frame
, Vframe_list
);
507 terminal_frame_count
++;
508 sprintf (name
, "F%d", terminal_frame_count
);
509 f
->name
= build_string (name
);
511 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
512 f
->async_visible
= 1; /* Don't let visible be cleared later. */
514 f
->output_data
.x
= &the_only_x_display
;
515 f
->output_method
= output_msdos_raw
;
516 init_frame_faces (f
);
517 #else /* not MSDOS */
518 f
->output_data
.nothing
= 1; /* Nonzero means frame isn't deleted. */
523 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
524 1, 1, 0, "Create an additional terminal frame.\n\
525 You can create multiple frames on a text-only terminal in this way.\n\
526 Only the selected terminal frame is actually displayed.\n\
527 This function takes one argument, an alist specifying frame parameters.\n\
528 In practice, generally you don't need to specify any parameters.\n\
529 Note that changing the size of one terminal frame automatically affects all.")
537 if (selected_frame
->output_method
!= output_msdos_raw
)
540 if (selected_frame
->output_method
!= output_termcap
)
541 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
544 f
= make_terminal_frame ();
545 change_frame_size (f
, FRAME_HEIGHT (selected_frame
),
546 FRAME_WIDTH (selected_frame
), 0, 0);
547 remake_frame_glyphs (f
);
549 XSETFRAME (frame
, f
);
550 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
551 Fmodify_frame_parameters (frame
, parms
);
552 f
->face_alist
= selected_frame
->face_alist
;
557 do_switch_frame (frame
, no_enter
, track
)
558 Lisp_Object frame
, no_enter
;
561 /* If FRAME is a switch-frame event, extract the frame we should
564 && EQ (XCONS (frame
)->car
, Qswitch_frame
)
565 && CONSP (XCONS (frame
)->cdr
))
566 frame
= XCONS (XCONS (frame
)->cdr
)->car
;
568 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
569 a switch-frame event to arrive after a frame is no longer live,
570 especially when deleting the initial frame during startup. */
571 CHECK_FRAME (frame
, 0);
572 if (! FRAME_LIVE_P (XFRAME (frame
)))
575 if (selected_frame
== XFRAME (frame
))
578 /* This is too greedy; it causes inappropriate focus redirection
579 that's hard to get rid of. */
581 /* If a frame's focus has been redirected toward the currently
582 selected frame, we should change the redirection to point to the
583 newly selected frame. This means that if the focus is redirected
584 from a minibufferless frame to a surrogate minibuffer frame, we
585 can use `other-window' to switch between all the frames using
586 that minibuffer frame, and the focus redirection will follow us
592 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
596 if (!FRAMEP (XCONS (tail
)->car
))
599 focus
= FRAME_FOCUS_FRAME (XFRAME (XCONS (tail
)->car
));
601 if (FRAMEP (focus
) && XFRAME (focus
) == selected_frame
)
602 Fredirect_frame_focus (XCONS (tail
)->car
, frame
);
606 /* Instead, apply it only to the frame we're pointing to. */
607 #ifdef HAVE_WINDOW_SYSTEM
608 if (track
&& (FRAME_WINDOW_P (XFRAME (frame
))))
610 Lisp_Object focus
, xfocus
;
612 xfocus
= x_get_focus_frame (XFRAME (frame
));
615 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
616 if (FRAMEP (focus
) && XFRAME (focus
) == selected_frame
)
617 Fredirect_frame_focus (xfocus
, frame
);
620 #endif /* HAVE_X_WINDOWS */
623 selected_frame
= XFRAME (frame
);
624 if (! FRAME_MINIBUF_ONLY_P (selected_frame
))
625 last_nonminibuf_frame
= selected_frame
;
627 Fselect_window (XFRAME (frame
)->selected_window
);
629 /* We want to make sure that the next event generates a frame-switch
630 event to the appropriate frame. This seems kludgy to me, but
631 before you take it out, make sure that evaluating something like
632 (select-window (frame-root-window (new-frame))) doesn't end up
633 with your typing being interpreted in the new frame instead of
634 the one you're actually typing in. */
635 internal_last_event_frame
= Qnil
;
640 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
641 "Select the frame FRAME.\n\
642 Subsequent editing commands apply to its selected window.\n\
643 The selection of FRAME lasts until the next time the user does\n\
644 something to select a different frame, or until the next time this\n\
645 function is called.")
647 Lisp_Object frame
, no_enter
;
649 return do_switch_frame (frame
, no_enter
, 1);
653 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 2, "e",
654 "Handle a switch-frame event EVENT.\n\
655 Switch-frame events are usually bound to this function.\n\
656 A switch-frame event tells Emacs that the window manager has requested\n\
657 that the user's events be directed to the frame mentioned in the event.\n\
658 This function selects the selected window of the frame of EVENT.\n\
660 If EVENT is frame object, handle it as if it were a switch-frame event\n\
663 Lisp_Object event
, no_enter
;
665 /* Preserve prefix arg that the command loop just cleared. */
666 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
667 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
668 return do_switch_frame (event
, no_enter
, 0);
671 DEFUN ("ignore-event", Fignore_event
, Signore_event
, 0, 0, "",
672 "Do nothing, but preserve any prefix argument already specified.\n\
673 This is a suitable binding for iconify-frame and make-frame-visible.")
676 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
680 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
681 "Return the frame that is now selected.")
685 XSETFRAME (tem
, selected_frame
);
689 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
690 "Return the frame object that window WINDOW is on.")
694 CHECK_LIVE_WINDOW (window
, 0);
695 return XWINDOW (window
)->frame
;
698 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
699 "Returns the topmost, leftmost window of FRAME.\n\
700 If omitted, FRAME defaults to the currently selected frame.")
707 w
= selected_frame
->root_window
;
710 CHECK_LIVE_FRAME (frame
, 0);
711 w
= XFRAME (frame
)->root_window
;
713 while (NILP (XWINDOW (w
)->buffer
))
715 if (! NILP (XWINDOW (w
)->hchild
))
716 w
= XWINDOW (w
)->hchild
;
717 else if (! NILP (XWINDOW (w
)->vchild
))
718 w
= XWINDOW (w
)->vchild
;
725 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
726 Sactive_minibuffer_window
, 0, 0, 0,
727 "Return the currently active minibuffer window, or nil if none.")
730 return minibuf_level
? minibuf_window
: Qnil
;
733 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
734 "Returns the root-window of FRAME.\n\
735 If omitted, FRAME defaults to the currently selected frame.")
740 XSETFRAME (frame
, selected_frame
);
742 CHECK_LIVE_FRAME (frame
, 0);
744 return XFRAME (frame
)->root_window
;
747 DEFUN ("frame-selected-window", Fframe_selected_window
,
748 Sframe_selected_window
, 0, 1, 0,
749 "Return the selected window of frame object FRAME.\n\
750 If omitted, FRAME defaults to the currently selected frame.")
755 XSETFRAME (frame
, selected_frame
);
757 CHECK_LIVE_FRAME (frame
, 0);
759 return XFRAME (frame
)->selected_window
;
762 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
763 Sset_frame_selected_window
, 2, 2, 0,
764 "Set the selected window of frame object FRAME to WINDOW.\n\
765 If FRAME is nil, the selected frame is used.\n\
766 If FRAME is the selected frame, this makes WINDOW the selected window.")
768 Lisp_Object frame
, window
;
771 XSETFRAME (frame
, selected_frame
);
773 CHECK_LIVE_FRAME (frame
, 0);
775 CHECK_LIVE_WINDOW (window
, 1);
777 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
778 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
780 if (XFRAME (frame
) == selected_frame
)
781 return Fselect_window (window
);
783 return XFRAME (frame
)->selected_window
= window
;
786 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
788 "Return a list of all frames.")
791 return Fcopy_sequence (Vframe_list
);
794 /* Return the next frame in the frame list after FRAME.
795 If MINIBUF is nil, exclude minibuffer-only frames.
796 If MINIBUF is a window, include only its own frame
797 and any frame now using that window as the minibuffer.
798 If MINIBUF is `visible', include all visible frames.
799 If MINIBUF is 0, include all visible and iconified frames.
800 Otherwise, include all frames. */
803 next_frame (frame
, minibuf
)
810 /* There must always be at least one frame in Vframe_list. */
811 if (! CONSP (Vframe_list
))
814 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
815 forever. Forestall that. */
816 CHECK_LIVE_FRAME (frame
, 0);
819 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
823 f
= XCONS (tail
)->car
;
826 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
828 /* Decide whether this frame is eligible to be returned. */
830 /* If we've looped all the way around without finding any
831 eligible frames, return the original frame. */
835 /* Let minibuf decide if this frame is acceptable. */
838 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
841 else if (EQ (minibuf
, Qvisible
))
843 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
844 if (FRAME_VISIBLE_P (XFRAME (f
)))
847 else if (XFASTINT (minibuf
) == 0)
849 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
850 if (FRAME_VISIBLE_P (XFRAME (f
))
851 || FRAME_ICONIFIED_P (XFRAME (f
)))
854 else if (WINDOWP (minibuf
))
856 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
857 /* Check that F either is, or has forwarded its focus to,
859 && (EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
860 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
861 FRAME_FOCUS_FRAME (XFRAME (f
)))))
873 /* Return the previous frame in the frame list before FRAME.
874 If MINIBUF is nil, exclude minibuffer-only frames.
875 If MINIBUF is a window, include only its own frame
876 and any frame now using that window as the minibuffer.
877 If MINIBUF is `visible', include all visible frames.
878 If MINIBUF is 0, include all visible and iconified frames.
879 Otherwise, include all frames. */
882 prev_frame (frame
, minibuf
)
889 /* There must always be at least one frame in Vframe_list. */
890 if (! CONSP (Vframe_list
))
894 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
898 f
= XCONS (tail
)->car
;
902 if (EQ (frame
, f
) && !NILP (prev
))
905 if (FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
907 /* Decide whether this frame is eligible to be returned,
908 according to minibuf. */
911 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
914 else if (WINDOWP (minibuf
))
916 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
917 /* Check that F either is, or has forwarded its focus to,
919 && (EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
920 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
921 FRAME_FOCUS_FRAME (XFRAME (f
)))))
924 else if (EQ (minibuf
, Qvisible
))
926 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
927 if (FRAME_VISIBLE_P (XFRAME (f
)))
930 else if (XFASTINT (minibuf
) == 0)
932 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
933 if (FRAME_VISIBLE_P (XFRAME (f
))
934 || FRAME_ICONIFIED_P (XFRAME (f
)))
942 /* We've scanned the entire list. */
944 /* We went through the whole frame list without finding a single
945 acceptable frame. Return the original frame. */
948 /* There were no acceptable frames in the list before FRAME; otherwise,
949 we would have returned directly from the loop. Since PREV is the last
950 acceptable frame in the list, return it. */
955 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
956 "Return the next frame in the frame list after FRAME.\n\
957 It considers only frames on the same terminal as FRAME.\n\
958 By default, skip minibuffer-only frames.\n\
959 If omitted, FRAME defaults to the selected frame.\n\
960 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
961 If MINIFRAME is a window, include only its own frame\n\
962 and any frame now using that window as the minibuffer.\n\
963 If MINIFRAME is `visible', include all visible frames.\n\
964 If MINIFRAME is 0, include all visible and iconified frames.\n\
965 Otherwise, include all frames.")
967 Lisp_Object frame
, miniframe
;
972 XSETFRAME (frame
, selected_frame
);
974 CHECK_LIVE_FRAME (frame
, 0);
976 return next_frame (frame
, miniframe
);
979 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
980 "Return the previous frame in the frame list before FRAME.\n\
981 It considers only frames on the same terminal as FRAME.\n\
982 By default, skip minibuffer-only frames.\n\
983 If omitted, FRAME defaults to the selected frame.\n\
984 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
985 If MINIFRAME is a window, include only its own frame\n\
986 and any frame now using that window as the minibuffer.\n\
987 If MINIFRAME is `visible', include all visible frames.\n\
988 If MINIFRAME is 0, include all visible and iconified frames.\n\
989 Otherwise, include all frames.")
991 Lisp_Object frame
, miniframe
;
996 XSETFRAME (frame
, selected_frame
);
998 CHECK_LIVE_FRAME (frame
, 0);
1000 return prev_frame (frame
, miniframe
);
1003 /* Return 1 if it is ok to delete frame F;
1004 0 if all frames aside from F are invisible.
1005 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1008 other_visible_frames (f
)
1011 /* We know the selected frame is visible,
1012 so if F is some other frame, it can't be the sole visible one. */
1013 if (f
== selected_frame
)
1018 for (frames
= Vframe_list
;
1020 frames
= XCONS (frames
)->cdr
)
1024 this = XCONS (frames
)->car
;
1025 /* Verify that the frame's window still exists
1026 and we can still talk to it. And note any recent change
1028 #ifdef HAVE_WINDOW_SYSTEM
1029 if (FRAME_WINDOW_P (XFRAME (this)))
1031 x_sync (XFRAME (this));
1032 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1036 if (FRAME_VISIBLE_P (XFRAME (this))
1037 || FRAME_ICONIFIED_P (XFRAME (this))
1038 /* Allow deleting the terminal frame when at least
1039 one X frame exists! */
1040 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1048 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1049 "Delete FRAME, permanently eliminating it from use.\n\
1050 If omitted, FRAME defaults to the selected frame.\n\
1051 A frame may not be deleted if its minibuffer is used by other frames.\n\
1052 Normally, you may not delete a frame if all other frames are invisible,\n\
1053 but if the second optional argument FORCE is non-nil, you may do so.")
1055 Lisp_Object frame
, force
;
1058 int minibuffer_selected
;
1060 if (EQ (frame
, Qnil
))
1063 XSETFRAME (frame
, f
);
1067 CHECK_FRAME (frame
, 0);
1071 if (! FRAME_LIVE_P (f
))
1074 if (NILP (force
) && !other_visible_frames (f
))
1075 error ("Attempt to delete the sole visible or iconified frame");
1078 /* This is a nice idea, but x_connection_closed needs to be able
1079 to delete the last frame, if it is gone. */
1080 if (NILP (XCONS (Vframe_list
)->cdr
))
1081 error ("Attempt to delete the only frame");
1084 /* Does this frame have a minibuffer, and is it the surrogate
1085 minibuffer for any other frame? */
1086 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1090 for (frames
= Vframe_list
;
1092 frames
= XCONS (frames
)->cdr
)
1095 this = XCONS (frames
)->car
;
1097 if (! EQ (this, frame
)
1099 WINDOW_FRAME (XWINDOW
1100 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1101 error ("Attempt to delete a surrogate minibuffer frame");
1105 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1107 /* Don't let the frame remain selected. */
1108 if (f
== selected_frame
)
1110 Lisp_Object tail
, frame1
;
1112 /* Look for another visible frame on the same terminal. */
1113 frame1
= next_frame (frame
, Qvisible
);
1115 /* If there is none, find *some* other frame. */
1116 if (NILP (frame1
) || EQ (frame1
, frame
))
1118 FOR_EACH_FRAME (tail
, frame1
)
1120 if (! EQ (frame
, frame1
))
1125 do_switch_frame (frame1
, Qnil
, 0);
1128 /* Don't allow minibuf_window to remain on a deleted frame. */
1129 if (EQ (f
->minibuffer_window
, minibuf_window
))
1131 Fset_window_buffer (selected_frame
->minibuffer_window
,
1132 XWINDOW (minibuf_window
)->buffer
);
1133 minibuf_window
= selected_frame
->minibuffer_window
;
1135 /* If the dying minibuffer window was selected,
1136 select the new one. */
1137 if (minibuffer_selected
)
1138 Fselect_window (minibuf_window
);
1141 /* Clear any X selections for this frame. */
1142 #ifdef HAVE_X_WINDOWS
1144 x_clear_frame_selections (f
);
1147 /* Mark all the windows that used to be on FRAME as deleted, and then
1148 remove the reference to them. */
1149 delete_all_subwindows (XWINDOW (f
->root_window
));
1150 f
->root_window
= Qnil
;
1152 Vframe_list
= Fdelq (frame
, Vframe_list
);
1153 FRAME_SET_VISIBLE (f
, 0);
1155 if (echo_area_glyphs
== FRAME_MESSAGE_BUF (f
))
1157 echo_area_glyphs
= 0;
1158 previous_echo_glyphs
= 0;
1163 if (FRAME_CURRENT_GLYPHS (f
))
1164 free_frame_glyphs (f
, FRAME_CURRENT_GLYPHS (f
));
1165 if (FRAME_DESIRED_GLYPHS (f
))
1166 free_frame_glyphs (f
, FRAME_DESIRED_GLYPHS (f
));
1167 if (FRAME_TEMP_GLYPHS (f
))
1168 free_frame_glyphs (f
, FRAME_TEMP_GLYPHS (f
));
1169 if (FRAME_INSERT_COST (f
))
1170 free (FRAME_INSERT_COST (f
));
1171 if (FRAME_DELETEN_COST (f
))
1172 free (FRAME_DELETEN_COST (f
));
1173 if (FRAME_INSERTN_COST (f
))
1174 free (FRAME_INSERTN_COST (f
));
1175 if (FRAME_DELETE_COST (f
))
1176 free (FRAME_DELETE_COST (f
));
1177 if (FRAME_MESSAGE_BUF (f
))
1178 free (FRAME_MESSAGE_BUF (f
));
1180 #ifdef HAVE_WINDOW_SYSTEM
1181 /* Free all fontset data. */
1182 free_fontset_data (FRAME_FONTSET_DATA (f
));
1185 /* Since some events are handled at the interrupt level, we may get
1186 an event for f at any time; if we zero out the frame's display
1187 now, then we may trip up the event-handling code. Instead, we'll
1188 promise that the display of the frame must be valid until we have
1189 called the window-system-dependent frame destruction routine. */
1191 /* I think this should be done with a hook. */
1192 #ifdef HAVE_WINDOW_SYSTEM
1193 if (FRAME_WINDOW_P (f
))
1194 x_destroy_window (f
);
1197 f
->output_data
.nothing
= 0;
1199 /* If we've deleted the last_nonminibuf_frame, then try to find
1201 if (f
== last_nonminibuf_frame
)
1205 last_nonminibuf_frame
= 0;
1207 for (frames
= Vframe_list
;
1209 frames
= XCONS (frames
)->cdr
)
1211 f
= XFRAME (XCONS (frames
)->car
);
1212 if (!FRAME_MINIBUF_ONLY_P (f
))
1214 last_nonminibuf_frame
= f
;
1220 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1221 find another one. Prefer minibuffer-only frames, but also notice
1222 frames with other windows. */
1223 if (EQ (frame
, FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
))
1227 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1228 Lisp_Object frame_with_minibuf
;
1229 /* Some frame we found on the same kboard, or nil if there are none. */
1230 Lisp_Object frame_on_same_kboard
;
1232 frame_on_same_kboard
= Qnil
;
1233 frame_with_minibuf
= Qnil
;
1235 for (frames
= Vframe_list
;
1237 frames
= XCONS (frames
)->cdr
)
1242 this = XCONS (frames
)->car
;
1247 /* Consider only frames on the same kboard
1248 and only those with minibuffers. */
1249 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
)
1250 && FRAME_HAS_MINIBUF_P (f1
))
1252 frame_with_minibuf
= this;
1253 if (FRAME_MINIBUF_ONLY_P (f1
))
1257 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1258 frame_on_same_kboard
= this;
1261 if (!NILP (frame_on_same_kboard
))
1263 /* We know that there must be some frame with a minibuffer out
1264 there. If this were not true, all of the frames present
1265 would have to be minibufferless, which implies that at some
1266 point their minibuffer frames must have been deleted, but
1267 that is prohibited at the top; you can't delete surrogate
1268 minibuffer frames. */
1269 if (NILP (frame_with_minibuf
))
1272 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1275 /* No frames left on this kboard--say no minibuffer either. */
1276 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= Qnil
;
1279 /* Cause frame titles to update--necessary if we now have just one frame. */
1280 update_mode_lines
= 1;
1285 /* Return mouse position in character cell units. */
1287 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1288 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
1289 The position is given in character cells, where (0, 0) is the\n\
1290 upper-left corner.\n\
1291 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
1292 to read the mouse position, it returns the selected frame for FRAME\n\
1293 and nil for X and Y.")
1297 Lisp_Object lispy_dummy
;
1298 enum scroll_bar_part party_dummy
;
1301 unsigned long long_dummy
;
1307 /* It's okay for the hook to refrain from storing anything. */
1308 if (mouse_position_hook
)
1309 (*mouse_position_hook
) (&f
, -1,
1310 &lispy_dummy
, &party_dummy
,
1317 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1322 XSETFRAME (lispy_dummy
, f
);
1323 return Fcons (lispy_dummy
, Fcons (x
, y
));
1326 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1327 Smouse_pixel_position
, 0, 0, 0,
1328 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
1329 The position is given in pixel units, where (0, 0) is the\n\
1330 upper-left corner.\n\
1331 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
1332 to read the mouse position, it returns the selected frame for FRAME\n\
1333 and nil for X and Y.")
1337 Lisp_Object lispy_dummy
;
1338 enum scroll_bar_part party_dummy
;
1341 unsigned long long_dummy
;
1347 /* It's okay for the hook to refrain from storing anything. */
1348 if (mouse_position_hook
)
1349 (*mouse_position_hook
) (&f
, -1,
1350 &lispy_dummy
, &party_dummy
,
1354 XSETFRAME (lispy_dummy
, f
);
1355 return Fcons (lispy_dummy
, Fcons (x
, y
));
1358 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1359 "Move the mouse pointer to the center of character cell (X,Y) in FRAME.\n\
1360 Note, this is a no-op for an X frame that is not visible.\n\
1361 If you have just created a frame, you must wait for it to become visible\n\
1362 before calling this function on it, like this.\n\
1363 (while (not (frame-visible-p frame)) (sleep-for .5))")
1365 Lisp_Object frame
, x
, y
;
1367 CHECK_LIVE_FRAME (frame
, 0);
1368 CHECK_NUMBER (x
, 2);
1369 CHECK_NUMBER (y
, 1);
1371 /* I think this should be done with a hook. */
1372 #ifdef HAVE_WINDOW_SYSTEM
1373 if (FRAME_WINDOW_P (XFRAME (frame
)))
1374 /* Warping the mouse will cause enternotify and focus events. */
1375 x_set_mouse_position (XFRAME (frame
), x
, y
);
1377 #if defined (MSDOS) && defined (HAVE_MOUSE)
1378 if (FRAME_MSDOS_P (XFRAME (frame
)))
1380 Fselect_frame (frame
, Qnil
);
1381 mouse_moveto (XINT (x
), XINT (y
));
1389 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1390 Sset_mouse_pixel_position
, 3, 3, 0,
1391 "Move the mouse pointer to pixel position (X,Y) in FRAME.\n\
1392 Note, this is a no-op for an X frame that is not visible.\n\
1393 If you have just created a frame, you must wait for it to become visible\n\
1394 before calling this function on it, like this.\n\
1395 (while (not (frame-visible-p frame)) (sleep-for .5))")
1397 Lisp_Object frame
, x
, y
;
1399 CHECK_LIVE_FRAME (frame
, 0);
1400 CHECK_NUMBER (x
, 2);
1401 CHECK_NUMBER (y
, 1);
1403 /* I think this should be done with a hook. */
1404 #ifdef HAVE_WINDOW_SYSTEM
1405 if (FRAME_WINDOW_P (XFRAME (frame
)))
1406 /* Warping the mouse will cause enternotify and focus events. */
1407 x_set_mouse_pixel_position (XFRAME (frame
), x
, y
);
1409 #if defined (MSDOS) && defined (HAVE_MOUSE)
1410 if (FRAME_MSDOS_P (XFRAME (frame
)))
1412 Fselect_frame (frame
, Qnil
);
1413 mouse_moveto (XINT (x
), XINT (y
));
1421 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1423 "Make the frame FRAME visible (assuming it is an X-window).\n\
1424 If omitted, FRAME defaults to the currently selected frame.")
1429 XSETFRAME (frame
, selected_frame
);
1431 CHECK_LIVE_FRAME (frame
, 0);
1433 /* I think this should be done with a hook. */
1434 #ifdef HAVE_WINDOW_SYSTEM
1435 if (FRAME_WINDOW_P (XFRAME (frame
)))
1437 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1438 x_make_frame_visible (XFRAME (frame
));
1442 /* Make menu bar update for the Buffers and Frams menus. */
1443 windows_or_buffers_changed
++;
1448 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1450 "Make the frame FRAME invisible (assuming it is an X-window).\n\
1451 If omitted, FRAME defaults to the currently selected frame.\n\
1452 Normally you may not make FRAME invisible if all other frames are invisible,\n\
1453 but if the second optional argument FORCE is non-nil, you may do so.")
1455 Lisp_Object frame
, force
;
1458 XSETFRAME (frame
, selected_frame
);
1460 CHECK_LIVE_FRAME (frame
, 0);
1462 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1463 error ("Attempt to make invisible the sole visible or iconified frame");
1465 #if 0 /* This isn't logically necessary, and it can do GC. */
1466 /* Don't let the frame remain selected. */
1467 if (XFRAME (frame
) == selected_frame
)
1468 do_switch_frame (next_frame (frame
, Qt
), Qnil
, 0)
1471 /* Don't allow minibuf_window to remain on a deleted frame. */
1472 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1474 Fset_window_buffer (selected_frame
->minibuffer_window
,
1475 XWINDOW (minibuf_window
)->buffer
);
1476 minibuf_window
= selected_frame
->minibuffer_window
;
1479 /* I think this should be done with a hook. */
1480 #ifdef HAVE_WINDOW_SYSTEM
1481 if (FRAME_WINDOW_P (XFRAME (frame
)))
1482 x_make_frame_invisible (XFRAME (frame
));
1485 /* Make menu bar update for the Buffers and Frams menus. */
1486 windows_or_buffers_changed
++;
1491 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1493 "Make the frame FRAME into an icon.\n\
1494 If omitted, FRAME defaults to the currently selected frame.")
1499 XSETFRAME (frame
, selected_frame
);
1501 CHECK_LIVE_FRAME (frame
, 0);
1503 #if 0 /* This isn't logically necessary, and it can do GC. */
1504 /* Don't let the frame remain selected. */
1505 if (XFRAME (frame
) == selected_frame
)
1506 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1509 /* Don't allow minibuf_window to remain on a deleted frame. */
1510 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1512 Fset_window_buffer (selected_frame
->minibuffer_window
,
1513 XWINDOW (minibuf_window
)->buffer
);
1514 minibuf_window
= selected_frame
->minibuffer_window
;
1517 /* I think this should be done with a hook. */
1518 #ifdef HAVE_WINDOW_SYSTEM
1519 if (FRAME_WINDOW_P (XFRAME (frame
)))
1520 x_iconify_frame (XFRAME (frame
));
1523 /* Make menu bar update for the Buffers and Frams menus. */
1524 windows_or_buffers_changed
++;
1529 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1531 "Return t if FRAME is now \"visible\" (actually in use for display).\n\
1532 A frame that is not \"visible\" is not updated and, if it works through\n\
1533 a window system, it may not show at all.\n\
1534 Return the symbol `icon' if frame is visible only as an icon.")
1538 CHECK_LIVE_FRAME (frame
, 0);
1540 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1542 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1544 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1549 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1551 "Return a list of all frames now \"visible\" (being updated).")
1554 Lisp_Object tail
, frame
;
1559 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
1561 frame
= XCONS (tail
)->car
;
1562 if (!FRAMEP (frame
))
1565 if (FRAME_VISIBLE_P (f
))
1566 value
= Fcons (frame
, value
);
1572 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1573 "Bring FRAME to the front, so it occludes any frames it overlaps.\n\
1574 If FRAME is invisible, make it visible.\n\
1575 If you don't specify a frame, the selected frame is used.\n\
1576 If Emacs is displaying on an ordinary terminal or some other device which\n\
1577 doesn't support multiple overlapping frames, this function does nothing.")
1582 XSETFRAME (frame
, selected_frame
);
1584 CHECK_LIVE_FRAME (frame
, 0);
1586 /* Do like the documentation says. */
1587 Fmake_frame_visible (frame
);
1589 if (frame_raise_lower_hook
)
1590 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1595 /* Should we have a corresponding function called Flower_Power? */
1596 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1597 "Send FRAME to the back, so it is occluded by any frames that overlap it.\n\
1598 If you don't specify a frame, the selected frame is used.\n\
1599 If Emacs is displaying on an ordinary terminal or some other device which\n\
1600 doesn't support multiple overlapping frames, this function does nothing.")
1605 XSETFRAME (frame
, selected_frame
);
1607 CHECK_LIVE_FRAME (frame
, 0);
1609 if (frame_raise_lower_hook
)
1610 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1616 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1618 "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
1619 In other words, switch-frame events caused by events in FRAME will\n\
1620 request a switch to FOCUS-FRAME, and `last-event-frame' will be\n\
1621 FOCUS-FRAME after reading an event typed at FRAME.\n\
1623 If FOCUS-FRAME is omitted or nil, any existing redirection is\n\
1624 cancelled, and the frame again receives its own keystrokes.\n\
1626 Focus redirection is useful for temporarily redirecting keystrokes to\n\
1627 a surrogate minibuffer frame when a frame doesn't have its own\n\
1628 minibuffer window.\n\
1630 A frame's focus redirection can be changed by select-frame. If frame\n\
1631 FOO is selected, and then a different frame BAR is selected, any\n\
1632 frames redirecting their focus to FOO are shifted to redirect their\n\
1633 focus to BAR. This allows focus redirection to work properly when the\n\
1634 user switches from one frame to another using `select-window'.\n\
1636 This means that a frame whose focus is redirected to itself is treated\n\
1637 differently from a frame whose focus is redirected to nil; the former\n\
1638 is affected by select-frame, while the latter is not.\n\
1640 The redirection lasts until `redirect-frame-focus' is called to change it.")
1641 (frame
, focus_frame
)
1642 Lisp_Object frame
, focus_frame
;
1644 /* Note that we don't check for a live frame here. It's reasonable
1645 to redirect the focus of a frame you're about to delete, if you
1646 know what other frame should receive those keystrokes. */
1647 CHECK_FRAME (frame
, 0);
1649 if (! NILP (focus_frame
))
1650 CHECK_LIVE_FRAME (focus_frame
, 1);
1652 XFRAME (frame
)->focus_frame
= focus_frame
;
1654 if (frame_rehighlight_hook
)
1655 (*frame_rehighlight_hook
) (XFRAME (frame
));
1661 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1662 "Return the frame to which FRAME's keystrokes are currently being sent.\n\
1663 This returns nil if FRAME's focus is not redirected.\n\
1664 See `redirect-frame-focus'.")
1668 CHECK_LIVE_FRAME (frame
, 0);
1670 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1675 /* Return the value of frame parameter PROP in frame FRAME. */
1678 get_frame_param (frame
, prop
)
1679 register struct frame
*frame
;
1682 register Lisp_Object tem
;
1684 tem
= Fassq (prop
, frame
->param_alist
);
1690 /* Return the buffer-predicate of the selected frame. */
1693 frame_buffer_predicate ()
1695 return selected_frame
->buffer_predicate
;
1698 /* Return the buffer-list of the selected frame. */
1701 frame_buffer_list ()
1703 return selected_frame
->buffer_list
;
1706 /* Set the buffer-list of the selected frame. */
1709 set_frame_buffer_list (list
)
1712 selected_frame
->buffer_list
= list
;
1715 /* Discard BUFFER from the buffer-list of each frame. */
1718 frames_discard_buffer (buffer
)
1721 Lisp_Object frame
, tail
;
1723 FOR_EACH_FRAME (tail
, frame
)
1725 XFRAME (frame
)->buffer_list
1726 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1730 /* Move BUFFER to the end of the buffer-list of each frame. */
1733 frames_bury_buffer (buffer
)
1736 Lisp_Object frame
, tail
;
1738 FOR_EACH_FRAME (tail
, frame
)
1740 XFRAME (frame
)->buffer_list
1741 = nconc2 (Fdelq (buffer
, XFRAME (frame
)->buffer_list
),
1742 Fcons (buffer
, Qnil
));
1746 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1747 If the alist already has an element for PROP, we change it. */
1750 store_in_alist (alistptr
, prop
, val
)
1751 Lisp_Object
*alistptr
, val
;
1754 register Lisp_Object tem
;
1756 tem
= Fassq (prop
, *alistptr
);
1758 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1764 frame_name_fnn_p (str
, len
)
1768 if (len
> 1 && str
[0] == 'F')
1771 long num
= strtol (str
+ 1, &end_ptr
, 10);
1773 if (end_ptr
== str
+ len
)
1779 /* Set the name of the terminal frame. Also used by MSDOS frames.
1780 Modeled after x_set_name which is used for WINDOW frames. */
1783 set_term_frame_name (f
, name
)
1787 f
->explicit_name
= ! NILP (name
);
1789 /* If NAME is nil, set the name to F<num>. */
1794 /* Check for no change needed in this very common case
1795 before we do any consing. */
1796 if (frame_name_fnn_p (XSTRING (f
->name
)->data
, XSTRING (f
->name
)->size
))
1799 terminal_frame_count
++;
1800 sprintf (namebuf
, "F%d", terminal_frame_count
);
1801 name
= build_string (namebuf
);
1805 CHECK_STRING (name
, 0);
1807 /* Don't change the name if it's already NAME. */
1808 if (! NILP (Fstring_equal (name
, f
->name
)))
1811 /* Don't allow the user to set the frame name to F<num>, so it
1812 doesn't clash with the names we generate for terminal frames. */
1813 if (frame_name_fnn_p (XSTRING (name
)->data
, XSTRING (name
)->size
))
1814 error ("Frame names of the form F<num> are usurped by Emacs");
1818 update_mode_lines
= 1;
1822 store_frame_param (f
, prop
, val
)
1824 Lisp_Object prop
, val
;
1826 register Lisp_Object tem
;
1828 if (EQ (prop
, Qbuffer_list
))
1830 f
->buffer_list
= val
;
1834 tem
= Fassq (prop
, f
->param_alist
);
1836 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
1840 if (EQ (prop
, Qbuffer_predicate
))
1841 f
->buffer_predicate
= val
;
1843 if (! FRAME_WINDOW_P (f
))
1845 if (EQ (prop
, Qmenu_bar_lines
))
1846 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
1847 else if (EQ (prop
, Qname
))
1848 set_term_frame_name (f
, val
);
1851 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
1853 if (! MINI_WINDOW_P (XWINDOW (val
)))
1854 error ("Surrogate minibuffer windows must be minibuffer windows.");
1856 if (FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
)
1857 && !EQ (val
, f
->minibuffer_window
))
1858 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
1860 /* Install the chosen minibuffer window, with proper buffer. */
1861 f
->minibuffer_window
= val
;
1865 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
1866 "Return the parameters-alist of frame FRAME.\n\
1867 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
1868 The meaningful PARMs depend on the kind of frame.\n\
1869 If FRAME is omitted, return information on the currently selected frame.")
1877 if (EQ (frame
, Qnil
))
1881 CHECK_FRAME (frame
, 0);
1885 if (!FRAME_LIVE_P (f
))
1888 alist
= Fcopy_alist (f
->param_alist
);
1890 if (FRAME_MSDOS_P (f
))
1892 static char *colornames
[16] =
1894 "black", "blue", "green", "cyan", "red", "magenta", "brown",
1895 "lightgray", "darkgray", "lightblue", "lightgreen", "lightcyan",
1896 "lightred", "lightmagenta", "yellow", "white"
1898 store_in_alist (&alist
, intern ("foreground-color"),
1899 build_string (colornames
[FRAME_FOREGROUND_PIXEL (f
)]));
1900 store_in_alist (&alist
, intern ("background-color"),
1901 build_string (colornames
[FRAME_BACKGROUND_PIXEL (f
)]));
1903 store_in_alist (&alist
, intern ("font"), build_string ("default"));
1905 store_in_alist (&alist
, Qname
, f
->name
);
1906 height
= (FRAME_NEW_HEIGHT (f
) ? FRAME_NEW_HEIGHT (f
) : FRAME_HEIGHT (f
));
1907 store_in_alist (&alist
, Qheight
, make_number (height
));
1908 width
= (FRAME_NEW_WIDTH (f
) ? FRAME_NEW_WIDTH (f
) : FRAME_WIDTH (f
));
1909 store_in_alist (&alist
, Qwidth
, make_number (width
));
1910 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
1911 store_in_alist (&alist
, Qminibuffer
,
1912 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
1913 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
1914 : FRAME_MINIBUF_WINDOW (f
)));
1915 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
1916 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list ());
1918 /* I think this should be done with a hook. */
1919 #ifdef HAVE_WINDOW_SYSTEM
1920 if (FRAME_WINDOW_P (f
))
1921 x_report_frame_params (f
, &alist
);
1925 /* This ought to be correct in f->param_alist for an X frame. */
1927 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
1928 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
1933 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
1934 Smodify_frame_parameters
, 2, 2, 0,
1935 "Modify the parameters of frame FRAME according to ALIST.\n\
1936 ALIST is an alist of parameters to change and their new values.\n\
1937 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
1938 The meaningful PARMs depend on the kind of frame.\n\
1939 Undefined PARMs are ignored, but stored in the frame's parameter list\n\
1940 so that `frame-parameters' will return them.")
1942 Lisp_Object frame
, alist
;
1945 register Lisp_Object tail
, elt
, prop
, val
;
1947 if (EQ (frame
, Qnil
))
1951 CHECK_LIVE_FRAME (frame
, 0);
1955 /* I think this should be done with a hook. */
1956 #ifdef HAVE_WINDOW_SYSTEM
1957 if (FRAME_WINDOW_P (f
))
1958 x_set_frame_parameters (f
, alist
);
1962 if (FRAME_MSDOS_P (f
))
1963 IT_set_frame_parameters (f
, alist
);
1967 int length
= XINT (Flength (alist
));
1970 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
1972 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
1974 /* Extract parm names and values into those vectors. */
1977 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
1979 Lisp_Object elt
, prop
, val
;
1982 parms
[i
] = Fcar (elt
);
1983 values
[i
] = Fcdr (elt
);
1987 /* Now process them in reverse of specified order. */
1988 for (i
--; i
>= 0; i
--)
1992 store_frame_param (f
, prop
, val
);
1999 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2001 "Height in pixels of a line in the font in frame FRAME.\n\
2002 If FRAME is omitted, the selected frame is used.\n\
2003 For a terminal frame, the value is always 1.")
2013 CHECK_FRAME (frame
, 0);
2017 #ifdef HAVE_WINDOW_SYSTEM
2018 if (FRAME_WINDOW_P (f
))
2019 return make_number (x_char_height (f
));
2022 return make_number (1);
2026 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2028 "Width in pixels of characters in the font in frame FRAME.\n\
2029 If FRAME is omitted, the selected frame is used.\n\
2030 The width is the same for all characters, because\n\
2031 currently Emacs supports only fixed-width fonts.\n\
2032 For a terminal screen, the value is always 1.")
2042 CHECK_FRAME (frame
, 0);
2046 #ifdef HAVE_WINDOW_SYSTEM
2047 if (FRAME_WINDOW_P (f
))
2048 return make_number (x_char_width (f
));
2051 return make_number (1);
2054 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2055 Sframe_pixel_height
, 0, 1, 0,
2056 "Return a FRAME's height in pixels.\n\
2057 This counts only the height available for text lines,\n\
2058 not menu bars on window-system Emacs frames.\n\
2059 For a terminal frame, the result really gives the height in characters.\n\
2060 If FRAME is omitted, the selected frame is used.")
2070 CHECK_FRAME (frame
, 0);
2074 #ifdef HAVE_WINDOW_SYSTEM
2075 if (FRAME_WINDOW_P (f
))
2076 return make_number (x_pixel_height (f
));
2079 return make_number (FRAME_HEIGHT (f
));
2082 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2083 Sframe_pixel_width
, 0, 1, 0,
2084 "Return FRAME's width in pixels.\n\
2085 For a terminal frame, the result really gives the width in characters.\n\
2086 If FRAME is omitted, the selected frame is used.")
2096 CHECK_FRAME (frame
, 0);
2100 #ifdef HAVE_WINDOW_SYSTEM
2101 if (FRAME_WINDOW_P (f
))
2102 return make_number (x_pixel_width (f
));
2105 return make_number (FRAME_WIDTH (f
));
2108 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2109 "Specify that the frame FRAME has LINES lines.\n\
2110 Optional third arg non-nil means that redisplay should use LINES lines\n\
2111 but that the idea of the actual height of the frame should not be changed.")
2112 (frame
, lines
, pretend
)
2113 Lisp_Object frame
, lines
, pretend
;
2115 register struct frame
*f
;
2117 CHECK_NUMBER (lines
, 0);
2122 CHECK_LIVE_FRAME (frame
, 0);
2126 /* I think this should be done with a hook. */
2127 #ifdef HAVE_WINDOW_SYSTEM
2128 if (FRAME_WINDOW_P (f
))
2130 if (XINT (lines
) != f
->height
)
2131 x_set_window_size (f
, 1, f
->width
, XINT (lines
));
2135 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0);
2139 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2140 "Specify that the frame FRAME has COLS columns.\n\
2141 Optional third arg non-nil means that redisplay should use COLS columns\n\
2142 but that the idea of the actual width of the frame should not be changed.")
2143 (frame
, cols
, pretend
)
2144 Lisp_Object frame
, cols
, pretend
;
2146 register struct frame
*f
;
2147 CHECK_NUMBER (cols
, 0);
2152 CHECK_LIVE_FRAME (frame
, 0);
2156 /* I think this should be done with a hook. */
2157 #ifdef HAVE_WINDOW_SYSTEM
2158 if (FRAME_WINDOW_P (f
))
2160 if (XINT (cols
) != f
->width
)
2161 x_set_window_size (f
, 1, XINT (cols
), f
->height
);
2165 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0);
2169 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2170 "Sets size of FRAME to COLS by ROWS, measured in characters.")
2172 Lisp_Object frame
, cols
, rows
;
2174 register struct frame
*f
;
2177 CHECK_LIVE_FRAME (frame
, 0);
2178 CHECK_NUMBER (cols
, 2);
2179 CHECK_NUMBER (rows
, 1);
2182 /* I think this should be done with a hook. */
2183 #ifdef HAVE_WINDOW_SYSTEM
2184 if (FRAME_WINDOW_P (f
))
2186 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
2187 || FRAME_NEW_HEIGHT (f
) || FRAME_NEW_WIDTH (f
))
2188 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2192 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0);
2197 DEFUN ("set-frame-position", Fset_frame_position
,
2198 Sset_frame_position
, 3, 3, 0,
2199 "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
2200 This is actually the position of the upper left corner of the frame.\n\
2201 Negative values for XOFFSET or YOFFSET are interpreted relative to\n\
2202 the rightmost or bottommost possible position (that stays within the screen).")
2203 (frame
, xoffset
, yoffset
)
2204 Lisp_Object frame
, xoffset
, yoffset
;
2206 register struct frame
*f
;
2209 CHECK_LIVE_FRAME (frame
, 0);
2210 CHECK_NUMBER (xoffset
, 1);
2211 CHECK_NUMBER (yoffset
, 2);
2214 /* I think this should be done with a hook. */
2215 #ifdef HAVE_WINDOW_SYSTEM
2216 if (FRAME_WINDOW_P (f
))
2217 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2228 staticpro (&Vframe_list
);
2230 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
2231 "The initial frame-object, which represents Emacs's stdout.");
2233 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
2234 "Non-nil if all of emacs is iconified and frame updates are not needed.");
2235 Vemacs_iconified
= Qnil
;
2237 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
2238 "Minibufferless frames use this frame's minibuffer.\n\
2240 Emacs cannot create minibufferless frames unless this is set to an\n\
2241 appropriate surrogate.\n\
2243 Emacs consults this variable only when creating minibufferless\n\
2244 frames; once the frame is created, it sticks with its assigned\n\
2245 minibuffer, no matter what this variable is set to. This means that\n\
2246 this variable doesn't necessarily say anything meaningful about the\n\
2247 current set of frames, or where the minibuffer is currently being\n\
2250 defsubr (&Sactive_minibuffer_window
);
2252 defsubr (&Sframe_live_p
);
2253 defsubr (&Smake_terminal_frame
);
2254 defsubr (&Shandle_switch_frame
);
2255 defsubr (&Signore_event
);
2256 defsubr (&Sselect_frame
);
2257 defsubr (&Sselected_frame
);
2258 defsubr (&Swindow_frame
);
2259 defsubr (&Sframe_root_window
);
2260 defsubr (&Sframe_first_window
);
2261 defsubr (&Sframe_selected_window
);
2262 defsubr (&Sset_frame_selected_window
);
2263 defsubr (&Sframe_list
);
2264 defsubr (&Snext_frame
);
2265 defsubr (&Sprevious_frame
);
2266 defsubr (&Sdelete_frame
);
2267 defsubr (&Smouse_position
);
2268 defsubr (&Smouse_pixel_position
);
2269 defsubr (&Sset_mouse_position
);
2270 defsubr (&Sset_mouse_pixel_position
);
2272 defsubr (&Sframe_configuration
);
2273 defsubr (&Srestore_frame_configuration
);
2275 defsubr (&Smake_frame_visible
);
2276 defsubr (&Smake_frame_invisible
);
2277 defsubr (&Siconify_frame
);
2278 defsubr (&Sframe_visible_p
);
2279 defsubr (&Svisible_frame_list
);
2280 defsubr (&Sraise_frame
);
2281 defsubr (&Slower_frame
);
2282 defsubr (&Sredirect_frame_focus
);
2283 defsubr (&Sframe_focus
);
2284 defsubr (&Sframe_parameters
);
2285 defsubr (&Smodify_frame_parameters
);
2286 defsubr (&Sframe_char_height
);
2287 defsubr (&Sframe_char_width
);
2288 defsubr (&Sframe_pixel_height
);
2289 defsubr (&Sframe_pixel_width
);
2290 defsubr (&Sset_frame_height
);
2291 defsubr (&Sset_frame_width
);
2292 defsubr (&Sset_frame_size
);
2293 defsubr (&Sset_frame_position
);
2298 initial_define_lispy_key (global_map
, "switch-frame", "handle-switch-frame");
2299 initial_define_lispy_key (global_map
, "delete-frame", "handle-delete-frame");
2300 initial_define_lispy_key (global_map
, "iconify-frame", "ignore-event");
2301 initial_define_lispy_key (global_map
, "make-frame-visible", "ignore-event");