1 /* Generic frame functions.
3 Copyright (C) 1993-1995, 1997, 1999-2013 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/>. */
22 #define FRAME_INLINE EXTERN_INLINE
31 #include "character.h"
33 #ifdef HAVE_WINDOW_SYSTEM
35 #endif /* HAVE_WINDOW_SYSTEM */
38 /* These help us bind and responding to switch-frame events. */
42 #include "blockinput.h"
44 #include "termhooks.h"
45 #include "dispextern.h"
48 #ifdef HAVE_WINDOW_SYSTEM
57 Lisp_Object Qns_parse_geometry
;
60 Lisp_Object Qframep
, Qframe_live_p
;
61 Lisp_Object Qicon
, Qmodeline
;
62 Lisp_Object Qonly
, Qnone
;
63 Lisp_Object Qx
, Qw32
, Qpc
, Qns
;
65 Lisp_Object Qdisplay_type
;
66 static Lisp_Object Qbackground_mode
;
69 static Lisp_Object Qx_frame_parameter
;
70 Lisp_Object Qx_resource_name
;
71 Lisp_Object Qterminal
;
72 Lisp_Object Qterminal_live_p
;
74 /* Frame parameters (set or reported). */
76 Lisp_Object Qauto_raise
, Qauto_lower
;
77 Lisp_Object Qborder_color
, Qborder_width
;
78 Lisp_Object Qcursor_color
, Qcursor_type
;
79 static Lisp_Object Qgeometry
; /* Not used */
80 Lisp_Object Qheight
, Qwidth
;
81 Lisp_Object Qleft
, Qright
;
82 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
84 Lisp_Object Qinternal_border_width
;
85 Lisp_Object Qmouse_color
;
86 Lisp_Object Qminibuffer
;
87 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
88 Lisp_Object Qvisibility
;
89 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
90 Lisp_Object Qscreen_gamma
;
91 Lisp_Object Qline_spacing
;
92 static Lisp_Object Quser_position
, Quser_size
;
93 Lisp_Object Qwait_for_wm
;
94 static Lisp_Object Qwindow_id
;
96 static Lisp_Object Qouter_window_id
;
98 Lisp_Object Qparent_id
;
99 Lisp_Object Qtitle
, Qname
;
100 static Lisp_Object Qexplicit_name
;
101 Lisp_Object Qunsplittable
;
102 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
, Qtool_bar_position
;
103 Lisp_Object Qleft_fringe
, Qright_fringe
;
104 Lisp_Object Qbuffer_predicate
;
105 static Lisp_Object Qbuffer_list
, Qburied_buffer_list
;
106 Lisp_Object Qtty_color_mode
;
107 Lisp_Object Qtty
, Qtty_type
;
109 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
111 Lisp_Object Qfont_backend
;
114 Lisp_Object Qface_set_after_frame_default
;
116 static Lisp_Object Qdelete_frame_functions
;
118 #ifdef HAVE_WINDOW_SYSTEM
119 static void x_report_frame_params (struct frame
*, Lisp_Object
*);
122 /* These setters are used only in this file, so they can be private. */
124 fset_buffer_predicate (struct frame
*f
, Lisp_Object val
)
126 f
->buffer_predicate
= val
;
129 fset_minibuffer_window (struct frame
*f
, Lisp_Object val
)
131 f
->minibuffer_window
= val
;
135 decode_live_frame (register Lisp_Object frame
)
138 frame
= selected_frame
;
139 CHECK_LIVE_FRAME (frame
);
140 return XFRAME (frame
);
144 decode_any_frame (register Lisp_Object frame
)
147 frame
= selected_frame
;
149 return XFRAME (frame
);
153 window_system_available (struct frame
*f
)
156 return FRAME_WINDOW_P (f
) || FRAME_MSDOS_P (f
);
158 #ifdef HAVE_WINDOW_SYSTEM
159 return x_display_list
!= NULL
;
166 decode_window_system_frame (Lisp_Object frame
)
168 struct frame
*f
= decode_live_frame (frame
);
170 if (!window_system_available (f
))
171 error ("Window system frame should be used");
176 check_window_system (struct frame
*f
)
178 if (!window_system_available (f
))
179 error (f
? "Window system frame should be used"
180 : "Window system is not in use or not initialized");
184 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
186 struct window
*w
= XWINDOW (window
);
188 w
->last_modified
= 0;
192 /* Handle just the top child in a vertical split. */
193 if (WINDOW_VERTICAL_COMBINATION_P (w
))
194 set_menu_bar_lines_1 (w
->contents
, n
);
195 else if (WINDOW_HORIZONTAL_COMBINATION_P (w
))
196 /* Adjust all children in a horizontal split. */
197 for (window
= w
->contents
; !NILP (window
); window
= w
->next
)
199 w
= XWINDOW (window
);
200 set_menu_bar_lines_1 (window
, n
);
205 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
208 int olines
= FRAME_MENU_BAR_LINES (f
);
210 /* Right now, menu bars don't work properly in minibuf-only frames;
211 most of the commands try to apply themselves to the minibuffer
212 frame itself, and get an error because you can't switch buffers
213 in or split the minibuffer window. */
214 if (FRAME_MINIBUF_ONLY_P (f
))
217 if (TYPE_RANGED_INTEGERP (int, value
))
218 nlines
= XINT (value
);
222 if (nlines
!= olines
)
224 windows_or_buffers_changed
++;
225 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
226 FRAME_MENU_BAR_LINES (f
) = nlines
;
227 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
232 Lisp_Object Vframe_list
;
235 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
236 doc
: /* Return non-nil if OBJECT is a frame.
238 t for a termcap frame (a character-only terminal),
239 'x' for an Emacs frame that is really an X window,
240 'w32' for an Emacs frame that is a window on MS-Windows display,
241 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
242 'pc' for a direct-write MS-DOS frame.
243 See also `frame-live-p'. */)
246 if (!FRAMEP (object
))
248 switch (XFRAME (object
)->output_method
)
250 case output_initial
: /* The initial frame is like a termcap frame. */
253 case output_x_window
:
257 case output_msdos_raw
:
266 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
267 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
268 Value is nil if OBJECT is not a live frame. If object is a live
269 frame, the return value indicates what sort of terminal device it is
270 displayed on. See the documentation of `framep' for possible
274 return ((FRAMEP (object
)
275 && FRAME_LIVE_P (XFRAME (object
)))
280 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
281 doc
: /* The name of the window system that FRAME is displaying through.
282 The value is a symbol:
283 nil for a termcap frame (a character-only terminal),
284 'x' for an Emacs frame that is really an X window,
285 'w32' for an Emacs frame that is a window on MS-Windows display,
286 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
287 'pc' for a direct-write MS-DOS frame.
289 FRAME defaults to the currently selected frame.
291 Use of this function as a predicate is deprecated. Instead,
292 use `display-graphic-p' or any of the other `display-*-p'
293 predicates which report frame's specific UI-related capabilities. */)
298 frame
= selected_frame
;
300 type
= Fframep (frame
);
303 wrong_type_argument (Qframep
, frame
);
312 make_frame (int mini_p
)
315 register struct frame
*f
;
316 register Lisp_Object root_window
;
317 register Lisp_Object mini_window
;
319 f
= allocate_frame ();
320 XSETFRAME (frame
, f
);
322 /* Initialize Lisp data. Note that allocate_frame initializes all
323 Lisp data to nil, so do it only for slots which should not be nil. */
324 fset_tool_bar_position (f
, Qtop
);
326 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
327 non-Lisp data, so do it only for slots which should not be zero.
328 To avoid subtle bugs and for the sake of readability, it's better to
329 initialize enum members explicitly even if their values are zero. */
330 f
->wants_modeline
= 1;
332 f
->has_minibuffer
= mini_p
;
333 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
334 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
335 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
336 #ifdef HAVE_WINDOW_SYSTEM
337 f
->want_fullscreen
= FULLSCREEN_NONE
;
340 root_window
= make_window ();
343 mini_window
= make_window ();
344 wset_next (XWINDOW (root_window
), mini_window
);
345 wset_prev (XWINDOW (mini_window
), root_window
);
346 XWINDOW (mini_window
)->mini
= 1;
347 wset_frame (XWINDOW (mini_window
), frame
);
348 fset_minibuffer_window (f
, mini_window
);
353 wset_next (XWINDOW (root_window
), Qnil
);
354 fset_minibuffer_window (f
, Qnil
);
357 wset_frame (XWINDOW (root_window
), frame
);
360 just so that there is "something there."
361 Correct size will be set up later with change_frame_size. */
363 SET_FRAME_COLS (f
, 10);
364 FRAME_LINES (f
) = 10;
366 XWINDOW (root_window
)->total_cols
= 10;
367 XWINDOW (root_window
)->total_lines
= mini_p
? 9 : 10;
371 XWINDOW (mini_window
)->total_cols
= 10;
372 XWINDOW (mini_window
)->top_line
= 9;
373 XWINDOW (mini_window
)->total_lines
= 1;
376 /* Choose a buffer for the frame's root window. */
378 Lisp_Object buf
= Fcurrent_buffer ();
380 /* If current buffer is hidden, try to find another one. */
381 if (BUFFER_HIDDEN_P (XBUFFER (buf
)))
382 buf
= other_buffer_safely (buf
);
384 /* Use set_window_buffer, not Fset_window_buffer, and don't let
385 hooks be run by it. The reason is that the whole frame/window
386 arrangement is not yet fully initialized at this point. Windows
387 don't have the right size, glyph matrices aren't initialized
388 etc. Running Lisp functions at this point surely ends in a
390 set_window_buffer (root_window
, buf
, 0, 0);
391 fset_buffer_list (f
, Fcons (buf
, Qnil
));
395 set_window_buffer (mini_window
,
396 (NILP (Vminibuffer_list
)
398 : Fcar (Vminibuffer_list
)),
401 fset_root_window (f
, root_window
);
402 fset_selected_window (f
, root_window
);
403 /* Make sure this window seems more recently used than
404 a newly-created, never-selected window. */
405 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
410 #ifdef HAVE_WINDOW_SYSTEM
411 /* Make a frame using a separate minibuffer window on another frame.
412 MINI_WINDOW is the minibuffer window to use. nil means use the
413 default (the global minibuffer). */
416 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
418 register struct frame
*f
;
421 if (!NILP (mini_window
))
422 CHECK_LIVE_WINDOW (mini_window
);
424 if (!NILP (mini_window
)
425 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
426 error ("Frame and minibuffer must be on the same terminal");
428 /* Make a frame containing just a root window. */
431 if (NILP (mini_window
))
433 /* Use default-minibuffer-frame if possible. */
434 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
435 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
437 Lisp_Object frame_dummy
;
439 XSETFRAME (frame_dummy
, f
);
440 GCPRO1 (frame_dummy
);
441 /* If there's no minibuffer frame to use, create one. */
442 kset_default_minibuffer_frame
443 (kb
, call1 (intern ("make-initial-minibuffer-frame"), display
));
448 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
451 fset_minibuffer_window (f
, mini_window
);
453 /* Make the chosen minibuffer window display the proper minibuffer,
454 unless it is already showing a minibuffer. */
455 if (NILP (Fmemq (XWINDOW (mini_window
)->contents
, Vminibuffer_list
)))
456 /* Use set_window_buffer instead of Fset_window_buffer (see
457 discussion of bug#11984, bug#12025, bug#12026). */
458 set_window_buffer (mini_window
,
459 (NILP (Vminibuffer_list
)
461 : Fcar (Vminibuffer_list
)), 0, 0);
465 /* Make a frame containing only a minibuffer window. */
468 make_minibuffer_frame (void)
470 /* First make a frame containing just a root window, no minibuffer. */
472 register struct frame
*f
= make_frame (0);
473 register Lisp_Object mini_window
;
474 register Lisp_Object frame
;
476 XSETFRAME (frame
, f
);
481 f
->wants_modeline
= 0;
482 f
->has_minibuffer
= 1;
484 /* Now label the root window as also being the minibuffer.
485 Avoid infinite looping on the window chain by marking next pointer
488 mini_window
= f
->root_window
;
489 fset_minibuffer_window (f
, mini_window
);
490 XWINDOW (mini_window
)->mini
= 1;
491 wset_next (XWINDOW (mini_window
), Qnil
);
492 wset_prev (XWINDOW (mini_window
), Qnil
);
493 wset_frame (XWINDOW (mini_window
), frame
);
495 /* Put the proper buffer in that window. */
497 /* Use set_window_buffer instead of Fset_window_buffer (see
498 discussion of bug#11984, bug#12025, bug#12026). */
499 set_window_buffer (mini_window
,
500 (NILP (Vminibuffer_list
)
502 : Fcar (Vminibuffer_list
)), 0, 0);
505 #endif /* HAVE_WINDOW_SYSTEM */
507 /* Construct a frame that refers to a terminal. */
509 static printmax_t tty_frame_count
;
512 make_initial_frame (void)
515 struct terminal
*terminal
;
518 eassert (initial_kboard
);
520 /* The first call must initialize Vframe_list. */
521 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
524 terminal
= init_initial_terminal ();
527 XSETFRAME (frame
, f
);
529 Vframe_list
= Fcons (frame
, Vframe_list
);
532 fset_name (f
, build_pure_c_string ("F1"));
534 SET_FRAME_VISIBLE (f
, 1);
536 f
->output_method
= terminal
->type
;
537 f
->terminal
= terminal
;
538 f
->terminal
->reference_count
++;
539 f
->output_data
.nothing
= 0;
541 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
542 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
544 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
546 /* The default value of menu-bar-mode is t. */
547 set_menu_bar_lines (f
, make_number (1), Qnil
);
550 init_frame_faces (f
);
556 static struct frame
*
557 make_terminal_frame (struct terminal
*terminal
)
559 register struct frame
*f
;
561 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
564 error ("Terminal is not live, can't create new frames on it");
568 XSETFRAME (frame
, f
);
569 Vframe_list
= Fcons (frame
, Vframe_list
);
571 fset_name (f
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
573 SET_FRAME_VISIBLE (f
, 1);
575 f
->terminal
= terminal
;
576 f
->terminal
->reference_count
++;
578 f
->output_data
.tty
->display_info
= &the_only_display_info
;
579 if (!inhibit_window_system
580 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
581 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
582 f
->output_method
= output_msdos_raw
;
584 f
->output_method
= output_termcap
;
585 #else /* not MSDOS */
586 f
->output_method
= output_termcap
;
587 create_tty_output (f
);
588 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
589 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
590 #endif /* not MSDOS */
592 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
593 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
595 /* Set the top frame to the newly created frame. */
596 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
597 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
598 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f
)->top_frame
), 2); /* obscured */
600 FRAME_TTY (f
)->top_frame
= frame
;
603 init_frame_faces (f
);
608 /* Get a suitable value for frame parameter PARAMETER for a newly
609 created frame, based on (1) the user-supplied frame parameter
610 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
613 get_future_frame_param (Lisp_Object parameter
,
614 Lisp_Object supplied_parms
,
619 result
= Fassq (parameter
, supplied_parms
);
621 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
622 if (NILP (result
) && current_value
!= NULL
)
623 result
= build_string (current_value
);
624 if (!NILP (result
) && !STRINGP (result
))
625 result
= XCDR (result
);
626 if (NILP (result
) || !STRINGP (result
))
632 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
634 doc
: /* Create an additional terminal frame, possibly on another terminal.
635 This function takes one argument, an alist specifying frame parameters.
637 You can create multiple frames on a single text terminal, but only one
638 of them (the selected terminal frame) is actually displayed.
640 In practice, generally you don't need to specify any parameters,
641 except when you want to create a new frame on another terminal.
642 In that case, the `tty' parameter specifies the device file to open,
643 and the `tty-type' parameter specifies the terminal type. Example:
645 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
647 Note that changing the size of one terminal frame automatically
648 affects all frames on the same terminal device. */)
652 struct terminal
*t
= NULL
;
653 Lisp_Object frame
, tem
;
654 struct frame
*sf
= SELECTED_FRAME ();
657 if (sf
->output_method
!= output_msdos_raw
658 && sf
->output_method
!= output_termcap
)
660 #else /* not MSDOS */
662 #ifdef WINDOWSNT /* This should work now! */
663 if (sf
->output_method
!= output_termcap
)
664 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
666 #endif /* not MSDOS */
669 Lisp_Object terminal
;
671 terminal
= Fassq (Qterminal
, parms
);
672 if (CONSP (terminal
))
674 terminal
= XCDR (terminal
);
675 t
= get_terminal (terminal
, 1);
678 if (t
&& t
!= the_only_display_info
.terminal
)
679 /* msdos.c assumes a single tty_display_info object. */
680 error ("Multiple terminals are not supported on this platform");
682 t
= the_only_display_info
.terminal
;
688 char *name
= 0, *type
= 0;
689 Lisp_Object tty
, tty_type
;
691 tty
= get_future_frame_param
692 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
693 ? FRAME_TTY (XFRAME (selected_frame
))->name
697 name
= alloca (SBYTES (tty
) + 1);
698 memcpy (name
, SSDATA (tty
), SBYTES (tty
));
699 name
[SBYTES (tty
)] = 0;
702 tty_type
= get_future_frame_param
703 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
704 ? FRAME_TTY (XFRAME (selected_frame
))->type
706 if (!NILP (tty_type
))
708 type
= alloca (SBYTES (tty_type
) + 1);
709 memcpy (type
, SSDATA (tty_type
), SBYTES (tty_type
));
710 type
[SBYTES (tty_type
)] = 0;
713 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
716 f
= make_terminal_frame (t
);
720 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
721 change_frame_size (f
, height
, width
, 0, 0, 0);
726 XSETFRAME (frame
, f
);
727 Fmodify_frame_parameters (frame
, parms
);
728 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
729 build_string (t
->display_info
.tty
->type
)),
731 if (t
->display_info
.tty
->name
!= NULL
)
732 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
733 build_string (t
->display_info
.tty
->name
)),
736 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
738 /* Make the frame face alist be frame-specific, so that each
739 frame could change its face definitions independently. */
740 fset_face_alist (f
, Fcopy_alist (sf
->face_alist
));
741 /* Simple Fcopy_alist isn't enough, because we need the contents of
742 the vectors which are the CDRs of associations in face_alist to
743 be copied as well. */
744 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
745 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
750 /* Perform the switch to frame FRAME.
752 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
755 If TRACK is non-zero and the frame that currently has the focus
756 redirects its focus to the selected frame, redirect that focused
757 frame's focus to FRAME instead.
759 FOR_DELETION non-zero means that the selected frame is being
760 deleted, which includes the possibility that the frame's terminal
763 The value of NORECORD is passed as argument to Fselect_window. */
766 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
768 struct frame
*sf
= SELECTED_FRAME ();
770 /* If FRAME is a switch-frame event, extract the frame we should
773 && EQ (XCAR (frame
), Qswitch_frame
)
774 && CONSP (XCDR (frame
)))
775 frame
= XCAR (XCDR (frame
));
777 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
778 a switch-frame event to arrive after a frame is no longer live,
779 especially when deleting the initial frame during startup. */
781 if (! FRAME_LIVE_P (XFRAME (frame
)))
784 if (sf
== XFRAME (frame
))
787 /* This is too greedy; it causes inappropriate focus redirection
788 that's hard to get rid of. */
790 /* If a frame's focus has been redirected toward the currently
791 selected frame, we should change the redirection to point to the
792 newly selected frame. This means that if the focus is redirected
793 from a minibufferless frame to a surrogate minibuffer frame, we
794 can use `other-window' to switch between all the frames using
795 that minibuffer frame, and the focus redirection will follow us
801 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
805 if (!FRAMEP (XCAR (tail
)))
808 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
810 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
811 Fredirect_frame_focus (XCAR (tail
), frame
);
815 /* Instead, apply it only to the frame we're pointing to. */
816 #ifdef HAVE_WINDOW_SYSTEM
817 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
819 Lisp_Object focus
, xfocus
;
821 xfocus
= x_get_focus_frame (XFRAME (frame
));
824 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
825 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
826 Fredirect_frame_focus (xfocus
, frame
);
829 #endif /* HAVE_X_WINDOWS */
832 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
833 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
835 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
837 Lisp_Object top_frame
= FRAME_TTY (XFRAME (frame
))->top_frame
;
839 /* Don't mark the frame garbaged and/or obscured if we are
840 switching to the frame that is already the top frame of that
842 if (!EQ (frame
, top_frame
))
844 if (FRAMEP (top_frame
))
845 /* Mark previously displayed frame as now obscured. */
846 SET_FRAME_VISIBLE (XFRAME (top_frame
), 2);
847 SET_FRAME_VISIBLE (XFRAME (frame
), 1);
849 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
852 selected_frame
= frame
;
853 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
854 last_nonminibuf_frame
= XFRAME (selected_frame
);
856 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
858 /* We want to make sure that the next event generates a frame-switch
859 event to the appropriate frame. This seems kludgy to me, but
860 before you take it out, make sure that evaluating something like
861 (select-window (frame-root-window (new-frame))) doesn't end up
862 with your typing being interpreted in the new frame instead of
863 the one you're actually typing in. */
864 internal_last_event_frame
= Qnil
;
869 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
870 doc
: /* Select FRAME.
871 Subsequent editing commands apply to its selected window.
872 Optional argument NORECORD means to neither change the order of
873 recently selected windows nor the buffer list.
875 The selection of FRAME lasts until the next time the user does
876 something to select a different frame, or until the next time
877 this function is called. If you are using a window system, the
878 previously selected frame may be restored as the selected frame
879 when returning to the command loop, because it still may have
880 the window system's input focus. On a text terminal, the next
881 redisplay will display FRAME.
883 This function returns FRAME, or nil if FRAME has been deleted. */)
884 (Lisp_Object frame
, Lisp_Object norecord
)
886 return do_switch_frame (frame
, 1, 0, norecord
);
890 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
891 doc
: /* Handle a switch-frame event EVENT.
892 Switch-frame events are usually bound to this function.
893 A switch-frame event tells Emacs that the window manager has requested
894 that the user's events be directed to the frame mentioned in the event.
895 This function selects the selected window of the frame of EVENT.
897 If EVENT is frame object, handle it as if it were a switch-frame event
901 /* Preserve prefix arg that the command loop just cleared. */
902 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
903 Frun_hooks (1, &Qmouse_leave_buffer_hook
);
904 return do_switch_frame (event
, 0, 0, Qnil
);
907 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
908 doc
: /* Return the frame that is now selected. */)
911 return selected_frame
;
914 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
916 doc
: /* Return a list of all live frames. */)
920 frames
= Fcopy_sequence (Vframe_list
);
921 #ifdef HAVE_WINDOW_SYSTEM
922 if (FRAMEP (tip_frame
))
923 frames
= Fdelq (tip_frame
, frames
);
928 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
929 same tty (for tty frames) or among frames which uses FRAME's keyboard.
930 If MINIBUF is nil, do not consider minibuffer-only candidate.
931 If MINIBUF is `visible', do not consider an invisible candidate.
932 If MINIBUF is a window, consider only its own frame and candidate now
933 using that window as the minibuffer.
934 If MINIBUF is 0, consider candidate if it is visible or iconified.
935 Otherwise consider any candidate and return nil if CANDIDATE is not
939 candidate_frame (Lisp_Object candidate
, Lisp_Object frame
, Lisp_Object minibuf
)
941 struct frame
*c
= XFRAME (candidate
), *f
= XFRAME (frame
);
943 if ((!FRAME_TERMCAP_P (c
) && !FRAME_TERMCAP_P (f
)
944 && FRAME_KBOARD (c
) == FRAME_KBOARD (f
))
945 || (FRAME_TERMCAP_P (c
) && FRAME_TERMCAP_P (f
)
946 && FRAME_TTY (c
) == FRAME_TTY (f
)))
950 if (!FRAME_MINIBUF_ONLY_P (c
))
953 else if (EQ (minibuf
, Qvisible
))
955 if (FRAME_VISIBLE_P (c
))
958 else if (WINDOWP (minibuf
))
960 if (EQ (FRAME_MINIBUF_WINDOW (c
), minibuf
)
961 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), candidate
)
962 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
963 FRAME_FOCUS_FRAME (c
)))
966 else if (XFASTINT (minibuf
) == 0)
968 if (FRAME_VISIBLE_P (c
) || FRAME_ICONIFIED_P (c
))
977 /* Return the next frame in the frame list after FRAME. */
980 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
985 /* There must always be at least one frame in Vframe_list. */
986 eassert (CONSP (Vframe_list
));
989 FOR_EACH_FRAME (tail
, f
)
993 f
= candidate_frame (f
, frame
, minibuf
);
1003 /* Return the previous frame in the frame list before FRAME. */
1006 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1008 Lisp_Object f
, tail
, prev
= Qnil
;
1010 /* There must always be at least one frame in Vframe_list. */
1011 eassert (CONSP (Vframe_list
));
1013 FOR_EACH_FRAME (tail
, f
)
1015 if (EQ (frame
, f
) && !NILP (prev
))
1017 f
= candidate_frame (f
, frame
, minibuf
);
1022 /* We've scanned the entire list. */
1024 /* We went through the whole frame list without finding a single
1025 acceptable frame. Return the original frame. */
1028 /* There were no acceptable frames in the list before FRAME; otherwise,
1029 we would have returned directly from the loop. Since PREV is the last
1030 acceptable frame in the list, return it. */
1035 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1036 doc
: /* Return the next frame in the frame list after FRAME.
1037 It considers only frames on the same terminal as FRAME.
1038 By default, skip minibuffer-only frames.
1039 If omitted, FRAME defaults to the selected frame.
1040 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1041 If MINIFRAME is a window, include only its own frame
1042 and any frame now using that window as the minibuffer.
1043 If MINIFRAME is `visible', include all visible frames.
1044 If MINIFRAME is 0, include all visible and iconified frames.
1045 Otherwise, include all frames. */)
1046 (Lisp_Object frame
, Lisp_Object miniframe
)
1049 frame
= selected_frame
;
1050 CHECK_LIVE_FRAME (frame
);
1051 return next_frame (frame
, miniframe
);
1054 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1055 doc
: /* Return the previous frame in the frame list before FRAME.
1056 It considers only frames on the same terminal as FRAME.
1057 By default, skip minibuffer-only frames.
1058 If omitted, FRAME defaults to the selected frame.
1059 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1060 If MINIFRAME is a window, include only its own frame
1061 and any frame now using that window as the minibuffer.
1062 If MINIFRAME is `visible', include all visible frames.
1063 If MINIFRAME is 0, include all visible and iconified frames.
1064 Otherwise, include all frames. */)
1065 (Lisp_Object frame
, Lisp_Object miniframe
)
1068 frame
= selected_frame
;
1069 CHECK_LIVE_FRAME (frame
);
1070 return prev_frame (frame
, miniframe
);
1073 /* Return 1 if it is ok to delete frame F;
1074 0 if all frames aside from F are invisible.
1075 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1078 other_visible_frames (FRAME_PTR f
)
1080 Lisp_Object frames
, this;
1082 FOR_EACH_FRAME (frames
, this)
1084 if (f
== XFRAME (this))
1087 /* Verify that we can still talk to the frame's X window,
1088 and note any recent change in visibility. */
1089 #ifdef HAVE_WINDOW_SYSTEM
1090 if (FRAME_WINDOW_P (XFRAME (this)))
1091 x_sync (XFRAME (this));
1094 if (FRAME_VISIBLE_P (XFRAME (this))
1095 || FRAME_ICONIFIED_P (XFRAME (this))
1096 /* Allow deleting the terminal frame when at least one X
1098 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1104 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1105 unconditionally. x_connection_closed and delete_terminal use
1106 this. Any other value of FORCE implements the semantics
1107 described for Fdelete_frame. */
1109 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1111 struct frame
*f
= decode_any_frame (frame
);
1112 struct frame
*sf
= SELECTED_FRAME ();
1115 int minibuffer_selected
, is_tooltip_frame
;
1117 if (! FRAME_LIVE_P (f
))
1120 if (NILP (force
) && !other_visible_frames (f
))
1121 error ("Attempt to delete the sole visible or iconified frame");
1123 /* x_connection_closed must have set FORCE to `noelisp' in order
1124 to delete the last frame, if it is gone. */
1125 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1126 error ("Attempt to delete the only frame");
1128 XSETFRAME (frame
, f
);
1130 /* Does this frame have a minibuffer, and is it the surrogate
1131 minibuffer for any other frame? */
1132 if (FRAME_HAS_MINIBUF_P (f
))
1134 Lisp_Object frames
, this;
1136 FOR_EACH_FRAME (frames
, this)
1138 if (! EQ (this, frame
)
1140 WINDOW_FRAME (XWINDOW
1141 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1143 /* If we MUST delete this frame, delete the other first.
1144 But do this only if FORCE equals `noelisp'. */
1145 if (EQ (force
, Qnoelisp
))
1146 delete_frame (this, Qnoelisp
);
1148 error ("Attempt to delete a surrogate minibuffer frame");
1153 is_tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1155 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1156 frame is a tooltip. FORCE is set to `noelisp' when handling
1157 a disconnect from the terminal, so we don't dare call Lisp
1159 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1161 else if (EQ (force
, Qnoelisp
))
1163 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1167 #ifdef HAVE_X_WINDOWS
1168 /* Also, save clipboard to the clipboard manager. */
1169 x_clipboard_manager_save_frame (frame
);
1172 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1175 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1176 if (! FRAME_LIVE_P (f
))
1179 /* At this point, we are committed to deleting the frame.
1180 There is no more chance for errors to prevent it. */
1182 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1184 /* Don't let the frame remain selected. */
1187 Lisp_Object tail
, frame1
;
1189 /* Look for another visible frame on the same terminal. */
1190 frame1
= next_frame (frame
, Qvisible
);
1192 /* If there is none, find *some* other frame. */
1193 if (NILP (frame1
) || EQ (frame1
, frame
))
1195 FOR_EACH_FRAME (tail
, frame1
)
1197 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1199 /* Do not change a text terminal's top-frame. */
1200 struct frame
*f1
= XFRAME (frame1
);
1201 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1203 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1204 if (!EQ (top_frame
, frame
))
1211 #ifdef NS_IMPL_COCOA
1213 /* Under NS, there is no system mechanism for choosing a new
1214 window to get focus -- it is left to application code.
1215 So the portion of THIS application interfacing with NS
1216 needs to know about it. We call Fraise_frame, but the
1217 purpose is really to transfer focus. */
1218 Fraise_frame (frame1
);
1221 do_switch_frame (frame1
, 0, 1, Qnil
);
1222 sf
= SELECTED_FRAME ();
1225 /* Don't allow minibuf_window to remain on a deleted frame. */
1226 if (EQ (f
->minibuffer_window
, minibuf_window
))
1228 /* Use set_window_buffer instead of Fset_window_buffer (see
1229 discussion of bug#11984, bug#12025, bug#12026). */
1230 set_window_buffer (sf
->minibuffer_window
,
1231 XWINDOW (minibuf_window
)->contents
, 0, 0);
1232 minibuf_window
= sf
->minibuffer_window
;
1234 /* If the dying minibuffer window was selected,
1235 select the new one. */
1236 if (minibuffer_selected
)
1237 Fselect_window (minibuf_window
, Qnil
);
1240 /* Don't let echo_area_window to remain on a deleted frame. */
1241 if (EQ (f
->minibuffer_window
, echo_area_window
))
1242 echo_area_window
= sf
->minibuffer_window
;
1244 /* Clear any X selections for this frame. */
1245 #ifdef HAVE_X_WINDOWS
1247 x_clear_frame_selections (f
);
1251 This function must be called before the window tree of the
1252 frame is deleted because windows contain dynamically allocated
1256 #ifdef HAVE_WINDOW_SYSTEM
1257 /* Give chance to each font driver to free a frame specific data. */
1258 font_update_drivers (f
, Qnil
);
1261 /* Mark all the windows that used to be on FRAME as deleted, and then
1262 remove the reference to them. */
1263 delete_all_child_windows (f
->root_window
);
1264 fset_root_window (f
, Qnil
);
1266 Vframe_list
= Fdelq (frame
, Vframe_list
);
1267 SET_FRAME_VISIBLE (f
, 0);
1269 /* Allow the vector of menu bar contents to be freed in the next
1270 garbage collection. The frame object itself may not be garbage
1271 collected until much later, because recent_keys and other data
1272 structures can still refer to it. */
1273 fset_menu_bar_vector (f
, Qnil
);
1275 /* If FRAME's buffer lists contains killed
1276 buffers, this helps GC to reclaim them. */
1277 fset_buffer_list (f
, Qnil
);
1278 fset_buried_buffer_list (f
, Qnil
);
1280 free_font_driver_list (f
);
1282 xfree (f
->decode_mode_spec_buffer
);
1283 xfree (FRAME_INSERT_COST (f
));
1284 xfree (FRAME_DELETEN_COST (f
));
1285 xfree (FRAME_INSERTN_COST (f
));
1286 xfree (FRAME_DELETE_COST (f
));
1288 /* Since some events are handled at the interrupt level, we may get
1289 an event for f at any time; if we zero out the frame's terminal
1290 now, then we may trip up the event-handling code. Instead, we'll
1291 promise that the terminal of the frame must be valid until we
1292 have called the window-system-dependent frame destruction
1295 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1296 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1299 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1300 f
->output_data
.nothing
= 0;
1301 f
->terminal
= 0; /* Now the frame is dead. */
1303 /* If needed, delete the terminal that this frame was on.
1304 (This must be done after the frame is killed.) */
1305 terminal
->reference_count
--;
1307 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1309 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1310 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1311 terminal
->reference_count
= 1;
1312 #endif /* USE_GTK */
1313 if (terminal
->reference_count
== 0)
1316 XSETTERMINAL (tmp
, terminal
);
1319 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1322 kb
= terminal
->kboard
;
1325 /* If we've deleted the last_nonminibuf_frame, then try to find
1327 if (f
== last_nonminibuf_frame
)
1329 Lisp_Object frames
, this;
1331 last_nonminibuf_frame
= 0;
1333 FOR_EACH_FRAME (frames
, this)
1336 if (!FRAME_MINIBUF_ONLY_P (f
))
1338 last_nonminibuf_frame
= f
;
1344 /* If there's no other frame on the same kboard, get out of
1345 single-kboard state if we're in it for this kboard. */
1348 Lisp_Object frames
, this;
1349 /* Some frame we found on the same kboard, or nil if there are none. */
1350 Lisp_Object frame_on_same_kboard
= Qnil
;
1352 FOR_EACH_FRAME (frames
, this)
1353 if (kb
== FRAME_KBOARD (XFRAME (this)))
1354 frame_on_same_kboard
= this;
1356 if (NILP (frame_on_same_kboard
))
1357 not_single_kboard_state (kb
);
1361 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1362 find another one. Prefer minibuffer-only frames, but also notice
1363 frames with other windows. */
1364 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1366 Lisp_Object frames
, this;
1368 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1369 Lisp_Object frame_with_minibuf
= Qnil
;
1370 /* Some frame we found on the same kboard, or nil if there are none. */
1371 Lisp_Object frame_on_same_kboard
= Qnil
;
1373 FOR_EACH_FRAME (frames
, this)
1375 struct frame
*f1
= XFRAME (this);
1377 /* Consider only frames on the same kboard
1378 and only those with minibuffers. */
1379 if (kb
== FRAME_KBOARD (f1
)
1380 && FRAME_HAS_MINIBUF_P (f1
))
1382 frame_with_minibuf
= this;
1383 if (FRAME_MINIBUF_ONLY_P (f1
))
1387 if (kb
== FRAME_KBOARD (f1
))
1388 frame_on_same_kboard
= this;
1391 if (!NILP (frame_on_same_kboard
))
1393 /* We know that there must be some frame with a minibuffer out
1394 there. If this were not true, all of the frames present
1395 would have to be minibufferless, which implies that at some
1396 point their minibuffer frames must have been deleted, but
1397 that is prohibited at the top; you can't delete surrogate
1398 minibuffer frames. */
1399 if (NILP (frame_with_minibuf
))
1402 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
1405 /* No frames left on this kboard--say no minibuffer either. */
1406 kset_default_minibuffer_frame (kb
, Qnil
);
1409 /* Cause frame titles to update--necessary if we now have just one frame. */
1410 if (!is_tooltip_frame
)
1411 update_mode_lines
= 1;
1416 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1417 doc
: /* Delete FRAME, permanently eliminating it from use.
1418 FRAME defaults to the selected frame.
1420 A frame may not be deleted if its minibuffer is used by other frames.
1421 Normally, you may not delete a frame if all other frames are invisible,
1422 but if the second optional argument FORCE is non-nil, you may do so.
1424 This function runs `delete-frame-functions' before actually
1425 deleting the frame, unless the frame is a tooltip.
1426 The functions are run with one argument, the frame to be deleted. */)
1427 (Lisp_Object frame
, Lisp_Object force
)
1429 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1433 /* Return mouse position in character cell units. */
1435 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1436 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1437 The position is given in character cells, where (0, 0) is the
1438 upper-left corner of the frame, X is the horizontal offset, and Y is
1439 the vertical offset.
1440 If Emacs is running on a mouseless terminal or hasn't been programmed
1441 to read the mouse position, it returns the selected frame for FRAME
1442 and nil for X and Y.
1443 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1444 passing the normal return value to that function as an argument,
1445 and returns whatever that function returns. */)
1449 Lisp_Object lispy_dummy
;
1450 Lisp_Object x
, y
, retval
;
1451 struct gcpro gcpro1
;
1453 f
= SELECTED_FRAME ();
1456 /* It's okay for the hook to refrain from storing anything. */
1457 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1459 enum scroll_bar_part party_dummy
;
1461 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1462 &lispy_dummy
, &party_dummy
,
1471 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1475 XSETFRAME (lispy_dummy
, f
);
1476 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1478 if (!NILP (Vmouse_position_function
))
1479 retval
= call1 (Vmouse_position_function
, retval
);
1480 RETURN_UNGCPRO (retval
);
1483 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1484 Smouse_pixel_position
, 0, 0, 0,
1485 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1486 The position is given in pixel units, where (0, 0) is the
1487 upper-left corner of the frame, X is the horizontal offset, and Y is
1488 the vertical offset.
1489 If Emacs is running on a mouseless terminal or hasn't been programmed
1490 to read the mouse position, it returns the selected frame for FRAME
1491 and nil for X and Y. */)
1495 Lisp_Object lispy_dummy
;
1498 f
= SELECTED_FRAME ();
1501 /* It's okay for the hook to refrain from storing anything. */
1502 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1504 enum scroll_bar_part party_dummy
;
1506 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1507 &lispy_dummy
, &party_dummy
,
1512 XSETFRAME (lispy_dummy
, f
);
1513 return Fcons (lispy_dummy
, Fcons (x
, y
));
1516 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1517 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1518 Coordinates are relative to the frame, not a window,
1519 so the coordinates of the top left character in the frame
1520 may be nonzero due to left-hand scroll bars or the menu bar.
1522 The position is given in character cells, where (0, 0) is the
1523 upper-left corner of the frame, X is the horizontal offset, and Y is
1524 the vertical offset.
1526 This function is a no-op for an X frame that is not visible.
1527 If you have just created a frame, you must wait for it to become visible
1528 before calling this function on it, like this.
1529 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1530 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1532 CHECK_LIVE_FRAME (frame
);
1533 CHECK_TYPE_RANGED_INTEGER (int, x
);
1534 CHECK_TYPE_RANGED_INTEGER (int, y
);
1536 /* I think this should be done with a hook. */
1537 #ifdef HAVE_WINDOW_SYSTEM
1538 if (FRAME_WINDOW_P (XFRAME (frame
)))
1539 /* Warping the mouse will cause enternotify and focus events. */
1540 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1543 if (FRAME_MSDOS_P (XFRAME (frame
)))
1545 Fselect_frame (frame
, Qnil
);
1546 mouse_moveto (XINT (x
), XINT (y
));
1551 Fselect_frame (frame
, Qnil
);
1552 term_mouse_moveto (XINT (x
), XINT (y
));
1561 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1562 Sset_mouse_pixel_position
, 3, 3, 0,
1563 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1564 The position is given in pixels, where (0, 0) is the upper-left corner
1565 of the frame, X is the horizontal offset, and Y is the vertical offset.
1567 Note, this is a no-op for an X frame that is not visible.
1568 If you have just created a frame, you must wait for it to become visible
1569 before calling this function on it, like this.
1570 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1571 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1573 CHECK_LIVE_FRAME (frame
);
1574 CHECK_TYPE_RANGED_INTEGER (int, x
);
1575 CHECK_TYPE_RANGED_INTEGER (int, y
);
1577 /* I think this should be done with a hook. */
1578 #ifdef HAVE_WINDOW_SYSTEM
1579 if (FRAME_WINDOW_P (XFRAME (frame
)))
1580 /* Warping the mouse will cause enternotify and focus events. */
1581 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1584 if (FRAME_MSDOS_P (XFRAME (frame
)))
1586 Fselect_frame (frame
, Qnil
);
1587 mouse_moveto (XINT (x
), XINT (y
));
1592 Fselect_frame (frame
, Qnil
);
1593 term_mouse_moveto (XINT (x
), XINT (y
));
1602 static void make_frame_visible_1 (Lisp_Object
);
1604 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1606 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1607 If omitted, FRAME defaults to the currently selected frame. */)
1610 struct frame
*f
= decode_live_frame (frame
);
1612 /* I think this should be done with a hook. */
1613 #ifdef HAVE_WINDOW_SYSTEM
1614 if (FRAME_WINDOW_P (f
))
1615 x_make_frame_visible (f
);
1618 make_frame_visible_1 (f
->root_window
);
1620 /* Make menu bar update for the Buffers and Frames menus. */
1621 windows_or_buffers_changed
++;
1623 XSETFRAME (frame
, f
);
1627 /* Update the display_time slot of the buffers shown in WINDOW
1628 and all its descendants. */
1631 make_frame_visible_1 (Lisp_Object window
)
1635 for (; !NILP (window
); window
= w
->next
)
1637 w
= XWINDOW (window
);
1638 if (WINDOWP (w
->contents
))
1639 make_frame_visible_1 (w
->contents
);
1641 bset_display_time (XBUFFER (w
->contents
), Fcurrent_time ());
1645 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1647 doc
: /* Make the frame FRAME invisible.
1648 If omitted, FRAME defaults to the currently selected frame.
1649 On graphical displays, invisible frames are not updated and are
1650 usually not displayed at all, even in a window system's \"taskbar\".
1652 Normally you may not make FRAME invisible if all other frames are invisible,
1653 but if the second optional argument FORCE is non-nil, you may do so.
1655 This function has no effect on text terminal frames. Such frames are
1656 always considered visible, whether or not they are currently being
1657 displayed in the terminal. */)
1658 (Lisp_Object frame
, Lisp_Object force
)
1660 struct frame
*f
= decode_live_frame (frame
);
1662 if (NILP (force
) && !other_visible_frames (f
))
1663 error ("Attempt to make invisible the sole visible or iconified frame");
1665 /* Don't allow minibuf_window to remain on a deleted frame. */
1666 if (EQ (f
->minibuffer_window
, minibuf_window
))
1668 struct frame
*sf
= XFRAME (selected_frame
);
1669 /* Use set_window_buffer instead of Fset_window_buffer (see
1670 discussion of bug#11984, bug#12025, bug#12026). */
1671 set_window_buffer (sf
->minibuffer_window
,
1672 XWINDOW (minibuf_window
)->contents
, 0, 0);
1673 minibuf_window
= sf
->minibuffer_window
;
1676 /* I think this should be done with a hook. */
1677 #ifdef HAVE_WINDOW_SYSTEM
1678 if (FRAME_WINDOW_P (f
))
1679 x_make_frame_invisible (f
);
1682 /* Make menu bar update for the Buffers and Frames menus. */
1683 windows_or_buffers_changed
++;
1688 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1690 doc
: /* Make the frame FRAME into an icon.
1691 If omitted, FRAME defaults to the currently selected frame. */)
1694 struct frame
*f
= decode_live_frame (frame
);
1696 /* Don't allow minibuf_window to remain on an iconified frame. */
1697 if (EQ (f
->minibuffer_window
, minibuf_window
))
1699 struct frame
*sf
= XFRAME (selected_frame
);
1700 /* Use set_window_buffer instead of Fset_window_buffer (see
1701 discussion of bug#11984, bug#12025, bug#12026). */
1702 set_window_buffer (sf
->minibuffer_window
,
1703 XWINDOW (minibuf_window
)->contents
, 0, 0);
1704 minibuf_window
= sf
->minibuffer_window
;
1707 /* I think this should be done with a hook. */
1708 #ifdef HAVE_WINDOW_SYSTEM
1709 if (FRAME_WINDOW_P (f
))
1710 x_iconify_frame (f
);
1713 /* Make menu bar update for the Buffers and Frames menus. */
1714 windows_or_buffers_changed
++;
1719 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1721 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1722 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1723 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1724 On graphical displays, invisible frames are not updated and are
1725 usually not displayed at all, even in a window system's \"taskbar\".
1727 If FRAME is a text terminal frame, this always returns t.
1728 Such frames are always considered visible, whether or not they are
1729 currently being displayed on the terminal. */)
1732 CHECK_LIVE_FRAME (frame
);
1734 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1736 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1741 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1743 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1746 Lisp_Object tail
, frame
, value
= Qnil
;
1748 FOR_EACH_FRAME (tail
, frame
)
1749 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1750 value
= Fcons (frame
, value
);
1756 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1757 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1758 If FRAME is invisible or iconified, make it visible.
1759 If you don't specify a frame, the selected frame is used.
1760 If Emacs is displaying on an ordinary terminal or some other device which
1761 doesn't support multiple overlapping frames, this function selects FRAME. */)
1764 struct frame
*f
= decode_live_frame (frame
);
1766 XSETFRAME (frame
, f
);
1768 if (FRAME_TERMCAP_P (f
))
1769 /* On a text terminal select FRAME. */
1770 Fselect_frame (frame
, Qnil
);
1772 /* Do like the documentation says. */
1773 Fmake_frame_visible (frame
);
1775 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1776 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
1781 /* Should we have a corresponding function called Flower_Power? */
1782 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1783 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1784 If you don't specify a frame, the selected frame is used.
1785 If Emacs is displaying on an ordinary terminal or some other device which
1786 doesn't support multiple overlapping frames, this function does nothing. */)
1789 struct frame
*f
= decode_live_frame (frame
);
1791 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1792 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
1798 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1800 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1801 In other words, switch-frame events caused by events in FRAME will
1802 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1803 FOCUS-FRAME after reading an event typed at FRAME.
1805 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
1806 frame again receives its own keystrokes.
1808 Focus redirection is useful for temporarily redirecting keystrokes to
1809 a surrogate minibuffer frame when a frame doesn't have its own
1812 A frame's focus redirection can be changed by `select-frame'. If frame
1813 FOO is selected, and then a different frame BAR is selected, any
1814 frames redirecting their focus to FOO are shifted to redirect their
1815 focus to BAR. This allows focus redirection to work properly when the
1816 user switches from one frame to another using `select-window'.
1818 This means that a frame whose focus is redirected to itself is treated
1819 differently from a frame whose focus is redirected to nil; the former
1820 is affected by `select-frame', while the latter is not.
1822 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1823 (Lisp_Object frame
, Lisp_Object focus_frame
)
1825 /* Note that we don't check for a live frame here. It's reasonable
1826 to redirect the focus of a frame you're about to delete, if you
1827 know what other frame should receive those keystrokes. */
1828 struct frame
*f
= decode_any_frame (frame
);
1830 if (! NILP (focus_frame
))
1831 CHECK_LIVE_FRAME (focus_frame
);
1833 fset_focus_frame (f
, focus_frame
);
1835 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
1836 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
1842 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 0, 1, 0,
1843 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1844 If FRAME is omitted or nil, the selected frame is used.
1845 Return nil if FRAME's focus is not redirected.
1846 See `redirect-frame-focus'. */)
1849 return FRAME_FOCUS_FRAME (decode_live_frame (frame
));
1854 /* Return the value of frame parameter PROP in frame FRAME. */
1856 #ifdef HAVE_WINDOW_SYSTEM
1857 #if !HAVE_NS && !defined(WINDOWSNT)
1861 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
1863 register Lisp_Object tem
;
1865 tem
= Fassq (prop
, frame
->param_alist
);
1872 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
1875 frames_discard_buffer (Lisp_Object buffer
)
1877 Lisp_Object frame
, tail
;
1879 FOR_EACH_FRAME (tail
, frame
)
1882 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
1883 fset_buried_buffer_list
1884 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
1888 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1889 If the alist already has an element for PROP, we change it. */
1892 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
1894 register Lisp_Object tem
;
1896 tem
= Fassq (prop
, *alistptr
);
1898 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1904 frame_name_fnn_p (char *str
, ptrdiff_t len
)
1906 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
1909 while ('0' <= *p
&& *p
<= '9')
1917 /* Set the name of the terminal frame. Also used by MSDOS frames.
1918 Modeled after x_set_name which is used for WINDOW frames. */
1921 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
1923 f
->explicit_name
= ! NILP (name
);
1925 /* If NAME is nil, set the name to F<num>. */
1928 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
1930 /* Check for no change needed in this very common case
1931 before we do any consing. */
1932 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
1935 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
1939 CHECK_STRING (name
);
1941 /* Don't change the name if it's already NAME. */
1942 if (! NILP (Fstring_equal (name
, f
->name
)))
1945 /* Don't allow the user to set the frame name to F<num>, so it
1946 doesn't clash with the names we generate for terminal frames. */
1947 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
1948 error ("Frame names of the form F<num> are usurped by Emacs");
1951 fset_name (f
, name
);
1952 update_mode_lines
= 1;
1956 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
1958 register Lisp_Object old_alist_elt
;
1960 /* The buffer-list parameters are stored in a special place and not
1961 in the alist. All buffers must be live. */
1962 if (EQ (prop
, Qbuffer_list
))
1964 Lisp_Object list
= Qnil
;
1965 for (; CONSP (val
); val
= XCDR (val
))
1966 if (!NILP (Fbuffer_live_p (XCAR (val
))))
1967 list
= Fcons (XCAR (val
), list
);
1968 fset_buffer_list (f
, Fnreverse (list
));
1971 if (EQ (prop
, Qburied_buffer_list
))
1973 Lisp_Object list
= Qnil
;
1974 for (; CONSP (val
); val
= XCDR (val
))
1975 if (!NILP (Fbuffer_live_p (XCAR (val
))))
1976 list
= Fcons (XCAR (val
), list
);
1977 fset_buried_buffer_list (f
, Fnreverse (list
));
1981 /* If PROP is a symbol which is supposed to have frame-local values,
1982 and it is set up based on this frame, switch to the global
1983 binding. That way, we can create or alter the frame-local binding
1984 without messing up the symbol's status. */
1987 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
1989 switch (sym
->redirect
)
1991 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
1992 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
1993 case SYMBOL_LOCALIZED
:
1994 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
1995 if (blv
->frame_local
&& blv_found (blv
) && XFRAME (blv
->where
) == f
)
1996 swap_in_global_binding (sym
);
1999 default: emacs_abort ();
2003 /* The tty color needed to be set before the frame's parameter
2004 alist was updated with the new value. This is not true any more,
2005 but we still do this test early on. */
2006 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2007 && f
== FRAME_TTY (f
)->previous_frame
)
2008 /* Force redisplay of this tty. */
2009 FRAME_TTY (f
)->previous_frame
= NULL
;
2011 /* Update the frame parameter alist. */
2012 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2013 if (EQ (old_alist_elt
, Qnil
))
2014 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2016 Fsetcdr (old_alist_elt
, val
);
2018 /* Update some other special parameters in their special places
2019 in addition to the alist. */
2021 if (EQ (prop
, Qbuffer_predicate
))
2022 fset_buffer_predicate (f
, val
);
2024 if (! FRAME_WINDOW_P (f
))
2026 if (EQ (prop
, Qmenu_bar_lines
))
2027 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2028 else if (EQ (prop
, Qname
))
2029 set_term_frame_name (f
, val
);
2032 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2034 if (! MINI_WINDOW_P (XWINDOW (val
)))
2035 error ("Surrogate minibuffer windows must be minibuffer windows");
2037 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2038 && !EQ (val
, f
->minibuffer_window
))
2039 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2041 /* Install the chosen minibuffer window, with proper buffer. */
2042 fset_minibuffer_window (f
, val
);
2046 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2047 doc
: /* Return the parameters-alist of frame FRAME.
2048 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2049 The meaningful PARMs depend on the kind of frame.
2050 If FRAME is omitted or nil, return information on the currently selected frame. */)
2054 struct frame
*f
= decode_any_frame (frame
);
2056 struct gcpro gcpro1
;
2058 if (!FRAME_LIVE_P (f
))
2061 alist
= Fcopy_alist (f
->param_alist
);
2064 if (!FRAME_WINDOW_P (f
))
2066 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2067 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2070 /* If the frame's parameter alist says the colors are
2071 unspecified and reversed, take the frame's background pixel
2072 for foreground and vice versa. */
2073 elt
= Fassq (Qforeground_color
, alist
);
2074 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2076 if (strncmp (SSDATA (XCDR (elt
)),
2078 SCHARS (XCDR (elt
))) == 0)
2079 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2080 else if (strncmp (SSDATA (XCDR (elt
)),
2082 SCHARS (XCDR (elt
))) == 0)
2083 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2086 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2087 elt
= Fassq (Qbackground_color
, alist
);
2088 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2090 if (strncmp (SSDATA (XCDR (elt
)),
2092 SCHARS (XCDR (elt
))) == 0)
2093 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2094 else if (strncmp (SSDATA (XCDR (elt
)),
2096 SCHARS (XCDR (elt
))) == 0)
2097 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2100 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2101 store_in_alist (&alist
, intern ("font"),
2102 build_string (FRAME_MSDOS_P (f
)
2104 : FRAME_W32_P (f
) ? "w32term"
2107 store_in_alist (&alist
, Qname
, f
->name
);
2108 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2109 store_in_alist (&alist
, Qheight
, make_number (height
));
2110 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2111 store_in_alist (&alist
, Qwidth
, make_number (width
));
2112 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2113 store_in_alist (&alist
, Qminibuffer
,
2114 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2115 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2116 : FRAME_MINIBUF_WINDOW (f
)));
2117 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2118 store_in_alist (&alist
, Qbuffer_list
, f
->buffer_list
);
2119 store_in_alist (&alist
, Qburied_buffer_list
, f
->buried_buffer_list
);
2121 /* I think this should be done with a hook. */
2122 #ifdef HAVE_WINDOW_SYSTEM
2123 if (FRAME_WINDOW_P (f
))
2124 x_report_frame_params (f
, &alist
);
2128 /* This ought to be correct in f->param_alist for an X frame. */
2130 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2131 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2139 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2140 doc
: /* Return FRAME's value for parameter PARAMETER.
2141 If FRAME is nil, describe the currently selected frame. */)
2142 (Lisp_Object frame
, Lisp_Object parameter
)
2144 struct frame
*f
= decode_any_frame (frame
);
2145 Lisp_Object value
= Qnil
;
2147 CHECK_SYMBOL (parameter
);
2149 XSETFRAME (frame
, f
);
2151 if (FRAME_LIVE_P (f
))
2153 /* Avoid consing in frequent cases. */
2154 if (EQ (parameter
, Qname
))
2156 #ifdef HAVE_X_WINDOWS
2157 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2158 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2159 #endif /* HAVE_X_WINDOWS */
2160 else if (EQ (parameter
, Qbackground_color
)
2161 || EQ (parameter
, Qforeground_color
))
2163 value
= Fassq (parameter
, f
->param_alist
);
2166 value
= XCDR (value
);
2167 /* Fframe_parameters puts the actual fg/bg color names,
2168 even if f->param_alist says otherwise. This is
2169 important when param_alist's notion of colors is
2170 "unspecified". We need to do the same here. */
2171 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2173 const char *color_name
;
2176 if (EQ (parameter
, Qbackground_color
))
2178 color_name
= SSDATA (value
);
2179 csz
= SCHARS (value
);
2180 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2181 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2182 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2183 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2185 else if (EQ (parameter
, Qforeground_color
))
2187 color_name
= SSDATA (value
);
2188 csz
= SCHARS (value
);
2189 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2190 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2191 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2192 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2197 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2199 else if (EQ (parameter
, Qdisplay_type
)
2200 || EQ (parameter
, Qbackground_mode
))
2201 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2203 /* FIXME: Avoid this code path at all (as well as code duplication)
2204 by sharing more code with Fframe_parameters. */
2205 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2212 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2213 Smodify_frame_parameters
, 2, 2, 0,
2214 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2215 If FRAME is nil, it defaults to the selected frame.
2216 ALIST is an alist of parameters to change and their new values.
2217 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2218 The meaningful PARMs depend on the kind of frame.
2219 Undefined PARMs are ignored, but stored in the frame's parameter list
2220 so that `frame-parameters' will return them.
2222 The value of frame parameter FOO can also be accessed
2223 as a frame-local binding for the variable FOO, if you have
2224 enabled such bindings for that variable with `make-variable-frame-local'.
2225 Note that this functionality is obsolete as of Emacs 22.2, and its
2226 use is not recommended. Explicitly check for a frame-parameter instead. */)
2227 (Lisp_Object frame
, Lisp_Object alist
)
2229 struct frame
*f
= decode_live_frame (frame
);
2230 register Lisp_Object tail
, prop
, val
;
2232 /* I think this should be done with a hook. */
2233 #ifdef HAVE_WINDOW_SYSTEM
2234 if (FRAME_WINDOW_P (f
))
2235 x_set_frame_parameters (f
, alist
);
2239 if (FRAME_MSDOS_P (f
))
2240 IT_set_frame_parameters (f
, alist
);
2245 EMACS_INT length
= XFASTINT (Flength (alist
));
2248 Lisp_Object
*values
;
2250 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2251 values
= parms
+ length
;
2253 /* Extract parm names and values into those vectors. */
2256 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2261 parms
[i
] = Fcar (elt
);
2262 values
[i
] = Fcdr (elt
);
2266 /* Now process them in reverse of specified order. */
2271 store_frame_param (f
, prop
, val
);
2273 if (EQ (prop
, Qforeground_color
)
2274 || EQ (prop
, Qbackground_color
))
2275 update_face_from_frame_parameter (f
, prop
, val
);
2283 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2285 doc
: /* Height in pixels of a line in the font in frame FRAME.
2286 If FRAME is omitted or nil, the selected frame is used.
2287 For a terminal frame, the value is always 1. */)
2290 #ifdef HAVE_WINDOW_SYSTEM
2291 struct frame
*f
= decode_any_frame (frame
);
2293 if (FRAME_WINDOW_P (f
))
2294 return make_number (FRAME_LINE_HEIGHT (f
));
2297 return make_number (1);
2301 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2303 doc
: /* Width in pixels of characters in the font in frame FRAME.
2304 If FRAME is omitted or nil, the selected frame is used.
2305 On a graphical screen, the width is the standard width of the default font.
2306 For a terminal screen, the value is always 1. */)
2309 #ifdef HAVE_WINDOW_SYSTEM
2310 struct frame
*f
= decode_any_frame (frame
);
2312 if (FRAME_WINDOW_P (f
))
2313 return make_number (FRAME_COLUMN_WIDTH (f
));
2316 return make_number (1);
2319 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2320 Sframe_pixel_height
, 0, 1, 0,
2321 doc
: /* Return a FRAME's height in pixels.
2322 If FRAME is omitted or nil, the selected frame is used. The exact value
2323 of the result depends on the window-system and toolkit in use:
2325 In the Gtk+ version of Emacs, it includes only any window (including
2326 the minibuffer or echo area), mode line, and header line. It does not
2327 include the tool bar or menu bar.
2329 With other graphical versions, it also includes the tool bar and the
2332 For a text terminal, it includes the menu bar. In this case, the
2333 result is really in characters rather than pixels (i.e., is identical
2334 to `frame-height'). */)
2337 struct frame
*f
= decode_any_frame (frame
);
2339 #ifdef HAVE_WINDOW_SYSTEM
2340 if (FRAME_WINDOW_P (f
))
2341 return make_number (x_pixel_height (f
));
2344 return make_number (FRAME_LINES (f
));
2347 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2348 Sframe_pixel_width
, 0, 1, 0,
2349 doc
: /* Return FRAME's width in pixels.
2350 For a terminal frame, the result really gives the width in characters.
2351 If FRAME is omitted or nil, the selected frame is used. */)
2354 struct frame
*f
= decode_any_frame (frame
);
2356 #ifdef HAVE_WINDOW_SYSTEM
2357 if (FRAME_WINDOW_P (f
))
2358 return make_number (x_pixel_width (f
));
2361 return make_number (FRAME_COLS (f
));
2364 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2365 Stool_bar_pixel_width
, 0, 1, 0,
2366 doc
: /* Return width in pixels of FRAME's tool bar.
2367 The result is greater than zero only when the tool bar is on the left
2368 or right side of FRAME. If FRAME is omitted or nil, the selected frame
2372 #ifdef FRAME_TOOLBAR_WIDTH
2373 struct frame
*f
= decode_any_frame (frame
);
2375 if (FRAME_WINDOW_P (f
))
2376 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2378 return make_number (0);
2381 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2382 doc
: /* Specify that the frame FRAME has LINES lines.
2383 Optional third arg non-nil means that redisplay should use LINES lines
2384 but that the idea of the actual height of the frame should not be changed. */)
2385 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2387 register struct frame
*f
= decode_live_frame (frame
);
2389 CHECK_TYPE_RANGED_INTEGER (int, lines
);
2391 /* I think this should be done with a hook. */
2392 #ifdef HAVE_WINDOW_SYSTEM
2393 if (FRAME_WINDOW_P (f
))
2395 if (XINT (lines
) != FRAME_LINES (f
))
2396 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2397 do_pending_window_change (0);
2401 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2405 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2406 doc
: /* Specify that the frame FRAME has COLS columns.
2407 Optional third arg non-nil means that redisplay should use COLS columns
2408 but that the idea of the actual width of the frame should not be changed. */)
2409 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2411 register struct frame
*f
= decode_live_frame (frame
);
2413 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2415 /* I think this should be done with a hook. */
2416 #ifdef HAVE_WINDOW_SYSTEM
2417 if (FRAME_WINDOW_P (f
))
2419 if (XINT (cols
) != FRAME_COLS (f
))
2420 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2421 do_pending_window_change (0);
2425 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2429 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2430 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2431 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2433 register struct frame
*f
;
2435 CHECK_LIVE_FRAME (frame
);
2436 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2437 CHECK_TYPE_RANGED_INTEGER (int, rows
);
2440 /* I think this should be done with a hook. */
2441 #ifdef HAVE_WINDOW_SYSTEM
2442 if (FRAME_WINDOW_P (f
))
2444 if (XINT (rows
) != FRAME_LINES (f
)
2445 || XINT (cols
) != FRAME_COLS (f
)
2446 || f
->new_text_lines
|| f
->new_text_cols
)
2447 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2448 do_pending_window_change (0);
2452 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2457 DEFUN ("set-frame-position", Fset_frame_position
,
2458 Sset_frame_position
, 3, 3, 0,
2459 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2460 This is actually the position of the upper left corner of the frame.
2461 Negative values for XOFFSET or YOFFSET are interpreted relative to
2462 the rightmost or bottommost possible position (that stays within the screen). */)
2463 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2465 register struct frame
*f
;
2467 CHECK_LIVE_FRAME (frame
);
2468 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2469 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2472 /* I think this should be done with a hook. */
2473 #ifdef HAVE_WINDOW_SYSTEM
2474 if (FRAME_WINDOW_P (f
))
2475 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2482 /***********************************************************************
2484 ***********************************************************************/
2486 /* Connect the frame-parameter names for X frames
2487 to the ways of passing the parameter values to the window system.
2489 The name of a parameter, as a Lisp symbol,
2490 has an `x-frame-parameter' property which is an integer in Lisp
2491 that is an index in this table. */
2493 struct frame_parm_table
{
2495 Lisp_Object
*variable
;
2498 static const struct frame_parm_table frame_parms
[] =
2500 {"auto-raise", &Qauto_raise
},
2501 {"auto-lower", &Qauto_lower
},
2502 {"background-color", 0},
2503 {"border-color", &Qborder_color
},
2504 {"border-width", &Qborder_width
},
2505 {"cursor-color", &Qcursor_color
},
2506 {"cursor-type", &Qcursor_type
},
2508 {"foreground-color", 0},
2509 {"icon-name", &Qicon_name
},
2510 {"icon-type", &Qicon_type
},
2511 {"internal-border-width", &Qinternal_border_width
},
2512 {"menu-bar-lines", &Qmenu_bar_lines
},
2513 {"mouse-color", &Qmouse_color
},
2515 {"scroll-bar-width", &Qscroll_bar_width
},
2517 {"unsplittable", &Qunsplittable
},
2518 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2519 {"visibility", &Qvisibility
},
2520 {"tool-bar-lines", &Qtool_bar_lines
},
2521 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2522 {"scroll-bar-background", &Qscroll_bar_background
},
2523 {"screen-gamma", &Qscreen_gamma
},
2524 {"line-spacing", &Qline_spacing
},
2525 {"left-fringe", &Qleft_fringe
},
2526 {"right-fringe", &Qright_fringe
},
2527 {"wait-for-wm", &Qwait_for_wm
},
2528 {"fullscreen", &Qfullscreen
},
2529 {"font-backend", &Qfont_backend
},
2531 {"sticky", &Qsticky
},
2532 {"tool-bar-position", &Qtool_bar_position
},
2537 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2538 wanted positions of the WM window (not Emacs window).
2539 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2540 window (FRAME_X_WINDOW).
2544 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2546 int newwidth
= FRAME_COLS (f
);
2547 int newheight
= FRAME_LINES (f
);
2548 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2550 *top_pos
= f
->top_pos
;
2551 *left_pos
= f
->left_pos
;
2553 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2557 ph
= x_display_pixel_height (dpyinfo
);
2558 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2559 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2560 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2564 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2568 pw
= x_display_pixel_width (dpyinfo
);
2569 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2570 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2571 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2576 *height
= newheight
;
2579 #endif /* HAVE_NTGUI */
2581 #ifdef HAVE_WINDOW_SYSTEM
2583 /* Change the parameters of frame F as specified by ALIST.
2584 If a parameter is not specially recognized, do nothing special;
2585 otherwise call the `x_set_...' function for that parameter.
2586 Except for certain geometry properties, always call store_frame_param
2587 to store the new value in the parameter alist. */
2590 x_set_frame_parameters (FRAME_PTR f
, Lisp_Object alist
)
2594 /* If both of these parameters are present, it's more efficient to
2595 set them both at once. So we wait until we've looked at the
2596 entire list before we set them. */
2600 Lisp_Object left
, top
;
2602 /* Same with these. */
2603 Lisp_Object icon_left
, icon_top
;
2605 /* Record in these vectors all the parms specified. */
2607 Lisp_Object
*values
;
2609 int left_no_change
= 0, top_no_change
= 0;
2610 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2611 int size_changed
= 0;
2612 struct gcpro gcpro1
, gcpro2
;
2615 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2618 parms
= alloca (i
* sizeof *parms
);
2619 values
= alloca (i
* sizeof *values
);
2621 /* Extract parm names and values into those vectors. */
2624 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2629 parms
[i
] = Fcar (elt
);
2630 values
[i
] = Fcdr (elt
);
2633 /* TAIL and ALIST are not used again below here. */
2634 alist
= tail
= Qnil
;
2636 GCPRO2 (*parms
, *values
);
2640 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2641 because their values appear in VALUES and strings are not valid. */
2642 top
= left
= Qunbound
;
2643 icon_left
= icon_top
= Qunbound
;
2645 /* Provide default values for HEIGHT and WIDTH. */
2646 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2647 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2649 /* Process foreground_color and background_color before anything else.
2650 They are independent of other properties, but other properties (e.g.,
2651 cursor_color) are dependent upon them. */
2652 /* Process default font as well, since fringe widths depends on it. */
2653 for (p
= 0; p
< i
; p
++)
2655 Lisp_Object prop
, val
;
2659 if (EQ (prop
, Qforeground_color
)
2660 || EQ (prop
, Qbackground_color
)
2661 || EQ (prop
, Qfont
))
2663 register Lisp_Object param_index
, old_value
;
2665 old_value
= get_frame_param (f
, prop
);
2666 if (NILP (Fequal (val
, old_value
)))
2668 store_frame_param (f
, prop
, val
);
2670 param_index
= Fget (prop
, Qx_frame_parameter
);
2671 if (NATNUMP (param_index
)
2672 && (XFASTINT (param_index
)
2673 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2674 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2675 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2680 /* Now process them in reverse of specified order. */
2683 Lisp_Object prop
, val
;
2688 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2691 width
= XFASTINT (val
);
2693 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2696 height
= XFASTINT (val
);
2698 else if (EQ (prop
, Qtop
))
2700 else if (EQ (prop
, Qleft
))
2702 else if (EQ (prop
, Qicon_top
))
2704 else if (EQ (prop
, Qicon_left
))
2706 else if (EQ (prop
, Qforeground_color
)
2707 || EQ (prop
, Qbackground_color
)
2708 || EQ (prop
, Qfont
))
2709 /* Processed above. */
2713 register Lisp_Object param_index
, old_value
;
2715 old_value
= get_frame_param (f
, prop
);
2717 store_frame_param (f
, prop
, val
);
2719 param_index
= Fget (prop
, Qx_frame_parameter
);
2720 if (NATNUMP (param_index
)
2721 && (XFASTINT (param_index
)
2722 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2723 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2724 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2728 /* Don't die if just one of these was set. */
2729 if (EQ (left
, Qunbound
))
2732 if (f
->left_pos
< 0)
2733 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2735 XSETINT (left
, f
->left_pos
);
2737 if (EQ (top
, Qunbound
))
2741 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2743 XSETINT (top
, f
->top_pos
);
2746 /* If one of the icon positions was not set, preserve or default it. */
2747 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
2749 icon_left_no_change
= 1;
2750 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2751 if (NILP (icon_left
))
2752 XSETINT (icon_left
, 0);
2754 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
2756 icon_top_no_change
= 1;
2757 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2758 if (NILP (icon_top
))
2759 XSETINT (icon_top
, 0);
2762 /* Don't set these parameters unless they've been explicitly
2763 specified. The window might be mapped or resized while we're in
2764 this function, and we don't want to override that unless the lisp
2765 code has asked for it.
2767 Don't set these parameters unless they actually differ from the
2768 window's current parameters; the window may not actually exist
2773 check_frame_size (f
, &height
, &width
);
2775 XSETFRAME (frame
, f
);
2778 && (width
!= FRAME_COLS (f
)
2779 || height
!= FRAME_LINES (f
)
2780 || f
->new_text_lines
|| f
->new_text_cols
))
2781 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2783 if ((!NILP (left
) || !NILP (top
))
2784 && ! (left_no_change
&& top_no_change
)
2785 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2786 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2791 /* Record the signs. */
2792 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2793 if (EQ (left
, Qminus
))
2794 f
->size_hint_flags
|= XNegative
;
2795 else if (TYPE_RANGED_INTEGERP (int, left
))
2797 leftpos
= XINT (left
);
2799 f
->size_hint_flags
|= XNegative
;
2801 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2802 && CONSP (XCDR (left
))
2803 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
2805 leftpos
= - XINT (XCAR (XCDR (left
)));
2806 f
->size_hint_flags
|= XNegative
;
2808 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2809 && CONSP (XCDR (left
))
2810 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
2812 leftpos
= XINT (XCAR (XCDR (left
)));
2815 if (EQ (top
, Qminus
))
2816 f
->size_hint_flags
|= YNegative
;
2817 else if (TYPE_RANGED_INTEGERP (int, top
))
2819 toppos
= XINT (top
);
2821 f
->size_hint_flags
|= YNegative
;
2823 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2824 && CONSP (XCDR (top
))
2825 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
2827 toppos
= - XINT (XCAR (XCDR (top
)));
2828 f
->size_hint_flags
|= YNegative
;
2830 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2831 && CONSP (XCDR (top
))
2832 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
2834 toppos
= XINT (XCAR (XCDR (top
)));
2838 /* Store the numeric value of the position. */
2839 f
->top_pos
= toppos
;
2840 f
->left_pos
= leftpos
;
2842 f
->win_gravity
= NorthWestGravity
;
2844 /* Actually set that position, and convert to absolute. */
2845 x_set_offset (f
, leftpos
, toppos
, -1);
2848 if ((!NILP (icon_left
) || !NILP (icon_top
))
2849 && ! (icon_left_no_change
&& icon_top_no_change
))
2850 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2857 /* Insert a description of internally-recorded parameters of frame X
2858 into the parameter alist *ALISTPTR that is to be given to the user.
2859 Only parameters that are specific to the X window system
2860 and whose values are not correctly recorded in the frame's
2861 param_alist need to be considered here. */
2864 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
2868 char buf
[INT_BUFSIZE_BOUND (w
)];
2870 /* Represent negative positions (off the top or left screen edge)
2871 in a way that Fmodify_frame_parameters will understand correctly. */
2872 XSETINT (tem
, f
->left_pos
);
2873 if (f
->left_pos
>= 0)
2874 store_in_alist (alistptr
, Qleft
, tem
);
2876 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2878 XSETINT (tem
, f
->top_pos
);
2879 if (f
->top_pos
>= 0)
2880 store_in_alist (alistptr
, Qtop
, tem
);
2882 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2884 store_in_alist (alistptr
, Qborder_width
,
2885 make_number (f
->border_width
));
2886 store_in_alist (alistptr
, Qinternal_border_width
,
2887 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
2888 store_in_alist (alistptr
, Qleft_fringe
,
2889 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
2890 store_in_alist (alistptr
, Qright_fringe
,
2891 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
2892 store_in_alist (alistptr
, Qscroll_bar_width
,
2893 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2895 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
2896 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
2897 /* nil means "use default width"
2898 for non-toolkit scroll bar.
2899 ruler-mode.el depends on this. */
2901 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
2902 MS-Windows it returns a value whose type is HANDLE, which is
2903 actually a pointer. Explicit casting avoids compiler
2905 w
= (uintptr_t) FRAME_X_WINDOW (f
);
2906 store_in_alist (alistptr
, Qwindow_id
,
2907 make_formatted_string (buf
, "%"pMu
, w
));
2908 #ifdef HAVE_X_WINDOWS
2909 #ifdef USE_X_TOOLKIT
2910 /* Tooltip frame may not have this widget. */
2911 if (FRAME_X_OUTPUT (f
)->widget
)
2913 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
2914 store_in_alist (alistptr
, Qouter_window_id
,
2915 make_formatted_string (buf
, "%"pMu
, w
));
2917 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
2918 store_in_alist (alistptr
, Qvisibility
,
2919 (FRAME_VISIBLE_P (f
) ? Qt
2920 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
2921 store_in_alist (alistptr
, Qdisplay
,
2922 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
2924 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
2927 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
2928 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
2929 store_in_alist (alistptr
, Qparent_id
, tem
);
2930 store_in_alist (alistptr
, Qtool_bar_position
, f
->tool_bar_position
);
2934 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
2935 the previous value of that parameter, NEW_VALUE is the new value. */
2938 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
2940 if (NILP (new_value
))
2941 f
->want_fullscreen
= FULLSCREEN_NONE
;
2942 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
2943 f
->want_fullscreen
= FULLSCREEN_BOTH
;
2944 else if (EQ (new_value
, Qfullwidth
))
2945 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
2946 else if (EQ (new_value
, Qfullheight
))
2947 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
2948 else if (EQ (new_value
, Qmaximized
))
2949 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
2951 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
2952 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
2956 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
2957 the previous value of that parameter, NEW_VALUE is the new value. */
2960 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
2962 if (NILP (new_value
))
2963 f
->extra_line_spacing
= 0;
2964 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
2965 f
->extra_line_spacing
= XFASTINT (new_value
);
2967 signal_error ("Invalid line-spacing", new_value
);
2968 if (FRAME_VISIBLE_P (f
))
2973 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
2974 the previous value of that parameter, NEW_VALUE is the new value. */
2977 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
2979 Lisp_Object bgcolor
;
2981 if (NILP (new_value
))
2983 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
2984 /* The value 0.4545 is the normal viewing gamma. */
2985 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
2987 signal_error ("Invalid screen-gamma", new_value
);
2989 /* Apply the new gamma value to the frame background. */
2990 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
2991 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
2993 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
2994 if (NATNUMP (parm_index
)
2995 && (XFASTINT (parm_index
)
2996 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2997 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
2998 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3002 Fclear_face_cache (Qnil
);
3007 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3009 Lisp_Object font_object
;
3011 #ifdef HAVE_X_WINDOWS
3012 Lisp_Object font_param
= arg
;
3015 /* Set the frame parameter back to the old value because we may
3016 fail to use ARG as the new parameter value. */
3017 store_frame_param (f
, Qfont
, oldval
);
3019 /* ARG is a fontset name, a font name, a cons of fontset name and a
3020 font object, or a font object. In the last case, this function
3024 fontset
= fs_query_fontset (arg
, 0);
3027 font_object
= font_open_by_name (f
, arg
);
3028 if (NILP (font_object
))
3029 error ("Font `%s' is not defined", SSDATA (arg
));
3030 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3032 else if (fontset
> 0)
3034 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
3035 if (NILP (font_object
))
3036 error ("Font `%s' is not defined", SDATA (arg
));
3037 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3040 error ("The default fontset can't be used for a frame font");
3042 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3044 /* This is the case that the ASCII font of F's fontset XCAR
3045 (arg) is changed to the font XCDR (arg) by
3046 `set-fontset-font'. */
3047 fontset
= fs_query_fontset (XCAR (arg
), 0);
3049 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3050 font_object
= XCDR (arg
);
3051 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3052 #ifdef HAVE_X_WINDOWS
3053 font_param
= Ffont_get (font_object
, QCname
);
3056 else if (FONT_OBJECT_P (arg
))
3059 #ifdef HAVE_X_WINDOWS
3060 font_param
= Ffont_get (font_object
, QCname
);
3062 /* This is to store the XLFD font name in the frame parameter for
3063 backward compatibility. We should store the font-object
3064 itself in the future. */
3065 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3066 fontset
= FRAME_FONTSET (f
);
3067 /* Check if we can use the current fontset. If not, set FONTSET
3068 to -1 to generate a new fontset from FONT-OBJECT. */
3071 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3072 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3075 signal_error ("Invalid font name", ascii_font
);
3077 if (! font_match_p (spec
, font_object
))
3082 signal_error ("Invalid font", arg
);
3084 if (! NILP (Fequal (font_object
, oldval
)))
3087 x_new_font (f
, font_object
, fontset
);
3088 store_frame_param (f
, Qfont
, arg
);
3089 #ifdef HAVE_X_WINDOWS
3090 store_frame_param (f
, Qfont_param
, font_param
);
3092 /* Recalculate toolbar height. */
3093 f
->n_tool_bar_rows
= 0;
3094 /* Ensure we redraw it. */
3095 clear_current_matrices (f
);
3097 recompute_basic_faces (f
);
3099 do_pending_window_change (0);
3101 /* We used to call face-set-after-frame-default here, but it leads to
3102 recursive calls (since that function can set the `default' face's
3103 font which in turns changes the frame's `font' parameter).
3104 Also I don't know what this call is meant to do, but it seems the
3105 wrong way to do it anyway (it does a lot more work than what seems
3106 reasonable in response to a change to `font'). */
3111 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3113 if (! NILP (new_value
)
3114 && !CONSP (new_value
))
3118 CHECK_STRING (new_value
);
3119 p0
= p1
= SSDATA (new_value
);
3123 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
3125 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3131 while ((c
= *++p1
) && c_isspace (c
));
3135 new_value
= Fnreverse (new_value
);
3138 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3142 free_all_realized_faces (Qnil
);
3144 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3145 if (NILP (new_value
))
3147 if (NILP (old_value
))
3148 error ("No font backend available");
3149 font_update_drivers (f
, old_value
);
3150 error ("None of specified font backends are available");
3152 store_frame_param (f
, Qfont_backend
, new_value
);
3158 XSETFRAME (frame
, f
);
3159 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3160 ++face_change_count
;
3161 ++windows_or_buffers_changed
;
3167 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3169 compute_fringe_widths (f
, 1);
3170 #ifdef HAVE_X_WINDOWS
3171 /* Must adjust this so window managers report correct number of columns. */
3172 if (FRAME_X_WINDOW (f
) != 0)
3173 x_wm_set_size_hint (f
, 0, 0);
3178 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3180 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3182 if (XINT (arg
) == f
->border_width
)
3185 if (FRAME_X_WINDOW (f
) != 0)
3186 error ("Cannot change the border width of a frame");
3188 f
->border_width
= XINT (arg
);
3192 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3194 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3196 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3197 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3198 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3199 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3201 #ifdef USE_X_TOOLKIT
3202 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3203 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3206 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3209 if (FRAME_X_WINDOW (f
) != 0)
3211 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3212 SET_FRAME_GARBAGED (f
);
3213 do_pending_window_change (0);
3216 SET_FRAME_GARBAGED (f
);
3220 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3223 XSETFRAME (frame
, f
);
3226 Fmake_frame_invisible (frame
, Qt
);
3227 else if (EQ (value
, Qicon
))
3228 Ficonify_frame (frame
);
3230 Fmake_frame_visible (frame
);
3234 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3236 f
->auto_raise
= !EQ (Qnil
, arg
);
3240 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3242 f
->auto_lower
= !EQ (Qnil
, arg
);
3246 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3248 f
->no_split
= !NILP (arg
);
3252 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3254 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3255 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3256 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3257 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3259 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3261 ? vertical_scroll_bar_none
3263 ? vertical_scroll_bar_left
3265 ? vertical_scroll_bar_right
3266 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3267 ? vertical_scroll_bar_left
3268 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3269 ? vertical_scroll_bar_right
3270 : vertical_scroll_bar_none
);
3272 /* We set this parameter before creating the X window for the
3273 frame, so we can get the geometry right from the start.
3274 However, if the window hasn't been created yet, we shouldn't
3275 call x_set_window_size. */
3276 if (FRAME_X_WINDOW (f
))
3277 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3278 do_pending_window_change (0);
3283 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3285 int wid
= FRAME_COLUMN_WIDTH (f
);
3289 x_set_scroll_bar_default_width (f
);
3291 if (FRAME_X_WINDOW (f
))
3292 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3293 do_pending_window_change (0);
3295 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3296 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3298 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3299 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3301 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3302 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3303 if (FRAME_X_WINDOW (f
))
3304 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3305 do_pending_window_change (0);
3308 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3309 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3310 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3315 /* Return non-nil if frame F wants a bitmap icon. */
3318 x_icon_type (FRAME_PTR f
)
3322 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3330 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3337 for (i
= 0; i
< 2; i
++)
3350 else if (FLOATP (item
))
3352 alpha
= XFLOAT_DATA (item
);
3353 if (! (0 <= alpha
&& alpha
<= 1.0))
3354 args_out_of_range (make_float (0.0), make_float (1.0));
3356 else if (INTEGERP (item
))
3358 EMACS_INT ialpha
= XINT (item
);
3359 if (! (0 <= ialpha
&& alpha
<= 100))
3360 args_out_of_range (make_number (0), make_number (100));
3361 alpha
= ialpha
/ 100.0;
3364 wrong_type_argument (Qnumberp
, item
);
3368 for (i
= 0; i
< 2; i
++)
3369 f
->alpha
[i
] = newval
[i
];
3371 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3373 x_set_frame_alpha (f
);
3381 /* Subroutines of creating an X frame. */
3383 /* Make sure that Vx_resource_name is set to a reasonable value.
3384 Fix it up, or set it to `emacs' if it is too hopeless. */
3387 validate_x_resource_name (void)
3390 /* Number of valid characters in the resource name. */
3391 ptrdiff_t good_count
= 0;
3392 /* Number of invalid characters in the resource name. */
3393 ptrdiff_t bad_count
= 0;
3397 if (!STRINGP (Vx_resource_class
))
3398 Vx_resource_class
= build_string (EMACS_CLASS
);
3400 if (STRINGP (Vx_resource_name
))
3402 unsigned char *p
= SDATA (Vx_resource_name
);
3404 len
= SBYTES (Vx_resource_name
);
3406 /* Only letters, digits, - and _ are valid in resource names.
3407 Count the valid characters and count the invalid ones. */
3408 for (i
= 0; i
< len
; i
++)
3411 if (! ((c
>= 'a' && c
<= 'z')
3412 || (c
>= 'A' && c
<= 'Z')
3413 || (c
>= '0' && c
<= '9')
3414 || c
== '-' || c
== '_'))
3421 /* Not a string => completely invalid. */
3422 bad_count
= 5, good_count
= 0;
3424 /* If name is valid already, return. */
3428 /* If name is entirely invalid, or nearly so, or is so implausibly
3429 large that alloca might not work, use `emacs'. */
3430 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
3432 Vx_resource_name
= build_string ("emacs");
3436 /* Name is partly valid. Copy it and replace the invalid characters
3437 with underscores. */
3439 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3441 for (i
= 0; i
< len
; i
++)
3443 int c
= SREF (new, i
);
3444 if (! ((c
>= 'a' && c
<= 'z')
3445 || (c
>= 'A' && c
<= 'Z')
3446 || (c
>= '0' && c
<= '9')
3447 || c
== '-' || c
== '_'))
3453 extern char *x_get_string_resource (XrmDatabase
, const char *, const char *);
3454 extern Display_Info
*check_x_display_info (Lisp_Object
);
3457 /* Get specified attribute from resource database RDB.
3458 See Fx_get_resource below for other parameters. */
3461 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3463 register char *value
;
3467 CHECK_STRING (attribute
);
3468 CHECK_STRING (class);
3470 if (!NILP (component
))
3471 CHECK_STRING (component
);
3472 if (!NILP (subclass
))
3473 CHECK_STRING (subclass
);
3474 if (NILP (component
) != NILP (subclass
))
3475 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3477 validate_x_resource_name ();
3479 /* Allocate space for the components, the dots which separate them,
3480 and the final '\0'. Make them big enough for the worst case. */
3481 name_key
= alloca (SBYTES (Vx_resource_name
)
3482 + (STRINGP (component
)
3483 ? SBYTES (component
) : 0)
3484 + SBYTES (attribute
)
3487 class_key
= alloca (SBYTES (Vx_resource_class
)
3489 + (STRINGP (subclass
)
3490 ? SBYTES (subclass
) : 0)
3493 /* Start with emacs.FRAMENAME for the name (the specific one)
3494 and with `Emacs' for the class key (the general one). */
3495 strcpy (name_key
, SSDATA (Vx_resource_name
));
3496 strcpy (class_key
, SSDATA (Vx_resource_class
));
3498 strcat (class_key
, ".");
3499 strcat (class_key
, SSDATA (class));
3501 if (!NILP (component
))
3503 strcat (class_key
, ".");
3504 strcat (class_key
, SSDATA (subclass
));
3506 strcat (name_key
, ".");
3507 strcat (name_key
, SSDATA (component
));
3510 strcat (name_key
, ".");
3511 strcat (name_key
, SSDATA (attribute
));
3513 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3515 if (value
!= (char *) 0 && *value
)
3516 return build_string (value
);
3522 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3523 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3524 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3525 class, where INSTANCE is the name under which Emacs was invoked, or
3526 the name specified by the `-name' or `-rn' command-line arguments.
3528 The optional arguments COMPONENT and SUBCLASS add to the key and the
3529 class, respectively. You must specify both of them or neither.
3530 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3531 and the class is `Emacs.CLASS.SUBCLASS'. */)
3532 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
,
3533 Lisp_Object subclass
)
3535 check_window_system (NULL
);
3537 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3538 attribute
, class, component
, subclass
);
3541 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3544 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
,
3545 Lisp_Object
class, Lisp_Object component
,
3546 Lisp_Object subclass
)
3548 return xrdb_get_resource (dpyinfo
->xrdb
,
3549 attribute
, class, component
, subclass
);
3552 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3553 /* Used when C code wants a resource value. */
3554 /* Called from oldXMenu/Create.c. */
3556 x_get_resource_string (const char *attribute
, const char *class)
3559 struct frame
*sf
= SELECTED_FRAME ();
3560 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
3563 /* Allocate space for the components, the dots which separate them,
3564 and the final '\0'. */
3565 char *name_key
= SAFE_ALLOCA (invocation_namelen
+ strlen (attribute
) + 2);
3566 char *class_key
= alloca ((sizeof (EMACS_CLASS
) - 1) + strlen (class) + 2);
3568 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
3569 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3571 result
= x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3572 name_key
, class_key
);
3578 /* Return the value of parameter PARAM.
3580 First search ALIST, then Vdefault_frame_alist, then the X defaults
3581 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3583 Convert the resource to the type specified by desired_type.
3585 If no default is specified, return Qunbound. If you call
3586 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3587 and don't let it get stored in any Lisp-visible variables! */
3590 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3591 const char *attribute
, const char *class, enum resource_types type
)
3593 register Lisp_Object tem
;
3595 tem
= Fassq (param
, alist
);
3599 /* If we find this parm in ALIST, clear it out
3600 so that it won't be "left over" at the end. */
3602 XSETCAR (tem
, Qnil
);
3603 /* In case the parameter appears more than once in the alist,
3605 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3606 if (CONSP (XCAR (tail
))
3607 && EQ (XCAR (XCAR (tail
)), param
))
3608 XSETCAR (XCAR (tail
), Qnil
);
3611 tem
= Fassq (param
, Vdefault_frame_alist
);
3613 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3614 look in the X resources. */
3617 if (attribute
&& dpyinfo
)
3619 tem
= display_x_get_resource (dpyinfo
,
3620 build_string (attribute
),
3621 build_string (class),
3629 case RES_TYPE_NUMBER
:
3630 return make_number (atoi (SSDATA (tem
)));
3632 case RES_TYPE_BOOLEAN_NUMBER
:
3633 if (!strcmp (SSDATA (tem
), "on")
3634 || !strcmp (SSDATA (tem
), "true"))
3635 return make_number (1);
3636 return make_number (atoi (SSDATA (tem
)));
3639 case RES_TYPE_FLOAT
:
3640 return make_float (atof (SSDATA (tem
)));
3642 case RES_TYPE_BOOLEAN
:
3643 tem
= Fdowncase (tem
);
3644 if (!strcmp (SSDATA (tem
), "on")
3646 || !strcmp (SSDATA (tem
), "yes")
3648 || !strcmp (SSDATA (tem
), "true"))
3653 case RES_TYPE_STRING
:
3656 case RES_TYPE_SYMBOL
:
3657 /* As a special case, we map the values `true' and `on'
3658 to Qt, and `false' and `off' to Qnil. */
3661 lower
= Fdowncase (tem
);
3662 if (!strcmp (SSDATA (lower
), "on")
3664 || !strcmp (SSDATA (lower
), "yes")
3666 || !strcmp (SSDATA (lower
), "true"))
3668 else if (!strcmp (SSDATA (lower
), "off")
3670 || !strcmp (SSDATA (lower
), "no")
3672 || !strcmp (SSDATA (lower
), "false"))
3675 return Fintern (tem
, Qnil
);
3689 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3690 const char *attribute
, const char *class,
3691 enum resource_types type
)
3693 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3694 alist
, param
, attribute
, class, type
);
3697 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3700 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3702 const char *attribute
, const char *class,
3703 enum resource_types type
)
3707 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3708 attribute
, class, type
);
3709 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3710 store_frame_param (f
, param
, value
);
3716 /* Record in frame F the specified or default value according to ALIST
3717 of the parameter named PROP (a Lisp symbol).
3718 If no value is specified for PROP, look for an X default for XPROP
3719 on the frame named NAME.
3720 If that is not found either, use the value DEFLT. */
3723 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
3724 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
3725 enum resource_types type
)
3729 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3730 if (EQ (tem
, Qunbound
))
3732 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3737 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
3740 * XParseGeometry parses strings of the form
3741 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
3742 * width, height, xoffset, and yoffset are unsigned integers.
3743 * Example: "=80x24+300-49"
3744 * The equal sign is optional.
3745 * It returns a bitmask that indicates which of the four values
3746 * were actually found in the string. For each value found,
3747 * the corresponding argument is updated; for each value
3748 * not found, the corresponding argument is left unchanged.
3752 XParseGeometry (char *string
,
3754 unsigned int *width
, unsigned int *height
)
3758 unsigned long int tempWidth
, tempHeight
;
3759 long int tempX
, tempY
;
3760 char *nextCharacter
;
3762 if (string
== NULL
|| *string
== '\0')
3765 string
++; /* ignore possible '=' at beg of geometry spec */
3768 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
3770 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
3771 if (strind
== nextCharacter
)
3773 strind
= nextCharacter
;
3777 if (*strind
== 'x' || *strind
== 'X')
3780 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
3781 if (strind
== nextCharacter
)
3783 strind
= nextCharacter
;
3784 mask
|= HeightValue
;
3787 if (*strind
== '+' || *strind
== '-')
3791 tempX
= strtol (strind
, &nextCharacter
, 10);
3792 if (strind
== nextCharacter
)
3794 strind
= nextCharacter
;
3796 if (*strind
== '+' || *strind
== '-')
3800 tempY
= strtol (strind
, &nextCharacter
, 10);
3801 if (strind
== nextCharacter
)
3803 strind
= nextCharacter
;
3808 /* If strind isn't at the end of the string then it's an invalid
3809 geometry specification. */
3811 if (*strind
!= '\0')
3815 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
3817 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
3818 if (mask
& WidthValue
)
3819 *width
= min (tempWidth
, UINT_MAX
);
3820 if (mask
& HeightValue
)
3821 *height
= min (tempHeight
, UINT_MAX
);
3825 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
3828 /* NS used to define x-parse-geometry in ns-win.el, but that confused
3829 make-docfile: the documentation string in ns-win.el was used for
3830 x-parse-geometry even in non-NS builds.
3832 With two definitions of x-parse-geometry in this file, various
3833 things still get confused (eg M-x apropos documentation), so that
3834 it is best if the two definitions just share the same doc-string.
3836 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3837 doc
: /* Parse a display geometry string STRING.
3838 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3839 The properties returned may include `top', `left', `height', and `width'.
3840 For X, the value of `left' or `top' may be an integer,
3841 or a list (+ N) meaning N pixels relative to top/left corner,
3842 or a list (- N) meaning -N pixels relative to bottom/right corner.
3843 On Nextstep, this just calls `ns-parse-geometry'. */)
3844 (Lisp_Object string
)
3847 unsigned int width
, height
;
3850 CHECK_STRING (string
);
3853 if (strchr (SSDATA (string
), ' ') != NULL
)
3854 return call1 (Qns_parse_geometry
, string
);
3856 geometry
= XParseGeometry (SSDATA (string
),
3857 &x
, &y
, &width
, &height
);
3859 if (geometry
& XValue
)
3861 Lisp_Object element
;
3863 if (x
>= 0 && (geometry
& XNegative
))
3864 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3865 else if (x
< 0 && ! (geometry
& XNegative
))
3866 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3868 element
= Fcons (Qleft
, make_number (x
));
3869 result
= Fcons (element
, result
);
3872 if (geometry
& YValue
)
3874 Lisp_Object element
;
3876 if (y
>= 0 && (geometry
& YNegative
))
3877 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3878 else if (y
< 0 && ! (geometry
& YNegative
))
3879 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3881 element
= Fcons (Qtop
, make_number (y
));
3882 result
= Fcons (element
, result
);
3885 if (geometry
& WidthValue
)
3886 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3887 if (geometry
& HeightValue
)
3888 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3894 /* Calculate the desired size and position of frame F.
3895 Return the flags saying which aspects were specified.
3897 Also set the win_gravity and size_hint_flags of F.
3899 Adjust height for toolbar if TOOLBAR_P is 1.
3901 This function does not make the coordinates positive. */
3903 #define DEFAULT_ROWS 35
3904 #define DEFAULT_COLS 80
3907 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, int toolbar_p
)
3909 register Lisp_Object tem0
, tem1
, tem2
;
3910 long window_prompting
= 0;
3911 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3913 /* Default values if we fall through.
3914 Actually, if that happens we should get
3915 window manager prompting. */
3916 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3917 FRAME_LINES (f
) = DEFAULT_ROWS
;
3918 /* Window managers expect that if program-specified
3919 positions are not (0,0), they're intentional, not defaults. */
3923 /* Ensure that old new_text_cols and new_text_lines will not override the
3925 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3926 f
->new_text_cols
= f
->new_text_lines
= 0;
3928 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3929 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3930 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3931 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3933 if (!EQ (tem0
, Qunbound
))
3935 CHECK_NUMBER (tem0
);
3936 if (! (0 <= XINT (tem0
) && XINT (tem0
) <= INT_MAX
))
3937 xsignal1 (Qargs_out_of_range
, tem0
);
3938 FRAME_LINES (f
) = XINT (tem0
);
3940 if (!EQ (tem1
, Qunbound
))
3942 CHECK_NUMBER (tem1
);
3943 if (! (0 <= XINT (tem1
) && XINT (tem1
) <= INT_MAX
))
3944 xsignal1 (Qargs_out_of_range
, tem1
);
3945 SET_FRAME_COLS (f
, XINT (tem1
));
3947 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
3948 window_prompting
|= USSize
;
3950 window_prompting
|= PSize
;
3953 f
->scroll_bar_actual_width
3954 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
3956 /* This used to be done _before_ calling x_figure_window_size, but
3957 since the height is reset here, this was really a no-op. I
3958 assume that moving it here does what Gerd intended (although he
3959 no longer can remember what that was... ++KFS, 2003-03-25. */
3961 /* Add the tool-bar height to the initial frame height so that the
3962 user gets a text display area of the size he specified with -g or
3963 via .Xdefaults. Later changes of the tool-bar height don't
3964 change the frame size. This is done so that users can create
3965 tall Emacs frames without having to guess how tall the tool-bar
3967 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
3969 int margin
, relief
, bar_height
;
3971 relief
= (tool_bar_button_relief
>= 0
3972 ? tool_bar_button_relief
3973 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
3975 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
3976 margin
= XFASTINT (Vtool_bar_button_margin
);
3977 else if (CONSP (Vtool_bar_button_margin
)
3978 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
3979 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
3983 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
3984 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
3987 compute_fringe_widths (f
, 0);
3989 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
3990 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
3992 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
3993 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
3994 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
3995 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3997 if (EQ (tem0
, Qminus
))
4000 window_prompting
|= YNegative
;
4002 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4003 && CONSP (XCDR (tem0
))
4004 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem0
)), INT_MAX
))
4006 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4007 window_prompting
|= YNegative
;
4009 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4010 && CONSP (XCDR (tem0
))
4011 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0
))))
4013 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4015 else if (EQ (tem0
, Qunbound
))
4019 CHECK_TYPE_RANGED_INTEGER (int, tem0
);
4020 f
->top_pos
= XINT (tem0
);
4022 window_prompting
|= YNegative
;
4025 if (EQ (tem1
, Qminus
))
4028 window_prompting
|= XNegative
;
4030 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4031 && CONSP (XCDR (tem1
))
4032 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem1
)), INT_MAX
))
4034 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4035 window_prompting
|= XNegative
;
4037 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4038 && CONSP (XCDR (tem1
))
4039 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1
))))
4041 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4043 else if (EQ (tem1
, Qunbound
))
4047 CHECK_TYPE_RANGED_INTEGER (int, tem1
);
4048 f
->left_pos
= XINT (tem1
);
4049 if (f
->left_pos
< 0)
4050 window_prompting
|= XNegative
;
4053 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4054 window_prompting
|= USPosition
;
4056 window_prompting
|= PPosition
;
4059 if (window_prompting
& XNegative
)
4061 if (window_prompting
& YNegative
)
4062 f
->win_gravity
= SouthEastGravity
;
4064 f
->win_gravity
= NorthEastGravity
;
4068 if (window_prompting
& YNegative
)
4069 f
->win_gravity
= SouthWestGravity
;
4071 f
->win_gravity
= NorthWestGravity
;
4074 f
->size_hint_flags
= window_prompting
;
4076 return window_prompting
;
4081 #endif /* HAVE_WINDOW_SYSTEM */
4084 frame_make_pointer_invisible (void)
4086 if (! NILP (Vmake_pointer_invisible
))
4089 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4092 f
= SELECTED_FRAME ();
4093 if (f
&& !f
->pointer_invisible
4094 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4097 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4098 f
->pointer_invisible
= 1;
4104 frame_make_pointer_visible (void)
4106 /* We don't check Vmake_pointer_invisible here in case the
4107 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4110 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4113 f
= SELECTED_FRAME ();
4114 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4115 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4117 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4118 f
->pointer_invisible
= 0;
4122 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4123 Sframe_pointer_visible_p
, 0, 1, 0,
4124 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4125 Otherwise it returns nil. FRAME omitted or nil means the
4126 selected frame. This is useful when `make-pointer-invisible' is set. */)
4129 return decode_any_frame (frame
)->pointer_invisible
? Qnil
: Qt
;
4133 /***********************************************************************
4135 ***********************************************************************/
4138 syms_of_frame (void)
4140 DEFSYM (Qframep
, "framep");
4141 DEFSYM (Qframe_live_p
, "frame-live-p");
4142 DEFSYM (Qexplicit_name
, "explicit-name");
4143 DEFSYM (Qheight
, "height");
4144 DEFSYM (Qicon
, "icon");
4145 DEFSYM (Qminibuffer
, "minibuffer");
4146 DEFSYM (Qmodeline
, "modeline");
4147 DEFSYM (Qonly
, "only");
4148 DEFSYM (Qnone
, "none");
4149 DEFSYM (Qwidth
, "width");
4150 DEFSYM (Qgeometry
, "geometry");
4151 DEFSYM (Qicon_left
, "icon-left");
4152 DEFSYM (Qicon_top
, "icon-top");
4153 DEFSYM (Qtooltip
, "tooltip");
4154 DEFSYM (Qleft
, "left");
4155 DEFSYM (Qright
, "right");
4156 DEFSYM (Quser_position
, "user-position");
4157 DEFSYM (Quser_size
, "user-size");
4158 DEFSYM (Qwindow_id
, "window-id");
4159 #ifdef HAVE_X_WINDOWS
4160 DEFSYM (Qouter_window_id
, "outer-window-id");
4162 DEFSYM (Qparent_id
, "parent-id");
4164 DEFSYM (Qw32
, "w32");
4167 DEFSYM (Qvisible
, "visible");
4168 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4169 DEFSYM (Qbuffer_list
, "buffer-list");
4170 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4171 DEFSYM (Qdisplay_type
, "display-type");
4172 DEFSYM (Qbackground_mode
, "background-mode");
4173 DEFSYM (Qnoelisp
, "noelisp");
4174 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4175 DEFSYM (Qtty
, "tty");
4176 DEFSYM (Qtty_type
, "tty-type");
4178 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4180 DEFSYM (Qfullwidth
, "fullwidth");
4181 DEFSYM (Qfullheight
, "fullheight");
4182 DEFSYM (Qfullboth
, "fullboth");
4183 DEFSYM (Qmaximized
, "maximized");
4184 DEFSYM (Qx_resource_name
, "x-resource-name");
4185 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4187 DEFSYM (Qterminal
, "terminal");
4188 DEFSYM (Qterminal_live_p
, "terminal-live-p");
4191 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4197 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4199 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4200 if (frame_parms
[i
].variable
)
4202 *frame_parms
[i
].variable
= v
;
4203 staticpro (frame_parms
[i
].variable
);
4205 Fput (v
, Qx_frame_parameter
, make_number (i
));
4209 #ifdef HAVE_WINDOW_SYSTEM
4210 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4211 doc
: /* The name Emacs uses to look up X resources.
4212 `x-get-resource' uses this as the first component of the instance name
4213 when requesting resource values.
4214 Emacs initially sets `x-resource-name' to the name under which Emacs
4215 was invoked, or to the value specified with the `-name' or `-rn'
4216 switches, if present.
4218 It may be useful to bind this variable locally around a call
4219 to `x-get-resource'. See also the variable `x-resource-class'. */);
4220 Vx_resource_name
= Qnil
;
4222 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4223 doc
: /* The class Emacs uses to look up X resources.
4224 `x-get-resource' uses this as the first component of the instance class
4225 when requesting resource values.
4227 Emacs initially sets `x-resource-class' to "Emacs".
4229 Setting this variable permanently is not a reasonable thing to do,
4230 but binding this variable locally around a call to `x-get-resource'
4231 is a reasonable practice. See also the variable `x-resource-name'. */);
4232 Vx_resource_class
= build_string (EMACS_CLASS
);
4234 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4235 doc
: /* The lower limit of the frame opacity (alpha transparency).
4236 The value should range from 0 (invisible) to 100 (completely opaque).
4237 You can also use a floating number between 0.0 and 1.0.
4238 The default is 20. */);
4239 Vframe_alpha_lower_limit
= make_number (20);
4242 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4243 doc
: /* Alist of default values for frame creation.
4244 These may be set in your init file, like this:
4245 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4246 These override values given in window system configuration data,
4247 including X Windows' defaults database.
4248 For values specific to the first Emacs frame, see `initial-frame-alist'.
4249 For window-system specific values, see `window-system-default-frame-alist'.
4250 For values specific to the separate minibuffer frame, see
4251 `minibuffer-frame-alist'.
4252 The `menu-bar-lines' element of the list controls whether new frames
4253 have menu bars; `menu-bar-mode' works by altering this element.
4254 Setting this variable does not affect existing frames, only new ones. */);
4255 Vdefault_frame_alist
= Qnil
;
4257 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4258 doc
: /* Default position of scroll bars on this window-system. */);
4259 #ifdef HAVE_WINDOW_SYSTEM
4260 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
4261 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4263 Vdefault_frame_scroll_bars
= Qright
;
4265 Vdefault_frame_scroll_bars
= Qleft
;
4268 Vdefault_frame_scroll_bars
= Qnil
;
4271 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
4272 scroll_bar_adjust_thumb_portion_p
,
4273 doc
: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
4274 Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
4275 even if the end of the buffer is shown (i.e. overscrolling).
4276 Set to nil if you want the thumb to be at the bottom when the end of the buffer
4277 is shown. Also, the thumb fills the whole scroll bar when the entire buffer
4278 is visible. In this case you can not overscroll. */);
4279 scroll_bar_adjust_thumb_portion_p
= 1;
4281 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4282 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4284 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4285 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4286 `mouse-position' calls this function, passing its usual return value as
4287 argument, and returns whatever this function returns.
4288 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4289 which need to do mouse handling at the Lisp level. */);
4290 Vmouse_position_function
= Qnil
;
4292 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4293 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4294 If the value is an integer, highlighting is only shown after moving the
4295 mouse, while keyboard input turns off the highlight even when the mouse
4296 is over the clickable text. However, the mouse shape still indicates
4297 when the mouse is over clickable text. */);
4298 Vmouse_highlight
= Qt
;
4300 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4301 doc
: /* If non-nil, make pointer invisible while typing.
4302 The pointer becomes visible again when the mouse is moved. */);
4303 Vmake_pointer_invisible
= Qt
;
4305 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4306 doc
: /* Functions run before deleting a frame.
4307 The functions are run with one arg, the frame to be deleted.
4310 Note that functions in this list may be called just before the frame is
4311 actually deleted, or some time later (or even both when an earlier function
4312 in `delete-frame-functions' (indirectly) calls `delete-frame'
4314 Vdelete_frame_functions
= Qnil
;
4315 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
4317 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4318 doc
: /* Non-nil if Menu-Bar mode is enabled.
4319 See the command `menu-bar-mode' for a description of this minor mode.
4320 Setting this variable directly does not take effect;
4321 either customize it (see the info node `Easy Customization')
4322 or call the function `menu-bar-mode'. */);
4323 Vmenu_bar_mode
= Qt
;
4325 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4326 doc
: /* Non-nil if Tool-Bar mode is enabled.
4327 See the command `tool-bar-mode' for a description of this minor mode.
4328 Setting this variable directly does not take effect;
4329 either customize it (see the info node `Easy Customization')
4330 or call the function `tool-bar-mode'. */);
4331 #ifdef HAVE_WINDOW_SYSTEM
4332 Vtool_bar_mode
= Qt
;
4334 Vtool_bar_mode
= Qnil
;
4337 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4338 doc
: /* Minibufferless frames use this frame's minibuffer.
4340 Emacs cannot create minibufferless frames unless this is set to an
4341 appropriate surrogate.
4343 Emacs consults this variable only when creating minibufferless
4344 frames; once the frame is created, it sticks with its assigned
4345 minibuffer, no matter what this variable is set to. This means that
4346 this variable doesn't necessarily say anything meaningful about the
4347 current set of frames, or where the minibuffer is currently being
4350 This variable is local to the current terminal and cannot be buffer-local. */);
4352 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
4353 doc
: /* Non-nil if window system changes focus when you move the mouse.
4354 You should set this variable to tell Emacs how your window manager
4355 handles focus, since there is no way in general for Emacs to find out
4356 automatically. See also `mouse-autoselect-window'. */);
4357 focus_follows_mouse
= 0;
4359 staticpro (&Vframe_list
);
4362 defsubr (&Sframe_live_p
);
4363 defsubr (&Swindow_system
);
4364 defsubr (&Smake_terminal_frame
);
4365 defsubr (&Shandle_switch_frame
);
4366 defsubr (&Sselect_frame
);
4367 defsubr (&Sselected_frame
);
4368 defsubr (&Sframe_list
);
4369 defsubr (&Snext_frame
);
4370 defsubr (&Sprevious_frame
);
4371 defsubr (&Sdelete_frame
);
4372 defsubr (&Smouse_position
);
4373 defsubr (&Smouse_pixel_position
);
4374 defsubr (&Sset_mouse_position
);
4375 defsubr (&Sset_mouse_pixel_position
);
4377 defsubr (&Sframe_configuration
);
4378 defsubr (&Srestore_frame_configuration
);
4380 defsubr (&Smake_frame_visible
);
4381 defsubr (&Smake_frame_invisible
);
4382 defsubr (&Siconify_frame
);
4383 defsubr (&Sframe_visible_p
);
4384 defsubr (&Svisible_frame_list
);
4385 defsubr (&Sraise_frame
);
4386 defsubr (&Slower_frame
);
4387 defsubr (&Sredirect_frame_focus
);
4388 defsubr (&Sframe_focus
);
4389 defsubr (&Sframe_parameters
);
4390 defsubr (&Sframe_parameter
);
4391 defsubr (&Smodify_frame_parameters
);
4392 defsubr (&Sframe_char_height
);
4393 defsubr (&Sframe_char_width
);
4394 defsubr (&Sframe_pixel_height
);
4395 defsubr (&Sframe_pixel_width
);
4396 defsubr (&Stool_bar_pixel_width
);
4397 defsubr (&Sset_frame_height
);
4398 defsubr (&Sset_frame_width
);
4399 defsubr (&Sset_frame_size
);
4400 defsubr (&Sset_frame_position
);
4401 defsubr (&Sframe_pointer_visible_p
);
4403 #ifdef HAVE_WINDOW_SYSTEM
4404 defsubr (&Sx_get_resource
);
4405 defsubr (&Sx_parse_geometry
);