1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26 #include "character.h"
37 /* These help us bind and responding to switch-frame events. */
41 #include "blockinput.h"
43 #include "termhooks.h"
44 #include "dispextern.h"
47 #ifdef HAVE_WINDOW_SYSTEM
56 /* If we shall make pointer invisible when typing or not. */
57 Lisp_Object Vmake_pointer_invisible
;
59 #ifdef HAVE_WINDOW_SYSTEM
61 /* The name we're using in resource queries. Most often "emacs". */
63 Lisp_Object Vx_resource_name
;
65 /* The application class we're using in resource queries.
68 Lisp_Object Vx_resource_class
;
70 /* Lower limit value of the frame opacity (alpha transparency). */
72 Lisp_Object Vframe_alpha_lower_limit
;
77 Lisp_Object Qns_parse_geometry
;
80 Lisp_Object Qframep
, Qframe_live_p
;
81 Lisp_Object Qicon
, Qmodeline
;
83 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
, Qns
;
85 Lisp_Object Qdisplay_type
;
86 Lisp_Object Qbackground_mode
;
89 Lisp_Object Qx_frame_parameter
;
90 Lisp_Object Qx_resource_name
;
91 Lisp_Object Qterminal
;
92 Lisp_Object Qterminal_live_p
;
94 /* Frame parameters (set or reported). */
96 Lisp_Object Qauto_raise
, Qauto_lower
;
97 Lisp_Object Qborder_color
, Qborder_width
;
98 Lisp_Object Qcursor_color
, Qcursor_type
;
99 Lisp_Object Qgeometry
; /* Not used */
100 Lisp_Object Qheight
, Qwidth
;
101 Lisp_Object Qleft
, Qright
;
102 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
103 Lisp_Object Qinternal_border_width
;
104 Lisp_Object Qmouse_color
;
105 Lisp_Object Qminibuffer
;
106 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
107 Lisp_Object Qvisibility
;
108 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
109 Lisp_Object Qscreen_gamma
;
110 Lisp_Object Qline_spacing
;
111 Lisp_Object Quser_position
, Quser_size
;
112 Lisp_Object Qwait_for_wm
;
113 Lisp_Object Qwindow_id
;
114 #ifdef HAVE_X_WINDOWS
115 Lisp_Object Qouter_window_id
;
117 Lisp_Object Qparent_id
;
118 Lisp_Object Qtitle
, Qname
;
119 Lisp_Object Qexplicit_name
;
120 Lisp_Object Qunsplittable
;
121 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
122 Lisp_Object Qleft_fringe
, Qright_fringe
;
123 Lisp_Object Qbuffer_predicate
, Qbuffer_list
, Qburied_buffer_list
;
124 Lisp_Object Qtty_color_mode
;
125 Lisp_Object Qtty
, Qtty_type
;
127 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
129 Lisp_Object Qfont_backend
;
132 Lisp_Object Qface_set_after_frame_default
;
134 Lisp_Object Vterminal_frame
;
135 Lisp_Object Vdefault_frame_alist
;
136 Lisp_Object Vdefault_frame_scroll_bars
;
137 Lisp_Object Vmouse_position_function
;
138 Lisp_Object Vmouse_highlight
;
139 static Lisp_Object Vdelete_frame_functions
, Qdelete_frame_functions
;
141 int focus_follows_mouse
;
144 set_menu_bar_lines_1 (window
, n
)
148 struct window
*w
= XWINDOW (window
);
150 XSETFASTINT (w
->last_modified
, 0);
151 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
152 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
154 if (INTEGERP (w
->orig_top_line
))
155 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
156 if (INTEGERP (w
->orig_total_lines
))
157 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
159 /* Handle just the top child in a vertical split. */
160 if (!NILP (w
->vchild
))
161 set_menu_bar_lines_1 (w
->vchild
, n
);
163 /* Adjust all children in a horizontal split. */
164 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
166 w
= XWINDOW (window
);
167 set_menu_bar_lines_1 (window
, n
);
172 set_menu_bar_lines (f
, value
, oldval
)
174 Lisp_Object value
, oldval
;
177 int olines
= FRAME_MENU_BAR_LINES (f
);
179 /* Right now, menu bars don't work properly in minibuf-only frames;
180 most of the commands try to apply themselves to the minibuffer
181 frame itself, and get an error because you can't switch buffers
182 in or split the minibuffer window. */
183 if (FRAME_MINIBUF_ONLY_P (f
))
186 if (INTEGERP (value
))
187 nlines
= XINT (value
);
191 if (nlines
!= olines
)
193 windows_or_buffers_changed
++;
194 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
195 FRAME_MENU_BAR_LINES (f
) = nlines
;
196 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
201 Lisp_Object Vframe_list
;
203 extern Lisp_Object Vminibuffer_list
;
204 extern Lisp_Object
get_minibuffer ();
205 extern Lisp_Object
Fhandle_switch_frame ();
206 extern Lisp_Object
Fredirect_frame_focus ();
207 extern Lisp_Object
x_get_focus_frame ();
208 extern Lisp_Object QCname
, Qfont_param
;
211 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
212 doc
: /* Return non-nil if OBJECT is a frame.
213 Value is t for a termcap frame (a character-only terminal),
214 `x' for an Emacs frame that is really an X window,
215 `w32' for an Emacs frame that is a window on MS-Windows display,
216 `ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
217 `pc' for a direct-write MS-DOS frame.
218 See also `frame-live-p'. */)
222 if (!FRAMEP (object
))
224 switch (XFRAME (object
)->output_method
)
226 case output_initial
: /* The initial frame is like a termcap frame. */
229 case output_x_window
:
233 case output_msdos_raw
:
244 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
245 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
246 Value is nil if OBJECT is not a live frame. If object is a live
247 frame, the return value indicates what sort of terminal device it is
248 displayed on. See the documentation of `framep' for possible
253 return ((FRAMEP (object
)
254 && FRAME_LIVE_P (XFRAME (object
)))
259 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
260 doc
: /* The name of the window system that FRAME is displaying through.
261 The value is a symbol---for instance, 'x' for X windows.
262 The value is nil if Emacs is using a text-only terminal.
264 FRAME defaults to the currently selected frame. */)
270 frame
= selected_frame
;
272 type
= Fframep (frame
);
275 wrong_type_argument (Qframep
, frame
);
288 register struct frame
*f
;
289 register Lisp_Object root_window
;
290 register Lisp_Object mini_window
;
292 f
= allocate_frame ();
293 XSETFRAME (frame
, f
);
295 f
->desired_matrix
= 0;
296 f
->current_matrix
= 0;
299 f
->glyphs_initialized_p
= 0;
300 f
->decode_mode_spec_buffer
= 0;
302 f
->async_visible
= 0;
303 f
->output_data
.nothing
= 0;
305 f
->async_iconified
= 0;
306 f
->wants_modeline
= 1;
311 f
->has_minibuffer
= mini_p
;
312 f
->focus_frame
= Qnil
;
313 f
->explicit_name
= 0;
314 f
->can_have_scroll_bars
= 0;
315 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
316 f
->param_alist
= Qnil
;
317 f
->scroll_bars
= Qnil
;
318 f
->condemned_scroll_bars
= Qnil
;
319 f
->face_alist
= Qnil
;
320 f
->face_cache
= NULL
;
321 f
->menu_bar_items
= Qnil
;
322 f
->menu_bar_vector
= Qnil
;
323 f
->menu_bar_items_used
= 0;
324 f
->buffer_predicate
= Qnil
;
325 f
->buffer_list
= Qnil
;
326 f
->buried_buffer_list
= Qnil
;
329 f
->menu_bar_window
= Qnil
;
330 f
->tool_bar_window
= Qnil
;
331 f
->tool_bar_items
= Qnil
;
332 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
333 f
->n_tool_bar_items
= 0;
334 f
->left_fringe_width
= f
->right_fringe_width
= 0;
336 f
->scroll_bar_actual_width
= 0;
338 f
->internal_border_width
= 0;
339 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
340 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
341 f
->x_pixels_diff
= f
->y_pixels_diff
= 0;
342 #ifdef HAVE_WINDOW_SYSTEM
343 f
->want_fullscreen
= FULLSCREEN_NONE
;
345 f
->size_hint_flags
= 0;
347 f
->font_driver_list
= NULL
;
348 f
->font_data_list
= NULL
;
350 root_window
= make_window ();
353 mini_window
= make_window ();
354 XWINDOW (root_window
)->next
= mini_window
;
355 XWINDOW (mini_window
)->prev
= root_window
;
356 XWINDOW (mini_window
)->mini_p
= Qt
;
357 XWINDOW (mini_window
)->frame
= frame
;
358 f
->minibuffer_window
= mini_window
;
363 XWINDOW (root_window
)->next
= Qnil
;
364 f
->minibuffer_window
= Qnil
;
367 XWINDOW (root_window
)->frame
= frame
;
370 just so that there is "something there."
371 Correct size will be set up later with change_frame_size. */
373 SET_FRAME_COLS (f
, 10);
374 FRAME_LINES (f
) = 10;
376 XSETFASTINT (XWINDOW (root_window
)->total_cols
, 10);
377 XSETFASTINT (XWINDOW (root_window
)->total_lines
, (mini_p
? 9 : 10));
381 XSETFASTINT (XWINDOW (mini_window
)->total_cols
, 10);
382 XSETFASTINT (XWINDOW (mini_window
)->top_line
, 9);
383 XSETFASTINT (XWINDOW (mini_window
)->total_lines
, 1);
386 /* Choose a buffer for the frame's root window. */
390 XWINDOW (root_window
)->buffer
= Qt
;
391 buf
= Fcurrent_buffer ();
392 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
393 a space), try to find another one. */
394 if (SREF (Fbuffer_name (buf
), 0) == ' ')
395 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
397 /* Use set_window_buffer, not Fset_window_buffer, and don't let
398 hooks be run by it. The reason is that the whole frame/window
399 arrangement is not yet fully intialized at this point. Windows
400 don't have the right size, glyph matrices aren't initialized
401 etc. Running Lisp functions at this point surely ends in a
403 set_window_buffer (root_window
, buf
, 0, 0);
404 f
->buffer_list
= Fcons (buf
, Qnil
);
409 XWINDOW (mini_window
)->buffer
= Qt
;
410 set_window_buffer (mini_window
,
411 (NILP (Vminibuffer_list
)
413 : Fcar (Vminibuffer_list
)),
417 f
->root_window
= root_window
;
418 f
->selected_window
= root_window
;
419 /* Make sure this window seems more recently used than
420 a newly-created, never-selected window. */
421 ++window_select_count
;
422 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, window_select_count
);
424 f
->default_face_done_p
= 0;
429 #ifdef HAVE_WINDOW_SYSTEM
430 /* Make a frame using a separate minibuffer window on another frame.
431 MINI_WINDOW is the minibuffer window to use. nil means use the
432 default (the global minibuffer). */
435 make_frame_without_minibuffer (mini_window
, kb
, display
)
436 register Lisp_Object mini_window
;
440 register struct frame
*f
;
443 if (!NILP (mini_window
))
444 CHECK_LIVE_WINDOW (mini_window
);
446 if (!NILP (mini_window
)
447 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
448 error ("Frame and minibuffer must be on the same terminal");
450 /* Make a frame containing just a root window. */
453 if (NILP (mini_window
))
455 /* Use default-minibuffer-frame if possible. */
456 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
457 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
459 Lisp_Object frame_dummy
;
461 XSETFRAME (frame_dummy
, f
);
462 GCPRO1 (frame_dummy
);
463 /* If there's no minibuffer frame to use, create one. */
464 kb
->Vdefault_minibuffer_frame
=
465 call1 (intern ("make-initial-minibuffer-frame"), display
);
469 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
472 f
->minibuffer_window
= mini_window
;
474 /* Make the chosen minibuffer window display the proper minibuffer,
475 unless it is already showing a minibuffer. */
476 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
477 Fset_window_buffer (mini_window
,
478 (NILP (Vminibuffer_list
)
480 : Fcar (Vminibuffer_list
)), Qnil
);
484 /* Make a frame containing only a minibuffer window. */
487 make_minibuffer_frame ()
489 /* First make a frame containing just a root window, no minibuffer. */
491 register struct frame
*f
= make_frame (0);
492 register Lisp_Object mini_window
;
493 register Lisp_Object frame
;
495 XSETFRAME (frame
, f
);
500 f
->wants_modeline
= 0;
501 f
->has_minibuffer
= 1;
503 /* Now label the root window as also being the minibuffer.
504 Avoid infinite looping on the window chain by marking next pointer
507 mini_window
= f
->minibuffer_window
= f
->root_window
;
508 XWINDOW (mini_window
)->mini_p
= Qt
;
509 XWINDOW (mini_window
)->next
= Qnil
;
510 XWINDOW (mini_window
)->prev
= Qnil
;
511 XWINDOW (mini_window
)->frame
= frame
;
513 /* Put the proper buffer in that window. */
515 Fset_window_buffer (mini_window
,
516 (NILP (Vminibuffer_list
)
518 : Fcar (Vminibuffer_list
)), Qnil
);
521 #endif /* HAVE_WINDOW_SYSTEM */
523 /* Construct a frame that refers to a terminal. */
525 static int tty_frame_count
;
528 make_initial_frame (void)
531 struct terminal
*terminal
;
534 eassert (initial_kboard
);
536 /* The first call must initialize Vframe_list. */
537 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
540 terminal
= init_initial_terminal ();
543 XSETFRAME (frame
, f
);
545 Vframe_list
= Fcons (frame
, Vframe_list
);
548 f
->name
= make_pure_c_string ("F1");
551 f
->async_visible
= 1;
553 f
->output_method
= terminal
->type
;
554 f
->terminal
= terminal
;
555 f
->terminal
->reference_count
++;
556 f
->output_data
.nothing
= 0;
558 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
559 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
561 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
562 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
566 init_frame_faces (f
);
574 make_terminal_frame (struct terminal
*terminal
)
576 register struct frame
*f
;
581 error ("Terminal is not live, can't create new frames on it");
585 XSETFRAME (frame
, f
);
586 Vframe_list
= Fcons (frame
, Vframe_list
);
589 sprintf (name
, "F%d", tty_frame_count
);
590 f
->name
= build_string (name
);
592 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
593 f
->async_visible
= 1; /* Don't let visible be cleared later. */
594 f
->terminal
= terminal
;
595 f
->terminal
->reference_count
++;
597 f
->output_data
.tty
->display_info
= &the_only_display_info
;
598 if (!inhibit_window_system
599 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
600 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
601 f
->output_method
= output_msdos_raw
;
603 f
->output_method
= output_termcap
;
604 #else /* not MSDOS */
605 f
->output_method
= output_termcap
;
606 create_tty_output (f
);
607 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
608 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
609 #endif /* not MSDOS */
611 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
612 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
614 /* Set the top frame to the newly created frame. */
615 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
616 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
617 XFRAME (FRAME_TTY (f
)->top_frame
)->async_visible
= 2; /* obscured */
619 FRAME_TTY (f
)->top_frame
= frame
;
622 init_frame_faces (f
);
627 /* Get a suitable value for frame parameter PARAMETER for a newly
628 created frame, based on (1) the user-supplied frame parameter
629 alist SUPPLIED_PARMS, (2) CURRENT_VALUE, and finally, if all else
630 fails, (3) Vdefault_frame_alist. */
633 get_future_frame_param (Lisp_Object parameter
,
634 Lisp_Object supplied_parms
,
639 result
= Fassq (parameter
, supplied_parms
);
641 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
642 if (NILP (result
) && current_value
!= NULL
)
643 result
= build_string (current_value
);
645 result
= Fassq (parameter
, Vdefault_frame_alist
);
646 if (!NILP (result
) && !STRINGP (result
))
647 result
= XCDR (result
);
648 if (NILP (result
) || !STRINGP (result
))
654 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
656 doc
: /* Create an additional terminal frame, possibly on another terminal.
657 This function takes one argument, an alist specifying frame parameters.
659 You can create multiple frames on a single text-only terminal, but
660 only one of them (the selected terminal frame) is actually displayed.
662 In practice, generally you don't need to specify any parameters,
663 except when you want to create a new frame on another terminal.
664 In that case, the `tty' parameter specifies the device file to open,
665 and the `tty-type' parameter specifies the terminal type. Example:
667 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
669 Note that changing the size of one terminal frame automatically
670 affects all frames on the same terminal device. */)
675 struct terminal
*t
= NULL
;
676 Lisp_Object frame
, tem
;
677 struct frame
*sf
= SELECTED_FRAME ();
680 if (sf
->output_method
!= output_msdos_raw
681 && sf
->output_method
!= output_termcap
)
683 #else /* not MSDOS */
685 #ifdef WINDOWSNT /* This should work now! */
686 if (sf
->output_method
!= output_termcap
)
687 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
689 #endif /* not MSDOS */
692 Lisp_Object terminal
;
694 terminal
= Fassq (Qterminal
, parms
);
695 if (!NILP (terminal
))
697 terminal
= XCDR (terminal
);
698 t
= get_terminal (terminal
, 1);
701 if (t
&& t
!= the_only_display_info
.terminal
)
702 /* msdos.c assumes a single tty_display_info object. */
703 error ("Multiple terminals are not supported on this platform");
705 t
= the_only_display_info
.terminal
;
711 char *name
= 0, *type
= 0;
712 Lisp_Object tty
, tty_type
;
714 tty
= get_future_frame_param
715 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
716 ? FRAME_TTY (XFRAME (selected_frame
))->name
720 name
= (char *) alloca (SBYTES (tty
) + 1);
721 strncpy (name
, SDATA (tty
), SBYTES (tty
));
722 name
[SBYTES (tty
)] = 0;
725 tty_type
= get_future_frame_param
726 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
727 ? FRAME_TTY (XFRAME (selected_frame
))->type
729 if (!NILP (tty_type
))
731 type
= (char *) alloca (SBYTES (tty_type
) + 1);
732 strncpy (type
, SDATA (tty_type
), SBYTES (tty_type
));
733 type
[SBYTES (tty_type
)] = 0;
736 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
739 f
= make_terminal_frame (t
);
743 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
744 change_frame_size (f
, height
, width
, 0, 0, 0);
749 XSETFRAME (frame
, f
);
750 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
751 Fmodify_frame_parameters (frame
, parms
);
752 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
753 build_string (t
->display_info
.tty
->type
)),
755 if (t
->display_info
.tty
->name
!= NULL
)
756 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
757 build_string (t
->display_info
.tty
->name
)),
760 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
762 /* Make the frame face alist be frame-specific, so that each
763 frame could change its face definitions independently. */
764 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
765 /* Simple Fcopy_alist isn't enough, because we need the contents of
766 the vectors which are the CDRs of associations in face_alist to
767 be copied as well. */
768 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
769 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
774 /* Perform the switch to frame FRAME.
776 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
779 If TRACK is non-zero and the frame that currently has the focus
780 redirects its focus to the selected frame, redirect that focused
781 frame's focus to FRAME instead.
783 FOR_DELETION non-zero means that the selected frame is being
784 deleted, which includes the possibility that the frame's terminal
787 The value of NORECORD is passed as argument to Fselect_window. */
790 do_switch_frame (frame
, track
, for_deletion
, norecord
)
791 Lisp_Object frame
, norecord
;
792 int track
, for_deletion
;
794 struct frame
*sf
= SELECTED_FRAME ();
796 /* If FRAME is a switch-frame event, extract the frame we should
799 && EQ (XCAR (frame
), Qswitch_frame
)
800 && CONSP (XCDR (frame
)))
801 frame
= XCAR (XCDR (frame
));
803 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
804 a switch-frame event to arrive after a frame is no longer live,
805 especially when deleting the initial frame during startup. */
807 if (! FRAME_LIVE_P (XFRAME (frame
)))
810 if (sf
== XFRAME (frame
))
813 /* This is too greedy; it causes inappropriate focus redirection
814 that's hard to get rid of. */
816 /* If a frame's focus has been redirected toward the currently
817 selected frame, we should change the redirection to point to the
818 newly selected frame. This means that if the focus is redirected
819 from a minibufferless frame to a surrogate minibuffer frame, we
820 can use `other-window' to switch between all the frames using
821 that minibuffer frame, and the focus redirection will follow us
827 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
831 if (!FRAMEP (XCAR (tail
)))
834 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
836 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
837 Fredirect_frame_focus (XCAR (tail
), frame
);
841 /* Instead, apply it only to the frame we're pointing to. */
842 #ifdef HAVE_WINDOW_SYSTEM
843 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
845 Lisp_Object focus
, xfocus
;
847 xfocus
= x_get_focus_frame (XFRAME (frame
));
850 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
851 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
852 Fredirect_frame_focus (xfocus
, frame
);
855 #endif /* HAVE_X_WINDOWS */
858 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
859 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
861 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
863 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
864 /* Mark previously displayed frame as now obscured. */
865 XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
)->async_visible
= 2;
866 XFRAME (frame
)->async_visible
= 1;
867 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
870 selected_frame
= frame
;
871 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
872 last_nonminibuf_frame
= XFRAME (selected_frame
);
874 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
876 /* We want to make sure that the next event generates a frame-switch
877 event to the appropriate frame. This seems kludgy to me, but
878 before you take it out, make sure that evaluating something like
879 (select-window (frame-root-window (new-frame))) doesn't end up
880 with your typing being interpreted in the new frame instead of
881 the one you're actually typing in. */
882 internal_last_event_frame
= Qnil
;
887 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
888 doc
: /* Select FRAME.
889 Subsequent editing commands apply to its selected window.
890 Optional argument NORECORD means to neither change the order of
891 recently selected windows nor the buffer list.
893 The selection of FRAME lasts until the next time the user does
894 something to select a different frame, or until the next time
895 this function is called. If you are using a window system, the
896 previously selected frame may be restored as the selected frame
897 when returning to the command loop, because it still may have
898 the window system's input focus. On a text-only terminal, the
899 next redisplay will display FRAME.
901 This function returns FRAME, or nil if FRAME has been deleted. */)
903 Lisp_Object frame
, norecord
;
905 return do_switch_frame (frame
, 1, 0, norecord
);
909 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
910 doc
: /* Handle a switch-frame event EVENT.
911 Switch-frame events are usually bound to this function.
912 A switch-frame event tells Emacs that the window manager has requested
913 that the user's events be directed to the frame mentioned in the event.
914 This function selects the selected window of the frame of EVENT.
916 If EVENT is frame object, handle it as if it were a switch-frame event
921 /* Preserve prefix arg that the command loop just cleared. */
922 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
923 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
924 return do_switch_frame (event
, 0, 0, Qnil
);
927 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
928 doc
: /* Return the frame that is now selected. */)
931 return selected_frame
;
934 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
935 doc
: /* Return the frame object that window WINDOW is on. */)
939 CHECK_LIVE_WINDOW (window
);
940 return XWINDOW (window
)->frame
;
943 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
944 doc
: /* Returns the topmost, leftmost window of FRAME.
945 If omitted, FRAME defaults to the currently selected frame. */)
952 w
= SELECTED_FRAME ()->root_window
;
955 CHECK_LIVE_FRAME (frame
);
956 w
= XFRAME (frame
)->root_window
;
958 while (NILP (XWINDOW (w
)->buffer
))
960 if (! NILP (XWINDOW (w
)->hchild
))
961 w
= XWINDOW (w
)->hchild
;
962 else if (! NILP (XWINDOW (w
)->vchild
))
963 w
= XWINDOW (w
)->vchild
;
970 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
971 Sactive_minibuffer_window
, 0, 0, 0,
972 doc
: /* Return the currently active minibuffer window, or nil if none. */)
975 return minibuf_level
? minibuf_window
: Qnil
;
978 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
979 doc
: /* Returns the root-window of FRAME.
980 If omitted, FRAME defaults to the currently selected frame. */)
987 window
= SELECTED_FRAME ()->root_window
;
990 CHECK_LIVE_FRAME (frame
);
991 window
= XFRAME (frame
)->root_window
;
997 DEFUN ("frame-selected-window", Fframe_selected_window
,
998 Sframe_selected_window
, 0, 1, 0,
999 doc
: /* Return the selected window of FRAME.
1000 FRAME defaults to the currently selected frame. */)
1007 window
= SELECTED_FRAME ()->selected_window
;
1010 CHECK_LIVE_FRAME (frame
);
1011 window
= XFRAME (frame
)->selected_window
;
1017 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
1018 Sset_frame_selected_window
, 2, 3, 0,
1019 doc
: /* Set selected window of FRAME to WINDOW.
1020 If FRAME is nil, use the selected frame. If FRAME is the
1021 selected frame, this makes WINDOW the selected window.
1022 Optional argument NORECORD non-nil means to neither change the
1023 order of recently selected windows nor the buffer list.
1025 (frame
, window
, norecord
)
1026 Lisp_Object frame
, window
, norecord
;
1029 frame
= selected_frame
;
1031 CHECK_LIVE_FRAME (frame
);
1032 CHECK_LIVE_WINDOW (window
);
1034 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
1035 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
1037 if (EQ (frame
, selected_frame
))
1038 return Fselect_window (window
, norecord
);
1040 return XFRAME (frame
)->selected_window
= window
;
1044 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1046 doc
: /* Return a list of all live frames. */)
1050 frames
= Fcopy_sequence (Vframe_list
);
1051 #ifdef HAVE_WINDOW_SYSTEM
1052 if (FRAMEP (tip_frame
))
1053 frames
= Fdelq (tip_frame
, frames
);
1058 /* Return the next frame in the frame list after FRAME.
1059 If MINIBUF is nil, exclude minibuffer-only frames.
1060 If MINIBUF is a window, include only its own frame
1061 and any frame now using that window as the minibuffer.
1062 If MINIBUF is `visible', include all visible frames.
1063 If MINIBUF is 0, include all visible and iconified frames.
1064 Otherwise, include all frames. */
1067 next_frame (frame
, minibuf
)
1069 Lisp_Object minibuf
;
1074 /* There must always be at least one frame in Vframe_list. */
1075 if (! CONSP (Vframe_list
))
1078 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
1079 forever. Forestall that. */
1080 CHECK_LIVE_FRAME (frame
);
1083 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1090 && ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1091 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1092 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1093 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
)))))
1095 /* Decide whether this frame is eligible to be returned. */
1097 /* If we've looped all the way around without finding any
1098 eligible frames, return the original frame. */
1102 /* Let minibuf decide if this frame is acceptable. */
1105 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1108 else if (EQ (minibuf
, Qvisible
))
1110 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1111 if (FRAME_VISIBLE_P (XFRAME (f
)))
1114 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
1116 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1117 if (FRAME_VISIBLE_P (XFRAME (f
))
1118 || FRAME_ICONIFIED_P (XFRAME (f
)))
1121 else if (WINDOWP (minibuf
))
1123 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1124 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1125 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1126 FRAME_FOCUS_FRAME (XFRAME (f
))))
1138 /* Return the previous frame in the frame list before FRAME.
1139 If MINIBUF is nil, exclude minibuffer-only frames.
1140 If MINIBUF is a window, include only its own frame
1141 and any frame now using that window as the minibuffer.
1142 If MINIBUF is `visible', include all visible frames.
1143 If MINIBUF is 0, include all visible and iconified frames.
1144 Otherwise, include all frames. */
1147 prev_frame (frame
, minibuf
)
1149 Lisp_Object minibuf
;
1154 /* There must always be at least one frame in Vframe_list. */
1155 if (! CONSP (Vframe_list
))
1159 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1167 if (EQ (frame
, f
) && !NILP (prev
))
1170 if ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1171 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1172 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1173 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
))))
1175 /* Decide whether this frame is eligible to be returned,
1176 according to minibuf. */
1179 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1182 else if (WINDOWP (minibuf
))
1184 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1185 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1186 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1187 FRAME_FOCUS_FRAME (XFRAME (f
))))
1190 else if (EQ (minibuf
, Qvisible
))
1192 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1193 if (FRAME_VISIBLE_P (XFRAME (f
)))
1196 else if (XFASTINT (minibuf
) == 0)
1198 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1199 if (FRAME_VISIBLE_P (XFRAME (f
))
1200 || FRAME_ICONIFIED_P (XFRAME (f
)))
1208 /* We've scanned the entire list. */
1210 /* We went through the whole frame list without finding a single
1211 acceptable frame. Return the original frame. */
1214 /* There were no acceptable frames in the list before FRAME; otherwise,
1215 we would have returned directly from the loop. Since PREV is the last
1216 acceptable frame in the list, return it. */
1221 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1222 doc
: /* Return the next frame in the frame list after FRAME.
1223 It considers only frames on the same terminal as FRAME.
1224 By default, skip minibuffer-only frames.
1225 If omitted, FRAME defaults to the selected frame.
1226 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1227 If MINIFRAME is a window, include only its own frame
1228 and any frame now using that window as the minibuffer.
1229 If MINIFRAME is `visible', include all visible frames.
1230 If MINIFRAME is 0, include all visible and iconified frames.
1231 Otherwise, include all frames. */)
1233 Lisp_Object frame
, miniframe
;
1236 frame
= selected_frame
;
1238 CHECK_LIVE_FRAME (frame
);
1239 return next_frame (frame
, miniframe
);
1242 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1243 doc
: /* Return the previous frame in the frame list before FRAME.
1244 It considers only frames on the same terminal as FRAME.
1245 By default, skip minibuffer-only frames.
1246 If omitted, FRAME defaults to the selected frame.
1247 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1248 If MINIFRAME is a window, include only its own frame
1249 and any frame now using that window as the minibuffer.
1250 If MINIFRAME is `visible', include all visible frames.
1251 If MINIFRAME is 0, include all visible and iconified frames.
1252 Otherwise, include all frames. */)
1254 Lisp_Object frame
, miniframe
;
1257 frame
= selected_frame
;
1258 CHECK_LIVE_FRAME (frame
);
1259 return prev_frame (frame
, miniframe
);
1262 /* Return 1 if it is ok to delete frame F;
1263 0 if all frames aside from F are invisible.
1264 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1267 other_visible_frames (f
)
1270 /* We know the selected frame is visible,
1271 so if F is some other frame, it can't be the sole visible one. */
1272 if (f
== SELECTED_FRAME ())
1277 for (frames
= Vframe_list
;
1279 frames
= XCDR (frames
))
1283 this = XCAR (frames
);
1284 /* Verify that the frame's window still exists
1285 and we can still talk to it. And note any recent change
1287 #ifdef HAVE_WINDOW_SYSTEM
1288 if (FRAME_WINDOW_P (XFRAME (this)))
1290 x_sync (XFRAME (this));
1291 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1295 if (FRAME_VISIBLE_P (XFRAME (this))
1296 || FRAME_ICONIFIED_P (XFRAME (this))
1297 /* Allow deleting the terminal frame when at least
1298 one X frame exists! */
1299 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1307 /* Error handler for `delete-frame-functions'. */
1309 delete_frame_handler (Lisp_Object arg
)
1311 add_to_log ("Error during `delete-frame': %s", arg
, Qnil
);
1315 extern Lisp_Object Qrun_hook_with_args
;
1317 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1318 unconditionally. x_connection_closed and delete_terminal use
1319 this. Any other value of FORCE implements the semantics
1320 described for Fdelete_frame. */
1322 delete_frame (frame
, force
)
1323 /* If we use `register' here, gcc-4.0.2 on amd64 using
1324 -DUSE_LISP_UNION_TYPE complains further down that we're getting the
1325 address of `force'. Go figure. */
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");
1351 /* x_connection_closed must have set FORCE to `noelisp' in order
1352 to delete the last frame, if it is gone. */
1353 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1354 error ("Attempt to delete the only frame");
1356 /* Does this frame have a minibuffer, and is it the surrogate
1357 minibuffer for any other frame? */
1358 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1362 for (frames
= Vframe_list
;
1364 frames
= XCDR (frames
))
1367 this = XCAR (frames
);
1369 if (! EQ (this, frame
)
1371 WINDOW_FRAME (XWINDOW
1372 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1374 /* If we MUST delete this frame, delete the other first.
1375 But do this only if FORCE equals `noelisp'. */
1376 if (EQ (force
, Qnoelisp
))
1377 delete_frame (this, Qnoelisp
);
1379 error ("Attempt to delete a surrogate minibuffer frame");
1384 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1385 frame is a tooltip. FORCE is set to `noelisp' when handling
1386 a disconnect from the terminal, so we don't dare call Lisp
1388 if (NILP (Vrun_hooks
) || !NILP (Fframe_parameter (frame
, intern ("tooltip"))))
1390 if (EQ (force
, Qnoelisp
))
1392 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1395 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1397 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1398 if (! FRAME_LIVE_P (f
))
1401 /* At this point, we are committed to deleting the frame.
1402 There is no more chance for errors to prevent it. */
1404 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1406 /* Don't let the frame remain selected. */
1409 Lisp_Object tail
, frame1
;
1411 /* Look for another visible frame on the same terminal. */
1412 frame1
= next_frame (frame
, Qvisible
);
1414 /* If there is none, find *some* other frame. */
1415 if (NILP (frame1
) || EQ (frame1
, frame
))
1417 FOR_EACH_FRAME (tail
, frame1
)
1419 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1423 #ifdef NS_IMPL_COCOA
1425 /* Under NS, there is no system mechanism for choosing a new
1426 window to get focus -- it is left to application code.
1427 So the portion of THIS application interfacing with NS
1428 needs to know about it. We call Fraise_frame, but the
1429 purpose is really to transfer focus. */
1430 Fraise_frame (frame1
);
1433 do_switch_frame (frame1
, 0, 1, Qnil
);
1434 sf
= SELECTED_FRAME ();
1437 /* Don't allow minibuf_window to remain on a deleted frame. */
1438 if (EQ (f
->minibuffer_window
, minibuf_window
))
1440 Fset_window_buffer (sf
->minibuffer_window
,
1441 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1442 minibuf_window
= sf
->minibuffer_window
;
1444 /* If the dying minibuffer window was selected,
1445 select the new one. */
1446 if (minibuffer_selected
)
1447 Fselect_window (minibuf_window
, Qnil
);
1450 /* Don't let echo_area_window to remain on a deleted frame. */
1451 if (EQ (f
->minibuffer_window
, echo_area_window
))
1452 echo_area_window
= sf
->minibuffer_window
;
1454 /* Clear any X selections for this frame. */
1455 #ifdef HAVE_X_WINDOWS
1457 x_clear_frame_selections (f
);
1461 This function must be called before the window tree of the
1462 frame is deleted because windows contain dynamically allocated
1466 #ifdef HAVE_WINDOW_SYSTEM
1467 /* Give chance to each font driver to free a frame specific data. */
1468 font_update_drivers (f
, Qnil
);
1471 /* Mark all the windows that used to be on FRAME as deleted, and then
1472 remove the reference to them. */
1473 delete_all_subwindows (XWINDOW (f
->root_window
));
1474 f
->root_window
= Qnil
;
1476 Vframe_list
= Fdelq (frame
, Vframe_list
);
1477 FRAME_SET_VISIBLE (f
, 0);
1479 /* Allow the vector of menu bar contents to be freed in the next
1480 garbage collection. The frame object itself may not be garbage
1481 collected until much later, because recent_keys and other data
1482 structures can still refer to it. */
1483 f
->menu_bar_vector
= Qnil
;
1485 free_font_driver_list (f
);
1487 xfree (f
->decode_mode_spec_buffer
);
1488 xfree (FRAME_INSERT_COST (f
));
1489 xfree (FRAME_DELETEN_COST (f
));
1490 xfree (FRAME_INSERTN_COST (f
));
1491 xfree (FRAME_DELETE_COST (f
));
1492 xfree (FRAME_MESSAGE_BUF (f
));
1494 /* Since some events are handled at the interrupt level, we may get
1495 an event for f at any time; if we zero out the frame's terminal
1496 now, then we may trip up the event-handling code. Instead, we'll
1497 promise that the terminal of the frame must be valid until we
1498 have called the window-system-dependent frame destruction
1501 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1502 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1505 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1506 f
->output_data
.nothing
= 0;
1507 f
->terminal
= 0; /* Now the frame is dead. */
1509 /* If needed, delete the terminal that this frame was on.
1510 (This must be done after the frame is killed.) */
1511 terminal
->reference_count
--;
1512 if (terminal
->reference_count
== 0)
1515 XSETTERMINAL (tmp
, terminal
);
1518 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1521 kb
= terminal
->kboard
;
1524 /* If we've deleted the last_nonminibuf_frame, then try to find
1526 if (f
== last_nonminibuf_frame
)
1530 last_nonminibuf_frame
= 0;
1532 for (frames
= Vframe_list
;
1534 frames
= XCDR (frames
))
1536 f
= XFRAME (XCAR (frames
));
1537 if (!FRAME_MINIBUF_ONLY_P (f
))
1539 last_nonminibuf_frame
= f
;
1545 /* If there's no other frame on the same kboard, get out of
1546 single-kboard state if we're in it for this kboard. */
1550 /* Some frame we found on the same kboard, or nil if there are none. */
1551 Lisp_Object frame_on_same_kboard
;
1553 frame_on_same_kboard
= Qnil
;
1555 for (frames
= Vframe_list
;
1557 frames
= XCDR (frames
))
1562 this = XCAR (frames
);
1567 if (kb
== FRAME_KBOARD (f1
))
1568 frame_on_same_kboard
= this;
1571 if (NILP (frame_on_same_kboard
))
1572 not_single_kboard_state (kb
);
1576 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1577 find another one. Prefer minibuffer-only frames, but also notice
1578 frames with other windows. */
1579 if (kb
!= NULL
&& EQ (frame
, kb
->Vdefault_minibuffer_frame
))
1583 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1584 Lisp_Object frame_with_minibuf
;
1585 /* Some frame we found on the same kboard, or nil if there are none. */
1586 Lisp_Object frame_on_same_kboard
;
1588 frame_on_same_kboard
= Qnil
;
1589 frame_with_minibuf
= Qnil
;
1591 for (frames
= Vframe_list
;
1593 frames
= XCDR (frames
))
1598 this = XCAR (frames
);
1603 /* Consider only frames on the same kboard
1604 and only those with minibuffers. */
1605 if (kb
== FRAME_KBOARD (f1
)
1606 && FRAME_HAS_MINIBUF_P (f1
))
1608 frame_with_minibuf
= this;
1609 if (FRAME_MINIBUF_ONLY_P (f1
))
1613 if (kb
== FRAME_KBOARD (f1
))
1614 frame_on_same_kboard
= this;
1617 if (!NILP (frame_on_same_kboard
))
1619 /* We know that there must be some frame with a minibuffer out
1620 there. If this were not true, all of the frames present
1621 would have to be minibufferless, which implies that at some
1622 point their minibuffer frames must have been deleted, but
1623 that is prohibited at the top; you can't delete surrogate
1624 minibuffer frames. */
1625 if (NILP (frame_with_minibuf
))
1628 kb
->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1631 /* No frames left on this kboard--say no minibuffer either. */
1632 kb
->Vdefault_minibuffer_frame
= Qnil
;
1635 /* Cause frame titles to update--necessary if we now have just one frame. */
1636 update_mode_lines
= 1;
1641 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1642 doc
: /* Delete FRAME, permanently eliminating it from use.
1643 FRAME defaults to the selected frame.
1645 A frame may not be deleted if its minibuffer is used by other frames.
1646 Normally, you may not delete a frame if all other frames are invisible,
1647 but if the second optional argument FORCE is non-nil, you may do so.
1649 This function runs `delete-frame-functions' before actually
1650 deleting the frame, unless the frame is a tooltip.
1651 The functions are run with one argument, the frame to be deleted. */)
1653 Lisp_Object frame
, force
;
1655 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1659 /* Return mouse position in character cell units. */
1661 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1662 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1663 The position is given in character cells, where (0, 0) is the
1664 upper-left corner of the frame, X is the horizontal offset, and Y is
1665 the vertical offset.
1666 If Emacs is running on a mouseless terminal or hasn't been programmed
1667 to read the mouse position, it returns the selected frame for FRAME
1668 and nil for X and Y.
1669 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1670 passing the normal return value to that function as an argument,
1671 and returns whatever that function returns. */)
1675 Lisp_Object lispy_dummy
;
1676 enum scroll_bar_part party_dummy
;
1677 Lisp_Object x
, y
, retval
;
1679 unsigned long long_dummy
;
1680 struct gcpro gcpro1
;
1682 f
= SELECTED_FRAME ();
1685 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1686 /* It's okay for the hook to refrain from storing anything. */
1687 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1688 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1689 &lispy_dummy
, &party_dummy
,
1696 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1701 XSETFRAME (lispy_dummy
, f
);
1702 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1704 if (!NILP (Vmouse_position_function
))
1705 retval
= call1 (Vmouse_position_function
, retval
);
1706 RETURN_UNGCPRO (retval
);
1709 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1710 Smouse_pixel_position
, 0, 0, 0,
1711 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1712 The position is given in pixel units, where (0, 0) is the
1713 upper-left corner of the frame, X is the horizontal offset, and Y is
1714 the vertical offset.
1715 If Emacs is running on a mouseless terminal or hasn't been programmed
1716 to read the mouse position, it returns the selected frame for FRAME
1717 and nil for X and Y. */)
1721 Lisp_Object lispy_dummy
;
1722 enum scroll_bar_part party_dummy
;
1724 unsigned long long_dummy
;
1726 f
= SELECTED_FRAME ();
1729 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1730 /* It's okay for the hook to refrain from storing anything. */
1731 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1732 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1733 &lispy_dummy
, &party_dummy
,
1737 XSETFRAME (lispy_dummy
, f
);
1738 return Fcons (lispy_dummy
, Fcons (x
, y
));
1741 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1742 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1743 Coordinates are relative to the frame, not a window,
1744 so the coordinates of the top left character in the frame
1745 may be nonzero due to left-hand scroll bars or the menu bar.
1747 The position is given in character cells, where (0, 0) is the
1748 upper-left corner of the frame, X is the horizontal offset, and Y is
1749 the vertical offset.
1751 This function is a no-op for an X frame that is not visible.
1752 If you have just created a frame, you must wait for it to become visible
1753 before calling this function on it, like this.
1754 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1756 Lisp_Object frame
, x
, y
;
1758 CHECK_LIVE_FRAME (frame
);
1762 /* I think this should be done with a hook. */
1763 #ifdef HAVE_WINDOW_SYSTEM
1764 if (FRAME_WINDOW_P (XFRAME (frame
)))
1765 /* Warping the mouse will cause enternotify and focus events. */
1766 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1768 #if defined (MSDOS) && defined (HAVE_MOUSE)
1769 if (FRAME_MSDOS_P (XFRAME (frame
)))
1771 Fselect_frame (frame
, Qnil
);
1772 mouse_moveto (XINT (x
), XINT (y
));
1777 Fselect_frame (frame
, Qnil
);
1778 term_mouse_moveto (XINT (x
), XINT (y
));
1787 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1788 Sset_mouse_pixel_position
, 3, 3, 0,
1789 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1790 The position is given in pixels, where (0, 0) is the upper-left corner
1791 of the frame, X is the horizontal offset, and Y is the vertical offset.
1793 Note, this is a no-op for an X frame that is not visible.
1794 If you have just created a frame, you must wait for it to become visible
1795 before calling this function on it, like this.
1796 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1798 Lisp_Object frame
, x
, y
;
1800 CHECK_LIVE_FRAME (frame
);
1804 /* I think this should be done with a hook. */
1805 #ifdef HAVE_WINDOW_SYSTEM
1806 if (FRAME_WINDOW_P (XFRAME (frame
)))
1807 /* Warping the mouse will cause enternotify and focus events. */
1808 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1810 #if defined (MSDOS) && defined (HAVE_MOUSE)
1811 if (FRAME_MSDOS_P (XFRAME (frame
)))
1813 Fselect_frame (frame
, Qnil
);
1814 mouse_moveto (XINT (x
), XINT (y
));
1819 Fselect_frame (frame
, Qnil
);
1820 term_mouse_moveto (XINT (x
), XINT (y
));
1829 static void make_frame_visible_1
P_ ((Lisp_Object
));
1831 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1833 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1834 If omitted, FRAME defaults to the currently selected frame. */)
1839 frame
= selected_frame
;
1841 CHECK_LIVE_FRAME (frame
);
1843 /* I think this should be done with a hook. */
1844 #ifdef HAVE_WINDOW_SYSTEM
1845 if (FRAME_WINDOW_P (XFRAME (frame
)))
1847 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1848 x_make_frame_visible (XFRAME (frame
));
1852 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1854 /* Make menu bar update for the Buffers and Frames menus. */
1855 windows_or_buffers_changed
++;
1860 /* Update the display_time slot of the buffers shown in WINDOW
1861 and all its descendents. */
1864 make_frame_visible_1 (window
)
1869 for (;!NILP (window
); window
= w
->next
)
1871 w
= XWINDOW (window
);
1873 if (!NILP (w
->buffer
))
1874 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1876 if (!NILP (w
->vchild
))
1877 make_frame_visible_1 (w
->vchild
);
1878 if (!NILP (w
->hchild
))
1879 make_frame_visible_1 (w
->hchild
);
1883 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1885 doc
: /* Make the frame FRAME invisible.
1886 If omitted, FRAME defaults to the currently selected frame.
1887 On graphical displays, invisible frames are not updated and are
1888 usually not displayed at all, even in a window system's \"taskbar\".
1890 Normally you may not make FRAME invisible if all other frames are invisible,
1891 but if the second optional argument FORCE is non-nil, you may do so.
1893 This function has no effect on text-only terminal frames. Such frames
1894 are always considered visible, whether or not they are currently being
1895 displayed in the terminal. */)
1897 Lisp_Object frame
, force
;
1900 frame
= selected_frame
;
1902 CHECK_LIVE_FRAME (frame
);
1904 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1905 error ("Attempt to make invisible the sole visible or iconified frame");
1907 #if 0 /* This isn't logically necessary, and it can do GC. */
1908 /* Don't let the frame remain selected. */
1909 if (EQ (frame
, selected_frame
))
1910 do_switch_frame (next_frame (frame
, Qt
), 0, 0, Qnil
)
1913 /* Don't allow minibuf_window to remain on a deleted frame. */
1914 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1916 struct frame
*sf
= XFRAME (selected_frame
);
1917 Fset_window_buffer (sf
->minibuffer_window
,
1918 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1919 minibuf_window
= sf
->minibuffer_window
;
1922 /* I think this should be done with a hook. */
1923 #ifdef HAVE_WINDOW_SYSTEM
1924 if (FRAME_WINDOW_P (XFRAME (frame
)))
1925 x_make_frame_invisible (XFRAME (frame
));
1928 /* Make menu bar update for the Buffers and Frames menus. */
1929 windows_or_buffers_changed
++;
1934 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1936 doc
: /* Make the frame FRAME into an icon.
1937 If omitted, FRAME defaults to the currently selected frame. */)
1942 frame
= selected_frame
;
1944 CHECK_LIVE_FRAME (frame
);
1946 #if 0 /* This isn't logically necessary, and it can do GC. */
1947 /* Don't let the frame remain selected. */
1948 if (EQ (frame
, selected_frame
))
1949 Fhandle_switch_frame (next_frame (frame
, Qt
));
1952 /* Don't allow minibuf_window to remain on a deleted frame. */
1953 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1955 struct frame
*sf
= XFRAME (selected_frame
);
1956 Fset_window_buffer (sf
->minibuffer_window
,
1957 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1958 minibuf_window
= sf
->minibuffer_window
;
1961 /* I think this should be done with a hook. */
1962 #ifdef HAVE_WINDOW_SYSTEM
1963 if (FRAME_WINDOW_P (XFRAME (frame
)))
1964 x_iconify_frame (XFRAME (frame
));
1967 /* Make menu bar update for the Buffers and Frames menus. */
1968 windows_or_buffers_changed
++;
1973 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1975 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1976 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1977 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1978 On graphical displays, invisible frames are not updated and are
1979 usually not displayed at all, even in a window system's \"taskbar\".
1981 If FRAME is a text-only terminal frame, this always returns t.
1982 Such frames are always considered visible, whether or not they are
1983 currently being displayed on the terminal. */)
1987 CHECK_LIVE_FRAME (frame
);
1989 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1991 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1993 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1998 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
2000 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
2003 Lisp_Object tail
, frame
;
2008 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
2010 frame
= XCAR (tail
);
2011 if (!FRAMEP (frame
))
2014 if (FRAME_VISIBLE_P (f
))
2015 value
= Fcons (frame
, value
);
2021 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
2022 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
2023 If FRAME is invisible or iconified, make it visible.
2024 If you don't specify a frame, the selected frame is used.
2025 If Emacs is displaying on an ordinary terminal or some other device which
2026 doesn't support multiple overlapping frames, this function selects FRAME. */)
2032 frame
= selected_frame
;
2034 CHECK_LIVE_FRAME (frame
);
2038 if (FRAME_TERMCAP_P (f
))
2039 /* On a text-only terminal select FRAME. */
2040 Fselect_frame (frame
, Qnil
);
2042 /* Do like the documentation says. */
2043 Fmake_frame_visible (frame
);
2045 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2046 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
2051 /* Should we have a corresponding function called Flower_Power? */
2052 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
2053 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2054 If you don't specify a frame, the selected frame is used.
2055 If Emacs is displaying on an ordinary terminal or some other device which
2056 doesn't support multiple overlapping frames, this function does nothing. */)
2063 frame
= selected_frame
;
2065 CHECK_LIVE_FRAME (frame
);
2069 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2070 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2076 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2078 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2079 In other words, switch-frame events caused by events in FRAME will
2080 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2081 FOCUS-FRAME after reading an event typed at FRAME.
2083 If FOCUS-FRAME is omitted or nil, any existing redirection is
2084 cancelled, and the frame again receives its own keystrokes.
2086 Focus redirection is useful for temporarily redirecting keystrokes to
2087 a surrogate minibuffer frame when a frame doesn't have its own
2090 A frame's focus redirection can be changed by `select-frame'. If frame
2091 FOO is selected, and then a different frame BAR is selected, any
2092 frames redirecting their focus to FOO are shifted to redirect their
2093 focus to BAR. This allows focus redirection to work properly when the
2094 user switches from one frame to another using `select-window'.
2096 This means that a frame whose focus is redirected to itself is treated
2097 differently from a frame whose focus is redirected to nil; the former
2098 is affected by `select-frame', while the latter is not.
2100 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2101 (frame
, focus_frame
)
2102 Lisp_Object frame
, focus_frame
;
2106 /* Note that we don't check for a live frame here. It's reasonable
2107 to redirect the focus of a frame you're about to delete, if you
2108 know what other frame should receive those keystrokes. */
2109 CHECK_FRAME (frame
);
2111 if (! NILP (focus_frame
))
2112 CHECK_LIVE_FRAME (focus_frame
);
2116 f
->focus_frame
= focus_frame
;
2118 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2119 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2125 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
2126 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2127 This returns nil if FRAME's focus is not redirected.
2128 See `redirect-frame-focus'. */)
2132 CHECK_LIVE_FRAME (frame
);
2134 return FRAME_FOCUS_FRAME (XFRAME (frame
));
2139 /* Return the value of frame parameter PROP in frame FRAME. */
2142 get_frame_param (frame
, prop
)
2143 register struct frame
*frame
;
2146 register Lisp_Object tem
;
2148 tem
= Fassq (prop
, frame
->param_alist
);
2154 /* Return the buffer-predicate of the selected frame. */
2157 frame_buffer_predicate (frame
)
2160 return XFRAME (frame
)->buffer_predicate
;
2163 /* Return the buffer-list of the selected frame. */
2166 frame_buffer_list (frame
)
2169 return XFRAME (frame
)->buffer_list
;
2172 /* Set the buffer-list of the selected frame. */
2175 set_frame_buffer_list (frame
, list
)
2176 Lisp_Object frame
, list
;
2178 XFRAME (frame
)->buffer_list
= list
;
2181 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2184 frames_discard_buffer (buffer
)
2187 Lisp_Object frame
, tail
;
2189 FOR_EACH_FRAME (tail
, frame
)
2191 XFRAME (frame
)->buffer_list
2192 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
2193 XFRAME (frame
)->buried_buffer_list
2194 = Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
);
2198 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2199 If the alist already has an element for PROP, we change it. */
2202 store_in_alist (alistptr
, prop
, val
)
2203 Lisp_Object
*alistptr
, val
;
2206 register Lisp_Object tem
;
2208 tem
= Fassq (prop
, *alistptr
);
2210 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2216 frame_name_fnn_p (str
, len
)
2220 if (len
> 1 && str
[0] == 'F')
2224 strtol (str
+ 1, &end_ptr
, 10);
2226 if (end_ptr
== str
+ len
)
2232 /* Set the name of the terminal frame. Also used by MSDOS frames.
2233 Modeled after x_set_name which is used for WINDOW frames. */
2236 set_term_frame_name (f
, name
)
2240 f
->explicit_name
= ! NILP (name
);
2242 /* If NAME is nil, set the name to F<num>. */
2247 /* Check for no change needed in this very common case
2248 before we do any consing. */
2249 if (frame_name_fnn_p (SDATA (f
->name
),
2254 sprintf (namebuf
, "F%d", tty_frame_count
);
2255 name
= build_string (namebuf
);
2259 CHECK_STRING (name
);
2261 /* Don't change the name if it's already NAME. */
2262 if (! NILP (Fstring_equal (name
, f
->name
)))
2265 /* Don't allow the user to set the frame name to F<num>, so it
2266 doesn't clash with the names we generate for terminal frames. */
2267 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
2268 error ("Frame names of the form F<num> are usurped by Emacs");
2272 update_mode_lines
= 1;
2276 store_frame_param (f
, prop
, val
)
2278 Lisp_Object prop
, val
;
2280 register Lisp_Object old_alist_elt
;
2282 /* The buffer-list parameters are stored in a special place and not
2284 if (EQ (prop
, Qbuffer_list
))
2286 f
->buffer_list
= val
;
2289 if (EQ (prop
, Qburied_buffer_list
))
2291 f
->buried_buffer_list
= val
;
2295 /* If PROP is a symbol which is supposed to have frame-local values,
2296 and it is set up based on this frame, switch to the global
2297 binding. That way, we can create or alter the frame-local binding
2298 without messing up the symbol's status. */
2301 Lisp_Object valcontents
;
2302 valcontents
= SYMBOL_VALUE (prop
);
2303 if ((BUFFER_LOCAL_VALUEP (valcontents
))
2304 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
2305 && XBUFFER_LOCAL_VALUE (valcontents
)->found_for_frame
2306 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
2307 swap_in_global_binding (prop
);
2310 /* The tty color needed to be set before the frame's parameter
2311 alist was updated with the new value. This is not true any more,
2312 but we still do this test early on. */
2313 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2314 && f
== FRAME_TTY (f
)->previous_frame
)
2315 /* Force redisplay of this tty. */
2316 FRAME_TTY (f
)->previous_frame
= NULL
;
2318 /* Update the frame parameter alist. */
2319 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2320 if (EQ (old_alist_elt
, Qnil
))
2321 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2323 Fsetcdr (old_alist_elt
, val
);
2325 /* Update some other special parameters in their special places
2326 in addition to the alist. */
2328 if (EQ (prop
, Qbuffer_predicate
))
2329 f
->buffer_predicate
= val
;
2331 if (! FRAME_WINDOW_P (f
))
2333 if (EQ (prop
, Qmenu_bar_lines
))
2334 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2335 else if (EQ (prop
, Qname
))
2336 set_term_frame_name (f
, val
);
2339 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2341 if (! MINI_WINDOW_P (XWINDOW (val
)))
2342 error ("Surrogate minibuffer windows must be minibuffer windows");
2344 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2345 && !EQ (val
, f
->minibuffer_window
))
2346 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2348 /* Install the chosen minibuffer window, with proper buffer. */
2349 f
->minibuffer_window
= val
;
2353 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2354 doc
: /* Return the parameters-alist of frame FRAME.
2355 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2356 The meaningful PARMs depend on the kind of frame.
2357 If FRAME is omitted, return information on the currently selected frame. */)
2364 struct gcpro gcpro1
;
2367 frame
= selected_frame
;
2369 CHECK_FRAME (frame
);
2372 if (!FRAME_LIVE_P (f
))
2375 alist
= Fcopy_alist (f
->param_alist
);
2378 if (!FRAME_WINDOW_P (f
))
2380 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2381 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2384 /* If the frame's parameter alist says the colors are
2385 unspecified and reversed, take the frame's background pixel
2386 for foreground and vice versa. */
2387 elt
= Fassq (Qforeground_color
, alist
);
2388 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2390 if (strncmp (SDATA (XCDR (elt
)),
2392 SCHARS (XCDR (elt
))) == 0)
2393 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2394 else if (strncmp (SDATA (XCDR (elt
)),
2396 SCHARS (XCDR (elt
))) == 0)
2397 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2400 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2401 elt
= Fassq (Qbackground_color
, alist
);
2402 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2404 if (strncmp (SDATA (XCDR (elt
)),
2406 SCHARS (XCDR (elt
))) == 0)
2407 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2408 else if (strncmp (SDATA (XCDR (elt
)),
2410 SCHARS (XCDR (elt
))) == 0)
2411 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2414 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2415 store_in_alist (&alist
, intern ("font"),
2416 build_string (FRAME_MSDOS_P (f
)
2418 : FRAME_W32_P (f
) ? "w32term"
2421 store_in_alist (&alist
, Qname
, f
->name
);
2422 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2423 store_in_alist (&alist
, Qheight
, make_number (height
));
2424 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2425 store_in_alist (&alist
, Qwidth
, make_number (width
));
2426 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2427 store_in_alist (&alist
, Qminibuffer
,
2428 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2429 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2430 : FRAME_MINIBUF_WINDOW (f
)));
2431 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2432 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2433 store_in_alist (&alist
, Qburied_buffer_list
, XFRAME (frame
)->buried_buffer_list
);
2435 /* I think this should be done with a hook. */
2436 #ifdef HAVE_WINDOW_SYSTEM
2437 if (FRAME_WINDOW_P (f
))
2438 x_report_frame_params (f
, &alist
);
2442 /* This ought to be correct in f->param_alist for an X frame. */
2444 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2445 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2453 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2454 doc
: /* Return FRAME's value for parameter PARAMETER.
2455 If FRAME is nil, describe the currently selected frame. */)
2457 Lisp_Object frame
, parameter
;
2463 frame
= selected_frame
;
2465 CHECK_FRAME (frame
);
2466 CHECK_SYMBOL (parameter
);
2471 if (FRAME_LIVE_P (f
))
2473 /* Avoid consing in frequent cases. */
2474 if (EQ (parameter
, Qname
))
2476 #ifdef HAVE_X_WINDOWS
2477 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2478 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2479 #endif /* HAVE_X_WINDOWS */
2480 else if (EQ (parameter
, Qbackground_color
)
2481 || EQ (parameter
, Qforeground_color
))
2483 value
= Fassq (parameter
, f
->param_alist
);
2486 value
= XCDR (value
);
2487 /* Fframe_parameters puts the actual fg/bg color names,
2488 even if f->param_alist says otherwise. This is
2489 important when param_alist's notion of colors is
2490 "unspecified". We need to do the same here. */
2491 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2493 const char *color_name
;
2496 if (EQ (parameter
, Qbackground_color
))
2498 color_name
= SDATA (value
);
2499 csz
= SCHARS (value
);
2500 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2501 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2502 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2503 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2505 else if (EQ (parameter
, Qforeground_color
))
2507 color_name
= SDATA (value
);
2508 csz
= SCHARS (value
);
2509 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2510 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2511 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2512 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2517 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2519 else if (EQ (parameter
, Qdisplay_type
)
2520 || EQ (parameter
, Qbackground_mode
))
2521 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2523 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2530 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2531 Smodify_frame_parameters
, 2, 2, 0,
2532 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2533 If FRAME is nil, it defaults to the selected frame.
2534 ALIST is an alist of parameters to change and their new values.
2535 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2536 The meaningful PARMs depend on the kind of frame.
2537 Undefined PARMs are ignored, but stored in the frame's parameter list
2538 so that `frame-parameters' will return them.
2540 The value of frame parameter FOO can also be accessed
2541 as a frame-local binding for the variable FOO, if you have
2542 enabled such bindings for that variable with `make-variable-frame-local'.
2543 Note that this functionality is obsolete as of Emacs 22.2, and its
2544 use is not recommended. Explicitly check for a frame-parameter instead. */)
2546 Lisp_Object frame
, alist
;
2549 register Lisp_Object tail
, prop
, val
;
2551 if (EQ (frame
, Qnil
))
2552 frame
= selected_frame
;
2553 CHECK_LIVE_FRAME (frame
);
2556 /* I think this should be done with a hook. */
2557 #ifdef HAVE_WINDOW_SYSTEM
2558 if (FRAME_WINDOW_P (f
))
2559 x_set_frame_parameters (f
, alist
);
2563 if (FRAME_MSDOS_P (f
))
2564 IT_set_frame_parameters (f
, alist
);
2569 int length
= XINT (Flength (alist
));
2572 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2574 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2576 /* Extract parm names and values into those vectors. */
2579 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2584 parms
[i
] = Fcar (elt
);
2585 values
[i
] = Fcdr (elt
);
2589 /* Now process them in reverse of specified order. */
2590 for (i
--; i
>= 0; i
--)
2594 store_frame_param (f
, prop
, val
);
2596 /* Changing the background color might change the background
2597 mode, so that we have to load new defface specs.
2598 Call frame-set-background-mode to do that. */
2599 if (EQ (prop
, Qbackground_color
))
2600 call1 (Qframe_set_background_mode
, frame
);
2606 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2608 doc
: /* Height in pixels of a line in the font in frame FRAME.
2609 If FRAME is omitted, the selected frame is used.
2610 For a terminal frame, the value is always 1. */)
2617 frame
= selected_frame
;
2618 CHECK_FRAME (frame
);
2621 #ifdef HAVE_WINDOW_SYSTEM
2622 if (FRAME_WINDOW_P (f
))
2623 return make_number (x_char_height (f
));
2626 return make_number (1);
2630 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2632 doc
: /* Width in pixels of characters in the font in frame FRAME.
2633 If FRAME is omitted, the selected frame is used.
2634 On a graphical screen, the width is the standard width of the default font.
2635 For a terminal screen, the value is always 1. */)
2642 frame
= selected_frame
;
2643 CHECK_FRAME (frame
);
2646 #ifdef HAVE_WINDOW_SYSTEM
2647 if (FRAME_WINDOW_P (f
))
2648 return make_number (x_char_width (f
));
2651 return make_number (1);
2654 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2655 Sframe_pixel_height
, 0, 1, 0,
2656 doc
: /* Return a FRAME's height in pixels.
2657 If FRAME is omitted, the selected frame is used. The exact value
2658 of the result depends on the window-system and toolkit in use:
2660 In the Gtk+ version of Emacs, it includes only any window (including
2661 the minibuffer or eacho area), mode line, and header line. It does not
2662 include the tool bar or menu bar.
2664 With the Motif or Lucid toolkits, it also includes the tool bar (but
2667 In a graphical version with no toolkit, it includes both the tool bar
2670 For a text-only terminal, it includes the menu bar. In this case, the
2671 result is really in characters rather than pixels (i.e., is identical
2672 to `frame-height'). */)
2679 frame
= selected_frame
;
2680 CHECK_FRAME (frame
);
2683 #ifdef HAVE_WINDOW_SYSTEM
2684 if (FRAME_WINDOW_P (f
))
2685 return make_number (x_pixel_height (f
));
2688 return make_number (FRAME_LINES (f
));
2691 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2692 Sframe_pixel_width
, 0, 1, 0,
2693 doc
: /* Return FRAME's width in pixels.
2694 For a terminal frame, the result really gives the width in characters.
2695 If FRAME is omitted, the selected frame is used. */)
2702 frame
= selected_frame
;
2703 CHECK_FRAME (frame
);
2706 #ifdef HAVE_WINDOW_SYSTEM
2707 if (FRAME_WINDOW_P (f
))
2708 return make_number (x_pixel_width (f
));
2711 return make_number (FRAME_COLS (f
));
2714 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2715 doc
: /* Specify that the frame FRAME has LINES lines.
2716 Optional third arg non-nil means that redisplay should use LINES lines
2717 but that the idea of the actual height of the frame should not be changed. */)
2718 (frame
, lines
, pretend
)
2719 Lisp_Object frame
, lines
, pretend
;
2721 register struct frame
*f
;
2723 CHECK_NUMBER (lines
);
2725 frame
= selected_frame
;
2726 CHECK_LIVE_FRAME (frame
);
2729 /* I think this should be done with a hook. */
2730 #ifdef HAVE_WINDOW_SYSTEM
2731 if (FRAME_WINDOW_P (f
))
2733 if (XINT (lines
) != FRAME_LINES (f
))
2734 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2735 do_pending_window_change (0);
2739 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2743 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2744 doc
: /* Specify that the frame FRAME has COLS columns.
2745 Optional third arg non-nil means that redisplay should use COLS columns
2746 but that the idea of the actual width of the frame should not be changed. */)
2747 (frame
, cols
, pretend
)
2748 Lisp_Object frame
, cols
, pretend
;
2750 register struct frame
*f
;
2751 CHECK_NUMBER (cols
);
2753 frame
= selected_frame
;
2754 CHECK_LIVE_FRAME (frame
);
2757 /* I think this should be done with a hook. */
2758 #ifdef HAVE_WINDOW_SYSTEM
2759 if (FRAME_WINDOW_P (f
))
2761 if (XINT (cols
) != FRAME_COLS (f
))
2762 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2763 do_pending_window_change (0);
2767 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2771 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2772 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2774 Lisp_Object frame
, cols
, rows
;
2776 register struct frame
*f
;
2778 CHECK_LIVE_FRAME (frame
);
2779 CHECK_NUMBER (cols
);
2780 CHECK_NUMBER (rows
);
2783 /* I think this should be done with a hook. */
2784 #ifdef HAVE_WINDOW_SYSTEM
2785 if (FRAME_WINDOW_P (f
))
2787 if (XINT (rows
) != FRAME_LINES (f
)
2788 || XINT (cols
) != FRAME_COLS (f
)
2789 || f
->new_text_lines
|| f
->new_text_cols
)
2790 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2791 do_pending_window_change (0);
2795 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2800 DEFUN ("set-frame-position", Fset_frame_position
,
2801 Sset_frame_position
, 3, 3, 0,
2802 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2803 This is actually the position of the upper left corner of the frame.
2804 Negative values for XOFFSET or YOFFSET are interpreted relative to
2805 the rightmost or bottommost possible position (that stays within the screen). */)
2806 (frame
, xoffset
, yoffset
)
2807 Lisp_Object frame
, xoffset
, yoffset
;
2809 register struct frame
*f
;
2811 CHECK_LIVE_FRAME (frame
);
2812 CHECK_NUMBER (xoffset
);
2813 CHECK_NUMBER (yoffset
);
2816 /* I think this should be done with a hook. */
2817 #ifdef HAVE_WINDOW_SYSTEM
2818 if (FRAME_WINDOW_P (f
))
2819 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2826 /***********************************************************************
2828 ***********************************************************************/
2830 /* Connect the frame-parameter names for X frames
2831 to the ways of passing the parameter values to the window system.
2833 The name of a parameter, as a Lisp symbol,
2834 has an `x-frame-parameter' property which is an integer in Lisp
2835 that is an index in this table. */
2837 struct frame_parm_table
{
2839 Lisp_Object
*variable
;
2842 static struct frame_parm_table frame_parms
[] =
2844 {"auto-raise", &Qauto_raise
},
2845 {"auto-lower", &Qauto_lower
},
2846 {"background-color", 0},
2847 {"border-color", &Qborder_color
},
2848 {"border-width", &Qborder_width
},
2849 {"cursor-color", &Qcursor_color
},
2850 {"cursor-type", &Qcursor_type
},
2852 {"foreground-color", 0},
2853 {"icon-name", &Qicon_name
},
2854 {"icon-type", &Qicon_type
},
2855 {"internal-border-width", &Qinternal_border_width
},
2856 {"menu-bar-lines", &Qmenu_bar_lines
},
2857 {"mouse-color", &Qmouse_color
},
2859 {"scroll-bar-width", &Qscroll_bar_width
},
2861 {"unsplittable", &Qunsplittable
},
2862 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2863 {"visibility", &Qvisibility
},
2864 {"tool-bar-lines", &Qtool_bar_lines
},
2865 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2866 {"scroll-bar-background", &Qscroll_bar_background
},
2867 {"screen-gamma", &Qscreen_gamma
},
2868 {"line-spacing", &Qline_spacing
},
2869 {"left-fringe", &Qleft_fringe
},
2870 {"right-fringe", &Qright_fringe
},
2871 {"wait-for-wm", &Qwait_for_wm
},
2872 {"fullscreen", &Qfullscreen
},
2873 {"font-backend", &Qfont_backend
},
2875 {"sticky", &Qsticky
},
2878 #ifdef HAVE_WINDOW_SYSTEM
2880 extern Lisp_Object Qbox
;
2881 extern Lisp_Object Qtop
;
2883 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2884 wanted positions of the WM window (not Emacs window).
2885 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2886 window (FRAME_X_WINDOW).
2890 x_fullscreen_adjust (f
, width
, height
, top_pos
, left_pos
)
2897 int newwidth
= FRAME_COLS (f
);
2898 int newheight
= FRAME_LINES (f
);
2899 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2901 *top_pos
= f
->top_pos
;
2902 *left_pos
= f
->left_pos
;
2904 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2908 ph
= x_display_pixel_height (dpyinfo
);
2909 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2910 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2911 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2915 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2919 pw
= x_display_pixel_width (dpyinfo
);
2920 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2921 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2922 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2927 *height
= newheight
;
2931 /* Change the parameters of frame F as specified by ALIST.
2932 If a parameter is not specially recognized, do nothing special;
2933 otherwise call the `x_set_...' function for that parameter.
2934 Except for certain geometry properties, always call store_frame_param
2935 to store the new value in the parameter alist. */
2938 x_set_frame_parameters (f
, alist
)
2944 /* If both of these parameters are present, it's more efficient to
2945 set them both at once. So we wait until we've looked at the
2946 entire list before we set them. */
2950 Lisp_Object left
, top
;
2952 /* Same with these. */
2953 Lisp_Object icon_left
, icon_top
;
2955 /* Record in these vectors all the parms specified. */
2957 Lisp_Object
*values
;
2959 int left_no_change
= 0, top_no_change
= 0;
2960 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2961 int size_changed
= 0;
2962 struct gcpro gcpro1
, gcpro2
;
2965 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2968 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2969 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2971 /* Extract parm names and values into those vectors. */
2974 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2979 parms
[i
] = Fcar (elt
);
2980 values
[i
] = Fcdr (elt
);
2983 /* TAIL and ALIST are not used again below here. */
2984 alist
= tail
= Qnil
;
2986 GCPRO2 (*parms
, *values
);
2990 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2991 because their values appear in VALUES and strings are not valid. */
2992 top
= left
= Qunbound
;
2993 icon_left
= icon_top
= Qunbound
;
2995 /* Provide default values for HEIGHT and WIDTH. */
2996 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2997 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2999 /* Process foreground_color and background_color before anything else.
3000 They are independent of other properties, but other properties (e.g.,
3001 cursor_color) are dependent upon them. */
3002 /* Process default font as well, since fringe widths depends on it. */
3003 for (p
= 0; p
< i
; p
++)
3005 Lisp_Object prop
, val
;
3009 if (EQ (prop
, Qforeground_color
)
3010 || EQ (prop
, Qbackground_color
)
3011 || EQ (prop
, Qfont
))
3013 register Lisp_Object param_index
, old_value
;
3015 old_value
= get_frame_param (f
, prop
);
3016 if (NILP (Fequal (val
, old_value
)))
3018 store_frame_param (f
, prop
, val
);
3020 param_index
= Fget (prop
, Qx_frame_parameter
);
3021 if (NATNUMP (param_index
)
3022 && (XFASTINT (param_index
)
3023 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3024 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3025 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3030 /* Now process them in reverse of specified order. */
3031 for (i
--; i
>= 0; i
--)
3033 Lisp_Object prop
, val
;
3038 if (EQ (prop
, Qwidth
) && NATNUMP (val
))
3041 width
= XFASTINT (val
);
3043 else if (EQ (prop
, Qheight
) && NATNUMP (val
))
3046 height
= XFASTINT (val
);
3048 else if (EQ (prop
, Qtop
))
3050 else if (EQ (prop
, Qleft
))
3052 else if (EQ (prop
, Qicon_top
))
3054 else if (EQ (prop
, Qicon_left
))
3056 else if (EQ (prop
, Qforeground_color
)
3057 || EQ (prop
, Qbackground_color
)
3058 || EQ (prop
, Qfont
))
3059 /* Processed above. */
3063 register Lisp_Object param_index
, old_value
;
3065 old_value
= get_frame_param (f
, prop
);
3067 store_frame_param (f
, prop
, val
);
3069 param_index
= Fget (prop
, Qx_frame_parameter
);
3070 if (NATNUMP (param_index
)
3071 && (XFASTINT (param_index
)
3072 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3073 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3074 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3078 /* Don't die if just one of these was set. */
3079 if (EQ (left
, Qunbound
))
3082 if (f
->left_pos
< 0)
3083 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
3085 XSETINT (left
, f
->left_pos
);
3087 if (EQ (top
, Qunbound
))
3091 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
3093 XSETINT (top
, f
->top_pos
);
3096 /* If one of the icon positions was not set, preserve or default it. */
3097 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
3099 icon_left_no_change
= 1;
3100 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3101 if (NILP (icon_left
))
3102 XSETINT (icon_left
, 0);
3104 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
3106 icon_top_no_change
= 1;
3107 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3108 if (NILP (icon_top
))
3109 XSETINT (icon_top
, 0);
3112 /* Don't set these parameters unless they've been explicitly
3113 specified. The window might be mapped or resized while we're in
3114 this function, and we don't want to override that unless the lisp
3115 code has asked for it.
3117 Don't set these parameters unless they actually differ from the
3118 window's current parameters; the window may not actually exist
3123 check_frame_size (f
, &height
, &width
);
3125 XSETFRAME (frame
, f
);
3128 && (width
!= FRAME_COLS (f
)
3129 || height
!= FRAME_LINES (f
)
3130 || f
->new_text_lines
|| f
->new_text_cols
))
3131 Fset_frame_size (frame
, make_number (width
), make_number (height
));
3133 if ((!NILP (left
) || !NILP (top
))
3134 && ! (left_no_change
&& top_no_change
)
3135 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3136 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3141 /* Record the signs. */
3142 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3143 if (EQ (left
, Qminus
))
3144 f
->size_hint_flags
|= XNegative
;
3145 else if (INTEGERP (left
))
3147 leftpos
= XINT (left
);
3149 f
->size_hint_flags
|= XNegative
;
3151 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3152 && CONSP (XCDR (left
))
3153 && INTEGERP (XCAR (XCDR (left
))))
3155 leftpos
= - XINT (XCAR (XCDR (left
)));
3156 f
->size_hint_flags
|= XNegative
;
3158 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3159 && CONSP (XCDR (left
))
3160 && INTEGERP (XCAR (XCDR (left
))))
3162 leftpos
= XINT (XCAR (XCDR (left
)));
3165 if (EQ (top
, Qminus
))
3166 f
->size_hint_flags
|= YNegative
;
3167 else if (INTEGERP (top
))
3169 toppos
= XINT (top
);
3171 f
->size_hint_flags
|= YNegative
;
3173 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3174 && CONSP (XCDR (top
))
3175 && INTEGERP (XCAR (XCDR (top
))))
3177 toppos
= - XINT (XCAR (XCDR (top
)));
3178 f
->size_hint_flags
|= YNegative
;
3180 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
3181 && CONSP (XCDR (top
))
3182 && INTEGERP (XCAR (XCDR (top
))))
3184 toppos
= XINT (XCAR (XCDR (top
)));
3188 /* Store the numeric value of the position. */
3189 f
->top_pos
= toppos
;
3190 f
->left_pos
= leftpos
;
3192 f
->win_gravity
= NorthWestGravity
;
3194 /* Actually set that position, and convert to absolute. */
3195 x_set_offset (f
, leftpos
, toppos
, -1);
3198 if ((!NILP (icon_left
) || !NILP (icon_top
))
3199 && ! (icon_left_no_change
&& icon_top_no_change
))
3200 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3207 /* Insert a description of internally-recorded parameters of frame X
3208 into the parameter alist *ALISTPTR that is to be given to the user.
3209 Only parameters that are specific to the X window system
3210 and whose values are not correctly recorded in the frame's
3211 param_alist need to be considered here. */
3214 x_report_frame_params (f
, alistptr
)
3216 Lisp_Object
*alistptr
;
3221 /* Represent negative positions (off the top or left screen edge)
3222 in a way that Fmodify_frame_parameters will understand correctly. */
3223 XSETINT (tem
, f
->left_pos
);
3224 if (f
->left_pos
>= 0)
3225 store_in_alist (alistptr
, Qleft
, tem
);
3227 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3229 XSETINT (tem
, f
->top_pos
);
3230 if (f
->top_pos
>= 0)
3231 store_in_alist (alistptr
, Qtop
, tem
);
3233 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3235 store_in_alist (alistptr
, Qborder_width
,
3236 make_number (f
->border_width
));
3237 store_in_alist (alistptr
, Qinternal_border_width
,
3238 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3239 store_in_alist (alistptr
, Qleft_fringe
,
3240 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3241 store_in_alist (alistptr
, Qright_fringe
,
3242 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3243 store_in_alist (alistptr
, Qscroll_bar_width
,
3244 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3246 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3247 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3248 /* nil means "use default width"
3249 for non-toolkit scroll bar.
3250 ruler-mode.el depends on this. */
3252 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
3253 store_in_alist (alistptr
, Qwindow_id
,
3254 build_string (buf
));
3255 #ifdef HAVE_X_WINDOWS
3256 #ifdef USE_X_TOOLKIT
3257 /* Tooltip frame may not have this widget. */
3258 if (FRAME_X_OUTPUT (f
)->widget
)
3260 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
3261 store_in_alist (alistptr
, Qouter_window_id
,
3262 build_string (buf
));
3264 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3265 FRAME_SAMPLE_VISIBILITY (f
);
3266 store_in_alist (alistptr
, Qvisibility
,
3267 (FRAME_VISIBLE_P (f
) ? Qt
3268 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3269 store_in_alist (alistptr
, Qdisplay
,
3270 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3272 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3275 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3276 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3277 store_in_alist (alistptr
, Qparent_id
, tem
);
3281 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3282 the previous value of that parameter, NEW_VALUE is the new value. */
3285 x_set_fullscreen (f
, new_value
, old_value
)
3287 Lisp_Object new_value
, old_value
;
3289 if (NILP (new_value
))
3290 f
->want_fullscreen
= FULLSCREEN_NONE
;
3291 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3292 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3293 else if (EQ (new_value
, Qfullwidth
))
3294 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3295 else if (EQ (new_value
, Qfullheight
))
3296 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3297 else if (EQ (new_value
, Qmaximized
))
3298 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3300 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3301 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3305 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3306 the previous value of that parameter, NEW_VALUE is the new value. */
3309 x_set_line_spacing (f
, new_value
, old_value
)
3311 Lisp_Object new_value
, old_value
;
3313 if (NILP (new_value
))
3314 f
->extra_line_spacing
= 0;
3315 else if (NATNUMP (new_value
))
3316 f
->extra_line_spacing
= XFASTINT (new_value
);
3318 signal_error ("Invalid line-spacing", new_value
);
3319 if (FRAME_VISIBLE_P (f
))
3324 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3325 the previous value of that parameter, NEW_VALUE is the new value. */
3328 x_set_screen_gamma (f
, new_value
, old_value
)
3330 Lisp_Object new_value
, old_value
;
3332 Lisp_Object bgcolor
;
3334 if (NILP (new_value
))
3336 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3337 /* The value 0.4545 is the normal viewing gamma. */
3338 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3340 signal_error ("Invalid screen-gamma", new_value
);
3342 /* Apply the new gamma value to the frame background. */
3343 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3344 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3346 Lisp_Object index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3348 && (XFASTINT (index
)
3349 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3350 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3351 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3355 Fclear_face_cache (Qnil
);
3360 x_set_font (f
, arg
, oldval
)
3362 Lisp_Object arg
, oldval
;
3364 Lisp_Object frame
, font_object
, font_param
= Qnil
;
3367 /* Set the frame parameter back to the old value because we may
3368 fail to use ARG as the new parameter value. */
3369 store_frame_param (f
, Qfont
, oldval
);
3371 /* ARG is a fontset name, a font name, a cons of fontset name and a
3372 font object, or a font object. In the last case, this function
3377 fontset
= fs_query_fontset (arg
, 0);
3380 font_object
= font_open_by_name (f
, SDATA (arg
));
3381 if (NILP (font_object
))
3382 error ("Font `%s' is not defined", SDATA (arg
));
3383 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3385 else if (fontset
> 0)
3387 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3389 font_object
= font_open_by_name (f
, SDATA (ascii_font
));
3390 if (NILP (font_object
))
3391 error ("Font `%s' is not defined", SDATA (arg
));
3392 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3395 error ("The default fontset can't be used for a frame font");
3397 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3399 /* This is the case that the ASCII font of F's fontset XCAR
3400 (arg) is changed to the font XCDR (arg) by
3401 `set-fontset-font'. */
3402 fontset
= fs_query_fontset (XCAR (arg
), 0);
3404 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3405 font_object
= XCDR (arg
);
3406 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3407 font_param
= Ffont_get (font_object
, QCname
);
3409 else if (FONT_OBJECT_P (arg
))
3412 font_param
= Ffont_get (font_object
, QCname
);
3413 /* This is to store the XLFD font name in the frame parameter for
3414 backward compatibility. We should store the font-object
3415 itself in the future. */
3416 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3417 fontset
= FRAME_FONTSET (f
);
3418 /* Check if we can use the current fontset. If not, set FONTSET
3419 to -1 to generate a new fontset from FONT-OBJECT. */
3422 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3423 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3425 if (! font_match_p (spec
, font_object
))
3430 signal_error ("Invalid font", arg
);
3432 if (! NILP (Fequal (font_object
, oldval
)))
3435 x_new_font (f
, font_object
, fontset
);
3436 store_frame_param (f
, Qfont
, arg
);
3437 #ifdef HAVE_X_WINDOWS
3438 store_frame_param (f
, Qfont_param
, font_param
);
3440 /* Recalculate toolbar height. */
3441 f
->n_tool_bar_rows
= 0;
3442 /* Ensure we redraw it. */
3443 clear_current_matrices (f
);
3445 recompute_basic_faces (f
);
3447 do_pending_window_change (0);
3449 /* We used to call face-set-after-frame-default here, but it leads to
3450 recursive calls (since that function can set the `default' face's
3451 font which in turns changes the frame's `font' parameter).
3452 Also I don't know what this call is meant to do, but it seems the
3453 wrong way to do it anyway (it does a lot more work than what seems
3454 reasonable in response to a change to `font'). */
3459 x_set_font_backend (f
, new_value
, old_value
)
3461 Lisp_Object new_value
, old_value
;
3463 if (! NILP (new_value
)
3464 && !CONSP (new_value
))
3468 CHECK_STRING (new_value
);
3469 p0
= p1
= SDATA (new_value
);
3473 while (*p1
&& ! isspace (*p1
) && *p1
!= ',') p1
++;
3475 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3481 while ((c
= *++p1
) && isspace (c
));
3485 new_value
= Fnreverse (new_value
);
3488 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3492 free_all_realized_faces (Qnil
);
3494 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3495 if (NILP (new_value
))
3497 if (NILP (old_value
))
3498 error ("No font backend available");
3499 font_update_drivers (f
, old_value
);
3500 error ("None of specified font backends are available");
3502 store_frame_param (f
, Qfont_backend
, new_value
);
3508 XSETFRAME (frame
, f
);
3509 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3510 ++face_change_count
;
3511 ++windows_or_buffers_changed
;
3517 x_set_fringe_width (f
, new_value
, old_value
)
3519 Lisp_Object new_value
, old_value
;
3521 compute_fringe_widths (f
, 1);
3525 x_set_border_width (f
, arg
, oldval
)
3527 Lisp_Object arg
, oldval
;
3531 if (XINT (arg
) == f
->border_width
)
3534 if (FRAME_X_WINDOW (f
) != 0)
3535 error ("Cannot change the border width of a frame");
3537 f
->border_width
= XINT (arg
);
3541 x_set_internal_border_width (f
, arg
, oldval
)
3543 Lisp_Object arg
, oldval
;
3545 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3548 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3549 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3550 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3552 #ifdef USE_X_TOOLKIT
3553 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3554 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3557 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3560 if (FRAME_X_WINDOW (f
) != 0)
3562 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3563 SET_FRAME_GARBAGED (f
);
3564 do_pending_window_change (0);
3567 SET_FRAME_GARBAGED (f
);
3571 x_set_visibility (f
, value
, oldval
)
3573 Lisp_Object value
, oldval
;
3576 XSETFRAME (frame
, f
);
3579 Fmake_frame_invisible (frame
, Qt
);
3580 else if (EQ (value
, Qicon
))
3581 Ficonify_frame (frame
);
3583 Fmake_frame_visible (frame
);
3587 x_set_autoraise (f
, arg
, oldval
)
3589 Lisp_Object arg
, oldval
;
3591 f
->auto_raise
= !EQ (Qnil
, arg
);
3595 x_set_autolower (f
, arg
, oldval
)
3597 Lisp_Object arg
, oldval
;
3599 f
->auto_lower
= !EQ (Qnil
, arg
);
3603 x_set_unsplittable (f
, arg
, oldval
)
3605 Lisp_Object arg
, oldval
;
3607 f
->no_split
= !NILP (arg
);
3611 x_set_vertical_scroll_bars (f
, arg
, oldval
)
3613 Lisp_Object arg
, oldval
;
3615 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3616 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3617 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3618 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3620 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3622 ? vertical_scroll_bar_none
3624 ? vertical_scroll_bar_left
3626 ? vertical_scroll_bar_right
3627 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3628 ? vertical_scroll_bar_left
3629 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3630 ? vertical_scroll_bar_right
3631 : vertical_scroll_bar_none
);
3633 /* We set this parameter before creating the X window for the
3634 frame, so we can get the geometry right from the start.
3635 However, if the window hasn't been created yet, we shouldn't
3636 call x_set_window_size. */
3637 if (FRAME_X_WINDOW (f
))
3638 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3639 do_pending_window_change (0);
3644 x_set_scroll_bar_width (f
, arg
, oldval
)
3646 Lisp_Object arg
, oldval
;
3648 int wid
= FRAME_COLUMN_WIDTH (f
);
3652 x_set_scroll_bar_default_width (f
);
3654 if (FRAME_X_WINDOW (f
))
3655 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3656 do_pending_window_change (0);
3658 else if (INTEGERP (arg
) && XINT (arg
) > 0
3659 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3661 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3662 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3664 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3665 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3666 if (FRAME_X_WINDOW (f
))
3667 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3668 do_pending_window_change (0);
3671 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3672 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3673 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3678 /* Return non-nil if frame F wants a bitmap icon. */
3686 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3694 x_set_alpha (f
, arg
, oldval
)
3696 Lisp_Object arg
, oldval
;
3703 for (i
= 0; i
< 2; i
++)
3716 else if (FLOATP (item
))
3718 alpha
= XFLOAT_DATA (item
);
3719 if (alpha
< 0.0 || 1.0 < alpha
)
3720 args_out_of_range (make_float (0.0), make_float (1.0));
3722 else if (INTEGERP (item
))
3724 ialpha
= XINT (item
);
3725 if (ialpha
< 0 || 100 < ialpha
)
3726 args_out_of_range (make_number (0), make_number (100));
3728 alpha
= ialpha
/ 100.0;
3731 wrong_type_argument (Qnumberp
, item
);
3735 for (i
= 0; i
< 2; i
++)
3736 f
->alpha
[i
] = newval
[i
];
3738 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3740 x_set_frame_alpha (f
);
3748 /* Subroutines of creating an X frame. */
3750 /* Make sure that Vx_resource_name is set to a reasonable value.
3751 Fix it up, or set it to `emacs' if it is too hopeless. */
3754 validate_x_resource_name ()
3757 /* Number of valid characters in the resource name. */
3759 /* Number of invalid characters in the resource name. */
3764 if (!STRINGP (Vx_resource_class
))
3765 Vx_resource_class
= build_string (EMACS_CLASS
);
3767 if (STRINGP (Vx_resource_name
))
3769 unsigned char *p
= SDATA (Vx_resource_name
);
3772 len
= SBYTES (Vx_resource_name
);
3774 /* Only letters, digits, - and _ are valid in resource names.
3775 Count the valid characters and count the invalid ones. */
3776 for (i
= 0; i
< len
; i
++)
3779 if (! ((c
>= 'a' && c
<= 'z')
3780 || (c
>= 'A' && c
<= 'Z')
3781 || (c
>= '0' && c
<= '9')
3782 || c
== '-' || c
== '_'))
3789 /* Not a string => completely invalid. */
3790 bad_count
= 5, good_count
= 0;
3792 /* If name is valid already, return. */
3796 /* If name is entirely invalid, or nearly so, use `emacs'. */
3798 || (good_count
== 1 && bad_count
> 0))
3800 Vx_resource_name
= build_string ("emacs");
3804 /* Name is partly valid. Copy it and replace the invalid characters
3805 with underscores. */
3807 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3809 for (i
= 0; i
< len
; i
++)
3811 int c
= SREF (new, i
);
3812 if (! ((c
>= 'a' && c
<= 'z')
3813 || (c
>= 'A' && c
<= 'Z')
3814 || (c
>= '0' && c
<= '9')
3815 || c
== '-' || c
== '_'))
3821 extern char *x_get_string_resource
P_ ((XrmDatabase
, char *, char *));
3822 extern Display_Info
*check_x_display_info
P_ ((Lisp_Object
));
3825 /* Get specified attribute from resource database RDB.
3826 See Fx_get_resource below for other parameters. */
3829 xrdb_get_resource (rdb
, attribute
, class, component
, subclass
)
3831 Lisp_Object attribute
, class, component
, subclass
;
3833 register char *value
;
3837 CHECK_STRING (attribute
);
3838 CHECK_STRING (class);
3840 if (!NILP (component
))
3841 CHECK_STRING (component
);
3842 if (!NILP (subclass
))
3843 CHECK_STRING (subclass
);
3844 if (NILP (component
) != NILP (subclass
))
3845 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3847 validate_x_resource_name ();
3849 /* Allocate space for the components, the dots which separate them,
3850 and the final '\0'. Make them big enough for the worst case. */
3851 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3852 + (STRINGP (component
)
3853 ? SBYTES (component
) : 0)
3854 + SBYTES (attribute
)
3857 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3859 + (STRINGP (subclass
)
3860 ? SBYTES (subclass
) : 0)
3863 /* Start with emacs.FRAMENAME for the name (the specific one)
3864 and with `Emacs' for the class key (the general one). */
3865 strcpy (name_key
, SDATA (Vx_resource_name
));
3866 strcpy (class_key
, SDATA (Vx_resource_class
));
3868 strcat (class_key
, ".");
3869 strcat (class_key
, SDATA (class));
3871 if (!NILP (component
))
3873 strcat (class_key
, ".");
3874 strcat (class_key
, SDATA (subclass
));
3876 strcat (name_key
, ".");
3877 strcat (name_key
, SDATA (component
));
3880 strcat (name_key
, ".");
3881 strcat (name_key
, SDATA (attribute
));
3883 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3885 if (value
!= (char *) 0 && *value
)
3886 return build_string (value
);
3892 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3893 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3894 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3895 class, where INSTANCE is the name under which Emacs was invoked, or
3896 the name specified by the `-name' or `-rn' command-line arguments.
3898 The optional arguments COMPONENT and SUBCLASS add to the key and the
3899 class, respectively. You must specify both of them or neither.
3900 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3901 and the class is `Emacs.CLASS.SUBCLASS'. */)
3902 (attribute
, class, component
, subclass
)
3903 Lisp_Object attribute
, class, component
, subclass
;
3905 #ifdef HAVE_X_WINDOWS
3909 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3910 attribute
, class, component
, subclass
);
3913 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3916 display_x_get_resource (dpyinfo
, attribute
, class, component
, subclass
)
3917 Display_Info
*dpyinfo
;
3918 Lisp_Object attribute
, class, component
, subclass
;
3920 return xrdb_get_resource (dpyinfo
->xrdb
,
3921 attribute
, class, component
, subclass
);
3924 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3925 /* Used when C code wants a resource value. */
3926 /* Called from oldXMenu/Create.c. */
3928 x_get_resource_string (attribute
, class)
3929 char *attribute
, *class;
3933 struct frame
*sf
= SELECTED_FRAME ();
3935 /* Allocate space for the components, the dots which separate them,
3936 and the final '\0'. */
3937 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3938 + strlen (attribute
) + 2);
3939 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3940 + strlen (class) + 2);
3942 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3943 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3945 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3946 name_key
, class_key
);
3950 /* Return the value of parameter PARAM.
3952 First search ALIST, then Vdefault_frame_alist, then the X defaults
3953 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3955 Convert the resource to the type specified by desired_type.
3957 If no default is specified, return Qunbound. If you call
3958 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3959 and don't let it get stored in any Lisp-visible variables! */
3962 x_get_arg (dpyinfo
, alist
, param
, attribute
, class, type
)
3963 Display_Info
*dpyinfo
;
3964 Lisp_Object alist
, param
;
3967 enum resource_types type
;
3969 register Lisp_Object tem
;
3971 tem
= Fassq (param
, alist
);
3975 /* If we find this parm in ALIST, clear it out
3976 so that it won't be "left over" at the end. */
3978 XSETCAR (tem
, Qnil
);
3979 /* In case the parameter appears more than once in the alist,
3981 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3982 if (CONSP (XCAR (tail
))
3983 && EQ (XCAR (XCAR (tail
)), param
))
3984 XSETCAR (XCAR (tail
), Qnil
);
3987 tem
= Fassq (param
, Vdefault_frame_alist
);
3989 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3990 look in the X resources. */
3993 if (attribute
&& dpyinfo
)
3995 tem
= display_x_get_resource (dpyinfo
,
3996 build_string (attribute
),
3997 build_string (class),
4005 case RES_TYPE_NUMBER
:
4006 return make_number (atoi (SDATA (tem
)));
4008 case RES_TYPE_FLOAT
:
4009 return make_float (atof (SDATA (tem
)));
4011 case RES_TYPE_BOOLEAN
:
4012 tem
= Fdowncase (tem
);
4013 if (!strcmp (SDATA (tem
), "on")
4015 || !strcmp(SDATA(tem
), "yes")
4017 || !strcmp (SDATA (tem
), "true"))
4022 case RES_TYPE_STRING
:
4025 case RES_TYPE_SYMBOL
:
4026 /* As a special case, we map the values `true' and `on'
4027 to Qt, and `false' and `off' to Qnil. */
4030 lower
= Fdowncase (tem
);
4031 if (!strcmp (SDATA (lower
), "on")
4033 || !strcmp(SDATA(lower
), "yes")
4035 || !strcmp (SDATA (lower
), "true"))
4037 else if (!strcmp (SDATA (lower
), "off")
4039 || !strcmp(SDATA(lower
), "no")
4041 || !strcmp (SDATA (lower
), "false"))
4044 return Fintern (tem
, Qnil
);
4058 x_frame_get_arg (f
, alist
, param
, attribute
, class, type
)
4060 Lisp_Object alist
, param
;
4063 enum resource_types type
;
4065 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
4066 alist
, param
, attribute
, class, type
);
4069 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
4072 x_frame_get_and_record_arg (f
, alist
, param
, attribute
, class, type
)
4074 Lisp_Object alist
, param
;
4077 enum resource_types type
;
4081 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
4082 attribute
, class, type
);
4083 if (! NILP (value
) && ! EQ (value
, Qunbound
))
4084 store_frame_param (f
, param
, value
);
4090 /* Record in frame F the specified or default value according to ALIST
4091 of the parameter named PROP (a Lisp symbol).
4092 If no value is specified for PROP, look for an X default for XPROP
4093 on the frame named NAME.
4094 If that is not found either, use the value DEFLT. */
4097 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
4104 enum resource_types type
;
4108 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
4109 if (EQ (tem
, Qunbound
))
4111 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
4118 /* NS used to define x-parse-geometry in ns-win.el, but that confused
4119 make-docfile: the documentation string in ns-win.el was used for
4120 x-parse-geometry even in non-NS builds.
4122 With two definitions of x-parse-geometry in this file, various
4123 things still get confused (eg M-x apropos documentation), so that
4124 it is best if the two definitions just share the same doc-string.
4126 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4127 doc
: /* Parse a display geometry string STRING.
4128 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4129 The properties returned may include `top', `left', `height', and `width'.
4130 For X, the value of `left' or `top' may be an integer,
4131 or a list (+ N) meaning N pixels relative to top/left corner,
4132 or a list (- N) meaning -N pixels relative to bottom/right corner.
4133 On Nextstep, this just calls `ns-parse-geometry'. */)
4138 call1 (Qns_parse_geometry
, string
);
4141 unsigned int width
, height
;
4144 CHECK_STRING (string
);
4146 geometry
= XParseGeometry ((char *) SDATA (string
),
4147 &x
, &y
, &width
, &height
);
4149 if (geometry
& XValue
)
4151 Lisp_Object element
;
4153 if (x
>= 0 && (geometry
& XNegative
))
4154 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
4155 else if (x
< 0 && ! (geometry
& XNegative
))
4156 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
4158 element
= Fcons (Qleft
, make_number (x
));
4159 result
= Fcons (element
, result
);
4162 if (geometry
& YValue
)
4164 Lisp_Object element
;
4166 if (y
>= 0 && (geometry
& YNegative
))
4167 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
4168 else if (y
< 0 && ! (geometry
& YNegative
))
4169 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
4171 element
= Fcons (Qtop
, make_number (y
));
4172 result
= Fcons (element
, result
);
4175 if (geometry
& WidthValue
)
4176 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
4177 if (geometry
& HeightValue
)
4178 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
4181 #endif /* HAVE_NS */
4185 /* Calculate the desired size and position of frame F.
4186 Return the flags saying which aspects were specified.
4188 Also set the win_gravity and size_hint_flags of F.
4190 Adjust height for toolbar if TOOLBAR_P is 1.
4192 This function does not make the coordinates positive. */
4194 #define DEFAULT_ROWS 40
4195 #define DEFAULT_COLS 80
4198 x_figure_window_size (f
, parms
, toolbar_p
)
4203 register Lisp_Object tem0
, tem1
, tem2
;
4204 long window_prompting
= 0;
4205 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
4207 /* Default values if we fall through.
4208 Actually, if that happens we should get
4209 window manager prompting. */
4210 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4211 FRAME_LINES (f
) = DEFAULT_ROWS
;
4212 /* Window managers expect that if program-specified
4213 positions are not (0,0), they're intentional, not defaults. */
4217 /* Ensure that old new_text_cols and new_text_lines will not override the
4219 /* ++KFS: This was specific to W32, but seems ok for all platforms */
4220 f
->new_text_cols
= f
->new_text_lines
= 0;
4222 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4223 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4224 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4225 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4227 if (!EQ (tem0
, Qunbound
))
4229 CHECK_NUMBER (tem0
);
4230 FRAME_LINES (f
) = XINT (tem0
);
4232 if (!EQ (tem1
, Qunbound
))
4234 CHECK_NUMBER (tem1
);
4235 SET_FRAME_COLS (f
, XINT (tem1
));
4237 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4238 window_prompting
|= USSize
;
4240 window_prompting
|= PSize
;
4243 f
->scroll_bar_actual_width
4244 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4246 /* This used to be done _before_ calling x_figure_window_size, but
4247 since the height is reset here, this was really a no-op. I
4248 assume that moving it here does what Gerd intended (although he
4249 no longer can remember what that was... ++KFS, 2003-03-25. */
4251 /* Add the tool-bar height to the initial frame height so that the
4252 user gets a text display area of the size he specified with -g or
4253 via .Xdefaults. Later changes of the tool-bar height don't
4254 change the frame size. This is done so that users can create
4255 tall Emacs frames without having to guess how tall the tool-bar
4257 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4259 int margin
, relief
, bar_height
;
4261 relief
= (tool_bar_button_relief
>= 0
4262 ? tool_bar_button_relief
4263 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4265 if (INTEGERP (Vtool_bar_button_margin
)
4266 && XINT (Vtool_bar_button_margin
) > 0)
4267 margin
= XFASTINT (Vtool_bar_button_margin
);
4268 else if (CONSP (Vtool_bar_button_margin
)
4269 && INTEGERP (XCDR (Vtool_bar_button_margin
))
4270 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
4271 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4275 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4276 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4279 compute_fringe_widths (f
, 0);
4281 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4282 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4284 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4285 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4286 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4287 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4289 if (EQ (tem0
, Qminus
))
4292 window_prompting
|= YNegative
;
4294 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4295 && CONSP (XCDR (tem0
))
4296 && INTEGERP (XCAR (XCDR (tem0
))))
4298 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4299 window_prompting
|= YNegative
;
4301 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4302 && CONSP (XCDR (tem0
))
4303 && INTEGERP (XCAR (XCDR (tem0
))))
4305 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4307 else if (EQ (tem0
, Qunbound
))
4311 CHECK_NUMBER (tem0
);
4312 f
->top_pos
= XINT (tem0
);
4314 window_prompting
|= YNegative
;
4317 if (EQ (tem1
, Qminus
))
4320 window_prompting
|= XNegative
;
4322 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4323 && CONSP (XCDR (tem1
))
4324 && INTEGERP (XCAR (XCDR (tem1
))))
4326 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4327 window_prompting
|= XNegative
;
4329 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4330 && CONSP (XCDR (tem1
))
4331 && INTEGERP (XCAR (XCDR (tem1
))))
4333 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4335 else if (EQ (tem1
, Qunbound
))
4339 CHECK_NUMBER (tem1
);
4340 f
->left_pos
= XINT (tem1
);
4341 if (f
->left_pos
< 0)
4342 window_prompting
|= XNegative
;
4345 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4346 window_prompting
|= USPosition
;
4348 window_prompting
|= PPosition
;
4351 if (window_prompting
& XNegative
)
4353 if (window_prompting
& YNegative
)
4354 f
->win_gravity
= SouthEastGravity
;
4356 f
->win_gravity
= NorthEastGravity
;
4360 if (window_prompting
& YNegative
)
4361 f
->win_gravity
= SouthWestGravity
;
4363 f
->win_gravity
= NorthWestGravity
;
4366 f
->size_hint_flags
= window_prompting
;
4368 return window_prompting
;
4373 #endif /* HAVE_WINDOW_SYSTEM */
4376 frame_make_pointer_invisible ()
4378 if (! NILP (Vmake_pointer_invisible
))
4381 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4384 f
= SELECTED_FRAME ();
4385 if (f
&& !f
->pointer_invisible
4386 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4389 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4390 f
->pointer_invisible
= 1;
4396 frame_make_pointer_visible ()
4398 /* We don't check Vmake_pointer_invisible here in case the
4399 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4402 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4405 f
= SELECTED_FRAME ();
4406 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4407 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4409 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4410 f
->pointer_invisible
= 0;
4416 /***********************************************************************
4418 ***********************************************************************/
4423 Qframep
= intern_c_string ("framep");
4424 staticpro (&Qframep
);
4425 Qframe_live_p
= intern_c_string ("frame-live-p");
4426 staticpro (&Qframe_live_p
);
4427 Qexplicit_name
= intern_c_string ("explicit-name");
4428 staticpro (&Qexplicit_name
);
4429 Qheight
= intern_c_string ("height");
4430 staticpro (&Qheight
);
4431 Qicon
= intern_c_string ("icon");
4433 Qminibuffer
= intern_c_string ("minibuffer");
4434 staticpro (&Qminibuffer
);
4435 Qmodeline
= intern_c_string ("modeline");
4436 staticpro (&Qmodeline
);
4437 Qonly
= intern_c_string ("only");
4439 Qwidth
= intern_c_string ("width");
4440 staticpro (&Qwidth
);
4441 Qgeometry
= intern_c_string ("geometry");
4442 staticpro (&Qgeometry
);
4443 Qicon_left
= intern_c_string ("icon-left");
4444 staticpro (&Qicon_left
);
4445 Qicon_top
= intern_c_string ("icon-top");
4446 staticpro (&Qicon_top
);
4447 Qleft
= intern_c_string ("left");
4449 Qright
= intern_c_string ("right");
4450 staticpro (&Qright
);
4451 Quser_position
= intern_c_string ("user-position");
4452 staticpro (&Quser_position
);
4453 Quser_size
= intern_c_string ("user-size");
4454 staticpro (&Quser_size
);
4455 Qwindow_id
= intern_c_string ("window-id");
4456 staticpro (&Qwindow_id
);
4457 #ifdef HAVE_X_WINDOWS
4458 Qouter_window_id
= intern_c_string ("outer-window-id");
4459 staticpro (&Qouter_window_id
);
4461 Qparent_id
= intern_c_string ("parent-id");
4462 staticpro (&Qparent_id
);
4463 Qx
= intern_c_string ("x");
4465 Qw32
= intern_c_string ("w32");
4467 Qpc
= intern_c_string ("pc");
4469 Qmac
= intern_c_string ("mac");
4471 Qns
= intern_c_string ("ns");
4473 Qvisible
= intern_c_string ("visible");
4474 staticpro (&Qvisible
);
4475 Qbuffer_predicate
= intern_c_string ("buffer-predicate");
4476 staticpro (&Qbuffer_predicate
);
4477 Qbuffer_list
= intern_c_string ("buffer-list");
4478 staticpro (&Qbuffer_list
);
4479 Qburied_buffer_list
= intern_c_string ("buried-buffer-list");
4480 staticpro (&Qburied_buffer_list
);
4481 Qdisplay_type
= intern_c_string ("display-type");
4482 staticpro (&Qdisplay_type
);
4483 Qbackground_mode
= intern_c_string ("background-mode");
4484 staticpro (&Qbackground_mode
);
4485 Qnoelisp
= intern_c_string ("noelisp");
4486 staticpro (&Qnoelisp
);
4487 Qtty_color_mode
= intern_c_string ("tty-color-mode");
4488 staticpro (&Qtty_color_mode
);
4489 Qtty
= intern_c_string ("tty");
4491 Qtty_type
= intern_c_string ("tty-type");
4492 staticpro (&Qtty_type
);
4494 Qface_set_after_frame_default
= intern_c_string ("face-set-after-frame-default");
4495 staticpro (&Qface_set_after_frame_default
);
4497 Qfullwidth
= intern_c_string ("fullwidth");
4498 staticpro (&Qfullwidth
);
4499 Qfullheight
= intern_c_string ("fullheight");
4500 staticpro (&Qfullheight
);
4501 Qfullboth
= intern_c_string ("fullboth");
4502 staticpro (&Qfullboth
);
4503 Qmaximized
= intern_c_string ("maximized");
4504 staticpro (&Qmaximized
);
4505 Qx_resource_name
= intern_c_string ("x-resource-name");
4506 staticpro (&Qx_resource_name
);
4508 Qx_frame_parameter
= intern_c_string ("x-frame-parameter");
4509 staticpro (&Qx_frame_parameter
);
4511 Qterminal
= intern_c_string ("terminal");
4512 staticpro (&Qterminal
);
4513 Qterminal_live_p
= intern_c_string ("terminal-live-p");
4514 staticpro (&Qterminal_live_p
);
4517 Qns_parse_geometry
= intern_c_string ("ns-parse-geometry");
4518 staticpro (&Qns_parse_geometry
);
4524 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4526 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4527 if (frame_parms
[i
].variable
)
4529 *frame_parms
[i
].variable
= v
;
4530 staticpro (frame_parms
[i
].variable
);
4532 Fput (v
, Qx_frame_parameter
, make_number (i
));
4536 #ifdef HAVE_WINDOW_SYSTEM
4537 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4538 doc
: /* The name Emacs uses to look up X resources.
4539 `x-get-resource' uses this as the first component of the instance name
4540 when requesting resource values.
4541 Emacs initially sets `x-resource-name' to the name under which Emacs
4542 was invoked, or to the value specified with the `-name' or `-rn'
4543 switches, if present.
4545 It may be useful to bind this variable locally around a call
4546 to `x-get-resource'. See also the variable `x-resource-class'. */);
4547 Vx_resource_name
= Qnil
;
4549 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4550 doc
: /* The class Emacs uses to look up X resources.
4551 `x-get-resource' uses this as the first component of the instance class
4552 when requesting resource values.
4554 Emacs initially sets `x-resource-class' to "Emacs".
4556 Setting this variable permanently is not a reasonable thing to do,
4557 but binding this variable locally around a call to `x-get-resource'
4558 is a reasonable practice. See also the variable `x-resource-name'. */);
4559 Vx_resource_class
= build_string (EMACS_CLASS
);
4561 DEFVAR_LISP ("frame-alpha-lower-limit", &Vframe_alpha_lower_limit
,
4562 doc
: /* The lower limit of the frame opacity (alpha transparency).
4563 The value should range from 0 (invisible) to 100 (completely opaque).
4564 You can also use a floating number between 0.0 and 1.0.
4565 The default is 20. */);
4566 Vframe_alpha_lower_limit
= make_number (20);
4569 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4570 doc
: /* Alist of default values for frame creation.
4571 These may be set in your init file, like this:
4572 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4573 These override values given in window system configuration data,
4574 including X Windows' defaults database.
4575 For values specific to the first Emacs frame, see `initial-frame-alist'.
4576 For window-system specific values, see `window-system-default-frame-alist'.
4577 For values specific to the separate minibuffer frame, see
4578 `minibuffer-frame-alist'.
4579 The `menu-bar-lines' element of the list controls whether new frames
4580 have menu bars; `menu-bar-mode' works by altering this element.
4581 Setting this variable does not affect existing frames, only new ones. */);
4582 Vdefault_frame_alist
= Qnil
;
4584 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars
,
4585 doc
: /* Default position of scroll bars on this window-system. */);
4586 #ifdef HAVE_WINDOW_SYSTEM
4587 #if defined(HAVE_NTGUI) || defined(NS_IMPL_COCOA)
4588 /* MS-Windows and Mac OS X have scroll bars on the right by default. */
4589 Vdefault_frame_scroll_bars
= Qright
;
4591 Vdefault_frame_scroll_bars
= Qleft
;
4594 Vdefault_frame_scroll_bars
= Qnil
;
4597 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4598 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4600 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4601 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4602 `mouse-position' calls this function, passing its usual return value as
4603 argument, and returns whatever this function returns.
4604 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4605 which need to do mouse handling at the Lisp level. */);
4606 Vmouse_position_function
= Qnil
;
4608 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4609 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4610 If the value is an integer, highlighting is only shown after moving the
4611 mouse, while keyboard input turns off the highlight even when the mouse
4612 is over the clickable text. However, the mouse shape still indicates
4613 when the mouse is over clickable text. */);
4614 Vmouse_highlight
= Qt
;
4616 DEFVAR_LISP ("make-pointer-invisible", &Vmake_pointer_invisible
,
4617 doc
: /* If non-nil, make pointer invisible while typing.
4618 The pointer becomes visible again when the mouse is moved. */);
4619 Vmake_pointer_invisible
= Qt
;
4621 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4622 doc
: /* Functions to be run before deleting a frame.
4623 The functions are run with one arg, the frame to be deleted.
4626 Note that functions in this list may be called just before the frame is
4627 actually deleted, or some time later (or even both when an earlier function
4628 in `delete-frame-functions' (indirectly) calls `delete-frame'
4630 Vdelete_frame_functions
= Qnil
;
4631 Qdelete_frame_functions
= intern_c_string ("delete-frame-functions");
4632 staticpro (&Qdelete_frame_functions
);
4634 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4635 doc
: /* Minibufferless frames use this frame's minibuffer.
4637 Emacs cannot create minibufferless frames unless this is set to an
4638 appropriate surrogate.
4640 Emacs consults this variable only when creating minibufferless
4641 frames; once the frame is created, it sticks with its assigned
4642 minibuffer, no matter what this variable is set to. This means that
4643 this variable doesn't necessarily say anything meaningful about the
4644 current set of frames, or where the minibuffer is currently being
4647 This variable is local to the current terminal and cannot be buffer-local. */);
4649 DEFVAR_BOOL ("focus-follows-mouse", &focus_follows_mouse
,
4650 doc
: /* Non-nil if window system changes focus when you move the mouse.
4651 You should set this variable to tell Emacs how your window manager
4652 handles focus, since there is no way in general for Emacs to find out
4653 automatically. See also `mouse-autoselect-window'. */);
4654 #ifdef HAVE_WINDOW_SYSTEM
4655 #if defined(HAVE_NTGUI) || defined(HAVE_NS)
4656 focus_follows_mouse
= 0;
4658 focus_follows_mouse
= 1;
4661 focus_follows_mouse
= 0;
4664 staticpro (&Vframe_list
);
4666 defsubr (&Sactive_minibuffer_window
);
4668 defsubr (&Sframe_live_p
);
4669 defsubr (&Swindow_system
);
4670 defsubr (&Smake_terminal_frame
);
4671 defsubr (&Shandle_switch_frame
);
4672 defsubr (&Sselect_frame
);
4673 defsubr (&Sselected_frame
);
4674 defsubr (&Swindow_frame
);
4675 defsubr (&Sframe_root_window
);
4676 defsubr (&Sframe_first_window
);
4677 defsubr (&Sframe_selected_window
);
4678 defsubr (&Sset_frame_selected_window
);
4679 defsubr (&Sframe_list
);
4680 defsubr (&Snext_frame
);
4681 defsubr (&Sprevious_frame
);
4682 defsubr (&Sdelete_frame
);
4683 defsubr (&Smouse_position
);
4684 defsubr (&Smouse_pixel_position
);
4685 defsubr (&Sset_mouse_position
);
4686 defsubr (&Sset_mouse_pixel_position
);
4688 defsubr (&Sframe_configuration
);
4689 defsubr (&Srestore_frame_configuration
);
4691 defsubr (&Smake_frame_visible
);
4692 defsubr (&Smake_frame_invisible
);
4693 defsubr (&Siconify_frame
);
4694 defsubr (&Sframe_visible_p
);
4695 defsubr (&Svisible_frame_list
);
4696 defsubr (&Sraise_frame
);
4697 defsubr (&Slower_frame
);
4698 defsubr (&Sredirect_frame_focus
);
4699 defsubr (&Sframe_focus
);
4700 defsubr (&Sframe_parameters
);
4701 defsubr (&Sframe_parameter
);
4702 defsubr (&Smodify_frame_parameters
);
4703 defsubr (&Sframe_char_height
);
4704 defsubr (&Sframe_char_width
);
4705 defsubr (&Sframe_pixel_height
);
4706 defsubr (&Sframe_pixel_width
);
4707 defsubr (&Sset_frame_height
);
4708 defsubr (&Sset_frame_width
);
4709 defsubr (&Sset_frame_size
);
4710 defsubr (&Sset_frame_position
);
4712 #ifdef HAVE_WINDOW_SYSTEM
4713 defsubr (&Sx_get_resource
);
4714 defsubr (&Sx_parse_geometry
);
4719 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4720 (do not change this comment) */