1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26 #include "character.h"
37 /* These help us bind and responding to switch-frame events. */
41 #include "blockinput.h"
43 #include "termhooks.h"
44 #include "dispextern.h"
47 #ifdef HAVE_WINDOW_SYSTEM
56 /* If we shall make pointer invisible when typing or not. */
57 Lisp_Object Vmake_pointer_invisible
;
59 #ifdef HAVE_WINDOW_SYSTEM
61 /* The name we're using in resource queries. Most often "emacs". */
63 Lisp_Object Vx_resource_name
;
65 /* The application class we're using in resource queries.
68 Lisp_Object Vx_resource_class
;
70 /* Lower limit value of the frame opacity (alpha transparency). */
72 Lisp_Object Vframe_alpha_lower_limit
;
77 Lisp_Object Qns_parse_geometry
;
80 Lisp_Object Qframep
, Qframe_live_p
;
81 Lisp_Object Qicon
, Qmodeline
;
83 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
, Qns
;
85 Lisp_Object Qdisplay_type
;
86 Lisp_Object Qbackground_mode
;
89 Lisp_Object Qx_frame_parameter
;
90 Lisp_Object Qx_resource_name
;
91 Lisp_Object Qterminal
;
92 Lisp_Object Qterminal_live_p
;
94 /* Frame parameters (set or reported). */
96 Lisp_Object Qauto_raise
, Qauto_lower
;
97 Lisp_Object Qborder_color
, Qborder_width
;
98 Lisp_Object Qcursor_color
, Qcursor_type
;
99 Lisp_Object Qgeometry
; /* Not used */
100 Lisp_Object Qheight
, Qwidth
;
101 Lisp_Object Qleft
, Qright
;
102 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
103 Lisp_Object Qinternal_border_width
;
104 Lisp_Object Qmouse_color
;
105 Lisp_Object Qminibuffer
;
106 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
107 Lisp_Object Qvisibility
;
108 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
109 Lisp_Object Qscreen_gamma
;
110 Lisp_Object Qline_spacing
;
111 Lisp_Object Quser_position
, Quser_size
;
112 Lisp_Object Qwait_for_wm
;
113 Lisp_Object Qwindow_id
;
114 #ifdef HAVE_X_WINDOWS
115 Lisp_Object Qouter_window_id
;
117 Lisp_Object Qparent_id
;
118 Lisp_Object Qtitle
, Qname
;
119 Lisp_Object Qexplicit_name
;
120 Lisp_Object Qunsplittable
;
121 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
122 Lisp_Object Vmenu_bar_mode
, Vtool_bar_mode
;
123 Lisp_Object Qleft_fringe
, Qright_fringe
;
124 Lisp_Object Qbuffer_predicate
, Qbuffer_list
, Qburied_buffer_list
;
125 Lisp_Object Qtty_color_mode
;
126 Lisp_Object Qtty
, Qtty_type
;
128 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
130 Lisp_Object Qfont_backend
;
133 Lisp_Object Qface_set_after_frame_default
;
135 Lisp_Object Vterminal_frame
;
136 Lisp_Object Vdefault_frame_alist
;
137 Lisp_Object Vdefault_frame_scroll_bars
;
138 Lisp_Object Vmouse_position_function
;
139 Lisp_Object Vmouse_highlight
;
140 static Lisp_Object Vdelete_frame_functions
, Qdelete_frame_functions
;
142 int focus_follows_mouse
;
145 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
147 struct window
*w
= XWINDOW (window
);
149 XSETFASTINT (w
->last_modified
, 0);
150 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
151 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
153 if (INTEGERP (w
->orig_top_line
))
154 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
155 if (INTEGERP (w
->orig_total_lines
))
156 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
158 /* Handle just the top child in a vertical split. */
159 if (!NILP (w
->vchild
))
160 set_menu_bar_lines_1 (w
->vchild
, n
);
162 /* Adjust all children in a horizontal split. */
163 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
165 w
= XWINDOW (window
);
166 set_menu_bar_lines_1 (window
, n
);
171 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
174 int olines
= FRAME_MENU_BAR_LINES (f
);
176 /* Right now, menu bars don't work properly in minibuf-only frames;
177 most of the commands try to apply themselves to the minibuffer
178 frame itself, and get an error because you can't switch buffers
179 in or split the minibuffer window. */
180 if (FRAME_MINIBUF_ONLY_P (f
))
183 if (INTEGERP (value
))
184 nlines
= XINT (value
);
188 if (nlines
!= olines
)
190 windows_or_buffers_changed
++;
191 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
192 FRAME_MENU_BAR_LINES (f
) = nlines
;
193 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
198 Lisp_Object Vframe_list
;
200 extern Lisp_Object Vminibuffer_list
;
201 extern Lisp_Object
get_minibuffer (int);
202 extern Lisp_Object
Fhandle_switch_frame (Lisp_Object event
);
203 extern Lisp_Object
Fredirect_frame_focus (Lisp_Object frame
, Lisp_Object focus_frame
);
204 extern Lisp_Object
x_get_focus_frame (struct frame
*frame
);
205 extern Lisp_Object QCname
, Qfont_param
;
208 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
209 doc
: /* Return non-nil if OBJECT is a frame.
210 Value is t for a termcap frame (a character-only terminal),
211 `x' for an Emacs frame that is really an X window,
212 `w32' for an Emacs frame that is a window on MS-Windows display,
213 `ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
214 `pc' for a direct-write MS-DOS frame.
215 See also `frame-live-p'. */)
219 if (!FRAMEP (object
))
221 switch (XFRAME (object
)->output_method
)
223 case output_initial
: /* The initial frame is like a termcap frame. */
226 case output_x_window
:
230 case output_msdos_raw
:
241 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
242 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
243 Value is nil if OBJECT is not a live frame. If object is a live
244 frame, the return value indicates what sort of terminal device it is
245 displayed on. See the documentation of `framep' for possible
250 return ((FRAMEP (object
)
251 && FRAME_LIVE_P (XFRAME (object
)))
256 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
257 doc
: /* The name of the window system that FRAME is displaying through.
258 The value is a symbol---for instance, 'x' for X windows.
259 The value is nil if Emacs is using a text-only terminal.
261 FRAME defaults to the currently selected frame. */)
267 frame
= selected_frame
;
269 type
= Fframep (frame
);
272 wrong_type_argument (Qframep
, frame
);
281 make_frame (int mini_p
)
284 register struct frame
*f
;
285 register Lisp_Object root_window
;
286 register Lisp_Object mini_window
;
288 f
= allocate_frame ();
289 XSETFRAME (frame
, f
);
291 f
->desired_matrix
= 0;
292 f
->current_matrix
= 0;
295 f
->glyphs_initialized_p
= 0;
296 f
->decode_mode_spec_buffer
= 0;
298 f
->async_visible
= 0;
299 f
->output_data
.nothing
= 0;
301 f
->async_iconified
= 0;
302 f
->wants_modeline
= 1;
307 f
->has_minibuffer
= mini_p
;
308 f
->focus_frame
= Qnil
;
309 f
->explicit_name
= 0;
310 f
->can_have_scroll_bars
= 0;
311 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
312 f
->param_alist
= Qnil
;
313 f
->scroll_bars
= Qnil
;
314 f
->condemned_scroll_bars
= Qnil
;
315 f
->face_alist
= Qnil
;
316 f
->face_cache
= NULL
;
317 f
->menu_bar_items
= Qnil
;
318 f
->menu_bar_vector
= Qnil
;
319 f
->menu_bar_items_used
= 0;
320 f
->buffer_predicate
= Qnil
;
321 f
->buffer_list
= Qnil
;
322 f
->buried_buffer_list
= Qnil
;
325 f
->menu_bar_window
= Qnil
;
326 f
->tool_bar_window
= Qnil
;
327 f
->tool_bar_items
= Qnil
;
328 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
329 f
->n_tool_bar_items
= 0;
330 f
->left_fringe_width
= f
->right_fringe_width
= 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
;
559 init_frame_faces (f
);
567 make_terminal_frame (struct terminal
*terminal
)
569 register struct frame
*f
;
574 error ("Terminal is not live, can't create new frames on it");
578 XSETFRAME (frame
, f
);
579 Vframe_list
= Fcons (frame
, Vframe_list
);
582 sprintf (name
, "F%d", tty_frame_count
);
583 f
->name
= build_string (name
);
585 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
586 f
->async_visible
= 1; /* Don't let visible be cleared later. */
587 f
->terminal
= terminal
;
588 f
->terminal
->reference_count
++;
590 f
->output_data
.tty
->display_info
= &the_only_display_info
;
591 if (!inhibit_window_system
592 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
593 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
594 f
->output_method
= output_msdos_raw
;
596 f
->output_method
= output_termcap
;
597 #else /* not MSDOS */
598 f
->output_method
= output_termcap
;
599 create_tty_output (f
);
600 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
601 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
602 #endif /* not MSDOS */
604 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
605 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
607 /* Set the top frame to the newly created frame. */
608 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
609 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
610 XFRAME (FRAME_TTY (f
)->top_frame
)->async_visible
= 2; /* obscured */
612 FRAME_TTY (f
)->top_frame
= frame
;
615 init_frame_faces (f
);
620 /* Get a suitable value for frame parameter PARAMETER for a newly
621 created frame, based on (1) the user-supplied frame parameter
622 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
625 get_future_frame_param (Lisp_Object parameter
,
626 Lisp_Object supplied_parms
,
631 result
= Fassq (parameter
, supplied_parms
);
633 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
634 if (NILP (result
) && current_value
!= NULL
)
635 result
= build_string (current_value
);
636 if (!NILP (result
) && !STRINGP (result
))
637 result
= XCDR (result
);
638 if (NILP (result
) || !STRINGP (result
))
644 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
646 doc
: /* Create an additional terminal frame, possibly on another terminal.
647 This function takes one argument, an alist specifying frame parameters.
649 You can create multiple frames on a single text-only terminal, but
650 only one of them (the selected terminal frame) is actually displayed.
652 In practice, generally you don't need to specify any parameters,
653 except when you want to create a new frame on another terminal.
654 In that case, the `tty' parameter specifies the device file to open,
655 and the `tty-type' parameter specifies the terminal type. Example:
657 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
659 Note that changing the size of one terminal frame automatically
660 affects all frames on the same terminal device. */)
665 struct terminal
*t
= NULL
;
666 Lisp_Object frame
, tem
;
667 struct frame
*sf
= SELECTED_FRAME ();
670 if (sf
->output_method
!= output_msdos_raw
671 && sf
->output_method
!= output_termcap
)
673 #else /* not MSDOS */
675 #ifdef WINDOWSNT /* This should work now! */
676 if (sf
->output_method
!= output_termcap
)
677 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
679 #endif /* not MSDOS */
682 Lisp_Object terminal
;
684 terminal
= Fassq (Qterminal
, parms
);
685 if (!NILP (terminal
))
687 terminal
= XCDR (terminal
);
688 t
= get_terminal (terminal
, 1);
691 if (t
&& t
!= the_only_display_info
.terminal
)
692 /* msdos.c assumes a single tty_display_info object. */
693 error ("Multiple terminals are not supported on this platform");
695 t
= the_only_display_info
.terminal
;
701 char *name
= 0, *type
= 0;
702 Lisp_Object tty
, tty_type
;
704 tty
= get_future_frame_param
705 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
706 ? FRAME_TTY (XFRAME (selected_frame
))->name
710 name
= (char *) alloca (SBYTES (tty
) + 1);
711 strncpy (name
, SDATA (tty
), SBYTES (tty
));
712 name
[SBYTES (tty
)] = 0;
715 tty_type
= get_future_frame_param
716 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
717 ? FRAME_TTY (XFRAME (selected_frame
))->type
719 if (!NILP (tty_type
))
721 type
= (char *) alloca (SBYTES (tty_type
) + 1);
722 strncpy (type
, SDATA (tty_type
), SBYTES (tty_type
));
723 type
[SBYTES (tty_type
)] = 0;
726 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
729 f
= make_terminal_frame (t
);
733 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
734 change_frame_size (f
, height
, width
, 0, 0, 0);
739 XSETFRAME (frame
, f
);
740 Fmodify_frame_parameters (frame
, parms
);
741 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
742 build_string (t
->display_info
.tty
->type
)),
744 if (t
->display_info
.tty
->name
!= NULL
)
745 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
746 build_string (t
->display_info
.tty
->name
)),
749 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
751 /* Make the frame face alist be frame-specific, so that each
752 frame could change its face definitions independently. */
753 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
754 /* Simple Fcopy_alist isn't enough, because we need the contents of
755 the vectors which are the CDRs of associations in face_alist to
756 be copied as well. */
757 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
758 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
763 /* Perform the switch to frame FRAME.
765 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
768 If TRACK is non-zero and the frame that currently has the focus
769 redirects its focus to the selected frame, redirect that focused
770 frame's focus to FRAME instead.
772 FOR_DELETION non-zero means that the selected frame is being
773 deleted, which includes the possibility that the frame's terminal
776 The value of NORECORD is passed as argument to Fselect_window. */
779 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
781 struct frame
*sf
= SELECTED_FRAME ();
783 /* If FRAME is a switch-frame event, extract the frame we should
786 && EQ (XCAR (frame
), Qswitch_frame
)
787 && CONSP (XCDR (frame
)))
788 frame
= XCAR (XCDR (frame
));
790 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
791 a switch-frame event to arrive after a frame is no longer live,
792 especially when deleting the initial frame during startup. */
794 if (! FRAME_LIVE_P (XFRAME (frame
)))
797 if (sf
== XFRAME (frame
))
800 /* This is too greedy; it causes inappropriate focus redirection
801 that's hard to get rid of. */
803 /* If a frame's focus has been redirected toward the currently
804 selected frame, we should change the redirection to point to the
805 newly selected frame. This means that if the focus is redirected
806 from a minibufferless frame to a surrogate minibuffer frame, we
807 can use `other-window' to switch between all the frames using
808 that minibuffer frame, and the focus redirection will follow us
814 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
818 if (!FRAMEP (XCAR (tail
)))
821 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
823 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
824 Fredirect_frame_focus (XCAR (tail
), frame
);
828 /* Instead, apply it only to the frame we're pointing to. */
829 #ifdef HAVE_WINDOW_SYSTEM
830 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
832 Lisp_Object focus
, xfocus
;
834 xfocus
= x_get_focus_frame (XFRAME (frame
));
837 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
838 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
839 Fredirect_frame_focus (xfocus
, frame
);
842 #endif /* HAVE_X_WINDOWS */
845 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
846 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
848 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
850 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
851 /* Mark previously displayed frame as now obscured. */
852 XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
)->async_visible
= 2;
853 XFRAME (frame
)->async_visible
= 1;
854 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
857 selected_frame
= frame
;
858 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
859 last_nonminibuf_frame
= XFRAME (selected_frame
);
861 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
863 /* We want to make sure that the next event generates a frame-switch
864 event to the appropriate frame. This seems kludgy to me, but
865 before you take it out, make sure that evaluating something like
866 (select-window (frame-root-window (new-frame))) doesn't end up
867 with your typing being interpreted in the new frame instead of
868 the one you're actually typing in. */
869 internal_last_event_frame
= Qnil
;
874 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
875 doc
: /* Select FRAME.
876 Subsequent editing commands apply to its selected window.
877 Optional argument NORECORD means to neither change the order of
878 recently selected windows nor the buffer list.
880 The selection of FRAME lasts until the next time the user does
881 something to select a different frame, or until the next time
882 this function is called. If you are using a window system, the
883 previously selected frame may be restored as the selected frame
884 when returning to the command loop, because it still may have
885 the window system's input focus. On a text-only terminal, the
886 next redisplay will display FRAME.
888 This function returns FRAME, or nil if FRAME has been deleted. */)
890 Lisp_Object frame
, norecord
;
892 return do_switch_frame (frame
, 1, 0, norecord
);
896 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
897 doc
: /* Handle a switch-frame event EVENT.
898 Switch-frame events are usually bound to this function.
899 A switch-frame event tells Emacs that the window manager has requested
900 that the user's events be directed to the frame mentioned in the event.
901 This function selects the selected window of the frame of EVENT.
903 If EVENT is frame object, handle it as if it were a switch-frame event
908 /* Preserve prefix arg that the command loop just cleared. */
909 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
910 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
911 return do_switch_frame (event
, 0, 0, Qnil
);
914 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
915 doc
: /* Return the frame that is now selected. */)
918 return selected_frame
;
921 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
922 doc
: /* Return the frame object that window WINDOW is on. */)
926 CHECK_LIVE_WINDOW (window
);
927 return XWINDOW (window
)->frame
;
930 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
931 doc
: /* Returns the topmost, leftmost window of FRAME.
932 If omitted, FRAME defaults to the currently selected frame. */)
939 w
= SELECTED_FRAME ()->root_window
;
942 CHECK_LIVE_FRAME (frame
);
943 w
= XFRAME (frame
)->root_window
;
945 while (NILP (XWINDOW (w
)->buffer
))
947 if (! NILP (XWINDOW (w
)->hchild
))
948 w
= XWINDOW (w
)->hchild
;
949 else if (! NILP (XWINDOW (w
)->vchild
))
950 w
= XWINDOW (w
)->vchild
;
957 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
958 Sactive_minibuffer_window
, 0, 0, 0,
959 doc
: /* Return the currently active minibuffer window, or nil if none. */)
962 return minibuf_level
? minibuf_window
: Qnil
;
965 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
966 doc
: /* Returns the root-window of FRAME.
967 If omitted, FRAME defaults to the currently selected frame. */)
974 window
= SELECTED_FRAME ()->root_window
;
977 CHECK_LIVE_FRAME (frame
);
978 window
= XFRAME (frame
)->root_window
;
984 DEFUN ("frame-selected-window", Fframe_selected_window
,
985 Sframe_selected_window
, 0, 1, 0,
986 doc
: /* Return the selected window of FRAME.
987 FRAME defaults to the currently selected frame. */)
994 window
= SELECTED_FRAME ()->selected_window
;
997 CHECK_LIVE_FRAME (frame
);
998 window
= XFRAME (frame
)->selected_window
;
1004 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
1005 Sset_frame_selected_window
, 2, 3, 0,
1006 doc
: /* Set selected window of FRAME to WINDOW.
1007 If FRAME is nil, use the selected frame. If FRAME is the
1008 selected frame, this makes WINDOW the selected window.
1009 Optional argument NORECORD non-nil means to neither change the
1010 order of recently selected windows nor the buffer list.
1012 (frame
, window
, norecord
)
1013 Lisp_Object frame
, window
, norecord
;
1016 frame
= selected_frame
;
1018 CHECK_LIVE_FRAME (frame
);
1019 CHECK_LIVE_WINDOW (window
);
1021 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
1022 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
1024 if (EQ (frame
, selected_frame
))
1025 return Fselect_window (window
, norecord
);
1027 return XFRAME (frame
)->selected_window
= window
;
1031 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1033 doc
: /* Return a list of all live frames. */)
1037 frames
= Fcopy_sequence (Vframe_list
);
1038 #ifdef HAVE_WINDOW_SYSTEM
1039 if (FRAMEP (tip_frame
))
1040 frames
= Fdelq (tip_frame
, frames
);
1045 /* Return the next frame in the frame list after FRAME.
1046 If MINIBUF is nil, exclude minibuffer-only frames.
1047 If MINIBUF is a window, include only its own frame
1048 and any frame now using that window as the minibuffer.
1049 If MINIBUF is `visible', include all visible frames.
1050 If MINIBUF is 0, include all visible and iconified frames.
1051 Otherwise, include all frames. */
1054 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1059 /* There must always be at least one frame in Vframe_list. */
1060 if (! CONSP (Vframe_list
))
1063 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
1064 forever. Forestall that. */
1065 CHECK_LIVE_FRAME (frame
);
1068 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1075 && ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1076 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1077 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1078 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
)))))
1080 /* Decide whether this frame is eligible to be returned. */
1082 /* If we've looped all the way around without finding any
1083 eligible frames, return the original frame. */
1087 /* Let minibuf decide if this frame is acceptable. */
1090 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1093 else if (EQ (minibuf
, Qvisible
))
1095 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1096 if (FRAME_VISIBLE_P (XFRAME (f
)))
1099 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
1101 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1102 if (FRAME_VISIBLE_P (XFRAME (f
))
1103 || FRAME_ICONIFIED_P (XFRAME (f
)))
1106 else if (WINDOWP (minibuf
))
1108 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1109 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1110 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1111 FRAME_FOCUS_FRAME (XFRAME (f
))))
1123 /* Return the previous frame in the frame list before FRAME.
1124 If MINIBUF is nil, exclude minibuffer-only frames.
1125 If MINIBUF is a window, include only its own frame
1126 and any frame now using that window as the minibuffer.
1127 If MINIBUF is `visible', include all visible frames.
1128 If MINIBUF is 0, include all visible and iconified frames.
1129 Otherwise, include all frames. */
1132 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1137 /* There must always be at least one frame in Vframe_list. */
1138 if (! CONSP (Vframe_list
))
1142 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1150 if (EQ (frame
, f
) && !NILP (prev
))
1153 if ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1154 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1155 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1156 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
))))
1158 /* Decide whether this frame is eligible to be returned,
1159 according to minibuf. */
1162 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1165 else if (WINDOWP (minibuf
))
1167 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1168 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1169 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1170 FRAME_FOCUS_FRAME (XFRAME (f
))))
1173 else if (EQ (minibuf
, Qvisible
))
1175 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1176 if (FRAME_VISIBLE_P (XFRAME (f
)))
1179 else if (XFASTINT (minibuf
) == 0)
1181 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1182 if (FRAME_VISIBLE_P (XFRAME (f
))
1183 || FRAME_ICONIFIED_P (XFRAME (f
)))
1191 /* We've scanned the entire list. */
1193 /* We went through the whole frame list without finding a single
1194 acceptable frame. Return the original frame. */
1197 /* There were no acceptable frames in the list before FRAME; otherwise,
1198 we would have returned directly from the loop. Since PREV is the last
1199 acceptable frame in the list, return it. */
1204 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1205 doc
: /* Return the next frame in the frame list after FRAME.
1206 It considers only frames on the same terminal as FRAME.
1207 By default, skip minibuffer-only frames.
1208 If omitted, FRAME defaults to the selected frame.
1209 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1210 If MINIFRAME is a window, include only its own frame
1211 and any frame now using that window as the minibuffer.
1212 If MINIFRAME is `visible', include all visible frames.
1213 If MINIFRAME is 0, include all visible and iconified frames.
1214 Otherwise, include all frames. */)
1216 Lisp_Object frame
, miniframe
;
1219 frame
= selected_frame
;
1221 CHECK_LIVE_FRAME (frame
);
1222 return next_frame (frame
, miniframe
);
1225 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1226 doc
: /* Return the previous frame in the frame list before FRAME.
1227 It considers only frames on the same terminal as FRAME.
1228 By default, skip minibuffer-only frames.
1229 If omitted, FRAME defaults to the selected frame.
1230 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1231 If MINIFRAME is a window, include only its own frame
1232 and any frame now using that window as the minibuffer.
1233 If MINIFRAME is `visible', include all visible frames.
1234 If MINIFRAME is 0, include all visible and iconified frames.
1235 Otherwise, include all frames. */)
1237 Lisp_Object frame
, miniframe
;
1240 frame
= selected_frame
;
1241 CHECK_LIVE_FRAME (frame
);
1242 return prev_frame (frame
, miniframe
);
1245 /* Return 1 if it is ok to delete frame F;
1246 0 if all frames aside from F are invisible.
1247 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1250 other_visible_frames (FRAME_PTR f
)
1252 /* We know the selected frame is visible,
1253 so if F is some other frame, it can't be the sole visible one. */
1254 if (f
== SELECTED_FRAME ())
1259 for (frames
= Vframe_list
;
1261 frames
= XCDR (frames
))
1265 this = XCAR (frames
);
1266 /* Verify that the frame's window still exists
1267 and we can still talk to it. And note any recent change
1269 #ifdef HAVE_WINDOW_SYSTEM
1270 if (FRAME_WINDOW_P (XFRAME (this)))
1272 x_sync (XFRAME (this));
1273 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1277 if (FRAME_VISIBLE_P (XFRAME (this))
1278 || FRAME_ICONIFIED_P (XFRAME (this))
1279 /* Allow deleting the terminal frame when at least
1280 one X frame exists! */
1281 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1289 /* Error handler for `delete-frame-functions'. */
1291 delete_frame_handler (Lisp_Object arg
)
1293 add_to_log ("Error during `delete-frame': %s", arg
, Qnil
);
1297 extern Lisp_Object Qrun_hook_with_args
;
1299 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1300 unconditionally. x_connection_closed and delete_terminal use
1301 this. Any other value of FORCE implements the semantics
1302 described for Fdelete_frame. */
1304 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1305 /* If we use `register' here, gcc-4.0.2 on amd64 using
1306 -DUSE_LISP_UNION_TYPE complains further down that we're getting the
1307 address of `force'. Go figure. */
1311 struct frame
*sf
= SELECTED_FRAME ();
1314 int minibuffer_selected
;
1316 if (EQ (frame
, Qnil
))
1319 XSETFRAME (frame
, f
);
1323 CHECK_FRAME (frame
);
1327 if (! FRAME_LIVE_P (f
))
1330 if (NILP (force
) && !other_visible_frames (f
))
1331 error ("Attempt to delete the sole visible or iconified frame");
1333 /* x_connection_closed must have set FORCE to `noelisp' in order
1334 to delete the last frame, if it is gone. */
1335 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1336 error ("Attempt to delete the only frame");
1338 /* Does this frame have a minibuffer, and is it the surrogate
1339 minibuffer for any other frame? */
1340 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1344 for (frames
= Vframe_list
;
1346 frames
= XCDR (frames
))
1349 this = XCAR (frames
);
1351 if (! EQ (this, frame
)
1353 WINDOW_FRAME (XWINDOW
1354 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1356 /* If we MUST delete this frame, delete the other first.
1357 But do this only if FORCE equals `noelisp'. */
1358 if (EQ (force
, Qnoelisp
))
1359 delete_frame (this, Qnoelisp
);
1361 error ("Attempt to delete a surrogate minibuffer frame");
1366 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1367 frame is a tooltip. FORCE is set to `noelisp' when handling
1368 a disconnect from the terminal, so we don't dare call Lisp
1370 if (NILP (Vrun_hooks
) || !NILP (Fframe_parameter (frame
, intern ("tooltip"))))
1372 if (EQ (force
, Qnoelisp
))
1374 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1377 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1379 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1380 if (! FRAME_LIVE_P (f
))
1383 /* At this point, we are committed to deleting the frame.
1384 There is no more chance for errors to prevent it. */
1386 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1388 /* Don't let the frame remain selected. */
1391 Lisp_Object tail
, frame1
;
1393 /* Look for another visible frame on the same terminal. */
1394 frame1
= next_frame (frame
, Qvisible
);
1396 /* If there is none, find *some* other frame. */
1397 if (NILP (frame1
) || EQ (frame1
, frame
))
1399 FOR_EACH_FRAME (tail
, frame1
)
1401 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1405 #ifdef NS_IMPL_COCOA
1407 /* Under NS, there is no system mechanism for choosing a new
1408 window to get focus -- it is left to application code.
1409 So the portion of THIS application interfacing with NS
1410 needs to know about it. We call Fraise_frame, but the
1411 purpose is really to transfer focus. */
1412 Fraise_frame (frame1
);
1415 do_switch_frame (frame1
, 0, 1, Qnil
);
1416 sf
= SELECTED_FRAME ();
1419 /* Don't allow minibuf_window to remain on a deleted frame. */
1420 if (EQ (f
->minibuffer_window
, minibuf_window
))
1422 Fset_window_buffer (sf
->minibuffer_window
,
1423 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1424 minibuf_window
= sf
->minibuffer_window
;
1426 /* If the dying minibuffer window was selected,
1427 select the new one. */
1428 if (minibuffer_selected
)
1429 Fselect_window (minibuf_window
, Qnil
);
1432 /* Don't let echo_area_window to remain on a deleted frame. */
1433 if (EQ (f
->minibuffer_window
, echo_area_window
))
1434 echo_area_window
= sf
->minibuffer_window
;
1436 /* Clear any X selections for this frame. */
1437 #ifdef HAVE_X_WINDOWS
1439 x_clear_frame_selections (f
);
1443 This function must be called before the window tree of the
1444 frame is deleted because windows contain dynamically allocated
1448 #ifdef HAVE_WINDOW_SYSTEM
1449 /* Give chance to each font driver to free a frame specific data. */
1450 font_update_drivers (f
, Qnil
);
1453 /* Mark all the windows that used to be on FRAME as deleted, and then
1454 remove the reference to them. */
1455 delete_all_subwindows (XWINDOW (f
->root_window
));
1456 f
->root_window
= Qnil
;
1458 Vframe_list
= Fdelq (frame
, Vframe_list
);
1459 FRAME_SET_VISIBLE (f
, 0);
1461 /* Allow the vector of menu bar contents to be freed in the next
1462 garbage collection. The frame object itself may not be garbage
1463 collected until much later, because recent_keys and other data
1464 structures can still refer to it. */
1465 f
->menu_bar_vector
= Qnil
;
1467 free_font_driver_list (f
);
1469 xfree (f
->decode_mode_spec_buffer
);
1470 xfree (FRAME_INSERT_COST (f
));
1471 xfree (FRAME_DELETEN_COST (f
));
1472 xfree (FRAME_INSERTN_COST (f
));
1473 xfree (FRAME_DELETE_COST (f
));
1474 xfree (FRAME_MESSAGE_BUF (f
));
1476 /* Since some events are handled at the interrupt level, we may get
1477 an event for f at any time; if we zero out the frame's terminal
1478 now, then we may trip up the event-handling code. Instead, we'll
1479 promise that the terminal of the frame must be valid until we
1480 have called the window-system-dependent frame destruction
1483 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1484 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1487 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1488 f
->output_data
.nothing
= 0;
1489 f
->terminal
= 0; /* Now the frame is dead. */
1491 /* If needed, delete the terminal that this frame was on.
1492 (This must be done after the frame is killed.) */
1493 terminal
->reference_count
--;
1494 if (terminal
->reference_count
== 0)
1497 XSETTERMINAL (tmp
, terminal
);
1500 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1503 kb
= terminal
->kboard
;
1506 /* If we've deleted the last_nonminibuf_frame, then try to find
1508 if (f
== last_nonminibuf_frame
)
1512 last_nonminibuf_frame
= 0;
1514 for (frames
= Vframe_list
;
1516 frames
= XCDR (frames
))
1518 f
= XFRAME (XCAR (frames
));
1519 if (!FRAME_MINIBUF_ONLY_P (f
))
1521 last_nonminibuf_frame
= f
;
1527 /* If there's no other frame on the same kboard, get out of
1528 single-kboard state if we're in it for this kboard. */
1532 /* Some frame we found on the same kboard, or nil if there are none. */
1533 Lisp_Object frame_on_same_kboard
;
1535 frame_on_same_kboard
= Qnil
;
1537 for (frames
= Vframe_list
;
1539 frames
= XCDR (frames
))
1544 this = XCAR (frames
);
1549 if (kb
== FRAME_KBOARD (f1
))
1550 frame_on_same_kboard
= this;
1553 if (NILP (frame_on_same_kboard
))
1554 not_single_kboard_state (kb
);
1558 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1559 find another one. Prefer minibuffer-only frames, but also notice
1560 frames with other windows. */
1561 if (kb
!= NULL
&& EQ (frame
, kb
->Vdefault_minibuffer_frame
))
1565 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1566 Lisp_Object frame_with_minibuf
;
1567 /* Some frame we found on the same kboard, or nil if there are none. */
1568 Lisp_Object frame_on_same_kboard
;
1570 frame_on_same_kboard
= Qnil
;
1571 frame_with_minibuf
= Qnil
;
1573 for (frames
= Vframe_list
;
1575 frames
= XCDR (frames
))
1580 this = XCAR (frames
);
1585 /* Consider only frames on the same kboard
1586 and only those with minibuffers. */
1587 if (kb
== FRAME_KBOARD (f1
)
1588 && FRAME_HAS_MINIBUF_P (f1
))
1590 frame_with_minibuf
= this;
1591 if (FRAME_MINIBUF_ONLY_P (f1
))
1595 if (kb
== FRAME_KBOARD (f1
))
1596 frame_on_same_kboard
= this;
1599 if (!NILP (frame_on_same_kboard
))
1601 /* We know that there must be some frame with a minibuffer out
1602 there. If this were not true, all of the frames present
1603 would have to be minibufferless, which implies that at some
1604 point their minibuffer frames must have been deleted, but
1605 that is prohibited at the top; you can't delete surrogate
1606 minibuffer frames. */
1607 if (NILP (frame_with_minibuf
))
1610 kb
->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1613 /* No frames left on this kboard--say no minibuffer either. */
1614 kb
->Vdefault_minibuffer_frame
= Qnil
;
1617 /* Cause frame titles to update--necessary if we now have just one frame. */
1618 update_mode_lines
= 1;
1623 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1624 doc
: /* Delete FRAME, permanently eliminating it from use.
1625 FRAME defaults to the selected frame.
1627 A frame may not be deleted if its minibuffer is used by other frames.
1628 Normally, you may not delete a frame if all other frames are invisible,
1629 but if the second optional argument FORCE is non-nil, you may do so.
1631 This function runs `delete-frame-functions' before actually
1632 deleting the frame, unless the frame is a tooltip.
1633 The functions are run with one argument, the frame to be deleted. */)
1635 Lisp_Object frame
, force
;
1637 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1641 /* Return mouse position in character cell units. */
1643 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1644 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1645 The position is given in character cells, where (0, 0) is the
1646 upper-left corner of the frame, X is the horizontal offset, and Y is
1647 the vertical offset.
1648 If Emacs is running on a mouseless terminal or hasn't been programmed
1649 to read the mouse position, it returns the selected frame for FRAME
1650 and nil for X and Y.
1651 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1652 passing the normal return value to that function as an argument,
1653 and returns whatever that function returns. */)
1657 Lisp_Object lispy_dummy
;
1658 enum scroll_bar_part party_dummy
;
1659 Lisp_Object x
, y
, retval
;
1661 unsigned long long_dummy
;
1662 struct gcpro gcpro1
;
1664 f
= SELECTED_FRAME ();
1667 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1668 /* It's okay for the hook to refrain from storing anything. */
1669 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1670 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1671 &lispy_dummy
, &party_dummy
,
1678 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1683 XSETFRAME (lispy_dummy
, f
);
1684 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1686 if (!NILP (Vmouse_position_function
))
1687 retval
= call1 (Vmouse_position_function
, retval
);
1688 RETURN_UNGCPRO (retval
);
1691 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1692 Smouse_pixel_position
, 0, 0, 0,
1693 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1694 The position is given in pixel units, where (0, 0) is the
1695 upper-left corner of the frame, X is the horizontal offset, and Y is
1696 the vertical offset.
1697 If Emacs is running on a mouseless terminal or hasn't been programmed
1698 to read the mouse position, it returns the selected frame for FRAME
1699 and nil for X and Y. */)
1703 Lisp_Object lispy_dummy
;
1704 enum scroll_bar_part party_dummy
;
1706 unsigned long long_dummy
;
1708 f
= SELECTED_FRAME ();
1711 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1712 /* It's okay for the hook to refrain from storing anything. */
1713 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1714 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1715 &lispy_dummy
, &party_dummy
,
1719 XSETFRAME (lispy_dummy
, f
);
1720 return Fcons (lispy_dummy
, Fcons (x
, y
));
1723 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1724 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1725 Coordinates are relative to the frame, not a window,
1726 so the coordinates of the top left character in the frame
1727 may be nonzero due to left-hand scroll bars or the menu bar.
1729 The position is given in character cells, where (0, 0) is the
1730 upper-left corner of the frame, X is the horizontal offset, and Y is
1731 the vertical offset.
1733 This function is a no-op for an X frame that is not visible.
1734 If you have just created a frame, you must wait for it to become visible
1735 before calling this function on it, like this.
1736 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1738 Lisp_Object frame
, x
, y
;
1740 CHECK_LIVE_FRAME (frame
);
1744 /* I think this should be done with a hook. */
1745 #ifdef HAVE_WINDOW_SYSTEM
1746 if (FRAME_WINDOW_P (XFRAME (frame
)))
1747 /* Warping the mouse will cause enternotify and focus events. */
1748 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1750 #if defined (MSDOS) && defined (HAVE_MOUSE)
1751 if (FRAME_MSDOS_P (XFRAME (frame
)))
1753 Fselect_frame (frame
, Qnil
);
1754 mouse_moveto (XINT (x
), XINT (y
));
1759 Fselect_frame (frame
, Qnil
);
1760 term_mouse_moveto (XINT (x
), XINT (y
));
1769 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1770 Sset_mouse_pixel_position
, 3, 3, 0,
1771 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1772 The position is given in pixels, where (0, 0) is the upper-left corner
1773 of the frame, X is the horizontal offset, and Y is the vertical offset.
1775 Note, this is a no-op for an X frame that is not visible.
1776 If you have just created a frame, you must wait for it to become visible
1777 before calling this function on it, like this.
1778 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1780 Lisp_Object frame
, x
, y
;
1782 CHECK_LIVE_FRAME (frame
);
1786 /* I think this should be done with a hook. */
1787 #ifdef HAVE_WINDOW_SYSTEM
1788 if (FRAME_WINDOW_P (XFRAME (frame
)))
1789 /* Warping the mouse will cause enternotify and focus events. */
1790 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1792 #if defined (MSDOS) && defined (HAVE_MOUSE)
1793 if (FRAME_MSDOS_P (XFRAME (frame
)))
1795 Fselect_frame (frame
, Qnil
);
1796 mouse_moveto (XINT (x
), XINT (y
));
1801 Fselect_frame (frame
, Qnil
);
1802 term_mouse_moveto (XINT (x
), XINT (y
));
1811 static void make_frame_visible_1 (Lisp_Object
);
1813 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1815 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1816 If omitted, FRAME defaults to the currently selected frame. */)
1821 frame
= selected_frame
;
1823 CHECK_LIVE_FRAME (frame
);
1825 /* I think this should be done with a hook. */
1826 #ifdef HAVE_WINDOW_SYSTEM
1827 if (FRAME_WINDOW_P (XFRAME (frame
)))
1829 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1830 x_make_frame_visible (XFRAME (frame
));
1834 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1836 /* Make menu bar update for the Buffers and Frames menus. */
1837 windows_or_buffers_changed
++;
1842 /* Update the display_time slot of the buffers shown in WINDOW
1843 and all its descendents. */
1846 make_frame_visible_1 (Lisp_Object window
)
1850 for (;!NILP (window
); window
= w
->next
)
1852 w
= XWINDOW (window
);
1854 if (!NILP (w
->buffer
))
1855 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1857 if (!NILP (w
->vchild
))
1858 make_frame_visible_1 (w
->vchild
);
1859 if (!NILP (w
->hchild
))
1860 make_frame_visible_1 (w
->hchild
);
1864 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1866 doc
: /* Make the frame FRAME invisible.
1867 If omitted, FRAME defaults to the currently selected frame.
1868 On graphical displays, invisible frames are not updated and are
1869 usually not displayed at all, even in a window system's \"taskbar\".
1871 Normally you may not make FRAME invisible if all other frames are invisible,
1872 but if the second optional argument FORCE is non-nil, you may do so.
1874 This function has no effect on text-only terminal frames. Such frames
1875 are always considered visible, whether or not they are currently being
1876 displayed in the terminal. */)
1878 Lisp_Object frame
, force
;
1881 frame
= selected_frame
;
1883 CHECK_LIVE_FRAME (frame
);
1885 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1886 error ("Attempt to make invisible the sole visible or iconified frame");
1888 #if 0 /* This isn't logically necessary, and it can do GC. */
1889 /* Don't let the frame remain selected. */
1890 if (EQ (frame
, selected_frame
))
1891 do_switch_frame (next_frame (frame
, Qt
), 0, 0, Qnil
)
1894 /* Don't allow minibuf_window to remain on a deleted frame. */
1895 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1897 struct frame
*sf
= XFRAME (selected_frame
);
1898 Fset_window_buffer (sf
->minibuffer_window
,
1899 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1900 minibuf_window
= sf
->minibuffer_window
;
1903 /* I think this should be done with a hook. */
1904 #ifdef HAVE_WINDOW_SYSTEM
1905 if (FRAME_WINDOW_P (XFRAME (frame
)))
1906 x_make_frame_invisible (XFRAME (frame
));
1909 /* Make menu bar update for the Buffers and Frames menus. */
1910 windows_or_buffers_changed
++;
1915 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1917 doc
: /* Make the frame FRAME into an icon.
1918 If omitted, FRAME defaults to the currently selected frame. */)
1923 frame
= selected_frame
;
1925 CHECK_LIVE_FRAME (frame
);
1927 #if 0 /* This isn't logically necessary, and it can do GC. */
1928 /* Don't let the frame remain selected. */
1929 if (EQ (frame
, selected_frame
))
1930 Fhandle_switch_frame (next_frame (frame
, Qt
));
1933 /* Don't allow minibuf_window to remain on a deleted frame. */
1934 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1936 struct frame
*sf
= XFRAME (selected_frame
);
1937 Fset_window_buffer (sf
->minibuffer_window
,
1938 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1939 minibuf_window
= sf
->minibuffer_window
;
1942 /* I think this should be done with a hook. */
1943 #ifdef HAVE_WINDOW_SYSTEM
1944 if (FRAME_WINDOW_P (XFRAME (frame
)))
1945 x_iconify_frame (XFRAME (frame
));
1948 /* Make menu bar update for the Buffers and Frames menus. */
1949 windows_or_buffers_changed
++;
1954 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1956 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1957 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1958 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1959 On graphical displays, invisible frames are not updated and are
1960 usually not displayed at all, even in a window system's \"taskbar\".
1962 If FRAME is a text-only terminal frame, this always returns t.
1963 Such frames are always considered visible, whether or not they are
1964 currently being displayed on the terminal. */)
1968 CHECK_LIVE_FRAME (frame
);
1970 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1972 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1974 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1979 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1981 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1984 Lisp_Object tail
, frame
;
1989 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1991 frame
= XCAR (tail
);
1992 if (!FRAMEP (frame
))
1995 if (FRAME_VISIBLE_P (f
))
1996 value
= Fcons (frame
, value
);
2002 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
2003 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
2004 If FRAME is invisible or iconified, make it visible.
2005 If you don't specify a frame, the selected frame is used.
2006 If Emacs is displaying on an ordinary terminal or some other device which
2007 doesn't support multiple overlapping frames, this function selects FRAME. */)
2013 frame
= selected_frame
;
2015 CHECK_LIVE_FRAME (frame
);
2019 if (FRAME_TERMCAP_P (f
))
2020 /* On a text-only terminal select FRAME. */
2021 Fselect_frame (frame
, Qnil
);
2023 /* Do like the documentation says. */
2024 Fmake_frame_visible (frame
);
2026 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2027 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
2032 /* Should we have a corresponding function called Flower_Power? */
2033 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
2034 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2035 If you don't specify a frame, the selected frame is used.
2036 If Emacs is displaying on an ordinary terminal or some other device which
2037 doesn't support multiple overlapping frames, this function does nothing. */)
2044 frame
= selected_frame
;
2046 CHECK_LIVE_FRAME (frame
);
2050 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2051 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2057 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2059 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2060 In other words, switch-frame events caused by events in FRAME will
2061 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2062 FOCUS-FRAME after reading an event typed at FRAME.
2064 If FOCUS-FRAME is omitted or nil, any existing redirection is
2065 cancelled, and the frame again receives its own keystrokes.
2067 Focus redirection is useful for temporarily redirecting keystrokes to
2068 a surrogate minibuffer frame when a frame doesn't have its own
2071 A frame's focus redirection can be changed by `select-frame'. If frame
2072 FOO is selected, and then a different frame BAR is selected, any
2073 frames redirecting their focus to FOO are shifted to redirect their
2074 focus to BAR. This allows focus redirection to work properly when the
2075 user switches from one frame to another using `select-window'.
2077 This means that a frame whose focus is redirected to itself is treated
2078 differently from a frame whose focus is redirected to nil; the former
2079 is affected by `select-frame', while the latter is not.
2081 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2082 (frame
, focus_frame
)
2083 Lisp_Object frame
, focus_frame
;
2087 /* Note that we don't check for a live frame here. It's reasonable
2088 to redirect the focus of a frame you're about to delete, if you
2089 know what other frame should receive those keystrokes. */
2090 CHECK_FRAME (frame
);
2092 if (! NILP (focus_frame
))
2093 CHECK_LIVE_FRAME (focus_frame
);
2097 f
->focus_frame
= focus_frame
;
2099 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2100 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2106 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
2107 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2108 This returns nil if FRAME's focus is not redirected.
2109 See `redirect-frame-focus'. */)
2113 CHECK_LIVE_FRAME (frame
);
2115 return FRAME_FOCUS_FRAME (XFRAME (frame
));
2120 /* Return the value of frame parameter PROP in frame FRAME. */
2123 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
2125 register Lisp_Object tem
;
2127 tem
= Fassq (prop
, frame
->param_alist
);
2133 /* Return the buffer-predicate of the selected frame. */
2136 frame_buffer_predicate (Lisp_Object frame
)
2138 return XFRAME (frame
)->buffer_predicate
;
2141 /* Return the buffer-list of the selected frame. */
2144 frame_buffer_list (Lisp_Object frame
)
2146 return XFRAME (frame
)->buffer_list
;
2149 /* Set the buffer-list of the selected frame. */
2152 set_frame_buffer_list (Lisp_Object frame
, Lisp_Object list
)
2154 XFRAME (frame
)->buffer_list
= list
;
2157 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2160 frames_discard_buffer (Lisp_Object buffer
)
2162 Lisp_Object frame
, tail
;
2164 FOR_EACH_FRAME (tail
, frame
)
2166 XFRAME (frame
)->buffer_list
2167 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
2168 XFRAME (frame
)->buried_buffer_list
2169 = Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
);
2173 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2174 If the alist already has an element for PROP, we change it. */
2177 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2179 register Lisp_Object tem
;
2181 tem
= Fassq (prop
, *alistptr
);
2183 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2189 frame_name_fnn_p (char *str
, EMACS_INT len
)
2191 if (len
> 1 && str
[0] == 'F')
2195 strtol (str
+ 1, &end_ptr
, 10);
2197 if (end_ptr
== str
+ len
)
2203 /* Set the name of the terminal frame. Also used by MSDOS frames.
2204 Modeled after x_set_name which is used for WINDOW frames. */
2207 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2209 f
->explicit_name
= ! NILP (name
);
2211 /* If NAME is nil, set the name to F<num>. */
2216 /* Check for no change needed in this very common case
2217 before we do any consing. */
2218 if (frame_name_fnn_p (SDATA (f
->name
),
2223 sprintf (namebuf
, "F%d", tty_frame_count
);
2224 name
= build_string (namebuf
);
2228 CHECK_STRING (name
);
2230 /* Don't change the name if it's already NAME. */
2231 if (! NILP (Fstring_equal (name
, f
->name
)))
2234 /* Don't allow the user to set the frame name to F<num>, so it
2235 doesn't clash with the names we generate for terminal frames. */
2236 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
2237 error ("Frame names of the form F<num> are usurped by Emacs");
2241 update_mode_lines
= 1;
2245 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2247 register Lisp_Object old_alist_elt
;
2249 /* The buffer-list parameters are stored in a special place and not
2251 if (EQ (prop
, Qbuffer_list
))
2253 f
->buffer_list
= val
;
2256 if (EQ (prop
, Qburied_buffer_list
))
2258 f
->buried_buffer_list
= val
;
2262 /* If PROP is a symbol which is supposed to have frame-local values,
2263 and it is set up based on this frame, switch to the global
2264 binding. That way, we can create or alter the frame-local binding
2265 without messing up the symbol's status. */
2268 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2270 switch (sym
->redirect
)
2272 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2273 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2274 case SYMBOL_LOCALIZED
:
2275 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2276 if (blv
->frame_local
&& BLV_FOUND (blv
) && XFRAME (blv
->where
) == f
)
2277 swap_in_global_binding (sym
);
2284 /* The tty color needed to be set before the frame's parameter
2285 alist was updated with the new value. This is not true any more,
2286 but we still do this test early on. */
2287 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2288 && f
== FRAME_TTY (f
)->previous_frame
)
2289 /* Force redisplay of this tty. */
2290 FRAME_TTY (f
)->previous_frame
= NULL
;
2292 /* Update the frame parameter alist. */
2293 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2294 if (EQ (old_alist_elt
, Qnil
))
2295 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2297 Fsetcdr (old_alist_elt
, val
);
2299 /* Update some other special parameters in their special places
2300 in addition to the alist. */
2302 if (EQ (prop
, Qbuffer_predicate
))
2303 f
->buffer_predicate
= val
;
2305 if (! FRAME_WINDOW_P (f
))
2307 if (EQ (prop
, Qmenu_bar_lines
))
2308 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2309 else if (EQ (prop
, Qname
))
2310 set_term_frame_name (f
, val
);
2313 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2315 if (! MINI_WINDOW_P (XWINDOW (val
)))
2316 error ("Surrogate minibuffer windows must be minibuffer windows");
2318 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2319 && !EQ (val
, f
->minibuffer_window
))
2320 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2322 /* Install the chosen minibuffer window, with proper buffer. */
2323 f
->minibuffer_window
= val
;
2327 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2328 doc
: /* Return the parameters-alist of frame FRAME.
2329 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2330 The meaningful PARMs depend on the kind of frame.
2331 If FRAME is omitted, return information on the currently selected frame. */)
2338 struct gcpro gcpro1
;
2341 frame
= selected_frame
;
2343 CHECK_FRAME (frame
);
2346 if (!FRAME_LIVE_P (f
))
2349 alist
= Fcopy_alist (f
->param_alist
);
2352 if (!FRAME_WINDOW_P (f
))
2354 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2355 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2358 /* If the frame's parameter alist says the colors are
2359 unspecified and reversed, take the frame's background pixel
2360 for foreground and vice versa. */
2361 elt
= Fassq (Qforeground_color
, alist
);
2362 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2364 if (strncmp (SDATA (XCDR (elt
)),
2366 SCHARS (XCDR (elt
))) == 0)
2367 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2368 else if (strncmp (SDATA (XCDR (elt
)),
2370 SCHARS (XCDR (elt
))) == 0)
2371 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2374 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2375 elt
= Fassq (Qbackground_color
, alist
);
2376 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2378 if (strncmp (SDATA (XCDR (elt
)),
2380 SCHARS (XCDR (elt
))) == 0)
2381 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2382 else if (strncmp (SDATA (XCDR (elt
)),
2384 SCHARS (XCDR (elt
))) == 0)
2385 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2388 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2389 store_in_alist (&alist
, intern ("font"),
2390 build_string (FRAME_MSDOS_P (f
)
2392 : FRAME_W32_P (f
) ? "w32term"
2395 store_in_alist (&alist
, Qname
, f
->name
);
2396 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2397 store_in_alist (&alist
, Qheight
, make_number (height
));
2398 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2399 store_in_alist (&alist
, Qwidth
, make_number (width
));
2400 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2401 store_in_alist (&alist
, Qminibuffer
,
2402 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2403 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2404 : FRAME_MINIBUF_WINDOW (f
)));
2405 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2406 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2407 store_in_alist (&alist
, Qburied_buffer_list
, XFRAME (frame
)->buried_buffer_list
);
2409 /* I think this should be done with a hook. */
2410 #ifdef HAVE_WINDOW_SYSTEM
2411 if (FRAME_WINDOW_P (f
))
2412 x_report_frame_params (f
, &alist
);
2416 /* This ought to be correct in f->param_alist for an X frame. */
2418 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2419 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2427 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2428 doc
: /* Return FRAME's value for parameter PARAMETER.
2429 If FRAME is nil, describe the currently selected frame. */)
2431 Lisp_Object frame
, parameter
;
2437 frame
= selected_frame
;
2439 CHECK_FRAME (frame
);
2440 CHECK_SYMBOL (parameter
);
2445 if (FRAME_LIVE_P (f
))
2447 /* Avoid consing in frequent cases. */
2448 if (EQ (parameter
, Qname
))
2450 #ifdef HAVE_X_WINDOWS
2451 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2452 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2453 #endif /* HAVE_X_WINDOWS */
2454 else if (EQ (parameter
, Qbackground_color
)
2455 || EQ (parameter
, Qforeground_color
))
2457 value
= Fassq (parameter
, f
->param_alist
);
2460 value
= XCDR (value
);
2461 /* Fframe_parameters puts the actual fg/bg color names,
2462 even if f->param_alist says otherwise. This is
2463 important when param_alist's notion of colors is
2464 "unspecified". We need to do the same here. */
2465 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2467 const char *color_name
;
2470 if (EQ (parameter
, Qbackground_color
))
2472 color_name
= SDATA (value
);
2473 csz
= SCHARS (value
);
2474 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2475 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2476 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2477 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2479 else if (EQ (parameter
, Qforeground_color
))
2481 color_name
= SDATA (value
);
2482 csz
= SCHARS (value
);
2483 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2484 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2485 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2486 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2491 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2493 else if (EQ (parameter
, Qdisplay_type
)
2494 || EQ (parameter
, Qbackground_mode
))
2495 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2497 /* FIXME: Avoid this code path at all (as well as code duplication)
2498 by sharing more code with Fframe_parameters. */
2499 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2506 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2507 Smodify_frame_parameters
, 2, 2, 0,
2508 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2509 If FRAME is nil, it defaults to the selected frame.
2510 ALIST is an alist of parameters to change and their new values.
2511 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2512 The meaningful PARMs depend on the kind of frame.
2513 Undefined PARMs are ignored, but stored in the frame's parameter list
2514 so that `frame-parameters' will return them.
2516 The value of frame parameter FOO can also be accessed
2517 as a frame-local binding for the variable FOO, if you have
2518 enabled such bindings for that variable with `make-variable-frame-local'.
2519 Note that this functionality is obsolete as of Emacs 22.2, and its
2520 use is not recommended. Explicitly check for a frame-parameter instead. */)
2522 Lisp_Object frame
, alist
;
2525 register Lisp_Object tail
, prop
, val
;
2527 if (EQ (frame
, Qnil
))
2528 frame
= selected_frame
;
2529 CHECK_LIVE_FRAME (frame
);
2532 /* I think this should be done with a hook. */
2533 #ifdef HAVE_WINDOW_SYSTEM
2534 if (FRAME_WINDOW_P (f
))
2535 x_set_frame_parameters (f
, alist
);
2539 if (FRAME_MSDOS_P (f
))
2540 IT_set_frame_parameters (f
, alist
);
2545 int length
= XINT (Flength (alist
));
2548 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2550 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2552 /* Extract parm names and values into those vectors. */
2555 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2560 parms
[i
] = Fcar (elt
);
2561 values
[i
] = Fcdr (elt
);
2565 /* Now process them in reverse of specified order. */
2566 for (i
--; i
>= 0; i
--)
2570 store_frame_param (f
, prop
, val
);
2572 /* Changing the background color might change the background
2573 mode, so that we have to load new defface specs.
2574 Call frame-set-background-mode to do that. */
2575 if (EQ (prop
, Qbackground_color
))
2576 call1 (Qframe_set_background_mode
, frame
);
2582 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2584 doc
: /* Height in pixels of a line in the font in frame FRAME.
2585 If FRAME is omitted, the selected frame is used.
2586 For a terminal frame, the value is always 1. */)
2593 frame
= selected_frame
;
2594 CHECK_FRAME (frame
);
2597 #ifdef HAVE_WINDOW_SYSTEM
2598 if (FRAME_WINDOW_P (f
))
2599 return make_number (x_char_height (f
));
2602 return make_number (1);
2606 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2608 doc
: /* Width in pixels of characters in the font in frame FRAME.
2609 If FRAME is omitted, the selected frame is used.
2610 On a graphical screen, the width is the standard width of the default font.
2611 For a terminal screen, the value is always 1. */)
2618 frame
= selected_frame
;
2619 CHECK_FRAME (frame
);
2622 #ifdef HAVE_WINDOW_SYSTEM
2623 if (FRAME_WINDOW_P (f
))
2624 return make_number (x_char_width (f
));
2627 return make_number (1);
2630 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2631 Sframe_pixel_height
, 0, 1, 0,
2632 doc
: /* Return a FRAME's height in pixels.
2633 If FRAME is omitted, the selected frame is used. The exact value
2634 of the result depends on the window-system and toolkit in use:
2636 In the Gtk+ version of Emacs, it includes only any window (including
2637 the minibuffer or eacho area), mode line, and header line. It does not
2638 include the tool bar or menu bar.
2640 With the Motif or Lucid toolkits, it also includes the tool bar (but
2643 In a graphical version with no toolkit, it includes both the tool bar
2646 For a text-only terminal, it includes the menu bar. In this case, the
2647 result is really in characters rather than pixels (i.e., is identical
2648 to `frame-height'). */)
2655 frame
= selected_frame
;
2656 CHECK_FRAME (frame
);
2659 #ifdef HAVE_WINDOW_SYSTEM
2660 if (FRAME_WINDOW_P (f
))
2661 return make_number (x_pixel_height (f
));
2664 return make_number (FRAME_LINES (f
));
2667 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2668 Sframe_pixel_width
, 0, 1, 0,
2669 doc
: /* Return FRAME's width in pixels.
2670 For a terminal frame, the result really gives the width in characters.
2671 If FRAME is omitted, the selected frame is used. */)
2678 frame
= selected_frame
;
2679 CHECK_FRAME (frame
);
2682 #ifdef HAVE_WINDOW_SYSTEM
2683 if (FRAME_WINDOW_P (f
))
2684 return make_number (x_pixel_width (f
));
2687 return make_number (FRAME_COLS (f
));
2690 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2691 doc
: /* Specify that the frame FRAME has LINES lines.
2692 Optional third arg non-nil means that redisplay should use LINES lines
2693 but that the idea of the actual height of the frame should not be changed. */)
2694 (frame
, lines
, pretend
)
2695 Lisp_Object frame
, lines
, pretend
;
2697 register struct frame
*f
;
2699 CHECK_NUMBER (lines
);
2701 frame
= selected_frame
;
2702 CHECK_LIVE_FRAME (frame
);
2705 /* I think this should be done with a hook. */
2706 #ifdef HAVE_WINDOW_SYSTEM
2707 if (FRAME_WINDOW_P (f
))
2709 if (XINT (lines
) != FRAME_LINES (f
))
2710 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2711 do_pending_window_change (0);
2715 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2719 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2720 doc
: /* Specify that the frame FRAME has COLS columns.
2721 Optional third arg non-nil means that redisplay should use COLS columns
2722 but that the idea of the actual width of the frame should not be changed. */)
2723 (frame
, cols
, pretend
)
2724 Lisp_Object frame
, cols
, pretend
;
2726 register struct frame
*f
;
2727 CHECK_NUMBER (cols
);
2729 frame
= selected_frame
;
2730 CHECK_LIVE_FRAME (frame
);
2733 /* I think this should be done with a hook. */
2734 #ifdef HAVE_WINDOW_SYSTEM
2735 if (FRAME_WINDOW_P (f
))
2737 if (XINT (cols
) != FRAME_COLS (f
))
2738 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2739 do_pending_window_change (0);
2743 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2747 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2748 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2750 Lisp_Object frame
, cols
, rows
;
2752 register struct frame
*f
;
2754 CHECK_LIVE_FRAME (frame
);
2755 CHECK_NUMBER (cols
);
2756 CHECK_NUMBER (rows
);
2759 /* I think this should be done with a hook. */
2760 #ifdef HAVE_WINDOW_SYSTEM
2761 if (FRAME_WINDOW_P (f
))
2763 if (XINT (rows
) != FRAME_LINES (f
)
2764 || XINT (cols
) != FRAME_COLS (f
)
2765 || f
->new_text_lines
|| f
->new_text_cols
)
2766 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2767 do_pending_window_change (0);
2771 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2776 DEFUN ("set-frame-position", Fset_frame_position
,
2777 Sset_frame_position
, 3, 3, 0,
2778 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2779 This is actually the position of the upper left corner of the frame.
2780 Negative values for XOFFSET or YOFFSET are interpreted relative to
2781 the rightmost or bottommost possible position (that stays within the screen). */)
2782 (frame
, xoffset
, yoffset
)
2783 Lisp_Object frame
, xoffset
, yoffset
;
2785 register struct frame
*f
;
2787 CHECK_LIVE_FRAME (frame
);
2788 CHECK_NUMBER (xoffset
);
2789 CHECK_NUMBER (yoffset
);
2792 /* I think this should be done with a hook. */
2793 #ifdef HAVE_WINDOW_SYSTEM
2794 if (FRAME_WINDOW_P (f
))
2795 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2802 /***********************************************************************
2804 ***********************************************************************/
2806 /* Connect the frame-parameter names for X frames
2807 to the ways of passing the parameter values to the window system.
2809 The name of a parameter, as a Lisp symbol,
2810 has an `x-frame-parameter' property which is an integer in Lisp
2811 that is an index in this table. */
2813 struct frame_parm_table
{
2815 Lisp_Object
*variable
;
2818 static struct frame_parm_table frame_parms
[] =
2820 {"auto-raise", &Qauto_raise
},
2821 {"auto-lower", &Qauto_lower
},
2822 {"background-color", 0},
2823 {"border-color", &Qborder_color
},
2824 {"border-width", &Qborder_width
},
2825 {"cursor-color", &Qcursor_color
},
2826 {"cursor-type", &Qcursor_type
},
2828 {"foreground-color", 0},
2829 {"icon-name", &Qicon_name
},
2830 {"icon-type", &Qicon_type
},
2831 {"internal-border-width", &Qinternal_border_width
},
2832 {"menu-bar-lines", &Qmenu_bar_lines
},
2833 {"mouse-color", &Qmouse_color
},
2835 {"scroll-bar-width", &Qscroll_bar_width
},
2837 {"unsplittable", &Qunsplittable
},
2838 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2839 {"visibility", &Qvisibility
},
2840 {"tool-bar-lines", &Qtool_bar_lines
},
2841 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2842 {"scroll-bar-background", &Qscroll_bar_background
},
2843 {"screen-gamma", &Qscreen_gamma
},
2844 {"line-spacing", &Qline_spacing
},
2845 {"left-fringe", &Qleft_fringe
},
2846 {"right-fringe", &Qright_fringe
},
2847 {"wait-for-wm", &Qwait_for_wm
},
2848 {"fullscreen", &Qfullscreen
},
2849 {"font-backend", &Qfont_backend
},
2851 {"sticky", &Qsticky
},
2854 #ifdef HAVE_WINDOW_SYSTEM
2856 extern Lisp_Object Qbox
;
2857 extern Lisp_Object Qtop
;
2859 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2860 wanted positions of the WM window (not Emacs window).
2861 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2862 window (FRAME_X_WINDOW).
2866 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2868 int newwidth
= FRAME_COLS (f
);
2869 int newheight
= FRAME_LINES (f
);
2870 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2872 *top_pos
= f
->top_pos
;
2873 *left_pos
= f
->left_pos
;
2875 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2879 ph
= x_display_pixel_height (dpyinfo
);
2880 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2881 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2882 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2886 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2890 pw
= x_display_pixel_width (dpyinfo
);
2891 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2892 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2893 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2898 *height
= newheight
;
2902 /* Change the parameters of frame F as specified by ALIST.
2903 If a parameter is not specially recognized, do nothing special;
2904 otherwise call the `x_set_...' function for that parameter.
2905 Except for certain geometry properties, always call store_frame_param
2906 to store the new value in the parameter alist. */
2909 x_set_frame_parameters (FRAME_PTR f
, Lisp_Object alist
)
2913 /* If both of these parameters are present, it's more efficient to
2914 set them both at once. So we wait until we've looked at the
2915 entire list before we set them. */
2919 Lisp_Object left
, top
;
2921 /* Same with these. */
2922 Lisp_Object icon_left
, icon_top
;
2924 /* Record in these vectors all the parms specified. */
2926 Lisp_Object
*values
;
2928 int left_no_change
= 0, top_no_change
= 0;
2929 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2930 int size_changed
= 0;
2931 struct gcpro gcpro1
, gcpro2
;
2934 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2937 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2938 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2940 /* Extract parm names and values into those vectors. */
2943 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2948 parms
[i
] = Fcar (elt
);
2949 values
[i
] = Fcdr (elt
);
2952 /* TAIL and ALIST are not used again below here. */
2953 alist
= tail
= Qnil
;
2955 GCPRO2 (*parms
, *values
);
2959 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2960 because their values appear in VALUES and strings are not valid. */
2961 top
= left
= Qunbound
;
2962 icon_left
= icon_top
= Qunbound
;
2964 /* Provide default values for HEIGHT and WIDTH. */
2965 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2966 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2968 /* Process foreground_color and background_color before anything else.
2969 They are independent of other properties, but other properties (e.g.,
2970 cursor_color) are dependent upon them. */
2971 /* Process default font as well, since fringe widths depends on it. */
2972 for (p
= 0; p
< i
; p
++)
2974 Lisp_Object prop
, val
;
2978 if (EQ (prop
, Qforeground_color
)
2979 || EQ (prop
, Qbackground_color
)
2980 || EQ (prop
, Qfont
))
2982 register Lisp_Object param_index
, old_value
;
2984 old_value
= get_frame_param (f
, prop
);
2985 if (NILP (Fequal (val
, old_value
)))
2987 store_frame_param (f
, prop
, val
);
2989 param_index
= Fget (prop
, Qx_frame_parameter
);
2990 if (NATNUMP (param_index
)
2991 && (XFASTINT (param_index
)
2992 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2993 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2994 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2999 /* Now process them in reverse of specified order. */
3000 for (i
--; i
>= 0; i
--)
3002 Lisp_Object prop
, val
;
3007 if (EQ (prop
, Qwidth
) && NATNUMP (val
))
3010 width
= XFASTINT (val
);
3012 else if (EQ (prop
, Qheight
) && NATNUMP (val
))
3015 height
= XFASTINT (val
);
3017 else if (EQ (prop
, Qtop
))
3019 else if (EQ (prop
, Qleft
))
3021 else if (EQ (prop
, Qicon_top
))
3023 else if (EQ (prop
, Qicon_left
))
3025 else if (EQ (prop
, Qforeground_color
)
3026 || EQ (prop
, Qbackground_color
)
3027 || EQ (prop
, Qfont
))
3028 /* Processed above. */
3032 register Lisp_Object param_index
, old_value
;
3034 old_value
= get_frame_param (f
, prop
);
3036 store_frame_param (f
, prop
, val
);
3038 param_index
= Fget (prop
, Qx_frame_parameter
);
3039 if (NATNUMP (param_index
)
3040 && (XFASTINT (param_index
)
3041 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3042 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3043 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3047 /* Don't die if just one of these was set. */
3048 if (EQ (left
, Qunbound
))
3051 if (f
->left_pos
< 0)
3052 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
3054 XSETINT (left
, f
->left_pos
);
3056 if (EQ (top
, Qunbound
))
3060 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
3062 XSETINT (top
, f
->top_pos
);
3065 /* If one of the icon positions was not set, preserve or default it. */
3066 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
3068 icon_left_no_change
= 1;
3069 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3070 if (NILP (icon_left
))
3071 XSETINT (icon_left
, 0);
3073 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
3075 icon_top_no_change
= 1;
3076 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3077 if (NILP (icon_top
))
3078 XSETINT (icon_top
, 0);
3081 /* Don't set these parameters unless they've been explicitly
3082 specified. The window might be mapped or resized while we're in
3083 this function, and we don't want to override that unless the lisp
3084 code has asked for it.
3086 Don't set these parameters unless they actually differ from the
3087 window's current parameters; the window may not actually exist
3092 check_frame_size (f
, &height
, &width
);
3094 XSETFRAME (frame
, f
);
3097 && (width
!= FRAME_COLS (f
)
3098 || height
!= FRAME_LINES (f
)
3099 || f
->new_text_lines
|| f
->new_text_cols
))
3100 Fset_frame_size (frame
, make_number (width
), make_number (height
));
3102 if ((!NILP (left
) || !NILP (top
))
3103 && ! (left_no_change
&& top_no_change
)
3104 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3105 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3110 /* Record the signs. */
3111 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3112 if (EQ (left
, Qminus
))
3113 f
->size_hint_flags
|= XNegative
;
3114 else if (INTEGERP (left
))
3116 leftpos
= XINT (left
);
3118 f
->size_hint_flags
|= XNegative
;
3120 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3121 && CONSP (XCDR (left
))
3122 && INTEGERP (XCAR (XCDR (left
))))
3124 leftpos
= - XINT (XCAR (XCDR (left
)));
3125 f
->size_hint_flags
|= XNegative
;
3127 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3128 && CONSP (XCDR (left
))
3129 && INTEGERP (XCAR (XCDR (left
))))
3131 leftpos
= XINT (XCAR (XCDR (left
)));
3134 if (EQ (top
, Qminus
))
3135 f
->size_hint_flags
|= YNegative
;
3136 else if (INTEGERP (top
))
3138 toppos
= XINT (top
);
3140 f
->size_hint_flags
|= YNegative
;
3142 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3143 && CONSP (XCDR (top
))
3144 && INTEGERP (XCAR (XCDR (top
))))
3146 toppos
= - XINT (XCAR (XCDR (top
)));
3147 f
->size_hint_flags
|= YNegative
;
3149 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
3150 && CONSP (XCDR (top
))
3151 && INTEGERP (XCAR (XCDR (top
))))
3153 toppos
= XINT (XCAR (XCDR (top
)));
3157 /* Store the numeric value of the position. */
3158 f
->top_pos
= toppos
;
3159 f
->left_pos
= leftpos
;
3161 f
->win_gravity
= NorthWestGravity
;
3163 /* Actually set that position, and convert to absolute. */
3164 x_set_offset (f
, leftpos
, toppos
, -1);
3167 if ((!NILP (icon_left
) || !NILP (icon_top
))
3168 && ! (icon_left_no_change
&& icon_top_no_change
))
3169 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3176 /* Insert a description of internally-recorded parameters of frame X
3177 into the parameter alist *ALISTPTR that is to be given to the user.
3178 Only parameters that are specific to the X window system
3179 and whose values are not correctly recorded in the frame's
3180 param_alist need to be considered here. */
3183 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3188 /* Represent negative positions (off the top or left screen edge)
3189 in a way that Fmodify_frame_parameters will understand correctly. */
3190 XSETINT (tem
, f
->left_pos
);
3191 if (f
->left_pos
>= 0)
3192 store_in_alist (alistptr
, Qleft
, tem
);
3194 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3196 XSETINT (tem
, f
->top_pos
);
3197 if (f
->top_pos
>= 0)
3198 store_in_alist (alistptr
, Qtop
, tem
);
3200 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3202 store_in_alist (alistptr
, Qborder_width
,
3203 make_number (f
->border_width
));
3204 store_in_alist (alistptr
, Qinternal_border_width
,
3205 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3206 store_in_alist (alistptr
, Qleft_fringe
,
3207 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3208 store_in_alist (alistptr
, Qright_fringe
,
3209 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3210 store_in_alist (alistptr
, Qscroll_bar_width
,
3211 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3213 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3214 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3215 /* nil means "use default width"
3216 for non-toolkit scroll bar.
3217 ruler-mode.el depends on this. */
3219 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
3220 store_in_alist (alistptr
, Qwindow_id
,
3221 build_string (buf
));
3222 #ifdef HAVE_X_WINDOWS
3223 #ifdef USE_X_TOOLKIT
3224 /* Tooltip frame may not have this widget. */
3225 if (FRAME_X_OUTPUT (f
)->widget
)
3227 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
3228 store_in_alist (alistptr
, Qouter_window_id
,
3229 build_string (buf
));
3231 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3232 FRAME_SAMPLE_VISIBILITY (f
);
3233 store_in_alist (alistptr
, Qvisibility
,
3234 (FRAME_VISIBLE_P (f
) ? Qt
3235 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3236 store_in_alist (alistptr
, Qdisplay
,
3237 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3239 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3242 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3243 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3244 store_in_alist (alistptr
, Qparent_id
, tem
);
3248 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3249 the previous value of that parameter, NEW_VALUE is the new value. */
3252 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3254 if (NILP (new_value
))
3255 f
->want_fullscreen
= FULLSCREEN_NONE
;
3256 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3257 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3258 else if (EQ (new_value
, Qfullwidth
))
3259 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3260 else if (EQ (new_value
, Qfullheight
))
3261 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3262 else if (EQ (new_value
, Qmaximized
))
3263 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3265 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3266 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3270 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3271 the previous value of that parameter, NEW_VALUE is the new value. */
3274 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3276 if (NILP (new_value
))
3277 f
->extra_line_spacing
= 0;
3278 else if (NATNUMP (new_value
))
3279 f
->extra_line_spacing
= XFASTINT (new_value
);
3281 signal_error ("Invalid line-spacing", new_value
);
3282 if (FRAME_VISIBLE_P (f
))
3287 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3288 the previous value of that parameter, NEW_VALUE is the new value. */
3291 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3293 Lisp_Object bgcolor
;
3295 if (NILP (new_value
))
3297 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3298 /* The value 0.4545 is the normal viewing gamma. */
3299 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3301 signal_error ("Invalid screen-gamma", new_value
);
3303 /* Apply the new gamma value to the frame background. */
3304 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3305 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3307 Lisp_Object index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3309 && (XFASTINT (index
)
3310 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3311 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3312 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3316 Fclear_face_cache (Qnil
);
3321 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3323 Lisp_Object frame
, font_object
, font_param
= Qnil
;
3326 /* Set the frame parameter back to the old value because we may
3327 fail to use ARG as the new parameter value. */
3328 store_frame_param (f
, Qfont
, oldval
);
3330 /* ARG is a fontset name, a font name, a cons of fontset name and a
3331 font object, or a font object. In the last case, this function
3336 fontset
= fs_query_fontset (arg
, 0);
3339 font_object
= font_open_by_name (f
, SDATA (arg
));
3340 if (NILP (font_object
))
3341 error ("Font `%s' is not defined", SDATA (arg
));
3342 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3344 else if (fontset
> 0)
3346 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3348 font_object
= font_open_by_name (f
, SDATA (ascii_font
));
3349 if (NILP (font_object
))
3350 error ("Font `%s' is not defined", SDATA (arg
));
3351 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3354 error ("The default fontset can't be used for a frame font");
3356 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3358 /* This is the case that the ASCII font of F's fontset XCAR
3359 (arg) is changed to the font XCDR (arg) by
3360 `set-fontset-font'. */
3361 fontset
= fs_query_fontset (XCAR (arg
), 0);
3363 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3364 font_object
= XCDR (arg
);
3365 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3366 font_param
= Ffont_get (font_object
, QCname
);
3368 else if (FONT_OBJECT_P (arg
))
3371 font_param
= Ffont_get (font_object
, QCname
);
3372 /* This is to store the XLFD font name in the frame parameter for
3373 backward compatibility. We should store the font-object
3374 itself in the future. */
3375 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3376 fontset
= FRAME_FONTSET (f
);
3377 /* Check if we can use the current fontset. If not, set FONTSET
3378 to -1 to generate a new fontset from FONT-OBJECT. */
3381 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3382 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3384 if (! font_match_p (spec
, font_object
))
3389 signal_error ("Invalid font", arg
);
3391 if (! NILP (Fequal (font_object
, oldval
)))
3394 x_new_font (f
, font_object
, fontset
);
3395 store_frame_param (f
, Qfont
, arg
);
3396 #ifdef HAVE_X_WINDOWS
3397 store_frame_param (f
, Qfont_param
, font_param
);
3399 /* Recalculate toolbar height. */
3400 f
->n_tool_bar_rows
= 0;
3401 /* Ensure we redraw it. */
3402 clear_current_matrices (f
);
3404 recompute_basic_faces (f
);
3406 do_pending_window_change (0);
3408 /* We used to call face-set-after-frame-default here, but it leads to
3409 recursive calls (since that function can set the `default' face's
3410 font which in turns changes the frame's `font' parameter).
3411 Also I don't know what this call is meant to do, but it seems the
3412 wrong way to do it anyway (it does a lot more work than what seems
3413 reasonable in response to a change to `font'). */
3418 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3420 if (! NILP (new_value
)
3421 && !CONSP (new_value
))
3425 CHECK_STRING (new_value
);
3426 p0
= p1
= SDATA (new_value
);
3430 while (*p1
&& ! isspace (*p1
) && *p1
!= ',') p1
++;
3432 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3438 while ((c
= *++p1
) && isspace (c
));
3442 new_value
= Fnreverse (new_value
);
3445 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3449 free_all_realized_faces (Qnil
);
3451 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3452 if (NILP (new_value
))
3454 if (NILP (old_value
))
3455 error ("No font backend available");
3456 font_update_drivers (f
, old_value
);
3457 error ("None of specified font backends are available");
3459 store_frame_param (f
, Qfont_backend
, new_value
);
3465 XSETFRAME (frame
, f
);
3466 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3467 ++face_change_count
;
3468 ++windows_or_buffers_changed
;
3474 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3476 compute_fringe_widths (f
, 1);
3480 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3484 if (XINT (arg
) == f
->border_width
)
3487 if (FRAME_X_WINDOW (f
) != 0)
3488 error ("Cannot change the border width of a frame");
3490 f
->border_width
= XINT (arg
);
3494 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3496 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3499 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3500 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3501 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3503 #ifdef USE_X_TOOLKIT
3504 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3505 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3508 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3511 if (FRAME_X_WINDOW (f
) != 0)
3513 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3514 SET_FRAME_GARBAGED (f
);
3515 do_pending_window_change (0);
3518 SET_FRAME_GARBAGED (f
);
3522 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3525 XSETFRAME (frame
, f
);
3528 Fmake_frame_invisible (frame
, Qt
);
3529 else if (EQ (value
, Qicon
))
3530 Ficonify_frame (frame
);
3532 Fmake_frame_visible (frame
);
3536 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3538 f
->auto_raise
= !EQ (Qnil
, arg
);
3542 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3544 f
->auto_lower
= !EQ (Qnil
, arg
);
3548 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3550 f
->no_split
= !NILP (arg
);
3554 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3556 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3557 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3558 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3559 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3561 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3563 ? vertical_scroll_bar_none
3565 ? vertical_scroll_bar_left
3567 ? vertical_scroll_bar_right
3568 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3569 ? vertical_scroll_bar_left
3570 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3571 ? vertical_scroll_bar_right
3572 : vertical_scroll_bar_none
);
3574 /* We set this parameter before creating the X window for the
3575 frame, so we can get the geometry right from the start.
3576 However, if the window hasn't been created yet, we shouldn't
3577 call x_set_window_size. */
3578 if (FRAME_X_WINDOW (f
))
3579 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3580 do_pending_window_change (0);
3585 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3587 int wid
= FRAME_COLUMN_WIDTH (f
);
3591 x_set_scroll_bar_default_width (f
);
3593 if (FRAME_X_WINDOW (f
))
3594 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3595 do_pending_window_change (0);
3597 else if (INTEGERP (arg
) && XINT (arg
) > 0
3598 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3600 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3601 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3603 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3604 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3605 if (FRAME_X_WINDOW (f
))
3606 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3607 do_pending_window_change (0);
3610 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3611 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3612 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3617 /* Return non-nil if frame F wants a bitmap icon. */
3620 x_icon_type (FRAME_PTR f
)
3624 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3632 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3639 for (i
= 0; i
< 2; i
++)
3652 else if (FLOATP (item
))
3654 alpha
= XFLOAT_DATA (item
);
3655 if (alpha
< 0.0 || 1.0 < alpha
)
3656 args_out_of_range (make_float (0.0), make_float (1.0));
3658 else if (INTEGERP (item
))
3660 ialpha
= XINT (item
);
3661 if (ialpha
< 0 || 100 < ialpha
)
3662 args_out_of_range (make_number (0), make_number (100));
3664 alpha
= ialpha
/ 100.0;
3667 wrong_type_argument (Qnumberp
, item
);
3671 for (i
= 0; i
< 2; i
++)
3672 f
->alpha
[i
] = newval
[i
];
3674 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3676 x_set_frame_alpha (f
);
3684 /* Subroutines of creating an X frame. */
3686 /* Make sure that Vx_resource_name is set to a reasonable value.
3687 Fix it up, or set it to `emacs' if it is too hopeless. */
3690 validate_x_resource_name (void)
3693 /* Number of valid characters in the resource name. */
3695 /* Number of invalid characters in the resource name. */
3700 if (!STRINGP (Vx_resource_class
))
3701 Vx_resource_class
= build_string (EMACS_CLASS
);
3703 if (STRINGP (Vx_resource_name
))
3705 unsigned char *p
= SDATA (Vx_resource_name
);
3708 len
= SBYTES (Vx_resource_name
);
3710 /* Only letters, digits, - and _ are valid in resource names.
3711 Count the valid characters and count the invalid ones. */
3712 for (i
= 0; i
< len
; i
++)
3715 if (! ((c
>= 'a' && c
<= 'z')
3716 || (c
>= 'A' && c
<= 'Z')
3717 || (c
>= '0' && c
<= '9')
3718 || c
== '-' || c
== '_'))
3725 /* Not a string => completely invalid. */
3726 bad_count
= 5, good_count
= 0;
3728 /* If name is valid already, return. */
3732 /* If name is entirely invalid, or nearly so, use `emacs'. */
3734 || (good_count
== 1 && bad_count
> 0))
3736 Vx_resource_name
= build_string ("emacs");
3740 /* Name is partly valid. Copy it and replace the invalid characters
3741 with underscores. */
3743 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3745 for (i
= 0; i
< len
; i
++)
3747 int c
= SREF (new, i
);
3748 if (! ((c
>= 'a' && c
<= 'z')
3749 || (c
>= 'A' && c
<= 'Z')
3750 || (c
>= '0' && c
<= '9')
3751 || c
== '-' || c
== '_'))
3757 extern char *x_get_string_resource (XrmDatabase
, char *, char *);
3758 extern Display_Info
*check_x_display_info (Lisp_Object
);
3761 /* Get specified attribute from resource database RDB.
3762 See Fx_get_resource below for other parameters. */
3765 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3767 register char *value
;
3771 CHECK_STRING (attribute
);
3772 CHECK_STRING (class);
3774 if (!NILP (component
))
3775 CHECK_STRING (component
);
3776 if (!NILP (subclass
))
3777 CHECK_STRING (subclass
);
3778 if (NILP (component
) != NILP (subclass
))
3779 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3781 validate_x_resource_name ();
3783 /* Allocate space for the components, the dots which separate them,
3784 and the final '\0'. Make them big enough for the worst case. */
3785 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3786 + (STRINGP (component
)
3787 ? SBYTES (component
) : 0)
3788 + SBYTES (attribute
)
3791 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3793 + (STRINGP (subclass
)
3794 ? SBYTES (subclass
) : 0)
3797 /* Start with emacs.FRAMENAME for the name (the specific one)
3798 and with `Emacs' for the class key (the general one). */
3799 strcpy (name_key
, SDATA (Vx_resource_name
));
3800 strcpy (class_key
, SDATA (Vx_resource_class
));
3802 strcat (class_key
, ".");
3803 strcat (class_key
, SDATA (class));
3805 if (!NILP (component
))
3807 strcat (class_key
, ".");
3808 strcat (class_key
, SDATA (subclass
));
3810 strcat (name_key
, ".");
3811 strcat (name_key
, SDATA (component
));
3814 strcat (name_key
, ".");
3815 strcat (name_key
, SDATA (attribute
));
3817 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3819 if (value
!= (char *) 0 && *value
)
3820 return build_string (value
);
3826 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3827 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3828 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3829 class, where INSTANCE is the name under which Emacs was invoked, or
3830 the name specified by the `-name' or `-rn' command-line arguments.
3832 The optional arguments COMPONENT and SUBCLASS add to the key and the
3833 class, respectively. You must specify both of them or neither.
3834 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3835 and the class is `Emacs.CLASS.SUBCLASS'. */)
3836 (attribute
, class, component
, subclass
)
3837 Lisp_Object attribute
, class, component
, subclass
;
3839 #ifdef HAVE_X_WINDOWS
3843 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3844 attribute
, class, component
, subclass
);
3847 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3850 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3852 return xrdb_get_resource (dpyinfo
->xrdb
,
3853 attribute
, class, component
, subclass
);
3856 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3857 /* Used when C code wants a resource value. */
3858 /* Called from oldXMenu/Create.c. */
3860 x_get_resource_string (char *attribute
, char *class)
3864 struct frame
*sf
= SELECTED_FRAME ();
3866 /* Allocate space for the components, the dots which separate them,
3867 and the final '\0'. */
3868 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3869 + strlen (attribute
) + 2);
3870 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3871 + strlen (class) + 2);
3873 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3874 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3876 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3877 name_key
, class_key
);
3881 /* Return the value of parameter PARAM.
3883 First search ALIST, then Vdefault_frame_alist, then the X defaults
3884 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3886 Convert the resource to the type specified by desired_type.
3888 If no default is specified, return Qunbound. If you call
3889 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3890 and don't let it get stored in any Lisp-visible variables! */
3893 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
, char *attribute
, char *class, enum resource_types type
)
3895 register Lisp_Object tem
;
3897 tem
= Fassq (param
, alist
);
3901 /* If we find this parm in ALIST, clear it out
3902 so that it won't be "left over" at the end. */
3904 XSETCAR (tem
, Qnil
);
3905 /* In case the parameter appears more than once in the alist,
3907 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3908 if (CONSP (XCAR (tail
))
3909 && EQ (XCAR (XCAR (tail
)), param
))
3910 XSETCAR (XCAR (tail
), Qnil
);
3913 tem
= Fassq (param
, Vdefault_frame_alist
);
3915 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3916 look in the X resources. */
3919 if (attribute
&& dpyinfo
)
3921 tem
= display_x_get_resource (dpyinfo
,
3922 build_string (attribute
),
3923 build_string (class),
3931 case RES_TYPE_NUMBER
:
3932 return make_number (atoi (SDATA (tem
)));
3934 case RES_TYPE_BOOLEAN_NUMBER
:
3935 if (!strcmp (SDATA (tem
), "on")
3936 || !strcmp (SDATA (tem
), "true"))
3937 return make_number (1);
3938 return make_number (atoi (SDATA (tem
)));
3941 case RES_TYPE_FLOAT
:
3942 return make_float (atof (SDATA (tem
)));
3944 case RES_TYPE_BOOLEAN
:
3945 tem
= Fdowncase (tem
);
3946 if (!strcmp (SDATA (tem
), "on")
3948 || !strcmp(SDATA(tem
), "yes")
3950 || !strcmp (SDATA (tem
), "true"))
3955 case RES_TYPE_STRING
:
3958 case RES_TYPE_SYMBOL
:
3959 /* As a special case, we map the values `true' and `on'
3960 to Qt, and `false' and `off' to Qnil. */
3963 lower
= Fdowncase (tem
);
3964 if (!strcmp (SDATA (lower
), "on")
3966 || !strcmp(SDATA(lower
), "yes")
3968 || !strcmp (SDATA (lower
), "true"))
3970 else if (!strcmp (SDATA (lower
), "off")
3972 || !strcmp(SDATA(lower
), "no")
3974 || !strcmp (SDATA (lower
), "false"))
3977 return Fintern (tem
, Qnil
);
3991 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
, char *attribute
, char *class, enum resource_types type
)
3993 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3994 alist
, param
, attribute
, class, type
);
3997 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
4000 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
, char *attribute
, char *class, enum resource_types type
)
4004 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
4005 attribute
, class, type
);
4006 if (! NILP (value
) && ! EQ (value
, Qunbound
))
4007 store_frame_param (f
, param
, value
);
4013 /* Record in frame F the specified or default value according to ALIST
4014 of the parameter named PROP (a Lisp symbol).
4015 If no value is specified for PROP, look for an X default for XPROP
4016 on the frame named NAME.
4017 If that is not found either, use the value DEFLT. */
4020 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
, Lisp_Object deflt
, char *xprop
, char *xclass
, enum resource_types type
)
4024 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
4025 if (EQ (tem
, Qunbound
))
4027 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
4034 /* NS used to define x-parse-geometry in ns-win.el, but that confused
4035 make-docfile: the documentation string in ns-win.el was used for
4036 x-parse-geometry even in non-NS builds.
4038 With two definitions of x-parse-geometry in this file, various
4039 things still get confused (eg M-x apropos documentation), so that
4040 it is best if the two definitions just share the same doc-string.
4042 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4043 doc
: /* Parse a display geometry string STRING.
4044 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4045 The properties returned may include `top', `left', `height', and `width'.
4046 For X, the value of `left' or `top' may be an integer,
4047 or a list (+ N) meaning N pixels relative to top/left corner,
4048 or a list (- N) meaning -N pixels relative to bottom/right corner.
4049 On Nextstep, this just calls `ns-parse-geometry'. */)
4054 call1 (Qns_parse_geometry
, string
);
4057 unsigned int width
, height
;
4060 CHECK_STRING (string
);
4062 geometry
= XParseGeometry ((char *) SDATA (string
),
4063 &x
, &y
, &width
, &height
);
4065 if (geometry
& XValue
)
4067 Lisp_Object element
;
4069 if (x
>= 0 && (geometry
& XNegative
))
4070 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
4071 else if (x
< 0 && ! (geometry
& XNegative
))
4072 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
4074 element
= Fcons (Qleft
, make_number (x
));
4075 result
= Fcons (element
, result
);
4078 if (geometry
& YValue
)
4080 Lisp_Object element
;
4082 if (y
>= 0 && (geometry
& YNegative
))
4083 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
4084 else if (y
< 0 && ! (geometry
& YNegative
))
4085 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
4087 element
= Fcons (Qtop
, make_number (y
));
4088 result
= Fcons (element
, result
);
4091 if (geometry
& WidthValue
)
4092 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
4093 if (geometry
& HeightValue
)
4094 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
4097 #endif /* HAVE_NS */
4101 /* Calculate the desired size and position of frame F.
4102 Return the flags saying which aspects were specified.
4104 Also set the win_gravity and size_hint_flags of F.
4106 Adjust height for toolbar if TOOLBAR_P is 1.
4108 This function does not make the coordinates positive. */
4110 #define DEFAULT_ROWS 35
4111 #define DEFAULT_COLS 80
4114 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, int toolbar_p
)
4116 register Lisp_Object tem0
, tem1
, tem2
;
4117 long window_prompting
= 0;
4118 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
4120 /* Default values if we fall through.
4121 Actually, if that happens we should get
4122 window manager prompting. */
4123 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4124 FRAME_LINES (f
) = DEFAULT_ROWS
;
4125 /* Window managers expect that if program-specified
4126 positions are not (0,0), they're intentional, not defaults. */
4130 /* Ensure that old new_text_cols and new_text_lines will not override the
4132 /* ++KFS: This was specific to W32, but seems ok for all platforms */
4133 f
->new_text_cols
= f
->new_text_lines
= 0;
4135 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4136 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4137 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4138 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4140 if (!EQ (tem0
, Qunbound
))
4142 CHECK_NUMBER (tem0
);
4143 FRAME_LINES (f
) = XINT (tem0
);
4145 if (!EQ (tem1
, Qunbound
))
4147 CHECK_NUMBER (tem1
);
4148 SET_FRAME_COLS (f
, XINT (tem1
));
4150 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4151 window_prompting
|= USSize
;
4153 window_prompting
|= PSize
;
4156 f
->scroll_bar_actual_width
4157 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4159 /* This used to be done _before_ calling x_figure_window_size, but
4160 since the height is reset here, this was really a no-op. I
4161 assume that moving it here does what Gerd intended (although he
4162 no longer can remember what that was... ++KFS, 2003-03-25. */
4164 /* Add the tool-bar height to the initial frame height so that the
4165 user gets a text display area of the size he specified with -g or
4166 via .Xdefaults. Later changes of the tool-bar height don't
4167 change the frame size. This is done so that users can create
4168 tall Emacs frames without having to guess how tall the tool-bar
4170 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4172 int margin
, relief
, bar_height
;
4174 relief
= (tool_bar_button_relief
>= 0
4175 ? tool_bar_button_relief
4176 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4178 if (INTEGERP (Vtool_bar_button_margin
)
4179 && XINT (Vtool_bar_button_margin
) > 0)
4180 margin
= XFASTINT (Vtool_bar_button_margin
);
4181 else if (CONSP (Vtool_bar_button_margin
)
4182 && INTEGERP (XCDR (Vtool_bar_button_margin
))
4183 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
4184 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4188 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4189 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4192 compute_fringe_widths (f
, 0);
4194 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4195 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4197 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4198 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4199 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4200 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4202 if (EQ (tem0
, Qminus
))
4205 window_prompting
|= YNegative
;
4207 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4208 && CONSP (XCDR (tem0
))
4209 && INTEGERP (XCAR (XCDR (tem0
))))
4211 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4212 window_prompting
|= YNegative
;
4214 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4215 && CONSP (XCDR (tem0
))
4216 && INTEGERP (XCAR (XCDR (tem0
))))
4218 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4220 else if (EQ (tem0
, Qunbound
))
4224 CHECK_NUMBER (tem0
);
4225 f
->top_pos
= XINT (tem0
);
4227 window_prompting
|= YNegative
;
4230 if (EQ (tem1
, Qminus
))
4233 window_prompting
|= XNegative
;
4235 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4236 && CONSP (XCDR (tem1
))
4237 && INTEGERP (XCAR (XCDR (tem1
))))
4239 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4240 window_prompting
|= XNegative
;
4242 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4243 && CONSP (XCDR (tem1
))
4244 && INTEGERP (XCAR (XCDR (tem1
))))
4246 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4248 else if (EQ (tem1
, Qunbound
))
4252 CHECK_NUMBER (tem1
);
4253 f
->left_pos
= XINT (tem1
);
4254 if (f
->left_pos
< 0)
4255 window_prompting
|= XNegative
;
4258 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4259 window_prompting
|= USPosition
;
4261 window_prompting
|= PPosition
;
4264 if (window_prompting
& XNegative
)
4266 if (window_prompting
& YNegative
)
4267 f
->win_gravity
= SouthEastGravity
;
4269 f
->win_gravity
= NorthEastGravity
;
4273 if (window_prompting
& YNegative
)
4274 f
->win_gravity
= SouthWestGravity
;
4276 f
->win_gravity
= NorthWestGravity
;
4279 f
->size_hint_flags
= window_prompting
;
4281 return window_prompting
;
4286 #endif /* HAVE_WINDOW_SYSTEM */
4289 frame_make_pointer_invisible (void)
4291 if (! NILP (Vmake_pointer_invisible
))
4294 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4297 f
= SELECTED_FRAME ();
4298 if (f
&& !f
->pointer_invisible
4299 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4302 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4303 f
->pointer_invisible
= 1;
4309 frame_make_pointer_visible (void)
4311 /* We don't check Vmake_pointer_invisible here in case the
4312 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4315 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4318 f
= SELECTED_FRAME ();
4319 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4320 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4322 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4323 f
->pointer_invisible
= 0;
4329 /***********************************************************************
4331 ***********************************************************************/
4334 syms_of_frame (void)
4336 Qframep
= intern_c_string ("framep");
4337 staticpro (&Qframep
);
4338 Qframe_live_p
= intern_c_string ("frame-live-p");
4339 staticpro (&Qframe_live_p
);
4340 Qexplicit_name
= intern_c_string ("explicit-name");
4341 staticpro (&Qexplicit_name
);
4342 Qheight
= intern_c_string ("height");
4343 staticpro (&Qheight
);
4344 Qicon
= intern_c_string ("icon");
4346 Qminibuffer
= intern_c_string ("minibuffer");
4347 staticpro (&Qminibuffer
);
4348 Qmodeline
= intern_c_string ("modeline");
4349 staticpro (&Qmodeline
);
4350 Qonly
= intern_c_string ("only");
4352 Qwidth
= intern_c_string ("width");
4353 staticpro (&Qwidth
);
4354 Qgeometry
= intern_c_string ("geometry");
4355 staticpro (&Qgeometry
);
4356 Qicon_left
= intern_c_string ("icon-left");
4357 staticpro (&Qicon_left
);
4358 Qicon_top
= intern_c_string ("icon-top");
4359 staticpro (&Qicon_top
);
4360 Qleft
= intern_c_string ("left");
4362 Qright
= intern_c_string ("right");
4363 staticpro (&Qright
);
4364 Quser_position
= intern_c_string ("user-position");
4365 staticpro (&Quser_position
);
4366 Quser_size
= intern_c_string ("user-size");
4367 staticpro (&Quser_size
);
4368 Qwindow_id
= intern_c_string ("window-id");
4369 staticpro (&Qwindow_id
);
4370 #ifdef HAVE_X_WINDOWS
4371 Qouter_window_id
= intern_c_string ("outer-window-id");
4372 staticpro (&Qouter_window_id
);
4374 Qparent_id
= intern_c_string ("parent-id");
4375 staticpro (&Qparent_id
);
4376 Qx
= intern_c_string ("x");
4378 Qw32
= intern_c_string ("w32");
4380 Qpc
= intern_c_string ("pc");
4382 Qmac
= intern_c_string ("mac");
4384 Qns
= intern_c_string ("ns");
4386 Qvisible
= intern_c_string ("visible");
4387 staticpro (&Qvisible
);
4388 Qbuffer_predicate
= intern_c_string ("buffer-predicate");
4389 staticpro (&Qbuffer_predicate
);
4390 Qbuffer_list
= intern_c_string ("buffer-list");
4391 staticpro (&Qbuffer_list
);
4392 Qburied_buffer_list
= intern_c_string ("buried-buffer-list");
4393 staticpro (&Qburied_buffer_list
);
4394 Qdisplay_type
= intern_c_string ("display-type");
4395 staticpro (&Qdisplay_type
);
4396 Qbackground_mode
= intern_c_string ("background-mode");
4397 staticpro (&Qbackground_mode
);
4398 Qnoelisp
= intern_c_string ("noelisp");
4399 staticpro (&Qnoelisp
);
4400 Qtty_color_mode
= intern_c_string ("tty-color-mode");
4401 staticpro (&Qtty_color_mode
);
4402 Qtty
= intern_c_string ("tty");
4404 Qtty_type
= intern_c_string ("tty-type");
4405 staticpro (&Qtty_type
);
4407 Qface_set_after_frame_default
= intern_c_string ("face-set-after-frame-default");
4408 staticpro (&Qface_set_after_frame_default
);
4410 Qfullwidth
= intern_c_string ("fullwidth");
4411 staticpro (&Qfullwidth
);
4412 Qfullheight
= intern_c_string ("fullheight");
4413 staticpro (&Qfullheight
);
4414 Qfullboth
= intern_c_string ("fullboth");
4415 staticpro (&Qfullboth
);
4416 Qmaximized
= intern_c_string ("maximized");
4417 staticpro (&Qmaximized
);
4418 Qx_resource_name
= intern_c_string ("x-resource-name");
4419 staticpro (&Qx_resource_name
);
4421 Qx_frame_parameter
= intern_c_string ("x-frame-parameter");
4422 staticpro (&Qx_frame_parameter
);
4424 Qterminal
= intern_c_string ("terminal");
4425 staticpro (&Qterminal
);
4426 Qterminal_live_p
= intern_c_string ("terminal-live-p");
4427 staticpro (&Qterminal_live_p
);
4430 Qns_parse_geometry
= intern_c_string ("ns-parse-geometry");
4431 staticpro (&Qns_parse_geometry
);
4437 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4439 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4440 if (frame_parms
[i
].variable
)
4442 *frame_parms
[i
].variable
= v
;
4443 staticpro (frame_parms
[i
].variable
);
4445 Fput (v
, Qx_frame_parameter
, make_number (i
));
4449 #ifdef HAVE_WINDOW_SYSTEM
4450 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4451 doc
: /* The name Emacs uses to look up X resources.
4452 `x-get-resource' uses this as the first component of the instance name
4453 when requesting resource values.
4454 Emacs initially sets `x-resource-name' to the name under which Emacs
4455 was invoked, or to the value specified with the `-name' or `-rn'
4456 switches, if present.
4458 It may be useful to bind this variable locally around a call
4459 to `x-get-resource'. See also the variable `x-resource-class'. */);
4460 Vx_resource_name
= Qnil
;
4462 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4463 doc
: /* The class Emacs uses to look up X resources.
4464 `x-get-resource' uses this as the first component of the instance class
4465 when requesting resource values.
4467 Emacs initially sets `x-resource-class' to "Emacs".
4469 Setting this variable permanently is not a reasonable thing to do,
4470 but binding this variable locally around a call to `x-get-resource'
4471 is a reasonable practice. See also the variable `x-resource-name'. */);
4472 Vx_resource_class
= build_string (EMACS_CLASS
);
4474 DEFVAR_LISP ("frame-alpha-lower-limit", &Vframe_alpha_lower_limit
,
4475 doc
: /* The lower limit of the frame opacity (alpha transparency).
4476 The value should range from 0 (invisible) to 100 (completely opaque).
4477 You can also use a floating number between 0.0 and 1.0.
4478 The default is 20. */);
4479 Vframe_alpha_lower_limit
= make_number (20);
4482 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4483 doc
: /* Alist of default values for frame creation.
4484 These may be set in your init file, like this:
4485 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4486 These override values given in window system configuration data,
4487 including X Windows' defaults database.
4488 For values specific to the first Emacs frame, see `initial-frame-alist'.
4489 For window-system specific values, see `window-system-default-frame-alist'.
4490 For values specific to the separate minibuffer frame, see
4491 `minibuffer-frame-alist'.
4492 The `menu-bar-lines' element of the list controls whether new frames
4493 have menu bars; `menu-bar-mode' works by altering this element.
4494 Setting this variable does not affect existing frames, only new ones. */);
4495 Vdefault_frame_alist
= Qnil
;
4497 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars
,
4498 doc
: /* Default position of scroll bars on this window-system. */);
4499 #ifdef HAVE_WINDOW_SYSTEM
4500 #if defined(HAVE_NTGUI) || defined(NS_IMPL_COCOA) || (defined(USE_GTK) && defined(USE_TOOLKIT_SCROLL_BARS))
4501 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4503 Vdefault_frame_scroll_bars
= Qright
;
4505 Vdefault_frame_scroll_bars
= Qleft
;
4508 Vdefault_frame_scroll_bars
= Qnil
;
4511 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4512 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4514 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4515 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4516 `mouse-position' calls this function, passing its usual return value as
4517 argument, and returns whatever this function returns.
4518 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4519 which need to do mouse handling at the Lisp level. */);
4520 Vmouse_position_function
= Qnil
;
4522 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4523 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4524 If the value is an integer, highlighting is only shown after moving the
4525 mouse, while keyboard input turns off the highlight even when the mouse
4526 is over the clickable text. However, the mouse shape still indicates
4527 when the mouse is over clickable text. */);
4528 Vmouse_highlight
= Qt
;
4530 DEFVAR_LISP ("make-pointer-invisible", &Vmake_pointer_invisible
,
4531 doc
: /* If non-nil, make pointer invisible while typing.
4532 The pointer becomes visible again when the mouse is moved. */);
4533 Vmake_pointer_invisible
= Qt
;
4535 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4536 doc
: /* Functions to be run before deleting a frame.
4537 The functions are run with one arg, the frame to be deleted.
4540 Note that functions in this list may be called just before the frame is
4541 actually deleted, or some time later (or even both when an earlier function
4542 in `delete-frame-functions' (indirectly) calls `delete-frame'
4544 Vdelete_frame_functions
= Qnil
;
4545 Qdelete_frame_functions
= intern_c_string ("delete-frame-functions");
4546 staticpro (&Qdelete_frame_functions
);
4548 DEFVAR_LISP ("menu-bar-mode", &Vmenu_bar_mode
,
4549 doc
: /* Non-nil if Menu-Bar mode is enabled. */);
4550 Vmenu_bar_mode
= Qt
;
4552 DEFVAR_LISP ("tool-bar-mode", &Vtool_bar_mode
,
4553 doc
: /* Non-nil if Tool-Bar mode is enabled. */);
4554 Vtool_bar_mode
= Qt
;
4556 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4557 doc
: /* Minibufferless frames use this frame's minibuffer.
4559 Emacs cannot create minibufferless frames unless this is set to an
4560 appropriate surrogate.
4562 Emacs consults this variable only when creating minibufferless
4563 frames; once the frame is created, it sticks with its assigned
4564 minibuffer, no matter what this variable is set to. This means that
4565 this variable doesn't necessarily say anything meaningful about the
4566 current set of frames, or where the minibuffer is currently being
4569 This variable is local to the current terminal and cannot be buffer-local. */);
4571 DEFVAR_BOOL ("focus-follows-mouse", &focus_follows_mouse
,
4572 doc
: /* Non-nil if window system changes focus when you move the mouse.
4573 You should set this variable to tell Emacs how your window manager
4574 handles focus, since there is no way in general for Emacs to find out
4575 automatically. See also `mouse-autoselect-window'. */);
4576 #ifdef HAVE_WINDOW_SYSTEM
4577 #if defined(HAVE_NTGUI) || defined(HAVE_NS)
4578 focus_follows_mouse
= 0;
4580 focus_follows_mouse
= 1;
4583 focus_follows_mouse
= 0;
4586 staticpro (&Vframe_list
);
4588 defsubr (&Sactive_minibuffer_window
);
4590 defsubr (&Sframe_live_p
);
4591 defsubr (&Swindow_system
);
4592 defsubr (&Smake_terminal_frame
);
4593 defsubr (&Shandle_switch_frame
);
4594 defsubr (&Sselect_frame
);
4595 defsubr (&Sselected_frame
);
4596 defsubr (&Swindow_frame
);
4597 defsubr (&Sframe_root_window
);
4598 defsubr (&Sframe_first_window
);
4599 defsubr (&Sframe_selected_window
);
4600 defsubr (&Sset_frame_selected_window
);
4601 defsubr (&Sframe_list
);
4602 defsubr (&Snext_frame
);
4603 defsubr (&Sprevious_frame
);
4604 defsubr (&Sdelete_frame
);
4605 defsubr (&Smouse_position
);
4606 defsubr (&Smouse_pixel_position
);
4607 defsubr (&Sset_mouse_position
);
4608 defsubr (&Sset_mouse_pixel_position
);
4610 defsubr (&Sframe_configuration
);
4611 defsubr (&Srestore_frame_configuration
);
4613 defsubr (&Smake_frame_visible
);
4614 defsubr (&Smake_frame_invisible
);
4615 defsubr (&Siconify_frame
);
4616 defsubr (&Sframe_visible_p
);
4617 defsubr (&Svisible_frame_list
);
4618 defsubr (&Sraise_frame
);
4619 defsubr (&Slower_frame
);
4620 defsubr (&Sredirect_frame_focus
);
4621 defsubr (&Sframe_focus
);
4622 defsubr (&Sframe_parameters
);
4623 defsubr (&Sframe_parameter
);
4624 defsubr (&Smodify_frame_parameters
);
4625 defsubr (&Sframe_char_height
);
4626 defsubr (&Sframe_char_width
);
4627 defsubr (&Sframe_pixel_height
);
4628 defsubr (&Sframe_pixel_width
);
4629 defsubr (&Sset_frame_height
);
4630 defsubr (&Sset_frame_width
);
4631 defsubr (&Sset_frame_size
);
4632 defsubr (&Sset_frame_position
);
4634 #ifdef HAVE_WINDOW_SYSTEM
4635 defsubr (&Sx_get_resource
);
4636 defsubr (&Sx_parse_geometry
);
4641 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4642 (do not change this comment) */