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
;
556 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
560 init_frame_faces (f
);
568 make_terminal_frame (struct terminal
*terminal
)
570 register struct frame
*f
;
575 error ("Terminal is not live, can't create new frames on it");
579 XSETFRAME (frame
, f
);
580 Vframe_list
= Fcons (frame
, Vframe_list
);
583 sprintf (name
, "F%d", tty_frame_count
);
584 f
->name
= build_string (name
);
586 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
587 f
->async_visible
= 1; /* Don't let visible be cleared later. */
588 f
->terminal
= terminal
;
589 f
->terminal
->reference_count
++;
591 f
->output_data
.tty
->display_info
= &the_only_display_info
;
592 if (!inhibit_window_system
593 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
594 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
595 f
->output_method
= output_msdos_raw
;
597 f
->output_method
= output_termcap
;
598 #else /* not MSDOS */
599 f
->output_method
= output_termcap
;
600 create_tty_output (f
);
601 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
602 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
603 #endif /* not MSDOS */
605 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
606 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
607 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
609 /* Set the top frame to the newly created frame. */
610 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
611 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
612 XFRAME (FRAME_TTY (f
)->top_frame
)->async_visible
= 2; /* obscured */
614 FRAME_TTY (f
)->top_frame
= frame
;
617 init_frame_faces (f
);
622 /* Get a suitable value for frame parameter PARAMETER for a newly
623 created frame, based on (1) the user-supplied frame parameter
624 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
627 get_future_frame_param (Lisp_Object parameter
,
628 Lisp_Object supplied_parms
,
633 result
= Fassq (parameter
, supplied_parms
);
635 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
636 if (NILP (result
) && current_value
!= NULL
)
637 result
= build_string (current_value
);
638 if (!NILP (result
) && !STRINGP (result
))
639 result
= XCDR (result
);
640 if (NILP (result
) || !STRINGP (result
))
646 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
648 doc
: /* Create an additional terminal frame, possibly on another terminal.
649 This function takes one argument, an alist specifying frame parameters.
651 You can create multiple frames on a single text-only terminal, but
652 only one of them (the selected terminal frame) is actually displayed.
654 In practice, generally you don't need to specify any parameters,
655 except when you want to create a new frame on another terminal.
656 In that case, the `tty' parameter specifies the device file to open,
657 and the `tty-type' parameter specifies the terminal type. Example:
659 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
661 Note that changing the size of one terminal frame automatically
662 affects all frames on the same terminal device. */)
666 struct terminal
*t
= NULL
;
667 Lisp_Object frame
, tem
;
668 struct frame
*sf
= SELECTED_FRAME ();
671 if (sf
->output_method
!= output_msdos_raw
672 && sf
->output_method
!= output_termcap
)
674 #else /* not MSDOS */
676 #ifdef WINDOWSNT /* This should work now! */
677 if (sf
->output_method
!= output_termcap
)
678 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
680 #endif /* not MSDOS */
683 Lisp_Object terminal
;
685 terminal
= Fassq (Qterminal
, parms
);
686 if (!NILP (terminal
))
688 terminal
= XCDR (terminal
);
689 t
= get_terminal (terminal
, 1);
692 if (t
&& t
!= the_only_display_info
.terminal
)
693 /* msdos.c assumes a single tty_display_info object. */
694 error ("Multiple terminals are not supported on this platform");
696 t
= the_only_display_info
.terminal
;
702 char *name
= 0, *type
= 0;
703 Lisp_Object tty
, tty_type
;
705 tty
= get_future_frame_param
706 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
707 ? FRAME_TTY (XFRAME (selected_frame
))->name
711 name
= (char *) alloca (SBYTES (tty
) + 1);
712 strncpy (name
, SDATA (tty
), SBYTES (tty
));
713 name
[SBYTES (tty
)] = 0;
716 tty_type
= get_future_frame_param
717 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
718 ? FRAME_TTY (XFRAME (selected_frame
))->type
720 if (!NILP (tty_type
))
722 type
= (char *) alloca (SBYTES (tty_type
) + 1);
723 strncpy (type
, SDATA (tty_type
), SBYTES (tty_type
));
724 type
[SBYTES (tty_type
)] = 0;
727 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
730 f
= make_terminal_frame (t
);
734 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
735 change_frame_size (f
, height
, width
, 0, 0, 0);
740 XSETFRAME (frame
, f
);
741 Fmodify_frame_parameters (frame
, parms
);
742 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
743 build_string (t
->display_info
.tty
->type
)),
745 if (t
->display_info
.tty
->name
!= NULL
)
746 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
747 build_string (t
->display_info
.tty
->name
)),
750 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
752 /* Make the frame face alist be frame-specific, so that each
753 frame could change its face definitions independently. */
754 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
755 /* Simple Fcopy_alist isn't enough, because we need the contents of
756 the vectors which are the CDRs of associations in face_alist to
757 be copied as well. */
758 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
759 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
764 /* Perform the switch to frame FRAME.
766 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
769 If TRACK is non-zero and the frame that currently has the focus
770 redirects its focus to the selected frame, redirect that focused
771 frame's focus to FRAME instead.
773 FOR_DELETION non-zero means that the selected frame is being
774 deleted, which includes the possibility that the frame's terminal
777 The value of NORECORD is passed as argument to Fselect_window. */
780 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
782 struct frame
*sf
= SELECTED_FRAME ();
784 /* If FRAME is a switch-frame event, extract the frame we should
787 && EQ (XCAR (frame
), Qswitch_frame
)
788 && CONSP (XCDR (frame
)))
789 frame
= XCAR (XCDR (frame
));
791 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
792 a switch-frame event to arrive after a frame is no longer live,
793 especially when deleting the initial frame during startup. */
795 if (! FRAME_LIVE_P (XFRAME (frame
)))
798 if (sf
== XFRAME (frame
))
801 /* This is too greedy; it causes inappropriate focus redirection
802 that's hard to get rid of. */
804 /* If a frame's focus has been redirected toward the currently
805 selected frame, we should change the redirection to point to the
806 newly selected frame. This means that if the focus is redirected
807 from a minibufferless frame to a surrogate minibuffer frame, we
808 can use `other-window' to switch between all the frames using
809 that minibuffer frame, and the focus redirection will follow us
815 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
819 if (!FRAMEP (XCAR (tail
)))
822 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
824 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
825 Fredirect_frame_focus (XCAR (tail
), frame
);
829 /* Instead, apply it only to the frame we're pointing to. */
830 #ifdef HAVE_WINDOW_SYSTEM
831 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
833 Lisp_Object focus
, xfocus
;
835 xfocus
= x_get_focus_frame (XFRAME (frame
));
838 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
839 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
840 Fredirect_frame_focus (xfocus
, frame
);
843 #endif /* HAVE_X_WINDOWS */
846 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
847 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
849 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
851 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
852 /* Mark previously displayed frame as now obscured. */
853 XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
)->async_visible
= 2;
854 XFRAME (frame
)->async_visible
= 1;
855 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
858 selected_frame
= frame
;
859 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
860 last_nonminibuf_frame
= XFRAME (selected_frame
);
862 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
864 /* We want to make sure that the next event generates a frame-switch
865 event to the appropriate frame. This seems kludgy to me, but
866 before you take it out, make sure that evaluating something like
867 (select-window (frame-root-window (new-frame))) doesn't end up
868 with your typing being interpreted in the new frame instead of
869 the one you're actually typing in. */
870 internal_last_event_frame
= Qnil
;
875 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
876 doc
: /* Select FRAME.
877 Subsequent editing commands apply to its selected window.
878 Optional argument NORECORD means to neither change the order of
879 recently selected windows nor the buffer list.
881 The selection of FRAME lasts until the next time the user does
882 something to select a different frame, or until the next time
883 this function is called. If you are using a window system, the
884 previously selected frame may be restored as the selected frame
885 when returning to the command loop, because it still may have
886 the window system's input focus. On a text-only terminal, the
887 next redisplay will display FRAME.
889 This function returns FRAME, or nil if FRAME has been deleted. */)
890 (Lisp_Object frame
, Lisp_Object norecord
)
892 return do_switch_frame (frame
, 1, 0, norecord
);
896 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
897 doc
: /* Handle a switch-frame event EVENT.
898 Switch-frame events are usually bound to this function.
899 A switch-frame event tells Emacs that the window manager has requested
900 that the user's events be directed to the frame mentioned in the event.
901 This function selects the selected window of the frame of EVENT.
903 If EVENT is frame object, handle it as if it were a switch-frame event
907 /* Preserve prefix arg that the command loop just cleared. */
908 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
909 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
910 return do_switch_frame (event
, 0, 0, Qnil
);
913 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
914 doc
: /* Return the frame that is now selected. */)
917 return selected_frame
;
920 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
921 doc
: /* Return the frame object that window WINDOW is on. */)
924 CHECK_LIVE_WINDOW (window
);
925 return XWINDOW (window
)->frame
;
928 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
929 doc
: /* Returns the topmost, leftmost window of FRAME.
930 If omitted, FRAME defaults to the currently selected frame. */)
936 w
= SELECTED_FRAME ()->root_window
;
939 CHECK_LIVE_FRAME (frame
);
940 w
= XFRAME (frame
)->root_window
;
942 while (NILP (XWINDOW (w
)->buffer
))
944 if (! NILP (XWINDOW (w
)->hchild
))
945 w
= XWINDOW (w
)->hchild
;
946 else if (! NILP (XWINDOW (w
)->vchild
))
947 w
= XWINDOW (w
)->vchild
;
954 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
955 Sactive_minibuffer_window
, 0, 0, 0,
956 doc
: /* Return the currently active minibuffer window, or nil if none. */)
959 return minibuf_level
? minibuf_window
: Qnil
;
962 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
963 doc
: /* Returns the root-window of FRAME.
964 If omitted, FRAME defaults to the currently selected frame. */)
970 window
= SELECTED_FRAME ()->root_window
;
973 CHECK_LIVE_FRAME (frame
);
974 window
= XFRAME (frame
)->root_window
;
980 DEFUN ("frame-selected-window", Fframe_selected_window
,
981 Sframe_selected_window
, 0, 1, 0,
982 doc
: /* Return the selected window of FRAME.
983 FRAME defaults to the currently selected frame. */)
989 window
= SELECTED_FRAME ()->selected_window
;
992 CHECK_LIVE_FRAME (frame
);
993 window
= XFRAME (frame
)->selected_window
;
999 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
1000 Sset_frame_selected_window
, 2, 3, 0,
1001 doc
: /* Set selected window of FRAME to WINDOW.
1002 If FRAME is nil, use the selected frame. If FRAME is the
1003 selected frame, this makes WINDOW the selected window.
1004 Optional argument NORECORD non-nil means to neither change the
1005 order of recently selected windows nor the buffer list.
1007 (Lisp_Object frame
, Lisp_Object window
, Lisp_Object norecord
)
1010 frame
= selected_frame
;
1012 CHECK_LIVE_FRAME (frame
);
1013 CHECK_LIVE_WINDOW (window
);
1015 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
1016 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
1018 if (EQ (frame
, selected_frame
))
1019 return Fselect_window (window
, norecord
);
1021 return XFRAME (frame
)->selected_window
= window
;
1025 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1027 doc
: /* Return a list of all live frames. */)
1031 frames
= Fcopy_sequence (Vframe_list
);
1032 #ifdef HAVE_WINDOW_SYSTEM
1033 if (FRAMEP (tip_frame
))
1034 frames
= Fdelq (tip_frame
, frames
);
1039 /* Return the next frame in the frame list after FRAME.
1040 If MINIBUF is nil, exclude minibuffer-only frames.
1041 If MINIBUF is a window, include only its own frame
1042 and any frame now using that window as the minibuffer.
1043 If MINIBUF is `visible', include all visible frames.
1044 If MINIBUF is 0, include all visible and iconified frames.
1045 Otherwise, include all frames. */
1048 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1053 /* There must always be at least one frame in Vframe_list. */
1054 if (! CONSP (Vframe_list
))
1057 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
1058 forever. Forestall that. */
1059 CHECK_LIVE_FRAME (frame
);
1062 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1069 && ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1070 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1071 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1072 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
)))))
1074 /* Decide whether this frame is eligible to be returned. */
1076 /* If we've looped all the way around without finding any
1077 eligible frames, return the original frame. */
1081 /* Let minibuf decide if this frame is acceptable. */
1084 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1087 else if (EQ (minibuf
, Qvisible
))
1089 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1090 if (FRAME_VISIBLE_P (XFRAME (f
)))
1093 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
1095 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1096 if (FRAME_VISIBLE_P (XFRAME (f
))
1097 || FRAME_ICONIFIED_P (XFRAME (f
)))
1100 else if (WINDOWP (minibuf
))
1102 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1103 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1104 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1105 FRAME_FOCUS_FRAME (XFRAME (f
))))
1117 /* Return the previous frame in the frame list before FRAME.
1118 If MINIBUF is nil, exclude minibuffer-only frames.
1119 If MINIBUF is a window, include only its own frame
1120 and any frame now using that window as the minibuffer.
1121 If MINIBUF is `visible', include all visible frames.
1122 If MINIBUF is 0, include all visible and iconified frames.
1123 Otherwise, include all frames. */
1126 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1131 /* There must always be at least one frame in Vframe_list. */
1132 if (! CONSP (Vframe_list
))
1136 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1144 if (EQ (frame
, f
) && !NILP (prev
))
1147 if ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1148 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1149 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1150 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
))))
1152 /* Decide whether this frame is eligible to be returned,
1153 according to minibuf. */
1156 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1159 else if (WINDOWP (minibuf
))
1161 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1162 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1163 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1164 FRAME_FOCUS_FRAME (XFRAME (f
))))
1167 else if (EQ (minibuf
, Qvisible
))
1169 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1170 if (FRAME_VISIBLE_P (XFRAME (f
)))
1173 else if (XFASTINT (minibuf
) == 0)
1175 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1176 if (FRAME_VISIBLE_P (XFRAME (f
))
1177 || FRAME_ICONIFIED_P (XFRAME (f
)))
1185 /* We've scanned the entire list. */
1187 /* We went through the whole frame list without finding a single
1188 acceptable frame. Return the original frame. */
1191 /* There were no acceptable frames in the list before FRAME; otherwise,
1192 we would have returned directly from the loop. Since PREV is the last
1193 acceptable frame in the list, return it. */
1198 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1199 doc
: /* Return the next frame in the frame list after FRAME.
1200 It considers only frames on the same terminal as FRAME.
1201 By default, skip minibuffer-only frames.
1202 If omitted, FRAME defaults to the selected frame.
1203 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1204 If MINIFRAME is a window, include only its own frame
1205 and any frame now using that window as the minibuffer.
1206 If MINIFRAME is `visible', include all visible frames.
1207 If MINIFRAME is 0, include all visible and iconified frames.
1208 Otherwise, include all frames. */)
1209 (Lisp_Object frame
, Lisp_Object miniframe
)
1212 frame
= selected_frame
;
1214 CHECK_LIVE_FRAME (frame
);
1215 return next_frame (frame
, miniframe
);
1218 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1219 doc
: /* Return the previous frame in the frame list before FRAME.
1220 It considers only frames on the same terminal as FRAME.
1221 By default, skip minibuffer-only frames.
1222 If omitted, FRAME defaults to the selected frame.
1223 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1224 If MINIFRAME is a window, include only its own frame
1225 and any frame now using that window as the minibuffer.
1226 If MINIFRAME is `visible', include all visible frames.
1227 If MINIFRAME is 0, include all visible and iconified frames.
1228 Otherwise, include all frames. */)
1229 (Lisp_Object frame
, Lisp_Object miniframe
)
1232 frame
= selected_frame
;
1233 CHECK_LIVE_FRAME (frame
);
1234 return prev_frame (frame
, miniframe
);
1237 /* Return 1 if it is ok to delete frame F;
1238 0 if all frames aside from F are invisible.
1239 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1242 other_visible_frames (FRAME_PTR f
)
1244 /* We know the selected frame is visible,
1245 so if F is some other frame, it can't be the sole visible one. */
1246 if (f
== SELECTED_FRAME ())
1251 for (frames
= Vframe_list
;
1253 frames
= XCDR (frames
))
1257 this = XCAR (frames
);
1258 /* Verify that the frame's window still exists
1259 and we can still talk to it. And note any recent change
1261 #ifdef HAVE_WINDOW_SYSTEM
1262 if (FRAME_WINDOW_P (XFRAME (this)))
1264 x_sync (XFRAME (this));
1265 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1269 if (FRAME_VISIBLE_P (XFRAME (this))
1270 || FRAME_ICONIFIED_P (XFRAME (this))
1271 /* Allow deleting the terminal frame when at least
1272 one X frame exists! */
1273 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1281 /* Error handler for `delete-frame-functions'. */
1283 delete_frame_handler (Lisp_Object arg
)
1285 add_to_log ("Error during `delete-frame': %s", arg
, Qnil
);
1289 extern Lisp_Object Qrun_hook_with_args
;
1291 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1292 unconditionally. x_connection_closed and delete_terminal use
1293 this. Any other value of FORCE implements the semantics
1294 described for Fdelete_frame. */
1296 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1297 /* If we use `register' here, gcc-4.0.2 on amd64 using
1298 -DUSE_LISP_UNION_TYPE complains further down that we're getting the
1299 address of `force'. Go figure. */
1303 struct frame
*sf
= SELECTED_FRAME ();
1306 int minibuffer_selected
, tooltip_frame
;
1308 if (EQ (frame
, Qnil
))
1311 XSETFRAME (frame
, f
);
1315 CHECK_FRAME (frame
);
1319 if (! FRAME_LIVE_P (f
))
1322 if (NILP (force
) && !other_visible_frames (f
))
1323 error ("Attempt to delete the sole visible or iconified frame");
1325 /* x_connection_closed must have set FORCE to `noelisp' in order
1326 to delete the last frame, if it is gone. */
1327 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1328 error ("Attempt to delete the only frame");
1330 /* Does this frame have a minibuffer, and is it the surrogate
1331 minibuffer for any other frame? */
1332 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1336 for (frames
= Vframe_list
;
1338 frames
= XCDR (frames
))
1341 this = XCAR (frames
);
1343 if (! EQ (this, frame
)
1345 WINDOW_FRAME (XWINDOW
1346 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1348 /* If we MUST delete this frame, delete the other first.
1349 But do this only if FORCE equals `noelisp'. */
1350 if (EQ (force
, Qnoelisp
))
1351 delete_frame (this, Qnoelisp
);
1353 error ("Attempt to delete a surrogate minibuffer frame");
1358 tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1360 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1361 frame is a tooltip. FORCE is set to `noelisp' when handling
1362 a disconnect from the terminal, so we don't dare call Lisp
1364 if (NILP (Vrun_hooks
) || tooltip_frame
)
1366 else if (EQ (force
, Qnoelisp
))
1368 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1371 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1373 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1374 if (! FRAME_LIVE_P (f
))
1377 /* At this point, we are committed to deleting the frame.
1378 There is no more chance for errors to prevent it. */
1380 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1382 /* Don't let the frame remain selected. */
1385 Lisp_Object tail
, frame1
;
1387 /* Look for another visible frame on the same terminal. */
1388 frame1
= next_frame (frame
, Qvisible
);
1390 /* If there is none, find *some* other frame. */
1391 if (NILP (frame1
) || EQ (frame1
, frame
))
1393 FOR_EACH_FRAME (tail
, frame1
)
1395 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1399 #ifdef NS_IMPL_COCOA
1401 /* Under NS, there is no system mechanism for choosing a new
1402 window to get focus -- it is left to application code.
1403 So the portion of THIS application interfacing with NS
1404 needs to know about it. We call Fraise_frame, but the
1405 purpose is really to transfer focus. */
1406 Fraise_frame (frame1
);
1409 do_switch_frame (frame1
, 0, 1, Qnil
);
1410 sf
= SELECTED_FRAME ();
1413 /* Don't allow minibuf_window to remain on a deleted frame. */
1414 if (EQ (f
->minibuffer_window
, minibuf_window
))
1416 Fset_window_buffer (sf
->minibuffer_window
,
1417 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1418 minibuf_window
= sf
->minibuffer_window
;
1420 /* If the dying minibuffer window was selected,
1421 select the new one. */
1422 if (minibuffer_selected
)
1423 Fselect_window (minibuf_window
, Qnil
);
1426 /* Don't let echo_area_window to remain on a deleted frame. */
1427 if (EQ (f
->minibuffer_window
, echo_area_window
))
1428 echo_area_window
= sf
->minibuffer_window
;
1430 /* Clear any X selections for this frame. */
1431 #ifdef HAVE_X_WINDOWS
1433 x_clear_frame_selections (f
);
1437 This function must be called before the window tree of the
1438 frame is deleted because windows contain dynamically allocated
1442 #ifdef HAVE_WINDOW_SYSTEM
1443 /* Give chance to each font driver to free a frame specific data. */
1444 font_update_drivers (f
, Qnil
);
1447 /* Mark all the windows that used to be on FRAME as deleted, and then
1448 remove the reference to them. */
1449 delete_all_subwindows (XWINDOW (f
->root_window
));
1450 f
->root_window
= Qnil
;
1452 Vframe_list
= Fdelq (frame
, Vframe_list
);
1453 FRAME_SET_VISIBLE (f
, 0);
1455 /* Allow the vector of menu bar contents to be freed in the next
1456 garbage collection. The frame object itself may not be garbage
1457 collected until much later, because recent_keys and other data
1458 structures can still refer to it. */
1459 f
->menu_bar_vector
= Qnil
;
1461 free_font_driver_list (f
);
1463 xfree (f
->decode_mode_spec_buffer
);
1464 xfree (FRAME_INSERT_COST (f
));
1465 xfree (FRAME_DELETEN_COST (f
));
1466 xfree (FRAME_INSERTN_COST (f
));
1467 xfree (FRAME_DELETE_COST (f
));
1468 xfree (FRAME_MESSAGE_BUF (f
));
1470 /* Since some events are handled at the interrupt level, we may get
1471 an event for f at any time; if we zero out the frame's terminal
1472 now, then we may trip up the event-handling code. Instead, we'll
1473 promise that the terminal of the frame must be valid until we
1474 have called the window-system-dependent frame destruction
1477 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1478 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1481 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1482 f
->output_data
.nothing
= 0;
1483 f
->terminal
= 0; /* Now the frame is dead. */
1485 /* If needed, delete the terminal that this frame was on.
1486 (This must be done after the frame is killed.) */
1487 terminal
->reference_count
--;
1488 if (terminal
->reference_count
== 0)
1491 XSETTERMINAL (tmp
, terminal
);
1494 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1497 kb
= terminal
->kboard
;
1500 /* If we've deleted the last_nonminibuf_frame, then try to find
1502 if (f
== last_nonminibuf_frame
)
1506 last_nonminibuf_frame
= 0;
1508 for (frames
= Vframe_list
;
1510 frames
= XCDR (frames
))
1512 f
= XFRAME (XCAR (frames
));
1513 if (!FRAME_MINIBUF_ONLY_P (f
))
1515 last_nonminibuf_frame
= f
;
1521 /* If there's no other frame on the same kboard, get out of
1522 single-kboard state if we're in it for this kboard. */
1526 /* Some frame we found on the same kboard, or nil if there are none. */
1527 Lisp_Object frame_on_same_kboard
;
1529 frame_on_same_kboard
= Qnil
;
1531 for (frames
= Vframe_list
;
1533 frames
= XCDR (frames
))
1538 this = XCAR (frames
);
1543 if (kb
== FRAME_KBOARD (f1
))
1544 frame_on_same_kboard
= this;
1547 if (NILP (frame_on_same_kboard
))
1548 not_single_kboard_state (kb
);
1552 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1553 find another one. Prefer minibuffer-only frames, but also notice
1554 frames with other windows. */
1555 if (kb
!= NULL
&& EQ (frame
, kb
->Vdefault_minibuffer_frame
))
1559 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1560 Lisp_Object frame_with_minibuf
;
1561 /* Some frame we found on the same kboard, or nil if there are none. */
1562 Lisp_Object frame_on_same_kboard
;
1564 frame_on_same_kboard
= Qnil
;
1565 frame_with_minibuf
= Qnil
;
1567 for (frames
= Vframe_list
;
1569 frames
= XCDR (frames
))
1574 this = XCAR (frames
);
1579 /* Consider only frames on the same kboard
1580 and only those with minibuffers. */
1581 if (kb
== FRAME_KBOARD (f1
)
1582 && FRAME_HAS_MINIBUF_P (f1
))
1584 frame_with_minibuf
= this;
1585 if (FRAME_MINIBUF_ONLY_P (f1
))
1589 if (kb
== FRAME_KBOARD (f1
))
1590 frame_on_same_kboard
= this;
1593 if (!NILP (frame_on_same_kboard
))
1595 /* We know that there must be some frame with a minibuffer out
1596 there. If this were not true, all of the frames present
1597 would have to be minibufferless, which implies that at some
1598 point their minibuffer frames must have been deleted, but
1599 that is prohibited at the top; you can't delete surrogate
1600 minibuffer frames. */
1601 if (NILP (frame_with_minibuf
))
1604 kb
->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1607 /* No frames left on this kboard--say no minibuffer either. */
1608 kb
->Vdefault_minibuffer_frame
= Qnil
;
1611 /* Cause frame titles to update--necessary if we now have just one frame. */
1613 update_mode_lines
= 1;
1618 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1619 doc
: /* Delete FRAME, permanently eliminating it from use.
1620 FRAME defaults to the selected frame.
1622 A frame may not be deleted if its minibuffer is used by other frames.
1623 Normally, you may not delete a frame if all other frames are invisible,
1624 but if the second optional argument FORCE is non-nil, you may do so.
1626 This function runs `delete-frame-functions' before actually
1627 deleting the frame, unless the frame is a tooltip.
1628 The functions are run with one argument, the frame to be deleted. */)
1629 (Lisp_Object frame
, Lisp_Object force
)
1631 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1635 /* Return mouse position in character cell units. */
1637 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1638 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1639 The position is given in character cells, where (0, 0) is the
1640 upper-left corner of the frame, X is the horizontal offset, and Y is
1641 the vertical offset.
1642 If Emacs is running on a mouseless terminal or hasn't been programmed
1643 to read the mouse position, it returns the selected frame for FRAME
1644 and nil for X and Y.
1645 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1646 passing the normal return value to that function as an argument,
1647 and returns whatever that function returns. */)
1651 Lisp_Object lispy_dummy
;
1652 enum scroll_bar_part party_dummy
;
1653 Lisp_Object x
, y
, retval
;
1655 unsigned long long_dummy
;
1656 struct gcpro gcpro1
;
1658 f
= SELECTED_FRAME ();
1661 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1662 /* It's okay for the hook to refrain from storing anything. */
1663 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1664 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1665 &lispy_dummy
, &party_dummy
,
1672 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1677 XSETFRAME (lispy_dummy
, f
);
1678 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1680 if (!NILP (Vmouse_position_function
))
1681 retval
= call1 (Vmouse_position_function
, retval
);
1682 RETURN_UNGCPRO (retval
);
1685 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1686 Smouse_pixel_position
, 0, 0, 0,
1687 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1688 The position is given in pixel units, where (0, 0) is the
1689 upper-left corner of the frame, X is the horizontal offset, and Y is
1690 the vertical offset.
1691 If Emacs is running on a mouseless terminal or hasn't been programmed
1692 to read the mouse position, it returns the selected frame for FRAME
1693 and nil for X and Y. */)
1697 Lisp_Object lispy_dummy
;
1698 enum scroll_bar_part party_dummy
;
1700 unsigned long long_dummy
;
1702 f
= SELECTED_FRAME ();
1705 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1706 /* It's okay for the hook to refrain from storing anything. */
1707 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1708 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1709 &lispy_dummy
, &party_dummy
,
1713 XSETFRAME (lispy_dummy
, f
);
1714 return Fcons (lispy_dummy
, Fcons (x
, y
));
1717 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1718 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1719 Coordinates are relative to the frame, not a window,
1720 so the coordinates of the top left character in the frame
1721 may be nonzero due to left-hand scroll bars or the menu bar.
1723 The position is given in character cells, where (0, 0) is the
1724 upper-left corner of the frame, X is the horizontal offset, and Y is
1725 the vertical offset.
1727 This function is a no-op for an X frame that is not visible.
1728 If you have just created a frame, you must wait for it to become visible
1729 before calling this function on it, like this.
1730 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1731 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1733 CHECK_LIVE_FRAME (frame
);
1737 /* I think this should be done with a hook. */
1738 #ifdef HAVE_WINDOW_SYSTEM
1739 if (FRAME_WINDOW_P (XFRAME (frame
)))
1740 /* Warping the mouse will cause enternotify and focus events. */
1741 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1743 #if defined (MSDOS) && defined (HAVE_MOUSE)
1744 if (FRAME_MSDOS_P (XFRAME (frame
)))
1746 Fselect_frame (frame
, Qnil
);
1747 mouse_moveto (XINT (x
), XINT (y
));
1752 Fselect_frame (frame
, Qnil
);
1753 term_mouse_moveto (XINT (x
), XINT (y
));
1762 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1763 Sset_mouse_pixel_position
, 3, 3, 0,
1764 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1765 The position is given in pixels, where (0, 0) is the upper-left corner
1766 of the frame, X is the horizontal offset, and Y is the vertical offset.
1768 Note, this is a no-op for an X frame that is not visible.
1769 If you have just created a frame, you must wait for it to become visible
1770 before calling this function on it, like this.
1771 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1772 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1774 CHECK_LIVE_FRAME (frame
);
1778 /* I think this should be done with a hook. */
1779 #ifdef HAVE_WINDOW_SYSTEM
1780 if (FRAME_WINDOW_P (XFRAME (frame
)))
1781 /* Warping the mouse will cause enternotify and focus events. */
1782 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1784 #if defined (MSDOS) && defined (HAVE_MOUSE)
1785 if (FRAME_MSDOS_P (XFRAME (frame
)))
1787 Fselect_frame (frame
, Qnil
);
1788 mouse_moveto (XINT (x
), XINT (y
));
1793 Fselect_frame (frame
, Qnil
);
1794 term_mouse_moveto (XINT (x
), XINT (y
));
1803 static void make_frame_visible_1 (Lisp_Object
);
1805 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1807 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1808 If omitted, FRAME defaults to the currently selected frame. */)
1812 frame
= selected_frame
;
1814 CHECK_LIVE_FRAME (frame
);
1816 /* I think this should be done with a hook. */
1817 #ifdef HAVE_WINDOW_SYSTEM
1818 if (FRAME_WINDOW_P (XFRAME (frame
)))
1820 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1821 x_make_frame_visible (XFRAME (frame
));
1825 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1827 /* Make menu bar update for the Buffers and Frames menus. */
1828 windows_or_buffers_changed
++;
1833 /* Update the display_time slot of the buffers shown in WINDOW
1834 and all its descendents. */
1837 make_frame_visible_1 (Lisp_Object window
)
1841 for (;!NILP (window
); window
= w
->next
)
1843 w
= XWINDOW (window
);
1845 if (!NILP (w
->buffer
))
1846 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1848 if (!NILP (w
->vchild
))
1849 make_frame_visible_1 (w
->vchild
);
1850 if (!NILP (w
->hchild
))
1851 make_frame_visible_1 (w
->hchild
);
1855 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1857 doc
: /* Make the frame FRAME invisible.
1858 If omitted, FRAME defaults to the currently selected frame.
1859 On graphical displays, invisible frames are not updated and are
1860 usually not displayed at all, even in a window system's \"taskbar\".
1862 Normally you may not make FRAME invisible if all other frames are invisible,
1863 but if the second optional argument FORCE is non-nil, you may do so.
1865 This function has no effect on text-only terminal frames. Such frames
1866 are always considered visible, whether or not they are currently being
1867 displayed in the terminal. */)
1868 (Lisp_Object frame
, Lisp_Object force
)
1871 frame
= selected_frame
;
1873 CHECK_LIVE_FRAME (frame
);
1875 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1876 error ("Attempt to make invisible the sole visible or iconified frame");
1878 #if 0 /* This isn't logically necessary, and it can do GC. */
1879 /* Don't let the frame remain selected. */
1880 if (EQ (frame
, selected_frame
))
1881 do_switch_frame (next_frame (frame
, Qt
), 0, 0, Qnil
)
1884 /* Don't allow minibuf_window to remain on a deleted frame. */
1885 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1887 struct frame
*sf
= XFRAME (selected_frame
);
1888 Fset_window_buffer (sf
->minibuffer_window
,
1889 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1890 minibuf_window
= sf
->minibuffer_window
;
1893 /* I think this should be done with a hook. */
1894 #ifdef HAVE_WINDOW_SYSTEM
1895 if (FRAME_WINDOW_P (XFRAME (frame
)))
1896 x_make_frame_invisible (XFRAME (frame
));
1899 /* Make menu bar update for the Buffers and Frames menus. */
1900 windows_or_buffers_changed
++;
1905 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1907 doc
: /* Make the frame FRAME into an icon.
1908 If omitted, FRAME defaults to the currently selected frame. */)
1912 frame
= selected_frame
;
1914 CHECK_LIVE_FRAME (frame
);
1916 #if 0 /* This isn't logically necessary, and it can do GC. */
1917 /* Don't let the frame remain selected. */
1918 if (EQ (frame
, selected_frame
))
1919 Fhandle_switch_frame (next_frame (frame
, Qt
));
1922 /* Don't allow minibuf_window to remain on a deleted frame. */
1923 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1925 struct frame
*sf
= XFRAME (selected_frame
);
1926 Fset_window_buffer (sf
->minibuffer_window
,
1927 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1928 minibuf_window
= sf
->minibuffer_window
;
1931 /* I think this should be done with a hook. */
1932 #ifdef HAVE_WINDOW_SYSTEM
1933 if (FRAME_WINDOW_P (XFRAME (frame
)))
1934 x_iconify_frame (XFRAME (frame
));
1937 /* Make menu bar update for the Buffers and Frames menus. */
1938 windows_or_buffers_changed
++;
1943 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1945 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1946 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1947 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1948 On graphical displays, invisible frames are not updated and are
1949 usually not displayed at all, even in a window system's \"taskbar\".
1951 If FRAME is a text-only terminal frame, this always returns t.
1952 Such frames are always considered visible, whether or not they are
1953 currently being displayed on the terminal. */)
1956 CHECK_LIVE_FRAME (frame
);
1958 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1960 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1962 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1967 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1969 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1972 Lisp_Object tail
, frame
;
1977 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1979 frame
= XCAR (tail
);
1980 if (!FRAMEP (frame
))
1983 if (FRAME_VISIBLE_P (f
))
1984 value
= Fcons (frame
, value
);
1990 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1991 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1992 If FRAME is invisible or iconified, make it visible.
1993 If you don't specify a frame, the selected frame is used.
1994 If Emacs is displaying on an ordinary terminal or some other device which
1995 doesn't support multiple overlapping frames, this function selects FRAME. */)
2000 frame
= selected_frame
;
2002 CHECK_LIVE_FRAME (frame
);
2006 if (FRAME_TERMCAP_P (f
))
2007 /* On a text-only terminal select FRAME. */
2008 Fselect_frame (frame
, Qnil
);
2010 /* Do like the documentation says. */
2011 Fmake_frame_visible (frame
);
2013 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2014 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
2019 /* Should we have a corresponding function called Flower_Power? */
2020 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
2021 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2022 If you don't specify a frame, the selected frame is used.
2023 If Emacs is displaying on an ordinary terminal or some other device which
2024 doesn't support multiple overlapping frames, this function does nothing. */)
2030 frame
= selected_frame
;
2032 CHECK_LIVE_FRAME (frame
);
2036 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2037 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2043 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2045 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2046 In other words, switch-frame events caused by events in FRAME will
2047 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2048 FOCUS-FRAME after reading an event typed at FRAME.
2050 If FOCUS-FRAME is omitted or nil, any existing redirection is
2051 cancelled, and the frame again receives its own keystrokes.
2053 Focus redirection is useful for temporarily redirecting keystrokes to
2054 a surrogate minibuffer frame when a frame doesn't have its own
2057 A frame's focus redirection can be changed by `select-frame'. If frame
2058 FOO is selected, and then a different frame BAR is selected, any
2059 frames redirecting their focus to FOO are shifted to redirect their
2060 focus to BAR. This allows focus redirection to work properly when the
2061 user switches from one frame to another using `select-window'.
2063 This means that a frame whose focus is redirected to itself is treated
2064 differently from a frame whose focus is redirected to nil; the former
2065 is affected by `select-frame', while the latter is not.
2067 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2068 (Lisp_Object frame
, Lisp_Object focus_frame
)
2072 /* Note that we don't check for a live frame here. It's reasonable
2073 to redirect the focus of a frame you're about to delete, if you
2074 know what other frame should receive those keystrokes. */
2075 CHECK_FRAME (frame
);
2077 if (! NILP (focus_frame
))
2078 CHECK_LIVE_FRAME (focus_frame
);
2082 f
->focus_frame
= focus_frame
;
2084 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2085 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2091 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
2092 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2093 This returns nil if FRAME's focus is not redirected.
2094 See `redirect-frame-focus'. */)
2097 CHECK_LIVE_FRAME (frame
);
2099 return FRAME_FOCUS_FRAME (XFRAME (frame
));
2104 /* Return the value of frame parameter PROP in frame FRAME. */
2107 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
2109 register Lisp_Object tem
;
2111 tem
= Fassq (prop
, frame
->param_alist
);
2117 /* Return the buffer-predicate of the selected frame. */
2120 frame_buffer_predicate (Lisp_Object frame
)
2122 return XFRAME (frame
)->buffer_predicate
;
2125 /* Return the buffer-list of the selected frame. */
2128 frame_buffer_list (Lisp_Object frame
)
2130 return XFRAME (frame
)->buffer_list
;
2133 /* Set the buffer-list of the selected frame. */
2136 set_frame_buffer_list (Lisp_Object frame
, Lisp_Object list
)
2138 XFRAME (frame
)->buffer_list
= list
;
2141 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2144 frames_discard_buffer (Lisp_Object buffer
)
2146 Lisp_Object frame
, tail
;
2148 FOR_EACH_FRAME (tail
, frame
)
2150 XFRAME (frame
)->buffer_list
2151 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
2152 XFRAME (frame
)->buried_buffer_list
2153 = Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
);
2157 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2158 If the alist already has an element for PROP, we change it. */
2161 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2163 register Lisp_Object tem
;
2165 tem
= Fassq (prop
, *alistptr
);
2167 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2173 frame_name_fnn_p (char *str
, EMACS_INT len
)
2175 if (len
> 1 && str
[0] == 'F')
2179 strtol (str
+ 1, &end_ptr
, 10);
2181 if (end_ptr
== str
+ len
)
2187 /* Set the name of the terminal frame. Also used by MSDOS frames.
2188 Modeled after x_set_name which is used for WINDOW frames. */
2191 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2193 f
->explicit_name
= ! NILP (name
);
2195 /* If NAME is nil, set the name to F<num>. */
2200 /* Check for no change needed in this very common case
2201 before we do any consing. */
2202 if (frame_name_fnn_p (SDATA (f
->name
),
2207 sprintf (namebuf
, "F%d", tty_frame_count
);
2208 name
= build_string (namebuf
);
2212 CHECK_STRING (name
);
2214 /* Don't change the name if it's already NAME. */
2215 if (! NILP (Fstring_equal (name
, f
->name
)))
2218 /* Don't allow the user to set the frame name to F<num>, so it
2219 doesn't clash with the names we generate for terminal frames. */
2220 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
2221 error ("Frame names of the form F<num> are usurped by Emacs");
2225 update_mode_lines
= 1;
2229 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2231 register Lisp_Object old_alist_elt
;
2233 /* The buffer-list parameters are stored in a special place and not
2235 if (EQ (prop
, Qbuffer_list
))
2237 f
->buffer_list
= val
;
2240 if (EQ (prop
, Qburied_buffer_list
))
2242 f
->buried_buffer_list
= val
;
2246 /* If PROP is a symbol which is supposed to have frame-local values,
2247 and it is set up based on this frame, switch to the global
2248 binding. That way, we can create or alter the frame-local binding
2249 without messing up the symbol's status. */
2252 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2254 switch (sym
->redirect
)
2256 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2257 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2258 case SYMBOL_LOCALIZED
:
2259 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2260 if (blv
->frame_local
&& BLV_FOUND (blv
) && XFRAME (blv
->where
) == f
)
2261 swap_in_global_binding (sym
);
2268 /* The tty color needed to be set before the frame's parameter
2269 alist was updated with the new value. This is not true any more,
2270 but we still do this test early on. */
2271 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2272 && f
== FRAME_TTY (f
)->previous_frame
)
2273 /* Force redisplay of this tty. */
2274 FRAME_TTY (f
)->previous_frame
= NULL
;
2276 /* Update the frame parameter alist. */
2277 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2278 if (EQ (old_alist_elt
, Qnil
))
2279 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2281 Fsetcdr (old_alist_elt
, val
);
2283 /* Update some other special parameters in their special places
2284 in addition to the alist. */
2286 if (EQ (prop
, Qbuffer_predicate
))
2287 f
->buffer_predicate
= val
;
2289 if (! FRAME_WINDOW_P (f
))
2291 if (EQ (prop
, Qmenu_bar_lines
))
2292 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2293 else if (EQ (prop
, Qname
))
2294 set_term_frame_name (f
, val
);
2297 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2299 if (! MINI_WINDOW_P (XWINDOW (val
)))
2300 error ("Surrogate minibuffer windows must be minibuffer windows");
2302 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2303 && !EQ (val
, f
->minibuffer_window
))
2304 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2306 /* Install the chosen minibuffer window, with proper buffer. */
2307 f
->minibuffer_window
= val
;
2311 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2312 doc
: /* Return the parameters-alist of frame FRAME.
2313 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2314 The meaningful PARMs depend on the kind of frame.
2315 If FRAME is omitted, return information on the currently selected frame. */)
2321 struct gcpro gcpro1
;
2324 frame
= selected_frame
;
2326 CHECK_FRAME (frame
);
2329 if (!FRAME_LIVE_P (f
))
2332 alist
= Fcopy_alist (f
->param_alist
);
2335 if (!FRAME_WINDOW_P (f
))
2337 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2338 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2341 /* If the frame's parameter alist says the colors are
2342 unspecified and reversed, take the frame's background pixel
2343 for foreground and vice versa. */
2344 elt
= Fassq (Qforeground_color
, alist
);
2345 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2347 if (strncmp (SDATA (XCDR (elt
)),
2349 SCHARS (XCDR (elt
))) == 0)
2350 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2351 else if (strncmp (SDATA (XCDR (elt
)),
2353 SCHARS (XCDR (elt
))) == 0)
2354 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2357 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2358 elt
= Fassq (Qbackground_color
, alist
);
2359 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2361 if (strncmp (SDATA (XCDR (elt
)),
2363 SCHARS (XCDR (elt
))) == 0)
2364 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2365 else if (strncmp (SDATA (XCDR (elt
)),
2367 SCHARS (XCDR (elt
))) == 0)
2368 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2371 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2372 store_in_alist (&alist
, intern ("font"),
2373 build_string (FRAME_MSDOS_P (f
)
2375 : FRAME_W32_P (f
) ? "w32term"
2378 store_in_alist (&alist
, Qname
, f
->name
);
2379 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2380 store_in_alist (&alist
, Qheight
, make_number (height
));
2381 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2382 store_in_alist (&alist
, Qwidth
, make_number (width
));
2383 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2384 store_in_alist (&alist
, Qminibuffer
,
2385 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2386 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2387 : FRAME_MINIBUF_WINDOW (f
)));
2388 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2389 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2390 store_in_alist (&alist
, Qburied_buffer_list
, XFRAME (frame
)->buried_buffer_list
);
2392 /* I think this should be done with a hook. */
2393 #ifdef HAVE_WINDOW_SYSTEM
2394 if (FRAME_WINDOW_P (f
))
2395 x_report_frame_params (f
, &alist
);
2399 /* This ought to be correct in f->param_alist for an X frame. */
2401 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2402 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2410 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2411 doc
: /* Return FRAME's value for parameter PARAMETER.
2412 If FRAME is nil, describe the currently selected frame. */)
2413 (Lisp_Object frame
, Lisp_Object parameter
)
2419 frame
= selected_frame
;
2421 CHECK_FRAME (frame
);
2422 CHECK_SYMBOL (parameter
);
2427 if (FRAME_LIVE_P (f
))
2429 /* Avoid consing in frequent cases. */
2430 if (EQ (parameter
, Qname
))
2432 #ifdef HAVE_X_WINDOWS
2433 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2434 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2435 #endif /* HAVE_X_WINDOWS */
2436 else if (EQ (parameter
, Qbackground_color
)
2437 || EQ (parameter
, Qforeground_color
))
2439 value
= Fassq (parameter
, f
->param_alist
);
2442 value
= XCDR (value
);
2443 /* Fframe_parameters puts the actual fg/bg color names,
2444 even if f->param_alist says otherwise. This is
2445 important when param_alist's notion of colors is
2446 "unspecified". We need to do the same here. */
2447 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2449 const char *color_name
;
2452 if (EQ (parameter
, Qbackground_color
))
2454 color_name
= SDATA (value
);
2455 csz
= SCHARS (value
);
2456 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2457 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2458 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2459 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2461 else if (EQ (parameter
, Qforeground_color
))
2463 color_name
= SDATA (value
);
2464 csz
= SCHARS (value
);
2465 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2466 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2467 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2468 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2473 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2475 else if (EQ (parameter
, Qdisplay_type
)
2476 || EQ (parameter
, Qbackground_mode
))
2477 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2479 /* FIXME: Avoid this code path at all (as well as code duplication)
2480 by sharing more code with Fframe_parameters. */
2481 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2488 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2489 Smodify_frame_parameters
, 2, 2, 0,
2490 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2491 If FRAME is nil, it defaults to the selected frame.
2492 ALIST is an alist of parameters to change and their new values.
2493 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2494 The meaningful PARMs depend on the kind of frame.
2495 Undefined PARMs are ignored, but stored in the frame's parameter list
2496 so that `frame-parameters' will return them.
2498 The value of frame parameter FOO can also be accessed
2499 as a frame-local binding for the variable FOO, if you have
2500 enabled such bindings for that variable with `make-variable-frame-local'.
2501 Note that this functionality is obsolete as of Emacs 22.2, and its
2502 use is not recommended. Explicitly check for a frame-parameter instead. */)
2503 (Lisp_Object frame
, Lisp_Object alist
)
2506 register Lisp_Object tail
, prop
, val
;
2508 if (EQ (frame
, Qnil
))
2509 frame
= selected_frame
;
2510 CHECK_LIVE_FRAME (frame
);
2513 /* I think this should be done with a hook. */
2514 #ifdef HAVE_WINDOW_SYSTEM
2515 if (FRAME_WINDOW_P (f
))
2516 x_set_frame_parameters (f
, alist
);
2520 if (FRAME_MSDOS_P (f
))
2521 IT_set_frame_parameters (f
, alist
);
2526 int length
= XINT (Flength (alist
));
2529 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2531 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2533 /* Extract parm names and values into those vectors. */
2536 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2541 parms
[i
] = Fcar (elt
);
2542 values
[i
] = Fcdr (elt
);
2546 /* Now process them in reverse of specified order. */
2547 for (i
--; i
>= 0; i
--)
2551 store_frame_param (f
, prop
, val
);
2553 /* Changing the background color might change the background
2554 mode, so that we have to load new defface specs.
2555 Call frame-set-background-mode to do that. */
2556 if (EQ (prop
, Qbackground_color
))
2557 call1 (Qframe_set_background_mode
, frame
);
2563 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2565 doc
: /* Height in pixels of a line in the font in frame FRAME.
2566 If FRAME is omitted, the selected frame is used.
2567 For a terminal frame, the value is always 1. */)
2573 frame
= selected_frame
;
2574 CHECK_FRAME (frame
);
2577 #ifdef HAVE_WINDOW_SYSTEM
2578 if (FRAME_WINDOW_P (f
))
2579 return make_number (x_char_height (f
));
2582 return make_number (1);
2586 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2588 doc
: /* Width in pixels of characters in the font in frame FRAME.
2589 If FRAME is omitted, the selected frame is used.
2590 On a graphical screen, the width is the standard width of the default font.
2591 For a terminal screen, the value is always 1. */)
2597 frame
= selected_frame
;
2598 CHECK_FRAME (frame
);
2601 #ifdef HAVE_WINDOW_SYSTEM
2602 if (FRAME_WINDOW_P (f
))
2603 return make_number (x_char_width (f
));
2606 return make_number (1);
2609 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2610 Sframe_pixel_height
, 0, 1, 0,
2611 doc
: /* Return a FRAME's height in pixels.
2612 If FRAME is omitted, the selected frame is used. The exact value
2613 of the result depends on the window-system and toolkit in use:
2615 In the Gtk+ version of Emacs, it includes only any window (including
2616 the minibuffer or eacho area), mode line, and header line. It does not
2617 include the tool bar or menu bar.
2619 With the Motif or Lucid toolkits, it also includes the tool bar (but
2622 In a graphical version with no toolkit, it includes both the tool bar
2625 For a text-only terminal, it includes the menu bar. In this case, the
2626 result is really in characters rather than pixels (i.e., is identical
2627 to `frame-height'). */)
2633 frame
= selected_frame
;
2634 CHECK_FRAME (frame
);
2637 #ifdef HAVE_WINDOW_SYSTEM
2638 if (FRAME_WINDOW_P (f
))
2639 return make_number (x_pixel_height (f
));
2642 return make_number (FRAME_LINES (f
));
2645 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2646 Sframe_pixel_width
, 0, 1, 0,
2647 doc
: /* Return FRAME's width in pixels.
2648 For a terminal frame, the result really gives the width in characters.
2649 If FRAME is omitted, the selected frame is used. */)
2655 frame
= selected_frame
;
2656 CHECK_FRAME (frame
);
2659 #ifdef HAVE_WINDOW_SYSTEM
2660 if (FRAME_WINDOW_P (f
))
2661 return make_number (x_pixel_width (f
));
2664 return make_number (FRAME_COLS (f
));
2667 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2668 doc
: /* Specify that the frame FRAME has LINES lines.
2669 Optional third arg non-nil means that redisplay should use LINES lines
2670 but that the idea of the actual height of the frame should not be changed. */)
2671 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2673 register struct frame
*f
;
2675 CHECK_NUMBER (lines
);
2677 frame
= selected_frame
;
2678 CHECK_LIVE_FRAME (frame
);
2681 /* I think this should be done with a hook. */
2682 #ifdef HAVE_WINDOW_SYSTEM
2683 if (FRAME_WINDOW_P (f
))
2685 if (XINT (lines
) != FRAME_LINES (f
))
2686 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2687 do_pending_window_change (0);
2691 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2695 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2696 doc
: /* Specify that the frame FRAME has COLS columns.
2697 Optional third arg non-nil means that redisplay should use COLS columns
2698 but that the idea of the actual width of the frame should not be changed. */)
2699 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2701 register struct frame
*f
;
2702 CHECK_NUMBER (cols
);
2704 frame
= selected_frame
;
2705 CHECK_LIVE_FRAME (frame
);
2708 /* I think this should be done with a hook. */
2709 #ifdef HAVE_WINDOW_SYSTEM
2710 if (FRAME_WINDOW_P (f
))
2712 if (XINT (cols
) != FRAME_COLS (f
))
2713 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2714 do_pending_window_change (0);
2718 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2722 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2723 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2724 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2726 register struct frame
*f
;
2728 CHECK_LIVE_FRAME (frame
);
2729 CHECK_NUMBER (cols
);
2730 CHECK_NUMBER (rows
);
2733 /* I think this should be done with a hook. */
2734 #ifdef HAVE_WINDOW_SYSTEM
2735 if (FRAME_WINDOW_P (f
))
2737 if (XINT (rows
) != FRAME_LINES (f
)
2738 || XINT (cols
) != FRAME_COLS (f
)
2739 || f
->new_text_lines
|| f
->new_text_cols
)
2740 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2741 do_pending_window_change (0);
2745 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2750 DEFUN ("set-frame-position", Fset_frame_position
,
2751 Sset_frame_position
, 3, 3, 0,
2752 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2753 This is actually the position of the upper left corner of the frame.
2754 Negative values for XOFFSET or YOFFSET are interpreted relative to
2755 the rightmost or bottommost possible position (that stays within the screen). */)
2756 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2758 register struct frame
*f
;
2760 CHECK_LIVE_FRAME (frame
);
2761 CHECK_NUMBER (xoffset
);
2762 CHECK_NUMBER (yoffset
);
2765 /* I think this should be done with a hook. */
2766 #ifdef HAVE_WINDOW_SYSTEM
2767 if (FRAME_WINDOW_P (f
))
2768 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2775 /***********************************************************************
2777 ***********************************************************************/
2779 /* Connect the frame-parameter names for X frames
2780 to the ways of passing the parameter values to the window system.
2782 The name of a parameter, as a Lisp symbol,
2783 has an `x-frame-parameter' property which is an integer in Lisp
2784 that is an index in this table. */
2786 struct frame_parm_table
{
2788 Lisp_Object
*variable
;
2791 static struct frame_parm_table frame_parms
[] =
2793 {"auto-raise", &Qauto_raise
},
2794 {"auto-lower", &Qauto_lower
},
2795 {"background-color", 0},
2796 {"border-color", &Qborder_color
},
2797 {"border-width", &Qborder_width
},
2798 {"cursor-color", &Qcursor_color
},
2799 {"cursor-type", &Qcursor_type
},
2801 {"foreground-color", 0},
2802 {"icon-name", &Qicon_name
},
2803 {"icon-type", &Qicon_type
},
2804 {"internal-border-width", &Qinternal_border_width
},
2805 {"menu-bar-lines", &Qmenu_bar_lines
},
2806 {"mouse-color", &Qmouse_color
},
2808 {"scroll-bar-width", &Qscroll_bar_width
},
2810 {"unsplittable", &Qunsplittable
},
2811 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2812 {"visibility", &Qvisibility
},
2813 {"tool-bar-lines", &Qtool_bar_lines
},
2814 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2815 {"scroll-bar-background", &Qscroll_bar_background
},
2816 {"screen-gamma", &Qscreen_gamma
},
2817 {"line-spacing", &Qline_spacing
},
2818 {"left-fringe", &Qleft_fringe
},
2819 {"right-fringe", &Qright_fringe
},
2820 {"wait-for-wm", &Qwait_for_wm
},
2821 {"fullscreen", &Qfullscreen
},
2822 {"font-backend", &Qfont_backend
},
2824 {"sticky", &Qsticky
},
2827 #ifdef HAVE_WINDOW_SYSTEM
2829 extern Lisp_Object Qbox
;
2830 extern Lisp_Object Qtop
;
2832 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2833 wanted positions of the WM window (not Emacs window).
2834 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2835 window (FRAME_X_WINDOW).
2839 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2841 int newwidth
= FRAME_COLS (f
);
2842 int newheight
= FRAME_LINES (f
);
2843 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2845 *top_pos
= f
->top_pos
;
2846 *left_pos
= f
->left_pos
;
2848 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2852 ph
= x_display_pixel_height (dpyinfo
);
2853 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2854 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2855 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2859 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2863 pw
= x_display_pixel_width (dpyinfo
);
2864 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2865 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2866 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2871 *height
= newheight
;
2875 /* Change the parameters of frame F as specified by ALIST.
2876 If a parameter is not specially recognized, do nothing special;
2877 otherwise call the `x_set_...' function for that parameter.
2878 Except for certain geometry properties, always call store_frame_param
2879 to store the new value in the parameter alist. */
2882 x_set_frame_parameters (FRAME_PTR f
, Lisp_Object alist
)
2886 /* If both of these parameters are present, it's more efficient to
2887 set them both at once. So we wait until we've looked at the
2888 entire list before we set them. */
2892 Lisp_Object left
, top
;
2894 /* Same with these. */
2895 Lisp_Object icon_left
, icon_top
;
2897 /* Record in these vectors all the parms specified. */
2899 Lisp_Object
*values
;
2901 int left_no_change
= 0, top_no_change
= 0;
2902 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2903 int size_changed
= 0;
2904 struct gcpro gcpro1
, gcpro2
;
2907 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2910 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2911 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2913 /* Extract parm names and values into those vectors. */
2916 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2921 parms
[i
] = Fcar (elt
);
2922 values
[i
] = Fcdr (elt
);
2925 /* TAIL and ALIST are not used again below here. */
2926 alist
= tail
= Qnil
;
2928 GCPRO2 (*parms
, *values
);
2932 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2933 because their values appear in VALUES and strings are not valid. */
2934 top
= left
= Qunbound
;
2935 icon_left
= icon_top
= Qunbound
;
2937 /* Provide default values for HEIGHT and WIDTH. */
2938 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2939 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2941 /* Process foreground_color and background_color before anything else.
2942 They are independent of other properties, but other properties (e.g.,
2943 cursor_color) are dependent upon them. */
2944 /* Process default font as well, since fringe widths depends on it. */
2945 for (p
= 0; p
< i
; p
++)
2947 Lisp_Object prop
, val
;
2951 if (EQ (prop
, Qforeground_color
)
2952 || EQ (prop
, Qbackground_color
)
2953 || EQ (prop
, Qfont
))
2955 register Lisp_Object param_index
, old_value
;
2957 old_value
= get_frame_param (f
, prop
);
2958 if (NILP (Fequal (val
, old_value
)))
2960 store_frame_param (f
, prop
, val
);
2962 param_index
= Fget (prop
, Qx_frame_parameter
);
2963 if (NATNUMP (param_index
)
2964 && (XFASTINT (param_index
)
2965 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2966 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2967 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2972 /* Now process them in reverse of specified order. */
2973 for (i
--; i
>= 0; i
--)
2975 Lisp_Object prop
, val
;
2980 if (EQ (prop
, Qwidth
) && NATNUMP (val
))
2983 width
= XFASTINT (val
);
2985 else if (EQ (prop
, Qheight
) && NATNUMP (val
))
2988 height
= XFASTINT (val
);
2990 else if (EQ (prop
, Qtop
))
2992 else if (EQ (prop
, Qleft
))
2994 else if (EQ (prop
, Qicon_top
))
2996 else if (EQ (prop
, Qicon_left
))
2998 else if (EQ (prop
, Qforeground_color
)
2999 || EQ (prop
, Qbackground_color
)
3000 || EQ (prop
, Qfont
))
3001 /* Processed above. */
3005 register Lisp_Object param_index
, old_value
;
3007 old_value
= get_frame_param (f
, prop
);
3009 store_frame_param (f
, prop
, val
);
3011 param_index
= Fget (prop
, Qx_frame_parameter
);
3012 if (NATNUMP (param_index
)
3013 && (XFASTINT (param_index
)
3014 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3015 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3016 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3020 /* Don't die if just one of these was set. */
3021 if (EQ (left
, Qunbound
))
3024 if (f
->left_pos
< 0)
3025 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
3027 XSETINT (left
, f
->left_pos
);
3029 if (EQ (top
, Qunbound
))
3033 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
3035 XSETINT (top
, f
->top_pos
);
3038 /* If one of the icon positions was not set, preserve or default it. */
3039 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
3041 icon_left_no_change
= 1;
3042 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3043 if (NILP (icon_left
))
3044 XSETINT (icon_left
, 0);
3046 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
3048 icon_top_no_change
= 1;
3049 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3050 if (NILP (icon_top
))
3051 XSETINT (icon_top
, 0);
3054 /* Don't set these parameters unless they've been explicitly
3055 specified. The window might be mapped or resized while we're in
3056 this function, and we don't want to override that unless the lisp
3057 code has asked for it.
3059 Don't set these parameters unless they actually differ from the
3060 window's current parameters; the window may not actually exist
3065 check_frame_size (f
, &height
, &width
);
3067 XSETFRAME (frame
, f
);
3070 && (width
!= FRAME_COLS (f
)
3071 || height
!= FRAME_LINES (f
)
3072 || f
->new_text_lines
|| f
->new_text_cols
))
3073 Fset_frame_size (frame
, make_number (width
), make_number (height
));
3075 if ((!NILP (left
) || !NILP (top
))
3076 && ! (left_no_change
&& top_no_change
)
3077 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3078 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3083 /* Record the signs. */
3084 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3085 if (EQ (left
, Qminus
))
3086 f
->size_hint_flags
|= XNegative
;
3087 else if (INTEGERP (left
))
3089 leftpos
= XINT (left
);
3091 f
->size_hint_flags
|= XNegative
;
3093 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3094 && CONSP (XCDR (left
))
3095 && INTEGERP (XCAR (XCDR (left
))))
3097 leftpos
= - XINT (XCAR (XCDR (left
)));
3098 f
->size_hint_flags
|= XNegative
;
3100 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3101 && CONSP (XCDR (left
))
3102 && INTEGERP (XCAR (XCDR (left
))))
3104 leftpos
= XINT (XCAR (XCDR (left
)));
3107 if (EQ (top
, Qminus
))
3108 f
->size_hint_flags
|= YNegative
;
3109 else if (INTEGERP (top
))
3111 toppos
= XINT (top
);
3113 f
->size_hint_flags
|= YNegative
;
3115 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3116 && CONSP (XCDR (top
))
3117 && INTEGERP (XCAR (XCDR (top
))))
3119 toppos
= - XINT (XCAR (XCDR (top
)));
3120 f
->size_hint_flags
|= YNegative
;
3122 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
3123 && CONSP (XCDR (top
))
3124 && INTEGERP (XCAR (XCDR (top
))))
3126 toppos
= XINT (XCAR (XCDR (top
)));
3130 /* Store the numeric value of the position. */
3131 f
->top_pos
= toppos
;
3132 f
->left_pos
= leftpos
;
3134 f
->win_gravity
= NorthWestGravity
;
3136 /* Actually set that position, and convert to absolute. */
3137 x_set_offset (f
, leftpos
, toppos
, -1);
3140 if ((!NILP (icon_left
) || !NILP (icon_top
))
3141 && ! (icon_left_no_change
&& icon_top_no_change
))
3142 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3149 /* Insert a description of internally-recorded parameters of frame X
3150 into the parameter alist *ALISTPTR that is to be given to the user.
3151 Only parameters that are specific to the X window system
3152 and whose values are not correctly recorded in the frame's
3153 param_alist need to be considered here. */
3156 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3161 /* Represent negative positions (off the top or left screen edge)
3162 in a way that Fmodify_frame_parameters will understand correctly. */
3163 XSETINT (tem
, f
->left_pos
);
3164 if (f
->left_pos
>= 0)
3165 store_in_alist (alistptr
, Qleft
, tem
);
3167 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3169 XSETINT (tem
, f
->top_pos
);
3170 if (f
->top_pos
>= 0)
3171 store_in_alist (alistptr
, Qtop
, tem
);
3173 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3175 store_in_alist (alistptr
, Qborder_width
,
3176 make_number (f
->border_width
));
3177 store_in_alist (alistptr
, Qinternal_border_width
,
3178 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3179 store_in_alist (alistptr
, Qleft_fringe
,
3180 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3181 store_in_alist (alistptr
, Qright_fringe
,
3182 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3183 store_in_alist (alistptr
, Qscroll_bar_width
,
3184 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3186 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3187 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3188 /* nil means "use default width"
3189 for non-toolkit scroll bar.
3190 ruler-mode.el depends on this. */
3192 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
3193 store_in_alist (alistptr
, Qwindow_id
,
3194 build_string (buf
));
3195 #ifdef HAVE_X_WINDOWS
3196 #ifdef USE_X_TOOLKIT
3197 /* Tooltip frame may not have this widget. */
3198 if (FRAME_X_OUTPUT (f
)->widget
)
3200 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
3201 store_in_alist (alistptr
, Qouter_window_id
,
3202 build_string (buf
));
3204 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3205 FRAME_SAMPLE_VISIBILITY (f
);
3206 store_in_alist (alistptr
, Qvisibility
,
3207 (FRAME_VISIBLE_P (f
) ? Qt
3208 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3209 store_in_alist (alistptr
, Qdisplay
,
3210 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3212 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3215 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3216 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3217 store_in_alist (alistptr
, Qparent_id
, tem
);
3221 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3222 the previous value of that parameter, NEW_VALUE is the new value. */
3225 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3227 if (NILP (new_value
))
3228 f
->want_fullscreen
= FULLSCREEN_NONE
;
3229 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3230 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3231 else if (EQ (new_value
, Qfullwidth
))
3232 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3233 else if (EQ (new_value
, Qfullheight
))
3234 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3235 else if (EQ (new_value
, Qmaximized
))
3236 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3238 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3239 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3243 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3244 the previous value of that parameter, NEW_VALUE is the new value. */
3247 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3249 if (NILP (new_value
))
3250 f
->extra_line_spacing
= 0;
3251 else if (NATNUMP (new_value
))
3252 f
->extra_line_spacing
= XFASTINT (new_value
);
3254 signal_error ("Invalid line-spacing", new_value
);
3255 if (FRAME_VISIBLE_P (f
))
3260 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3261 the previous value of that parameter, NEW_VALUE is the new value. */
3264 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3266 Lisp_Object bgcolor
;
3268 if (NILP (new_value
))
3270 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3271 /* The value 0.4545 is the normal viewing gamma. */
3272 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3274 signal_error ("Invalid screen-gamma", new_value
);
3276 /* Apply the new gamma value to the frame background. */
3277 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3278 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3280 Lisp_Object index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3282 && (XFASTINT (index
)
3283 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3284 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3285 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3289 Fclear_face_cache (Qnil
);
3294 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3296 Lisp_Object frame
, font_object
, font_param
= Qnil
;
3299 /* Set the frame parameter back to the old value because we may
3300 fail to use ARG as the new parameter value. */
3301 store_frame_param (f
, Qfont
, oldval
);
3303 /* ARG is a fontset name, a font name, a cons of fontset name and a
3304 font object, or a font object. In the last case, this function
3309 fontset
= fs_query_fontset (arg
, 0);
3312 font_object
= font_open_by_name (f
, SDATA (arg
));
3313 if (NILP (font_object
))
3314 error ("Font `%s' is not defined", SDATA (arg
));
3315 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3317 else if (fontset
> 0)
3319 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3321 font_object
= font_open_by_name (f
, SDATA (ascii_font
));
3322 if (NILP (font_object
))
3323 error ("Font `%s' is not defined", SDATA (arg
));
3324 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3327 error ("The default fontset can't be used for a frame font");
3329 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3331 /* This is the case that the ASCII font of F's fontset XCAR
3332 (arg) is changed to the font XCDR (arg) by
3333 `set-fontset-font'. */
3334 fontset
= fs_query_fontset (XCAR (arg
), 0);
3336 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3337 font_object
= XCDR (arg
);
3338 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3339 font_param
= Ffont_get (font_object
, QCname
);
3341 else if (FONT_OBJECT_P (arg
))
3344 font_param
= Ffont_get (font_object
, QCname
);
3345 /* This is to store the XLFD font name in the frame parameter for
3346 backward compatibility. We should store the font-object
3347 itself in the future. */
3348 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3349 fontset
= FRAME_FONTSET (f
);
3350 /* Check if we can use the current fontset. If not, set FONTSET
3351 to -1 to generate a new fontset from FONT-OBJECT. */
3354 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3355 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3357 if (! font_match_p (spec
, font_object
))
3362 signal_error ("Invalid font", arg
);
3364 if (! NILP (Fequal (font_object
, oldval
)))
3367 x_new_font (f
, font_object
, fontset
);
3368 store_frame_param (f
, Qfont
, arg
);
3369 #ifdef HAVE_X_WINDOWS
3370 store_frame_param (f
, Qfont_param
, font_param
);
3372 /* Recalculate toolbar height. */
3373 f
->n_tool_bar_rows
= 0;
3374 /* Ensure we redraw it. */
3375 clear_current_matrices (f
);
3377 recompute_basic_faces (f
);
3379 do_pending_window_change (0);
3381 /* We used to call face-set-after-frame-default here, but it leads to
3382 recursive calls (since that function can set the `default' face's
3383 font which in turns changes the frame's `font' parameter).
3384 Also I don't know what this call is meant to do, but it seems the
3385 wrong way to do it anyway (it does a lot more work than what seems
3386 reasonable in response to a change to `font'). */
3391 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3393 if (! NILP (new_value
)
3394 && !CONSP (new_value
))
3398 CHECK_STRING (new_value
);
3399 p0
= p1
= SDATA (new_value
);
3403 while (*p1
&& ! isspace (*p1
) && *p1
!= ',') p1
++;
3405 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3411 while ((c
= *++p1
) && isspace (c
));
3415 new_value
= Fnreverse (new_value
);
3418 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3422 free_all_realized_faces (Qnil
);
3424 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3425 if (NILP (new_value
))
3427 if (NILP (old_value
))
3428 error ("No font backend available");
3429 font_update_drivers (f
, old_value
);
3430 error ("None of specified font backends are available");
3432 store_frame_param (f
, Qfont_backend
, new_value
);
3438 XSETFRAME (frame
, f
);
3439 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3440 ++face_change_count
;
3441 ++windows_or_buffers_changed
;
3447 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3449 compute_fringe_widths (f
, 1);
3453 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3457 if (XINT (arg
) == f
->border_width
)
3460 if (FRAME_X_WINDOW (f
) != 0)
3461 error ("Cannot change the border width of a frame");
3463 f
->border_width
= XINT (arg
);
3467 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3469 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3472 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3473 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3474 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3476 #ifdef USE_X_TOOLKIT
3477 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3478 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3481 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3484 if (FRAME_X_WINDOW (f
) != 0)
3486 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3487 SET_FRAME_GARBAGED (f
);
3488 do_pending_window_change (0);
3491 SET_FRAME_GARBAGED (f
);
3495 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3498 XSETFRAME (frame
, f
);
3501 Fmake_frame_invisible (frame
, Qt
);
3502 else if (EQ (value
, Qicon
))
3503 Ficonify_frame (frame
);
3505 Fmake_frame_visible (frame
);
3509 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3511 f
->auto_raise
= !EQ (Qnil
, arg
);
3515 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3517 f
->auto_lower
= !EQ (Qnil
, arg
);
3521 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3523 f
->no_split
= !NILP (arg
);
3527 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3529 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3530 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3531 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3532 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3534 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3536 ? vertical_scroll_bar_none
3538 ? vertical_scroll_bar_left
3540 ? vertical_scroll_bar_right
3541 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3542 ? vertical_scroll_bar_left
3543 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3544 ? vertical_scroll_bar_right
3545 : vertical_scroll_bar_none
);
3547 /* We set this parameter before creating the X window for the
3548 frame, so we can get the geometry right from the start.
3549 However, if the window hasn't been created yet, we shouldn't
3550 call x_set_window_size. */
3551 if (FRAME_X_WINDOW (f
))
3552 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3553 do_pending_window_change (0);
3558 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3560 int wid
= FRAME_COLUMN_WIDTH (f
);
3564 x_set_scroll_bar_default_width (f
);
3566 if (FRAME_X_WINDOW (f
))
3567 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3568 do_pending_window_change (0);
3570 else if (INTEGERP (arg
) && XINT (arg
) > 0
3571 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3573 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3574 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3576 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3577 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3578 if (FRAME_X_WINDOW (f
))
3579 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3580 do_pending_window_change (0);
3583 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3584 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3585 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3590 /* Return non-nil if frame F wants a bitmap icon. */
3593 x_icon_type (FRAME_PTR f
)
3597 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3605 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3612 for (i
= 0; i
< 2; i
++)
3625 else if (FLOATP (item
))
3627 alpha
= XFLOAT_DATA (item
);
3628 if (alpha
< 0.0 || 1.0 < alpha
)
3629 args_out_of_range (make_float (0.0), make_float (1.0));
3631 else if (INTEGERP (item
))
3633 ialpha
= XINT (item
);
3634 if (ialpha
< 0 || 100 < ialpha
)
3635 args_out_of_range (make_number (0), make_number (100));
3637 alpha
= ialpha
/ 100.0;
3640 wrong_type_argument (Qnumberp
, item
);
3644 for (i
= 0; i
< 2; i
++)
3645 f
->alpha
[i
] = newval
[i
];
3647 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3649 x_set_frame_alpha (f
);
3657 /* Subroutines of creating an X frame. */
3659 /* Make sure that Vx_resource_name is set to a reasonable value.
3660 Fix it up, or set it to `emacs' if it is too hopeless. */
3663 validate_x_resource_name (void)
3666 /* Number of valid characters in the resource name. */
3668 /* Number of invalid characters in the resource name. */
3673 if (!STRINGP (Vx_resource_class
))
3674 Vx_resource_class
= build_string (EMACS_CLASS
);
3676 if (STRINGP (Vx_resource_name
))
3678 unsigned char *p
= SDATA (Vx_resource_name
);
3681 len
= SBYTES (Vx_resource_name
);
3683 /* Only letters, digits, - and _ are valid in resource names.
3684 Count the valid characters and count the invalid ones. */
3685 for (i
= 0; i
< len
; i
++)
3688 if (! ((c
>= 'a' && c
<= 'z')
3689 || (c
>= 'A' && c
<= 'Z')
3690 || (c
>= '0' && c
<= '9')
3691 || c
== '-' || c
== '_'))
3698 /* Not a string => completely invalid. */
3699 bad_count
= 5, good_count
= 0;
3701 /* If name is valid already, return. */
3705 /* If name is entirely invalid, or nearly so, use `emacs'. */
3707 || (good_count
== 1 && bad_count
> 0))
3709 Vx_resource_name
= build_string ("emacs");
3713 /* Name is partly valid. Copy it and replace the invalid characters
3714 with underscores. */
3716 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3718 for (i
= 0; i
< len
; i
++)
3720 int c
= SREF (new, i
);
3721 if (! ((c
>= 'a' && c
<= 'z')
3722 || (c
>= 'A' && c
<= 'Z')
3723 || (c
>= '0' && c
<= '9')
3724 || c
== '-' || c
== '_'))
3730 extern char *x_get_string_resource (XrmDatabase
, char *, char *);
3731 extern Display_Info
*check_x_display_info (Lisp_Object
);
3734 /* Get specified attribute from resource database RDB.
3735 See Fx_get_resource below for other parameters. */
3738 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3740 register char *value
;
3744 CHECK_STRING (attribute
);
3745 CHECK_STRING (class);
3747 if (!NILP (component
))
3748 CHECK_STRING (component
);
3749 if (!NILP (subclass
))
3750 CHECK_STRING (subclass
);
3751 if (NILP (component
) != NILP (subclass
))
3752 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3754 validate_x_resource_name ();
3756 /* Allocate space for the components, the dots which separate them,
3757 and the final '\0'. Make them big enough for the worst case. */
3758 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3759 + (STRINGP (component
)
3760 ? SBYTES (component
) : 0)
3761 + SBYTES (attribute
)
3764 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3766 + (STRINGP (subclass
)
3767 ? SBYTES (subclass
) : 0)
3770 /* Start with emacs.FRAMENAME for the name (the specific one)
3771 and with `Emacs' for the class key (the general one). */
3772 strcpy (name_key
, SDATA (Vx_resource_name
));
3773 strcpy (class_key
, SDATA (Vx_resource_class
));
3775 strcat (class_key
, ".");
3776 strcat (class_key
, SDATA (class));
3778 if (!NILP (component
))
3780 strcat (class_key
, ".");
3781 strcat (class_key
, SDATA (subclass
));
3783 strcat (name_key
, ".");
3784 strcat (name_key
, SDATA (component
));
3787 strcat (name_key
, ".");
3788 strcat (name_key
, SDATA (attribute
));
3790 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3792 if (value
!= (char *) 0 && *value
)
3793 return build_string (value
);
3799 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3800 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3801 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3802 class, where INSTANCE is the name under which Emacs was invoked, or
3803 the name specified by the `-name' or `-rn' command-line arguments.
3805 The optional arguments COMPONENT and SUBCLASS add to the key and the
3806 class, respectively. You must specify both of them or neither.
3807 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3808 and the class is `Emacs.CLASS.SUBCLASS'. */)
3809 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3811 #ifdef HAVE_X_WINDOWS
3815 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3816 attribute
, class, component
, subclass
);
3819 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3822 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3824 return xrdb_get_resource (dpyinfo
->xrdb
,
3825 attribute
, class, component
, subclass
);
3828 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3829 /* Used when C code wants a resource value. */
3830 /* Called from oldXMenu/Create.c. */
3832 x_get_resource_string (char *attribute
, char *class)
3836 struct frame
*sf
= SELECTED_FRAME ();
3838 /* Allocate space for the components, the dots which separate them,
3839 and the final '\0'. */
3840 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3841 + strlen (attribute
) + 2);
3842 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3843 + strlen (class) + 2);
3845 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3846 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3848 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3849 name_key
, class_key
);
3853 /* Return the value of parameter PARAM.
3855 First search ALIST, then Vdefault_frame_alist, then the X defaults
3856 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3858 Convert the resource to the type specified by desired_type.
3860 If no default is specified, return Qunbound. If you call
3861 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3862 and don't let it get stored in any Lisp-visible variables! */
3865 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
, char *attribute
, char *class, enum resource_types type
)
3867 register Lisp_Object tem
;
3869 tem
= Fassq (param
, alist
);
3873 /* If we find this parm in ALIST, clear it out
3874 so that it won't be "left over" at the end. */
3876 XSETCAR (tem
, Qnil
);
3877 /* In case the parameter appears more than once in the alist,
3879 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3880 if (CONSP (XCAR (tail
))
3881 && EQ (XCAR (XCAR (tail
)), param
))
3882 XSETCAR (XCAR (tail
), Qnil
);
3885 tem
= Fassq (param
, Vdefault_frame_alist
);
3887 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3888 look in the X resources. */
3891 if (attribute
&& dpyinfo
)
3893 tem
= display_x_get_resource (dpyinfo
,
3894 build_string (attribute
),
3895 build_string (class),
3903 case RES_TYPE_NUMBER
:
3904 return make_number (atoi (SDATA (tem
)));
3906 case RES_TYPE_BOOLEAN_NUMBER
:
3907 if (!strcmp (SDATA (tem
), "on")
3908 || !strcmp (SDATA (tem
), "true"))
3909 return make_number (1);
3910 return make_number (atoi (SDATA (tem
)));
3913 case RES_TYPE_FLOAT
:
3914 return make_float (atof (SDATA (tem
)));
3916 case RES_TYPE_BOOLEAN
:
3917 tem
= Fdowncase (tem
);
3918 if (!strcmp (SDATA (tem
), "on")
3920 || !strcmp(SDATA(tem
), "yes")
3922 || !strcmp (SDATA (tem
), "true"))
3927 case RES_TYPE_STRING
:
3930 case RES_TYPE_SYMBOL
:
3931 /* As a special case, we map the values `true' and `on'
3932 to Qt, and `false' and `off' to Qnil. */
3935 lower
= Fdowncase (tem
);
3936 if (!strcmp (SDATA (lower
), "on")
3938 || !strcmp(SDATA(lower
), "yes")
3940 || !strcmp (SDATA (lower
), "true"))
3942 else if (!strcmp (SDATA (lower
), "off")
3944 || !strcmp(SDATA(lower
), "no")
3946 || !strcmp (SDATA (lower
), "false"))
3949 return Fintern (tem
, Qnil
);
3963 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
, char *attribute
, char *class, enum resource_types type
)
3965 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3966 alist
, param
, attribute
, class, type
);
3969 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3972 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
, char *attribute
, char *class, 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
, Lisp_Object deflt
, char *xprop
, char *xclass
, enum resource_types type
)
3996 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3997 if (EQ (tem
, Qunbound
))
3999 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
4006 /* NS used to define x-parse-geometry in ns-win.el, but that confused
4007 make-docfile: the documentation string in ns-win.el was used for
4008 x-parse-geometry even in non-NS builds.
4010 With two definitions of x-parse-geometry in this file, various
4011 things still get confused (eg M-x apropos documentation), so that
4012 it is best if the two definitions just share the same doc-string.
4014 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4015 doc
: /* Parse a display geometry string STRING.
4016 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4017 The properties returned may include `top', `left', `height', and `width'.
4018 For X, the value of `left' or `top' may be an integer,
4019 or a list (+ N) meaning N pixels relative to top/left corner,
4020 or a list (- N) meaning -N pixels relative to bottom/right corner.
4021 On Nextstep, this just calls `ns-parse-geometry'. */)
4022 (Lisp_Object string
)
4025 call1 (Qns_parse_geometry
, string
);
4028 unsigned int width
, height
;
4031 CHECK_STRING (string
);
4033 geometry
= XParseGeometry ((char *) SDATA (string
),
4034 &x
, &y
, &width
, &height
);
4036 if (geometry
& XValue
)
4038 Lisp_Object element
;
4040 if (x
>= 0 && (geometry
& XNegative
))
4041 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
4042 else if (x
< 0 && ! (geometry
& XNegative
))
4043 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
4045 element
= Fcons (Qleft
, make_number (x
));
4046 result
= Fcons (element
, result
);
4049 if (geometry
& YValue
)
4051 Lisp_Object element
;
4053 if (y
>= 0 && (geometry
& YNegative
))
4054 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
4055 else if (y
< 0 && ! (geometry
& YNegative
))
4056 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
4058 element
= Fcons (Qtop
, make_number (y
));
4059 result
= Fcons (element
, result
);
4062 if (geometry
& WidthValue
)
4063 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
4064 if (geometry
& HeightValue
)
4065 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
4068 #endif /* HAVE_NS */
4072 /* Calculate the desired size and position of frame F.
4073 Return the flags saying which aspects were specified.
4075 Also set the win_gravity and size_hint_flags of F.
4077 Adjust height for toolbar if TOOLBAR_P is 1.
4079 This function does not make the coordinates positive. */
4081 #define DEFAULT_ROWS 35
4082 #define DEFAULT_COLS 80
4085 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, int toolbar_p
)
4087 register Lisp_Object tem0
, tem1
, tem2
;
4088 long window_prompting
= 0;
4089 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
4091 /* Default values if we fall through.
4092 Actually, if that happens we should get
4093 window manager prompting. */
4094 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4095 FRAME_LINES (f
) = DEFAULT_ROWS
;
4096 /* Window managers expect that if program-specified
4097 positions are not (0,0), they're intentional, not defaults. */
4101 /* Ensure that old new_text_cols and new_text_lines will not override the
4103 /* ++KFS: This was specific to W32, but seems ok for all platforms */
4104 f
->new_text_cols
= f
->new_text_lines
= 0;
4106 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4107 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4108 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4109 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4111 if (!EQ (tem0
, Qunbound
))
4113 CHECK_NUMBER (tem0
);
4114 FRAME_LINES (f
) = XINT (tem0
);
4116 if (!EQ (tem1
, Qunbound
))
4118 CHECK_NUMBER (tem1
);
4119 SET_FRAME_COLS (f
, XINT (tem1
));
4121 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4122 window_prompting
|= USSize
;
4124 window_prompting
|= PSize
;
4127 f
->scroll_bar_actual_width
4128 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4130 /* This used to be done _before_ calling x_figure_window_size, but
4131 since the height is reset here, this was really a no-op. I
4132 assume that moving it here does what Gerd intended (although he
4133 no longer can remember what that was... ++KFS, 2003-03-25. */
4135 /* Add the tool-bar height to the initial frame height so that the
4136 user gets a text display area of the size he specified with -g or
4137 via .Xdefaults. Later changes of the tool-bar height don't
4138 change the frame size. This is done so that users can create
4139 tall Emacs frames without having to guess how tall the tool-bar
4141 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4143 int margin
, relief
, bar_height
;
4145 relief
= (tool_bar_button_relief
>= 0
4146 ? tool_bar_button_relief
4147 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4149 if (INTEGERP (Vtool_bar_button_margin
)
4150 && XINT (Vtool_bar_button_margin
) > 0)
4151 margin
= XFASTINT (Vtool_bar_button_margin
);
4152 else if (CONSP (Vtool_bar_button_margin
)
4153 && INTEGERP (XCDR (Vtool_bar_button_margin
))
4154 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
4155 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4159 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4160 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4163 compute_fringe_widths (f
, 0);
4165 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4166 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4168 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4169 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4170 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4171 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4173 if (EQ (tem0
, Qminus
))
4176 window_prompting
|= YNegative
;
4178 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4179 && CONSP (XCDR (tem0
))
4180 && INTEGERP (XCAR (XCDR (tem0
))))
4182 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4183 window_prompting
|= YNegative
;
4185 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4186 && CONSP (XCDR (tem0
))
4187 && INTEGERP (XCAR (XCDR (tem0
))))
4189 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4191 else if (EQ (tem0
, Qunbound
))
4195 CHECK_NUMBER (tem0
);
4196 f
->top_pos
= XINT (tem0
);
4198 window_prompting
|= YNegative
;
4201 if (EQ (tem1
, Qminus
))
4204 window_prompting
|= XNegative
;
4206 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4207 && CONSP (XCDR (tem1
))
4208 && INTEGERP (XCAR (XCDR (tem1
))))
4210 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4211 window_prompting
|= XNegative
;
4213 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4214 && CONSP (XCDR (tem1
))
4215 && INTEGERP (XCAR (XCDR (tem1
))))
4217 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4219 else if (EQ (tem1
, Qunbound
))
4223 CHECK_NUMBER (tem1
);
4224 f
->left_pos
= XINT (tem1
);
4225 if (f
->left_pos
< 0)
4226 window_prompting
|= XNegative
;
4229 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4230 window_prompting
|= USPosition
;
4232 window_prompting
|= PPosition
;
4235 if (window_prompting
& XNegative
)
4237 if (window_prompting
& YNegative
)
4238 f
->win_gravity
= SouthEastGravity
;
4240 f
->win_gravity
= NorthEastGravity
;
4244 if (window_prompting
& YNegative
)
4245 f
->win_gravity
= SouthWestGravity
;
4247 f
->win_gravity
= NorthWestGravity
;
4250 f
->size_hint_flags
= window_prompting
;
4252 return window_prompting
;
4257 #endif /* HAVE_WINDOW_SYSTEM */
4260 frame_make_pointer_invisible (void)
4262 if (! NILP (Vmake_pointer_invisible
))
4265 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4268 f
= SELECTED_FRAME ();
4269 if (f
&& !f
->pointer_invisible
4270 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4273 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4274 f
->pointer_invisible
= 1;
4280 frame_make_pointer_visible (void)
4282 /* We don't check Vmake_pointer_invisible here in case the
4283 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4286 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4289 f
= SELECTED_FRAME ();
4290 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4291 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4293 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4294 f
->pointer_invisible
= 0;
4300 /***********************************************************************
4302 ***********************************************************************/
4305 syms_of_frame (void)
4307 Qframep
= intern_c_string ("framep");
4308 staticpro (&Qframep
);
4309 Qframe_live_p
= intern_c_string ("frame-live-p");
4310 staticpro (&Qframe_live_p
);
4311 Qexplicit_name
= intern_c_string ("explicit-name");
4312 staticpro (&Qexplicit_name
);
4313 Qheight
= intern_c_string ("height");
4314 staticpro (&Qheight
);
4315 Qicon
= intern_c_string ("icon");
4317 Qminibuffer
= intern_c_string ("minibuffer");
4318 staticpro (&Qminibuffer
);
4319 Qmodeline
= intern_c_string ("modeline");
4320 staticpro (&Qmodeline
);
4321 Qonly
= intern_c_string ("only");
4323 Qwidth
= intern_c_string ("width");
4324 staticpro (&Qwidth
);
4325 Qgeometry
= intern_c_string ("geometry");
4326 staticpro (&Qgeometry
);
4327 Qicon_left
= intern_c_string ("icon-left");
4328 staticpro (&Qicon_left
);
4329 Qicon_top
= intern_c_string ("icon-top");
4330 staticpro (&Qicon_top
);
4331 Qtooltip
= intern_c_string ("tooltip");
4332 staticpro (&Qtooltip
);
4333 Qleft
= intern_c_string ("left");
4335 Qright
= intern_c_string ("right");
4336 staticpro (&Qright
);
4337 Quser_position
= intern_c_string ("user-position");
4338 staticpro (&Quser_position
);
4339 Quser_size
= intern_c_string ("user-size");
4340 staticpro (&Quser_size
);
4341 Qwindow_id
= intern_c_string ("window-id");
4342 staticpro (&Qwindow_id
);
4343 #ifdef HAVE_X_WINDOWS
4344 Qouter_window_id
= intern_c_string ("outer-window-id");
4345 staticpro (&Qouter_window_id
);
4347 Qparent_id
= intern_c_string ("parent-id");
4348 staticpro (&Qparent_id
);
4349 Qx
= intern_c_string ("x");
4351 Qw32
= intern_c_string ("w32");
4353 Qpc
= intern_c_string ("pc");
4355 Qmac
= intern_c_string ("mac");
4357 Qns
= intern_c_string ("ns");
4359 Qvisible
= intern_c_string ("visible");
4360 staticpro (&Qvisible
);
4361 Qbuffer_predicate
= intern_c_string ("buffer-predicate");
4362 staticpro (&Qbuffer_predicate
);
4363 Qbuffer_list
= intern_c_string ("buffer-list");
4364 staticpro (&Qbuffer_list
);
4365 Qburied_buffer_list
= intern_c_string ("buried-buffer-list");
4366 staticpro (&Qburied_buffer_list
);
4367 Qdisplay_type
= intern_c_string ("display-type");
4368 staticpro (&Qdisplay_type
);
4369 Qbackground_mode
= intern_c_string ("background-mode");
4370 staticpro (&Qbackground_mode
);
4371 Qnoelisp
= intern_c_string ("noelisp");
4372 staticpro (&Qnoelisp
);
4373 Qtty_color_mode
= intern_c_string ("tty-color-mode");
4374 staticpro (&Qtty_color_mode
);
4375 Qtty
= intern_c_string ("tty");
4377 Qtty_type
= intern_c_string ("tty-type");
4378 staticpro (&Qtty_type
);
4380 Qface_set_after_frame_default
= intern_c_string ("face-set-after-frame-default");
4381 staticpro (&Qface_set_after_frame_default
);
4383 Qfullwidth
= intern_c_string ("fullwidth");
4384 staticpro (&Qfullwidth
);
4385 Qfullheight
= intern_c_string ("fullheight");
4386 staticpro (&Qfullheight
);
4387 Qfullboth
= intern_c_string ("fullboth");
4388 staticpro (&Qfullboth
);
4389 Qmaximized
= intern_c_string ("maximized");
4390 staticpro (&Qmaximized
);
4391 Qx_resource_name
= intern_c_string ("x-resource-name");
4392 staticpro (&Qx_resource_name
);
4394 Qx_frame_parameter
= intern_c_string ("x-frame-parameter");
4395 staticpro (&Qx_frame_parameter
);
4397 Qterminal
= intern_c_string ("terminal");
4398 staticpro (&Qterminal
);
4399 Qterminal_live_p
= intern_c_string ("terminal-live-p");
4400 staticpro (&Qterminal_live_p
);
4403 Qns_parse_geometry
= intern_c_string ("ns-parse-geometry");
4404 staticpro (&Qns_parse_geometry
);
4410 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4412 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4413 if (frame_parms
[i
].variable
)
4415 *frame_parms
[i
].variable
= v
;
4416 staticpro (frame_parms
[i
].variable
);
4418 Fput (v
, Qx_frame_parameter
, make_number (i
));
4422 #ifdef HAVE_WINDOW_SYSTEM
4423 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4424 doc
: /* The name Emacs uses to look up X resources.
4425 `x-get-resource' uses this as the first component of the instance name
4426 when requesting resource values.
4427 Emacs initially sets `x-resource-name' to the name under which Emacs
4428 was invoked, or to the value specified with the `-name' or `-rn'
4429 switches, if present.
4431 It may be useful to bind this variable locally around a call
4432 to `x-get-resource'. See also the variable `x-resource-class'. */);
4433 Vx_resource_name
= Qnil
;
4435 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4436 doc
: /* The class Emacs uses to look up X resources.
4437 `x-get-resource' uses this as the first component of the instance class
4438 when requesting resource values.
4440 Emacs initially sets `x-resource-class' to "Emacs".
4442 Setting this variable permanently is not a reasonable thing to do,
4443 but binding this variable locally around a call to `x-get-resource'
4444 is a reasonable practice. See also the variable `x-resource-name'. */);
4445 Vx_resource_class
= build_string (EMACS_CLASS
);
4447 DEFVAR_LISP ("frame-alpha-lower-limit", &Vframe_alpha_lower_limit
,
4448 doc
: /* The lower limit of the frame opacity (alpha transparency).
4449 The value should range from 0 (invisible) to 100 (completely opaque).
4450 You can also use a floating number between 0.0 and 1.0.
4451 The default is 20. */);
4452 Vframe_alpha_lower_limit
= make_number (20);
4455 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4456 doc
: /* Alist of default values for frame creation.
4457 These may be set in your init file, like this:
4458 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4459 These override values given in window system configuration data,
4460 including X Windows' defaults database.
4461 For values specific to the first Emacs frame, see `initial-frame-alist'.
4462 For window-system specific values, see `window-system-default-frame-alist'.
4463 For values specific to the separate minibuffer frame, see
4464 `minibuffer-frame-alist'.
4465 The `menu-bar-lines' element of the list controls whether new frames
4466 have menu bars; `menu-bar-mode' works by altering this element.
4467 Setting this variable does not affect existing frames, only new ones. */);
4468 Vdefault_frame_alist
= Qnil
;
4470 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars
,
4471 doc
: /* Default position of scroll bars on this window-system. */);
4472 #ifdef HAVE_WINDOW_SYSTEM
4473 #if defined(HAVE_NTGUI) || defined(NS_IMPL_COCOA) || (defined(USE_GTK) && defined(USE_TOOLKIT_SCROLL_BARS))
4474 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4476 Vdefault_frame_scroll_bars
= Qright
;
4478 Vdefault_frame_scroll_bars
= Qleft
;
4481 Vdefault_frame_scroll_bars
= Qnil
;
4484 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4485 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4487 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4488 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4489 `mouse-position' calls this function, passing its usual return value as
4490 argument, and returns whatever this function returns.
4491 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4492 which need to do mouse handling at the Lisp level. */);
4493 Vmouse_position_function
= Qnil
;
4495 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4496 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4497 If the value is an integer, highlighting is only shown after moving the
4498 mouse, while keyboard input turns off the highlight even when the mouse
4499 is over the clickable text. However, the mouse shape still indicates
4500 when the mouse is over clickable text. */);
4501 Vmouse_highlight
= Qt
;
4503 DEFVAR_LISP ("make-pointer-invisible", &Vmake_pointer_invisible
,
4504 doc
: /* If non-nil, make pointer invisible while typing.
4505 The pointer becomes visible again when the mouse is moved. */);
4506 Vmake_pointer_invisible
= Qt
;
4508 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4509 doc
: /* Functions to be run before deleting a frame.
4510 The functions are run with one arg, the frame to be deleted.
4513 Note that functions in this list may be called just before the frame is
4514 actually deleted, or some time later (or even both when an earlier function
4515 in `delete-frame-functions' (indirectly) calls `delete-frame'
4517 Vdelete_frame_functions
= Qnil
;
4518 Qdelete_frame_functions
= intern_c_string ("delete-frame-functions");
4519 staticpro (&Qdelete_frame_functions
);
4521 DEFVAR_LISP ("menu-bar-mode", &Vmenu_bar_mode
,
4522 doc
: /* Non-nil if Menu-Bar mode is enabled. */);
4523 Vmenu_bar_mode
= Qt
;
4525 DEFVAR_LISP ("tool-bar-mode", &Vtool_bar_mode
,
4526 doc
: /* Non-nil if Tool-Bar mode is enabled. */);
4527 Vtool_bar_mode
= Qt
;
4529 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4530 doc
: /* Minibufferless frames use this frame's minibuffer.
4532 Emacs cannot create minibufferless frames unless this is set to an
4533 appropriate surrogate.
4535 Emacs consults this variable only when creating minibufferless
4536 frames; once the frame is created, it sticks with its assigned
4537 minibuffer, no matter what this variable is set to. This means that
4538 this variable doesn't necessarily say anything meaningful about the
4539 current set of frames, or where the minibuffer is currently being
4542 This variable is local to the current terminal and cannot be buffer-local. */);
4544 DEFVAR_BOOL ("focus-follows-mouse", &focus_follows_mouse
,
4545 doc
: /* Non-nil if window system changes focus when you move the mouse.
4546 You should set this variable to tell Emacs how your window manager
4547 handles focus, since there is no way in general for Emacs to find out
4548 automatically. See also `mouse-autoselect-window'. */);
4549 #ifdef HAVE_WINDOW_SYSTEM
4550 #if defined(HAVE_NTGUI) || defined(HAVE_NS)
4551 focus_follows_mouse
= 0;
4553 focus_follows_mouse
= 1;
4556 focus_follows_mouse
= 0;
4559 staticpro (&Vframe_list
);
4561 defsubr (&Sactive_minibuffer_window
);
4563 defsubr (&Sframe_live_p
);
4564 defsubr (&Swindow_system
);
4565 defsubr (&Smake_terminal_frame
);
4566 defsubr (&Shandle_switch_frame
);
4567 defsubr (&Sselect_frame
);
4568 defsubr (&Sselected_frame
);
4569 defsubr (&Swindow_frame
);
4570 defsubr (&Sframe_root_window
);
4571 defsubr (&Sframe_first_window
);
4572 defsubr (&Sframe_selected_window
);
4573 defsubr (&Sset_frame_selected_window
);
4574 defsubr (&Sframe_list
);
4575 defsubr (&Snext_frame
);
4576 defsubr (&Sprevious_frame
);
4577 defsubr (&Sdelete_frame
);
4578 defsubr (&Smouse_position
);
4579 defsubr (&Smouse_pixel_position
);
4580 defsubr (&Sset_mouse_position
);
4581 defsubr (&Sset_mouse_pixel_position
);
4583 defsubr (&Sframe_configuration
);
4584 defsubr (&Srestore_frame_configuration
);
4586 defsubr (&Smake_frame_visible
);
4587 defsubr (&Smake_frame_invisible
);
4588 defsubr (&Siconify_frame
);
4589 defsubr (&Sframe_visible_p
);
4590 defsubr (&Svisible_frame_list
);
4591 defsubr (&Sraise_frame
);
4592 defsubr (&Slower_frame
);
4593 defsubr (&Sredirect_frame_focus
);
4594 defsubr (&Sframe_focus
);
4595 defsubr (&Sframe_parameters
);
4596 defsubr (&Sframe_parameter
);
4597 defsubr (&Smodify_frame_parameters
);
4598 defsubr (&Sframe_char_height
);
4599 defsubr (&Sframe_char_width
);
4600 defsubr (&Sframe_pixel_height
);
4601 defsubr (&Sframe_pixel_width
);
4602 defsubr (&Sset_frame_height
);
4603 defsubr (&Sset_frame_width
);
4604 defsubr (&Sset_frame_size
);
4605 defsubr (&Sset_frame_position
);
4607 #ifdef HAVE_WINDOW_SYSTEM
4608 defsubr (&Sx_get_resource
);
4609 defsubr (&Sx_parse_geometry
);
4614 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4615 (do not change this comment) */