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 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
838 /* Mark previously displayed frame as now obscured. */
839 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
), 2);
840 SET_FRAME_VISIBLE (XFRAME (frame
), 1);
841 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
844 selected_frame
= frame
;
845 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
846 last_nonminibuf_frame
= XFRAME (selected_frame
);
848 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
850 /* We want to make sure that the next event generates a frame-switch
851 event to the appropriate frame. This seems kludgy to me, but
852 before you take it out, make sure that evaluating something like
853 (select-window (frame-root-window (new-frame))) doesn't end up
854 with your typing being interpreted in the new frame instead of
855 the one you're actually typing in. */
856 internal_last_event_frame
= Qnil
;
861 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
862 doc
: /* Select FRAME.
863 Subsequent editing commands apply to its selected window.
864 Optional argument NORECORD means to neither change the order of
865 recently selected windows nor the buffer list.
867 The selection of FRAME lasts until the next time the user does
868 something to select a different frame, or until the next time
869 this function is called. If you are using a window system, the
870 previously selected frame may be restored as the selected frame
871 when returning to the command loop, because it still may have
872 the window system's input focus. On a text terminal, the next
873 redisplay will display FRAME.
875 This function returns FRAME, or nil if FRAME has been deleted. */)
876 (Lisp_Object frame
, Lisp_Object norecord
)
878 return do_switch_frame (frame
, 1, 0, norecord
);
882 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
883 doc
: /* Handle a switch-frame event EVENT.
884 Switch-frame events are usually bound to this function.
885 A switch-frame event tells Emacs that the window manager has requested
886 that the user's events be directed to the frame mentioned in the event.
887 This function selects the selected window of the frame of EVENT.
889 If EVENT is frame object, handle it as if it were a switch-frame event
893 /* Preserve prefix arg that the command loop just cleared. */
894 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
895 Frun_hooks (1, &Qmouse_leave_buffer_hook
);
896 return do_switch_frame (event
, 0, 0, Qnil
);
899 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
900 doc
: /* Return the frame that is now selected. */)
903 return selected_frame
;
906 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
908 doc
: /* Return a list of all live frames. */)
912 frames
= Fcopy_sequence (Vframe_list
);
913 #ifdef HAVE_WINDOW_SYSTEM
914 if (FRAMEP (tip_frame
))
915 frames
= Fdelq (tip_frame
, frames
);
920 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
921 same tty (for tty frames) or among frames which uses FRAME's keyboard.
922 If MINIBUF is nil, do not consider minibuffer-only candidate.
923 If MINIBUF is `visible', do not consider an invisible candidate.
924 If MINIBUF is a window, consider only its own frame and candidate now
925 using that window as the minibuffer.
926 If MINIBUF is 0, consider candidate if it is visible or iconified.
927 Otherwise consider any candidate and return nil if CANDIDATE is not
931 candidate_frame (Lisp_Object candidate
, Lisp_Object frame
, Lisp_Object minibuf
)
933 struct frame
*c
= XFRAME (candidate
), *f
= XFRAME (frame
);
935 if ((!FRAME_TERMCAP_P (c
) && !FRAME_TERMCAP_P (f
)
936 && FRAME_KBOARD (c
) == FRAME_KBOARD (f
))
937 || (FRAME_TERMCAP_P (c
) && FRAME_TERMCAP_P (f
)
938 && FRAME_TTY (c
) == FRAME_TTY (f
)))
942 if (!FRAME_MINIBUF_ONLY_P (c
))
945 else if (EQ (minibuf
, Qvisible
))
947 if (FRAME_VISIBLE_P (c
))
950 else if (WINDOWP (minibuf
))
952 if (EQ (FRAME_MINIBUF_WINDOW (c
), minibuf
)
953 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), candidate
)
954 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
955 FRAME_FOCUS_FRAME (c
)))
958 else if (XFASTINT (minibuf
) == 0)
960 if (FRAME_VISIBLE_P (c
) || FRAME_ICONIFIED_P (c
))
969 /* Return the next frame in the frame list after FRAME. */
972 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
977 /* There must always be at least one frame in Vframe_list. */
978 eassert (CONSP (Vframe_list
));
981 FOR_EACH_FRAME (tail
, f
)
985 f
= candidate_frame (f
, frame
, minibuf
);
995 /* Return the previous frame in the frame list before FRAME. */
998 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1000 Lisp_Object f
, tail
, prev
= Qnil
;
1002 /* There must always be at least one frame in Vframe_list. */
1003 eassert (CONSP (Vframe_list
));
1005 FOR_EACH_FRAME (tail
, f
)
1007 if (EQ (frame
, f
) && !NILP (prev
))
1009 f
= candidate_frame (f
, frame
, minibuf
);
1014 /* We've scanned the entire list. */
1016 /* We went through the whole frame list without finding a single
1017 acceptable frame. Return the original frame. */
1020 /* There were no acceptable frames in the list before FRAME; otherwise,
1021 we would have returned directly from the loop. Since PREV is the last
1022 acceptable frame in the list, return it. */
1027 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1028 doc
: /* Return the next frame in the frame list after FRAME.
1029 It considers only frames on the same terminal as FRAME.
1030 By default, skip minibuffer-only frames.
1031 If omitted, FRAME defaults to the selected frame.
1032 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1033 If MINIFRAME is a window, include only its own frame
1034 and any frame now using that window as the minibuffer.
1035 If MINIFRAME is `visible', include all visible frames.
1036 If MINIFRAME is 0, include all visible and iconified frames.
1037 Otherwise, include all frames. */)
1038 (Lisp_Object frame
, Lisp_Object miniframe
)
1041 frame
= selected_frame
;
1042 CHECK_LIVE_FRAME (frame
);
1043 return next_frame (frame
, miniframe
);
1046 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1047 doc
: /* Return the previous frame in the frame list before FRAME.
1048 It considers only frames on the same terminal as FRAME.
1049 By default, skip minibuffer-only frames.
1050 If omitted, FRAME defaults to the selected frame.
1051 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1052 If MINIFRAME is a window, include only its own frame
1053 and any frame now using that window as the minibuffer.
1054 If MINIFRAME is `visible', include all visible frames.
1055 If MINIFRAME is 0, include all visible and iconified frames.
1056 Otherwise, include all frames. */)
1057 (Lisp_Object frame
, Lisp_Object miniframe
)
1060 frame
= selected_frame
;
1061 CHECK_LIVE_FRAME (frame
);
1062 return prev_frame (frame
, miniframe
);
1065 /* Return 1 if it is ok to delete frame F;
1066 0 if all frames aside from F are invisible.
1067 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1070 other_visible_frames (FRAME_PTR f
)
1072 Lisp_Object frames
, this;
1074 FOR_EACH_FRAME (frames
, this)
1076 if (f
== XFRAME (this))
1079 /* Verify that we can still talk to the frame's X window,
1080 and note any recent change in visibility. */
1081 #ifdef HAVE_WINDOW_SYSTEM
1082 if (FRAME_WINDOW_P (XFRAME (this)))
1083 x_sync (XFRAME (this));
1086 if (FRAME_VISIBLE_P (XFRAME (this))
1087 || FRAME_ICONIFIED_P (XFRAME (this))
1088 /* Allow deleting the terminal frame when at least one X
1090 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1096 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1097 unconditionally. x_connection_closed and delete_terminal use
1098 this. Any other value of FORCE implements the semantics
1099 described for Fdelete_frame. */
1101 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1103 struct frame
*f
= decode_any_frame (frame
);
1104 struct frame
*sf
= SELECTED_FRAME ();
1107 int minibuffer_selected
, is_tooltip_frame
;
1109 if (! FRAME_LIVE_P (f
))
1112 if (NILP (force
) && !other_visible_frames (f
))
1113 error ("Attempt to delete the sole visible or iconified frame");
1115 /* x_connection_closed must have set FORCE to `noelisp' in order
1116 to delete the last frame, if it is gone. */
1117 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1118 error ("Attempt to delete the only frame");
1120 XSETFRAME (frame
, f
);
1122 /* Does this frame have a minibuffer, and is it the surrogate
1123 minibuffer for any other frame? */
1124 if (FRAME_HAS_MINIBUF_P (f
))
1126 Lisp_Object frames
, this;
1128 FOR_EACH_FRAME (frames
, this)
1130 if (! EQ (this, frame
)
1132 WINDOW_FRAME (XWINDOW
1133 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1135 /* If we MUST delete this frame, delete the other first.
1136 But do this only if FORCE equals `noelisp'. */
1137 if (EQ (force
, Qnoelisp
))
1138 delete_frame (this, Qnoelisp
);
1140 error ("Attempt to delete a surrogate minibuffer frame");
1145 is_tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1147 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1148 frame is a tooltip. FORCE is set to `noelisp' when handling
1149 a disconnect from the terminal, so we don't dare call Lisp
1151 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1153 else if (EQ (force
, Qnoelisp
))
1155 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1159 #ifdef HAVE_X_WINDOWS
1160 /* Also, save clipboard to the clipboard manager. */
1161 x_clipboard_manager_save_frame (frame
);
1164 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1167 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1168 if (! FRAME_LIVE_P (f
))
1171 /* At this point, we are committed to deleting the frame.
1172 There is no more chance for errors to prevent it. */
1174 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1176 /* Don't let the frame remain selected. */
1179 Lisp_Object tail
, frame1
;
1181 /* Look for another visible frame on the same terminal. */
1182 frame1
= next_frame (frame
, Qvisible
);
1184 /* If there is none, find *some* other frame. */
1185 if (NILP (frame1
) || EQ (frame1
, frame
))
1187 FOR_EACH_FRAME (tail
, frame1
)
1189 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1191 /* Do not change a text terminal's top-frame. */
1192 struct frame
*f1
= XFRAME (frame1
);
1193 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1195 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1196 if (!EQ (top_frame
, frame
))
1203 #ifdef NS_IMPL_COCOA
1205 /* Under NS, there is no system mechanism for choosing a new
1206 window to get focus -- it is left to application code.
1207 So the portion of THIS application interfacing with NS
1208 needs to know about it. We call Fraise_frame, but the
1209 purpose is really to transfer focus. */
1210 Fraise_frame (frame1
);
1213 do_switch_frame (frame1
, 0, 1, Qnil
);
1214 sf
= SELECTED_FRAME ();
1217 /* Don't allow minibuf_window to remain on a deleted frame. */
1218 if (EQ (f
->minibuffer_window
, minibuf_window
))
1220 /* Use set_window_buffer instead of Fset_window_buffer (see
1221 discussion of bug#11984, bug#12025, bug#12026). */
1222 set_window_buffer (sf
->minibuffer_window
,
1223 XWINDOW (minibuf_window
)->contents
, 0, 0);
1224 minibuf_window
= sf
->minibuffer_window
;
1226 /* If the dying minibuffer window was selected,
1227 select the new one. */
1228 if (minibuffer_selected
)
1229 Fselect_window (minibuf_window
, Qnil
);
1232 /* Don't let echo_area_window to remain on a deleted frame. */
1233 if (EQ (f
->minibuffer_window
, echo_area_window
))
1234 echo_area_window
= sf
->minibuffer_window
;
1236 /* Clear any X selections for this frame. */
1237 #ifdef HAVE_X_WINDOWS
1239 x_clear_frame_selections (f
);
1243 This function must be called before the window tree of the
1244 frame is deleted because windows contain dynamically allocated
1248 #ifdef HAVE_WINDOW_SYSTEM
1249 /* Give chance to each font driver to free a frame specific data. */
1250 font_update_drivers (f
, Qnil
);
1253 /* Mark all the windows that used to be on FRAME as deleted, and then
1254 remove the reference to them. */
1255 delete_all_child_windows (f
->root_window
);
1256 fset_root_window (f
, Qnil
);
1258 Vframe_list
= Fdelq (frame
, Vframe_list
);
1259 SET_FRAME_VISIBLE (f
, 0);
1261 /* Allow the vector of menu bar contents to be freed in the next
1262 garbage collection. The frame object itself may not be garbage
1263 collected until much later, because recent_keys and other data
1264 structures can still refer to it. */
1265 fset_menu_bar_vector (f
, Qnil
);
1267 /* If FRAME's buffer lists contains killed
1268 buffers, this helps GC to reclaim them. */
1269 fset_buffer_list (f
, Qnil
);
1270 fset_buried_buffer_list (f
, Qnil
);
1272 free_font_driver_list (f
);
1274 xfree (f
->decode_mode_spec_buffer
);
1275 xfree (FRAME_INSERT_COST (f
));
1276 xfree (FRAME_DELETEN_COST (f
));
1277 xfree (FRAME_INSERTN_COST (f
));
1278 xfree (FRAME_DELETE_COST (f
));
1280 /* Since some events are handled at the interrupt level, we may get
1281 an event for f at any time; if we zero out the frame's terminal
1282 now, then we may trip up the event-handling code. Instead, we'll
1283 promise that the terminal of the frame must be valid until we
1284 have called the window-system-dependent frame destruction
1287 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1288 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1291 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1292 f
->output_data
.nothing
= 0;
1293 f
->terminal
= 0; /* Now the frame is dead. */
1295 /* If needed, delete the terminal that this frame was on.
1296 (This must be done after the frame is killed.) */
1297 terminal
->reference_count
--;
1299 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1301 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1302 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1303 terminal
->reference_count
= 1;
1304 #endif /* USE_GTK */
1305 if (terminal
->reference_count
== 0)
1308 XSETTERMINAL (tmp
, terminal
);
1311 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1314 kb
= terminal
->kboard
;
1317 /* If we've deleted the last_nonminibuf_frame, then try to find
1319 if (f
== last_nonminibuf_frame
)
1321 Lisp_Object frames
, this;
1323 last_nonminibuf_frame
= 0;
1325 FOR_EACH_FRAME (frames
, this)
1328 if (!FRAME_MINIBUF_ONLY_P (f
))
1330 last_nonminibuf_frame
= f
;
1336 /* If there's no other frame on the same kboard, get out of
1337 single-kboard state if we're in it for this kboard. */
1340 Lisp_Object frames
, this;
1341 /* Some frame we found on the same kboard, or nil if there are none. */
1342 Lisp_Object frame_on_same_kboard
= Qnil
;
1344 FOR_EACH_FRAME (frames
, this)
1345 if (kb
== FRAME_KBOARD (XFRAME (this)))
1346 frame_on_same_kboard
= this;
1348 if (NILP (frame_on_same_kboard
))
1349 not_single_kboard_state (kb
);
1353 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1354 find another one. Prefer minibuffer-only frames, but also notice
1355 frames with other windows. */
1356 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1358 Lisp_Object frames
, this;
1360 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1361 Lisp_Object frame_with_minibuf
= Qnil
;
1362 /* Some frame we found on the same kboard, or nil if there are none. */
1363 Lisp_Object frame_on_same_kboard
= Qnil
;
1365 FOR_EACH_FRAME (frames
, this)
1367 struct frame
*f1
= XFRAME (this);
1369 /* Consider only frames on the same kboard
1370 and only those with minibuffers. */
1371 if (kb
== FRAME_KBOARD (f1
)
1372 && FRAME_HAS_MINIBUF_P (f1
))
1374 frame_with_minibuf
= this;
1375 if (FRAME_MINIBUF_ONLY_P (f1
))
1379 if (kb
== FRAME_KBOARD (f1
))
1380 frame_on_same_kboard
= this;
1383 if (!NILP (frame_on_same_kboard
))
1385 /* We know that there must be some frame with a minibuffer out
1386 there. If this were not true, all of the frames present
1387 would have to be minibufferless, which implies that at some
1388 point their minibuffer frames must have been deleted, but
1389 that is prohibited at the top; you can't delete surrogate
1390 minibuffer frames. */
1391 if (NILP (frame_with_minibuf
))
1394 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
1397 /* No frames left on this kboard--say no minibuffer either. */
1398 kset_default_minibuffer_frame (kb
, Qnil
);
1401 /* Cause frame titles to update--necessary if we now have just one frame. */
1402 if (!is_tooltip_frame
)
1403 update_mode_lines
= 1;
1408 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1409 doc
: /* Delete FRAME, permanently eliminating it from use.
1410 FRAME defaults to the selected frame.
1412 A frame may not be deleted if its minibuffer is used by other frames.
1413 Normally, you may not delete a frame if all other frames are invisible,
1414 but if the second optional argument FORCE is non-nil, you may do so.
1416 This function runs `delete-frame-functions' before actually
1417 deleting the frame, unless the frame is a tooltip.
1418 The functions are run with one argument, the frame to be deleted. */)
1419 (Lisp_Object frame
, Lisp_Object force
)
1421 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1425 /* Return mouse position in character cell units. */
1427 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1428 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1429 The position is given in character cells, where (0, 0) is the
1430 upper-left corner of the frame, X is the horizontal offset, and Y is
1431 the vertical offset.
1432 If Emacs is running on a mouseless terminal or hasn't been programmed
1433 to read the mouse position, it returns the selected frame for FRAME
1434 and nil for X and Y.
1435 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1436 passing the normal return value to that function as an argument,
1437 and returns whatever that function returns. */)
1441 Lisp_Object lispy_dummy
;
1442 Lisp_Object x
, y
, retval
;
1443 struct gcpro gcpro1
;
1445 f
= SELECTED_FRAME ();
1448 /* It's okay for the hook to refrain from storing anything. */
1449 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1451 enum scroll_bar_part party_dummy
;
1453 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1454 &lispy_dummy
, &party_dummy
,
1463 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1467 XSETFRAME (lispy_dummy
, f
);
1468 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1470 if (!NILP (Vmouse_position_function
))
1471 retval
= call1 (Vmouse_position_function
, retval
);
1472 RETURN_UNGCPRO (retval
);
1475 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1476 Smouse_pixel_position
, 0, 0, 0,
1477 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1478 The position is given in pixel units, where (0, 0) is the
1479 upper-left corner of the frame, X is the horizontal offset, and Y is
1480 the vertical offset.
1481 If Emacs is running on a mouseless terminal or hasn't been programmed
1482 to read the mouse position, it returns the selected frame for FRAME
1483 and nil for X and Y. */)
1487 Lisp_Object lispy_dummy
;
1490 f
= SELECTED_FRAME ();
1493 /* It's okay for the hook to refrain from storing anything. */
1494 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1496 enum scroll_bar_part party_dummy
;
1498 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1499 &lispy_dummy
, &party_dummy
,
1504 XSETFRAME (lispy_dummy
, f
);
1505 return Fcons (lispy_dummy
, Fcons (x
, y
));
1508 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1509 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1510 Coordinates are relative to the frame, not a window,
1511 so the coordinates of the top left character in the frame
1512 may be nonzero due to left-hand scroll bars or the menu bar.
1514 The position is given in character cells, where (0, 0) is the
1515 upper-left corner of the frame, X is the horizontal offset, and Y is
1516 the vertical offset.
1518 This function is a no-op for an X frame that is not visible.
1519 If you have just created a frame, you must wait for it to become visible
1520 before calling this function on it, like this.
1521 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1522 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1524 CHECK_LIVE_FRAME (frame
);
1525 CHECK_TYPE_RANGED_INTEGER (int, x
);
1526 CHECK_TYPE_RANGED_INTEGER (int, y
);
1528 /* I think this should be done with a hook. */
1529 #ifdef HAVE_WINDOW_SYSTEM
1530 if (FRAME_WINDOW_P (XFRAME (frame
)))
1531 /* Warping the mouse will cause enternotify and focus events. */
1532 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1535 if (FRAME_MSDOS_P (XFRAME (frame
)))
1537 Fselect_frame (frame
, Qnil
);
1538 mouse_moveto (XINT (x
), XINT (y
));
1543 Fselect_frame (frame
, Qnil
);
1544 term_mouse_moveto (XINT (x
), XINT (y
));
1553 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1554 Sset_mouse_pixel_position
, 3, 3, 0,
1555 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1556 The position is given in pixels, where (0, 0) is the upper-left corner
1557 of the frame, X is the horizontal offset, and Y is the vertical offset.
1559 Note, this is a no-op for an X frame that is not visible.
1560 If you have just created a frame, you must wait for it to become visible
1561 before calling this function on it, like this.
1562 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1563 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1565 CHECK_LIVE_FRAME (frame
);
1566 CHECK_TYPE_RANGED_INTEGER (int, x
);
1567 CHECK_TYPE_RANGED_INTEGER (int, y
);
1569 /* I think this should be done with a hook. */
1570 #ifdef HAVE_WINDOW_SYSTEM
1571 if (FRAME_WINDOW_P (XFRAME (frame
)))
1572 /* Warping the mouse will cause enternotify and focus events. */
1573 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1576 if (FRAME_MSDOS_P (XFRAME (frame
)))
1578 Fselect_frame (frame
, Qnil
);
1579 mouse_moveto (XINT (x
), XINT (y
));
1584 Fselect_frame (frame
, Qnil
);
1585 term_mouse_moveto (XINT (x
), XINT (y
));
1594 static void make_frame_visible_1 (Lisp_Object
);
1596 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1598 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1599 If omitted, FRAME defaults to the currently selected frame. */)
1602 struct frame
*f
= decode_live_frame (frame
);
1604 /* I think this should be done with a hook. */
1605 #ifdef HAVE_WINDOW_SYSTEM
1606 if (FRAME_WINDOW_P (f
))
1607 x_make_frame_visible (f
);
1610 make_frame_visible_1 (f
->root_window
);
1612 /* Make menu bar update for the Buffers and Frames menus. */
1613 windows_or_buffers_changed
++;
1615 XSETFRAME (frame
, f
);
1619 /* Update the display_time slot of the buffers shown in WINDOW
1620 and all its descendants. */
1623 make_frame_visible_1 (Lisp_Object window
)
1627 for (; !NILP (window
); window
= w
->next
)
1629 w
= XWINDOW (window
);
1630 if (WINDOWP (w
->contents
))
1631 make_frame_visible_1 (w
->contents
);
1633 bset_display_time (XBUFFER (w
->contents
), Fcurrent_time ());
1637 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1639 doc
: /* Make the frame FRAME invisible.
1640 If omitted, FRAME defaults to the currently selected frame.
1641 On graphical displays, invisible frames are not updated and are
1642 usually not displayed at all, even in a window system's \"taskbar\".
1644 Normally you may not make FRAME invisible if all other frames are invisible,
1645 but if the second optional argument FORCE is non-nil, you may do so.
1647 This function has no effect on text terminal frames. Such frames are
1648 always considered visible, whether or not they are currently being
1649 displayed in the terminal. */)
1650 (Lisp_Object frame
, Lisp_Object force
)
1652 struct frame
*f
= decode_live_frame (frame
);
1654 if (NILP (force
) && !other_visible_frames (f
))
1655 error ("Attempt to make invisible the sole visible or iconified frame");
1657 /* Don't allow minibuf_window to remain on a deleted frame. */
1658 if (EQ (f
->minibuffer_window
, minibuf_window
))
1660 struct frame
*sf
= XFRAME (selected_frame
);
1661 /* Use set_window_buffer instead of Fset_window_buffer (see
1662 discussion of bug#11984, bug#12025, bug#12026). */
1663 set_window_buffer (sf
->minibuffer_window
,
1664 XWINDOW (minibuf_window
)->contents
, 0, 0);
1665 minibuf_window
= sf
->minibuffer_window
;
1668 /* I think this should be done with a hook. */
1669 #ifdef HAVE_WINDOW_SYSTEM
1670 if (FRAME_WINDOW_P (f
))
1671 x_make_frame_invisible (f
);
1674 /* Make menu bar update for the Buffers and Frames menus. */
1675 windows_or_buffers_changed
++;
1680 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1682 doc
: /* Make the frame FRAME into an icon.
1683 If omitted, FRAME defaults to the currently selected frame. */)
1686 struct frame
*f
= decode_live_frame (frame
);
1688 /* Don't allow minibuf_window to remain on an iconified frame. */
1689 if (EQ (f
->minibuffer_window
, minibuf_window
))
1691 struct frame
*sf
= XFRAME (selected_frame
);
1692 /* Use set_window_buffer instead of Fset_window_buffer (see
1693 discussion of bug#11984, bug#12025, bug#12026). */
1694 set_window_buffer (sf
->minibuffer_window
,
1695 XWINDOW (minibuf_window
)->contents
, 0, 0);
1696 minibuf_window
= sf
->minibuffer_window
;
1699 /* I think this should be done with a hook. */
1700 #ifdef HAVE_WINDOW_SYSTEM
1701 if (FRAME_WINDOW_P (f
))
1702 x_iconify_frame (f
);
1705 /* Make menu bar update for the Buffers and Frames menus. */
1706 windows_or_buffers_changed
++;
1711 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1713 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1714 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1715 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1716 On graphical displays, invisible frames are not updated and are
1717 usually not displayed at all, even in a window system's \"taskbar\".
1719 If FRAME is a text terminal frame, this always returns t.
1720 Such frames are always considered visible, whether or not they are
1721 currently being displayed on the terminal. */)
1724 CHECK_LIVE_FRAME (frame
);
1726 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1728 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1733 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1735 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1738 Lisp_Object tail
, frame
, value
= Qnil
;
1740 FOR_EACH_FRAME (tail
, frame
)
1741 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1742 value
= Fcons (frame
, value
);
1748 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1749 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1750 If FRAME is invisible or iconified, make it visible.
1751 If you don't specify a frame, the selected frame is used.
1752 If Emacs is displaying on an ordinary terminal or some other device which
1753 doesn't support multiple overlapping frames, this function selects FRAME. */)
1756 struct frame
*f
= decode_live_frame (frame
);
1758 XSETFRAME (frame
, f
);
1760 if (FRAME_TERMCAP_P (f
))
1761 /* On a text terminal select FRAME. */
1762 Fselect_frame (frame
, Qnil
);
1764 /* Do like the documentation says. */
1765 Fmake_frame_visible (frame
);
1767 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1768 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
1773 /* Should we have a corresponding function called Flower_Power? */
1774 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1775 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1776 If you don't specify a frame, the selected frame is used.
1777 If Emacs is displaying on an ordinary terminal or some other device which
1778 doesn't support multiple overlapping frames, this function does nothing. */)
1781 struct frame
*f
= decode_live_frame (frame
);
1783 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1784 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
1790 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1792 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1793 In other words, switch-frame events caused by events in FRAME will
1794 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1795 FOCUS-FRAME after reading an event typed at FRAME.
1797 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
1798 frame again receives its own keystrokes.
1800 Focus redirection is useful for temporarily redirecting keystrokes to
1801 a surrogate minibuffer frame when a frame doesn't have its own
1804 A frame's focus redirection can be changed by `select-frame'. If frame
1805 FOO is selected, and then a different frame BAR is selected, any
1806 frames redirecting their focus to FOO are shifted to redirect their
1807 focus to BAR. This allows focus redirection to work properly when the
1808 user switches from one frame to another using `select-window'.
1810 This means that a frame whose focus is redirected to itself is treated
1811 differently from a frame whose focus is redirected to nil; the former
1812 is affected by `select-frame', while the latter is not.
1814 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1815 (Lisp_Object frame
, Lisp_Object focus_frame
)
1817 /* Note that we don't check for a live frame here. It's reasonable
1818 to redirect the focus of a frame you're about to delete, if you
1819 know what other frame should receive those keystrokes. */
1820 struct frame
*f
= decode_any_frame (frame
);
1822 if (! NILP (focus_frame
))
1823 CHECK_LIVE_FRAME (focus_frame
);
1825 fset_focus_frame (f
, focus_frame
);
1827 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
1828 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
1834 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 0, 1, 0,
1835 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1836 If FRAME is omitted or nil, the selected frame is used.
1837 Return nil if FRAME's focus is not redirected.
1838 See `redirect-frame-focus'. */)
1841 return FRAME_FOCUS_FRAME (decode_live_frame (frame
));
1846 /* Return the value of frame parameter PROP in frame FRAME. */
1848 #ifdef HAVE_WINDOW_SYSTEM
1849 #if !HAVE_NS && !defined(WINDOWSNT)
1853 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
1855 register Lisp_Object tem
;
1857 tem
= Fassq (prop
, frame
->param_alist
);
1864 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
1867 frames_discard_buffer (Lisp_Object buffer
)
1869 Lisp_Object frame
, tail
;
1871 FOR_EACH_FRAME (tail
, frame
)
1874 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
1875 fset_buried_buffer_list
1876 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
1880 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1881 If the alist already has an element for PROP, we change it. */
1884 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
1886 register Lisp_Object tem
;
1888 tem
= Fassq (prop
, *alistptr
);
1890 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1896 frame_name_fnn_p (char *str
, ptrdiff_t len
)
1898 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
1901 while ('0' <= *p
&& *p
<= '9')
1909 /* Set the name of the terminal frame. Also used by MSDOS frames.
1910 Modeled after x_set_name which is used for WINDOW frames. */
1913 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
1915 f
->explicit_name
= ! NILP (name
);
1917 /* If NAME is nil, set the name to F<num>. */
1920 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
1922 /* Check for no change needed in this very common case
1923 before we do any consing. */
1924 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
1927 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
1931 CHECK_STRING (name
);
1933 /* Don't change the name if it's already NAME. */
1934 if (! NILP (Fstring_equal (name
, f
->name
)))
1937 /* Don't allow the user to set the frame name to F<num>, so it
1938 doesn't clash with the names we generate for terminal frames. */
1939 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
1940 error ("Frame names of the form F<num> are usurped by Emacs");
1943 fset_name (f
, name
);
1944 update_mode_lines
= 1;
1948 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
1950 register Lisp_Object old_alist_elt
;
1952 /* The buffer-list parameters are stored in a special place and not
1953 in the alist. All buffers must be live. */
1954 if (EQ (prop
, Qbuffer_list
))
1956 Lisp_Object list
= Qnil
;
1957 for (; CONSP (val
); val
= XCDR (val
))
1958 if (!NILP (Fbuffer_live_p (XCAR (val
))))
1959 list
= Fcons (XCAR (val
), list
);
1960 fset_buffer_list (f
, Fnreverse (list
));
1963 if (EQ (prop
, Qburied_buffer_list
))
1965 Lisp_Object list
= Qnil
;
1966 for (; CONSP (val
); val
= XCDR (val
))
1967 if (!NILP (Fbuffer_live_p (XCAR (val
))))
1968 list
= Fcons (XCAR (val
), list
);
1969 fset_buried_buffer_list (f
, Fnreverse (list
));
1973 /* If PROP is a symbol which is supposed to have frame-local values,
1974 and it is set up based on this frame, switch to the global
1975 binding. That way, we can create or alter the frame-local binding
1976 without messing up the symbol's status. */
1979 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
1981 switch (sym
->redirect
)
1983 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
1984 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
1985 case SYMBOL_LOCALIZED
:
1986 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
1987 if (blv
->frame_local
&& blv_found (blv
) && XFRAME (blv
->where
) == f
)
1988 swap_in_global_binding (sym
);
1991 default: emacs_abort ();
1995 /* The tty color needed to be set before the frame's parameter
1996 alist was updated with the new value. This is not true any more,
1997 but we still do this test early on. */
1998 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
1999 && f
== FRAME_TTY (f
)->previous_frame
)
2000 /* Force redisplay of this tty. */
2001 FRAME_TTY (f
)->previous_frame
= NULL
;
2003 /* Update the frame parameter alist. */
2004 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2005 if (EQ (old_alist_elt
, Qnil
))
2006 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2008 Fsetcdr (old_alist_elt
, val
);
2010 /* Update some other special parameters in their special places
2011 in addition to the alist. */
2013 if (EQ (prop
, Qbuffer_predicate
))
2014 fset_buffer_predicate (f
, val
);
2016 if (! FRAME_WINDOW_P (f
))
2018 if (EQ (prop
, Qmenu_bar_lines
))
2019 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2020 else if (EQ (prop
, Qname
))
2021 set_term_frame_name (f
, val
);
2024 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2026 if (! MINI_WINDOW_P (XWINDOW (val
)))
2027 error ("Surrogate minibuffer windows must be minibuffer windows");
2029 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2030 && !EQ (val
, f
->minibuffer_window
))
2031 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2033 /* Install the chosen minibuffer window, with proper buffer. */
2034 fset_minibuffer_window (f
, val
);
2038 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2039 doc
: /* Return the parameters-alist of frame FRAME.
2040 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2041 The meaningful PARMs depend on the kind of frame.
2042 If FRAME is omitted or nil, return information on the currently selected frame. */)
2046 struct frame
*f
= decode_any_frame (frame
);
2048 struct gcpro gcpro1
;
2050 if (!FRAME_LIVE_P (f
))
2053 alist
= Fcopy_alist (f
->param_alist
);
2056 if (!FRAME_WINDOW_P (f
))
2058 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2059 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2062 /* If the frame's parameter alist says the colors are
2063 unspecified and reversed, take the frame's background pixel
2064 for foreground and vice versa. */
2065 elt
= Fassq (Qforeground_color
, alist
);
2066 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2068 if (strncmp (SSDATA (XCDR (elt
)),
2070 SCHARS (XCDR (elt
))) == 0)
2071 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2072 else if (strncmp (SSDATA (XCDR (elt
)),
2074 SCHARS (XCDR (elt
))) == 0)
2075 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2078 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2079 elt
= Fassq (Qbackground_color
, alist
);
2080 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2082 if (strncmp (SSDATA (XCDR (elt
)),
2084 SCHARS (XCDR (elt
))) == 0)
2085 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2086 else if (strncmp (SSDATA (XCDR (elt
)),
2088 SCHARS (XCDR (elt
))) == 0)
2089 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2092 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2093 store_in_alist (&alist
, intern ("font"),
2094 build_string (FRAME_MSDOS_P (f
)
2096 : FRAME_W32_P (f
) ? "w32term"
2099 store_in_alist (&alist
, Qname
, f
->name
);
2100 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2101 store_in_alist (&alist
, Qheight
, make_number (height
));
2102 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2103 store_in_alist (&alist
, Qwidth
, make_number (width
));
2104 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2105 store_in_alist (&alist
, Qminibuffer
,
2106 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2107 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2108 : FRAME_MINIBUF_WINDOW (f
)));
2109 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2110 store_in_alist (&alist
, Qbuffer_list
, f
->buffer_list
);
2111 store_in_alist (&alist
, Qburied_buffer_list
, f
->buried_buffer_list
);
2113 /* I think this should be done with a hook. */
2114 #ifdef HAVE_WINDOW_SYSTEM
2115 if (FRAME_WINDOW_P (f
))
2116 x_report_frame_params (f
, &alist
);
2120 /* This ought to be correct in f->param_alist for an X frame. */
2122 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2123 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2131 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2132 doc
: /* Return FRAME's value for parameter PARAMETER.
2133 If FRAME is nil, describe the currently selected frame. */)
2134 (Lisp_Object frame
, Lisp_Object parameter
)
2136 struct frame
*f
= decode_any_frame (frame
);
2137 Lisp_Object value
= Qnil
;
2139 CHECK_SYMBOL (parameter
);
2141 XSETFRAME (frame
, f
);
2143 if (FRAME_LIVE_P (f
))
2145 /* Avoid consing in frequent cases. */
2146 if (EQ (parameter
, Qname
))
2148 #ifdef HAVE_X_WINDOWS
2149 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2150 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2151 #endif /* HAVE_X_WINDOWS */
2152 else if (EQ (parameter
, Qbackground_color
)
2153 || EQ (parameter
, Qforeground_color
))
2155 value
= Fassq (parameter
, f
->param_alist
);
2158 value
= XCDR (value
);
2159 /* Fframe_parameters puts the actual fg/bg color names,
2160 even if f->param_alist says otherwise. This is
2161 important when param_alist's notion of colors is
2162 "unspecified". We need to do the same here. */
2163 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2165 const char *color_name
;
2168 if (EQ (parameter
, Qbackground_color
))
2170 color_name
= SSDATA (value
);
2171 csz
= SCHARS (value
);
2172 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2173 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2174 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2175 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2177 else if (EQ (parameter
, Qforeground_color
))
2179 color_name
= SSDATA (value
);
2180 csz
= SCHARS (value
);
2181 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2182 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2183 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2184 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2189 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2191 else if (EQ (parameter
, Qdisplay_type
)
2192 || EQ (parameter
, Qbackground_mode
))
2193 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2195 /* FIXME: Avoid this code path at all (as well as code duplication)
2196 by sharing more code with Fframe_parameters. */
2197 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2204 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2205 Smodify_frame_parameters
, 2, 2, 0,
2206 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2207 If FRAME is nil, it defaults to the selected frame.
2208 ALIST is an alist of parameters to change and their new values.
2209 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2210 The meaningful PARMs depend on the kind of frame.
2211 Undefined PARMs are ignored, but stored in the frame's parameter list
2212 so that `frame-parameters' will return them.
2214 The value of frame parameter FOO can also be accessed
2215 as a frame-local binding for the variable FOO, if you have
2216 enabled such bindings for that variable with `make-variable-frame-local'.
2217 Note that this functionality is obsolete as of Emacs 22.2, and its
2218 use is not recommended. Explicitly check for a frame-parameter instead. */)
2219 (Lisp_Object frame
, Lisp_Object alist
)
2221 struct frame
*f
= decode_live_frame (frame
);
2222 register Lisp_Object tail
, prop
, val
;
2224 /* I think this should be done with a hook. */
2225 #ifdef HAVE_WINDOW_SYSTEM
2226 if (FRAME_WINDOW_P (f
))
2227 x_set_frame_parameters (f
, alist
);
2231 if (FRAME_MSDOS_P (f
))
2232 IT_set_frame_parameters (f
, alist
);
2237 EMACS_INT length
= XFASTINT (Flength (alist
));
2240 Lisp_Object
*values
;
2242 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2243 values
= parms
+ length
;
2245 /* Extract parm names and values into those vectors. */
2248 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2253 parms
[i
] = Fcar (elt
);
2254 values
[i
] = Fcdr (elt
);
2258 /* Now process them in reverse of specified order. */
2263 store_frame_param (f
, prop
, val
);
2265 if (EQ (prop
, Qforeground_color
)
2266 || EQ (prop
, Qbackground_color
))
2267 update_face_from_frame_parameter (f
, prop
, val
);
2275 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2277 doc
: /* Height in pixels of a line in the font in frame FRAME.
2278 If FRAME is omitted or nil, the selected frame is used.
2279 For a terminal frame, the value is always 1. */)
2282 #ifdef HAVE_WINDOW_SYSTEM
2283 struct frame
*f
= decode_any_frame (frame
);
2285 if (FRAME_WINDOW_P (f
))
2286 return make_number (FRAME_LINE_HEIGHT (f
));
2289 return make_number (1);
2293 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2295 doc
: /* Width in pixels of characters in the font in frame FRAME.
2296 If FRAME is omitted or nil, the selected frame is used.
2297 On a graphical screen, the width is the standard width of the default font.
2298 For a terminal screen, the value is always 1. */)
2301 #ifdef HAVE_WINDOW_SYSTEM
2302 struct frame
*f
= decode_any_frame (frame
);
2304 if (FRAME_WINDOW_P (f
))
2305 return make_number (FRAME_COLUMN_WIDTH (f
));
2308 return make_number (1);
2311 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2312 Sframe_pixel_height
, 0, 1, 0,
2313 doc
: /* Return a FRAME's height in pixels.
2314 If FRAME is omitted or nil, the selected frame is used. The exact value
2315 of the result depends on the window-system and toolkit in use:
2317 In the Gtk+ version of Emacs, it includes only any window (including
2318 the minibuffer or echo area), mode line, and header line. It does not
2319 include the tool bar or menu bar.
2321 With other graphical versions, it also includes the tool bar and the
2324 For a text terminal, it includes the menu bar. In this case, the
2325 result is really in characters rather than pixels (i.e., is identical
2326 to `frame-height'). */)
2329 struct frame
*f
= decode_any_frame (frame
);
2331 #ifdef HAVE_WINDOW_SYSTEM
2332 if (FRAME_WINDOW_P (f
))
2333 return make_number (x_pixel_height (f
));
2336 return make_number (FRAME_LINES (f
));
2339 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2340 Sframe_pixel_width
, 0, 1, 0,
2341 doc
: /* Return FRAME's width in pixels.
2342 For a terminal frame, the result really gives the width in characters.
2343 If FRAME is omitted or nil, the selected frame is used. */)
2346 struct frame
*f
= decode_any_frame (frame
);
2348 #ifdef HAVE_WINDOW_SYSTEM
2349 if (FRAME_WINDOW_P (f
))
2350 return make_number (x_pixel_width (f
));
2353 return make_number (FRAME_COLS (f
));
2356 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2357 Stool_bar_pixel_width
, 0, 1, 0,
2358 doc
: /* Return width in pixels of FRAME's tool bar.
2359 The result is greater than zero only when the tool bar is on the left
2360 or right side of FRAME. If FRAME is omitted or nil, the selected frame
2364 #ifdef FRAME_TOOLBAR_WIDTH
2365 struct frame
*f
= decode_any_frame (frame
);
2367 if (FRAME_WINDOW_P (f
))
2368 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2370 return make_number (0);
2373 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2374 doc
: /* Specify that the frame FRAME has LINES lines.
2375 Optional third arg non-nil means that redisplay should use LINES lines
2376 but that the idea of the actual height of the frame should not be changed. */)
2377 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2379 register struct frame
*f
= decode_live_frame (frame
);
2381 CHECK_TYPE_RANGED_INTEGER (int, lines
);
2383 /* I think this should be done with a hook. */
2384 #ifdef HAVE_WINDOW_SYSTEM
2385 if (FRAME_WINDOW_P (f
))
2387 if (XINT (lines
) != FRAME_LINES (f
))
2388 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2389 do_pending_window_change (0);
2393 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2397 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2398 doc
: /* Specify that the frame FRAME has COLS columns.
2399 Optional third arg non-nil means that redisplay should use COLS columns
2400 but that the idea of the actual width of the frame should not be changed. */)
2401 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2403 register struct frame
*f
= decode_live_frame (frame
);
2405 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2407 /* I think this should be done with a hook. */
2408 #ifdef HAVE_WINDOW_SYSTEM
2409 if (FRAME_WINDOW_P (f
))
2411 if (XINT (cols
) != FRAME_COLS (f
))
2412 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2413 do_pending_window_change (0);
2417 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2421 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2422 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2423 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2425 register struct frame
*f
;
2427 CHECK_LIVE_FRAME (frame
);
2428 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2429 CHECK_TYPE_RANGED_INTEGER (int, rows
);
2432 /* I think this should be done with a hook. */
2433 #ifdef HAVE_WINDOW_SYSTEM
2434 if (FRAME_WINDOW_P (f
))
2436 if (XINT (rows
) != FRAME_LINES (f
)
2437 || XINT (cols
) != FRAME_COLS (f
)
2438 || f
->new_text_lines
|| f
->new_text_cols
)
2439 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2440 do_pending_window_change (0);
2444 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2449 DEFUN ("set-frame-position", Fset_frame_position
,
2450 Sset_frame_position
, 3, 3, 0,
2451 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2452 This is actually the position of the upper left corner of the frame.
2453 Negative values for XOFFSET or YOFFSET are interpreted relative to
2454 the rightmost or bottommost possible position (that stays within the screen). */)
2455 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2457 register struct frame
*f
;
2459 CHECK_LIVE_FRAME (frame
);
2460 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2461 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2464 /* I think this should be done with a hook. */
2465 #ifdef HAVE_WINDOW_SYSTEM
2466 if (FRAME_WINDOW_P (f
))
2467 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2474 /***********************************************************************
2476 ***********************************************************************/
2478 /* Connect the frame-parameter names for X frames
2479 to the ways of passing the parameter values to the window system.
2481 The name of a parameter, as a Lisp symbol,
2482 has an `x-frame-parameter' property which is an integer in Lisp
2483 that is an index in this table. */
2485 struct frame_parm_table
{
2487 Lisp_Object
*variable
;
2490 static const struct frame_parm_table frame_parms
[] =
2492 {"auto-raise", &Qauto_raise
},
2493 {"auto-lower", &Qauto_lower
},
2494 {"background-color", 0},
2495 {"border-color", &Qborder_color
},
2496 {"border-width", &Qborder_width
},
2497 {"cursor-color", &Qcursor_color
},
2498 {"cursor-type", &Qcursor_type
},
2500 {"foreground-color", 0},
2501 {"icon-name", &Qicon_name
},
2502 {"icon-type", &Qicon_type
},
2503 {"internal-border-width", &Qinternal_border_width
},
2504 {"menu-bar-lines", &Qmenu_bar_lines
},
2505 {"mouse-color", &Qmouse_color
},
2507 {"scroll-bar-width", &Qscroll_bar_width
},
2509 {"unsplittable", &Qunsplittable
},
2510 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2511 {"visibility", &Qvisibility
},
2512 {"tool-bar-lines", &Qtool_bar_lines
},
2513 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2514 {"scroll-bar-background", &Qscroll_bar_background
},
2515 {"screen-gamma", &Qscreen_gamma
},
2516 {"line-spacing", &Qline_spacing
},
2517 {"left-fringe", &Qleft_fringe
},
2518 {"right-fringe", &Qright_fringe
},
2519 {"wait-for-wm", &Qwait_for_wm
},
2520 {"fullscreen", &Qfullscreen
},
2521 {"font-backend", &Qfont_backend
},
2523 {"sticky", &Qsticky
},
2524 {"tool-bar-position", &Qtool_bar_position
},
2529 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2530 wanted positions of the WM window (not Emacs window).
2531 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2532 window (FRAME_X_WINDOW).
2536 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2538 int newwidth
= FRAME_COLS (f
);
2539 int newheight
= FRAME_LINES (f
);
2540 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2542 *top_pos
= f
->top_pos
;
2543 *left_pos
= f
->left_pos
;
2545 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2549 ph
= x_display_pixel_height (dpyinfo
);
2550 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2551 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2552 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2556 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2560 pw
= x_display_pixel_width (dpyinfo
);
2561 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2562 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2563 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2568 *height
= newheight
;
2571 #endif /* HAVE_NTGUI */
2573 #ifdef HAVE_WINDOW_SYSTEM
2575 /* Change the parameters of frame F as specified by ALIST.
2576 If a parameter is not specially recognized, do nothing special;
2577 otherwise call the `x_set_...' function for that parameter.
2578 Except for certain geometry properties, always call store_frame_param
2579 to store the new value in the parameter alist. */
2582 x_set_frame_parameters (FRAME_PTR f
, Lisp_Object alist
)
2586 /* If both of these parameters are present, it's more efficient to
2587 set them both at once. So we wait until we've looked at the
2588 entire list before we set them. */
2592 Lisp_Object left
, top
;
2594 /* Same with these. */
2595 Lisp_Object icon_left
, icon_top
;
2597 /* Record in these vectors all the parms specified. */
2599 Lisp_Object
*values
;
2601 int left_no_change
= 0, top_no_change
= 0;
2602 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2603 int size_changed
= 0;
2604 struct gcpro gcpro1
, gcpro2
;
2607 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2610 parms
= alloca (i
* sizeof *parms
);
2611 values
= alloca (i
* sizeof *values
);
2613 /* Extract parm names and values into those vectors. */
2616 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2621 parms
[i
] = Fcar (elt
);
2622 values
[i
] = Fcdr (elt
);
2625 /* TAIL and ALIST are not used again below here. */
2626 alist
= tail
= Qnil
;
2628 GCPRO2 (*parms
, *values
);
2632 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2633 because their values appear in VALUES and strings are not valid. */
2634 top
= left
= Qunbound
;
2635 icon_left
= icon_top
= Qunbound
;
2637 /* Provide default values for HEIGHT and WIDTH. */
2638 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2639 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2641 /* Process foreground_color and background_color before anything else.
2642 They are independent of other properties, but other properties (e.g.,
2643 cursor_color) are dependent upon them. */
2644 /* Process default font as well, since fringe widths depends on it. */
2645 for (p
= 0; p
< i
; p
++)
2647 Lisp_Object prop
, val
;
2651 if (EQ (prop
, Qforeground_color
)
2652 || EQ (prop
, Qbackground_color
)
2653 || EQ (prop
, Qfont
))
2655 register Lisp_Object param_index
, old_value
;
2657 old_value
= get_frame_param (f
, prop
);
2658 if (NILP (Fequal (val
, old_value
)))
2660 store_frame_param (f
, prop
, val
);
2662 param_index
= Fget (prop
, Qx_frame_parameter
);
2663 if (NATNUMP (param_index
)
2664 && (XFASTINT (param_index
)
2665 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2666 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2667 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2672 /* Now process them in reverse of specified order. */
2675 Lisp_Object prop
, val
;
2680 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2683 width
= XFASTINT (val
);
2685 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2688 height
= XFASTINT (val
);
2690 else if (EQ (prop
, Qtop
))
2692 else if (EQ (prop
, Qleft
))
2694 else if (EQ (prop
, Qicon_top
))
2696 else if (EQ (prop
, Qicon_left
))
2698 else if (EQ (prop
, Qforeground_color
)
2699 || EQ (prop
, Qbackground_color
)
2700 || EQ (prop
, Qfont
))
2701 /* Processed above. */
2705 register Lisp_Object param_index
, old_value
;
2707 old_value
= get_frame_param (f
, prop
);
2709 store_frame_param (f
, prop
, val
);
2711 param_index
= Fget (prop
, Qx_frame_parameter
);
2712 if (NATNUMP (param_index
)
2713 && (XFASTINT (param_index
)
2714 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2715 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2716 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2720 /* Don't die if just one of these was set. */
2721 if (EQ (left
, Qunbound
))
2724 if (f
->left_pos
< 0)
2725 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2727 XSETINT (left
, f
->left_pos
);
2729 if (EQ (top
, Qunbound
))
2733 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2735 XSETINT (top
, f
->top_pos
);
2738 /* If one of the icon positions was not set, preserve or default it. */
2739 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
2741 icon_left_no_change
= 1;
2742 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2743 if (NILP (icon_left
))
2744 XSETINT (icon_left
, 0);
2746 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
2748 icon_top_no_change
= 1;
2749 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2750 if (NILP (icon_top
))
2751 XSETINT (icon_top
, 0);
2754 /* Don't set these parameters unless they've been explicitly
2755 specified. The window might be mapped or resized while we're in
2756 this function, and we don't want to override that unless the lisp
2757 code has asked for it.
2759 Don't set these parameters unless they actually differ from the
2760 window's current parameters; the window may not actually exist
2765 check_frame_size (f
, &height
, &width
);
2767 XSETFRAME (frame
, f
);
2770 && (width
!= FRAME_COLS (f
)
2771 || height
!= FRAME_LINES (f
)
2772 || f
->new_text_lines
|| f
->new_text_cols
))
2773 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2775 if ((!NILP (left
) || !NILP (top
))
2776 && ! (left_no_change
&& top_no_change
)
2777 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2778 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2783 /* Record the signs. */
2784 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2785 if (EQ (left
, Qminus
))
2786 f
->size_hint_flags
|= XNegative
;
2787 else if (TYPE_RANGED_INTEGERP (int, left
))
2789 leftpos
= XINT (left
);
2791 f
->size_hint_flags
|= XNegative
;
2793 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2794 && CONSP (XCDR (left
))
2795 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
2797 leftpos
= - XINT (XCAR (XCDR (left
)));
2798 f
->size_hint_flags
|= XNegative
;
2800 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2801 && CONSP (XCDR (left
))
2802 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
2804 leftpos
= XINT (XCAR (XCDR (left
)));
2807 if (EQ (top
, Qminus
))
2808 f
->size_hint_flags
|= YNegative
;
2809 else if (TYPE_RANGED_INTEGERP (int, top
))
2811 toppos
= XINT (top
);
2813 f
->size_hint_flags
|= YNegative
;
2815 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2816 && CONSP (XCDR (top
))
2817 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
2819 toppos
= - XINT (XCAR (XCDR (top
)));
2820 f
->size_hint_flags
|= YNegative
;
2822 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2823 && CONSP (XCDR (top
))
2824 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
2826 toppos
= XINT (XCAR (XCDR (top
)));
2830 /* Store the numeric value of the position. */
2831 f
->top_pos
= toppos
;
2832 f
->left_pos
= leftpos
;
2834 f
->win_gravity
= NorthWestGravity
;
2836 /* Actually set that position, and convert to absolute. */
2837 x_set_offset (f
, leftpos
, toppos
, -1);
2840 if ((!NILP (icon_left
) || !NILP (icon_top
))
2841 && ! (icon_left_no_change
&& icon_top_no_change
))
2842 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2849 /* Insert a description of internally-recorded parameters of frame X
2850 into the parameter alist *ALISTPTR that is to be given to the user.
2851 Only parameters that are specific to the X window system
2852 and whose values are not correctly recorded in the frame's
2853 param_alist need to be considered here. */
2856 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
2860 char buf
[INT_BUFSIZE_BOUND (w
)];
2862 /* Represent negative positions (off the top or left screen edge)
2863 in a way that Fmodify_frame_parameters will understand correctly. */
2864 XSETINT (tem
, f
->left_pos
);
2865 if (f
->left_pos
>= 0)
2866 store_in_alist (alistptr
, Qleft
, tem
);
2868 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2870 XSETINT (tem
, f
->top_pos
);
2871 if (f
->top_pos
>= 0)
2872 store_in_alist (alistptr
, Qtop
, tem
);
2874 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2876 store_in_alist (alistptr
, Qborder_width
,
2877 make_number (f
->border_width
));
2878 store_in_alist (alistptr
, Qinternal_border_width
,
2879 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
2880 store_in_alist (alistptr
, Qleft_fringe
,
2881 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
2882 store_in_alist (alistptr
, Qright_fringe
,
2883 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
2884 store_in_alist (alistptr
, Qscroll_bar_width
,
2885 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2887 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
2888 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
2889 /* nil means "use default width"
2890 for non-toolkit scroll bar.
2891 ruler-mode.el depends on this. */
2893 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
2894 MS-Windows it returns a value whose type is HANDLE, which is
2895 actually a pointer. Explicit casting avoids compiler
2897 w
= (uintptr_t) FRAME_X_WINDOW (f
);
2898 store_in_alist (alistptr
, Qwindow_id
,
2899 make_formatted_string (buf
, "%"pMu
, w
));
2900 #ifdef HAVE_X_WINDOWS
2901 #ifdef USE_X_TOOLKIT
2902 /* Tooltip frame may not have this widget. */
2903 if (FRAME_X_OUTPUT (f
)->widget
)
2905 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
2906 store_in_alist (alistptr
, Qouter_window_id
,
2907 make_formatted_string (buf
, "%"pMu
, w
));
2909 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
2910 store_in_alist (alistptr
, Qvisibility
,
2911 (FRAME_VISIBLE_P (f
) ? Qt
2912 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
2913 store_in_alist (alistptr
, Qdisplay
,
2914 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
2916 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
2919 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
2920 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
2921 store_in_alist (alistptr
, Qparent_id
, tem
);
2922 store_in_alist (alistptr
, Qtool_bar_position
, f
->tool_bar_position
);
2926 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
2927 the previous value of that parameter, NEW_VALUE is the new value. */
2930 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
2932 if (NILP (new_value
))
2933 f
->want_fullscreen
= FULLSCREEN_NONE
;
2934 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
2935 f
->want_fullscreen
= FULLSCREEN_BOTH
;
2936 else if (EQ (new_value
, Qfullwidth
))
2937 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
2938 else if (EQ (new_value
, Qfullheight
))
2939 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
2940 else if (EQ (new_value
, Qmaximized
))
2941 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
2943 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
2944 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
2948 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
2949 the previous value of that parameter, NEW_VALUE is the new value. */
2952 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
2954 if (NILP (new_value
))
2955 f
->extra_line_spacing
= 0;
2956 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
2957 f
->extra_line_spacing
= XFASTINT (new_value
);
2959 signal_error ("Invalid line-spacing", new_value
);
2960 if (FRAME_VISIBLE_P (f
))
2965 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
2966 the previous value of that parameter, NEW_VALUE is the new value. */
2969 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
2971 Lisp_Object bgcolor
;
2973 if (NILP (new_value
))
2975 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
2976 /* The value 0.4545 is the normal viewing gamma. */
2977 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
2979 signal_error ("Invalid screen-gamma", new_value
);
2981 /* Apply the new gamma value to the frame background. */
2982 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
2983 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
2985 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
2986 if (NATNUMP (parm_index
)
2987 && (XFASTINT (parm_index
)
2988 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2989 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
2990 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
2994 Fclear_face_cache (Qnil
);
2999 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3001 Lisp_Object font_object
;
3003 #ifdef HAVE_X_WINDOWS
3004 Lisp_Object font_param
= arg
;
3007 /* Set the frame parameter back to the old value because we may
3008 fail to use ARG as the new parameter value. */
3009 store_frame_param (f
, Qfont
, oldval
);
3011 /* ARG is a fontset name, a font name, a cons of fontset name and a
3012 font object, or a font object. In the last case, this function
3016 fontset
= fs_query_fontset (arg
, 0);
3019 font_object
= font_open_by_name (f
, arg
);
3020 if (NILP (font_object
))
3021 error ("Font `%s' is not defined", SSDATA (arg
));
3022 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3024 else if (fontset
> 0)
3026 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
3027 if (NILP (font_object
))
3028 error ("Font `%s' is not defined", SDATA (arg
));
3029 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3032 error ("The default fontset can't be used for a frame font");
3034 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3036 /* This is the case that the ASCII font of F's fontset XCAR
3037 (arg) is changed to the font XCDR (arg) by
3038 `set-fontset-font'. */
3039 fontset
= fs_query_fontset (XCAR (arg
), 0);
3041 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3042 font_object
= XCDR (arg
);
3043 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3044 #ifdef HAVE_X_WINDOWS
3045 font_param
= Ffont_get (font_object
, QCname
);
3048 else if (FONT_OBJECT_P (arg
))
3051 #ifdef HAVE_X_WINDOWS
3052 font_param
= Ffont_get (font_object
, QCname
);
3054 /* This is to store the XLFD font name in the frame parameter for
3055 backward compatibility. We should store the font-object
3056 itself in the future. */
3057 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3058 fontset
= FRAME_FONTSET (f
);
3059 /* Check if we can use the current fontset. If not, set FONTSET
3060 to -1 to generate a new fontset from FONT-OBJECT. */
3063 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3064 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3067 signal_error ("Invalid font name", ascii_font
);
3069 if (! font_match_p (spec
, font_object
))
3074 signal_error ("Invalid font", arg
);
3076 if (! NILP (Fequal (font_object
, oldval
)))
3079 x_new_font (f
, font_object
, fontset
);
3080 store_frame_param (f
, Qfont
, arg
);
3081 #ifdef HAVE_X_WINDOWS
3082 store_frame_param (f
, Qfont_param
, font_param
);
3084 /* Recalculate toolbar height. */
3085 f
->n_tool_bar_rows
= 0;
3086 /* Ensure we redraw it. */
3087 clear_current_matrices (f
);
3089 recompute_basic_faces (f
);
3091 do_pending_window_change (0);
3093 /* We used to call face-set-after-frame-default here, but it leads to
3094 recursive calls (since that function can set the `default' face's
3095 font which in turns changes the frame's `font' parameter).
3096 Also I don't know what this call is meant to do, but it seems the
3097 wrong way to do it anyway (it does a lot more work than what seems
3098 reasonable in response to a change to `font'). */
3103 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3105 if (! NILP (new_value
)
3106 && !CONSP (new_value
))
3110 CHECK_STRING (new_value
);
3111 p0
= p1
= SSDATA (new_value
);
3115 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
3117 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3123 while ((c
= *++p1
) && c_isspace (c
));
3127 new_value
= Fnreverse (new_value
);
3130 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3134 free_all_realized_faces (Qnil
);
3136 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3137 if (NILP (new_value
))
3139 if (NILP (old_value
))
3140 error ("No font backend available");
3141 font_update_drivers (f
, old_value
);
3142 error ("None of specified font backends are available");
3144 store_frame_param (f
, Qfont_backend
, new_value
);
3150 XSETFRAME (frame
, f
);
3151 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3152 ++face_change_count
;
3153 ++windows_or_buffers_changed
;
3159 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3161 compute_fringe_widths (f
, 1);
3162 #ifdef HAVE_X_WINDOWS
3163 /* Must adjust this so window managers report correct number of columns. */
3164 if (FRAME_X_WINDOW (f
) != 0)
3165 x_wm_set_size_hint (f
, 0, 0);
3170 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3172 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3174 if (XINT (arg
) == f
->border_width
)
3177 if (FRAME_X_WINDOW (f
) != 0)
3178 error ("Cannot change the border width of a frame");
3180 f
->border_width
= XINT (arg
);
3184 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3186 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3188 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3189 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3190 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3191 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3193 #ifdef USE_X_TOOLKIT
3194 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3195 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3198 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3201 if (FRAME_X_WINDOW (f
) != 0)
3203 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3204 SET_FRAME_GARBAGED (f
);
3205 do_pending_window_change (0);
3208 SET_FRAME_GARBAGED (f
);
3212 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3215 XSETFRAME (frame
, f
);
3218 Fmake_frame_invisible (frame
, Qt
);
3219 else if (EQ (value
, Qicon
))
3220 Ficonify_frame (frame
);
3222 Fmake_frame_visible (frame
);
3226 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3228 f
->auto_raise
= !EQ (Qnil
, arg
);
3232 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3234 f
->auto_lower
= !EQ (Qnil
, arg
);
3238 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3240 f
->no_split
= !NILP (arg
);
3244 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3246 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3247 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3248 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3249 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3251 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3253 ? vertical_scroll_bar_none
3255 ? vertical_scroll_bar_left
3257 ? vertical_scroll_bar_right
3258 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3259 ? vertical_scroll_bar_left
3260 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3261 ? vertical_scroll_bar_right
3262 : vertical_scroll_bar_none
);
3264 /* We set this parameter before creating the X window for the
3265 frame, so we can get the geometry right from the start.
3266 However, if the window hasn't been created yet, we shouldn't
3267 call x_set_window_size. */
3268 if (FRAME_X_WINDOW (f
))
3269 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3270 do_pending_window_change (0);
3275 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3277 int wid
= FRAME_COLUMN_WIDTH (f
);
3281 x_set_scroll_bar_default_width (f
);
3283 if (FRAME_X_WINDOW (f
))
3284 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3285 do_pending_window_change (0);
3287 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3288 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3290 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3291 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3293 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3294 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3295 if (FRAME_X_WINDOW (f
))
3296 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3297 do_pending_window_change (0);
3300 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3301 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3302 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3307 /* Return non-nil if frame F wants a bitmap icon. */
3310 x_icon_type (FRAME_PTR f
)
3314 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3322 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3329 for (i
= 0; i
< 2; i
++)
3342 else if (FLOATP (item
))
3344 alpha
= XFLOAT_DATA (item
);
3345 if (! (0 <= alpha
&& alpha
<= 1.0))
3346 args_out_of_range (make_float (0.0), make_float (1.0));
3348 else if (INTEGERP (item
))
3350 EMACS_INT ialpha
= XINT (item
);
3351 if (! (0 <= ialpha
&& alpha
<= 100))
3352 args_out_of_range (make_number (0), make_number (100));
3353 alpha
= ialpha
/ 100.0;
3356 wrong_type_argument (Qnumberp
, item
);
3360 for (i
= 0; i
< 2; i
++)
3361 f
->alpha
[i
] = newval
[i
];
3363 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3365 x_set_frame_alpha (f
);
3373 /* Subroutines of creating an X frame. */
3375 /* Make sure that Vx_resource_name is set to a reasonable value.
3376 Fix it up, or set it to `emacs' if it is too hopeless. */
3379 validate_x_resource_name (void)
3382 /* Number of valid characters in the resource name. */
3383 ptrdiff_t good_count
= 0;
3384 /* Number of invalid characters in the resource name. */
3385 ptrdiff_t bad_count
= 0;
3389 if (!STRINGP (Vx_resource_class
))
3390 Vx_resource_class
= build_string (EMACS_CLASS
);
3392 if (STRINGP (Vx_resource_name
))
3394 unsigned char *p
= SDATA (Vx_resource_name
);
3396 len
= SBYTES (Vx_resource_name
);
3398 /* Only letters, digits, - and _ are valid in resource names.
3399 Count the valid characters and count the invalid ones. */
3400 for (i
= 0; i
< len
; i
++)
3403 if (! ((c
>= 'a' && c
<= 'z')
3404 || (c
>= 'A' && c
<= 'Z')
3405 || (c
>= '0' && c
<= '9')
3406 || c
== '-' || c
== '_'))
3413 /* Not a string => completely invalid. */
3414 bad_count
= 5, good_count
= 0;
3416 /* If name is valid already, return. */
3420 /* If name is entirely invalid, or nearly so, or is so implausibly
3421 large that alloca might not work, use `emacs'. */
3422 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
3424 Vx_resource_name
= build_string ("emacs");
3428 /* Name is partly valid. Copy it and replace the invalid characters
3429 with underscores. */
3431 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3433 for (i
= 0; i
< len
; i
++)
3435 int c
= SREF (new, i
);
3436 if (! ((c
>= 'a' && c
<= 'z')
3437 || (c
>= 'A' && c
<= 'Z')
3438 || (c
>= '0' && c
<= '9')
3439 || c
== '-' || c
== '_'))
3445 extern char *x_get_string_resource (XrmDatabase
, const char *, const char *);
3446 extern Display_Info
*check_x_display_info (Lisp_Object
);
3449 /* Get specified attribute from resource database RDB.
3450 See Fx_get_resource below for other parameters. */
3453 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3455 register char *value
;
3459 CHECK_STRING (attribute
);
3460 CHECK_STRING (class);
3462 if (!NILP (component
))
3463 CHECK_STRING (component
);
3464 if (!NILP (subclass
))
3465 CHECK_STRING (subclass
);
3466 if (NILP (component
) != NILP (subclass
))
3467 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3469 validate_x_resource_name ();
3471 /* Allocate space for the components, the dots which separate them,
3472 and the final '\0'. Make them big enough for the worst case. */
3473 name_key
= alloca (SBYTES (Vx_resource_name
)
3474 + (STRINGP (component
)
3475 ? SBYTES (component
) : 0)
3476 + SBYTES (attribute
)
3479 class_key
= alloca (SBYTES (Vx_resource_class
)
3481 + (STRINGP (subclass
)
3482 ? SBYTES (subclass
) : 0)
3485 /* Start with emacs.FRAMENAME for the name (the specific one)
3486 and with `Emacs' for the class key (the general one). */
3487 strcpy (name_key
, SSDATA (Vx_resource_name
));
3488 strcpy (class_key
, SSDATA (Vx_resource_class
));
3490 strcat (class_key
, ".");
3491 strcat (class_key
, SSDATA (class));
3493 if (!NILP (component
))
3495 strcat (class_key
, ".");
3496 strcat (class_key
, SSDATA (subclass
));
3498 strcat (name_key
, ".");
3499 strcat (name_key
, SSDATA (component
));
3502 strcat (name_key
, ".");
3503 strcat (name_key
, SSDATA (attribute
));
3505 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3507 if (value
!= (char *) 0 && *value
)
3508 return build_string (value
);
3514 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3515 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3516 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3517 class, where INSTANCE is the name under which Emacs was invoked, or
3518 the name specified by the `-name' or `-rn' command-line arguments.
3520 The optional arguments COMPONENT and SUBCLASS add to the key and the
3521 class, respectively. You must specify both of them or neither.
3522 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3523 and the class is `Emacs.CLASS.SUBCLASS'. */)
3524 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
,
3525 Lisp_Object subclass
)
3527 check_window_system (NULL
);
3529 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3530 attribute
, class, component
, subclass
);
3533 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3536 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
,
3537 Lisp_Object
class, Lisp_Object component
,
3538 Lisp_Object subclass
)
3540 return xrdb_get_resource (dpyinfo
->xrdb
,
3541 attribute
, class, component
, subclass
);
3544 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3545 /* Used when C code wants a resource value. */
3546 /* Called from oldXMenu/Create.c. */
3548 x_get_resource_string (const char *attribute
, const char *class)
3551 struct frame
*sf
= SELECTED_FRAME ();
3552 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
3555 /* Allocate space for the components, the dots which separate them,
3556 and the final '\0'. */
3557 char *name_key
= SAFE_ALLOCA (invocation_namelen
+ strlen (attribute
) + 2);
3558 char *class_key
= alloca ((sizeof (EMACS_CLASS
) - 1) + strlen (class) + 2);
3560 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
3561 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3563 result
= x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3564 name_key
, class_key
);
3570 /* Return the value of parameter PARAM.
3572 First search ALIST, then Vdefault_frame_alist, then the X defaults
3573 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3575 Convert the resource to the type specified by desired_type.
3577 If no default is specified, return Qunbound. If you call
3578 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3579 and don't let it get stored in any Lisp-visible variables! */
3582 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3583 const char *attribute
, const char *class, enum resource_types type
)
3585 register Lisp_Object tem
;
3587 tem
= Fassq (param
, alist
);
3591 /* If we find this parm in ALIST, clear it out
3592 so that it won't be "left over" at the end. */
3594 XSETCAR (tem
, Qnil
);
3595 /* In case the parameter appears more than once in the alist,
3597 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3598 if (CONSP (XCAR (tail
))
3599 && EQ (XCAR (XCAR (tail
)), param
))
3600 XSETCAR (XCAR (tail
), Qnil
);
3603 tem
= Fassq (param
, Vdefault_frame_alist
);
3605 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3606 look in the X resources. */
3609 if (attribute
&& dpyinfo
)
3611 tem
= display_x_get_resource (dpyinfo
,
3612 build_string (attribute
),
3613 build_string (class),
3621 case RES_TYPE_NUMBER
:
3622 return make_number (atoi (SSDATA (tem
)));
3624 case RES_TYPE_BOOLEAN_NUMBER
:
3625 if (!strcmp (SSDATA (tem
), "on")
3626 || !strcmp (SSDATA (tem
), "true"))
3627 return make_number (1);
3628 return make_number (atoi (SSDATA (tem
)));
3631 case RES_TYPE_FLOAT
:
3632 return make_float (atof (SSDATA (tem
)));
3634 case RES_TYPE_BOOLEAN
:
3635 tem
= Fdowncase (tem
);
3636 if (!strcmp (SSDATA (tem
), "on")
3638 || !strcmp (SSDATA (tem
), "yes")
3640 || !strcmp (SSDATA (tem
), "true"))
3645 case RES_TYPE_STRING
:
3648 case RES_TYPE_SYMBOL
:
3649 /* As a special case, we map the values `true' and `on'
3650 to Qt, and `false' and `off' to Qnil. */
3653 lower
= Fdowncase (tem
);
3654 if (!strcmp (SSDATA (lower
), "on")
3656 || !strcmp (SSDATA (lower
), "yes")
3658 || !strcmp (SSDATA (lower
), "true"))
3660 else if (!strcmp (SSDATA (lower
), "off")
3662 || !strcmp (SSDATA (lower
), "no")
3664 || !strcmp (SSDATA (lower
), "false"))
3667 return Fintern (tem
, Qnil
);
3681 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3682 const char *attribute
, const char *class,
3683 enum resource_types type
)
3685 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3686 alist
, param
, attribute
, class, type
);
3689 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3692 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3694 const char *attribute
, const char *class,
3695 enum resource_types type
)
3699 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3700 attribute
, class, type
);
3701 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3702 store_frame_param (f
, param
, value
);
3708 /* Record in frame F the specified or default value according to ALIST
3709 of the parameter named PROP (a Lisp symbol).
3710 If no value is specified for PROP, look for an X default for XPROP
3711 on the frame named NAME.
3712 If that is not found either, use the value DEFLT. */
3715 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
3716 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
3717 enum resource_types type
)
3721 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3722 if (EQ (tem
, Qunbound
))
3724 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3729 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
3732 * XParseGeometry parses strings of the form
3733 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
3734 * width, height, xoffset, and yoffset are unsigned integers.
3735 * Example: "=80x24+300-49"
3736 * The equal sign is optional.
3737 * It returns a bitmask that indicates which of the four values
3738 * were actually found in the string. For each value found,
3739 * the corresponding argument is updated; for each value
3740 * not found, the corresponding argument is left unchanged.
3744 XParseGeometry (char *string
,
3746 unsigned int *width
, unsigned int *height
)
3750 unsigned long int tempWidth
, tempHeight
;
3751 long int tempX
, tempY
;
3752 char *nextCharacter
;
3754 if (string
== NULL
|| *string
== '\0')
3757 string
++; /* ignore possible '=' at beg of geometry spec */
3760 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
3762 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
3763 if (strind
== nextCharacter
)
3765 strind
= nextCharacter
;
3769 if (*strind
== 'x' || *strind
== 'X')
3772 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
3773 if (strind
== nextCharacter
)
3775 strind
= nextCharacter
;
3776 mask
|= HeightValue
;
3779 if (*strind
== '+' || *strind
== '-')
3783 tempX
= strtol (strind
, &nextCharacter
, 10);
3784 if (strind
== nextCharacter
)
3786 strind
= nextCharacter
;
3788 if (*strind
== '+' || *strind
== '-')
3792 tempY
= strtol (strind
, &nextCharacter
, 10);
3793 if (strind
== nextCharacter
)
3795 strind
= nextCharacter
;
3800 /* If strind isn't at the end of the string then it's an invalid
3801 geometry specification. */
3803 if (*strind
!= '\0')
3807 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
3809 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
3810 if (mask
& WidthValue
)
3811 *width
= min (tempWidth
, UINT_MAX
);
3812 if (mask
& HeightValue
)
3813 *height
= min (tempHeight
, UINT_MAX
);
3817 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
3820 /* NS used to define x-parse-geometry in ns-win.el, but that confused
3821 make-docfile: the documentation string in ns-win.el was used for
3822 x-parse-geometry even in non-NS builds.
3824 With two definitions of x-parse-geometry in this file, various
3825 things still get confused (eg M-x apropos documentation), so that
3826 it is best if the two definitions just share the same doc-string.
3828 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3829 doc
: /* Parse a display geometry string STRING.
3830 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3831 The properties returned may include `top', `left', `height', and `width'.
3832 For X, the value of `left' or `top' may be an integer,
3833 or a list (+ N) meaning N pixels relative to top/left corner,
3834 or a list (- N) meaning -N pixels relative to bottom/right corner.
3835 On Nextstep, this just calls `ns-parse-geometry'. */)
3836 (Lisp_Object string
)
3839 unsigned int width
, height
;
3842 CHECK_STRING (string
);
3845 if (strchr (SSDATA (string
), ' ') != NULL
)
3846 return call1 (Qns_parse_geometry
, string
);
3848 geometry
= XParseGeometry (SSDATA (string
),
3849 &x
, &y
, &width
, &height
);
3851 if (geometry
& XValue
)
3853 Lisp_Object element
;
3855 if (x
>= 0 && (geometry
& XNegative
))
3856 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3857 else if (x
< 0 && ! (geometry
& XNegative
))
3858 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3860 element
= Fcons (Qleft
, make_number (x
));
3861 result
= Fcons (element
, result
);
3864 if (geometry
& YValue
)
3866 Lisp_Object element
;
3868 if (y
>= 0 && (geometry
& YNegative
))
3869 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3870 else if (y
< 0 && ! (geometry
& YNegative
))
3871 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3873 element
= Fcons (Qtop
, make_number (y
));
3874 result
= Fcons (element
, result
);
3877 if (geometry
& WidthValue
)
3878 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3879 if (geometry
& HeightValue
)
3880 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3886 /* Calculate the desired size and position of frame F.
3887 Return the flags saying which aspects were specified.
3889 Also set the win_gravity and size_hint_flags of F.
3891 Adjust height for toolbar if TOOLBAR_P is 1.
3893 This function does not make the coordinates positive. */
3895 #define DEFAULT_ROWS 35
3896 #define DEFAULT_COLS 80
3899 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, int toolbar_p
)
3901 register Lisp_Object tem0
, tem1
, tem2
;
3902 long window_prompting
= 0;
3903 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3905 /* Default values if we fall through.
3906 Actually, if that happens we should get
3907 window manager prompting. */
3908 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3909 FRAME_LINES (f
) = DEFAULT_ROWS
;
3910 /* Window managers expect that if program-specified
3911 positions are not (0,0), they're intentional, not defaults. */
3915 /* Ensure that old new_text_cols and new_text_lines will not override the
3917 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3918 f
->new_text_cols
= f
->new_text_lines
= 0;
3920 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3921 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3922 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3923 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3925 if (!EQ (tem0
, Qunbound
))
3927 CHECK_NUMBER (tem0
);
3928 if (! (0 <= XINT (tem0
) && XINT (tem0
) <= INT_MAX
))
3929 xsignal1 (Qargs_out_of_range
, tem0
);
3930 FRAME_LINES (f
) = XINT (tem0
);
3932 if (!EQ (tem1
, Qunbound
))
3934 CHECK_NUMBER (tem1
);
3935 if (! (0 <= XINT (tem1
) && XINT (tem1
) <= INT_MAX
))
3936 xsignal1 (Qargs_out_of_range
, tem1
);
3937 SET_FRAME_COLS (f
, XINT (tem1
));
3939 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
3940 window_prompting
|= USSize
;
3942 window_prompting
|= PSize
;
3945 f
->scroll_bar_actual_width
3946 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
3948 /* This used to be done _before_ calling x_figure_window_size, but
3949 since the height is reset here, this was really a no-op. I
3950 assume that moving it here does what Gerd intended (although he
3951 no longer can remember what that was... ++KFS, 2003-03-25. */
3953 /* Add the tool-bar height to the initial frame height so that the
3954 user gets a text display area of the size he specified with -g or
3955 via .Xdefaults. Later changes of the tool-bar height don't
3956 change the frame size. This is done so that users can create
3957 tall Emacs frames without having to guess how tall the tool-bar
3959 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
3961 int margin
, relief
, bar_height
;
3963 relief
= (tool_bar_button_relief
>= 0
3964 ? tool_bar_button_relief
3965 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
3967 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
3968 margin
= XFASTINT (Vtool_bar_button_margin
);
3969 else if (CONSP (Vtool_bar_button_margin
)
3970 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
3971 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
3975 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
3976 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
3979 compute_fringe_widths (f
, 0);
3981 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
3982 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
3984 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
3985 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
3986 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
3987 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3989 if (EQ (tem0
, Qminus
))
3992 window_prompting
|= YNegative
;
3994 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
3995 && CONSP (XCDR (tem0
))
3996 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem0
)), INT_MAX
))
3998 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
3999 window_prompting
|= YNegative
;
4001 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4002 && CONSP (XCDR (tem0
))
4003 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0
))))
4005 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4007 else if (EQ (tem0
, Qunbound
))
4011 CHECK_TYPE_RANGED_INTEGER (int, tem0
);
4012 f
->top_pos
= XINT (tem0
);
4014 window_prompting
|= YNegative
;
4017 if (EQ (tem1
, Qminus
))
4020 window_prompting
|= XNegative
;
4022 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4023 && CONSP (XCDR (tem1
))
4024 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem1
)), INT_MAX
))
4026 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4027 window_prompting
|= XNegative
;
4029 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4030 && CONSP (XCDR (tem1
))
4031 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1
))))
4033 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4035 else if (EQ (tem1
, Qunbound
))
4039 CHECK_TYPE_RANGED_INTEGER (int, tem1
);
4040 f
->left_pos
= XINT (tem1
);
4041 if (f
->left_pos
< 0)
4042 window_prompting
|= XNegative
;
4045 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4046 window_prompting
|= USPosition
;
4048 window_prompting
|= PPosition
;
4051 if (window_prompting
& XNegative
)
4053 if (window_prompting
& YNegative
)
4054 f
->win_gravity
= SouthEastGravity
;
4056 f
->win_gravity
= NorthEastGravity
;
4060 if (window_prompting
& YNegative
)
4061 f
->win_gravity
= SouthWestGravity
;
4063 f
->win_gravity
= NorthWestGravity
;
4066 f
->size_hint_flags
= window_prompting
;
4068 return window_prompting
;
4073 #endif /* HAVE_WINDOW_SYSTEM */
4076 frame_make_pointer_invisible (void)
4078 if (! NILP (Vmake_pointer_invisible
))
4081 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4084 f
= SELECTED_FRAME ();
4085 if (f
&& !f
->pointer_invisible
4086 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4089 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4090 f
->pointer_invisible
= 1;
4096 frame_make_pointer_visible (void)
4098 /* We don't check Vmake_pointer_invisible here in case the
4099 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4102 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4105 f
= SELECTED_FRAME ();
4106 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4107 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4109 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4110 f
->pointer_invisible
= 0;
4114 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4115 Sframe_pointer_visible_p
, 0, 1, 0,
4116 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4117 Otherwise it returns nil. FRAME omitted or nil means the
4118 selected frame. This is useful when `make-pointer-invisible' is set. */)
4121 return decode_any_frame (frame
)->pointer_invisible
? Qnil
: Qt
;
4125 /***********************************************************************
4127 ***********************************************************************/
4130 syms_of_frame (void)
4132 DEFSYM (Qframep
, "framep");
4133 DEFSYM (Qframe_live_p
, "frame-live-p");
4134 DEFSYM (Qexplicit_name
, "explicit-name");
4135 DEFSYM (Qheight
, "height");
4136 DEFSYM (Qicon
, "icon");
4137 DEFSYM (Qminibuffer
, "minibuffer");
4138 DEFSYM (Qmodeline
, "modeline");
4139 DEFSYM (Qonly
, "only");
4140 DEFSYM (Qnone
, "none");
4141 DEFSYM (Qwidth
, "width");
4142 DEFSYM (Qgeometry
, "geometry");
4143 DEFSYM (Qicon_left
, "icon-left");
4144 DEFSYM (Qicon_top
, "icon-top");
4145 DEFSYM (Qtooltip
, "tooltip");
4146 DEFSYM (Qleft
, "left");
4147 DEFSYM (Qright
, "right");
4148 DEFSYM (Quser_position
, "user-position");
4149 DEFSYM (Quser_size
, "user-size");
4150 DEFSYM (Qwindow_id
, "window-id");
4151 #ifdef HAVE_X_WINDOWS
4152 DEFSYM (Qouter_window_id
, "outer-window-id");
4154 DEFSYM (Qparent_id
, "parent-id");
4156 DEFSYM (Qw32
, "w32");
4159 DEFSYM (Qvisible
, "visible");
4160 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4161 DEFSYM (Qbuffer_list
, "buffer-list");
4162 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4163 DEFSYM (Qdisplay_type
, "display-type");
4164 DEFSYM (Qbackground_mode
, "background-mode");
4165 DEFSYM (Qnoelisp
, "noelisp");
4166 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4167 DEFSYM (Qtty
, "tty");
4168 DEFSYM (Qtty_type
, "tty-type");
4170 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4172 DEFSYM (Qfullwidth
, "fullwidth");
4173 DEFSYM (Qfullheight
, "fullheight");
4174 DEFSYM (Qfullboth
, "fullboth");
4175 DEFSYM (Qmaximized
, "maximized");
4176 DEFSYM (Qx_resource_name
, "x-resource-name");
4177 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4179 DEFSYM (Qterminal
, "terminal");
4180 DEFSYM (Qterminal_live_p
, "terminal-live-p");
4183 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4189 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4191 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4192 if (frame_parms
[i
].variable
)
4194 *frame_parms
[i
].variable
= v
;
4195 staticpro (frame_parms
[i
].variable
);
4197 Fput (v
, Qx_frame_parameter
, make_number (i
));
4201 #ifdef HAVE_WINDOW_SYSTEM
4202 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4203 doc
: /* The name Emacs uses to look up X resources.
4204 `x-get-resource' uses this as the first component of the instance name
4205 when requesting resource values.
4206 Emacs initially sets `x-resource-name' to the name under which Emacs
4207 was invoked, or to the value specified with the `-name' or `-rn'
4208 switches, if present.
4210 It may be useful to bind this variable locally around a call
4211 to `x-get-resource'. See also the variable `x-resource-class'. */);
4212 Vx_resource_name
= Qnil
;
4214 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4215 doc
: /* The class Emacs uses to look up X resources.
4216 `x-get-resource' uses this as the first component of the instance class
4217 when requesting resource values.
4219 Emacs initially sets `x-resource-class' to "Emacs".
4221 Setting this variable permanently is not a reasonable thing to do,
4222 but binding this variable locally around a call to `x-get-resource'
4223 is a reasonable practice. See also the variable `x-resource-name'. */);
4224 Vx_resource_class
= build_string (EMACS_CLASS
);
4226 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4227 doc
: /* The lower limit of the frame opacity (alpha transparency).
4228 The value should range from 0 (invisible) to 100 (completely opaque).
4229 You can also use a floating number between 0.0 and 1.0.
4230 The default is 20. */);
4231 Vframe_alpha_lower_limit
= make_number (20);
4234 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4235 doc
: /* Alist of default values for frame creation.
4236 These may be set in your init file, like this:
4237 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4238 These override values given in window system configuration data,
4239 including X Windows' defaults database.
4240 For values specific to the first Emacs frame, see `initial-frame-alist'.
4241 For window-system specific values, see `window-system-default-frame-alist'.
4242 For values specific to the separate minibuffer frame, see
4243 `minibuffer-frame-alist'.
4244 The `menu-bar-lines' element of the list controls whether new frames
4245 have menu bars; `menu-bar-mode' works by altering this element.
4246 Setting this variable does not affect existing frames, only new ones. */);
4247 Vdefault_frame_alist
= Qnil
;
4249 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4250 doc
: /* Default position of scroll bars on this window-system. */);
4251 #ifdef HAVE_WINDOW_SYSTEM
4252 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
4253 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4255 Vdefault_frame_scroll_bars
= Qright
;
4257 Vdefault_frame_scroll_bars
= Qleft
;
4260 Vdefault_frame_scroll_bars
= Qnil
;
4263 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
4264 scroll_bar_adjust_thumb_portion_p
,
4265 doc
: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
4266 Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
4267 even if the end of the buffer is shown (i.e. overscrolling).
4268 Set to nil if you want the thumb to be at the bottom when the end of the buffer
4269 is shown. Also, the thumb fills the whole scroll bar when the entire buffer
4270 is visible. In this case you can not overscroll. */);
4271 scroll_bar_adjust_thumb_portion_p
= 1;
4273 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4274 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4276 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4277 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4278 `mouse-position' calls this function, passing its usual return value as
4279 argument, and returns whatever this function returns.
4280 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4281 which need to do mouse handling at the Lisp level. */);
4282 Vmouse_position_function
= Qnil
;
4284 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4285 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4286 If the value is an integer, highlighting is only shown after moving the
4287 mouse, while keyboard input turns off the highlight even when the mouse
4288 is over the clickable text. However, the mouse shape still indicates
4289 when the mouse is over clickable text. */);
4290 Vmouse_highlight
= Qt
;
4292 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4293 doc
: /* If non-nil, make pointer invisible while typing.
4294 The pointer becomes visible again when the mouse is moved. */);
4295 Vmake_pointer_invisible
= Qt
;
4297 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4298 doc
: /* Functions run before deleting a frame.
4299 The functions are run with one arg, the frame to be deleted.
4302 Note that functions in this list may be called just before the frame is
4303 actually deleted, or some time later (or even both when an earlier function
4304 in `delete-frame-functions' (indirectly) calls `delete-frame'
4306 Vdelete_frame_functions
= Qnil
;
4307 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
4309 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4310 doc
: /* Non-nil if Menu-Bar mode is enabled.
4311 See the command `menu-bar-mode' for a description of this minor mode.
4312 Setting this variable directly does not take effect;
4313 either customize it (see the info node `Easy Customization')
4314 or call the function `menu-bar-mode'. */);
4315 Vmenu_bar_mode
= Qt
;
4317 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4318 doc
: /* Non-nil if Tool-Bar mode is enabled.
4319 See the command `tool-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 `tool-bar-mode'. */);
4323 #ifdef HAVE_WINDOW_SYSTEM
4324 Vtool_bar_mode
= Qt
;
4326 Vtool_bar_mode
= Qnil
;
4329 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4330 doc
: /* Minibufferless frames use this frame's minibuffer.
4332 Emacs cannot create minibufferless frames unless this is set to an
4333 appropriate surrogate.
4335 Emacs consults this variable only when creating minibufferless
4336 frames; once the frame is created, it sticks with its assigned
4337 minibuffer, no matter what this variable is set to. This means that
4338 this variable doesn't necessarily say anything meaningful about the
4339 current set of frames, or where the minibuffer is currently being
4342 This variable is local to the current terminal and cannot be buffer-local. */);
4344 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
4345 doc
: /* Non-nil if window system changes focus when you move the mouse.
4346 You should set this variable to tell Emacs how your window manager
4347 handles focus, since there is no way in general for Emacs to find out
4348 automatically. See also `mouse-autoselect-window'. */);
4349 focus_follows_mouse
= 0;
4351 staticpro (&Vframe_list
);
4354 defsubr (&Sframe_live_p
);
4355 defsubr (&Swindow_system
);
4356 defsubr (&Smake_terminal_frame
);
4357 defsubr (&Shandle_switch_frame
);
4358 defsubr (&Sselect_frame
);
4359 defsubr (&Sselected_frame
);
4360 defsubr (&Sframe_list
);
4361 defsubr (&Snext_frame
);
4362 defsubr (&Sprevious_frame
);
4363 defsubr (&Sdelete_frame
);
4364 defsubr (&Smouse_position
);
4365 defsubr (&Smouse_pixel_position
);
4366 defsubr (&Sset_mouse_position
);
4367 defsubr (&Sset_mouse_pixel_position
);
4369 defsubr (&Sframe_configuration
);
4370 defsubr (&Srestore_frame_configuration
);
4372 defsubr (&Smake_frame_visible
);
4373 defsubr (&Smake_frame_invisible
);
4374 defsubr (&Siconify_frame
);
4375 defsubr (&Sframe_visible_p
);
4376 defsubr (&Svisible_frame_list
);
4377 defsubr (&Sraise_frame
);
4378 defsubr (&Slower_frame
);
4379 defsubr (&Sredirect_frame_focus
);
4380 defsubr (&Sframe_focus
);
4381 defsubr (&Sframe_parameters
);
4382 defsubr (&Sframe_parameter
);
4383 defsubr (&Smodify_frame_parameters
);
4384 defsubr (&Sframe_char_height
);
4385 defsubr (&Sframe_char_width
);
4386 defsubr (&Sframe_pixel_height
);
4387 defsubr (&Sframe_pixel_width
);
4388 defsubr (&Stool_bar_pixel_width
);
4389 defsubr (&Sset_frame_height
);
4390 defsubr (&Sset_frame_width
);
4391 defsubr (&Sset_frame_size
);
4392 defsubr (&Sset_frame_position
);
4393 defsubr (&Sframe_pointer_visible_p
);
4395 #ifdef HAVE_WINDOW_SYSTEM
4396 defsubr (&Sx_get_resource
);
4397 defsubr (&Sx_parse_geometry
);