1 /* Generic frame functions.
3 Copyright (C) 1993-1995, 1997, 1999-2011 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 3 of the License, or
10 (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>. */
28 #include "character.h"
39 /* These help us bind and responding to switch-frame events. */
43 #include "blockinput.h"
45 #include "termhooks.h"
46 #include "dispextern.h"
49 #ifdef HAVE_WINDOW_SYSTEM
58 #ifdef HAVE_WINDOW_SYSTEM
63 Lisp_Object Qns_parse_geometry
;
66 Lisp_Object Qframep
, Qframe_live_p
;
67 Lisp_Object Qicon
, Qmodeline
;
69 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
, Qns
;
71 Lisp_Object Qdisplay_type
;
72 static Lisp_Object Qbackground_mode
;
75 static Lisp_Object Qx_frame_parameter
;
76 Lisp_Object Qx_resource_name
;
77 Lisp_Object Qterminal
;
78 Lisp_Object Qterminal_live_p
;
80 /* Frame parameters (set or reported). */
82 Lisp_Object Qauto_raise
, Qauto_lower
;
83 Lisp_Object Qborder_color
, Qborder_width
;
84 Lisp_Object Qcursor_color
, Qcursor_type
;
85 static Lisp_Object Qgeometry
; /* Not used */
86 Lisp_Object Qheight
, Qwidth
;
87 Lisp_Object Qleft
, Qright
;
88 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
90 Lisp_Object Qinternal_border_width
;
91 Lisp_Object Qmouse_color
;
92 Lisp_Object Qminibuffer
;
93 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
94 Lisp_Object Qvisibility
;
95 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
96 Lisp_Object Qscreen_gamma
;
97 Lisp_Object Qline_spacing
;
98 static Lisp_Object Quser_position
, Quser_size
;
99 Lisp_Object Qwait_for_wm
;
100 static Lisp_Object Qwindow_id
;
101 #ifdef HAVE_X_WINDOWS
102 static Lisp_Object Qouter_window_id
;
104 Lisp_Object Qparent_id
;
105 Lisp_Object Qtitle
, Qname
;
106 static Lisp_Object Qexplicit_name
;
107 Lisp_Object Qunsplittable
;
108 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
, Qtool_bar_position
;
109 Lisp_Object Qleft_fringe
, Qright_fringe
;
110 Lisp_Object Qbuffer_predicate
;
111 static Lisp_Object Qbuffer_list
, Qburied_buffer_list
;
112 Lisp_Object Qtty_color_mode
;
113 Lisp_Object Qtty
, Qtty_type
;
115 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
117 Lisp_Object Qfont_backend
;
120 Lisp_Object Qface_set_after_frame_default
;
122 static Lisp_Object Qdelete_frame_functions
;
126 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
128 struct window
*w
= XWINDOW (window
);
130 XSETFASTINT (w
->last_modified
, 0);
131 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
132 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
134 if (INTEGERP (w
->orig_top_line
))
135 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
136 if (INTEGERP (w
->orig_total_lines
))
137 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
139 /* Handle just the top child in a vertical split. */
140 if (!NILP (w
->vchild
))
141 set_menu_bar_lines_1 (w
->vchild
, n
);
143 /* Adjust all children in a horizontal split. */
144 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
146 w
= XWINDOW (window
);
147 set_menu_bar_lines_1 (window
, n
);
152 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
155 int olines
= FRAME_MENU_BAR_LINES (f
);
157 /* Right now, menu bars don't work properly in minibuf-only frames;
158 most of the commands try to apply themselves to the minibuffer
159 frame itself, and get an error because you can't switch buffers
160 in or split the minibuffer window. */
161 if (FRAME_MINIBUF_ONLY_P (f
))
164 if (INTEGERP (value
))
165 nlines
= XINT (value
);
169 if (nlines
!= olines
)
171 windows_or_buffers_changed
++;
172 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
173 FRAME_MENU_BAR_LINES (f
) = nlines
;
174 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
179 Lisp_Object Vframe_list
;
182 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
183 doc
: /* Return non-nil if OBJECT is a frame.
185 t for a termcap frame (a character-only terminal),
186 'x' for an Emacs frame that is really an X window,
187 'w32' for an Emacs frame that is a window on MS-Windows display,
188 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
189 'pc' for a direct-write MS-DOS frame.
190 See also `frame-live-p'. */)
193 if (!FRAMEP (object
))
195 switch (XFRAME (object
)->output_method
)
197 case output_initial
: /* The initial frame is like a termcap frame. */
200 case output_x_window
:
204 case output_msdos_raw
:
215 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
216 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
217 Value is nil if OBJECT is not a live frame. If object is a live
218 frame, the return value indicates what sort of terminal device it is
219 displayed on. See the documentation of `framep' for possible
223 return ((FRAMEP (object
)
224 && FRAME_LIVE_P (XFRAME (object
)))
229 DEFUE ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
230 doc
: /* The name of the window system that FRAME is displaying through.
231 The value is a symbol:
232 nil for a termcap frame (a character-only terminal),
233 'x' for an Emacs frame that is really an X window,
234 'w32' for an Emacs frame that is a window on MS-Windows display,
235 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
236 'pc' for a direct-write MS-DOS frame.
238 FRAME defaults to the currently selected frame.
240 Use of this function as a predicate is deprecated. Instead,
241 use `display-graphic-p' or any of the other `display-*-p'
242 predicates which report frame's specific UI-related capabilities. */)
247 frame
= selected_frame
;
249 type
= Fframep (frame
);
252 wrong_type_argument (Qframep
, frame
);
261 make_frame (int mini_p
)
264 register struct frame
*f
;
265 register Lisp_Object root_window
;
266 register Lisp_Object mini_window
;
268 f
= allocate_frame ();
269 XSETFRAME (frame
, f
);
271 f
->desired_matrix
= 0;
272 f
->current_matrix
= 0;
275 f
->glyphs_initialized_p
= 0;
276 f
->decode_mode_spec_buffer
= 0;
278 f
->async_visible
= 0;
279 f
->output_data
.nothing
= 0;
281 f
->async_iconified
= 0;
282 f
->wants_modeline
= 1;
287 f
->has_minibuffer
= mini_p
;
288 f
->focus_frame
= Qnil
;
289 f
->explicit_name
= 0;
290 f
->can_have_scroll_bars
= 0;
291 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
292 f
->param_alist
= Qnil
;
293 f
->scroll_bars
= Qnil
;
294 f
->condemned_scroll_bars
= Qnil
;
295 f
->face_alist
= Qnil
;
296 f
->face_cache
= NULL
;
297 f
->menu_bar_items
= Qnil
;
298 f
->menu_bar_vector
= Qnil
;
299 f
->menu_bar_items_used
= 0;
300 f
->buffer_predicate
= Qnil
;
301 f
->buffer_list
= Qnil
;
302 f
->buried_buffer_list
= Qnil
;
305 f
->menu_bar_window
= Qnil
;
306 f
->tool_bar_window
= Qnil
;
307 f
->tool_bar_items
= Qnil
;
308 f
->tool_bar_position
= Qtop
;
309 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
310 f
->n_tool_bar_items
= 0;
311 f
->left_fringe_width
= f
->right_fringe_width
= 0;
313 f
->menu_bar_lines
= 0;
314 f
->tool_bar_lines
= 0;
315 f
->scroll_bar_actual_width
= 0;
317 f
->internal_border_width
= 0;
318 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
319 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
320 f
->x_pixels_diff
= f
->y_pixels_diff
= 0;
321 #ifdef HAVE_WINDOW_SYSTEM
322 f
->want_fullscreen
= FULLSCREEN_NONE
;
324 f
->size_hint_flags
= 0;
326 f
->font_driver_list
= NULL
;
327 f
->font_data_list
= NULL
;
329 root_window
= make_window ();
332 mini_window
= make_window ();
333 XWINDOW (root_window
)->next
= mini_window
;
334 XWINDOW (mini_window
)->prev
= root_window
;
335 XWINDOW (mini_window
)->mini_p
= Qt
;
336 XWINDOW (mini_window
)->frame
= frame
;
337 f
->minibuffer_window
= mini_window
;
342 XWINDOW (root_window
)->next
= Qnil
;
343 f
->minibuffer_window
= Qnil
;
346 XWINDOW (root_window
)->frame
= frame
;
349 just so that there is "something there."
350 Correct size will be set up later with change_frame_size. */
352 SET_FRAME_COLS (f
, 10);
353 FRAME_LINES (f
) = 10;
355 XSETFASTINT (XWINDOW (root_window
)->total_cols
, 10);
356 XSETFASTINT (XWINDOW (root_window
)->total_lines
, (mini_p
? 9 : 10));
360 XSETFASTINT (XWINDOW (mini_window
)->total_cols
, 10);
361 XSETFASTINT (XWINDOW (mini_window
)->top_line
, 9);
362 XSETFASTINT (XWINDOW (mini_window
)->total_lines
, 1);
365 /* Choose a buffer for the frame's root window. */
369 XWINDOW (root_window
)->buffer
= Qt
;
370 buf
= Fcurrent_buffer ();
371 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
372 a space), try to find another one. */
373 if (SREF (Fbuffer_name (buf
), 0) == ' ')
374 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
376 /* Use set_window_buffer, not Fset_window_buffer, and don't let
377 hooks be run by it. The reason is that the whole frame/window
378 arrangement is not yet fully intialized at this point. Windows
379 don't have the right size, glyph matrices aren't initialized
380 etc. Running Lisp functions at this point surely ends in a
382 set_window_buffer (root_window
, buf
, 0, 0);
383 f
->buffer_list
= Fcons (buf
, Qnil
);
388 XWINDOW (mini_window
)->buffer
= Qt
;
389 set_window_buffer (mini_window
,
390 (NILP (Vminibuffer_list
)
392 : Fcar (Vminibuffer_list
)),
396 f
->root_window
= root_window
;
397 f
->selected_window
= root_window
;
398 /* Make sure this window seems more recently used than
399 a newly-created, never-selected window. */
400 ++window_select_count
;
401 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, window_select_count
);
403 f
->default_face_done_p
= 0;
408 #ifdef HAVE_WINDOW_SYSTEM
409 /* Make a frame using a separate minibuffer window on another frame.
410 MINI_WINDOW is the minibuffer window to use. nil means use the
411 default (the global minibuffer). */
414 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
416 register struct frame
*f
;
419 if (!NILP (mini_window
))
420 CHECK_LIVE_WINDOW (mini_window
);
422 if (!NILP (mini_window
)
423 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
424 error ("Frame and minibuffer must be on the same terminal");
426 /* Make a frame containing just a root window. */
429 if (NILP (mini_window
))
431 /* Use default-minibuffer-frame if possible. */
432 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
433 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
435 Lisp_Object frame_dummy
;
437 XSETFRAME (frame_dummy
, f
);
438 GCPRO1 (frame_dummy
);
439 /* If there's no minibuffer frame to use, create one. */
440 KVAR (kb
, Vdefault_minibuffer_frame
) =
441 call1 (intern ("make-initial-minibuffer-frame"), display
);
445 mini_window
= XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
448 f
->minibuffer_window
= mini_window
;
450 /* Make the chosen minibuffer window display the proper minibuffer,
451 unless it is already showing a minibuffer. */
452 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
453 Fset_window_buffer (mini_window
,
454 (NILP (Vminibuffer_list
)
456 : Fcar (Vminibuffer_list
)), Qnil
);
460 /* Make a frame containing only a minibuffer window. */
463 make_minibuffer_frame (void)
465 /* First make a frame containing just a root window, no minibuffer. */
467 register struct frame
*f
= make_frame (0);
468 register Lisp_Object mini_window
;
469 register Lisp_Object frame
;
471 XSETFRAME (frame
, f
);
476 f
->wants_modeline
= 0;
477 f
->has_minibuffer
= 1;
479 /* Now label the root window as also being the minibuffer.
480 Avoid infinite looping on the window chain by marking next pointer
483 mini_window
= f
->minibuffer_window
= f
->root_window
;
484 XWINDOW (mini_window
)->mini_p
= Qt
;
485 XWINDOW (mini_window
)->next
= Qnil
;
486 XWINDOW (mini_window
)->prev
= Qnil
;
487 XWINDOW (mini_window
)->frame
= frame
;
489 /* Put the proper buffer in that window. */
491 Fset_window_buffer (mini_window
,
492 (NILP (Vminibuffer_list
)
494 : Fcar (Vminibuffer_list
)), Qnil
);
497 #endif /* HAVE_WINDOW_SYSTEM */
499 /* Construct a frame that refers to a terminal. */
501 static int tty_frame_count
;
504 make_initial_frame (void)
507 struct terminal
*terminal
;
510 eassert (initial_kboard
);
512 /* The first call must initialize Vframe_list. */
513 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
516 terminal
= init_initial_terminal ();
519 XSETFRAME (frame
, f
);
521 Vframe_list
= Fcons (frame
, Vframe_list
);
524 f
->name
= make_pure_c_string ("F1");
527 f
->async_visible
= 1;
529 f
->output_method
= terminal
->type
;
530 f
->terminal
= terminal
;
531 f
->terminal
->reference_count
++;
532 f
->output_data
.nothing
= 0;
534 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
535 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
537 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
538 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
540 /* The default value of menu-bar-mode is t. */
541 set_menu_bar_lines (f
, make_number (1), Qnil
);
545 init_frame_faces (f
);
553 make_terminal_frame (struct terminal
*terminal
)
555 register struct frame
*f
;
560 error ("Terminal is not live, can't create new frames on it");
564 XSETFRAME (frame
, f
);
565 Vframe_list
= Fcons (frame
, Vframe_list
);
568 sprintf (name
, "F%d", tty_frame_count
);
569 f
->name
= build_string (name
);
571 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
572 f
->async_visible
= 1; /* Don't let visible be cleared later. */
573 f
->terminal
= terminal
;
574 f
->terminal
->reference_count
++;
576 f
->output_data
.tty
->display_info
= &the_only_display_info
;
577 if (!inhibit_window_system
578 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
579 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
580 f
->output_method
= output_msdos_raw
;
582 f
->output_method
= output_termcap
;
583 #else /* not MSDOS */
584 f
->output_method
= output_termcap
;
585 create_tty_output (f
);
586 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
587 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
588 #endif /* not MSDOS */
590 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
591 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
592 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
594 /* Set the top frame to the newly created frame. */
595 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
596 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
597 XFRAME (FRAME_TTY (f
)->top_frame
)->async_visible
= 2; /* obscured */
599 FRAME_TTY (f
)->top_frame
= frame
;
602 init_frame_faces (f
);
607 /* Get a suitable value for frame parameter PARAMETER for a newly
608 created frame, based on (1) the user-supplied frame parameter
609 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
612 get_future_frame_param (Lisp_Object parameter
,
613 Lisp_Object supplied_parms
,
618 result
= Fassq (parameter
, supplied_parms
);
620 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
621 if (NILP (result
) && current_value
!= NULL
)
622 result
= build_string (current_value
);
623 if (!NILP (result
) && !STRINGP (result
))
624 result
= XCDR (result
);
625 if (NILP (result
) || !STRINGP (result
))
631 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
633 doc
: /* Create an additional terminal frame, possibly on another terminal.
634 This function takes one argument, an alist specifying frame parameters.
636 You can create multiple frames on a single text-only terminal, but
637 only one of them (the selected terminal frame) is actually displayed.
639 In practice, generally you don't need to specify any parameters,
640 except when you want to create a new frame on another terminal.
641 In that case, the `tty' parameter specifies the device file to open,
642 and the `tty-type' parameter specifies the terminal type. Example:
644 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
646 Note that changing the size of one terminal frame automatically
647 affects all frames on the same terminal device. */)
651 struct terminal
*t
= NULL
;
652 Lisp_Object frame
, tem
;
653 struct frame
*sf
= SELECTED_FRAME ();
656 if (sf
->output_method
!= output_msdos_raw
657 && sf
->output_method
!= output_termcap
)
659 #else /* not MSDOS */
661 #ifdef WINDOWSNT /* This should work now! */
662 if (sf
->output_method
!= output_termcap
)
663 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
665 #endif /* not MSDOS */
668 Lisp_Object terminal
;
670 terminal
= Fassq (Qterminal
, parms
);
671 if (!NILP (terminal
))
673 terminal
= XCDR (terminal
);
674 t
= get_terminal (terminal
, 1);
677 if (t
&& t
!= the_only_display_info
.terminal
)
678 /* msdos.c assumes a single tty_display_info object. */
679 error ("Multiple terminals are not supported on this platform");
681 t
= the_only_display_info
.terminal
;
687 char *name
= 0, *type
= 0;
688 Lisp_Object tty
, tty_type
;
690 tty
= get_future_frame_param
691 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
692 ? FRAME_TTY (XFRAME (selected_frame
))->name
696 name
= (char *) alloca (SBYTES (tty
) + 1);
697 strncpy (name
, SSDATA (tty
), SBYTES (tty
));
698 name
[SBYTES (tty
)] = 0;
701 tty_type
= get_future_frame_param
702 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
703 ? FRAME_TTY (XFRAME (selected_frame
))->type
705 if (!NILP (tty_type
))
707 type
= (char *) alloca (SBYTES (tty_type
) + 1);
708 strncpy (type
, SSDATA (tty_type
), SBYTES (tty_type
));
709 type
[SBYTES (tty_type
)] = 0;
712 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
715 f
= make_terminal_frame (t
);
719 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
720 change_frame_size (f
, height
, width
, 0, 0, 0);
725 XSETFRAME (frame
, f
);
726 Fmodify_frame_parameters (frame
, parms
);
727 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
728 build_string (t
->display_info
.tty
->type
)),
730 if (t
->display_info
.tty
->name
!= NULL
)
731 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
732 build_string (t
->display_info
.tty
->name
)),
735 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
737 /* Make the frame face alist be frame-specific, so that each
738 frame could change its face definitions independently. */
739 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
740 /* Simple Fcopy_alist isn't enough, because we need the contents of
741 the vectors which are the CDRs of associations in face_alist to
742 be copied as well. */
743 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
744 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
749 /* Perform the switch to frame FRAME.
751 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
754 If TRACK is non-zero and the frame that currently has the focus
755 redirects its focus to the selected frame, redirect that focused
756 frame's focus to FRAME instead.
758 FOR_DELETION non-zero means that the selected frame is being
759 deleted, which includes the possibility that the frame's terminal
762 The value of NORECORD is passed as argument to Fselect_window. */
765 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
767 struct frame
*sf
= SELECTED_FRAME ();
769 /* If FRAME is a switch-frame event, extract the frame we should
772 && EQ (XCAR (frame
), Qswitch_frame
)
773 && CONSP (XCDR (frame
)))
774 frame
= XCAR (XCDR (frame
));
776 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
777 a switch-frame event to arrive after a frame is no longer live,
778 especially when deleting the initial frame during startup. */
780 if (! FRAME_LIVE_P (XFRAME (frame
)))
783 if (sf
== XFRAME (frame
))
786 /* This is too greedy; it causes inappropriate focus redirection
787 that's hard to get rid of. */
789 /* If a frame's focus has been redirected toward the currently
790 selected frame, we should change the redirection to point to the
791 newly selected frame. This means that if the focus is redirected
792 from a minibufferless frame to a surrogate minibuffer frame, we
793 can use `other-window' to switch between all the frames using
794 that minibuffer frame, and the focus redirection will follow us
800 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
804 if (!FRAMEP (XCAR (tail
)))
807 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
809 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
810 Fredirect_frame_focus (XCAR (tail
), frame
);
814 /* Instead, apply it only to the frame we're pointing to. */
815 #ifdef HAVE_WINDOW_SYSTEM
816 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
818 Lisp_Object focus
, xfocus
;
820 xfocus
= x_get_focus_frame (XFRAME (frame
));
823 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
824 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
825 Fredirect_frame_focus (xfocus
, frame
);
828 #endif /* HAVE_X_WINDOWS */
831 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
832 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
834 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
836 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
837 /* Mark previously displayed frame as now obscured. */
838 XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
)->async_visible
= 2;
839 XFRAME (frame
)->async_visible
= 1;
840 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
843 selected_frame
= frame
;
844 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
845 last_nonminibuf_frame
= XFRAME (selected_frame
);
847 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
849 /* We want to make sure that the next event generates a frame-switch
850 event to the appropriate frame. This seems kludgy to me, but
851 before you take it out, make sure that evaluating something like
852 (select-window (frame-root-window (new-frame))) doesn't end up
853 with your typing being interpreted in the new frame instead of
854 the one you're actually typing in. */
855 internal_last_event_frame
= Qnil
;
860 DEFUE ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
861 doc
: /* Select FRAME.
862 Subsequent editing commands apply to its selected window.
863 Optional argument NORECORD means to neither change the order of
864 recently selected windows nor the buffer list.
866 The selection of FRAME lasts until the next time the user does
867 something to select a different frame, or until the next time
868 this function is called. If you are using a window system, the
869 previously selected frame may be restored as the selected frame
870 when returning to the command loop, because it still may have
871 the window system's input focus. On a text-only terminal, the
872 next redisplay will display FRAME.
874 This function returns FRAME, or nil if FRAME has been deleted. */)
875 (Lisp_Object frame
, Lisp_Object norecord
)
877 return do_switch_frame (frame
, 1, 0, norecord
);
881 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
882 doc
: /* Handle a switch-frame event EVENT.
883 Switch-frame events are usually bound to this function.
884 A switch-frame event tells Emacs that the window manager has requested
885 that the user's events be directed to the frame mentioned in the event.
886 This function selects the selected window of the frame of EVENT.
888 If EVENT is frame object, handle it as if it were a switch-frame event
892 /* Preserve prefix arg that the command loop just cleared. */
893 KVAR (current_kboard
, Vprefix_arg
) = Vcurrent_prefix_arg
;
894 Frun_hooks (1, &Qmouse_leave_buffer_hook
);
895 return do_switch_frame (event
, 0, 0, Qnil
);
898 DEFUE ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
899 doc
: /* Return the frame that is now selected. */)
902 return selected_frame
;
905 DEFUE ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
906 doc
: /* Return the frame object that window WINDOW is on. */)
909 CHECK_LIVE_WINDOW (window
);
910 return XWINDOW (window
)->frame
;
913 DEFUE ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
914 doc
: /* Returns the topmost, leftmost window of FRAME.
915 If omitted, FRAME defaults to the currently selected frame. */)
921 w
= SELECTED_FRAME ()->root_window
;
924 CHECK_LIVE_FRAME (frame
);
925 w
= XFRAME (frame
)->root_window
;
927 while (NILP (XWINDOW (w
)->buffer
))
929 if (! NILP (XWINDOW (w
)->hchild
))
930 w
= XWINDOW (w
)->hchild
;
931 else if (! NILP (XWINDOW (w
)->vchild
))
932 w
= XWINDOW (w
)->vchild
;
939 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
940 Sactive_minibuffer_window
, 0, 0, 0,
941 doc
: /* Return the currently active minibuffer window, or nil if none. */)
944 return minibuf_level
? minibuf_window
: Qnil
;
947 DEFUE ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
948 doc
: /* Returns the root-window of FRAME.
949 If omitted, FRAME defaults to the currently selected frame. */)
955 window
= SELECTED_FRAME ()->root_window
;
958 CHECK_LIVE_FRAME (frame
);
959 window
= XFRAME (frame
)->root_window
;
965 DEFUN ("frame-selected-window", Fframe_selected_window
,
966 Sframe_selected_window
, 0, 1, 0,
967 doc
: /* Return the selected window of FRAME.
968 FRAME defaults to the currently selected frame. */)
974 window
= SELECTED_FRAME ()->selected_window
;
977 CHECK_LIVE_FRAME (frame
);
978 window
= XFRAME (frame
)->selected_window
;
984 DEFUE ("set-frame-selected-window", Fset_frame_selected_window
,
985 Sset_frame_selected_window
, 2, 3, 0,
986 doc
: /* Set selected window of FRAME to WINDOW.
987 If FRAME is nil, use the selected frame. If FRAME is the
988 selected frame, this makes WINDOW the selected window.
989 Optional argument NORECORD non-nil means to neither change the
990 order of recently selected windows nor the buffer list.
992 (Lisp_Object frame
, Lisp_Object window
, Lisp_Object norecord
)
995 frame
= selected_frame
;
997 CHECK_LIVE_FRAME (frame
);
998 CHECK_LIVE_WINDOW (window
);
1000 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
1001 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
1003 if (EQ (frame
, selected_frame
))
1004 return Fselect_window (window
, norecord
);
1006 return XFRAME (frame
)->selected_window
= window
;
1010 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1012 doc
: /* Return a list of all live frames. */)
1016 frames
= Fcopy_sequence (Vframe_list
);
1017 #ifdef HAVE_WINDOW_SYSTEM
1018 if (FRAMEP (tip_frame
))
1019 frames
= Fdelq (tip_frame
, frames
);
1024 /* Return the next frame in the frame list after FRAME.
1025 If MINIBUF is nil, exclude minibuffer-only frames.
1026 If MINIBUF is a window, include only its own frame
1027 and any frame now using that window as the minibuffer.
1028 If MINIBUF is `visible', include all visible frames.
1029 If MINIBUF is 0, include all visible and iconified frames.
1030 Otherwise, include all frames. */
1033 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1038 /* There must always be at least one frame in Vframe_list. */
1039 if (! CONSP (Vframe_list
))
1042 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
1043 forever. Forestall that. */
1044 CHECK_LIVE_FRAME (frame
);
1047 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1054 && ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1055 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1056 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1057 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
)))))
1059 /* Decide whether this frame is eligible to be returned. */
1061 /* If we've looped all the way around without finding any
1062 eligible frames, return the original frame. */
1066 /* Let minibuf decide if this frame is acceptable. */
1069 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1072 else if (EQ (minibuf
, Qvisible
))
1074 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1075 if (FRAME_VISIBLE_P (XFRAME (f
)))
1078 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
1080 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1081 if (FRAME_VISIBLE_P (XFRAME (f
))
1082 || FRAME_ICONIFIED_P (XFRAME (f
)))
1085 else if (WINDOWP (minibuf
))
1087 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1088 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1089 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1090 FRAME_FOCUS_FRAME (XFRAME (f
))))
1102 /* Return the previous frame in the frame list before FRAME.
1103 If MINIBUF is nil, exclude minibuffer-only frames.
1104 If MINIBUF is a window, include only its own frame
1105 and any frame now using that window as the minibuffer.
1106 If MINIBUF is `visible', include all visible frames.
1107 If MINIBUF is 0, include all visible and iconified frames.
1108 Otherwise, include all frames. */
1111 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1116 /* There must always be at least one frame in Vframe_list. */
1117 if (! CONSP (Vframe_list
))
1121 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1129 if (EQ (frame
, f
) && !NILP (prev
))
1132 if ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1133 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1134 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1135 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
))))
1137 /* Decide whether this frame is eligible to be returned,
1138 according to minibuf. */
1141 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1144 else if (WINDOWP (minibuf
))
1146 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1147 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1148 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1149 FRAME_FOCUS_FRAME (XFRAME (f
))))
1152 else if (EQ (minibuf
, Qvisible
))
1154 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1155 if (FRAME_VISIBLE_P (XFRAME (f
)))
1158 else if (XFASTINT (minibuf
) == 0)
1160 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1161 if (FRAME_VISIBLE_P (XFRAME (f
))
1162 || FRAME_ICONIFIED_P (XFRAME (f
)))
1170 /* We've scanned the entire list. */
1172 /* We went through the whole frame list without finding a single
1173 acceptable frame. Return the original frame. */
1176 /* There were no acceptable frames in the list before FRAME; otherwise,
1177 we would have returned directly from the loop. Since PREV is the last
1178 acceptable frame in the list, return it. */
1183 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1184 doc
: /* Return the next frame in the frame list after FRAME.
1185 It considers only frames on the same terminal as FRAME.
1186 By default, skip minibuffer-only frames.
1187 If omitted, FRAME defaults to the selected frame.
1188 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1189 If MINIFRAME is a window, include only its own frame
1190 and any frame now using that window as the minibuffer.
1191 If MINIFRAME is `visible', include all visible frames.
1192 If MINIFRAME is 0, include all visible and iconified frames.
1193 Otherwise, include all frames. */)
1194 (Lisp_Object frame
, Lisp_Object miniframe
)
1197 frame
= selected_frame
;
1199 CHECK_LIVE_FRAME (frame
);
1200 return next_frame (frame
, miniframe
);
1203 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1204 doc
: /* Return the previous frame in the frame list before FRAME.
1205 It considers only frames on the same terminal as FRAME.
1206 By default, skip minibuffer-only frames.
1207 If omitted, FRAME defaults to the selected frame.
1208 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1209 If MINIFRAME is a window, include only its own frame
1210 and any frame now using that window as the minibuffer.
1211 If MINIFRAME is `visible', include all visible frames.
1212 If MINIFRAME is 0, include all visible and iconified frames.
1213 Otherwise, include all frames. */)
1214 (Lisp_Object frame
, Lisp_Object miniframe
)
1217 frame
= selected_frame
;
1218 CHECK_LIVE_FRAME (frame
);
1219 return prev_frame (frame
, miniframe
);
1222 /* Return 1 if it is ok to delete frame F;
1223 0 if all frames aside from F are invisible.
1224 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1227 other_visible_frames (FRAME_PTR f
)
1229 /* We know the selected frame is visible,
1230 so if F is some other frame, it can't be the sole visible one. */
1231 if (f
== SELECTED_FRAME ())
1236 for (frames
= Vframe_list
;
1238 frames
= XCDR (frames
))
1242 this = XCAR (frames
);
1243 /* Verify that the frame's window still exists
1244 and we can still talk to it. And note any recent change
1246 #ifdef HAVE_WINDOW_SYSTEM
1247 if (FRAME_WINDOW_P (XFRAME (this)))
1249 x_sync (XFRAME (this));
1250 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1254 if (FRAME_VISIBLE_P (XFRAME (this))
1255 || FRAME_ICONIFIED_P (XFRAME (this))
1256 /* Allow deleting the terminal frame when at least
1257 one X frame exists! */
1258 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1266 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1267 unconditionally. x_connection_closed and delete_terminal use
1268 this. Any other value of FORCE implements the semantics
1269 described for Fdelete_frame. */
1271 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1272 /* If we use `register' here, gcc-4.0.2 on amd64 using
1273 -DUSE_LISP_UNION_TYPE complains further down that we're getting the
1274 address of `force'. Go figure. */
1278 struct frame
*sf
= SELECTED_FRAME ();
1281 int minibuffer_selected
, tooltip_frame
;
1283 if (EQ (frame
, Qnil
))
1286 XSETFRAME (frame
, f
);
1290 CHECK_FRAME (frame
);
1294 if (! FRAME_LIVE_P (f
))
1297 if (NILP (force
) && !other_visible_frames (f
))
1298 error ("Attempt to delete the sole visible or iconified frame");
1300 /* x_connection_closed must have set FORCE to `noelisp' in order
1301 to delete the last frame, if it is gone. */
1302 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1303 error ("Attempt to delete the only frame");
1305 /* Does this frame have a minibuffer, and is it the surrogate
1306 minibuffer for any other frame? */
1307 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1311 for (frames
= Vframe_list
;
1313 frames
= XCDR (frames
))
1316 this = XCAR (frames
);
1318 if (! EQ (this, frame
)
1320 WINDOW_FRAME (XWINDOW
1321 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1323 /* If we MUST delete this frame, delete the other first.
1324 But do this only if FORCE equals `noelisp'. */
1325 if (EQ (force
, Qnoelisp
))
1326 delete_frame (this, Qnoelisp
);
1328 error ("Attempt to delete a surrogate minibuffer frame");
1333 tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1335 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1336 frame is a tooltip. FORCE is set to `noelisp' when handling
1337 a disconnect from the terminal, so we don't dare call Lisp
1339 if (NILP (Vrun_hooks
) || tooltip_frame
)
1341 else if (EQ (force
, Qnoelisp
))
1343 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1346 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1348 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1349 if (! FRAME_LIVE_P (f
))
1352 /* At this point, we are committed to deleting the frame.
1353 There is no more chance for errors to prevent it. */
1355 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1357 /* Don't let the frame remain selected. */
1360 Lisp_Object tail
, frame1
;
1362 /* Look for another visible frame on the same terminal. */
1363 frame1
= next_frame (frame
, Qvisible
);
1365 /* If there is none, find *some* other frame. */
1366 if (NILP (frame1
) || EQ (frame1
, frame
))
1368 FOR_EACH_FRAME (tail
, frame1
)
1370 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1374 #ifdef NS_IMPL_COCOA
1376 /* Under NS, there is no system mechanism for choosing a new
1377 window to get focus -- it is left to application code.
1378 So the portion of THIS application interfacing with NS
1379 needs to know about it. We call Fraise_frame, but the
1380 purpose is really to transfer focus. */
1381 Fraise_frame (frame1
);
1384 do_switch_frame (frame1
, 0, 1, Qnil
);
1385 sf
= SELECTED_FRAME ();
1388 /* Don't allow minibuf_window to remain on a deleted frame. */
1389 if (EQ (f
->minibuffer_window
, minibuf_window
))
1391 Fset_window_buffer (sf
->minibuffer_window
,
1392 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1393 minibuf_window
= sf
->minibuffer_window
;
1395 /* If the dying minibuffer window was selected,
1396 select the new one. */
1397 if (minibuffer_selected
)
1398 Fselect_window (minibuf_window
, Qnil
);
1401 /* Don't let echo_area_window to remain on a deleted frame. */
1402 if (EQ (f
->minibuffer_window
, echo_area_window
))
1403 echo_area_window
= sf
->minibuffer_window
;
1405 /* Clear any X selections for this frame. */
1406 #ifdef HAVE_X_WINDOWS
1408 x_clear_frame_selections (f
);
1412 This function must be called before the window tree of the
1413 frame is deleted because windows contain dynamically allocated
1417 #ifdef HAVE_WINDOW_SYSTEM
1418 /* Give chance to each font driver to free a frame specific data. */
1419 font_update_drivers (f
, Qnil
);
1422 /* Mark all the windows that used to be on FRAME as deleted, and then
1423 remove the reference to them. */
1424 delete_all_subwindows (XWINDOW (f
->root_window
));
1425 f
->root_window
= Qnil
;
1427 Vframe_list
= Fdelq (frame
, Vframe_list
);
1428 FRAME_SET_VISIBLE (f
, 0);
1430 /* Allow the vector of menu bar contents to be freed in the next
1431 garbage collection. The frame object itself may not be garbage
1432 collected until much later, because recent_keys and other data
1433 structures can still refer to it. */
1434 f
->menu_bar_vector
= Qnil
;
1436 free_font_driver_list (f
);
1438 xfree (f
->decode_mode_spec_buffer
);
1439 xfree (FRAME_INSERT_COST (f
));
1440 xfree (FRAME_DELETEN_COST (f
));
1441 xfree (FRAME_INSERTN_COST (f
));
1442 xfree (FRAME_DELETE_COST (f
));
1443 xfree (FRAME_MESSAGE_BUF (f
));
1445 /* Since some events are handled at the interrupt level, we may get
1446 an event for f at any time; if we zero out the frame's terminal
1447 now, then we may trip up the event-handling code. Instead, we'll
1448 promise that the terminal of the frame must be valid until we
1449 have called the window-system-dependent frame destruction
1452 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1453 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1456 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1457 f
->output_data
.nothing
= 0;
1458 f
->terminal
= 0; /* Now the frame is dead. */
1460 /* If needed, delete the terminal that this frame was on.
1461 (This must be done after the frame is killed.) */
1462 terminal
->reference_count
--;
1463 if (terminal
->reference_count
== 0)
1466 XSETTERMINAL (tmp
, terminal
);
1469 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1472 kb
= terminal
->kboard
;
1475 /* If we've deleted the last_nonminibuf_frame, then try to find
1477 if (f
== last_nonminibuf_frame
)
1481 last_nonminibuf_frame
= 0;
1483 for (frames
= Vframe_list
;
1485 frames
= XCDR (frames
))
1487 f
= XFRAME (XCAR (frames
));
1488 if (!FRAME_MINIBUF_ONLY_P (f
))
1490 last_nonminibuf_frame
= f
;
1496 /* If there's no other frame on the same kboard, get out of
1497 single-kboard state if we're in it for this kboard. */
1501 /* Some frame we found on the same kboard, or nil if there are none. */
1502 Lisp_Object frame_on_same_kboard
;
1504 frame_on_same_kboard
= Qnil
;
1506 for (frames
= Vframe_list
;
1508 frames
= XCDR (frames
))
1513 this = XCAR (frames
);
1518 if (kb
== FRAME_KBOARD (f1
))
1519 frame_on_same_kboard
= this;
1522 if (NILP (frame_on_same_kboard
))
1523 not_single_kboard_state (kb
);
1527 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1528 find another one. Prefer minibuffer-only frames, but also notice
1529 frames with other windows. */
1530 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1534 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1535 Lisp_Object frame_with_minibuf
;
1536 /* Some frame we found on the same kboard, or nil if there are none. */
1537 Lisp_Object frame_on_same_kboard
;
1539 frame_on_same_kboard
= Qnil
;
1540 frame_with_minibuf
= Qnil
;
1542 for (frames
= Vframe_list
;
1544 frames
= XCDR (frames
))
1549 this = XCAR (frames
);
1554 /* Consider only frames on the same kboard
1555 and only those with minibuffers. */
1556 if (kb
== FRAME_KBOARD (f1
)
1557 && FRAME_HAS_MINIBUF_P (f1
))
1559 frame_with_minibuf
= this;
1560 if (FRAME_MINIBUF_ONLY_P (f1
))
1564 if (kb
== FRAME_KBOARD (f1
))
1565 frame_on_same_kboard
= this;
1568 if (!NILP (frame_on_same_kboard
))
1570 /* We know that there must be some frame with a minibuffer out
1571 there. If this were not true, all of the frames present
1572 would have to be minibufferless, which implies that at some
1573 point their minibuffer frames must have been deleted, but
1574 that is prohibited at the top; you can't delete surrogate
1575 minibuffer frames. */
1576 if (NILP (frame_with_minibuf
))
1579 KVAR (kb
, Vdefault_minibuffer_frame
) = frame_with_minibuf
;
1582 /* No frames left on this kboard--say no minibuffer either. */
1583 KVAR (kb
, Vdefault_minibuffer_frame
) = Qnil
;
1586 /* Cause frame titles to update--necessary if we now have just one frame. */
1588 update_mode_lines
= 1;
1593 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1594 doc
: /* Delete FRAME, permanently eliminating it from use.
1595 FRAME defaults to the selected frame.
1597 A frame may not be deleted if its minibuffer is used by other frames.
1598 Normally, you may not delete a frame if all other frames are invisible,
1599 but if the second optional argument FORCE is non-nil, you may do so.
1601 This function runs `delete-frame-functions' before actually
1602 deleting the frame, unless the frame is a tooltip.
1603 The functions are run with one argument, the frame to be deleted. */)
1604 (Lisp_Object frame
, Lisp_Object force
)
1606 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1610 /* Return mouse position in character cell units. */
1612 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1613 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1614 The position is given in character cells, where (0, 0) is the
1615 upper-left corner of the frame, X is the horizontal offset, and Y is
1616 the vertical offset.
1617 If Emacs is running on a mouseless terminal or hasn't been programmed
1618 to read the mouse position, it returns the selected frame for FRAME
1619 and nil for X and Y.
1620 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1621 passing the normal return value to that function as an argument,
1622 and returns whatever that function returns. */)
1626 Lisp_Object lispy_dummy
;
1627 enum scroll_bar_part party_dummy
;
1628 Lisp_Object x
, y
, retval
;
1630 unsigned long long_dummy
;
1631 struct gcpro gcpro1
;
1633 f
= SELECTED_FRAME ();
1636 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1637 /* It's okay for the hook to refrain from storing anything. */
1638 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1639 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1640 &lispy_dummy
, &party_dummy
,
1647 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1652 XSETFRAME (lispy_dummy
, f
);
1653 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1655 if (!NILP (Vmouse_position_function
))
1656 retval
= call1 (Vmouse_position_function
, retval
);
1657 RETURN_UNGCPRO (retval
);
1660 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1661 Smouse_pixel_position
, 0, 0, 0,
1662 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1663 The position is given in pixel units, where (0, 0) is the
1664 upper-left corner of the frame, X is the horizontal offset, and Y is
1665 the vertical offset.
1666 If Emacs is running on a mouseless terminal or hasn't been programmed
1667 to read the mouse position, it returns the selected frame for FRAME
1668 and nil for X and Y. */)
1672 Lisp_Object lispy_dummy
;
1673 enum scroll_bar_part party_dummy
;
1675 unsigned long long_dummy
;
1677 f
= SELECTED_FRAME ();
1680 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1681 /* It's okay for the hook to refrain from storing anything. */
1682 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1683 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1684 &lispy_dummy
, &party_dummy
,
1688 XSETFRAME (lispy_dummy
, f
);
1689 return Fcons (lispy_dummy
, Fcons (x
, y
));
1692 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1693 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1694 Coordinates are relative to the frame, not a window,
1695 so the coordinates of the top left character in the frame
1696 may be nonzero due to left-hand scroll bars or the menu bar.
1698 The position is given in character cells, where (0, 0) is the
1699 upper-left corner of the frame, X is the horizontal offset, and Y is
1700 the vertical offset.
1702 This function is a no-op for an X frame that is not visible.
1703 If you have just created a frame, you must wait for it to become visible
1704 before calling this function on it, like this.
1705 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1706 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1708 CHECK_LIVE_FRAME (frame
);
1712 /* I think this should be done with a hook. */
1713 #ifdef HAVE_WINDOW_SYSTEM
1714 if (FRAME_WINDOW_P (XFRAME (frame
)))
1715 /* Warping the mouse will cause enternotify and focus events. */
1716 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1718 #if defined (MSDOS) && defined (HAVE_MOUSE)
1719 if (FRAME_MSDOS_P (XFRAME (frame
)))
1721 Fselect_frame (frame
, Qnil
);
1722 mouse_moveto (XINT (x
), XINT (y
));
1727 Fselect_frame (frame
, Qnil
);
1728 term_mouse_moveto (XINT (x
), XINT (y
));
1737 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1738 Sset_mouse_pixel_position
, 3, 3, 0,
1739 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1740 The position is given in pixels, where (0, 0) is the upper-left corner
1741 of the frame, X is the horizontal offset, and Y is the vertical offset.
1743 Note, this is a no-op for an X frame that is not visible.
1744 If you have just created a frame, you must wait for it to become visible
1745 before calling this function on it, like this.
1746 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1747 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1749 CHECK_LIVE_FRAME (frame
);
1753 /* I think this should be done with a hook. */
1754 #ifdef HAVE_WINDOW_SYSTEM
1755 if (FRAME_WINDOW_P (XFRAME (frame
)))
1756 /* Warping the mouse will cause enternotify and focus events. */
1757 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1759 #if defined (MSDOS) && defined (HAVE_MOUSE)
1760 if (FRAME_MSDOS_P (XFRAME (frame
)))
1762 Fselect_frame (frame
, Qnil
);
1763 mouse_moveto (XINT (x
), XINT (y
));
1768 Fselect_frame (frame
, Qnil
);
1769 term_mouse_moveto (XINT (x
), XINT (y
));
1778 static void make_frame_visible_1 (Lisp_Object
);
1780 DEFUE ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1782 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1783 If omitted, FRAME defaults to the currently selected frame. */)
1787 frame
= selected_frame
;
1789 CHECK_LIVE_FRAME (frame
);
1791 /* I think this should be done with a hook. */
1792 #ifdef HAVE_WINDOW_SYSTEM
1793 if (FRAME_WINDOW_P (XFRAME (frame
)))
1795 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1796 x_make_frame_visible (XFRAME (frame
));
1800 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1802 /* Make menu bar update for the Buffers and Frames menus. */
1803 windows_or_buffers_changed
++;
1808 /* Update the display_time slot of the buffers shown in WINDOW
1809 and all its descendents. */
1812 make_frame_visible_1 (Lisp_Object window
)
1816 for (;!NILP (window
); window
= w
->next
)
1818 w
= XWINDOW (window
);
1820 if (!NILP (w
->buffer
))
1821 BVAR (XBUFFER (w
->buffer
), display_time
) = Fcurrent_time ();
1823 if (!NILP (w
->vchild
))
1824 make_frame_visible_1 (w
->vchild
);
1825 if (!NILP (w
->hchild
))
1826 make_frame_visible_1 (w
->hchild
);
1830 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1832 doc
: /* Make the frame FRAME invisible.
1833 If omitted, FRAME defaults to the currently selected frame.
1834 On graphical displays, invisible frames are not updated and are
1835 usually not displayed at all, even in a window system's \"taskbar\".
1837 Normally you may not make FRAME invisible if all other frames are invisible,
1838 but if the second optional argument FORCE is non-nil, you may do so.
1840 This function has no effect on text-only terminal frames. Such frames
1841 are always considered visible, whether or not they are currently being
1842 displayed in the terminal. */)
1843 (Lisp_Object frame
, Lisp_Object force
)
1846 frame
= selected_frame
;
1848 CHECK_LIVE_FRAME (frame
);
1850 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1851 error ("Attempt to make invisible the sole visible or iconified frame");
1853 #if 0 /* This isn't logically necessary, and it can do GC. */
1854 /* Don't let the frame remain selected. */
1855 if (EQ (frame
, selected_frame
))
1856 do_switch_frame (next_frame (frame
, Qt
), 0, 0, Qnil
)
1859 /* Don't allow minibuf_window to remain on a deleted frame. */
1860 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1862 struct frame
*sf
= XFRAME (selected_frame
);
1863 Fset_window_buffer (sf
->minibuffer_window
,
1864 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1865 minibuf_window
= sf
->minibuffer_window
;
1868 /* I think this should be done with a hook. */
1869 #ifdef HAVE_WINDOW_SYSTEM
1870 if (FRAME_WINDOW_P (XFRAME (frame
)))
1871 x_make_frame_invisible (XFRAME (frame
));
1874 /* Make menu bar update for the Buffers and Frames menus. */
1875 windows_or_buffers_changed
++;
1880 DEFUE ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1882 doc
: /* Make the frame FRAME into an icon.
1883 If omitted, FRAME defaults to the currently selected frame. */)
1887 frame
= selected_frame
;
1889 CHECK_LIVE_FRAME (frame
);
1891 #if 0 /* This isn't logically necessary, and it can do GC. */
1892 /* Don't let the frame remain selected. */
1893 if (EQ (frame
, selected_frame
))
1894 Fhandle_switch_frame (next_frame (frame
, Qt
));
1897 /* Don't allow minibuf_window to remain on a deleted frame. */
1898 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1900 struct frame
*sf
= XFRAME (selected_frame
);
1901 Fset_window_buffer (sf
->minibuffer_window
,
1902 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1903 minibuf_window
= sf
->minibuffer_window
;
1906 /* I think this should be done with a hook. */
1907 #ifdef HAVE_WINDOW_SYSTEM
1908 if (FRAME_WINDOW_P (XFRAME (frame
)))
1909 x_iconify_frame (XFRAME (frame
));
1912 /* Make menu bar update for the Buffers and Frames menus. */
1913 windows_or_buffers_changed
++;
1918 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1920 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1921 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1922 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1923 On graphical displays, invisible frames are not updated and are
1924 usually not displayed at all, even in a window system's \"taskbar\".
1926 If FRAME is a text-only terminal frame, this always returns t.
1927 Such frames are always considered visible, whether or not they are
1928 currently being displayed on the terminal. */)
1931 CHECK_LIVE_FRAME (frame
);
1933 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1935 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1937 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1942 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1944 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1947 Lisp_Object tail
, frame
;
1952 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1954 frame
= XCAR (tail
);
1955 if (!FRAMEP (frame
))
1958 if (FRAME_VISIBLE_P (f
))
1959 value
= Fcons (frame
, value
);
1965 DEFUE ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1966 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1967 If FRAME is invisible or iconified, make it visible.
1968 If you don't specify a frame, the selected frame is used.
1969 If Emacs is displaying on an ordinary terminal or some other device which
1970 doesn't support multiple overlapping frames, this function selects FRAME. */)
1975 frame
= selected_frame
;
1977 CHECK_LIVE_FRAME (frame
);
1981 if (FRAME_TERMCAP_P (f
))
1982 /* On a text-only terminal select FRAME. */
1983 Fselect_frame (frame
, Qnil
);
1985 /* Do like the documentation says. */
1986 Fmake_frame_visible (frame
);
1988 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1989 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
1994 /* Should we have a corresponding function called Flower_Power? */
1995 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1996 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1997 If you don't specify a frame, the selected frame is used.
1998 If Emacs is displaying on an ordinary terminal or some other device which
1999 doesn't support multiple overlapping frames, this function does nothing. */)
2005 frame
= selected_frame
;
2007 CHECK_LIVE_FRAME (frame
);
2011 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2012 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2018 DEFUE ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2020 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2021 In other words, switch-frame events caused by events in FRAME will
2022 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2023 FOCUS-FRAME after reading an event typed at FRAME.
2025 If FOCUS-FRAME is omitted or nil, any existing redirection is
2026 cancelled, and the frame again receives its own keystrokes.
2028 Focus redirection is useful for temporarily redirecting keystrokes to
2029 a surrogate minibuffer frame when a frame doesn't have its own
2032 A frame's focus redirection can be changed by `select-frame'. If frame
2033 FOO is selected, and then a different frame BAR is selected, any
2034 frames redirecting their focus to FOO are shifted to redirect their
2035 focus to BAR. This allows focus redirection to work properly when the
2036 user switches from one frame to another using `select-window'.
2038 This means that a frame whose focus is redirected to itself is treated
2039 differently from a frame whose focus is redirected to nil; the former
2040 is affected by `select-frame', while the latter is not.
2042 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2043 (Lisp_Object frame
, Lisp_Object focus_frame
)
2047 /* Note that we don't check for a live frame here. It's reasonable
2048 to redirect the focus of a frame you're about to delete, if you
2049 know what other frame should receive those keystrokes. */
2050 CHECK_FRAME (frame
);
2052 if (! NILP (focus_frame
))
2053 CHECK_LIVE_FRAME (focus_frame
);
2057 f
->focus_frame
= focus_frame
;
2059 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2060 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2066 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
2067 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2068 This returns nil if FRAME's focus is not redirected.
2069 See `redirect-frame-focus'. */)
2072 CHECK_LIVE_FRAME (frame
);
2074 return FRAME_FOCUS_FRAME (XFRAME (frame
));
2079 /* Return the value of frame parameter PROP in frame FRAME. */
2082 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
2084 register Lisp_Object tem
;
2086 tem
= Fassq (prop
, frame
->param_alist
);
2092 /* Return the buffer-predicate of the selected frame. */
2095 frame_buffer_predicate (Lisp_Object frame
)
2097 return XFRAME (frame
)->buffer_predicate
;
2100 /* Return the buffer-list of the selected frame. */
2103 frame_buffer_list (Lisp_Object frame
)
2105 return XFRAME (frame
)->buffer_list
;
2108 /* Set the buffer-list of the selected frame. */
2111 set_frame_buffer_list (Lisp_Object frame
, Lisp_Object list
)
2113 XFRAME (frame
)->buffer_list
= list
;
2116 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2119 frames_discard_buffer (Lisp_Object buffer
)
2121 Lisp_Object frame
, tail
;
2123 FOR_EACH_FRAME (tail
, frame
)
2125 XFRAME (frame
)->buffer_list
2126 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
2127 XFRAME (frame
)->buried_buffer_list
2128 = Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
);
2132 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2133 If the alist already has an element for PROP, we change it. */
2136 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2138 register Lisp_Object tem
;
2140 tem
= Fassq (prop
, *alistptr
);
2142 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2148 frame_name_fnn_p (char *str
, EMACS_INT len
)
2150 if (len
> 1 && str
[0] == 'F')
2155 n
= strtol (str
+ 1, &end_ptr
, 10);
2157 if (end_ptr
== str
+ len
2158 && INT_MIN
<= n
&& n
<= INT_MAX
2159 && ((LONG_MIN
< n
&& n
< LONG_MAX
) || errno
!= ERANGE
))
2165 /* Set the name of the terminal frame. Also used by MSDOS frames.
2166 Modeled after x_set_name which is used for WINDOW frames. */
2169 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2171 f
->explicit_name
= ! NILP (name
);
2173 /* If NAME is nil, set the name to F<num>. */
2178 /* Check for no change needed in this very common case
2179 before we do any consing. */
2180 if (frame_name_fnn_p (SSDATA (f
->name
),
2185 sprintf (namebuf
, "F%d", tty_frame_count
);
2186 name
= build_string (namebuf
);
2190 CHECK_STRING (name
);
2192 /* Don't change the name if it's already NAME. */
2193 if (! NILP (Fstring_equal (name
, f
->name
)))
2196 /* Don't allow the user to set the frame name to F<num>, so it
2197 doesn't clash with the names we generate for terminal frames. */
2198 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2199 error ("Frame names of the form F<num> are usurped by Emacs");
2203 update_mode_lines
= 1;
2207 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2209 register Lisp_Object old_alist_elt
;
2211 /* The buffer-list parameters are stored in a special place and not
2212 in the alist. All buffers must be live. */
2213 if (EQ (prop
, Qbuffer_list
))
2215 Lisp_Object list
= Qnil
;
2216 for (; CONSP (val
); val
= XCDR (val
))
2217 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2218 list
= Fcons (XCAR (val
), list
);
2219 f
->buffer_list
= Fnreverse (list
);
2222 if (EQ (prop
, Qburied_buffer_list
))
2224 Lisp_Object list
= Qnil
;
2225 for (; CONSP (val
); val
= XCDR (val
))
2226 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2227 list
= Fcons (XCAR (val
), list
);
2228 f
->buried_buffer_list
= Fnreverse (list
);
2232 /* If PROP is a symbol which is supposed to have frame-local values,
2233 and it is set up based on this frame, switch to the global
2234 binding. That way, we can create or alter the frame-local binding
2235 without messing up the symbol's status. */
2238 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2240 switch (sym
->redirect
)
2242 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2243 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2244 case SYMBOL_LOCALIZED
:
2245 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2246 if (blv
->frame_local
&& BLV_FOUND (blv
) && XFRAME (blv
->where
) == f
)
2247 swap_in_global_binding (sym
);
2254 /* The tty color needed to be set before the frame's parameter
2255 alist was updated with the new value. This is not true any more,
2256 but we still do this test early on. */
2257 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2258 && f
== FRAME_TTY (f
)->previous_frame
)
2259 /* Force redisplay of this tty. */
2260 FRAME_TTY (f
)->previous_frame
= NULL
;
2262 /* Update the frame parameter alist. */
2263 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2264 if (EQ (old_alist_elt
, Qnil
))
2265 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2267 Fsetcdr (old_alist_elt
, val
);
2269 /* Update some other special parameters in their special places
2270 in addition to the alist. */
2272 if (EQ (prop
, Qbuffer_predicate
))
2273 f
->buffer_predicate
= val
;
2275 if (! FRAME_WINDOW_P (f
))
2277 if (EQ (prop
, Qmenu_bar_lines
))
2278 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2279 else if (EQ (prop
, Qname
))
2280 set_term_frame_name (f
, val
);
2283 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2285 if (! MINI_WINDOW_P (XWINDOW (val
)))
2286 error ("Surrogate minibuffer windows must be minibuffer windows");
2288 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2289 && !EQ (val
, f
->minibuffer_window
))
2290 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2292 /* Install the chosen minibuffer window, with proper buffer. */
2293 f
->minibuffer_window
= val
;
2297 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2298 doc
: /* Return the parameters-alist of frame FRAME.
2299 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2300 The meaningful PARMs depend on the kind of frame.
2301 If FRAME is omitted, return information on the currently selected frame. */)
2307 struct gcpro gcpro1
;
2310 frame
= selected_frame
;
2312 CHECK_FRAME (frame
);
2315 if (!FRAME_LIVE_P (f
))
2318 alist
= Fcopy_alist (f
->param_alist
);
2321 if (!FRAME_WINDOW_P (f
))
2323 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2324 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2327 /* If the frame's parameter alist says the colors are
2328 unspecified and reversed, take the frame's background pixel
2329 for foreground and vice versa. */
2330 elt
= Fassq (Qforeground_color
, alist
);
2331 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2333 if (strncmp (SSDATA (XCDR (elt
)),
2335 SCHARS (XCDR (elt
))) == 0)
2336 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2337 else if (strncmp (SSDATA (XCDR (elt
)),
2339 SCHARS (XCDR (elt
))) == 0)
2340 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2343 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2344 elt
= Fassq (Qbackground_color
, alist
);
2345 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2347 if (strncmp (SSDATA (XCDR (elt
)),
2349 SCHARS (XCDR (elt
))) == 0)
2350 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2351 else if (strncmp (SSDATA (XCDR (elt
)),
2353 SCHARS (XCDR (elt
))) == 0)
2354 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2357 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2358 store_in_alist (&alist
, intern ("font"),
2359 build_string (FRAME_MSDOS_P (f
)
2361 : FRAME_W32_P (f
) ? "w32term"
2364 store_in_alist (&alist
, Qname
, f
->name
);
2365 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2366 store_in_alist (&alist
, Qheight
, make_number (height
));
2367 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2368 store_in_alist (&alist
, Qwidth
, make_number (width
));
2369 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2370 store_in_alist (&alist
, Qminibuffer
,
2371 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2372 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2373 : FRAME_MINIBUF_WINDOW (f
)));
2374 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2375 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2376 store_in_alist (&alist
, Qburied_buffer_list
, XFRAME (frame
)->buried_buffer_list
);
2378 /* I think this should be done with a hook. */
2379 #ifdef HAVE_WINDOW_SYSTEM
2380 if (FRAME_WINDOW_P (f
))
2381 x_report_frame_params (f
, &alist
);
2385 /* This ought to be correct in f->param_alist for an X frame. */
2387 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2388 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2396 DEFUE ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2397 doc
: /* Return FRAME's value for parameter PARAMETER.
2398 If FRAME is nil, describe the currently selected frame. */)
2399 (Lisp_Object frame
, Lisp_Object parameter
)
2405 frame
= selected_frame
;
2407 CHECK_FRAME (frame
);
2408 CHECK_SYMBOL (parameter
);
2413 if (FRAME_LIVE_P (f
))
2415 /* Avoid consing in frequent cases. */
2416 if (EQ (parameter
, Qname
))
2418 #ifdef HAVE_X_WINDOWS
2419 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2420 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2421 #endif /* HAVE_X_WINDOWS */
2422 else if (EQ (parameter
, Qbackground_color
)
2423 || EQ (parameter
, Qforeground_color
))
2425 value
= Fassq (parameter
, f
->param_alist
);
2428 value
= XCDR (value
);
2429 /* Fframe_parameters puts the actual fg/bg color names,
2430 even if f->param_alist says otherwise. This is
2431 important when param_alist's notion of colors is
2432 "unspecified". We need to do the same here. */
2433 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2435 const char *color_name
;
2438 if (EQ (parameter
, Qbackground_color
))
2440 color_name
= SSDATA (value
);
2441 csz
= SCHARS (value
);
2442 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2443 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2444 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2445 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2447 else if (EQ (parameter
, Qforeground_color
))
2449 color_name
= SSDATA (value
);
2450 csz
= SCHARS (value
);
2451 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2452 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2453 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2454 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2459 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2461 else if (EQ (parameter
, Qdisplay_type
)
2462 || EQ (parameter
, Qbackground_mode
))
2463 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2465 /* FIXME: Avoid this code path at all (as well as code duplication)
2466 by sharing more code with Fframe_parameters. */
2467 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2474 DEFUE ("modify-frame-parameters", Fmodify_frame_parameters
,
2475 Smodify_frame_parameters
, 2, 2, 0,
2476 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2477 If FRAME is nil, it defaults to the selected frame.
2478 ALIST is an alist of parameters to change and their new values.
2479 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2480 The meaningful PARMs depend on the kind of frame.
2481 Undefined PARMs are ignored, but stored in the frame's parameter list
2482 so that `frame-parameters' will return them.
2484 The value of frame parameter FOO can also be accessed
2485 as a frame-local binding for the variable FOO, if you have
2486 enabled such bindings for that variable with `make-variable-frame-local'.
2487 Note that this functionality is obsolete as of Emacs 22.2, and its
2488 use is not recommended. Explicitly check for a frame-parameter instead. */)
2489 (Lisp_Object frame
, Lisp_Object alist
)
2492 register Lisp_Object tail
, prop
, val
;
2494 if (EQ (frame
, Qnil
))
2495 frame
= selected_frame
;
2496 CHECK_LIVE_FRAME (frame
);
2499 /* I think this should be done with a hook. */
2500 #ifdef HAVE_WINDOW_SYSTEM
2501 if (FRAME_WINDOW_P (f
))
2502 x_set_frame_parameters (f
, alist
);
2506 if (FRAME_MSDOS_P (f
))
2507 IT_set_frame_parameters (f
, alist
);
2512 int length
= XINT (Flength (alist
));
2515 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2517 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2519 /* Extract parm names and values into those vectors. */
2522 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2527 parms
[i
] = Fcar (elt
);
2528 values
[i
] = Fcdr (elt
);
2532 /* Now process them in reverse of specified order. */
2537 store_frame_param (f
, prop
, val
);
2539 /* Changing the background color might change the background
2540 mode, so that we have to load new defface specs.
2541 Call frame-set-background-mode to do that. */
2542 if (EQ (prop
, Qbackground_color
))
2543 call1 (Qframe_set_background_mode
, frame
);
2549 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2551 doc
: /* Height in pixels of a line in the font in frame FRAME.
2552 If FRAME is omitted, the selected frame is used.
2553 For a terminal frame, the value is always 1. */)
2559 frame
= selected_frame
;
2560 CHECK_FRAME (frame
);
2563 #ifdef HAVE_WINDOW_SYSTEM
2564 if (FRAME_WINDOW_P (f
))
2565 return make_number (x_char_height (f
));
2568 return make_number (1);
2572 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2574 doc
: /* Width in pixels of characters in the font in frame FRAME.
2575 If FRAME is omitted, the selected frame is used.
2576 On a graphical screen, the width is the standard width of the default font.
2577 For a terminal screen, the value is always 1. */)
2583 frame
= selected_frame
;
2584 CHECK_FRAME (frame
);
2587 #ifdef HAVE_WINDOW_SYSTEM
2588 if (FRAME_WINDOW_P (f
))
2589 return make_number (x_char_width (f
));
2592 return make_number (1);
2595 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2596 Sframe_pixel_height
, 0, 1, 0,
2597 doc
: /* Return a FRAME's height in pixels.
2598 If FRAME is omitted, the selected frame is used. The exact value
2599 of the result depends on the window-system and toolkit in use:
2601 In the Gtk+ version of Emacs, it includes only any window (including
2602 the minibuffer or eacho area), mode line, and header line. It does not
2603 include the tool bar or menu bar.
2605 With the Motif or Lucid toolkits, it also includes the tool bar (but
2608 In a graphical version with no toolkit, it includes both the tool bar
2611 For a text-only terminal, it includes the menu bar. In this case, the
2612 result is really in characters rather than pixels (i.e., is identical
2613 to `frame-height'). */)
2619 frame
= selected_frame
;
2620 CHECK_FRAME (frame
);
2623 #ifdef HAVE_WINDOW_SYSTEM
2624 if (FRAME_WINDOW_P (f
))
2625 return make_number (x_pixel_height (f
));
2628 return make_number (FRAME_LINES (f
));
2631 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2632 Sframe_pixel_width
, 0, 1, 0,
2633 doc
: /* Return FRAME's width in pixels.
2634 For a terminal frame, the result really gives the width in characters.
2635 If FRAME is omitted, the selected frame is used. */)
2641 frame
= selected_frame
;
2642 CHECK_FRAME (frame
);
2645 #ifdef HAVE_WINDOW_SYSTEM
2646 if (FRAME_WINDOW_P (f
))
2647 return make_number (x_pixel_width (f
));
2650 return make_number (FRAME_COLS (f
));
2653 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2654 Stool_bar_pixel_width
, 0, 1, 0,
2655 doc
: /* Return width in pixels of FRAME's tool bar.
2656 The result is greater than zero only when the tool bar is on the left
2657 or right side of FRAME. If FRAME is omitted, the selected frame is
2664 frame
= selected_frame
;
2665 CHECK_FRAME (frame
);
2668 #ifdef FRAME_TOOLBAR_WIDTH
2669 if (FRAME_WINDOW_P (f
))
2670 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2672 return make_number (0);
2675 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2676 doc
: /* Specify that the frame FRAME has LINES lines.
2677 Optional third arg non-nil means that redisplay should use LINES lines
2678 but that the idea of the actual height of the frame should not be changed. */)
2679 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2681 register struct frame
*f
;
2683 CHECK_NUMBER (lines
);
2685 frame
= selected_frame
;
2686 CHECK_LIVE_FRAME (frame
);
2689 /* I think this should be done with a hook. */
2690 #ifdef HAVE_WINDOW_SYSTEM
2691 if (FRAME_WINDOW_P (f
))
2693 if (XINT (lines
) != FRAME_LINES (f
))
2694 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2695 do_pending_window_change (0);
2699 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2703 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2704 doc
: /* Specify that the frame FRAME has COLS columns.
2705 Optional third arg non-nil means that redisplay should use COLS columns
2706 but that the idea of the actual width of the frame should not be changed. */)
2707 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2709 register struct frame
*f
;
2710 CHECK_NUMBER (cols
);
2712 frame
= selected_frame
;
2713 CHECK_LIVE_FRAME (frame
);
2716 /* I think this should be done with a hook. */
2717 #ifdef HAVE_WINDOW_SYSTEM
2718 if (FRAME_WINDOW_P (f
))
2720 if (XINT (cols
) != FRAME_COLS (f
))
2721 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2722 do_pending_window_change (0);
2726 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2730 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2731 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2732 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2734 register struct frame
*f
;
2736 CHECK_LIVE_FRAME (frame
);
2737 CHECK_NUMBER (cols
);
2738 CHECK_NUMBER (rows
);
2741 /* I think this should be done with a hook. */
2742 #ifdef HAVE_WINDOW_SYSTEM
2743 if (FRAME_WINDOW_P (f
))
2745 if (XINT (rows
) != FRAME_LINES (f
)
2746 || XINT (cols
) != FRAME_COLS (f
)
2747 || f
->new_text_lines
|| f
->new_text_cols
)
2748 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2749 do_pending_window_change (0);
2753 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2758 DEFUN ("set-frame-position", Fset_frame_position
,
2759 Sset_frame_position
, 3, 3, 0,
2760 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2761 This is actually the position of the upper left corner of the frame.
2762 Negative values for XOFFSET or YOFFSET are interpreted relative to
2763 the rightmost or bottommost possible position (that stays within the screen). */)
2764 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2766 register struct frame
*f
;
2768 CHECK_LIVE_FRAME (frame
);
2769 CHECK_NUMBER (xoffset
);
2770 CHECK_NUMBER (yoffset
);
2773 /* I think this should be done with a hook. */
2774 #ifdef HAVE_WINDOW_SYSTEM
2775 if (FRAME_WINDOW_P (f
))
2776 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2783 /***********************************************************************
2785 ***********************************************************************/
2787 /* Connect the frame-parameter names for X frames
2788 to the ways of passing the parameter values to the window system.
2790 The name of a parameter, as a Lisp symbol,
2791 has an `x-frame-parameter' property which is an integer in Lisp
2792 that is an index in this table. */
2794 struct frame_parm_table
{
2796 Lisp_Object
*variable
;
2799 static const struct frame_parm_table frame_parms
[] =
2801 {"auto-raise", &Qauto_raise
},
2802 {"auto-lower", &Qauto_lower
},
2803 {"background-color", 0},
2804 {"border-color", &Qborder_color
},
2805 {"border-width", &Qborder_width
},
2806 {"cursor-color", &Qcursor_color
},
2807 {"cursor-type", &Qcursor_type
},
2809 {"foreground-color", 0},
2810 {"icon-name", &Qicon_name
},
2811 {"icon-type", &Qicon_type
},
2812 {"internal-border-width", &Qinternal_border_width
},
2813 {"menu-bar-lines", &Qmenu_bar_lines
},
2814 {"mouse-color", &Qmouse_color
},
2816 {"scroll-bar-width", &Qscroll_bar_width
},
2818 {"unsplittable", &Qunsplittable
},
2819 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2820 {"visibility", &Qvisibility
},
2821 {"tool-bar-lines", &Qtool_bar_lines
},
2822 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2823 {"scroll-bar-background", &Qscroll_bar_background
},
2824 {"screen-gamma", &Qscreen_gamma
},
2825 {"line-spacing", &Qline_spacing
},
2826 {"left-fringe", &Qleft_fringe
},
2827 {"right-fringe", &Qright_fringe
},
2828 {"wait-for-wm", &Qwait_for_wm
},
2829 {"fullscreen", &Qfullscreen
},
2830 {"font-backend", &Qfont_backend
},
2832 {"sticky", &Qsticky
},
2833 {"tool-bar-position", &Qtool_bar_position
},
2836 #ifdef HAVE_WINDOW_SYSTEM
2838 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2839 wanted positions of the WM window (not Emacs window).
2840 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2841 window (FRAME_X_WINDOW).
2845 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2847 int newwidth
= FRAME_COLS (f
);
2848 int newheight
= FRAME_LINES (f
);
2849 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2851 *top_pos
= f
->top_pos
;
2852 *left_pos
= f
->left_pos
;
2854 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2858 ph
= x_display_pixel_height (dpyinfo
);
2859 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2860 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2861 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2865 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2869 pw
= x_display_pixel_width (dpyinfo
);
2870 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2871 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2872 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2877 *height
= newheight
;
2881 /* Change the parameters of frame F as specified by ALIST.
2882 If a parameter is not specially recognized, do nothing special;
2883 otherwise call the `x_set_...' function for that parameter.
2884 Except for certain geometry properties, always call store_frame_param
2885 to store the new value in the parameter alist. */
2888 x_set_frame_parameters (FRAME_PTR f
, Lisp_Object alist
)
2892 /* If both of these parameters are present, it's more efficient to
2893 set them both at once. So we wait until we've looked at the
2894 entire list before we set them. */
2898 Lisp_Object left
, top
;
2900 /* Same with these. */
2901 Lisp_Object icon_left
, icon_top
;
2903 /* Record in these vectors all the parms specified. */
2905 Lisp_Object
*values
;
2907 int left_no_change
= 0, top_no_change
= 0;
2908 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2909 int size_changed
= 0;
2910 struct gcpro gcpro1
, gcpro2
;
2913 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2916 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2917 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2919 /* Extract parm names and values into those vectors. */
2922 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2927 parms
[i
] = Fcar (elt
);
2928 values
[i
] = Fcdr (elt
);
2931 /* TAIL and ALIST are not used again below here. */
2932 alist
= tail
= Qnil
;
2934 GCPRO2 (*parms
, *values
);
2938 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2939 because their values appear in VALUES and strings are not valid. */
2940 top
= left
= Qunbound
;
2941 icon_left
= icon_top
= Qunbound
;
2943 /* Provide default values for HEIGHT and WIDTH. */
2944 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2945 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2947 /* Process foreground_color and background_color before anything else.
2948 They are independent of other properties, but other properties (e.g.,
2949 cursor_color) are dependent upon them. */
2950 /* Process default font as well, since fringe widths depends on it. */
2951 for (p
= 0; p
< i
; p
++)
2953 Lisp_Object prop
, val
;
2957 if (EQ (prop
, Qforeground_color
)
2958 || EQ (prop
, Qbackground_color
)
2959 || EQ (prop
, Qfont
))
2961 register Lisp_Object param_index
, old_value
;
2963 old_value
= get_frame_param (f
, prop
);
2964 if (NILP (Fequal (val
, old_value
)))
2966 store_frame_param (f
, prop
, val
);
2968 param_index
= Fget (prop
, Qx_frame_parameter
);
2969 if (NATNUMP (param_index
)
2970 && (XFASTINT (param_index
)
2971 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2972 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2973 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2978 /* Now process them in reverse of specified order. */
2981 Lisp_Object prop
, val
;
2986 if (EQ (prop
, Qwidth
) && NATNUMP (val
))
2989 width
= XFASTINT (val
);
2991 else if (EQ (prop
, Qheight
) && NATNUMP (val
))
2994 height
= XFASTINT (val
);
2996 else if (EQ (prop
, Qtop
))
2998 else if (EQ (prop
, Qleft
))
3000 else if (EQ (prop
, Qicon_top
))
3002 else if (EQ (prop
, Qicon_left
))
3004 else if (EQ (prop
, Qforeground_color
)
3005 || EQ (prop
, Qbackground_color
)
3006 || EQ (prop
, Qfont
))
3007 /* Processed above. */
3011 register Lisp_Object param_index
, old_value
;
3013 old_value
= get_frame_param (f
, prop
);
3015 store_frame_param (f
, prop
, val
);
3017 param_index
= Fget (prop
, Qx_frame_parameter
);
3018 if (NATNUMP (param_index
)
3019 && (XFASTINT (param_index
)
3020 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3021 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3022 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3026 /* Don't die if just one of these was set. */
3027 if (EQ (left
, Qunbound
))
3030 if (f
->left_pos
< 0)
3031 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
3033 XSETINT (left
, f
->left_pos
);
3035 if (EQ (top
, Qunbound
))
3039 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
3041 XSETINT (top
, f
->top_pos
);
3044 /* If one of the icon positions was not set, preserve or default it. */
3045 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
3047 icon_left_no_change
= 1;
3048 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3049 if (NILP (icon_left
))
3050 XSETINT (icon_left
, 0);
3052 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
3054 icon_top_no_change
= 1;
3055 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3056 if (NILP (icon_top
))
3057 XSETINT (icon_top
, 0);
3060 /* Don't set these parameters unless they've been explicitly
3061 specified. The window might be mapped or resized while we're in
3062 this function, and we don't want to override that unless the lisp
3063 code has asked for it.
3065 Don't set these parameters unless they actually differ from the
3066 window's current parameters; the window may not actually exist
3071 check_frame_size (f
, &height
, &width
);
3073 XSETFRAME (frame
, f
);
3076 && (width
!= FRAME_COLS (f
)
3077 || height
!= FRAME_LINES (f
)
3078 || f
->new_text_lines
|| f
->new_text_cols
))
3079 Fset_frame_size (frame
, make_number (width
), make_number (height
));
3081 if ((!NILP (left
) || !NILP (top
))
3082 && ! (left_no_change
&& top_no_change
)
3083 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3084 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3089 /* Record the signs. */
3090 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3091 if (EQ (left
, Qminus
))
3092 f
->size_hint_flags
|= XNegative
;
3093 else if (INTEGERP (left
))
3095 leftpos
= XINT (left
);
3097 f
->size_hint_flags
|= XNegative
;
3099 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3100 && CONSP (XCDR (left
))
3101 && INTEGERP (XCAR (XCDR (left
))))
3103 leftpos
= - XINT (XCAR (XCDR (left
)));
3104 f
->size_hint_flags
|= XNegative
;
3106 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3107 && CONSP (XCDR (left
))
3108 && INTEGERP (XCAR (XCDR (left
))))
3110 leftpos
= XINT (XCAR (XCDR (left
)));
3113 if (EQ (top
, Qminus
))
3114 f
->size_hint_flags
|= YNegative
;
3115 else if (INTEGERP (top
))
3117 toppos
= XINT (top
);
3119 f
->size_hint_flags
|= YNegative
;
3121 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3122 && CONSP (XCDR (top
))
3123 && INTEGERP (XCAR (XCDR (top
))))
3125 toppos
= - XINT (XCAR (XCDR (top
)));
3126 f
->size_hint_flags
|= YNegative
;
3128 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
3129 && CONSP (XCDR (top
))
3130 && INTEGERP (XCAR (XCDR (top
))))
3132 toppos
= XINT (XCAR (XCDR (top
)));
3136 /* Store the numeric value of the position. */
3137 f
->top_pos
= toppos
;
3138 f
->left_pos
= leftpos
;
3140 f
->win_gravity
= NorthWestGravity
;
3142 /* Actually set that position, and convert to absolute. */
3143 x_set_offset (f
, leftpos
, toppos
, -1);
3146 if ((!NILP (icon_left
) || !NILP (icon_top
))
3147 && ! (icon_left_no_change
&& icon_top_no_change
))
3148 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3155 /* Insert a description of internally-recorded parameters of frame X
3156 into the parameter alist *ALISTPTR that is to be given to the user.
3157 Only parameters that are specific to the X window system
3158 and whose values are not correctly recorded in the frame's
3159 param_alist need to be considered here. */
3162 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3167 /* Represent negative positions (off the top or left screen edge)
3168 in a way that Fmodify_frame_parameters will understand correctly. */
3169 XSETINT (tem
, f
->left_pos
);
3170 if (f
->left_pos
>= 0)
3171 store_in_alist (alistptr
, Qleft
, tem
);
3173 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3175 XSETINT (tem
, f
->top_pos
);
3176 if (f
->top_pos
>= 0)
3177 store_in_alist (alistptr
, Qtop
, tem
);
3179 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3181 store_in_alist (alistptr
, Qborder_width
,
3182 make_number (f
->border_width
));
3183 store_in_alist (alistptr
, Qinternal_border_width
,
3184 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3185 store_in_alist (alistptr
, Qleft_fringe
,
3186 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3187 store_in_alist (alistptr
, Qright_fringe
,
3188 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3189 store_in_alist (alistptr
, Qscroll_bar_width
,
3190 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3192 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3193 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3194 /* nil means "use default width"
3195 for non-toolkit scroll bar.
3196 ruler-mode.el depends on this. */
3198 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
3199 store_in_alist (alistptr
, Qwindow_id
,
3200 build_string (buf
));
3201 #ifdef HAVE_X_WINDOWS
3202 #ifdef USE_X_TOOLKIT
3203 /* Tooltip frame may not have this widget. */
3204 if (FRAME_X_OUTPUT (f
)->widget
)
3206 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
3207 store_in_alist (alistptr
, Qouter_window_id
,
3208 build_string (buf
));
3210 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3211 FRAME_SAMPLE_VISIBILITY (f
);
3212 store_in_alist (alistptr
, Qvisibility
,
3213 (FRAME_VISIBLE_P (f
) ? Qt
3214 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3215 store_in_alist (alistptr
, Qdisplay
,
3216 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3218 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3221 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3222 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3223 store_in_alist (alistptr
, Qparent_id
, tem
);
3224 store_in_alist (alistptr
, Qtool_bar_position
, f
->tool_bar_position
);
3228 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3229 the previous value of that parameter, NEW_VALUE is the new value. */
3232 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3234 if (NILP (new_value
))
3235 f
->want_fullscreen
= FULLSCREEN_NONE
;
3236 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3237 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3238 else if (EQ (new_value
, Qfullwidth
))
3239 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3240 else if (EQ (new_value
, Qfullheight
))
3241 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3242 else if (EQ (new_value
, Qmaximized
))
3243 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3245 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3246 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3250 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3251 the previous value of that parameter, NEW_VALUE is the new value. */
3254 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3256 if (NILP (new_value
))
3257 f
->extra_line_spacing
= 0;
3258 else if (NATNUMP (new_value
))
3259 f
->extra_line_spacing
= XFASTINT (new_value
);
3261 signal_error ("Invalid line-spacing", new_value
);
3262 if (FRAME_VISIBLE_P (f
))
3267 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3268 the previous value of that parameter, NEW_VALUE is the new value. */
3271 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3273 Lisp_Object bgcolor
;
3275 if (NILP (new_value
))
3277 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3278 /* The value 0.4545 is the normal viewing gamma. */
3279 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3281 signal_error ("Invalid screen-gamma", new_value
);
3283 /* Apply the new gamma value to the frame background. */
3284 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3285 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3287 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3288 if (NATNUMP (parm_index
)
3289 && (XFASTINT (parm_index
)
3290 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3291 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3292 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3296 Fclear_face_cache (Qnil
);
3301 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3303 Lisp_Object font_object
, font_param
= Qnil
;
3306 /* Set the frame parameter back to the old value because we may
3307 fail to use ARG as the new parameter value. */
3308 store_frame_param (f
, Qfont
, oldval
);
3310 /* ARG is a fontset name, a font name, a cons of fontset name and a
3311 font object, or a font object. In the last case, this function
3316 fontset
= fs_query_fontset (arg
, 0);
3319 font_object
= font_open_by_name (f
, SSDATA (arg
));
3320 if (NILP (font_object
))
3321 error ("Font `%s' is not defined", SSDATA (arg
));
3322 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3324 else if (fontset
> 0)
3326 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3328 font_object
= font_open_by_name (f
, SSDATA (ascii_font
));
3329 if (NILP (font_object
))
3330 error ("Font `%s' is not defined", SDATA (arg
));
3331 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3334 error ("The default fontset can't be used for a frame font");
3336 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3338 /* This is the case that the ASCII font of F's fontset XCAR
3339 (arg) is changed to the font XCDR (arg) by
3340 `set-fontset-font'. */
3341 fontset
= fs_query_fontset (XCAR (arg
), 0);
3343 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3344 font_object
= XCDR (arg
);
3345 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3346 font_param
= Ffont_get (font_object
, QCname
);
3348 else if (FONT_OBJECT_P (arg
))
3351 font_param
= Ffont_get (font_object
, QCname
);
3352 /* This is to store the XLFD font name in the frame parameter for
3353 backward compatibility. We should store the font-object
3354 itself in the future. */
3355 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3356 fontset
= FRAME_FONTSET (f
);
3357 /* Check if we can use the current fontset. If not, set FONTSET
3358 to -1 to generate a new fontset from FONT-OBJECT. */
3361 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3362 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3364 if (! font_match_p (spec
, font_object
))
3369 signal_error ("Invalid font", arg
);
3371 if (! NILP (Fequal (font_object
, oldval
)))
3374 x_new_font (f
, font_object
, fontset
);
3375 store_frame_param (f
, Qfont
, arg
);
3376 #ifdef HAVE_X_WINDOWS
3377 store_frame_param (f
, Qfont_param
, font_param
);
3379 /* Recalculate toolbar height. */
3380 f
->n_tool_bar_rows
= 0;
3381 /* Ensure we redraw it. */
3382 clear_current_matrices (f
);
3384 recompute_basic_faces (f
);
3386 do_pending_window_change (0);
3388 /* We used to call face-set-after-frame-default here, but it leads to
3389 recursive calls (since that function can set the `default' face's
3390 font which in turns changes the frame's `font' parameter).
3391 Also I don't know what this call is meant to do, but it seems the
3392 wrong way to do it anyway (it does a lot more work than what seems
3393 reasonable in response to a change to `font'). */
3398 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3400 if (! NILP (new_value
)
3401 && !CONSP (new_value
))
3405 CHECK_STRING (new_value
);
3406 p0
= p1
= SSDATA (new_value
);
3410 while (*p1
&& ! isspace (*p1
) && *p1
!= ',') p1
++;
3412 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3418 while ((c
= *++p1
) && isspace (c
));
3422 new_value
= Fnreverse (new_value
);
3425 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3429 free_all_realized_faces (Qnil
);
3431 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3432 if (NILP (new_value
))
3434 if (NILP (old_value
))
3435 error ("No font backend available");
3436 font_update_drivers (f
, old_value
);
3437 error ("None of specified font backends are available");
3439 store_frame_param (f
, Qfont_backend
, new_value
);
3445 XSETFRAME (frame
, f
);
3446 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3447 ++face_change_count
;
3448 ++windows_or_buffers_changed
;
3454 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3456 compute_fringe_widths (f
, 1);
3457 #ifdef HAVE_X_WINDOWS
3458 /* Must adjust this so window managers report correct number of columns. */
3459 if (FRAME_X_WINDOW (f
) != 0)
3460 x_wm_set_size_hint (f
, 0, 0);
3465 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3469 if (XINT (arg
) == f
->border_width
)
3472 if (FRAME_X_WINDOW (f
) != 0)
3473 error ("Cannot change the border width of a frame");
3475 f
->border_width
= XINT (arg
);
3479 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3481 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3484 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3485 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3486 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3488 #ifdef USE_X_TOOLKIT
3489 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3490 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3493 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3496 if (FRAME_X_WINDOW (f
) != 0)
3498 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3499 SET_FRAME_GARBAGED (f
);
3500 do_pending_window_change (0);
3503 SET_FRAME_GARBAGED (f
);
3507 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3510 XSETFRAME (frame
, f
);
3513 Fmake_frame_invisible (frame
, Qt
);
3514 else if (EQ (value
, Qicon
))
3515 Ficonify_frame (frame
);
3517 Fmake_frame_visible (frame
);
3521 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3523 f
->auto_raise
= !EQ (Qnil
, arg
);
3527 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3529 f
->auto_lower
= !EQ (Qnil
, arg
);
3533 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3535 f
->no_split
= !NILP (arg
);
3539 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3541 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3542 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3543 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3544 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3546 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3548 ? vertical_scroll_bar_none
3550 ? vertical_scroll_bar_left
3552 ? vertical_scroll_bar_right
3553 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3554 ? vertical_scroll_bar_left
3555 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3556 ? vertical_scroll_bar_right
3557 : vertical_scroll_bar_none
);
3559 /* We set this parameter before creating the X window for the
3560 frame, so we can get the geometry right from the start.
3561 However, if the window hasn't been created yet, we shouldn't
3562 call x_set_window_size. */
3563 if (FRAME_X_WINDOW (f
))
3564 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3565 do_pending_window_change (0);
3570 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3572 int wid
= FRAME_COLUMN_WIDTH (f
);
3576 x_set_scroll_bar_default_width (f
);
3578 if (FRAME_X_WINDOW (f
))
3579 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3580 do_pending_window_change (0);
3582 else if (INTEGERP (arg
) && XINT (arg
) > 0
3583 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3585 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3586 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3588 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3589 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3590 if (FRAME_X_WINDOW (f
))
3591 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3592 do_pending_window_change (0);
3595 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3596 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3597 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3602 /* Return non-nil if frame F wants a bitmap icon. */
3605 x_icon_type (FRAME_PTR f
)
3609 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3617 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3624 for (i
= 0; i
< 2; i
++)
3637 else if (FLOATP (item
))
3639 alpha
= XFLOAT_DATA (item
);
3640 if (alpha
< 0.0 || 1.0 < alpha
)
3641 args_out_of_range (make_float (0.0), make_float (1.0));
3643 else if (INTEGERP (item
))
3645 ialpha
= XINT (item
);
3646 if (ialpha
< 0 || 100 < ialpha
)
3647 args_out_of_range (make_number (0), make_number (100));
3649 alpha
= ialpha
/ 100.0;
3652 wrong_type_argument (Qnumberp
, item
);
3656 for (i
= 0; i
< 2; i
++)
3657 f
->alpha
[i
] = newval
[i
];
3659 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3661 x_set_frame_alpha (f
);
3669 /* Subroutines of creating an X frame. */
3671 /* Make sure that Vx_resource_name is set to a reasonable value.
3672 Fix it up, or set it to `emacs' if it is too hopeless. */
3675 validate_x_resource_name (void)
3678 /* Number of valid characters in the resource name. */
3680 /* Number of invalid characters in the resource name. */
3685 if (!STRINGP (Vx_resource_class
))
3686 Vx_resource_class
= build_string (EMACS_CLASS
);
3688 if (STRINGP (Vx_resource_name
))
3690 unsigned char *p
= SDATA (Vx_resource_name
);
3692 len
= SBYTES (Vx_resource_name
);
3694 /* Only letters, digits, - and _ are valid in resource names.
3695 Count the valid characters and count the invalid ones. */
3696 for (i
= 0; i
< len
; i
++)
3699 if (! ((c
>= 'a' && c
<= 'z')
3700 || (c
>= 'A' && c
<= 'Z')
3701 || (c
>= '0' && c
<= '9')
3702 || c
== '-' || c
== '_'))
3709 /* Not a string => completely invalid. */
3710 bad_count
= 5, good_count
= 0;
3712 /* If name is valid already, return. */
3716 /* If name is entirely invalid, or nearly so, use `emacs'. */
3719 Vx_resource_name
= build_string ("emacs");
3723 /* Name is partly valid. Copy it and replace the invalid characters
3724 with underscores. */
3726 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3728 for (i
= 0; i
< len
; i
++)
3730 int c
= SREF (new, i
);
3731 if (! ((c
>= 'a' && c
<= 'z')
3732 || (c
>= 'A' && c
<= 'Z')
3733 || (c
>= '0' && c
<= '9')
3734 || c
== '-' || c
== '_'))
3740 extern char *x_get_string_resource (XrmDatabase
, const char *, const char *);
3741 extern Display_Info
*check_x_display_info (Lisp_Object
);
3744 /* Get specified attribute from resource database RDB.
3745 See Fx_get_resource below for other parameters. */
3748 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3750 register char *value
;
3754 CHECK_STRING (attribute
);
3755 CHECK_STRING (class);
3757 if (!NILP (component
))
3758 CHECK_STRING (component
);
3759 if (!NILP (subclass
))
3760 CHECK_STRING (subclass
);
3761 if (NILP (component
) != NILP (subclass
))
3762 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3764 validate_x_resource_name ();
3766 /* Allocate space for the components, the dots which separate them,
3767 and the final '\0'. Make them big enough for the worst case. */
3768 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3769 + (STRINGP (component
)
3770 ? SBYTES (component
) : 0)
3771 + SBYTES (attribute
)
3774 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3776 + (STRINGP (subclass
)
3777 ? SBYTES (subclass
) : 0)
3780 /* Start with emacs.FRAMENAME for the name (the specific one)
3781 and with `Emacs' for the class key (the general one). */
3782 strcpy (name_key
, SSDATA (Vx_resource_name
));
3783 strcpy (class_key
, SSDATA (Vx_resource_class
));
3785 strcat (class_key
, ".");
3786 strcat (class_key
, SSDATA (class));
3788 if (!NILP (component
))
3790 strcat (class_key
, ".");
3791 strcat (class_key
, SSDATA (subclass
));
3793 strcat (name_key
, ".");
3794 strcat (name_key
, SSDATA (component
));
3797 strcat (name_key
, ".");
3798 strcat (name_key
, SSDATA (attribute
));
3800 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3802 if (value
!= (char *) 0 && *value
)
3803 return build_string (value
);
3809 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3810 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3811 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3812 class, where INSTANCE is the name under which Emacs was invoked, or
3813 the name specified by the `-name' or `-rn' command-line arguments.
3815 The optional arguments COMPONENT and SUBCLASS add to the key and the
3816 class, respectively. You must specify both of them or neither.
3817 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3818 and the class is `Emacs.CLASS.SUBCLASS'. */)
3819 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3821 #ifdef HAVE_X_WINDOWS
3825 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3826 attribute
, class, component
, subclass
);
3829 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3832 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3834 return xrdb_get_resource (dpyinfo
->xrdb
,
3835 attribute
, class, component
, subclass
);
3838 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3839 /* Used when C code wants a resource value. */
3840 /* Called from oldXMenu/Create.c. */
3842 x_get_resource_string (const char *attribute
, const char *class)
3846 struct frame
*sf
= SELECTED_FRAME ();
3848 /* Allocate space for the components, the dots which separate them,
3849 and the final '\0'. */
3850 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3851 + strlen (attribute
) + 2);
3852 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3853 + strlen (class) + 2);
3855 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3856 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3858 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3859 name_key
, class_key
);
3863 /* Return the value of parameter PARAM.
3865 First search ALIST, then Vdefault_frame_alist, then the X defaults
3866 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3868 Convert the resource to the type specified by desired_type.
3870 If no default is specified, return Qunbound. If you call
3871 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3872 and don't let it get stored in any Lisp-visible variables! */
3875 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3876 const char *attribute
, const char *class, enum resource_types type
)
3878 register Lisp_Object tem
;
3880 tem
= Fassq (param
, alist
);
3884 /* If we find this parm in ALIST, clear it out
3885 so that it won't be "left over" at the end. */
3887 XSETCAR (tem
, Qnil
);
3888 /* In case the parameter appears more than once in the alist,
3890 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3891 if (CONSP (XCAR (tail
))
3892 && EQ (XCAR (XCAR (tail
)), param
))
3893 XSETCAR (XCAR (tail
), Qnil
);
3896 tem
= Fassq (param
, Vdefault_frame_alist
);
3898 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3899 look in the X resources. */
3902 if (attribute
&& dpyinfo
)
3904 tem
= display_x_get_resource (dpyinfo
,
3905 build_string (attribute
),
3906 build_string (class),
3914 case RES_TYPE_NUMBER
:
3915 return make_number (atoi (SSDATA (tem
)));
3917 case RES_TYPE_BOOLEAN_NUMBER
:
3918 if (!strcmp (SSDATA (tem
), "on")
3919 || !strcmp (SSDATA (tem
), "true"))
3920 return make_number (1);
3921 return make_number (atoi (SSDATA (tem
)));
3924 case RES_TYPE_FLOAT
:
3925 return make_float (atof (SSDATA (tem
)));
3927 case RES_TYPE_BOOLEAN
:
3928 tem
= Fdowncase (tem
);
3929 if (!strcmp (SSDATA (tem
), "on")
3931 || !strcmp (SSDATA (tem
), "yes")
3933 || !strcmp (SSDATA (tem
), "true"))
3938 case RES_TYPE_STRING
:
3941 case RES_TYPE_SYMBOL
:
3942 /* As a special case, we map the values `true' and `on'
3943 to Qt, and `false' and `off' to Qnil. */
3946 lower
= Fdowncase (tem
);
3947 if (!strcmp (SSDATA (lower
), "on")
3949 || !strcmp (SSDATA (lower
), "yes")
3951 || !strcmp (SSDATA (lower
), "true"))
3953 else if (!strcmp (SSDATA (lower
), "off")
3955 || !strcmp (SSDATA (lower
), "no")
3957 || !strcmp (SSDATA (lower
), "false"))
3960 return Fintern (tem
, Qnil
);
3974 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3975 const char *attribute
, const char *class,
3976 enum resource_types type
)
3978 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3979 alist
, param
, attribute
, class, type
);
3982 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3985 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3987 const char *attribute
, const char *class,
3988 enum resource_types type
)
3992 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3993 attribute
, class, type
);
3994 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3995 store_frame_param (f
, param
, value
);
4001 /* Record in frame F the specified or default value according to ALIST
4002 of the parameter named PROP (a Lisp symbol).
4003 If no value is specified for PROP, look for an X default for XPROP
4004 on the frame named NAME.
4005 If that is not found either, use the value DEFLT. */
4008 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
4009 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
4010 enum resource_types type
)
4014 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
4015 if (EQ (tem
, Qunbound
))
4017 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
4024 /* NS used to define x-parse-geometry in ns-win.el, but that confused
4025 make-docfile: the documentation string in ns-win.el was used for
4026 x-parse-geometry even in non-NS builds.
4028 With two definitions of x-parse-geometry in this file, various
4029 things still get confused (eg M-x apropos documentation), so that
4030 it is best if the two definitions just share the same doc-string.
4032 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4033 doc
: /* Parse a display geometry string STRING.
4034 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4035 The properties returned may include `top', `left', `height', and `width'.
4036 For X, the value of `left' or `top' may be an integer,
4037 or a list (+ N) meaning N pixels relative to top/left corner,
4038 or a list (- N) meaning -N pixels relative to bottom/right corner.
4039 On Nextstep, this just calls `ns-parse-geometry'. */)
4040 (Lisp_Object string
)
4043 call1 (Qns_parse_geometry
, string
);
4046 unsigned int width
, height
;
4049 CHECK_STRING (string
);
4051 geometry
= XParseGeometry (SSDATA (string
),
4052 &x
, &y
, &width
, &height
);
4054 if (geometry
& XValue
)
4056 Lisp_Object element
;
4058 if (x
>= 0 && (geometry
& XNegative
))
4059 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
4060 else if (x
< 0 && ! (geometry
& XNegative
))
4061 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
4063 element
= Fcons (Qleft
, make_number (x
));
4064 result
= Fcons (element
, result
);
4067 if (geometry
& YValue
)
4069 Lisp_Object element
;
4071 if (y
>= 0 && (geometry
& YNegative
))
4072 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
4073 else if (y
< 0 && ! (geometry
& YNegative
))
4074 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
4076 element
= Fcons (Qtop
, make_number (y
));
4077 result
= Fcons (element
, result
);
4080 if (geometry
& WidthValue
)
4081 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
4082 if (geometry
& HeightValue
)
4083 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
4086 #endif /* HAVE_NS */
4090 /* Calculate the desired size and position of frame F.
4091 Return the flags saying which aspects were specified.
4093 Also set the win_gravity and size_hint_flags of F.
4095 Adjust height for toolbar if TOOLBAR_P is 1.
4097 This function does not make the coordinates positive. */
4099 #define DEFAULT_ROWS 35
4100 #define DEFAULT_COLS 80
4103 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, int toolbar_p
)
4105 register Lisp_Object tem0
, tem1
, tem2
;
4106 long window_prompting
= 0;
4107 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
4109 /* Default values if we fall through.
4110 Actually, if that happens we should get
4111 window manager prompting. */
4112 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4113 FRAME_LINES (f
) = DEFAULT_ROWS
;
4114 /* Window managers expect that if program-specified
4115 positions are not (0,0), they're intentional, not defaults. */
4119 /* Ensure that old new_text_cols and new_text_lines will not override the
4121 /* ++KFS: This was specific to W32, but seems ok for all platforms */
4122 f
->new_text_cols
= f
->new_text_lines
= 0;
4124 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4125 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4126 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4127 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4129 if (!EQ (tem0
, Qunbound
))
4131 CHECK_NUMBER (tem0
);
4132 FRAME_LINES (f
) = XINT (tem0
);
4134 if (!EQ (tem1
, Qunbound
))
4136 CHECK_NUMBER (tem1
);
4137 SET_FRAME_COLS (f
, XINT (tem1
));
4139 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4140 window_prompting
|= USSize
;
4142 window_prompting
|= PSize
;
4145 f
->scroll_bar_actual_width
4146 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4148 /* This used to be done _before_ calling x_figure_window_size, but
4149 since the height is reset here, this was really a no-op. I
4150 assume that moving it here does what Gerd intended (although he
4151 no longer can remember what that was... ++KFS, 2003-03-25. */
4153 /* Add the tool-bar height to the initial frame height so that the
4154 user gets a text display area of the size he specified with -g or
4155 via .Xdefaults. Later changes of the tool-bar height don't
4156 change the frame size. This is done so that users can create
4157 tall Emacs frames without having to guess how tall the tool-bar
4159 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4161 int margin
, relief
, bar_height
;
4163 relief
= (tool_bar_button_relief
>= 0
4164 ? tool_bar_button_relief
4165 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4167 if (INTEGERP (Vtool_bar_button_margin
)
4168 && XINT (Vtool_bar_button_margin
) > 0)
4169 margin
= XFASTINT (Vtool_bar_button_margin
);
4170 else if (CONSP (Vtool_bar_button_margin
)
4171 && INTEGERP (XCDR (Vtool_bar_button_margin
))
4172 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
4173 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4177 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4178 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4181 compute_fringe_widths (f
, 0);
4183 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4184 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4186 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4187 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4188 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4189 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4191 if (EQ (tem0
, Qminus
))
4194 window_prompting
|= YNegative
;
4196 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4197 && CONSP (XCDR (tem0
))
4198 && INTEGERP (XCAR (XCDR (tem0
))))
4200 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4201 window_prompting
|= YNegative
;
4203 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4204 && CONSP (XCDR (tem0
))
4205 && INTEGERP (XCAR (XCDR (tem0
))))
4207 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4209 else if (EQ (tem0
, Qunbound
))
4213 CHECK_NUMBER (tem0
);
4214 f
->top_pos
= XINT (tem0
);
4216 window_prompting
|= YNegative
;
4219 if (EQ (tem1
, Qminus
))
4222 window_prompting
|= XNegative
;
4224 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4225 && CONSP (XCDR (tem1
))
4226 && INTEGERP (XCAR (XCDR (tem1
))))
4228 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4229 window_prompting
|= XNegative
;
4231 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4232 && CONSP (XCDR (tem1
))
4233 && INTEGERP (XCAR (XCDR (tem1
))))
4235 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4237 else if (EQ (tem1
, Qunbound
))
4241 CHECK_NUMBER (tem1
);
4242 f
->left_pos
= XINT (tem1
);
4243 if (f
->left_pos
< 0)
4244 window_prompting
|= XNegative
;
4247 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4248 window_prompting
|= USPosition
;
4250 window_prompting
|= PPosition
;
4253 if (window_prompting
& XNegative
)
4255 if (window_prompting
& YNegative
)
4256 f
->win_gravity
= SouthEastGravity
;
4258 f
->win_gravity
= NorthEastGravity
;
4262 if (window_prompting
& YNegative
)
4263 f
->win_gravity
= SouthWestGravity
;
4265 f
->win_gravity
= NorthWestGravity
;
4268 f
->size_hint_flags
= window_prompting
;
4270 return window_prompting
;
4275 #endif /* HAVE_WINDOW_SYSTEM */
4278 frame_make_pointer_invisible (void)
4280 if (! NILP (Vmake_pointer_invisible
))
4283 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4286 f
= SELECTED_FRAME ();
4287 if (f
&& !f
->pointer_invisible
4288 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4291 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4292 f
->pointer_invisible
= 1;
4298 frame_make_pointer_visible (void)
4300 /* We don't check Vmake_pointer_invisible here in case the
4301 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4304 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4307 f
= SELECTED_FRAME ();
4308 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4309 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4311 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4312 f
->pointer_invisible
= 0;
4316 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4317 Sframe_pointer_visible_p
, 0, 1, 0,
4318 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4319 Otherwise it returns nil. FRAME omitted or nil means the
4320 selected frame. This is useful when `make-pointer-invisible' is set. */)
4324 frame
= selected_frame
;
4326 CHECK_FRAME (frame
);
4328 return (XFRAME (frame
)->pointer_invisible
? Qnil
: Qt
);
4332 /***********************************************************************
4334 ***********************************************************************/
4337 syms_of_frame (void)
4339 Qframep
= intern_c_string ("framep");
4340 staticpro (&Qframep
);
4341 Qframe_live_p
= intern_c_string ("frame-live-p");
4342 staticpro (&Qframe_live_p
);
4343 Qexplicit_name
= intern_c_string ("explicit-name");
4344 staticpro (&Qexplicit_name
);
4345 Qheight
= intern_c_string ("height");
4346 staticpro (&Qheight
);
4347 Qicon
= intern_c_string ("icon");
4349 Qminibuffer
= intern_c_string ("minibuffer");
4350 staticpro (&Qminibuffer
);
4351 Qmodeline
= intern_c_string ("modeline");
4352 staticpro (&Qmodeline
);
4353 Qonly
= intern_c_string ("only");
4355 Qwidth
= intern_c_string ("width");
4356 staticpro (&Qwidth
);
4357 Qgeometry
= intern_c_string ("geometry");
4358 staticpro (&Qgeometry
);
4359 Qicon_left
= intern_c_string ("icon-left");
4360 staticpro (&Qicon_left
);
4361 Qicon_top
= intern_c_string ("icon-top");
4362 staticpro (&Qicon_top
);
4363 Qtooltip
= intern_c_string ("tooltip");
4364 staticpro (&Qtooltip
);
4365 Qleft
= intern_c_string ("left");
4367 Qright
= intern_c_string ("right");
4368 staticpro (&Qright
);
4369 Quser_position
= intern_c_string ("user-position");
4370 staticpro (&Quser_position
);
4371 Quser_size
= intern_c_string ("user-size");
4372 staticpro (&Quser_size
);
4373 Qwindow_id
= intern_c_string ("window-id");
4374 staticpro (&Qwindow_id
);
4375 #ifdef HAVE_X_WINDOWS
4376 Qouter_window_id
= intern_c_string ("outer-window-id");
4377 staticpro (&Qouter_window_id
);
4379 Qparent_id
= intern_c_string ("parent-id");
4380 staticpro (&Qparent_id
);
4381 Qx
= intern_c_string ("x");
4383 Qw32
= intern_c_string ("w32");
4385 Qpc
= intern_c_string ("pc");
4387 Qmac
= intern_c_string ("mac");
4389 Qns
= intern_c_string ("ns");
4391 Qvisible
= intern_c_string ("visible");
4392 staticpro (&Qvisible
);
4393 Qbuffer_predicate
= intern_c_string ("buffer-predicate");
4394 staticpro (&Qbuffer_predicate
);
4395 Qbuffer_list
= intern_c_string ("buffer-list");
4396 staticpro (&Qbuffer_list
);
4397 Qburied_buffer_list
= intern_c_string ("buried-buffer-list");
4398 staticpro (&Qburied_buffer_list
);
4399 Qdisplay_type
= intern_c_string ("display-type");
4400 staticpro (&Qdisplay_type
);
4401 Qbackground_mode
= intern_c_string ("background-mode");
4402 staticpro (&Qbackground_mode
);
4403 Qnoelisp
= intern_c_string ("noelisp");
4404 staticpro (&Qnoelisp
);
4405 Qtty_color_mode
= intern_c_string ("tty-color-mode");
4406 staticpro (&Qtty_color_mode
);
4407 Qtty
= intern_c_string ("tty");
4409 Qtty_type
= intern_c_string ("tty-type");
4410 staticpro (&Qtty_type
);
4412 Qface_set_after_frame_default
= intern_c_string ("face-set-after-frame-default");
4413 staticpro (&Qface_set_after_frame_default
);
4415 Qfullwidth
= intern_c_string ("fullwidth");
4416 staticpro (&Qfullwidth
);
4417 Qfullheight
= intern_c_string ("fullheight");
4418 staticpro (&Qfullheight
);
4419 Qfullboth
= intern_c_string ("fullboth");
4420 staticpro (&Qfullboth
);
4421 Qmaximized
= intern_c_string ("maximized");
4422 staticpro (&Qmaximized
);
4423 Qx_resource_name
= intern_c_string ("x-resource-name");
4424 staticpro (&Qx_resource_name
);
4426 Qx_frame_parameter
= intern_c_string ("x-frame-parameter");
4427 staticpro (&Qx_frame_parameter
);
4429 Qterminal
= intern_c_string ("terminal");
4430 staticpro (&Qterminal
);
4431 Qterminal_live_p
= intern_c_string ("terminal-live-p");
4432 staticpro (&Qterminal_live_p
);
4435 Qns_parse_geometry
= intern_c_string ("ns-parse-geometry");
4436 staticpro (&Qns_parse_geometry
);
4442 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4444 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4445 if (frame_parms
[i
].variable
)
4447 *frame_parms
[i
].variable
= v
;
4448 staticpro (frame_parms
[i
].variable
);
4450 Fput (v
, Qx_frame_parameter
, make_number (i
));
4454 #ifdef HAVE_WINDOW_SYSTEM
4455 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4456 doc
: /* The name Emacs uses to look up X resources.
4457 `x-get-resource' uses this as the first component of the instance name
4458 when requesting resource values.
4459 Emacs initially sets `x-resource-name' to the name under which Emacs
4460 was invoked, or to the value specified with the `-name' or `-rn'
4461 switches, if present.
4463 It may be useful to bind this variable locally around a call
4464 to `x-get-resource'. See also the variable `x-resource-class'. */);
4465 Vx_resource_name
= Qnil
;
4467 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4468 doc
: /* The class Emacs uses to look up X resources.
4469 `x-get-resource' uses this as the first component of the instance class
4470 when requesting resource values.
4472 Emacs initially sets `x-resource-class' to "Emacs".
4474 Setting this variable permanently is not a reasonable thing to do,
4475 but binding this variable locally around a call to `x-get-resource'
4476 is a reasonable practice. See also the variable `x-resource-name'. */);
4477 Vx_resource_class
= build_string (EMACS_CLASS
);
4479 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4480 doc
: /* The lower limit of the frame opacity (alpha transparency).
4481 The value should range from 0 (invisible) to 100 (completely opaque).
4482 You can also use a floating number between 0.0 and 1.0.
4483 The default is 20. */);
4484 Vframe_alpha_lower_limit
= make_number (20);
4487 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4488 doc
: /* Alist of default values for frame creation.
4489 These may be set in your init file, like this:
4490 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4491 These override values given in window system configuration data,
4492 including X Windows' defaults database.
4493 For values specific to the first Emacs frame, see `initial-frame-alist'.
4494 For window-system specific values, see `window-system-default-frame-alist'.
4495 For values specific to the separate minibuffer frame, see
4496 `minibuffer-frame-alist'.
4497 The `menu-bar-lines' element of the list controls whether new frames
4498 have menu bars; `menu-bar-mode' works by altering this element.
4499 Setting this variable does not affect existing frames, only new ones. */);
4500 Vdefault_frame_alist
= Qnil
;
4502 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4503 doc
: /* Default position of scroll bars on this window-system. */);
4504 #ifdef HAVE_WINDOW_SYSTEM
4505 #if defined(HAVE_NTGUI) || defined(NS_IMPL_COCOA) || (defined(USE_GTK) && defined(USE_TOOLKIT_SCROLL_BARS))
4506 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4508 Vdefault_frame_scroll_bars
= Qright
;
4510 Vdefault_frame_scroll_bars
= Qleft
;
4513 Vdefault_frame_scroll_bars
= Qnil
;
4516 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4517 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4519 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4520 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4521 `mouse-position' calls this function, passing its usual return value as
4522 argument, and returns whatever this function returns.
4523 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4524 which need to do mouse handling at the Lisp level. */);
4525 Vmouse_position_function
= Qnil
;
4527 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4528 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4529 If the value is an integer, highlighting is only shown after moving the
4530 mouse, while keyboard input turns off the highlight even when the mouse
4531 is over the clickable text. However, the mouse shape still indicates
4532 when the mouse is over clickable text. */);
4533 Vmouse_highlight
= Qt
;
4535 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4536 doc
: /* If non-nil, make pointer invisible while typing.
4537 The pointer becomes visible again when the mouse is moved. */);
4538 Vmake_pointer_invisible
= Qt
;
4540 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4541 doc
: /* Functions to be run before deleting a frame.
4542 The functions are run with one arg, the frame to be deleted.
4545 Note that functions in this list may be called just before the frame is
4546 actually deleted, or some time later (or even both when an earlier function
4547 in `delete-frame-functions' (indirectly) calls `delete-frame'
4549 Vdelete_frame_functions
= Qnil
;
4550 Qdelete_frame_functions
= intern_c_string ("delete-frame-functions");
4551 staticpro (&Qdelete_frame_functions
);
4553 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4554 doc
: /* Non-nil if Menu-Bar mode is enabled.
4555 See the command `menu-bar-mode' for a description of this minor mode.
4556 Setting this variable directly does not take effect;
4557 either customize it (see the info node `Easy Customization')
4558 or call the function `menu-bar-mode'. */);
4559 Vmenu_bar_mode
= Qt
;
4561 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4562 doc
: /* Non-nil if Tool-Bar mode is enabled.
4563 See the command `tool-bar-mode' for a description of this minor mode.
4564 Setting this variable directly does not take effect;
4565 either customize it (see the info node `Easy Customization')
4566 or call the function `tool-bar-mode'. */);
4567 #ifdef HAVE_WINDOW_SYSTEM
4568 Vtool_bar_mode
= Qt
;
4570 Vtool_bar_mode
= Qnil
;
4573 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4574 doc
: /* Minibufferless frames use this frame's minibuffer.
4576 Emacs cannot create minibufferless frames unless this is set to an
4577 appropriate surrogate.
4579 Emacs consults this variable only when creating minibufferless
4580 frames; once the frame is created, it sticks with its assigned
4581 minibuffer, no matter what this variable is set to. This means that
4582 this variable doesn't necessarily say anything meaningful about the
4583 current set of frames, or where the minibuffer is currently being
4586 This variable is local to the current terminal and cannot be buffer-local. */);
4588 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
4589 doc
: /* Non-nil if window system changes focus when you move the mouse.
4590 You should set this variable to tell Emacs how your window manager
4591 handles focus, since there is no way in general for Emacs to find out
4592 automatically. See also `mouse-autoselect-window'. */);
4593 focus_follows_mouse
= 0;
4595 staticpro (&Vframe_list
);
4597 defsubr (&Sactive_minibuffer_window
);
4599 defsubr (&Sframe_live_p
);
4600 defsubr (&Swindow_system
);
4601 defsubr (&Smake_terminal_frame
);
4602 defsubr (&Shandle_switch_frame
);
4603 defsubr (&Sselect_frame
);
4604 defsubr (&Sselected_frame
);
4605 defsubr (&Swindow_frame
);
4606 defsubr (&Sframe_root_window
);
4607 defsubr (&Sframe_first_window
);
4608 defsubr (&Sframe_selected_window
);
4609 defsubr (&Sset_frame_selected_window
);
4610 defsubr (&Sframe_list
);
4611 defsubr (&Snext_frame
);
4612 defsubr (&Sprevious_frame
);
4613 defsubr (&Sdelete_frame
);
4614 defsubr (&Smouse_position
);
4615 defsubr (&Smouse_pixel_position
);
4616 defsubr (&Sset_mouse_position
);
4617 defsubr (&Sset_mouse_pixel_position
);
4619 defsubr (&Sframe_configuration
);
4620 defsubr (&Srestore_frame_configuration
);
4622 defsubr (&Smake_frame_visible
);
4623 defsubr (&Smake_frame_invisible
);
4624 defsubr (&Siconify_frame
);
4625 defsubr (&Sframe_visible_p
);
4626 defsubr (&Svisible_frame_list
);
4627 defsubr (&Sraise_frame
);
4628 defsubr (&Slower_frame
);
4629 defsubr (&Sredirect_frame_focus
);
4630 defsubr (&Sframe_focus
);
4631 defsubr (&Sframe_parameters
);
4632 defsubr (&Sframe_parameter
);
4633 defsubr (&Smodify_frame_parameters
);
4634 defsubr (&Sframe_char_height
);
4635 defsubr (&Sframe_char_width
);
4636 defsubr (&Sframe_pixel_height
);
4637 defsubr (&Sframe_pixel_width
);
4638 defsubr (&Stool_bar_pixel_width
);
4639 defsubr (&Sset_frame_height
);
4640 defsubr (&Sset_frame_width
);
4641 defsubr (&Sset_frame_size
);
4642 defsubr (&Sset_frame_position
);
4643 defsubr (&Sframe_pointer_visible_p
);
4645 #ifdef HAVE_WINDOW_SYSTEM
4646 defsubr (&Sx_get_resource
);
4647 defsubr (&Sx_parse_geometry
);