1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001
3 Free Software Foundation.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
37 /* These help us bind and responding to switch-frame events. */
41 #ifdef HAVE_WINDOW_SYSTEM
44 #include "termhooks.h"
45 #include "dispextern.h"
53 Lisp_Object Qframe_live_p
;
56 Lisp_Object Qminibuffer
;
57 Lisp_Object Qmodeline
;
60 Lisp_Object Qunsplittable
;
61 Lisp_Object Qmenu_bar_lines
;
62 Lisp_Object Qtool_bar_lines
;
69 Lisp_Object Qbuffer_predicate
;
70 Lisp_Object Qbuffer_list
;
72 Lisp_Object Qdisplay_type
;
73 Lisp_Object Qbackground_mode
;
74 Lisp_Object Qinhibit_default_face_x_resources
;
75 Lisp_Object Qleft_fringe
;
76 Lisp_Object Qright_fringe
;
77 Lisp_Object Qtty_color_mode
;
79 Lisp_Object Vterminal_frame
;
80 Lisp_Object Vdefault_frame_alist
;
81 Lisp_Object Vmouse_position_function
;
82 Lisp_Object Vmouse_highlight
;
85 set_menu_bar_lines_1 (window
, n
)
89 struct window
*w
= XWINDOW (window
);
91 XSETFASTINT (w
->last_modified
, 0);
92 XSETFASTINT (w
->top
, XFASTINT (w
->top
) + n
);
93 XSETFASTINT (w
->height
, XFASTINT (w
->height
) - n
);
95 if (INTEGERP (w
->orig_top
))
96 XSETFASTINT (w
->orig_top
, XFASTINT (w
->orig_top
) + n
);
97 if (INTEGERP (w
->orig_height
))
98 XSETFASTINT (w
->orig_height
, XFASTINT (w
->orig_height
) - n
);
100 /* Handle just the top child in a vertical split. */
101 if (!NILP (w
->vchild
))
102 set_menu_bar_lines_1 (w
->vchild
, n
);
104 /* Adjust all children in a horizontal split. */
105 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
107 w
= XWINDOW (window
);
108 set_menu_bar_lines_1 (window
, n
);
113 set_menu_bar_lines (f
, value
, oldval
)
115 Lisp_Object value
, oldval
;
118 int olines
= FRAME_MENU_BAR_LINES (f
);
120 /* Right now, menu bars don't work properly in minibuf-only frames;
121 most of the commands try to apply themselves to the minibuffer
122 frame itself, and get an error because you can't switch buffers
123 in or split the minibuffer window. */
124 if (FRAME_MINIBUF_ONLY_P (f
))
127 if (INTEGERP (value
))
128 nlines
= XINT (value
);
132 if (nlines
!= olines
)
134 windows_or_buffers_changed
++;
135 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
136 FRAME_MENU_BAR_LINES (f
) = nlines
;
137 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
142 Lisp_Object Vemacs_iconified
;
143 Lisp_Object Vframe_list
;
145 struct x_output tty_display
;
147 extern Lisp_Object Vminibuffer_list
;
148 extern Lisp_Object
get_minibuffer ();
149 extern Lisp_Object
Fhandle_switch_frame ();
150 extern Lisp_Object
Fredirect_frame_focus ();
151 extern Lisp_Object
x_get_focus_frame ();
153 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
154 doc
: /* Return non-nil if OBJECT is a frame.
155 Value is t for a termcap frame (a character-only terminal),
156 `x' for an Emacs frame that is really an X window,
157 `w32' for an Emacs frame that is a window on MS-Windows display,
158 `mac' for an Emacs frame on a Macintosh display,
159 `pc' for a direct-write MS-DOS frame.
160 See also `frame-live-p'. */)
164 if (!FRAMEP (object
))
166 switch (XFRAME (object
)->output_method
)
170 case output_x_window
:
174 case output_msdos_raw
:
183 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
184 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
185 Value is nil if OBJECT is not a live frame. If object is a live
186 frame, the return value indicates what sort of output device it is
187 displayed on. See the documentation of `framep' for possible
192 return ((FRAMEP (object
)
193 && FRAME_LIVE_P (XFRAME (object
)))
203 register struct frame
*f
;
204 register Lisp_Object root_window
;
205 register Lisp_Object mini_window
;
207 f
= allocate_frame ();
208 XSETFRAME (frame
, f
);
210 f
->desired_matrix
= 0;
211 f
->current_matrix
= 0;
214 f
->glyphs_initialized_p
= 0;
215 f
->decode_mode_spec_buffer
= 0;
217 f
->async_visible
= 0;
218 f
->output_data
.nothing
= 0;
220 f
->async_iconified
= 0;
221 f
->wants_modeline
= 1;
226 f
->has_minibuffer
= mini_p
;
227 f
->focus_frame
= Qnil
;
228 f
->explicit_name
= 0;
229 f
->can_have_scroll_bars
= 0;
230 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
231 f
->param_alist
= Qnil
;
232 f
->scroll_bars
= Qnil
;
233 f
->condemned_scroll_bars
= Qnil
;
234 f
->face_alist
= Qnil
;
235 f
->face_cache
= NULL
;
236 f
->menu_bar_items
= Qnil
;
237 f
->menu_bar_vector
= Qnil
;
238 f
->menu_bar_items_used
= 0;
239 f
->buffer_predicate
= Qnil
;
240 f
->buffer_list
= Qnil
;
242 f
->kboard
= initial_kboard
;
246 f
->menu_bar_window
= Qnil
;
247 f
->tool_bar_window
= Qnil
;
248 f
->tool_bar_items
= Qnil
;
249 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
250 f
->n_tool_bar_items
= 0;
252 root_window
= make_window ();
255 mini_window
= make_window ();
256 XWINDOW (root_window
)->next
= mini_window
;
257 XWINDOW (mini_window
)->prev
= root_window
;
258 XWINDOW (mini_window
)->mini_p
= Qt
;
259 XWINDOW (mini_window
)->frame
= frame
;
260 f
->minibuffer_window
= mini_window
;
265 XWINDOW (root_window
)->next
= Qnil
;
266 f
->minibuffer_window
= Qnil
;
269 XWINDOW (root_window
)->frame
= frame
;
272 just so that there is "something there."
273 Correct size will be set up later with change_frame_size. */
275 SET_FRAME_WIDTH (f
, 10);
278 XSETFASTINT (XWINDOW (root_window
)->width
, 10);
279 XSETFASTINT (XWINDOW (root_window
)->height
, (mini_p
? 9 : 10));
283 XSETFASTINT (XWINDOW (mini_window
)->width
, 10);
284 XSETFASTINT (XWINDOW (mini_window
)->top
, 9);
285 XSETFASTINT (XWINDOW (mini_window
)->height
, 1);
288 /* Choose a buffer for the frame's root window. */
292 XWINDOW (root_window
)->buffer
= Qt
;
293 buf
= Fcurrent_buffer ();
294 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
295 a space), try to find another one. */
296 if (XSTRING (Fbuffer_name (buf
))->data
[0] == ' ')
297 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
299 /* Use set_window_buffer, not Fset_window_buffer, and don't let
300 hooks be run by it. The reason is that the whole frame/window
301 arrangement is not yet fully intialized at this point. Windows
302 don't have the right size, glyph matrices aren't initialized
303 etc. Running Lisp functions at this point surely ends in a
305 set_window_buffer (root_window
, buf
, 0);
306 f
->buffer_list
= Fcons (buf
, Qnil
);
311 XWINDOW (mini_window
)->buffer
= Qt
;
312 set_window_buffer (mini_window
,
313 (NILP (Vminibuffer_list
)
315 : Fcar (Vminibuffer_list
)),
319 f
->root_window
= root_window
;
320 f
->selected_window
= root_window
;
321 /* Make sure this window seems more recently used than
322 a newly-created, never-selected window. */
323 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, ++window_select_count
);
328 #ifdef HAVE_WINDOW_SYSTEM
329 /* Make a frame using a separate minibuffer window on another frame.
330 MINI_WINDOW is the minibuffer window to use. nil means use the
331 default (the global minibuffer). */
334 make_frame_without_minibuffer (mini_window
, kb
, display
)
335 register Lisp_Object mini_window
;
339 register struct frame
*f
;
342 if (!NILP (mini_window
))
343 CHECK_LIVE_WINDOW (mini_window
);
346 if (!NILP (mini_window
)
347 && XFRAME (XWINDOW (mini_window
)->frame
)->kboard
!= kb
)
348 error ("frame and minibuffer must be on the same display");
351 /* Make a frame containing just a root window. */
354 if (NILP (mini_window
))
356 /* Use default-minibuffer-frame if possible. */
357 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
358 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
360 Lisp_Object frame_dummy
;
362 XSETFRAME (frame_dummy
, f
);
363 GCPRO1 (frame_dummy
);
364 /* If there's no minibuffer frame to use, create one. */
365 kb
->Vdefault_minibuffer_frame
=
366 call1 (intern ("make-initial-minibuffer-frame"), display
);
370 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
373 f
->minibuffer_window
= mini_window
;
375 /* Make the chosen minibuffer window display the proper minibuffer,
376 unless it is already showing a minibuffer. */
377 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
378 Fset_window_buffer (mini_window
,
379 (NILP (Vminibuffer_list
)
381 : Fcar (Vminibuffer_list
)));
385 /* Make a frame containing only a minibuffer window. */
388 make_minibuffer_frame ()
390 /* First make a frame containing just a root window, no minibuffer. */
392 register struct frame
*f
= make_frame (0);
393 register Lisp_Object mini_window
;
394 register Lisp_Object frame
;
396 XSETFRAME (frame
, f
);
401 f
->wants_modeline
= 0;
402 f
->has_minibuffer
= 1;
404 /* Now label the root window as also being the minibuffer.
405 Avoid infinite looping on the window chain by marking next pointer
408 mini_window
= f
->minibuffer_window
= f
->root_window
;
409 XWINDOW (mini_window
)->mini_p
= Qt
;
410 XWINDOW (mini_window
)->next
= Qnil
;
411 XWINDOW (mini_window
)->prev
= Qnil
;
412 XWINDOW (mini_window
)->frame
= frame
;
414 /* Put the proper buffer in that window. */
416 Fset_window_buffer (mini_window
,
417 (NILP (Vminibuffer_list
)
419 : Fcar (Vminibuffer_list
)));
422 #endif /* HAVE_WINDOW_SYSTEM */
424 /* Construct a frame that refers to the terminal (stdin and stdout). */
426 static int terminal_frame_count
;
429 make_terminal_frame ()
431 register struct frame
*f
;
438 initial_kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
439 init_kboard (initial_kboard
);
440 initial_kboard
->next_kboard
= all_kboards
;
441 all_kboards
= initial_kboard
;
445 /* The first call must initialize Vframe_list. */
446 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
451 XSETFRAME (frame
, f
);
452 Vframe_list
= Fcons (frame
, Vframe_list
);
454 terminal_frame_count
++;
455 sprintf (name
, "F%d", terminal_frame_count
);
456 f
->name
= build_string (name
);
458 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
459 f
->async_visible
= 1; /* Don't let visible be cleared later. */
461 f
->output_data
.x
= &the_only_x_display
;
462 if (!inhibit_window_system
463 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
464 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
466 f
->output_method
= output_msdos_raw
;
467 /* This initialization of foreground and background pixels is
468 only important for the initial frame created in temacs. If
469 we don't do that, we get black background and foreground in
470 the dumped Emacs because the_only_x_display is a static
471 variable, hence it is born all-zeroes, and zero is the code
472 for the black color. Other frames all inherit their pixels
473 from what's already in the_only_x_display. */
474 if ((!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
475 && f
->output_data
.x
->background_pixel
== 0
476 && f
->output_data
.x
->foreground_pixel
== 0)
478 f
->output_data
.x
->background_pixel
= FACE_TTY_DEFAULT_BG_COLOR
;
479 f
->output_data
.x
->foreground_pixel
= FACE_TTY_DEFAULT_FG_COLOR
;
483 f
->output_method
= output_termcap
;
486 f
->output_method
= output_termcap
;
487 f
->output_data
.x
= &tty_display
;
490 make_mac_terminal_frame (f
);
492 f
->output_data
.x
= &tty_display
;
494 #endif /* WINDOWSNT */
498 init_frame_faces (f
);
503 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
505 doc
: /* Create an additional terminal frame.
506 You can create multiple frames on a text-only terminal in this way.
507 Only the selected terminal frame is actually displayed.
508 This function takes one argument, an alist specifying frame parameters.
509 In practice, generally you don't need to specify any parameters.
510 Note that changing the size of one terminal frame automatically affects all. */)
515 Lisp_Object frame
, tem
;
516 struct frame
*sf
= SELECTED_FRAME ();
519 if (sf
->output_method
!= output_msdos_raw
520 && sf
->output_method
!= output_termcap
)
522 #else /* not MSDOS */
525 if (sf
->output_method
!= output_mac
)
526 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
528 if (sf
->output_method
!= output_termcap
)
529 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
531 #endif /* not MSDOS */
533 f
= make_terminal_frame ();
535 change_frame_size (f
, FRAME_HEIGHT (sf
),
536 FRAME_WIDTH (sf
), 0, 0, 0);
539 XSETFRAME (frame
, f
);
540 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
541 Fmodify_frame_parameters (frame
, parms
);
543 /* Make the frame face alist be frame-specific, so that each
544 frame could change its face definitions independently. */
545 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
546 /* Simple Fcopy_alist isn't enough, because we need the contents of
547 the vectors which are the CDRs of associations in face_alist to
548 be copied as well. */
549 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
550 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
555 /* Perform the switch to frame FRAME.
557 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
560 If TRACK is non-zero and the frame that currently has the focus
561 redirects its focus to the selected frame, redirect that focused
562 frame's focus to FRAME instead.
564 FOR_DELETION non-zero means that the selected frame is being
565 deleted, which includes the possibility that the frame's display
569 do_switch_frame (frame
, track
, for_deletion
)
571 int track
, for_deletion
;
573 struct frame
*sf
= SELECTED_FRAME ();
575 /* If FRAME is a switch-frame event, extract the frame we should
578 && EQ (XCAR (frame
), Qswitch_frame
)
579 && CONSP (XCDR (frame
)))
580 frame
= XCAR (XCDR (frame
));
582 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
583 a switch-frame event to arrive after a frame is no longer live,
584 especially when deleting the initial frame during startup. */
586 if (! FRAME_LIVE_P (XFRAME (frame
)))
589 if (sf
== XFRAME (frame
))
592 /* This is too greedy; it causes inappropriate focus redirection
593 that's hard to get rid of. */
595 /* If a frame's focus has been redirected toward the currently
596 selected frame, we should change the redirection to point to the
597 newly selected frame. This means that if the focus is redirected
598 from a minibufferless frame to a surrogate minibuffer frame, we
599 can use `other-window' to switch between all the frames using
600 that minibuffer frame, and the focus redirection will follow us
606 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
610 if (!FRAMEP (XCAR (tail
)))
613 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
615 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
616 Fredirect_frame_focus (XCAR (tail
), frame
);
620 /* Instead, apply it only to the frame we're pointing to. */
621 #ifdef HAVE_WINDOW_SYSTEM
622 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
624 Lisp_Object focus
, xfocus
;
626 xfocus
= x_get_focus_frame (XFRAME (frame
));
629 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
630 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
631 Fredirect_frame_focus (xfocus
, frame
);
634 #endif /* HAVE_X_WINDOWS */
637 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
638 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
640 selected_frame
= frame
;
641 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
642 last_nonminibuf_frame
= XFRAME (selected_frame
);
644 Fselect_window (XFRAME (frame
)->selected_window
);
647 /* Make sure to switch the tty color mode to that of the newly
649 sf
= SELECTED_FRAME ();
650 if (FRAME_TERMCAP_P (sf
))
652 Lisp_Object color_mode_spec
, color_mode
;
654 color_mode_spec
= assq_no_quit (Qtty_color_mode
, sf
->param_alist
);
655 if (CONSP (color_mode_spec
))
656 color_mode
= XCDR (color_mode_spec
);
658 color_mode
= make_number (0);
659 set_tty_color_mode (sf
, color_mode
);
661 #endif /* !WINDOWSNT */
663 /* We want to make sure that the next event generates a frame-switch
664 event to the appropriate frame. This seems kludgy to me, but
665 before you take it out, make sure that evaluating something like
666 (select-window (frame-root-window (new-frame))) doesn't end up
667 with your typing being interpreted in the new frame instead of
668 the one you're actually typing in. */
669 internal_last_event_frame
= Qnil
;
674 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
675 doc
: /* Select the frame FRAME.
676 Subsequent editing commands apply to its selected window.
677 The selection of FRAME lasts until the next time the user does
678 something to select a different frame, or until the next time this
679 function is called. */)
681 Lisp_Object frame
, no_enter
;
683 return do_switch_frame (frame
, 1, 0);
687 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 2, "e",
688 doc
: /* Handle a switch-frame event EVENT.
689 Switch-frame events are usually bound to this function.
690 A switch-frame event tells Emacs that the window manager has requested
691 that the user's events be directed to the frame mentioned in the event.
692 This function selects the selected window of the frame of EVENT.
694 If EVENT is frame object, handle it as if it were a switch-frame event
697 Lisp_Object event
, no_enter
;
699 /* Preserve prefix arg that the command loop just cleared. */
700 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
701 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
702 return do_switch_frame (event
, 0, 0);
705 DEFUN ("ignore-event", Fignore_event
, Signore_event
, 0, 0, "",
706 doc
: /* Do nothing, but preserve any prefix argument already specified.
707 This is a suitable binding for iconify-frame and make-frame-visible. */)
710 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
714 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
715 doc
: /* Return the frame that is now selected. */)
718 return selected_frame
;
721 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
722 doc
: /* Return the frame object that window WINDOW is on. */)
726 CHECK_LIVE_WINDOW (window
);
727 return XWINDOW (window
)->frame
;
730 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
731 doc
: /* Returns the topmost, leftmost window of FRAME.
732 If omitted, FRAME defaults to the currently selected frame. */)
739 w
= SELECTED_FRAME ()->root_window
;
742 CHECK_LIVE_FRAME (frame
);
743 w
= XFRAME (frame
)->root_window
;
745 while (NILP (XWINDOW (w
)->buffer
))
747 if (! NILP (XWINDOW (w
)->hchild
))
748 w
= XWINDOW (w
)->hchild
;
749 else if (! NILP (XWINDOW (w
)->vchild
))
750 w
= XWINDOW (w
)->vchild
;
757 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
758 Sactive_minibuffer_window
, 0, 0, 0,
759 doc
: /* Return the currently active minibuffer window, or nil if none. */)
762 return minibuf_level
? minibuf_window
: Qnil
;
765 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
766 doc
: /* Returns the root-window of FRAME.
767 If omitted, FRAME defaults to the currently selected frame. */)
774 window
= SELECTED_FRAME ()->root_window
;
777 CHECK_LIVE_FRAME (frame
);
778 window
= XFRAME (frame
)->root_window
;
784 DEFUN ("frame-selected-window", Fframe_selected_window
,
785 Sframe_selected_window
, 0, 1, 0,
786 doc
: /* Return the selected window of frame object FRAME.
787 If omitted, FRAME defaults to the currently selected frame. */)
794 window
= SELECTED_FRAME ()->selected_window
;
797 CHECK_LIVE_FRAME (frame
);
798 window
= XFRAME (frame
)->selected_window
;
804 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
805 Sset_frame_selected_window
, 2, 2, 0,
806 doc
: /* Set the selected window of frame object FRAME to WINDOW.
807 If FRAME is nil, the selected frame is used.
808 If FRAME is the selected frame, this makes WINDOW the selected window. */)
810 Lisp_Object frame
, window
;
813 frame
= selected_frame
;
815 CHECK_LIVE_FRAME (frame
);
816 CHECK_LIVE_WINDOW (window
);
818 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
819 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
821 if (EQ (frame
, selected_frame
))
822 return Fselect_window (window
);
824 return XFRAME (frame
)->selected_window
= window
;
827 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
829 doc
: /* Return a list of all frames. */)
833 frames
= Fcopy_sequence (Vframe_list
);
834 #ifdef HAVE_WINDOW_SYSTEM
835 if (FRAMEP (tip_frame
))
836 frames
= Fdelq (tip_frame
, frames
);
841 /* Return the next frame in the frame list after FRAME.
842 If MINIBUF is nil, exclude minibuffer-only frames.
843 If MINIBUF is a window, include only its own frame
844 and any frame now using that window as the minibuffer.
845 If MINIBUF is `visible', include all visible frames.
846 If MINIBUF is 0, include all visible and iconified frames.
847 Otherwise, include all frames. */
850 next_frame (frame
, minibuf
)
857 /* There must always be at least one frame in Vframe_list. */
858 if (! CONSP (Vframe_list
))
861 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
862 forever. Forestall that. */
863 CHECK_LIVE_FRAME (frame
);
866 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
873 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
875 /* Decide whether this frame is eligible to be returned. */
877 /* If we've looped all the way around without finding any
878 eligible frames, return the original frame. */
882 /* Let minibuf decide if this frame is acceptable. */
885 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
888 else if (EQ (minibuf
, Qvisible
))
890 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
891 if (FRAME_VISIBLE_P (XFRAME (f
)))
894 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
896 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
897 if (FRAME_VISIBLE_P (XFRAME (f
))
898 || FRAME_ICONIFIED_P (XFRAME (f
)))
901 else if (WINDOWP (minibuf
))
903 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
904 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
905 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
906 FRAME_FOCUS_FRAME (XFRAME (f
))))
918 /* Return the previous frame in the frame list before FRAME.
919 If MINIBUF is nil, exclude minibuffer-only frames.
920 If MINIBUF is a window, include only its own frame
921 and any frame now using that window as the minibuffer.
922 If MINIBUF is `visible', include all visible frames.
923 If MINIBUF is 0, include all visible and iconified frames.
924 Otherwise, include all frames. */
927 prev_frame (frame
, minibuf
)
934 /* There must always be at least one frame in Vframe_list. */
935 if (! CONSP (Vframe_list
))
939 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
947 if (EQ (frame
, f
) && !NILP (prev
))
950 if (FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
952 /* Decide whether this frame is eligible to be returned,
953 according to minibuf. */
956 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
959 else if (WINDOWP (minibuf
))
961 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
962 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
963 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
964 FRAME_FOCUS_FRAME (XFRAME (f
))))
967 else if (EQ (minibuf
, Qvisible
))
969 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
970 if (FRAME_VISIBLE_P (XFRAME (f
)))
973 else if (XFASTINT (minibuf
) == 0)
975 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
976 if (FRAME_VISIBLE_P (XFRAME (f
))
977 || FRAME_ICONIFIED_P (XFRAME (f
)))
985 /* We've scanned the entire list. */
987 /* We went through the whole frame list without finding a single
988 acceptable frame. Return the original frame. */
991 /* There were no acceptable frames in the list before FRAME; otherwise,
992 we would have returned directly from the loop. Since PREV is the last
993 acceptable frame in the list, return it. */
998 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
999 doc
: /* Return the next frame in the frame list after FRAME.
1000 It considers only frames on the same terminal as FRAME.
1001 By default, skip minibuffer-only frames.
1002 If omitted, FRAME defaults to the selected frame.
1003 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1004 If MINIFRAME is a window, include only its own frame
1005 and any frame now using that window as the minibuffer.
1006 If MINIFRAME is `visible', include all visible frames.
1007 If MINIFRAME is 0, include all visible and iconified frames.
1008 Otherwise, include all frames. */)
1010 Lisp_Object frame
, miniframe
;
1013 frame
= selected_frame
;
1015 CHECK_LIVE_FRAME (frame
);
1016 return next_frame (frame
, miniframe
);
1019 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1020 doc
: /* Return the previous frame in the frame list before FRAME.
1021 It considers only frames on the same terminal as FRAME.
1022 By default, skip minibuffer-only frames.
1023 If omitted, FRAME defaults to the selected frame.
1024 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1025 If MINIFRAME is a window, include only its own frame
1026 and any frame now using that window as the minibuffer.
1027 If MINIFRAME is `visible', include all visible frames.
1028 If MINIFRAME is 0, include all visible and iconified frames.
1029 Otherwise, include all frames. */)
1031 Lisp_Object frame
, miniframe
;
1034 frame
= selected_frame
;
1035 CHECK_LIVE_FRAME (frame
);
1036 return prev_frame (frame
, miniframe
);
1039 /* Return 1 if it is ok to delete frame F;
1040 0 if all frames aside from F are invisible.
1041 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1044 other_visible_frames (f
)
1047 /* We know the selected frame is visible,
1048 so if F is some other frame, it can't be the sole visible one. */
1049 if (f
== SELECTED_FRAME ())
1054 for (frames
= Vframe_list
;
1056 frames
= XCDR (frames
))
1060 this = XCAR (frames
);
1061 /* Verify that the frame's window still exists
1062 and we can still talk to it. And note any recent change
1064 #ifdef HAVE_WINDOW_SYSTEM
1065 if (FRAME_WINDOW_P (XFRAME (this)))
1067 x_sync (XFRAME (this));
1068 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1072 if (FRAME_VISIBLE_P (XFRAME (this))
1073 || FRAME_ICONIFIED_P (XFRAME (this))
1074 /* Allow deleting the terminal frame when at least
1075 one X frame exists! */
1076 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1084 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1085 doc
: /* Delete FRAME, permanently eliminating it from use.
1086 If omitted, FRAME defaults to the selected frame.
1087 A frame may not be deleted if its minibuffer is used by other frames.
1088 Normally, you may not delete a frame if all other frames are invisible,
1089 but if the second optional argument FORCE is non-nil, you may do so.
1091 This function runs `delete-frame-hook' before actually deleting the
1092 frame. The hook is called with one argument FRAME. */)
1094 Lisp_Object frame
, force
;
1097 struct frame
*sf
= SELECTED_FRAME ();
1098 int minibuffer_selected
;
1100 if (EQ (frame
, Qnil
))
1103 XSETFRAME (frame
, f
);
1107 CHECK_FRAME (frame
);
1111 if (! FRAME_LIVE_P (f
))
1114 if (NILP (force
) && !other_visible_frames (f
)
1116 /* Terminal frame deleted before any other visible frames are
1118 && strcmp (XSTRING (f
->name
)->data
, "F1") != 0
1121 error ("Attempt to delete the sole visible or iconified frame");
1124 /* This is a nice idea, but x_connection_closed needs to be able
1125 to delete the last frame, if it is gone. */
1126 if (NILP (XCDR (Vframe_list
)))
1127 error ("Attempt to delete the only frame");
1130 /* Does this frame have a minibuffer, and is it the surrogate
1131 minibuffer for any other frame? */
1132 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1136 for (frames
= Vframe_list
;
1138 frames
= XCDR (frames
))
1141 this = XCAR (frames
);
1143 if (! EQ (this, frame
)
1145 WINDOW_FRAME (XWINDOW
1146 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1147 error ("Attempt to delete a surrogate minibuffer frame");
1151 /* Run `delete-frame-hook'. */
1152 if (!NILP (Vrun_hooks
))
1154 Lisp_Object args
[2];
1155 args
[0] = intern ("delete-frame-hook");
1157 Frun_hook_with_args (2, args
);
1160 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1162 /* Don't let the frame remain selected. */
1165 Lisp_Object tail
, frame1
;
1167 /* Look for another visible frame on the same terminal. */
1168 frame1
= next_frame (frame
, Qvisible
);
1170 /* If there is none, find *some* other frame. */
1171 if (NILP (frame1
) || EQ (frame1
, frame
))
1173 FOR_EACH_FRAME (tail
, frame1
)
1175 if (! EQ (frame
, frame1
))
1180 do_switch_frame (frame1
, 0, 1);
1181 sf
= SELECTED_FRAME ();
1184 /* Don't allow minibuf_window to remain on a deleted frame. */
1185 if (EQ (f
->minibuffer_window
, minibuf_window
))
1187 Fset_window_buffer (sf
->minibuffer_window
,
1188 XWINDOW (minibuf_window
)->buffer
);
1189 minibuf_window
= sf
->minibuffer_window
;
1191 /* If the dying minibuffer window was selected,
1192 select the new one. */
1193 if (minibuffer_selected
)
1194 Fselect_window (minibuf_window
);
1197 /* Don't let echo_area_window to remain on a deleted frame. */
1198 if (EQ (f
->minibuffer_window
, echo_area_window
))
1199 echo_area_window
= sf
->minibuffer_window
;
1201 /* Clear any X selections for this frame. */
1202 #ifdef HAVE_X_WINDOWS
1204 x_clear_frame_selections (f
);
1208 This function must be called before the window tree of the
1209 frame is deleted because windows contain dynamically allocated
1213 /* Mark all the windows that used to be on FRAME as deleted, and then
1214 remove the reference to them. */
1215 delete_all_subwindows (XWINDOW (f
->root_window
));
1216 f
->root_window
= Qnil
;
1218 Vframe_list
= Fdelq (frame
, Vframe_list
);
1219 FRAME_SET_VISIBLE (f
, 0);
1223 if (FRAME_INSERT_COST (f
))
1224 xfree (FRAME_INSERT_COST (f
));
1225 if (FRAME_DELETEN_COST (f
))
1226 xfree (FRAME_DELETEN_COST (f
));
1227 if (FRAME_INSERTN_COST (f
))
1228 xfree (FRAME_INSERTN_COST (f
));
1229 if (FRAME_DELETE_COST (f
))
1230 xfree (FRAME_DELETE_COST (f
));
1231 if (FRAME_MESSAGE_BUF (f
))
1232 xfree (FRAME_MESSAGE_BUF (f
));
1234 /* Since some events are handled at the interrupt level, we may get
1235 an event for f at any time; if we zero out the frame's display
1236 now, then we may trip up the event-handling code. Instead, we'll
1237 promise that the display of the frame must be valid until we have
1238 called the window-system-dependent frame destruction routine. */
1240 /* I think this should be done with a hook. */
1241 #ifdef HAVE_WINDOW_SYSTEM
1242 if (FRAME_WINDOW_P (f
))
1243 x_destroy_window (f
);
1246 f
->output_data
.nothing
= 0;
1248 /* If we've deleted the last_nonminibuf_frame, then try to find
1250 if (f
== last_nonminibuf_frame
)
1254 last_nonminibuf_frame
= 0;
1256 for (frames
= Vframe_list
;
1258 frames
= XCDR (frames
))
1260 f
= XFRAME (XCAR (frames
));
1261 if (!FRAME_MINIBUF_ONLY_P (f
))
1263 last_nonminibuf_frame
= f
;
1269 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1270 find another one. Prefer minibuffer-only frames, but also notice
1271 frames with other windows. */
1272 if (EQ (frame
, FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
))
1276 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1277 Lisp_Object frame_with_minibuf
;
1278 /* Some frame we found on the same kboard, or nil if there are none. */
1279 Lisp_Object frame_on_same_kboard
;
1281 frame_on_same_kboard
= Qnil
;
1282 frame_with_minibuf
= Qnil
;
1284 for (frames
= Vframe_list
;
1286 frames
= XCDR (frames
))
1291 this = XCAR (frames
);
1296 /* Consider only frames on the same kboard
1297 and only those with minibuffers. */
1298 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
)
1299 && FRAME_HAS_MINIBUF_P (f1
))
1301 frame_with_minibuf
= this;
1302 if (FRAME_MINIBUF_ONLY_P (f1
))
1306 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1307 frame_on_same_kboard
= this;
1310 if (!NILP (frame_on_same_kboard
))
1312 /* We know that there must be some frame with a minibuffer out
1313 there. If this were not true, all of the frames present
1314 would have to be minibufferless, which implies that at some
1315 point their minibuffer frames must have been deleted, but
1316 that is prohibited at the top; you can't delete surrogate
1317 minibuffer frames. */
1318 if (NILP (frame_with_minibuf
))
1321 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1324 /* No frames left on this kboard--say no minibuffer either. */
1325 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= Qnil
;
1328 /* Cause frame titles to update--necessary if we now have just one frame. */
1329 update_mode_lines
= 1;
1334 /* Return mouse position in character cell units. */
1336 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1337 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1338 The position is given in character cells, where (0, 0) is the
1340 If Emacs is running on a mouseless terminal or hasn't been programmed
1341 to read the mouse position, it returns the selected frame for FRAME
1342 and nil for X and Y.
1343 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1344 passing the normal return value to that function as an argument,
1345 and returns whatever that function returns. */)
1349 Lisp_Object lispy_dummy
;
1350 enum scroll_bar_part party_dummy
;
1351 Lisp_Object x
, y
, retval
;
1353 unsigned long long_dummy
;
1354 struct gcpro gcpro1
;
1356 f
= SELECTED_FRAME ();
1360 /* It's okay for the hook to refrain from storing anything. */
1361 if (mouse_position_hook
)
1362 (*mouse_position_hook
) (&f
, -1,
1363 &lispy_dummy
, &party_dummy
,
1370 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1375 XSETFRAME (lispy_dummy
, f
);
1376 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1378 if (!NILP (Vmouse_position_function
))
1379 retval
= call1 (Vmouse_position_function
, retval
);
1380 RETURN_UNGCPRO (retval
);
1383 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1384 Smouse_pixel_position
, 0, 0, 0,
1385 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1386 The position is given in pixel units, where (0, 0) is the
1388 If Emacs is running on a mouseless terminal or hasn't been programmed
1389 to read the mouse position, it returns the selected frame for FRAME
1390 and nil for X and Y. */)
1394 Lisp_Object lispy_dummy
;
1395 enum scroll_bar_part party_dummy
;
1397 unsigned long long_dummy
;
1399 f
= SELECTED_FRAME ();
1403 /* It's okay for the hook to refrain from storing anything. */
1404 if (mouse_position_hook
)
1405 (*mouse_position_hook
) (&f
, -1,
1406 &lispy_dummy
, &party_dummy
,
1410 XSETFRAME (lispy_dummy
, f
);
1411 return Fcons (lispy_dummy
, Fcons (x
, y
));
1414 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1415 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1416 Coordinates are relative to the frame, not a window,
1417 so the coordinates of the top left character in the frame
1418 may be nonzero due to left-hand scroll bars or the menu bar.
1420 This function is a no-op for an X frame that is not visible.
1421 If you have just created a frame, you must wait for it to become visible
1422 before calling this function on it, like this.
1423 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1425 Lisp_Object frame
, x
, y
;
1427 CHECK_LIVE_FRAME (frame
);
1431 /* I think this should be done with a hook. */
1432 #ifdef HAVE_WINDOW_SYSTEM
1433 if (FRAME_WINDOW_P (XFRAME (frame
)))
1434 /* Warping the mouse will cause enternotify and focus events. */
1435 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1437 #if defined (MSDOS) && defined (HAVE_MOUSE)
1438 if (FRAME_MSDOS_P (XFRAME (frame
)))
1440 Fselect_frame (frame
, Qnil
);
1441 mouse_moveto (XINT (x
), XINT (y
));
1449 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1450 Sset_mouse_pixel_position
, 3, 3, 0,
1451 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1452 Note, this is a no-op for an X frame that is not visible.
1453 If you have just created a frame, you must wait for it to become visible
1454 before calling this function on it, like this.
1455 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1457 Lisp_Object frame
, x
, y
;
1459 CHECK_LIVE_FRAME (frame
);
1463 /* I think this should be done with a hook. */
1464 #ifdef HAVE_WINDOW_SYSTEM
1465 if (FRAME_WINDOW_P (XFRAME (frame
)))
1466 /* Warping the mouse will cause enternotify and focus events. */
1467 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1469 #if defined (MSDOS) && defined (HAVE_MOUSE)
1470 if (FRAME_MSDOS_P (XFRAME (frame
)))
1472 Fselect_frame (frame
, Qnil
);
1473 mouse_moveto (XINT (x
), XINT (y
));
1481 static void make_frame_visible_1
P_ ((Lisp_Object
));
1483 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1485 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1486 If omitted, FRAME defaults to the currently selected frame. */)
1491 frame
= selected_frame
;
1493 CHECK_LIVE_FRAME (frame
);
1495 /* I think this should be done with a hook. */
1496 #ifdef HAVE_WINDOW_SYSTEM
1497 if (FRAME_WINDOW_P (XFRAME (frame
)))
1499 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1500 x_make_frame_visible (XFRAME (frame
));
1504 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1506 /* Make menu bar update for the Buffers and Frames menus. */
1507 windows_or_buffers_changed
++;
1512 /* Update the display_time slot of the buffers shown in WINDOW
1513 and all its descendents. */
1516 make_frame_visible_1 (window
)
1521 for (;!NILP (window
); window
= w
->next
)
1523 w
= XWINDOW (window
);
1525 if (!NILP (w
->buffer
))
1526 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1528 if (!NILP (w
->vchild
))
1529 make_frame_visible_1 (w
->vchild
);
1530 if (!NILP (w
->hchild
))
1531 make_frame_visible_1 (w
->hchild
);
1535 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1537 doc
: /* Make the frame FRAME invisible (assuming it is an X window).
1538 If omitted, FRAME defaults to the currently selected frame.
1539 Normally you may not make FRAME invisible if all other frames are invisible,
1540 but if the second optional argument FORCE is non-nil, you may do so. */)
1542 Lisp_Object frame
, force
;
1545 frame
= selected_frame
;
1547 CHECK_LIVE_FRAME (frame
);
1549 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1550 error ("Attempt to make invisible the sole visible or iconified frame");
1552 #if 0 /* This isn't logically necessary, and it can do GC. */
1553 /* Don't let the frame remain selected. */
1554 if (EQ (frame
, selected_frame
))
1555 do_switch_frame (next_frame (frame
, Qt
), 0, 0)
1558 /* Don't allow minibuf_window to remain on a deleted frame. */
1559 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1561 struct frame
*sf
= XFRAME (selected_frame
);
1562 Fset_window_buffer (sf
->minibuffer_window
,
1563 XWINDOW (minibuf_window
)->buffer
);
1564 minibuf_window
= sf
->minibuffer_window
;
1567 /* I think this should be done with a hook. */
1568 #ifdef HAVE_WINDOW_SYSTEM
1569 if (FRAME_WINDOW_P (XFRAME (frame
)))
1570 x_make_frame_invisible (XFRAME (frame
));
1573 /* Make menu bar update for the Buffers and Frames menus. */
1574 windows_or_buffers_changed
++;
1579 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1581 doc
: /* Make the frame FRAME into an icon.
1582 If omitted, FRAME defaults to the currently selected frame. */)
1587 frame
= selected_frame
;
1589 CHECK_LIVE_FRAME (frame
);
1591 #if 0 /* This isn't logically necessary, and it can do GC. */
1592 /* Don't let the frame remain selected. */
1593 if (EQ (frame
, selected_frame
))
1594 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1597 /* Don't allow minibuf_window to remain on a deleted frame. */
1598 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1600 struct frame
*sf
= XFRAME (selected_frame
);
1601 Fset_window_buffer (sf
->minibuffer_window
,
1602 XWINDOW (minibuf_window
)->buffer
);
1603 minibuf_window
= sf
->minibuffer_window
;
1606 /* I think this should be done with a hook. */
1607 #ifdef HAVE_WINDOW_SYSTEM
1608 if (FRAME_WINDOW_P (XFRAME (frame
)))
1609 x_iconify_frame (XFRAME (frame
));
1612 /* Make menu bar update for the Buffers and Frames menus. */
1613 windows_or_buffers_changed
++;
1618 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1620 doc
: /* Return t if FRAME is now \"visible\" (actually in use for display).
1621 A frame that is not \"visible\" is not updated and, if it works through
1622 a window system, it may not show at all.
1623 Return the symbol `icon' if frame is visible only as an icon. */)
1627 CHECK_LIVE_FRAME (frame
);
1629 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1631 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1633 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1638 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1640 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1643 Lisp_Object tail
, frame
;
1648 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1650 frame
= XCAR (tail
);
1651 if (!FRAMEP (frame
))
1654 if (FRAME_VISIBLE_P (f
))
1655 value
= Fcons (frame
, value
);
1661 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1662 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1663 If FRAME is invisible, make it visible.
1664 If you don't specify a frame, the selected frame is used.
1665 If Emacs is displaying on an ordinary terminal or some other device which
1666 doesn't support multiple overlapping frames, this function does nothing. */)
1671 frame
= selected_frame
;
1673 CHECK_LIVE_FRAME (frame
);
1675 /* Do like the documentation says. */
1676 Fmake_frame_visible (frame
);
1678 if (frame_raise_lower_hook
)
1679 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1684 /* Should we have a corresponding function called Flower_Power? */
1685 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1686 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1687 If you don't specify a frame, the selected frame is used.
1688 If Emacs is displaying on an ordinary terminal or some other device which
1689 doesn't support multiple overlapping frames, this function does nothing. */)
1694 frame
= selected_frame
;
1696 CHECK_LIVE_FRAME (frame
);
1698 if (frame_raise_lower_hook
)
1699 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1705 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1707 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1708 In other words, switch-frame events caused by events in FRAME will
1709 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1710 FOCUS-FRAME after reading an event typed at FRAME.
1712 If FOCUS-FRAME is omitted or nil, any existing redirection is
1713 cancelled, and the frame again receives its own keystrokes.
1715 Focus redirection is useful for temporarily redirecting keystrokes to
1716 a surrogate minibuffer frame when a frame doesn't have its own
1719 A frame's focus redirection can be changed by select-frame. If frame
1720 FOO is selected, and then a different frame BAR is selected, any
1721 frames redirecting their focus to FOO are shifted to redirect their
1722 focus to BAR. This allows focus redirection to work properly when the
1723 user switches from one frame to another using `select-window'.
1725 This means that a frame whose focus is redirected to itself is treated
1726 differently from a frame whose focus is redirected to nil; the former
1727 is affected by select-frame, while the latter is not.
1729 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1730 (frame
, focus_frame
)
1731 Lisp_Object frame
, focus_frame
;
1733 /* Note that we don't check for a live frame here. It's reasonable
1734 to redirect the focus of a frame you're about to delete, if you
1735 know what other frame should receive those keystrokes. */
1736 CHECK_FRAME (frame
);
1738 if (! NILP (focus_frame
))
1739 CHECK_LIVE_FRAME (focus_frame
);
1741 XFRAME (frame
)->focus_frame
= focus_frame
;
1743 if (frame_rehighlight_hook
)
1744 (*frame_rehighlight_hook
) (XFRAME (frame
));
1750 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1751 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1752 This returns nil if FRAME's focus is not redirected.
1753 See `redirect-frame-focus'. */)
1757 CHECK_LIVE_FRAME (frame
);
1759 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1764 /* Return the value of frame parameter PROP in frame FRAME. */
1767 get_frame_param (frame
, prop
)
1768 register struct frame
*frame
;
1771 register Lisp_Object tem
;
1773 tem
= Fassq (prop
, frame
->param_alist
);
1779 /* Return the buffer-predicate of the selected frame. */
1782 frame_buffer_predicate (frame
)
1785 return XFRAME (frame
)->buffer_predicate
;
1788 /* Return the buffer-list of the selected frame. */
1791 frame_buffer_list (frame
)
1794 return XFRAME (frame
)->buffer_list
;
1797 /* Set the buffer-list of the selected frame. */
1800 set_frame_buffer_list (frame
, list
)
1801 Lisp_Object frame
, list
;
1803 XFRAME (frame
)->buffer_list
= list
;
1806 /* Discard BUFFER from the buffer-list of each frame. */
1809 frames_discard_buffer (buffer
)
1812 Lisp_Object frame
, tail
;
1814 FOR_EACH_FRAME (tail
, frame
)
1816 XFRAME (frame
)->buffer_list
1817 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1821 /* Move BUFFER to the end of the buffer-list of each frame. */
1824 frames_bury_buffer (buffer
)
1827 Lisp_Object frame
, tail
;
1829 FOR_EACH_FRAME (tail
, frame
)
1831 struct frame
*f
= XFRAME (frame
);
1834 found
= Fmemq (buffer
, f
->buffer_list
);
1836 f
->buffer_list
= nconc2 (Fdelq (buffer
, f
->buffer_list
),
1837 Fcons (buffer
, Qnil
));
1841 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1842 If the alist already has an element for PROP, we change it. */
1845 store_in_alist (alistptr
, prop
, val
)
1846 Lisp_Object
*alistptr
, val
;
1849 register Lisp_Object tem
;
1851 tem
= Fassq (prop
, *alistptr
);
1853 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1859 frame_name_fnn_p (str
, len
)
1863 if (len
> 1 && str
[0] == 'F')
1867 strtol (str
+ 1, &end_ptr
, 10);
1869 if (end_ptr
== str
+ len
)
1875 /* Set the name of the terminal frame. Also used by MSDOS frames.
1876 Modeled after x_set_name which is used for WINDOW frames. */
1879 set_term_frame_name (f
, name
)
1883 f
->explicit_name
= ! NILP (name
);
1885 /* If NAME is nil, set the name to F<num>. */
1890 /* Check for no change needed in this very common case
1891 before we do any consing. */
1892 if (frame_name_fnn_p (XSTRING (f
->name
)->data
,
1893 STRING_BYTES (XSTRING (f
->name
))))
1896 terminal_frame_count
++;
1897 sprintf (namebuf
, "F%d", terminal_frame_count
);
1898 name
= build_string (namebuf
);
1902 CHECK_STRING (name
);
1904 /* Don't change the name if it's already NAME. */
1905 if (! NILP (Fstring_equal (name
, f
->name
)))
1908 /* Don't allow the user to set the frame name to F<num>, so it
1909 doesn't clash with the names we generate for terminal frames. */
1910 if (frame_name_fnn_p (XSTRING (name
)->data
, STRING_BYTES (XSTRING (name
))))
1911 error ("Frame names of the form F<num> are usurped by Emacs");
1915 update_mode_lines
= 1;
1919 store_frame_param (f
, prop
, val
)
1921 Lisp_Object prop
, val
;
1923 register Lisp_Object old_alist_elt
;
1925 /* The buffer-alist parameter is stored in a special place and is
1926 not in the alist. */
1927 if (EQ (prop
, Qbuffer_list
))
1929 f
->buffer_list
= val
;
1933 /* If PROP is a symbol which is supposed to have frame-local values,
1934 and it is set up based on this frame, switch to the global
1935 binding. That way, we can create or alter the frame-local binding
1936 without messing up the symbol's status. */
1939 Lisp_Object valcontents
;
1940 valcontents
= SYMBOL_VALUE (prop
);
1941 if ((BUFFER_LOCAL_VALUEP (valcontents
)
1942 || SOME_BUFFER_LOCAL_VALUEP (valcontents
))
1943 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
1944 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
1945 swap_in_global_binding (prop
);
1949 /* The tty color mode needs to be set before the frame's parameter
1950 alist is updated with the new value, because set_tty_color_mode
1951 wants to look at the old mode. */
1952 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
))
1953 set_tty_color_mode (f
, val
);
1956 /* Update the frame parameter alist. */
1957 old_alist_elt
= Fassq (prop
, f
->param_alist
);
1958 if (EQ (old_alist_elt
, Qnil
))
1959 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
1961 Fsetcdr (old_alist_elt
, val
);
1963 /* Update some other special parameters in their special places
1964 in addition to the alist. */
1966 if (EQ (prop
, Qbuffer_predicate
))
1967 f
->buffer_predicate
= val
;
1969 if (! FRAME_WINDOW_P (f
))
1971 if (EQ (prop
, Qmenu_bar_lines
))
1972 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
1973 else if (EQ (prop
, Qname
))
1974 set_term_frame_name (f
, val
);
1977 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
1979 if (! MINI_WINDOW_P (XWINDOW (val
)))
1980 error ("Surrogate minibuffer windows must be minibuffer windows.");
1982 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
1983 && !EQ (val
, f
->minibuffer_window
))
1984 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
1986 /* Install the chosen minibuffer window, with proper buffer. */
1987 f
->minibuffer_window
= val
;
1991 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
1992 doc
: /* Return the parameters-alist of frame FRAME.
1993 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
1994 The meaningful PARMs depend on the kind of frame.
1995 If FRAME is omitted, return information on the currently selected frame. */)
2002 struct gcpro gcpro1
;
2005 frame
= selected_frame
;
2007 CHECK_FRAME (frame
);
2010 if (!FRAME_LIVE_P (f
))
2013 alist
= Fcopy_alist (f
->param_alist
);
2016 if (!FRAME_WINDOW_P (f
))
2018 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2019 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2022 /* If the frame's parameter alist says the colors are
2023 unspecified and reversed, take the frame's background pixel
2024 for foreground and vice versa. */
2025 elt
= Fassq (Qforeground_color
, alist
);
2026 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2028 if (strncmp (XSTRING (XCDR (elt
))->data
,
2030 XSTRING (XCDR (elt
))->size
) == 0)
2031 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2032 else if (strncmp (XSTRING (XCDR (elt
))->data
,
2034 XSTRING (XCDR (elt
))->size
) == 0)
2035 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2038 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2039 elt
= Fassq (Qbackground_color
, alist
);
2040 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2042 if (strncmp (XSTRING (XCDR (elt
))->data
,
2044 XSTRING (XCDR (elt
))->size
) == 0)
2045 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2046 else if (strncmp (XSTRING (XCDR (elt
))->data
,
2048 XSTRING (XCDR (elt
))->size
) == 0)
2049 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2052 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2053 store_in_alist (&alist
, intern ("font"),
2054 build_string (FRAME_MSDOS_P (f
)
2056 : FRAME_W32_P (f
) ? "w32term"
2059 store_in_alist (&alist
, Qname
, f
->name
);
2060 height
= (FRAME_NEW_HEIGHT (f
) ? FRAME_NEW_HEIGHT (f
) : FRAME_HEIGHT (f
));
2061 store_in_alist (&alist
, Qheight
, make_number (height
));
2062 width
= (FRAME_NEW_WIDTH (f
) ? FRAME_NEW_WIDTH (f
) : FRAME_WIDTH (f
));
2063 store_in_alist (&alist
, Qwidth
, make_number (width
));
2064 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2065 store_in_alist (&alist
, Qminibuffer
,
2066 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2067 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2068 : FRAME_MINIBUF_WINDOW (f
)));
2069 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2070 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2072 /* I think this should be done with a hook. */
2073 #ifdef HAVE_WINDOW_SYSTEM
2074 if (FRAME_WINDOW_P (f
))
2075 x_report_frame_params (f
, &alist
);
2079 /* This ought to be correct in f->param_alist for an X frame. */
2081 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2082 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2090 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2091 doc
: /* Return FRAME's value for parameter PARAMETER.
2092 If FRAME is nil, describe the currently selected frame. */)
2094 Lisp_Object frame
, parameter
;
2100 frame
= selected_frame
;
2102 CHECK_FRAME (frame
);
2103 CHECK_SYMBOL (parameter
);
2108 if (FRAME_LIVE_P (f
))
2110 /* Avoid consing in frequent cases. */
2111 if (EQ (parameter
, Qname
))
2113 #ifdef HAVE_X_WINDOWS
2114 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2115 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2116 #endif /* HAVE_X_WINDOWS */
2117 else if (EQ (parameter
, Qbackground_color
)
2118 || EQ (parameter
, Qforeground_color
))
2120 value
= Fassq (parameter
, f
->param_alist
);
2123 value
= XCDR (value
);
2124 /* Fframe_parameters puts the actual fg/bg color names,
2125 even if f->param_alist says otherwise. This is
2126 important when param_alist's notion of colors is
2127 "unspecified". We need to do the same here. */
2128 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2133 if (EQ (parameter
, Qbackground_color
))
2135 color_name
= XSTRING (value
)->data
;
2136 csz
= XSTRING (value
)->size
;
2137 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2138 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2139 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2140 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2142 else if (EQ (parameter
, Qforeground_color
))
2144 color_name
= XSTRING (value
)->data
;
2145 csz
= XSTRING (value
)->size
;
2146 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2147 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2148 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2149 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2154 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2156 else if (EQ (parameter
, Qdisplay_type
)
2157 || EQ (parameter
, Qbackground_mode
))
2158 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2160 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2167 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2168 Smodify_frame_parameters
, 2, 2, 0,
2169 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2170 If FRAME is nil, it defaults to the selected frame.
2171 ALIST is an alist of parameters to change and their new values.
2172 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2173 The meaningful PARMs depend on the kind of frame.
2174 Undefined PARMs are ignored, but stored in the frame's parameter list
2175 so that `frame-parameters' will return them.
2177 The value of frame parameter FOO can also be accessed
2178 as a frame-local binding for the variable FOO, if you have
2179 enabled such bindings for that variable with `make-variable-frame-local'. */)
2181 Lisp_Object frame
, alist
;
2184 register Lisp_Object tail
, prop
, val
;
2185 int count
= BINDING_STACK_SIZE ();
2187 /* Bind this to t to inhibit initialization of the default face from
2188 X resources in face-set-after-frame-default. If we don't inhibit
2189 this, modifying the `font' frame parameter, for example, while
2190 there is a `default.attributeFont' X resource, won't work,
2191 because `default's font is reset to the value of the X resource
2192 and that resets the `font' frame parameter. */
2193 specbind (Qinhibit_default_face_x_resources
, Qt
);
2195 if (EQ (frame
, Qnil
))
2196 frame
= selected_frame
;
2197 CHECK_LIVE_FRAME (frame
);
2200 /* I think this should be done with a hook. */
2201 #ifdef HAVE_WINDOW_SYSTEM
2202 if (FRAME_WINDOW_P (f
))
2203 x_set_frame_parameters (f
, alist
);
2207 if (FRAME_MSDOS_P (f
))
2208 IT_set_frame_parameters (f
, alist
);
2213 int length
= XINT (Flength (alist
));
2216 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2218 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2220 /* Extract parm names and values into those vectors. */
2223 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2228 parms
[i
] = Fcar (elt
);
2229 values
[i
] = Fcdr (elt
);
2233 /* Now process them in reverse of specified order. */
2234 for (i
--; i
>= 0; i
--)
2238 store_frame_param (f
, prop
, val
);
2242 return unbind_to (count
, Qnil
);
2245 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2247 doc
: /* Height in pixels of a line in the font in frame FRAME.
2248 If FRAME is omitted, the selected frame is used.
2249 For a terminal frame, the value is always 1. */)
2256 frame
= selected_frame
;
2257 CHECK_FRAME (frame
);
2260 #ifdef HAVE_WINDOW_SYSTEM
2261 if (FRAME_WINDOW_P (f
))
2262 return make_number (x_char_height (f
));
2265 return make_number (1);
2269 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2271 doc
: /* Width in pixels of characters in the font in frame FRAME.
2272 If FRAME is omitted, the selected frame is used.
2273 The width is the same for all characters, because
2274 currently Emacs supports only fixed-width fonts.
2275 For a terminal screen, the value is always 1. */)
2282 frame
= selected_frame
;
2283 CHECK_FRAME (frame
);
2286 #ifdef HAVE_WINDOW_SYSTEM
2287 if (FRAME_WINDOW_P (f
))
2288 return make_number (x_char_width (f
));
2291 return make_number (1);
2294 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2295 Sframe_pixel_height
, 0, 1, 0,
2296 doc
: /* Return a FRAME's height in pixels.
2297 This counts only the height available for text lines,
2298 not menu bars on window-system Emacs frames.
2299 For a terminal frame, the result really gives the height in characters.
2300 If FRAME is omitted, the selected frame is used. */)
2307 frame
= selected_frame
;
2308 CHECK_FRAME (frame
);
2311 #ifdef HAVE_WINDOW_SYSTEM
2312 if (FRAME_WINDOW_P (f
))
2313 return make_number (x_pixel_height (f
));
2316 return make_number (FRAME_HEIGHT (f
));
2319 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2320 Sframe_pixel_width
, 0, 1, 0,
2321 doc
: /* Return FRAME's width in pixels.
2322 For a terminal frame, the result really gives the width in characters.
2323 If FRAME is omitted, the selected frame is used. */)
2330 frame
= selected_frame
;
2331 CHECK_FRAME (frame
);
2334 #ifdef HAVE_WINDOW_SYSTEM
2335 if (FRAME_WINDOW_P (f
))
2336 return make_number (x_pixel_width (f
));
2339 return make_number (FRAME_WIDTH (f
));
2342 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2343 doc
: /* Specify that the frame FRAME has LINES lines.
2344 Optional third arg non-nil means that redisplay should use LINES lines
2345 but that the idea of the actual height of the frame should not be changed. */)
2346 (frame
, lines
, pretend
)
2347 Lisp_Object frame
, lines
, pretend
;
2349 register struct frame
*f
;
2351 CHECK_NUMBER (lines
);
2353 frame
= selected_frame
;
2354 CHECK_LIVE_FRAME (frame
);
2357 /* I think this should be done with a hook. */
2358 #ifdef HAVE_WINDOW_SYSTEM
2359 if (FRAME_WINDOW_P (f
))
2361 if (XINT (lines
) != f
->height
)
2362 x_set_window_size (f
, 1, f
->width
, XINT (lines
));
2363 do_pending_window_change (0);
2367 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2371 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2372 doc
: /* Specify that the frame FRAME has COLS columns.
2373 Optional third arg non-nil means that redisplay should use COLS columns
2374 but that the idea of the actual width of the frame should not be changed. */)
2375 (frame
, cols
, pretend
)
2376 Lisp_Object frame
, cols
, pretend
;
2378 register struct frame
*f
;
2379 CHECK_NUMBER (cols
);
2381 frame
= selected_frame
;
2382 CHECK_LIVE_FRAME (frame
);
2385 /* I think this should be done with a hook. */
2386 #ifdef HAVE_WINDOW_SYSTEM
2387 if (FRAME_WINDOW_P (f
))
2389 if (XINT (cols
) != f
->width
)
2390 x_set_window_size (f
, 1, XINT (cols
), f
->height
);
2391 do_pending_window_change (0);
2395 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2399 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2400 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2402 Lisp_Object frame
, cols
, rows
;
2404 register struct frame
*f
;
2406 CHECK_LIVE_FRAME (frame
);
2407 CHECK_NUMBER (cols
);
2408 CHECK_NUMBER (rows
);
2411 /* I think this should be done with a hook. */
2412 #ifdef HAVE_WINDOW_SYSTEM
2413 if (FRAME_WINDOW_P (f
))
2415 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
2416 || FRAME_NEW_HEIGHT (f
) || FRAME_NEW_WIDTH (f
))
2417 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2418 do_pending_window_change (0);
2422 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2427 DEFUN ("set-frame-position", Fset_frame_position
,
2428 Sset_frame_position
, 3, 3, 0,
2429 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2430 This is actually the position of the upper left corner of the frame.
2431 Negative values for XOFFSET or YOFFSET are interpreted relative to
2432 the rightmost or bottommost possible position (that stays within the screen). */)
2433 (frame
, xoffset
, yoffset
)
2434 Lisp_Object frame
, xoffset
, yoffset
;
2436 register struct frame
*f
;
2438 CHECK_LIVE_FRAME (frame
);
2439 CHECK_NUMBER (xoffset
);
2440 CHECK_NUMBER (yoffset
);
2443 /* I think this should be done with a hook. */
2444 #ifdef HAVE_WINDOW_SYSTEM
2445 if (FRAME_WINDOW_P (f
))
2446 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2456 Qframep
= intern ("framep");
2457 staticpro (&Qframep
);
2458 Qframe_live_p
= intern ("frame-live-p");
2459 staticpro (&Qframe_live_p
);
2460 Qheight
= intern ("height");
2461 staticpro (&Qheight
);
2462 Qicon
= intern ("icon");
2464 Qminibuffer
= intern ("minibuffer");
2465 staticpro (&Qminibuffer
);
2466 Qmodeline
= intern ("modeline");
2467 staticpro (&Qmodeline
);
2468 Qname
= intern ("name");
2470 Qonly
= intern ("only");
2472 Qunsplittable
= intern ("unsplittable");
2473 staticpro (&Qunsplittable
);
2474 Qmenu_bar_lines
= intern ("menu-bar-lines");
2475 staticpro (&Qmenu_bar_lines
);
2476 Qtool_bar_lines
= intern ("tool-bar-lines");
2477 staticpro (&Qtool_bar_lines
);
2478 Qwidth
= intern ("width");
2479 staticpro (&Qwidth
);
2482 Qw32
= intern ("w32");
2484 Qpc
= intern ("pc");
2486 Qmac
= intern ("mac");
2488 Qvisible
= intern ("visible");
2489 staticpro (&Qvisible
);
2490 Qbuffer_predicate
= intern ("buffer-predicate");
2491 staticpro (&Qbuffer_predicate
);
2492 Qbuffer_list
= intern ("buffer-list");
2493 staticpro (&Qbuffer_list
);
2494 Qtitle
= intern ("title");
2495 staticpro (&Qtitle
);
2496 Qdisplay_type
= intern ("display-type");
2497 staticpro (&Qdisplay_type
);
2498 Qbackground_mode
= intern ("background-mode");
2499 staticpro (&Qbackground_mode
);
2500 Qleft_fringe
= intern ("left-fringe");
2501 staticpro (&Qleft_fringe
);
2502 Qright_fringe
= intern ("right-fringe");
2503 staticpro (&Qright_fringe
);
2504 Qtty_color_mode
= intern ("tty-color-mode");
2505 staticpro (&Qtty_color_mode
);
2507 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
2508 doc
: /* Alist of default values for frame creation.
2509 These may be set in your init file, like this:
2510 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))
2511 These override values given in window system configuration data,
2512 including X Windows' defaults database.
2513 For values specific to the first Emacs frame, see `initial-frame-alist'.
2514 For values specific to the separate minibuffer frame, see
2515 `minibuffer-frame-alist'.
2516 The `menu-bar-lines' element of the list controls whether new frames
2517 have menu bars; `menu-bar-mode' works by altering this element.
2518 Setting this variable does not affect existing frames, only new ones. */);
2519 Vdefault_frame_alist
= Qnil
;
2521 Qinhibit_default_face_x_resources
2522 = intern ("inhibit-default-face-x-resources");
2523 staticpro (&Qinhibit_default_face_x_resources
);
2525 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
2526 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
2528 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
2529 doc
: /* Non-nil if all of emacs is iconified and frame updates are not needed. */);
2530 Vemacs_iconified
= Qnil
;
2532 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
2533 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
2534 `mouse-position' calls this function, passing its usual return value as
2535 argument, and returns whatever this function returns.
2536 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
2537 which need to do mouse handling at the Lisp level. */);
2538 Vmouse_position_function
= Qnil
;
2540 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
2541 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
2542 If the value is an integer, highlighting is only shown after moving the
2543 mouse, while keyboard input turns off the highlight even when the mouse
2544 is over the clickable text. However, the mouse shape still indicates
2545 when the mouse is over clickable text. */);
2546 Vmouse_highlight
= Qt
;
2548 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
2549 doc
: /* Minibufferless frames use this frame's minibuffer.
2551 Emacs cannot create minibufferless frames unless this is set to an
2552 appropriate surrogate.
2554 Emacs consults this variable only when creating minibufferless
2555 frames; once the frame is created, it sticks with its assigned
2556 minibuffer, no matter what this variable is set to. This means that
2557 this variable doesn't necessarily say anything meaningful about the
2558 current set of frames, or where the minibuffer is currently being
2561 This variable is local to the current terminal and cannot be buffer-local. */);
2563 staticpro (&Vframe_list
);
2565 defsubr (&Sactive_minibuffer_window
);
2567 defsubr (&Sframe_live_p
);
2568 defsubr (&Smake_terminal_frame
);
2569 defsubr (&Shandle_switch_frame
);
2570 defsubr (&Signore_event
);
2571 defsubr (&Sselect_frame
);
2572 defsubr (&Sselected_frame
);
2573 defsubr (&Swindow_frame
);
2574 defsubr (&Sframe_root_window
);
2575 defsubr (&Sframe_first_window
);
2576 defsubr (&Sframe_selected_window
);
2577 defsubr (&Sset_frame_selected_window
);
2578 defsubr (&Sframe_list
);
2579 defsubr (&Snext_frame
);
2580 defsubr (&Sprevious_frame
);
2581 defsubr (&Sdelete_frame
);
2582 defsubr (&Smouse_position
);
2583 defsubr (&Smouse_pixel_position
);
2584 defsubr (&Sset_mouse_position
);
2585 defsubr (&Sset_mouse_pixel_position
);
2587 defsubr (&Sframe_configuration
);
2588 defsubr (&Srestore_frame_configuration
);
2590 defsubr (&Smake_frame_visible
);
2591 defsubr (&Smake_frame_invisible
);
2592 defsubr (&Siconify_frame
);
2593 defsubr (&Sframe_visible_p
);
2594 defsubr (&Svisible_frame_list
);
2595 defsubr (&Sraise_frame
);
2596 defsubr (&Slower_frame
);
2597 defsubr (&Sredirect_frame_focus
);
2598 defsubr (&Sframe_focus
);
2599 defsubr (&Sframe_parameters
);
2600 defsubr (&Sframe_parameter
);
2601 defsubr (&Smodify_frame_parameters
);
2602 defsubr (&Sframe_char_height
);
2603 defsubr (&Sframe_char_width
);
2604 defsubr (&Sframe_pixel_height
);
2605 defsubr (&Sframe_pixel_width
);
2606 defsubr (&Sset_frame_height
);
2607 defsubr (&Sset_frame_width
);
2608 defsubr (&Sset_frame_size
);
2609 defsubr (&Sset_frame_position
);