1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
24 #include "character.h"
35 /* These help us bind and responding to switch-frame events. */
39 #include "blockinput.h"
41 #include "termhooks.h"
42 #include "dispextern.h"
44 #ifdef HAVE_WINDOW_SYSTEM
54 #ifdef HAVE_WINDOW_SYSTEM
56 /* The name we're using in resource queries. Most often "emacs". */
58 Lisp_Object Vx_resource_name
;
60 /* The application class we're using in resource queries.
63 Lisp_Object Vx_resource_class
;
67 Lisp_Object Qframep
, Qframe_live_p
;
68 Lisp_Object Qicon
, Qmodeline
;
70 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
;
72 Lisp_Object Qdisplay_type
;
73 Lisp_Object Qbackground_mode
;
76 Lisp_Object Qx_frame_parameter
;
77 Lisp_Object Qx_resource_name
;
78 Lisp_Object Qterminal
;
79 Lisp_Object Qterminal_live_p
;
81 /* Frame parameters (set or reported). */
83 Lisp_Object Qauto_raise
, Qauto_lower
;
84 Lisp_Object Qborder_color
, Qborder_width
;
85 Lisp_Object Qcursor_color
, Qcursor_type
;
86 Lisp_Object Qgeometry
; /* Not used */
87 Lisp_Object Qheight
, Qwidth
;
88 Lisp_Object Qleft
, Qright
;
89 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
90 Lisp_Object Qinternal_border_width
;
91 Lisp_Object Qmouse_color
;
92 Lisp_Object Qminibuffer
;
93 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
94 Lisp_Object Qvisibility
;
95 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
96 Lisp_Object Qscreen_gamma
;
97 Lisp_Object Qline_spacing
;
98 Lisp_Object Quser_position
, Quser_size
;
99 Lisp_Object Qwait_for_wm
;
100 Lisp_Object Qwindow_id
;
101 #ifdef HAVE_X_WINDOWS
102 Lisp_Object Qouter_window_id
;
104 Lisp_Object Qparent_id
;
105 Lisp_Object Qtitle
, Qname
;
106 Lisp_Object Qexplicit_name
;
107 Lisp_Object Qunsplittable
;
108 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
109 Lisp_Object Qleft_fringe
, Qright_fringe
;
110 Lisp_Object Qbuffer_predicate
, Qbuffer_list
, Qburied_buffer_list
;
111 Lisp_Object Qtty_color_mode
;
112 Lisp_Object Qtty
, Qtty_type
;
114 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
;
115 Lisp_Object Qfont_backend
;
117 Lisp_Object Qinhibit_face_set_after_frame_default
;
118 Lisp_Object Qface_set_after_frame_default
;
120 Lisp_Object Vterminal_frame
;
121 Lisp_Object Vdefault_frame_alist
;
122 Lisp_Object Vdefault_frame_scroll_bars
;
123 Lisp_Object Vmouse_position_function
;
124 Lisp_Object Vmouse_highlight
;
125 static Lisp_Object Vdelete_frame_functions
, Qdelete_frame_functions
;
127 int focus_follows_mouse
;
130 set_menu_bar_lines_1 (window
, n
)
134 struct window
*w
= XWINDOW (window
);
136 XSETFASTINT (w
->last_modified
, 0);
137 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
138 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
140 if (INTEGERP (w
->orig_top_line
))
141 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
142 if (INTEGERP (w
->orig_total_lines
))
143 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
145 /* Handle just the top child in a vertical split. */
146 if (!NILP (w
->vchild
))
147 set_menu_bar_lines_1 (w
->vchild
, n
);
149 /* Adjust all children in a horizontal split. */
150 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
152 w
= XWINDOW (window
);
153 set_menu_bar_lines_1 (window
, n
);
158 set_menu_bar_lines (f
, value
, oldval
)
160 Lisp_Object value
, oldval
;
163 int olines
= FRAME_MENU_BAR_LINES (f
);
165 /* Right now, menu bars don't work properly in minibuf-only frames;
166 most of the commands try to apply themselves to the minibuffer
167 frame itself, and get an error because you can't switch buffers
168 in or split the minibuffer window. */
169 if (FRAME_MINIBUF_ONLY_P (f
))
172 if (INTEGERP (value
))
173 nlines
= XINT (value
);
177 if (nlines
!= olines
)
179 windows_or_buffers_changed
++;
180 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
181 FRAME_MENU_BAR_LINES (f
) = nlines
;
182 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
187 Lisp_Object Vemacs_iconified
;
188 Lisp_Object Vframe_list
;
190 extern Lisp_Object Vminibuffer_list
;
191 extern Lisp_Object
get_minibuffer ();
192 extern Lisp_Object
Fhandle_switch_frame ();
193 extern Lisp_Object
Fredirect_frame_focus ();
194 extern Lisp_Object
x_get_focus_frame ();
196 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
197 doc
: /* Return non-nil if OBJECT is a frame.
198 Value is t for a termcap frame (a character-only terminal),
199 `x' for an Emacs frame that is really an X window,
200 `w32' for an Emacs frame that is a window on MS-Windows display,
201 `mac' for an Emacs frame on a Macintosh display,
202 `pc' for a direct-write MS-DOS frame.
203 See also `frame-live-p'. */)
207 if (!FRAMEP (object
))
209 switch (XFRAME (object
)->output_method
)
211 case output_initial
: /* The initial frame is like a termcap frame. */
214 case output_x_window
:
218 case output_msdos_raw
:
227 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
228 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
229 Value is nil if OBJECT is not a live frame. If object is a live
230 frame, the return value indicates what sort of terminal device it is
231 displayed on. See the documentation of `framep' for possible
236 return ((FRAMEP (object
)
237 && FRAME_LIVE_P (XFRAME (object
)))
242 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
243 doc
: /* The name of the window system that FRAME is displaying through.
244 The value is a symbol---for instance, 'x' for X windows.
245 The value is nil if Emacs is using a text-only terminal.
247 FRAME defaults to the currently selected frame. */)
253 frame
= selected_frame
;
255 type
= Fframep (frame
);
258 wrong_type_argument (Qframep
, frame
);
271 register struct frame
*f
;
272 register Lisp_Object root_window
;
273 register Lisp_Object mini_window
;
275 f
= allocate_frame ();
276 XSETFRAME (frame
, f
);
278 f
->desired_matrix
= 0;
279 f
->current_matrix
= 0;
282 f
->glyphs_initialized_p
= 0;
283 f
->decode_mode_spec_buffer
= 0;
285 f
->async_visible
= 0;
286 f
->output_data
.nothing
= 0;
288 f
->async_iconified
= 0;
289 f
->wants_modeline
= 1;
294 f
->has_minibuffer
= mini_p
;
295 f
->focus_frame
= Qnil
;
296 f
->explicit_name
= 0;
297 f
->can_have_scroll_bars
= 0;
298 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
299 f
->param_alist
= Qnil
;
300 f
->scroll_bars
= Qnil
;
301 f
->condemned_scroll_bars
= Qnil
;
302 f
->face_alist
= Qnil
;
303 f
->face_cache
= NULL
;
304 f
->menu_bar_items
= Qnil
;
305 f
->menu_bar_vector
= Qnil
;
306 f
->menu_bar_items_used
= 0;
307 f
->buffer_predicate
= Qnil
;
308 f
->buffer_list
= Qnil
;
309 f
->buried_buffer_list
= Qnil
;
312 f
->menu_bar_window
= Qnil
;
313 f
->tool_bar_window
= Qnil
;
314 f
->tool_bar_items
= Qnil
;
315 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
316 f
->n_tool_bar_items
= 0;
317 f
->left_fringe_width
= f
->right_fringe_width
= 0;
319 f
->scroll_bar_actual_width
= 0;
321 f
->internal_border_width
= 0;
322 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
323 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
324 f
->x_pixels_diff
= f
->y_pixels_diff
= 0;
325 #ifdef HAVE_WINDOW_SYSTEM
326 f
->want_fullscreen
= FULLSCREEN_NONE
;
328 f
->size_hint_flags
= 0;
330 f
->font_driver_list
= NULL
;
331 f
->font_data_list
= NULL
;
333 root_window
= make_window ();
336 mini_window
= make_window ();
337 XWINDOW (root_window
)->next
= mini_window
;
338 XWINDOW (mini_window
)->prev
= root_window
;
339 XWINDOW (mini_window
)->mini_p
= Qt
;
340 XWINDOW (mini_window
)->frame
= frame
;
341 f
->minibuffer_window
= mini_window
;
346 XWINDOW (root_window
)->next
= Qnil
;
347 f
->minibuffer_window
= Qnil
;
350 XWINDOW (root_window
)->frame
= frame
;
353 just so that there is "something there."
354 Correct size will be set up later with change_frame_size. */
356 SET_FRAME_COLS (f
, 10);
357 FRAME_LINES (f
) = 10;
359 XSETFASTINT (XWINDOW (root_window
)->total_cols
, 10);
360 XSETFASTINT (XWINDOW (root_window
)->total_lines
, (mini_p
? 9 : 10));
364 XSETFASTINT (XWINDOW (mini_window
)->total_cols
, 10);
365 XSETFASTINT (XWINDOW (mini_window
)->top_line
, 9);
366 XSETFASTINT (XWINDOW (mini_window
)->total_lines
, 1);
369 /* Choose a buffer for the frame's root window. */
373 XWINDOW (root_window
)->buffer
= Qt
;
374 buf
= Fcurrent_buffer ();
375 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
376 a space), try to find another one. */
377 if (SREF (Fbuffer_name (buf
), 0) == ' ')
378 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
380 /* Use set_window_buffer, not Fset_window_buffer, and don't let
381 hooks be run by it. The reason is that the whole frame/window
382 arrangement is not yet fully intialized at this point. Windows
383 don't have the right size, glyph matrices aren't initialized
384 etc. Running Lisp functions at this point surely ends in a
386 set_window_buffer (root_window
, buf
, 0, 0);
387 f
->buffer_list
= Fcons (buf
, Qnil
);
392 XWINDOW (mini_window
)->buffer
= Qt
;
393 set_window_buffer (mini_window
,
394 (NILP (Vminibuffer_list
)
396 : Fcar (Vminibuffer_list
)),
400 f
->root_window
= root_window
;
401 f
->selected_window
= root_window
;
402 /* Make sure this window seems more recently used than
403 a newly-created, never-selected window. */
404 ++window_select_count
;
405 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, window_select_count
);
407 f
->default_face_done_p
= 0;
412 #ifdef HAVE_WINDOW_SYSTEM
413 /* Make a frame using a separate minibuffer window on another frame.
414 MINI_WINDOW is the minibuffer window to use. nil means use the
415 default (the global minibuffer). */
418 make_frame_without_minibuffer (mini_window
, kb
, display
)
419 register Lisp_Object mini_window
;
423 register struct frame
*f
;
426 if (!NILP (mini_window
))
427 CHECK_LIVE_WINDOW (mini_window
);
430 if (!NILP (mini_window
)
431 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
432 error ("Frame and minibuffer must be on the same terminal");
435 /* Make a frame containing just a root window. */
438 if (NILP (mini_window
))
440 /* Use default-minibuffer-frame if possible. */
441 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
442 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
444 Lisp_Object frame_dummy
;
446 XSETFRAME (frame_dummy
, f
);
447 GCPRO1 (frame_dummy
);
448 /* If there's no minibuffer frame to use, create one. */
449 kb
->Vdefault_minibuffer_frame
=
450 call1 (intern ("make-initial-minibuffer-frame"), display
);
454 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
457 f
->minibuffer_window
= mini_window
;
459 /* Make the chosen minibuffer window display the proper minibuffer,
460 unless it is already showing a minibuffer. */
461 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
462 Fset_window_buffer (mini_window
,
463 (NILP (Vminibuffer_list
)
465 : Fcar (Vminibuffer_list
)), Qnil
);
469 /* Make a frame containing only a minibuffer window. */
472 make_minibuffer_frame ()
474 /* First make a frame containing just a root window, no minibuffer. */
476 register struct frame
*f
= make_frame (0);
477 register Lisp_Object mini_window
;
478 register Lisp_Object frame
;
480 XSETFRAME (frame
, f
);
485 f
->wants_modeline
= 0;
486 f
->has_minibuffer
= 1;
488 /* Now label the root window as also being the minibuffer.
489 Avoid infinite looping on the window chain by marking next pointer
492 mini_window
= f
->minibuffer_window
= f
->root_window
;
493 XWINDOW (mini_window
)->mini_p
= Qt
;
494 XWINDOW (mini_window
)->next
= Qnil
;
495 XWINDOW (mini_window
)->prev
= Qnil
;
496 XWINDOW (mini_window
)->frame
= frame
;
498 /* Put the proper buffer in that window. */
500 Fset_window_buffer (mini_window
,
501 (NILP (Vminibuffer_list
)
503 : Fcar (Vminibuffer_list
)), Qnil
);
506 #endif /* HAVE_WINDOW_SYSTEM */
508 /* Construct a frame that refers to a terminal. */
510 static int tty_frame_count
;
513 make_initial_frame (void)
516 struct terminal
*terminal
;
519 eassert (initial_kboard
);
521 /* The first call must initialize Vframe_list. */
522 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
525 terminal
= init_initial_terminal ();
528 XSETFRAME (frame
, f
);
530 Vframe_list
= Fcons (frame
, Vframe_list
);
533 f
->name
= build_string ("F1");
536 f
->async_visible
= 1;
538 f
->output_method
= terminal
->type
;
539 f
->terminal
= terminal
;
540 f
->terminal
->reference_count
++;
541 f
->output_data
.nothing
= 0;
543 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
544 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
546 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
547 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
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. */
575 f
->output_data
.x
= &the_only_x_display
;
576 if (!inhibit_window_system
577 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
578 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
580 f
->output_method
= output_msdos_raw
;
581 /* This initialization of foreground and background pixels is
582 only important for the initial frame created in temacs. If
583 we don't do that, we get black background and foreground in
584 the dumped Emacs because the_only_x_display is a static
585 variable, hence it is born all-zeroes, and zero is the code
586 for the black color. Other frames all inherit their pixels
587 from what's already in the_only_x_display. */
588 if ((!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
589 && FRAME_BACKGROUND_PIXEL (f
) == 0
590 && FRAME_FOREGROUND_PIXEL (f
) == 0)
592 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
593 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
597 f
->output_method
= output_termcap
;
600 f
->output_method
= output_termcap
;
601 f
->terminal
= terminal
;
602 f
->terminal
->reference_count
++;
603 create_tty_output (f
);
605 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
606 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
608 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
609 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
611 /* Set the top frame to the newly created frame. */
612 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
613 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
614 XFRAME (FRAME_TTY (f
)->top_frame
)->async_visible
= 2; /* obscured */
616 FRAME_TTY (f
)->top_frame
= frame
;
620 FRAME_FOREGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_FG_COLOR
;
621 FRAME_BACKGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_BG_COLOR
;
626 init_frame_faces (f
);
631 /* Get a suitable value for frame parameter PARAMETER for a newly
632 created frame, based on (1) the user-supplied frame parameter
633 alist SUPPLIED_PARMS, (2) CURRENT_VALUE, and finally, if all else
634 fails, (3) Vdefault_frame_alist. */
637 get_future_frame_param (Lisp_Object parameter
,
638 Lisp_Object supplied_parms
,
643 result
= Fassq (parameter
, supplied_parms
);
645 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
646 if (NILP (result
) && current_value
!= NULL
)
647 result
= build_string (current_value
);
649 result
= Fassq (parameter
, Vdefault_frame_alist
);
650 if (!NILP (result
) && !STRINGP (result
))
651 result
= XCDR (result
);
652 if (NILP (result
) || !STRINGP (result
))
658 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
660 doc
: /* Create an additional terminal frame, possibly on another terminal.
661 This function takes one argument, an alist specifying frame parameters.
663 You can create multiple frames on a single text-only terminal, but
664 only one of them (the selected terminal frame) is actually displayed.
666 In practice, generally you don't need to specify any parameters,
667 except when you want to create a new frame on another terminal.
668 In that case, the `tty' parameter specifies the device file to open,
669 and the `tty-type' parameter specifies the terminal type. Example:
671 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
673 Note that changing the size of one terminal frame automatically
674 affects all frames on the same terminal device. */)
679 struct terminal
*t
= NULL
;
680 Lisp_Object frame
, tem
;
681 struct frame
*sf
= SELECTED_FRAME ();
684 if (sf
->output_method
!= output_msdos_raw
685 && sf
->output_method
!= output_termcap
)
687 #else /* not MSDOS */
690 /* This can happen for multi-tty when using both terminal frames and
692 if (sf
->output_method
!= output_mac
)
693 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
695 #if 0 /* This should work now! */
696 if (sf
->output_method
!= output_termcap
)
697 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
700 #endif /* not MSDOS */
703 Lisp_Object terminal
;
705 terminal
= Fassq (Qterminal
, parms
);
706 if (!NILP (terminal
))
708 terminal
= XCDR (terminal
);
709 t
= get_terminal (terminal
, 1);
715 char *name
= 0, *type
= 0;
716 Lisp_Object tty
, tty_type
;
718 tty
= get_future_frame_param
719 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
720 ? FRAME_TTY (XFRAME (selected_frame
))->name
724 name
= (char *) alloca (SBYTES (tty
) + 1);
725 strncpy (name
, SDATA (tty
), SBYTES (tty
));
726 name
[SBYTES (tty
)] = 0;
729 tty_type
= get_future_frame_param
730 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
731 ? FRAME_TTY (XFRAME (selected_frame
))->type
733 if (!NILP (tty_type
))
735 type
= (char *) alloca (SBYTES (tty_type
) + 1);
736 strncpy (type
, SDATA (tty_type
), SBYTES (tty_type
));
737 type
[SBYTES (tty_type
)] = 0;
740 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
743 f
= make_terminal_frame (t
);
747 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
748 change_frame_size (f
, height
, width
, 0, 0, 0);
753 XSETFRAME (frame
, f
);
754 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
755 Fmodify_frame_parameters (frame
, parms
);
756 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
757 build_string (t
->display_info
.tty
->type
)),
759 if (t
->display_info
.tty
->name
!= NULL
)
760 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
761 build_string (t
->display_info
.tty
->name
)),
764 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
766 /* Make the frame face alist be frame-specific, so that each
767 frame could change its face definitions independently. */
768 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
769 /* Simple Fcopy_alist isn't enough, because we need the contents of
770 the vectors which are the CDRs of associations in face_alist to
771 be copied as well. */
772 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
773 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
778 /* Perform the switch to frame FRAME.
780 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
783 If TRACK is non-zero and the frame that currently has the focus
784 redirects its focus to the selected frame, redirect that focused
785 frame's focus to FRAME instead.
787 FOR_DELETION non-zero means that the selected frame is being
788 deleted, which includes the possibility that the frame's terminal
792 do_switch_frame (frame
, track
, for_deletion
)
794 int track
, for_deletion
;
796 struct frame
*sf
= SELECTED_FRAME ();
798 /* If FRAME is a switch-frame event, extract the frame we should
801 && EQ (XCAR (frame
), Qswitch_frame
)
802 && CONSP (XCDR (frame
)))
803 frame
= XCAR (XCDR (frame
));
805 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
806 a switch-frame event to arrive after a frame is no longer live,
807 especially when deleting the initial frame during startup. */
809 if (! FRAME_LIVE_P (XFRAME (frame
)))
812 if (sf
== XFRAME (frame
))
815 /* This is too greedy; it causes inappropriate focus redirection
816 that's hard to get rid of. */
818 /* If a frame's focus has been redirected toward the currently
819 selected frame, we should change the redirection to point to the
820 newly selected frame. This means that if the focus is redirected
821 from a minibufferless frame to a surrogate minibuffer frame, we
822 can use `other-window' to switch between all the frames using
823 that minibuffer frame, and the focus redirection will follow us
829 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
833 if (!FRAMEP (XCAR (tail
)))
836 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
838 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
839 Fredirect_frame_focus (XCAR (tail
), frame
);
843 /* Instead, apply it only to the frame we're pointing to. */
844 #ifdef HAVE_WINDOW_SYSTEM
845 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
847 Lisp_Object focus
, xfocus
;
849 xfocus
= x_get_focus_frame (XFRAME (frame
));
852 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
853 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
854 Fredirect_frame_focus (xfocus
, frame
);
857 #endif /* HAVE_X_WINDOWS */
860 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
861 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
863 if (FRAME_TERMCAP_P (XFRAME (frame
)))
865 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
866 /* Mark previously displayed frame as now obscured. */
867 XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
)->async_visible
= 2;
868 XFRAME (frame
)->async_visible
= 1;
869 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
872 selected_frame
= frame
;
873 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
874 last_nonminibuf_frame
= XFRAME (selected_frame
);
876 Fselect_window (XFRAME (frame
)->selected_window
, Qnil
);
878 /* We want to make sure that the next event generates a frame-switch
879 event to the appropriate frame. This seems kludgy to me, but
880 before you take it out, make sure that evaluating something like
881 (select-window (frame-root-window (new-frame))) doesn't end up
882 with your typing being interpreted in the new frame instead of
883 the one you're actually typing in. */
884 internal_last_event_frame
= Qnil
;
889 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 1, "e",
890 doc
: /* Select the frame FRAME.
891 Subsequent editing commands apply to its selected window.
892 The selection of FRAME lasts until the next time the user does
893 something to select a different frame, or until the next time this
894 function is called. If you are using a window system, the previously
895 selected frame may be restored as the selected frame after return to
896 the command loop, because it still may have the window system's input
897 focus. On a text-only terminal, the next redisplay will display FRAME.
899 This function returns FRAME, or nil if FRAME has been deleted. */)
903 return do_switch_frame (frame
, 1, 0);
907 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
908 doc
: /* Handle a switch-frame event EVENT.
909 Switch-frame events are usually bound to this function.
910 A switch-frame event tells Emacs that the window manager has requested
911 that the user's events be directed to the frame mentioned in the event.
912 This function selects the selected window of the frame of EVENT.
914 If EVENT is frame object, handle it as if it were a switch-frame event
919 /* Preserve prefix arg that the command loop just cleared. */
920 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
921 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
922 return do_switch_frame (event
, 0, 0);
925 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
926 doc
: /* Return the frame that is now selected. */)
929 return selected_frame
;
932 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
933 doc
: /* Return the frame object that window WINDOW is on. */)
937 CHECK_LIVE_WINDOW (window
);
938 return XWINDOW (window
)->frame
;
941 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
942 doc
: /* Returns the topmost, leftmost window of FRAME.
943 If omitted, FRAME defaults to the currently selected frame. */)
950 w
= SELECTED_FRAME ()->root_window
;
953 CHECK_LIVE_FRAME (frame
);
954 w
= XFRAME (frame
)->root_window
;
956 while (NILP (XWINDOW (w
)->buffer
))
958 if (! NILP (XWINDOW (w
)->hchild
))
959 w
= XWINDOW (w
)->hchild
;
960 else if (! NILP (XWINDOW (w
)->vchild
))
961 w
= XWINDOW (w
)->vchild
;
968 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
969 Sactive_minibuffer_window
, 0, 0, 0,
970 doc
: /* Return the currently active minibuffer window, or nil if none. */)
973 return minibuf_level
? minibuf_window
: Qnil
;
976 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
977 doc
: /* Returns the root-window of FRAME.
978 If omitted, FRAME defaults to the currently selected frame. */)
985 window
= SELECTED_FRAME ()->root_window
;
988 CHECK_LIVE_FRAME (frame
);
989 window
= XFRAME (frame
)->root_window
;
995 DEFUN ("frame-selected-window", Fframe_selected_window
,
996 Sframe_selected_window
, 0, 1, 0,
997 doc
: /* Return the selected window of frame object FRAME.
998 If omitted, FRAME defaults to the currently selected frame. */)
1005 window
= SELECTED_FRAME ()->selected_window
;
1008 CHECK_LIVE_FRAME (frame
);
1009 window
= XFRAME (frame
)->selected_window
;
1015 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
1016 Sset_frame_selected_window
, 2, 2, 0,
1017 doc
: /* Set the selected window of frame object FRAME to WINDOW.
1019 If FRAME is nil, the selected frame is used.
1020 If FRAME is the selected frame, this makes WINDOW the selected window. */)
1022 Lisp_Object frame
, window
;
1025 frame
= selected_frame
;
1027 CHECK_LIVE_FRAME (frame
);
1028 CHECK_LIVE_WINDOW (window
);
1030 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
1031 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
1033 if (EQ (frame
, selected_frame
))
1034 return Fselect_window (window
, Qnil
);
1036 return XFRAME (frame
)->selected_window
= window
;
1040 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1042 doc
: /* Return a list of all frames. */)
1046 frames
= Fcopy_sequence (Vframe_list
);
1047 #ifdef HAVE_WINDOW_SYSTEM
1048 if (FRAMEP (tip_frame
))
1049 frames
= Fdelq (tip_frame
, frames
);
1054 /* Return the next frame in the frame list after FRAME.
1055 If MINIBUF is nil, exclude minibuffer-only frames.
1056 If MINIBUF is a window, include only its own frame
1057 and any frame now using that window as the minibuffer.
1058 If MINIBUF is `visible', include all visible frames.
1059 If MINIBUF is 0, include all visible and iconified frames.
1060 Otherwise, include all frames. */
1063 next_frame (frame
, minibuf
)
1065 Lisp_Object minibuf
;
1070 /* There must always be at least one frame in Vframe_list. */
1071 if (! CONSP (Vframe_list
))
1074 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
1075 forever. Forestall that. */
1076 CHECK_LIVE_FRAME (frame
);
1079 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1086 && ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1087 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1088 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1089 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
)))))
1091 /* Decide whether this frame is eligible to be returned. */
1093 /* If we've looped all the way around without finding any
1094 eligible frames, return the original frame. */
1098 /* Let minibuf decide if this frame is acceptable. */
1101 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1104 else if (EQ (minibuf
, Qvisible
))
1106 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1107 if (FRAME_VISIBLE_P (XFRAME (f
)))
1110 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
1112 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1113 if (FRAME_VISIBLE_P (XFRAME (f
))
1114 || FRAME_ICONIFIED_P (XFRAME (f
)))
1117 else if (WINDOWP (minibuf
))
1119 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1120 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1121 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1122 FRAME_FOCUS_FRAME (XFRAME (f
))))
1134 /* Return the previous frame in the frame list before FRAME.
1135 If MINIBUF is nil, exclude minibuffer-only frames.
1136 If MINIBUF is a window, include only its own frame
1137 and any frame now using that window as the minibuffer.
1138 If MINIBUF is `visible', include all visible frames.
1139 If MINIBUF is 0, include all visible and iconified frames.
1140 Otherwise, include all frames. */
1143 prev_frame (frame
, minibuf
)
1145 Lisp_Object minibuf
;
1150 /* There must always be at least one frame in Vframe_list. */
1151 if (! CONSP (Vframe_list
))
1155 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1163 if (EQ (frame
, f
) && !NILP (prev
))
1166 if ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1167 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1168 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1169 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
))))
1171 /* Decide whether this frame is eligible to be returned,
1172 according to minibuf. */
1175 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1178 else if (WINDOWP (minibuf
))
1180 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1181 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1182 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1183 FRAME_FOCUS_FRAME (XFRAME (f
))))
1186 else if (EQ (minibuf
, Qvisible
))
1188 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1189 if (FRAME_VISIBLE_P (XFRAME (f
)))
1192 else if (XFASTINT (minibuf
) == 0)
1194 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1195 if (FRAME_VISIBLE_P (XFRAME (f
))
1196 || FRAME_ICONIFIED_P (XFRAME (f
)))
1204 /* We've scanned the entire list. */
1206 /* We went through the whole frame list without finding a single
1207 acceptable frame. Return the original frame. */
1210 /* There were no acceptable frames in the list before FRAME; otherwise,
1211 we would have returned directly from the loop. Since PREV is the last
1212 acceptable frame in the list, return it. */
1217 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1218 doc
: /* Return the next frame in the frame list after FRAME.
1219 It considers only frames on the same terminal as FRAME.
1220 By default, skip minibuffer-only frames.
1221 If omitted, FRAME defaults to the selected frame.
1222 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1223 If MINIFRAME is a window, include only its own frame
1224 and any frame now using that window as the minibuffer.
1225 If MINIFRAME is `visible', include all visible frames.
1226 If MINIFRAME is 0, include all visible and iconified frames.
1227 Otherwise, include all frames. */)
1229 Lisp_Object frame
, miniframe
;
1232 frame
= selected_frame
;
1234 CHECK_LIVE_FRAME (frame
);
1235 return next_frame (frame
, miniframe
);
1238 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1239 doc
: /* Return the previous frame in the frame list before FRAME.
1240 It considers only frames on the same terminal as FRAME.
1241 By default, skip minibuffer-only frames.
1242 If omitted, FRAME defaults to the selected frame.
1243 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1244 If MINIFRAME is a window, include only its own frame
1245 and any frame now using that window as the minibuffer.
1246 If MINIFRAME is `visible', include all visible frames.
1247 If MINIFRAME is 0, include all visible and iconified frames.
1248 Otherwise, include all frames. */)
1250 Lisp_Object frame
, miniframe
;
1253 frame
= selected_frame
;
1254 CHECK_LIVE_FRAME (frame
);
1255 return prev_frame (frame
, miniframe
);
1258 /* Return 1 if it is ok to delete frame F;
1259 0 if all frames aside from F are invisible.
1260 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1263 other_visible_frames (f
)
1266 /* We know the selected frame is visible,
1267 so if F is some other frame, it can't be the sole visible one. */
1268 if (f
== SELECTED_FRAME ())
1273 for (frames
= Vframe_list
;
1275 frames
= XCDR (frames
))
1279 this = XCAR (frames
);
1280 /* Verify that the frame's window still exists
1281 and we can still talk to it. And note any recent change
1283 #ifdef HAVE_WINDOW_SYSTEM
1284 if (FRAME_WINDOW_P (XFRAME (this)))
1286 x_sync (XFRAME (this));
1287 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1291 if (FRAME_VISIBLE_P (XFRAME (this))
1292 || FRAME_ICONIFIED_P (XFRAME (this))
1293 /* Allow deleting the terminal frame when at least
1294 one X frame exists! */
1295 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1303 /* Error handler for `delete-frame-functions'. */
1305 delete_frame_handler (Lisp_Object arg
)
1307 add_to_log ("Error during `delete-frame': %s", arg
, Qnil
);
1311 extern Lisp_Object Qrun_hook_with_args
;
1313 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1314 doc
: /* Delete FRAME, permanently eliminating it from use.
1315 If omitted, FRAME defaults to the selected frame.
1316 A frame may not be deleted if its minibuffer is used by other frames.
1317 Normally, you may not delete a frame if all other frames are invisible,
1318 but if the second optional argument FORCE is non-nil, you may do so.
1320 This function runs `delete-frame-functions' before actually deleting the
1321 frame, unless the frame is a tooltip.
1322 The functions are run with one arg, the frame to be deleted.
1323 But FORCE inhibits this too. */)
1324 /* FORCE is non-nil when handling a disconnected terminal. */
1326 Lisp_Object frame
, force
;
1329 struct frame
*sf
= SELECTED_FRAME ();
1332 int minibuffer_selected
;
1334 if (EQ (frame
, Qnil
))
1337 XSETFRAME (frame
, f
);
1341 CHECK_FRAME (frame
);
1345 if (! FRAME_LIVE_P (f
))
1348 if (NILP (force
) && !other_visible_frames (f
))
1349 error ("Attempt to delete the sole visible or iconified frame");
1352 /* This is a nice idea, but x_connection_closed needs to be able
1353 to delete the last frame, if it is gone. */
1354 if (NILP (XCDR (Vframe_list
)))
1355 error ("Attempt to delete the only frame");
1358 /* Does this frame have a minibuffer, and is it the surrogate
1359 minibuffer for any other frame? */
1360 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1364 for (frames
= Vframe_list
;
1366 frames
= XCDR (frames
))
1369 this = XCAR (frames
);
1371 if (! EQ (this, frame
)
1373 WINDOW_FRAME (XWINDOW
1374 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1376 /* If we MUST delete this frame, delete the other first. */
1378 Fdelete_frame (this, force
);
1380 error ("Attempt to delete a surrogate minibuffer frame");
1385 /* Run `delete-frame-functions'
1386 unless FORCE is `noelisp' or frame is a tooltip.
1387 FORCE is set to `noelisp' when handling a disconnect from the terminal,
1388 so we don't dare call Lisp code. */
1389 if (NILP (Vrun_hooks
) || !NILP (Fframe_parameter (frame
, intern ("tooltip"))))
1391 if (EQ (force
, Qnoelisp
))
1393 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1396 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1398 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1399 if (! FRAME_LIVE_P (f
))
1402 /* At this point, we are committed to deleting the frame.
1403 There is no more chance for errors to prevent it. */
1405 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1407 /* Don't let the frame remain selected. */
1410 Lisp_Object tail
, frame1
;
1412 /* Look for another visible frame on the same terminal. */
1413 frame1
= next_frame (frame
, Qvisible
);
1415 /* If there is none, find *some* other frame. */
1416 if (NILP (frame1
) || EQ (frame1
, frame
))
1418 FOR_EACH_FRAME (tail
, frame1
)
1420 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1425 do_switch_frame (frame1
, 0, 1);
1426 sf
= SELECTED_FRAME ();
1429 /* Don't allow minibuf_window to remain on a deleted frame. */
1430 if (EQ (f
->minibuffer_window
, minibuf_window
))
1432 Fset_window_buffer (sf
->minibuffer_window
,
1433 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1434 minibuf_window
= sf
->minibuffer_window
;
1436 /* If the dying minibuffer window was selected,
1437 select the new one. */
1438 if (minibuffer_selected
)
1439 Fselect_window (minibuf_window
, Qnil
);
1442 /* Don't let echo_area_window to remain on a deleted frame. */
1443 if (EQ (f
->minibuffer_window
, echo_area_window
))
1444 echo_area_window
= sf
->minibuffer_window
;
1446 /* Clear any X selections for this frame. */
1447 #ifdef HAVE_X_WINDOWS
1449 x_clear_frame_selections (f
);
1452 if (FRAME_MAC_P (f
))
1453 x_clear_frame_selections (f
);
1457 This function must be called before the window tree of the
1458 frame is deleted because windows contain dynamically allocated
1462 #ifdef HAVE_WINDOW_SYSTEM
1463 /* Give chance to each font driver to free a frame specific data. */
1464 font_update_drivers (f
, Qnil
);
1467 /* Mark all the windows that used to be on FRAME as deleted, and then
1468 remove the reference to them. */
1469 delete_all_subwindows (XWINDOW (f
->root_window
));
1470 f
->root_window
= Qnil
;
1472 Vframe_list
= Fdelq (frame
, Vframe_list
);
1473 FRAME_SET_VISIBLE (f
, 0);
1477 if (f
->decode_mode_spec_buffer
)
1478 xfree (f
->decode_mode_spec_buffer
);
1479 if (FRAME_INSERT_COST (f
))
1480 xfree (FRAME_INSERT_COST (f
));
1481 if (FRAME_DELETEN_COST (f
))
1482 xfree (FRAME_DELETEN_COST (f
));
1483 if (FRAME_INSERTN_COST (f
))
1484 xfree (FRAME_INSERTN_COST (f
));
1485 if (FRAME_DELETE_COST (f
))
1486 xfree (FRAME_DELETE_COST (f
));
1487 if (FRAME_MESSAGE_BUF (f
))
1488 xfree (FRAME_MESSAGE_BUF (f
));
1490 /* Since some events are handled at the interrupt level, we may get
1491 an event for f at any time; if we zero out the frame's terminal
1492 now, then we may trip up the event-handling code. Instead, we'll
1493 promise that the terminal of the frame must be valid until we
1494 have called the window-system-dependent frame destruction
1497 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1498 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1501 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1502 f
->output_data
.nothing
= 0;
1503 f
->terminal
= 0; /* Now the frame is dead. */
1505 /* If needed, delete the terminal that this frame was on.
1506 (This must be done after the frame is killed.) */
1507 terminal
->reference_count
--;
1508 if (terminal
->reference_count
== 0)
1511 XSETTERMINAL (tmp
, terminal
);
1514 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1518 kb
= terminal
->kboard
;
1522 /* If we've deleted the last_nonminibuf_frame, then try to find
1524 if (f
== last_nonminibuf_frame
)
1528 last_nonminibuf_frame
= 0;
1530 for (frames
= Vframe_list
;
1532 frames
= XCDR (frames
))
1534 f
= XFRAME (XCAR (frames
));
1535 if (!FRAME_MINIBUF_ONLY_P (f
))
1537 last_nonminibuf_frame
= f
;
1543 /* If there's no other frame on the same kboard, get out of
1544 single-kboard state if we're in it for this kboard. */
1548 /* Some frame we found on the same kboard, or nil if there are none. */
1549 Lisp_Object frame_on_same_kboard
;
1551 frame_on_same_kboard
= Qnil
;
1553 for (frames
= Vframe_list
;
1555 frames
= XCDR (frames
))
1560 this = XCAR (frames
);
1565 if (kb
== FRAME_KBOARD (f1
))
1566 frame_on_same_kboard
= this;
1569 if (NILP (frame_on_same_kboard
))
1570 not_single_kboard_state (kb
);
1574 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1575 find another one. Prefer minibuffer-only frames, but also notice
1576 frames with other windows. */
1577 if (kb
!= NULL
&& EQ (frame
, kb
->Vdefault_minibuffer_frame
))
1581 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1582 Lisp_Object frame_with_minibuf
;
1583 /* Some frame we found on the same kboard, or nil if there are none. */
1584 Lisp_Object frame_on_same_kboard
;
1586 frame_on_same_kboard
= Qnil
;
1587 frame_with_minibuf
= Qnil
;
1589 for (frames
= Vframe_list
;
1591 frames
= XCDR (frames
))
1596 this = XCAR (frames
);
1601 /* Consider only frames on the same kboard
1602 and only those with minibuffers. */
1603 if (kb
== FRAME_KBOARD (f1
)
1604 && FRAME_HAS_MINIBUF_P (f1
))
1606 frame_with_minibuf
= this;
1607 if (FRAME_MINIBUF_ONLY_P (f1
))
1611 if (kb
== FRAME_KBOARD (f1
))
1612 frame_on_same_kboard
= this;
1615 if (!NILP (frame_on_same_kboard
))
1617 /* We know that there must be some frame with a minibuffer out
1618 there. If this were not true, all of the frames present
1619 would have to be minibufferless, which implies that at some
1620 point their minibuffer frames must have been deleted, but
1621 that is prohibited at the top; you can't delete surrogate
1622 minibuffer frames. */
1623 if (NILP (frame_with_minibuf
))
1626 kb
->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1629 /* No frames left on this kboard--say no minibuffer either. */
1630 kb
->Vdefault_minibuffer_frame
= Qnil
;
1633 /* Cause frame titles to update--necessary if we now have just one frame. */
1634 update_mode_lines
= 1;
1639 /* Return mouse position in character cell units. */
1641 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1642 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1643 The position is given in character cells, where (0, 0) is the
1644 upper-left corner of the frame, X is the horizontal offset, and Y is
1645 the vertical offset.
1646 If Emacs is running on a mouseless terminal or hasn't been programmed
1647 to read the mouse position, it returns the selected frame for FRAME
1648 and nil for X and Y.
1649 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1650 passing the normal return value to that function as an argument,
1651 and returns whatever that function returns. */)
1655 Lisp_Object lispy_dummy
;
1656 enum scroll_bar_part party_dummy
;
1657 Lisp_Object x
, y
, retval
;
1659 unsigned long long_dummy
;
1660 struct gcpro gcpro1
;
1662 f
= SELECTED_FRAME ();
1665 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1666 /* It's okay for the hook to refrain from storing anything. */
1667 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1668 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1669 &lispy_dummy
, &party_dummy
,
1676 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1681 XSETFRAME (lispy_dummy
, f
);
1682 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1684 if (!NILP (Vmouse_position_function
))
1685 retval
= call1 (Vmouse_position_function
, retval
);
1686 RETURN_UNGCPRO (retval
);
1689 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1690 Smouse_pixel_position
, 0, 0, 0,
1691 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1692 The position is given in pixel units, where (0, 0) is the
1693 upper-left corner of the frame, X is the horizontal offset, and Y is
1694 the vertical offset.
1695 If Emacs is running on a mouseless terminal or hasn't been programmed
1696 to read the mouse position, it returns the selected frame for FRAME
1697 and nil for X and Y. */)
1701 Lisp_Object lispy_dummy
;
1702 enum scroll_bar_part party_dummy
;
1704 unsigned long long_dummy
;
1706 f
= SELECTED_FRAME ();
1709 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1710 /* It's okay for the hook to refrain from storing anything. */
1711 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1712 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1713 &lispy_dummy
, &party_dummy
,
1717 XSETFRAME (lispy_dummy
, f
);
1718 return Fcons (lispy_dummy
, Fcons (x
, y
));
1721 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1722 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1723 Coordinates are relative to the frame, not a window,
1724 so the coordinates of the top left character in the frame
1725 may be nonzero due to left-hand scroll bars or the menu bar.
1727 The position is given in character cells, where (0, 0) is the
1728 upper-left corner of the frame, X is the horizontal offset, and Y is
1729 the vertical offset.
1731 This function is a no-op for an X frame that is not visible.
1732 If you have just created a frame, you must wait for it to become visible
1733 before calling this function on it, like this.
1734 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1736 Lisp_Object frame
, x
, y
;
1738 CHECK_LIVE_FRAME (frame
);
1742 /* I think this should be done with a hook. */
1743 #ifdef HAVE_WINDOW_SYSTEM
1744 if (FRAME_WINDOW_P (XFRAME (frame
)))
1745 /* Warping the mouse will cause enternotify and focus events. */
1746 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1748 #if defined (MSDOS) && defined (HAVE_MOUSE)
1749 if (FRAME_MSDOS_P (XFRAME (frame
)))
1751 Fselect_frame (frame
);
1752 mouse_moveto (XINT (x
), XINT (y
));
1757 Fselect_frame (frame
);
1758 term_mouse_moveto (XINT (x
), XINT (y
));
1767 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1768 Sset_mouse_pixel_position
, 3, 3, 0,
1769 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1770 The position is given in pixels, where (0, 0) is the upper-left corner
1771 of the frame, X is the horizontal offset, and Y is the vertical offset.
1773 Note, this is a no-op for an X frame that is not visible.
1774 If you have just created a frame, you must wait for it to become visible
1775 before calling this function on it, like this.
1776 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1778 Lisp_Object frame
, x
, y
;
1780 CHECK_LIVE_FRAME (frame
);
1784 /* I think this should be done with a hook. */
1785 #ifdef HAVE_WINDOW_SYSTEM
1786 if (FRAME_WINDOW_P (XFRAME (frame
)))
1787 /* Warping the mouse will cause enternotify and focus events. */
1788 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1790 #if defined (MSDOS) && defined (HAVE_MOUSE)
1791 if (FRAME_MSDOS_P (XFRAME (frame
)))
1793 Fselect_frame (frame
);
1794 mouse_moveto (XINT (x
), XINT (y
));
1799 Fselect_frame (frame
);
1800 term_mouse_moveto (XINT (x
), XINT (y
));
1809 static void make_frame_visible_1
P_ ((Lisp_Object
));
1811 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1813 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1814 If omitted, FRAME defaults to the currently selected frame. */)
1819 frame
= selected_frame
;
1821 CHECK_LIVE_FRAME (frame
);
1823 /* I think this should be done with a hook. */
1824 #ifdef HAVE_WINDOW_SYSTEM
1825 if (FRAME_WINDOW_P (XFRAME (frame
)))
1827 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1828 x_make_frame_visible (XFRAME (frame
));
1832 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1834 /* Make menu bar update for the Buffers and Frames menus. */
1835 windows_or_buffers_changed
++;
1840 /* Update the display_time slot of the buffers shown in WINDOW
1841 and all its descendents. */
1844 make_frame_visible_1 (window
)
1849 for (;!NILP (window
); window
= w
->next
)
1851 w
= XWINDOW (window
);
1853 if (!NILP (w
->buffer
))
1854 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1856 if (!NILP (w
->vchild
))
1857 make_frame_visible_1 (w
->vchild
);
1858 if (!NILP (w
->hchild
))
1859 make_frame_visible_1 (w
->hchild
);
1863 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1865 doc
: /* Make the frame FRAME invisible (assuming it is an X window).
1866 If omitted, FRAME defaults to the currently selected frame.
1867 Normally you may not make FRAME invisible if all other frames are invisible,
1868 but if the second optional argument FORCE is non-nil, you may do so. */)
1870 Lisp_Object frame
, force
;
1873 frame
= selected_frame
;
1875 CHECK_LIVE_FRAME (frame
);
1877 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1878 error ("Attempt to make invisible the sole visible or iconified frame");
1880 #if 0 /* This isn't logically necessary, and it can do GC. */
1881 /* Don't let the frame remain selected. */
1882 if (EQ (frame
, selected_frame
))
1883 do_switch_frame (next_frame (frame
, Qt
), 0, 0)
1886 /* Don't allow minibuf_window to remain on a deleted frame. */
1887 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1889 struct frame
*sf
= XFRAME (selected_frame
);
1890 Fset_window_buffer (sf
->minibuffer_window
,
1891 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1892 minibuf_window
= sf
->minibuffer_window
;
1895 /* I think this should be done with a hook. */
1896 #ifdef HAVE_WINDOW_SYSTEM
1897 if (FRAME_WINDOW_P (XFRAME (frame
)))
1898 x_make_frame_invisible (XFRAME (frame
));
1901 /* Make menu bar update for the Buffers and Frames menus. */
1902 windows_or_buffers_changed
++;
1907 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1909 doc
: /* Make the frame FRAME into an icon.
1910 If omitted, FRAME defaults to the currently selected frame. */)
1915 frame
= selected_frame
;
1917 CHECK_LIVE_FRAME (frame
);
1919 #if 0 /* This isn't logically necessary, and it can do GC. */
1920 /* Don't let the frame remain selected. */
1921 if (EQ (frame
, selected_frame
))
1922 Fhandle_switch_frame (next_frame (frame
, Qt
));
1925 /* Don't allow minibuf_window to remain on a deleted frame. */
1926 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1928 struct frame
*sf
= XFRAME (selected_frame
);
1929 Fset_window_buffer (sf
->minibuffer_window
,
1930 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1931 minibuf_window
= sf
->minibuffer_window
;
1934 /* I think this should be done with a hook. */
1935 #ifdef HAVE_WINDOW_SYSTEM
1936 if (FRAME_WINDOW_P (XFRAME (frame
)))
1937 x_iconify_frame (XFRAME (frame
));
1940 /* Make menu bar update for the Buffers and Frames menus. */
1941 windows_or_buffers_changed
++;
1946 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1948 doc
: /* Return t if FRAME is now \"visible\" (actually in use for display).
1949 A frame that is not \"visible\" is not updated and, if it works through
1950 a window system, it may not show at all.
1951 Return the symbol `icon' if frame is visible only as an icon.
1953 On a text-only terminal, all frames are considered visible, whether
1954 they are currently being displayed or not, and this function returns t
1959 CHECK_LIVE_FRAME (frame
);
1961 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1963 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1965 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1970 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1972 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1975 Lisp_Object tail
, frame
;
1980 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1982 frame
= XCAR (tail
);
1983 if (!FRAMEP (frame
))
1986 if (FRAME_VISIBLE_P (f
))
1987 value
= Fcons (frame
, value
);
1993 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1994 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1995 If FRAME is invisible or iconified, make it visible.
1996 If you don't specify a frame, the selected frame is used.
1997 If Emacs is displaying on an ordinary terminal or some other device which
1998 doesn't support multiple overlapping frames, this function does nothing. */)
2004 frame
= selected_frame
;
2006 CHECK_LIVE_FRAME (frame
);
2010 /* Do like the documentation says. */
2011 Fmake_frame_visible (frame
);
2013 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2014 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
2019 /* Should we have a corresponding function called Flower_Power? */
2020 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
2021 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2022 If you don't specify a frame, the selected frame is used.
2023 If Emacs is displaying on an ordinary terminal or some other device which
2024 doesn't support multiple overlapping frames, this function does nothing. */)
2031 frame
= selected_frame
;
2033 CHECK_LIVE_FRAME (frame
);
2037 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2038 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2044 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2046 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2047 In other words, switch-frame events caused by events in FRAME will
2048 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2049 FOCUS-FRAME after reading an event typed at FRAME.
2051 If FOCUS-FRAME is omitted or nil, any existing redirection is
2052 cancelled, and the frame again receives its own keystrokes.
2054 Focus redirection is useful for temporarily redirecting keystrokes to
2055 a surrogate minibuffer frame when a frame doesn't have its own
2058 A frame's focus redirection can be changed by `select-frame'. If frame
2059 FOO is selected, and then a different frame BAR is selected, any
2060 frames redirecting their focus to FOO are shifted to redirect their
2061 focus to BAR. This allows focus redirection to work properly when the
2062 user switches from one frame to another using `select-window'.
2064 This means that a frame whose focus is redirected to itself is treated
2065 differently from a frame whose focus is redirected to nil; the former
2066 is affected by `select-frame', while the latter is not.
2068 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2069 (frame
, focus_frame
)
2070 Lisp_Object frame
, focus_frame
;
2074 /* Note that we don't check for a live frame here. It's reasonable
2075 to redirect the focus of a frame you're about to delete, if you
2076 know what other frame should receive those keystrokes. */
2077 CHECK_FRAME (frame
);
2079 if (! NILP (focus_frame
))
2080 CHECK_LIVE_FRAME (focus_frame
);
2084 f
->focus_frame
= focus_frame
;
2086 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2087 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2093 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
2094 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2095 This returns nil if FRAME's focus is not redirected.
2096 See `redirect-frame-focus'. */)
2100 CHECK_LIVE_FRAME (frame
);
2102 return FRAME_FOCUS_FRAME (XFRAME (frame
));
2107 /* Return the value of frame parameter PROP in frame FRAME. */
2110 get_frame_param (frame
, prop
)
2111 register struct frame
*frame
;
2114 register Lisp_Object tem
;
2116 tem
= Fassq (prop
, frame
->param_alist
);
2122 /* Return the buffer-predicate of the selected frame. */
2125 frame_buffer_predicate (frame
)
2128 return XFRAME (frame
)->buffer_predicate
;
2131 /* Return the buffer-list of the selected frame. */
2134 frame_buffer_list (frame
)
2137 return XFRAME (frame
)->buffer_list
;
2140 /* Set the buffer-list of the selected frame. */
2143 set_frame_buffer_list (frame
, list
)
2144 Lisp_Object frame
, list
;
2146 XFRAME (frame
)->buffer_list
= list
;
2149 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2152 frames_discard_buffer (buffer
)
2155 Lisp_Object frame
, tail
;
2157 FOR_EACH_FRAME (tail
, frame
)
2159 XFRAME (frame
)->buffer_list
2160 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
2161 XFRAME (frame
)->buried_buffer_list
2162 = Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
);
2166 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2167 If the alist already has an element for PROP, we change it. */
2170 store_in_alist (alistptr
, prop
, val
)
2171 Lisp_Object
*alistptr
, val
;
2174 register Lisp_Object tem
;
2176 tem
= Fassq (prop
, *alistptr
);
2178 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2184 frame_name_fnn_p (str
, len
)
2188 if (len
> 1 && str
[0] == 'F')
2192 strtol (str
+ 1, &end_ptr
, 10);
2194 if (end_ptr
== str
+ len
)
2200 /* Set the name of the terminal frame. Also used by MSDOS frames.
2201 Modeled after x_set_name which is used for WINDOW frames. */
2204 set_term_frame_name (f
, name
)
2208 f
->explicit_name
= ! NILP (name
);
2210 /* If NAME is nil, set the name to F<num>. */
2215 /* Check for no change needed in this very common case
2216 before we do any consing. */
2217 if (frame_name_fnn_p (SDATA (f
->name
),
2222 sprintf (namebuf
, "F%d", tty_frame_count
);
2223 name
= build_string (namebuf
);
2227 CHECK_STRING (name
);
2229 /* Don't change the name if it's already NAME. */
2230 if (! NILP (Fstring_equal (name
, f
->name
)))
2233 /* Don't allow the user to set the frame name to F<num>, so it
2234 doesn't clash with the names we generate for terminal frames. */
2235 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
2236 error ("Frame names of the form F<num> are usurped by Emacs");
2240 update_mode_lines
= 1;
2244 store_frame_param (f
, prop
, val
)
2246 Lisp_Object prop
, val
;
2248 register Lisp_Object old_alist_elt
;
2250 /* The buffer-list parameters are stored in a special place and not
2252 if (EQ (prop
, Qbuffer_list
))
2254 f
->buffer_list
= val
;
2257 if (EQ (prop
, Qburied_buffer_list
))
2259 f
->buried_buffer_list
= val
;
2263 /* If PROP is a symbol which is supposed to have frame-local values,
2264 and it is set up based on this frame, switch to the global
2265 binding. That way, we can create or alter the frame-local binding
2266 without messing up the symbol's status. */
2269 Lisp_Object valcontents
;
2270 valcontents
= SYMBOL_VALUE (prop
);
2271 if ((BUFFER_LOCAL_VALUEP (valcontents
))
2272 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
2273 && XBUFFER_LOCAL_VALUE (valcontents
)->found_for_frame
2274 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
2275 swap_in_global_binding (prop
);
2279 /* The tty color needed to be set before the frame's parameter
2280 alist was updated with the new value. This is not true any more,
2281 but we still do this test early on. */
2282 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2283 && f
== FRAME_TTY (f
)->previous_frame
)
2284 /* Force redisplay of this tty. */
2285 FRAME_TTY (f
)->previous_frame
= NULL
;
2288 /* Update the frame parameter alist. */
2289 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2290 if (EQ (old_alist_elt
, Qnil
))
2291 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2293 Fsetcdr (old_alist_elt
, val
);
2295 /* Update some other special parameters in their special places
2296 in addition to the alist. */
2298 if (EQ (prop
, Qbuffer_predicate
))
2299 f
->buffer_predicate
= val
;
2301 if (! FRAME_WINDOW_P (f
))
2303 if (EQ (prop
, Qmenu_bar_lines
))
2304 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2305 else if (EQ (prop
, Qname
))
2306 set_term_frame_name (f
, val
);
2309 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2311 if (! MINI_WINDOW_P (XWINDOW (val
)))
2312 error ("Surrogate minibuffer windows must be minibuffer windows");
2314 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2315 && !EQ (val
, f
->minibuffer_window
))
2316 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2318 /* Install the chosen minibuffer window, with proper buffer. */
2319 f
->minibuffer_window
= val
;
2323 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2324 doc
: /* Return the parameters-alist of frame FRAME.
2325 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2326 The meaningful PARMs depend on the kind of frame.
2327 If FRAME is omitted, return information on the currently selected frame. */)
2334 struct gcpro gcpro1
;
2337 frame
= selected_frame
;
2339 CHECK_FRAME (frame
);
2342 if (!FRAME_LIVE_P (f
))
2345 alist
= Fcopy_alist (f
->param_alist
);
2348 if (!FRAME_WINDOW_P (f
))
2350 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2351 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2354 /* If the frame's parameter alist says the colors are
2355 unspecified and reversed, take the frame's background pixel
2356 for foreground and vice versa. */
2357 elt
= Fassq (Qforeground_color
, alist
);
2358 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2360 if (strncmp (SDATA (XCDR (elt
)),
2362 SCHARS (XCDR (elt
))) == 0)
2363 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2364 else if (strncmp (SDATA (XCDR (elt
)),
2366 SCHARS (XCDR (elt
))) == 0)
2367 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2370 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2371 elt
= Fassq (Qbackground_color
, alist
);
2372 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2374 if (strncmp (SDATA (XCDR (elt
)),
2376 SCHARS (XCDR (elt
))) == 0)
2377 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2378 else if (strncmp (SDATA (XCDR (elt
)),
2380 SCHARS (XCDR (elt
))) == 0)
2381 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2384 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2385 store_in_alist (&alist
, intern ("font"),
2386 build_string (FRAME_MSDOS_P (f
)
2388 : FRAME_W32_P (f
) ? "w32term"
2391 store_in_alist (&alist
, Qname
, f
->name
);
2392 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2393 store_in_alist (&alist
, Qheight
, make_number (height
));
2394 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2395 store_in_alist (&alist
, Qwidth
, make_number (width
));
2396 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2397 store_in_alist (&alist
, Qminibuffer
,
2398 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2399 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2400 : FRAME_MINIBUF_WINDOW (f
)));
2401 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2402 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2403 store_in_alist (&alist
, Qburied_buffer_list
, XFRAME (frame
)->buried_buffer_list
);
2405 /* I think this should be done with a hook. */
2406 #ifdef HAVE_WINDOW_SYSTEM
2407 if (FRAME_WINDOW_P (f
))
2408 x_report_frame_params (f
, &alist
);
2412 /* This ought to be correct in f->param_alist for an X frame. */
2414 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2415 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2423 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2424 doc
: /* Return FRAME's value for parameter PARAMETER.
2425 If FRAME is nil, describe the currently selected frame. */)
2427 Lisp_Object frame
, parameter
;
2433 frame
= selected_frame
;
2435 CHECK_FRAME (frame
);
2436 CHECK_SYMBOL (parameter
);
2441 if (FRAME_LIVE_P (f
))
2443 /* Avoid consing in frequent cases. */
2444 if (EQ (parameter
, Qname
))
2446 #ifdef HAVE_X_WINDOWS
2447 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2448 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2449 #endif /* HAVE_X_WINDOWS */
2450 else if (EQ (parameter
, Qbackground_color
)
2451 || EQ (parameter
, Qforeground_color
))
2453 value
= Fassq (parameter
, f
->param_alist
);
2456 value
= XCDR (value
);
2457 /* Fframe_parameters puts the actual fg/bg color names,
2458 even if f->param_alist says otherwise. This is
2459 important when param_alist's notion of colors is
2460 "unspecified". We need to do the same here. */
2461 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2463 const char *color_name
;
2466 if (EQ (parameter
, Qbackground_color
))
2468 color_name
= SDATA (value
);
2469 csz
= SCHARS (value
);
2470 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2471 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2472 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2473 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2475 else if (EQ (parameter
, Qforeground_color
))
2477 color_name
= SDATA (value
);
2478 csz
= SCHARS (value
);
2479 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2480 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2481 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2482 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2487 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2489 else if (EQ (parameter
, Qdisplay_type
)
2490 || EQ (parameter
, Qbackground_mode
))
2491 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2493 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2500 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2501 Smodify_frame_parameters
, 2, 2, 0,
2502 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2503 If FRAME is nil, it defaults to the selected frame.
2504 ALIST is an alist of parameters to change and their new values.
2505 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2506 The meaningful PARMs depend on the kind of frame.
2507 Undefined PARMs are ignored, but stored in the frame's parameter list
2508 so that `frame-parameters' will return them.
2510 The value of frame parameter FOO can also be accessed
2511 as a frame-local binding for the variable FOO, if you have
2512 enabled such bindings for that variable with `make-variable-frame-local'. */)
2514 Lisp_Object frame
, alist
;
2517 register Lisp_Object tail
, prop
, val
;
2519 if (EQ (frame
, Qnil
))
2520 frame
= selected_frame
;
2521 CHECK_LIVE_FRAME (frame
);
2524 /* I think this should be done with a hook. */
2525 #ifdef HAVE_WINDOW_SYSTEM
2526 if (FRAME_WINDOW_P (f
))
2527 x_set_frame_parameters (f
, alist
);
2531 if (FRAME_MSDOS_P (f
))
2532 IT_set_frame_parameters (f
, alist
);
2537 int length
= XINT (Flength (alist
));
2540 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2542 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2544 /* Extract parm names and values into those vectors. */
2547 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2552 parms
[i
] = Fcar (elt
);
2553 values
[i
] = Fcdr (elt
);
2557 /* Now process them in reverse of specified order. */
2558 for (i
--; i
>= 0; i
--)
2562 store_frame_param (f
, prop
, val
);
2564 /* Changing the background color might change the background
2565 mode, so that we have to load new defface specs.
2566 Call frame-set-background-mode to do that. */
2567 if (EQ (prop
, Qbackground_color
))
2568 call1 (Qframe_set_background_mode
, frame
);
2574 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2576 doc
: /* Height in pixels of a line in the font in frame FRAME.
2577 If FRAME is omitted, the selected frame is used.
2578 For a terminal frame, the value is always 1. */)
2585 frame
= selected_frame
;
2586 CHECK_FRAME (frame
);
2589 #ifdef HAVE_WINDOW_SYSTEM
2590 if (FRAME_WINDOW_P (f
))
2591 return make_number (x_char_height (f
));
2594 return make_number (1);
2598 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2600 doc
: /* Width in pixels of characters in the font in frame FRAME.
2601 If FRAME is omitted, the selected frame is used.
2602 On a graphical screen, the width is the standard width of the default font.
2603 For a terminal screen, the value is always 1. */)
2610 frame
= selected_frame
;
2611 CHECK_FRAME (frame
);
2614 #ifdef HAVE_WINDOW_SYSTEM
2615 if (FRAME_WINDOW_P (f
))
2616 return make_number (x_char_width (f
));
2619 return make_number (1);
2622 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2623 Sframe_pixel_height
, 0, 1, 0,
2624 doc
: /* Return a FRAME's height in pixels.
2625 This counts only the height available for text lines,
2626 not menu bars on window-system Emacs frames.
2627 For a terminal frame, the result really gives the height in characters.
2628 If FRAME is omitted, the selected frame is used. */)
2635 frame
= selected_frame
;
2636 CHECK_FRAME (frame
);
2639 #ifdef HAVE_WINDOW_SYSTEM
2640 if (FRAME_WINDOW_P (f
))
2641 return make_number (x_pixel_height (f
));
2644 return make_number (FRAME_LINES (f
));
2647 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2648 Sframe_pixel_width
, 0, 1, 0,
2649 doc
: /* Return FRAME's width in pixels.
2650 For a terminal frame, the result really gives the width in characters.
2651 If FRAME is omitted, the selected frame is used. */)
2658 frame
= selected_frame
;
2659 CHECK_FRAME (frame
);
2662 #ifdef HAVE_WINDOW_SYSTEM
2663 if (FRAME_WINDOW_P (f
))
2664 return make_number (x_pixel_width (f
));
2667 return make_number (FRAME_COLS (f
));
2670 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2671 doc
: /* Specify that the frame FRAME has LINES lines.
2672 Optional third arg non-nil means that redisplay should use LINES lines
2673 but that the idea of the actual height of the frame should not be changed. */)
2674 (frame
, lines
, pretend
)
2675 Lisp_Object frame
, lines
, pretend
;
2677 register struct frame
*f
;
2679 CHECK_NUMBER (lines
);
2681 frame
= selected_frame
;
2682 CHECK_LIVE_FRAME (frame
);
2685 /* I think this should be done with a hook. */
2686 #ifdef HAVE_WINDOW_SYSTEM
2687 if (FRAME_WINDOW_P (f
))
2689 if (XINT (lines
) != FRAME_LINES (f
))
2690 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2691 do_pending_window_change (0);
2695 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2699 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2700 doc
: /* Specify that the frame FRAME has COLS columns.
2701 Optional third arg non-nil means that redisplay should use COLS columns
2702 but that the idea of the actual width of the frame should not be changed. */)
2703 (frame
, cols
, pretend
)
2704 Lisp_Object frame
, cols
, pretend
;
2706 register struct frame
*f
;
2707 CHECK_NUMBER (cols
);
2709 frame
= selected_frame
;
2710 CHECK_LIVE_FRAME (frame
);
2713 /* I think this should be done with a hook. */
2714 #ifdef HAVE_WINDOW_SYSTEM
2715 if (FRAME_WINDOW_P (f
))
2717 if (XINT (cols
) != FRAME_COLS (f
))
2718 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2719 do_pending_window_change (0);
2723 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2727 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2728 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2730 Lisp_Object frame
, cols
, rows
;
2732 register struct frame
*f
;
2734 CHECK_LIVE_FRAME (frame
);
2735 CHECK_NUMBER (cols
);
2736 CHECK_NUMBER (rows
);
2739 /* I think this should be done with a hook. */
2740 #ifdef HAVE_WINDOW_SYSTEM
2741 if (FRAME_WINDOW_P (f
))
2743 if (XINT (rows
) != FRAME_LINES (f
)
2744 || XINT (cols
) != FRAME_COLS (f
)
2745 || f
->new_text_lines
|| f
->new_text_cols
)
2746 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2747 do_pending_window_change (0);
2751 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2756 DEFUN ("set-frame-position", Fset_frame_position
,
2757 Sset_frame_position
, 3, 3, 0,
2758 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2759 This is actually the position of the upper left corner of the frame.
2760 Negative values for XOFFSET or YOFFSET are interpreted relative to
2761 the rightmost or bottommost possible position (that stays within the screen). */)
2762 (frame
, xoffset
, yoffset
)
2763 Lisp_Object frame
, xoffset
, yoffset
;
2765 register struct frame
*f
;
2767 CHECK_LIVE_FRAME (frame
);
2768 CHECK_NUMBER (xoffset
);
2769 CHECK_NUMBER (yoffset
);
2772 /* I think this should be done with a hook. */
2773 #ifdef HAVE_WINDOW_SYSTEM
2774 if (FRAME_WINDOW_P (f
))
2775 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2782 /***********************************************************************
2784 ***********************************************************************/
2786 /* Connect the frame-parameter names for X frames
2787 to the ways of passing the parameter values to the window system.
2789 The name of a parameter, as a Lisp symbol,
2790 has an `x-frame-parameter' property which is an integer in Lisp
2791 that is an index in this table. */
2793 struct frame_parm_table
{
2795 Lisp_Object
*variable
;
2798 static struct frame_parm_table frame_parms
[] =
2800 {"auto-raise", &Qauto_raise
},
2801 {"auto-lower", &Qauto_lower
},
2802 {"background-color", 0},
2803 {"border-color", &Qborder_color
},
2804 {"border-width", &Qborder_width
},
2805 {"cursor-color", &Qcursor_color
},
2806 {"cursor-type", &Qcursor_type
},
2808 {"foreground-color", 0},
2809 {"icon-name", &Qicon_name
},
2810 {"icon-type", &Qicon_type
},
2811 {"internal-border-width", &Qinternal_border_width
},
2812 {"menu-bar-lines", &Qmenu_bar_lines
},
2813 {"mouse-color", &Qmouse_color
},
2815 {"scroll-bar-width", &Qscroll_bar_width
},
2817 {"unsplittable", &Qunsplittable
},
2818 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2819 {"visibility", &Qvisibility
},
2820 {"tool-bar-lines", &Qtool_bar_lines
},
2821 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2822 {"scroll-bar-background", &Qscroll_bar_background
},
2823 {"screen-gamma", &Qscreen_gamma
},
2824 {"line-spacing", &Qline_spacing
},
2825 {"left-fringe", &Qleft_fringe
},
2826 {"right-fringe", &Qright_fringe
},
2827 {"wait-for-wm", &Qwait_for_wm
},
2828 {"fullscreen", &Qfullscreen
},
2829 {"font-backend", &Qfont_backend
}
2832 #ifdef HAVE_WINDOW_SYSTEM
2834 extern Lisp_Object Qbox
;
2835 extern Lisp_Object Qtop
;
2837 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2838 wanted positions of the WM window (not Emacs window).
2839 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2840 window (FRAME_X_WINDOW).
2844 x_fullscreen_adjust (f
, width
, height
, top_pos
, left_pos
)
2851 int newwidth
= FRAME_COLS (f
);
2852 int newheight
= FRAME_LINES (f
);
2854 *top_pos
= f
->top_pos
;
2855 *left_pos
= f
->left_pos
;
2857 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2861 ph
= FRAME_X_DISPLAY_INFO (f
)->height
;
2862 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2863 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2864 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2868 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2872 pw
= FRAME_X_DISPLAY_INFO (f
)->width
;
2873 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2874 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2875 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2880 *height
= newheight
;
2884 /* Change the parameters of frame F as specified by ALIST.
2885 If a parameter is not specially recognized, do nothing special;
2886 otherwise call the `x_set_...' function for that parameter.
2887 Except for certain geometry properties, always call store_frame_param
2888 to store the new value in the parameter alist. */
2891 x_set_frame_parameters (f
, alist
)
2897 /* If both of these parameters are present, it's more efficient to
2898 set them both at once. So we wait until we've looked at the
2899 entire list before we set them. */
2903 Lisp_Object left
, top
;
2905 /* Same with these. */
2906 Lisp_Object icon_left
, icon_top
;
2908 /* Record in these vectors all the parms specified. */
2910 Lisp_Object
*values
;
2912 int left_no_change
= 0, top_no_change
= 0;
2913 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2914 int fullscreen_is_being_set
= 0;
2916 struct gcpro gcpro1
, gcpro2
;
2919 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2922 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2923 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2925 /* Extract parm names and values into those vectors. */
2928 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2933 parms
[i
] = Fcar (elt
);
2934 values
[i
] = Fcdr (elt
);
2937 /* TAIL and ALIST are not used again below here. */
2938 alist
= tail
= Qnil
;
2940 GCPRO2 (*parms
, *values
);
2944 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2945 because their values appear in VALUES and strings are not valid. */
2946 top
= left
= Qunbound
;
2947 icon_left
= icon_top
= Qunbound
;
2949 /* Provide default values for HEIGHT and WIDTH. */
2950 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2951 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2953 /* Process foreground_color and background_color before anything else.
2954 They are independent of other properties, but other properties (e.g.,
2955 cursor_color) are dependent upon them. */
2956 /* Process default font as well, since fringe widths depends on it. */
2957 /* Also, process fullscreen, width and height depend upon that */
2958 for (p
= 0; p
< i
; p
++)
2960 Lisp_Object prop
, val
;
2964 if (EQ (prop
, Qforeground_color
)
2965 || EQ (prop
, Qbackground_color
)
2967 || EQ (prop
, Qfullscreen
))
2969 register Lisp_Object param_index
, old_value
;
2970 int count
= SPECPDL_INDEX ();
2972 old_value
= get_frame_param (f
, prop
);
2973 fullscreen_is_being_set
|= EQ (prop
, Qfullscreen
);
2975 if (NILP (Fequal (val
, old_value
)))
2977 /* For :font attributes, the frame_parm_handler
2978 x_set_font calls `face-set-after-frame-default'.
2979 Unless we bind inhibit-face-set-after-frame-default
2980 here, this would reset the :font attribute that we
2981 just applied to the default value for new faces. */
2982 specbind (Qinhibit_face_set_after_frame_default
, Qt
);
2984 store_frame_param (f
, prop
, val
);
2986 param_index
= Fget (prop
, Qx_frame_parameter
);
2987 if (NATNUMP (param_index
)
2988 && (XFASTINT (param_index
)
2989 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2990 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2991 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2992 unbind_to (count
, Qnil
);
2997 /* Now process them in reverse of specified order. */
2998 for (i
--; i
>= 0; i
--)
3000 Lisp_Object prop
, val
;
3005 if (EQ (prop
, Qwidth
) && NATNUMP (val
))
3006 width
= XFASTINT (val
);
3007 else if (EQ (prop
, Qheight
) && NATNUMP (val
))
3008 height
= XFASTINT (val
);
3009 else if (EQ (prop
, Qtop
))
3011 else if (EQ (prop
, Qleft
))
3013 else if (EQ (prop
, Qicon_top
))
3015 else if (EQ (prop
, Qicon_left
))
3017 else if (EQ (prop
, Qforeground_color
)
3018 || EQ (prop
, Qbackground_color
)
3020 || EQ (prop
, Qfullscreen
))
3021 /* Processed above. */
3025 register Lisp_Object param_index
, old_value
;
3027 old_value
= get_frame_param (f
, prop
);
3029 store_frame_param (f
, prop
, val
);
3031 param_index
= Fget (prop
, Qx_frame_parameter
);
3032 if (NATNUMP (param_index
)
3033 && (XFASTINT (param_index
)
3034 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3035 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3036 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3040 /* Don't die if just one of these was set. */
3041 if (EQ (left
, Qunbound
))
3044 if (f
->left_pos
< 0)
3045 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
3047 XSETINT (left
, f
->left_pos
);
3049 if (EQ (top
, Qunbound
))
3053 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
3055 XSETINT (top
, f
->top_pos
);
3058 /* If one of the icon positions was not set, preserve or default it. */
3059 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
3061 icon_left_no_change
= 1;
3062 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3063 if (NILP (icon_left
))
3064 XSETINT (icon_left
, 0);
3066 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
3068 icon_top_no_change
= 1;
3069 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3070 if (NILP (icon_top
))
3071 XSETINT (icon_top
, 0);
3074 if (FRAME_VISIBLE_P (f
) && fullscreen_is_being_set
)
3076 /* If the frame is visible already and the fullscreen parameter is
3077 being set, it is too late to set WM manager hints to specify
3079 Here we first get the width, height and position that applies to
3080 fullscreen. We then move the frame to the appropriate
3081 position. Resize of the frame is taken care of in the code after
3082 this if-statement. */
3083 int new_left
, new_top
;
3085 x_fullscreen_adjust (f
, &width
, &height
, &new_top
, &new_left
);
3086 if (new_top
!= f
->top_pos
|| new_left
!= f
->left_pos
)
3087 x_set_offset (f
, new_left
, new_top
, 1);
3090 /* Don't set these parameters unless they've been explicitly
3091 specified. The window might be mapped or resized while we're in
3092 this function, and we don't want to override that unless the lisp
3093 code has asked for it.
3095 Don't set these parameters unless they actually differ from the
3096 window's current parameters; the window may not actually exist
3101 check_frame_size (f
, &height
, &width
);
3103 XSETFRAME (frame
, f
);
3105 if (width
!= FRAME_COLS (f
)
3106 || height
!= FRAME_LINES (f
)
3107 || f
->new_text_lines
|| f
->new_text_cols
)
3108 Fset_frame_size (frame
, make_number (width
), make_number (height
));
3110 if ((!NILP (left
) || !NILP (top
))
3111 && ! (left_no_change
&& top_no_change
)
3112 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3113 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3118 /* Record the signs. */
3119 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3120 if (EQ (left
, Qminus
))
3121 f
->size_hint_flags
|= XNegative
;
3122 else if (INTEGERP (left
))
3124 leftpos
= XINT (left
);
3126 f
->size_hint_flags
|= XNegative
;
3128 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3129 && CONSP (XCDR (left
))
3130 && INTEGERP (XCAR (XCDR (left
))))
3132 leftpos
= - XINT (XCAR (XCDR (left
)));
3133 f
->size_hint_flags
|= XNegative
;
3135 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3136 && CONSP (XCDR (left
))
3137 && INTEGERP (XCAR (XCDR (left
))))
3139 leftpos
= XINT (XCAR (XCDR (left
)));
3142 if (EQ (top
, Qminus
))
3143 f
->size_hint_flags
|= YNegative
;
3144 else if (INTEGERP (top
))
3146 toppos
= XINT (top
);
3148 f
->size_hint_flags
|= YNegative
;
3150 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3151 && CONSP (XCDR (top
))
3152 && INTEGERP (XCAR (XCDR (top
))))
3154 toppos
= - XINT (XCAR (XCDR (top
)));
3155 f
->size_hint_flags
|= YNegative
;
3157 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
3158 && CONSP (XCDR (top
))
3159 && INTEGERP (XCAR (XCDR (top
))))
3161 toppos
= XINT (XCAR (XCDR (top
)));
3165 /* Store the numeric value of the position. */
3166 f
->top_pos
= toppos
;
3167 f
->left_pos
= leftpos
;
3169 f
->win_gravity
= NorthWestGravity
;
3171 /* Actually set that position, and convert to absolute. */
3172 x_set_offset (f
, leftpos
, toppos
, -1);
3175 if ((!NILP (icon_left
) || !NILP (icon_top
))
3176 && ! (icon_left_no_change
&& icon_top_no_change
))
3177 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3184 /* Insert a description of internally-recorded parameters of frame X
3185 into the parameter alist *ALISTPTR that is to be given to the user.
3186 Only parameters that are specific to the X window system
3187 and whose values are not correctly recorded in the frame's
3188 param_alist need to be considered here. */
3191 x_report_frame_params (f
, alistptr
)
3193 Lisp_Object
*alistptr
;
3198 /* Represent negative positions (off the top or left screen edge)
3199 in a way that Fmodify_frame_parameters will understand correctly. */
3200 XSETINT (tem
, f
->left_pos
);
3201 if (f
->left_pos
>= 0)
3202 store_in_alist (alistptr
, Qleft
, tem
);
3204 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3206 XSETINT (tem
, f
->top_pos
);
3207 if (f
->top_pos
>= 0)
3208 store_in_alist (alistptr
, Qtop
, tem
);
3210 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3212 store_in_alist (alistptr
, Qborder_width
,
3213 make_number (f
->border_width
));
3214 store_in_alist (alistptr
, Qinternal_border_width
,
3215 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3216 store_in_alist (alistptr
, Qleft_fringe
,
3217 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3218 store_in_alist (alistptr
, Qright_fringe
,
3219 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3220 store_in_alist (alistptr
, Qscroll_bar_width
,
3221 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3223 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3224 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3225 /* nil means "use default width"
3226 for non-toolkit scroll bar.
3227 ruler-mode.el depends on this. */
3229 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
3230 store_in_alist (alistptr
, Qwindow_id
,
3231 build_string (buf
));
3232 #ifdef HAVE_X_WINDOWS
3233 #ifdef USE_X_TOOLKIT
3234 /* Tooltip frame may not have this widget. */
3235 if (FRAME_X_OUTPUT (f
)->widget
)
3237 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
3238 store_in_alist (alistptr
, Qouter_window_id
,
3239 build_string (buf
));
3241 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3242 FRAME_SAMPLE_VISIBILITY (f
);
3243 store_in_alist (alistptr
, Qvisibility
,
3244 (FRAME_VISIBLE_P (f
) ? Qt
3245 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3246 store_in_alist (alistptr
, Qdisplay
,
3247 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3249 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3252 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3253 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3254 store_in_alist (alistptr
, Qparent_id
, tem
);
3258 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3259 the previous value of that parameter, NEW_VALUE is the new value. */
3262 x_set_fullscreen (f
, new_value
, old_value
)
3264 Lisp_Object new_value
, old_value
;
3266 if (NILP (new_value
))
3267 f
->want_fullscreen
= FULLSCREEN_NONE
;
3268 else if (EQ (new_value
, Qfullboth
))
3269 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3270 else if (EQ (new_value
, Qfullwidth
))
3271 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3272 else if (EQ (new_value
, Qfullheight
))
3273 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3275 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3276 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3280 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3281 the previous value of that parameter, NEW_VALUE is the new value. */
3284 x_set_line_spacing (f
, new_value
, old_value
)
3286 Lisp_Object new_value
, old_value
;
3288 if (NILP (new_value
))
3289 f
->extra_line_spacing
= 0;
3290 else if (NATNUMP (new_value
))
3291 f
->extra_line_spacing
= XFASTINT (new_value
);
3293 signal_error ("Invalid line-spacing", new_value
);
3294 if (FRAME_VISIBLE_P (f
))
3299 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3300 the previous value of that parameter, NEW_VALUE is the new value. */
3303 x_set_screen_gamma (f
, new_value
, old_value
)
3305 Lisp_Object new_value
, old_value
;
3307 Lisp_Object bgcolor
;
3309 if (NILP (new_value
))
3311 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3312 /* The value 0.4545 is the normal viewing gamma. */
3313 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3315 signal_error ("Invalid screen-gamma", new_value
);
3317 /* Apply the new gamma value to the frame background. */
3318 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3319 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3321 Lisp_Object index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3323 && (XFASTINT (index
)
3324 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3325 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3326 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3330 Fclear_face_cache (Qnil
);
3335 x_set_font (f
, arg
, oldval
)
3337 Lisp_Object arg
, oldval
;
3341 Lisp_Object font_object
;
3343 /* Set the frame parameter back to the old value because we mail
3344 fail to use ARG as the new parameter value. */
3345 store_frame_param (f
, Qfont
, oldval
);
3347 /* ARG is a fontset name, a font name, or a font object.
3348 In the last case, this function never fail. */
3351 fontset
= fs_query_fontset (arg
, 0);
3354 font_object
= font_open_by_name (f
, SDATA (arg
));
3355 if (NILP (font_object
))
3356 error ("Font `%s' is not defined", SDATA (arg
));
3357 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3359 else if (fontset
> 0)
3361 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3363 font_object
= font_open_by_name (f
, SDATA (ascii_font
));
3364 if (NILP (font_object
))
3365 error ("Font `%s' is not defined", SDATA (arg
));
3366 arg
= fontset_name (fontset
);
3369 error ("The default fontset can't be used for a frame font");
3371 else if (FONT_OBJECT_P (arg
))
3374 /* This is store the XLFD font name in the frame parameter for
3375 backward compatiblity. We should store the font-object
3376 itself in the future. */
3377 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3380 signal_error ("Invalid font", arg
);
3382 if (! NILP (Fequal (font_object
, oldval
)))
3384 x_new_font (f
, font_object
, fontset
);
3385 store_frame_param (f
, Qfont
, arg
);
3386 /* Recalculate toolbar height. */
3387 f
->n_tool_bar_rows
= 0;
3388 /* Ensure we redraw it. */
3389 clear_current_matrices (f
);
3391 recompute_basic_faces (f
);
3393 do_pending_window_change (0);
3395 /* Don't call `face-set-after-frame-default' when faces haven't been
3396 initialized yet. This is the case when called from
3397 Fx_create_frame. In that case, the X widget or window doesn't
3398 exist either, and we can end up in x_report_frame_params with a
3399 null widget which gives a segfault. */
3400 if (FRAME_FACE_CACHE (f
))
3402 XSETFRAME (frame
, f
);
3403 call1 (Qface_set_after_frame_default
, frame
);
3409 x_set_font_backend (f
, new_value
, old_value
)
3411 Lisp_Object new_value
, old_value
;
3413 if (! NILP (new_value
)
3414 && !CONSP (new_value
))
3418 CHECK_STRING (new_value
);
3419 p0
= p1
= SDATA (new_value
);
3423 while (*p1
&& *p1
!= ',') p1
++;
3425 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3431 new_value
= Fnreverse (new_value
);
3434 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3438 free_all_realized_faces (Qnil
);
3440 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3441 if (NILP (new_value
))
3443 if (NILP (old_value
))
3444 error ("No font backend available");
3445 font_update_drivers (f
, old_value
);
3446 error ("None of specified font backends are available");
3448 store_frame_param (f
, Qfont_backend
, new_value
);
3454 XSETFRAME (frame
, f
);
3455 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3456 ++face_change_count
;
3457 ++windows_or_buffers_changed
;
3463 x_set_fringe_width (f
, new_value
, old_value
)
3465 Lisp_Object new_value
, old_value
;
3467 compute_fringe_widths (f
, 1);
3471 x_set_border_width (f
, arg
, oldval
)
3473 Lisp_Object arg
, oldval
;
3477 if (XINT (arg
) == f
->border_width
)
3480 if (FRAME_X_WINDOW (f
) != 0)
3481 error ("Cannot change the border width of a frame");
3483 f
->border_width
= XINT (arg
);
3487 x_set_internal_border_width (f
, arg
, oldval
)
3489 Lisp_Object arg
, oldval
;
3491 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3494 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3495 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3496 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3498 #ifdef USE_X_TOOLKIT
3499 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3500 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3503 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3506 if (FRAME_X_WINDOW (f
) != 0)
3508 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3509 SET_FRAME_GARBAGED (f
);
3510 do_pending_window_change (0);
3513 SET_FRAME_GARBAGED (f
);
3517 x_set_visibility (f
, value
, oldval
)
3519 Lisp_Object value
, oldval
;
3522 XSETFRAME (frame
, f
);
3525 Fmake_frame_invisible (frame
, Qt
);
3526 else if (EQ (value
, Qicon
))
3527 Ficonify_frame (frame
);
3529 Fmake_frame_visible (frame
);
3533 x_set_autoraise (f
, arg
, oldval
)
3535 Lisp_Object arg
, oldval
;
3537 f
->auto_raise
= !EQ (Qnil
, arg
);
3541 x_set_autolower (f
, arg
, oldval
)
3543 Lisp_Object arg
, oldval
;
3545 f
->auto_lower
= !EQ (Qnil
, arg
);
3549 x_set_unsplittable (f
, arg
, oldval
)
3551 Lisp_Object arg
, oldval
;
3553 f
->no_split
= !NILP (arg
);
3557 x_set_vertical_scroll_bars (f
, arg
, oldval
)
3559 Lisp_Object arg
, oldval
;
3561 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3562 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3563 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3564 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3566 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3568 ? vertical_scroll_bar_none
3570 ? vertical_scroll_bar_left
3572 ? vertical_scroll_bar_right
3573 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3574 ? vertical_scroll_bar_left
3575 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3576 ? vertical_scroll_bar_right
3577 : vertical_scroll_bar_none
);
3579 /* We set this parameter before creating the X window for the
3580 frame, so we can get the geometry right from the start.
3581 However, if the window hasn't been created yet, we shouldn't
3582 call x_set_window_size. */
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);
3590 x_set_scroll_bar_width (f
, arg
, oldval
)
3592 Lisp_Object arg
, oldval
;
3594 int wid
= FRAME_COLUMN_WIDTH (f
);
3598 x_set_scroll_bar_default_width (f
);
3600 if (FRAME_X_WINDOW (f
))
3601 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3602 do_pending_window_change (0);
3604 else if (INTEGERP (arg
) && XINT (arg
) > 0
3605 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3607 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3608 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3610 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3611 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3612 if (FRAME_X_WINDOW (f
))
3613 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3614 do_pending_window_change (0);
3617 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3618 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3619 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3624 /* Return non-nil if frame F wants a bitmap icon. */
3632 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3640 /* Subroutines of creating an X frame. */
3642 /* Make sure that Vx_resource_name is set to a reasonable value.
3643 Fix it up, or set it to `emacs' if it is too hopeless. */
3646 validate_x_resource_name ()
3649 /* Number of valid characters in the resource name. */
3651 /* Number of invalid characters in the resource name. */
3656 if (!STRINGP (Vx_resource_class
))
3657 Vx_resource_class
= build_string (EMACS_CLASS
);
3659 if (STRINGP (Vx_resource_name
))
3661 unsigned char *p
= SDATA (Vx_resource_name
);
3664 len
= SBYTES (Vx_resource_name
);
3666 /* Only letters, digits, - and _ are valid in resource names.
3667 Count the valid characters and count the invalid ones. */
3668 for (i
= 0; i
< len
; i
++)
3671 if (! ((c
>= 'a' && c
<= 'z')
3672 || (c
>= 'A' && c
<= 'Z')
3673 || (c
>= '0' && c
<= '9')
3674 || c
== '-' || c
== '_'))
3681 /* Not a string => completely invalid. */
3682 bad_count
= 5, good_count
= 0;
3684 /* If name is valid already, return. */
3688 /* If name is entirely invalid, or nearly so, use `emacs'. */
3690 || (good_count
== 1 && bad_count
> 0))
3692 Vx_resource_name
= build_string ("emacs");
3696 /* Name is partly valid. Copy it and replace the invalid characters
3697 with underscores. */
3699 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3701 for (i
= 0; i
< len
; i
++)
3703 int c
= SREF (new, i
);
3704 if (! ((c
>= 'a' && c
<= 'z')
3705 || (c
>= 'A' && c
<= 'Z')
3706 || (c
>= '0' && c
<= '9')
3707 || c
== '-' || c
== '_'))
3713 extern char *x_get_string_resource
P_ ((XrmDatabase
, char *, char *));
3714 extern Display_Info
*check_x_display_info
P_ ((Lisp_Object
));
3717 /* Get specified attribute from resource database RDB.
3718 See Fx_get_resource below for other parameters. */
3721 xrdb_get_resource (rdb
, attribute
, class, component
, subclass
)
3723 Lisp_Object attribute
, class, component
, subclass
;
3725 register char *value
;
3729 CHECK_STRING (attribute
);
3730 CHECK_STRING (class);
3732 if (!NILP (component
))
3733 CHECK_STRING (component
);
3734 if (!NILP (subclass
))
3735 CHECK_STRING (subclass
);
3736 if (NILP (component
) != NILP (subclass
))
3737 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3739 validate_x_resource_name ();
3741 /* Allocate space for the components, the dots which separate them,
3742 and the final '\0'. Make them big enough for the worst case. */
3743 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3744 + (STRINGP (component
)
3745 ? SBYTES (component
) : 0)
3746 + SBYTES (attribute
)
3749 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3751 + (STRINGP (subclass
)
3752 ? SBYTES (subclass
) : 0)
3755 /* Start with emacs.FRAMENAME for the name (the specific one)
3756 and with `Emacs' for the class key (the general one). */
3757 strcpy (name_key
, SDATA (Vx_resource_name
));
3758 strcpy (class_key
, SDATA (Vx_resource_class
));
3760 strcat (class_key
, ".");
3761 strcat (class_key
, SDATA (class));
3763 if (!NILP (component
))
3765 strcat (class_key
, ".");
3766 strcat (class_key
, SDATA (subclass
));
3768 strcat (name_key
, ".");
3769 strcat (name_key
, SDATA (component
));
3772 strcat (name_key
, ".");
3773 strcat (name_key
, SDATA (attribute
));
3775 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3777 if (value
!= (char *) 0)
3778 return build_string (value
);
3784 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3785 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3786 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3787 class, where INSTANCE is the name under which Emacs was invoked, or
3788 the name specified by the `-name' or `-rn' command-line arguments.
3790 The optional arguments COMPONENT and SUBCLASS add to the key and the
3791 class, respectively. You must specify both of them or neither.
3792 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3793 and the class is `Emacs.CLASS.SUBCLASS'. */)
3794 (attribute
, class, component
, subclass
)
3795 Lisp_Object attribute
, class, component
, subclass
;
3797 #ifdef HAVE_X_WINDOWS
3801 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3802 attribute
, class, component
, subclass
);
3805 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3808 display_x_get_resource (dpyinfo
, attribute
, class, component
, subclass
)
3809 Display_Info
*dpyinfo
;
3810 Lisp_Object attribute
, class, component
, subclass
;
3812 return xrdb_get_resource (dpyinfo
->xrdb
,
3813 attribute
, class, component
, subclass
);
3816 /* Used when C code wants a resource value. */
3819 x_get_resource_string (attribute
, class)
3820 char *attribute
, *class;
3824 struct frame
*sf
= SELECTED_FRAME ();
3826 /* Allocate space for the components, the dots which separate them,
3827 and the final '\0'. */
3828 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3829 + strlen (attribute
) + 2);
3830 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3831 + strlen (class) + 2);
3833 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3834 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3836 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3837 name_key
, class_key
);
3841 /* Return the value of parameter PARAM.
3843 First search ALIST, then Vdefault_frame_alist, then the X defaults
3844 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3846 Convert the resource to the type specified by desired_type.
3848 If no default is specified, return Qunbound. If you call
3849 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3850 and don't let it get stored in any Lisp-visible variables! */
3853 x_get_arg (dpyinfo
, alist
, param
, attribute
, class, type
)
3854 Display_Info
*dpyinfo
;
3855 Lisp_Object alist
, param
;
3858 enum resource_types type
;
3860 register Lisp_Object tem
;
3862 tem
= Fassq (param
, alist
);
3866 /* If we find this parm in ALIST, clear it out
3867 so that it won't be "left over" at the end. */
3868 #ifndef WINDOWSNT /* w32fns.c has not yet been changed to cope with this. */
3870 XSETCAR (tem
, Qnil
);
3871 /* In case the parameter appears more than once in the alist,
3873 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3874 if (CONSP (XCAR (tail
))
3875 && EQ (XCAR (XCAR (tail
)), param
))
3876 XSETCAR (XCAR (tail
), Qnil
);
3880 tem
= Fassq (param
, Vdefault_frame_alist
);
3882 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3883 look in the X resources. */
3888 tem
= display_x_get_resource (dpyinfo
,
3889 build_string (attribute
),
3890 build_string (class),
3898 case RES_TYPE_NUMBER
:
3899 return make_number (atoi (SDATA (tem
)));
3901 case RES_TYPE_FLOAT
:
3902 return make_float (atof (SDATA (tem
)));
3904 case RES_TYPE_BOOLEAN
:
3905 tem
= Fdowncase (tem
);
3906 if (!strcmp (SDATA (tem
), "on")
3907 || !strcmp (SDATA (tem
), "true"))
3912 case RES_TYPE_STRING
:
3915 case RES_TYPE_SYMBOL
:
3916 /* As a special case, we map the values `true' and `on'
3917 to Qt, and `false' and `off' to Qnil. */
3920 lower
= Fdowncase (tem
);
3921 if (!strcmp (SDATA (lower
), "on")
3922 || !strcmp (SDATA (lower
), "true"))
3924 else if (!strcmp (SDATA (lower
), "off")
3925 || !strcmp (SDATA (lower
), "false"))
3928 return Fintern (tem
, Qnil
);
3942 x_frame_get_arg (f
, alist
, param
, attribute
, class, type
)
3944 Lisp_Object alist
, param
;
3947 enum resource_types type
;
3949 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3950 alist
, param
, attribute
, class, type
);
3953 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3956 x_frame_get_and_record_arg (f
, alist
, param
, attribute
, class, type
)
3958 Lisp_Object alist
, param
;
3961 enum resource_types type
;
3965 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3966 attribute
, class, type
);
3967 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3968 store_frame_param (f
, param
, value
);
3974 /* Record in frame F the specified or default value according to ALIST
3975 of the parameter named PROP (a Lisp symbol).
3976 If no value is specified for PROP, look for an X default for XPROP
3977 on the frame named NAME.
3978 If that is not found either, use the value DEFLT. */
3981 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
3988 enum resource_types type
;
3992 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3993 if (EQ (tem
, Qunbound
))
3995 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
4002 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4003 doc
: /* Parse an X-style geometry string STRING.
4004 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4005 The properties returned may include `top', `left', `height', and `width'.
4006 The value of `left' or `top' may be an integer,
4007 or a list (+ N) meaning N pixels relative to top/left corner,
4008 or a list (- N) meaning -N pixels relative to bottom/right corner. */)
4013 unsigned int width
, height
;
4016 CHECK_STRING (string
);
4018 geometry
= XParseGeometry ((char *) SDATA (string
),
4019 &x
, &y
, &width
, &height
);
4022 if (!!(geometry
& XValue
) != !!(geometry
& YValue
))
4023 error ("Must specify both x and y position, or neither");
4027 if (geometry
& XValue
)
4029 Lisp_Object element
;
4031 if (x
>= 0 && (geometry
& XNegative
))
4032 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
4033 else if (x
< 0 && ! (geometry
& XNegative
))
4034 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
4036 element
= Fcons (Qleft
, make_number (x
));
4037 result
= Fcons (element
, result
);
4040 if (geometry
& YValue
)
4042 Lisp_Object element
;
4044 if (y
>= 0 && (geometry
& YNegative
))
4045 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
4046 else if (y
< 0 && ! (geometry
& YNegative
))
4047 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
4049 element
= Fcons (Qtop
, make_number (y
));
4050 result
= Fcons (element
, result
);
4053 if (geometry
& WidthValue
)
4054 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
4055 if (geometry
& HeightValue
)
4056 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
4061 /* Calculate the desired size and position of frame F.
4062 Return the flags saying which aspects were specified.
4064 Also set the win_gravity and size_hint_flags of F.
4066 Adjust height for toolbar if TOOLBAR_P is 1.
4068 This function does not make the coordinates positive. */
4070 #define DEFAULT_ROWS 40
4071 #define DEFAULT_COLS 80
4074 x_figure_window_size (f
, parms
, toolbar_p
)
4079 register Lisp_Object tem0
, tem1
, tem2
;
4080 long window_prompting
= 0;
4081 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
4083 /* Default values if we fall through.
4084 Actually, if that happens we should get
4085 window manager prompting. */
4086 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4087 FRAME_LINES (f
) = DEFAULT_ROWS
;
4088 /* Window managers expect that if program-specified
4089 positions are not (0,0), they're intentional, not defaults. */
4093 /* Ensure that old new_text_cols and new_text_lines will not override the
4095 /* ++KFS: This was specific to W32, but seems ok for all platforms */
4096 f
->new_text_cols
= f
->new_text_lines
= 0;
4098 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4099 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4100 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4101 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4103 if (!EQ (tem0
, Qunbound
))
4105 CHECK_NUMBER (tem0
);
4106 FRAME_LINES (f
) = XINT (tem0
);
4108 if (!EQ (tem1
, Qunbound
))
4110 CHECK_NUMBER (tem1
);
4111 SET_FRAME_COLS (f
, XINT (tem1
));
4113 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4114 window_prompting
|= USSize
;
4116 window_prompting
|= PSize
;
4119 f
->scroll_bar_actual_width
4120 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4122 /* This used to be done _before_ calling x_figure_window_size, but
4123 since the height is reset here, this was really a no-op. I
4124 assume that moving it here does what Gerd intended (although he
4125 no longer can remember what that was... ++KFS, 2003-03-25. */
4127 /* Add the tool-bar height to the initial frame height so that the
4128 user gets a text display area of the size he specified with -g or
4129 via .Xdefaults. Later changes of the tool-bar height don't
4130 change the frame size. This is done so that users can create
4131 tall Emacs frames without having to guess how tall the tool-bar
4133 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4135 int margin
, relief
, bar_height
;
4137 relief
= (tool_bar_button_relief
>= 0
4138 ? tool_bar_button_relief
4139 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4141 if (INTEGERP (Vtool_bar_button_margin
)
4142 && XINT (Vtool_bar_button_margin
) > 0)
4143 margin
= XFASTINT (Vtool_bar_button_margin
);
4144 else if (CONSP (Vtool_bar_button_margin
)
4145 && INTEGERP (XCDR (Vtool_bar_button_margin
))
4146 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
4147 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4151 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4152 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4155 compute_fringe_widths (f
, 0);
4157 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4158 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4160 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4161 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4162 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4163 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4165 if (EQ (tem0
, Qminus
))
4168 window_prompting
|= YNegative
;
4170 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4171 && CONSP (XCDR (tem0
))
4172 && INTEGERP (XCAR (XCDR (tem0
))))
4174 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4175 window_prompting
|= YNegative
;
4177 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4178 && CONSP (XCDR (tem0
))
4179 && INTEGERP (XCAR (XCDR (tem0
))))
4181 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4183 else if (EQ (tem0
, Qunbound
))
4187 CHECK_NUMBER (tem0
);
4188 f
->top_pos
= XINT (tem0
);
4190 window_prompting
|= YNegative
;
4193 if (EQ (tem1
, Qminus
))
4196 window_prompting
|= XNegative
;
4198 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4199 && CONSP (XCDR (tem1
))
4200 && INTEGERP (XCAR (XCDR (tem1
))))
4202 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4203 window_prompting
|= XNegative
;
4205 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4206 && CONSP (XCDR (tem1
))
4207 && INTEGERP (XCAR (XCDR (tem1
))))
4209 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4211 else if (EQ (tem1
, Qunbound
))
4215 CHECK_NUMBER (tem1
);
4216 f
->left_pos
= XINT (tem1
);
4217 if (f
->left_pos
< 0)
4218 window_prompting
|= XNegative
;
4221 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4222 window_prompting
|= USPosition
;
4224 window_prompting
|= PPosition
;
4227 if (f
->want_fullscreen
!= FULLSCREEN_NONE
)
4232 /* It takes both for some WM:s to place it where we want */
4233 window_prompting
|= USPosition
| PPosition
;
4234 x_fullscreen_adjust (f
, &width
, &height
, &top
, &left
);
4235 FRAME_COLS (f
) = width
;
4236 FRAME_LINES (f
) = height
;
4237 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, width
);
4238 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, height
);
4243 if (window_prompting
& XNegative
)
4245 if (window_prompting
& YNegative
)
4246 f
->win_gravity
= SouthEastGravity
;
4248 f
->win_gravity
= NorthEastGravity
;
4252 if (window_prompting
& YNegative
)
4253 f
->win_gravity
= SouthWestGravity
;
4255 f
->win_gravity
= NorthWestGravity
;
4258 f
->size_hint_flags
= window_prompting
;
4260 return window_prompting
;
4265 #endif /* HAVE_WINDOW_SYSTEM */
4269 /***********************************************************************
4271 ***********************************************************************/
4276 Qframep
= intern ("framep");
4277 staticpro (&Qframep
);
4278 Qframe_live_p
= intern ("frame-live-p");
4279 staticpro (&Qframe_live_p
);
4280 Qexplicit_name
= intern ("explicit-name");
4281 staticpro (&Qexplicit_name
);
4282 Qheight
= intern ("height");
4283 staticpro (&Qheight
);
4284 Qicon
= intern ("icon");
4286 Qminibuffer
= intern ("minibuffer");
4287 staticpro (&Qminibuffer
);
4288 Qmodeline
= intern ("modeline");
4289 staticpro (&Qmodeline
);
4290 Qonly
= intern ("only");
4292 Qwidth
= intern ("width");
4293 staticpro (&Qwidth
);
4294 Qgeometry
= intern ("geometry");
4295 staticpro (&Qgeometry
);
4296 Qicon_left
= intern ("icon-left");
4297 staticpro (&Qicon_left
);
4298 Qicon_top
= intern ("icon-top");
4299 staticpro (&Qicon_top
);
4300 Qleft
= intern ("left");
4302 Qright
= intern ("right");
4303 staticpro (&Qright
);
4304 Quser_position
= intern ("user-position");
4305 staticpro (&Quser_position
);
4306 Quser_size
= intern ("user-size");
4307 staticpro (&Quser_size
);
4308 Qwindow_id
= intern ("window-id");
4309 staticpro (&Qwindow_id
);
4310 #ifdef HAVE_X_WINDOWS
4311 Qouter_window_id
= intern ("outer-window-id");
4312 staticpro (&Qouter_window_id
);
4314 Qparent_id
= intern ("parent-id");
4315 staticpro (&Qparent_id
);
4318 Qw32
= intern ("w32");
4320 Qpc
= intern ("pc");
4322 Qmac
= intern ("mac");
4324 Qvisible
= intern ("visible");
4325 staticpro (&Qvisible
);
4326 Qbuffer_predicate
= intern ("buffer-predicate");
4327 staticpro (&Qbuffer_predicate
);
4328 Qbuffer_list
= intern ("buffer-list");
4329 staticpro (&Qbuffer_list
);
4330 Qburied_buffer_list
= intern ("buried-buffer-list");
4331 staticpro (&Qburied_buffer_list
);
4332 Qdisplay_type
= intern ("display-type");
4333 staticpro (&Qdisplay_type
);
4334 Qbackground_mode
= intern ("background-mode");
4335 staticpro (&Qbackground_mode
);
4336 Qnoelisp
= intern ("noelisp");
4337 staticpro (&Qnoelisp
);
4338 Qtty_color_mode
= intern ("tty-color-mode");
4339 staticpro (&Qtty_color_mode
);
4340 Qtty
= intern ("tty");
4342 Qtty_type
= intern ("tty-type");
4343 staticpro (&Qtty_type
);
4345 Qface_set_after_frame_default
= intern ("face-set-after-frame-default");
4346 staticpro (&Qface_set_after_frame_default
);
4348 Qinhibit_face_set_after_frame_default
4349 = intern ("inhibit-face-set-after-frame-default");
4350 staticpro (&Qinhibit_face_set_after_frame_default
);
4352 Qfullwidth
= intern ("fullwidth");
4353 staticpro (&Qfullwidth
);
4354 Qfullheight
= intern ("fullheight");
4355 staticpro (&Qfullheight
);
4356 Qfullboth
= intern ("fullboth");
4357 staticpro (&Qfullboth
);
4358 Qx_resource_name
= intern ("x-resource-name");
4359 staticpro (&Qx_resource_name
);
4361 Qx_frame_parameter
= intern ("x-frame-parameter");
4362 staticpro (&Qx_frame_parameter
);
4364 Qterminal
= intern ("terminal");
4365 staticpro (&Qterminal
);
4366 Qterminal_live_p
= intern ("terminal-live-p");
4367 staticpro (&Qterminal_live_p
);
4372 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4374 Lisp_Object v
= intern (frame_parms
[i
].name
);
4375 if (frame_parms
[i
].variable
)
4377 *frame_parms
[i
].variable
= v
;
4378 staticpro (frame_parms
[i
].variable
);
4380 Fput (v
, Qx_frame_parameter
, make_number (i
));
4384 #ifdef HAVE_WINDOW_SYSTEM
4385 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4386 doc
: /* The name Emacs uses to look up X resources.
4387 `x-get-resource' uses this as the first component of the instance name
4388 when requesting resource values.
4389 Emacs initially sets `x-resource-name' to the name under which Emacs
4390 was invoked, or to the value specified with the `-name' or `-rn'
4391 switches, if present.
4393 It may be useful to bind this variable locally around a call
4394 to `x-get-resource'. See also the variable `x-resource-class'. */);
4395 Vx_resource_name
= Qnil
;
4397 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4398 doc
: /* The class Emacs uses to look up X resources.
4399 `x-get-resource' uses this as the first component of the instance class
4400 when requesting resource values.
4402 Emacs initially sets `x-resource-class' to "Emacs".
4404 Setting this variable permanently is not a reasonable thing to do,
4405 but binding this variable locally around a call to `x-get-resource'
4406 is a reasonable practice. See also the variable `x-resource-name'. */);
4407 Vx_resource_class
= build_string (EMACS_CLASS
);
4410 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4411 doc
: /* Alist of default values for frame creation.
4412 These may be set in your init file, like this:
4413 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4414 These override values given in window system configuration data,
4415 including X Windows' defaults database.
4416 For values specific to the first Emacs frame, see `initial-frame-alist'.
4417 For window-system specific values, see `window-system-default-frame-alist'.
4418 For values specific to the separate minibuffer frame, see
4419 `minibuffer-frame-alist'.
4420 The `menu-bar-lines' element of the list controls whether new frames
4421 have menu bars; `menu-bar-mode' works by altering this element.
4422 Setting this variable does not affect existing frames, only new ones. */);
4423 Vdefault_frame_alist
= Qnil
;
4425 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars
,
4426 doc
: /* Default position of scroll bars on this window-system. */);
4427 #ifdef HAVE_WINDOW_SYSTEM
4428 #if defined(HAVE_NTGUI) || defined(MAC_OS)
4429 /* MS-Windows has scroll bars on the right by default. */
4430 Vdefault_frame_scroll_bars
= Qright
;
4432 Vdefault_frame_scroll_bars
= Qleft
;
4435 Vdefault_frame_scroll_bars
= Qnil
;
4438 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4439 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4441 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
4442 doc
: /* Non-nil if all of Emacs is iconified and frame updates are not needed. */);
4443 Vemacs_iconified
= Qnil
;
4445 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4446 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4447 `mouse-position' calls this function, passing its usual return value as
4448 argument, and returns whatever this function returns.
4449 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4450 which need to do mouse handling at the Lisp level. */);
4451 Vmouse_position_function
= Qnil
;
4453 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4454 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4455 If the value is an integer, highlighting is only shown after moving the
4456 mouse, while keyboard input turns off the highlight even when the mouse
4457 is over the clickable text. However, the mouse shape still indicates
4458 when the mouse is over clickable text. */);
4459 Vmouse_highlight
= Qt
;
4461 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4462 doc
: /* Functions to be run before deleting a frame.
4463 The functions are run with one arg, the frame to be deleted.
4466 Note that functions in this list may be called just before the frame is
4467 actually deleted, or some time later (or even both when an earlier function
4468 in `delete-frame-functions' (indirectly) calls `delete-frame'
4470 Vdelete_frame_functions
= Qnil
;
4471 Qdelete_frame_functions
= intern ("delete-frame-functions");
4472 staticpro (&Qdelete_frame_functions
);
4474 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4475 doc
: /* Minibufferless frames use this frame's minibuffer.
4477 Emacs cannot create minibufferless frames unless this is set to an
4478 appropriate surrogate.
4480 Emacs consults this variable only when creating minibufferless
4481 frames; once the frame is created, it sticks with its assigned
4482 minibuffer, no matter what this variable is set to. This means that
4483 this variable doesn't necessarily say anything meaningful about the
4484 current set of frames, or where the minibuffer is currently being
4487 This variable is local to the current terminal and cannot be buffer-local. */);
4489 DEFVAR_BOOL ("focus-follows-mouse", &focus_follows_mouse
,
4490 doc
: /* Non-nil if window system changes focus when you move the mouse.
4491 You should set this variable to tell Emacs how your window manager
4492 handles focus, since there is no way in general for Emacs to find out
4494 #ifdef HAVE_WINDOW_SYSTEM
4495 #if defined(HAVE_NTGUI) || defined(MAC_OS)
4496 focus_follows_mouse
= 0;
4498 focus_follows_mouse
= 1;
4501 focus_follows_mouse
= 0;
4504 staticpro (&Vframe_list
);
4506 defsubr (&Sactive_minibuffer_window
);
4508 defsubr (&Sframe_live_p
);
4509 defsubr (&Swindow_system
);
4510 defsubr (&Smake_terminal_frame
);
4511 defsubr (&Shandle_switch_frame
);
4512 defsubr (&Sselect_frame
);
4513 defsubr (&Sselected_frame
);
4514 defsubr (&Swindow_frame
);
4515 defsubr (&Sframe_root_window
);
4516 defsubr (&Sframe_first_window
);
4517 defsubr (&Sframe_selected_window
);
4518 defsubr (&Sset_frame_selected_window
);
4519 defsubr (&Sframe_list
);
4520 defsubr (&Snext_frame
);
4521 defsubr (&Sprevious_frame
);
4522 defsubr (&Sdelete_frame
);
4523 defsubr (&Smouse_position
);
4524 defsubr (&Smouse_pixel_position
);
4525 defsubr (&Sset_mouse_position
);
4526 defsubr (&Sset_mouse_pixel_position
);
4528 defsubr (&Sframe_configuration
);
4529 defsubr (&Srestore_frame_configuration
);
4531 defsubr (&Smake_frame_visible
);
4532 defsubr (&Smake_frame_invisible
);
4533 defsubr (&Siconify_frame
);
4534 defsubr (&Sframe_visible_p
);
4535 defsubr (&Svisible_frame_list
);
4536 defsubr (&Sraise_frame
);
4537 defsubr (&Slower_frame
);
4538 defsubr (&Sredirect_frame_focus
);
4539 defsubr (&Sframe_focus
);
4540 defsubr (&Sframe_parameters
);
4541 defsubr (&Sframe_parameter
);
4542 defsubr (&Smodify_frame_parameters
);
4543 defsubr (&Sframe_char_height
);
4544 defsubr (&Sframe_char_width
);
4545 defsubr (&Sframe_pixel_height
);
4546 defsubr (&Sframe_pixel_width
);
4547 defsubr (&Sset_frame_height
);
4548 defsubr (&Sset_frame_width
);
4549 defsubr (&Sset_frame_size
);
4550 defsubr (&Sset_frame_position
);
4552 #ifdef HAVE_WINDOW_SYSTEM
4553 defsubr (&Sx_get_resource
);
4554 defsubr (&Sx_parse_geometry
);
4559 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4560 (do not change this comment) */