1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
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., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
26 #include "character.h"
37 /* These help us bind and responding to switch-frame events. */
41 #ifdef HAVE_WINDOW_SYSTEM
44 #include "blockinput.h"
45 #include "termhooks.h"
46 #include "dispextern.h"
54 #ifdef HAVE_WINDOW_SYSTEM
56 #ifdef USE_FONT_BACKEND
58 #endif /* USE_FONT_BACKEND */
60 /* The name we're using in resource queries. Most often "emacs". */
62 Lisp_Object Vx_resource_name
;
64 /* The application class we're using in resource queries.
67 Lisp_Object Vx_resource_class
;
71 Lisp_Object Qframep
, Qframe_live_p
;
72 Lisp_Object Qicon
, Qmodeline
;
74 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
;
76 Lisp_Object Qdisplay_type
;
77 Lisp_Object Qbackground_mode
;
79 Lisp_Object Qx_frame_parameter
;
80 Lisp_Object Qx_resource_name
;
82 /* Frame parameters (set or reported). */
84 Lisp_Object Qauto_raise
, Qauto_lower
;
85 Lisp_Object Qborder_color
, Qborder_width
;
86 Lisp_Object Qcursor_color
, Qcursor_type
;
87 Lisp_Object Qgeometry
; /* Not used */
88 Lisp_Object Qheight
, Qwidth
;
89 Lisp_Object Qleft
, Qright
;
90 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
91 Lisp_Object Qinternal_border_width
;
92 Lisp_Object Qmouse_color
;
93 Lisp_Object Qminibuffer
;
94 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
95 Lisp_Object Qvisibility
;
96 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
97 Lisp_Object Qscreen_gamma
;
98 Lisp_Object Qline_spacing
;
99 Lisp_Object Quser_position
, Quser_size
;
100 Lisp_Object Qwait_for_wm
;
101 Lisp_Object Qwindow_id
;
102 #ifdef HAVE_X_WINDOWS
103 Lisp_Object Qouter_window_id
;
105 Lisp_Object Qparent_id
;
106 Lisp_Object Qtitle
, Qname
;
107 Lisp_Object Qunsplittable
;
108 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
109 Lisp_Object Qleft_fringe
, Qright_fringe
;
110 Lisp_Object Qbuffer_predicate
, Qbuffer_list
;
111 Lisp_Object Qtty_color_mode
;
113 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
;
114 #ifdef USE_FONT_BACKEND
115 Lisp_Object Qfont_backend
;
116 #endif /* USE_FONT_BACKEND */
118 Lisp_Object Qinhibit_face_set_after_frame_default
;
119 Lisp_Object Qface_set_after_frame_default
;
122 Lisp_Object Vterminal_frame
;
123 Lisp_Object Vdefault_frame_alist
;
124 Lisp_Object Vdefault_frame_scroll_bars
;
125 Lisp_Object Vmouse_position_function
;
126 Lisp_Object Vmouse_highlight
;
127 Lisp_Object Vdelete_frame_functions
;
130 set_menu_bar_lines_1 (window
, n
)
134 struct window
*w
= XWINDOW (window
);
136 XSETFASTINT (w
->last_modified
, 0);
137 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
138 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
140 if (INTEGERP (w
->orig_top_line
))
141 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
142 if (INTEGERP (w
->orig_total_lines
))
143 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
145 /* Handle just the top child in a vertical split. */
146 if (!NILP (w
->vchild
))
147 set_menu_bar_lines_1 (w
->vchild
, n
);
149 /* Adjust all children in a horizontal split. */
150 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
152 w
= XWINDOW (window
);
153 set_menu_bar_lines_1 (window
, n
);
158 set_menu_bar_lines (f
, value
, oldval
)
160 Lisp_Object value
, oldval
;
163 int olines
= FRAME_MENU_BAR_LINES (f
);
165 /* Right now, menu bars don't work properly in minibuf-only frames;
166 most of the commands try to apply themselves to the minibuffer
167 frame itself, and get an error because you can't switch buffers
168 in or split the minibuffer window. */
169 if (FRAME_MINIBUF_ONLY_P (f
))
172 if (INTEGERP (value
))
173 nlines
= XINT (value
);
177 if (nlines
!= olines
)
179 windows_or_buffers_changed
++;
180 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
181 FRAME_MENU_BAR_LINES (f
) = nlines
;
182 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
187 Lisp_Object Vemacs_iconified
;
188 Lisp_Object Vframe_list
;
190 struct x_output tty_display
;
192 extern Lisp_Object Vminibuffer_list
;
193 extern Lisp_Object
get_minibuffer ();
194 extern Lisp_Object
Fhandle_switch_frame ();
195 extern Lisp_Object
Fredirect_frame_focus ();
196 extern Lisp_Object
x_get_focus_frame ();
198 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
199 doc
: /* Return non-nil if OBJECT is a frame.
200 Value is t for a termcap frame (a character-only terminal),
201 `x' for an Emacs frame that is really an X window,
202 `w32' for an Emacs frame that is a window on MS-Windows display,
203 `mac' for an Emacs frame on a Macintosh display,
204 `pc' for a direct-write MS-DOS frame.
205 See also `frame-live-p'. */)
209 if (!FRAMEP (object
))
211 switch (XFRAME (object
)->output_method
)
215 case output_x_window
:
219 case output_msdos_raw
:
228 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
229 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
230 Value is nil if OBJECT is not a live frame. If object is a live
231 frame, the return value indicates what sort of output device it is
232 displayed on. See the documentation of `framep' for possible
237 return ((FRAMEP (object
)
238 && FRAME_LIVE_P (XFRAME (object
)))
248 register struct frame
*f
;
249 register Lisp_Object root_window
;
250 register Lisp_Object mini_window
;
252 f
= allocate_frame ();
253 XSETFRAME (frame
, f
);
255 f
->desired_matrix
= 0;
256 f
->current_matrix
= 0;
259 f
->glyphs_initialized_p
= 0;
260 f
->decode_mode_spec_buffer
= 0;
262 f
->async_visible
= 0;
263 f
->output_data
.nothing
= 0;
265 f
->async_iconified
= 0;
266 f
->wants_modeline
= 1;
271 f
->has_minibuffer
= mini_p
;
272 f
->focus_frame
= Qnil
;
273 f
->explicit_name
= 0;
274 f
->can_have_scroll_bars
= 0;
275 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
276 f
->param_alist
= Qnil
;
277 f
->scroll_bars
= Qnil
;
278 f
->condemned_scroll_bars
= Qnil
;
279 f
->face_alist
= Qnil
;
280 f
->face_cache
= NULL
;
281 f
->menu_bar_items
= Qnil
;
282 f
->menu_bar_vector
= Qnil
;
283 f
->menu_bar_items_used
= 0;
284 f
->buffer_predicate
= Qnil
;
285 f
->buffer_list
= Qnil
;
287 f
->kboard
= initial_kboard
;
291 f
->menu_bar_window
= Qnil
;
292 f
->tool_bar_window
= Qnil
;
293 f
->tool_bar_items
= Qnil
;
294 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
295 f
->n_tool_bar_items
= 0;
296 f
->left_fringe_width
= f
->right_fringe_width
= 0;
298 f
->scroll_bar_actual_width
= 0;
300 f
->internal_border_width
= 0;
301 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
302 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
303 f
->x_pixels_diff
= f
->y_pixels_diff
= 0;
304 #ifdef HAVE_WINDOW_SYSTEM
305 f
->want_fullscreen
= FULLSCREEN_NONE
;
307 f
->size_hint_flags
= 0;
309 #ifdef USE_FONT_BACKEND
310 f
->font_driver_list
= NULL
;
311 #endif /* USE_FONT_BACKEND */
313 root_window
= make_window ();
316 mini_window
= make_window ();
317 XWINDOW (root_window
)->next
= mini_window
;
318 XWINDOW (mini_window
)->prev
= root_window
;
319 XWINDOW (mini_window
)->mini_p
= Qt
;
320 XWINDOW (mini_window
)->frame
= frame
;
321 f
->minibuffer_window
= mini_window
;
326 XWINDOW (root_window
)->next
= Qnil
;
327 f
->minibuffer_window
= Qnil
;
330 XWINDOW (root_window
)->frame
= frame
;
333 just so that there is "something there."
334 Correct size will be set up later with change_frame_size. */
336 SET_FRAME_COLS (f
, 10);
337 FRAME_LINES (f
) = 10;
339 XSETFASTINT (XWINDOW (root_window
)->total_cols
, 10);
340 XSETFASTINT (XWINDOW (root_window
)->total_lines
, (mini_p
? 9 : 10));
344 XSETFASTINT (XWINDOW (mini_window
)->total_cols
, 10);
345 XSETFASTINT (XWINDOW (mini_window
)->top_line
, 9);
346 XSETFASTINT (XWINDOW (mini_window
)->total_lines
, 1);
349 /* Choose a buffer for the frame's root window. */
353 XWINDOW (root_window
)->buffer
= Qt
;
354 buf
= Fcurrent_buffer ();
355 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
356 a space), try to find another one. */
357 if (SREF (Fbuffer_name (buf
), 0) == ' ')
358 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
360 /* Use set_window_buffer, not Fset_window_buffer, and don't let
361 hooks be run by it. The reason is that the whole frame/window
362 arrangement is not yet fully intialized at this point. Windows
363 don't have the right size, glyph matrices aren't initialized
364 etc. Running Lisp functions at this point surely ends in a
366 set_window_buffer (root_window
, buf
, 0, 0);
367 f
->buffer_list
= Fcons (buf
, Qnil
);
372 XWINDOW (mini_window
)->buffer
= Qt
;
373 set_window_buffer (mini_window
,
374 (NILP (Vminibuffer_list
)
376 : Fcar (Vminibuffer_list
)),
380 f
->root_window
= root_window
;
381 f
->selected_window
= root_window
;
382 /* Make sure this window seems more recently used than
383 a newly-created, never-selected window. */
384 ++window_select_count
;
385 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, window_select_count
);
387 f
->default_face_done_p
= 0;
392 #ifdef HAVE_WINDOW_SYSTEM
393 /* Make a frame using a separate minibuffer window on another frame.
394 MINI_WINDOW is the minibuffer window to use. nil means use the
395 default (the global minibuffer). */
398 make_frame_without_minibuffer (mini_window
, kb
, display
)
399 register Lisp_Object mini_window
;
403 register struct frame
*f
;
406 if (!NILP (mini_window
))
407 CHECK_LIVE_WINDOW (mini_window
);
410 if (!NILP (mini_window
)
411 && XFRAME (XWINDOW (mini_window
)->frame
)->kboard
!= kb
)
412 error ("Frame and minibuffer must be on the same display");
415 /* Make a frame containing just a root window. */
418 if (NILP (mini_window
))
420 /* Use default-minibuffer-frame if possible. */
421 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
422 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
424 Lisp_Object frame_dummy
;
426 XSETFRAME (frame_dummy
, f
);
427 GCPRO1 (frame_dummy
);
428 /* If there's no minibuffer frame to use, create one. */
429 kb
->Vdefault_minibuffer_frame
=
430 call1 (intern ("make-initial-minibuffer-frame"), display
);
434 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
437 f
->minibuffer_window
= mini_window
;
439 /* Make the chosen minibuffer window display the proper minibuffer,
440 unless it is already showing a minibuffer. */
441 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
442 Fset_window_buffer (mini_window
,
443 (NILP (Vminibuffer_list
)
445 : Fcar (Vminibuffer_list
)), Qnil
);
449 /* Make a frame containing only a minibuffer window. */
452 make_minibuffer_frame ()
454 /* First make a frame containing just a root window, no minibuffer. */
456 register struct frame
*f
= make_frame (0);
457 register Lisp_Object mini_window
;
458 register Lisp_Object frame
;
460 XSETFRAME (frame
, f
);
465 f
->wants_modeline
= 0;
466 f
->has_minibuffer
= 1;
468 /* Now label the root window as also being the minibuffer.
469 Avoid infinite looping on the window chain by marking next pointer
472 mini_window
= f
->minibuffer_window
= f
->root_window
;
473 XWINDOW (mini_window
)->mini_p
= Qt
;
474 XWINDOW (mini_window
)->next
= Qnil
;
475 XWINDOW (mini_window
)->prev
= Qnil
;
476 XWINDOW (mini_window
)->frame
= frame
;
478 /* Put the proper buffer in that window. */
480 Fset_window_buffer (mini_window
,
481 (NILP (Vminibuffer_list
)
483 : Fcar (Vminibuffer_list
)), Qnil
);
486 #endif /* HAVE_WINDOW_SYSTEM */
488 /* Construct a frame that refers to the terminal (stdin and stdout). */
490 static int terminal_frame_count
;
493 make_terminal_frame ()
495 register struct frame
*f
;
502 initial_kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
503 init_kboard (initial_kboard
);
504 initial_kboard
->next_kboard
= all_kboards
;
505 all_kboards
= initial_kboard
;
509 /* The first call must initialize Vframe_list. */
510 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
515 XSETFRAME (frame
, f
);
516 Vframe_list
= Fcons (frame
, Vframe_list
);
518 terminal_frame_count
++;
519 sprintf (name
, "F%d", terminal_frame_count
);
520 f
->name
= build_string (name
);
522 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
523 f
->async_visible
= 1; /* Don't let visible be cleared later. */
525 f
->output_data
.x
= &the_only_x_display
;
526 if (!inhibit_window_system
527 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
528 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
530 f
->output_method
= output_msdos_raw
;
531 /* This initialization of foreground and background pixels is
532 only important for the initial frame created in temacs. If
533 we don't do that, we get black background and foreground in
534 the dumped Emacs because the_only_x_display is a static
535 variable, hence it is born all-zeroes, and zero is the code
536 for the black color. Other frames all inherit their pixels
537 from what's already in the_only_x_display. */
538 if ((!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
539 && f
->output_data
.x
->background_pixel
== 0
540 && f
->output_data
.x
->foreground_pixel
== 0)
542 f
->output_data
.x
->background_pixel
= FACE_TTY_DEFAULT_BG_COLOR
;
543 f
->output_data
.x
->foreground_pixel
= FACE_TTY_DEFAULT_FG_COLOR
;
547 f
->output_method
= output_termcap
;
550 f
->output_method
= output_termcap
;
551 f
->output_data
.x
= &tty_display
;
554 make_mac_terminal_frame (f
);
556 f
->output_data
.x
= &tty_display
;
558 FRAME_FOREGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_FG_COLOR
;
559 FRAME_BACKGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_BG_COLOR
;
562 #endif /* WINDOWSNT */
566 init_frame_faces (f
);
571 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
573 doc
: /* Create an additional terminal frame.
574 You can create multiple frames on a text-only terminal in this way.
575 Only the selected terminal frame is actually displayed.
576 This function takes one argument, an alist specifying frame parameters.
577 In practice, generally you don't need to specify any parameters.
578 Note that changing the size of one terminal frame automatically affects all. */)
583 Lisp_Object frame
, tem
;
584 struct frame
*sf
= SELECTED_FRAME ();
587 if (sf
->output_method
!= output_msdos_raw
588 && sf
->output_method
!= output_termcap
)
590 #else /* not MSDOS */
593 if (sf
->output_method
!= output_mac
)
594 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
596 if (sf
->output_method
!= output_termcap
)
597 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
599 #endif /* not MSDOS */
601 f
= make_terminal_frame ();
603 change_frame_size (f
, FRAME_LINES (sf
),
604 FRAME_COLS (sf
), 0, 0, 0);
607 XSETFRAME (frame
, f
);
608 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
609 Fmodify_frame_parameters (frame
, parms
);
611 /* Make the frame face alist be frame-specific, so that each
612 frame could change its face definitions independently. */
613 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
614 /* Simple Fcopy_alist isn't enough, because we need the contents of
615 the vectors which are the CDRs of associations in face_alist to
616 be copied as well. */
617 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
618 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
623 /* Perform the switch to frame FRAME.
625 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
628 If TRACK is non-zero and the frame that currently has the focus
629 redirects its focus to the selected frame, redirect that focused
630 frame's focus to FRAME instead.
632 FOR_DELETION non-zero means that the selected frame is being
633 deleted, which includes the possibility that the frame's display
637 do_switch_frame (frame
, track
, for_deletion
)
639 int track
, for_deletion
;
641 struct frame
*sf
= SELECTED_FRAME ();
643 /* If FRAME is a switch-frame event, extract the frame we should
646 && EQ (XCAR (frame
), Qswitch_frame
)
647 && CONSP (XCDR (frame
)))
648 frame
= XCAR (XCDR (frame
));
650 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
651 a switch-frame event to arrive after a frame is no longer live,
652 especially when deleting the initial frame during startup. */
654 if (! FRAME_LIVE_P (XFRAME (frame
)))
657 if (sf
== XFRAME (frame
))
660 /* This is too greedy; it causes inappropriate focus redirection
661 that's hard to get rid of. */
663 /* If a frame's focus has been redirected toward the currently
664 selected frame, we should change the redirection to point to the
665 newly selected frame. This means that if the focus is redirected
666 from a minibufferless frame to a surrogate minibuffer frame, we
667 can use `other-window' to switch between all the frames using
668 that minibuffer frame, and the focus redirection will follow us
674 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
678 if (!FRAMEP (XCAR (tail
)))
681 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
683 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
684 Fredirect_frame_focus (XCAR (tail
), frame
);
688 /* Instead, apply it only to the frame we're pointing to. */
689 #ifdef HAVE_WINDOW_SYSTEM
690 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
692 Lisp_Object focus
, xfocus
;
694 xfocus
= x_get_focus_frame (XFRAME (frame
));
697 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
698 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
699 Fredirect_frame_focus (xfocus
, frame
);
702 #endif /* HAVE_X_WINDOWS */
705 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
706 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
708 selected_frame
= frame
;
709 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
710 last_nonminibuf_frame
= XFRAME (selected_frame
);
712 Fselect_window (XFRAME (frame
)->selected_window
, Qnil
);
715 /* Make sure to switch the tty color mode to that of the newly
717 sf
= SELECTED_FRAME ();
718 if (FRAME_TERMCAP_P (sf
))
720 Lisp_Object color_mode_spec
, color_mode
;
722 color_mode_spec
= assq_no_quit (Qtty_color_mode
, sf
->param_alist
);
723 if (CONSP (color_mode_spec
))
724 color_mode
= XCDR (color_mode_spec
);
726 color_mode
= make_number (0);
727 set_tty_color_mode (sf
, color_mode
);
729 #endif /* !WINDOWSNT */
731 /* We want to make sure that the next event generates a frame-switch
732 event to the appropriate frame. This seems kludgy to me, but
733 before you take it out, make sure that evaluating something like
734 (select-window (frame-root-window (new-frame))) doesn't end up
735 with your typing being interpreted in the new frame instead of
736 the one you're actually typing in. */
737 internal_last_event_frame
= Qnil
;
742 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 1, "e",
743 doc
: /* Select the frame FRAME.
744 Subsequent editing commands apply to its selected window.
745 The selection of FRAME lasts until the next time the user does
746 something to select a different frame, or until the next time this
747 function is called. If you are using a window system, the previously
748 selected frame may be restored as the selected frame after return to
749 the command loop, because it still may have the window system's input
750 focus. On a text-only terminal, the next redisplay will display FRAME.
752 This function returns FRAME, or nil if FRAME has been deleted. */)
756 return do_switch_frame (frame
, 1, 0);
760 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
761 doc
: /* Handle a switch-frame event EVENT.
762 Switch-frame events are usually bound to this function.
763 A switch-frame event tells Emacs that the window manager has requested
764 that the user's events be directed to the frame mentioned in the event.
765 This function selects the selected window of the frame of EVENT.
767 If EVENT is frame object, handle it as if it were a switch-frame event
772 /* Preserve prefix arg that the command loop just cleared. */
773 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
774 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
775 return do_switch_frame (event
, 0, 0);
778 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
779 doc
: /* Return the frame that is now selected. */)
782 return selected_frame
;
785 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
786 doc
: /* Return the frame object that window WINDOW is on. */)
790 CHECK_LIVE_WINDOW (window
);
791 return XWINDOW (window
)->frame
;
794 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
795 doc
: /* Returns the topmost, leftmost window of FRAME.
796 If omitted, FRAME defaults to the currently selected frame. */)
803 w
= SELECTED_FRAME ()->root_window
;
806 CHECK_LIVE_FRAME (frame
);
807 w
= XFRAME (frame
)->root_window
;
809 while (NILP (XWINDOW (w
)->buffer
))
811 if (! NILP (XWINDOW (w
)->hchild
))
812 w
= XWINDOW (w
)->hchild
;
813 else if (! NILP (XWINDOW (w
)->vchild
))
814 w
= XWINDOW (w
)->vchild
;
821 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
822 Sactive_minibuffer_window
, 0, 0, 0,
823 doc
: /* Return the currently active minibuffer window, or nil if none. */)
826 return minibuf_level
? minibuf_window
: Qnil
;
829 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
830 doc
: /* Returns the root-window of FRAME.
831 If omitted, FRAME defaults to the currently selected frame. */)
838 window
= SELECTED_FRAME ()->root_window
;
841 CHECK_LIVE_FRAME (frame
);
842 window
= XFRAME (frame
)->root_window
;
848 DEFUN ("frame-selected-window", Fframe_selected_window
,
849 Sframe_selected_window
, 0, 1, 0,
850 doc
: /* Return the selected window of frame object FRAME.
851 If omitted, FRAME defaults to the currently selected frame. */)
858 window
= SELECTED_FRAME ()->selected_window
;
861 CHECK_LIVE_FRAME (frame
);
862 window
= XFRAME (frame
)->selected_window
;
868 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
869 Sset_frame_selected_window
, 2, 2, 0,
870 doc
: /* Set the selected window of frame object FRAME to WINDOW.
872 If FRAME is nil, the selected frame is used.
873 If FRAME is the selected frame, this makes WINDOW the selected window. */)
875 Lisp_Object frame
, window
;
878 frame
= selected_frame
;
880 CHECK_LIVE_FRAME (frame
);
881 CHECK_LIVE_WINDOW (window
);
883 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
884 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
886 if (EQ (frame
, selected_frame
))
887 return Fselect_window (window
, Qnil
);
889 return XFRAME (frame
)->selected_window
= window
;
892 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
894 doc
: /* Return a list of all frames. */)
898 frames
= Fcopy_sequence (Vframe_list
);
899 #ifdef HAVE_WINDOW_SYSTEM
900 if (FRAMEP (tip_frame
))
901 frames
= Fdelq (tip_frame
, frames
);
906 /* Return the next frame in the frame list after FRAME.
907 If MINIBUF is nil, exclude minibuffer-only frames.
908 If MINIBUF is a window, include only its own frame
909 and any frame now using that window as the minibuffer.
910 If MINIBUF is `visible', include all visible frames.
911 If MINIBUF is 0, include all visible and iconified frames.
912 Otherwise, include all frames. */
915 next_frame (frame
, minibuf
)
922 /* There must always be at least one frame in Vframe_list. */
923 if (! CONSP (Vframe_list
))
926 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
927 forever. Forestall that. */
928 CHECK_LIVE_FRAME (frame
);
931 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
938 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
940 /* Decide whether this frame is eligible to be returned. */
942 /* If we've looped all the way around without finding any
943 eligible frames, return the original frame. */
947 /* Let minibuf decide if this frame is acceptable. */
950 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
953 else if (EQ (minibuf
, Qvisible
))
955 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
956 if (FRAME_VISIBLE_P (XFRAME (f
)))
959 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
961 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
962 if (FRAME_VISIBLE_P (XFRAME (f
))
963 || FRAME_ICONIFIED_P (XFRAME (f
)))
966 else if (WINDOWP (minibuf
))
968 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
969 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
970 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
971 FRAME_FOCUS_FRAME (XFRAME (f
))))
983 /* Return the previous frame in the frame list before FRAME.
984 If MINIBUF is nil, exclude minibuffer-only frames.
985 If MINIBUF is a window, include only its own frame
986 and any frame now using that window as the minibuffer.
987 If MINIBUF is `visible', include all visible frames.
988 If MINIBUF is 0, include all visible and iconified frames.
989 Otherwise, include all frames. */
992 prev_frame (frame
, minibuf
)
999 /* There must always be at least one frame in Vframe_list. */
1000 if (! CONSP (Vframe_list
))
1004 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1012 if (EQ (frame
, f
) && !NILP (prev
))
1015 if (FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1017 /* Decide whether this frame is eligible to be returned,
1018 according to minibuf. */
1021 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1024 else if (WINDOWP (minibuf
))
1026 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1027 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1028 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1029 FRAME_FOCUS_FRAME (XFRAME (f
))))
1032 else if (EQ (minibuf
, Qvisible
))
1034 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1035 if (FRAME_VISIBLE_P (XFRAME (f
)))
1038 else if (XFASTINT (minibuf
) == 0)
1040 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1041 if (FRAME_VISIBLE_P (XFRAME (f
))
1042 || FRAME_ICONIFIED_P (XFRAME (f
)))
1050 /* We've scanned the entire list. */
1052 /* We went through the whole frame list without finding a single
1053 acceptable frame. Return the original frame. */
1056 /* There were no acceptable frames in the list before FRAME; otherwise,
1057 we would have returned directly from the loop. Since PREV is the last
1058 acceptable frame in the list, return it. */
1063 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1064 doc
: /* Return the next frame in the frame list after FRAME.
1065 It considers only frames on the same terminal as FRAME.
1066 By default, skip minibuffer-only frames.
1067 If omitted, FRAME defaults to the selected frame.
1068 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1069 If MINIFRAME is a window, include only its own frame
1070 and any frame now using that window as the minibuffer.
1071 If MINIFRAME is `visible', include all visible frames.
1072 If MINIFRAME is 0, include all visible and iconified frames.
1073 Otherwise, include all frames. */)
1075 Lisp_Object frame
, miniframe
;
1078 frame
= selected_frame
;
1080 CHECK_LIVE_FRAME (frame
);
1081 return next_frame (frame
, miniframe
);
1084 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1085 doc
: /* Return the previous frame in the frame list before FRAME.
1086 It considers only frames on the same terminal as FRAME.
1087 By default, skip minibuffer-only frames.
1088 If omitted, FRAME defaults to the selected frame.
1089 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1090 If MINIFRAME is a window, include only its own frame
1091 and any frame now using that window as the minibuffer.
1092 If MINIFRAME is `visible', include all visible frames.
1093 If MINIFRAME is 0, include all visible and iconified frames.
1094 Otherwise, include all frames. */)
1096 Lisp_Object frame
, miniframe
;
1099 frame
= selected_frame
;
1100 CHECK_LIVE_FRAME (frame
);
1101 return prev_frame (frame
, miniframe
);
1104 /* Return 1 if it is ok to delete frame F;
1105 0 if all frames aside from F are invisible.
1106 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1109 other_visible_frames (f
)
1112 /* We know the selected frame is visible,
1113 so if F is some other frame, it can't be the sole visible one. */
1114 if (f
== SELECTED_FRAME ())
1119 for (frames
= Vframe_list
;
1121 frames
= XCDR (frames
))
1125 this = XCAR (frames
);
1126 /* Verify that the frame's window still exists
1127 and we can still talk to it. And note any recent change
1129 #ifdef HAVE_WINDOW_SYSTEM
1130 if (FRAME_WINDOW_P (XFRAME (this)))
1132 x_sync (XFRAME (this));
1133 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1137 if (FRAME_VISIBLE_P (XFRAME (this))
1138 || FRAME_ICONIFIED_P (XFRAME (this))
1139 /* Allow deleting the terminal frame when at least
1140 one X frame exists! */
1141 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1149 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1150 doc
: /* Delete FRAME, permanently eliminating it from use.
1151 If omitted, FRAME defaults to the selected frame.
1152 A frame may not be deleted if its minibuffer is used by other frames.
1153 Normally, you may not delete a frame if all other frames are invisible,
1154 but if the second optional argument FORCE is non-nil, you may do so.
1156 This function runs `delete-frame-functions' before actually deleting the
1157 frame, unless the frame is a tooltip.
1158 The functions are run with one arg, the frame to be deleted. */)
1160 Lisp_Object frame
, force
;
1163 struct frame
*sf
= SELECTED_FRAME ();
1164 int minibuffer_selected
;
1166 if (EQ (frame
, Qnil
))
1169 XSETFRAME (frame
, f
);
1173 CHECK_FRAME (frame
);
1177 if (! FRAME_LIVE_P (f
))
1180 if (NILP (force
) && !other_visible_frames (f
)
1182 /* Terminal frame deleted before any other visible frames are
1184 && strcmp (SDATA (f
->name
), "F1") != 0
1187 error ("Attempt to delete the sole visible or iconified frame");
1190 /* This is a nice idea, but x_connection_closed needs to be able
1191 to delete the last frame, if it is gone. */
1192 if (NILP (XCDR (Vframe_list
)))
1193 error ("Attempt to delete the only frame");
1196 /* Does this frame have a minibuffer, and is it the surrogate
1197 minibuffer for any other frame? */
1198 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1202 for (frames
= Vframe_list
;
1204 frames
= XCDR (frames
))
1207 this = XCAR (frames
);
1209 if (! EQ (this, frame
)
1211 WINDOW_FRAME (XWINDOW
1212 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1213 error ("Attempt to delete a surrogate minibuffer frame");
1217 /* Run `delete-frame-functions' unless frame is a tooltip. */
1218 if (!NILP (Vrun_hooks
)
1219 && NILP (Fframe_parameter (frame
, intern ("tooltip"))))
1221 Lisp_Object args
[2];
1222 args
[0] = intern ("delete-frame-functions");
1224 Frun_hook_with_args (2, args
);
1227 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1229 /* Don't let the frame remain selected. */
1232 Lisp_Object tail
, frame1
;
1234 /* Look for another visible frame on the same terminal. */
1235 frame1
= next_frame (frame
, Qvisible
);
1237 /* If there is none, find *some* other frame. */
1238 if (NILP (frame1
) || EQ (frame1
, frame
))
1240 FOR_EACH_FRAME (tail
, frame1
)
1242 if (! EQ (frame
, frame1
))
1247 do_switch_frame (frame1
, 0, 1);
1248 sf
= SELECTED_FRAME ();
1251 /* Don't allow minibuf_window to remain on a deleted frame. */
1252 if (EQ (f
->minibuffer_window
, minibuf_window
))
1254 Fset_window_buffer (sf
->minibuffer_window
,
1255 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1256 minibuf_window
= sf
->minibuffer_window
;
1258 /* If the dying minibuffer window was selected,
1259 select the new one. */
1260 if (minibuffer_selected
)
1261 Fselect_window (minibuf_window
, Qnil
);
1264 /* Don't let echo_area_window to remain on a deleted frame. */
1265 if (EQ (f
->minibuffer_window
, echo_area_window
))
1266 echo_area_window
= sf
->minibuffer_window
;
1268 /* Clear any X selections for this frame. */
1269 #ifdef HAVE_X_WINDOWS
1271 x_clear_frame_selections (f
);
1274 if (FRAME_MAC_P (f
))
1275 x_clear_frame_selections (f
);
1279 This function must be called before the window tree of the
1280 frame is deleted because windows contain dynamically allocated
1284 /* Mark all the windows that used to be on FRAME as deleted, and then
1285 remove the reference to them. */
1286 delete_all_subwindows (XWINDOW (f
->root_window
));
1287 f
->root_window
= Qnil
;
1289 Vframe_list
= Fdelq (frame
, Vframe_list
);
1290 FRAME_SET_VISIBLE (f
, 0);
1294 if (f
->decode_mode_spec_buffer
)
1295 xfree (f
->decode_mode_spec_buffer
);
1296 if (FRAME_INSERT_COST (f
))
1297 xfree (FRAME_INSERT_COST (f
));
1298 if (FRAME_DELETEN_COST (f
))
1299 xfree (FRAME_DELETEN_COST (f
));
1300 if (FRAME_INSERTN_COST (f
))
1301 xfree (FRAME_INSERTN_COST (f
));
1302 if (FRAME_DELETE_COST (f
))
1303 xfree (FRAME_DELETE_COST (f
));
1304 if (FRAME_MESSAGE_BUF (f
))
1305 xfree (FRAME_MESSAGE_BUF (f
));
1307 /* Since some events are handled at the interrupt level, we may get
1308 an event for f at any time; if we zero out the frame's display
1309 now, then we may trip up the event-handling code. Instead, we'll
1310 promise that the display of the frame must be valid until we have
1311 called the window-system-dependent frame destruction routine. */
1313 /* I think this should be done with a hook. */
1314 #ifdef HAVE_WINDOW_SYSTEM
1315 if (FRAME_WINDOW_P (f
))
1316 x_destroy_window (f
);
1319 f
->output_data
.nothing
= 0;
1321 /* If we've deleted the last_nonminibuf_frame, then try to find
1323 if (f
== last_nonminibuf_frame
)
1327 last_nonminibuf_frame
= 0;
1329 for (frames
= Vframe_list
;
1331 frames
= XCDR (frames
))
1333 f
= XFRAME (XCAR (frames
));
1334 if (!FRAME_MINIBUF_ONLY_P (f
))
1336 last_nonminibuf_frame
= f
;
1342 /* If there's no other frame on the same kboard, get out of
1343 single-kboard state if we're in it for this kboard. */
1346 /* Some frame we found on the same kboard, or nil if there are none. */
1347 Lisp_Object frame_on_same_kboard
;
1349 frame_on_same_kboard
= Qnil
;
1351 for (frames
= Vframe_list
;
1353 frames
= XCDR (frames
))
1358 this = XCAR (frames
);
1363 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1364 frame_on_same_kboard
= this;
1367 if (NILP (frame_on_same_kboard
))
1368 not_single_kboard_state (FRAME_KBOARD (f
));
1372 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1373 find another one. Prefer minibuffer-only frames, but also notice
1374 frames with other windows. */
1375 if (EQ (frame
, FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
))
1379 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1380 Lisp_Object frame_with_minibuf
;
1381 /* Some frame we found on the same kboard, or nil if there are none. */
1382 Lisp_Object frame_on_same_kboard
;
1384 frame_on_same_kboard
= Qnil
;
1385 frame_with_minibuf
= Qnil
;
1387 for (frames
= Vframe_list
;
1389 frames
= XCDR (frames
))
1394 this = XCAR (frames
);
1399 /* Consider only frames on the same kboard
1400 and only those with minibuffers. */
1401 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
)
1402 && FRAME_HAS_MINIBUF_P (f1
))
1404 frame_with_minibuf
= this;
1405 if (FRAME_MINIBUF_ONLY_P (f1
))
1409 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1410 frame_on_same_kboard
= this;
1413 if (!NILP (frame_on_same_kboard
))
1415 /* We know that there must be some frame with a minibuffer out
1416 there. If this were not true, all of the frames present
1417 would have to be minibufferless, which implies that at some
1418 point their minibuffer frames must have been deleted, but
1419 that is prohibited at the top; you can't delete surrogate
1420 minibuffer frames. */
1421 if (NILP (frame_with_minibuf
))
1424 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1427 /* No frames left on this kboard--say no minibuffer either. */
1428 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= Qnil
;
1431 /* Cause frame titles to update--necessary if we now have just one frame. */
1432 update_mode_lines
= 1;
1437 /* Return mouse position in character cell units. */
1439 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1440 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1441 The position is given in character cells, where (0, 0) is the
1442 upper-left corner of the frame, X is the horizontal offset, and Y is
1443 the vertical offset.
1444 If Emacs is running on a mouseless terminal or hasn't been programmed
1445 to read the mouse position, it returns the selected frame for FRAME
1446 and nil for X and Y.
1447 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1448 passing the normal return value to that function as an argument,
1449 and returns whatever that function returns. */)
1453 Lisp_Object lispy_dummy
;
1454 enum scroll_bar_part party_dummy
;
1455 Lisp_Object x
, y
, retval
;
1457 unsigned long long_dummy
;
1458 struct gcpro gcpro1
;
1460 f
= SELECTED_FRAME ();
1464 /* It's okay for the hook to refrain from storing anything. */
1465 if (mouse_position_hook
)
1466 (*mouse_position_hook
) (&f
, -1,
1467 &lispy_dummy
, &party_dummy
,
1474 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1479 XSETFRAME (lispy_dummy
, f
);
1480 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1482 if (!NILP (Vmouse_position_function
))
1483 retval
= call1 (Vmouse_position_function
, retval
);
1484 RETURN_UNGCPRO (retval
);
1487 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1488 Smouse_pixel_position
, 0, 0, 0,
1489 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1490 The position is given in pixel units, where (0, 0) is the
1491 upper-left corner of the frame, X is the horizontal offset, and Y is
1492 the vertical offset.
1493 If Emacs is running on a mouseless terminal or hasn't been programmed
1494 to read the mouse position, it returns the selected frame for FRAME
1495 and nil for X and Y. */)
1499 Lisp_Object lispy_dummy
;
1500 enum scroll_bar_part party_dummy
;
1502 unsigned long long_dummy
;
1504 f
= SELECTED_FRAME ();
1508 /* It's okay for the hook to refrain from storing anything. */
1509 if (mouse_position_hook
)
1510 (*mouse_position_hook
) (&f
, -1,
1511 &lispy_dummy
, &party_dummy
,
1515 XSETFRAME (lispy_dummy
, f
);
1516 return Fcons (lispy_dummy
, Fcons (x
, y
));
1519 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1520 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1521 Coordinates are relative to the frame, not a window,
1522 so the coordinates of the top left character in the frame
1523 may be nonzero due to left-hand scroll bars or the menu bar.
1525 The position is given in character cells, where (0, 0) is the
1526 upper-left corner of the frame, X is the horizontal offset, and Y is
1527 the vertical offset.
1529 This function is a no-op for an X frame that is not visible.
1530 If you have just created a frame, you must wait for it to become visible
1531 before calling this function on it, like this.
1532 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1534 Lisp_Object frame
, x
, y
;
1536 CHECK_LIVE_FRAME (frame
);
1540 /* I think this should be done with a hook. */
1541 #ifdef HAVE_WINDOW_SYSTEM
1542 if (FRAME_WINDOW_P (XFRAME (frame
)))
1543 /* Warping the mouse will cause enternotify and focus events. */
1544 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1546 #if defined (MSDOS) && defined (HAVE_MOUSE)
1547 if (FRAME_MSDOS_P (XFRAME (frame
)))
1549 Fselect_frame (frame
);
1550 mouse_moveto (XINT (x
), XINT (y
));
1558 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1559 Sset_mouse_pixel_position
, 3, 3, 0,
1560 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1561 The position is given in pixels, where (0, 0) is the upper-left corner
1562 of the frame, X is the horizontal offset, and Y is the vertical offset.
1564 Note, this is a no-op for an X frame that is not visible.
1565 If you have just created a frame, you must wait for it to become visible
1566 before calling this function on it, like this.
1567 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1569 Lisp_Object frame
, x
, y
;
1571 CHECK_LIVE_FRAME (frame
);
1575 /* I think this should be done with a hook. */
1576 #ifdef HAVE_WINDOW_SYSTEM
1577 if (FRAME_WINDOW_P (XFRAME (frame
)))
1578 /* Warping the mouse will cause enternotify and focus events. */
1579 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1581 #if defined (MSDOS) && defined (HAVE_MOUSE)
1582 if (FRAME_MSDOS_P (XFRAME (frame
)))
1584 Fselect_frame (frame
);
1585 mouse_moveto (XINT (x
), XINT (y
));
1593 static void make_frame_visible_1
P_ ((Lisp_Object
));
1595 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1597 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1598 If omitted, FRAME defaults to the currently selected frame. */)
1603 frame
= selected_frame
;
1605 CHECK_LIVE_FRAME (frame
);
1607 /* I think this should be done with a hook. */
1608 #ifdef HAVE_WINDOW_SYSTEM
1609 if (FRAME_WINDOW_P (XFRAME (frame
)))
1611 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1612 x_make_frame_visible (XFRAME (frame
));
1616 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1618 /* Make menu bar update for the Buffers and Frames menus. */
1619 windows_or_buffers_changed
++;
1624 /* Update the display_time slot of the buffers shown in WINDOW
1625 and all its descendents. */
1628 make_frame_visible_1 (window
)
1633 for (;!NILP (window
); window
= w
->next
)
1635 w
= XWINDOW (window
);
1637 if (!NILP (w
->buffer
))
1638 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1640 if (!NILP (w
->vchild
))
1641 make_frame_visible_1 (w
->vchild
);
1642 if (!NILP (w
->hchild
))
1643 make_frame_visible_1 (w
->hchild
);
1647 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1649 doc
: /* Make the frame FRAME invisible (assuming it is an X window).
1650 If omitted, FRAME defaults to the currently selected frame.
1651 Normally you may not make FRAME invisible if all other frames are invisible,
1652 but if the second optional argument FORCE is non-nil, you may do so. */)
1654 Lisp_Object frame
, force
;
1657 frame
= selected_frame
;
1659 CHECK_LIVE_FRAME (frame
);
1661 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1662 error ("Attempt to make invisible the sole visible or iconified frame");
1664 #if 0 /* This isn't logically necessary, and it can do GC. */
1665 /* Don't let the frame remain selected. */
1666 if (EQ (frame
, selected_frame
))
1667 do_switch_frame (next_frame (frame
, Qt
), 0, 0)
1670 /* Don't allow minibuf_window to remain on a deleted frame. */
1671 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1673 struct frame
*sf
= XFRAME (selected_frame
);
1674 Fset_window_buffer (sf
->minibuffer_window
,
1675 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1676 minibuf_window
= sf
->minibuffer_window
;
1679 /* I think this should be done with a hook. */
1680 #ifdef HAVE_WINDOW_SYSTEM
1681 if (FRAME_WINDOW_P (XFRAME (frame
)))
1682 x_make_frame_invisible (XFRAME (frame
));
1685 /* Make menu bar update for the Buffers and Frames menus. */
1686 windows_or_buffers_changed
++;
1691 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1693 doc
: /* Make the frame FRAME into an icon.
1694 If omitted, FRAME defaults to the currently selected frame. */)
1699 frame
= selected_frame
;
1701 CHECK_LIVE_FRAME (frame
);
1703 #if 0 /* This isn't logically necessary, and it can do GC. */
1704 /* Don't let the frame remain selected. */
1705 if (EQ (frame
, selected_frame
))
1706 Fhandle_switch_frame (next_frame (frame
, Qt
));
1709 /* Don't allow minibuf_window to remain on a deleted frame. */
1710 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1712 struct frame
*sf
= XFRAME (selected_frame
);
1713 Fset_window_buffer (sf
->minibuffer_window
,
1714 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1715 minibuf_window
= sf
->minibuffer_window
;
1718 /* I think this should be done with a hook. */
1719 #ifdef HAVE_WINDOW_SYSTEM
1720 if (FRAME_WINDOW_P (XFRAME (frame
)))
1721 x_iconify_frame (XFRAME (frame
));
1724 /* Make menu bar update for the Buffers and Frames menus. */
1725 windows_or_buffers_changed
++;
1730 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1732 doc
: /* Return t if FRAME is now \"visible\" (actually in use for display).
1733 A frame that is not \"visible\" is not updated and, if it works through
1734 a window system, it may not show at all.
1735 Return the symbol `icon' if frame is visible only as an icon.
1737 On a text-only terminal, all frames are considered visible, whether
1738 they are currently being displayed or not, and this function returns t
1743 CHECK_LIVE_FRAME (frame
);
1745 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1747 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1749 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1754 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1756 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1759 Lisp_Object tail
, frame
;
1764 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1766 frame
= XCAR (tail
);
1767 if (!FRAMEP (frame
))
1770 if (FRAME_VISIBLE_P (f
))
1771 value
= Fcons (frame
, value
);
1777 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1778 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1779 If FRAME is invisible or iconified, make it visible.
1780 If you don't specify a frame, the selected frame is used.
1781 If Emacs is displaying on an ordinary terminal or some other device which
1782 doesn't support multiple overlapping frames, this function does nothing. */)
1787 frame
= selected_frame
;
1789 CHECK_LIVE_FRAME (frame
);
1791 /* Do like the documentation says. */
1792 Fmake_frame_visible (frame
);
1794 if (frame_raise_lower_hook
)
1795 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1800 /* Should we have a corresponding function called Flower_Power? */
1801 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1802 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1803 If you don't specify a frame, the selected frame is used.
1804 If Emacs is displaying on an ordinary terminal or some other device which
1805 doesn't support multiple overlapping frames, this function does nothing. */)
1810 frame
= selected_frame
;
1812 CHECK_LIVE_FRAME (frame
);
1814 if (frame_raise_lower_hook
)
1815 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1821 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1823 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1824 In other words, switch-frame events caused by events in FRAME will
1825 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1826 FOCUS-FRAME after reading an event typed at FRAME.
1828 If FOCUS-FRAME is omitted or nil, any existing redirection is
1829 cancelled, and the frame again receives its own keystrokes.
1831 Focus redirection is useful for temporarily redirecting keystrokes to
1832 a surrogate minibuffer frame when a frame doesn't have its own
1835 A frame's focus redirection can be changed by `select-frame'. If frame
1836 FOO is selected, and then a different frame BAR is selected, any
1837 frames redirecting their focus to FOO are shifted to redirect their
1838 focus to BAR. This allows focus redirection to work properly when the
1839 user switches from one frame to another using `select-window'.
1841 This means that a frame whose focus is redirected to itself is treated
1842 differently from a frame whose focus is redirected to nil; the former
1843 is affected by `select-frame', while the latter is not.
1845 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1846 (frame
, focus_frame
)
1847 Lisp_Object frame
, focus_frame
;
1849 /* Note that we don't check for a live frame here. It's reasonable
1850 to redirect the focus of a frame you're about to delete, if you
1851 know what other frame should receive those keystrokes. */
1852 CHECK_FRAME (frame
);
1854 if (! NILP (focus_frame
))
1855 CHECK_LIVE_FRAME (focus_frame
);
1857 XFRAME (frame
)->focus_frame
= focus_frame
;
1859 if (frame_rehighlight_hook
)
1860 (*frame_rehighlight_hook
) (XFRAME (frame
));
1866 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1867 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1868 This returns nil if FRAME's focus is not redirected.
1869 See `redirect-frame-focus'. */)
1873 CHECK_LIVE_FRAME (frame
);
1875 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1880 /* Return the value of frame parameter PROP in frame FRAME. */
1883 get_frame_param (frame
, prop
)
1884 register struct frame
*frame
;
1887 register Lisp_Object tem
;
1889 tem
= Fassq (prop
, frame
->param_alist
);
1895 /* Return the buffer-predicate of the selected frame. */
1898 frame_buffer_predicate (frame
)
1901 return XFRAME (frame
)->buffer_predicate
;
1904 /* Return the buffer-list of the selected frame. */
1907 frame_buffer_list (frame
)
1910 return XFRAME (frame
)->buffer_list
;
1913 /* Set the buffer-list of the selected frame. */
1916 set_frame_buffer_list (frame
, list
)
1917 Lisp_Object frame
, list
;
1919 XFRAME (frame
)->buffer_list
= list
;
1922 /* Discard BUFFER from the buffer-list of each frame. */
1925 frames_discard_buffer (buffer
)
1928 Lisp_Object frame
, tail
;
1930 FOR_EACH_FRAME (tail
, frame
)
1932 XFRAME (frame
)->buffer_list
1933 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1937 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1938 If the alist already has an element for PROP, we change it. */
1941 store_in_alist (alistptr
, prop
, val
)
1942 Lisp_Object
*alistptr
, val
;
1945 register Lisp_Object tem
;
1947 tem
= Fassq (prop
, *alistptr
);
1949 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1955 frame_name_fnn_p (str
, len
)
1959 if (len
> 1 && str
[0] == 'F')
1963 strtol (str
+ 1, &end_ptr
, 10);
1965 if (end_ptr
== str
+ len
)
1971 /* Set the name of the terminal frame. Also used by MSDOS frames.
1972 Modeled after x_set_name which is used for WINDOW frames. */
1975 set_term_frame_name (f
, name
)
1979 f
->explicit_name
= ! NILP (name
);
1981 /* If NAME is nil, set the name to F<num>. */
1986 /* Check for no change needed in this very common case
1987 before we do any consing. */
1988 if (frame_name_fnn_p (SDATA (f
->name
),
1992 terminal_frame_count
++;
1993 sprintf (namebuf
, "F%d", terminal_frame_count
);
1994 name
= build_string (namebuf
);
1998 CHECK_STRING (name
);
2000 /* Don't change the name if it's already NAME. */
2001 if (! NILP (Fstring_equal (name
, f
->name
)))
2004 /* Don't allow the user to set the frame name to F<num>, so it
2005 doesn't clash with the names we generate for terminal frames. */
2006 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
2007 error ("Frame names of the form F<num> are usurped by Emacs");
2011 update_mode_lines
= 1;
2015 store_frame_param (f
, prop
, val
)
2017 Lisp_Object prop
, val
;
2019 register Lisp_Object old_alist_elt
;
2021 /* The buffer-alist parameter is stored in a special place and is
2022 not in the alist. */
2023 if (EQ (prop
, Qbuffer_list
))
2025 f
->buffer_list
= val
;
2029 /* If PROP is a symbol which is supposed to have frame-local values,
2030 and it is set up based on this frame, switch to the global
2031 binding. That way, we can create or alter the frame-local binding
2032 without messing up the symbol's status. */
2035 Lisp_Object valcontents
;
2036 valcontents
= SYMBOL_VALUE (prop
);
2037 if ((BUFFER_LOCAL_VALUEP (valcontents
)
2038 || SOME_BUFFER_LOCAL_VALUEP (valcontents
))
2039 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
2040 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
2041 swap_in_global_binding (prop
);
2045 /* The tty color mode needs to be set before the frame's parameter
2046 alist is updated with the new value, because set_tty_color_mode
2047 wants to look at the old mode. */
2048 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
))
2049 set_tty_color_mode (f
, val
);
2052 /* Update the frame parameter alist. */
2053 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2054 if (EQ (old_alist_elt
, Qnil
))
2055 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2057 Fsetcdr (old_alist_elt
, val
);
2059 /* Update some other special parameters in their special places
2060 in addition to the alist. */
2062 if (EQ (prop
, Qbuffer_predicate
))
2063 f
->buffer_predicate
= val
;
2065 if (! FRAME_WINDOW_P (f
))
2067 if (EQ (prop
, Qmenu_bar_lines
))
2068 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2069 else if (EQ (prop
, Qname
))
2070 set_term_frame_name (f
, val
);
2073 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2075 if (! MINI_WINDOW_P (XWINDOW (val
)))
2076 error ("Surrogate minibuffer windows must be minibuffer windows");
2078 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2079 && !EQ (val
, f
->minibuffer_window
))
2080 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2082 /* Install the chosen minibuffer window, with proper buffer. */
2083 f
->minibuffer_window
= val
;
2087 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2088 doc
: /* Return the parameters-alist of frame FRAME.
2089 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2090 The meaningful PARMs depend on the kind of frame.
2091 If FRAME is omitted, return information on the currently selected frame. */)
2098 struct gcpro gcpro1
;
2101 frame
= selected_frame
;
2103 CHECK_FRAME (frame
);
2106 if (!FRAME_LIVE_P (f
))
2109 alist
= Fcopy_alist (f
->param_alist
);
2112 if (!FRAME_WINDOW_P (f
))
2114 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2115 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2118 /* If the frame's parameter alist says the colors are
2119 unspecified and reversed, take the frame's background pixel
2120 for foreground and vice versa. */
2121 elt
= Fassq (Qforeground_color
, alist
);
2122 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2124 if (strncmp (SDATA (XCDR (elt
)),
2126 SCHARS (XCDR (elt
))) == 0)
2127 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2128 else if (strncmp (SDATA (XCDR (elt
)),
2130 SCHARS (XCDR (elt
))) == 0)
2131 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2134 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2135 elt
= Fassq (Qbackground_color
, alist
);
2136 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2138 if (strncmp (SDATA (XCDR (elt
)),
2140 SCHARS (XCDR (elt
))) == 0)
2141 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2142 else if (strncmp (SDATA (XCDR (elt
)),
2144 SCHARS (XCDR (elt
))) == 0)
2145 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2148 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2149 store_in_alist (&alist
, intern ("font"),
2150 build_string (FRAME_MSDOS_P (f
)
2152 : FRAME_W32_P (f
) ? "w32term"
2155 store_in_alist (&alist
, Qname
, f
->name
);
2156 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2157 store_in_alist (&alist
, Qheight
, make_number (height
));
2158 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2159 store_in_alist (&alist
, Qwidth
, make_number (width
));
2160 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2161 store_in_alist (&alist
, Qminibuffer
,
2162 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2163 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2164 : FRAME_MINIBUF_WINDOW (f
)));
2165 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2166 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2168 /* I think this should be done with a hook. */
2169 #ifdef HAVE_WINDOW_SYSTEM
2170 if (FRAME_WINDOW_P (f
))
2171 x_report_frame_params (f
, &alist
);
2175 /* This ought to be correct in f->param_alist for an X frame. */
2177 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2178 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2186 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2187 doc
: /* Return FRAME's value for parameter PARAMETER.
2188 If FRAME is nil, describe the currently selected frame. */)
2190 Lisp_Object frame
, parameter
;
2196 frame
= selected_frame
;
2198 CHECK_FRAME (frame
);
2199 CHECK_SYMBOL (parameter
);
2204 if (FRAME_LIVE_P (f
))
2206 /* Avoid consing in frequent cases. */
2207 if (EQ (parameter
, Qname
))
2209 #ifdef HAVE_X_WINDOWS
2210 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2211 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2212 #endif /* HAVE_X_WINDOWS */
2213 else if (EQ (parameter
, Qbackground_color
)
2214 || EQ (parameter
, Qforeground_color
))
2216 value
= Fassq (parameter
, f
->param_alist
);
2219 value
= XCDR (value
);
2220 /* Fframe_parameters puts the actual fg/bg color names,
2221 even if f->param_alist says otherwise. This is
2222 important when param_alist's notion of colors is
2223 "unspecified". We need to do the same here. */
2224 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2226 const char *color_name
;
2229 if (EQ (parameter
, Qbackground_color
))
2231 color_name
= SDATA (value
);
2232 csz
= SCHARS (value
);
2233 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2234 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2235 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2236 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2238 else if (EQ (parameter
, Qforeground_color
))
2240 color_name
= SDATA (value
);
2241 csz
= SCHARS (value
);
2242 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2243 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2244 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2245 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2250 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2252 else if (EQ (parameter
, Qdisplay_type
)
2253 || EQ (parameter
, Qbackground_mode
))
2254 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2256 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2263 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2264 Smodify_frame_parameters
, 2, 2, 0,
2265 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2266 If FRAME is nil, it defaults to the selected frame.
2267 ALIST is an alist of parameters to change and their new values.
2268 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2269 The meaningful PARMs depend on the kind of frame.
2270 Undefined PARMs are ignored, but stored in the frame's parameter list
2271 so that `frame-parameters' will return them.
2273 The value of frame parameter FOO can also be accessed
2274 as a frame-local binding for the variable FOO, if you have
2275 enabled such bindings for that variable with `make-variable-frame-local'. */)
2277 Lisp_Object frame
, alist
;
2280 register Lisp_Object tail
, prop
, val
;
2282 if (EQ (frame
, Qnil
))
2283 frame
= selected_frame
;
2284 CHECK_LIVE_FRAME (frame
);
2287 /* I think this should be done with a hook. */
2288 #ifdef HAVE_WINDOW_SYSTEM
2289 if (FRAME_WINDOW_P (f
))
2290 x_set_frame_parameters (f
, alist
);
2294 if (FRAME_MSDOS_P (f
))
2295 IT_set_frame_parameters (f
, alist
);
2300 int length
= XINT (Flength (alist
));
2303 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2305 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2307 /* Extract parm names and values into those vectors. */
2310 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2315 parms
[i
] = Fcar (elt
);
2316 values
[i
] = Fcdr (elt
);
2320 /* Now process them in reverse of specified order. */
2321 for (i
--; i
>= 0; i
--)
2325 store_frame_param (f
, prop
, val
);
2327 /* Changing the background color might change the background
2328 mode, so that we have to load new defface specs.
2329 Call frame-set-background-mode to do that. */
2330 if (EQ (prop
, Qbackground_color
))
2331 call1 (Qframe_set_background_mode
, frame
);
2338 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2340 doc
: /* Height in pixels of a line in the font in frame FRAME.
2341 If FRAME is omitted, the selected frame is used.
2342 For a terminal frame, the value is always 1. */)
2349 frame
= selected_frame
;
2350 CHECK_FRAME (frame
);
2353 #ifdef HAVE_WINDOW_SYSTEM
2354 if (FRAME_WINDOW_P (f
))
2355 return make_number (x_char_height (f
));
2358 return make_number (1);
2362 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2364 doc
: /* Width in pixels of characters in the font in frame FRAME.
2365 If FRAME is omitted, the selected frame is used.
2366 On a graphical screen, the width is the standard width of the default font.
2367 For a terminal screen, the value is always 1. */)
2374 frame
= selected_frame
;
2375 CHECK_FRAME (frame
);
2378 #ifdef HAVE_WINDOW_SYSTEM
2379 if (FRAME_WINDOW_P (f
))
2380 return make_number (x_char_width (f
));
2383 return make_number (1);
2386 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2387 Sframe_pixel_height
, 0, 1, 0,
2388 doc
: /* Return a FRAME's height in pixels.
2389 This counts only the height available for text lines,
2390 not menu bars on window-system Emacs frames.
2391 For a terminal frame, the result really gives the height in characters.
2392 If FRAME is omitted, the selected frame is used. */)
2399 frame
= selected_frame
;
2400 CHECK_FRAME (frame
);
2403 #ifdef HAVE_WINDOW_SYSTEM
2404 if (FRAME_WINDOW_P (f
))
2405 return make_number (x_pixel_height (f
));
2408 return make_number (FRAME_LINES (f
));
2411 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2412 Sframe_pixel_width
, 0, 1, 0,
2413 doc
: /* Return FRAME's width in pixels.
2414 For a terminal frame, the result really gives the width in characters.
2415 If FRAME is omitted, the selected frame is used. */)
2422 frame
= selected_frame
;
2423 CHECK_FRAME (frame
);
2426 #ifdef HAVE_WINDOW_SYSTEM
2427 if (FRAME_WINDOW_P (f
))
2428 return make_number (x_pixel_width (f
));
2431 return make_number (FRAME_COLS (f
));
2434 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2435 doc
: /* Specify that the frame FRAME has LINES lines.
2436 Optional third arg non-nil means that redisplay should use LINES lines
2437 but that the idea of the actual height of the frame should not be changed. */)
2438 (frame
, lines
, pretend
)
2439 Lisp_Object frame
, lines
, pretend
;
2441 register struct frame
*f
;
2443 CHECK_NUMBER (lines
);
2445 frame
= selected_frame
;
2446 CHECK_LIVE_FRAME (frame
);
2449 /* I think this should be done with a hook. */
2450 #ifdef HAVE_WINDOW_SYSTEM
2451 if (FRAME_WINDOW_P (f
))
2453 if (XINT (lines
) != FRAME_LINES (f
))
2454 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2455 do_pending_window_change (0);
2459 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2463 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2464 doc
: /* Specify that the frame FRAME has COLS columns.
2465 Optional third arg non-nil means that redisplay should use COLS columns
2466 but that the idea of the actual width of the frame should not be changed. */)
2467 (frame
, cols
, pretend
)
2468 Lisp_Object frame
, cols
, pretend
;
2470 register struct frame
*f
;
2471 CHECK_NUMBER (cols
);
2473 frame
= selected_frame
;
2474 CHECK_LIVE_FRAME (frame
);
2477 /* I think this should be done with a hook. */
2478 #ifdef HAVE_WINDOW_SYSTEM
2479 if (FRAME_WINDOW_P (f
))
2481 if (XINT (cols
) != FRAME_COLS (f
))
2482 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2483 do_pending_window_change (0);
2487 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2491 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2492 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2494 Lisp_Object frame
, cols
, rows
;
2496 register struct frame
*f
;
2498 CHECK_LIVE_FRAME (frame
);
2499 CHECK_NUMBER (cols
);
2500 CHECK_NUMBER (rows
);
2503 /* I think this should be done with a hook. */
2504 #ifdef HAVE_WINDOW_SYSTEM
2505 if (FRAME_WINDOW_P (f
))
2507 if (XINT (rows
) != FRAME_LINES (f
)
2508 || XINT (cols
) != FRAME_COLS (f
)
2509 || f
->new_text_lines
|| f
->new_text_cols
)
2510 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2511 do_pending_window_change (0);
2515 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2520 DEFUN ("set-frame-position", Fset_frame_position
,
2521 Sset_frame_position
, 3, 3, 0,
2522 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2523 This is actually the position of the upper left corner of the frame.
2524 Negative values for XOFFSET or YOFFSET are interpreted relative to
2525 the rightmost or bottommost possible position (that stays within the screen). */)
2526 (frame
, xoffset
, yoffset
)
2527 Lisp_Object frame
, xoffset
, yoffset
;
2529 register struct frame
*f
;
2531 CHECK_LIVE_FRAME (frame
);
2532 CHECK_NUMBER (xoffset
);
2533 CHECK_NUMBER (yoffset
);
2536 /* I think this should be done with a hook. */
2537 #ifdef HAVE_WINDOW_SYSTEM
2538 if (FRAME_WINDOW_P (f
))
2539 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2546 /***********************************************************************
2548 ***********************************************************************/
2550 /* Connect the frame-parameter names for X frames
2551 to the ways of passing the parameter values to the window system.
2553 The name of a parameter, as a Lisp symbol,
2554 has an `x-frame-parameter' property which is an integer in Lisp
2555 that is an index in this table. */
2557 struct frame_parm_table
{
2559 Lisp_Object
*variable
;
2562 static struct frame_parm_table frame_parms
[] =
2564 {"auto-raise", &Qauto_raise
},
2565 {"auto-lower", &Qauto_lower
},
2566 {"background-color", 0},
2567 {"border-color", &Qborder_color
},
2568 {"border-width", &Qborder_width
},
2569 {"cursor-color", &Qcursor_color
},
2570 {"cursor-type", &Qcursor_type
},
2572 {"foreground-color", 0},
2573 {"icon-name", &Qicon_name
},
2574 {"icon-type", &Qicon_type
},
2575 {"internal-border-width", &Qinternal_border_width
},
2576 {"menu-bar-lines", &Qmenu_bar_lines
},
2577 {"mouse-color", &Qmouse_color
},
2579 {"scroll-bar-width", &Qscroll_bar_width
},
2581 {"unsplittable", &Qunsplittable
},
2582 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2583 {"visibility", &Qvisibility
},
2584 {"tool-bar-lines", &Qtool_bar_lines
},
2585 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2586 {"scroll-bar-background", &Qscroll_bar_background
},
2587 {"screen-gamma", &Qscreen_gamma
},
2588 {"line-spacing", &Qline_spacing
},
2589 {"left-fringe", &Qleft_fringe
},
2590 {"right-fringe", &Qright_fringe
},
2591 {"wait-for-wm", &Qwait_for_wm
},
2592 {"fullscreen", &Qfullscreen
},
2593 #ifdef USE_FONT_BACKEND
2594 {"font-backend", &Qfont_backend
}
2595 #endif /* USE_FONT_BACKEND */
2598 #ifdef HAVE_WINDOW_SYSTEM
2600 extern Lisp_Object Qbox
;
2601 extern Lisp_Object Qtop
;
2603 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2604 wanted positions of the WM window (not Emacs window).
2605 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2606 window (FRAME_X_WINDOW).
2610 x_fullscreen_adjust (f
, width
, height
, top_pos
, left_pos
)
2617 int newwidth
= FRAME_COLS (f
);
2618 int newheight
= FRAME_LINES (f
);
2620 *top_pos
= f
->top_pos
;
2621 *left_pos
= f
->left_pos
;
2623 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2627 ph
= FRAME_X_DISPLAY_INFO (f
)->height
;
2628 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2629 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2630 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2634 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2638 pw
= FRAME_X_DISPLAY_INFO (f
)->width
;
2639 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2640 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2641 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2646 *height
= newheight
;
2650 /* Change the parameters of frame F as specified by ALIST.
2651 If a parameter is not specially recognized, do nothing special;
2652 otherwise call the `x_set_...' function for that parameter.
2653 Except for certain geometry properties, always call store_frame_param
2654 to store the new value in the parameter alist. */
2657 x_set_frame_parameters (f
, alist
)
2663 /* If both of these parameters are present, it's more efficient to
2664 set them both at once. So we wait until we've looked at the
2665 entire list before we set them. */
2669 Lisp_Object left
, top
;
2671 /* Same with these. */
2672 Lisp_Object icon_left
, icon_top
;
2674 /* Record in these vectors all the parms specified. */
2676 Lisp_Object
*values
;
2678 int left_no_change
= 0, top_no_change
= 0;
2679 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2680 int fullscreen_is_being_set
= 0;
2682 struct gcpro gcpro1
, gcpro2
;
2685 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2688 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2689 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2691 /* Extract parm names and values into those vectors. */
2694 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2699 parms
[i
] = Fcar (elt
);
2700 values
[i
] = Fcdr (elt
);
2703 /* TAIL and ALIST are not used again below here. */
2704 alist
= tail
= Qnil
;
2706 GCPRO2 (*parms
, *values
);
2710 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2711 because their values appear in VALUES and strings are not valid. */
2712 top
= left
= Qunbound
;
2713 icon_left
= icon_top
= Qunbound
;
2715 /* Provide default values for HEIGHT and WIDTH. */
2716 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2717 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2719 /* Process foreground_color and background_color before anything else.
2720 They are independent of other properties, but other properties (e.g.,
2721 cursor_color) are dependent upon them. */
2722 /* Process default font as well, since fringe widths depends on it. */
2723 /* Also, process fullscreen, width and height depend upon that */
2724 for (p
= 0; p
< i
; p
++)
2726 Lisp_Object prop
, val
;
2730 if (EQ (prop
, Qforeground_color
)
2731 || EQ (prop
, Qbackground_color
)
2733 || EQ (prop
, Qfullscreen
))
2735 register Lisp_Object param_index
, old_value
;
2736 int count
= SPECPDL_INDEX ();
2738 old_value
= get_frame_param (f
, prop
);
2739 fullscreen_is_being_set
|= EQ (prop
, Qfullscreen
);
2741 if (NILP (Fequal (val
, old_value
)))
2743 /* For :font attributes, the frame_parm_handler
2744 x_set_font calls `face-set-after-frame-default'.
2745 Unless we bind inhibit-face-set-after-frame-default
2746 here, this would reset the :font attribute that we
2747 just applied to the default value for new faces. */
2748 specbind (Qinhibit_face_set_after_frame_default
, Qt
);
2750 store_frame_param (f
, prop
, val
);
2752 param_index
= Fget (prop
, Qx_frame_parameter
);
2753 if (NATNUMP (param_index
)
2754 && (XFASTINT (param_index
)
2755 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2756 && rif
->frame_parm_handlers
[XINT (param_index
)])
2757 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2759 unbind_to (count
, Qnil
);
2764 /* Now process them in reverse of specified order. */
2765 for (i
--; i
>= 0; i
--)
2767 Lisp_Object prop
, val
;
2772 if (EQ (prop
, Qwidth
) && NUMBERP (val
))
2773 width
= XFASTINT (val
);
2774 else if (EQ (prop
, Qheight
) && NUMBERP (val
))
2775 height
= XFASTINT (val
);
2776 else if (EQ (prop
, Qtop
))
2778 else if (EQ (prop
, Qleft
))
2780 else if (EQ (prop
, Qicon_top
))
2782 else if (EQ (prop
, Qicon_left
))
2784 else if (EQ (prop
, Qforeground_color
)
2785 || EQ (prop
, Qbackground_color
)
2787 || EQ (prop
, Qfullscreen
))
2788 /* Processed above. */
2792 register Lisp_Object param_index
, old_value
;
2794 old_value
= get_frame_param (f
, prop
);
2796 store_frame_param (f
, prop
, val
);
2798 param_index
= Fget (prop
, Qx_frame_parameter
);
2799 if (NATNUMP (param_index
)
2800 && (XFASTINT (param_index
)
2801 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2802 && rif
->frame_parm_handlers
[XINT (param_index
)])
2803 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2807 /* Don't die if just one of these was set. */
2808 if (EQ (left
, Qunbound
))
2811 if (f
->left_pos
< 0)
2812 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2814 XSETINT (left
, f
->left_pos
);
2816 if (EQ (top
, Qunbound
))
2820 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2822 XSETINT (top
, f
->top_pos
);
2825 /* If one of the icon positions was not set, preserve or default it. */
2826 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
2828 icon_left_no_change
= 1;
2829 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2830 if (NILP (icon_left
))
2831 XSETINT (icon_left
, 0);
2833 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
2835 icon_top_no_change
= 1;
2836 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2837 if (NILP (icon_top
))
2838 XSETINT (icon_top
, 0);
2841 if (FRAME_VISIBLE_P (f
) && fullscreen_is_being_set
)
2843 /* If the frame is visible already and the fullscreen parameter is
2844 being set, it is too late to set WM manager hints to specify
2846 Here we first get the width, height and position that applies to
2847 fullscreen. We then move the frame to the appropriate
2848 position. Resize of the frame is taken care of in the code after
2849 this if-statement. */
2850 int new_left
, new_top
;
2852 x_fullscreen_adjust (f
, &width
, &height
, &new_top
, &new_left
);
2853 if (new_top
!= f
->top_pos
|| new_left
!= f
->left_pos
)
2854 x_set_offset (f
, new_left
, new_top
, 1);
2857 /* Don't set these parameters unless they've been explicitly
2858 specified. The window might be mapped or resized while we're in
2859 this function, and we don't want to override that unless the lisp
2860 code has asked for it.
2862 Don't set these parameters unless they actually differ from the
2863 window's current parameters; the window may not actually exist
2868 check_frame_size (f
, &height
, &width
);
2870 XSETFRAME (frame
, f
);
2872 if (width
!= FRAME_COLS (f
)
2873 || height
!= FRAME_LINES (f
)
2874 || f
->new_text_lines
|| f
->new_text_cols
)
2875 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2877 if ((!NILP (left
) || !NILP (top
))
2878 && ! (left_no_change
&& top_no_change
)
2879 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2880 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2885 /* Record the signs. */
2886 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2887 if (EQ (left
, Qminus
))
2888 f
->size_hint_flags
|= XNegative
;
2889 else if (INTEGERP (left
))
2891 leftpos
= XINT (left
);
2893 f
->size_hint_flags
|= XNegative
;
2895 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2896 && CONSP (XCDR (left
))
2897 && INTEGERP (XCAR (XCDR (left
))))
2899 leftpos
= - XINT (XCAR (XCDR (left
)));
2900 f
->size_hint_flags
|= XNegative
;
2902 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2903 && CONSP (XCDR (left
))
2904 && INTEGERP (XCAR (XCDR (left
))))
2906 leftpos
= XINT (XCAR (XCDR (left
)));
2909 if (EQ (top
, Qminus
))
2910 f
->size_hint_flags
|= YNegative
;
2911 else if (INTEGERP (top
))
2913 toppos
= XINT (top
);
2915 f
->size_hint_flags
|= YNegative
;
2917 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2918 && CONSP (XCDR (top
))
2919 && INTEGERP (XCAR (XCDR (top
))))
2921 toppos
= - XINT (XCAR (XCDR (top
)));
2922 f
->size_hint_flags
|= YNegative
;
2924 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2925 && CONSP (XCDR (top
))
2926 && INTEGERP (XCAR (XCDR (top
))))
2928 toppos
= XINT (XCAR (XCDR (top
)));
2932 /* Store the numeric value of the position. */
2933 f
->top_pos
= toppos
;
2934 f
->left_pos
= leftpos
;
2936 f
->win_gravity
= NorthWestGravity
;
2938 /* Actually set that position, and convert to absolute. */
2939 x_set_offset (f
, leftpos
, toppos
, -1);
2942 if ((!NILP (icon_left
) || !NILP (icon_top
))
2943 && ! (icon_left_no_change
&& icon_top_no_change
))
2944 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2951 /* Insert a description of internally-recorded parameters of frame X
2952 into the parameter alist *ALISTPTR that is to be given to the user.
2953 Only parameters that are specific to the X window system
2954 and whose values are not correctly recorded in the frame's
2955 param_alist need to be considered here. */
2958 x_report_frame_params (f
, alistptr
)
2960 Lisp_Object
*alistptr
;
2965 /* Represent negative positions (off the top or left screen edge)
2966 in a way that Fmodify_frame_parameters will understand correctly. */
2967 XSETINT (tem
, f
->left_pos
);
2968 if (f
->left_pos
>= 0)
2969 store_in_alist (alistptr
, Qleft
, tem
);
2971 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2973 XSETINT (tem
, f
->top_pos
);
2974 if (f
->top_pos
>= 0)
2975 store_in_alist (alistptr
, Qtop
, tem
);
2977 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2979 store_in_alist (alistptr
, Qborder_width
,
2980 make_number (f
->border_width
));
2981 store_in_alist (alistptr
, Qinternal_border_width
,
2982 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
2983 store_in_alist (alistptr
, Qleft_fringe
,
2984 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
2985 store_in_alist (alistptr
, Qright_fringe
,
2986 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
2987 store_in_alist (alistptr
, Qscroll_bar_width
,
2988 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2990 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
2991 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
2992 /* nil means "use default width"
2993 for non-toolkit scroll bar.
2994 ruler-mode.el depends on this. */
2996 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
2997 store_in_alist (alistptr
, Qwindow_id
,
2998 build_string (buf
));
2999 #ifdef HAVE_X_WINDOWS
3000 #ifdef USE_X_TOOLKIT
3001 /* Tooltip frame may not have this widget. */
3002 if (FRAME_X_OUTPUT (f
)->widget
)
3004 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
3005 store_in_alist (alistptr
, Qouter_window_id
,
3006 build_string (buf
));
3008 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3009 FRAME_SAMPLE_VISIBILITY (f
);
3010 store_in_alist (alistptr
, Qvisibility
,
3011 (FRAME_VISIBLE_P (f
) ? Qt
3012 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3013 store_in_alist (alistptr
, Qdisplay
,
3014 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3016 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3019 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3020 store_in_alist (alistptr
, Qparent_id
, tem
);
3024 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3025 the previous value of that parameter, NEW_VALUE is the new value. */
3028 x_set_fullscreen (f
, new_value
, old_value
)
3030 Lisp_Object new_value
, old_value
;
3032 if (NILP (new_value
))
3033 f
->want_fullscreen
= FULLSCREEN_NONE
;
3034 else if (EQ (new_value
, Qfullboth
))
3035 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3036 else if (EQ (new_value
, Qfullwidth
))
3037 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3038 else if (EQ (new_value
, Qfullheight
))
3039 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3041 if (fullscreen_hook
!= NULL
)
3042 fullscreen_hook (f
);
3046 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3047 the previous value of that parameter, NEW_VALUE is the new value. */
3050 x_set_line_spacing (f
, new_value
, old_value
)
3052 Lisp_Object new_value
, old_value
;
3054 if (NILP (new_value
))
3055 f
->extra_line_spacing
= 0;
3056 else if (NATNUMP (new_value
))
3057 f
->extra_line_spacing
= XFASTINT (new_value
);
3059 signal_error ("Invalid line-spacing", new_value
);
3060 if (FRAME_VISIBLE_P (f
))
3065 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3066 the previous value of that parameter, NEW_VALUE is the new value. */
3069 x_set_screen_gamma (f
, new_value
, old_value
)
3071 Lisp_Object new_value
, old_value
;
3073 Lisp_Object bgcolor
;
3075 if (NILP (new_value
))
3077 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3078 /* The value 0.4545 is the normal viewing gamma. */
3079 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3081 signal_error ("Invalid screen-gamma", new_value
);
3083 /* Apply the new gamma value to the frame background. */
3084 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3085 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3087 Lisp_Object index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3089 && (XFASTINT (index
)
3090 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3091 && rif
->frame_parm_handlers
[XFASTINT (index
)])
3092 (*(rif
->frame_parm_handlers
[XFASTINT (index
)]))
3096 Fclear_face_cache (Qnil
);
3101 x_set_font (f
, arg
, oldval
)
3103 Lisp_Object arg
, oldval
;
3106 Lisp_Object fontset_name
;
3108 int old_fontset
= FRAME_FONTSET(f
);
3110 #ifdef USE_FONT_BACKEND
3111 if (enable_font_backend
)
3114 Lisp_Object font_object
;
3116 /* ARG is a fontset name, a font name, or a font object.
3117 In the last case, this function never fail. */
3120 fontset
= fs_query_fontset (arg
, 0);
3122 font_object
= font_open_by_name (f
, SDATA (arg
));
3123 else if (fontset
> 0)
3125 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3127 font_object
= font_open_by_name (f
, SDATA (ascii_font
));
3133 if (fontset
< 0 && ! NILP (font_object
))
3134 fontset
= new_fontset_from_font (font_object
);
3137 /* Refuse the default fontset. */
3139 else if (NILP (font_object
))
3142 result
= x_new_fontset2 (f
, fontset
, font_object
);
3146 #endif /* USE_FONT_BACKEND */
3149 fontset_name
= Fquery_fontset (arg
, Qnil
);
3152 result
= (STRINGP (fontset_name
)
3153 ? x_new_fontset (f
, fontset_name
)
3154 : x_new_fontset (f
, arg
));
3156 #ifdef USE_FONT_BACKEND
3160 if (EQ (result
, Qnil
))
3161 error ("Font `%s' is not defined", SDATA (arg
));
3162 else if (EQ (result
, Qt
))
3163 error ("The default fontset can't be used for a frame font");
3164 else if (STRINGP (result
))
3166 set_default_ascii_font (result
);
3167 if (STRINGP (fontset_name
))
3169 /* Fontset names are built from ASCII font names, so the
3170 names may be equal despite there was a change. */
3171 if (old_fontset
== FRAME_FONTSET (f
))
3174 store_frame_param (f
, Qfont
, result
);
3176 if (!NILP (Fequal (result
, oldval
)))
3179 /* Recalculate toolbar height. */
3180 f
->n_tool_bar_rows
= 0;
3181 /* Ensure we redraw it. */
3182 clear_current_matrices (f
);
3184 recompute_basic_faces (f
);
3189 do_pending_window_change (0);
3191 /* Don't call `face-set-after-frame-default' when faces haven't been
3192 initialized yet. This is the case when called from
3193 Fx_create_frame. In that case, the X widget or window doesn't
3194 exist either, and we can end up in x_report_frame_params with a
3195 null widget which gives a segfault. */
3196 if (FRAME_FACE_CACHE (f
))
3198 XSETFRAME (frame
, f
);
3199 call1 (Qface_set_after_frame_default
, frame
);
3204 #ifdef USE_FONT_BACKEND
3206 x_set_font_backend (f
, new_value
, old_value
)
3208 Lisp_Object new_value
, old_value
;
3210 if (! NILP (new_value
)
3211 && !CONSP (new_value
))
3215 CHECK_STRING (new_value
);
3216 p0
= p1
= SDATA (new_value
);
3220 while (*p1
&& *p1
!= ',') p1
++;
3222 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3228 new_value
= Fnreverse (new_value
);
3231 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3234 if (FRAME_FONT_OBJECT (f
))
3236 free_all_realized_faces (Qnil
);
3237 Fclear_font_cache ();
3240 new_value
= font_update_drivers (f
, new_value
);
3241 if (NILP (new_value
))
3242 error ("No font backend available");
3243 store_frame_param (f
, Qfont_backend
, new_value
);
3245 if (FRAME_FONT_OBJECT (f
))
3249 XSETFRAME (frame
, f
);
3250 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3251 ++face_change_count
;
3252 ++windows_or_buffers_changed
;
3255 #endif /* USE_FONT_BACKEND */
3259 x_set_fringe_width (f
, new_value
, old_value
)
3261 Lisp_Object new_value
, old_value
;
3263 compute_fringe_widths (f
, 1);
3267 x_set_border_width (f
, arg
, oldval
)
3269 Lisp_Object arg
, oldval
;
3273 if (XINT (arg
) == f
->border_width
)
3276 if (FRAME_X_WINDOW (f
) != 0)
3277 error ("Cannot change the border width of a frame");
3279 f
->border_width
= XINT (arg
);
3283 x_set_internal_border_width (f
, arg
, oldval
)
3285 Lisp_Object arg
, oldval
;
3287 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3290 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3291 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3292 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3294 #ifdef USE_X_TOOLKIT
3295 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3296 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3299 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3302 if (FRAME_X_WINDOW (f
) != 0)
3304 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3305 SET_FRAME_GARBAGED (f
);
3306 do_pending_window_change (0);
3309 SET_FRAME_GARBAGED (f
);
3313 x_set_visibility (f
, value
, oldval
)
3315 Lisp_Object value
, oldval
;
3318 XSETFRAME (frame
, f
);
3321 Fmake_frame_invisible (frame
, Qt
);
3322 else if (EQ (value
, Qicon
))
3323 Ficonify_frame (frame
);
3325 Fmake_frame_visible (frame
);
3329 x_set_autoraise (f
, arg
, oldval
)
3331 Lisp_Object arg
, oldval
;
3333 f
->auto_raise
= !EQ (Qnil
, arg
);
3337 x_set_autolower (f
, arg
, oldval
)
3339 Lisp_Object arg
, oldval
;
3341 f
->auto_lower
= !EQ (Qnil
, arg
);
3345 x_set_unsplittable (f
, arg
, oldval
)
3347 Lisp_Object arg
, oldval
;
3349 f
->no_split
= !NILP (arg
);
3353 x_set_vertical_scroll_bars (f
, arg
, oldval
)
3355 Lisp_Object arg
, oldval
;
3357 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3358 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3359 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3360 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3362 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3364 ? vertical_scroll_bar_none
3366 ? vertical_scroll_bar_left
3368 ? vertical_scroll_bar_right
3369 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3370 ? vertical_scroll_bar_left
3371 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3372 ? vertical_scroll_bar_right
3373 : vertical_scroll_bar_none
);
3375 /* We set this parameter before creating the X window for the
3376 frame, so we can get the geometry right from the start.
3377 However, if the window hasn't been created yet, we shouldn't
3378 call x_set_window_size. */
3379 if (FRAME_X_WINDOW (f
))
3380 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3381 do_pending_window_change (0);
3386 x_set_scroll_bar_width (f
, arg
, oldval
)
3388 Lisp_Object arg
, oldval
;
3390 int wid
= FRAME_COLUMN_WIDTH (f
);
3394 x_set_scroll_bar_default_width (f
);
3396 if (FRAME_X_WINDOW (f
))
3397 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3398 do_pending_window_change (0);
3400 else if (INTEGERP (arg
) && XINT (arg
) > 0
3401 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3403 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3404 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3406 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3407 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3408 if (FRAME_X_WINDOW (f
))
3409 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3410 do_pending_window_change (0);
3413 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3414 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3415 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3420 /* Return non-nil if frame F wants a bitmap icon. */
3428 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3436 /* Subroutines of creating an X frame. */
3438 /* Make sure that Vx_resource_name is set to a reasonable value.
3439 Fix it up, or set it to `emacs' if it is too hopeless. */
3442 validate_x_resource_name ()
3445 /* Number of valid characters in the resource name. */
3447 /* Number of invalid characters in the resource name. */
3452 if (!STRINGP (Vx_resource_class
))
3453 Vx_resource_class
= build_string (EMACS_CLASS
);
3455 if (STRINGP (Vx_resource_name
))
3457 unsigned char *p
= SDATA (Vx_resource_name
);
3460 len
= SBYTES (Vx_resource_name
);
3462 /* Only letters, digits, - and _ are valid in resource names.
3463 Count the valid characters and count the invalid ones. */
3464 for (i
= 0; i
< len
; i
++)
3467 if (! ((c
>= 'a' && c
<= 'z')
3468 || (c
>= 'A' && c
<= 'Z')
3469 || (c
>= '0' && c
<= '9')
3470 || c
== '-' || c
== '_'))
3477 /* Not a string => completely invalid. */
3478 bad_count
= 5, good_count
= 0;
3480 /* If name is valid already, return. */
3484 /* If name is entirely invalid, or nearly so, use `emacs'. */
3486 || (good_count
== 1 && bad_count
> 0))
3488 Vx_resource_name
= build_string ("emacs");
3492 /* Name is partly valid. Copy it and replace the invalid characters
3493 with underscores. */
3495 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3497 for (i
= 0; i
< len
; i
++)
3499 int c
= SREF (new, i
);
3500 if (! ((c
>= 'a' && c
<= 'z')
3501 || (c
>= 'A' && c
<= 'Z')
3502 || (c
>= '0' && c
<= '9')
3503 || c
== '-' || c
== '_'))
3509 extern char *x_get_string_resource
P_ ((XrmDatabase
, char *, char *));
3510 extern Display_Info
*check_x_display_info
P_ ((Lisp_Object
));
3513 /* Get specified attribute from resource database RDB.
3514 See Fx_get_resource below for other parameters. */
3517 xrdb_get_resource (rdb
, attribute
, class, component
, subclass
)
3519 Lisp_Object attribute
, class, component
, subclass
;
3521 register char *value
;
3525 CHECK_STRING (attribute
);
3526 CHECK_STRING (class);
3528 if (!NILP (component
))
3529 CHECK_STRING (component
);
3530 if (!NILP (subclass
))
3531 CHECK_STRING (subclass
);
3532 if (NILP (component
) != NILP (subclass
))
3533 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3535 validate_x_resource_name ();
3537 /* Allocate space for the components, the dots which separate them,
3538 and the final '\0'. Make them big enough for the worst case. */
3539 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3540 + (STRINGP (component
)
3541 ? SBYTES (component
) : 0)
3542 + SBYTES (attribute
)
3545 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3547 + (STRINGP (subclass
)
3548 ? SBYTES (subclass
) : 0)
3551 /* Start with emacs.FRAMENAME for the name (the specific one)
3552 and with `Emacs' for the class key (the general one). */
3553 strcpy (name_key
, SDATA (Vx_resource_name
));
3554 strcpy (class_key
, SDATA (Vx_resource_class
));
3556 strcat (class_key
, ".");
3557 strcat (class_key
, SDATA (class));
3559 if (!NILP (component
))
3561 strcat (class_key
, ".");
3562 strcat (class_key
, SDATA (subclass
));
3564 strcat (name_key
, ".");
3565 strcat (name_key
, SDATA (component
));
3568 strcat (name_key
, ".");
3569 strcat (name_key
, SDATA (attribute
));
3571 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3573 if (value
!= (char *) 0)
3574 return build_string (value
);
3580 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3581 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3582 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3583 class, where INSTANCE is the name under which Emacs was invoked, or
3584 the name specified by the `-name' or `-rn' command-line arguments.
3586 The optional arguments COMPONENT and SUBCLASS add to the key and the
3587 class, respectively. You must specify both of them or neither.
3588 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3589 and the class is `Emacs.CLASS.SUBCLASS'. */)
3590 (attribute
, class, component
, subclass
)
3591 Lisp_Object attribute
, class, component
, subclass
;
3593 #ifdef HAVE_X_WINDOWS
3597 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3598 attribute
, class, component
, subclass
);
3601 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3604 display_x_get_resource (dpyinfo
, attribute
, class, component
, subclass
)
3605 Display_Info
*dpyinfo
;
3606 Lisp_Object attribute
, class, component
, subclass
;
3608 return xrdb_get_resource (dpyinfo
->xrdb
,
3609 attribute
, class, component
, subclass
);
3612 /* Used when C code wants a resource value. */
3615 x_get_resource_string (attribute
, class)
3616 char *attribute
, *class;
3620 struct frame
*sf
= SELECTED_FRAME ();
3622 /* Allocate space for the components, the dots which separate them,
3623 and the final '\0'. */
3624 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3625 + strlen (attribute
) + 2);
3626 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3627 + strlen (class) + 2);
3629 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3630 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3632 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3633 name_key
, class_key
);
3637 /* Return the value of parameter PARAM.
3639 First search ALIST, then Vdefault_frame_alist, then the X defaults
3640 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3642 Convert the resource to the type specified by desired_type.
3644 If no default is specified, return Qunbound. If you call
3645 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3646 and don't let it get stored in any Lisp-visible variables! */
3649 x_get_arg (dpyinfo
, alist
, param
, attribute
, class, type
)
3650 Display_Info
*dpyinfo
;
3651 Lisp_Object alist
, param
;
3654 enum resource_types type
;
3656 register Lisp_Object tem
;
3658 tem
= Fassq (param
, alist
);
3662 /* If we find this parm in ALIST, clear it out
3663 so that it won't be "left over" at the end. */
3664 #ifndef WINDOWSNT /* w32fns.c has not yet been changed to cope with this. */
3666 XSETCAR (tem
, Qnil
);
3667 /* In case the parameter appears more than once in the alist,
3669 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3670 if (CONSP (XCAR (tail
))
3671 && EQ (XCAR (XCAR (tail
)), param
))
3672 XSETCAR (XCAR (tail
), Qnil
);
3676 tem
= Fassq (param
, Vdefault_frame_alist
);
3678 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3679 look in the X resources. */
3684 tem
= display_x_get_resource (dpyinfo
,
3685 build_string (attribute
),
3686 build_string (class),
3694 case RES_TYPE_NUMBER
:
3695 return make_number (atoi (SDATA (tem
)));
3697 case RES_TYPE_FLOAT
:
3698 return make_float (atof (SDATA (tem
)));
3700 case RES_TYPE_BOOLEAN
:
3701 tem
= Fdowncase (tem
);
3702 if (!strcmp (SDATA (tem
), "on")
3703 || !strcmp (SDATA (tem
), "true"))
3708 case RES_TYPE_STRING
:
3711 case RES_TYPE_SYMBOL
:
3712 /* As a special case, we map the values `true' and `on'
3713 to Qt, and `false' and `off' to Qnil. */
3716 lower
= Fdowncase (tem
);
3717 if (!strcmp (SDATA (lower
), "on")
3718 || !strcmp (SDATA (lower
), "true"))
3720 else if (!strcmp (SDATA (lower
), "off")
3721 || !strcmp (SDATA (lower
), "false"))
3724 return Fintern (tem
, Qnil
);
3738 x_frame_get_arg (f
, alist
, param
, attribute
, class, type
)
3740 Lisp_Object alist
, param
;
3743 enum resource_types type
;
3745 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3746 alist
, param
, attribute
, class, type
);
3749 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3752 x_frame_get_and_record_arg (f
, alist
, param
, attribute
, class, type
)
3754 Lisp_Object alist
, param
;
3757 enum resource_types type
;
3761 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3762 attribute
, class, type
);
3763 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3764 store_frame_param (f
, param
, value
);
3770 /* Record in frame F the specified or default value according to ALIST
3771 of the parameter named PROP (a Lisp symbol).
3772 If no value is specified for PROP, look for an X default for XPROP
3773 on the frame named NAME.
3774 If that is not found either, use the value DEFLT. */
3777 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
3784 enum resource_types type
;
3788 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3789 if (EQ (tem
, Qunbound
))
3791 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3798 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3799 doc
: /* Parse an X-style geometry string STRING.
3800 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3801 The properties returned may include `top', `left', `height', and `width'.
3802 The value of `left' or `top' may be an integer,
3803 or a list (+ N) meaning N pixels relative to top/left corner,
3804 or a list (- N) meaning -N pixels relative to bottom/right corner. */)
3809 unsigned int width
, height
;
3812 CHECK_STRING (string
);
3814 geometry
= XParseGeometry ((char *) SDATA (string
),
3815 &x
, &y
, &width
, &height
);
3818 if (!!(geometry
& XValue
) != !!(geometry
& YValue
))
3819 error ("Must specify both x and y position, or neither");
3823 if (geometry
& XValue
)
3825 Lisp_Object element
;
3827 if (x
>= 0 && (geometry
& XNegative
))
3828 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3829 else if (x
< 0 && ! (geometry
& XNegative
))
3830 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3832 element
= Fcons (Qleft
, make_number (x
));
3833 result
= Fcons (element
, result
);
3836 if (geometry
& YValue
)
3838 Lisp_Object element
;
3840 if (y
>= 0 && (geometry
& YNegative
))
3841 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3842 else if (y
< 0 && ! (geometry
& YNegative
))
3843 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3845 element
= Fcons (Qtop
, make_number (y
));
3846 result
= Fcons (element
, result
);
3849 if (geometry
& WidthValue
)
3850 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3851 if (geometry
& HeightValue
)
3852 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3857 /* Calculate the desired size and position of frame F.
3858 Return the flags saying which aspects were specified.
3860 Also set the win_gravity and size_hint_flags of F.
3862 Adjust height for toolbar if TOOLBAR_P is 1.
3864 This function does not make the coordinates positive. */
3866 #define DEFAULT_ROWS 40
3867 #define DEFAULT_COLS 80
3870 x_figure_window_size (f
, parms
, toolbar_p
)
3875 register Lisp_Object tem0
, tem1
, tem2
;
3876 long window_prompting
= 0;
3877 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3879 /* Default values if we fall through.
3880 Actually, if that happens we should get
3881 window manager prompting. */
3882 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3883 FRAME_LINES (f
) = DEFAULT_ROWS
;
3884 /* Window managers expect that if program-specified
3885 positions are not (0,0), they're intentional, not defaults. */
3889 /* Ensure that old new_text_cols and new_text_lines will not override the
3891 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3892 f
->new_text_cols
= f
->new_text_lines
= 0;
3894 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3895 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3896 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3897 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3899 if (!EQ (tem0
, Qunbound
))
3901 CHECK_NUMBER (tem0
);
3902 FRAME_LINES (f
) = XINT (tem0
);
3904 if (!EQ (tem1
, Qunbound
))
3906 CHECK_NUMBER (tem1
);
3907 SET_FRAME_COLS (f
, XINT (tem1
));
3909 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
3910 window_prompting
|= USSize
;
3912 window_prompting
|= PSize
;
3915 f
->scroll_bar_actual_width
3916 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
3918 /* This used to be done _before_ calling x_figure_window_size, but
3919 since the height is reset here, this was really a no-op. I
3920 assume that moving it here does what Gerd intended (although he
3921 no longer can remember what that was... ++KFS, 2003-03-25. */
3923 /* Add the tool-bar height to the initial frame height so that the
3924 user gets a text display area of the size he specified with -g or
3925 via .Xdefaults. Later changes of the tool-bar height don't
3926 change the frame size. This is done so that users can create
3927 tall Emacs frames without having to guess how tall the tool-bar
3929 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
3931 int margin
, relief
, bar_height
;
3933 relief
= (tool_bar_button_relief
>= 0
3934 ? tool_bar_button_relief
3935 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
3937 if (INTEGERP (Vtool_bar_button_margin
)
3938 && XINT (Vtool_bar_button_margin
) > 0)
3939 margin
= XFASTINT (Vtool_bar_button_margin
);
3940 else if (CONSP (Vtool_bar_button_margin
)
3941 && INTEGERP (XCDR (Vtool_bar_button_margin
))
3942 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
3943 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
3947 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
3948 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
3951 compute_fringe_widths (f
, 0);
3953 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
3954 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
3956 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
3957 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
3958 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
3959 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3961 if (EQ (tem0
, Qminus
))
3964 window_prompting
|= YNegative
;
3966 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
3967 && CONSP (XCDR (tem0
))
3968 && INTEGERP (XCAR (XCDR (tem0
))))
3970 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
3971 window_prompting
|= YNegative
;
3973 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
3974 && CONSP (XCDR (tem0
))
3975 && INTEGERP (XCAR (XCDR (tem0
))))
3977 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
3979 else if (EQ (tem0
, Qunbound
))
3983 CHECK_NUMBER (tem0
);
3984 f
->top_pos
= XINT (tem0
);
3986 window_prompting
|= YNegative
;
3989 if (EQ (tem1
, Qminus
))
3992 window_prompting
|= XNegative
;
3994 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
3995 && CONSP (XCDR (tem1
))
3996 && INTEGERP (XCAR (XCDR (tem1
))))
3998 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
3999 window_prompting
|= XNegative
;
4001 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4002 && CONSP (XCDR (tem1
))
4003 && INTEGERP (XCAR (XCDR (tem1
))))
4005 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4007 else if (EQ (tem1
, Qunbound
))
4011 CHECK_NUMBER (tem1
);
4012 f
->left_pos
= XINT (tem1
);
4013 if (f
->left_pos
< 0)
4014 window_prompting
|= XNegative
;
4017 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4018 window_prompting
|= USPosition
;
4020 window_prompting
|= PPosition
;
4023 if (f
->want_fullscreen
!= FULLSCREEN_NONE
)
4028 /* It takes both for some WM:s to place it where we want */
4029 window_prompting
= USPosition
| PPosition
;
4030 x_fullscreen_adjust (f
, &width
, &height
, &top
, &left
);
4031 FRAME_COLS (f
) = width
;
4032 FRAME_LINES (f
) = height
;
4033 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, width
);
4034 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, height
);
4039 if (window_prompting
& XNegative
)
4041 if (window_prompting
& YNegative
)
4042 f
->win_gravity
= SouthEastGravity
;
4044 f
->win_gravity
= NorthEastGravity
;
4048 if (window_prompting
& YNegative
)
4049 f
->win_gravity
= SouthWestGravity
;
4051 f
->win_gravity
= NorthWestGravity
;
4054 f
->size_hint_flags
= window_prompting
;
4056 return window_prompting
;
4061 #endif /* HAVE_WINDOW_SYSTEM */
4065 /***********************************************************************
4067 ***********************************************************************/
4072 Qframep
= intern ("framep");
4073 staticpro (&Qframep
);
4074 Qframe_live_p
= intern ("frame-live-p");
4075 staticpro (&Qframe_live_p
);
4076 Qheight
= intern ("height");
4077 staticpro (&Qheight
);
4078 Qicon
= intern ("icon");
4080 Qminibuffer
= intern ("minibuffer");
4081 staticpro (&Qminibuffer
);
4082 Qmodeline
= intern ("modeline");
4083 staticpro (&Qmodeline
);
4084 Qonly
= intern ("only");
4086 Qwidth
= intern ("width");
4087 staticpro (&Qwidth
);
4088 Qgeometry
= intern ("geometry");
4089 staticpro (&Qgeometry
);
4090 Qicon_left
= intern ("icon-left");
4091 staticpro (&Qicon_left
);
4092 Qicon_top
= intern ("icon-top");
4093 staticpro (&Qicon_top
);
4094 Qleft
= intern ("left");
4096 Qright
= intern ("right");
4097 staticpro (&Qright
);
4098 Quser_position
= intern ("user-position");
4099 staticpro (&Quser_position
);
4100 Quser_size
= intern ("user-size");
4101 staticpro (&Quser_size
);
4102 Qwindow_id
= intern ("window-id");
4103 staticpro (&Qwindow_id
);
4104 #ifdef HAVE_X_WINDOWS
4105 Qouter_window_id
= intern ("outer-window-id");
4106 staticpro (&Qouter_window_id
);
4108 Qparent_id
= intern ("parent-id");
4109 staticpro (&Qparent_id
);
4112 Qw32
= intern ("w32");
4114 Qpc
= intern ("pc");
4116 Qmac
= intern ("mac");
4118 Qvisible
= intern ("visible");
4119 staticpro (&Qvisible
);
4120 Qbuffer_predicate
= intern ("buffer-predicate");
4121 staticpro (&Qbuffer_predicate
);
4122 Qbuffer_list
= intern ("buffer-list");
4123 staticpro (&Qbuffer_list
);
4124 Qdisplay_type
= intern ("display-type");
4125 staticpro (&Qdisplay_type
);
4126 Qbackground_mode
= intern ("background-mode");
4127 staticpro (&Qbackground_mode
);
4128 Qtty_color_mode
= intern ("tty-color-mode");
4129 staticpro (&Qtty_color_mode
);
4131 Qface_set_after_frame_default
= intern ("face-set-after-frame-default");
4132 staticpro (&Qface_set_after_frame_default
);
4134 Qinhibit_face_set_after_frame_default
4135 = intern ("inhibit-face-set-after-frame-default");
4136 staticpro (&Qinhibit_face_set_after_frame_default
);
4138 Qfullwidth
= intern ("fullwidth");
4139 staticpro (&Qfullwidth
);
4140 Qfullheight
= intern ("fullheight");
4141 staticpro (&Qfullheight
);
4142 Qfullboth
= intern ("fullboth");
4143 staticpro (&Qfullboth
);
4144 Qx_resource_name
= intern ("x-resource-name");
4145 staticpro (&Qx_resource_name
);
4147 Qx_frame_parameter
= intern ("x-frame-parameter");
4148 staticpro (&Qx_frame_parameter
);
4153 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4155 Lisp_Object v
= intern (frame_parms
[i
].name
);
4156 if (frame_parms
[i
].variable
)
4158 *frame_parms
[i
].variable
= v
;
4159 staticpro (frame_parms
[i
].variable
);
4161 Fput (v
, Qx_frame_parameter
, make_number (i
));
4165 #ifdef HAVE_WINDOW_SYSTEM
4166 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4167 doc
: /* The name Emacs uses to look up X resources.
4168 `x-get-resource' uses this as the first component of the instance name
4169 when requesting resource values.
4170 Emacs initially sets `x-resource-name' to the name under which Emacs
4171 was invoked, or to the value specified with the `-name' or `-rn'
4172 switches, if present.
4174 It may be useful to bind this variable locally around a call
4175 to `x-get-resource'. See also the variable `x-resource-class'. */);
4176 Vx_resource_name
= Qnil
;
4178 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4179 doc
: /* The class Emacs uses to look up X resources.
4180 `x-get-resource' uses this as the first component of the instance class
4181 when requesting resource values.
4183 Emacs initially sets `x-resource-class' to "Emacs".
4185 Setting this variable permanently is not a reasonable thing to do,
4186 but binding this variable locally around a call to `x-get-resource'
4187 is a reasonable practice. See also the variable `x-resource-name'. */);
4188 Vx_resource_class
= build_string (EMACS_CLASS
);
4191 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4192 doc
: /* Alist of default values for frame creation.
4193 These may be set in your init file, like this:
4194 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4195 These override values given in window system configuration data,
4196 including X Windows' defaults database.
4197 For values specific to the first Emacs frame, see `initial-frame-alist'.
4198 For values specific to the separate minibuffer frame, see
4199 `minibuffer-frame-alist'.
4200 The `menu-bar-lines' element of the list controls whether new frames
4201 have menu bars; `menu-bar-mode' works by altering this element.
4202 Setting this variable does not affect existing frames, only new ones. */);
4203 Vdefault_frame_alist
= Qnil
;
4205 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars
,
4206 doc
: /* Default position of scroll bars on this window-system. */);
4207 #ifdef HAVE_WINDOW_SYSTEM
4208 #if defined(HAVE_NTGUI) || defined(MAC_OS)
4209 /* MS-Windows has scroll bars on the right by default. */
4210 Vdefault_frame_scroll_bars
= Qright
;
4212 Vdefault_frame_scroll_bars
= Qleft
;
4215 Vdefault_frame_scroll_bars
= Qnil
;
4218 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4219 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4221 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
4222 doc
: /* Non-nil if all of Emacs is iconified and frame updates are not needed. */);
4223 Vemacs_iconified
= Qnil
;
4225 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4226 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4227 `mouse-position' calls this function, passing its usual return value as
4228 argument, and returns whatever this function returns.
4229 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4230 which need to do mouse handling at the Lisp level. */);
4231 Vmouse_position_function
= Qnil
;
4233 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4234 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4235 If the value is an integer, highlighting is only shown after moving the
4236 mouse, while keyboard input turns off the highlight even when the mouse
4237 is over the clickable text. However, the mouse shape still indicates
4238 when the mouse is over clickable text. */);
4239 Vmouse_highlight
= Qt
;
4241 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4242 doc
: /* Functions to be run before deleting a frame.
4243 The functions are run with one arg, the frame to be deleted.
4244 See `delete-frame'. */);
4245 Vdelete_frame_functions
= Qnil
;
4247 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4248 doc
: /* Minibufferless frames use this frame's minibuffer.
4250 Emacs cannot create minibufferless frames unless this is set to an
4251 appropriate surrogate.
4253 Emacs consults this variable only when creating minibufferless
4254 frames; once the frame is created, it sticks with its assigned
4255 minibuffer, no matter what this variable is set to. This means that
4256 this variable doesn't necessarily say anything meaningful about the
4257 current set of frames, or where the minibuffer is currently being
4260 This variable is local to the current terminal and cannot be buffer-local. */);
4262 staticpro (&Vframe_list
);
4264 defsubr (&Sactive_minibuffer_window
);
4266 defsubr (&Sframe_live_p
);
4267 defsubr (&Smake_terminal_frame
);
4268 defsubr (&Shandle_switch_frame
);
4269 defsubr (&Sselect_frame
);
4270 defsubr (&Sselected_frame
);
4271 defsubr (&Swindow_frame
);
4272 defsubr (&Sframe_root_window
);
4273 defsubr (&Sframe_first_window
);
4274 defsubr (&Sframe_selected_window
);
4275 defsubr (&Sset_frame_selected_window
);
4276 defsubr (&Sframe_list
);
4277 defsubr (&Snext_frame
);
4278 defsubr (&Sprevious_frame
);
4279 defsubr (&Sdelete_frame
);
4280 defsubr (&Smouse_position
);
4281 defsubr (&Smouse_pixel_position
);
4282 defsubr (&Sset_mouse_position
);
4283 defsubr (&Sset_mouse_pixel_position
);
4285 defsubr (&Sframe_configuration
);
4286 defsubr (&Srestore_frame_configuration
);
4288 defsubr (&Smake_frame_visible
);
4289 defsubr (&Smake_frame_invisible
);
4290 defsubr (&Siconify_frame
);
4291 defsubr (&Sframe_visible_p
);
4292 defsubr (&Svisible_frame_list
);
4293 defsubr (&Sraise_frame
);
4294 defsubr (&Slower_frame
);
4295 defsubr (&Sredirect_frame_focus
);
4296 defsubr (&Sframe_focus
);
4297 defsubr (&Sframe_parameters
);
4298 defsubr (&Sframe_parameter
);
4299 defsubr (&Smodify_frame_parameters
);
4300 defsubr (&Sframe_char_height
);
4301 defsubr (&Sframe_char_width
);
4302 defsubr (&Sframe_pixel_height
);
4303 defsubr (&Sframe_pixel_width
);
4304 defsubr (&Sset_frame_height
);
4305 defsubr (&Sset_frame_width
);
4306 defsubr (&Sset_frame_size
);
4307 defsubr (&Sset_frame_position
);
4309 #ifdef HAVE_WINDOW_SYSTEM
4310 defsubr (&Sx_get_resource
);
4311 defsubr (&Sx_parse_geometry
);
4316 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4317 (do not change this comment) */