1 /* Generic frame functions.
3 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
4 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
5 Free Software Foundation, Inc.
7 This file is part of GNU Emacs.
9 GNU Emacs is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 GNU Emacs is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
30 #include "character.h"
41 /* These help us bind and responding to switch-frame events. */
45 #include "blockinput.h"
47 #include "termhooks.h"
48 #include "dispextern.h"
51 #ifdef HAVE_WINDOW_SYSTEM
60 #ifdef HAVE_WINDOW_SYSTEM
65 Lisp_Object Qns_parse_geometry
;
68 Lisp_Object Qframep
, Qframe_live_p
;
69 Lisp_Object Qicon
, Qmodeline
;
71 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
, Qns
;
73 Lisp_Object Qdisplay_type
;
74 Lisp_Object Qbackground_mode
;
77 Lisp_Object Qx_frame_parameter
;
78 Lisp_Object Qx_resource_name
;
79 Lisp_Object Qterminal
;
80 Lisp_Object Qterminal_live_p
;
82 /* Frame parameters (set or reported). */
84 Lisp_Object Qauto_raise
, Qauto_lower
;
85 Lisp_Object Qborder_color
, Qborder_width
;
86 Lisp_Object Qcursor_color
, Qcursor_type
;
87 Lisp_Object Qgeometry
; /* Not used */
88 Lisp_Object Qheight
, Qwidth
;
89 Lisp_Object Qleft
, Qright
;
90 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
92 Lisp_Object Qinternal_border_width
;
93 Lisp_Object Qmouse_color
;
94 Lisp_Object Qminibuffer
;
95 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
96 Lisp_Object Qvisibility
;
97 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
98 Lisp_Object Qscreen_gamma
;
99 Lisp_Object Qline_spacing
;
100 Lisp_Object Quser_position
, Quser_size
;
101 Lisp_Object Qwait_for_wm
;
102 Lisp_Object Qwindow_id
;
103 #ifdef HAVE_X_WINDOWS
104 Lisp_Object Qouter_window_id
;
106 Lisp_Object Qparent_id
;
107 Lisp_Object Qtitle
, Qname
;
108 Lisp_Object Qexplicit_name
;
109 Lisp_Object Qunsplittable
;
110 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
, Qtool_bar_position
;
111 Lisp_Object Qleft_fringe
, Qright_fringe
;
112 Lisp_Object Qbuffer_predicate
, Qbuffer_list
, Qburied_buffer_list
;
113 Lisp_Object Qtty_color_mode
;
114 Lisp_Object Qtty
, Qtty_type
;
116 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
118 Lisp_Object Qfont_backend
;
121 Lisp_Object Qface_set_after_frame_default
;
123 static Lisp_Object Qdelete_frame_functions
;
127 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
129 struct window
*w
= XWINDOW (window
);
131 XSETFASTINT (w
->last_modified
, 0);
132 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
133 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
135 if (INTEGERP (w
->orig_top_line
))
136 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
137 if (INTEGERP (w
->orig_total_lines
))
138 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
140 /* Handle just the top child in a vertical split. */
141 if (!NILP (w
->vchild
))
142 set_menu_bar_lines_1 (w
->vchild
, n
);
144 /* Adjust all children in a horizontal split. */
145 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
147 w
= XWINDOW (window
);
148 set_menu_bar_lines_1 (window
, n
);
153 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
156 int olines
= FRAME_MENU_BAR_LINES (f
);
158 /* Right now, menu bars don't work properly in minibuf-only frames;
159 most of the commands try to apply themselves to the minibuffer
160 frame itself, and get an error because you can't switch buffers
161 in or split the minibuffer window. */
162 if (FRAME_MINIBUF_ONLY_P (f
))
165 if (INTEGERP (value
))
166 nlines
= XINT (value
);
170 if (nlines
!= olines
)
172 windows_or_buffers_changed
++;
173 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
174 FRAME_MENU_BAR_LINES (f
) = nlines
;
175 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
180 Lisp_Object Vframe_list
;
183 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
184 doc
: /* Return non-nil if OBJECT is a frame.
186 t for a termcap frame (a character-only terminal),
187 'x' for an Emacs frame that is really an X window,
188 'w32' for an Emacs frame that is a window on MS-Windows display,
189 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
190 'pc' for a direct-write MS-DOS frame.
191 See also `frame-live-p'. */)
194 if (!FRAMEP (object
))
196 switch (XFRAME (object
)->output_method
)
198 case output_initial
: /* The initial frame is like a termcap frame. */
201 case output_x_window
:
205 case output_msdos_raw
:
216 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
217 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
218 Value is nil if OBJECT is not a live frame. If object is a live
219 frame, the return value indicates what sort of terminal device it is
220 displayed on. See the documentation of `framep' for possible
224 return ((FRAMEP (object
)
225 && FRAME_LIVE_P (XFRAME (object
)))
230 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
231 doc
: /* The name of the window system that FRAME is displaying through.
232 The value is a symbol:
233 nil for a termcap frame (a character-only terminal),
234 'x' for an Emacs frame that is really an X window,
235 'w32' for an Emacs frame that is a window on MS-Windows display,
236 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
237 'pc' for a direct-write MS-DOS frame.
239 FRAME defaults to the currently selected frame.
241 Use of this function as a predicate is deprecated. Instead,
242 use `display-graphic-p' or any of the other `display-*-p'
243 predicates which report frame's specific UI-related capabilities. */)
248 frame
= selected_frame
;
250 type
= Fframep (frame
);
253 wrong_type_argument (Qframep
, frame
);
262 make_frame (int mini_p
)
265 register struct frame
*f
;
266 register Lisp_Object root_window
;
267 register Lisp_Object mini_window
;
269 f
= allocate_frame ();
270 XSETFRAME (frame
, f
);
272 f
->desired_matrix
= 0;
273 f
->current_matrix
= 0;
276 f
->glyphs_initialized_p
= 0;
277 f
->decode_mode_spec_buffer
= 0;
279 f
->async_visible
= 0;
280 f
->output_data
.nothing
= 0;
282 f
->async_iconified
= 0;
283 f
->wants_modeline
= 1;
288 f
->has_minibuffer
= mini_p
;
289 f
->focus_frame
= Qnil
;
290 f
->explicit_name
= 0;
291 f
->can_have_scroll_bars
= 0;
292 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
293 f
->param_alist
= Qnil
;
294 f
->scroll_bars
= Qnil
;
295 f
->condemned_scroll_bars
= Qnil
;
296 f
->face_alist
= Qnil
;
297 f
->face_cache
= NULL
;
298 f
->menu_bar_items
= Qnil
;
299 f
->menu_bar_vector
= Qnil
;
300 f
->menu_bar_items_used
= 0;
301 f
->buffer_predicate
= Qnil
;
302 f
->buffer_list
= Qnil
;
303 f
->buried_buffer_list
= Qnil
;
306 f
->menu_bar_window
= Qnil
;
307 f
->tool_bar_window
= Qnil
;
308 f
->tool_bar_items
= Qnil
;
309 f
->tool_bar_position
= Qtop
;
310 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
311 f
->n_tool_bar_items
= 0;
312 f
->left_fringe_width
= f
->right_fringe_width
= 0;
314 f
->menu_bar_lines
= 0;
315 f
->tool_bar_lines
= 0;
316 f
->scroll_bar_actual_width
= 0;
318 f
->internal_border_width
= 0;
319 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
320 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
321 f
->x_pixels_diff
= f
->y_pixels_diff
= 0;
322 #ifdef HAVE_WINDOW_SYSTEM
323 f
->want_fullscreen
= FULLSCREEN_NONE
;
325 f
->size_hint_flags
= 0;
327 f
->font_driver_list
= NULL
;
328 f
->font_data_list
= NULL
;
330 root_window
= make_window ();
333 mini_window
= make_window ();
334 XWINDOW (root_window
)->next
= mini_window
;
335 XWINDOW (mini_window
)->prev
= root_window
;
336 XWINDOW (mini_window
)->mini_p
= Qt
;
337 XWINDOW (mini_window
)->frame
= frame
;
338 f
->minibuffer_window
= mini_window
;
343 XWINDOW (root_window
)->next
= Qnil
;
344 f
->minibuffer_window
= Qnil
;
347 XWINDOW (root_window
)->frame
= frame
;
350 just so that there is "something there."
351 Correct size will be set up later with change_frame_size. */
353 SET_FRAME_COLS (f
, 10);
354 FRAME_LINES (f
) = 10;
356 XSETFASTINT (XWINDOW (root_window
)->total_cols
, 10);
357 XSETFASTINT (XWINDOW (root_window
)->total_lines
, (mini_p
? 9 : 10));
361 XSETFASTINT (XWINDOW (mini_window
)->total_cols
, 10);
362 XSETFASTINT (XWINDOW (mini_window
)->top_line
, 9);
363 XSETFASTINT (XWINDOW (mini_window
)->total_lines
, 1);
366 /* Choose a buffer for the frame's root window. */
370 XWINDOW (root_window
)->buffer
= Qt
;
371 buf
= Fcurrent_buffer ();
372 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
373 a space), try to find another one. */
374 if (SREF (Fbuffer_name (buf
), 0) == ' ')
375 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
377 /* Use set_window_buffer, not Fset_window_buffer, and don't let
378 hooks be run by it. The reason is that the whole frame/window
379 arrangement is not yet fully intialized at this point. Windows
380 don't have the right size, glyph matrices aren't initialized
381 etc. Running Lisp functions at this point surely ends in a
383 set_window_buffer (root_window
, buf
, 0, 0);
384 f
->buffer_list
= Fcons (buf
, Qnil
);
389 XWINDOW (mini_window
)->buffer
= Qt
;
390 set_window_buffer (mini_window
,
391 (NILP (Vminibuffer_list
)
393 : Fcar (Vminibuffer_list
)),
397 f
->root_window
= root_window
;
398 f
->selected_window
= root_window
;
399 /* Make sure this window seems more recently used than
400 a newly-created, never-selected window. */
401 ++window_select_count
;
402 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, window_select_count
);
404 f
->default_face_done_p
= 0;
409 #ifdef HAVE_WINDOW_SYSTEM
410 /* Make a frame using a separate minibuffer window on another frame.
411 MINI_WINDOW is the minibuffer window to use. nil means use the
412 default (the global minibuffer). */
415 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
417 register struct frame
*f
;
420 if (!NILP (mini_window
))
421 CHECK_LIVE_WINDOW (mini_window
);
423 if (!NILP (mini_window
)
424 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
425 error ("Frame and minibuffer must be on the same terminal");
427 /* Make a frame containing just a root window. */
430 if (NILP (mini_window
))
432 /* Use default-minibuffer-frame if possible. */
433 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
434 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
436 Lisp_Object frame_dummy
;
438 XSETFRAME (frame_dummy
, f
);
439 GCPRO1 (frame_dummy
);
440 /* If there's no minibuffer frame to use, create one. */
441 kb
->Vdefault_minibuffer_frame
=
442 call1 (intern ("make-initial-minibuffer-frame"), display
);
446 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
449 f
->minibuffer_window
= mini_window
;
451 /* Make the chosen minibuffer window display the proper minibuffer,
452 unless it is already showing a minibuffer. */
453 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
454 Fset_window_buffer (mini_window
,
455 (NILP (Vminibuffer_list
)
457 : Fcar (Vminibuffer_list
)), Qnil
);
461 /* Make a frame containing only a minibuffer window. */
464 make_minibuffer_frame (void)
466 /* First make a frame containing just a root window, no minibuffer. */
468 register struct frame
*f
= make_frame (0);
469 register Lisp_Object mini_window
;
470 register Lisp_Object frame
;
472 XSETFRAME (frame
, f
);
477 f
->wants_modeline
= 0;
478 f
->has_minibuffer
= 1;
480 /* Now label the root window as also being the minibuffer.
481 Avoid infinite looping on the window chain by marking next pointer
484 mini_window
= f
->minibuffer_window
= f
->root_window
;
485 XWINDOW (mini_window
)->mini_p
= Qt
;
486 XWINDOW (mini_window
)->next
= Qnil
;
487 XWINDOW (mini_window
)->prev
= Qnil
;
488 XWINDOW (mini_window
)->frame
= frame
;
490 /* Put the proper buffer in that window. */
492 Fset_window_buffer (mini_window
,
493 (NILP (Vminibuffer_list
)
495 : Fcar (Vminibuffer_list
)), Qnil
);
498 #endif /* HAVE_WINDOW_SYSTEM */
500 /* Construct a frame that refers to a terminal. */
502 static int tty_frame_count
;
505 make_initial_frame (void)
508 struct terminal
*terminal
;
511 eassert (initial_kboard
);
513 /* The first call must initialize Vframe_list. */
514 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
517 terminal
= init_initial_terminal ();
520 XSETFRAME (frame
, f
);
522 Vframe_list
= Fcons (frame
, Vframe_list
);
525 f
->name
= make_pure_c_string ("F1");
528 f
->async_visible
= 1;
530 f
->output_method
= terminal
->type
;
531 f
->terminal
= terminal
;
532 f
->terminal
->reference_count
++;
533 f
->output_data
.nothing
= 0;
535 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
536 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
538 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
539 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
541 /* The default value of menu-bar-mode is t. */
542 set_menu_bar_lines (f
, make_number (1), Qnil
);
546 init_frame_faces (f
);
554 make_terminal_frame (struct terminal
*terminal
)
556 register struct frame
*f
;
561 error ("Terminal is not live, can't create new frames on it");
565 XSETFRAME (frame
, f
);
566 Vframe_list
= Fcons (frame
, Vframe_list
);
569 sprintf (name
, "F%d", tty_frame_count
);
570 f
->name
= build_string (name
);
572 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
573 f
->async_visible
= 1; /* Don't let visible be cleared later. */
574 f
->terminal
= terminal
;
575 f
->terminal
->reference_count
++;
577 f
->output_data
.tty
->display_info
= &the_only_display_info
;
578 if (!inhibit_window_system
579 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
580 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
581 f
->output_method
= output_msdos_raw
;
583 f
->output_method
= output_termcap
;
584 #else /* not MSDOS */
585 f
->output_method
= output_termcap
;
586 create_tty_output (f
);
587 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
588 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
589 #endif /* not MSDOS */
591 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
592 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
593 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
595 /* Set the top frame to the newly created frame. */
596 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
597 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
598 XFRAME (FRAME_TTY (f
)->top_frame
)->async_visible
= 2; /* obscured */
600 FRAME_TTY (f
)->top_frame
= frame
;
603 init_frame_faces (f
);
608 /* Get a suitable value for frame parameter PARAMETER for a newly
609 created frame, based on (1) the user-supplied frame parameter
610 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
613 get_future_frame_param (Lisp_Object parameter
,
614 Lisp_Object supplied_parms
,
619 result
= Fassq (parameter
, supplied_parms
);
621 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
622 if (NILP (result
) && current_value
!= NULL
)
623 result
= build_string (current_value
);
624 if (!NILP (result
) && !STRINGP (result
))
625 result
= XCDR (result
);
626 if (NILP (result
) || !STRINGP (result
))
632 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
634 doc
: /* Create an additional terminal frame, possibly on another terminal.
635 This function takes one argument, an alist specifying frame parameters.
637 You can create multiple frames on a single text-only terminal, but
638 only one of them (the selected terminal frame) is actually displayed.
640 In practice, generally you don't need to specify any parameters,
641 except when you want to create a new frame on another terminal.
642 In that case, the `tty' parameter specifies the device file to open,
643 and the `tty-type' parameter specifies the terminal type. Example:
645 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
647 Note that changing the size of one terminal frame automatically
648 affects all frames on the same terminal device. */)
652 struct terminal
*t
= NULL
;
653 Lisp_Object frame
, tem
;
654 struct frame
*sf
= SELECTED_FRAME ();
657 if (sf
->output_method
!= output_msdos_raw
658 && sf
->output_method
!= output_termcap
)
660 #else /* not MSDOS */
662 #ifdef WINDOWSNT /* This should work now! */
663 if (sf
->output_method
!= output_termcap
)
664 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
666 #endif /* not MSDOS */
669 Lisp_Object terminal
;
671 terminal
= Fassq (Qterminal
, parms
);
672 if (!NILP (terminal
))
674 terminal
= XCDR (terminal
);
675 t
= get_terminal (terminal
, 1);
678 if (t
&& t
!= the_only_display_info
.terminal
)
679 /* msdos.c assumes a single tty_display_info object. */
680 error ("Multiple terminals are not supported on this platform");
682 t
= the_only_display_info
.terminal
;
688 char *name
= 0, *type
= 0;
689 Lisp_Object tty
, tty_type
;
691 tty
= get_future_frame_param
692 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
693 ? FRAME_TTY (XFRAME (selected_frame
))->name
697 name
= (char *) alloca (SBYTES (tty
) + 1);
698 strncpy (name
, SDATA (tty
), SBYTES (tty
));
699 name
[SBYTES (tty
)] = 0;
702 tty_type
= get_future_frame_param
703 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
704 ? FRAME_TTY (XFRAME (selected_frame
))->type
706 if (!NILP (tty_type
))
708 type
= (char *) alloca (SBYTES (tty_type
) + 1);
709 strncpy (type
, SDATA (tty_type
), SBYTES (tty_type
));
710 type
[SBYTES (tty_type
)] = 0;
713 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
716 f
= make_terminal_frame (t
);
720 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
721 change_frame_size (f
, height
, width
, 0, 0, 0);
726 XSETFRAME (frame
, f
);
727 Fmodify_frame_parameters (frame
, parms
);
728 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
729 build_string (t
->display_info
.tty
->type
)),
731 if (t
->display_info
.tty
->name
!= NULL
)
732 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
733 build_string (t
->display_info
.tty
->name
)),
736 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
738 /* Make the frame face alist be frame-specific, so that each
739 frame could change its face definitions independently. */
740 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
741 /* Simple Fcopy_alist isn't enough, because we need the contents of
742 the vectors which are the CDRs of associations in face_alist to
743 be copied as well. */
744 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
745 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
750 /* Perform the switch to frame FRAME.
752 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
755 If TRACK is non-zero and the frame that currently has the focus
756 redirects its focus to the selected frame, redirect that focused
757 frame's focus to FRAME instead.
759 FOR_DELETION non-zero means that the selected frame is being
760 deleted, which includes the possibility that the frame's terminal
763 The value of NORECORD is passed as argument to Fselect_window. */
766 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
768 struct frame
*sf
= SELECTED_FRAME ();
770 /* If FRAME is a switch-frame event, extract the frame we should
773 && EQ (XCAR (frame
), Qswitch_frame
)
774 && CONSP (XCDR (frame
)))
775 frame
= XCAR (XCDR (frame
));
777 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
778 a switch-frame event to arrive after a frame is no longer live,
779 especially when deleting the initial frame during startup. */
781 if (! FRAME_LIVE_P (XFRAME (frame
)))
784 if (sf
== XFRAME (frame
))
787 /* This is too greedy; it causes inappropriate focus redirection
788 that's hard to get rid of. */
790 /* If a frame's focus has been redirected toward the currently
791 selected frame, we should change the redirection to point to the
792 newly selected frame. This means that if the focus is redirected
793 from a minibufferless frame to a surrogate minibuffer frame, we
794 can use `other-window' to switch between all the frames using
795 that minibuffer frame, and the focus redirection will follow us
801 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
805 if (!FRAMEP (XCAR (tail
)))
808 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
810 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
811 Fredirect_frame_focus (XCAR (tail
), frame
);
815 /* Instead, apply it only to the frame we're pointing to. */
816 #ifdef HAVE_WINDOW_SYSTEM
817 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
819 Lisp_Object focus
, xfocus
;
821 xfocus
= x_get_focus_frame (XFRAME (frame
));
824 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
825 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
826 Fredirect_frame_focus (xfocus
, frame
);
829 #endif /* HAVE_X_WINDOWS */
832 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
833 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
835 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
837 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
838 /* Mark previously displayed frame as now obscured. */
839 XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
)->async_visible
= 2;
840 XFRAME (frame
)->async_visible
= 1;
841 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
844 selected_frame
= frame
;
845 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
846 last_nonminibuf_frame
= XFRAME (selected_frame
);
848 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
850 /* We want to make sure that the next event generates a frame-switch
851 event to the appropriate frame. This seems kludgy to me, but
852 before you take it out, make sure that evaluating something like
853 (select-window (frame-root-window (new-frame))) doesn't end up
854 with your typing being interpreted in the new frame instead of
855 the one you're actually typing in. */
856 internal_last_event_frame
= Qnil
;
861 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
862 doc
: /* Select FRAME.
863 Subsequent editing commands apply to its selected window.
864 Optional argument NORECORD means to neither change the order of
865 recently selected windows nor the buffer list.
867 The selection of FRAME lasts until the next time the user does
868 something to select a different frame, or until the next time
869 this function is called. If you are using a window system, the
870 previously selected frame may be restored as the selected frame
871 when returning to the command loop, because it still may have
872 the window system's input focus. On a text-only terminal, the
873 next redisplay will display FRAME.
875 This function returns FRAME, or nil if FRAME has been deleted. */)
876 (Lisp_Object frame
, Lisp_Object norecord
)
878 return do_switch_frame (frame
, 1, 0, norecord
);
882 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
883 doc
: /* Handle a switch-frame event EVENT.
884 Switch-frame events are usually bound to this function.
885 A switch-frame event tells Emacs that the window manager has requested
886 that the user's events be directed to the frame mentioned in the event.
887 This function selects the selected window of the frame of EVENT.
889 If EVENT is frame object, handle it as if it were a switch-frame event
893 /* Preserve prefix arg that the command loop just cleared. */
894 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
895 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
896 return do_switch_frame (event
, 0, 0, Qnil
);
899 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
900 doc
: /* Return the frame that is now selected. */)
903 return selected_frame
;
906 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
907 doc
: /* Return the frame object that window WINDOW is on. */)
910 CHECK_LIVE_WINDOW (window
);
911 return XWINDOW (window
)->frame
;
914 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
915 doc
: /* Returns the topmost, leftmost window of FRAME.
916 If omitted, FRAME defaults to the currently selected frame. */)
922 w
= SELECTED_FRAME ()->root_window
;
925 CHECK_LIVE_FRAME (frame
);
926 w
= XFRAME (frame
)->root_window
;
928 while (NILP (XWINDOW (w
)->buffer
))
930 if (! NILP (XWINDOW (w
)->hchild
))
931 w
= XWINDOW (w
)->hchild
;
932 else if (! NILP (XWINDOW (w
)->vchild
))
933 w
= XWINDOW (w
)->vchild
;
940 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
941 Sactive_minibuffer_window
, 0, 0, 0,
942 doc
: /* Return the currently active minibuffer window, or nil if none. */)
945 return minibuf_level
? minibuf_window
: Qnil
;
948 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
949 doc
: /* Returns the root-window of FRAME.
950 If omitted, FRAME defaults to the currently selected frame. */)
956 window
= SELECTED_FRAME ()->root_window
;
959 CHECK_LIVE_FRAME (frame
);
960 window
= XFRAME (frame
)->root_window
;
966 DEFUN ("frame-selected-window", Fframe_selected_window
,
967 Sframe_selected_window
, 0, 1, 0,
968 doc
: /* Return the selected window of FRAME.
969 FRAME defaults to the currently selected frame. */)
975 window
= SELECTED_FRAME ()->selected_window
;
978 CHECK_LIVE_FRAME (frame
);
979 window
= XFRAME (frame
)->selected_window
;
985 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
986 Sset_frame_selected_window
, 2, 3, 0,
987 doc
: /* Set selected window of FRAME to WINDOW.
988 If FRAME is nil, use the selected frame. If FRAME is the
989 selected frame, this makes WINDOW the selected window.
990 Optional argument NORECORD non-nil means to neither change the
991 order of recently selected windows nor the buffer list.
993 (Lisp_Object frame
, Lisp_Object window
, Lisp_Object norecord
)
996 frame
= selected_frame
;
998 CHECK_LIVE_FRAME (frame
);
999 CHECK_LIVE_WINDOW (window
);
1001 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
1002 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
1004 if (EQ (frame
, selected_frame
))
1005 return Fselect_window (window
, norecord
);
1007 return XFRAME (frame
)->selected_window
= window
;
1011 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1013 doc
: /* Return a list of all live frames. */)
1017 frames
= Fcopy_sequence (Vframe_list
);
1018 #ifdef HAVE_WINDOW_SYSTEM
1019 if (FRAMEP (tip_frame
))
1020 frames
= Fdelq (tip_frame
, frames
);
1025 /* Return the next frame in the frame list after FRAME.
1026 If MINIBUF is nil, exclude minibuffer-only frames.
1027 If MINIBUF is a window, include only its own frame
1028 and any frame now using that window as the minibuffer.
1029 If MINIBUF is `visible', include all visible frames.
1030 If MINIBUF is 0, include all visible and iconified frames.
1031 Otherwise, include all frames. */
1034 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1039 /* There must always be at least one frame in Vframe_list. */
1040 if (! CONSP (Vframe_list
))
1043 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
1044 forever. Forestall that. */
1045 CHECK_LIVE_FRAME (frame
);
1048 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1055 && ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1056 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1057 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1058 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
)))))
1060 /* Decide whether this frame is eligible to be returned. */
1062 /* If we've looped all the way around without finding any
1063 eligible frames, return the original frame. */
1067 /* Let minibuf decide if this frame is acceptable. */
1070 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1073 else if (EQ (minibuf
, Qvisible
))
1075 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1076 if (FRAME_VISIBLE_P (XFRAME (f
)))
1079 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
1081 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1082 if (FRAME_VISIBLE_P (XFRAME (f
))
1083 || FRAME_ICONIFIED_P (XFRAME (f
)))
1086 else if (WINDOWP (minibuf
))
1088 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1089 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1090 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1091 FRAME_FOCUS_FRAME (XFRAME (f
))))
1103 /* Return the previous frame in the frame list before FRAME.
1104 If MINIBUF is nil, exclude minibuffer-only frames.
1105 If MINIBUF is a window, include only its own frame
1106 and any frame now using that window as the minibuffer.
1107 If MINIBUF is `visible', include all visible frames.
1108 If MINIBUF is 0, include all visible and iconified frames.
1109 Otherwise, include all frames. */
1112 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1117 /* There must always be at least one frame in Vframe_list. */
1118 if (! CONSP (Vframe_list
))
1122 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1130 if (EQ (frame
, f
) && !NILP (prev
))
1133 if ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1134 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1135 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1136 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
))))
1138 /* Decide whether this frame is eligible to be returned,
1139 according to minibuf. */
1142 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1145 else if (WINDOWP (minibuf
))
1147 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1148 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1149 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1150 FRAME_FOCUS_FRAME (XFRAME (f
))))
1153 else if (EQ (minibuf
, Qvisible
))
1155 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1156 if (FRAME_VISIBLE_P (XFRAME (f
)))
1159 else if (XFASTINT (minibuf
) == 0)
1161 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1162 if (FRAME_VISIBLE_P (XFRAME (f
))
1163 || FRAME_ICONIFIED_P (XFRAME (f
)))
1171 /* We've scanned the entire list. */
1173 /* We went through the whole frame list without finding a single
1174 acceptable frame. Return the original frame. */
1177 /* There were no acceptable frames in the list before FRAME; otherwise,
1178 we would have returned directly from the loop. Since PREV is the last
1179 acceptable frame in the list, return it. */
1184 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1185 doc
: /* Return the next frame in the frame list after FRAME.
1186 It considers only frames on the same terminal as FRAME.
1187 By default, skip minibuffer-only frames.
1188 If omitted, FRAME defaults to the selected frame.
1189 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1190 If MINIFRAME is a window, include only its own frame
1191 and any frame now using that window as the minibuffer.
1192 If MINIFRAME is `visible', include all visible frames.
1193 If MINIFRAME is 0, include all visible and iconified frames.
1194 Otherwise, include all frames. */)
1195 (Lisp_Object frame
, Lisp_Object miniframe
)
1198 frame
= selected_frame
;
1200 CHECK_LIVE_FRAME (frame
);
1201 return next_frame (frame
, miniframe
);
1204 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1205 doc
: /* Return the previous frame in the frame list before 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. */)
1215 (Lisp_Object frame
, Lisp_Object miniframe
)
1218 frame
= selected_frame
;
1219 CHECK_LIVE_FRAME (frame
);
1220 return prev_frame (frame
, miniframe
);
1223 /* Return 1 if it is ok to delete frame F;
1224 0 if all frames aside from F are invisible.
1225 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1228 other_visible_frames (FRAME_PTR f
)
1230 /* We know the selected frame is visible,
1231 so if F is some other frame, it can't be the sole visible one. */
1232 if (f
== SELECTED_FRAME ())
1237 for (frames
= Vframe_list
;
1239 frames
= XCDR (frames
))
1243 this = XCAR (frames
);
1244 /* Verify that the frame's window still exists
1245 and we can still talk to it. And note any recent change
1247 #ifdef HAVE_WINDOW_SYSTEM
1248 if (FRAME_WINDOW_P (XFRAME (this)))
1250 x_sync (XFRAME (this));
1251 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1255 if (FRAME_VISIBLE_P (XFRAME (this))
1256 || FRAME_ICONIFIED_P (XFRAME (this))
1257 /* Allow deleting the terminal frame when at least
1258 one X frame exists! */
1259 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1267 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1268 unconditionally. x_connection_closed and delete_terminal use
1269 this. Any other value of FORCE implements the semantics
1270 described for Fdelete_frame. */
1272 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1273 /* If we use `register' here, gcc-4.0.2 on amd64 using
1274 -DUSE_LISP_UNION_TYPE complains further down that we're getting the
1275 address of `force'. Go figure. */
1279 struct frame
*sf
= SELECTED_FRAME ();
1282 int minibuffer_selected
, tooltip_frame
;
1284 if (EQ (frame
, Qnil
))
1287 XSETFRAME (frame
, f
);
1291 CHECK_FRAME (frame
);
1295 if (! FRAME_LIVE_P (f
))
1298 if (NILP (force
) && !other_visible_frames (f
))
1299 error ("Attempt to delete the sole visible or iconified frame");
1301 /* x_connection_closed must have set FORCE to `noelisp' in order
1302 to delete the last frame, if it is gone. */
1303 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1304 error ("Attempt to delete the only frame");
1306 /* Does this frame have a minibuffer, and is it the surrogate
1307 minibuffer for any other frame? */
1308 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1312 for (frames
= Vframe_list
;
1314 frames
= XCDR (frames
))
1317 this = XCAR (frames
);
1319 if (! EQ (this, frame
)
1321 WINDOW_FRAME (XWINDOW
1322 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1324 /* If we MUST delete this frame, delete the other first.
1325 But do this only if FORCE equals `noelisp'. */
1326 if (EQ (force
, Qnoelisp
))
1327 delete_frame (this, Qnoelisp
);
1329 error ("Attempt to delete a surrogate minibuffer frame");
1334 tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1336 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1337 frame is a tooltip. FORCE is set to `noelisp' when handling
1338 a disconnect from the terminal, so we don't dare call Lisp
1340 if (NILP (Vrun_hooks
) || tooltip_frame
)
1342 else if (EQ (force
, Qnoelisp
))
1344 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1347 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1349 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1350 if (! FRAME_LIVE_P (f
))
1353 /* At this point, we are committed to deleting the frame.
1354 There is no more chance for errors to prevent it. */
1356 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1358 /* Don't let the frame remain selected. */
1361 Lisp_Object tail
, frame1
;
1363 /* Look for another visible frame on the same terminal. */
1364 frame1
= next_frame (frame
, Qvisible
);
1366 /* If there is none, find *some* other frame. */
1367 if (NILP (frame1
) || EQ (frame1
, frame
))
1369 FOR_EACH_FRAME (tail
, frame1
)
1371 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1375 #ifdef NS_IMPL_COCOA
1377 /* Under NS, there is no system mechanism for choosing a new
1378 window to get focus -- it is left to application code.
1379 So the portion of THIS application interfacing with NS
1380 needs to know about it. We call Fraise_frame, but the
1381 purpose is really to transfer focus. */
1382 Fraise_frame (frame1
);
1385 do_switch_frame (frame1
, 0, 1, Qnil
);
1386 sf
= SELECTED_FRAME ();
1389 /* Don't allow minibuf_window to remain on a deleted frame. */
1390 if (EQ (f
->minibuffer_window
, minibuf_window
))
1392 Fset_window_buffer (sf
->minibuffer_window
,
1393 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1394 minibuf_window
= sf
->minibuffer_window
;
1396 /* If the dying minibuffer window was selected,
1397 select the new one. */
1398 if (minibuffer_selected
)
1399 Fselect_window (minibuf_window
, Qnil
);
1402 /* Don't let echo_area_window to remain on a deleted frame. */
1403 if (EQ (f
->minibuffer_window
, echo_area_window
))
1404 echo_area_window
= sf
->minibuffer_window
;
1406 /* Clear any X selections for this frame. */
1407 #ifdef HAVE_X_WINDOWS
1409 x_clear_frame_selections (f
);
1413 This function must be called before the window tree of the
1414 frame is deleted because windows contain dynamically allocated
1418 #ifdef HAVE_WINDOW_SYSTEM
1419 /* Give chance to each font driver to free a frame specific data. */
1420 font_update_drivers (f
, Qnil
);
1423 /* Mark all the windows that used to be on FRAME as deleted, and then
1424 remove the reference to them. */
1425 delete_all_subwindows (XWINDOW (f
->root_window
));
1426 f
->root_window
= Qnil
;
1428 Vframe_list
= Fdelq (frame
, Vframe_list
);
1429 FRAME_SET_VISIBLE (f
, 0);
1431 /* Allow the vector of menu bar contents to be freed in the next
1432 garbage collection. The frame object itself may not be garbage
1433 collected until much later, because recent_keys and other data
1434 structures can still refer to it. */
1435 f
->menu_bar_vector
= Qnil
;
1437 free_font_driver_list (f
);
1439 xfree (f
->decode_mode_spec_buffer
);
1440 xfree (FRAME_INSERT_COST (f
));
1441 xfree (FRAME_DELETEN_COST (f
));
1442 xfree (FRAME_INSERTN_COST (f
));
1443 xfree (FRAME_DELETE_COST (f
));
1444 xfree (FRAME_MESSAGE_BUF (f
));
1446 /* Since some events are handled at the interrupt level, we may get
1447 an event for f at any time; if we zero out the frame's terminal
1448 now, then we may trip up the event-handling code. Instead, we'll
1449 promise that the terminal of the frame must be valid until we
1450 have called the window-system-dependent frame destruction
1453 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1454 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1457 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1458 f
->output_data
.nothing
= 0;
1459 f
->terminal
= 0; /* Now the frame is dead. */
1461 /* If needed, delete the terminal that this frame was on.
1462 (This must be done after the frame is killed.) */
1463 terminal
->reference_count
--;
1464 if (terminal
->reference_count
== 0)
1467 XSETTERMINAL (tmp
, terminal
);
1470 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1473 kb
= terminal
->kboard
;
1476 /* If we've deleted the last_nonminibuf_frame, then try to find
1478 if (f
== last_nonminibuf_frame
)
1482 last_nonminibuf_frame
= 0;
1484 for (frames
= Vframe_list
;
1486 frames
= XCDR (frames
))
1488 f
= XFRAME (XCAR (frames
));
1489 if (!FRAME_MINIBUF_ONLY_P (f
))
1491 last_nonminibuf_frame
= f
;
1497 /* If there's no other frame on the same kboard, get out of
1498 single-kboard state if we're in it for this kboard. */
1502 /* Some frame we found on the same kboard, or nil if there are none. */
1503 Lisp_Object frame_on_same_kboard
;
1505 frame_on_same_kboard
= Qnil
;
1507 for (frames
= Vframe_list
;
1509 frames
= XCDR (frames
))
1514 this = XCAR (frames
);
1519 if (kb
== FRAME_KBOARD (f1
))
1520 frame_on_same_kboard
= this;
1523 if (NILP (frame_on_same_kboard
))
1524 not_single_kboard_state (kb
);
1528 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1529 find another one. Prefer minibuffer-only frames, but also notice
1530 frames with other windows. */
1531 if (kb
!= NULL
&& EQ (frame
, kb
->Vdefault_minibuffer_frame
))
1535 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1536 Lisp_Object frame_with_minibuf
;
1537 /* Some frame we found on the same kboard, or nil if there are none. */
1538 Lisp_Object frame_on_same_kboard
;
1540 frame_on_same_kboard
= Qnil
;
1541 frame_with_minibuf
= Qnil
;
1543 for (frames
= Vframe_list
;
1545 frames
= XCDR (frames
))
1550 this = XCAR (frames
);
1555 /* Consider only frames on the same kboard
1556 and only those with minibuffers. */
1557 if (kb
== FRAME_KBOARD (f1
)
1558 && FRAME_HAS_MINIBUF_P (f1
))
1560 frame_with_minibuf
= this;
1561 if (FRAME_MINIBUF_ONLY_P (f1
))
1565 if (kb
== FRAME_KBOARD (f1
))
1566 frame_on_same_kboard
= this;
1569 if (!NILP (frame_on_same_kboard
))
1571 /* We know that there must be some frame with a minibuffer out
1572 there. If this were not true, all of the frames present
1573 would have to be minibufferless, which implies that at some
1574 point their minibuffer frames must have been deleted, but
1575 that is prohibited at the top; you can't delete surrogate
1576 minibuffer frames. */
1577 if (NILP (frame_with_minibuf
))
1580 kb
->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1583 /* No frames left on this kboard--say no minibuffer either. */
1584 kb
->Vdefault_minibuffer_frame
= Qnil
;
1587 /* Cause frame titles to update--necessary if we now have just one frame. */
1589 update_mode_lines
= 1;
1594 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1595 doc
: /* Delete FRAME, permanently eliminating it from use.
1596 FRAME defaults to the selected frame.
1598 A frame may not be deleted if its minibuffer is used by other frames.
1599 Normally, you may not delete a frame if all other frames are invisible,
1600 but if the second optional argument FORCE is non-nil, you may do so.
1602 This function runs `delete-frame-functions' before actually
1603 deleting the frame, unless the frame is a tooltip.
1604 The functions are run with one argument, the frame to be deleted. */)
1605 (Lisp_Object frame
, Lisp_Object force
)
1607 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1611 /* Return mouse position in character cell units. */
1613 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1614 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1615 The position is given in character cells, where (0, 0) is the
1616 upper-left corner of the frame, X is the horizontal offset, and Y is
1617 the vertical offset.
1618 If Emacs is running on a mouseless terminal or hasn't been programmed
1619 to read the mouse position, it returns the selected frame for FRAME
1620 and nil for X and Y.
1621 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1622 passing the normal return value to that function as an argument,
1623 and returns whatever that function returns. */)
1627 Lisp_Object lispy_dummy
;
1628 enum scroll_bar_part party_dummy
;
1629 Lisp_Object x
, y
, retval
;
1631 unsigned long long_dummy
;
1632 struct gcpro gcpro1
;
1634 f
= SELECTED_FRAME ();
1637 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1638 /* It's okay for the hook to refrain from storing anything. */
1639 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1640 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1641 &lispy_dummy
, &party_dummy
,
1648 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1653 XSETFRAME (lispy_dummy
, f
);
1654 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1656 if (!NILP (Vmouse_position_function
))
1657 retval
= call1 (Vmouse_position_function
, retval
);
1658 RETURN_UNGCPRO (retval
);
1661 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1662 Smouse_pixel_position
, 0, 0, 0,
1663 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1664 The position is given in pixel units, where (0, 0) is the
1665 upper-left corner of the frame, X is the horizontal offset, and Y is
1666 the vertical offset.
1667 If Emacs is running on a mouseless terminal or hasn't been programmed
1668 to read the mouse position, it returns the selected frame for FRAME
1669 and nil for X and Y. */)
1673 Lisp_Object lispy_dummy
;
1674 enum scroll_bar_part party_dummy
;
1676 unsigned long long_dummy
;
1678 f
= SELECTED_FRAME ();
1681 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1682 /* It's okay for the hook to refrain from storing anything. */
1683 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1684 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1685 &lispy_dummy
, &party_dummy
,
1689 XSETFRAME (lispy_dummy
, f
);
1690 return Fcons (lispy_dummy
, Fcons (x
, y
));
1693 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1694 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1695 Coordinates are relative to the frame, not a window,
1696 so the coordinates of the top left character in the frame
1697 may be nonzero due to left-hand scroll bars or the menu bar.
1699 The position is given in character cells, where (0, 0) is the
1700 upper-left corner of the frame, X is the horizontal offset, and Y is
1701 the vertical offset.
1703 This function is a no-op for an X frame that is not visible.
1704 If you have just created a frame, you must wait for it to become visible
1705 before calling this function on it, like this.
1706 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1707 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1709 CHECK_LIVE_FRAME (frame
);
1713 /* I think this should be done with a hook. */
1714 #ifdef HAVE_WINDOW_SYSTEM
1715 if (FRAME_WINDOW_P (XFRAME (frame
)))
1716 /* Warping the mouse will cause enternotify and focus events. */
1717 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1719 #if defined (MSDOS) && defined (HAVE_MOUSE)
1720 if (FRAME_MSDOS_P (XFRAME (frame
)))
1722 Fselect_frame (frame
, Qnil
);
1723 mouse_moveto (XINT (x
), XINT (y
));
1728 Fselect_frame (frame
, Qnil
);
1729 term_mouse_moveto (XINT (x
), XINT (y
));
1738 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1739 Sset_mouse_pixel_position
, 3, 3, 0,
1740 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1741 The position is given in pixels, where (0, 0) is the upper-left corner
1742 of the frame, X is the horizontal offset, and Y is the vertical offset.
1744 Note, this is a no-op for an X frame that is not visible.
1745 If you have just created a frame, you must wait for it to become visible
1746 before calling this function on it, like this.
1747 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1748 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1750 CHECK_LIVE_FRAME (frame
);
1754 /* I think this should be done with a hook. */
1755 #ifdef HAVE_WINDOW_SYSTEM
1756 if (FRAME_WINDOW_P (XFRAME (frame
)))
1757 /* Warping the mouse will cause enternotify and focus events. */
1758 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1760 #if defined (MSDOS) && defined (HAVE_MOUSE)
1761 if (FRAME_MSDOS_P (XFRAME (frame
)))
1763 Fselect_frame (frame
, Qnil
);
1764 mouse_moveto (XINT (x
), XINT (y
));
1769 Fselect_frame (frame
, Qnil
);
1770 term_mouse_moveto (XINT (x
), XINT (y
));
1779 static void make_frame_visible_1 (Lisp_Object
);
1781 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1783 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1784 If omitted, FRAME defaults to the currently selected frame. */)
1788 frame
= selected_frame
;
1790 CHECK_LIVE_FRAME (frame
);
1792 /* I think this should be done with a hook. */
1793 #ifdef HAVE_WINDOW_SYSTEM
1794 if (FRAME_WINDOW_P (XFRAME (frame
)))
1796 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1797 x_make_frame_visible (XFRAME (frame
));
1801 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1803 /* Make menu bar update for the Buffers and Frames menus. */
1804 windows_or_buffers_changed
++;
1809 /* Update the display_time slot of the buffers shown in WINDOW
1810 and all its descendents. */
1813 make_frame_visible_1 (Lisp_Object window
)
1817 for (;!NILP (window
); window
= w
->next
)
1819 w
= XWINDOW (window
);
1821 if (!NILP (w
->buffer
))
1822 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1824 if (!NILP (w
->vchild
))
1825 make_frame_visible_1 (w
->vchild
);
1826 if (!NILP (w
->hchild
))
1827 make_frame_visible_1 (w
->hchild
);
1831 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1833 doc
: /* Make the frame FRAME invisible.
1834 If omitted, FRAME defaults to the currently selected frame.
1835 On graphical displays, invisible frames are not updated and are
1836 usually not displayed at all, even in a window system's \"taskbar\".
1838 Normally you may not make FRAME invisible if all other frames are invisible,
1839 but if the second optional argument FORCE is non-nil, you may do so.
1841 This function has no effect on text-only terminal frames. Such frames
1842 are always considered visible, whether or not they are currently being
1843 displayed in the terminal. */)
1844 (Lisp_Object frame
, Lisp_Object force
)
1847 frame
= selected_frame
;
1849 CHECK_LIVE_FRAME (frame
);
1851 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1852 error ("Attempt to make invisible the sole visible or iconified frame");
1854 #if 0 /* This isn't logically necessary, and it can do GC. */
1855 /* Don't let the frame remain selected. */
1856 if (EQ (frame
, selected_frame
))
1857 do_switch_frame (next_frame (frame
, Qt
), 0, 0, Qnil
)
1860 /* Don't allow minibuf_window to remain on a deleted frame. */
1861 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1863 struct frame
*sf
= XFRAME (selected_frame
);
1864 Fset_window_buffer (sf
->minibuffer_window
,
1865 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1866 minibuf_window
= sf
->minibuffer_window
;
1869 /* I think this should be done with a hook. */
1870 #ifdef HAVE_WINDOW_SYSTEM
1871 if (FRAME_WINDOW_P (XFRAME (frame
)))
1872 x_make_frame_invisible (XFRAME (frame
));
1875 /* Make menu bar update for the Buffers and Frames menus. */
1876 windows_or_buffers_changed
++;
1881 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1883 doc
: /* Make the frame FRAME into an icon.
1884 If omitted, FRAME defaults to the currently selected frame. */)
1888 frame
= selected_frame
;
1890 CHECK_LIVE_FRAME (frame
);
1892 #if 0 /* This isn't logically necessary, and it can do GC. */
1893 /* Don't let the frame remain selected. */
1894 if (EQ (frame
, selected_frame
))
1895 Fhandle_switch_frame (next_frame (frame
, Qt
));
1898 /* Don't allow minibuf_window to remain on a deleted frame. */
1899 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1901 struct frame
*sf
= XFRAME (selected_frame
);
1902 Fset_window_buffer (sf
->minibuffer_window
,
1903 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1904 minibuf_window
= sf
->minibuffer_window
;
1907 /* I think this should be done with a hook. */
1908 #ifdef HAVE_WINDOW_SYSTEM
1909 if (FRAME_WINDOW_P (XFRAME (frame
)))
1910 x_iconify_frame (XFRAME (frame
));
1913 /* Make menu bar update for the Buffers and Frames menus. */
1914 windows_or_buffers_changed
++;
1919 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1921 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1922 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1923 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1924 On graphical displays, invisible frames are not updated and are
1925 usually not displayed at all, even in a window system's \"taskbar\".
1927 If FRAME is a text-only terminal frame, this always returns t.
1928 Such frames are always considered visible, whether or not they are
1929 currently being displayed on the terminal. */)
1932 CHECK_LIVE_FRAME (frame
);
1934 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1936 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1938 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1943 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1945 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1948 Lisp_Object tail
, frame
;
1953 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1955 frame
= XCAR (tail
);
1956 if (!FRAMEP (frame
))
1959 if (FRAME_VISIBLE_P (f
))
1960 value
= Fcons (frame
, value
);
1966 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1967 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1968 If FRAME is invisible or iconified, make it visible.
1969 If you don't specify a frame, the selected frame is used.
1970 If Emacs is displaying on an ordinary terminal or some other device which
1971 doesn't support multiple overlapping frames, this function selects FRAME. */)
1976 frame
= selected_frame
;
1978 CHECK_LIVE_FRAME (frame
);
1982 if (FRAME_TERMCAP_P (f
))
1983 /* On a text-only terminal select FRAME. */
1984 Fselect_frame (frame
, Qnil
);
1986 /* Do like the documentation says. */
1987 Fmake_frame_visible (frame
);
1989 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1990 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
1995 /* Should we have a corresponding function called Flower_Power? */
1996 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1997 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1998 If you don't specify a frame, the selected frame is used.
1999 If Emacs is displaying on an ordinary terminal or some other device which
2000 doesn't support multiple overlapping frames, this function does nothing. */)
2006 frame
= selected_frame
;
2008 CHECK_LIVE_FRAME (frame
);
2012 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2013 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2019 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2021 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2022 In other words, switch-frame events caused by events in FRAME will
2023 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2024 FOCUS-FRAME after reading an event typed at FRAME.
2026 If FOCUS-FRAME is omitted or nil, any existing redirection is
2027 cancelled, and the frame again receives its own keystrokes.
2029 Focus redirection is useful for temporarily redirecting keystrokes to
2030 a surrogate minibuffer frame when a frame doesn't have its own
2033 A frame's focus redirection can be changed by `select-frame'. If frame
2034 FOO is selected, and then a different frame BAR is selected, any
2035 frames redirecting their focus to FOO are shifted to redirect their
2036 focus to BAR. This allows focus redirection to work properly when the
2037 user switches from one frame to another using `select-window'.
2039 This means that a frame whose focus is redirected to itself is treated
2040 differently from a frame whose focus is redirected to nil; the former
2041 is affected by `select-frame', while the latter is not.
2043 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2044 (Lisp_Object frame
, Lisp_Object focus_frame
)
2048 /* Note that we don't check for a live frame here. It's reasonable
2049 to redirect the focus of a frame you're about to delete, if you
2050 know what other frame should receive those keystrokes. */
2051 CHECK_FRAME (frame
);
2053 if (! NILP (focus_frame
))
2054 CHECK_LIVE_FRAME (focus_frame
);
2058 f
->focus_frame
= focus_frame
;
2060 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2061 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2067 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
2068 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2069 This returns nil if FRAME's focus is not redirected.
2070 See `redirect-frame-focus'. */)
2073 CHECK_LIVE_FRAME (frame
);
2075 return FRAME_FOCUS_FRAME (XFRAME (frame
));
2080 /* Return the value of frame parameter PROP in frame FRAME. */
2083 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
2085 register Lisp_Object tem
;
2087 tem
= Fassq (prop
, frame
->param_alist
);
2093 /* Return the buffer-predicate of the selected frame. */
2096 frame_buffer_predicate (Lisp_Object frame
)
2098 return XFRAME (frame
)->buffer_predicate
;
2101 /* Return the buffer-list of the selected frame. */
2104 frame_buffer_list (Lisp_Object frame
)
2106 return XFRAME (frame
)->buffer_list
;
2109 /* Set the buffer-list of the selected frame. */
2112 set_frame_buffer_list (Lisp_Object frame
, Lisp_Object list
)
2114 XFRAME (frame
)->buffer_list
= list
;
2117 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2120 frames_discard_buffer (Lisp_Object buffer
)
2122 Lisp_Object frame
, tail
;
2124 FOR_EACH_FRAME (tail
, frame
)
2126 XFRAME (frame
)->buffer_list
2127 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
2128 XFRAME (frame
)->buried_buffer_list
2129 = Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
);
2133 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2134 If the alist already has an element for PROP, we change it. */
2137 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2139 register Lisp_Object tem
;
2141 tem
= Fassq (prop
, *alistptr
);
2143 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2149 frame_name_fnn_p (char *str
, EMACS_INT len
)
2151 if (len
> 1 && str
[0] == 'F')
2156 n
= strtol (str
+ 1, &end_ptr
, 10);
2158 if (end_ptr
== str
+ len
2159 && INT_MIN
<= n
&& n
<= INT_MAX
2160 && ((LONG_MIN
< n
&& n
< LONG_MAX
) || errno
!= ERANGE
))
2166 /* Set the name of the terminal frame. Also used by MSDOS frames.
2167 Modeled after x_set_name which is used for WINDOW frames. */
2170 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2172 f
->explicit_name
= ! NILP (name
);
2174 /* If NAME is nil, set the name to F<num>. */
2179 /* Check for no change needed in this very common case
2180 before we do any consing. */
2181 if (frame_name_fnn_p (SDATA (f
->name
),
2186 sprintf (namebuf
, "F%d", tty_frame_count
);
2187 name
= build_string (namebuf
);
2191 CHECK_STRING (name
);
2193 /* Don't change the name if it's already NAME. */
2194 if (! NILP (Fstring_equal (name
, f
->name
)))
2197 /* Don't allow the user to set the frame name to F<num>, so it
2198 doesn't clash with the names we generate for terminal frames. */
2199 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
2200 error ("Frame names of the form F<num> are usurped by Emacs");
2204 update_mode_lines
= 1;
2208 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2210 register Lisp_Object old_alist_elt
;
2212 /* The buffer-list parameters are stored in a special place and not
2214 if (EQ (prop
, Qbuffer_list
))
2216 f
->buffer_list
= val
;
2219 if (EQ (prop
, Qburied_buffer_list
))
2221 f
->buried_buffer_list
= val
;
2225 /* If PROP is a symbol which is supposed to have frame-local values,
2226 and it is set up based on this frame, switch to the global
2227 binding. That way, we can create or alter the frame-local binding
2228 without messing up the symbol's status. */
2231 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2233 switch (sym
->redirect
)
2235 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2236 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2237 case SYMBOL_LOCALIZED
:
2238 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2239 if (blv
->frame_local
&& BLV_FOUND (blv
) && XFRAME (blv
->where
) == f
)
2240 swap_in_global_binding (sym
);
2247 /* The tty color needed to be set before the frame's parameter
2248 alist was updated with the new value. This is not true any more,
2249 but we still do this test early on. */
2250 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2251 && f
== FRAME_TTY (f
)->previous_frame
)
2252 /* Force redisplay of this tty. */
2253 FRAME_TTY (f
)->previous_frame
= NULL
;
2255 /* Update the frame parameter alist. */
2256 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2257 if (EQ (old_alist_elt
, Qnil
))
2258 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2260 Fsetcdr (old_alist_elt
, val
);
2262 /* Update some other special parameters in their special places
2263 in addition to the alist. */
2265 if (EQ (prop
, Qbuffer_predicate
))
2266 f
->buffer_predicate
= val
;
2268 if (! FRAME_WINDOW_P (f
))
2270 if (EQ (prop
, Qmenu_bar_lines
))
2271 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2272 else if (EQ (prop
, Qname
))
2273 set_term_frame_name (f
, val
);
2276 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2278 if (! MINI_WINDOW_P (XWINDOW (val
)))
2279 error ("Surrogate minibuffer windows must be minibuffer windows");
2281 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2282 && !EQ (val
, f
->minibuffer_window
))
2283 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2285 /* Install the chosen minibuffer window, with proper buffer. */
2286 f
->minibuffer_window
= val
;
2290 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2291 doc
: /* Return the parameters-alist of frame FRAME.
2292 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2293 The meaningful PARMs depend on the kind of frame.
2294 If FRAME is omitted, return information on the currently selected frame. */)
2300 struct gcpro gcpro1
;
2303 frame
= selected_frame
;
2305 CHECK_FRAME (frame
);
2308 if (!FRAME_LIVE_P (f
))
2311 alist
= Fcopy_alist (f
->param_alist
);
2314 if (!FRAME_WINDOW_P (f
))
2316 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2317 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2320 /* If the frame's parameter alist says the colors are
2321 unspecified and reversed, take the frame's background pixel
2322 for foreground and vice versa. */
2323 elt
= Fassq (Qforeground_color
, alist
);
2324 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2326 if (strncmp (SDATA (XCDR (elt
)),
2328 SCHARS (XCDR (elt
))) == 0)
2329 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2330 else if (strncmp (SDATA (XCDR (elt
)),
2332 SCHARS (XCDR (elt
))) == 0)
2333 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2336 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2337 elt
= Fassq (Qbackground_color
, alist
);
2338 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2340 if (strncmp (SDATA (XCDR (elt
)),
2342 SCHARS (XCDR (elt
))) == 0)
2343 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2344 else if (strncmp (SDATA (XCDR (elt
)),
2346 SCHARS (XCDR (elt
))) == 0)
2347 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2350 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2351 store_in_alist (&alist
, intern ("font"),
2352 build_string (FRAME_MSDOS_P (f
)
2354 : FRAME_W32_P (f
) ? "w32term"
2357 store_in_alist (&alist
, Qname
, f
->name
);
2358 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2359 store_in_alist (&alist
, Qheight
, make_number (height
));
2360 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2361 store_in_alist (&alist
, Qwidth
, make_number (width
));
2362 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2363 store_in_alist (&alist
, Qminibuffer
,
2364 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2365 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2366 : FRAME_MINIBUF_WINDOW (f
)));
2367 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2368 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2369 store_in_alist (&alist
, Qburied_buffer_list
, XFRAME (frame
)->buried_buffer_list
);
2371 /* I think this should be done with a hook. */
2372 #ifdef HAVE_WINDOW_SYSTEM
2373 if (FRAME_WINDOW_P (f
))
2374 x_report_frame_params (f
, &alist
);
2378 /* This ought to be correct in f->param_alist for an X frame. */
2380 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2381 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2389 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2390 doc
: /* Return FRAME's value for parameter PARAMETER.
2391 If FRAME is nil, describe the currently selected frame. */)
2392 (Lisp_Object frame
, Lisp_Object parameter
)
2398 frame
= selected_frame
;
2400 CHECK_FRAME (frame
);
2401 CHECK_SYMBOL (parameter
);
2406 if (FRAME_LIVE_P (f
))
2408 /* Avoid consing in frequent cases. */
2409 if (EQ (parameter
, Qname
))
2411 #ifdef HAVE_X_WINDOWS
2412 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2413 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2414 #endif /* HAVE_X_WINDOWS */
2415 else if (EQ (parameter
, Qbackground_color
)
2416 || EQ (parameter
, Qforeground_color
))
2418 value
= Fassq (parameter
, f
->param_alist
);
2421 value
= XCDR (value
);
2422 /* Fframe_parameters puts the actual fg/bg color names,
2423 even if f->param_alist says otherwise. This is
2424 important when param_alist's notion of colors is
2425 "unspecified". We need to do the same here. */
2426 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2428 const char *color_name
;
2431 if (EQ (parameter
, Qbackground_color
))
2433 color_name
= SDATA (value
);
2434 csz
= SCHARS (value
);
2435 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2436 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2437 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2438 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2440 else if (EQ (parameter
, Qforeground_color
))
2442 color_name
= SDATA (value
);
2443 csz
= SCHARS (value
);
2444 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2445 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2446 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2447 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2452 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2454 else if (EQ (parameter
, Qdisplay_type
)
2455 || EQ (parameter
, Qbackground_mode
))
2456 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2458 /* FIXME: Avoid this code path at all (as well as code duplication)
2459 by sharing more code with Fframe_parameters. */
2460 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2467 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2468 Smodify_frame_parameters
, 2, 2, 0,
2469 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2470 If FRAME is nil, it defaults to the selected frame.
2471 ALIST is an alist of parameters to change and their new values.
2472 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2473 The meaningful PARMs depend on the kind of frame.
2474 Undefined PARMs are ignored, but stored in the frame's parameter list
2475 so that `frame-parameters' will return them.
2477 The value of frame parameter FOO can also be accessed
2478 as a frame-local binding for the variable FOO, if you have
2479 enabled such bindings for that variable with `make-variable-frame-local'.
2480 Note that this functionality is obsolete as of Emacs 22.2, and its
2481 use is not recommended. Explicitly check for a frame-parameter instead. */)
2482 (Lisp_Object frame
, Lisp_Object alist
)
2485 register Lisp_Object tail
, prop
, val
;
2487 if (EQ (frame
, Qnil
))
2488 frame
= selected_frame
;
2489 CHECK_LIVE_FRAME (frame
);
2492 /* I think this should be done with a hook. */
2493 #ifdef HAVE_WINDOW_SYSTEM
2494 if (FRAME_WINDOW_P (f
))
2495 x_set_frame_parameters (f
, alist
);
2499 if (FRAME_MSDOS_P (f
))
2500 IT_set_frame_parameters (f
, alist
);
2505 int length
= XINT (Flength (alist
));
2508 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2510 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2512 /* Extract parm names and values into those vectors. */
2515 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2520 parms
[i
] = Fcar (elt
);
2521 values
[i
] = Fcdr (elt
);
2525 /* Now process them in reverse of specified order. */
2526 for (i
--; i
>= 0; i
--)
2530 store_frame_param (f
, prop
, val
);
2532 /* Changing the background color might change the background
2533 mode, so that we have to load new defface specs.
2534 Call frame-set-background-mode to do that. */
2535 if (EQ (prop
, Qbackground_color
))
2536 call1 (Qframe_set_background_mode
, frame
);
2542 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2544 doc
: /* Height in pixels of a line in the font in frame FRAME.
2545 If FRAME is omitted, the selected frame is used.
2546 For a terminal frame, the value is always 1. */)
2552 frame
= selected_frame
;
2553 CHECK_FRAME (frame
);
2556 #ifdef HAVE_WINDOW_SYSTEM
2557 if (FRAME_WINDOW_P (f
))
2558 return make_number (x_char_height (f
));
2561 return make_number (1);
2565 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2567 doc
: /* Width in pixels of characters in the font in frame FRAME.
2568 If FRAME is omitted, the selected frame is used.
2569 On a graphical screen, the width is the standard width of the default font.
2570 For a terminal screen, the value is always 1. */)
2576 frame
= selected_frame
;
2577 CHECK_FRAME (frame
);
2580 #ifdef HAVE_WINDOW_SYSTEM
2581 if (FRAME_WINDOW_P (f
))
2582 return make_number (x_char_width (f
));
2585 return make_number (1);
2588 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2589 Sframe_pixel_height
, 0, 1, 0,
2590 doc
: /* Return a FRAME's height in pixels.
2591 If FRAME is omitted, the selected frame is used. The exact value
2592 of the result depends on the window-system and toolkit in use:
2594 In the Gtk+ version of Emacs, it includes only any window (including
2595 the minibuffer or eacho area), mode line, and header line. It does not
2596 include the tool bar or menu bar.
2598 With the Motif or Lucid toolkits, it also includes the tool bar (but
2601 In a graphical version with no toolkit, it includes both the tool bar
2604 For a text-only terminal, it includes the menu bar. In this case, the
2605 result is really in characters rather than pixels (i.e., is identical
2606 to `frame-height'). */)
2612 frame
= selected_frame
;
2613 CHECK_FRAME (frame
);
2616 #ifdef HAVE_WINDOW_SYSTEM
2617 if (FRAME_WINDOW_P (f
))
2618 return make_number (x_pixel_height (f
));
2621 return make_number (FRAME_LINES (f
));
2624 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2625 Sframe_pixel_width
, 0, 1, 0,
2626 doc
: /* Return FRAME's width in pixels.
2627 For a terminal frame, the result really gives the width in characters.
2628 If FRAME is omitted, the selected frame is used. */)
2634 frame
= selected_frame
;
2635 CHECK_FRAME (frame
);
2638 #ifdef HAVE_WINDOW_SYSTEM
2639 if (FRAME_WINDOW_P (f
))
2640 return make_number (x_pixel_width (f
));
2643 return make_number (FRAME_COLS (f
));
2646 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2647 Stool_bar_pixel_width
, 0, 1, 0,
2648 doc
: /* Return width in pixels of FRAME's tool bar.
2649 The result is greater than zero only when the tool bar is on the left
2650 or right side of FRAME. If FRAME is omitted, the selected frame is
2657 frame
= selected_frame
;
2658 CHECK_FRAME (frame
);
2661 #ifdef FRAME_TOOLBAR_WIDTH
2662 if (FRAME_WINDOW_P (f
))
2663 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2665 return make_number (0);
2668 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2669 doc
: /* Specify that the frame FRAME has LINES lines.
2670 Optional third arg non-nil means that redisplay should use LINES lines
2671 but that the idea of the actual height of the frame should not be changed. */)
2672 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2674 register struct frame
*f
;
2676 CHECK_NUMBER (lines
);
2678 frame
= selected_frame
;
2679 CHECK_LIVE_FRAME (frame
);
2682 /* I think this should be done with a hook. */
2683 #ifdef HAVE_WINDOW_SYSTEM
2684 if (FRAME_WINDOW_P (f
))
2686 if (XINT (lines
) != FRAME_LINES (f
))
2687 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2688 do_pending_window_change (0);
2692 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2696 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2697 doc
: /* Specify that the frame FRAME has COLS columns.
2698 Optional third arg non-nil means that redisplay should use COLS columns
2699 but that the idea of the actual width of the frame should not be changed. */)
2700 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2702 register struct frame
*f
;
2703 CHECK_NUMBER (cols
);
2705 frame
= selected_frame
;
2706 CHECK_LIVE_FRAME (frame
);
2709 /* I think this should be done with a hook. */
2710 #ifdef HAVE_WINDOW_SYSTEM
2711 if (FRAME_WINDOW_P (f
))
2713 if (XINT (cols
) != FRAME_COLS (f
))
2714 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2715 do_pending_window_change (0);
2719 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2723 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2724 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2725 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2727 register struct frame
*f
;
2729 CHECK_LIVE_FRAME (frame
);
2730 CHECK_NUMBER (cols
);
2731 CHECK_NUMBER (rows
);
2734 /* I think this should be done with a hook. */
2735 #ifdef HAVE_WINDOW_SYSTEM
2736 if (FRAME_WINDOW_P (f
))
2738 if (XINT (rows
) != FRAME_LINES (f
)
2739 || XINT (cols
) != FRAME_COLS (f
)
2740 || f
->new_text_lines
|| f
->new_text_cols
)
2741 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2742 do_pending_window_change (0);
2746 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2751 DEFUN ("set-frame-position", Fset_frame_position
,
2752 Sset_frame_position
, 3, 3, 0,
2753 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2754 This is actually the position of the upper left corner of the frame.
2755 Negative values for XOFFSET or YOFFSET are interpreted relative to
2756 the rightmost or bottommost possible position (that stays within the screen). */)
2757 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2759 register struct frame
*f
;
2761 CHECK_LIVE_FRAME (frame
);
2762 CHECK_NUMBER (xoffset
);
2763 CHECK_NUMBER (yoffset
);
2766 /* I think this should be done with a hook. */
2767 #ifdef HAVE_WINDOW_SYSTEM
2768 if (FRAME_WINDOW_P (f
))
2769 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2776 /***********************************************************************
2778 ***********************************************************************/
2780 /* Connect the frame-parameter names for X frames
2781 to the ways of passing the parameter values to the window system.
2783 The name of a parameter, as a Lisp symbol,
2784 has an `x-frame-parameter' property which is an integer in Lisp
2785 that is an index in this table. */
2787 struct frame_parm_table
{
2789 Lisp_Object
*variable
;
2792 static const struct frame_parm_table frame_parms
[] =
2794 {"auto-raise", &Qauto_raise
},
2795 {"auto-lower", &Qauto_lower
},
2796 {"background-color", 0},
2797 {"border-color", &Qborder_color
},
2798 {"border-width", &Qborder_width
},
2799 {"cursor-color", &Qcursor_color
},
2800 {"cursor-type", &Qcursor_type
},
2802 {"foreground-color", 0},
2803 {"icon-name", &Qicon_name
},
2804 {"icon-type", &Qicon_type
},
2805 {"internal-border-width", &Qinternal_border_width
},
2806 {"menu-bar-lines", &Qmenu_bar_lines
},
2807 {"mouse-color", &Qmouse_color
},
2809 {"scroll-bar-width", &Qscroll_bar_width
},
2811 {"unsplittable", &Qunsplittable
},
2812 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2813 {"visibility", &Qvisibility
},
2814 {"tool-bar-lines", &Qtool_bar_lines
},
2815 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2816 {"scroll-bar-background", &Qscroll_bar_background
},
2817 {"screen-gamma", &Qscreen_gamma
},
2818 {"line-spacing", &Qline_spacing
},
2819 {"left-fringe", &Qleft_fringe
},
2820 {"right-fringe", &Qright_fringe
},
2821 {"wait-for-wm", &Qwait_for_wm
},
2822 {"fullscreen", &Qfullscreen
},
2823 {"font-backend", &Qfont_backend
},
2825 {"sticky", &Qsticky
},
2826 {"tool-bar-position", &Qtool_bar_position
},
2829 #ifdef HAVE_WINDOW_SYSTEM
2831 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2832 wanted positions of the WM window (not Emacs window).
2833 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2834 window (FRAME_X_WINDOW).
2838 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2840 int newwidth
= FRAME_COLS (f
);
2841 int newheight
= FRAME_LINES (f
);
2842 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2844 *top_pos
= f
->top_pos
;
2845 *left_pos
= f
->left_pos
;
2847 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2851 ph
= x_display_pixel_height (dpyinfo
);
2852 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2853 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2854 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2858 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2862 pw
= x_display_pixel_width (dpyinfo
);
2863 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2864 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2865 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2870 *height
= newheight
;
2874 /* Change the parameters of frame F as specified by ALIST.
2875 If a parameter is not specially recognized, do nothing special;
2876 otherwise call the `x_set_...' function for that parameter.
2877 Except for certain geometry properties, always call store_frame_param
2878 to store the new value in the parameter alist. */
2881 x_set_frame_parameters (FRAME_PTR f
, Lisp_Object alist
)
2885 /* If both of these parameters are present, it's more efficient to
2886 set them both at once. So we wait until we've looked at the
2887 entire list before we set them. */
2891 Lisp_Object left
, top
;
2893 /* Same with these. */
2894 Lisp_Object icon_left
, icon_top
;
2896 /* Record in these vectors all the parms specified. */
2898 Lisp_Object
*values
;
2900 int left_no_change
= 0, top_no_change
= 0;
2901 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2902 int size_changed
= 0;
2903 struct gcpro gcpro1
, gcpro2
;
2906 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2909 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2910 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2912 /* Extract parm names and values into those vectors. */
2915 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2920 parms
[i
] = Fcar (elt
);
2921 values
[i
] = Fcdr (elt
);
2924 /* TAIL and ALIST are not used again below here. */
2925 alist
= tail
= Qnil
;
2927 GCPRO2 (*parms
, *values
);
2931 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2932 because their values appear in VALUES and strings are not valid. */
2933 top
= left
= Qunbound
;
2934 icon_left
= icon_top
= Qunbound
;
2936 /* Provide default values for HEIGHT and WIDTH. */
2937 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2938 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2940 /* Process foreground_color and background_color before anything else.
2941 They are independent of other properties, but other properties (e.g.,
2942 cursor_color) are dependent upon them. */
2943 /* Process default font as well, since fringe widths depends on it. */
2944 for (p
= 0; p
< i
; p
++)
2946 Lisp_Object prop
, val
;
2950 if (EQ (prop
, Qforeground_color
)
2951 || EQ (prop
, Qbackground_color
)
2952 || EQ (prop
, Qfont
))
2954 register Lisp_Object param_index
, old_value
;
2956 old_value
= get_frame_param (f
, prop
);
2957 if (NILP (Fequal (val
, old_value
)))
2959 store_frame_param (f
, prop
, val
);
2961 param_index
= Fget (prop
, Qx_frame_parameter
);
2962 if (NATNUMP (param_index
)
2963 && (XFASTINT (param_index
)
2964 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2965 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2966 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2971 /* Now process them in reverse of specified order. */
2972 for (i
--; i
>= 0; i
--)
2974 Lisp_Object prop
, val
;
2979 if (EQ (prop
, Qwidth
) && NATNUMP (val
))
2982 width
= XFASTINT (val
);
2984 else if (EQ (prop
, Qheight
) && NATNUMP (val
))
2987 height
= XFASTINT (val
);
2989 else if (EQ (prop
, Qtop
))
2991 else if (EQ (prop
, Qleft
))
2993 else if (EQ (prop
, Qicon_top
))
2995 else if (EQ (prop
, Qicon_left
))
2997 else if (EQ (prop
, Qforeground_color
)
2998 || EQ (prop
, Qbackground_color
)
2999 || EQ (prop
, Qfont
))
3000 /* Processed above. */
3004 register Lisp_Object param_index
, old_value
;
3006 old_value
= get_frame_param (f
, prop
);
3008 store_frame_param (f
, prop
, val
);
3010 param_index
= Fget (prop
, Qx_frame_parameter
);
3011 if (NATNUMP (param_index
)
3012 && (XFASTINT (param_index
)
3013 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3014 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3015 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3019 /* Don't die if just one of these was set. */
3020 if (EQ (left
, Qunbound
))
3023 if (f
->left_pos
< 0)
3024 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
3026 XSETINT (left
, f
->left_pos
);
3028 if (EQ (top
, Qunbound
))
3032 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
3034 XSETINT (top
, f
->top_pos
);
3037 /* If one of the icon positions was not set, preserve or default it. */
3038 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
3040 icon_left_no_change
= 1;
3041 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3042 if (NILP (icon_left
))
3043 XSETINT (icon_left
, 0);
3045 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
3047 icon_top_no_change
= 1;
3048 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3049 if (NILP (icon_top
))
3050 XSETINT (icon_top
, 0);
3053 /* Don't set these parameters unless they've been explicitly
3054 specified. The window might be mapped or resized while we're in
3055 this function, and we don't want to override that unless the lisp
3056 code has asked for it.
3058 Don't set these parameters unless they actually differ from the
3059 window's current parameters; the window may not actually exist
3064 check_frame_size (f
, &height
, &width
);
3066 XSETFRAME (frame
, f
);
3069 && (width
!= FRAME_COLS (f
)
3070 || height
!= FRAME_LINES (f
)
3071 || f
->new_text_lines
|| f
->new_text_cols
))
3072 Fset_frame_size (frame
, make_number (width
), make_number (height
));
3074 if ((!NILP (left
) || !NILP (top
))
3075 && ! (left_no_change
&& top_no_change
)
3076 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3077 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3082 /* Record the signs. */
3083 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3084 if (EQ (left
, Qminus
))
3085 f
->size_hint_flags
|= XNegative
;
3086 else if (INTEGERP (left
))
3088 leftpos
= XINT (left
);
3090 f
->size_hint_flags
|= XNegative
;
3092 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3093 && CONSP (XCDR (left
))
3094 && INTEGERP (XCAR (XCDR (left
))))
3096 leftpos
= - XINT (XCAR (XCDR (left
)));
3097 f
->size_hint_flags
|= XNegative
;
3099 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3100 && CONSP (XCDR (left
))
3101 && INTEGERP (XCAR (XCDR (left
))))
3103 leftpos
= XINT (XCAR (XCDR (left
)));
3106 if (EQ (top
, Qminus
))
3107 f
->size_hint_flags
|= YNegative
;
3108 else if (INTEGERP (top
))
3110 toppos
= XINT (top
);
3112 f
->size_hint_flags
|= YNegative
;
3114 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3115 && CONSP (XCDR (top
))
3116 && INTEGERP (XCAR (XCDR (top
))))
3118 toppos
= - XINT (XCAR (XCDR (top
)));
3119 f
->size_hint_flags
|= YNegative
;
3121 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
3122 && CONSP (XCDR (top
))
3123 && INTEGERP (XCAR (XCDR (top
))))
3125 toppos
= XINT (XCAR (XCDR (top
)));
3129 /* Store the numeric value of the position. */
3130 f
->top_pos
= toppos
;
3131 f
->left_pos
= leftpos
;
3133 f
->win_gravity
= NorthWestGravity
;
3135 /* Actually set that position, and convert to absolute. */
3136 x_set_offset (f
, leftpos
, toppos
, -1);
3139 if ((!NILP (icon_left
) || !NILP (icon_top
))
3140 && ! (icon_left_no_change
&& icon_top_no_change
))
3141 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3148 /* Insert a description of internally-recorded parameters of frame X
3149 into the parameter alist *ALISTPTR that is to be given to the user.
3150 Only parameters that are specific to the X window system
3151 and whose values are not correctly recorded in the frame's
3152 param_alist need to be considered here. */
3155 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3160 /* Represent negative positions (off the top or left screen edge)
3161 in a way that Fmodify_frame_parameters will understand correctly. */
3162 XSETINT (tem
, f
->left_pos
);
3163 if (f
->left_pos
>= 0)
3164 store_in_alist (alistptr
, Qleft
, tem
);
3166 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3168 XSETINT (tem
, f
->top_pos
);
3169 if (f
->top_pos
>= 0)
3170 store_in_alist (alistptr
, Qtop
, tem
);
3172 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3174 store_in_alist (alistptr
, Qborder_width
,
3175 make_number (f
->border_width
));
3176 store_in_alist (alistptr
, Qinternal_border_width
,
3177 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3178 store_in_alist (alistptr
, Qleft_fringe
,
3179 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3180 store_in_alist (alistptr
, Qright_fringe
,
3181 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3182 store_in_alist (alistptr
, Qscroll_bar_width
,
3183 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3185 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3186 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3187 /* nil means "use default width"
3188 for non-toolkit scroll bar.
3189 ruler-mode.el depends on this. */
3191 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
3192 store_in_alist (alistptr
, Qwindow_id
,
3193 build_string (buf
));
3194 #ifdef HAVE_X_WINDOWS
3195 #ifdef USE_X_TOOLKIT
3196 /* Tooltip frame may not have this widget. */
3197 if (FRAME_X_OUTPUT (f
)->widget
)
3199 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
3200 store_in_alist (alistptr
, Qouter_window_id
,
3201 build_string (buf
));
3203 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3204 FRAME_SAMPLE_VISIBILITY (f
);
3205 store_in_alist (alistptr
, Qvisibility
,
3206 (FRAME_VISIBLE_P (f
) ? Qt
3207 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3208 store_in_alist (alistptr
, Qdisplay
,
3209 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3211 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3214 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3215 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3216 store_in_alist (alistptr
, Qparent_id
, tem
);
3217 store_in_alist (alistptr
, Qtool_bar_position
, f
->tool_bar_position
);
3221 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3222 the previous value of that parameter, NEW_VALUE is the new value. */
3225 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3227 if (NILP (new_value
))
3228 f
->want_fullscreen
= FULLSCREEN_NONE
;
3229 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3230 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3231 else if (EQ (new_value
, Qfullwidth
))
3232 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3233 else if (EQ (new_value
, Qfullheight
))
3234 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3235 else if (EQ (new_value
, Qmaximized
))
3236 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3238 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3239 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3243 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3244 the previous value of that parameter, NEW_VALUE is the new value. */
3247 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3249 if (NILP (new_value
))
3250 f
->extra_line_spacing
= 0;
3251 else if (NATNUMP (new_value
))
3252 f
->extra_line_spacing
= XFASTINT (new_value
);
3254 signal_error ("Invalid line-spacing", new_value
);
3255 if (FRAME_VISIBLE_P (f
))
3260 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3261 the previous value of that parameter, NEW_VALUE is the new value. */
3264 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3266 Lisp_Object bgcolor
;
3268 if (NILP (new_value
))
3270 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3271 /* The value 0.4545 is the normal viewing gamma. */
3272 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3274 signal_error ("Invalid screen-gamma", new_value
);
3276 /* Apply the new gamma value to the frame background. */
3277 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3278 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3280 Lisp_Object index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3282 && (XFASTINT (index
)
3283 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3284 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3285 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3289 Fclear_face_cache (Qnil
);
3294 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3296 Lisp_Object font_object
, font_param
= Qnil
;
3299 /* Set the frame parameter back to the old value because we may
3300 fail to use ARG as the new parameter value. */
3301 store_frame_param (f
, Qfont
, oldval
);
3303 /* ARG is a fontset name, a font name, a cons of fontset name and a
3304 font object, or a font object. In the last case, this function
3309 fontset
= fs_query_fontset (arg
, 0);
3312 font_object
= font_open_by_name (f
, SDATA (arg
));
3313 if (NILP (font_object
))
3314 error ("Font `%s' is not defined", SDATA (arg
));
3315 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3317 else if (fontset
> 0)
3319 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3321 font_object
= font_open_by_name (f
, SDATA (ascii_font
));
3322 if (NILP (font_object
))
3323 error ("Font `%s' is not defined", SDATA (arg
));
3324 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3327 error ("The default fontset can't be used for a frame font");
3329 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3331 /* This is the case that the ASCII font of F's fontset XCAR
3332 (arg) is changed to the font XCDR (arg) by
3333 `set-fontset-font'. */
3334 fontset
= fs_query_fontset (XCAR (arg
), 0);
3336 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3337 font_object
= XCDR (arg
);
3338 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3339 font_param
= Ffont_get (font_object
, QCname
);
3341 else if (FONT_OBJECT_P (arg
))
3344 font_param
= Ffont_get (font_object
, QCname
);
3345 /* This is to store the XLFD font name in the frame parameter for
3346 backward compatibility. We should store the font-object
3347 itself in the future. */
3348 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3349 fontset
= FRAME_FONTSET (f
);
3350 /* Check if we can use the current fontset. If not, set FONTSET
3351 to -1 to generate a new fontset from FONT-OBJECT. */
3354 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3355 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3357 if (! font_match_p (spec
, font_object
))
3362 signal_error ("Invalid font", arg
);
3364 if (! NILP (Fequal (font_object
, oldval
)))
3367 x_new_font (f
, font_object
, fontset
);
3368 store_frame_param (f
, Qfont
, arg
);
3369 #ifdef HAVE_X_WINDOWS
3370 store_frame_param (f
, Qfont_param
, font_param
);
3372 /* Recalculate toolbar height. */
3373 f
->n_tool_bar_rows
= 0;
3374 /* Ensure we redraw it. */
3375 clear_current_matrices (f
);
3377 recompute_basic_faces (f
);
3379 do_pending_window_change (0);
3381 /* We used to call face-set-after-frame-default here, but it leads to
3382 recursive calls (since that function can set the `default' face's
3383 font which in turns changes the frame's `font' parameter).
3384 Also I don't know what this call is meant to do, but it seems the
3385 wrong way to do it anyway (it does a lot more work than what seems
3386 reasonable in response to a change to `font'). */
3391 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3393 if (! NILP (new_value
)
3394 && !CONSP (new_value
))
3398 CHECK_STRING (new_value
);
3399 p0
= p1
= SDATA (new_value
);
3403 while (*p1
&& ! isspace (*p1
) && *p1
!= ',') p1
++;
3405 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3411 while ((c
= *++p1
) && isspace (c
));
3415 new_value
= Fnreverse (new_value
);
3418 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3422 free_all_realized_faces (Qnil
);
3424 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3425 if (NILP (new_value
))
3427 if (NILP (old_value
))
3428 error ("No font backend available");
3429 font_update_drivers (f
, old_value
);
3430 error ("None of specified font backends are available");
3432 store_frame_param (f
, Qfont_backend
, new_value
);
3438 XSETFRAME (frame
, f
);
3439 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3440 ++face_change_count
;
3441 ++windows_or_buffers_changed
;
3447 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3449 compute_fringe_widths (f
, 1);
3450 #ifdef HAVE_X_WINDOWS
3451 /* Must adjust this so window managers report correct number of columns. */
3452 if (FRAME_X_WINDOW (f
) != 0)
3453 x_wm_set_size_hint (f
, 0, 0);
3458 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3462 if (XINT (arg
) == f
->border_width
)
3465 if (FRAME_X_WINDOW (f
) != 0)
3466 error ("Cannot change the border width of a frame");
3468 f
->border_width
= XINT (arg
);
3472 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3474 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3477 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3478 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3479 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3481 #ifdef USE_X_TOOLKIT
3482 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3483 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3486 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3489 if (FRAME_X_WINDOW (f
) != 0)
3491 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3492 SET_FRAME_GARBAGED (f
);
3493 do_pending_window_change (0);
3496 SET_FRAME_GARBAGED (f
);
3500 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3503 XSETFRAME (frame
, f
);
3506 Fmake_frame_invisible (frame
, Qt
);
3507 else if (EQ (value
, Qicon
))
3508 Ficonify_frame (frame
);
3510 Fmake_frame_visible (frame
);
3514 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3516 f
->auto_raise
= !EQ (Qnil
, arg
);
3520 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3522 f
->auto_lower
= !EQ (Qnil
, arg
);
3526 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3528 f
->no_split
= !NILP (arg
);
3532 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3534 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3535 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3536 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3537 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3539 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3541 ? vertical_scroll_bar_none
3543 ? vertical_scroll_bar_left
3545 ? vertical_scroll_bar_right
3546 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3547 ? vertical_scroll_bar_left
3548 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3549 ? vertical_scroll_bar_right
3550 : vertical_scroll_bar_none
);
3552 /* We set this parameter before creating the X window for the
3553 frame, so we can get the geometry right from the start.
3554 However, if the window hasn't been created yet, we shouldn't
3555 call x_set_window_size. */
3556 if (FRAME_X_WINDOW (f
))
3557 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3558 do_pending_window_change (0);
3563 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3565 int wid
= FRAME_COLUMN_WIDTH (f
);
3569 x_set_scroll_bar_default_width (f
);
3571 if (FRAME_X_WINDOW (f
))
3572 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3573 do_pending_window_change (0);
3575 else if (INTEGERP (arg
) && XINT (arg
) > 0
3576 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3578 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3579 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3581 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3582 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3583 if (FRAME_X_WINDOW (f
))
3584 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3585 do_pending_window_change (0);
3588 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3589 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3590 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3595 /* Return non-nil if frame F wants a bitmap icon. */
3598 x_icon_type (FRAME_PTR f
)
3602 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3610 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3617 for (i
= 0; i
< 2; i
++)
3630 else if (FLOATP (item
))
3632 alpha
= XFLOAT_DATA (item
);
3633 if (alpha
< 0.0 || 1.0 < alpha
)
3634 args_out_of_range (make_float (0.0), make_float (1.0));
3636 else if (INTEGERP (item
))
3638 ialpha
= XINT (item
);
3639 if (ialpha
< 0 || 100 < ialpha
)
3640 args_out_of_range (make_number (0), make_number (100));
3642 alpha
= ialpha
/ 100.0;
3645 wrong_type_argument (Qnumberp
, item
);
3649 for (i
= 0; i
< 2; i
++)
3650 f
->alpha
[i
] = newval
[i
];
3652 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3654 x_set_frame_alpha (f
);
3662 /* Subroutines of creating an X frame. */
3664 /* Make sure that Vx_resource_name is set to a reasonable value.
3665 Fix it up, or set it to `emacs' if it is too hopeless. */
3668 validate_x_resource_name (void)
3671 /* Number of valid characters in the resource name. */
3673 /* Number of invalid characters in the resource name. */
3678 if (!STRINGP (Vx_resource_class
))
3679 Vx_resource_class
= build_string (EMACS_CLASS
);
3681 if (STRINGP (Vx_resource_name
))
3683 unsigned char *p
= SDATA (Vx_resource_name
);
3685 len
= SBYTES (Vx_resource_name
);
3687 /* Only letters, digits, - and _ are valid in resource names.
3688 Count the valid characters and count the invalid ones. */
3689 for (i
= 0; i
< len
; i
++)
3692 if (! ((c
>= 'a' && c
<= 'z')
3693 || (c
>= 'A' && c
<= 'Z')
3694 || (c
>= '0' && c
<= '9')
3695 || c
== '-' || c
== '_'))
3702 /* Not a string => completely invalid. */
3703 bad_count
= 5, good_count
= 0;
3705 /* If name is valid already, return. */
3709 /* If name is entirely invalid, or nearly so, use `emacs'. */
3711 || (good_count
== 1 && bad_count
> 0))
3713 Vx_resource_name
= build_string ("emacs");
3717 /* Name is partly valid. Copy it and replace the invalid characters
3718 with underscores. */
3720 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3722 for (i
= 0; i
< len
; i
++)
3724 int c
= SREF (new, i
);
3725 if (! ((c
>= 'a' && c
<= 'z')
3726 || (c
>= 'A' && c
<= 'Z')
3727 || (c
>= '0' && c
<= '9')
3728 || c
== '-' || c
== '_'))
3734 extern char *x_get_string_resource (XrmDatabase
, const char *, const char *);
3735 extern Display_Info
*check_x_display_info (Lisp_Object
);
3738 /* Get specified attribute from resource database RDB.
3739 See Fx_get_resource below for other parameters. */
3742 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3744 register char *value
;
3748 CHECK_STRING (attribute
);
3749 CHECK_STRING (class);
3751 if (!NILP (component
))
3752 CHECK_STRING (component
);
3753 if (!NILP (subclass
))
3754 CHECK_STRING (subclass
);
3755 if (NILP (component
) != NILP (subclass
))
3756 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3758 validate_x_resource_name ();
3760 /* Allocate space for the components, the dots which separate them,
3761 and the final '\0'. Make them big enough for the worst case. */
3762 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3763 + (STRINGP (component
)
3764 ? SBYTES (component
) : 0)
3765 + SBYTES (attribute
)
3768 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3770 + (STRINGP (subclass
)
3771 ? SBYTES (subclass
) : 0)
3774 /* Start with emacs.FRAMENAME for the name (the specific one)
3775 and with `Emacs' for the class key (the general one). */
3776 strcpy (name_key
, SDATA (Vx_resource_name
));
3777 strcpy (class_key
, SDATA (Vx_resource_class
));
3779 strcat (class_key
, ".");
3780 strcat (class_key
, SDATA (class));
3782 if (!NILP (component
))
3784 strcat (class_key
, ".");
3785 strcat (class_key
, SDATA (subclass
));
3787 strcat (name_key
, ".");
3788 strcat (name_key
, SDATA (component
));
3791 strcat (name_key
, ".");
3792 strcat (name_key
, SDATA (attribute
));
3794 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3796 if (value
!= (char *) 0 && *value
)
3797 return build_string (value
);
3803 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3804 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3805 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3806 class, where INSTANCE is the name under which Emacs was invoked, or
3807 the name specified by the `-name' or `-rn' command-line arguments.
3809 The optional arguments COMPONENT and SUBCLASS add to the key and the
3810 class, respectively. You must specify both of them or neither.
3811 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3812 and the class is `Emacs.CLASS.SUBCLASS'. */)
3813 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3815 #ifdef HAVE_X_WINDOWS
3819 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3820 attribute
, class, component
, subclass
);
3823 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3826 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3828 return xrdb_get_resource (dpyinfo
->xrdb
,
3829 attribute
, class, component
, subclass
);
3832 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3833 /* Used when C code wants a resource value. */
3834 /* Called from oldXMenu/Create.c. */
3836 x_get_resource_string (const char *attribute
, const char *class)
3840 struct frame
*sf
= SELECTED_FRAME ();
3842 /* Allocate space for the components, the dots which separate them,
3843 and the final '\0'. */
3844 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3845 + strlen (attribute
) + 2);
3846 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3847 + strlen (class) + 2);
3849 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3850 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3852 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3853 name_key
, class_key
);
3857 /* Return the value of parameter PARAM.
3859 First search ALIST, then Vdefault_frame_alist, then the X defaults
3860 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3862 Convert the resource to the type specified by desired_type.
3864 If no default is specified, return Qunbound. If you call
3865 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3866 and don't let it get stored in any Lisp-visible variables! */
3869 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3870 const char *attribute
, const char *class, enum resource_types type
)
3872 register Lisp_Object tem
;
3874 tem
= Fassq (param
, alist
);
3878 /* If we find this parm in ALIST, clear it out
3879 so that it won't be "left over" at the end. */
3881 XSETCAR (tem
, Qnil
);
3882 /* In case the parameter appears more than once in the alist,
3884 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3885 if (CONSP (XCAR (tail
))
3886 && EQ (XCAR (XCAR (tail
)), param
))
3887 XSETCAR (XCAR (tail
), Qnil
);
3890 tem
= Fassq (param
, Vdefault_frame_alist
);
3892 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3893 look in the X resources. */
3896 if (attribute
&& dpyinfo
)
3898 tem
= display_x_get_resource (dpyinfo
,
3899 build_string (attribute
),
3900 build_string (class),
3908 case RES_TYPE_NUMBER
:
3909 return make_number (atoi (SDATA (tem
)));
3911 case RES_TYPE_BOOLEAN_NUMBER
:
3912 if (!strcmp (SDATA (tem
), "on")
3913 || !strcmp (SDATA (tem
), "true"))
3914 return make_number (1);
3915 return make_number (atoi (SDATA (tem
)));
3918 case RES_TYPE_FLOAT
:
3919 return make_float (atof (SDATA (tem
)));
3921 case RES_TYPE_BOOLEAN
:
3922 tem
= Fdowncase (tem
);
3923 if (!strcmp (SDATA (tem
), "on")
3925 || !strcmp(SDATA(tem
), "yes")
3927 || !strcmp (SDATA (tem
), "true"))
3932 case RES_TYPE_STRING
:
3935 case RES_TYPE_SYMBOL
:
3936 /* As a special case, we map the values `true' and `on'
3937 to Qt, and `false' and `off' to Qnil. */
3940 lower
= Fdowncase (tem
);
3941 if (!strcmp (SDATA (lower
), "on")
3943 || !strcmp(SDATA(lower
), "yes")
3945 || !strcmp (SDATA (lower
), "true"))
3947 else if (!strcmp (SDATA (lower
), "off")
3949 || !strcmp(SDATA(lower
), "no")
3951 || !strcmp (SDATA (lower
), "false"))
3954 return Fintern (tem
, Qnil
);
3968 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3969 const char *attribute
, const char *class,
3970 enum resource_types type
)
3972 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3973 alist
, param
, attribute
, class, type
);
3976 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3979 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3981 const char *attribute
, const char *class,
3982 enum resource_types type
)
3986 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3987 attribute
, class, type
);
3988 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3989 store_frame_param (f
, param
, value
);
3995 /* Record in frame F the specified or default value according to ALIST
3996 of the parameter named PROP (a Lisp symbol).
3997 If no value is specified for PROP, look for an X default for XPROP
3998 on the frame named NAME.
3999 If that is not found either, use the value DEFLT. */
4002 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
4003 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
4004 enum resource_types type
)
4008 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
4009 if (EQ (tem
, Qunbound
))
4011 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
4018 /* NS used to define x-parse-geometry in ns-win.el, but that confused
4019 make-docfile: the documentation string in ns-win.el was used for
4020 x-parse-geometry even in non-NS builds.
4022 With two definitions of x-parse-geometry in this file, various
4023 things still get confused (eg M-x apropos documentation), so that
4024 it is best if the two definitions just share the same doc-string.
4026 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4027 doc
: /* Parse a display geometry string STRING.
4028 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4029 The properties returned may include `top', `left', `height', and `width'.
4030 For X, the value of `left' or `top' may be an integer,
4031 or a list (+ N) meaning N pixels relative to top/left corner,
4032 or a list (- N) meaning -N pixels relative to bottom/right corner.
4033 On Nextstep, this just calls `ns-parse-geometry'. */)
4034 (Lisp_Object string
)
4037 call1 (Qns_parse_geometry
, string
);
4040 unsigned int width
, height
;
4043 CHECK_STRING (string
);
4045 geometry
= XParseGeometry (SSDATA (string
),
4046 &x
, &y
, &width
, &height
);
4048 if (geometry
& XValue
)
4050 Lisp_Object element
;
4052 if (x
>= 0 && (geometry
& XNegative
))
4053 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
4054 else if (x
< 0 && ! (geometry
& XNegative
))
4055 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
4057 element
= Fcons (Qleft
, make_number (x
));
4058 result
= Fcons (element
, result
);
4061 if (geometry
& YValue
)
4063 Lisp_Object element
;
4065 if (y
>= 0 && (geometry
& YNegative
))
4066 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
4067 else if (y
< 0 && ! (geometry
& YNegative
))
4068 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
4070 element
= Fcons (Qtop
, make_number (y
));
4071 result
= Fcons (element
, result
);
4074 if (geometry
& WidthValue
)
4075 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
4076 if (geometry
& HeightValue
)
4077 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
4080 #endif /* HAVE_NS */
4084 /* Calculate the desired size and position of frame F.
4085 Return the flags saying which aspects were specified.
4087 Also set the win_gravity and size_hint_flags of F.
4089 Adjust height for toolbar if TOOLBAR_P is 1.
4091 This function does not make the coordinates positive. */
4093 #define DEFAULT_ROWS 35
4094 #define DEFAULT_COLS 80
4097 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, int toolbar_p
)
4099 register Lisp_Object tem0
, tem1
, tem2
;
4100 long window_prompting
= 0;
4101 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
4103 /* Default values if we fall through.
4104 Actually, if that happens we should get
4105 window manager prompting. */
4106 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4107 FRAME_LINES (f
) = DEFAULT_ROWS
;
4108 /* Window managers expect that if program-specified
4109 positions are not (0,0), they're intentional, not defaults. */
4113 /* Ensure that old new_text_cols and new_text_lines will not override the
4115 /* ++KFS: This was specific to W32, but seems ok for all platforms */
4116 f
->new_text_cols
= f
->new_text_lines
= 0;
4118 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4119 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4120 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4121 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4123 if (!EQ (tem0
, Qunbound
))
4125 CHECK_NUMBER (tem0
);
4126 FRAME_LINES (f
) = XINT (tem0
);
4128 if (!EQ (tem1
, Qunbound
))
4130 CHECK_NUMBER (tem1
);
4131 SET_FRAME_COLS (f
, XINT (tem1
));
4133 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4134 window_prompting
|= USSize
;
4136 window_prompting
|= PSize
;
4139 f
->scroll_bar_actual_width
4140 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4142 /* This used to be done _before_ calling x_figure_window_size, but
4143 since the height is reset here, this was really a no-op. I
4144 assume that moving it here does what Gerd intended (although he
4145 no longer can remember what that was... ++KFS, 2003-03-25. */
4147 /* Add the tool-bar height to the initial frame height so that the
4148 user gets a text display area of the size he specified with -g or
4149 via .Xdefaults. Later changes of the tool-bar height don't
4150 change the frame size. This is done so that users can create
4151 tall Emacs frames without having to guess how tall the tool-bar
4153 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4155 int margin
, relief
, bar_height
;
4157 relief
= (tool_bar_button_relief
>= 0
4158 ? tool_bar_button_relief
4159 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4161 if (INTEGERP (Vtool_bar_button_margin
)
4162 && XINT (Vtool_bar_button_margin
) > 0)
4163 margin
= XFASTINT (Vtool_bar_button_margin
);
4164 else if (CONSP (Vtool_bar_button_margin
)
4165 && INTEGERP (XCDR (Vtool_bar_button_margin
))
4166 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
4167 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4171 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4172 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4175 compute_fringe_widths (f
, 0);
4177 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4178 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4180 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4181 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4182 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4183 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4185 if (EQ (tem0
, Qminus
))
4188 window_prompting
|= YNegative
;
4190 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4191 && CONSP (XCDR (tem0
))
4192 && INTEGERP (XCAR (XCDR (tem0
))))
4194 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4195 window_prompting
|= YNegative
;
4197 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4198 && CONSP (XCDR (tem0
))
4199 && INTEGERP (XCAR (XCDR (tem0
))))
4201 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4203 else if (EQ (tem0
, Qunbound
))
4207 CHECK_NUMBER (tem0
);
4208 f
->top_pos
= XINT (tem0
);
4210 window_prompting
|= YNegative
;
4213 if (EQ (tem1
, Qminus
))
4216 window_prompting
|= XNegative
;
4218 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4219 && CONSP (XCDR (tem1
))
4220 && INTEGERP (XCAR (XCDR (tem1
))))
4222 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4223 window_prompting
|= XNegative
;
4225 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4226 && CONSP (XCDR (tem1
))
4227 && INTEGERP (XCAR (XCDR (tem1
))))
4229 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4231 else if (EQ (tem1
, Qunbound
))
4235 CHECK_NUMBER (tem1
);
4236 f
->left_pos
= XINT (tem1
);
4237 if (f
->left_pos
< 0)
4238 window_prompting
|= XNegative
;
4241 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4242 window_prompting
|= USPosition
;
4244 window_prompting
|= PPosition
;
4247 if (window_prompting
& XNegative
)
4249 if (window_prompting
& YNegative
)
4250 f
->win_gravity
= SouthEastGravity
;
4252 f
->win_gravity
= NorthEastGravity
;
4256 if (window_prompting
& YNegative
)
4257 f
->win_gravity
= SouthWestGravity
;
4259 f
->win_gravity
= NorthWestGravity
;
4262 f
->size_hint_flags
= window_prompting
;
4264 return window_prompting
;
4269 #endif /* HAVE_WINDOW_SYSTEM */
4272 frame_make_pointer_invisible (void)
4274 if (! NILP (Vmake_pointer_invisible
))
4277 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4280 f
= SELECTED_FRAME ();
4281 if (f
&& !f
->pointer_invisible
4282 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4285 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4286 f
->pointer_invisible
= 1;
4292 frame_make_pointer_visible (void)
4294 /* We don't check Vmake_pointer_invisible here in case the
4295 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4298 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4301 f
= SELECTED_FRAME ();
4302 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4303 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4305 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4306 f
->pointer_invisible
= 0;
4310 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4311 Sframe_pointer_visible_p
, 0, 1, 0,
4312 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4313 Otherwise it returns nil. FRAME omitted or nil means the
4314 selected frame. This is useful when `make-pointer-invisible' is set. */)
4318 frame
= selected_frame
;
4320 CHECK_FRAME (frame
);
4322 return (XFRAME (frame
)->pointer_invisible
? Qnil
: Qt
);
4326 /***********************************************************************
4328 ***********************************************************************/
4331 syms_of_frame (void)
4333 Qframep
= intern_c_string ("framep");
4334 staticpro (&Qframep
);
4335 Qframe_live_p
= intern_c_string ("frame-live-p");
4336 staticpro (&Qframe_live_p
);
4337 Qexplicit_name
= intern_c_string ("explicit-name");
4338 staticpro (&Qexplicit_name
);
4339 Qheight
= intern_c_string ("height");
4340 staticpro (&Qheight
);
4341 Qicon
= intern_c_string ("icon");
4343 Qminibuffer
= intern_c_string ("minibuffer");
4344 staticpro (&Qminibuffer
);
4345 Qmodeline
= intern_c_string ("modeline");
4346 staticpro (&Qmodeline
);
4347 Qonly
= intern_c_string ("only");
4349 Qwidth
= intern_c_string ("width");
4350 staticpro (&Qwidth
);
4351 Qgeometry
= intern_c_string ("geometry");
4352 staticpro (&Qgeometry
);
4353 Qicon_left
= intern_c_string ("icon-left");
4354 staticpro (&Qicon_left
);
4355 Qicon_top
= intern_c_string ("icon-top");
4356 staticpro (&Qicon_top
);
4357 Qtooltip
= intern_c_string ("tooltip");
4358 staticpro (&Qtooltip
);
4359 Qleft
= intern_c_string ("left");
4361 Qright
= intern_c_string ("right");
4362 staticpro (&Qright
);
4363 Quser_position
= intern_c_string ("user-position");
4364 staticpro (&Quser_position
);
4365 Quser_size
= intern_c_string ("user-size");
4366 staticpro (&Quser_size
);
4367 Qwindow_id
= intern_c_string ("window-id");
4368 staticpro (&Qwindow_id
);
4369 #ifdef HAVE_X_WINDOWS
4370 Qouter_window_id
= intern_c_string ("outer-window-id");
4371 staticpro (&Qouter_window_id
);
4373 Qparent_id
= intern_c_string ("parent-id");
4374 staticpro (&Qparent_id
);
4375 Qx
= intern_c_string ("x");
4377 Qw32
= intern_c_string ("w32");
4379 Qpc
= intern_c_string ("pc");
4381 Qmac
= intern_c_string ("mac");
4383 Qns
= intern_c_string ("ns");
4385 Qvisible
= intern_c_string ("visible");
4386 staticpro (&Qvisible
);
4387 Qbuffer_predicate
= intern_c_string ("buffer-predicate");
4388 staticpro (&Qbuffer_predicate
);
4389 Qbuffer_list
= intern_c_string ("buffer-list");
4390 staticpro (&Qbuffer_list
);
4391 Qburied_buffer_list
= intern_c_string ("buried-buffer-list");
4392 staticpro (&Qburied_buffer_list
);
4393 Qdisplay_type
= intern_c_string ("display-type");
4394 staticpro (&Qdisplay_type
);
4395 Qbackground_mode
= intern_c_string ("background-mode");
4396 staticpro (&Qbackground_mode
);
4397 Qnoelisp
= intern_c_string ("noelisp");
4398 staticpro (&Qnoelisp
);
4399 Qtty_color_mode
= intern_c_string ("tty-color-mode");
4400 staticpro (&Qtty_color_mode
);
4401 Qtty
= intern_c_string ("tty");
4403 Qtty_type
= intern_c_string ("tty-type");
4404 staticpro (&Qtty_type
);
4406 Qface_set_after_frame_default
= intern_c_string ("face-set-after-frame-default");
4407 staticpro (&Qface_set_after_frame_default
);
4409 Qfullwidth
= intern_c_string ("fullwidth");
4410 staticpro (&Qfullwidth
);
4411 Qfullheight
= intern_c_string ("fullheight");
4412 staticpro (&Qfullheight
);
4413 Qfullboth
= intern_c_string ("fullboth");
4414 staticpro (&Qfullboth
);
4415 Qmaximized
= intern_c_string ("maximized");
4416 staticpro (&Qmaximized
);
4417 Qx_resource_name
= intern_c_string ("x-resource-name");
4418 staticpro (&Qx_resource_name
);
4420 Qx_frame_parameter
= intern_c_string ("x-frame-parameter");
4421 staticpro (&Qx_frame_parameter
);
4423 Qterminal
= intern_c_string ("terminal");
4424 staticpro (&Qterminal
);
4425 Qterminal_live_p
= intern_c_string ("terminal-live-p");
4426 staticpro (&Qterminal_live_p
);
4429 Qns_parse_geometry
= intern_c_string ("ns-parse-geometry");
4430 staticpro (&Qns_parse_geometry
);
4436 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4438 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4439 if (frame_parms
[i
].variable
)
4441 *frame_parms
[i
].variable
= v
;
4442 staticpro (frame_parms
[i
].variable
);
4444 Fput (v
, Qx_frame_parameter
, make_number (i
));
4448 #ifdef HAVE_WINDOW_SYSTEM
4449 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4450 doc
: /* The name Emacs uses to look up X resources.
4451 `x-get-resource' uses this as the first component of the instance name
4452 when requesting resource values.
4453 Emacs initially sets `x-resource-name' to the name under which Emacs
4454 was invoked, or to the value specified with the `-name' or `-rn'
4455 switches, if present.
4457 It may be useful to bind this variable locally around a call
4458 to `x-get-resource'. See also the variable `x-resource-class'. */);
4459 Vx_resource_name
= Qnil
;
4461 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4462 doc
: /* The class Emacs uses to look up X resources.
4463 `x-get-resource' uses this as the first component of the instance class
4464 when requesting resource values.
4466 Emacs initially sets `x-resource-class' to "Emacs".
4468 Setting this variable permanently is not a reasonable thing to do,
4469 but binding this variable locally around a call to `x-get-resource'
4470 is a reasonable practice. See also the variable `x-resource-name'. */);
4471 Vx_resource_class
= build_string (EMACS_CLASS
);
4473 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4474 doc
: /* The lower limit of the frame opacity (alpha transparency).
4475 The value should range from 0 (invisible) to 100 (completely opaque).
4476 You can also use a floating number between 0.0 and 1.0.
4477 The default is 20. */);
4478 Vframe_alpha_lower_limit
= make_number (20);
4481 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4482 doc
: /* Alist of default values for frame creation.
4483 These may be set in your init file, like this:
4484 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4485 These override values given in window system configuration data,
4486 including X Windows' defaults database.
4487 For values specific to the first Emacs frame, see `initial-frame-alist'.
4488 For window-system specific values, see `window-system-default-frame-alist'.
4489 For values specific to the separate minibuffer frame, see
4490 `minibuffer-frame-alist'.
4491 The `menu-bar-lines' element of the list controls whether new frames
4492 have menu bars; `menu-bar-mode' works by altering this element.
4493 Setting this variable does not affect existing frames, only new ones. */);
4494 Vdefault_frame_alist
= Qnil
;
4496 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4497 doc
: /* Default position of scroll bars on this window-system. */);
4498 #ifdef HAVE_WINDOW_SYSTEM
4499 #if defined(HAVE_NTGUI) || defined(NS_IMPL_COCOA) || (defined(USE_GTK) && defined(USE_TOOLKIT_SCROLL_BARS))
4500 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4502 Vdefault_frame_scroll_bars
= Qright
;
4504 Vdefault_frame_scroll_bars
= Qleft
;
4507 Vdefault_frame_scroll_bars
= Qnil
;
4510 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4511 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4513 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4514 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4515 `mouse-position' calls this function, passing its usual return value as
4516 argument, and returns whatever this function returns.
4517 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4518 which need to do mouse handling at the Lisp level. */);
4519 Vmouse_position_function
= Qnil
;
4521 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4522 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4523 If the value is an integer, highlighting is only shown after moving the
4524 mouse, while keyboard input turns off the highlight even when the mouse
4525 is over the clickable text. However, the mouse shape still indicates
4526 when the mouse is over clickable text. */);
4527 Vmouse_highlight
= Qt
;
4529 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4530 doc
: /* If non-nil, make pointer invisible while typing.
4531 The pointer becomes visible again when the mouse is moved. */);
4532 Vmake_pointer_invisible
= Qt
;
4534 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4535 doc
: /* Functions to be run before deleting a frame.
4536 The functions are run with one arg, the frame to be deleted.
4539 Note that functions in this list may be called just before the frame is
4540 actually deleted, or some time later (or even both when an earlier function
4541 in `delete-frame-functions' (indirectly) calls `delete-frame'
4543 Vdelete_frame_functions
= Qnil
;
4544 Qdelete_frame_functions
= intern_c_string ("delete-frame-functions");
4545 staticpro (&Qdelete_frame_functions
);
4547 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4548 doc
: /* Non-nil if Menu-Bar mode is enabled.
4549 See the command `menu-bar-mode' for a description of this minor mode.
4550 Setting this variable directly does not take effect;
4551 either customize it (see the info node `Easy Customization')
4552 or call the function `menu-bar-mode'. */);
4553 Vmenu_bar_mode
= Qt
;
4555 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4556 doc
: /* Non-nil if Tool-Bar mode is enabled.
4557 See the command `tool-bar-mode' for a description of this minor mode.
4558 Setting this variable directly does not take effect;
4559 either customize it (see the info node `Easy Customization')
4560 or call the function `tool-bar-mode'. */);
4561 #ifdef HAVE_WINDOW_SYSTEM
4562 Vtool_bar_mode
= Qt
;
4564 Vtool_bar_mode
= Qnil
;
4567 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4568 doc
: /* Minibufferless frames use this frame's minibuffer.
4570 Emacs cannot create minibufferless frames unless this is set to an
4571 appropriate surrogate.
4573 Emacs consults this variable only when creating minibufferless
4574 frames; once the frame is created, it sticks with its assigned
4575 minibuffer, no matter what this variable is set to. This means that
4576 this variable doesn't necessarily say anything meaningful about the
4577 current set of frames, or where the minibuffer is currently being
4580 This variable is local to the current terminal and cannot be buffer-local. */);
4582 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
4583 doc
: /* Non-nil if window system changes focus when you move the mouse.
4584 You should set this variable to tell Emacs how your window manager
4585 handles focus, since there is no way in general for Emacs to find out
4586 automatically. See also `mouse-autoselect-window'. */);
4587 focus_follows_mouse
= 0;
4589 staticpro (&Vframe_list
);
4591 defsubr (&Sactive_minibuffer_window
);
4593 defsubr (&Sframe_live_p
);
4594 defsubr (&Swindow_system
);
4595 defsubr (&Smake_terminal_frame
);
4596 defsubr (&Shandle_switch_frame
);
4597 defsubr (&Sselect_frame
);
4598 defsubr (&Sselected_frame
);
4599 defsubr (&Swindow_frame
);
4600 defsubr (&Sframe_root_window
);
4601 defsubr (&Sframe_first_window
);
4602 defsubr (&Sframe_selected_window
);
4603 defsubr (&Sset_frame_selected_window
);
4604 defsubr (&Sframe_list
);
4605 defsubr (&Snext_frame
);
4606 defsubr (&Sprevious_frame
);
4607 defsubr (&Sdelete_frame
);
4608 defsubr (&Smouse_position
);
4609 defsubr (&Smouse_pixel_position
);
4610 defsubr (&Sset_mouse_position
);
4611 defsubr (&Sset_mouse_pixel_position
);
4613 defsubr (&Sframe_configuration
);
4614 defsubr (&Srestore_frame_configuration
);
4616 defsubr (&Smake_frame_visible
);
4617 defsubr (&Smake_frame_invisible
);
4618 defsubr (&Siconify_frame
);
4619 defsubr (&Sframe_visible_p
);
4620 defsubr (&Svisible_frame_list
);
4621 defsubr (&Sraise_frame
);
4622 defsubr (&Slower_frame
);
4623 defsubr (&Sredirect_frame_focus
);
4624 defsubr (&Sframe_focus
);
4625 defsubr (&Sframe_parameters
);
4626 defsubr (&Sframe_parameter
);
4627 defsubr (&Smodify_frame_parameters
);
4628 defsubr (&Sframe_char_height
);
4629 defsubr (&Sframe_char_width
);
4630 defsubr (&Sframe_pixel_height
);
4631 defsubr (&Sframe_pixel_width
);
4632 defsubr (&Stool_bar_pixel_width
);
4633 defsubr (&Sset_frame_height
);
4634 defsubr (&Sset_frame_width
);
4635 defsubr (&Sset_frame_size
);
4636 defsubr (&Sset_frame_position
);
4637 defsubr (&Sframe_pointer_visible_p
);
4639 #ifdef HAVE_WINDOW_SYSTEM
4640 defsubr (&Sx_get_resource
);
4641 defsubr (&Sx_parse_geometry
);