1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000 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. */
33 /* These help us bind and responding to switch-frame events. */
37 #ifdef HAVE_WINDOW_SYSTEM
40 #include "termhooks.h"
41 #include "dispextern.h"
49 extern struct mac_output
*NewMacWindow ();
50 extern void DisposeMacWindow (struct mac_output
*);
53 /* Evaluate this expression to rebuild the section of syms_of_frame
54 that initializes and staticpros the symbols declared below. Note
55 that Emacs 18 has a bug that keeps C-x C-e from being able to
56 evaluate this expression.
59 ;; Accumulate a list of the symbols we want to initialize from the
60 ;; declarations at the top of the file.
61 (goto-char (point-min))
62 (search-forward "/\*&&& symbols declared here &&&*\/\n")
64 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
66 (cons (buffer-substring (match-beginning 1) (match-end 1))
69 (setq symbol-list (nreverse symbol-list))
70 ;; Delete the section of syms_of_... where we initialize the symbols.
71 (search-forward "\n /\*&&& init symbols here &&&*\/\n")
72 (let ((start (point)))
73 (while (looking-at "^ Q")
75 (kill-region start (point)))
76 ;; Write a new symbol initialization section.
78 (insert (format " %s = intern (\"" (car symbol-list)))
79 (let ((start (point)))
80 (insert (substring (car symbol-list) 1))
81 (subst-char-in-region start (point) ?_ ?-))
82 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
83 (setq symbol-list (cdr symbol-list)))))
86 /*&&& symbols declared here &&&*/
88 Lisp_Object Qframe_live_p
;
91 Lisp_Object Qminibuffer
;
92 Lisp_Object Qmodeline
;
95 Lisp_Object Qunsplittable
;
96 Lisp_Object Qmenu_bar_lines
;
97 Lisp_Object Qtool_bar_lines
;
103 Lisp_Object Qvisible
;
104 Lisp_Object Qbuffer_predicate
;
105 Lisp_Object Qbuffer_list
;
107 Lisp_Object Qdisplay_type
;
108 Lisp_Object Qbackground_mode
;
110 Lisp_Object Vterminal_frame
;
111 Lisp_Object Vdefault_frame_alist
;
112 Lisp_Object Vmouse_position_function
;
117 /*&&& init symbols here &&&*/
118 Qframep
= intern ("framep");
119 staticpro (&Qframep
);
120 Qframe_live_p
= intern ("frame-live-p");
121 staticpro (&Qframe_live_p
);
122 Qheight
= intern ("height");
123 staticpro (&Qheight
);
124 Qicon
= intern ("icon");
126 Qminibuffer
= intern ("minibuffer");
127 staticpro (&Qminibuffer
);
128 Qmodeline
= intern ("modeline");
129 staticpro (&Qmodeline
);
130 Qname
= intern ("name");
132 Qonly
= intern ("only");
134 Qunsplittable
= intern ("unsplittable");
135 staticpro (&Qunsplittable
);
136 Qmenu_bar_lines
= intern ("menu-bar-lines");
137 staticpro (&Qmenu_bar_lines
);
138 Qtool_bar_lines
= intern ("tool-bar-lines");
139 staticpro (&Qtool_bar_lines
);
140 Qwidth
= intern ("width");
144 Qw32
= intern ("w32");
148 Qmac
= intern ("mac");
150 Qvisible
= intern ("visible");
151 staticpro (&Qvisible
);
152 Qbuffer_predicate
= intern ("buffer-predicate");
153 staticpro (&Qbuffer_predicate
);
154 Qbuffer_list
= intern ("buffer-list");
155 staticpro (&Qbuffer_list
);
156 Qtitle
= intern ("title");
158 Qdisplay_type
= intern ("display-type");
159 staticpro (&Qdisplay_type
);
160 Qbackground_mode
= intern ("background-mode");
161 staticpro (&Qbackground_mode
);
163 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
164 "Alist of default values for frame creation.\n\
165 These may be set in your init file, like this:\n\
166 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))\n\
167 These override values given in window system configuration data,\n\
168 including X Windows' defaults database.\n\
169 For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
170 For values specific to the separate minibuffer frame, see\n\
171 `minibuffer-frame-alist'.\n\
172 The `menu-bar-lines' element of the list controls whether new frames\n\
173 have menu bars; `menu-bar-mode' works by altering this element.");
174 Vdefault_frame_alist
= Qnil
;
178 set_menu_bar_lines_1 (window
, n
)
182 struct window
*w
= XWINDOW (window
);
184 XSETFASTINT (w
->last_modified
, 0);
185 XSETFASTINT (w
->top
, XFASTINT (w
->top
) + n
);
186 XSETFASTINT (w
->height
, XFASTINT (w
->height
) - n
);
188 if (INTEGERP (w
->orig_top
))
189 XSETFASTINT (w
->orig_top
, XFASTINT (w
->orig_top
) + n
);
190 if (INTEGERP (w
->orig_height
))
191 XSETFASTINT (w
->orig_height
, XFASTINT (w
->orig_height
) - n
);
193 /* Handle just the top child in a vertical split. */
194 if (!NILP (w
->vchild
))
195 set_menu_bar_lines_1 (w
->vchild
, n
);
197 /* Adjust all children in a horizontal split. */
198 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
200 w
= XWINDOW (window
);
201 set_menu_bar_lines_1 (window
, n
);
206 set_menu_bar_lines (f
, value
, oldval
)
208 Lisp_Object value
, oldval
;
211 int olines
= FRAME_MENU_BAR_LINES (f
);
213 /* Right now, menu bars don't work properly in minibuf-only frames;
214 most of the commands try to apply themselves to the minibuffer
215 frame itself, and get an error because you can't switch buffers
216 in or split the minibuffer window. */
217 if (FRAME_MINIBUF_ONLY_P (f
))
220 if (INTEGERP (value
))
221 nlines
= XINT (value
);
225 if (nlines
!= olines
)
227 windows_or_buffers_changed
++;
228 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
229 FRAME_MENU_BAR_LINES (f
) = nlines
;
230 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
235 Lisp_Object Vemacs_iconified
;
236 Lisp_Object Vframe_list
;
238 struct x_output tty_display
;
240 extern Lisp_Object Vminibuffer_list
;
241 extern Lisp_Object
get_minibuffer ();
242 extern Lisp_Object
Fhandle_switch_frame ();
243 extern Lisp_Object
Fredirect_frame_focus ();
244 extern Lisp_Object
x_get_focus_frame ();
246 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
247 "Return non-nil if OBJECT is a frame.\n\
248 Value is t for a termcap frame (a character-only terminal),\n\
249 `x' for an Emacs frame that is really an X window,\n\
250 `w32' for an Emacs frame that is a window on MS-Windows display,\n\
251 `mac' for an Emacs frame on a Macintosh display,\n\
252 `pc' for a direct-write MS-DOS frame.\n\
253 See also `frame-live-p'.")
257 if (!FRAMEP (object
))
259 switch (XFRAME (object
)->output_method
)
263 case output_x_window
:
267 case output_msdos_raw
:
276 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
277 "Return non-nil if OBJECT is a frame which has not been deleted.\n\
278 Value is nil if OBJECT is not a live frame. If object is a live\n\
279 frame, the return value indicates what sort of output device it is\n\
280 displayed on. Value is t for a termcap frame (a character-only\n\
281 terminal), `x' for an Emacs frame being displayed in an X window.")
285 return ((FRAMEP (object
)
286 && FRAME_LIVE_P (XFRAME (object
)))
296 register struct frame
*f
;
297 register Lisp_Object root_window
;
298 register Lisp_Object mini_window
;
299 register struct Lisp_Vector
*vec
;
302 vec
= allocate_vectorlike ((EMACS_INT
) VECSIZE (struct frame
));
303 for (i
= 0; i
< VECSIZE (struct frame
); i
++)
304 XSETFASTINT (vec
->contents
[i
], 0);
305 vec
->size
= VECSIZE (struct frame
);
306 f
= (struct frame
*)vec
;
307 XSETFRAME (frame
, f
);
309 f
->desired_matrix
= 0;
310 f
->current_matrix
= 0;
313 f
->glyphs_initialized_p
= 0;
314 f
->decode_mode_spec_buffer
= 0;
316 f
->async_visible
= 0;
317 f
->output_data
.nothing
= 0;
319 f
->async_iconified
= 0;
320 f
->wants_modeline
= 1;
325 f
->has_minibuffer
= mini_p
;
326 f
->focus_frame
= Qnil
;
327 f
->explicit_name
= 0;
328 f
->can_have_scroll_bars
= 0;
329 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
330 f
->param_alist
= Qnil
;
331 f
->scroll_bars
= Qnil
;
332 f
->condemned_scroll_bars
= Qnil
;
333 f
->face_alist
= Qnil
;
334 f
->face_cache
= NULL
;
335 f
->menu_bar_items
= Qnil
;
336 f
->menu_bar_vector
= Qnil
;
337 f
->menu_bar_items_used
= 0;
338 f
->buffer_predicate
= Qnil
;
339 f
->buffer_list
= Qnil
;
341 f
->kboard
= initial_kboard
;
345 f
->menu_bar_window
= Qnil
;
346 f
->tool_bar_window
= Qnil
;
347 f
->desired_tool_bar_items
= f
->current_tool_bar_items
= Qnil
;
348 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
349 f
->n_desired_tool_bar_items
= f
->n_current_tool_bar_items
= 0;
351 root_window
= make_window ();
354 mini_window
= make_window ();
355 XWINDOW (root_window
)->next
= mini_window
;
356 XWINDOW (mini_window
)->prev
= root_window
;
357 XWINDOW (mini_window
)->mini_p
= Qt
;
358 XWINDOW (mini_window
)->frame
= frame
;
359 f
->minibuffer_window
= mini_window
;
364 XWINDOW (root_window
)->next
= Qnil
;
365 f
->minibuffer_window
= Qnil
;
368 XWINDOW (root_window
)->frame
= frame
;
371 just so that there is "something there."
372 Correct size will be set up later with change_frame_size. */
374 SET_FRAME_WIDTH (f
, 10);
377 XSETFASTINT (XWINDOW (root_window
)->width
, 10);
378 XSETFASTINT (XWINDOW (root_window
)->height
, (mini_p
? 9 : 10));
382 XSETFASTINT (XWINDOW (mini_window
)->width
, 10);
383 XSETFASTINT (XWINDOW (mini_window
)->top
, 9);
384 XSETFASTINT (XWINDOW (mini_window
)->height
, 1);
387 /* Choose a buffer for the frame's root window. */
391 XWINDOW (root_window
)->buffer
= Qt
;
392 buf
= Fcurrent_buffer ();
393 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
394 a space), try to find another one. */
395 if (XSTRING (Fbuffer_name (buf
))->data
[0] == ' ')
396 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
398 /* Use set_window_buffer, not Fset_window_buffer, and don't let
399 hooks be run by it. The reason is that the whole frame/window
400 arrangement is not yet fully intialized at this point. Windows
401 don't have the right size, glyph matrices aren't initialized
402 etc. Running Lisp functions at this point surely ends in a
404 set_window_buffer (root_window
, buf
, 0);
405 f
->buffer_list
= Fcons (buf
, Qnil
);
410 XWINDOW (mini_window
)->buffer
= Qt
;
411 set_window_buffer (mini_window
,
412 (NILP (Vminibuffer_list
)
414 : Fcar (Vminibuffer_list
)),
418 f
->root_window
= root_window
;
419 f
->selected_window
= root_window
;
420 /* Make sure this window seems more recently used than
421 a newly-created, never-selected window. */
422 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, ++window_select_count
);
427 #ifdef HAVE_WINDOW_SYSTEM
428 /* Make a frame using a separate minibuffer window on another frame.
429 MINI_WINDOW is the minibuffer window to use. nil means use the
430 default (the global minibuffer). */
433 make_frame_without_minibuffer (mini_window
, kb
, display
)
434 register Lisp_Object mini_window
;
438 register struct frame
*f
;
441 if (!NILP (mini_window
))
442 CHECK_LIVE_WINDOW (mini_window
, 0);
445 if (!NILP (mini_window
)
446 && XFRAME (XWINDOW (mini_window
)->frame
)->kboard
!= kb
)
447 error ("frame and minibuffer must be on the same display");
450 /* Make a frame containing just a root window. */
453 if (NILP (mini_window
))
455 /* Use default-minibuffer-frame if possible. */
456 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
457 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
459 Lisp_Object frame_dummy
;
461 XSETFRAME (frame_dummy
, f
);
462 GCPRO1 (frame_dummy
);
463 /* If there's no minibuffer frame to use, create one. */
464 kb
->Vdefault_minibuffer_frame
=
465 call1 (intern ("make-initial-minibuffer-frame"), display
);
469 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
472 f
->minibuffer_window
= mini_window
;
474 /* Make the chosen minibuffer window display the proper minibuffer,
475 unless it is already showing a minibuffer. */
476 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
477 Fset_window_buffer (mini_window
,
478 (NILP (Vminibuffer_list
)
480 : Fcar (Vminibuffer_list
)));
484 /* Make a frame containing only a minibuffer window. */
487 make_minibuffer_frame ()
489 /* First make a frame containing just a root window, no minibuffer. */
491 register struct frame
*f
= make_frame (0);
492 register Lisp_Object mini_window
;
493 register Lisp_Object frame
;
495 XSETFRAME (frame
, f
);
500 f
->wants_modeline
= 0;
501 f
->has_minibuffer
= 1;
503 /* Now label the root window as also being the minibuffer.
504 Avoid infinite looping on the window chain by marking next pointer
507 mini_window
= f
->minibuffer_window
= f
->root_window
;
508 XWINDOW (mini_window
)->mini_p
= Qt
;
509 XWINDOW (mini_window
)->next
= Qnil
;
510 XWINDOW (mini_window
)->prev
= Qnil
;
511 XWINDOW (mini_window
)->frame
= frame
;
513 /* Put the proper buffer in that window. */
515 Fset_window_buffer (mini_window
,
516 (NILP (Vminibuffer_list
)
518 : Fcar (Vminibuffer_list
)));
521 #endif /* HAVE_WINDOW_SYSTEM */
523 /* Construct a frame that refers to the terminal (stdin and stdout). */
525 static int terminal_frame_count
;
528 make_terminal_frame ()
530 register struct frame
*f
;
537 initial_kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
538 init_kboard (initial_kboard
);
539 initial_kboard
->next_kboard
= all_kboards
;
540 all_kboards
= initial_kboard
;
544 /* The first call must initialize Vframe_list. */
545 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
550 XSETFRAME (frame
, f
);
551 Vframe_list
= Fcons (frame
, Vframe_list
);
553 terminal_frame_count
++;
554 sprintf (name
, "F%d", terminal_frame_count
);
555 f
->name
= build_string (name
);
557 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
558 f
->async_visible
= 1; /* Don't let visible be cleared later. */
560 f
->output_data
.x
= &the_only_x_display
;
561 if (!inhibit_window_system
562 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
563 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
565 f
->output_method
= output_msdos_raw
;
566 /* This initialization of foreground and background pixels is
567 only important for the initial frame created in temacs. If
568 we don't do that, we get black background and foreground in
569 the dumped Emacs because the_only_x_display is a static
570 variable, hence it is born all-zeroes, and zero is the code
571 for the black color. Other frames all inherit their pixels
572 from what's already in the_only_x_display. */
573 if ((!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
574 && f
->output_data
.x
->background_pixel
== 0
575 && f
->output_data
.x
->foreground_pixel
== 0)
577 f
->output_data
.x
->background_pixel
= FACE_TTY_DEFAULT_BG_COLOR
;
578 f
->output_data
.x
->foreground_pixel
= FACE_TTY_DEFAULT_FG_COLOR
;
582 f
->output_method
= output_termcap
;
585 f
->output_data
.mac
= NewMacWindow(f
);
586 f
->output_data
.mac
->background_pixel
= 0xffffff;
587 f
->output_data
.mac
->foreground_pixel
= 0;
588 f
->output_data
.mac
->n_param_faces
= 0;
589 f
->output_data
.mac
->n_computed_faces
= 0;
590 f
->output_data
.mac
->size_computed_faces
= 0;
591 f
->output_method
= output_mac
;
594 init_frame_faces (f
);
595 #else /* !macintosh */
596 f
->output_data
.x
= &tty_display
;
597 #endif /* !macintosh */
602 init_frame_faces (f
);
607 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
608 1, 1, 0, "Create an additional terminal frame.\n\
609 You can create multiple frames on a text-only terminal in this way.\n\
610 Only the selected terminal frame is actually displayed.\n\
611 This function takes one argument, an alist specifying frame parameters.\n\
612 In practice, generally you don't need to specify any parameters.\n\
613 Note that changing the size of one terminal frame automatically affects all.")
618 Lisp_Object frame
, tem
;
619 struct frame
*sf
= SELECTED_FRAME ();
622 if (sf
->output_method
!= output_msdos_raw
623 && sf
->output_method
!= output_termcap
)
625 #else /* not MSDOS */
628 if (sf
->output_method
!= output_mac
)
629 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
631 if (sf
->output_method
!= output_termcap
)
632 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
634 #endif /* not MSDOS */
636 f
= make_terminal_frame ();
638 change_frame_size (f
, FRAME_HEIGHT (sf
),
639 FRAME_WIDTH (sf
), 0, 0, 0);
642 XSETFRAME (frame
, f
);
643 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
644 Fmodify_frame_parameters (frame
, parms
);
646 /* Make the frame face alist be frame-specific, so that each
647 frame could change its face definitions independently. */
648 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
649 /* Simple Fcopy_alist isn't enough, because we need the contents of
650 the vectors which are the CDRs of associations in face_alist to
651 be copied as well. */
652 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
653 XCDR (XCAR (tem
)) = Fcopy_sequence (XCDR (XCAR (tem
)));
658 do_switch_frame (frame
, no_enter
, track
)
659 Lisp_Object frame
, no_enter
;
662 struct frame
*sf
= SELECTED_FRAME ();
664 /* If FRAME is a switch-frame event, extract the frame we should
667 && EQ (XCAR (frame
), Qswitch_frame
)
668 && CONSP (XCDR (frame
)))
669 frame
= XCAR (XCDR (frame
));
671 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
672 a switch-frame event to arrive after a frame is no longer live,
673 especially when deleting the initial frame during startup. */
674 CHECK_FRAME (frame
, 0);
675 if (! FRAME_LIVE_P (XFRAME (frame
)))
678 if (sf
== XFRAME (frame
))
681 /* This is too greedy; it causes inappropriate focus redirection
682 that's hard to get rid of. */
684 /* If a frame's focus has been redirected toward the currently
685 selected frame, we should change the redirection to point to the
686 newly selected frame. This means that if the focus is redirected
687 from a minibufferless frame to a surrogate minibuffer frame, we
688 can use `other-window' to switch between all the frames using
689 that minibuffer frame, and the focus redirection will follow us
695 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
699 if (!FRAMEP (XCAR (tail
)))
702 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
704 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
705 Fredirect_frame_focus (XCAR (tail
), frame
);
709 /* Instead, apply it only to the frame we're pointing to. */
710 #ifdef HAVE_WINDOW_SYSTEM
711 if (track
&& (FRAME_WINDOW_P (XFRAME (frame
))))
713 Lisp_Object focus
, xfocus
;
715 xfocus
= x_get_focus_frame (XFRAME (frame
));
718 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
719 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
720 Fredirect_frame_focus (xfocus
, frame
);
723 #endif /* HAVE_X_WINDOWS */
726 selected_frame
= frame
;
727 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
728 last_nonminibuf_frame
= XFRAME (selected_frame
);
730 Fselect_window (XFRAME (frame
)->selected_window
);
732 /* We want to make sure that the next event generates a frame-switch
733 event to the appropriate frame. This seems kludgy to me, but
734 before you take it out, make sure that evaluating something like
735 (select-window (frame-root-window (new-frame))) doesn't end up
736 with your typing being interpreted in the new frame instead of
737 the one you're actually typing in. */
738 internal_last_event_frame
= Qnil
;
743 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
744 "Select the frame FRAME.\n\
745 Subsequent editing commands apply to its selected window.\n\
746 The selection of FRAME lasts until the next time the user does\n\
747 something to select a different frame, or until the next time this\n\
748 function is called.")
750 Lisp_Object frame
, no_enter
;
752 return do_switch_frame (frame
, no_enter
, 1);
756 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 2, "e",
757 "Handle a switch-frame event EVENT.\n\
758 Switch-frame events are usually bound to this function.\n\
759 A switch-frame event tells Emacs that the window manager has requested\n\
760 that the user's events be directed to the frame mentioned in the event.\n\
761 This function selects the selected window of the frame of EVENT.\n\
763 If EVENT is frame object, handle it as if it were a switch-frame event\n\
766 Lisp_Object event
, no_enter
;
768 /* Preserve prefix arg that the command loop just cleared. */
769 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
770 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
771 return do_switch_frame (event
, no_enter
, 0);
774 DEFUN ("ignore-event", Fignore_event
, Signore_event
, 0, 0, "",
775 "Do nothing, but preserve any prefix argument already specified.\n\
776 This is a suitable binding for iconify-frame and make-frame-visible.")
779 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
783 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
784 "Return the frame that is now selected.")
787 return selected_frame
;
790 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
791 "Return the frame object that window WINDOW is on.")
795 CHECK_LIVE_WINDOW (window
, 0);
796 return XWINDOW (window
)->frame
;
799 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
800 "Returns the topmost, leftmost window of FRAME.\n\
801 If omitted, FRAME defaults to the currently selected frame.")
808 w
= SELECTED_FRAME ()->root_window
;
811 CHECK_LIVE_FRAME (frame
, 0);
812 w
= XFRAME (frame
)->root_window
;
814 while (NILP (XWINDOW (w
)->buffer
))
816 if (! NILP (XWINDOW (w
)->hchild
))
817 w
= XWINDOW (w
)->hchild
;
818 else if (! NILP (XWINDOW (w
)->vchild
))
819 w
= XWINDOW (w
)->vchild
;
826 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
827 Sactive_minibuffer_window
, 0, 0, 0,
828 "Return the currently active minibuffer window, or nil if none.")
831 return minibuf_level
? minibuf_window
: Qnil
;
834 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
835 "Returns the root-window of FRAME.\n\
836 If omitted, FRAME defaults to the currently selected frame.")
843 window
= SELECTED_FRAME ()->root_window
;
846 CHECK_LIVE_FRAME (frame
, 0);
847 window
= XFRAME (frame
)->root_window
;
853 DEFUN ("frame-selected-window", Fframe_selected_window
,
854 Sframe_selected_window
, 0, 1, 0,
855 "Return the selected window of frame object FRAME.\n\
856 If omitted, FRAME defaults to the currently selected frame.")
863 window
= SELECTED_FRAME ()->selected_window
;
866 CHECK_LIVE_FRAME (frame
, 0);
867 window
= XFRAME (frame
)->selected_window
;
873 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
874 Sset_frame_selected_window
, 2, 2, 0,
875 "Set the selected window of frame object FRAME to WINDOW.\n\
876 If FRAME is nil, the selected frame is used.\n\
877 If FRAME is the selected frame, this makes WINDOW the selected window.")
879 Lisp_Object frame
, window
;
882 frame
= selected_frame
;
884 CHECK_LIVE_FRAME (frame
, 0);
885 CHECK_LIVE_WINDOW (window
, 1);
887 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
888 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
890 if (EQ (frame
, selected_frame
))
891 return Fselect_window (window
);
893 return XFRAME (frame
)->selected_window
= window
;
896 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
898 "Return a list of all frames.")
901 return Fcopy_sequence (Vframe_list
);
904 /* Return the next frame in the frame list after FRAME.
905 If MINIBUF is nil, exclude minibuffer-only frames.
906 If MINIBUF is a window, include only its own frame
907 and any frame now using that window as the minibuffer.
908 If MINIBUF is `visible', include all visible frames.
909 If MINIBUF is 0, include all visible and iconified frames.
910 Otherwise, include all frames. */
913 next_frame (frame
, minibuf
)
920 /* There must always be at least one frame in Vframe_list. */
921 if (! CONSP (Vframe_list
))
924 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
925 forever. Forestall that. */
926 CHECK_LIVE_FRAME (frame
, 0);
929 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
936 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
938 /* Decide whether this frame is eligible to be returned. */
940 /* If we've looped all the way around without finding any
941 eligible frames, return the original frame. */
945 /* Let minibuf decide if this frame is acceptable. */
948 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
951 else if (EQ (minibuf
, Qvisible
))
953 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
954 if (FRAME_VISIBLE_P (XFRAME (f
)))
957 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
959 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
960 if (FRAME_VISIBLE_P (XFRAME (f
))
961 || FRAME_ICONIFIED_P (XFRAME (f
)))
964 else if (WINDOWP (minibuf
))
966 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
967 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
968 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
969 FRAME_FOCUS_FRAME (XFRAME (f
))))
981 /* Return the previous frame in the frame list before FRAME.
982 If MINIBUF is nil, exclude minibuffer-only frames.
983 If MINIBUF is a window, include only its own frame
984 and any frame now using that window as the minibuffer.
985 If MINIBUF is `visible', include all visible frames.
986 If MINIBUF is 0, include all visible and iconified frames.
987 Otherwise, include all frames. */
990 prev_frame (frame
, minibuf
)
997 /* There must always be at least one frame in Vframe_list. */
998 if (! CONSP (Vframe_list
))
1002 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1010 if (EQ (frame
, f
) && !NILP (prev
))
1013 if (FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1015 /* Decide whether this frame is eligible to be returned,
1016 according to minibuf. */
1019 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1022 else if (WINDOWP (minibuf
))
1024 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1025 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1026 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1027 FRAME_FOCUS_FRAME (XFRAME (f
))))
1030 else if (EQ (minibuf
, Qvisible
))
1032 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1033 if (FRAME_VISIBLE_P (XFRAME (f
)))
1036 else if (XFASTINT (minibuf
) == 0)
1038 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1039 if (FRAME_VISIBLE_P (XFRAME (f
))
1040 || FRAME_ICONIFIED_P (XFRAME (f
)))
1048 /* We've scanned the entire list. */
1050 /* We went through the whole frame list without finding a single
1051 acceptable frame. Return the original frame. */
1054 /* There were no acceptable frames in the list before FRAME; otherwise,
1055 we would have returned directly from the loop. Since PREV is the last
1056 acceptable frame in the list, return it. */
1061 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1062 "Return the next frame in the frame list after FRAME.\n\
1063 It considers only frames on the same terminal as FRAME.\n\
1064 By default, skip minibuffer-only frames.\n\
1065 If omitted, FRAME defaults to the selected frame.\n\
1066 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
1067 If MINIFRAME is a window, include only its own frame\n\
1068 and any frame now using that window as the minibuffer.\n\
1069 If MINIFRAME is `visible', include all visible frames.\n\
1070 If MINIFRAME is 0, include all visible and iconified frames.\n\
1071 Otherwise, include all frames.")
1073 Lisp_Object frame
, miniframe
;
1076 frame
= selected_frame
;
1078 CHECK_LIVE_FRAME (frame
, 0);
1079 return next_frame (frame
, miniframe
);
1082 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1083 "Return the previous frame in the frame list before FRAME.\n\
1084 It considers only frames on the same terminal as FRAME.\n\
1085 By default, skip minibuffer-only frames.\n\
1086 If omitted, FRAME defaults to the selected frame.\n\
1087 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
1088 If MINIFRAME is a window, include only its own frame\n\
1089 and any frame now using that window as the minibuffer.\n\
1090 If MINIFRAME is `visible', include all visible frames.\n\
1091 If MINIFRAME is 0, include all visible and iconified frames.\n\
1092 Otherwise, include all frames.")
1094 Lisp_Object frame
, miniframe
;
1097 frame
= selected_frame
;
1098 CHECK_LIVE_FRAME (frame
, 0);
1099 return prev_frame (frame
, miniframe
);
1102 /* Return 1 if it is ok to delete frame F;
1103 0 if all frames aside from F are invisible.
1104 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1107 other_visible_frames (f
)
1110 /* We know the selected frame is visible,
1111 so if F is some other frame, it can't be the sole visible one. */
1112 if (f
== SELECTED_FRAME ())
1117 for (frames
= Vframe_list
;
1119 frames
= XCDR (frames
))
1123 this = XCAR (frames
);
1124 /* Verify that the frame's window still exists
1125 and we can still talk to it. And note any recent change
1127 #ifdef HAVE_WINDOW_SYSTEM
1128 if (FRAME_WINDOW_P (XFRAME (this)))
1130 x_sync (XFRAME (this));
1131 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1135 if (FRAME_VISIBLE_P (XFRAME (this))
1136 || FRAME_ICONIFIED_P (XFRAME (this))
1137 /* Allow deleting the terminal frame when at least
1138 one X frame exists! */
1139 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1147 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1148 "Delete FRAME, permanently eliminating it from use.\n\
1149 If omitted, FRAME defaults to the selected frame.\n\
1150 A frame may not be deleted if its minibuffer is used by other frames.\n\
1151 Normally, you may not delete a frame if all other frames are invisible,\n\
1152 but if the second optional argument FORCE is non-nil, you may do so.")
1154 Lisp_Object frame
, force
;
1157 struct frame
*sf
= SELECTED_FRAME ();
1158 int minibuffer_selected
;
1160 if (EQ (frame
, Qnil
))
1163 XSETFRAME (frame
, f
);
1167 CHECK_FRAME (frame
, 0);
1171 if (! FRAME_LIVE_P (f
))
1174 if (NILP (force
) && !other_visible_frames (f
))
1175 error ("Attempt to delete the sole visible or iconified frame");
1178 /* This is a nice idea, but x_connection_closed needs to be able
1179 to delete the last frame, if it is gone. */
1180 if (NILP (XCDR (Vframe_list
)))
1181 error ("Attempt to delete the only frame");
1184 /* Does this frame have a minibuffer, and is it the surrogate
1185 minibuffer for any other frame? */
1186 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1190 for (frames
= Vframe_list
;
1192 frames
= XCDR (frames
))
1195 this = XCAR (frames
);
1197 if (! EQ (this, frame
)
1199 WINDOW_FRAME (XWINDOW
1200 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1201 error ("Attempt to delete a surrogate minibuffer frame");
1205 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1207 /* Don't let the frame remain selected. */
1210 Lisp_Object tail
, frame1
;
1212 /* Look for another visible frame on the same terminal. */
1213 frame1
= next_frame (frame
, Qvisible
);
1215 /* If there is none, find *some* other frame. */
1216 if (NILP (frame1
) || EQ (frame1
, frame
))
1218 FOR_EACH_FRAME (tail
, frame1
)
1220 if (! EQ (frame
, frame1
))
1225 do_switch_frame (frame1
, Qnil
, 0);
1226 sf
= SELECTED_FRAME ();
1229 /* Don't allow minibuf_window to remain on a deleted frame. */
1230 if (EQ (f
->minibuffer_window
, minibuf_window
))
1232 Fset_window_buffer (sf
->minibuffer_window
,
1233 XWINDOW (minibuf_window
)->buffer
);
1234 minibuf_window
= sf
->minibuffer_window
;
1236 /* If the dying minibuffer window was selected,
1237 select the new one. */
1238 if (minibuffer_selected
)
1239 Fselect_window (minibuf_window
);
1242 /* Don't let echo_area_window to remain on a deleted frame. */
1243 if (EQ (f
->minibuffer_window
, echo_area_window
))
1244 echo_area_window
= sf
->minibuffer_window
;
1246 /* Clear any X selections for this frame. */
1247 #ifdef HAVE_X_WINDOWS
1249 x_clear_frame_selections (f
);
1253 This function must be called before the window tree of the
1254 frame is deleted because windows contain dynamically allocated
1258 /* Mark all the windows that used to be on FRAME as deleted, and then
1259 remove the reference to them. */
1260 delete_all_subwindows (XWINDOW (f
->root_window
));
1261 f
->root_window
= Qnil
;
1263 Vframe_list
= Fdelq (frame
, Vframe_list
);
1264 FRAME_SET_VISIBLE (f
, 0);
1268 if (FRAME_INSERT_COST (f
))
1269 xfree (FRAME_INSERT_COST (f
));
1270 if (FRAME_DELETEN_COST (f
))
1271 xfree (FRAME_DELETEN_COST (f
));
1272 if (FRAME_INSERTN_COST (f
))
1273 xfree (FRAME_INSERTN_COST (f
));
1274 if (FRAME_DELETE_COST (f
))
1275 xfree (FRAME_DELETE_COST (f
));
1276 if (FRAME_MESSAGE_BUF (f
))
1277 xfree (FRAME_MESSAGE_BUF (f
));
1279 /* Since some events are handled at the interrupt level, we may get
1280 an event for f at any time; if we zero out the frame's display
1281 now, then we may trip up the event-handling code. Instead, we'll
1282 promise that the display of the frame must be valid until we have
1283 called the window-system-dependent frame destruction routine. */
1285 /* I think this should be done with a hook. */
1286 #ifdef HAVE_WINDOW_SYSTEM
1287 if (FRAME_WINDOW_P (f
))
1288 x_destroy_window (f
);
1291 /* Done by x_destroy_window above already */
1294 if (FRAME_MAC_P (f
))
1295 DisposeMacWindow (f
->output_data
.mac
);
1299 f
->output_data
.nothing
= 0;
1301 /* If we've deleted the last_nonminibuf_frame, then try to find
1303 if (f
== last_nonminibuf_frame
)
1307 last_nonminibuf_frame
= 0;
1309 for (frames
= Vframe_list
;
1311 frames
= XCDR (frames
))
1313 f
= XFRAME (XCAR (frames
));
1314 if (!FRAME_MINIBUF_ONLY_P (f
))
1316 last_nonminibuf_frame
= f
;
1322 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1323 find another one. Prefer minibuffer-only frames, but also notice
1324 frames with other windows. */
1325 if (EQ (frame
, FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
))
1329 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1330 Lisp_Object frame_with_minibuf
;
1331 /* Some frame we found on the same kboard, or nil if there are none. */
1332 Lisp_Object frame_on_same_kboard
;
1334 frame_on_same_kboard
= Qnil
;
1335 frame_with_minibuf
= Qnil
;
1337 for (frames
= Vframe_list
;
1339 frames
= XCDR (frames
))
1344 this = XCAR (frames
);
1349 /* Consider only frames on the same kboard
1350 and only those with minibuffers. */
1351 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
)
1352 && FRAME_HAS_MINIBUF_P (f1
))
1354 frame_with_minibuf
= this;
1355 if (FRAME_MINIBUF_ONLY_P (f1
))
1359 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1360 frame_on_same_kboard
= this;
1363 if (!NILP (frame_on_same_kboard
))
1365 /* We know that there must be some frame with a minibuffer out
1366 there. If this were not true, all of the frames present
1367 would have to be minibufferless, which implies that at some
1368 point their minibuffer frames must have been deleted, but
1369 that is prohibited at the top; you can't delete surrogate
1370 minibuffer frames. */
1371 if (NILP (frame_with_minibuf
))
1374 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1377 /* No frames left on this kboard--say no minibuffer either. */
1378 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= Qnil
;
1381 /* Cause frame titles to update--necessary if we now have just one frame. */
1382 update_mode_lines
= 1;
1387 /* Return mouse position in character cell units. */
1389 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1390 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
1391 The position is given in character cells, where (0, 0) is the\n\
1392 upper-left corner.\n\
1393 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
1394 to read the mouse position, it returns the selected frame for FRAME\n\
1395 and nil for X and Y.\n\
1396 Runs the abnormal hook `mouse-position-function' with the normal return\n\
1397 value as argument.")
1401 Lisp_Object lispy_dummy
;
1402 enum scroll_bar_part party_dummy
;
1403 Lisp_Object x
, y
, retval
;
1405 unsigned long long_dummy
;
1406 struct gcpro gcpro1
;
1408 f
= SELECTED_FRAME ();
1412 /* It's okay for the hook to refrain from storing anything. */
1413 if (mouse_position_hook
)
1414 (*mouse_position_hook
) (&f
, -1,
1415 &lispy_dummy
, &party_dummy
,
1422 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1427 XSETFRAME (lispy_dummy
, f
);
1428 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1430 if (!NILP (Vmouse_position_function
))
1431 retval
= call1 (Vmouse_position_function
, retval
);
1432 RETURN_UNGCPRO (retval
);
1435 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1436 Smouse_pixel_position
, 0, 0, 0,
1437 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
1438 The position is given in pixel units, where (0, 0) is the\n\
1439 upper-left corner.\n\
1440 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
1441 to read the mouse position, it returns the selected frame for FRAME\n\
1442 and nil for X and Y.")
1446 Lisp_Object lispy_dummy
;
1447 enum scroll_bar_part party_dummy
;
1449 unsigned long long_dummy
;
1451 f
= SELECTED_FRAME ();
1455 /* It's okay for the hook to refrain from storing anything. */
1456 if (mouse_position_hook
)
1457 (*mouse_position_hook
) (&f
, -1,
1458 &lispy_dummy
, &party_dummy
,
1462 XSETFRAME (lispy_dummy
, f
);
1463 return Fcons (lispy_dummy
, Fcons (x
, y
));
1466 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1467 "Move the mouse pointer to the center of character cell (X,Y) in FRAME.\n\
1468 Coordinates are relative to the frame, not a window,\n\
1469 so the coordinates of the top left character in the frame\n\
1470 may be nonzero due to left-hand scroll bars or the menu bar.\n\
1472 This function is a no-op for an X frame that is not visible.\n\
1473 If you have just created a frame, you must wait for it to become visible\n\
1474 before calling this function on it, like this.\n\
1475 (while (not (frame-visible-p frame)) (sleep-for .5))")
1477 Lisp_Object frame
, x
, y
;
1479 CHECK_LIVE_FRAME (frame
, 0);
1480 CHECK_NUMBER (x
, 2);
1481 CHECK_NUMBER (y
, 1);
1483 /* I think this should be done with a hook. */
1484 #ifdef HAVE_WINDOW_SYSTEM
1485 if (FRAME_WINDOW_P (XFRAME (frame
)))
1486 /* Warping the mouse will cause enternotify and focus events. */
1487 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1489 #if defined (MSDOS) && defined (HAVE_MOUSE)
1490 if (FRAME_MSDOS_P (XFRAME (frame
)))
1492 Fselect_frame (frame
, Qnil
);
1493 mouse_moveto (XINT (x
), XINT (y
));
1501 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1502 Sset_mouse_pixel_position
, 3, 3, 0,
1503 "Move the mouse pointer to pixel position (X,Y) in FRAME.\n\
1504 Note, this is a no-op for an X frame that is not visible.\n\
1505 If you have just created a frame, you must wait for it to become visible\n\
1506 before calling this function on it, like this.\n\
1507 (while (not (frame-visible-p frame)) (sleep-for .5))")
1509 Lisp_Object frame
, x
, y
;
1511 CHECK_LIVE_FRAME (frame
, 0);
1512 CHECK_NUMBER (x
, 2);
1513 CHECK_NUMBER (y
, 1);
1515 /* I think this should be done with a hook. */
1516 #ifdef HAVE_WINDOW_SYSTEM
1517 if (FRAME_WINDOW_P (XFRAME (frame
)))
1518 /* Warping the mouse will cause enternotify and focus events. */
1519 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1521 #if defined (MSDOS) && defined (HAVE_MOUSE)
1522 if (FRAME_MSDOS_P (XFRAME (frame
)))
1524 Fselect_frame (frame
, Qnil
);
1525 mouse_moveto (XINT (x
), XINT (y
));
1533 static void make_frame_visible_1
P_ ((Lisp_Object
));
1535 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1537 "Make the frame FRAME visible (assuming it is an X-window).\n\
1538 If omitted, FRAME defaults to the currently selected frame.")
1543 frame
= selected_frame
;
1545 CHECK_LIVE_FRAME (frame
, 0);
1547 /* I think this should be done with a hook. */
1548 #ifdef HAVE_WINDOW_SYSTEM
1549 if (FRAME_WINDOW_P (XFRAME (frame
)))
1551 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1552 x_make_frame_visible (XFRAME (frame
));
1556 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1558 /* Make menu bar update for the Buffers and Frams menus. */
1559 windows_or_buffers_changed
++;
1564 /* Update the display_time slot of the buffers shown in WINDOW
1565 and all its descendents. */
1568 make_frame_visible_1 (window
)
1573 for (;!NILP (window
); window
= w
->next
)
1575 w
= XWINDOW (window
);
1577 if (!NILP (w
->buffer
))
1578 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1580 if (!NILP (w
->vchild
))
1581 make_frame_visible_1 (w
->vchild
);
1582 if (!NILP (w
->hchild
))
1583 make_frame_visible_1 (w
->hchild
);
1587 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1589 "Make the frame FRAME invisible (assuming it is an X-window).\n\
1590 If omitted, FRAME defaults to the currently selected frame.\n\
1591 Normally you may not make FRAME invisible if all other frames are invisible,\n\
1592 but if the second optional argument FORCE is non-nil, you may do so.")
1594 Lisp_Object frame
, force
;
1597 frame
= selected_frame
;
1599 CHECK_LIVE_FRAME (frame
, 0);
1601 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1602 error ("Attempt to make invisible the sole visible or iconified frame");
1604 #if 0 /* This isn't logically necessary, and it can do GC. */
1605 /* Don't let the frame remain selected. */
1606 if (EQ (frame
, selected_frame
))
1607 do_switch_frame (next_frame (frame
, Qt
), Qnil
, 0)
1610 /* Don't allow minibuf_window to remain on a deleted frame. */
1611 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1613 struct frame
*sf
= XFRAME (selected_frame
);
1614 Fset_window_buffer (sf
->minibuffer_window
,
1615 XWINDOW (minibuf_window
)->buffer
);
1616 minibuf_window
= sf
->minibuffer_window
;
1619 /* I think this should be done with a hook. */
1620 #ifdef HAVE_WINDOW_SYSTEM
1621 if (FRAME_WINDOW_P (XFRAME (frame
)))
1622 x_make_frame_invisible (XFRAME (frame
));
1625 /* Make menu bar update for the Buffers and Frams menus. */
1626 windows_or_buffers_changed
++;
1631 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1633 "Make the frame FRAME into an icon.\n\
1634 If omitted, FRAME defaults to the currently selected frame.")
1639 frame
= selected_frame
;
1641 CHECK_LIVE_FRAME (frame
, 0);
1643 #if 0 /* This isn't logically necessary, and it can do GC. */
1644 /* Don't let the frame remain selected. */
1645 if (EQ (frame
, selected_frame
))
1646 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1649 /* Don't allow minibuf_window to remain on a deleted frame. */
1650 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1652 struct frame
*sf
= XFRAME (selected_frame
);
1653 Fset_window_buffer (sf
->minibuffer_window
,
1654 XWINDOW (minibuf_window
)->buffer
);
1655 minibuf_window
= sf
->minibuffer_window
;
1658 /* I think this should be done with a hook. */
1659 #ifdef HAVE_WINDOW_SYSTEM
1660 if (FRAME_WINDOW_P (XFRAME (frame
)))
1661 x_iconify_frame (XFRAME (frame
));
1664 /* Make menu bar update for the Buffers and Frams menus. */
1665 windows_or_buffers_changed
++;
1670 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1672 "Return t if FRAME is now \"visible\" (actually in use for display).\n\
1673 A frame that is not \"visible\" is not updated and, if it works through\n\
1674 a window system, it may not show at all.\n\
1675 Return the symbol `icon' if frame is visible only as an icon.")
1679 CHECK_LIVE_FRAME (frame
, 0);
1681 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1683 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1685 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1690 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1692 "Return a list of all frames now \"visible\" (being updated).")
1695 Lisp_Object tail
, frame
;
1700 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1702 frame
= XCAR (tail
);
1703 if (!FRAMEP (frame
))
1706 if (FRAME_VISIBLE_P (f
))
1707 value
= Fcons (frame
, value
);
1713 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1714 "Bring FRAME to the front, so it occludes any frames it overlaps.\n\
1715 If FRAME is invisible, make it visible.\n\
1716 If you don't specify a frame, the selected frame is used.\n\
1717 If Emacs is displaying on an ordinary terminal or some other device which\n\
1718 doesn't support multiple overlapping frames, this function does nothing.")
1723 frame
= selected_frame
;
1725 CHECK_LIVE_FRAME (frame
, 0);
1727 /* Do like the documentation says. */
1728 Fmake_frame_visible (frame
);
1730 if (frame_raise_lower_hook
)
1731 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1736 /* Should we have a corresponding function called Flower_Power? */
1737 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1738 "Send FRAME to the back, so it is occluded by any frames that overlap it.\n\
1739 If you don't specify a frame, the selected frame is used.\n\
1740 If Emacs is displaying on an ordinary terminal or some other device which\n\
1741 doesn't support multiple overlapping frames, this function does nothing.")
1746 frame
= selected_frame
;
1748 CHECK_LIVE_FRAME (frame
, 0);
1750 if (frame_raise_lower_hook
)
1751 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1757 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1759 "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
1760 In other words, switch-frame events caused by events in FRAME will\n\
1761 request a switch to FOCUS-FRAME, and `last-event-frame' will be\n\
1762 FOCUS-FRAME after reading an event typed at FRAME.\n\
1764 If FOCUS-FRAME is omitted or nil, any existing redirection is\n\
1765 cancelled, and the frame again receives its own keystrokes.\n\
1767 Focus redirection is useful for temporarily redirecting keystrokes to\n\
1768 a surrogate minibuffer frame when a frame doesn't have its own\n\
1769 minibuffer window.\n\
1771 A frame's focus redirection can be changed by select-frame. If frame\n\
1772 FOO is selected, and then a different frame BAR is selected, any\n\
1773 frames redirecting their focus to FOO are shifted to redirect their\n\
1774 focus to BAR. This allows focus redirection to work properly when the\n\
1775 user switches from one frame to another using `select-window'.\n\
1777 This means that a frame whose focus is redirected to itself is treated\n\
1778 differently from a frame whose focus is redirected to nil; the former\n\
1779 is affected by select-frame, while the latter is not.\n\
1781 The redirection lasts until `redirect-frame-focus' is called to change it.")
1782 (frame
, focus_frame
)
1783 Lisp_Object frame
, focus_frame
;
1785 /* Note that we don't check for a live frame here. It's reasonable
1786 to redirect the focus of a frame you're about to delete, if you
1787 know what other frame should receive those keystrokes. */
1788 CHECK_FRAME (frame
, 0);
1790 if (! NILP (focus_frame
))
1791 CHECK_LIVE_FRAME (focus_frame
, 1);
1793 XFRAME (frame
)->focus_frame
= focus_frame
;
1795 if (frame_rehighlight_hook
)
1796 (*frame_rehighlight_hook
) (XFRAME (frame
));
1802 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1803 "Return the frame to which FRAME's keystrokes are currently being sent.\n\
1804 This returns nil if FRAME's focus is not redirected.\n\
1805 See `redirect-frame-focus'.")
1809 CHECK_LIVE_FRAME (frame
, 0);
1811 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1816 /* Return the value of frame parameter PROP in frame FRAME. */
1819 get_frame_param (frame
, prop
)
1820 register struct frame
*frame
;
1823 register Lisp_Object tem
;
1825 tem
= Fassq (prop
, frame
->param_alist
);
1831 /* Return the buffer-predicate of the selected frame. */
1834 frame_buffer_predicate (frame
)
1837 return XFRAME (frame
)->buffer_predicate
;
1840 /* Return the buffer-list of the selected frame. */
1843 frame_buffer_list (frame
)
1846 return XFRAME (frame
)->buffer_list
;
1849 /* Set the buffer-list of the selected frame. */
1852 set_frame_buffer_list (frame
, list
)
1853 Lisp_Object frame
, list
;
1855 XFRAME (frame
)->buffer_list
= list
;
1858 /* Discard BUFFER from the buffer-list of each frame. */
1861 frames_discard_buffer (buffer
)
1864 Lisp_Object frame
, tail
;
1866 FOR_EACH_FRAME (tail
, frame
)
1868 XFRAME (frame
)->buffer_list
1869 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1873 /* Move BUFFER to the end of the buffer-list of each frame. */
1876 frames_bury_buffer (buffer
)
1879 Lisp_Object frame
, tail
;
1881 FOR_EACH_FRAME (tail
, frame
)
1883 struct frame
*f
= XFRAME (frame
);
1886 found
= Fmemq (buffer
, f
->buffer_list
);
1888 f
->buffer_list
= nconc2 (Fdelq (buffer
, f
->buffer_list
),
1889 Fcons (buffer
, Qnil
));
1893 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1894 If the alist already has an element for PROP, we change it. */
1897 store_in_alist (alistptr
, prop
, val
)
1898 Lisp_Object
*alistptr
, val
;
1901 register Lisp_Object tem
;
1903 tem
= Fassq (prop
, *alistptr
);
1905 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1911 frame_name_fnn_p (str
, len
)
1915 if (len
> 1 && str
[0] == 'F')
1919 strtol (str
+ 1, &end_ptr
, 10);
1921 if (end_ptr
== str
+ len
)
1927 /* Set the name of the terminal frame. Also used by MSDOS frames.
1928 Modeled after x_set_name which is used for WINDOW frames. */
1931 set_term_frame_name (f
, name
)
1935 f
->explicit_name
= ! NILP (name
);
1937 /* If NAME is nil, set the name to F<num>. */
1942 /* Check for no change needed in this very common case
1943 before we do any consing. */
1944 if (frame_name_fnn_p (XSTRING (f
->name
)->data
,
1945 STRING_BYTES (XSTRING (f
->name
))))
1948 terminal_frame_count
++;
1949 sprintf (namebuf
, "F%d", terminal_frame_count
);
1950 name
= build_string (namebuf
);
1954 CHECK_STRING (name
, 0);
1956 /* Don't change the name if it's already NAME. */
1957 if (! NILP (Fstring_equal (name
, f
->name
)))
1960 /* Don't allow the user to set the frame name to F<num>, so it
1961 doesn't clash with the names we generate for terminal frames. */
1962 if (frame_name_fnn_p (XSTRING (name
)->data
, STRING_BYTES (XSTRING (name
))))
1963 error ("Frame names of the form F<num> are usurped by Emacs");
1967 update_mode_lines
= 1;
1971 store_frame_param (f
, prop
, val
)
1973 Lisp_Object prop
, val
;
1975 register Lisp_Object old_alist_elt
;
1977 /* The buffer-alist parameter is stored in a special place and is
1978 not in the alist. */
1979 if (EQ (prop
, Qbuffer_list
))
1981 f
->buffer_list
= val
;
1985 /* If PROP is a symbol which is supposed to have frame-local values,
1986 and it is set up based on this frame, switch to the global
1987 binding. That way, we can create or alter the frame-local binding
1988 without messing up the symbol's status. */
1991 Lisp_Object valcontents
;
1992 valcontents
= XSYMBOL (prop
)->value
;
1993 if ((BUFFER_LOCAL_VALUEP (valcontents
)
1994 || SOME_BUFFER_LOCAL_VALUEP (valcontents
))
1995 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
1996 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
1997 swap_in_global_binding (prop
);
2000 /* Update the frame parameter alist. */
2001 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2002 if (EQ (old_alist_elt
, Qnil
))
2003 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2005 Fsetcdr (old_alist_elt
, val
);
2007 /* Update some other special parameters in their special places
2008 in addition to the alist. */
2010 if (EQ (prop
, Qbuffer_predicate
))
2011 f
->buffer_predicate
= val
;
2013 if (! FRAME_WINDOW_P (f
))
2015 if (EQ (prop
, Qmenu_bar_lines
))
2016 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2017 else if (EQ (prop
, Qname
))
2018 set_term_frame_name (f
, val
);
2021 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2023 if (! MINI_WINDOW_P (XWINDOW (val
)))
2024 error ("Surrogate minibuffer windows must be minibuffer windows.");
2026 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2027 && !EQ (val
, f
->minibuffer_window
))
2028 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2030 /* Install the chosen minibuffer window, with proper buffer. */
2031 f
->minibuffer_window
= val
;
2035 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2036 "Return the parameters-alist of frame FRAME.\n\
2037 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
2038 The meaningful PARMs depend on the kind of frame.\n\
2039 If FRAME is omitted, return information on the currently selected frame.")
2046 struct gcpro gcpro1
;
2048 if (EQ (frame
, Qnil
))
2049 frame
= selected_frame
;
2051 CHECK_FRAME (frame
, 0);
2054 if (!FRAME_LIVE_P (f
))
2057 alist
= Fcopy_alist (f
->param_alist
);
2060 if (!FRAME_WINDOW_P (f
))
2062 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2063 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2065 store_in_alist (&alist
, intern ("foreground-color"),
2066 tty_color_name (f
, fg
));
2067 store_in_alist (&alist
, intern ("background-color"),
2068 tty_color_name (f
, bg
));
2069 store_in_alist (&alist
, intern ("font"),
2070 build_string (FRAME_MSDOS_P (f
)
2072 : FRAME_W32_P (f
) ? "w32term" : "tty"));
2074 store_in_alist (&alist
, Qname
, f
->name
);
2075 height
= (FRAME_NEW_HEIGHT (f
) ? FRAME_NEW_HEIGHT (f
) : FRAME_HEIGHT (f
));
2076 store_in_alist (&alist
, Qheight
, make_number (height
));
2077 width
= (FRAME_NEW_WIDTH (f
) ? FRAME_NEW_WIDTH (f
) : FRAME_WIDTH (f
));
2078 store_in_alist (&alist
, Qwidth
, make_number (width
));
2079 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2080 store_in_alist (&alist
, Qminibuffer
,
2081 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2082 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2083 : FRAME_MINIBUF_WINDOW (f
)));
2084 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2085 store_in_alist (&alist
, Qbuffer_list
,
2086 frame_buffer_list (selected_frame
));
2088 /* I think this should be done with a hook. */
2089 #ifdef HAVE_WINDOW_SYSTEM
2090 if (FRAME_WINDOW_P (f
))
2091 x_report_frame_params (f
, &alist
);
2095 /* This ought to be correct in f->param_alist for an X frame. */
2097 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2098 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2106 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2107 "Return FRAME's value for parameter PARAMETER.\n\
2108 If FRAME is nil, describe the currently selected frame.")
2110 Lisp_Object frame
, parameter
;
2116 frame
= selected_frame
;
2118 CHECK_FRAME (frame
, 0);
2119 CHECK_SYMBOL (parameter
, 1);
2124 if (FRAME_LIVE_P (f
))
2126 if (EQ (parameter
, Qname
))
2128 #ifdef HAVE_X_WINDOWS
2129 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2130 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2131 #endif /* HAVE_X_WINDOWS */
2134 value
= Fassq (parameter
, f
->param_alist
);
2136 value
= XCDR (value
);
2137 else if (EQ (parameter
, Qdisplay_type
)
2138 || EQ (parameter
, Qbackground_mode
))
2139 /* Avoid consing in frequent cases. */
2142 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2150 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2151 Smodify_frame_parameters
, 2, 2, 0,
2152 "Modify the parameters of frame FRAME according to ALIST.\n\
2153 ALIST is an alist of parameters to change and their new values.\n\
2154 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
2155 The meaningful PARMs depend on the kind of frame.\n\
2156 Undefined PARMs are ignored, but stored in the frame's parameter list\n\
2157 so that `frame-parameters' will return them.\n\
2159 The value of frame parameter FOO can also be accessed\n\
2160 as a frame-local binding for the variable FOO, if you have\n\
2161 enabled such bindings for that variable with `make-variable-frame-local'.")
2163 Lisp_Object frame
, alist
;
2166 register Lisp_Object tail
, prop
, val
;
2168 if (EQ (frame
, Qnil
))
2169 frame
= selected_frame
;
2170 CHECK_LIVE_FRAME (frame
, 0);
2173 /* I think this should be done with a hook. */
2174 #ifdef HAVE_WINDOW_SYSTEM
2175 if (FRAME_WINDOW_P (f
))
2176 x_set_frame_parameters (f
, alist
);
2180 if (FRAME_MSDOS_P (f
))
2181 IT_set_frame_parameters (f
, alist
);
2185 if (FRAME_MAC_P (f
))
2186 mac_set_frame_parameters (f
, alist
);
2191 int length
= XINT (Flength (alist
));
2194 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2196 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2198 /* Extract parm names and values into those vectors. */
2201 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2206 parms
[i
] = Fcar (elt
);
2207 values
[i
] = Fcdr (elt
);
2211 /* Now process them in reverse of specified order. */
2212 for (i
--; i
>= 0; i
--)
2216 store_frame_param (f
, prop
, val
);
2223 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2225 "Height in pixels of a line in the font in frame FRAME.\n\
2226 If FRAME is omitted, the selected frame is used.\n\
2227 For a terminal frame, the value is always 1.")
2234 frame
= selected_frame
;
2235 CHECK_FRAME (frame
, 0);
2238 #ifdef HAVE_WINDOW_SYSTEM
2239 if (FRAME_WINDOW_P (f
))
2240 return make_number (x_char_height (f
));
2243 return make_number (1);
2247 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2249 "Width in pixels of characters in the font in frame FRAME.\n\
2250 If FRAME is omitted, the selected frame is used.\n\
2251 The width is the same for all characters, because\n\
2252 currently Emacs supports only fixed-width fonts.\n\
2253 For a terminal screen, the value is always 1.")
2260 frame
= selected_frame
;
2261 CHECK_FRAME (frame
, 0);
2264 #ifdef HAVE_WINDOW_SYSTEM
2265 if (FRAME_WINDOW_P (f
))
2266 return make_number (x_char_width (f
));
2269 return make_number (1);
2272 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2273 Sframe_pixel_height
, 0, 1, 0,
2274 "Return a FRAME's height in pixels.\n\
2275 This counts only the height available for text lines,\n\
2276 not menu bars on window-system Emacs frames.\n\
2277 For a terminal frame, the result really gives the height in characters.\n\
2278 If FRAME is omitted, the selected frame is used.")
2285 frame
= selected_frame
;
2286 CHECK_FRAME (frame
, 0);
2289 #ifdef HAVE_WINDOW_SYSTEM
2290 if (FRAME_WINDOW_P (f
))
2291 return make_number (x_pixel_height (f
));
2294 return make_number (FRAME_HEIGHT (f
));
2297 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2298 Sframe_pixel_width
, 0, 1, 0,
2299 "Return FRAME's width in pixels.\n\
2300 For a terminal frame, the result really gives the width in characters.\n\
2301 If FRAME is omitted, the selected frame is used.")
2308 frame
= selected_frame
;
2309 CHECK_FRAME (frame
, 0);
2312 #ifdef HAVE_WINDOW_SYSTEM
2313 if (FRAME_WINDOW_P (f
))
2314 return make_number (x_pixel_width (f
));
2317 return make_number (FRAME_WIDTH (f
));
2320 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2321 "Specify that the frame FRAME has LINES lines.\n\
2322 Optional third arg non-nil means that redisplay should use LINES lines\n\
2323 but that the idea of the actual height of the frame should not be changed.")
2324 (frame
, lines
, pretend
)
2325 Lisp_Object frame
, lines
, pretend
;
2327 register struct frame
*f
;
2329 CHECK_NUMBER (lines
, 0);
2331 frame
= selected_frame
;
2332 CHECK_LIVE_FRAME (frame
, 0);
2335 /* I think this should be done with a hook. */
2336 #ifdef HAVE_WINDOW_SYSTEM
2337 if (FRAME_WINDOW_P (f
))
2339 if (XINT (lines
) != f
->height
)
2340 x_set_window_size (f
, 1, f
->width
, XINT (lines
));
2341 do_pending_window_change (0);
2345 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2349 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2350 "Specify that the frame FRAME has COLS columns.\n\
2351 Optional third arg non-nil means that redisplay should use COLS columns\n\
2352 but that the idea of the actual width of the frame should not be changed.")
2353 (frame
, cols
, pretend
)
2354 Lisp_Object frame
, cols
, pretend
;
2356 register struct frame
*f
;
2357 CHECK_NUMBER (cols
, 0);
2359 frame
= selected_frame
;
2360 CHECK_LIVE_FRAME (frame
, 0);
2363 /* I think this should be done with a hook. */
2364 #ifdef HAVE_WINDOW_SYSTEM
2365 if (FRAME_WINDOW_P (f
))
2367 if (XINT (cols
) != f
->width
)
2368 x_set_window_size (f
, 1, XINT (cols
), f
->height
);
2369 do_pending_window_change (0);
2373 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2377 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2378 "Sets size of FRAME to COLS by ROWS, measured in characters.")
2380 Lisp_Object frame
, cols
, rows
;
2382 register struct frame
*f
;
2384 CHECK_LIVE_FRAME (frame
, 0);
2385 CHECK_NUMBER (cols
, 2);
2386 CHECK_NUMBER (rows
, 1);
2389 /* I think this should be done with a hook. */
2390 #ifdef HAVE_WINDOW_SYSTEM
2391 if (FRAME_WINDOW_P (f
))
2393 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
2394 || FRAME_NEW_HEIGHT (f
) || FRAME_NEW_WIDTH (f
))
2395 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2396 do_pending_window_change (0);
2400 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2405 DEFUN ("set-frame-position", Fset_frame_position
,
2406 Sset_frame_position
, 3, 3, 0,
2407 "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
2408 This is actually the position of the upper left corner of the frame.\n\
2409 Negative values for XOFFSET or YOFFSET are interpreted relative to\n\
2410 the rightmost or bottommost possible position (that stays within the screen).")
2411 (frame
, xoffset
, yoffset
)
2412 Lisp_Object frame
, xoffset
, yoffset
;
2414 register struct frame
*f
;
2416 CHECK_LIVE_FRAME (frame
, 0);
2417 CHECK_NUMBER (xoffset
, 1);
2418 CHECK_NUMBER (yoffset
, 2);
2421 /* I think this should be done with a hook. */
2422 #ifdef HAVE_WINDOW_SYSTEM
2423 if (FRAME_WINDOW_P (f
))
2424 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2436 staticpro (&Vframe_list
);
2438 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
2439 "The initial frame-object, which represents Emacs's stdout.");
2441 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
2442 "Non-nil if all of emacs is iconified and frame updates are not needed.");
2443 Vemacs_iconified
= Qnil
;
2445 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
2446 "If non-nil, function applied to the normal result of `mouse-position'.\n\
2447 This abnormal hook exists for the benefit of packages like XTerm-mouse\n\
2448 which need to do mouse handling at the Lisp level.");
2449 Vmouse_position_function
= Qnil
;
2451 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
2452 "Minibufferless frames use this frame's minibuffer.\n\
2454 Emacs cannot create minibufferless frames unless this is set to an\n\
2455 appropriate surrogate.\n\
2457 Emacs consults this variable only when creating minibufferless\n\
2458 frames; once the frame is created, it sticks with its assigned\n\
2459 minibuffer, no matter what this variable is set to. This means that\n\
2460 this variable doesn't necessarily say anything meaningful about the\n\
2461 current set of frames, or where the minibuffer is currently being\n\
2464 defsubr (&Sactive_minibuffer_window
);
2466 defsubr (&Sframe_live_p
);
2467 defsubr (&Smake_terminal_frame
);
2468 defsubr (&Shandle_switch_frame
);
2469 defsubr (&Signore_event
);
2470 defsubr (&Sselect_frame
);
2471 defsubr (&Sselected_frame
);
2472 defsubr (&Swindow_frame
);
2473 defsubr (&Sframe_root_window
);
2474 defsubr (&Sframe_first_window
);
2475 defsubr (&Sframe_selected_window
);
2476 defsubr (&Sset_frame_selected_window
);
2477 defsubr (&Sframe_list
);
2478 defsubr (&Snext_frame
);
2479 defsubr (&Sprevious_frame
);
2480 defsubr (&Sdelete_frame
);
2481 defsubr (&Smouse_position
);
2482 defsubr (&Smouse_pixel_position
);
2483 defsubr (&Sset_mouse_position
);
2484 defsubr (&Sset_mouse_pixel_position
);
2486 defsubr (&Sframe_configuration
);
2487 defsubr (&Srestore_frame_configuration
);
2489 defsubr (&Smake_frame_visible
);
2490 defsubr (&Smake_frame_invisible
);
2491 defsubr (&Siconify_frame
);
2492 defsubr (&Sframe_visible_p
);
2493 defsubr (&Svisible_frame_list
);
2494 defsubr (&Sraise_frame
);
2495 defsubr (&Slower_frame
);
2496 defsubr (&Sredirect_frame_focus
);
2497 defsubr (&Sframe_focus
);
2498 defsubr (&Sframe_parameters
);
2499 defsubr (&Sframe_parameter
);
2500 defsubr (&Smodify_frame_parameters
);
2501 defsubr (&Sframe_char_height
);
2502 defsubr (&Sframe_char_width
);
2503 defsubr (&Sframe_pixel_height
);
2504 defsubr (&Sframe_pixel_width
);
2505 defsubr (&Sset_frame_height
);
2506 defsubr (&Sset_frame_width
);
2507 defsubr (&Sset_frame_size
);
2508 defsubr (&Sset_frame_position
);
2514 initial_define_lispy_key (global_map
, "switch-frame", "handle-switch-frame");
2515 initial_define_lispy_key (global_map
, "delete-frame", "handle-delete-frame");
2516 initial_define_lispy_key (global_map
, "iconify-frame", "ignore-event");
2517 initial_define_lispy_key (global_map
, "make-frame-visible", "ignore-event");