1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007, 2008, 2009, 2010 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/>. */
26 #include "character.h"
37 /* These help us bind and responding to switch-frame events. */
41 #include "blockinput.h"
43 #include "termhooks.h"
44 #include "dispextern.h"
47 #ifdef HAVE_WINDOW_SYSTEM
56 /* If we shall make pointer invisible when typing or not. */
57 Lisp_Object Vmake_pointer_invisible
;
59 #ifdef HAVE_WINDOW_SYSTEM
61 /* The name we're using in resource queries. Most often "emacs". */
63 Lisp_Object Vx_resource_name
;
65 /* The application class we're using in resource queries.
68 Lisp_Object Vx_resource_class
;
70 /* Lower limit value of the frame opacity (alpha transparency). */
72 Lisp_Object Vframe_alpha_lower_limit
;
77 Lisp_Object Qns_parse_geometry
;
80 Lisp_Object Qframep
, Qframe_live_p
;
81 Lisp_Object Qicon
, Qmodeline
;
83 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
, Qns
;
85 Lisp_Object Qdisplay_type
;
86 Lisp_Object Qbackground_mode
;
89 Lisp_Object Qx_frame_parameter
;
90 Lisp_Object Qx_resource_name
;
91 Lisp_Object Qterminal
;
92 Lisp_Object Qterminal_live_p
;
94 /* Frame parameters (set or reported). */
96 Lisp_Object Qauto_raise
, Qauto_lower
;
97 Lisp_Object Qborder_color
, Qborder_width
;
98 Lisp_Object Qcursor_color
, Qcursor_type
;
99 Lisp_Object Qgeometry
; /* Not used */
100 Lisp_Object Qheight
, Qwidth
;
101 Lisp_Object Qleft
, Qright
;
102 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
103 Lisp_Object Qtooltip
;
104 Lisp_Object Qinternal_border_width
;
105 Lisp_Object Qmouse_color
;
106 Lisp_Object Qminibuffer
;
107 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
108 Lisp_Object Qvisibility
;
109 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
110 Lisp_Object Qscreen_gamma
;
111 Lisp_Object Qline_spacing
;
112 Lisp_Object Quser_position
, Quser_size
;
113 Lisp_Object Qwait_for_wm
;
114 Lisp_Object Qwindow_id
;
115 #ifdef HAVE_X_WINDOWS
116 Lisp_Object Qouter_window_id
;
118 Lisp_Object Qparent_id
;
119 Lisp_Object Qtitle
, Qname
;
120 Lisp_Object Qexplicit_name
;
121 Lisp_Object Qunsplittable
;
122 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
123 Lisp_Object Vmenu_bar_mode
, Vtool_bar_mode
;
124 Lisp_Object Qleft_fringe
, Qright_fringe
;
125 Lisp_Object Qbuffer_predicate
, Qbuffer_list
, Qburied_buffer_list
;
126 Lisp_Object Qtty_color_mode
;
127 Lisp_Object Qtty
, Qtty_type
;
129 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
131 Lisp_Object Qfont_backend
;
134 Lisp_Object Qface_set_after_frame_default
;
136 Lisp_Object Vterminal_frame
;
137 Lisp_Object Vdefault_frame_alist
;
138 Lisp_Object Vdefault_frame_scroll_bars
;
139 Lisp_Object Vmouse_position_function
;
140 Lisp_Object Vmouse_highlight
;
141 static Lisp_Object Vdelete_frame_functions
, Qdelete_frame_functions
;
143 int focus_follows_mouse
;
146 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
148 struct window
*w
= XWINDOW (window
);
150 XSETFASTINT (w
->last_modified
, 0);
151 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
152 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
154 if (INTEGERP (w
->orig_top_line
))
155 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
156 if (INTEGERP (w
->orig_total_lines
))
157 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
159 /* Handle just the top child in a vertical split. */
160 if (!NILP (w
->vchild
))
161 set_menu_bar_lines_1 (w
->vchild
, n
);
163 /* Adjust all children in a horizontal split. */
164 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
166 w
= XWINDOW (window
);
167 set_menu_bar_lines_1 (window
, n
);
172 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
175 int olines
= FRAME_MENU_BAR_LINES (f
);
177 /* Right now, menu bars don't work properly in minibuf-only frames;
178 most of the commands try to apply themselves to the minibuffer
179 frame itself, and get an error because you can't switch buffers
180 in or split the minibuffer window. */
181 if (FRAME_MINIBUF_ONLY_P (f
))
184 if (INTEGERP (value
))
185 nlines
= XINT (value
);
189 if (nlines
!= olines
)
191 windows_or_buffers_changed
++;
192 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
193 FRAME_MENU_BAR_LINES (f
) = nlines
;
194 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
199 Lisp_Object Vframe_list
;
201 extern Lisp_Object Vminibuffer_list
;
202 extern Lisp_Object
get_minibuffer (int);
203 extern Lisp_Object
Fhandle_switch_frame (Lisp_Object event
);
204 extern Lisp_Object
Fredirect_frame_focus (Lisp_Object frame
, Lisp_Object focus_frame
);
205 extern Lisp_Object
x_get_focus_frame (struct frame
*frame
);
206 extern Lisp_Object QCname
, Qfont_param
;
209 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
210 doc
: /* Return non-nil if OBJECT is a frame.
211 Value is t for a termcap frame (a character-only terminal),
212 `x' for an Emacs frame that is really an X window,
213 `w32' for an Emacs frame that is a window on MS-Windows display,
214 `ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
215 `pc' for a direct-write MS-DOS frame.
216 See also `frame-live-p'. */)
219 if (!FRAMEP (object
))
221 switch (XFRAME (object
)->output_method
)
223 case output_initial
: /* The initial frame is like a termcap frame. */
226 case output_x_window
:
230 case output_msdos_raw
:
241 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
242 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
243 Value is nil if OBJECT is not a live frame. If object is a live
244 frame, the return value indicates what sort of terminal device it is
245 displayed on. See the documentation of `framep' for possible
249 return ((FRAMEP (object
)
250 && FRAME_LIVE_P (XFRAME (object
)))
255 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
256 doc
: /* The name of the window system that FRAME is displaying through.
257 The value is a symbol---for instance, 'x' for X windows.
258 The value is nil if Emacs is using a text-only terminal.
260 FRAME defaults to the currently selected frame. */)
265 frame
= selected_frame
;
267 type
= Fframep (frame
);
270 wrong_type_argument (Qframep
, frame
);
279 make_frame (int mini_p
)
282 register struct frame
*f
;
283 register Lisp_Object root_window
;
284 register Lisp_Object mini_window
;
286 f
= allocate_frame ();
287 XSETFRAME (frame
, f
);
289 f
->desired_matrix
= 0;
290 f
->current_matrix
= 0;
293 f
->glyphs_initialized_p
= 0;
294 f
->decode_mode_spec_buffer
= 0;
296 f
->async_visible
= 0;
297 f
->output_data
.nothing
= 0;
299 f
->async_iconified
= 0;
300 f
->wants_modeline
= 1;
305 f
->has_minibuffer
= mini_p
;
306 f
->focus_frame
= Qnil
;
307 f
->explicit_name
= 0;
308 f
->can_have_scroll_bars
= 0;
309 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
310 f
->param_alist
= Qnil
;
311 f
->scroll_bars
= Qnil
;
312 f
->condemned_scroll_bars
= Qnil
;
313 f
->face_alist
= Qnil
;
314 f
->face_cache
= NULL
;
315 f
->menu_bar_items
= Qnil
;
316 f
->menu_bar_vector
= Qnil
;
317 f
->menu_bar_items_used
= 0;
318 f
->buffer_predicate
= Qnil
;
319 f
->buffer_list
= Qnil
;
320 f
->buried_buffer_list
= Qnil
;
323 f
->menu_bar_window
= Qnil
;
324 f
->tool_bar_window
= Qnil
;
325 f
->tool_bar_items
= Qnil
;
326 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
327 f
->n_tool_bar_items
= 0;
328 f
->left_fringe_width
= f
->right_fringe_width
= 0;
330 f
->menu_bar_lines
= 0;
331 f
->tool_bar_lines
= 0;
332 f
->scroll_bar_actual_width
= 0;
334 f
->internal_border_width
= 0;
335 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
336 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
337 f
->x_pixels_diff
= f
->y_pixels_diff
= 0;
338 #ifdef HAVE_WINDOW_SYSTEM
339 f
->want_fullscreen
= FULLSCREEN_NONE
;
341 f
->size_hint_flags
= 0;
343 f
->font_driver_list
= NULL
;
344 f
->font_data_list
= NULL
;
346 root_window
= make_window ();
349 mini_window
= make_window ();
350 XWINDOW (root_window
)->next
= mini_window
;
351 XWINDOW (mini_window
)->prev
= root_window
;
352 XWINDOW (mini_window
)->mini_p
= Qt
;
353 XWINDOW (mini_window
)->frame
= frame
;
354 f
->minibuffer_window
= mini_window
;
359 XWINDOW (root_window
)->next
= Qnil
;
360 f
->minibuffer_window
= Qnil
;
363 XWINDOW (root_window
)->frame
= frame
;
366 just so that there is "something there."
367 Correct size will be set up later with change_frame_size. */
369 SET_FRAME_COLS (f
, 10);
370 FRAME_LINES (f
) = 10;
372 XSETFASTINT (XWINDOW (root_window
)->total_cols
, 10);
373 XSETFASTINT (XWINDOW (root_window
)->total_lines
, (mini_p
? 9 : 10));
377 XSETFASTINT (XWINDOW (mini_window
)->total_cols
, 10);
378 XSETFASTINT (XWINDOW (mini_window
)->top_line
, 9);
379 XSETFASTINT (XWINDOW (mini_window
)->total_lines
, 1);
382 /* Choose a buffer for the frame's root window. */
386 XWINDOW (root_window
)->buffer
= Qt
;
387 buf
= Fcurrent_buffer ();
388 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
389 a space), try to find another one. */
390 if (SREF (Fbuffer_name (buf
), 0) == ' ')
391 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
393 /* Use set_window_buffer, not Fset_window_buffer, and don't let
394 hooks be run by it. The reason is that the whole frame/window
395 arrangement is not yet fully intialized at this point. Windows
396 don't have the right size, glyph matrices aren't initialized
397 etc. Running Lisp functions at this point surely ends in a
399 set_window_buffer (root_window
, buf
, 0, 0);
400 f
->buffer_list
= Fcons (buf
, Qnil
);
405 XWINDOW (mini_window
)->buffer
= Qt
;
406 set_window_buffer (mini_window
,
407 (NILP (Vminibuffer_list
)
409 : Fcar (Vminibuffer_list
)),
413 f
->root_window
= root_window
;
414 f
->selected_window
= root_window
;
415 /* Make sure this window seems more recently used than
416 a newly-created, never-selected window. */
417 ++window_select_count
;
418 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, window_select_count
);
420 f
->default_face_done_p
= 0;
425 #ifdef HAVE_WINDOW_SYSTEM
426 /* Make a frame using a separate minibuffer window on another frame.
427 MINI_WINDOW is the minibuffer window to use. nil means use the
428 default (the global minibuffer). */
431 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
433 register struct frame
*f
;
436 if (!NILP (mini_window
))
437 CHECK_LIVE_WINDOW (mini_window
);
439 if (!NILP (mini_window
)
440 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
441 error ("Frame and minibuffer must be on the same terminal");
443 /* Make a frame containing just a root window. */
446 if (NILP (mini_window
))
448 /* Use default-minibuffer-frame if possible. */
449 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
450 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
452 Lisp_Object frame_dummy
;
454 XSETFRAME (frame_dummy
, f
);
455 GCPRO1 (frame_dummy
);
456 /* If there's no minibuffer frame to use, create one. */
457 kb
->Vdefault_minibuffer_frame
=
458 call1 (intern ("make-initial-minibuffer-frame"), display
);
462 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
465 f
->minibuffer_window
= mini_window
;
467 /* Make the chosen minibuffer window display the proper minibuffer,
468 unless it is already showing a minibuffer. */
469 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
470 Fset_window_buffer (mini_window
,
471 (NILP (Vminibuffer_list
)
473 : Fcar (Vminibuffer_list
)), Qnil
);
477 /* Make a frame containing only a minibuffer window. */
480 make_minibuffer_frame (void)
482 /* First make a frame containing just a root window, no minibuffer. */
484 register struct frame
*f
= make_frame (0);
485 register Lisp_Object mini_window
;
486 register Lisp_Object frame
;
488 XSETFRAME (frame
, f
);
493 f
->wants_modeline
= 0;
494 f
->has_minibuffer
= 1;
496 /* Now label the root window as also being the minibuffer.
497 Avoid infinite looping on the window chain by marking next pointer
500 mini_window
= f
->minibuffer_window
= f
->root_window
;
501 XWINDOW (mini_window
)->mini_p
= Qt
;
502 XWINDOW (mini_window
)->next
= Qnil
;
503 XWINDOW (mini_window
)->prev
= Qnil
;
504 XWINDOW (mini_window
)->frame
= frame
;
506 /* Put the proper buffer in that window. */
508 Fset_window_buffer (mini_window
,
509 (NILP (Vminibuffer_list
)
511 : Fcar (Vminibuffer_list
)), Qnil
);
514 #endif /* HAVE_WINDOW_SYSTEM */
516 /* Construct a frame that refers to a terminal. */
518 static int tty_frame_count
;
521 make_initial_frame (void)
524 struct terminal
*terminal
;
527 eassert (initial_kboard
);
529 /* The first call must initialize Vframe_list. */
530 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
533 terminal
= init_initial_terminal ();
536 XSETFRAME (frame
, f
);
538 Vframe_list
= Fcons (frame
, Vframe_list
);
541 f
->name
= make_pure_c_string ("F1");
544 f
->async_visible
= 1;
546 f
->output_method
= terminal
->type
;
547 f
->terminal
= terminal
;
548 f
->terminal
->reference_count
++;
549 f
->output_data
.nothing
= 0;
551 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
552 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
554 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
555 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
557 /* The default value of menu-bar-mode is t. */
558 set_menu_bar_lines (f
, make_number (1), Qnil
);
562 init_frame_faces (f
);
570 make_terminal_frame (struct terminal
*terminal
)
572 register struct frame
*f
;
577 error ("Terminal is not live, can't create new frames on it");
581 XSETFRAME (frame
, f
);
582 Vframe_list
= Fcons (frame
, Vframe_list
);
585 sprintf (name
, "F%d", tty_frame_count
);
586 f
->name
= build_string (name
);
588 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
589 f
->async_visible
= 1; /* Don't let visible be cleared later. */
590 f
->terminal
= terminal
;
591 f
->terminal
->reference_count
++;
593 f
->output_data
.tty
->display_info
= &the_only_display_info
;
594 if (!inhibit_window_system
595 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
596 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
597 f
->output_method
= output_msdos_raw
;
599 f
->output_method
= output_termcap
;
600 #else /* not MSDOS */
601 f
->output_method
= output_termcap
;
602 create_tty_output (f
);
603 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
604 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
605 #endif /* not MSDOS */
607 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
608 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
609 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
611 /* Set the top frame to the newly created frame. */
612 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
613 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
614 XFRAME (FRAME_TTY (f
)->top_frame
)->async_visible
= 2; /* obscured */
616 FRAME_TTY (f
)->top_frame
= frame
;
619 init_frame_faces (f
);
624 /* Get a suitable value for frame parameter PARAMETER for a newly
625 created frame, based on (1) the user-supplied frame parameter
626 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
629 get_future_frame_param (Lisp_Object parameter
,
630 Lisp_Object supplied_parms
,
635 result
= Fassq (parameter
, supplied_parms
);
637 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
638 if (NILP (result
) && current_value
!= NULL
)
639 result
= build_string (current_value
);
640 if (!NILP (result
) && !STRINGP (result
))
641 result
= XCDR (result
);
642 if (NILP (result
) || !STRINGP (result
))
648 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
650 doc
: /* Create an additional terminal frame, possibly on another terminal.
651 This function takes one argument, an alist specifying frame parameters.
653 You can create multiple frames on a single text-only terminal, but
654 only one of them (the selected terminal frame) is actually displayed.
656 In practice, generally you don't need to specify any parameters,
657 except when you want to create a new frame on another terminal.
658 In that case, the `tty' parameter specifies the device file to open,
659 and the `tty-type' parameter specifies the terminal type. Example:
661 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
663 Note that changing the size of one terminal frame automatically
664 affects all frames on the same terminal device. */)
668 struct terminal
*t
= NULL
;
669 Lisp_Object frame
, tem
;
670 struct frame
*sf
= SELECTED_FRAME ();
673 if (sf
->output_method
!= output_msdos_raw
674 && sf
->output_method
!= output_termcap
)
676 #else /* not MSDOS */
678 #ifdef WINDOWSNT /* This should work now! */
679 if (sf
->output_method
!= output_termcap
)
680 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
682 #endif /* not MSDOS */
685 Lisp_Object terminal
;
687 terminal
= Fassq (Qterminal
, parms
);
688 if (!NILP (terminal
))
690 terminal
= XCDR (terminal
);
691 t
= get_terminal (terminal
, 1);
694 if (t
&& t
!= the_only_display_info
.terminal
)
695 /* msdos.c assumes a single tty_display_info object. */
696 error ("Multiple terminals are not supported on this platform");
698 t
= the_only_display_info
.terminal
;
704 char *name
= 0, *type
= 0;
705 Lisp_Object tty
, tty_type
;
707 tty
= get_future_frame_param
708 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
709 ? FRAME_TTY (XFRAME (selected_frame
))->name
713 name
= (char *) alloca (SBYTES (tty
) + 1);
714 strncpy (name
, SDATA (tty
), SBYTES (tty
));
715 name
[SBYTES (tty
)] = 0;
718 tty_type
= get_future_frame_param
719 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
720 ? FRAME_TTY (XFRAME (selected_frame
))->type
722 if (!NILP (tty_type
))
724 type
= (char *) alloca (SBYTES (tty_type
) + 1);
725 strncpy (type
, SDATA (tty_type
), SBYTES (tty_type
));
726 type
[SBYTES (tty_type
)] = 0;
729 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
732 f
= make_terminal_frame (t
);
736 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
737 change_frame_size (f
, height
, width
, 0, 0, 0);
742 XSETFRAME (frame
, f
);
743 Fmodify_frame_parameters (frame
, parms
);
744 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
745 build_string (t
->display_info
.tty
->type
)),
747 if (t
->display_info
.tty
->name
!= NULL
)
748 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
749 build_string (t
->display_info
.tty
->name
)),
752 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
754 /* Make the frame face alist be frame-specific, so that each
755 frame could change its face definitions independently. */
756 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
757 /* Simple Fcopy_alist isn't enough, because we need the contents of
758 the vectors which are the CDRs of associations in face_alist to
759 be copied as well. */
760 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
761 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
766 /* Perform the switch to frame FRAME.
768 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
771 If TRACK is non-zero and the frame that currently has the focus
772 redirects its focus to the selected frame, redirect that focused
773 frame's focus to FRAME instead.
775 FOR_DELETION non-zero means that the selected frame is being
776 deleted, which includes the possibility that the frame's terminal
779 The value of NORECORD is passed as argument to Fselect_window. */
782 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
784 struct frame
*sf
= SELECTED_FRAME ();
786 /* If FRAME is a switch-frame event, extract the frame we should
789 && EQ (XCAR (frame
), Qswitch_frame
)
790 && CONSP (XCDR (frame
)))
791 frame
= XCAR (XCDR (frame
));
793 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
794 a switch-frame event to arrive after a frame is no longer live,
795 especially when deleting the initial frame during startup. */
797 if (! FRAME_LIVE_P (XFRAME (frame
)))
800 if (sf
== XFRAME (frame
))
803 /* This is too greedy; it causes inappropriate focus redirection
804 that's hard to get rid of. */
806 /* If a frame's focus has been redirected toward the currently
807 selected frame, we should change the redirection to point to the
808 newly selected frame. This means that if the focus is redirected
809 from a minibufferless frame to a surrogate minibuffer frame, we
810 can use `other-window' to switch between all the frames using
811 that minibuffer frame, and the focus redirection will follow us
817 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
821 if (!FRAMEP (XCAR (tail
)))
824 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
826 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
827 Fredirect_frame_focus (XCAR (tail
), frame
);
831 /* Instead, apply it only to the frame we're pointing to. */
832 #ifdef HAVE_WINDOW_SYSTEM
833 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
835 Lisp_Object focus
, xfocus
;
837 xfocus
= x_get_focus_frame (XFRAME (frame
));
840 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
841 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
842 Fredirect_frame_focus (xfocus
, frame
);
845 #endif /* HAVE_X_WINDOWS */
848 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
849 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
851 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
853 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
854 /* Mark previously displayed frame as now obscured. */
855 XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
)->async_visible
= 2;
856 XFRAME (frame
)->async_visible
= 1;
857 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
860 selected_frame
= frame
;
861 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
862 last_nonminibuf_frame
= XFRAME (selected_frame
);
864 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
866 /* We want to make sure that the next event generates a frame-switch
867 event to the appropriate frame. This seems kludgy to me, but
868 before you take it out, make sure that evaluating something like
869 (select-window (frame-root-window (new-frame))) doesn't end up
870 with your typing being interpreted in the new frame instead of
871 the one you're actually typing in. */
872 internal_last_event_frame
= Qnil
;
877 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
878 doc
: /* Select FRAME.
879 Subsequent editing commands apply to its selected window.
880 Optional argument NORECORD means to neither change the order of
881 recently selected windows nor the buffer list.
883 The selection of FRAME lasts until the next time the user does
884 something to select a different frame, or until the next time
885 this function is called. If you are using a window system, the
886 previously selected frame may be restored as the selected frame
887 when returning to the command loop, because it still may have
888 the window system's input focus. On a text-only terminal, the
889 next redisplay will display FRAME.
891 This function returns FRAME, or nil if FRAME has been deleted. */)
892 (Lisp_Object frame
, Lisp_Object norecord
)
894 return do_switch_frame (frame
, 1, 0, norecord
);
898 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
899 doc
: /* Handle a switch-frame event EVENT.
900 Switch-frame events are usually bound to this function.
901 A switch-frame event tells Emacs that the window manager has requested
902 that the user's events be directed to the frame mentioned in the event.
903 This function selects the selected window of the frame of EVENT.
905 If EVENT is frame object, handle it as if it were a switch-frame event
909 /* Preserve prefix arg that the command loop just cleared. */
910 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
911 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
912 return do_switch_frame (event
, 0, 0, Qnil
);
915 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
916 doc
: /* Return the frame that is now selected. */)
919 return selected_frame
;
922 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
923 doc
: /* Return the frame object that window WINDOW is on. */)
926 CHECK_LIVE_WINDOW (window
);
927 return XWINDOW (window
)->frame
;
930 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
931 doc
: /* Returns the topmost, leftmost window of FRAME.
932 If omitted, FRAME defaults to the currently selected frame. */)
938 w
= SELECTED_FRAME ()->root_window
;
941 CHECK_LIVE_FRAME (frame
);
942 w
= XFRAME (frame
)->root_window
;
944 while (NILP (XWINDOW (w
)->buffer
))
946 if (! NILP (XWINDOW (w
)->hchild
))
947 w
= XWINDOW (w
)->hchild
;
948 else if (! NILP (XWINDOW (w
)->vchild
))
949 w
= XWINDOW (w
)->vchild
;
956 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
957 Sactive_minibuffer_window
, 0, 0, 0,
958 doc
: /* Return the currently active minibuffer window, or nil if none. */)
961 return minibuf_level
? minibuf_window
: Qnil
;
964 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
965 doc
: /* Returns the root-window of FRAME.
966 If omitted, FRAME defaults to the currently selected frame. */)
972 window
= SELECTED_FRAME ()->root_window
;
975 CHECK_LIVE_FRAME (frame
);
976 window
= XFRAME (frame
)->root_window
;
982 DEFUN ("frame-selected-window", Fframe_selected_window
,
983 Sframe_selected_window
, 0, 1, 0,
984 doc
: /* Return the selected window of FRAME.
985 FRAME defaults to the currently selected frame. */)
991 window
= SELECTED_FRAME ()->selected_window
;
994 CHECK_LIVE_FRAME (frame
);
995 window
= XFRAME (frame
)->selected_window
;
1001 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
1002 Sset_frame_selected_window
, 2, 3, 0,
1003 doc
: /* Set selected window of FRAME to WINDOW.
1004 If FRAME is nil, use the selected frame. If FRAME is the
1005 selected frame, this makes WINDOW the selected window.
1006 Optional argument NORECORD non-nil means to neither change the
1007 order of recently selected windows nor the buffer list.
1009 (Lisp_Object frame
, Lisp_Object window
, Lisp_Object norecord
)
1012 frame
= selected_frame
;
1014 CHECK_LIVE_FRAME (frame
);
1015 CHECK_LIVE_WINDOW (window
);
1017 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
1018 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
1020 if (EQ (frame
, selected_frame
))
1021 return Fselect_window (window
, norecord
);
1023 return XFRAME (frame
)->selected_window
= window
;
1027 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1029 doc
: /* Return a list of all live frames. */)
1033 frames
= Fcopy_sequence (Vframe_list
);
1034 #ifdef HAVE_WINDOW_SYSTEM
1035 if (FRAMEP (tip_frame
))
1036 frames
= Fdelq (tip_frame
, frames
);
1041 /* Return the next frame in the frame list after FRAME.
1042 If MINIBUF is nil, exclude minibuffer-only frames.
1043 If MINIBUF is a window, include only its own frame
1044 and any frame now using that window as the minibuffer.
1045 If MINIBUF is `visible', include all visible frames.
1046 If MINIBUF is 0, include all visible and iconified frames.
1047 Otherwise, include all frames. */
1050 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1055 /* There must always be at least one frame in Vframe_list. */
1056 if (! CONSP (Vframe_list
))
1059 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
1060 forever. Forestall that. */
1061 CHECK_LIVE_FRAME (frame
);
1064 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1071 && ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1072 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1073 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1074 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
)))))
1076 /* Decide whether this frame is eligible to be returned. */
1078 /* If we've looped all the way around without finding any
1079 eligible frames, return the original frame. */
1083 /* Let minibuf decide if this frame is acceptable. */
1086 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1089 else if (EQ (minibuf
, Qvisible
))
1091 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1092 if (FRAME_VISIBLE_P (XFRAME (f
)))
1095 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
1097 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1098 if (FRAME_VISIBLE_P (XFRAME (f
))
1099 || FRAME_ICONIFIED_P (XFRAME (f
)))
1102 else if (WINDOWP (minibuf
))
1104 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1105 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1106 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1107 FRAME_FOCUS_FRAME (XFRAME (f
))))
1119 /* Return the previous frame in the frame list before FRAME.
1120 If MINIBUF is nil, exclude minibuffer-only frames.
1121 If MINIBUF is a window, include only its own frame
1122 and any frame now using that window as the minibuffer.
1123 If MINIBUF is `visible', include all visible frames.
1124 If MINIBUF is 0, include all visible and iconified frames.
1125 Otherwise, include all frames. */
1128 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1133 /* There must always be at least one frame in Vframe_list. */
1134 if (! CONSP (Vframe_list
))
1138 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1146 if (EQ (frame
, f
) && !NILP (prev
))
1149 if ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1150 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1151 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1152 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
))))
1154 /* Decide whether this frame is eligible to be returned,
1155 according to minibuf. */
1158 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1161 else if (WINDOWP (minibuf
))
1163 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1164 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1165 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1166 FRAME_FOCUS_FRAME (XFRAME (f
))))
1169 else if (EQ (minibuf
, Qvisible
))
1171 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1172 if (FRAME_VISIBLE_P (XFRAME (f
)))
1175 else if (XFASTINT (minibuf
) == 0)
1177 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1178 if (FRAME_VISIBLE_P (XFRAME (f
))
1179 || FRAME_ICONIFIED_P (XFRAME (f
)))
1187 /* We've scanned the entire list. */
1189 /* We went through the whole frame list without finding a single
1190 acceptable frame. Return the original frame. */
1193 /* There were no acceptable frames in the list before FRAME; otherwise,
1194 we would have returned directly from the loop. Since PREV is the last
1195 acceptable frame in the list, return it. */
1200 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1201 doc
: /* Return the next frame in the frame list after FRAME.
1202 It considers only frames on the same terminal as FRAME.
1203 By default, skip minibuffer-only frames.
1204 If omitted, FRAME defaults to the selected frame.
1205 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1206 If MINIFRAME is a window, include only its own frame
1207 and any frame now using that window as the minibuffer.
1208 If MINIFRAME is `visible', include all visible frames.
1209 If MINIFRAME is 0, include all visible and iconified frames.
1210 Otherwise, include all frames. */)
1211 (Lisp_Object frame
, Lisp_Object miniframe
)
1214 frame
= selected_frame
;
1216 CHECK_LIVE_FRAME (frame
);
1217 return next_frame (frame
, miniframe
);
1220 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1221 doc
: /* Return the previous frame in the frame list before FRAME.
1222 It considers only frames on the same terminal as FRAME.
1223 By default, skip minibuffer-only frames.
1224 If omitted, FRAME defaults to the selected frame.
1225 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1226 If MINIFRAME is a window, include only its own frame
1227 and any frame now using that window as the minibuffer.
1228 If MINIFRAME is `visible', include all visible frames.
1229 If MINIFRAME is 0, include all visible and iconified frames.
1230 Otherwise, include all frames. */)
1231 (Lisp_Object frame
, Lisp_Object miniframe
)
1234 frame
= selected_frame
;
1235 CHECK_LIVE_FRAME (frame
);
1236 return prev_frame (frame
, miniframe
);
1239 /* Return 1 if it is ok to delete frame F;
1240 0 if all frames aside from F are invisible.
1241 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1244 other_visible_frames (FRAME_PTR f
)
1246 /* We know the selected frame is visible,
1247 so if F is some other frame, it can't be the sole visible one. */
1248 if (f
== SELECTED_FRAME ())
1253 for (frames
= Vframe_list
;
1255 frames
= XCDR (frames
))
1259 this = XCAR (frames
);
1260 /* Verify that the frame's window still exists
1261 and we can still talk to it. And note any recent change
1263 #ifdef HAVE_WINDOW_SYSTEM
1264 if (FRAME_WINDOW_P (XFRAME (this)))
1266 x_sync (XFRAME (this));
1267 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1271 if (FRAME_VISIBLE_P (XFRAME (this))
1272 || FRAME_ICONIFIED_P (XFRAME (this))
1273 /* Allow deleting the terminal frame when at least
1274 one X frame exists! */
1275 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1283 extern Lisp_Object Qrun_hook_with_args
;
1285 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1286 unconditionally. x_connection_closed and delete_terminal use
1287 this. Any other value of FORCE implements the semantics
1288 described for Fdelete_frame. */
1290 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1291 /* If we use `register' here, gcc-4.0.2 on amd64 using
1292 -DUSE_LISP_UNION_TYPE complains further down that we're getting the
1293 address of `force'. Go figure. */
1297 struct frame
*sf
= SELECTED_FRAME ();
1300 int minibuffer_selected
, tooltip_frame
;
1302 if (EQ (frame
, Qnil
))
1305 XSETFRAME (frame
, f
);
1309 CHECK_FRAME (frame
);
1313 if (! FRAME_LIVE_P (f
))
1316 if (NILP (force
) && !other_visible_frames (f
))
1317 error ("Attempt to delete the sole visible or iconified frame");
1319 /* x_connection_closed must have set FORCE to `noelisp' in order
1320 to delete the last frame, if it is gone. */
1321 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1322 error ("Attempt to delete the only frame");
1324 /* Does this frame have a minibuffer, and is it the surrogate
1325 minibuffer for any other frame? */
1326 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1330 for (frames
= Vframe_list
;
1332 frames
= XCDR (frames
))
1335 this = XCAR (frames
);
1337 if (! EQ (this, frame
)
1339 WINDOW_FRAME (XWINDOW
1340 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1342 /* If we MUST delete this frame, delete the other first.
1343 But do this only if FORCE equals `noelisp'. */
1344 if (EQ (force
, Qnoelisp
))
1345 delete_frame (this, Qnoelisp
);
1347 error ("Attempt to delete a surrogate minibuffer frame");
1352 tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1354 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1355 frame is a tooltip. FORCE is set to `noelisp' when handling
1356 a disconnect from the terminal, so we don't dare call Lisp
1358 if (NILP (Vrun_hooks
) || tooltip_frame
)
1360 else if (EQ (force
, Qnoelisp
))
1362 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1365 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1367 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1368 if (! FRAME_LIVE_P (f
))
1371 /* At this point, we are committed to deleting the frame.
1372 There is no more chance for errors to prevent it. */
1374 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1376 /* Don't let the frame remain selected. */
1379 Lisp_Object tail
, frame1
;
1381 /* Look for another visible frame on the same terminal. */
1382 frame1
= next_frame (frame
, Qvisible
);
1384 /* If there is none, find *some* other frame. */
1385 if (NILP (frame1
) || EQ (frame1
, frame
))
1387 FOR_EACH_FRAME (tail
, frame1
)
1389 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1393 #ifdef NS_IMPL_COCOA
1395 /* Under NS, there is no system mechanism for choosing a new
1396 window to get focus -- it is left to application code.
1397 So the portion of THIS application interfacing with NS
1398 needs to know about it. We call Fraise_frame, but the
1399 purpose is really to transfer focus. */
1400 Fraise_frame (frame1
);
1403 do_switch_frame (frame1
, 0, 1, Qnil
);
1404 sf
= SELECTED_FRAME ();
1407 /* Don't allow minibuf_window to remain on a deleted frame. */
1408 if (EQ (f
->minibuffer_window
, minibuf_window
))
1410 Fset_window_buffer (sf
->minibuffer_window
,
1411 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1412 minibuf_window
= sf
->minibuffer_window
;
1414 /* If the dying minibuffer window was selected,
1415 select the new one. */
1416 if (minibuffer_selected
)
1417 Fselect_window (minibuf_window
, Qnil
);
1420 /* Don't let echo_area_window to remain on a deleted frame. */
1421 if (EQ (f
->minibuffer_window
, echo_area_window
))
1422 echo_area_window
= sf
->minibuffer_window
;
1424 /* Clear any X selections for this frame. */
1425 #ifdef HAVE_X_WINDOWS
1427 x_clear_frame_selections (f
);
1431 This function must be called before the window tree of the
1432 frame is deleted because windows contain dynamically allocated
1436 #ifdef HAVE_WINDOW_SYSTEM
1437 /* Give chance to each font driver to free a frame specific data. */
1438 font_update_drivers (f
, Qnil
);
1441 /* Mark all the windows that used to be on FRAME as deleted, and then
1442 remove the reference to them. */
1443 delete_all_subwindows (XWINDOW (f
->root_window
));
1444 f
->root_window
= Qnil
;
1446 Vframe_list
= Fdelq (frame
, Vframe_list
);
1447 FRAME_SET_VISIBLE (f
, 0);
1449 /* Allow the vector of menu bar contents to be freed in the next
1450 garbage collection. The frame object itself may not be garbage
1451 collected until much later, because recent_keys and other data
1452 structures can still refer to it. */
1453 f
->menu_bar_vector
= Qnil
;
1455 free_font_driver_list (f
);
1457 xfree (f
->decode_mode_spec_buffer
);
1458 xfree (FRAME_INSERT_COST (f
));
1459 xfree (FRAME_DELETEN_COST (f
));
1460 xfree (FRAME_INSERTN_COST (f
));
1461 xfree (FRAME_DELETE_COST (f
));
1462 xfree (FRAME_MESSAGE_BUF (f
));
1464 /* Since some events are handled at the interrupt level, we may get
1465 an event for f at any time; if we zero out the frame's terminal
1466 now, then we may trip up the event-handling code. Instead, we'll
1467 promise that the terminal of the frame must be valid until we
1468 have called the window-system-dependent frame destruction
1471 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1472 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1475 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1476 f
->output_data
.nothing
= 0;
1477 f
->terminal
= 0; /* Now the frame is dead. */
1479 /* If needed, delete the terminal that this frame was on.
1480 (This must be done after the frame is killed.) */
1481 terminal
->reference_count
--;
1482 if (terminal
->reference_count
== 0)
1485 XSETTERMINAL (tmp
, terminal
);
1488 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1491 kb
= terminal
->kboard
;
1494 /* If we've deleted the last_nonminibuf_frame, then try to find
1496 if (f
== last_nonminibuf_frame
)
1500 last_nonminibuf_frame
= 0;
1502 for (frames
= Vframe_list
;
1504 frames
= XCDR (frames
))
1506 f
= XFRAME (XCAR (frames
));
1507 if (!FRAME_MINIBUF_ONLY_P (f
))
1509 last_nonminibuf_frame
= f
;
1515 /* If there's no other frame on the same kboard, get out of
1516 single-kboard state if we're in it for this kboard. */
1520 /* Some frame we found on the same kboard, or nil if there are none. */
1521 Lisp_Object frame_on_same_kboard
;
1523 frame_on_same_kboard
= Qnil
;
1525 for (frames
= Vframe_list
;
1527 frames
= XCDR (frames
))
1532 this = XCAR (frames
);
1537 if (kb
== FRAME_KBOARD (f1
))
1538 frame_on_same_kboard
= this;
1541 if (NILP (frame_on_same_kboard
))
1542 not_single_kboard_state (kb
);
1546 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1547 find another one. Prefer minibuffer-only frames, but also notice
1548 frames with other windows. */
1549 if (kb
!= NULL
&& EQ (frame
, kb
->Vdefault_minibuffer_frame
))
1553 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1554 Lisp_Object frame_with_minibuf
;
1555 /* Some frame we found on the same kboard, or nil if there are none. */
1556 Lisp_Object frame_on_same_kboard
;
1558 frame_on_same_kboard
= Qnil
;
1559 frame_with_minibuf
= Qnil
;
1561 for (frames
= Vframe_list
;
1563 frames
= XCDR (frames
))
1568 this = XCAR (frames
);
1573 /* Consider only frames on the same kboard
1574 and only those with minibuffers. */
1575 if (kb
== FRAME_KBOARD (f1
)
1576 && FRAME_HAS_MINIBUF_P (f1
))
1578 frame_with_minibuf
= this;
1579 if (FRAME_MINIBUF_ONLY_P (f1
))
1583 if (kb
== FRAME_KBOARD (f1
))
1584 frame_on_same_kboard
= this;
1587 if (!NILP (frame_on_same_kboard
))
1589 /* We know that there must be some frame with a minibuffer out
1590 there. If this were not true, all of the frames present
1591 would have to be minibufferless, which implies that at some
1592 point their minibuffer frames must have been deleted, but
1593 that is prohibited at the top; you can't delete surrogate
1594 minibuffer frames. */
1595 if (NILP (frame_with_minibuf
))
1598 kb
->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1601 /* No frames left on this kboard--say no minibuffer either. */
1602 kb
->Vdefault_minibuffer_frame
= Qnil
;
1605 /* Cause frame titles to update--necessary if we now have just one frame. */
1607 update_mode_lines
= 1;
1612 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1613 doc
: /* Delete FRAME, permanently eliminating it from use.
1614 FRAME defaults to the selected frame.
1616 A frame may not be deleted if its minibuffer is used by other frames.
1617 Normally, you may not delete a frame if all other frames are invisible,
1618 but if the second optional argument FORCE is non-nil, you may do so.
1620 This function runs `delete-frame-functions' before actually
1621 deleting the frame, unless the frame is a tooltip.
1622 The functions are run with one argument, the frame to be deleted. */)
1623 (Lisp_Object frame
, Lisp_Object force
)
1625 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1629 /* Return mouse position in character cell units. */
1631 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1632 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1633 The position is given in character cells, where (0, 0) is the
1634 upper-left corner of the frame, X is the horizontal offset, and Y is
1635 the vertical offset.
1636 If Emacs is running on a mouseless terminal or hasn't been programmed
1637 to read the mouse position, it returns the selected frame for FRAME
1638 and nil for X and Y.
1639 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1640 passing the normal return value to that function as an argument,
1641 and returns whatever that function returns. */)
1645 Lisp_Object lispy_dummy
;
1646 enum scroll_bar_part party_dummy
;
1647 Lisp_Object x
, y
, retval
;
1649 unsigned long long_dummy
;
1650 struct gcpro gcpro1
;
1652 f
= SELECTED_FRAME ();
1655 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1656 /* It's okay for the hook to refrain from storing anything. */
1657 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1658 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1659 &lispy_dummy
, &party_dummy
,
1666 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1671 XSETFRAME (lispy_dummy
, f
);
1672 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1674 if (!NILP (Vmouse_position_function
))
1675 retval
= call1 (Vmouse_position_function
, retval
);
1676 RETURN_UNGCPRO (retval
);
1679 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1680 Smouse_pixel_position
, 0, 0, 0,
1681 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1682 The position is given in pixel units, where (0, 0) is the
1683 upper-left corner of the frame, X is the horizontal offset, and Y is
1684 the vertical offset.
1685 If Emacs is running on a mouseless terminal or hasn't been programmed
1686 to read the mouse position, it returns the selected frame for FRAME
1687 and nil for X and Y. */)
1691 Lisp_Object lispy_dummy
;
1692 enum scroll_bar_part party_dummy
;
1694 unsigned long long_dummy
;
1696 f
= SELECTED_FRAME ();
1699 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1700 /* It's okay for the hook to refrain from storing anything. */
1701 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1702 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1703 &lispy_dummy
, &party_dummy
,
1707 XSETFRAME (lispy_dummy
, f
);
1708 return Fcons (lispy_dummy
, Fcons (x
, y
));
1711 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1712 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1713 Coordinates are relative to the frame, not a window,
1714 so the coordinates of the top left character in the frame
1715 may be nonzero due to left-hand scroll bars or the menu bar.
1717 The position is given in character cells, where (0, 0) is the
1718 upper-left corner of the frame, X is the horizontal offset, and Y is
1719 the vertical offset.
1721 This function is a no-op for an X frame that is not visible.
1722 If you have just created a frame, you must wait for it to become visible
1723 before calling this function on it, like this.
1724 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1725 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1727 CHECK_LIVE_FRAME (frame
);
1731 /* I think this should be done with a hook. */
1732 #ifdef HAVE_WINDOW_SYSTEM
1733 if (FRAME_WINDOW_P (XFRAME (frame
)))
1734 /* Warping the mouse will cause enternotify and focus events. */
1735 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1737 #if defined (MSDOS) && defined (HAVE_MOUSE)
1738 if (FRAME_MSDOS_P (XFRAME (frame
)))
1740 Fselect_frame (frame
, Qnil
);
1741 mouse_moveto (XINT (x
), XINT (y
));
1746 Fselect_frame (frame
, Qnil
);
1747 term_mouse_moveto (XINT (x
), XINT (y
));
1756 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1757 Sset_mouse_pixel_position
, 3, 3, 0,
1758 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1759 The position is given in pixels, where (0, 0) is the upper-left corner
1760 of the frame, X is the horizontal offset, and Y is the vertical offset.
1762 Note, this is a no-op for an X frame that is not visible.
1763 If you have just created a frame, you must wait for it to become visible
1764 before calling this function on it, like this.
1765 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1766 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1768 CHECK_LIVE_FRAME (frame
);
1772 /* I think this should be done with a hook. */
1773 #ifdef HAVE_WINDOW_SYSTEM
1774 if (FRAME_WINDOW_P (XFRAME (frame
)))
1775 /* Warping the mouse will cause enternotify and focus events. */
1776 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1778 #if defined (MSDOS) && defined (HAVE_MOUSE)
1779 if (FRAME_MSDOS_P (XFRAME (frame
)))
1781 Fselect_frame (frame
, Qnil
);
1782 mouse_moveto (XINT (x
), XINT (y
));
1787 Fselect_frame (frame
, Qnil
);
1788 term_mouse_moveto (XINT (x
), XINT (y
));
1797 static void make_frame_visible_1 (Lisp_Object
);
1799 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1801 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1802 If omitted, FRAME defaults to the currently selected frame. */)
1806 frame
= selected_frame
;
1808 CHECK_LIVE_FRAME (frame
);
1810 /* I think this should be done with a hook. */
1811 #ifdef HAVE_WINDOW_SYSTEM
1812 if (FRAME_WINDOW_P (XFRAME (frame
)))
1814 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1815 x_make_frame_visible (XFRAME (frame
));
1819 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1821 /* Make menu bar update for the Buffers and Frames menus. */
1822 windows_or_buffers_changed
++;
1827 /* Update the display_time slot of the buffers shown in WINDOW
1828 and all its descendents. */
1831 make_frame_visible_1 (Lisp_Object window
)
1835 for (;!NILP (window
); window
= w
->next
)
1837 w
= XWINDOW (window
);
1839 if (!NILP (w
->buffer
))
1840 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1842 if (!NILP (w
->vchild
))
1843 make_frame_visible_1 (w
->vchild
);
1844 if (!NILP (w
->hchild
))
1845 make_frame_visible_1 (w
->hchild
);
1849 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1851 doc
: /* Make the frame FRAME invisible.
1852 If omitted, FRAME defaults to the currently selected frame.
1853 On graphical displays, invisible frames are not updated and are
1854 usually not displayed at all, even in a window system's \"taskbar\".
1856 Normally you may not make FRAME invisible if all other frames are invisible,
1857 but if the second optional argument FORCE is non-nil, you may do so.
1859 This function has no effect on text-only terminal frames. Such frames
1860 are always considered visible, whether or not they are currently being
1861 displayed in the terminal. */)
1862 (Lisp_Object frame
, Lisp_Object force
)
1865 frame
= selected_frame
;
1867 CHECK_LIVE_FRAME (frame
);
1869 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1870 error ("Attempt to make invisible the sole visible or iconified frame");
1872 #if 0 /* This isn't logically necessary, and it can do GC. */
1873 /* Don't let the frame remain selected. */
1874 if (EQ (frame
, selected_frame
))
1875 do_switch_frame (next_frame (frame
, Qt
), 0, 0, Qnil
)
1878 /* Don't allow minibuf_window to remain on a deleted frame. */
1879 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1881 struct frame
*sf
= XFRAME (selected_frame
);
1882 Fset_window_buffer (sf
->minibuffer_window
,
1883 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1884 minibuf_window
= sf
->minibuffer_window
;
1887 /* I think this should be done with a hook. */
1888 #ifdef HAVE_WINDOW_SYSTEM
1889 if (FRAME_WINDOW_P (XFRAME (frame
)))
1890 x_make_frame_invisible (XFRAME (frame
));
1893 /* Make menu bar update for the Buffers and Frames menus. */
1894 windows_or_buffers_changed
++;
1899 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1901 doc
: /* Make the frame FRAME into an icon.
1902 If omitted, FRAME defaults to the currently selected frame. */)
1906 frame
= selected_frame
;
1908 CHECK_LIVE_FRAME (frame
);
1910 #if 0 /* This isn't logically necessary, and it can do GC. */
1911 /* Don't let the frame remain selected. */
1912 if (EQ (frame
, selected_frame
))
1913 Fhandle_switch_frame (next_frame (frame
, Qt
));
1916 /* Don't allow minibuf_window to remain on a deleted frame. */
1917 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1919 struct frame
*sf
= XFRAME (selected_frame
);
1920 Fset_window_buffer (sf
->minibuffer_window
,
1921 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1922 minibuf_window
= sf
->minibuffer_window
;
1925 /* I think this should be done with a hook. */
1926 #ifdef HAVE_WINDOW_SYSTEM
1927 if (FRAME_WINDOW_P (XFRAME (frame
)))
1928 x_iconify_frame (XFRAME (frame
));
1931 /* Make menu bar update for the Buffers and Frames menus. */
1932 windows_or_buffers_changed
++;
1937 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1939 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1940 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1941 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1942 On graphical displays, invisible frames are not updated and are
1943 usually not displayed at all, even in a window system's \"taskbar\".
1945 If FRAME is a text-only terminal frame, this always returns t.
1946 Such frames are always considered visible, whether or not they are
1947 currently being displayed on the terminal. */)
1950 CHECK_LIVE_FRAME (frame
);
1952 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1954 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1956 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1961 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1963 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1966 Lisp_Object tail
, frame
;
1971 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1973 frame
= XCAR (tail
);
1974 if (!FRAMEP (frame
))
1977 if (FRAME_VISIBLE_P (f
))
1978 value
= Fcons (frame
, value
);
1984 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1985 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1986 If FRAME is invisible or iconified, make it visible.
1987 If you don't specify a frame, the selected frame is used.
1988 If Emacs is displaying on an ordinary terminal or some other device which
1989 doesn't support multiple overlapping frames, this function selects FRAME. */)
1994 frame
= selected_frame
;
1996 CHECK_LIVE_FRAME (frame
);
2000 if (FRAME_TERMCAP_P (f
))
2001 /* On a text-only terminal select FRAME. */
2002 Fselect_frame (frame
, Qnil
);
2004 /* Do like the documentation says. */
2005 Fmake_frame_visible (frame
);
2007 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2008 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
2013 /* Should we have a corresponding function called Flower_Power? */
2014 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
2015 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2016 If you don't specify a frame, the selected frame is used.
2017 If Emacs is displaying on an ordinary terminal or some other device which
2018 doesn't support multiple overlapping frames, this function does nothing. */)
2024 frame
= selected_frame
;
2026 CHECK_LIVE_FRAME (frame
);
2030 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2031 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2037 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2039 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2040 In other words, switch-frame events caused by events in FRAME will
2041 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2042 FOCUS-FRAME after reading an event typed at FRAME.
2044 If FOCUS-FRAME is omitted or nil, any existing redirection is
2045 cancelled, and the frame again receives its own keystrokes.
2047 Focus redirection is useful for temporarily redirecting keystrokes to
2048 a surrogate minibuffer frame when a frame doesn't have its own
2051 A frame's focus redirection can be changed by `select-frame'. If frame
2052 FOO is selected, and then a different frame BAR is selected, any
2053 frames redirecting their focus to FOO are shifted to redirect their
2054 focus to BAR. This allows focus redirection to work properly when the
2055 user switches from one frame to another using `select-window'.
2057 This means that a frame whose focus is redirected to itself is treated
2058 differently from a frame whose focus is redirected to nil; the former
2059 is affected by `select-frame', while the latter is not.
2061 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2062 (Lisp_Object frame
, Lisp_Object focus_frame
)
2066 /* Note that we don't check for a live frame here. It's reasonable
2067 to redirect the focus of a frame you're about to delete, if you
2068 know what other frame should receive those keystrokes. */
2069 CHECK_FRAME (frame
);
2071 if (! NILP (focus_frame
))
2072 CHECK_LIVE_FRAME (focus_frame
);
2076 f
->focus_frame
= focus_frame
;
2078 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2079 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2085 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
2086 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2087 This returns nil if FRAME's focus is not redirected.
2088 See `redirect-frame-focus'. */)
2091 CHECK_LIVE_FRAME (frame
);
2093 return FRAME_FOCUS_FRAME (XFRAME (frame
));
2098 /* Return the value of frame parameter PROP in frame FRAME. */
2101 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
2103 register Lisp_Object tem
;
2105 tem
= Fassq (prop
, frame
->param_alist
);
2111 /* Return the buffer-predicate of the selected frame. */
2114 frame_buffer_predicate (Lisp_Object frame
)
2116 return XFRAME (frame
)->buffer_predicate
;
2119 /* Return the buffer-list of the selected frame. */
2122 frame_buffer_list (Lisp_Object frame
)
2124 return XFRAME (frame
)->buffer_list
;
2127 /* Set the buffer-list of the selected frame. */
2130 set_frame_buffer_list (Lisp_Object frame
, Lisp_Object list
)
2132 XFRAME (frame
)->buffer_list
= list
;
2135 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2138 frames_discard_buffer (Lisp_Object buffer
)
2140 Lisp_Object frame
, tail
;
2142 FOR_EACH_FRAME (tail
, frame
)
2144 XFRAME (frame
)->buffer_list
2145 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
2146 XFRAME (frame
)->buried_buffer_list
2147 = Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
);
2151 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2152 If the alist already has an element for PROP, we change it. */
2155 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2157 register Lisp_Object tem
;
2159 tem
= Fassq (prop
, *alistptr
);
2161 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2167 frame_name_fnn_p (char *str
, EMACS_INT len
)
2169 if (len
> 1 && str
[0] == 'F')
2173 strtol (str
+ 1, &end_ptr
, 10);
2175 if (end_ptr
== str
+ len
)
2181 /* Set the name of the terminal frame. Also used by MSDOS frames.
2182 Modeled after x_set_name which is used for WINDOW frames. */
2185 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2187 f
->explicit_name
= ! NILP (name
);
2189 /* If NAME is nil, set the name to F<num>. */
2194 /* Check for no change needed in this very common case
2195 before we do any consing. */
2196 if (frame_name_fnn_p (SDATA (f
->name
),
2201 sprintf (namebuf
, "F%d", tty_frame_count
);
2202 name
= build_string (namebuf
);
2206 CHECK_STRING (name
);
2208 /* Don't change the name if it's already NAME. */
2209 if (! NILP (Fstring_equal (name
, f
->name
)))
2212 /* Don't allow the user to set the frame name to F<num>, so it
2213 doesn't clash with the names we generate for terminal frames. */
2214 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
2215 error ("Frame names of the form F<num> are usurped by Emacs");
2219 update_mode_lines
= 1;
2223 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2225 register Lisp_Object old_alist_elt
;
2227 /* The buffer-list parameters are stored in a special place and not
2229 if (EQ (prop
, Qbuffer_list
))
2231 f
->buffer_list
= val
;
2234 if (EQ (prop
, Qburied_buffer_list
))
2236 f
->buried_buffer_list
= val
;
2240 /* If PROP is a symbol which is supposed to have frame-local values,
2241 and it is set up based on this frame, switch to the global
2242 binding. That way, we can create or alter the frame-local binding
2243 without messing up the symbol's status. */
2246 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2248 switch (sym
->redirect
)
2250 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2251 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2252 case SYMBOL_LOCALIZED
:
2253 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2254 if (blv
->frame_local
&& BLV_FOUND (blv
) && XFRAME (blv
->where
) == f
)
2255 swap_in_global_binding (sym
);
2262 /* The tty color needed to be set before the frame's parameter
2263 alist was updated with the new value. This is not true any more,
2264 but we still do this test early on. */
2265 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2266 && f
== FRAME_TTY (f
)->previous_frame
)
2267 /* Force redisplay of this tty. */
2268 FRAME_TTY (f
)->previous_frame
= NULL
;
2270 /* Update the frame parameter alist. */
2271 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2272 if (EQ (old_alist_elt
, Qnil
))
2273 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2275 Fsetcdr (old_alist_elt
, val
);
2277 /* Update some other special parameters in their special places
2278 in addition to the alist. */
2280 if (EQ (prop
, Qbuffer_predicate
))
2281 f
->buffer_predicate
= val
;
2283 if (! FRAME_WINDOW_P (f
))
2285 if (EQ (prop
, Qmenu_bar_lines
))
2286 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2287 else if (EQ (prop
, Qname
))
2288 set_term_frame_name (f
, val
);
2291 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2293 if (! MINI_WINDOW_P (XWINDOW (val
)))
2294 error ("Surrogate minibuffer windows must be minibuffer windows");
2296 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2297 && !EQ (val
, f
->minibuffer_window
))
2298 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2300 /* Install the chosen minibuffer window, with proper buffer. */
2301 f
->minibuffer_window
= val
;
2305 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2306 doc
: /* Return the parameters-alist of frame FRAME.
2307 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2308 The meaningful PARMs depend on the kind of frame.
2309 If FRAME is omitted, return information on the currently selected frame. */)
2315 struct gcpro gcpro1
;
2318 frame
= selected_frame
;
2320 CHECK_FRAME (frame
);
2323 if (!FRAME_LIVE_P (f
))
2326 alist
= Fcopy_alist (f
->param_alist
);
2329 if (!FRAME_WINDOW_P (f
))
2331 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2332 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2335 /* If the frame's parameter alist says the colors are
2336 unspecified and reversed, take the frame's background pixel
2337 for foreground and vice versa. */
2338 elt
= Fassq (Qforeground_color
, alist
);
2339 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2341 if (strncmp (SDATA (XCDR (elt
)),
2343 SCHARS (XCDR (elt
))) == 0)
2344 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2345 else if (strncmp (SDATA (XCDR (elt
)),
2347 SCHARS (XCDR (elt
))) == 0)
2348 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2351 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2352 elt
= Fassq (Qbackground_color
, alist
);
2353 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2355 if (strncmp (SDATA (XCDR (elt
)),
2357 SCHARS (XCDR (elt
))) == 0)
2358 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2359 else if (strncmp (SDATA (XCDR (elt
)),
2361 SCHARS (XCDR (elt
))) == 0)
2362 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2365 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2366 store_in_alist (&alist
, intern ("font"),
2367 build_string (FRAME_MSDOS_P (f
)
2369 : FRAME_W32_P (f
) ? "w32term"
2372 store_in_alist (&alist
, Qname
, f
->name
);
2373 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2374 store_in_alist (&alist
, Qheight
, make_number (height
));
2375 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2376 store_in_alist (&alist
, Qwidth
, make_number (width
));
2377 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2378 store_in_alist (&alist
, Qminibuffer
,
2379 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2380 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2381 : FRAME_MINIBUF_WINDOW (f
)));
2382 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2383 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2384 store_in_alist (&alist
, Qburied_buffer_list
, XFRAME (frame
)->buried_buffer_list
);
2386 /* I think this should be done with a hook. */
2387 #ifdef HAVE_WINDOW_SYSTEM
2388 if (FRAME_WINDOW_P (f
))
2389 x_report_frame_params (f
, &alist
);
2393 /* This ought to be correct in f->param_alist for an X frame. */
2395 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2396 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2404 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2405 doc
: /* Return FRAME's value for parameter PARAMETER.
2406 If FRAME is nil, describe the currently selected frame. */)
2407 (Lisp_Object frame
, Lisp_Object parameter
)
2413 frame
= selected_frame
;
2415 CHECK_FRAME (frame
);
2416 CHECK_SYMBOL (parameter
);
2421 if (FRAME_LIVE_P (f
))
2423 /* Avoid consing in frequent cases. */
2424 if (EQ (parameter
, Qname
))
2426 #ifdef HAVE_X_WINDOWS
2427 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2428 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2429 #endif /* HAVE_X_WINDOWS */
2430 else if (EQ (parameter
, Qbackground_color
)
2431 || EQ (parameter
, Qforeground_color
))
2433 value
= Fassq (parameter
, f
->param_alist
);
2436 value
= XCDR (value
);
2437 /* Fframe_parameters puts the actual fg/bg color names,
2438 even if f->param_alist says otherwise. This is
2439 important when param_alist's notion of colors is
2440 "unspecified". We need to do the same here. */
2441 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2443 const char *color_name
;
2446 if (EQ (parameter
, Qbackground_color
))
2448 color_name
= SDATA (value
);
2449 csz
= SCHARS (value
);
2450 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2451 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2452 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2453 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2455 else if (EQ (parameter
, Qforeground_color
))
2457 color_name
= SDATA (value
);
2458 csz
= SCHARS (value
);
2459 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2460 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2461 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2462 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2467 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2469 else if (EQ (parameter
, Qdisplay_type
)
2470 || EQ (parameter
, Qbackground_mode
))
2471 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2473 /* FIXME: Avoid this code path at all (as well as code duplication)
2474 by sharing more code with Fframe_parameters. */
2475 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2482 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2483 Smodify_frame_parameters
, 2, 2, 0,
2484 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2485 If FRAME is nil, it defaults to the selected frame.
2486 ALIST is an alist of parameters to change and their new values.
2487 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2488 The meaningful PARMs depend on the kind of frame.
2489 Undefined PARMs are ignored, but stored in the frame's parameter list
2490 so that `frame-parameters' will return them.
2492 The value of frame parameter FOO can also be accessed
2493 as a frame-local binding for the variable FOO, if you have
2494 enabled such bindings for that variable with `make-variable-frame-local'.
2495 Note that this functionality is obsolete as of Emacs 22.2, and its
2496 use is not recommended. Explicitly check for a frame-parameter instead. */)
2497 (Lisp_Object frame
, Lisp_Object alist
)
2500 register Lisp_Object tail
, prop
, val
;
2502 if (EQ (frame
, Qnil
))
2503 frame
= selected_frame
;
2504 CHECK_LIVE_FRAME (frame
);
2507 /* I think this should be done with a hook. */
2508 #ifdef HAVE_WINDOW_SYSTEM
2509 if (FRAME_WINDOW_P (f
))
2510 x_set_frame_parameters (f
, alist
);
2514 if (FRAME_MSDOS_P (f
))
2515 IT_set_frame_parameters (f
, alist
);
2520 int length
= XINT (Flength (alist
));
2523 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2525 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2527 /* Extract parm names and values into those vectors. */
2530 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2535 parms
[i
] = Fcar (elt
);
2536 values
[i
] = Fcdr (elt
);
2540 /* Now process them in reverse of specified order. */
2541 for (i
--; i
>= 0; i
--)
2545 store_frame_param (f
, prop
, val
);
2547 /* Changing the background color might change the background
2548 mode, so that we have to load new defface specs.
2549 Call frame-set-background-mode to do that. */
2550 if (EQ (prop
, Qbackground_color
))
2551 call1 (Qframe_set_background_mode
, frame
);
2557 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2559 doc
: /* Height in pixels of a line in the font in frame FRAME.
2560 If FRAME is omitted, the selected frame is used.
2561 For a terminal frame, the value is always 1. */)
2567 frame
= selected_frame
;
2568 CHECK_FRAME (frame
);
2571 #ifdef HAVE_WINDOW_SYSTEM
2572 if (FRAME_WINDOW_P (f
))
2573 return make_number (x_char_height (f
));
2576 return make_number (1);
2580 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2582 doc
: /* Width in pixels of characters in the font in frame FRAME.
2583 If FRAME is omitted, the selected frame is used.
2584 On a graphical screen, the width is the standard width of the default font.
2585 For a terminal screen, the value is always 1. */)
2591 frame
= selected_frame
;
2592 CHECK_FRAME (frame
);
2595 #ifdef HAVE_WINDOW_SYSTEM
2596 if (FRAME_WINDOW_P (f
))
2597 return make_number (x_char_width (f
));
2600 return make_number (1);
2603 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2604 Sframe_pixel_height
, 0, 1, 0,
2605 doc
: /* Return a FRAME's height in pixels.
2606 If FRAME is omitted, the selected frame is used. The exact value
2607 of the result depends on the window-system and toolkit in use:
2609 In the Gtk+ version of Emacs, it includes only any window (including
2610 the minibuffer or eacho area), mode line, and header line. It does not
2611 include the tool bar or menu bar.
2613 With the Motif or Lucid toolkits, it also includes the tool bar (but
2616 In a graphical version with no toolkit, it includes both the tool bar
2619 For a text-only terminal, it includes the menu bar. In this case, the
2620 result is really in characters rather than pixels (i.e., is identical
2621 to `frame-height'). */)
2627 frame
= selected_frame
;
2628 CHECK_FRAME (frame
);
2631 #ifdef HAVE_WINDOW_SYSTEM
2632 if (FRAME_WINDOW_P (f
))
2633 return make_number (x_pixel_height (f
));
2636 return make_number (FRAME_LINES (f
));
2639 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2640 Sframe_pixel_width
, 0, 1, 0,
2641 doc
: /* Return FRAME's width in pixels.
2642 For a terminal frame, the result really gives the width in characters.
2643 If FRAME is omitted, the selected frame is used. */)
2649 frame
= selected_frame
;
2650 CHECK_FRAME (frame
);
2653 #ifdef HAVE_WINDOW_SYSTEM
2654 if (FRAME_WINDOW_P (f
))
2655 return make_number (x_pixel_width (f
));
2658 return make_number (FRAME_COLS (f
));
2661 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2662 doc
: /* Specify that the frame FRAME has LINES lines.
2663 Optional third arg non-nil means that redisplay should use LINES lines
2664 but that the idea of the actual height of the frame should not be changed. */)
2665 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2667 register struct frame
*f
;
2669 CHECK_NUMBER (lines
);
2671 frame
= selected_frame
;
2672 CHECK_LIVE_FRAME (frame
);
2675 /* I think this should be done with a hook. */
2676 #ifdef HAVE_WINDOW_SYSTEM
2677 if (FRAME_WINDOW_P (f
))
2679 if (XINT (lines
) != FRAME_LINES (f
))
2680 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2681 do_pending_window_change (0);
2685 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2689 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2690 doc
: /* Specify that the frame FRAME has COLS columns.
2691 Optional third arg non-nil means that redisplay should use COLS columns
2692 but that the idea of the actual width of the frame should not be changed. */)
2693 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2695 register struct frame
*f
;
2696 CHECK_NUMBER (cols
);
2698 frame
= selected_frame
;
2699 CHECK_LIVE_FRAME (frame
);
2702 /* I think this should be done with a hook. */
2703 #ifdef HAVE_WINDOW_SYSTEM
2704 if (FRAME_WINDOW_P (f
))
2706 if (XINT (cols
) != FRAME_COLS (f
))
2707 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2708 do_pending_window_change (0);
2712 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2716 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2717 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2718 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2720 register struct frame
*f
;
2722 CHECK_LIVE_FRAME (frame
);
2723 CHECK_NUMBER (cols
);
2724 CHECK_NUMBER (rows
);
2727 /* I think this should be done with a hook. */
2728 #ifdef HAVE_WINDOW_SYSTEM
2729 if (FRAME_WINDOW_P (f
))
2731 if (XINT (rows
) != FRAME_LINES (f
)
2732 || XINT (cols
) != FRAME_COLS (f
)
2733 || f
->new_text_lines
|| f
->new_text_cols
)
2734 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2735 do_pending_window_change (0);
2739 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2744 DEFUN ("set-frame-position", Fset_frame_position
,
2745 Sset_frame_position
, 3, 3, 0,
2746 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2747 This is actually the position of the upper left corner of the frame.
2748 Negative values for XOFFSET or YOFFSET are interpreted relative to
2749 the rightmost or bottommost possible position (that stays within the screen). */)
2750 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2752 register struct frame
*f
;
2754 CHECK_LIVE_FRAME (frame
);
2755 CHECK_NUMBER (xoffset
);
2756 CHECK_NUMBER (yoffset
);
2759 /* I think this should be done with a hook. */
2760 #ifdef HAVE_WINDOW_SYSTEM
2761 if (FRAME_WINDOW_P (f
))
2762 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2769 /***********************************************************************
2771 ***********************************************************************/
2773 /* Connect the frame-parameter names for X frames
2774 to the ways of passing the parameter values to the window system.
2776 The name of a parameter, as a Lisp symbol,
2777 has an `x-frame-parameter' property which is an integer in Lisp
2778 that is an index in this table. */
2780 struct frame_parm_table
{
2782 Lisp_Object
*variable
;
2785 static struct frame_parm_table frame_parms
[] =
2787 {"auto-raise", &Qauto_raise
},
2788 {"auto-lower", &Qauto_lower
},
2789 {"background-color", 0},
2790 {"border-color", &Qborder_color
},
2791 {"border-width", &Qborder_width
},
2792 {"cursor-color", &Qcursor_color
},
2793 {"cursor-type", &Qcursor_type
},
2795 {"foreground-color", 0},
2796 {"icon-name", &Qicon_name
},
2797 {"icon-type", &Qicon_type
},
2798 {"internal-border-width", &Qinternal_border_width
},
2799 {"menu-bar-lines", &Qmenu_bar_lines
},
2800 {"mouse-color", &Qmouse_color
},
2802 {"scroll-bar-width", &Qscroll_bar_width
},
2804 {"unsplittable", &Qunsplittable
},
2805 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2806 {"visibility", &Qvisibility
},
2807 {"tool-bar-lines", &Qtool_bar_lines
},
2808 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2809 {"scroll-bar-background", &Qscroll_bar_background
},
2810 {"screen-gamma", &Qscreen_gamma
},
2811 {"line-spacing", &Qline_spacing
},
2812 {"left-fringe", &Qleft_fringe
},
2813 {"right-fringe", &Qright_fringe
},
2814 {"wait-for-wm", &Qwait_for_wm
},
2815 {"fullscreen", &Qfullscreen
},
2816 {"font-backend", &Qfont_backend
},
2818 {"sticky", &Qsticky
},
2821 #ifdef HAVE_WINDOW_SYSTEM
2823 extern Lisp_Object Qbox
;
2824 extern Lisp_Object Qtop
;
2826 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2827 wanted positions of the WM window (not Emacs window).
2828 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2829 window (FRAME_X_WINDOW).
2833 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2835 int newwidth
= FRAME_COLS (f
);
2836 int newheight
= FRAME_LINES (f
);
2837 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2839 *top_pos
= f
->top_pos
;
2840 *left_pos
= f
->left_pos
;
2842 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2846 ph
= x_display_pixel_height (dpyinfo
);
2847 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2848 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2849 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2853 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2857 pw
= x_display_pixel_width (dpyinfo
);
2858 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2859 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2860 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2865 *height
= newheight
;
2869 /* Change the parameters of frame F as specified by ALIST.
2870 If a parameter is not specially recognized, do nothing special;
2871 otherwise call the `x_set_...' function for that parameter.
2872 Except for certain geometry properties, always call store_frame_param
2873 to store the new value in the parameter alist. */
2876 x_set_frame_parameters (FRAME_PTR f
, Lisp_Object alist
)
2880 /* If both of these parameters are present, it's more efficient to
2881 set them both at once. So we wait until we've looked at the
2882 entire list before we set them. */
2886 Lisp_Object left
, top
;
2888 /* Same with these. */
2889 Lisp_Object icon_left
, icon_top
;
2891 /* Record in these vectors all the parms specified. */
2893 Lisp_Object
*values
;
2895 int left_no_change
= 0, top_no_change
= 0;
2896 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2897 int size_changed
= 0;
2898 struct gcpro gcpro1
, gcpro2
;
2901 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2904 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2905 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2907 /* Extract parm names and values into those vectors. */
2910 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2915 parms
[i
] = Fcar (elt
);
2916 values
[i
] = Fcdr (elt
);
2919 /* TAIL and ALIST are not used again below here. */
2920 alist
= tail
= Qnil
;
2922 GCPRO2 (*parms
, *values
);
2926 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2927 because their values appear in VALUES and strings are not valid. */
2928 top
= left
= Qunbound
;
2929 icon_left
= icon_top
= Qunbound
;
2931 /* Provide default values for HEIGHT and WIDTH. */
2932 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2933 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2935 /* Process foreground_color and background_color before anything else.
2936 They are independent of other properties, but other properties (e.g.,
2937 cursor_color) are dependent upon them. */
2938 /* Process default font as well, since fringe widths depends on it. */
2939 for (p
= 0; p
< i
; p
++)
2941 Lisp_Object prop
, val
;
2945 if (EQ (prop
, Qforeground_color
)
2946 || EQ (prop
, Qbackground_color
)
2947 || EQ (prop
, Qfont
))
2949 register Lisp_Object param_index
, old_value
;
2951 old_value
= get_frame_param (f
, prop
);
2952 if (NILP (Fequal (val
, old_value
)))
2954 store_frame_param (f
, prop
, val
);
2956 param_index
= Fget (prop
, Qx_frame_parameter
);
2957 if (NATNUMP (param_index
)
2958 && (XFASTINT (param_index
)
2959 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2960 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2961 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2966 /* Now process them in reverse of specified order. */
2967 for (i
--; i
>= 0; i
--)
2969 Lisp_Object prop
, val
;
2974 if (EQ (prop
, Qwidth
) && NATNUMP (val
))
2977 width
= XFASTINT (val
);
2979 else if (EQ (prop
, Qheight
) && NATNUMP (val
))
2982 height
= XFASTINT (val
);
2984 else if (EQ (prop
, Qtop
))
2986 else if (EQ (prop
, Qleft
))
2988 else if (EQ (prop
, Qicon_top
))
2990 else if (EQ (prop
, Qicon_left
))
2992 else if (EQ (prop
, Qforeground_color
)
2993 || EQ (prop
, Qbackground_color
)
2994 || EQ (prop
, Qfont
))
2995 /* Processed above. */
2999 register Lisp_Object param_index
, old_value
;
3001 old_value
= get_frame_param (f
, prop
);
3003 store_frame_param (f
, prop
, val
);
3005 param_index
= Fget (prop
, Qx_frame_parameter
);
3006 if (NATNUMP (param_index
)
3007 && (XFASTINT (param_index
)
3008 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3009 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3010 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3014 /* Don't die if just one of these was set. */
3015 if (EQ (left
, Qunbound
))
3018 if (f
->left_pos
< 0)
3019 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
3021 XSETINT (left
, f
->left_pos
);
3023 if (EQ (top
, Qunbound
))
3027 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
3029 XSETINT (top
, f
->top_pos
);
3032 /* If one of the icon positions was not set, preserve or default it. */
3033 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
3035 icon_left_no_change
= 1;
3036 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3037 if (NILP (icon_left
))
3038 XSETINT (icon_left
, 0);
3040 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
3042 icon_top_no_change
= 1;
3043 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3044 if (NILP (icon_top
))
3045 XSETINT (icon_top
, 0);
3048 /* Don't set these parameters unless they've been explicitly
3049 specified. The window might be mapped or resized while we're in
3050 this function, and we don't want to override that unless the lisp
3051 code has asked for it.
3053 Don't set these parameters unless they actually differ from the
3054 window's current parameters; the window may not actually exist
3059 check_frame_size (f
, &height
, &width
);
3061 XSETFRAME (frame
, f
);
3064 && (width
!= FRAME_COLS (f
)
3065 || height
!= FRAME_LINES (f
)
3066 || f
->new_text_lines
|| f
->new_text_cols
))
3067 Fset_frame_size (frame
, make_number (width
), make_number (height
));
3069 if ((!NILP (left
) || !NILP (top
))
3070 && ! (left_no_change
&& top_no_change
)
3071 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3072 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3077 /* Record the signs. */
3078 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3079 if (EQ (left
, Qminus
))
3080 f
->size_hint_flags
|= XNegative
;
3081 else if (INTEGERP (left
))
3083 leftpos
= XINT (left
);
3085 f
->size_hint_flags
|= XNegative
;
3087 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3088 && CONSP (XCDR (left
))
3089 && INTEGERP (XCAR (XCDR (left
))))
3091 leftpos
= - XINT (XCAR (XCDR (left
)));
3092 f
->size_hint_flags
|= XNegative
;
3094 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3095 && CONSP (XCDR (left
))
3096 && INTEGERP (XCAR (XCDR (left
))))
3098 leftpos
= XINT (XCAR (XCDR (left
)));
3101 if (EQ (top
, Qminus
))
3102 f
->size_hint_flags
|= YNegative
;
3103 else if (INTEGERP (top
))
3105 toppos
= XINT (top
);
3107 f
->size_hint_flags
|= YNegative
;
3109 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3110 && CONSP (XCDR (top
))
3111 && INTEGERP (XCAR (XCDR (top
))))
3113 toppos
= - XINT (XCAR (XCDR (top
)));
3114 f
->size_hint_flags
|= YNegative
;
3116 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
3117 && CONSP (XCDR (top
))
3118 && INTEGERP (XCAR (XCDR (top
))))
3120 toppos
= XINT (XCAR (XCDR (top
)));
3124 /* Store the numeric value of the position. */
3125 f
->top_pos
= toppos
;
3126 f
->left_pos
= leftpos
;
3128 f
->win_gravity
= NorthWestGravity
;
3130 /* Actually set that position, and convert to absolute. */
3131 x_set_offset (f
, leftpos
, toppos
, -1);
3134 if ((!NILP (icon_left
) || !NILP (icon_top
))
3135 && ! (icon_left_no_change
&& icon_top_no_change
))
3136 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3143 /* Insert a description of internally-recorded parameters of frame X
3144 into the parameter alist *ALISTPTR that is to be given to the user.
3145 Only parameters that are specific to the X window system
3146 and whose values are not correctly recorded in the frame's
3147 param_alist need to be considered here. */
3150 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3155 /* Represent negative positions (off the top or left screen edge)
3156 in a way that Fmodify_frame_parameters will understand correctly. */
3157 XSETINT (tem
, f
->left_pos
);
3158 if (f
->left_pos
>= 0)
3159 store_in_alist (alistptr
, Qleft
, tem
);
3161 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3163 XSETINT (tem
, f
->top_pos
);
3164 if (f
->top_pos
>= 0)
3165 store_in_alist (alistptr
, Qtop
, tem
);
3167 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3169 store_in_alist (alistptr
, Qborder_width
,
3170 make_number (f
->border_width
));
3171 store_in_alist (alistptr
, Qinternal_border_width
,
3172 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3173 store_in_alist (alistptr
, Qleft_fringe
,
3174 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3175 store_in_alist (alistptr
, Qright_fringe
,
3176 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3177 store_in_alist (alistptr
, Qscroll_bar_width
,
3178 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3180 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3181 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3182 /* nil means "use default width"
3183 for non-toolkit scroll bar.
3184 ruler-mode.el depends on this. */
3186 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
3187 store_in_alist (alistptr
, Qwindow_id
,
3188 build_string (buf
));
3189 #ifdef HAVE_X_WINDOWS
3190 #ifdef USE_X_TOOLKIT
3191 /* Tooltip frame may not have this widget. */
3192 if (FRAME_X_OUTPUT (f
)->widget
)
3194 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
3195 store_in_alist (alistptr
, Qouter_window_id
,
3196 build_string (buf
));
3198 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3199 FRAME_SAMPLE_VISIBILITY (f
);
3200 store_in_alist (alistptr
, Qvisibility
,
3201 (FRAME_VISIBLE_P (f
) ? Qt
3202 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3203 store_in_alist (alistptr
, Qdisplay
,
3204 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3206 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3209 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3210 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3211 store_in_alist (alistptr
, Qparent_id
, tem
);
3215 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3216 the previous value of that parameter, NEW_VALUE is the new value. */
3219 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3221 if (NILP (new_value
))
3222 f
->want_fullscreen
= FULLSCREEN_NONE
;
3223 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3224 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3225 else if (EQ (new_value
, Qfullwidth
))
3226 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3227 else if (EQ (new_value
, Qfullheight
))
3228 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3229 else if (EQ (new_value
, Qmaximized
))
3230 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3232 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3233 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3237 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3238 the previous value of that parameter, NEW_VALUE is the new value. */
3241 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3243 if (NILP (new_value
))
3244 f
->extra_line_spacing
= 0;
3245 else if (NATNUMP (new_value
))
3246 f
->extra_line_spacing
= XFASTINT (new_value
);
3248 signal_error ("Invalid line-spacing", new_value
);
3249 if (FRAME_VISIBLE_P (f
))
3254 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3255 the previous value of that parameter, NEW_VALUE is the new value. */
3258 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3260 Lisp_Object bgcolor
;
3262 if (NILP (new_value
))
3264 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3265 /* The value 0.4545 is the normal viewing gamma. */
3266 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3268 signal_error ("Invalid screen-gamma", new_value
);
3270 /* Apply the new gamma value to the frame background. */
3271 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3272 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3274 Lisp_Object index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3276 && (XFASTINT (index
)
3277 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3278 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3279 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3283 Fclear_face_cache (Qnil
);
3288 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3290 Lisp_Object frame
, font_object
, font_param
= Qnil
;
3293 /* Set the frame parameter back to the old value because we may
3294 fail to use ARG as the new parameter value. */
3295 store_frame_param (f
, Qfont
, oldval
);
3297 /* ARG is a fontset name, a font name, a cons of fontset name and a
3298 font object, or a font object. In the last case, this function
3303 fontset
= fs_query_fontset (arg
, 0);
3306 font_object
= font_open_by_name (f
, SDATA (arg
));
3307 if (NILP (font_object
))
3308 error ("Font `%s' is not defined", SDATA (arg
));
3309 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3311 else if (fontset
> 0)
3313 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3315 font_object
= font_open_by_name (f
, SDATA (ascii_font
));
3316 if (NILP (font_object
))
3317 error ("Font `%s' is not defined", SDATA (arg
));
3318 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3321 error ("The default fontset can't be used for a frame font");
3323 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3325 /* This is the case that the ASCII font of F's fontset XCAR
3326 (arg) is changed to the font XCDR (arg) by
3327 `set-fontset-font'. */
3328 fontset
= fs_query_fontset (XCAR (arg
), 0);
3330 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3331 font_object
= XCDR (arg
);
3332 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3333 font_param
= Ffont_get (font_object
, QCname
);
3335 else if (FONT_OBJECT_P (arg
))
3338 font_param
= Ffont_get (font_object
, QCname
);
3339 /* This is to store the XLFD font name in the frame parameter for
3340 backward compatibility. We should store the font-object
3341 itself in the future. */
3342 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3343 fontset
= FRAME_FONTSET (f
);
3344 /* Check if we can use the current fontset. If not, set FONTSET
3345 to -1 to generate a new fontset from FONT-OBJECT. */
3348 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3349 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3351 if (! font_match_p (spec
, font_object
))
3356 signal_error ("Invalid font", arg
);
3358 if (! NILP (Fequal (font_object
, oldval
)))
3361 x_new_font (f
, font_object
, fontset
);
3362 store_frame_param (f
, Qfont
, arg
);
3363 #ifdef HAVE_X_WINDOWS
3364 store_frame_param (f
, Qfont_param
, font_param
);
3366 /* Recalculate toolbar height. */
3367 f
->n_tool_bar_rows
= 0;
3368 /* Ensure we redraw it. */
3369 clear_current_matrices (f
);
3371 recompute_basic_faces (f
);
3373 do_pending_window_change (0);
3375 /* We used to call face-set-after-frame-default here, but it leads to
3376 recursive calls (since that function can set the `default' face's
3377 font which in turns changes the frame's `font' parameter).
3378 Also I don't know what this call is meant to do, but it seems the
3379 wrong way to do it anyway (it does a lot more work than what seems
3380 reasonable in response to a change to `font'). */
3385 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3387 if (! NILP (new_value
)
3388 && !CONSP (new_value
))
3392 CHECK_STRING (new_value
);
3393 p0
= p1
= SDATA (new_value
);
3397 while (*p1
&& ! isspace (*p1
) && *p1
!= ',') p1
++;
3399 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3405 while ((c
= *++p1
) && isspace (c
));
3409 new_value
= Fnreverse (new_value
);
3412 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3416 free_all_realized_faces (Qnil
);
3418 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3419 if (NILP (new_value
))
3421 if (NILP (old_value
))
3422 error ("No font backend available");
3423 font_update_drivers (f
, old_value
);
3424 error ("None of specified font backends are available");
3426 store_frame_param (f
, Qfont_backend
, new_value
);
3432 XSETFRAME (frame
, f
);
3433 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3434 ++face_change_count
;
3435 ++windows_or_buffers_changed
;
3441 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3443 compute_fringe_widths (f
, 1);
3447 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3451 if (XINT (arg
) == f
->border_width
)
3454 if (FRAME_X_WINDOW (f
) != 0)
3455 error ("Cannot change the border width of a frame");
3457 f
->border_width
= XINT (arg
);
3461 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3463 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3466 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3467 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3468 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3470 #ifdef USE_X_TOOLKIT
3471 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3472 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3475 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3478 if (FRAME_X_WINDOW (f
) != 0)
3480 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3481 SET_FRAME_GARBAGED (f
);
3482 do_pending_window_change (0);
3485 SET_FRAME_GARBAGED (f
);
3489 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3492 XSETFRAME (frame
, f
);
3495 Fmake_frame_invisible (frame
, Qt
);
3496 else if (EQ (value
, Qicon
))
3497 Ficonify_frame (frame
);
3499 Fmake_frame_visible (frame
);
3503 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3505 f
->auto_raise
= !EQ (Qnil
, arg
);
3509 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3511 f
->auto_lower
= !EQ (Qnil
, arg
);
3515 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3517 f
->no_split
= !NILP (arg
);
3521 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3523 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3524 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3525 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3526 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3528 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3530 ? vertical_scroll_bar_none
3532 ? vertical_scroll_bar_left
3534 ? vertical_scroll_bar_right
3535 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3536 ? vertical_scroll_bar_left
3537 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3538 ? vertical_scroll_bar_right
3539 : vertical_scroll_bar_none
);
3541 /* We set this parameter before creating the X window for the
3542 frame, so we can get the geometry right from the start.
3543 However, if the window hasn't been created yet, we shouldn't
3544 call x_set_window_size. */
3545 if (FRAME_X_WINDOW (f
))
3546 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3547 do_pending_window_change (0);
3552 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3554 int wid
= FRAME_COLUMN_WIDTH (f
);
3558 x_set_scroll_bar_default_width (f
);
3560 if (FRAME_X_WINDOW (f
))
3561 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3562 do_pending_window_change (0);
3564 else if (INTEGERP (arg
) && XINT (arg
) > 0
3565 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3567 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3568 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3570 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3571 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3572 if (FRAME_X_WINDOW (f
))
3573 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3574 do_pending_window_change (0);
3577 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3578 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3579 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3584 /* Return non-nil if frame F wants a bitmap icon. */
3587 x_icon_type (FRAME_PTR f
)
3591 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3599 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3606 for (i
= 0; i
< 2; i
++)
3619 else if (FLOATP (item
))
3621 alpha
= XFLOAT_DATA (item
);
3622 if (alpha
< 0.0 || 1.0 < alpha
)
3623 args_out_of_range (make_float (0.0), make_float (1.0));
3625 else if (INTEGERP (item
))
3627 ialpha
= XINT (item
);
3628 if (ialpha
< 0 || 100 < ialpha
)
3629 args_out_of_range (make_number (0), make_number (100));
3631 alpha
= ialpha
/ 100.0;
3634 wrong_type_argument (Qnumberp
, item
);
3638 for (i
= 0; i
< 2; i
++)
3639 f
->alpha
[i
] = newval
[i
];
3641 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3643 x_set_frame_alpha (f
);
3651 /* Subroutines of creating an X frame. */
3653 /* Make sure that Vx_resource_name is set to a reasonable value.
3654 Fix it up, or set it to `emacs' if it is too hopeless. */
3657 validate_x_resource_name (void)
3660 /* Number of valid characters in the resource name. */
3662 /* Number of invalid characters in the resource name. */
3667 if (!STRINGP (Vx_resource_class
))
3668 Vx_resource_class
= build_string (EMACS_CLASS
);
3670 if (STRINGP (Vx_resource_name
))
3672 unsigned char *p
= SDATA (Vx_resource_name
);
3675 len
= SBYTES (Vx_resource_name
);
3677 /* Only letters, digits, - and _ are valid in resource names.
3678 Count the valid characters and count the invalid ones. */
3679 for (i
= 0; i
< len
; i
++)
3682 if (! ((c
>= 'a' && c
<= 'z')
3683 || (c
>= 'A' && c
<= 'Z')
3684 || (c
>= '0' && c
<= '9')
3685 || c
== '-' || c
== '_'))
3692 /* Not a string => completely invalid. */
3693 bad_count
= 5, good_count
= 0;
3695 /* If name is valid already, return. */
3699 /* If name is entirely invalid, or nearly so, use `emacs'. */
3701 || (good_count
== 1 && bad_count
> 0))
3703 Vx_resource_name
= build_string ("emacs");
3707 /* Name is partly valid. Copy it and replace the invalid characters
3708 with underscores. */
3710 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3712 for (i
= 0; i
< len
; i
++)
3714 int c
= SREF (new, i
);
3715 if (! ((c
>= 'a' && c
<= 'z')
3716 || (c
>= 'A' && c
<= 'Z')
3717 || (c
>= '0' && c
<= '9')
3718 || c
== '-' || c
== '_'))
3724 extern char *x_get_string_resource (XrmDatabase
, const char *, const char *);
3725 extern Display_Info
*check_x_display_info (Lisp_Object
);
3728 /* Get specified attribute from resource database RDB.
3729 See Fx_get_resource below for other parameters. */
3732 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3734 register char *value
;
3738 CHECK_STRING (attribute
);
3739 CHECK_STRING (class);
3741 if (!NILP (component
))
3742 CHECK_STRING (component
);
3743 if (!NILP (subclass
))
3744 CHECK_STRING (subclass
);
3745 if (NILP (component
) != NILP (subclass
))
3746 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3748 validate_x_resource_name ();
3750 /* Allocate space for the components, the dots which separate them,
3751 and the final '\0'. Make them big enough for the worst case. */
3752 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3753 + (STRINGP (component
)
3754 ? SBYTES (component
) : 0)
3755 + SBYTES (attribute
)
3758 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3760 + (STRINGP (subclass
)
3761 ? SBYTES (subclass
) : 0)
3764 /* Start with emacs.FRAMENAME for the name (the specific one)
3765 and with `Emacs' for the class key (the general one). */
3766 strcpy (name_key
, SDATA (Vx_resource_name
));
3767 strcpy (class_key
, SDATA (Vx_resource_class
));
3769 strcat (class_key
, ".");
3770 strcat (class_key
, SDATA (class));
3772 if (!NILP (component
))
3774 strcat (class_key
, ".");
3775 strcat (class_key
, SDATA (subclass
));
3777 strcat (name_key
, ".");
3778 strcat (name_key
, SDATA (component
));
3781 strcat (name_key
, ".");
3782 strcat (name_key
, SDATA (attribute
));
3784 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3786 if (value
!= (char *) 0 && *value
)
3787 return build_string (value
);
3793 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3794 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3795 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3796 class, where INSTANCE is the name under which Emacs was invoked, or
3797 the name specified by the `-name' or `-rn' command-line arguments.
3799 The optional arguments COMPONENT and SUBCLASS add to the key and the
3800 class, respectively. You must specify both of them or neither.
3801 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3802 and the class is `Emacs.CLASS.SUBCLASS'. */)
3803 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3805 #ifdef HAVE_X_WINDOWS
3809 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3810 attribute
, class, component
, subclass
);
3813 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3816 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3818 return xrdb_get_resource (dpyinfo
->xrdb
,
3819 attribute
, class, component
, subclass
);
3822 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3823 /* Used when C code wants a resource value. */
3824 /* Called from oldXMenu/Create.c. */
3826 x_get_resource_string (const char *attribute
, const char *class)
3830 struct frame
*sf
= SELECTED_FRAME ();
3832 /* Allocate space for the components, the dots which separate them,
3833 and the final '\0'. */
3834 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3835 + strlen (attribute
) + 2);
3836 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3837 + strlen (class) + 2);
3839 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3840 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3842 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3843 name_key
, class_key
);
3847 /* Return the value of parameter PARAM.
3849 First search ALIST, then Vdefault_frame_alist, then the X defaults
3850 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3852 Convert the resource to the type specified by desired_type.
3854 If no default is specified, return Qunbound. If you call
3855 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3856 and don't let it get stored in any Lisp-visible variables! */
3859 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3860 const char *attribute
, const char *class, enum resource_types type
)
3862 register Lisp_Object tem
;
3864 tem
= Fassq (param
, alist
);
3868 /* If we find this parm in ALIST, clear it out
3869 so that it won't be "left over" at the end. */
3871 XSETCAR (tem
, Qnil
);
3872 /* In case the parameter appears more than once in the alist,
3874 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3875 if (CONSP (XCAR (tail
))
3876 && EQ (XCAR (XCAR (tail
)), param
))
3877 XSETCAR (XCAR (tail
), Qnil
);
3880 tem
= Fassq (param
, Vdefault_frame_alist
);
3882 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3883 look in the X resources. */
3886 if (attribute
&& dpyinfo
)
3888 tem
= display_x_get_resource (dpyinfo
,
3889 build_string (attribute
),
3890 build_string (class),
3898 case RES_TYPE_NUMBER
:
3899 return make_number (atoi (SDATA (tem
)));
3901 case RES_TYPE_BOOLEAN_NUMBER
:
3902 if (!strcmp (SDATA (tem
), "on")
3903 || !strcmp (SDATA (tem
), "true"))
3904 return make_number (1);
3905 return make_number (atoi (SDATA (tem
)));
3908 case RES_TYPE_FLOAT
:
3909 return make_float (atof (SDATA (tem
)));
3911 case RES_TYPE_BOOLEAN
:
3912 tem
= Fdowncase (tem
);
3913 if (!strcmp (SDATA (tem
), "on")
3915 || !strcmp(SDATA(tem
), "yes")
3917 || !strcmp (SDATA (tem
), "true"))
3922 case RES_TYPE_STRING
:
3925 case RES_TYPE_SYMBOL
:
3926 /* As a special case, we map the values `true' and `on'
3927 to Qt, and `false' and `off' to Qnil. */
3930 lower
= Fdowncase (tem
);
3931 if (!strcmp (SDATA (lower
), "on")
3933 || !strcmp(SDATA(lower
), "yes")
3935 || !strcmp (SDATA (lower
), "true"))
3937 else if (!strcmp (SDATA (lower
), "off")
3939 || !strcmp(SDATA(lower
), "no")
3941 || !strcmp (SDATA (lower
), "false"))
3944 return Fintern (tem
, Qnil
);
3958 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3959 const char *attribute
, const char *class,
3960 enum resource_types type
)
3962 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3963 alist
, param
, attribute
, class, type
);
3966 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3969 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3971 const char *attribute
, const char *class,
3972 enum resource_types type
)
3976 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3977 attribute
, class, type
);
3978 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3979 store_frame_param (f
, param
, value
);
3985 /* Record in frame F the specified or default value according to ALIST
3986 of the parameter named PROP (a Lisp symbol).
3987 If no value is specified for PROP, look for an X default for XPROP
3988 on the frame named NAME.
3989 If that is not found either, use the value DEFLT. */
3992 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
3993 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
3994 enum resource_types type
)
3998 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3999 if (EQ (tem
, Qunbound
))
4001 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
4008 /* NS used to define x-parse-geometry in ns-win.el, but that confused
4009 make-docfile: the documentation string in ns-win.el was used for
4010 x-parse-geometry even in non-NS builds.
4012 With two definitions of x-parse-geometry in this file, various
4013 things still get confused (eg M-x apropos documentation), so that
4014 it is best if the two definitions just share the same doc-string.
4016 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4017 doc
: /* Parse a display geometry string STRING.
4018 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4019 The properties returned may include `top', `left', `height', and `width'.
4020 For X, the value of `left' or `top' may be an integer,
4021 or a list (+ N) meaning N pixels relative to top/left corner,
4022 or a list (- N) meaning -N pixels relative to bottom/right corner.
4023 On Nextstep, this just calls `ns-parse-geometry'. */)
4024 (Lisp_Object string
)
4027 call1 (Qns_parse_geometry
, string
);
4030 unsigned int width
, height
;
4033 CHECK_STRING (string
);
4035 geometry
= XParseGeometry ((char *) SDATA (string
),
4036 &x
, &y
, &width
, &height
);
4038 if (geometry
& XValue
)
4040 Lisp_Object element
;
4042 if (x
>= 0 && (geometry
& XNegative
))
4043 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
4044 else if (x
< 0 && ! (geometry
& XNegative
))
4045 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
4047 element
= Fcons (Qleft
, make_number (x
));
4048 result
= Fcons (element
, result
);
4051 if (geometry
& YValue
)
4053 Lisp_Object element
;
4055 if (y
>= 0 && (geometry
& YNegative
))
4056 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
4057 else if (y
< 0 && ! (geometry
& YNegative
))
4058 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
4060 element
= Fcons (Qtop
, make_number (y
));
4061 result
= Fcons (element
, result
);
4064 if (geometry
& WidthValue
)
4065 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
4066 if (geometry
& HeightValue
)
4067 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
4070 #endif /* HAVE_NS */
4074 /* Calculate the desired size and position of frame F.
4075 Return the flags saying which aspects were specified.
4077 Also set the win_gravity and size_hint_flags of F.
4079 Adjust height for toolbar if TOOLBAR_P is 1.
4081 This function does not make the coordinates positive. */
4083 #define DEFAULT_ROWS 35
4084 #define DEFAULT_COLS 80
4087 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, int toolbar_p
)
4089 register Lisp_Object tem0
, tem1
, tem2
;
4090 long window_prompting
= 0;
4091 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
4093 /* Default values if we fall through.
4094 Actually, if that happens we should get
4095 window manager prompting. */
4096 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4097 FRAME_LINES (f
) = DEFAULT_ROWS
;
4098 /* Window managers expect that if program-specified
4099 positions are not (0,0), they're intentional, not defaults. */
4103 /* Ensure that old new_text_cols and new_text_lines will not override the
4105 /* ++KFS: This was specific to W32, but seems ok for all platforms */
4106 f
->new_text_cols
= f
->new_text_lines
= 0;
4108 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4109 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4110 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4111 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4113 if (!EQ (tem0
, Qunbound
))
4115 CHECK_NUMBER (tem0
);
4116 FRAME_LINES (f
) = XINT (tem0
);
4118 if (!EQ (tem1
, Qunbound
))
4120 CHECK_NUMBER (tem1
);
4121 SET_FRAME_COLS (f
, XINT (tem1
));
4123 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4124 window_prompting
|= USSize
;
4126 window_prompting
|= PSize
;
4129 f
->scroll_bar_actual_width
4130 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4132 /* This used to be done _before_ calling x_figure_window_size, but
4133 since the height is reset here, this was really a no-op. I
4134 assume that moving it here does what Gerd intended (although he
4135 no longer can remember what that was... ++KFS, 2003-03-25. */
4137 /* Add the tool-bar height to the initial frame height so that the
4138 user gets a text display area of the size he specified with -g or
4139 via .Xdefaults. Later changes of the tool-bar height don't
4140 change the frame size. This is done so that users can create
4141 tall Emacs frames without having to guess how tall the tool-bar
4143 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4145 int margin
, relief
, bar_height
;
4147 relief
= (tool_bar_button_relief
>= 0
4148 ? tool_bar_button_relief
4149 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4151 if (INTEGERP (Vtool_bar_button_margin
)
4152 && XINT (Vtool_bar_button_margin
) > 0)
4153 margin
= XFASTINT (Vtool_bar_button_margin
);
4154 else if (CONSP (Vtool_bar_button_margin
)
4155 && INTEGERP (XCDR (Vtool_bar_button_margin
))
4156 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
4157 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4161 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4162 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4165 compute_fringe_widths (f
, 0);
4167 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4168 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4170 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4171 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4172 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4173 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4175 if (EQ (tem0
, Qminus
))
4178 window_prompting
|= YNegative
;
4180 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4181 && CONSP (XCDR (tem0
))
4182 && INTEGERP (XCAR (XCDR (tem0
))))
4184 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4185 window_prompting
|= YNegative
;
4187 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4188 && CONSP (XCDR (tem0
))
4189 && INTEGERP (XCAR (XCDR (tem0
))))
4191 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4193 else if (EQ (tem0
, Qunbound
))
4197 CHECK_NUMBER (tem0
);
4198 f
->top_pos
= XINT (tem0
);
4200 window_prompting
|= YNegative
;
4203 if (EQ (tem1
, Qminus
))
4206 window_prompting
|= XNegative
;
4208 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4209 && CONSP (XCDR (tem1
))
4210 && INTEGERP (XCAR (XCDR (tem1
))))
4212 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4213 window_prompting
|= XNegative
;
4215 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4216 && CONSP (XCDR (tem1
))
4217 && INTEGERP (XCAR (XCDR (tem1
))))
4219 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4221 else if (EQ (tem1
, Qunbound
))
4225 CHECK_NUMBER (tem1
);
4226 f
->left_pos
= XINT (tem1
);
4227 if (f
->left_pos
< 0)
4228 window_prompting
|= XNegative
;
4231 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4232 window_prompting
|= USPosition
;
4234 window_prompting
|= PPosition
;
4237 if (window_prompting
& XNegative
)
4239 if (window_prompting
& YNegative
)
4240 f
->win_gravity
= SouthEastGravity
;
4242 f
->win_gravity
= NorthEastGravity
;
4246 if (window_prompting
& YNegative
)
4247 f
->win_gravity
= SouthWestGravity
;
4249 f
->win_gravity
= NorthWestGravity
;
4252 f
->size_hint_flags
= window_prompting
;
4254 return window_prompting
;
4259 #endif /* HAVE_WINDOW_SYSTEM */
4262 frame_make_pointer_invisible (void)
4264 if (! NILP (Vmake_pointer_invisible
))
4267 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4270 f
= SELECTED_FRAME ();
4271 if (f
&& !f
->pointer_invisible
4272 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4275 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4276 f
->pointer_invisible
= 1;
4282 frame_make_pointer_visible (void)
4284 /* We don't check Vmake_pointer_invisible here in case the
4285 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4288 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4291 f
= SELECTED_FRAME ();
4292 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4293 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4295 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4296 f
->pointer_invisible
= 0;
4302 /***********************************************************************
4304 ***********************************************************************/
4307 syms_of_frame (void)
4309 Qframep
= intern_c_string ("framep");
4310 staticpro (&Qframep
);
4311 Qframe_live_p
= intern_c_string ("frame-live-p");
4312 staticpro (&Qframe_live_p
);
4313 Qexplicit_name
= intern_c_string ("explicit-name");
4314 staticpro (&Qexplicit_name
);
4315 Qheight
= intern_c_string ("height");
4316 staticpro (&Qheight
);
4317 Qicon
= intern_c_string ("icon");
4319 Qminibuffer
= intern_c_string ("minibuffer");
4320 staticpro (&Qminibuffer
);
4321 Qmodeline
= intern_c_string ("modeline");
4322 staticpro (&Qmodeline
);
4323 Qonly
= intern_c_string ("only");
4325 Qwidth
= intern_c_string ("width");
4326 staticpro (&Qwidth
);
4327 Qgeometry
= intern_c_string ("geometry");
4328 staticpro (&Qgeometry
);
4329 Qicon_left
= intern_c_string ("icon-left");
4330 staticpro (&Qicon_left
);
4331 Qicon_top
= intern_c_string ("icon-top");
4332 staticpro (&Qicon_top
);
4333 Qtooltip
= intern_c_string ("tooltip");
4334 staticpro (&Qtooltip
);
4335 Qleft
= intern_c_string ("left");
4337 Qright
= intern_c_string ("right");
4338 staticpro (&Qright
);
4339 Quser_position
= intern_c_string ("user-position");
4340 staticpro (&Quser_position
);
4341 Quser_size
= intern_c_string ("user-size");
4342 staticpro (&Quser_size
);
4343 Qwindow_id
= intern_c_string ("window-id");
4344 staticpro (&Qwindow_id
);
4345 #ifdef HAVE_X_WINDOWS
4346 Qouter_window_id
= intern_c_string ("outer-window-id");
4347 staticpro (&Qouter_window_id
);
4349 Qparent_id
= intern_c_string ("parent-id");
4350 staticpro (&Qparent_id
);
4351 Qx
= intern_c_string ("x");
4353 Qw32
= intern_c_string ("w32");
4355 Qpc
= intern_c_string ("pc");
4357 Qmac
= intern_c_string ("mac");
4359 Qns
= intern_c_string ("ns");
4361 Qvisible
= intern_c_string ("visible");
4362 staticpro (&Qvisible
);
4363 Qbuffer_predicate
= intern_c_string ("buffer-predicate");
4364 staticpro (&Qbuffer_predicate
);
4365 Qbuffer_list
= intern_c_string ("buffer-list");
4366 staticpro (&Qbuffer_list
);
4367 Qburied_buffer_list
= intern_c_string ("buried-buffer-list");
4368 staticpro (&Qburied_buffer_list
);
4369 Qdisplay_type
= intern_c_string ("display-type");
4370 staticpro (&Qdisplay_type
);
4371 Qbackground_mode
= intern_c_string ("background-mode");
4372 staticpro (&Qbackground_mode
);
4373 Qnoelisp
= intern_c_string ("noelisp");
4374 staticpro (&Qnoelisp
);
4375 Qtty_color_mode
= intern_c_string ("tty-color-mode");
4376 staticpro (&Qtty_color_mode
);
4377 Qtty
= intern_c_string ("tty");
4379 Qtty_type
= intern_c_string ("tty-type");
4380 staticpro (&Qtty_type
);
4382 Qface_set_after_frame_default
= intern_c_string ("face-set-after-frame-default");
4383 staticpro (&Qface_set_after_frame_default
);
4385 Qfullwidth
= intern_c_string ("fullwidth");
4386 staticpro (&Qfullwidth
);
4387 Qfullheight
= intern_c_string ("fullheight");
4388 staticpro (&Qfullheight
);
4389 Qfullboth
= intern_c_string ("fullboth");
4390 staticpro (&Qfullboth
);
4391 Qmaximized
= intern_c_string ("maximized");
4392 staticpro (&Qmaximized
);
4393 Qx_resource_name
= intern_c_string ("x-resource-name");
4394 staticpro (&Qx_resource_name
);
4396 Qx_frame_parameter
= intern_c_string ("x-frame-parameter");
4397 staticpro (&Qx_frame_parameter
);
4399 Qterminal
= intern_c_string ("terminal");
4400 staticpro (&Qterminal
);
4401 Qterminal_live_p
= intern_c_string ("terminal-live-p");
4402 staticpro (&Qterminal_live_p
);
4405 Qns_parse_geometry
= intern_c_string ("ns-parse-geometry");
4406 staticpro (&Qns_parse_geometry
);
4412 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4414 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4415 if (frame_parms
[i
].variable
)
4417 *frame_parms
[i
].variable
= v
;
4418 staticpro (frame_parms
[i
].variable
);
4420 Fput (v
, Qx_frame_parameter
, make_number (i
));
4424 #ifdef HAVE_WINDOW_SYSTEM
4425 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4426 doc
: /* The name Emacs uses to look up X resources.
4427 `x-get-resource' uses this as the first component of the instance name
4428 when requesting resource values.
4429 Emacs initially sets `x-resource-name' to the name under which Emacs
4430 was invoked, or to the value specified with the `-name' or `-rn'
4431 switches, if present.
4433 It may be useful to bind this variable locally around a call
4434 to `x-get-resource'. See also the variable `x-resource-class'. */);
4435 Vx_resource_name
= Qnil
;
4437 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4438 doc
: /* The class Emacs uses to look up X resources.
4439 `x-get-resource' uses this as the first component of the instance class
4440 when requesting resource values.
4442 Emacs initially sets `x-resource-class' to "Emacs".
4444 Setting this variable permanently is not a reasonable thing to do,
4445 but binding this variable locally around a call to `x-get-resource'
4446 is a reasonable practice. See also the variable `x-resource-name'. */);
4447 Vx_resource_class
= build_string (EMACS_CLASS
);
4449 DEFVAR_LISP ("frame-alpha-lower-limit", &Vframe_alpha_lower_limit
,
4450 doc
: /* The lower limit of the frame opacity (alpha transparency).
4451 The value should range from 0 (invisible) to 100 (completely opaque).
4452 You can also use a floating number between 0.0 and 1.0.
4453 The default is 20. */);
4454 Vframe_alpha_lower_limit
= make_number (20);
4457 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4458 doc
: /* Alist of default values for frame creation.
4459 These may be set in your init file, like this:
4460 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4461 These override values given in window system configuration data,
4462 including X Windows' defaults database.
4463 For values specific to the first Emacs frame, see `initial-frame-alist'.
4464 For window-system specific values, see `window-system-default-frame-alist'.
4465 For values specific to the separate minibuffer frame, see
4466 `minibuffer-frame-alist'.
4467 The `menu-bar-lines' element of the list controls whether new frames
4468 have menu bars; `menu-bar-mode' works by altering this element.
4469 Setting this variable does not affect existing frames, only new ones. */);
4470 Vdefault_frame_alist
= Qnil
;
4472 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars
,
4473 doc
: /* Default position of scroll bars on this window-system. */);
4474 #ifdef HAVE_WINDOW_SYSTEM
4475 #if defined(HAVE_NTGUI) || defined(NS_IMPL_COCOA) || (defined(USE_GTK) && defined(USE_TOOLKIT_SCROLL_BARS))
4476 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4478 Vdefault_frame_scroll_bars
= Qright
;
4480 Vdefault_frame_scroll_bars
= Qleft
;
4483 Vdefault_frame_scroll_bars
= Qnil
;
4486 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4487 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4489 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4490 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4491 `mouse-position' calls this function, passing its usual return value as
4492 argument, and returns whatever this function returns.
4493 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4494 which need to do mouse handling at the Lisp level. */);
4495 Vmouse_position_function
= Qnil
;
4497 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4498 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4499 If the value is an integer, highlighting is only shown after moving the
4500 mouse, while keyboard input turns off the highlight even when the mouse
4501 is over the clickable text. However, the mouse shape still indicates
4502 when the mouse is over clickable text. */);
4503 Vmouse_highlight
= Qt
;
4505 DEFVAR_LISP ("make-pointer-invisible", &Vmake_pointer_invisible
,
4506 doc
: /* If non-nil, make pointer invisible while typing.
4507 The pointer becomes visible again when the mouse is moved. */);
4508 Vmake_pointer_invisible
= Qt
;
4510 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4511 doc
: /* Functions to be run before deleting a frame.
4512 The functions are run with one arg, the frame to be deleted.
4515 Note that functions in this list may be called just before the frame is
4516 actually deleted, or some time later (or even both when an earlier function
4517 in `delete-frame-functions' (indirectly) calls `delete-frame'
4519 Vdelete_frame_functions
= Qnil
;
4520 Qdelete_frame_functions
= intern_c_string ("delete-frame-functions");
4521 staticpro (&Qdelete_frame_functions
);
4523 DEFVAR_LISP ("menu-bar-mode", &Vmenu_bar_mode
,
4524 doc
: /* Non-nil if Menu-Bar mode is enabled. */);
4525 Vmenu_bar_mode
= Qt
;
4527 DEFVAR_LISP ("tool-bar-mode", &Vtool_bar_mode
,
4528 doc
: /* Non-nil if Tool-Bar mode is enabled. */);
4529 Vtool_bar_mode
= Qt
;
4531 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4532 doc
: /* Minibufferless frames use this frame's minibuffer.
4534 Emacs cannot create minibufferless frames unless this is set to an
4535 appropriate surrogate.
4537 Emacs consults this variable only when creating minibufferless
4538 frames; once the frame is created, it sticks with its assigned
4539 minibuffer, no matter what this variable is set to. This means that
4540 this variable doesn't necessarily say anything meaningful about the
4541 current set of frames, or where the minibuffer is currently being
4544 This variable is local to the current terminal and cannot be buffer-local. */);
4546 DEFVAR_BOOL ("focus-follows-mouse", &focus_follows_mouse
,
4547 doc
: /* Non-nil if window system changes focus when you move the mouse.
4548 You should set this variable to tell Emacs how your window manager
4549 handles focus, since there is no way in general for Emacs to find out
4550 automatically. See also `mouse-autoselect-window'. */);
4551 #ifdef HAVE_WINDOW_SYSTEM
4552 #if defined(HAVE_NTGUI) || defined(HAVE_NS)
4553 focus_follows_mouse
= 0;
4555 focus_follows_mouse
= 1;
4558 focus_follows_mouse
= 0;
4561 staticpro (&Vframe_list
);
4563 defsubr (&Sactive_minibuffer_window
);
4565 defsubr (&Sframe_live_p
);
4566 defsubr (&Swindow_system
);
4567 defsubr (&Smake_terminal_frame
);
4568 defsubr (&Shandle_switch_frame
);
4569 defsubr (&Sselect_frame
);
4570 defsubr (&Sselected_frame
);
4571 defsubr (&Swindow_frame
);
4572 defsubr (&Sframe_root_window
);
4573 defsubr (&Sframe_first_window
);
4574 defsubr (&Sframe_selected_window
);
4575 defsubr (&Sset_frame_selected_window
);
4576 defsubr (&Sframe_list
);
4577 defsubr (&Snext_frame
);
4578 defsubr (&Sprevious_frame
);
4579 defsubr (&Sdelete_frame
);
4580 defsubr (&Smouse_position
);
4581 defsubr (&Smouse_pixel_position
);
4582 defsubr (&Sset_mouse_position
);
4583 defsubr (&Sset_mouse_pixel_position
);
4585 defsubr (&Sframe_configuration
);
4586 defsubr (&Srestore_frame_configuration
);
4588 defsubr (&Smake_frame_visible
);
4589 defsubr (&Smake_frame_invisible
);
4590 defsubr (&Siconify_frame
);
4591 defsubr (&Sframe_visible_p
);
4592 defsubr (&Svisible_frame_list
);
4593 defsubr (&Sraise_frame
);
4594 defsubr (&Slower_frame
);
4595 defsubr (&Sredirect_frame_focus
);
4596 defsubr (&Sframe_focus
);
4597 defsubr (&Sframe_parameters
);
4598 defsubr (&Sframe_parameter
);
4599 defsubr (&Smodify_frame_parameters
);
4600 defsubr (&Sframe_char_height
);
4601 defsubr (&Sframe_char_width
);
4602 defsubr (&Sframe_pixel_height
);
4603 defsubr (&Sframe_pixel_width
);
4604 defsubr (&Sset_frame_height
);
4605 defsubr (&Sset_frame_width
);
4606 defsubr (&Sset_frame_size
);
4607 defsubr (&Sset_frame_position
);
4609 #ifdef HAVE_WINDOW_SYSTEM
4610 defsubr (&Sx_get_resource
);
4611 defsubr (&Sx_parse_geometry
);
4616 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4617 (do not change this comment) */