1 /* Generic frame functions.
3 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
4 2004, 2005, 2006, 2007, 2008, 2009, 2010
5 Free Software Foundation, Inc.
7 This file is part of GNU Emacs.
9 GNU Emacs is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 GNU Emacs is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
28 #include "character.h"
39 /* These help us bind and responding to switch-frame events. */
43 #include "blockinput.h"
45 #include "termhooks.h"
46 #include "dispextern.h"
49 #ifdef HAVE_WINDOW_SYSTEM
58 /* If we shall make pointer invisible when typing or not. */
59 Lisp_Object Vmake_pointer_invisible
;
61 #ifdef HAVE_WINDOW_SYSTEM
63 /* The name we're using in resource queries. Most often "emacs". */
65 Lisp_Object Vx_resource_name
;
67 /* The application class we're using in resource queries.
70 Lisp_Object Vx_resource_class
;
72 /* Lower limit value of the frame opacity (alpha transparency). */
74 Lisp_Object Vframe_alpha_lower_limit
;
79 Lisp_Object Qns_parse_geometry
;
82 Lisp_Object Qframep
, Qframe_live_p
;
83 Lisp_Object Qicon
, Qmodeline
;
85 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
, Qns
;
87 Lisp_Object Qdisplay_type
;
88 Lisp_Object Qbackground_mode
;
91 Lisp_Object Qx_frame_parameter
;
92 Lisp_Object Qx_resource_name
;
93 Lisp_Object Qterminal
;
94 Lisp_Object Qterminal_live_p
;
96 /* Frame parameters (set or reported). */
98 Lisp_Object Qauto_raise
, Qauto_lower
;
99 Lisp_Object Qborder_color
, Qborder_width
;
100 Lisp_Object Qcursor_color
, Qcursor_type
;
101 Lisp_Object Qgeometry
; /* Not used */
102 Lisp_Object Qheight
, Qwidth
;
103 Lisp_Object Qleft
, Qright
;
104 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
105 Lisp_Object Qtooltip
;
106 Lisp_Object Qinternal_border_width
;
107 Lisp_Object Qmouse_color
;
108 Lisp_Object Qminibuffer
;
109 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
110 Lisp_Object Qvisibility
;
111 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
112 Lisp_Object Qscreen_gamma
;
113 Lisp_Object Qline_spacing
;
114 Lisp_Object Quser_position
, Quser_size
;
115 Lisp_Object Qwait_for_wm
;
116 Lisp_Object Qwindow_id
;
117 #ifdef HAVE_X_WINDOWS
118 Lisp_Object Qouter_window_id
;
120 Lisp_Object Qparent_id
;
121 Lisp_Object Qtitle
, Qname
;
122 Lisp_Object Qexplicit_name
;
123 Lisp_Object Qunsplittable
;
124 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
, Qtool_bar_position
;
125 Lisp_Object Vmenu_bar_mode
, Vtool_bar_mode
;
126 Lisp_Object Qleft_fringe
, Qright_fringe
;
127 Lisp_Object Qbuffer_predicate
, Qbuffer_list
, Qburied_buffer_list
;
128 Lisp_Object Qtty_color_mode
;
129 Lisp_Object Qtty
, Qtty_type
;
131 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
133 Lisp_Object Qfont_backend
;
136 Lisp_Object Qface_set_after_frame_default
;
138 Lisp_Object Vterminal_frame
;
139 Lisp_Object Vdefault_frame_alist
;
140 Lisp_Object Vdefault_frame_scroll_bars
;
141 Lisp_Object Vmouse_position_function
;
142 Lisp_Object Vmouse_highlight
;
143 static Lisp_Object Vdelete_frame_functions
, Qdelete_frame_functions
;
145 int focus_follows_mouse
;
148 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
150 struct window
*w
= XWINDOW (window
);
152 XSETFASTINT (w
->last_modified
, 0);
153 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
154 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
156 /* Handle just the top child in a vertical split. */
157 if (!NILP (w
->vchild
))
158 set_menu_bar_lines_1 (w
->vchild
, n
);
160 /* Adjust all children in a horizontal split. */
161 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
163 w
= XWINDOW (window
);
164 set_menu_bar_lines_1 (window
, n
);
169 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
172 int olines
= FRAME_MENU_BAR_LINES (f
);
174 /* Right now, menu bars don't work properly in minibuf-only frames;
175 most of the commands try to apply themselves to the minibuffer
176 frame itself, and get an error because you can't switch buffers
177 in or split the minibuffer window. */
178 if (FRAME_MINIBUF_ONLY_P (f
))
181 if (INTEGERP (value
))
182 nlines
= XINT (value
);
186 if (nlines
!= olines
)
188 windows_or_buffers_changed
++;
189 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
190 FRAME_MENU_BAR_LINES (f
) = nlines
;
191 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
196 Lisp_Object Vframe_list
;
199 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
200 doc
: /* Return non-nil if OBJECT is a frame.
202 t for a termcap frame (a character-only terminal),
203 'x' for an Emacs frame that is really an X window,
204 'w32' for an Emacs frame that is a window on MS-Windows display,
205 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
206 'pc' for a direct-write MS-DOS frame.
207 See also `frame-live-p'. */)
210 if (!FRAMEP (object
))
212 switch (XFRAME (object
)->output_method
)
214 case output_initial
: /* The initial frame is like a termcap frame. */
217 case output_x_window
:
221 case output_msdos_raw
:
232 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
233 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
234 Value is nil if OBJECT is not a live frame. If object is a live
235 frame, the return value indicates what sort of terminal device it is
236 displayed on. See the documentation of `framep' for possible
240 return ((FRAMEP (object
)
241 && FRAME_LIVE_P (XFRAME (object
)))
246 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
247 doc
: /* The name of the window system that FRAME is displaying through.
248 The value is a symbol:
249 nil for a termcap frame (a character-only terminal),
250 'x' for an Emacs frame that is really an X window,
251 'w32' for an Emacs frame that is a window on MS-Windows display,
252 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
253 'pc' for a direct-write MS-DOS frame.
255 FRAME defaults to the currently selected frame.
257 Use of this function as a predicate is deprecated. Instead,
258 use `display-graphic-p' or any of the other `display-*-p'
259 predicates which report frame's specific UI-related capabilities. */)
264 frame
= selected_frame
;
266 type
= Fframep (frame
);
269 wrong_type_argument (Qframep
, frame
);
278 make_frame (int mini_p
)
281 register struct frame
*f
;
282 register Lisp_Object root_window
;
283 register Lisp_Object mini_window
;
285 f
= allocate_frame ();
286 XSETFRAME (frame
, f
);
288 f
->desired_matrix
= 0;
289 f
->current_matrix
= 0;
292 f
->glyphs_initialized_p
= 0;
293 f
->decode_mode_spec_buffer
= 0;
295 f
->async_visible
= 0;
296 f
->output_data
.nothing
= 0;
298 f
->async_iconified
= 0;
299 f
->wants_modeline
= 1;
304 f
->has_minibuffer
= mini_p
;
305 f
->focus_frame
= Qnil
;
306 f
->explicit_name
= 0;
307 f
->can_have_scroll_bars
= 0;
308 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
309 f
->param_alist
= Qnil
;
310 f
->scroll_bars
= Qnil
;
311 f
->condemned_scroll_bars
= Qnil
;
312 f
->face_alist
= Qnil
;
313 f
->face_cache
= NULL
;
314 f
->menu_bar_items
= Qnil
;
315 f
->menu_bar_vector
= Qnil
;
316 f
->menu_bar_items_used
= 0;
317 f
->buffer_predicate
= Qnil
;
318 f
->buffer_list
= Qnil
;
319 f
->buried_buffer_list
= Qnil
;
322 f
->menu_bar_window
= Qnil
;
323 f
->tool_bar_window
= Qnil
;
324 f
->tool_bar_items
= Qnil
;
325 f
->tool_bar_position
= Qtop
;
326 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
327 f
->n_tool_bar_items
= 0;
328 f
->left_fringe_width
= f
->right_fringe_width
= 0;
330 f
->menu_bar_lines
= 0;
331 f
->tool_bar_lines
= 0;
332 f
->scroll_bar_actual_width
= 0;
334 f
->internal_border_width
= 0;
335 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
336 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
337 f
->x_pixels_diff
= f
->y_pixels_diff
= 0;
338 #ifdef HAVE_WINDOW_SYSTEM
339 f
->want_fullscreen
= FULLSCREEN_NONE
;
341 f
->size_hint_flags
= 0;
343 f
->font_driver_list
= NULL
;
344 f
->font_data_list
= NULL
;
346 root_window
= make_window ();
349 mini_window
= make_window ();
350 XWINDOW (root_window
)->next
= mini_window
;
351 XWINDOW (mini_window
)->prev
= root_window
;
352 XWINDOW (mini_window
)->mini_p
= Qt
;
353 XWINDOW (mini_window
)->frame
= frame
;
354 f
->minibuffer_window
= mini_window
;
359 XWINDOW (root_window
)->next
= Qnil
;
360 f
->minibuffer_window
= Qnil
;
363 XWINDOW (root_window
)->frame
= frame
;
366 just so that there is "something there."
367 Correct size will be set up later with change_frame_size. */
369 SET_FRAME_COLS (f
, 10);
370 FRAME_LINES (f
) = 10;
372 XSETFASTINT (XWINDOW (root_window
)->total_cols
, 10);
373 XSETFASTINT (XWINDOW (root_window
)->total_lines
, (mini_p
? 9 : 10));
377 XSETFASTINT (XWINDOW (mini_window
)->total_cols
, 10);
378 XSETFASTINT (XWINDOW (mini_window
)->top_line
, 9);
379 XSETFASTINT (XWINDOW (mini_window
)->total_lines
, 1);
382 /* Choose a buffer for the frame's root window. */
386 XWINDOW (root_window
)->buffer
= Qt
;
387 buf
= Fcurrent_buffer ();
388 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
389 a space), try to find another one. */
390 if (SREF (Fbuffer_name (buf
), 0) == ' ')
391 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
393 /* Use set_window_buffer, not Fset_window_buffer, and don't let
394 hooks be run by it. The reason is that the whole frame/window
395 arrangement is not yet fully intialized at this point. Windows
396 don't have the right size, glyph matrices aren't initialized
397 etc. Running Lisp functions at this point surely ends in a
399 set_window_buffer (root_window
, buf
, 0, 0);
400 f
->buffer_list
= Fcons (buf
, Qnil
);
405 XWINDOW (mini_window
)->buffer
= Qt
;
406 set_window_buffer (mini_window
,
407 (NILP (Vminibuffer_list
)
409 : Fcar (Vminibuffer_list
)),
413 f
->root_window
= root_window
;
414 f
->selected_window
= root_window
;
415 /* Make sure this window seems more recently used than
416 a newly-created, never-selected window. */
417 ++window_select_count
;
418 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, window_select_count
);
420 f
->default_face_done_p
= 0;
425 #ifdef HAVE_WINDOW_SYSTEM
426 /* Make a frame using a separate minibuffer window on another frame.
427 MINI_WINDOW is the minibuffer window to use. nil means use the
428 default (the global minibuffer). */
431 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
433 register struct frame
*f
;
436 if (!NILP (mini_window
))
437 CHECK_LIVE_WINDOW (mini_window
);
439 if (!NILP (mini_window
)
440 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
441 error ("Frame and minibuffer must be on the same terminal");
443 /* Make a frame containing just a root window. */
446 if (NILP (mini_window
))
448 /* Use default-minibuffer-frame if possible. */
449 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
450 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
452 Lisp_Object frame_dummy
;
454 XSETFRAME (frame_dummy
, f
);
455 GCPRO1 (frame_dummy
);
456 /* If there's no minibuffer frame to use, create one. */
457 kb
->Vdefault_minibuffer_frame
=
458 call1 (intern ("make-initial-minibuffer-frame"), display
);
462 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
465 f
->minibuffer_window
= mini_window
;
467 /* Make the chosen minibuffer window display the proper minibuffer,
468 unless it is already showing a minibuffer. */
469 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
470 Fset_window_buffer (mini_window
,
471 (NILP (Vminibuffer_list
)
473 : Fcar (Vminibuffer_list
)), Qnil
);
477 /* Make a frame containing only a minibuffer window. */
480 make_minibuffer_frame (void)
482 /* First make a frame containing just a root window, no minibuffer. */
484 register struct frame
*f
= make_frame (0);
485 register Lisp_Object mini_window
;
486 register Lisp_Object frame
;
488 XSETFRAME (frame
, f
);
493 f
->wants_modeline
= 0;
494 f
->has_minibuffer
= 1;
496 /* Now label the root window as also being the minibuffer.
497 Avoid infinite looping on the window chain by marking next pointer
500 mini_window
= f
->minibuffer_window
= f
->root_window
;
501 XWINDOW (mini_window
)->mini_p
= Qt
;
502 XWINDOW (mini_window
)->next
= Qnil
;
503 XWINDOW (mini_window
)->prev
= Qnil
;
504 XWINDOW (mini_window
)->frame
= frame
;
506 /* Put the proper buffer in that window. */
508 Fset_window_buffer (mini_window
,
509 (NILP (Vminibuffer_list
)
511 : Fcar (Vminibuffer_list
)), Qnil
);
514 #endif /* HAVE_WINDOW_SYSTEM */
516 /* Construct a frame that refers to a terminal. */
518 static int tty_frame_count
;
521 make_initial_frame (void)
524 struct terminal
*terminal
;
527 eassert (initial_kboard
);
529 /* The first call must initialize Vframe_list. */
530 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
533 terminal
= init_initial_terminal ();
536 XSETFRAME (frame
, f
);
538 Vframe_list
= Fcons (frame
, Vframe_list
);
541 f
->name
= make_pure_c_string ("F1");
544 f
->async_visible
= 1;
546 f
->output_method
= terminal
->type
;
547 f
->terminal
= terminal
;
548 f
->terminal
->reference_count
++;
549 f
->output_data
.nothing
= 0;
551 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
552 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
554 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
555 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
557 /* The default value of menu-bar-mode is t. */
558 set_menu_bar_lines (f
, make_number (1), Qnil
);
562 init_frame_faces (f
);
570 make_terminal_frame (struct terminal
*terminal
)
572 register struct frame
*f
;
577 error ("Terminal is not live, can't create new frames on it");
581 XSETFRAME (frame
, f
);
582 Vframe_list
= Fcons (frame
, Vframe_list
);
585 sprintf (name
, "F%d", tty_frame_count
);
586 f
->name
= build_string (name
);
588 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
589 f
->async_visible
= 1; /* Don't let visible be cleared later. */
590 f
->terminal
= terminal
;
591 f
->terminal
->reference_count
++;
593 f
->output_data
.tty
->display_info
= &the_only_display_info
;
594 if (!inhibit_window_system
595 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
596 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
597 f
->output_method
= output_msdos_raw
;
599 f
->output_method
= output_termcap
;
600 #else /* not MSDOS */
601 f
->output_method
= output_termcap
;
602 create_tty_output (f
);
603 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
604 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
605 #endif /* not MSDOS */
607 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
608 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
609 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
611 /* Set the top frame to the newly created frame. */
612 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
613 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
614 XFRAME (FRAME_TTY (f
)->top_frame
)->async_visible
= 2; /* obscured */
616 FRAME_TTY (f
)->top_frame
= frame
;
619 init_frame_faces (f
);
624 /* Get a suitable value for frame parameter PARAMETER for a newly
625 created frame, based on (1) the user-supplied frame parameter
626 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
629 get_future_frame_param (Lisp_Object parameter
,
630 Lisp_Object supplied_parms
,
635 result
= Fassq (parameter
, supplied_parms
);
637 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
638 if (NILP (result
) && current_value
!= NULL
)
639 result
= build_string (current_value
);
640 if (!NILP (result
) && !STRINGP (result
))
641 result
= XCDR (result
);
642 if (NILP (result
) || !STRINGP (result
))
648 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
650 doc
: /* Create an additional terminal frame, possibly on another terminal.
651 This function takes one argument, an alist specifying frame parameters.
653 You can create multiple frames on a single text-only terminal, but
654 only one of them (the selected terminal frame) is actually displayed.
656 In practice, generally you don't need to specify any parameters,
657 except when you want to create a new frame on another terminal.
658 In that case, the `tty' parameter specifies the device file to open,
659 and the `tty-type' parameter specifies the terminal type. Example:
661 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
663 Note that changing the size of one terminal frame automatically
664 affects all frames on the same terminal device. */)
668 struct terminal
*t
= NULL
;
669 Lisp_Object frame
, tem
;
670 struct frame
*sf
= SELECTED_FRAME ();
673 if (sf
->output_method
!= output_msdos_raw
674 && sf
->output_method
!= output_termcap
)
676 #else /* not MSDOS */
678 #ifdef WINDOWSNT /* This should work now! */
679 if (sf
->output_method
!= output_termcap
)
680 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
682 #endif /* not MSDOS */
685 Lisp_Object terminal
;
687 terminal
= Fassq (Qterminal
, parms
);
688 if (!NILP (terminal
))
690 terminal
= XCDR (terminal
);
691 t
= get_terminal (terminal
, 1);
694 if (t
&& t
!= the_only_display_info
.terminal
)
695 /* msdos.c assumes a single tty_display_info object. */
696 error ("Multiple terminals are not supported on this platform");
698 t
= the_only_display_info
.terminal
;
704 char *name
= 0, *type
= 0;
705 Lisp_Object tty
, tty_type
;
707 tty
= get_future_frame_param
708 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
709 ? FRAME_TTY (XFRAME (selected_frame
))->name
713 name
= (char *) alloca (SBYTES (tty
) + 1);
714 strncpy (name
, SDATA (tty
), SBYTES (tty
));
715 name
[SBYTES (tty
)] = 0;
718 tty_type
= get_future_frame_param
719 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
720 ? FRAME_TTY (XFRAME (selected_frame
))->type
722 if (!NILP (tty_type
))
724 type
= (char *) alloca (SBYTES (tty_type
) + 1);
725 strncpy (type
, SDATA (tty_type
), SBYTES (tty_type
));
726 type
[SBYTES (tty_type
)] = 0;
729 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
732 f
= make_terminal_frame (t
);
736 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
737 change_frame_size (f
, height
, width
, 0, 0, 0);
742 XSETFRAME (frame
, f
);
743 Fmodify_frame_parameters (frame
, parms
);
744 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
745 build_string (t
->display_info
.tty
->type
)),
747 if (t
->display_info
.tty
->name
!= NULL
)
748 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
749 build_string (t
->display_info
.tty
->name
)),
752 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
754 /* Make the frame face alist be frame-specific, so that each
755 frame could change its face definitions independently. */
756 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
757 /* Simple Fcopy_alist isn't enough, because we need the contents of
758 the vectors which are the CDRs of associations in face_alist to
759 be copied as well. */
760 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
761 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
766 /* Perform the switch to frame FRAME.
768 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
771 If TRACK is non-zero and the frame that currently has the focus
772 redirects its focus to the selected frame, redirect that focused
773 frame's focus to FRAME instead.
775 FOR_DELETION non-zero means that the selected frame is being
776 deleted, which includes the possibility that the frame's terminal
779 The value of NORECORD is passed as argument to Fselect_window. */
782 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
784 struct frame
*sf
= SELECTED_FRAME ();
786 /* If FRAME is a switch-frame event, extract the frame we should
789 && EQ (XCAR (frame
), Qswitch_frame
)
790 && CONSP (XCDR (frame
)))
791 frame
= XCAR (XCDR (frame
));
793 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
794 a switch-frame event to arrive after a frame is no longer live,
795 especially when deleting the initial frame during startup. */
797 if (! FRAME_LIVE_P (XFRAME (frame
)))
800 if (sf
== XFRAME (frame
))
803 /* This is too greedy; it causes inappropriate focus redirection
804 that's hard to get rid of. */
806 /* If a frame's focus has been redirected toward the currently
807 selected frame, we should change the redirection to point to the
808 newly selected frame. This means that if the focus is redirected
809 from a minibufferless frame to a surrogate minibuffer frame, we
810 can use `other-window' to switch between all the frames using
811 that minibuffer frame, and the focus redirection will follow us
817 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
821 if (!FRAMEP (XCAR (tail
)))
824 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
826 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
827 Fredirect_frame_focus (XCAR (tail
), frame
);
831 /* Instead, apply it only to the frame we're pointing to. */
832 #ifdef HAVE_WINDOW_SYSTEM
833 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
835 Lisp_Object focus
, xfocus
;
837 xfocus
= x_get_focus_frame (XFRAME (frame
));
840 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
841 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
842 Fredirect_frame_focus (xfocus
, frame
);
845 #endif /* HAVE_X_WINDOWS */
848 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
849 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
851 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
853 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
854 /* Mark previously displayed frame as now obscured. */
855 XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
)->async_visible
= 2;
856 XFRAME (frame
)->async_visible
= 1;
857 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
860 selected_frame
= frame
;
861 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
862 last_nonminibuf_frame
= XFRAME (selected_frame
);
864 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
866 /* We want to make sure that the next event generates a frame-switch
867 event to the appropriate frame. This seems kludgy to me, but
868 before you take it out, make sure that evaluating something like
869 (select-window (frame-root-window (new-frame))) doesn't end up
870 with your typing being interpreted in the new frame instead of
871 the one you're actually typing in. */
872 internal_last_event_frame
= Qnil
;
877 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
878 doc
: /* Select FRAME.
879 Subsequent editing commands apply to its selected window.
880 Optional argument NORECORD means to neither change the order of
881 recently selected windows nor the buffer list.
883 The selection of FRAME lasts until the next time the user does
884 something to select a different frame, or until the next time
885 this function is called. If you are using a window system, the
886 previously selected frame may be restored as the selected frame
887 when returning to the command loop, because it still may have
888 the window system's input focus. On a text-only terminal, the
889 next redisplay will display FRAME.
891 This function returns FRAME, or nil if FRAME has been deleted. */)
892 (Lisp_Object frame
, Lisp_Object norecord
)
894 return do_switch_frame (frame
, 1, 0, norecord
);
898 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
899 doc
: /* Handle a switch-frame event EVENT.
900 Switch-frame events are usually bound to this function.
901 A switch-frame event tells Emacs that the window manager has requested
902 that the user's events be directed to the frame mentioned in the event.
903 This function selects the selected window of the frame of EVENT.
905 If EVENT is frame object, handle it as if it were a switch-frame event
909 /* Preserve prefix arg that the command loop just cleared. */
910 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
911 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
912 return do_switch_frame (event
, 0, 0, Qnil
);
915 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
916 doc
: /* Return the frame that is now selected. */)
919 return selected_frame
;
922 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
924 doc
: /* Return a list of all live frames. */)
928 frames
= Fcopy_sequence (Vframe_list
);
929 #ifdef HAVE_WINDOW_SYSTEM
930 if (FRAMEP (tip_frame
))
931 frames
= Fdelq (tip_frame
, frames
);
936 /* Return the next frame in the frame list after FRAME.
937 If MINIBUF is nil, exclude minibuffer-only frames.
938 If MINIBUF is a window, include only its own frame
939 and any frame now using that window as the minibuffer.
940 If MINIBUF is `visible', include all visible frames.
941 If MINIBUF is 0, include all visible and iconified frames.
942 Otherwise, include all frames. */
945 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
950 /* There must always be at least one frame in Vframe_list. */
951 if (! CONSP (Vframe_list
))
954 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
955 forever. Forestall that. */
956 CHECK_LIVE_FRAME (frame
);
959 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
966 && ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
967 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
968 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
969 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
)))))
971 /* Decide whether this frame is eligible to be returned. */
973 /* If we've looped all the way around without finding any
974 eligible frames, return the original frame. */
978 /* Let minibuf decide if this frame is acceptable. */
981 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
984 else if (EQ (minibuf
, Qvisible
))
986 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
987 if (FRAME_VISIBLE_P (XFRAME (f
)))
990 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
992 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
993 if (FRAME_VISIBLE_P (XFRAME (f
))
994 || FRAME_ICONIFIED_P (XFRAME (f
)))
997 else if (WINDOWP (minibuf
))
999 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1000 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1001 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1002 FRAME_FOCUS_FRAME (XFRAME (f
))))
1014 /* Return the previous frame in the frame list before FRAME.
1015 If MINIBUF is nil, exclude minibuffer-only frames.
1016 If MINIBUF is a window, include only its own frame
1017 and any frame now using that window as the minibuffer.
1018 If MINIBUF is `visible', include all visible frames.
1019 If MINIBUF is 0, include all visible and iconified frames.
1020 Otherwise, include all frames. */
1023 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1028 /* There must always be at least one frame in Vframe_list. */
1029 if (! CONSP (Vframe_list
))
1033 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1041 if (EQ (frame
, f
) && !NILP (prev
))
1044 if ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1045 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1046 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1047 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
))))
1049 /* Decide whether this frame is eligible to be returned,
1050 according to minibuf. */
1053 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1056 else if (WINDOWP (minibuf
))
1058 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1059 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1060 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1061 FRAME_FOCUS_FRAME (XFRAME (f
))))
1064 else if (EQ (minibuf
, Qvisible
))
1066 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1067 if (FRAME_VISIBLE_P (XFRAME (f
)))
1070 else if (XFASTINT (minibuf
) == 0)
1072 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1073 if (FRAME_VISIBLE_P (XFRAME (f
))
1074 || FRAME_ICONIFIED_P (XFRAME (f
)))
1082 /* We've scanned the entire list. */
1084 /* We went through the whole frame list without finding a single
1085 acceptable frame. Return the original frame. */
1088 /* There were no acceptable frames in the list before FRAME; otherwise,
1089 we would have returned directly from the loop. Since PREV is the last
1090 acceptable frame in the list, return it. */
1095 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1096 doc
: /* Return the next frame in the frame list after FRAME.
1097 It considers only frames on the same terminal as FRAME.
1098 By default, skip minibuffer-only frames.
1099 If omitted, FRAME defaults to the selected frame.
1100 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1101 If MINIFRAME is a window, include only its own frame
1102 and any frame now using that window as the minibuffer.
1103 If MINIFRAME is `visible', include all visible frames.
1104 If MINIFRAME is 0, include all visible and iconified frames.
1105 Otherwise, include all frames. */)
1106 (Lisp_Object frame
, Lisp_Object miniframe
)
1109 frame
= selected_frame
;
1111 CHECK_LIVE_FRAME (frame
);
1112 return next_frame (frame
, miniframe
);
1115 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1116 doc
: /* Return the previous frame in the frame list before FRAME.
1117 It considers only frames on the same terminal as FRAME.
1118 By default, skip minibuffer-only frames.
1119 If omitted, FRAME defaults to the selected frame.
1120 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1121 If MINIFRAME is a window, include only its own frame
1122 and any frame now using that window as the minibuffer.
1123 If MINIFRAME is `visible', include all visible frames.
1124 If MINIFRAME is 0, include all visible and iconified frames.
1125 Otherwise, include all frames. */)
1126 (Lisp_Object frame
, Lisp_Object miniframe
)
1129 frame
= selected_frame
;
1130 CHECK_LIVE_FRAME (frame
);
1131 return prev_frame (frame
, miniframe
);
1134 /* Return 1 if it is ok to delete frame F;
1135 0 if all frames aside from F are invisible.
1136 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1139 other_visible_frames (FRAME_PTR f
)
1141 /* We know the selected frame is visible,
1142 so if F is some other frame, it can't be the sole visible one. */
1143 if (f
== SELECTED_FRAME ())
1148 for (frames
= Vframe_list
;
1150 frames
= XCDR (frames
))
1154 this = XCAR (frames
);
1155 /* Verify that the frame's window still exists
1156 and we can still talk to it. And note any recent change
1158 #ifdef HAVE_WINDOW_SYSTEM
1159 if (FRAME_WINDOW_P (XFRAME (this)))
1161 x_sync (XFRAME (this));
1162 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1166 if (FRAME_VISIBLE_P (XFRAME (this))
1167 || FRAME_ICONIFIED_P (XFRAME (this))
1168 /* Allow deleting the terminal frame when at least
1169 one X frame exists! */
1170 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1178 DEFUN ("other-visible-frames-p", Fother_visible_frames_p
, Sother_visible_frames_p
, 0, 1, 0,
1179 doc
: /* Return t if there are other visible frames beside FRAME.
1180 FRAME defaults to the selected frame. */)
1184 frame
= selected_frame
;
1185 CHECK_LIVE_FRAME (frame
);
1186 return other_visible_frames (XFRAME (frame
)) ? Qt
: Qnil
;
1189 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1190 unconditionally. x_connection_closed and delete_terminal use
1191 this. Any other value of FORCE implements the semantics
1192 described for Fdelete_frame. */
1194 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1195 /* If we use `register' here, gcc-4.0.2 on amd64 using
1196 -DUSE_LISP_UNION_TYPE complains further down that we're getting the
1197 address of `force'. Go figure. */
1201 struct frame
*sf
= SELECTED_FRAME ();
1204 int minibuffer_selected
, tooltip_frame
;
1206 if (EQ (frame
, Qnil
))
1209 XSETFRAME (frame
, f
);
1213 CHECK_FRAME (frame
);
1217 if (! FRAME_LIVE_P (f
))
1220 if (NILP (force
) && !other_visible_frames (f
))
1221 error ("Attempt to delete the sole visible or iconified frame");
1223 /* x_connection_closed must have set FORCE to `noelisp' in order
1224 to delete the last frame, if it is gone. */
1225 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1226 error ("Attempt to delete the only frame");
1228 /* Does this frame have a minibuffer, and is it the surrogate
1229 minibuffer for any other frame? */
1230 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1234 for (frames
= Vframe_list
;
1236 frames
= XCDR (frames
))
1239 this = XCAR (frames
);
1241 if (! EQ (this, frame
)
1243 WINDOW_FRAME (XWINDOW
1244 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1246 /* If we MUST delete this frame, delete the other first.
1247 But do this only if FORCE equals `noelisp'. */
1248 if (EQ (force
, Qnoelisp
))
1249 delete_frame (this, Qnoelisp
);
1251 error ("Attempt to delete a surrogate minibuffer frame");
1256 tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1258 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1259 frame is a tooltip. FORCE is set to `noelisp' when handling
1260 a disconnect from the terminal, so we don't dare call Lisp
1262 if (NILP (Vrun_hooks
) || tooltip_frame
)
1264 else if (EQ (force
, Qnoelisp
))
1266 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1269 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1271 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1272 if (! FRAME_LIVE_P (f
))
1275 /* At this point, we are committed to deleting the frame.
1276 There is no more chance for errors to prevent it. */
1278 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1280 /* Don't let the frame remain selected. */
1283 Lisp_Object tail
, frame1
;
1285 /* Look for another visible frame on the same terminal. */
1286 frame1
= next_frame (frame
, Qvisible
);
1288 /* If there is none, find *some* other frame. */
1289 if (NILP (frame1
) || EQ (frame1
, frame
))
1291 FOR_EACH_FRAME (tail
, frame1
)
1293 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1297 #ifdef NS_IMPL_COCOA
1299 /* Under NS, there is no system mechanism for choosing a new
1300 window to get focus -- it is left to application code.
1301 So the portion of THIS application interfacing with NS
1302 needs to know about it. We call Fraise_frame, but the
1303 purpose is really to transfer focus. */
1304 Fraise_frame (frame1
);
1307 do_switch_frame (frame1
, 0, 1, Qnil
);
1308 sf
= SELECTED_FRAME ();
1311 /* Don't allow minibuf_window to remain on a deleted frame. */
1312 if (EQ (f
->minibuffer_window
, minibuf_window
))
1314 Fset_window_buffer (sf
->minibuffer_window
,
1315 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1316 minibuf_window
= sf
->minibuffer_window
;
1318 /* If the dying minibuffer window was selected,
1319 select the new one. */
1320 if (minibuffer_selected
)
1321 Fselect_window (minibuf_window
, Qnil
);
1324 /* Don't let echo_area_window to remain on a deleted frame. */
1325 if (EQ (f
->minibuffer_window
, echo_area_window
))
1326 echo_area_window
= sf
->minibuffer_window
;
1328 /* Clear any X selections for this frame. */
1329 #ifdef HAVE_X_WINDOWS
1331 x_clear_frame_selections (f
);
1335 This function must be called before the window tree of the
1336 frame is deleted because windows contain dynamically allocated
1340 #ifdef HAVE_WINDOW_SYSTEM
1341 /* Give chance to each font driver to free a frame specific data. */
1342 font_update_drivers (f
, Qnil
);
1345 /* Mark all the windows that used to be on FRAME as deleted, and then
1346 remove the reference to them. */
1347 delete_all_subwindows (f
->root_window
);
1348 f
->root_window
= Qnil
;
1350 Vframe_list
= Fdelq (frame
, Vframe_list
);
1351 FRAME_SET_VISIBLE (f
, 0);
1353 /* Allow the vector of menu bar contents to be freed in the next
1354 garbage collection. The frame object itself may not be garbage
1355 collected until much later, because recent_keys and other data
1356 structures can still refer to it. */
1357 f
->menu_bar_vector
= Qnil
;
1359 free_font_driver_list (f
);
1361 xfree (f
->decode_mode_spec_buffer
);
1362 xfree (FRAME_INSERT_COST (f
));
1363 xfree (FRAME_DELETEN_COST (f
));
1364 xfree (FRAME_INSERTN_COST (f
));
1365 xfree (FRAME_DELETE_COST (f
));
1366 xfree (FRAME_MESSAGE_BUF (f
));
1368 /* Since some events are handled at the interrupt level, we may get
1369 an event for f at any time; if we zero out the frame's terminal
1370 now, then we may trip up the event-handling code. Instead, we'll
1371 promise that the terminal of the frame must be valid until we
1372 have called the window-system-dependent frame destruction
1375 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1376 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1379 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1380 f
->output_data
.nothing
= 0;
1381 f
->terminal
= 0; /* Now the frame is dead. */
1383 /* If needed, delete the terminal that this frame was on.
1384 (This must be done after the frame is killed.) */
1385 terminal
->reference_count
--;
1386 if (terminal
->reference_count
== 0)
1389 XSETTERMINAL (tmp
, terminal
);
1392 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1395 kb
= terminal
->kboard
;
1398 /* If we've deleted the last_nonminibuf_frame, then try to find
1400 if (f
== last_nonminibuf_frame
)
1404 last_nonminibuf_frame
= 0;
1406 for (frames
= Vframe_list
;
1408 frames
= XCDR (frames
))
1410 f
= XFRAME (XCAR (frames
));
1411 if (!FRAME_MINIBUF_ONLY_P (f
))
1413 last_nonminibuf_frame
= f
;
1419 /* If there's no other frame on the same kboard, get out of
1420 single-kboard state if we're in it for this kboard. */
1424 /* Some frame we found on the same kboard, or nil if there are none. */
1425 Lisp_Object frame_on_same_kboard
;
1427 frame_on_same_kboard
= Qnil
;
1429 for (frames
= Vframe_list
;
1431 frames
= XCDR (frames
))
1436 this = XCAR (frames
);
1441 if (kb
== FRAME_KBOARD (f1
))
1442 frame_on_same_kboard
= this;
1445 if (NILP (frame_on_same_kboard
))
1446 not_single_kboard_state (kb
);
1450 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1451 find another one. Prefer minibuffer-only frames, but also notice
1452 frames with other windows. */
1453 if (kb
!= NULL
&& EQ (frame
, kb
->Vdefault_minibuffer_frame
))
1457 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1458 Lisp_Object frame_with_minibuf
;
1459 /* Some frame we found on the same kboard, or nil if there are none. */
1460 Lisp_Object frame_on_same_kboard
;
1462 frame_on_same_kboard
= Qnil
;
1463 frame_with_minibuf
= Qnil
;
1465 for (frames
= Vframe_list
;
1467 frames
= XCDR (frames
))
1472 this = XCAR (frames
);
1477 /* Consider only frames on the same kboard
1478 and only those with minibuffers. */
1479 if (kb
== FRAME_KBOARD (f1
)
1480 && FRAME_HAS_MINIBUF_P (f1
))
1482 frame_with_minibuf
= this;
1483 if (FRAME_MINIBUF_ONLY_P (f1
))
1487 if (kb
== FRAME_KBOARD (f1
))
1488 frame_on_same_kboard
= this;
1491 if (!NILP (frame_on_same_kboard
))
1493 /* We know that there must be some frame with a minibuffer out
1494 there. If this were not true, all of the frames present
1495 would have to be minibufferless, which implies that at some
1496 point their minibuffer frames must have been deleted, but
1497 that is prohibited at the top; you can't delete surrogate
1498 minibuffer frames. */
1499 if (NILP (frame_with_minibuf
))
1502 kb
->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1505 /* No frames left on this kboard--say no minibuffer either. */
1506 kb
->Vdefault_minibuffer_frame
= Qnil
;
1509 /* Cause frame titles to update--necessary if we now have just one frame. */
1511 update_mode_lines
= 1;
1516 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1517 doc
: /* Delete FRAME, permanently eliminating it from use.
1518 FRAME defaults to the selected frame.
1520 A frame may not be deleted if its minibuffer is used by other frames.
1521 Normally, you may not delete a frame if all other frames are invisible,
1522 but if the second optional argument FORCE is non-nil, you may do so.
1524 This function runs `delete-frame-functions' before actually
1525 deleting the frame, unless the frame is a tooltip.
1526 The functions are run with one argument, the frame to be deleted. */)
1527 (Lisp_Object frame
, Lisp_Object force
)
1529 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1533 /* Return mouse position in character cell units. */
1535 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1536 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1537 The position is given in character cells, where (0, 0) is the
1538 upper-left corner of the frame, X is the horizontal offset, and Y is
1539 the vertical offset.
1540 If Emacs is running on a mouseless terminal or hasn't been programmed
1541 to read the mouse position, it returns the selected frame for FRAME
1542 and nil for X and Y.
1543 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1544 passing the normal return value to that function as an argument,
1545 and returns whatever that function returns. */)
1549 Lisp_Object lispy_dummy
;
1550 enum scroll_bar_part party_dummy
;
1551 Lisp_Object x
, y
, retval
;
1553 unsigned long long_dummy
;
1554 struct gcpro gcpro1
;
1556 f
= SELECTED_FRAME ();
1559 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1560 /* It's okay for the hook to refrain from storing anything. */
1561 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1562 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1563 &lispy_dummy
, &party_dummy
,
1570 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1575 XSETFRAME (lispy_dummy
, f
);
1576 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1578 if (!NILP (Vmouse_position_function
))
1579 retval
= call1 (Vmouse_position_function
, retval
);
1580 RETURN_UNGCPRO (retval
);
1583 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1584 Smouse_pixel_position
, 0, 0, 0,
1585 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1586 The position is given in pixel units, where (0, 0) is the
1587 upper-left corner of the frame, X is the horizontal offset, and Y is
1588 the vertical offset.
1589 If Emacs is running on a mouseless terminal or hasn't been programmed
1590 to read the mouse position, it returns the selected frame for FRAME
1591 and nil for X and Y. */)
1595 Lisp_Object lispy_dummy
;
1596 enum scroll_bar_part party_dummy
;
1598 unsigned long long_dummy
;
1600 f
= SELECTED_FRAME ();
1603 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1604 /* It's okay for the hook to refrain from storing anything. */
1605 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1606 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1607 &lispy_dummy
, &party_dummy
,
1611 XSETFRAME (lispy_dummy
, f
);
1612 return Fcons (lispy_dummy
, Fcons (x
, y
));
1615 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1616 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1617 Coordinates are relative to the frame, not a window,
1618 so the coordinates of the top left character in the frame
1619 may be nonzero due to left-hand scroll bars or the menu bar.
1621 The position is given in character cells, where (0, 0) is the
1622 upper-left corner of the frame, X is the horizontal offset, and Y is
1623 the vertical offset.
1625 This function is a no-op for an X frame that is not visible.
1626 If you have just created a frame, you must wait for it to become visible
1627 before calling this function on it, like this.
1628 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1629 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1631 CHECK_LIVE_FRAME (frame
);
1635 /* I think this should be done with a hook. */
1636 #ifdef HAVE_WINDOW_SYSTEM
1637 if (FRAME_WINDOW_P (XFRAME (frame
)))
1638 /* Warping the mouse will cause enternotify and focus events. */
1639 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1641 #if defined (MSDOS) && defined (HAVE_MOUSE)
1642 if (FRAME_MSDOS_P (XFRAME (frame
)))
1644 Fselect_frame (frame
, Qnil
);
1645 mouse_moveto (XINT (x
), XINT (y
));
1650 Fselect_frame (frame
, Qnil
);
1651 term_mouse_moveto (XINT (x
), XINT (y
));
1660 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1661 Sset_mouse_pixel_position
, 3, 3, 0,
1662 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1663 The position is given in pixels, where (0, 0) is the upper-left corner
1664 of the frame, X is the horizontal offset, and Y is the vertical offset.
1666 Note, this is a no-op for an X frame that is not visible.
1667 If you have just created a frame, you must wait for it to become visible
1668 before calling this function on it, like this.
1669 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1670 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1672 CHECK_LIVE_FRAME (frame
);
1676 /* I think this should be done with a hook. */
1677 #ifdef HAVE_WINDOW_SYSTEM
1678 if (FRAME_WINDOW_P (XFRAME (frame
)))
1679 /* Warping the mouse will cause enternotify and focus events. */
1680 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1682 #if defined (MSDOS) && defined (HAVE_MOUSE)
1683 if (FRAME_MSDOS_P (XFRAME (frame
)))
1685 Fselect_frame (frame
, Qnil
);
1686 mouse_moveto (XINT (x
), XINT (y
));
1691 Fselect_frame (frame
, Qnil
);
1692 term_mouse_moveto (XINT (x
), XINT (y
));
1701 static void make_frame_visible_1 (Lisp_Object
);
1703 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1705 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1706 If omitted, FRAME defaults to the currently selected frame. */)
1710 frame
= selected_frame
;
1712 CHECK_LIVE_FRAME (frame
);
1714 /* I think this should be done with a hook. */
1715 #ifdef HAVE_WINDOW_SYSTEM
1716 if (FRAME_WINDOW_P (XFRAME (frame
)))
1718 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1719 x_make_frame_visible (XFRAME (frame
));
1723 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1725 /* Make menu bar update for the Buffers and Frames menus. */
1726 windows_or_buffers_changed
++;
1731 /* Update the display_time slot of the buffers shown in WINDOW
1732 and all its descendents. */
1735 make_frame_visible_1 (Lisp_Object window
)
1739 for (;!NILP (window
); window
= w
->next
)
1741 w
= XWINDOW (window
);
1743 if (!NILP (w
->buffer
))
1744 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1746 if (!NILP (w
->vchild
))
1747 make_frame_visible_1 (w
->vchild
);
1748 if (!NILP (w
->hchild
))
1749 make_frame_visible_1 (w
->hchild
);
1753 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1755 doc
: /* Make the frame FRAME invisible.
1756 If omitted, FRAME defaults to the currently selected frame.
1757 On graphical displays, invisible frames are not updated and are
1758 usually not displayed at all, even in a window system's \"taskbar\".
1760 Normally you may not make FRAME invisible if all other frames are invisible,
1761 but if the second optional argument FORCE is non-nil, you may do so.
1763 This function has no effect on text-only terminal frames. Such frames
1764 are always considered visible, whether or not they are currently being
1765 displayed in the terminal. */)
1766 (Lisp_Object frame
, Lisp_Object force
)
1769 frame
= selected_frame
;
1771 CHECK_LIVE_FRAME (frame
);
1773 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1774 error ("Attempt to make invisible the sole visible or iconified frame");
1776 #if 0 /* This isn't logically necessary, and it can do GC. */
1777 /* Don't let the frame remain selected. */
1778 if (EQ (frame
, selected_frame
))
1779 do_switch_frame (next_frame (frame
, Qt
), 0, 0, Qnil
)
1782 /* Don't allow minibuf_window to remain on a deleted frame. */
1783 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1785 struct frame
*sf
= XFRAME (selected_frame
);
1786 Fset_window_buffer (sf
->minibuffer_window
,
1787 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1788 minibuf_window
= sf
->minibuffer_window
;
1791 /* I think this should be done with a hook. */
1792 #ifdef HAVE_WINDOW_SYSTEM
1793 if (FRAME_WINDOW_P (XFRAME (frame
)))
1794 x_make_frame_invisible (XFRAME (frame
));
1797 /* Make menu bar update for the Buffers and Frames menus. */
1798 windows_or_buffers_changed
++;
1803 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1805 doc
: /* Make the frame FRAME into an icon.
1806 If omitted, FRAME defaults to the currently selected frame. */)
1810 frame
= selected_frame
;
1812 CHECK_LIVE_FRAME (frame
);
1814 #if 0 /* This isn't logically necessary, and it can do GC. */
1815 /* Don't let the frame remain selected. */
1816 if (EQ (frame
, selected_frame
))
1817 Fhandle_switch_frame (next_frame (frame
, Qt
));
1820 /* Don't allow minibuf_window to remain on a deleted frame. */
1821 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1823 struct frame
*sf
= XFRAME (selected_frame
);
1824 Fset_window_buffer (sf
->minibuffer_window
,
1825 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1826 minibuf_window
= sf
->minibuffer_window
;
1829 /* I think this should be done with a hook. */
1830 #ifdef HAVE_WINDOW_SYSTEM
1831 if (FRAME_WINDOW_P (XFRAME (frame
)))
1832 x_iconify_frame (XFRAME (frame
));
1835 /* Make menu bar update for the Buffers and Frames menus. */
1836 windows_or_buffers_changed
++;
1841 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1843 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1844 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1845 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1846 On graphical displays, invisible frames are not updated and are
1847 usually not displayed at all, even in a window system's \"taskbar\".
1849 If FRAME is a text-only terminal frame, this always returns t.
1850 Such frames are always considered visible, whether or not they are
1851 currently being displayed on the terminal. */)
1854 CHECK_LIVE_FRAME (frame
);
1856 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1858 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1860 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1865 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1867 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1870 Lisp_Object tail
, frame
;
1875 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1877 frame
= XCAR (tail
);
1878 if (!FRAMEP (frame
))
1881 if (FRAME_VISIBLE_P (f
))
1882 value
= Fcons (frame
, value
);
1888 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1889 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1890 If FRAME is invisible or iconified, make it visible.
1891 If you don't specify a frame, the selected frame is used.
1892 If Emacs is displaying on an ordinary terminal or some other device which
1893 doesn't support multiple overlapping frames, this function selects FRAME. */)
1898 frame
= selected_frame
;
1900 CHECK_LIVE_FRAME (frame
);
1904 if (FRAME_TERMCAP_P (f
))
1905 /* On a text-only terminal select FRAME. */
1906 Fselect_frame (frame
, Qnil
);
1908 /* Do like the documentation says. */
1909 Fmake_frame_visible (frame
);
1911 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1912 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
1917 /* Should we have a corresponding function called Flower_Power? */
1918 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1919 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1920 If you don't specify a frame, the selected frame is used.
1921 If Emacs is displaying on an ordinary terminal or some other device which
1922 doesn't support multiple overlapping frames, this function does nothing. */)
1928 frame
= selected_frame
;
1930 CHECK_LIVE_FRAME (frame
);
1934 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1935 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
1941 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1943 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1944 In other words, switch-frame events caused by events in FRAME will
1945 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1946 FOCUS-FRAME after reading an event typed at FRAME.
1948 If FOCUS-FRAME is omitted or nil, any existing redirection is
1949 cancelled, and the frame again receives its own keystrokes.
1951 Focus redirection is useful for temporarily redirecting keystrokes to
1952 a surrogate minibuffer frame when a frame doesn't have its own
1955 A frame's focus redirection can be changed by `select-frame'. If frame
1956 FOO is selected, and then a different frame BAR is selected, any
1957 frames redirecting their focus to FOO are shifted to redirect their
1958 focus to BAR. This allows focus redirection to work properly when the
1959 user switches from one frame to another using `select-window'.
1961 This means that a frame whose focus is redirected to itself is treated
1962 differently from a frame whose focus is redirected to nil; the former
1963 is affected by `select-frame', while the latter is not.
1965 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1966 (Lisp_Object frame
, Lisp_Object focus_frame
)
1970 /* Note that we don't check for a live frame here. It's reasonable
1971 to redirect the focus of a frame you're about to delete, if you
1972 know what other frame should receive those keystrokes. */
1973 CHECK_FRAME (frame
);
1975 if (! NILP (focus_frame
))
1976 CHECK_LIVE_FRAME (focus_frame
);
1980 f
->focus_frame
= focus_frame
;
1982 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
1983 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
1989 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1990 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1991 This returns nil if FRAME's focus is not redirected.
1992 See `redirect-frame-focus'. */)
1995 CHECK_LIVE_FRAME (frame
);
1997 return FRAME_FOCUS_FRAME (XFRAME (frame
));
2002 /* Return the value of frame parameter PROP in frame FRAME. */
2005 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
2007 register Lisp_Object tem
;
2009 tem
= Fassq (prop
, frame
->param_alist
);
2015 /* Return the buffer-predicate of the selected frame. */
2018 frame_buffer_predicate (Lisp_Object frame
)
2020 return XFRAME (frame
)->buffer_predicate
;
2023 /* Return the buffer-list of the selected frame. */
2026 frame_buffer_list (Lisp_Object frame
)
2028 return XFRAME (frame
)->buffer_list
;
2031 /* Set the buffer-list of the selected frame. */
2034 set_frame_buffer_list (Lisp_Object frame
, Lisp_Object list
)
2036 XFRAME (frame
)->buffer_list
= list
;
2039 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2042 frames_discard_buffer (Lisp_Object buffer
)
2044 Lisp_Object frame
, tail
;
2046 FOR_EACH_FRAME (tail
, frame
)
2048 XFRAME (frame
)->buffer_list
2049 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
2050 XFRAME (frame
)->buried_buffer_list
2051 = Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
);
2055 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2056 If the alist already has an element for PROP, we change it. */
2059 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2061 register Lisp_Object tem
;
2063 tem
= Fassq (prop
, *alistptr
);
2065 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2071 frame_name_fnn_p (char *str
, EMACS_INT len
)
2073 if (len
> 1 && str
[0] == 'F')
2077 strtol (str
+ 1, &end_ptr
, 10);
2079 if (end_ptr
== str
+ len
)
2085 /* Set the name of the terminal frame. Also used by MSDOS frames.
2086 Modeled after x_set_name which is used for WINDOW frames. */
2089 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2091 f
->explicit_name
= ! NILP (name
);
2093 /* If NAME is nil, set the name to F<num>. */
2098 /* Check for no change needed in this very common case
2099 before we do any consing. */
2100 if (frame_name_fnn_p (SDATA (f
->name
),
2105 sprintf (namebuf
, "F%d", tty_frame_count
);
2106 name
= build_string (namebuf
);
2110 CHECK_STRING (name
);
2112 /* Don't change the name if it's already NAME. */
2113 if (! NILP (Fstring_equal (name
, f
->name
)))
2116 /* Don't allow the user to set the frame name to F<num>, so it
2117 doesn't clash with the names we generate for terminal frames. */
2118 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
2119 error ("Frame names of the form F<num> are usurped by Emacs");
2123 update_mode_lines
= 1;
2127 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2129 register Lisp_Object old_alist_elt
;
2131 /* The buffer-list parameters are stored in a special place and not
2133 if (EQ (prop
, Qbuffer_list
))
2135 f
->buffer_list
= val
;
2138 if (EQ (prop
, Qburied_buffer_list
))
2140 f
->buried_buffer_list
= val
;
2144 /* If PROP is a symbol which is supposed to have frame-local values,
2145 and it is set up based on this frame, switch to the global
2146 binding. That way, we can create or alter the frame-local binding
2147 without messing up the symbol's status. */
2150 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2152 switch (sym
->redirect
)
2154 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2155 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2156 case SYMBOL_LOCALIZED
:
2157 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2158 if (blv
->frame_local
&& BLV_FOUND (blv
) && XFRAME (blv
->where
) == f
)
2159 swap_in_global_binding (sym
);
2166 /* The tty color needed to be set before the frame's parameter
2167 alist was updated with the new value. This is not true any more,
2168 but we still do this test early on. */
2169 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2170 && f
== FRAME_TTY (f
)->previous_frame
)
2171 /* Force redisplay of this tty. */
2172 FRAME_TTY (f
)->previous_frame
= NULL
;
2174 /* Update the frame parameter alist. */
2175 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2176 if (EQ (old_alist_elt
, Qnil
))
2177 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2179 Fsetcdr (old_alist_elt
, val
);
2181 /* Update some other special parameters in their special places
2182 in addition to the alist. */
2184 if (EQ (prop
, Qbuffer_predicate
))
2185 f
->buffer_predicate
= val
;
2187 if (! FRAME_WINDOW_P (f
))
2189 if (EQ (prop
, Qmenu_bar_lines
))
2190 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2191 else if (EQ (prop
, Qname
))
2192 set_term_frame_name (f
, val
);
2195 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2197 if (! MINI_WINDOW_P (XWINDOW (val
)))
2198 error ("Surrogate minibuffer windows must be minibuffer windows");
2200 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2201 && !EQ (val
, f
->minibuffer_window
))
2202 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2204 /* Install the chosen minibuffer window, with proper buffer. */
2205 f
->minibuffer_window
= val
;
2209 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2210 doc
: /* Return the parameters-alist of frame FRAME.
2211 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2212 The meaningful PARMs depend on the kind of frame.
2213 If FRAME is omitted, return information on the currently selected frame. */)
2219 struct gcpro gcpro1
;
2222 frame
= selected_frame
;
2224 CHECK_FRAME (frame
);
2227 if (!FRAME_LIVE_P (f
))
2230 alist
= Fcopy_alist (f
->param_alist
);
2233 if (!FRAME_WINDOW_P (f
))
2235 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2236 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2239 /* If the frame's parameter alist says the colors are
2240 unspecified and reversed, take the frame's background pixel
2241 for foreground and vice versa. */
2242 elt
= Fassq (Qforeground_color
, alist
);
2243 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2245 if (strncmp (SDATA (XCDR (elt
)),
2247 SCHARS (XCDR (elt
))) == 0)
2248 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2249 else if (strncmp (SDATA (XCDR (elt
)),
2251 SCHARS (XCDR (elt
))) == 0)
2252 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2255 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2256 elt
= Fassq (Qbackground_color
, alist
);
2257 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2259 if (strncmp (SDATA (XCDR (elt
)),
2261 SCHARS (XCDR (elt
))) == 0)
2262 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2263 else if (strncmp (SDATA (XCDR (elt
)),
2265 SCHARS (XCDR (elt
))) == 0)
2266 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2269 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2270 store_in_alist (&alist
, intern ("font"),
2271 build_string (FRAME_MSDOS_P (f
)
2273 : FRAME_W32_P (f
) ? "w32term"
2276 store_in_alist (&alist
, Qname
, f
->name
);
2277 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2278 store_in_alist (&alist
, Qheight
, make_number (height
));
2279 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2280 store_in_alist (&alist
, Qwidth
, make_number (width
));
2281 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2282 store_in_alist (&alist
, Qminibuffer
,
2283 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2284 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2285 : FRAME_MINIBUF_WINDOW (f
)));
2286 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2287 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2288 store_in_alist (&alist
, Qburied_buffer_list
, XFRAME (frame
)->buried_buffer_list
);
2290 /* I think this should be done with a hook. */
2291 #ifdef HAVE_WINDOW_SYSTEM
2292 if (FRAME_WINDOW_P (f
))
2293 x_report_frame_params (f
, &alist
);
2297 /* This ought to be correct in f->param_alist for an X frame. */
2299 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2300 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2308 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2309 doc
: /* Return FRAME's value for parameter PARAMETER.
2310 If FRAME is nil, describe the currently selected frame. */)
2311 (Lisp_Object frame
, Lisp_Object parameter
)
2317 frame
= selected_frame
;
2319 CHECK_FRAME (frame
);
2320 CHECK_SYMBOL (parameter
);
2325 if (FRAME_LIVE_P (f
))
2327 /* Avoid consing in frequent cases. */
2328 if (EQ (parameter
, Qname
))
2330 #ifdef HAVE_X_WINDOWS
2331 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2332 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2333 #endif /* HAVE_X_WINDOWS */
2334 else if (EQ (parameter
, Qbackground_color
)
2335 || EQ (parameter
, Qforeground_color
))
2337 value
= Fassq (parameter
, f
->param_alist
);
2340 value
= XCDR (value
);
2341 /* Fframe_parameters puts the actual fg/bg color names,
2342 even if f->param_alist says otherwise. This is
2343 important when param_alist's notion of colors is
2344 "unspecified". We need to do the same here. */
2345 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2347 const char *color_name
;
2350 if (EQ (parameter
, Qbackground_color
))
2352 color_name
= SDATA (value
);
2353 csz
= SCHARS (value
);
2354 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2355 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2356 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2357 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2359 else if (EQ (parameter
, Qforeground_color
))
2361 color_name
= SDATA (value
);
2362 csz
= SCHARS (value
);
2363 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2364 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2365 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2366 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2371 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2373 else if (EQ (parameter
, Qdisplay_type
)
2374 || EQ (parameter
, Qbackground_mode
))
2375 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2377 /* FIXME: Avoid this code path at all (as well as code duplication)
2378 by sharing more code with Fframe_parameters. */
2379 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2386 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2387 Smodify_frame_parameters
, 2, 2, 0,
2388 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2389 If FRAME is nil, it defaults to the selected frame.
2390 ALIST is an alist of parameters to change and their new values.
2391 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2392 The meaningful PARMs depend on the kind of frame.
2393 Undefined PARMs are ignored, but stored in the frame's parameter list
2394 so that `frame-parameters' will return them.
2396 The value of frame parameter FOO can also be accessed
2397 as a frame-local binding for the variable FOO, if you have
2398 enabled such bindings for that variable with `make-variable-frame-local'.
2399 Note that this functionality is obsolete as of Emacs 22.2, and its
2400 use is not recommended. Explicitly check for a frame-parameter instead. */)
2401 (Lisp_Object frame
, Lisp_Object alist
)
2404 register Lisp_Object tail
, prop
, val
;
2406 if (EQ (frame
, Qnil
))
2407 frame
= selected_frame
;
2408 CHECK_LIVE_FRAME (frame
);
2411 /* I think this should be done with a hook. */
2412 #ifdef HAVE_WINDOW_SYSTEM
2413 if (FRAME_WINDOW_P (f
))
2414 x_set_frame_parameters (f
, alist
);
2418 if (FRAME_MSDOS_P (f
))
2419 IT_set_frame_parameters (f
, alist
);
2424 int length
= XINT (Flength (alist
));
2427 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2429 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2431 /* Extract parm names and values into those vectors. */
2434 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2439 parms
[i
] = Fcar (elt
);
2440 values
[i
] = Fcdr (elt
);
2444 /* Now process them in reverse of specified order. */
2445 for (i
--; i
>= 0; i
--)
2449 store_frame_param (f
, prop
, val
);
2451 /* Changing the background color might change the background
2452 mode, so that we have to load new defface specs.
2453 Call frame-set-background-mode to do that. */
2454 if (EQ (prop
, Qbackground_color
))
2455 call1 (Qframe_set_background_mode
, frame
);
2461 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2463 doc
: /* Height in pixels of a line in the font in frame FRAME.
2464 If FRAME is omitted, the selected frame is used.
2465 For a terminal frame, the value is always 1. */)
2471 frame
= selected_frame
;
2472 CHECK_FRAME (frame
);
2475 #ifdef HAVE_WINDOW_SYSTEM
2476 if (FRAME_WINDOW_P (f
))
2477 return make_number (x_char_height (f
));
2480 return make_number (1);
2484 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2486 doc
: /* Width in pixels of characters in the font in frame FRAME.
2487 If FRAME is omitted, the selected frame is used.
2488 On a graphical screen, the width is the standard width of the default font.
2489 For a terminal screen, the value is always 1. */)
2495 frame
= selected_frame
;
2496 CHECK_FRAME (frame
);
2499 #ifdef HAVE_WINDOW_SYSTEM
2500 if (FRAME_WINDOW_P (f
))
2501 return make_number (x_char_width (f
));
2504 return make_number (1);
2507 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2508 Sframe_pixel_height
, 0, 1, 0,
2509 doc
: /* Return a FRAME's height in pixels.
2510 If FRAME is omitted, the selected frame is used. The exact value
2511 of the result depends on the window-system and toolkit in use:
2513 In the Gtk+ version of Emacs, it includes only any window (including
2514 the minibuffer or eacho area), mode line, and header line. It does not
2515 include the tool bar or menu bar.
2517 With the Motif or Lucid toolkits, it also includes the tool bar (but
2520 In a graphical version with no toolkit, it includes both the tool bar
2523 For a text-only terminal, it includes the menu bar. In this case, the
2524 result is really in characters rather than pixels (i.e., is identical
2525 to `frame-height'). */)
2531 frame
= selected_frame
;
2532 CHECK_FRAME (frame
);
2535 #ifdef HAVE_WINDOW_SYSTEM
2536 if (FRAME_WINDOW_P (f
))
2537 return make_number (x_pixel_height (f
));
2540 return make_number (FRAME_LINES (f
));
2543 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2544 Sframe_pixel_width
, 0, 1, 0,
2545 doc
: /* Return FRAME's width in pixels.
2546 For a terminal frame, the result really gives the width in characters.
2547 If FRAME is omitted, the selected frame is used. */)
2553 frame
= selected_frame
;
2554 CHECK_FRAME (frame
);
2557 #ifdef HAVE_WINDOW_SYSTEM
2558 if (FRAME_WINDOW_P (f
))
2559 return make_number (x_pixel_width (f
));
2562 return make_number (FRAME_COLS (f
));
2565 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2566 Stool_bar_pixel_width
, 0, 1, 0,
2567 doc
: /* Return width in pixels of FRAME's tool bar.
2568 The result is greater than zero only when the tool bar is on the left
2569 or right side of FRAME. If FRAME is omitted, the selected frame is
2576 frame
= selected_frame
;
2577 CHECK_FRAME (frame
);
2580 #ifdef FRAME_TOOLBAR_WIDTH
2581 if (FRAME_WINDOW_P (f
))
2582 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2584 return make_number (0);
2587 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2588 doc
: /* Specify that the frame FRAME has LINES lines.
2589 Optional third arg non-nil means that redisplay should use LINES lines
2590 but that the idea of the actual height of the frame should not be changed. */)
2591 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2593 register struct frame
*f
;
2595 CHECK_NUMBER (lines
);
2597 frame
= selected_frame
;
2598 CHECK_LIVE_FRAME (frame
);
2601 /* I think this should be done with a hook. */
2602 #ifdef HAVE_WINDOW_SYSTEM
2603 if (FRAME_WINDOW_P (f
))
2605 if (XINT (lines
) != FRAME_LINES (f
))
2606 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2607 do_pending_window_change (0);
2611 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2615 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2616 doc
: /* Specify that the frame FRAME has COLS columns.
2617 Optional third arg non-nil means that redisplay should use COLS columns
2618 but that the idea of the actual width of the frame should not be changed. */)
2619 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2621 register struct frame
*f
;
2622 CHECK_NUMBER (cols
);
2624 frame
= selected_frame
;
2625 CHECK_LIVE_FRAME (frame
);
2628 /* I think this should be done with a hook. */
2629 #ifdef HAVE_WINDOW_SYSTEM
2630 if (FRAME_WINDOW_P (f
))
2632 if (XINT (cols
) != FRAME_COLS (f
))
2633 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2634 do_pending_window_change (0);
2638 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2642 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2643 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2644 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2646 register struct frame
*f
;
2648 CHECK_LIVE_FRAME (frame
);
2649 CHECK_NUMBER (cols
);
2650 CHECK_NUMBER (rows
);
2653 /* I think this should be done with a hook. */
2654 #ifdef HAVE_WINDOW_SYSTEM
2655 if (FRAME_WINDOW_P (f
))
2657 if (XINT (rows
) != FRAME_LINES (f
)
2658 || XINT (cols
) != FRAME_COLS (f
)
2659 || f
->new_text_lines
|| f
->new_text_cols
)
2660 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2661 do_pending_window_change (0);
2665 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2670 DEFUN ("set-frame-position", Fset_frame_position
,
2671 Sset_frame_position
, 3, 3, 0,
2672 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2673 This is actually the position of the upper left corner of the frame.
2674 Negative values for XOFFSET or YOFFSET are interpreted relative to
2675 the rightmost or bottommost possible position (that stays within the screen). */)
2676 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2678 register struct frame
*f
;
2680 CHECK_LIVE_FRAME (frame
);
2681 CHECK_NUMBER (xoffset
);
2682 CHECK_NUMBER (yoffset
);
2685 /* I think this should be done with a hook. */
2686 #ifdef HAVE_WINDOW_SYSTEM
2687 if (FRAME_WINDOW_P (f
))
2688 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2695 /***********************************************************************
2697 ***********************************************************************/
2699 /* Connect the frame-parameter names for X frames
2700 to the ways of passing the parameter values to the window system.
2702 The name of a parameter, as a Lisp symbol,
2703 has an `x-frame-parameter' property which is an integer in Lisp
2704 that is an index in this table. */
2706 struct frame_parm_table
{
2708 Lisp_Object
*variable
;
2711 static const struct frame_parm_table frame_parms
[] =
2713 {"auto-raise", &Qauto_raise
},
2714 {"auto-lower", &Qauto_lower
},
2715 {"background-color", 0},
2716 {"border-color", &Qborder_color
},
2717 {"border-width", &Qborder_width
},
2718 {"cursor-color", &Qcursor_color
},
2719 {"cursor-type", &Qcursor_type
},
2721 {"foreground-color", 0},
2722 {"icon-name", &Qicon_name
},
2723 {"icon-type", &Qicon_type
},
2724 {"internal-border-width", &Qinternal_border_width
},
2725 {"menu-bar-lines", &Qmenu_bar_lines
},
2726 {"mouse-color", &Qmouse_color
},
2728 {"scroll-bar-width", &Qscroll_bar_width
},
2730 {"unsplittable", &Qunsplittable
},
2731 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2732 {"visibility", &Qvisibility
},
2733 {"tool-bar-lines", &Qtool_bar_lines
},
2734 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2735 {"scroll-bar-background", &Qscroll_bar_background
},
2736 {"screen-gamma", &Qscreen_gamma
},
2737 {"line-spacing", &Qline_spacing
},
2738 {"left-fringe", &Qleft_fringe
},
2739 {"right-fringe", &Qright_fringe
},
2740 {"wait-for-wm", &Qwait_for_wm
},
2741 {"fullscreen", &Qfullscreen
},
2742 {"font-backend", &Qfont_backend
},
2744 {"sticky", &Qsticky
},
2745 {"tool-bar-position", &Qtool_bar_position
},
2748 #ifdef HAVE_WINDOW_SYSTEM
2750 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2751 wanted positions of the WM window (not Emacs window).
2752 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2753 window (FRAME_X_WINDOW).
2757 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2759 int newwidth
= FRAME_COLS (f
);
2760 int newheight
= FRAME_LINES (f
);
2761 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2763 *top_pos
= f
->top_pos
;
2764 *left_pos
= f
->left_pos
;
2766 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2770 ph
= x_display_pixel_height (dpyinfo
);
2771 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2772 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2773 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2777 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2781 pw
= x_display_pixel_width (dpyinfo
);
2782 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2783 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2784 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2789 *height
= newheight
;
2793 /* Change the parameters of frame F as specified by ALIST.
2794 If a parameter is not specially recognized, do nothing special;
2795 otherwise call the `x_set_...' function for that parameter.
2796 Except for certain geometry properties, always call store_frame_param
2797 to store the new value in the parameter alist. */
2800 x_set_frame_parameters (FRAME_PTR f
, Lisp_Object alist
)
2804 /* If both of these parameters are present, it's more efficient to
2805 set them both at once. So we wait until we've looked at the
2806 entire list before we set them. */
2810 Lisp_Object left
, top
;
2812 /* Same with these. */
2813 Lisp_Object icon_left
, icon_top
;
2815 /* Record in these vectors all the parms specified. */
2817 Lisp_Object
*values
;
2819 int left_no_change
= 0, top_no_change
= 0;
2820 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2821 int size_changed
= 0;
2822 struct gcpro gcpro1
, gcpro2
;
2825 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2828 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2829 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2831 /* Extract parm names and values into those vectors. */
2834 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2839 parms
[i
] = Fcar (elt
);
2840 values
[i
] = Fcdr (elt
);
2843 /* TAIL and ALIST are not used again below here. */
2844 alist
= tail
= Qnil
;
2846 GCPRO2 (*parms
, *values
);
2850 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2851 because their values appear in VALUES and strings are not valid. */
2852 top
= left
= Qunbound
;
2853 icon_left
= icon_top
= Qunbound
;
2855 /* Provide default values for HEIGHT and WIDTH. */
2856 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2857 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2859 /* Process foreground_color and background_color before anything else.
2860 They are independent of other properties, but other properties (e.g.,
2861 cursor_color) are dependent upon them. */
2862 /* Process default font as well, since fringe widths depends on it. */
2863 for (p
= 0; p
< i
; p
++)
2865 Lisp_Object prop
, val
;
2869 if (EQ (prop
, Qforeground_color
)
2870 || EQ (prop
, Qbackground_color
)
2871 || EQ (prop
, Qfont
))
2873 register Lisp_Object param_index
, old_value
;
2875 old_value
= get_frame_param (f
, prop
);
2876 if (NILP (Fequal (val
, old_value
)))
2878 store_frame_param (f
, prop
, val
);
2880 param_index
= Fget (prop
, Qx_frame_parameter
);
2881 if (NATNUMP (param_index
)
2882 && (XFASTINT (param_index
)
2883 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2884 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2885 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2890 /* Now process them in reverse of specified order. */
2891 for (i
--; i
>= 0; i
--)
2893 Lisp_Object prop
, val
;
2898 if (EQ (prop
, Qwidth
) && NATNUMP (val
))
2901 width
= XFASTINT (val
);
2903 else if (EQ (prop
, Qheight
) && NATNUMP (val
))
2906 height
= XFASTINT (val
);
2908 else if (EQ (prop
, Qtop
))
2910 else if (EQ (prop
, Qleft
))
2912 else if (EQ (prop
, Qicon_top
))
2914 else if (EQ (prop
, Qicon_left
))
2916 else if (EQ (prop
, Qforeground_color
)
2917 || EQ (prop
, Qbackground_color
)
2918 || EQ (prop
, Qfont
))
2919 /* Processed above. */
2923 register Lisp_Object param_index
, old_value
;
2925 old_value
= get_frame_param (f
, prop
);
2927 store_frame_param (f
, prop
, val
);
2929 param_index
= Fget (prop
, Qx_frame_parameter
);
2930 if (NATNUMP (param_index
)
2931 && (XFASTINT (param_index
)
2932 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2933 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2934 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2938 /* Don't die if just one of these was set. */
2939 if (EQ (left
, Qunbound
))
2942 if (f
->left_pos
< 0)
2943 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2945 XSETINT (left
, f
->left_pos
);
2947 if (EQ (top
, Qunbound
))
2951 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2953 XSETINT (top
, f
->top_pos
);
2956 /* If one of the icon positions was not set, preserve or default it. */
2957 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
2959 icon_left_no_change
= 1;
2960 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2961 if (NILP (icon_left
))
2962 XSETINT (icon_left
, 0);
2964 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
2966 icon_top_no_change
= 1;
2967 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2968 if (NILP (icon_top
))
2969 XSETINT (icon_top
, 0);
2972 /* Don't set these parameters unless they've been explicitly
2973 specified. The window might be mapped or resized while we're in
2974 this function, and we don't want to override that unless the lisp
2975 code has asked for it.
2977 Don't set these parameters unless they actually differ from the
2978 window's current parameters; the window may not actually exist
2983 check_frame_size (f
, &height
, &width
);
2985 XSETFRAME (frame
, f
);
2988 && (width
!= FRAME_COLS (f
)
2989 || height
!= FRAME_LINES (f
)
2990 || f
->new_text_lines
|| f
->new_text_cols
))
2991 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2993 if ((!NILP (left
) || !NILP (top
))
2994 && ! (left_no_change
&& top_no_change
)
2995 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2996 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3001 /* Record the signs. */
3002 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3003 if (EQ (left
, Qminus
))
3004 f
->size_hint_flags
|= XNegative
;
3005 else if (INTEGERP (left
))
3007 leftpos
= XINT (left
);
3009 f
->size_hint_flags
|= XNegative
;
3011 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3012 && CONSP (XCDR (left
))
3013 && INTEGERP (XCAR (XCDR (left
))))
3015 leftpos
= - XINT (XCAR (XCDR (left
)));
3016 f
->size_hint_flags
|= XNegative
;
3018 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3019 && CONSP (XCDR (left
))
3020 && INTEGERP (XCAR (XCDR (left
))))
3022 leftpos
= XINT (XCAR (XCDR (left
)));
3025 if (EQ (top
, Qminus
))
3026 f
->size_hint_flags
|= YNegative
;
3027 else if (INTEGERP (top
))
3029 toppos
= XINT (top
);
3031 f
->size_hint_flags
|= YNegative
;
3033 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3034 && CONSP (XCDR (top
))
3035 && INTEGERP (XCAR (XCDR (top
))))
3037 toppos
= - XINT (XCAR (XCDR (top
)));
3038 f
->size_hint_flags
|= YNegative
;
3040 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
3041 && CONSP (XCDR (top
))
3042 && INTEGERP (XCAR (XCDR (top
))))
3044 toppos
= XINT (XCAR (XCDR (top
)));
3048 /* Store the numeric value of the position. */
3049 f
->top_pos
= toppos
;
3050 f
->left_pos
= leftpos
;
3052 f
->win_gravity
= NorthWestGravity
;
3054 /* Actually set that position, and convert to absolute. */
3055 x_set_offset (f
, leftpos
, toppos
, -1);
3058 if ((!NILP (icon_left
) || !NILP (icon_top
))
3059 && ! (icon_left_no_change
&& icon_top_no_change
))
3060 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3067 /* Insert a description of internally-recorded parameters of frame X
3068 into the parameter alist *ALISTPTR that is to be given to the user.
3069 Only parameters that are specific to the X window system
3070 and whose values are not correctly recorded in the frame's
3071 param_alist need to be considered here. */
3074 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3079 /* Represent negative positions (off the top or left screen edge)
3080 in a way that Fmodify_frame_parameters will understand correctly. */
3081 XSETINT (tem
, f
->left_pos
);
3082 if (f
->left_pos
>= 0)
3083 store_in_alist (alistptr
, Qleft
, tem
);
3085 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3087 XSETINT (tem
, f
->top_pos
);
3088 if (f
->top_pos
>= 0)
3089 store_in_alist (alistptr
, Qtop
, tem
);
3091 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3093 store_in_alist (alistptr
, Qborder_width
,
3094 make_number (f
->border_width
));
3095 store_in_alist (alistptr
, Qinternal_border_width
,
3096 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3097 store_in_alist (alistptr
, Qleft_fringe
,
3098 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3099 store_in_alist (alistptr
, Qright_fringe
,
3100 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3101 store_in_alist (alistptr
, Qscroll_bar_width
,
3102 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3104 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3105 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3106 /* nil means "use default width"
3107 for non-toolkit scroll bar.
3108 ruler-mode.el depends on this. */
3110 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
3111 store_in_alist (alistptr
, Qwindow_id
,
3112 build_string (buf
));
3113 #ifdef HAVE_X_WINDOWS
3114 #ifdef USE_X_TOOLKIT
3115 /* Tooltip frame may not have this widget. */
3116 if (FRAME_X_OUTPUT (f
)->widget
)
3118 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
3119 store_in_alist (alistptr
, Qouter_window_id
,
3120 build_string (buf
));
3122 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3123 FRAME_SAMPLE_VISIBILITY (f
);
3124 store_in_alist (alistptr
, Qvisibility
,
3125 (FRAME_VISIBLE_P (f
) ? Qt
3126 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3127 store_in_alist (alistptr
, Qdisplay
,
3128 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3130 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3133 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3134 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3135 store_in_alist (alistptr
, Qparent_id
, tem
);
3136 store_in_alist (alistptr
, Qtool_bar_position
, f
->tool_bar_position
);
3140 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3141 the previous value of that parameter, NEW_VALUE is the new value. */
3144 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3146 if (NILP (new_value
))
3147 f
->want_fullscreen
= FULLSCREEN_NONE
;
3148 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3149 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3150 else if (EQ (new_value
, Qfullwidth
))
3151 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3152 else if (EQ (new_value
, Qfullheight
))
3153 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3154 else if (EQ (new_value
, Qmaximized
))
3155 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3157 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3158 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3162 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3163 the previous value of that parameter, NEW_VALUE is the new value. */
3166 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3168 if (NILP (new_value
))
3169 f
->extra_line_spacing
= 0;
3170 else if (NATNUMP (new_value
))
3171 f
->extra_line_spacing
= XFASTINT (new_value
);
3173 signal_error ("Invalid line-spacing", new_value
);
3174 if (FRAME_VISIBLE_P (f
))
3179 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3180 the previous value of that parameter, NEW_VALUE is the new value. */
3183 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3185 Lisp_Object bgcolor
;
3187 if (NILP (new_value
))
3189 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3190 /* The value 0.4545 is the normal viewing gamma. */
3191 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3193 signal_error ("Invalid screen-gamma", new_value
);
3195 /* Apply the new gamma value to the frame background. */
3196 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3197 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3199 Lisp_Object index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3201 && (XFASTINT (index
)
3202 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3203 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3204 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3208 Fclear_face_cache (Qnil
);
3213 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3215 Lisp_Object font_object
, font_param
= Qnil
;
3218 /* Set the frame parameter back to the old value because we may
3219 fail to use ARG as the new parameter value. */
3220 store_frame_param (f
, Qfont
, oldval
);
3222 /* ARG is a fontset name, a font name, a cons of fontset name and a
3223 font object, or a font object. In the last case, this function
3228 fontset
= fs_query_fontset (arg
, 0);
3231 font_object
= font_open_by_name (f
, SDATA (arg
));
3232 if (NILP (font_object
))
3233 error ("Font `%s' is not defined", SDATA (arg
));
3234 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3236 else if (fontset
> 0)
3238 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3240 font_object
= font_open_by_name (f
, SDATA (ascii_font
));
3241 if (NILP (font_object
))
3242 error ("Font `%s' is not defined", SDATA (arg
));
3243 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3246 error ("The default fontset can't be used for a frame font");
3248 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3250 /* This is the case that the ASCII font of F's fontset XCAR
3251 (arg) is changed to the font XCDR (arg) by
3252 `set-fontset-font'. */
3253 fontset
= fs_query_fontset (XCAR (arg
), 0);
3255 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3256 font_object
= XCDR (arg
);
3257 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3258 font_param
= Ffont_get (font_object
, QCname
);
3260 else if (FONT_OBJECT_P (arg
))
3263 font_param
= Ffont_get (font_object
, QCname
);
3264 /* This is to store the XLFD font name in the frame parameter for
3265 backward compatibility. We should store the font-object
3266 itself in the future. */
3267 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3268 fontset
= FRAME_FONTSET (f
);
3269 /* Check if we can use the current fontset. If not, set FONTSET
3270 to -1 to generate a new fontset from FONT-OBJECT. */
3273 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3274 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3276 if (! font_match_p (spec
, font_object
))
3281 signal_error ("Invalid font", arg
);
3283 if (! NILP (Fequal (font_object
, oldval
)))
3286 x_new_font (f
, font_object
, fontset
);
3287 store_frame_param (f
, Qfont
, arg
);
3288 #ifdef HAVE_X_WINDOWS
3289 store_frame_param (f
, Qfont_param
, font_param
);
3291 /* Recalculate toolbar height. */
3292 f
->n_tool_bar_rows
= 0;
3293 /* Ensure we redraw it. */
3294 clear_current_matrices (f
);
3296 recompute_basic_faces (f
);
3298 do_pending_window_change (0);
3300 /* We used to call face-set-after-frame-default here, but it leads to
3301 recursive calls (since that function can set the `default' face's
3302 font which in turns changes the frame's `font' parameter).
3303 Also I don't know what this call is meant to do, but it seems the
3304 wrong way to do it anyway (it does a lot more work than what seems
3305 reasonable in response to a change to `font'). */
3310 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3312 if (! NILP (new_value
)
3313 && !CONSP (new_value
))
3317 CHECK_STRING (new_value
);
3318 p0
= p1
= SDATA (new_value
);
3322 while (*p1
&& ! isspace (*p1
) && *p1
!= ',') p1
++;
3324 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3330 while ((c
= *++p1
) && isspace (c
));
3334 new_value
= Fnreverse (new_value
);
3337 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3341 free_all_realized_faces (Qnil
);
3343 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3344 if (NILP (new_value
))
3346 if (NILP (old_value
))
3347 error ("No font backend available");
3348 font_update_drivers (f
, old_value
);
3349 error ("None of specified font backends are available");
3351 store_frame_param (f
, Qfont_backend
, new_value
);
3357 XSETFRAME (frame
, f
);
3358 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3359 ++face_change_count
;
3360 ++windows_or_buffers_changed
;
3366 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3368 compute_fringe_widths (f
, 1);
3369 #ifdef HAVE_X_WINDOWS
3370 /* Must adjust this so window managers report correct number of columns. */
3371 if (FRAME_X_WINDOW (f
) != 0)
3372 x_wm_set_size_hint (f
, 0, 0);
3377 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3381 if (XINT (arg
) == f
->border_width
)
3384 if (FRAME_X_WINDOW (f
) != 0)
3385 error ("Cannot change the border width of a frame");
3387 f
->border_width
= XINT (arg
);
3391 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3393 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3396 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3397 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3398 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3400 #ifdef USE_X_TOOLKIT
3401 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3402 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3405 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3408 if (FRAME_X_WINDOW (f
) != 0)
3410 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3411 SET_FRAME_GARBAGED (f
);
3412 do_pending_window_change (0);
3415 SET_FRAME_GARBAGED (f
);
3419 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3422 XSETFRAME (frame
, f
);
3425 Fmake_frame_invisible (frame
, Qt
);
3426 else if (EQ (value
, Qicon
))
3427 Ficonify_frame (frame
);
3429 Fmake_frame_visible (frame
);
3433 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3435 f
->auto_raise
= !EQ (Qnil
, arg
);
3439 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3441 f
->auto_lower
= !EQ (Qnil
, arg
);
3445 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3447 f
->no_split
= !NILP (arg
);
3451 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3453 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3454 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3455 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3456 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3458 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3460 ? vertical_scroll_bar_none
3462 ? vertical_scroll_bar_left
3464 ? vertical_scroll_bar_right
3465 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3466 ? vertical_scroll_bar_left
3467 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3468 ? vertical_scroll_bar_right
3469 : vertical_scroll_bar_none
);
3471 /* We set this parameter before creating the X window for the
3472 frame, so we can get the geometry right from the start.
3473 However, if the window hasn't been created yet, we shouldn't
3474 call x_set_window_size. */
3475 if (FRAME_X_WINDOW (f
))
3476 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3477 do_pending_window_change (0);
3482 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3484 int wid
= FRAME_COLUMN_WIDTH (f
);
3488 x_set_scroll_bar_default_width (f
);
3490 if (FRAME_X_WINDOW (f
))
3491 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3492 do_pending_window_change (0);
3494 else if (INTEGERP (arg
) && XINT (arg
) > 0
3495 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3497 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3498 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3500 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3501 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3502 if (FRAME_X_WINDOW (f
))
3503 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3504 do_pending_window_change (0);
3507 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3508 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3509 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3514 /* Return non-nil if frame F wants a bitmap icon. */
3517 x_icon_type (FRAME_PTR f
)
3521 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3529 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3536 for (i
= 0; i
< 2; i
++)
3549 else if (FLOATP (item
))
3551 alpha
= XFLOAT_DATA (item
);
3552 if (alpha
< 0.0 || 1.0 < alpha
)
3553 args_out_of_range (make_float (0.0), make_float (1.0));
3555 else if (INTEGERP (item
))
3557 ialpha
= XINT (item
);
3558 if (ialpha
< 0 || 100 < ialpha
)
3559 args_out_of_range (make_number (0), make_number (100));
3561 alpha
= ialpha
/ 100.0;
3564 wrong_type_argument (Qnumberp
, item
);
3568 for (i
= 0; i
< 2; i
++)
3569 f
->alpha
[i
] = newval
[i
];
3571 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3573 x_set_frame_alpha (f
);
3581 /* Subroutines of creating an X frame. */
3583 /* Make sure that Vx_resource_name is set to a reasonable value.
3584 Fix it up, or set it to `emacs' if it is too hopeless. */
3587 validate_x_resource_name (void)
3590 /* Number of valid characters in the resource name. */
3592 /* Number of invalid characters in the resource name. */
3597 if (!STRINGP (Vx_resource_class
))
3598 Vx_resource_class
= build_string (EMACS_CLASS
);
3600 if (STRINGP (Vx_resource_name
))
3602 unsigned char *p
= SDATA (Vx_resource_name
);
3604 len
= SBYTES (Vx_resource_name
);
3606 /* Only letters, digits, - and _ are valid in resource names.
3607 Count the valid characters and count the invalid ones. */
3608 for (i
= 0; i
< len
; i
++)
3611 if (! ((c
>= 'a' && c
<= 'z')
3612 || (c
>= 'A' && c
<= 'Z')
3613 || (c
>= '0' && c
<= '9')
3614 || c
== '-' || c
== '_'))
3621 /* Not a string => completely invalid. */
3622 bad_count
= 5, good_count
= 0;
3624 /* If name is valid already, return. */
3628 /* If name is entirely invalid, or nearly so, use `emacs'. */
3630 || (good_count
== 1 && bad_count
> 0))
3632 Vx_resource_name
= build_string ("emacs");
3636 /* Name is partly valid. Copy it and replace the invalid characters
3637 with underscores. */
3639 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3641 for (i
= 0; i
< len
; i
++)
3643 int c
= SREF (new, i
);
3644 if (! ((c
>= 'a' && c
<= 'z')
3645 || (c
>= 'A' && c
<= 'Z')
3646 || (c
>= '0' && c
<= '9')
3647 || c
== '-' || c
== '_'))
3653 extern char *x_get_string_resource (XrmDatabase
, const char *, const char *);
3654 extern Display_Info
*check_x_display_info (Lisp_Object
);
3657 /* Get specified attribute from resource database RDB.
3658 See Fx_get_resource below for other parameters. */
3661 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3663 register char *value
;
3667 CHECK_STRING (attribute
);
3668 CHECK_STRING (class);
3670 if (!NILP (component
))
3671 CHECK_STRING (component
);
3672 if (!NILP (subclass
))
3673 CHECK_STRING (subclass
);
3674 if (NILP (component
) != NILP (subclass
))
3675 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3677 validate_x_resource_name ();
3679 /* Allocate space for the components, the dots which separate them,
3680 and the final '\0'. Make them big enough for the worst case. */
3681 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3682 + (STRINGP (component
)
3683 ? SBYTES (component
) : 0)
3684 + SBYTES (attribute
)
3687 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3689 + (STRINGP (subclass
)
3690 ? SBYTES (subclass
) : 0)
3693 /* Start with emacs.FRAMENAME for the name (the specific one)
3694 and with `Emacs' for the class key (the general one). */
3695 strcpy (name_key
, SDATA (Vx_resource_name
));
3696 strcpy (class_key
, SDATA (Vx_resource_class
));
3698 strcat (class_key
, ".");
3699 strcat (class_key
, SDATA (class));
3701 if (!NILP (component
))
3703 strcat (class_key
, ".");
3704 strcat (class_key
, SDATA (subclass
));
3706 strcat (name_key
, ".");
3707 strcat (name_key
, SDATA (component
));
3710 strcat (name_key
, ".");
3711 strcat (name_key
, SDATA (attribute
));
3713 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3715 if (value
!= (char *) 0 && *value
)
3716 return build_string (value
);
3722 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3723 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3724 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3725 class, where INSTANCE is the name under which Emacs was invoked, or
3726 the name specified by the `-name' or `-rn' command-line arguments.
3728 The optional arguments COMPONENT and SUBCLASS add to the key and the
3729 class, respectively. You must specify both of them or neither.
3730 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3731 and the class is `Emacs.CLASS.SUBCLASS'. */)
3732 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3734 #ifdef HAVE_X_WINDOWS
3738 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3739 attribute
, class, component
, subclass
);
3742 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3745 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3747 return xrdb_get_resource (dpyinfo
->xrdb
,
3748 attribute
, class, component
, subclass
);
3751 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3752 /* Used when C code wants a resource value. */
3753 /* Called from oldXMenu/Create.c. */
3755 x_get_resource_string (const char *attribute
, const char *class)
3759 struct frame
*sf
= SELECTED_FRAME ();
3761 /* Allocate space for the components, the dots which separate them,
3762 and the final '\0'. */
3763 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3764 + strlen (attribute
) + 2);
3765 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3766 + strlen (class) + 2);
3768 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3769 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3771 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3772 name_key
, class_key
);
3776 /* Return the value of parameter PARAM.
3778 First search ALIST, then Vdefault_frame_alist, then the X defaults
3779 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3781 Convert the resource to the type specified by desired_type.
3783 If no default is specified, return Qunbound. If you call
3784 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3785 and don't let it get stored in any Lisp-visible variables! */
3788 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3789 const char *attribute
, const char *class, enum resource_types type
)
3791 register Lisp_Object tem
;
3793 tem
= Fassq (param
, alist
);
3797 /* If we find this parm in ALIST, clear it out
3798 so that it won't be "left over" at the end. */
3800 XSETCAR (tem
, Qnil
);
3801 /* In case the parameter appears more than once in the alist,
3803 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3804 if (CONSP (XCAR (tail
))
3805 && EQ (XCAR (XCAR (tail
)), param
))
3806 XSETCAR (XCAR (tail
), Qnil
);
3809 tem
= Fassq (param
, Vdefault_frame_alist
);
3811 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3812 look in the X resources. */
3815 if (attribute
&& dpyinfo
)
3817 tem
= display_x_get_resource (dpyinfo
,
3818 build_string (attribute
),
3819 build_string (class),
3827 case RES_TYPE_NUMBER
:
3828 return make_number (atoi (SDATA (tem
)));
3830 case RES_TYPE_BOOLEAN_NUMBER
:
3831 if (!strcmp (SDATA (tem
), "on")
3832 || !strcmp (SDATA (tem
), "true"))
3833 return make_number (1);
3834 return make_number (atoi (SDATA (tem
)));
3837 case RES_TYPE_FLOAT
:
3838 return make_float (atof (SDATA (tem
)));
3840 case RES_TYPE_BOOLEAN
:
3841 tem
= Fdowncase (tem
);
3842 if (!strcmp (SDATA (tem
), "on")
3844 || !strcmp(SDATA(tem
), "yes")
3846 || !strcmp (SDATA (tem
), "true"))
3851 case RES_TYPE_STRING
:
3854 case RES_TYPE_SYMBOL
:
3855 /* As a special case, we map the values `true' and `on'
3856 to Qt, and `false' and `off' to Qnil. */
3859 lower
= Fdowncase (tem
);
3860 if (!strcmp (SDATA (lower
), "on")
3862 || !strcmp(SDATA(lower
), "yes")
3864 || !strcmp (SDATA (lower
), "true"))
3866 else if (!strcmp (SDATA (lower
), "off")
3868 || !strcmp(SDATA(lower
), "no")
3870 || !strcmp (SDATA (lower
), "false"))
3873 return Fintern (tem
, Qnil
);
3887 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3888 const char *attribute
, const char *class,
3889 enum resource_types type
)
3891 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3892 alist
, param
, attribute
, class, type
);
3895 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3898 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3900 const char *attribute
, const char *class,
3901 enum resource_types type
)
3905 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3906 attribute
, class, type
);
3907 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3908 store_frame_param (f
, param
, value
);
3914 /* Record in frame F the specified or default value according to ALIST
3915 of the parameter named PROP (a Lisp symbol).
3916 If no value is specified for PROP, look for an X default for XPROP
3917 on the frame named NAME.
3918 If that is not found either, use the value DEFLT. */
3921 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
3922 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
3923 enum resource_types type
)
3927 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3928 if (EQ (tem
, Qunbound
))
3930 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3937 /* NS used to define x-parse-geometry in ns-win.el, but that confused
3938 make-docfile: the documentation string in ns-win.el was used for
3939 x-parse-geometry even in non-NS builds.
3941 With two definitions of x-parse-geometry in this file, various
3942 things still get confused (eg M-x apropos documentation), so that
3943 it is best if the two definitions just share the same doc-string.
3945 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3946 doc
: /* Parse a display geometry string STRING.
3947 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3948 The properties returned may include `top', `left', `height', and `width'.
3949 For X, the value of `left' or `top' may be an integer,
3950 or a list (+ N) meaning N pixels relative to top/left corner,
3951 or a list (- N) meaning -N pixels relative to bottom/right corner.
3952 On Nextstep, this just calls `ns-parse-geometry'. */)
3953 (Lisp_Object string
)
3956 call1 (Qns_parse_geometry
, string
);
3959 unsigned int width
, height
;
3962 CHECK_STRING (string
);
3964 geometry
= XParseGeometry ((char *) SDATA (string
),
3965 &x
, &y
, &width
, &height
);
3967 if (geometry
& XValue
)
3969 Lisp_Object element
;
3971 if (x
>= 0 && (geometry
& XNegative
))
3972 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3973 else if (x
< 0 && ! (geometry
& XNegative
))
3974 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3976 element
= Fcons (Qleft
, make_number (x
));
3977 result
= Fcons (element
, result
);
3980 if (geometry
& YValue
)
3982 Lisp_Object element
;
3984 if (y
>= 0 && (geometry
& YNegative
))
3985 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3986 else if (y
< 0 && ! (geometry
& YNegative
))
3987 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3989 element
= Fcons (Qtop
, make_number (y
));
3990 result
= Fcons (element
, result
);
3993 if (geometry
& WidthValue
)
3994 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3995 if (geometry
& HeightValue
)
3996 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3999 #endif /* HAVE_NS */
4003 /* Calculate the desired size and position of frame F.
4004 Return the flags saying which aspects were specified.
4006 Also set the win_gravity and size_hint_flags of F.
4008 Adjust height for toolbar if TOOLBAR_P is 1.
4010 This function does not make the coordinates positive. */
4012 #define DEFAULT_ROWS 35
4013 #define DEFAULT_COLS 80
4016 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, int toolbar_p
)
4018 register Lisp_Object tem0
, tem1
, tem2
;
4019 long window_prompting
= 0;
4020 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
4022 /* Default values if we fall through.
4023 Actually, if that happens we should get
4024 window manager prompting. */
4025 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4026 FRAME_LINES (f
) = DEFAULT_ROWS
;
4027 /* Window managers expect that if program-specified
4028 positions are not (0,0), they're intentional, not defaults. */
4032 /* Ensure that old new_text_cols and new_text_lines will not override the
4034 /* ++KFS: This was specific to W32, but seems ok for all platforms */
4035 f
->new_text_cols
= f
->new_text_lines
= 0;
4037 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4038 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4039 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4040 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4042 if (!EQ (tem0
, Qunbound
))
4044 CHECK_NUMBER (tem0
);
4045 FRAME_LINES (f
) = XINT (tem0
);
4047 if (!EQ (tem1
, Qunbound
))
4049 CHECK_NUMBER (tem1
);
4050 SET_FRAME_COLS (f
, XINT (tem1
));
4052 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4053 window_prompting
|= USSize
;
4055 window_prompting
|= PSize
;
4058 f
->scroll_bar_actual_width
4059 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4061 /* This used to be done _before_ calling x_figure_window_size, but
4062 since the height is reset here, this was really a no-op. I
4063 assume that moving it here does what Gerd intended (although he
4064 no longer can remember what that was... ++KFS, 2003-03-25. */
4066 /* Add the tool-bar height to the initial frame height so that the
4067 user gets a text display area of the size he specified with -g or
4068 via .Xdefaults. Later changes of the tool-bar height don't
4069 change the frame size. This is done so that users can create
4070 tall Emacs frames without having to guess how tall the tool-bar
4072 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4074 int margin
, relief
, bar_height
;
4076 relief
= (tool_bar_button_relief
>= 0
4077 ? tool_bar_button_relief
4078 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4080 if (INTEGERP (Vtool_bar_button_margin
)
4081 && XINT (Vtool_bar_button_margin
) > 0)
4082 margin
= XFASTINT (Vtool_bar_button_margin
);
4083 else if (CONSP (Vtool_bar_button_margin
)
4084 && INTEGERP (XCDR (Vtool_bar_button_margin
))
4085 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
4086 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4090 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4091 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4094 compute_fringe_widths (f
, 0);
4096 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4097 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4099 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4100 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4101 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4102 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4104 if (EQ (tem0
, Qminus
))
4107 window_prompting
|= YNegative
;
4109 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4110 && CONSP (XCDR (tem0
))
4111 && INTEGERP (XCAR (XCDR (tem0
))))
4113 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4114 window_prompting
|= YNegative
;
4116 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4117 && CONSP (XCDR (tem0
))
4118 && INTEGERP (XCAR (XCDR (tem0
))))
4120 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4122 else if (EQ (tem0
, Qunbound
))
4126 CHECK_NUMBER (tem0
);
4127 f
->top_pos
= XINT (tem0
);
4129 window_prompting
|= YNegative
;
4132 if (EQ (tem1
, Qminus
))
4135 window_prompting
|= XNegative
;
4137 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4138 && CONSP (XCDR (tem1
))
4139 && INTEGERP (XCAR (XCDR (tem1
))))
4141 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4142 window_prompting
|= XNegative
;
4144 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4145 && CONSP (XCDR (tem1
))
4146 && INTEGERP (XCAR (XCDR (tem1
))))
4148 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4150 else if (EQ (tem1
, Qunbound
))
4154 CHECK_NUMBER (tem1
);
4155 f
->left_pos
= XINT (tem1
);
4156 if (f
->left_pos
< 0)
4157 window_prompting
|= XNegative
;
4160 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4161 window_prompting
|= USPosition
;
4163 window_prompting
|= PPosition
;
4166 if (window_prompting
& XNegative
)
4168 if (window_prompting
& YNegative
)
4169 f
->win_gravity
= SouthEastGravity
;
4171 f
->win_gravity
= NorthEastGravity
;
4175 if (window_prompting
& YNegative
)
4176 f
->win_gravity
= SouthWestGravity
;
4178 f
->win_gravity
= NorthWestGravity
;
4181 f
->size_hint_flags
= window_prompting
;
4183 return window_prompting
;
4188 #endif /* HAVE_WINDOW_SYSTEM */
4191 frame_make_pointer_invisible (void)
4193 if (! NILP (Vmake_pointer_invisible
))
4196 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4199 f
= SELECTED_FRAME ();
4200 if (f
&& !f
->pointer_invisible
4201 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4204 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4205 f
->pointer_invisible
= 1;
4211 frame_make_pointer_visible (void)
4213 /* We don't check Vmake_pointer_invisible here in case the
4214 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4217 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4220 f
= SELECTED_FRAME ();
4221 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4222 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4224 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4225 f
->pointer_invisible
= 0;
4229 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4230 Sframe_pointer_visible_p
, 0, 1, 0,
4231 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4232 Otherwise it returns nil. FRAME omitted or nil means the
4233 selected frame. This is useful when `make-pointer-invisible' is set. */)
4237 frame
= selected_frame
;
4239 CHECK_FRAME (frame
);
4241 return (XFRAME (frame
)->pointer_invisible
? Qnil
: Qt
);
4245 /***********************************************************************
4247 ***********************************************************************/
4250 syms_of_frame (void)
4252 Qframep
= intern_c_string ("framep");
4253 staticpro (&Qframep
);
4254 Qframe_live_p
= intern_c_string ("frame-live-p");
4255 staticpro (&Qframe_live_p
);
4256 Qexplicit_name
= intern_c_string ("explicit-name");
4257 staticpro (&Qexplicit_name
);
4258 Qheight
= intern_c_string ("height");
4259 staticpro (&Qheight
);
4260 Qicon
= intern_c_string ("icon");
4262 Qminibuffer
= intern_c_string ("minibuffer");
4263 staticpro (&Qminibuffer
);
4264 Qmodeline
= intern_c_string ("modeline");
4265 staticpro (&Qmodeline
);
4266 Qonly
= intern_c_string ("only");
4268 Qwidth
= intern_c_string ("width");
4269 staticpro (&Qwidth
);
4270 Qgeometry
= intern_c_string ("geometry");
4271 staticpro (&Qgeometry
);
4272 Qicon_left
= intern_c_string ("icon-left");
4273 staticpro (&Qicon_left
);
4274 Qicon_top
= intern_c_string ("icon-top");
4275 staticpro (&Qicon_top
);
4276 Qtooltip
= intern_c_string ("tooltip");
4277 staticpro (&Qtooltip
);
4278 Qleft
= intern_c_string ("left");
4280 Qright
= intern_c_string ("right");
4281 staticpro (&Qright
);
4282 Quser_position
= intern_c_string ("user-position");
4283 staticpro (&Quser_position
);
4284 Quser_size
= intern_c_string ("user-size");
4285 staticpro (&Quser_size
);
4286 Qwindow_id
= intern_c_string ("window-id");
4287 staticpro (&Qwindow_id
);
4288 #ifdef HAVE_X_WINDOWS
4289 Qouter_window_id
= intern_c_string ("outer-window-id");
4290 staticpro (&Qouter_window_id
);
4292 Qparent_id
= intern_c_string ("parent-id");
4293 staticpro (&Qparent_id
);
4294 Qx
= intern_c_string ("x");
4296 Qw32
= intern_c_string ("w32");
4298 Qpc
= intern_c_string ("pc");
4300 Qmac
= intern_c_string ("mac");
4302 Qns
= intern_c_string ("ns");
4304 Qvisible
= intern_c_string ("visible");
4305 staticpro (&Qvisible
);
4306 Qbuffer_predicate
= intern_c_string ("buffer-predicate");
4307 staticpro (&Qbuffer_predicate
);
4308 Qbuffer_list
= intern_c_string ("buffer-list");
4309 staticpro (&Qbuffer_list
);
4310 Qburied_buffer_list
= intern_c_string ("buried-buffer-list");
4311 staticpro (&Qburied_buffer_list
);
4312 Qdisplay_type
= intern_c_string ("display-type");
4313 staticpro (&Qdisplay_type
);
4314 Qbackground_mode
= intern_c_string ("background-mode");
4315 staticpro (&Qbackground_mode
);
4316 Qnoelisp
= intern_c_string ("noelisp");
4317 staticpro (&Qnoelisp
);
4318 Qtty_color_mode
= intern_c_string ("tty-color-mode");
4319 staticpro (&Qtty_color_mode
);
4320 Qtty
= intern_c_string ("tty");
4322 Qtty_type
= intern_c_string ("tty-type");
4323 staticpro (&Qtty_type
);
4325 Qface_set_after_frame_default
= intern_c_string ("face-set-after-frame-default");
4326 staticpro (&Qface_set_after_frame_default
);
4328 Qfullwidth
= intern_c_string ("fullwidth");
4329 staticpro (&Qfullwidth
);
4330 Qfullheight
= intern_c_string ("fullheight");
4331 staticpro (&Qfullheight
);
4332 Qfullboth
= intern_c_string ("fullboth");
4333 staticpro (&Qfullboth
);
4334 Qmaximized
= intern_c_string ("maximized");
4335 staticpro (&Qmaximized
);
4336 Qx_resource_name
= intern_c_string ("x-resource-name");
4337 staticpro (&Qx_resource_name
);
4339 Qx_frame_parameter
= intern_c_string ("x-frame-parameter");
4340 staticpro (&Qx_frame_parameter
);
4342 Qterminal
= intern_c_string ("terminal");
4343 staticpro (&Qterminal
);
4344 Qterminal_live_p
= intern_c_string ("terminal-live-p");
4345 staticpro (&Qterminal_live_p
);
4348 Qns_parse_geometry
= intern_c_string ("ns-parse-geometry");
4349 staticpro (&Qns_parse_geometry
);
4355 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4357 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4358 if (frame_parms
[i
].variable
)
4360 *frame_parms
[i
].variable
= v
;
4361 staticpro (frame_parms
[i
].variable
);
4363 Fput (v
, Qx_frame_parameter
, make_number (i
));
4367 #ifdef HAVE_WINDOW_SYSTEM
4368 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4369 doc
: /* The name Emacs uses to look up X resources.
4370 `x-get-resource' uses this as the first component of the instance name
4371 when requesting resource values.
4372 Emacs initially sets `x-resource-name' to the name under which Emacs
4373 was invoked, or to the value specified with the `-name' or `-rn'
4374 switches, if present.
4376 It may be useful to bind this variable locally around a call
4377 to `x-get-resource'. See also the variable `x-resource-class'. */);
4378 Vx_resource_name
= Qnil
;
4380 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4381 doc
: /* The class Emacs uses to look up X resources.
4382 `x-get-resource' uses this as the first component of the instance class
4383 when requesting resource values.
4385 Emacs initially sets `x-resource-class' to "Emacs".
4387 Setting this variable permanently is not a reasonable thing to do,
4388 but binding this variable locally around a call to `x-get-resource'
4389 is a reasonable practice. See also the variable `x-resource-name'. */);
4390 Vx_resource_class
= build_string (EMACS_CLASS
);
4392 DEFVAR_LISP ("frame-alpha-lower-limit", &Vframe_alpha_lower_limit
,
4393 doc
: /* The lower limit of the frame opacity (alpha transparency).
4394 The value should range from 0 (invisible) to 100 (completely opaque).
4395 You can also use a floating number between 0.0 and 1.0.
4396 The default is 20. */);
4397 Vframe_alpha_lower_limit
= make_number (20);
4400 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4401 doc
: /* Alist of default values for frame creation.
4402 These may be set in your init file, like this:
4403 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4404 These override values given in window system configuration data,
4405 including X Windows' defaults database.
4406 For values specific to the first Emacs frame, see `initial-frame-alist'.
4407 For window-system specific values, see `window-system-default-frame-alist'.
4408 For values specific to the separate minibuffer frame, see
4409 `minibuffer-frame-alist'.
4410 The `menu-bar-lines' element of the list controls whether new frames
4411 have menu bars; `menu-bar-mode' works by altering this element.
4412 Setting this variable does not affect existing frames, only new ones. */);
4413 Vdefault_frame_alist
= Qnil
;
4415 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars
,
4416 doc
: /* Default position of scroll bars on this window-system. */);
4417 #ifdef HAVE_WINDOW_SYSTEM
4418 #if defined(HAVE_NTGUI) || defined(NS_IMPL_COCOA) || (defined(USE_GTK) && defined(USE_TOOLKIT_SCROLL_BARS))
4419 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4421 Vdefault_frame_scroll_bars
= Qright
;
4423 Vdefault_frame_scroll_bars
= Qleft
;
4426 Vdefault_frame_scroll_bars
= Qnil
;
4429 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4430 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4432 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4433 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4434 `mouse-position' calls this function, passing its usual return value as
4435 argument, and returns whatever this function returns.
4436 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4437 which need to do mouse handling at the Lisp level. */);
4438 Vmouse_position_function
= Qnil
;
4440 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4441 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4442 If the value is an integer, highlighting is only shown after moving the
4443 mouse, while keyboard input turns off the highlight even when the mouse
4444 is over the clickable text. However, the mouse shape still indicates
4445 when the mouse is over clickable text. */);
4446 Vmouse_highlight
= Qt
;
4448 DEFVAR_LISP ("make-pointer-invisible", &Vmake_pointer_invisible
,
4449 doc
: /* If non-nil, make pointer invisible while typing.
4450 The pointer becomes visible again when the mouse is moved. */);
4451 Vmake_pointer_invisible
= Qt
;
4453 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4454 doc
: /* Functions to be run before deleting a frame.
4455 The functions are run with one arg, the frame to be deleted.
4458 Note that functions in this list may be called just before the frame is
4459 actually deleted, or some time later (or even both when an earlier function
4460 in `delete-frame-functions' (indirectly) calls `delete-frame'
4462 Vdelete_frame_functions
= Qnil
;
4463 Qdelete_frame_functions
= intern_c_string ("delete-frame-functions");
4464 staticpro (&Qdelete_frame_functions
);
4466 DEFVAR_LISP ("menu-bar-mode", &Vmenu_bar_mode
,
4467 doc
: /* Non-nil if Menu-Bar mode is enabled.
4468 See the command `menu-bar-mode' for a description of this minor mode.
4469 Setting this variable directly does not take effect;
4470 either customize it (see the info node `Easy Customization')
4471 or call the function `menu-bar-mode'. */);
4472 Vmenu_bar_mode
= Qt
;
4474 DEFVAR_LISP ("tool-bar-mode", &Vtool_bar_mode
,
4475 doc
: /* Non-nil if Tool-Bar mode is enabled.
4476 See the command `tool-bar-mode' for a description of this minor mode.
4477 Setting this variable directly does not take effect;
4478 either customize it (see the info node `Easy Customization')
4479 or call the function `tool-bar-mode'. */);
4480 #ifdef HAVE_WINDOW_SYSTEM
4481 Vtool_bar_mode
= Qt
;
4483 Vtool_bar_mode
= Qnil
;
4486 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4487 doc
: /* Minibufferless frames use this frame's minibuffer.
4489 Emacs cannot create minibufferless frames unless this is set to an
4490 appropriate surrogate.
4492 Emacs consults this variable only when creating minibufferless
4493 frames; once the frame is created, it sticks with its assigned
4494 minibuffer, no matter what this variable is set to. This means that
4495 this variable doesn't necessarily say anything meaningful about the
4496 current set of frames, or where the minibuffer is currently being
4499 This variable is local to the current terminal and cannot be buffer-local. */);
4501 DEFVAR_BOOL ("focus-follows-mouse", &focus_follows_mouse
,
4502 doc
: /* Non-nil if window system changes focus when you move the mouse.
4503 You should set this variable to tell Emacs how your window manager
4504 handles focus, since there is no way in general for Emacs to find out
4505 automatically. See also `mouse-autoselect-window'. */);
4506 focus_follows_mouse
= 0;
4508 staticpro (&Vframe_list
);
4511 defsubr (&Sframe_live_p
);
4512 defsubr (&Swindow_system
);
4513 defsubr (&Smake_terminal_frame
);
4514 defsubr (&Shandle_switch_frame
);
4515 defsubr (&Sselect_frame
);
4516 defsubr (&Sselected_frame
);
4517 defsubr (&Sframe_list
);
4518 defsubr (&Snext_frame
);
4519 defsubr (&Sprevious_frame
);
4520 defsubr (&Sother_visible_frames_p
);
4521 defsubr (&Sdelete_frame
);
4522 defsubr (&Smouse_position
);
4523 defsubr (&Smouse_pixel_position
);
4524 defsubr (&Sset_mouse_position
);
4525 defsubr (&Sset_mouse_pixel_position
);
4527 defsubr (&Sframe_configuration
);
4528 defsubr (&Srestore_frame_configuration
);
4530 defsubr (&Smake_frame_visible
);
4531 defsubr (&Smake_frame_invisible
);
4532 defsubr (&Siconify_frame
);
4533 defsubr (&Sframe_visible_p
);
4534 defsubr (&Svisible_frame_list
);
4535 defsubr (&Sraise_frame
);
4536 defsubr (&Slower_frame
);
4537 defsubr (&Sredirect_frame_focus
);
4538 defsubr (&Sframe_focus
);
4539 defsubr (&Sframe_parameters
);
4540 defsubr (&Sframe_parameter
);
4541 defsubr (&Smodify_frame_parameters
);
4542 defsubr (&Sframe_char_height
);
4543 defsubr (&Sframe_char_width
);
4544 defsubr (&Sframe_pixel_height
);
4545 defsubr (&Sframe_pixel_width
);
4546 defsubr (&Stool_bar_pixel_width
);
4547 defsubr (&Sset_frame_height
);
4548 defsubr (&Sset_frame_width
);
4549 defsubr (&Sset_frame_size
);
4550 defsubr (&Sset_frame_position
);
4551 defsubr (&Sframe_pointer_visible_p
);
4553 #ifdef HAVE_WINDOW_SYSTEM
4554 defsubr (&Sx_get_resource
);
4555 defsubr (&Sx_parse_geometry
);