1 /* Generic frame functions.
2 Copyright (C) 1993 Free Software Foundation.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
25 #include "termhooks.h"
32 /* These help us bind and responding to switch-frame events. */
36 Lisp_Object Vemacs_iconified
;
37 Lisp_Object Vframe_list
;
38 Lisp_Object Vterminal_frame
;
39 Lisp_Object Vdefault_minibuffer_frame
;
40 Lisp_Object Vdefault_frame_alist
;
42 /* Evaluate this expression to rebuild the section of syms_of_frame
43 that initializes and staticpros the symbols declared below. Note
44 that Emacs 18 has a bug that keeps C-x C-e from being able to
45 evaluate this expression.
48 ;; Accumulate a list of the symbols we want to initialize from the
49 ;; declarations at the top of the file.
50 (goto-char (point-min))
51 (search-forward "/\*&&& symbols declared here &&&*\/\n")
53 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
55 (cons (buffer-substring (match-beginning 1) (match-end 1))
58 (setq symbol-list (nreverse symbol-list))
59 ;; Delete the section of syms_of_... where we initialize the symbols.
60 (search-forward "\n /\*&&& init symbols here &&&*\/\n")
61 (let ((start (point)))
62 (while (looking-at "^ Q")
64 (kill-region start (point)))
65 ;; Write a new symbol initialization section.
67 (insert (format " %s = intern (\"" (car symbol-list)))
68 (let ((start (point)))
69 (insert (substring (car symbol-list) 1))
70 (subst-char-in-region start (point) ?_ ?-))
71 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
72 (setq symbol-list (cdr symbol-list)))))
75 /*&&& symbols declared here &&&*/
77 Lisp_Object Qframe_live_p
;
80 Lisp_Object Qminibuffer
;
81 Lisp_Object Qmodeline
;
84 Lisp_Object Qunsplittable
;
85 Lisp_Object Qmenu_bar_lines
;
90 extern Lisp_Object Vminibuffer_list
;
91 extern Lisp_Object
get_minibuffer ();
92 extern Lisp_Object
Fhandle_switch_frame ();
93 extern Lisp_Object
Fredirect_frame_focus ();
95 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
96 "Return non-nil if OBJECT is a frame.\n\
97 Value is t for a termcap frame (a character-only terminal),\n\
98 `x' for an Emacs frame that is really an X window.\n\
99 Also see `live-frame-p'.")
103 if (XTYPE (object
) != Lisp_Frame
)
105 switch (XFRAME (object
)->output_method
)
109 case output_x_window
:
116 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
117 "Return non-nil if OBJECT is a frame which has not been deleted.\n\
118 Value is nil if OBJECT is not a live frame. If object is a live\n\
119 frame, the return value indicates what sort of output device it is\n\
120 displayed on. Value is t for a termcap frame (a character-only\n\
121 terminal), `x' for an Emacs frame being displayed in an X window.")
125 return ((FRAMEP (object
)
126 && FRAME_LIVE_P (XFRAME (object
)))
136 register struct frame
*f
;
137 register Lisp_Object root_window
;
138 register Lisp_Object mini_window
;
140 frame
= Fmake_vector (((sizeof (struct frame
) - (sizeof (Lisp_Vector
)
141 - sizeof (Lisp_Object
)))
142 / sizeof (Lisp_Object
)),
144 XSETTYPE (frame
, Lisp_Frame
);
149 f
->current_glyphs
= 0;
150 f
->desired_glyphs
= 0;
152 f
->async_visible
= 0;
153 f
->display
.nothing
= 0;
155 f
->async_iconified
= 0;
156 f
->wants_modeline
= 1;
161 f
->has_minibuffer
= mini_p
;
162 f
->focus_frame
= Qnil
;
163 f
->explicit_name
= 0;
164 f
->can_have_scroll_bars
= 0;
165 f
->has_vertical_scroll_bars
= 0;
166 f
->param_alist
= Qnil
;
167 f
->scroll_bars
= Qnil
;
168 f
->condemned_scroll_bars
= Qnil
;
169 f
->face_alist
= Qnil
;
170 f
->menu_bar_items
= Qnil
;
172 root_window
= make_window ();
175 mini_window
= make_window ();
176 XWINDOW (root_window
)->next
= mini_window
;
177 XWINDOW (mini_window
)->prev
= root_window
;
178 XWINDOW (mini_window
)->mini_p
= Qt
;
179 XWINDOW (mini_window
)->frame
= frame
;
180 f
->minibuffer_window
= mini_window
;
185 XWINDOW (root_window
)->next
= Qnil
;
186 f
->minibuffer_window
= Qnil
;
189 XWINDOW (root_window
)->frame
= frame
;
192 just so that there is "something there."
193 Correct size will be set up later with change_frame_size. */
198 XFASTINT (XWINDOW (root_window
)->width
) = 10;
199 XFASTINT (XWINDOW (root_window
)->height
) = (mini_p
? 9 : 10);
203 XFASTINT (XWINDOW (mini_window
)->width
) = 10;
204 XFASTINT (XWINDOW (mini_window
)->top
) = 9;
205 XFASTINT (XWINDOW (mini_window
)->height
) = 1;
208 /* Choose a buffer for the frame's root window. */
212 XWINDOW (root_window
)->buffer
= Qt
;
213 buf
= Fcurrent_buffer ();
214 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
215 a space), try to find another one. */
216 if (XSTRING (Fbuffer_name (buf
))->data
[0] == ' ')
217 buf
= Fother_buffer (buf
, Qnil
);
218 Fset_window_buffer (root_window
, buf
);
223 XWINDOW (mini_window
)->buffer
= Qt
;
224 Fset_window_buffer (mini_window
,
225 (NILP (Vminibuffer_list
)
227 : Fcar (Vminibuffer_list
)));
230 f
->root_window
= root_window
;
231 f
->selected_window
= root_window
;
232 /* Make sure this window seems more recently used than
233 a newly-created, never-selected window. */
234 XFASTINT (XWINDOW (f
->selected_window
)->use_time
) = ++window_select_count
;
239 /* Make a frame using a separate minibuffer window on another frame.
240 MINI_WINDOW is the minibuffer window to use. nil means use the
241 default (the global minibuffer). */
244 make_frame_without_minibuffer (mini_window
)
245 register Lisp_Object mini_window
;
247 register struct frame
*f
;
249 /* Choose the minibuffer window to use. */
250 if (NILP (mini_window
))
252 if (XTYPE (Vdefault_minibuffer_frame
) != Lisp_Frame
)
253 error ("default-minibuffer-frame must be set when creating minibufferless frames");
254 if (! FRAME_LIVE_P (XFRAME (Vdefault_minibuffer_frame
)))
255 error ("default-minibuffer-frame must be a live frame");
256 mini_window
= XFRAME (Vdefault_minibuffer_frame
)->minibuffer_window
;
260 CHECK_LIVE_WINDOW (mini_window
, 0);
263 /* Make a frame containing just a root window. */
266 /* Install the chosen minibuffer window, with proper buffer. */
267 f
->minibuffer_window
= mini_window
;
268 Fset_window_buffer (mini_window
,
269 (NILP (Vminibuffer_list
)
271 : Fcar (Vminibuffer_list
)));
275 /* Make a frame containing only a minibuffer window. */
278 make_minibuffer_frame ()
280 /* First make a frame containing just a root window, no minibuffer. */
282 register struct frame
*f
= make_frame (0);
283 register Lisp_Object mini_window
;
284 register Lisp_Object frame
;
286 XSET (frame
, Lisp_Frame
, f
);
291 f
->wants_modeline
= 0;
292 f
->has_minibuffer
= 1;
294 /* Now label the root window as also being the minibuffer.
295 Avoid infinite looping on the window chain by marking next pointer
298 mini_window
= f
->minibuffer_window
= f
->root_window
;
299 XWINDOW (mini_window
)->mini_p
= Qt
;
300 XWINDOW (mini_window
)->next
= Qnil
;
301 XWINDOW (mini_window
)->prev
= Qnil
;
302 XWINDOW (mini_window
)->frame
= frame
;
304 /* Put the proper buffer in that window. */
306 Fset_window_buffer (mini_window
,
307 (NILP (Vminibuffer_list
)
309 : Fcar (Vminibuffer_list
)));
313 /* Construct a frame that refers to the terminal (stdin and stdout). */
316 make_terminal_frame ()
318 register struct frame
*f
;
324 XSET (frame
, Lisp_Frame
, f
);
325 Vframe_list
= Fcons (frame
, Vframe_list
);
327 f
->name
= build_string ("terminal");
328 FRAME_SET_VISIBLE (f
, 1);
329 f
->display
.nothing
= 1; /* Nonzero means frame isn't deleted. */
330 XSET (Vterminal_frame
, Lisp_Frame
, f
);
334 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
335 "Select the frame FRAME.\n\
336 Subsequent editing commands apply to its selected window.\n\
337 The selection of FRAME lasts until the next time the user does\n\
338 something to select a different frame, or until the next time this\n\
339 function is called.")
341 Lisp_Object frame
, no_enter
;
343 return Fhandle_switch_frame (frame
, no_enter
);
347 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 2, "e",
348 "Handle a switch-frame event EVENT.\n\
349 Switch-frame events are usually bound to this function.\n\
350 A switch-frame event tells Emacs that the window manager has requested\n\
351 that the user's events be directed to the frame mentioned in the event.\n\
352 This function selects the selected window of the frame of EVENT.\n\
354 If EVENT is frame object, handle it as if it were a switch-frame event\n\
357 Lisp_Object frame
, no_enter
;
359 /* If FRAME is a switch-frame event, extract the frame we should
362 && EQ (XCONS (frame
)->car
, Qswitch_frame
)
363 && CONSP (XCONS (frame
)->cdr
))
364 frame
= XCONS (XCONS (frame
)->cdr
)->car
;
366 CHECK_LIVE_FRAME (frame
, 0);
368 if (selected_frame
== XFRAME (frame
))
371 /* If a frame's focus has been redirected toward the currently
372 selected frame, we should change the redirection to point to the
373 newly selected frame. This means that if the focus is redirected
374 from a minibufferless frame to a surrogate minibuffer frame, we
375 can use `other-window' to switch between all the frames using
376 that minibuffer frame, and the focus redirection will follow us
381 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
385 if (XTYPE (XCONS (tail
)->car
) != Lisp_Frame
)
388 focus
= FRAME_FOCUS_FRAME (XFRAME (XCONS (tail
)->car
));
390 if (XTYPE (focus
) == Lisp_Frame
391 && XFRAME (focus
) == selected_frame
)
392 Fredirect_frame_focus (XCONS (tail
)->car
, frame
);
396 selected_frame
= XFRAME (frame
);
397 if (! FRAME_MINIBUF_ONLY_P (selected_frame
))
398 last_nonminibuf_frame
= selected_frame
;
400 Fselect_window (XFRAME (frame
)->selected_window
);
401 choose_minibuf_frame ();
403 /* We want to make sure that the next event generates a frame-switch
404 event to the appropriate frame. This seems kludgy to me, but
405 before you take it out, make sure that evaluating something like
406 (select-window (frame-root-window (new-frame))) doesn't end up
407 with your typing being interpreted in the new frame instead of
408 the one you're actually typing in. */
409 internal_last_event_frame
= Qnil
;
414 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
415 "Return the frame that is now selected.")
419 XSET (tem
, Lisp_Frame
, selected_frame
);
423 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
424 "Return the frame object that window WINDOW is on.")
428 CHECK_LIVE_WINDOW (window
, 0);
429 return XWINDOW (window
)->frame
;
432 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
433 "Returns the root-window of FRAME.\n\
434 If omitted, FRAME defaults to the currently selected frame.")
439 XSET (frame
, Lisp_Frame
, selected_frame
);
441 CHECK_LIVE_FRAME (frame
, 0);
443 return XFRAME (frame
)->root_window
;
446 DEFUN ("frame-selected-window", Fframe_selected_window
,
447 Sframe_selected_window
, 0, 1, 0,
448 "Return the selected window of frame object FRAME.\n\
449 If omitted, FRAME defaults to the currently selected frame.")
454 XSET (frame
, Lisp_Frame
, selected_frame
);
456 CHECK_LIVE_FRAME (frame
, 0);
458 return XFRAME (frame
)->selected_window
;
461 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
463 "Return a list of all frames.")
466 return Fcopy_sequence (Vframe_list
);
469 /* Return the next frame in the frame list after FRAME.
470 If MINIBUF is nil, exclude minibuffer-only frames.
471 If MINIBUF is a window, include only frames using that window for
473 If MINIBUF is `visible', include all visible frames.
474 Otherwise, include all frames. */
477 next_frame (frame
, minibuf
)
484 /* There must always be at least one frame in Vframe_list. */
485 if (! CONSP (Vframe_list
))
488 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
489 forever. Forestall that. */
490 CHECK_LIVE_FRAME (frame
, 0);
493 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
495 Lisp_Object f
= XCONS (tail
)->car
;
499 /* Decide whether this frame is eligible to be returned. */
501 /* If we've looped all the way around without finding any
502 eligible frames, return the original frame. */
506 /* Let minibuf decide if this frame is acceptable. */
509 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
512 else if (EQ (minibuf
, Qvisible
))
514 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
515 if (FRAME_VISIBLE_P (XFRAME (f
)))
518 else if (WINDOWP (minibuf
))
520 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
))
532 /* Return the previous frame in the frame list before FRAME.
533 If MINIBUF is nil, exclude minibuffer-only frames.
534 If MINIBUF is a window, include only frames using that window for
536 If MINIBUF is `visible', include all visible frames.
537 Otherwise, include all frames. */
540 prev_frame (frame
, minibuf
)
547 /* There must always be at least one frame in Vframe_list. */
548 if (! CONSP (Vframe_list
))
552 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
554 Lisp_Object f
= XCONS (tail
)->car
;
556 if (XTYPE (f
) != Lisp_Frame
)
559 if (EQ (frame
, f
) && !NILP (prev
))
562 /* Decide whether this frame is eligible to be returned,
563 according to minibuf. */
566 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
569 else if (XTYPE (minibuf
) == Lisp_Window
)
571 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
))
574 else if (EQ (minibuf
, Qvisible
))
576 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
577 if (FRAME_VISIBLE_P (XFRAME (f
)))
584 /* We've scanned the entire list. */
586 /* We went through the whole frame list without finding a single
587 acceptable frame. Return the original frame. */
590 /* There were no acceptable frames in the list before FRAME; otherwise,
591 we would have returned directly from the loop. Since PREV is the last
592 acceptable frame in the list, return it. */
597 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
598 "Return the next frame in the frame list after FRAME.\n\
599 By default, skip minibuffer-only frames.\n\
600 If omitted, FRAME defaults to the selected frame.\n\
601 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
602 If MINIFRAME is a window, include only frames using that window for their\n\
604 If MINIFRAME is `visible', include all visible frames.\n\
605 Otherwise, include all frames.")
607 Lisp_Object frame
, miniframe
;
612 XSET (frame
, Lisp_Frame
, selected_frame
);
614 CHECK_LIVE_FRAME (frame
, 0);
616 return next_frame (frame
, miniframe
);
619 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
620 "Return the previous frame in the frame list before FRAME.\n\
621 By default, skip minibuffer-only frames.\n\
622 If omitted, FRAME defaults to the selected frame.\n\
623 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.\n\
624 If MINIFRAME is a window, include only frames using that window for their\n\
626 If MINIFRAME is `visible', include all visible frames.\n\
627 Otherwise, include all frames.")
629 Lisp_Object frame
, miniframe
;
634 XSET (frame
, Lisp_Frame
, selected_frame
);
636 CHECK_LIVE_FRAME (frame
, 0);
638 return prev_frame (frame
, miniframe
);
641 /* Return 1 if it is ok to delete frame F;
642 0 if all frames aside from F are invisible.
643 (Exception: if F is the terminal frame, and we are using X, return 1.) */
646 other_visible_frames (f
)
649 /* We know the selected frame is visible,
650 so if F is some other frame, it can't be the sole visible one. */
651 if (f
== selected_frame
)
656 for (frames
= Vframe_list
;
658 frames
= XCONS (frames
)->cdr
)
660 Lisp_Object
this = XCONS (frames
)->car
;
662 /* Verify that the frame's window still exists
663 and we can still talk to it. And note any recent change
665 #ifdef HAVE_X_WINDOWS
666 if (FRAME_X_P (XFRAME (this)))
669 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
673 if (FRAME_VISIBLE_P (XFRAME (this))
674 || FRAME_ICONIFIED_P (XFRAME (this))
675 /* Allow deleting the terminal frame when at least
676 one X frame exists! */
677 || (FRAME_X_P (XFRAME (this)) && !FRAME_X_P (f
)))
685 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
686 "Delete FRAME, permanently eliminating it from use.\n\
687 If omitted, FRAME defaults to the selected frame.\n\
688 A frame may not be deleted if its minibuffer is used by other frames.\n\
689 Normally, you may not delete a frame if all other frames are invisible,\n\
690 but if the second optional argument FORCE is non-nil, you may do so.")
692 Lisp_Object frame
, force
;
696 if (EQ (frame
, Qnil
))
699 XSET (frame
, Lisp_Frame
, f
);
703 CHECK_FRAME (frame
, 0);
707 if (! FRAME_LIVE_P (f
))
710 if (NILP (force
) && !other_visible_frames (f
))
711 error ("Attempt to delete the sole visible or iconified frame");
713 /* Does this frame have a minibuffer, and is it the surrogate
714 minibuffer for any other frame? */
715 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
719 for (frames
= Vframe_list
;
721 frames
= XCONS (frames
)->cdr
)
724 this = XCONS (frames
)->car
;
726 if (! EQ (this, frame
)
728 WINDOW_FRAME (XWINDOW
729 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
730 error ("Attempt to delete a surrogate minibuffer frame");
734 /* Don't let the frame remain selected. */
735 if (f
== selected_frame
)
736 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
738 /* Don't allow minibuf_window to remain on a deleted frame. */
739 if (EQ (f
->minibuffer_window
, minibuf_window
))
741 Fset_window_buffer (selected_frame
->minibuffer_window
,
742 XWINDOW (minibuf_window
)->buffer
);
743 minibuf_window
= selected_frame
->minibuffer_window
;
746 /* Mark all the windows that used to be on FRAME as deleted, and then
747 remove the reference to them. */
748 delete_all_subwindows (XWINDOW (f
->root_window
));
749 f
->root_window
= Qnil
;
751 Vframe_list
= Fdelq (frame
, Vframe_list
);
752 FRAME_SET_VISIBLE (f
, 0);
754 /* Since some events are handled at the interrupt level, we may get
755 an event for f at any time; if we zero out the frame's display
756 now, then we may trip up the event-handling code. Instead, we'll
757 promise that the display of the frame must be valid until we have
758 called the window-system-dependent frame destruction routine. */
760 /* I think this should be done with a hook. */
761 #ifdef HAVE_X_WINDOWS
763 x_destroy_window (f
);
766 f
->display
.nothing
= 0;
768 /* If we've deleted the last_nonminibuf_frame, then try to find
770 if (f
== last_nonminibuf_frame
)
774 last_nonminibuf_frame
= 0;
776 for (frames
= Vframe_list
;
778 frames
= XCONS (frames
)->cdr
)
780 f
= XFRAME (XCONS (frames
)->car
);
781 if (!FRAME_MINIBUF_ONLY_P (f
))
783 last_nonminibuf_frame
= f
;
789 /* If we've deleted Vdefault_minibuffer_frame, try to find another
790 one. Prefer minibuffer-only frames, but also notice frames
791 with other windows. */
792 if (EQ (frame
, Vdefault_minibuffer_frame
))
796 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
797 Lisp_Object frame_with_minibuf
= Qnil
;
799 for (frames
= Vframe_list
;
801 frames
= XCONS (frames
)->cdr
)
803 Lisp_Object
this = XCONS (frames
)->car
;
805 if (XTYPE (this) != Lisp_Frame
)
809 if (FRAME_HAS_MINIBUF_P (f
))
811 frame_with_minibuf
= this;
812 if (FRAME_MINIBUF_ONLY_P (f
))
817 /* We know that there must be some frame with a minibuffer out
818 there. If this were not true, all of the frames present
819 would have to be minibufferless, which implies that at some
820 point their minibuffer frames must have been deleted, but
821 that is prohibited at the top; you can't delete surrogate
822 minibuffer frames. */
823 if (NILP (frame_with_minibuf
))
826 Vdefault_minibuffer_frame
= frame_with_minibuf
;
832 /* Return mouse position in character cell units. */
834 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
835 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
836 The position is given in character cells, where (0, 0) is the\n\
837 upper-left corner.\n\
838 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
839 to read the mouse position, it returns the selected frame for FRAME\n\
840 and nil for X and Y.")
844 Lisp_Object lispy_dummy
;
845 enum scroll_bar_part party_dummy
;
848 unsigned long long_dummy
;
853 /* It's okay for the hook to refrain from storing anything. */
854 if (mouse_position_hook
)
855 (*mouse_position_hook
) (&f
,
856 &lispy_dummy
, &party_dummy
,
861 glyph_to_pixel_coords (f
, col
, row
, &col
, &row
);
864 XSET (lispy_dummy
, Lisp_Frame
, f
);
865 return Fcons (lispy_dummy
, Fcons (x
, y
));
868 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
869 "Move the mouse pointer to the center of character cell (X,Y) in FRAME.\n\
870 WARNING: If you use this under X, you should do `unfocus-frame' afterwards.")
872 Lisp_Object frame
, x
, y
;
874 CHECK_LIVE_FRAME (frame
, 0);
878 /* I think this should be done with a hook. */
879 #ifdef HAVE_X_WINDOWS
880 if (FRAME_X_P (XFRAME (frame
)))
881 /* Warping the mouse will cause enternotify and focus events. */
882 x_set_mouse_position (XFRAME (frame
), x
, y
);
888 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
890 "Make the frame FRAME visible (assuming it is an X-window).\n\
891 If omitted, FRAME defaults to the currently selected frame.")
896 XSET (frame
, Lisp_Frame
, selected_frame
);
898 CHECK_LIVE_FRAME (frame
, 0);
900 /* I think this should be done with a hook. */
901 #ifdef HAVE_X_WINDOWS
902 if (FRAME_X_P (XFRAME (frame
)))
904 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
905 x_make_frame_visible (XFRAME (frame
));
912 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
914 "Make the frame FRAME invisible (assuming it is an X-window).\n\
915 If omitted, FRAME defaults to the currently selected frame.\n\
916 Normally you may not make FRAME invisible if all other frames are invisible,\n\
917 but if the second optional argument FORCE is non-nil, you may do so.")
919 Lisp_Object frame
, force
;
922 XSET (frame
, Lisp_Frame
, selected_frame
);
924 CHECK_LIVE_FRAME (frame
, 0);
926 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
927 error ("Attempt to make invisible the sole visible or iconified frame");
929 /* Don't let the frame remain selected. */
930 if (XFRAME (frame
) == selected_frame
)
931 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
933 /* Don't allow minibuf_window to remain on a deleted frame. */
934 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
936 Fset_window_buffer (selected_frame
->minibuffer_window
,
937 XWINDOW (minibuf_window
)->buffer
);
938 minibuf_window
= selected_frame
->minibuffer_window
;
941 /* I think this should be done with a hook. */
942 #ifdef HAVE_X_WINDOWS
943 if (FRAME_X_P (XFRAME (frame
)))
944 x_make_frame_invisible (XFRAME (frame
));
950 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
952 "Make the frame FRAME into an icon.\n\
953 If omitted, FRAME defaults to the currently selected frame.")
958 XSET (frame
, Lisp_Frame
, selected_frame
);
960 CHECK_LIVE_FRAME (frame
, 0);
962 /* Don't let the frame remain selected. */
963 if (XFRAME (frame
) == selected_frame
)
964 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
966 /* Don't allow minibuf_window to remain on a deleted frame. */
967 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
969 Fset_window_buffer (selected_frame
->minibuffer_window
,
970 XWINDOW (minibuf_window
)->buffer
);
971 minibuf_window
= selected_frame
->minibuffer_window
;
974 /* I think this should be done with a hook. */
975 #ifdef HAVE_X_WINDOWS
976 if (FRAME_X_P (XFRAME (frame
)))
977 x_iconify_frame (XFRAME (frame
));
983 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
985 "Return t if FRAME is now \"visible\" (actually in use for display).\n\
986 A frame that is not \"visible\" is not updated and, if it works through\n\
987 a window system, it may not show at all.\n\
988 Return the symbol `icon' if frame is visible only as an icon.")
992 CHECK_LIVE_FRAME (frame
, 0);
994 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
996 if (FRAME_VISIBLE_P (XFRAME (frame
)))
998 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1003 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1005 "Return a list of all frames now \"visible\" (being updated).")
1008 Lisp_Object tail
, frame
;
1013 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
1015 frame
= XCONS (tail
)->car
;
1016 if (XTYPE (frame
) != Lisp_Frame
)
1019 if (FRAME_VISIBLE_P (f
))
1020 value
= Fcons (frame
, value
);
1026 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 1, 1, 0,
1027 "Bring FRAME to the front, so it occludes any frames it overlaps.\n\
1028 If FRAME is invisible, make it visible.\n\
1029 If Emacs is displaying on an ordinary terminal or some other device which\n\
1030 doesn't support multiple overlapping frames, this function does nothing.")
1034 CHECK_LIVE_FRAME (frame
, 0);
1036 /* Do like the documentation says. */
1037 Fmake_frame_visible (frame
);
1039 if (frame_raise_lower_hook
)
1040 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1045 /* Should we have a corresponding function called Flower_Power? */
1046 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 1, 1, 0,
1047 "Send FRAME to the back, so it is occluded by any frames that overlap it.\n\
1048 If Emacs is displaying on an ordinary terminal or some other device which\n\
1049 doesn't support multiple overlapping frames, this function does nothing.")
1053 CHECK_LIVE_FRAME (frame
, 0);
1055 if (frame_raise_lower_hook
)
1056 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1062 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1064 "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\
1065 In other words, switch-frame events caused by events in FRAME will\n\
1066 request a switch to FOCUS-FRAME, and `last-event-frame' will be\n\
1067 FOCUS-FRAME after reading an event typed at FRAME.\n\
1069 If FOCUS-FRAME is omitted or nil, any existing redirection is\n\
1070 cancelled, and the frame again receives its own keystrokes.\n\
1072 Focus redirection is useful for temporarily redirecting keystrokes to\n\
1073 a surrogate minibuffer frame when a frame doesn't have its own\n\
1074 minibuffer window.\n\
1076 A frame's focus redirection can be changed by select-frame. If frame\n\
1077 FOO is selected, and then a different frame BAR is selected, any\n\
1078 frames redirecting their focus to FOO are shifted to redirect their\n\
1079 focus to BAR. This allows focus redirection to work properly when the\n\
1080 user switches from one frame to another using `select-window'.\n\
1082 This means that a frame whose focus is redirected to itself is treated\n\
1083 differently from a frame whose focus is redirected to nil; the former\n\
1084 is affected by select-frame, while the latter is not.\n\
1086 The redirection lasts until `redirect-frame-focus' is called to change it.")
1087 (frame
, focus_frame
)
1088 Lisp_Object frame
, focus_frame
;
1090 /* Note that we don't check for a live frame here. It's reasonable
1091 to redirect the focus of a frame you're about to delete, if you
1092 know what other frame should receive those keystrokes. */
1093 CHECK_FRAME (frame
, 0);
1095 if (! NILP (focus_frame
))
1096 CHECK_LIVE_FRAME (focus_frame
, 1);
1098 XFRAME (frame
)->focus_frame
= focus_frame
;
1100 /* I think this should be done with a hook. */
1101 #ifdef HAVE_X_WINDOWS
1102 if (!NILP (focus_frame
) && ! EQ (focus_frame
, frame
)
1103 && FRAME_X_P (XFRAME (focus_frame
)))
1104 Ffocus_frame (focus_frame
);
1107 if (frame_rehighlight_hook
)
1108 (*frame_rehighlight_hook
) ();
1114 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1115 "Return the frame to which FRAME's keystrokes are currently being sent.\n\
1116 This returns nil if FRAME's focus is not redirected.\n\
1117 See `redirect-frame-focus'.")
1121 CHECK_LIVE_FRAME (frame
, 0);
1123 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1129 get_frame_param (frame
, prop
)
1130 register struct frame
*frame
;
1133 register Lisp_Object tem
;
1135 tem
= Fassq (prop
, frame
->param_alist
);
1142 store_in_alist (alistptr
, prop
, val
)
1143 Lisp_Object
*alistptr
, val
;
1146 register Lisp_Object tem
;
1148 tem
= Fassq (prop
, *alistptr
);
1150 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1156 store_frame_param (f
, prop
, val
)
1158 Lisp_Object prop
, val
;
1160 register Lisp_Object tem
;
1162 tem
= Fassq (prop
, f
->param_alist
);
1164 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
1168 if (EQ (prop
, Qminibuffer
)
1169 && XTYPE (val
) == Lisp_Window
)
1171 if (! MINI_WINDOW_P (XWINDOW (val
)))
1172 error ("Surrogate minibuffer windows must be minibuffer windows.");
1174 if (FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
1175 error ("can't change the surrogate minibuffer of a frame with its own minibuffer");
1177 /* Install the chosen minibuffer window, with proper buffer. */
1178 f
->minibuffer_window
= val
;
1182 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
1183 "Return the parameters-alist of frame FRAME.\n\
1184 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\
1185 The meaningful PARMs depend on the kind of frame.\n\
1186 If FRAME is omitted, return information on the currently selected frame.")
1193 if (EQ (frame
, Qnil
))
1197 CHECK_FRAME (frame
, 0);
1201 if (f
->display
.nothing
== 0)
1204 alist
= Fcopy_alist (f
->param_alist
);
1205 store_in_alist (&alist
, Qname
, f
->name
);
1206 store_in_alist (&alist
, Qheight
, make_number (f
->height
));
1207 store_in_alist (&alist
, Qwidth
, make_number (f
->width
));
1208 store_in_alist (&alist
, Qmodeline
, (f
->wants_modeline
? Qt
: Qnil
));
1209 store_in_alist (&alist
, Qminibuffer
,
1210 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
1211 : (FRAME_MINIBUF_ONLY_P (f
) ? Qonly
1212 : FRAME_MINIBUF_WINDOW (f
))));
1213 store_in_alist (&alist
, Qunsplittable
, (f
->no_split
? Qt
: Qnil
));
1214 store_in_alist (&alist
, Qmenu_bar_lines
, (FRAME_MENU_BAR_LINES (f
)));
1216 /* I think this should be done with a hook. */
1217 #ifdef HAVE_X_WINDOWS
1219 x_report_frame_params (f
, &alist
);
1224 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
1225 Smodify_frame_parameters
, 2, 2, 0,
1226 "Modify the parameters of frame FRAME according to ALIST.\n\
1227 ALIST is an alist of parameters to change and their new values.\n\
1228 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
1229 The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
1231 Lisp_Object frame
, alist
;
1234 register Lisp_Object tail
, elt
, prop
, val
;
1236 if (EQ (frame
, Qnil
))
1240 CHECK_LIVE_FRAME (frame
, 0);
1244 /* I think this should be done with a hook. */
1245 #ifdef HAVE_X_WINDOWS
1248 x_set_frame_parameters (f
, alist
);
1250 for (tail
= alist
; !EQ (tail
, Qnil
); tail
= Fcdr (tail
))
1255 x_set_frame_param (f
, prop
, val
, get_frame_param (f
, prop
));
1256 store_frame_param (f
, prop
, val
);
1264 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
1266 "Height in pixels of a line in the font in frame FRAME.\n\
1267 If FRAME is omitted, the selected frame is used.\n\
1268 For a terminal frame, the value is always 1.")
1278 CHECK_FRAME (frame
, 0);
1282 #ifdef HAVE_X_WINDOWS
1284 return make_number (x_char_height (f
));
1287 return make_number (1);
1291 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
1293 "Width in pixels of characters in the font in frame FRAME.\n\
1294 If FRAME is omitted, the selected frame is used.\n\
1295 The width is the same for all characters, because\n\
1296 currently Emacs supports only fixed-width fonts.\n\
1297 For a terminal screen, the value is always 1.")
1307 CHECK_FRAME (frame
, 0);
1311 #ifdef HAVE_X_WINDOWS
1313 return make_number (x_char_width (f
));
1316 return make_number (1);
1319 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
1320 Sframe_pixel_height
, 0, 1, 0,
1321 "Return a FRAME's height in pixels.\n\
1322 For a terminal frame, the result really gives the height in characters.\n\
1323 If FRAME is omitted, the selected frame is used.")
1333 CHECK_FRAME (frame
, 0);
1337 #ifdef HAVE_X_WINDOWS
1339 return make_number (x_pixel_height (f
));
1342 return make_number (FRAME_HEIGHT (f
));
1345 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
1346 Sframe_pixel_width
, 0, 1, 0,
1347 "Return FRAME's width in pixels.\n\
1348 For a terminal frame, the result really gives the width in characters.\n\
1349 If FRAME is omitted, the selected frame is used.")
1359 CHECK_FRAME (frame
, 0);
1363 #ifdef HAVE_X_WINDOWS
1365 return make_number (x_pixel_width (f
));
1368 return make_number (FRAME_WIDTH (f
));
1371 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1372 "Specify that the frame FRAME has LINES lines.\n\
1373 Optional third arg non-nil means that redisplay should use LINES lines\n\
1374 but that the idea of the actual height of the frame should not be changed.")
1375 (frame
, rows
, pretend
)
1376 Lisp_Object frame
, rows
, pretend
;
1378 register struct frame
*f
;
1380 CHECK_NUMBER (rows
, 0);
1385 CHECK_LIVE_FRAME (frame
, 0);
1389 /* I think this should be done with a hook. */
1390 #ifdef HAVE_X_WINDOWS
1393 if (XINT (rows
) != f
->width
)
1394 x_set_window_size (f
, 1, f
->width
, XINT (rows
));
1398 change_frame_size (f
, XINT (rows
), 0, !NILP (pretend
), 0);
1402 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1403 "Specify that the frame FRAME has COLS columns.\n\
1404 Optional third arg non-nil means that redisplay should use COLS columns\n\
1405 but that the idea of the actual width of the frame should not be changed.")
1406 (frame
, cols
, pretend
)
1407 Lisp_Object frame
, cols
, pretend
;
1409 register struct frame
*f
;
1410 CHECK_NUMBER (cols
, 0);
1415 CHECK_LIVE_FRAME (frame
, 0);
1419 /* I think this should be done with a hook. */
1420 #ifdef HAVE_X_WINDOWS
1423 if (XINT (cols
) != f
->width
)
1424 x_set_window_size (f
, 1, XINT (cols
), f
->height
);
1428 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0);
1432 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1433 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1435 Lisp_Object frame
, cols
, rows
;
1437 register struct frame
*f
;
1440 CHECK_LIVE_FRAME (frame
, 0);
1441 CHECK_NUMBER (cols
, 2);
1442 CHECK_NUMBER (rows
, 1);
1445 /* I think this should be done with a hook. */
1446 #ifdef HAVE_X_WINDOWS
1449 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
)
1450 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
1454 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0);
1459 DEFUN ("set-frame-position", Fset_frame_position
,
1460 Sset_frame_position
, 3, 3, 0,
1461 "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\
1462 This is actually the position of the upper left corner of the frame.\n\
1463 Negative values for XOFFSET or YOFFSET are interpreted relative to\n\
1464 the rightmost or bottommost possible position (that stays within the screen).")
1465 (frame
, xoffset
, yoffset
)
1466 Lisp_Object frame
, xoffset
, yoffset
;
1468 register struct frame
*f
;
1471 CHECK_LIVE_FRAME (frame
, 0);
1472 CHECK_NUMBER (xoffset
, 1);
1473 CHECK_NUMBER (yoffset
, 2);
1476 /* I think this should be done with a hook. */
1477 #ifdef HAVE_X_WINDOWS
1479 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
));
1486 choose_minibuf_frame ()
1488 /* For lowest-level minibuf, put it on currently selected frame
1489 if frame has a minibuffer. */
1491 if (minibuf_level
== 0
1492 && selected_frame
!= 0
1493 && !EQ (minibuf_window
, selected_frame
->minibuffer_window
))
1495 /* I don't think that any frames may validly have a null minibuffer
1497 if (NILP (selected_frame
->minibuffer_window
))
1500 Fset_window_buffer (selected_frame
->minibuffer_window
,
1501 XWINDOW (minibuf_window
)->buffer
);
1502 minibuf_window
= selected_frame
->minibuffer_window
;
1508 /*&&& init symbols here &&&*/
1509 Qframep
= intern ("framep");
1510 staticpro (&Qframep
);
1511 Qframe_live_p
= intern ("frame-live-p");
1512 staticpro (&Qframe_live_p
);
1513 Qheight
= intern ("height");
1514 staticpro (&Qheight
);
1515 Qicon
= intern ("icon");
1517 Qminibuffer
= intern ("minibuffer");
1518 staticpro (&Qminibuffer
);
1519 Qmodeline
= intern ("modeline");
1520 staticpro (&Qmodeline
);
1521 Qname
= intern ("name");
1523 Qonly
= intern ("only");
1525 Qunsplittable
= intern ("unsplittable");
1526 staticpro (&Qunsplittable
);
1527 Qmenu_bar_lines
= intern ("menu-bar-lines");
1528 staticpro (&Qmenu_bar_lines
);
1529 Qwidth
= intern ("width");
1530 staticpro (&Qwidth
);
1533 Qvisible
= intern ("visible");
1534 staticpro (&Qvisible
);
1536 staticpro (&Vframe_list
);
1538 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
1539 "The initial frame-object, which represents Emacs's stdout.");
1541 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
1542 "Non-nil if all of emacs is iconified and frame updates are not needed.");
1543 Vemacs_iconified
= Qnil
;
1545 DEFVAR_LISP ("default-minibuffer-frame", &Vdefault_minibuffer_frame
,
1546 "Minibufferless frames use this frame's minibuffer.\n\
1548 Emacs cannot create minibufferless frames unless this is set to an\n\
1549 appropriate surrogate.\n\
1551 Emacs consults this variable only when creating minibufferless\n\
1552 frames; once the frame is created, it sticks with its assigned\n\
1553 minibuffer, no matter what this variable is set to. This means that\n\
1554 this variable doesn't necessarily say anything meaningful about the\n\
1555 current set of frames, or where the minibuffer is currently being\n\
1557 Vdefault_minibuffer_frame
= Qnil
;
1559 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
1560 "Alist of default values for frame creation.\n\
1561 These may be set in your init file, like this:\n\
1562 (setq default-frame-alist '((width . 80) (height . 55)))\n\
1563 These override values given in window system configuration data, like\n\
1564 X Windows' defaults database.\n\
1565 For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
1566 For values specific to the separate minibuffer frame, see\n\
1567 `minibuffer-frame-alist'.");
1568 Vdefault_frame_alist
= Qnil
;
1571 defsubr (&Sframe_live_p
);
1572 defsubr (&Shandle_switch_frame
);
1573 defsubr (&Sselect_frame
);
1574 defsubr (&Sselected_frame
);
1575 defsubr (&Swindow_frame
);
1576 defsubr (&Sframe_root_window
);
1577 defsubr (&Sframe_selected_window
);
1578 defsubr (&Sframe_list
);
1579 defsubr (&Snext_frame
);
1580 defsubr (&Sprevious_frame
);
1581 defsubr (&Sdelete_frame
);
1582 defsubr (&Smouse_position
);
1583 defsubr (&Sset_mouse_position
);
1585 defsubr (&Sframe_configuration
);
1586 defsubr (&Srestore_frame_configuration
);
1588 defsubr (&Smake_frame_visible
);
1589 defsubr (&Smake_frame_invisible
);
1590 defsubr (&Siconify_frame
);
1591 defsubr (&Sframe_visible_p
);
1592 defsubr (&Svisible_frame_list
);
1593 defsubr (&Sraise_frame
);
1594 defsubr (&Slower_frame
);
1595 defsubr (&Sredirect_frame_focus
);
1596 defsubr (&Sframe_focus
);
1597 defsubr (&Sframe_parameters
);
1598 defsubr (&Smodify_frame_parameters
);
1599 defsubr (&Sframe_char_height
);
1600 defsubr (&Sframe_char_width
);
1601 defsubr (&Sframe_pixel_height
);
1602 defsubr (&Sframe_pixel_width
);
1603 defsubr (&Sset_frame_height
);
1604 defsubr (&Sset_frame_width
);
1605 defsubr (&Sset_frame_size
);
1606 defsubr (&Sset_frame_position
);
1611 initial_define_lispy_key (global_map
, "switch-frame", "handle-switch-frame");
1614 #else /* not MULTI_FRAME */
1616 /* If we're not using multi-frame stuff, we still need to provide some
1617 support functions. */
1619 /* Unless this function is defined, providing set-frame-height and
1620 set-frame-width doesn't help compatibility any, since they both
1621 want this as their first argument. */
1622 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1623 "Return the frame that is now selected.")
1630 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
1631 "Return non-nil if OBJECT is a frame.\n\
1632 Value is t for a termcap frame (a character-only terminal),\n\
1633 `x' for an Emacs frame that is really an X window.\n\
1634 Also see `live-frame-p'.")
1641 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
1642 "Specify that the frame FRAME has LINES lines.\n\
1643 Optional third arg non-nil means that redisplay should use LINES lines\n\
1644 but that the idea of the actual height of the frame should not be changed.")
1645 (frame
, rows
, pretend
)
1646 Lisp_Object frame
, rows
, pretend
;
1648 CHECK_NUMBER (rows
, 0);
1650 change_frame_size (0, XINT (rows
), 0, !NILP (pretend
), 0);
1654 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
1655 "Specify that the frame FRAME has COLS columns.\n\
1656 Optional third arg non-nil means that redisplay should use COLS columns\n\
1657 but that the idea of the actual width of the frame should not be changed.")
1658 (frame
, cols
, pretend
)
1659 Lisp_Object frame
, cols
, pretend
;
1661 CHECK_NUMBER (cols
, 0);
1663 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1667 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
1668 "Sets size of FRAME to COLS by ROWS, measured in characters.")
1670 Lisp_Object frame
, cols
, rows
;
1672 CHECK_NUMBER (cols
, 2);
1673 CHECK_NUMBER (rows
, 1);
1675 change_frame_size (0, XINT (rows
), XINT (cols
), 0, 0);
1680 DEFUN ("frame-height", Fframe_height
, Sframe_height
, 0, 1, 0,
1681 "Return number of lines available for display on FRAME.\n\
1682 If FRAME is omitted, describe the currently selected frame.")
1686 return make_number (FRAME_HEIGHT (selected_frame
));
1689 DEFUN ("frame-width", Fframe_width
, Sframe_width
, 0, 1, 0,
1690 "Return number of columns available for display on FRAME.\n\
1691 If FRAME is omitted, describe the currently selected frame.")
1695 return make_number (FRAME_WIDTH (selected_frame
));
1698 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
1700 "Height in pixels of a line in the font in frame FRAME.\n\
1701 If FRAME is omitted, the selected frame is used.\n\
1702 For a terminal frame, the value is always 1.")
1706 return make_number (1);
1710 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
1712 "Width in pixels of characters in the font in frame FRAME.\n\
1713 If FRAME is omitted, the selected frame is used.\n\
1714 The width is the same for all characters, because\n\
1715 currently Emacs supports only fixed-width fonts.\n\
1716 For a terminal screen, the value is always 1.")
1720 return make_number (1);
1723 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
1724 Sframe_pixel_height
, 0, 1, 0,
1725 "Return FRAME's height in pixels.\n\
1726 For a terminal frame, the result really gives the height in characters.\n\
1727 If FRAME is omitted, the selected frame is used.")
1731 return make_number (FRAME_HEIGHT (f
));
1734 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
1735 Sframe_pixel_width
, 0, 1, 0,
1736 "Return FRAME's width in pixels.\n\
1737 For a terminal frame, the result really gives the width in characters.\n\
1738 If FRAME is omitted, the selected frame is used.")
1742 return make_number (FRAME_WIDTH (f
));
1745 /* These are for backward compatibility with Emacs 18. */
1747 DEFUN ("set-screen-height", Fset_screen_height
, Sset_screen_height
, 1, 2, 0,
1748 "Tell redisplay that the screen has LINES lines.\n\
1749 Optional second arg non-nil means that redisplay should use LINES lines\n\
1750 but that the idea of the actual height of the screen should not be changed.")
1752 Lisp_Object lines
, pretend
;
1754 CHECK_NUMBER (lines
, 0);
1756 change_frame_size (0, XINT (lines
), 0, !NILP (pretend
), 0);
1760 DEFUN ("set-screen-width", Fset_screen_width
, Sset_screen_width
, 1, 2, 0,
1761 "Tell redisplay that the screen has COLS columns.\n\
1762 Optional second arg non-nil means that redisplay should use COLS columns\n\
1763 but that the idea of the actual width of the screen should not be changed.")
1765 Lisp_Object cols
, pretend
;
1767 CHECK_NUMBER (cols
, 0);
1769 change_frame_size (0, 0, XINT (cols
), !NILP (pretend
), 0);
1773 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1774 "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
1775 The position is given in character cells, where (0, 0) is the\n\
1776 upper-left corner.\n\
1777 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
1778 to read the mouse position, it returns the selected frame for FRAME\n\
1779 and nil for X and Y.")
1783 Lisp_Object lispy_dummy
;
1784 enum scroll_bar_part party_dummy
;
1786 unsigned long long_dummy
;
1791 /* It's okay for the hook to refrain from storing anything. */
1792 if (mouse_position_hook
)
1793 (*mouse_position_hook
) (&f
,
1794 &lispy_dummy
, &party_dummy
,
1800 glyph_to_pixel_coords (f
, col
, row
, &col
, &row
);
1803 /* Always return nil for frame. */
1804 return Fcons (Qnil
, Fcons (x
, y
));
1809 defsubr (&Sselected_frame
);
1811 defsubr (&Sframe_char_height
);
1812 defsubr (&Sframe_char_width
);
1813 defsubr (&Sframe_pixel_height
);
1814 defsubr (&Sframe_pixel_width
);
1815 defsubr (&Sset_frame_height
);
1816 defsubr (&Sset_frame_width
);
1817 defsubr (&Sset_frame_size
);
1818 defsubr (&Sset_screen_height
);
1819 defsubr (&Sset_screen_width
);
1820 defsubr (&Sframe_height
);
1821 Ffset (intern ("screen-height"), intern ("frame-height"));
1822 defsubr (&Sframe_width
);
1823 Ffset (intern ("screen-width"), intern ("frame-width"));
1824 defsubr (&Smouse_position
);
1831 #endif /* not MULTI_FRAME */