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 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
155 struct window
*w
= XWINDOW (window
);
157 w
->last_modified
= 0;
161 /* Handle just the top child in a vertical split. */
162 if (WINDOW_VERTICAL_COMBINATION_P (w
))
163 set_menu_bar_lines_1 (w
->contents
, n
);
164 else if (WINDOW_HORIZONTAL_COMBINATION_P (w
))
165 /* Adjust all children in a horizontal split. */
166 for (window
= w
->contents
; !NILP (window
); window
= w
->next
)
168 w
= XWINDOW (window
);
169 set_menu_bar_lines_1 (window
, n
);
174 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
177 int olines
= FRAME_MENU_BAR_LINES (f
);
179 /* Right now, menu bars don't work properly in minibuf-only frames;
180 most of the commands try to apply themselves to the minibuffer
181 frame itself, and get an error because you can't switch buffers
182 in or split the minibuffer window. */
183 if (FRAME_MINIBUF_ONLY_P (f
))
186 if (TYPE_RANGED_INTEGERP (int, value
))
187 nlines
= XINT (value
);
191 if (nlines
!= olines
)
193 windows_or_buffers_changed
++;
194 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
195 FRAME_MENU_BAR_LINES (f
) = nlines
;
196 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
201 Lisp_Object Vframe_list
;
204 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
205 doc
: /* Return non-nil if OBJECT is a frame.
207 t for a termcap frame (a character-only terminal),
208 'x' for an Emacs frame that is really an X window,
209 'w32' for an Emacs frame that is a window on MS-Windows display,
210 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
211 'pc' for a direct-write MS-DOS frame.
212 See also `frame-live-p'. */)
215 if (!FRAMEP (object
))
217 switch (XFRAME (object
)->output_method
)
219 case output_initial
: /* The initial frame is like a termcap frame. */
222 case output_x_window
:
226 case output_msdos_raw
:
235 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
236 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
237 Value is nil if OBJECT is not a live frame. If object is a live
238 frame, the return value indicates what sort of terminal device it is
239 displayed on. See the documentation of `framep' for possible
243 return ((FRAMEP (object
)
244 && FRAME_LIVE_P (XFRAME (object
)))
249 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
250 doc
: /* The name of the window system that FRAME is displaying through.
251 The value is a symbol:
252 nil for a termcap frame (a character-only terminal),
253 'x' for an Emacs frame that is really an X window,
254 'w32' for an Emacs frame that is a window on MS-Windows display,
255 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
256 'pc' for a direct-write MS-DOS frame.
258 FRAME defaults to the currently selected frame.
260 Use of this function as a predicate is deprecated. Instead,
261 use `display-graphic-p' or any of the other `display-*-p'
262 predicates which report frame's specific UI-related capabilities. */)
267 frame
= selected_frame
;
269 type
= Fframep (frame
);
272 wrong_type_argument (Qframep
, frame
);
281 make_frame (int mini_p
)
284 register struct frame
*f
;
285 register Lisp_Object root_window
;
286 register Lisp_Object mini_window
;
288 f
= allocate_frame ();
289 XSETFRAME (frame
, f
);
291 /* Initialize Lisp data. Note that allocate_frame initializes all
292 Lisp data to nil, so do it only for slots which should not be nil. */
293 fset_tool_bar_position (f
, Qtop
);
295 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
296 non-Lisp data, so do it only for slots which should not be zero.
297 To avoid subtle bugs and for the sake of readability, it's better to
298 initialize enum members explicitly even if their values are zero. */
299 f
->wants_modeline
= 1;
301 f
->has_minibuffer
= mini_p
;
302 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
303 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
304 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
305 #ifdef HAVE_WINDOW_SYSTEM
306 f
->want_fullscreen
= FULLSCREEN_NONE
;
309 root_window
= make_window ();
312 mini_window
= make_window ();
313 wset_next (XWINDOW (root_window
), mini_window
);
314 wset_prev (XWINDOW (mini_window
), root_window
);
315 XWINDOW (mini_window
)->mini
= 1;
316 wset_frame (XWINDOW (mini_window
), frame
);
317 fset_minibuffer_window (f
, mini_window
);
322 wset_next (XWINDOW (root_window
), Qnil
);
323 fset_minibuffer_window (f
, Qnil
);
326 wset_frame (XWINDOW (root_window
), frame
);
329 just so that there is "something there."
330 Correct size will be set up later with change_frame_size. */
332 SET_FRAME_COLS (f
, 10);
333 FRAME_LINES (f
) = 10;
335 XWINDOW (root_window
)->total_cols
= 10;
336 XWINDOW (root_window
)->total_lines
= mini_p
? 9 : 10;
340 XWINDOW (mini_window
)->total_cols
= 10;
341 XWINDOW (mini_window
)->top_line
= 9;
342 XWINDOW (mini_window
)->total_lines
= 1;
345 /* Choose a buffer for the frame's root window. */
347 Lisp_Object buf
= Fcurrent_buffer ();
349 /* If current buffer is hidden, try to find another one. */
350 if (BUFFER_HIDDEN_P (XBUFFER (buf
)))
351 buf
= other_buffer_safely (buf
);
353 /* Use set_window_buffer, not Fset_window_buffer, and don't let
354 hooks be run by it. The reason is that the whole frame/window
355 arrangement is not yet fully initialized at this point. Windows
356 don't have the right size, glyph matrices aren't initialized
357 etc. Running Lisp functions at this point surely ends in a
359 set_window_buffer (root_window
, buf
, 0, 0);
360 fset_buffer_list (f
, Fcons (buf
, Qnil
));
364 set_window_buffer (mini_window
,
365 (NILP (Vminibuffer_list
)
367 : Fcar (Vminibuffer_list
)),
370 fset_root_window (f
, root_window
);
371 fset_selected_window (f
, root_window
);
372 /* Make sure this window seems more recently used than
373 a newly-created, never-selected window. */
374 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
379 #ifdef HAVE_WINDOW_SYSTEM
380 /* Make a frame using a separate minibuffer window on another frame.
381 MINI_WINDOW is the minibuffer window to use. nil means use the
382 default (the global minibuffer). */
385 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
387 register struct frame
*f
;
390 if (!NILP (mini_window
))
391 CHECK_LIVE_WINDOW (mini_window
);
393 if (!NILP (mini_window
)
394 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
395 error ("Frame and minibuffer must be on the same terminal");
397 /* Make a frame containing just a root window. */
400 if (NILP (mini_window
))
402 /* Use default-minibuffer-frame if possible. */
403 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
404 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
406 Lisp_Object frame_dummy
;
408 XSETFRAME (frame_dummy
, f
);
409 GCPRO1 (frame_dummy
);
410 /* If there's no minibuffer frame to use, create one. */
411 kset_default_minibuffer_frame
412 (kb
, call1 (intern ("make-initial-minibuffer-frame"), display
));
417 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
420 fset_minibuffer_window (f
, mini_window
);
422 /* Make the chosen minibuffer window display the proper minibuffer,
423 unless it is already showing a minibuffer. */
424 if (NILP (Fmemq (XWINDOW (mini_window
)->contents
, Vminibuffer_list
)))
425 /* Use set_window_buffer instead of Fset_window_buffer (see
426 discussion of bug#11984, bug#12025, bug#12026). */
427 set_window_buffer (mini_window
,
428 (NILP (Vminibuffer_list
)
430 : Fcar (Vminibuffer_list
)), 0, 0);
434 /* Make a frame containing only a minibuffer window. */
437 make_minibuffer_frame (void)
439 /* First make a frame containing just a root window, no minibuffer. */
441 register struct frame
*f
= make_frame (0);
442 register Lisp_Object mini_window
;
443 register Lisp_Object frame
;
445 XSETFRAME (frame
, f
);
450 f
->wants_modeline
= 0;
451 f
->has_minibuffer
= 1;
453 /* Now label the root window as also being the minibuffer.
454 Avoid infinite looping on the window chain by marking next pointer
457 mini_window
= f
->root_window
;
458 fset_minibuffer_window (f
, mini_window
);
459 XWINDOW (mini_window
)->mini
= 1;
460 wset_next (XWINDOW (mini_window
), Qnil
);
461 wset_prev (XWINDOW (mini_window
), Qnil
);
462 wset_frame (XWINDOW (mini_window
), frame
);
464 /* Put the proper buffer in that window. */
466 /* Use set_window_buffer instead of Fset_window_buffer (see
467 discussion of bug#11984, bug#12025, bug#12026). */
468 set_window_buffer (mini_window
,
469 (NILP (Vminibuffer_list
)
471 : Fcar (Vminibuffer_list
)), 0, 0);
474 #endif /* HAVE_WINDOW_SYSTEM */
476 /* Construct a frame that refers to a terminal. */
478 static printmax_t tty_frame_count
;
481 make_initial_frame (void)
484 struct terminal
*terminal
;
487 eassert (initial_kboard
);
489 /* The first call must initialize Vframe_list. */
490 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
493 terminal
= init_initial_terminal ();
496 XSETFRAME (frame
, f
);
498 Vframe_list
= Fcons (frame
, Vframe_list
);
501 fset_name (f
, build_pure_c_string ("F1"));
503 SET_FRAME_VISIBLE (f
, 1);
505 f
->output_method
= terminal
->type
;
506 f
->terminal
= terminal
;
507 f
->terminal
->reference_count
++;
508 f
->output_data
.nothing
= 0;
510 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
511 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
513 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
515 /* The default value of menu-bar-mode is t. */
516 set_menu_bar_lines (f
, make_number (1), Qnil
);
519 init_frame_faces (f
);
525 static struct frame
*
526 make_terminal_frame (struct terminal
*terminal
)
528 register struct frame
*f
;
530 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
533 error ("Terminal is not live, can't create new frames on it");
537 XSETFRAME (frame
, f
);
538 Vframe_list
= Fcons (frame
, Vframe_list
);
540 fset_name (f
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
542 SET_FRAME_VISIBLE (f
, 1);
544 f
->terminal
= terminal
;
545 f
->terminal
->reference_count
++;
547 f
->output_data
.tty
->display_info
= &the_only_display_info
;
548 if (!inhibit_window_system
549 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
550 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
551 f
->output_method
= output_msdos_raw
;
553 f
->output_method
= output_termcap
;
554 #else /* not MSDOS */
555 f
->output_method
= output_termcap
;
556 create_tty_output (f
);
557 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
558 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
559 #endif /* not MSDOS */
561 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
562 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
564 /* Set the top frame to the newly created frame. */
565 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
566 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
567 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f
)->top_frame
), 2); /* obscured */
569 FRAME_TTY (f
)->top_frame
= frame
;
572 init_frame_faces (f
);
577 /* Get a suitable value for frame parameter PARAMETER for a newly
578 created frame, based on (1) the user-supplied frame parameter
579 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
582 get_future_frame_param (Lisp_Object parameter
,
583 Lisp_Object supplied_parms
,
588 result
= Fassq (parameter
, supplied_parms
);
590 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
591 if (NILP (result
) && current_value
!= NULL
)
592 result
= build_string (current_value
);
593 if (!NILP (result
) && !STRINGP (result
))
594 result
= XCDR (result
);
595 if (NILP (result
) || !STRINGP (result
))
601 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
603 doc
: /* Create an additional terminal frame, possibly on another terminal.
604 This function takes one argument, an alist specifying frame parameters.
606 You can create multiple frames on a single text terminal, but only one
607 of them (the selected terminal frame) is actually displayed.
609 In practice, generally you don't need to specify any parameters,
610 except when you want to create a new frame on another terminal.
611 In that case, the `tty' parameter specifies the device file to open,
612 and the `tty-type' parameter specifies the terminal type. Example:
614 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
616 Note that changing the size of one terminal frame automatically
617 affects all frames on the same terminal device. */)
621 struct terminal
*t
= NULL
;
622 Lisp_Object frame
, tem
;
623 struct frame
*sf
= SELECTED_FRAME ();
626 if (sf
->output_method
!= output_msdos_raw
627 && sf
->output_method
!= output_termcap
)
629 #else /* not MSDOS */
631 #ifdef WINDOWSNT /* This should work now! */
632 if (sf
->output_method
!= output_termcap
)
633 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
635 #endif /* not MSDOS */
638 Lisp_Object terminal
;
640 terminal
= Fassq (Qterminal
, parms
);
641 if (CONSP (terminal
))
643 terminal
= XCDR (terminal
);
644 t
= get_terminal (terminal
, 1);
647 if (t
&& t
!= the_only_display_info
.terminal
)
648 /* msdos.c assumes a single tty_display_info object. */
649 error ("Multiple terminals are not supported on this platform");
651 t
= the_only_display_info
.terminal
;
657 char *name
= 0, *type
= 0;
658 Lisp_Object tty
, tty_type
;
660 tty
= get_future_frame_param
661 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
662 ? FRAME_TTY (XFRAME (selected_frame
))->name
666 name
= alloca (SBYTES (tty
) + 1);
667 memcpy (name
, SSDATA (tty
), SBYTES (tty
));
668 name
[SBYTES (tty
)] = 0;
671 tty_type
= get_future_frame_param
672 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
673 ? FRAME_TTY (XFRAME (selected_frame
))->type
675 if (!NILP (tty_type
))
677 type
= alloca (SBYTES (tty_type
) + 1);
678 memcpy (type
, SSDATA (tty_type
), SBYTES (tty_type
));
679 type
[SBYTES (tty_type
)] = 0;
682 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
685 f
= make_terminal_frame (t
);
689 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
690 change_frame_size (f
, height
, width
, 0, 0, 0);
695 XSETFRAME (frame
, f
);
696 Fmodify_frame_parameters (frame
, parms
);
697 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
698 build_string (t
->display_info
.tty
->type
)),
700 if (t
->display_info
.tty
->name
!= NULL
)
701 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
702 build_string (t
->display_info
.tty
->name
)),
705 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
707 /* Make the frame face alist be frame-specific, so that each
708 frame could change its face definitions independently. */
709 fset_face_alist (f
, Fcopy_alist (sf
->face_alist
));
710 /* Simple Fcopy_alist isn't enough, because we need the contents of
711 the vectors which are the CDRs of associations in face_alist to
712 be copied as well. */
713 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
714 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
719 /* Perform the switch to frame FRAME.
721 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
724 If TRACK is non-zero and the frame that currently has the focus
725 redirects its focus to the selected frame, redirect that focused
726 frame's focus to FRAME instead.
728 FOR_DELETION non-zero means that the selected frame is being
729 deleted, which includes the possibility that the frame's terminal
732 The value of NORECORD is passed as argument to Fselect_window. */
735 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
737 struct frame
*sf
= SELECTED_FRAME ();
739 /* If FRAME is a switch-frame event, extract the frame we should
742 && EQ (XCAR (frame
), Qswitch_frame
)
743 && CONSP (XCDR (frame
)))
744 frame
= XCAR (XCDR (frame
));
746 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
747 a switch-frame event to arrive after a frame is no longer live,
748 especially when deleting the initial frame during startup. */
750 if (! FRAME_LIVE_P (XFRAME (frame
)))
753 if (sf
== XFRAME (frame
))
756 /* This is too greedy; it causes inappropriate focus redirection
757 that's hard to get rid of. */
759 /* If a frame's focus has been redirected toward the currently
760 selected frame, we should change the redirection to point to the
761 newly selected frame. This means that if the focus is redirected
762 from a minibufferless frame to a surrogate minibuffer frame, we
763 can use `other-window' to switch between all the frames using
764 that minibuffer frame, and the focus redirection will follow us
770 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
774 if (!FRAMEP (XCAR (tail
)))
777 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
779 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
780 Fredirect_frame_focus (XCAR (tail
), frame
);
784 /* Instead, apply it only to the frame we're pointing to. */
785 #ifdef HAVE_WINDOW_SYSTEM
786 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
788 Lisp_Object focus
, xfocus
;
790 xfocus
= x_get_focus_frame (XFRAME (frame
));
793 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
794 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
795 Fredirect_frame_focus (xfocus
, frame
);
798 #endif /* HAVE_X_WINDOWS */
801 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
802 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
804 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
806 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
807 /* Mark previously displayed frame as now obscured. */
808 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
), 2);
809 SET_FRAME_VISIBLE (XFRAME (frame
), 1);
810 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
813 selected_frame
= frame
;
814 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
815 last_nonminibuf_frame
= XFRAME (selected_frame
);
817 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
819 /* We want to make sure that the next event generates a frame-switch
820 event to the appropriate frame. This seems kludgy to me, but
821 before you take it out, make sure that evaluating something like
822 (select-window (frame-root-window (new-frame))) doesn't end up
823 with your typing being interpreted in the new frame instead of
824 the one you're actually typing in. */
825 internal_last_event_frame
= Qnil
;
830 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
831 doc
: /* Select FRAME.
832 Subsequent editing commands apply to its selected window.
833 Optional argument NORECORD means to neither change the order of
834 recently selected windows nor the buffer list.
836 The selection of FRAME lasts until the next time the user does
837 something to select a different frame, or until the next time
838 this function is called. If you are using a window system, the
839 previously selected frame may be restored as the selected frame
840 when returning to the command loop, because it still may have
841 the window system's input focus. On a text terminal, the next
842 redisplay will display FRAME.
844 This function returns FRAME, or nil if FRAME has been deleted. */)
845 (Lisp_Object frame
, Lisp_Object norecord
)
847 return do_switch_frame (frame
, 1, 0, norecord
);
851 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
852 doc
: /* Handle a switch-frame event EVENT.
853 Switch-frame events are usually bound to this function.
854 A switch-frame event tells Emacs that the window manager has requested
855 that the user's events be directed to the frame mentioned in the event.
856 This function selects the selected window of the frame of EVENT.
858 If EVENT is frame object, handle it as if it were a switch-frame event
862 /* Preserve prefix arg that the command loop just cleared. */
863 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
864 Frun_hooks (1, &Qmouse_leave_buffer_hook
);
865 return do_switch_frame (event
, 0, 0, Qnil
);
868 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
869 doc
: /* Return the frame that is now selected. */)
872 return selected_frame
;
875 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
877 doc
: /* Return a list of all live frames. */)
881 frames
= Fcopy_sequence (Vframe_list
);
882 #ifdef HAVE_WINDOW_SYSTEM
883 if (FRAMEP (tip_frame
))
884 frames
= Fdelq (tip_frame
, frames
);
889 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
890 same tty (for tty frames) or among frames which uses FRAME's keyboard.
891 If MINIBUF is nil, do not consider minibuffer-only candidate.
892 If MINIBUF is `visible', do not consider an invisible candidate.
893 If MINIBUF is a window, consider only its own frame and candidate now
894 using that window as the minibuffer.
895 If MINIBUF is 0, consider candidate if it is visible or iconified.
896 Otherwise consider any candidate and return nil if CANDIDATE is not
900 candidate_frame (Lisp_Object candidate
, Lisp_Object frame
, Lisp_Object minibuf
)
902 struct frame
*c
= XFRAME (candidate
), *f
= XFRAME (frame
);
904 if ((!FRAME_TERMCAP_P (c
) && !FRAME_TERMCAP_P (f
)
905 && FRAME_KBOARD (c
) == FRAME_KBOARD (f
))
906 || (FRAME_TERMCAP_P (c
) && FRAME_TERMCAP_P (f
)
907 && FRAME_TTY (c
) == FRAME_TTY (f
)))
911 if (!FRAME_MINIBUF_ONLY_P (c
))
914 else if (EQ (minibuf
, Qvisible
))
916 if (FRAME_VISIBLE_P (c
))
919 else if (WINDOWP (minibuf
))
921 if (EQ (FRAME_MINIBUF_WINDOW (c
), minibuf
)
922 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), candidate
)
923 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
924 FRAME_FOCUS_FRAME (c
)))
927 else if (XFASTINT (minibuf
) == 0)
929 if (FRAME_VISIBLE_P (c
) || FRAME_ICONIFIED_P (c
))
938 /* Return the next frame in the frame list after FRAME. */
941 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
946 /* There must always be at least one frame in Vframe_list. */
947 eassert (CONSP (Vframe_list
));
950 FOR_EACH_FRAME (tail
, f
)
954 f
= candidate_frame (f
, frame
, minibuf
);
964 /* Return the previous frame in the frame list before FRAME. */
967 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
969 Lisp_Object f
, tail
, prev
= Qnil
;
971 /* There must always be at least one frame in Vframe_list. */
972 eassert (CONSP (Vframe_list
));
974 FOR_EACH_FRAME (tail
, f
)
976 if (EQ (frame
, f
) && !NILP (prev
))
978 f
= candidate_frame (f
, frame
, minibuf
);
983 /* We've scanned the entire list. */
985 /* We went through the whole frame list without finding a single
986 acceptable frame. Return the original frame. */
989 /* There were no acceptable frames in the list before FRAME; otherwise,
990 we would have returned directly from the loop. Since PREV is the last
991 acceptable frame in the list, return it. */
996 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
997 doc
: /* Return the next frame in the frame list after FRAME.
998 It considers only frames on the same terminal as FRAME.
999 By default, skip minibuffer-only frames.
1000 If omitted, FRAME defaults to the selected frame.
1001 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1002 If MINIFRAME is a window, include only its own frame
1003 and any frame now using that window as the minibuffer.
1004 If MINIFRAME is `visible', include all visible frames.
1005 If MINIFRAME is 0, include all visible and iconified frames.
1006 Otherwise, include all frames. */)
1007 (Lisp_Object frame
, Lisp_Object miniframe
)
1010 frame
= selected_frame
;
1011 CHECK_LIVE_FRAME (frame
);
1012 return next_frame (frame
, miniframe
);
1015 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1016 doc
: /* Return the previous frame in the frame list before FRAME.
1017 It considers only frames on the same terminal as FRAME.
1018 By default, skip minibuffer-only frames.
1019 If omitted, FRAME defaults to the selected frame.
1020 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1021 If MINIFRAME is a window, include only its own frame
1022 and any frame now using that window as the minibuffer.
1023 If MINIFRAME is `visible', include all visible frames.
1024 If MINIFRAME is 0, include all visible and iconified frames.
1025 Otherwise, include all frames. */)
1026 (Lisp_Object frame
, Lisp_Object miniframe
)
1029 frame
= selected_frame
;
1030 CHECK_LIVE_FRAME (frame
);
1031 return prev_frame (frame
, miniframe
);
1034 /* Return 1 if it is ok to delete frame F;
1035 0 if all frames aside from F are invisible.
1036 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1039 other_visible_frames (FRAME_PTR f
)
1041 Lisp_Object frames
, this;
1043 FOR_EACH_FRAME (frames
, this)
1045 if (f
== XFRAME (this))
1048 /* Verify that we can still talk to the frame's X window,
1049 and note any recent change in visibility. */
1050 #ifdef HAVE_WINDOW_SYSTEM
1051 if (FRAME_WINDOW_P (XFRAME (this)))
1052 x_sync (XFRAME (this));
1055 if (FRAME_VISIBLE_P (XFRAME (this))
1056 || FRAME_ICONIFIED_P (XFRAME (this))
1057 /* Allow deleting the terminal frame when at least one X
1059 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1065 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1066 unconditionally. x_connection_closed and delete_terminal use
1067 this. Any other value of FORCE implements the semantics
1068 described for Fdelete_frame. */
1070 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1072 struct frame
*f
= decode_any_frame (frame
);
1073 struct frame
*sf
= SELECTED_FRAME ();
1076 int minibuffer_selected
, is_tooltip_frame
;
1078 if (! FRAME_LIVE_P (f
))
1081 if (NILP (force
) && !other_visible_frames (f
))
1082 error ("Attempt to delete the sole visible or iconified frame");
1084 /* x_connection_closed must have set FORCE to `noelisp' in order
1085 to delete the last frame, if it is gone. */
1086 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1087 error ("Attempt to delete the only frame");
1089 XSETFRAME (frame
, f
);
1091 /* Does this frame have a minibuffer, and is it the surrogate
1092 minibuffer for any other frame? */
1093 if (FRAME_HAS_MINIBUF_P (f
))
1095 Lisp_Object frames
, this;
1097 FOR_EACH_FRAME (frames
, this)
1099 if (! EQ (this, frame
)
1101 WINDOW_FRAME (XWINDOW
1102 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1104 /* If we MUST delete this frame, delete the other first.
1105 But do this only if FORCE equals `noelisp'. */
1106 if (EQ (force
, Qnoelisp
))
1107 delete_frame (this, Qnoelisp
);
1109 error ("Attempt to delete a surrogate minibuffer frame");
1114 is_tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1116 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1117 frame is a tooltip. FORCE is set to `noelisp' when handling
1118 a disconnect from the terminal, so we don't dare call Lisp
1120 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1122 else if (EQ (force
, Qnoelisp
))
1124 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1128 #ifdef HAVE_X_WINDOWS
1129 /* Also, save clipboard to the clipboard manager. */
1130 x_clipboard_manager_save_frame (frame
);
1133 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1136 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1137 if (! FRAME_LIVE_P (f
))
1140 /* At this point, we are committed to deleting the frame.
1141 There is no more chance for errors to prevent it. */
1143 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1145 /* Don't let the frame remain selected. */
1148 Lisp_Object tail
, frame1
;
1150 /* Look for another visible frame on the same terminal. */
1151 frame1
= next_frame (frame
, Qvisible
);
1153 /* If there is none, find *some* other frame. */
1154 if (NILP (frame1
) || EQ (frame1
, frame
))
1156 FOR_EACH_FRAME (tail
, frame1
)
1158 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1160 /* Do not change a text terminal's top-frame. */
1161 struct frame
*f1
= XFRAME (frame1
);
1162 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1164 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1165 if (!EQ (top_frame
, frame
))
1172 #ifdef NS_IMPL_COCOA
1174 /* Under NS, there is no system mechanism for choosing a new
1175 window to get focus -- it is left to application code.
1176 So the portion of THIS application interfacing with NS
1177 needs to know about it. We call Fraise_frame, but the
1178 purpose is really to transfer focus. */
1179 Fraise_frame (frame1
);
1182 do_switch_frame (frame1
, 0, 1, Qnil
);
1183 sf
= SELECTED_FRAME ();
1186 /* Don't allow minibuf_window to remain on a deleted frame. */
1187 if (EQ (f
->minibuffer_window
, minibuf_window
))
1189 /* Use set_window_buffer instead of Fset_window_buffer (see
1190 discussion of bug#11984, bug#12025, bug#12026). */
1191 set_window_buffer (sf
->minibuffer_window
,
1192 XWINDOW (minibuf_window
)->contents
, 0, 0);
1193 minibuf_window
= sf
->minibuffer_window
;
1195 /* If the dying minibuffer window was selected,
1196 select the new one. */
1197 if (minibuffer_selected
)
1198 Fselect_window (minibuf_window
, Qnil
);
1201 /* Don't let echo_area_window to remain on a deleted frame. */
1202 if (EQ (f
->minibuffer_window
, echo_area_window
))
1203 echo_area_window
= sf
->minibuffer_window
;
1205 /* Clear any X selections for this frame. */
1206 #ifdef HAVE_X_WINDOWS
1208 x_clear_frame_selections (f
);
1212 This function must be called before the window tree of the
1213 frame is deleted because windows contain dynamically allocated
1217 #ifdef HAVE_WINDOW_SYSTEM
1218 /* Give chance to each font driver to free a frame specific data. */
1219 font_update_drivers (f
, Qnil
);
1222 /* Mark all the windows that used to be on FRAME as deleted, and then
1223 remove the reference to them. */
1224 delete_all_child_windows (f
->root_window
);
1225 fset_root_window (f
, Qnil
);
1227 Vframe_list
= Fdelq (frame
, Vframe_list
);
1228 SET_FRAME_VISIBLE (f
, 0);
1230 /* Allow the vector of menu bar contents to be freed in the next
1231 garbage collection. The frame object itself may not be garbage
1232 collected until much later, because recent_keys and other data
1233 structures can still refer to it. */
1234 fset_menu_bar_vector (f
, Qnil
);
1236 /* If FRAME's buffer lists contains killed
1237 buffers, this helps GC to reclaim them. */
1238 fset_buffer_list (f
, Qnil
);
1239 fset_buried_buffer_list (f
, Qnil
);
1241 free_font_driver_list (f
);
1243 xfree (f
->decode_mode_spec_buffer
);
1244 xfree (FRAME_INSERT_COST (f
));
1245 xfree (FRAME_DELETEN_COST (f
));
1246 xfree (FRAME_INSERTN_COST (f
));
1247 xfree (FRAME_DELETE_COST (f
));
1249 /* Since some events are handled at the interrupt level, we may get
1250 an event for f at any time; if we zero out the frame's terminal
1251 now, then we may trip up the event-handling code. Instead, we'll
1252 promise that the terminal of the frame must be valid until we
1253 have called the window-system-dependent frame destruction
1256 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1257 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1260 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1261 f
->output_data
.nothing
= 0;
1262 f
->terminal
= 0; /* Now the frame is dead. */
1264 /* If needed, delete the terminal that this frame was on.
1265 (This must be done after the frame is killed.) */
1266 terminal
->reference_count
--;
1268 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1270 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1271 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1272 terminal
->reference_count
= 1;
1273 #endif /* USE_GTK */
1274 if (terminal
->reference_count
== 0)
1277 XSETTERMINAL (tmp
, terminal
);
1280 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1283 kb
= terminal
->kboard
;
1286 /* If we've deleted the last_nonminibuf_frame, then try to find
1288 if (f
== last_nonminibuf_frame
)
1290 Lisp_Object frames
, this;
1292 last_nonminibuf_frame
= 0;
1294 FOR_EACH_FRAME (frames
, this)
1297 if (!FRAME_MINIBUF_ONLY_P (f
))
1299 last_nonminibuf_frame
= f
;
1305 /* If there's no other frame on the same kboard, get out of
1306 single-kboard state if we're in it for this kboard. */
1309 Lisp_Object frames
, this;
1310 /* Some frame we found on the same kboard, or nil if there are none. */
1311 Lisp_Object frame_on_same_kboard
= Qnil
;
1313 FOR_EACH_FRAME (frames
, this)
1314 if (kb
== FRAME_KBOARD (XFRAME (this)))
1315 frame_on_same_kboard
= this;
1317 if (NILP (frame_on_same_kboard
))
1318 not_single_kboard_state (kb
);
1322 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1323 find another one. Prefer minibuffer-only frames, but also notice
1324 frames with other windows. */
1325 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1327 Lisp_Object frames
, this;
1329 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1330 Lisp_Object frame_with_minibuf
= Qnil
;
1331 /* Some frame we found on the same kboard, or nil if there are none. */
1332 Lisp_Object frame_on_same_kboard
= Qnil
;
1334 FOR_EACH_FRAME (frames
, this)
1336 struct frame
*f1
= XFRAME (this);
1338 /* Consider only frames on the same kboard
1339 and only those with minibuffers. */
1340 if (kb
== FRAME_KBOARD (f1
)
1341 && FRAME_HAS_MINIBUF_P (f1
))
1343 frame_with_minibuf
= this;
1344 if (FRAME_MINIBUF_ONLY_P (f1
))
1348 if (kb
== FRAME_KBOARD (f1
))
1349 frame_on_same_kboard
= this;
1352 if (!NILP (frame_on_same_kboard
))
1354 /* We know that there must be some frame with a minibuffer out
1355 there. If this were not true, all of the frames present
1356 would have to be minibufferless, which implies that at some
1357 point their minibuffer frames must have been deleted, but
1358 that is prohibited at the top; you can't delete surrogate
1359 minibuffer frames. */
1360 if (NILP (frame_with_minibuf
))
1363 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
1366 /* No frames left on this kboard--say no minibuffer either. */
1367 kset_default_minibuffer_frame (kb
, Qnil
);
1370 /* Cause frame titles to update--necessary if we now have just one frame. */
1371 if (!is_tooltip_frame
)
1372 update_mode_lines
= 1;
1377 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1378 doc
: /* Delete FRAME, permanently eliminating it from use.
1379 FRAME defaults to the selected frame.
1381 A frame may not be deleted if its minibuffer is used by other frames.
1382 Normally, you may not delete a frame if all other frames are invisible,
1383 but if the second optional argument FORCE is non-nil, you may do so.
1385 This function runs `delete-frame-functions' before actually
1386 deleting the frame, unless the frame is a tooltip.
1387 The functions are run with one argument, the frame to be deleted. */)
1388 (Lisp_Object frame
, Lisp_Object force
)
1390 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1394 /* Return mouse position in character cell units. */
1396 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1397 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1398 The position is given in character cells, where (0, 0) is the
1399 upper-left corner of the frame, X is the horizontal offset, and Y is
1400 the vertical offset.
1401 If Emacs is running on a mouseless terminal or hasn't been programmed
1402 to read the mouse position, it returns the selected frame for FRAME
1403 and nil for X and Y.
1404 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1405 passing the normal return value to that function as an argument,
1406 and returns whatever that function returns. */)
1410 Lisp_Object lispy_dummy
;
1411 Lisp_Object x
, y
, retval
;
1412 struct gcpro gcpro1
;
1414 f
= SELECTED_FRAME ();
1417 /* It's okay for the hook to refrain from storing anything. */
1418 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1420 enum scroll_bar_part party_dummy
;
1422 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1423 &lispy_dummy
, &party_dummy
,
1432 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1436 XSETFRAME (lispy_dummy
, f
);
1437 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1439 if (!NILP (Vmouse_position_function
))
1440 retval
= call1 (Vmouse_position_function
, retval
);
1441 RETURN_UNGCPRO (retval
);
1444 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1445 Smouse_pixel_position
, 0, 0, 0,
1446 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1447 The position is given in pixel units, where (0, 0) is the
1448 upper-left corner of the frame, X is the horizontal offset, and Y is
1449 the vertical offset.
1450 If Emacs is running on a mouseless terminal or hasn't been programmed
1451 to read the mouse position, it returns the selected frame for FRAME
1452 and nil for X and Y. */)
1456 Lisp_Object lispy_dummy
;
1459 f
= SELECTED_FRAME ();
1462 /* It's okay for the hook to refrain from storing anything. */
1463 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1465 enum scroll_bar_part party_dummy
;
1467 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1468 &lispy_dummy
, &party_dummy
,
1473 XSETFRAME (lispy_dummy
, f
);
1474 return Fcons (lispy_dummy
, Fcons (x
, y
));
1477 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1478 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1479 Coordinates are relative to the frame, not a window,
1480 so the coordinates of the top left character in the frame
1481 may be nonzero due to left-hand scroll bars or the menu bar.
1483 The position is given in character cells, where (0, 0) is the
1484 upper-left corner of the frame, X is the horizontal offset, and Y is
1485 the vertical offset.
1487 This function is a no-op for an X frame that is not visible.
1488 If you have just created a frame, you must wait for it to become visible
1489 before calling this function on it, like this.
1490 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1491 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1493 CHECK_LIVE_FRAME (frame
);
1494 CHECK_TYPE_RANGED_INTEGER (int, x
);
1495 CHECK_TYPE_RANGED_INTEGER (int, y
);
1497 /* I think this should be done with a hook. */
1498 #ifdef HAVE_WINDOW_SYSTEM
1499 if (FRAME_WINDOW_P (XFRAME (frame
)))
1500 /* Warping the mouse will cause enternotify and focus events. */
1501 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1504 if (FRAME_MSDOS_P (XFRAME (frame
)))
1506 Fselect_frame (frame
, Qnil
);
1507 mouse_moveto (XINT (x
), XINT (y
));
1512 Fselect_frame (frame
, Qnil
);
1513 term_mouse_moveto (XINT (x
), XINT (y
));
1522 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1523 Sset_mouse_pixel_position
, 3, 3, 0,
1524 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1525 The position is given in pixels, where (0, 0) is the upper-left corner
1526 of the frame, X is the horizontal offset, and Y is the vertical offset.
1528 Note, this is a no-op for an X frame that is not visible.
1529 If you have just created a frame, you must wait for it to become visible
1530 before calling this function on it, like this.
1531 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1532 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1534 CHECK_LIVE_FRAME (frame
);
1535 CHECK_TYPE_RANGED_INTEGER (int, x
);
1536 CHECK_TYPE_RANGED_INTEGER (int, y
);
1538 /* I think this should be done with a hook. */
1539 #ifdef HAVE_WINDOW_SYSTEM
1540 if (FRAME_WINDOW_P (XFRAME (frame
)))
1541 /* Warping the mouse will cause enternotify and focus events. */
1542 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1545 if (FRAME_MSDOS_P (XFRAME (frame
)))
1547 Fselect_frame (frame
, Qnil
);
1548 mouse_moveto (XINT (x
), XINT (y
));
1553 Fselect_frame (frame
, Qnil
);
1554 term_mouse_moveto (XINT (x
), XINT (y
));
1563 static void make_frame_visible_1 (Lisp_Object
);
1565 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1567 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1568 If omitted, FRAME defaults to the currently selected frame. */)
1571 struct frame
*f
= decode_live_frame (frame
);
1573 /* I think this should be done with a hook. */
1574 #ifdef HAVE_WINDOW_SYSTEM
1575 if (FRAME_WINDOW_P (f
))
1576 x_make_frame_visible (f
);
1579 make_frame_visible_1 (f
->root_window
);
1581 /* Make menu bar update for the Buffers and Frames menus. */
1582 windows_or_buffers_changed
++;
1584 XSETFRAME (frame
, f
);
1588 /* Update the display_time slot of the buffers shown in WINDOW
1589 and all its descendants. */
1592 make_frame_visible_1 (Lisp_Object window
)
1596 for (; !NILP (window
); window
= w
->next
)
1598 w
= XWINDOW (window
);
1599 if (WINDOWP (w
->contents
))
1600 make_frame_visible_1 (w
->contents
);
1602 bset_display_time (XBUFFER (w
->contents
), Fcurrent_time ());
1606 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1608 doc
: /* Make the frame FRAME invisible.
1609 If omitted, FRAME defaults to the currently selected frame.
1610 On graphical displays, invisible frames are not updated and are
1611 usually not displayed at all, even in a window system's \"taskbar\".
1613 Normally you may not make FRAME invisible if all other frames are invisible,
1614 but if the second optional argument FORCE is non-nil, you may do so.
1616 This function has no effect on text terminal frames. Such frames are
1617 always considered visible, whether or not they are currently being
1618 displayed in the terminal. */)
1619 (Lisp_Object frame
, Lisp_Object force
)
1621 struct frame
*f
= decode_live_frame (frame
);
1623 if (NILP (force
) && !other_visible_frames (f
))
1624 error ("Attempt to make invisible the sole visible or iconified frame");
1626 /* Don't allow minibuf_window to remain on a deleted frame. */
1627 if (EQ (f
->minibuffer_window
, minibuf_window
))
1629 struct frame
*sf
= XFRAME (selected_frame
);
1630 /* Use set_window_buffer instead of Fset_window_buffer (see
1631 discussion of bug#11984, bug#12025, bug#12026). */
1632 set_window_buffer (sf
->minibuffer_window
,
1633 XWINDOW (minibuf_window
)->contents
, 0, 0);
1634 minibuf_window
= sf
->minibuffer_window
;
1637 /* I think this should be done with a hook. */
1638 #ifdef HAVE_WINDOW_SYSTEM
1639 if (FRAME_WINDOW_P (f
))
1640 x_make_frame_invisible (f
);
1643 /* Make menu bar update for the Buffers and Frames menus. */
1644 windows_or_buffers_changed
++;
1649 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1651 doc
: /* Make the frame FRAME into an icon.
1652 If omitted, FRAME defaults to the currently selected frame. */)
1655 struct frame
*f
= decode_live_frame (frame
);
1657 /* Don't allow minibuf_window to remain on an iconified 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_iconify_frame (f
);
1674 /* Make menu bar update for the Buffers and Frames menus. */
1675 windows_or_buffers_changed
++;
1680 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1682 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1683 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1684 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1685 On graphical displays, invisible frames are not updated and are
1686 usually not displayed at all, even in a window system's \"taskbar\".
1688 If FRAME is a text terminal frame, this always returns t.
1689 Such frames are always considered visible, whether or not they are
1690 currently being displayed on the terminal. */)
1693 CHECK_LIVE_FRAME (frame
);
1695 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1697 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1702 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1704 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1707 Lisp_Object tail
, frame
, value
= Qnil
;
1709 FOR_EACH_FRAME (tail
, frame
)
1710 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1711 value
= Fcons (frame
, value
);
1717 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1718 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1719 If FRAME is invisible or iconified, make it visible.
1720 If you don't specify a frame, the selected frame is used.
1721 If Emacs is displaying on an ordinary terminal or some other device which
1722 doesn't support multiple overlapping frames, this function selects FRAME. */)
1725 struct frame
*f
= decode_live_frame (frame
);
1727 XSETFRAME (frame
, f
);
1729 if (FRAME_TERMCAP_P (f
))
1730 /* On a text terminal select FRAME. */
1731 Fselect_frame (frame
, Qnil
);
1733 /* Do like the documentation says. */
1734 Fmake_frame_visible (frame
);
1736 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1737 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
1742 /* Should we have a corresponding function called Flower_Power? */
1743 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1744 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1745 If you don't specify a frame, the selected frame is used.
1746 If Emacs is displaying on an ordinary terminal or some other device which
1747 doesn't support multiple overlapping frames, this function does nothing. */)
1750 struct frame
*f
= decode_live_frame (frame
);
1752 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1753 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
1759 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1761 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1762 In other words, switch-frame events caused by events in FRAME will
1763 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1764 FOCUS-FRAME after reading an event typed at FRAME.
1766 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
1767 frame again receives its own keystrokes.
1769 Focus redirection is useful for temporarily redirecting keystrokes to
1770 a surrogate minibuffer frame when a frame doesn't have its own
1773 A frame's focus redirection can be changed by `select-frame'. If frame
1774 FOO is selected, and then a different frame BAR is selected, any
1775 frames redirecting their focus to FOO are shifted to redirect their
1776 focus to BAR. This allows focus redirection to work properly when the
1777 user switches from one frame to another using `select-window'.
1779 This means that a frame whose focus is redirected to itself is treated
1780 differently from a frame whose focus is redirected to nil; the former
1781 is affected by `select-frame', while the latter is not.
1783 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1784 (Lisp_Object frame
, Lisp_Object focus_frame
)
1786 /* Note that we don't check for a live frame here. It's reasonable
1787 to redirect the focus of a frame you're about to delete, if you
1788 know what other frame should receive those keystrokes. */
1789 struct frame
*f
= decode_any_frame (frame
);
1791 if (! NILP (focus_frame
))
1792 CHECK_LIVE_FRAME (focus_frame
);
1794 fset_focus_frame (f
, focus_frame
);
1796 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
1797 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
1803 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 0, 1, 0,
1804 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1805 If FRAME is omitted or nil, the selected frame is used.
1806 Return nil if FRAME's focus is not redirected.
1807 See `redirect-frame-focus'. */)
1810 return FRAME_FOCUS_FRAME (decode_live_frame (frame
));
1815 /* Return the value of frame parameter PROP in frame FRAME. */
1817 #ifdef HAVE_WINDOW_SYSTEM
1818 #if !HAVE_NS && !defined(WINDOWSNT)
1822 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
1824 register Lisp_Object tem
;
1826 tem
= Fassq (prop
, frame
->param_alist
);
1833 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
1836 frames_discard_buffer (Lisp_Object buffer
)
1838 Lisp_Object frame
, tail
;
1840 FOR_EACH_FRAME (tail
, frame
)
1843 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
1844 fset_buried_buffer_list
1845 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
1849 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1850 If the alist already has an element for PROP, we change it. */
1853 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
1855 register Lisp_Object tem
;
1857 tem
= Fassq (prop
, *alistptr
);
1859 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1865 frame_name_fnn_p (char *str
, ptrdiff_t len
)
1867 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
1870 while ('0' <= *p
&& *p
<= '9')
1878 /* Set the name of the terminal frame. Also used by MSDOS frames.
1879 Modeled after x_set_name which is used for WINDOW frames. */
1882 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
1884 f
->explicit_name
= ! NILP (name
);
1886 /* If NAME is nil, set the name to F<num>. */
1889 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
1891 /* Check for no change needed in this very common case
1892 before we do any consing. */
1893 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
1896 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
1900 CHECK_STRING (name
);
1902 /* Don't change the name if it's already NAME. */
1903 if (! NILP (Fstring_equal (name
, f
->name
)))
1906 /* Don't allow the user to set the frame name to F<num>, so it
1907 doesn't clash with the names we generate for terminal frames. */
1908 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
1909 error ("Frame names of the form F<num> are usurped by Emacs");
1912 fset_name (f
, name
);
1913 update_mode_lines
= 1;
1917 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
1919 register Lisp_Object old_alist_elt
;
1921 /* The buffer-list parameters are stored in a special place and not
1922 in the alist. All buffers must be live. */
1923 if (EQ (prop
, Qbuffer_list
))
1925 Lisp_Object list
= Qnil
;
1926 for (; CONSP (val
); val
= XCDR (val
))
1927 if (!NILP (Fbuffer_live_p (XCAR (val
))))
1928 list
= Fcons (XCAR (val
), list
);
1929 fset_buffer_list (f
, Fnreverse (list
));
1932 if (EQ (prop
, Qburied_buffer_list
))
1934 Lisp_Object list
= Qnil
;
1935 for (; CONSP (val
); val
= XCDR (val
))
1936 if (!NILP (Fbuffer_live_p (XCAR (val
))))
1937 list
= Fcons (XCAR (val
), list
);
1938 fset_buried_buffer_list (f
, Fnreverse (list
));
1942 /* If PROP is a symbol which is supposed to have frame-local values,
1943 and it is set up based on this frame, switch to the global
1944 binding. That way, we can create or alter the frame-local binding
1945 without messing up the symbol's status. */
1948 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
1950 switch (sym
->redirect
)
1952 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
1953 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
1954 case SYMBOL_LOCALIZED
:
1955 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
1956 if (blv
->frame_local
&& blv_found (blv
) && XFRAME (blv
->where
) == f
)
1957 swap_in_global_binding (sym
);
1960 default: emacs_abort ();
1964 /* The tty color needed to be set before the frame's parameter
1965 alist was updated with the new value. This is not true any more,
1966 but we still do this test early on. */
1967 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
1968 && f
== FRAME_TTY (f
)->previous_frame
)
1969 /* Force redisplay of this tty. */
1970 FRAME_TTY (f
)->previous_frame
= NULL
;
1972 /* Update the frame parameter alist. */
1973 old_alist_elt
= Fassq (prop
, f
->param_alist
);
1974 if (EQ (old_alist_elt
, Qnil
))
1975 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
1977 Fsetcdr (old_alist_elt
, val
);
1979 /* Update some other special parameters in their special places
1980 in addition to the alist. */
1982 if (EQ (prop
, Qbuffer_predicate
))
1983 fset_buffer_predicate (f
, val
);
1985 if (! FRAME_WINDOW_P (f
))
1987 if (EQ (prop
, Qmenu_bar_lines
))
1988 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
1989 else if (EQ (prop
, Qname
))
1990 set_term_frame_name (f
, val
);
1993 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
1995 if (! MINI_WINDOW_P (XWINDOW (val
)))
1996 error ("Surrogate minibuffer windows must be minibuffer windows");
1998 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
1999 && !EQ (val
, f
->minibuffer_window
))
2000 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2002 /* Install the chosen minibuffer window, with proper buffer. */
2003 fset_minibuffer_window (f
, val
);
2007 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2008 doc
: /* Return the parameters-alist of frame FRAME.
2009 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2010 The meaningful PARMs depend on the kind of frame.
2011 If FRAME is omitted or nil, return information on the currently selected frame. */)
2015 struct frame
*f
= decode_any_frame (frame
);
2017 struct gcpro gcpro1
;
2019 if (!FRAME_LIVE_P (f
))
2022 alist
= Fcopy_alist (f
->param_alist
);
2025 if (!FRAME_WINDOW_P (f
))
2027 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2028 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2031 /* If the frame's parameter alist says the colors are
2032 unspecified and reversed, take the frame's background pixel
2033 for foreground and vice versa. */
2034 elt
= Fassq (Qforeground_color
, alist
);
2035 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2037 if (strncmp (SSDATA (XCDR (elt
)),
2039 SCHARS (XCDR (elt
))) == 0)
2040 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2041 else if (strncmp (SSDATA (XCDR (elt
)),
2043 SCHARS (XCDR (elt
))) == 0)
2044 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2047 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2048 elt
= Fassq (Qbackground_color
, alist
);
2049 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2051 if (strncmp (SSDATA (XCDR (elt
)),
2053 SCHARS (XCDR (elt
))) == 0)
2054 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2055 else if (strncmp (SSDATA (XCDR (elt
)),
2057 SCHARS (XCDR (elt
))) == 0)
2058 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2061 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2062 store_in_alist (&alist
, intern ("font"),
2063 build_string (FRAME_MSDOS_P (f
)
2065 : FRAME_W32_P (f
) ? "w32term"
2068 store_in_alist (&alist
, Qname
, f
->name
);
2069 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2070 store_in_alist (&alist
, Qheight
, make_number (height
));
2071 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2072 store_in_alist (&alist
, Qwidth
, make_number (width
));
2073 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2074 store_in_alist (&alist
, Qminibuffer
,
2075 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2076 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2077 : FRAME_MINIBUF_WINDOW (f
)));
2078 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2079 store_in_alist (&alist
, Qbuffer_list
, f
->buffer_list
);
2080 store_in_alist (&alist
, Qburied_buffer_list
, f
->buried_buffer_list
);
2082 /* I think this should be done with a hook. */
2083 #ifdef HAVE_WINDOW_SYSTEM
2084 if (FRAME_WINDOW_P (f
))
2085 x_report_frame_params (f
, &alist
);
2089 /* This ought to be correct in f->param_alist for an X frame. */
2091 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2092 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2100 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2101 doc
: /* Return FRAME's value for parameter PARAMETER.
2102 If FRAME is nil, describe the currently selected frame. */)
2103 (Lisp_Object frame
, Lisp_Object parameter
)
2105 struct frame
*f
= decode_any_frame (frame
);
2106 Lisp_Object value
= Qnil
;
2108 CHECK_SYMBOL (parameter
);
2110 XSETFRAME (frame
, f
);
2112 if (FRAME_LIVE_P (f
))
2114 /* Avoid consing in frequent cases. */
2115 if (EQ (parameter
, Qname
))
2117 #ifdef HAVE_X_WINDOWS
2118 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2119 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2120 #endif /* HAVE_X_WINDOWS */
2121 else if (EQ (parameter
, Qbackground_color
)
2122 || EQ (parameter
, Qforeground_color
))
2124 value
= Fassq (parameter
, f
->param_alist
);
2127 value
= XCDR (value
);
2128 /* Fframe_parameters puts the actual fg/bg color names,
2129 even if f->param_alist says otherwise. This is
2130 important when param_alist's notion of colors is
2131 "unspecified". We need to do the same here. */
2132 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2134 const char *color_name
;
2137 if (EQ (parameter
, Qbackground_color
))
2139 color_name
= SSDATA (value
);
2140 csz
= SCHARS (value
);
2141 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2142 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2143 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2144 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2146 else if (EQ (parameter
, Qforeground_color
))
2148 color_name
= SSDATA (value
);
2149 csz
= SCHARS (value
);
2150 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2151 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2152 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2153 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2158 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2160 else if (EQ (parameter
, Qdisplay_type
)
2161 || EQ (parameter
, Qbackground_mode
))
2162 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2164 /* FIXME: Avoid this code path at all (as well as code duplication)
2165 by sharing more code with Fframe_parameters. */
2166 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2173 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2174 Smodify_frame_parameters
, 2, 2, 0,
2175 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2176 If FRAME is nil, it defaults to the selected frame.
2177 ALIST is an alist of parameters to change and their new values.
2178 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2179 The meaningful PARMs depend on the kind of frame.
2180 Undefined PARMs are ignored, but stored in the frame's parameter list
2181 so that `frame-parameters' will return them.
2183 The value of frame parameter FOO can also be accessed
2184 as a frame-local binding for the variable FOO, if you have
2185 enabled such bindings for that variable with `make-variable-frame-local'.
2186 Note that this functionality is obsolete as of Emacs 22.2, and its
2187 use is not recommended. Explicitly check for a frame-parameter instead. */)
2188 (Lisp_Object frame
, Lisp_Object alist
)
2190 struct frame
*f
= decode_live_frame (frame
);
2191 register Lisp_Object tail
, prop
, val
;
2193 /* I think this should be done with a hook. */
2194 #ifdef HAVE_WINDOW_SYSTEM
2195 if (FRAME_WINDOW_P (f
))
2196 x_set_frame_parameters (f
, alist
);
2200 if (FRAME_MSDOS_P (f
))
2201 IT_set_frame_parameters (f
, alist
);
2206 EMACS_INT length
= XFASTINT (Flength (alist
));
2209 Lisp_Object
*values
;
2211 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2212 values
= parms
+ length
;
2214 /* Extract parm names and values into those vectors. */
2217 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2222 parms
[i
] = Fcar (elt
);
2223 values
[i
] = Fcdr (elt
);
2227 /* Now process them in reverse of specified order. */
2232 store_frame_param (f
, prop
, val
);
2234 if (EQ (prop
, Qforeground_color
)
2235 || EQ (prop
, Qbackground_color
))
2236 update_face_from_frame_parameter (f
, prop
, val
);
2244 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2246 doc
: /* Height in pixels of a line in the font in frame FRAME.
2247 If FRAME is omitted or nil, the selected frame is used.
2248 For a terminal frame, the value is always 1. */)
2251 #ifdef HAVE_WINDOW_SYSTEM
2252 struct frame
*f
= decode_any_frame (frame
);
2254 if (FRAME_WINDOW_P (f
))
2255 return make_number (FRAME_LINE_HEIGHT (f
));
2258 return make_number (1);
2262 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2264 doc
: /* Width in pixels of characters in the font in frame FRAME.
2265 If FRAME is omitted or nil, the selected frame is used.
2266 On a graphical screen, the width is the standard width of the default font.
2267 For a terminal screen, the value is always 1. */)
2270 #ifdef HAVE_WINDOW_SYSTEM
2271 struct frame
*f
= decode_any_frame (frame
);
2273 if (FRAME_WINDOW_P (f
))
2274 return make_number (FRAME_COLUMN_WIDTH (f
));
2277 return make_number (1);
2280 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2281 Sframe_pixel_height
, 0, 1, 0,
2282 doc
: /* Return a FRAME's height in pixels.
2283 If FRAME is omitted or nil, the selected frame is used. The exact value
2284 of the result depends on the window-system and toolkit in use:
2286 In the Gtk+ version of Emacs, it includes only any window (including
2287 the minibuffer or echo area), mode line, and header line. It does not
2288 include the tool bar or menu bar.
2290 With other graphical versions, it also includes the tool bar and the
2293 For a text terminal, it includes the menu bar. In this case, the
2294 result is really in characters rather than pixels (i.e., is identical
2295 to `frame-height'). */)
2298 struct frame
*f
= decode_any_frame (frame
);
2300 #ifdef HAVE_WINDOW_SYSTEM
2301 if (FRAME_WINDOW_P (f
))
2302 return make_number (x_pixel_height (f
));
2305 return make_number (FRAME_LINES (f
));
2308 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2309 Sframe_pixel_width
, 0, 1, 0,
2310 doc
: /* Return FRAME's width in pixels.
2311 For a terminal frame, the result really gives the width in characters.
2312 If FRAME is omitted or nil, the selected frame is used. */)
2315 struct frame
*f
= decode_any_frame (frame
);
2317 #ifdef HAVE_WINDOW_SYSTEM
2318 if (FRAME_WINDOW_P (f
))
2319 return make_number (x_pixel_width (f
));
2322 return make_number (FRAME_COLS (f
));
2325 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2326 Stool_bar_pixel_width
, 0, 1, 0,
2327 doc
: /* Return width in pixels of FRAME's tool bar.
2328 The result is greater than zero only when the tool bar is on the left
2329 or right side of FRAME. If FRAME is omitted or nil, the selected frame
2333 #ifdef FRAME_TOOLBAR_WIDTH
2334 struct frame
*f
= decode_any_frame (frame
);
2336 if (FRAME_WINDOW_P (f
))
2337 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2339 return make_number (0);
2342 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2343 doc
: /* Specify that the frame FRAME has LINES lines.
2344 Optional third arg non-nil means that redisplay should use LINES lines
2345 but that the idea of the actual height of the frame should not be changed. */)
2346 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2348 register struct frame
*f
= decode_live_frame (frame
);
2350 CHECK_TYPE_RANGED_INTEGER (int, lines
);
2352 /* I think this should be done with a hook. */
2353 #ifdef HAVE_WINDOW_SYSTEM
2354 if (FRAME_WINDOW_P (f
))
2356 if (XINT (lines
) != FRAME_LINES (f
))
2357 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2358 do_pending_window_change (0);
2362 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2366 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2367 doc
: /* Specify that the frame FRAME has COLS columns.
2368 Optional third arg non-nil means that redisplay should use COLS columns
2369 but that the idea of the actual width of the frame should not be changed. */)
2370 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2372 register struct frame
*f
= decode_live_frame (frame
);
2374 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2376 /* I think this should be done with a hook. */
2377 #ifdef HAVE_WINDOW_SYSTEM
2378 if (FRAME_WINDOW_P (f
))
2380 if (XINT (cols
) != FRAME_COLS (f
))
2381 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2382 do_pending_window_change (0);
2386 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2390 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2391 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2392 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2394 register struct frame
*f
;
2396 CHECK_LIVE_FRAME (frame
);
2397 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2398 CHECK_TYPE_RANGED_INTEGER (int, rows
);
2401 /* I think this should be done with a hook. */
2402 #ifdef HAVE_WINDOW_SYSTEM
2403 if (FRAME_WINDOW_P (f
))
2405 if (XINT (rows
) != FRAME_LINES (f
)
2406 || XINT (cols
) != FRAME_COLS (f
)
2407 || f
->new_text_lines
|| f
->new_text_cols
)
2408 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2409 do_pending_window_change (0);
2413 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2418 DEFUN ("set-frame-position", Fset_frame_position
,
2419 Sset_frame_position
, 3, 3, 0,
2420 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2421 This is actually the position of the upper left corner of the frame.
2422 Negative values for XOFFSET or YOFFSET are interpreted relative to
2423 the rightmost or bottommost possible position (that stays within the screen). */)
2424 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2426 register struct frame
*f
;
2428 CHECK_LIVE_FRAME (frame
);
2429 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2430 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2433 /* I think this should be done with a hook. */
2434 #ifdef HAVE_WINDOW_SYSTEM
2435 if (FRAME_WINDOW_P (f
))
2436 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2443 /***********************************************************************
2445 ***********************************************************************/
2447 /* Connect the frame-parameter names for X frames
2448 to the ways of passing the parameter values to the window system.
2450 The name of a parameter, as a Lisp symbol,
2451 has an `x-frame-parameter' property which is an integer in Lisp
2452 that is an index in this table. */
2454 struct frame_parm_table
{
2456 Lisp_Object
*variable
;
2459 static const struct frame_parm_table frame_parms
[] =
2461 {"auto-raise", &Qauto_raise
},
2462 {"auto-lower", &Qauto_lower
},
2463 {"background-color", 0},
2464 {"border-color", &Qborder_color
},
2465 {"border-width", &Qborder_width
},
2466 {"cursor-color", &Qcursor_color
},
2467 {"cursor-type", &Qcursor_type
},
2469 {"foreground-color", 0},
2470 {"icon-name", &Qicon_name
},
2471 {"icon-type", &Qicon_type
},
2472 {"internal-border-width", &Qinternal_border_width
},
2473 {"menu-bar-lines", &Qmenu_bar_lines
},
2474 {"mouse-color", &Qmouse_color
},
2476 {"scroll-bar-width", &Qscroll_bar_width
},
2478 {"unsplittable", &Qunsplittable
},
2479 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2480 {"visibility", &Qvisibility
},
2481 {"tool-bar-lines", &Qtool_bar_lines
},
2482 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2483 {"scroll-bar-background", &Qscroll_bar_background
},
2484 {"screen-gamma", &Qscreen_gamma
},
2485 {"line-spacing", &Qline_spacing
},
2486 {"left-fringe", &Qleft_fringe
},
2487 {"right-fringe", &Qright_fringe
},
2488 {"wait-for-wm", &Qwait_for_wm
},
2489 {"fullscreen", &Qfullscreen
},
2490 {"font-backend", &Qfont_backend
},
2492 {"sticky", &Qsticky
},
2493 {"tool-bar-position", &Qtool_bar_position
},
2498 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2499 wanted positions of the WM window (not Emacs window).
2500 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2501 window (FRAME_X_WINDOW).
2505 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2507 int newwidth
= FRAME_COLS (f
);
2508 int newheight
= FRAME_LINES (f
);
2509 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2511 *top_pos
= f
->top_pos
;
2512 *left_pos
= f
->left_pos
;
2514 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2518 ph
= x_display_pixel_height (dpyinfo
);
2519 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2520 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2521 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2525 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2529 pw
= x_display_pixel_width (dpyinfo
);
2530 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2531 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2532 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2537 *height
= newheight
;
2540 #endif /* HAVE_NTGUI */
2542 #ifdef HAVE_WINDOW_SYSTEM
2544 /* Change the parameters of frame F as specified by ALIST.
2545 If a parameter is not specially recognized, do nothing special;
2546 otherwise call the `x_set_...' function for that parameter.
2547 Except for certain geometry properties, always call store_frame_param
2548 to store the new value in the parameter alist. */
2551 x_set_frame_parameters (FRAME_PTR f
, Lisp_Object alist
)
2555 /* If both of these parameters are present, it's more efficient to
2556 set them both at once. So we wait until we've looked at the
2557 entire list before we set them. */
2561 Lisp_Object left
, top
;
2563 /* Same with these. */
2564 Lisp_Object icon_left
, icon_top
;
2566 /* Record in these vectors all the parms specified. */
2568 Lisp_Object
*values
;
2570 int left_no_change
= 0, top_no_change
= 0;
2571 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2572 int size_changed
= 0;
2573 struct gcpro gcpro1
, gcpro2
;
2576 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2579 parms
= alloca (i
* sizeof *parms
);
2580 values
= alloca (i
* sizeof *values
);
2582 /* Extract parm names and values into those vectors. */
2585 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2590 parms
[i
] = Fcar (elt
);
2591 values
[i
] = Fcdr (elt
);
2594 /* TAIL and ALIST are not used again below here. */
2595 alist
= tail
= Qnil
;
2597 GCPRO2 (*parms
, *values
);
2601 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2602 because their values appear in VALUES and strings are not valid. */
2603 top
= left
= Qunbound
;
2604 icon_left
= icon_top
= Qunbound
;
2606 /* Provide default values for HEIGHT and WIDTH. */
2607 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2608 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2610 /* Process foreground_color and background_color before anything else.
2611 They are independent of other properties, but other properties (e.g.,
2612 cursor_color) are dependent upon them. */
2613 /* Process default font as well, since fringe widths depends on it. */
2614 for (p
= 0; p
< i
; p
++)
2616 Lisp_Object prop
, val
;
2620 if (EQ (prop
, Qforeground_color
)
2621 || EQ (prop
, Qbackground_color
)
2622 || EQ (prop
, Qfont
))
2624 register Lisp_Object param_index
, old_value
;
2626 old_value
= get_frame_param (f
, prop
);
2627 if (NILP (Fequal (val
, old_value
)))
2629 store_frame_param (f
, prop
, val
);
2631 param_index
= Fget (prop
, Qx_frame_parameter
);
2632 if (NATNUMP (param_index
)
2633 && (XFASTINT (param_index
)
2634 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2635 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2636 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2641 /* Now process them in reverse of specified order. */
2644 Lisp_Object prop
, val
;
2649 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2652 width
= XFASTINT (val
);
2654 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2657 height
= XFASTINT (val
);
2659 else if (EQ (prop
, Qtop
))
2661 else if (EQ (prop
, Qleft
))
2663 else if (EQ (prop
, Qicon_top
))
2665 else if (EQ (prop
, Qicon_left
))
2667 else if (EQ (prop
, Qforeground_color
)
2668 || EQ (prop
, Qbackground_color
)
2669 || EQ (prop
, Qfont
))
2670 /* Processed above. */
2674 register Lisp_Object param_index
, old_value
;
2676 old_value
= get_frame_param (f
, prop
);
2678 store_frame_param (f
, prop
, val
);
2680 param_index
= Fget (prop
, Qx_frame_parameter
);
2681 if (NATNUMP (param_index
)
2682 && (XFASTINT (param_index
)
2683 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2684 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2685 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2689 /* Don't die if just one of these was set. */
2690 if (EQ (left
, Qunbound
))
2693 if (f
->left_pos
< 0)
2694 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2696 XSETINT (left
, f
->left_pos
);
2698 if (EQ (top
, Qunbound
))
2702 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2704 XSETINT (top
, f
->top_pos
);
2707 /* If one of the icon positions was not set, preserve or default it. */
2708 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
2710 icon_left_no_change
= 1;
2711 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2712 if (NILP (icon_left
))
2713 XSETINT (icon_left
, 0);
2715 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
2717 icon_top_no_change
= 1;
2718 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2719 if (NILP (icon_top
))
2720 XSETINT (icon_top
, 0);
2723 /* Don't set these parameters unless they've been explicitly
2724 specified. The window might be mapped or resized while we're in
2725 this function, and we don't want to override that unless the lisp
2726 code has asked for it.
2728 Don't set these parameters unless they actually differ from the
2729 window's current parameters; the window may not actually exist
2734 check_frame_size (f
, &height
, &width
);
2736 XSETFRAME (frame
, f
);
2739 && (width
!= FRAME_COLS (f
)
2740 || height
!= FRAME_LINES (f
)
2741 || f
->new_text_lines
|| f
->new_text_cols
))
2742 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2744 if ((!NILP (left
) || !NILP (top
))
2745 && ! (left_no_change
&& top_no_change
)
2746 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2747 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2752 /* Record the signs. */
2753 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2754 if (EQ (left
, Qminus
))
2755 f
->size_hint_flags
|= XNegative
;
2756 else if (TYPE_RANGED_INTEGERP (int, left
))
2758 leftpos
= XINT (left
);
2760 f
->size_hint_flags
|= XNegative
;
2762 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2763 && CONSP (XCDR (left
))
2764 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
2766 leftpos
= - XINT (XCAR (XCDR (left
)));
2767 f
->size_hint_flags
|= XNegative
;
2769 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2770 && CONSP (XCDR (left
))
2771 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
2773 leftpos
= XINT (XCAR (XCDR (left
)));
2776 if (EQ (top
, Qminus
))
2777 f
->size_hint_flags
|= YNegative
;
2778 else if (TYPE_RANGED_INTEGERP (int, top
))
2780 toppos
= XINT (top
);
2782 f
->size_hint_flags
|= YNegative
;
2784 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2785 && CONSP (XCDR (top
))
2786 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
2788 toppos
= - XINT (XCAR (XCDR (top
)));
2789 f
->size_hint_flags
|= YNegative
;
2791 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2792 && CONSP (XCDR (top
))
2793 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
2795 toppos
= XINT (XCAR (XCDR (top
)));
2799 /* Store the numeric value of the position. */
2800 f
->top_pos
= toppos
;
2801 f
->left_pos
= leftpos
;
2803 f
->win_gravity
= NorthWestGravity
;
2805 /* Actually set that position, and convert to absolute. */
2806 x_set_offset (f
, leftpos
, toppos
, -1);
2809 if ((!NILP (icon_left
) || !NILP (icon_top
))
2810 && ! (icon_left_no_change
&& icon_top_no_change
))
2811 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2818 /* Insert a description of internally-recorded parameters of frame X
2819 into the parameter alist *ALISTPTR that is to be given to the user.
2820 Only parameters that are specific to the X window system
2821 and whose values are not correctly recorded in the frame's
2822 param_alist need to be considered here. */
2825 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
2829 char buf
[INT_BUFSIZE_BOUND (w
)];
2831 /* Represent negative positions (off the top or left screen edge)
2832 in a way that Fmodify_frame_parameters will understand correctly. */
2833 XSETINT (tem
, f
->left_pos
);
2834 if (f
->left_pos
>= 0)
2835 store_in_alist (alistptr
, Qleft
, tem
);
2837 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2839 XSETINT (tem
, f
->top_pos
);
2840 if (f
->top_pos
>= 0)
2841 store_in_alist (alistptr
, Qtop
, tem
);
2843 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2845 store_in_alist (alistptr
, Qborder_width
,
2846 make_number (f
->border_width
));
2847 store_in_alist (alistptr
, Qinternal_border_width
,
2848 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
2849 store_in_alist (alistptr
, Qleft_fringe
,
2850 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
2851 store_in_alist (alistptr
, Qright_fringe
,
2852 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
2853 store_in_alist (alistptr
, Qscroll_bar_width
,
2854 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2856 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
2857 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
2858 /* nil means "use default width"
2859 for non-toolkit scroll bar.
2860 ruler-mode.el depends on this. */
2862 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
2863 MS-Windows it returns a value whose type is HANDLE, which is
2864 actually a pointer. Explicit casting avoids compiler
2866 w
= (uintptr_t) FRAME_X_WINDOW (f
);
2867 store_in_alist (alistptr
, Qwindow_id
,
2868 make_formatted_string (buf
, "%"pMu
, w
));
2869 #ifdef HAVE_X_WINDOWS
2870 #ifdef USE_X_TOOLKIT
2871 /* Tooltip frame may not have this widget. */
2872 if (FRAME_X_OUTPUT (f
)->widget
)
2874 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
2875 store_in_alist (alistptr
, Qouter_window_id
,
2876 make_formatted_string (buf
, "%"pMu
, w
));
2878 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
2879 store_in_alist (alistptr
, Qvisibility
,
2880 (FRAME_VISIBLE_P (f
) ? Qt
2881 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
2882 store_in_alist (alistptr
, Qdisplay
,
2883 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
2885 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
2888 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
2889 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
2890 store_in_alist (alistptr
, Qparent_id
, tem
);
2891 store_in_alist (alistptr
, Qtool_bar_position
, f
->tool_bar_position
);
2895 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
2896 the previous value of that parameter, NEW_VALUE is the new value. */
2899 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
2901 if (NILP (new_value
))
2902 f
->want_fullscreen
= FULLSCREEN_NONE
;
2903 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
2904 f
->want_fullscreen
= FULLSCREEN_BOTH
;
2905 else if (EQ (new_value
, Qfullwidth
))
2906 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
2907 else if (EQ (new_value
, Qfullheight
))
2908 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
2909 else if (EQ (new_value
, Qmaximized
))
2910 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
2912 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
2913 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
2917 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
2918 the previous value of that parameter, NEW_VALUE is the new value. */
2921 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
2923 if (NILP (new_value
))
2924 f
->extra_line_spacing
= 0;
2925 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
2926 f
->extra_line_spacing
= XFASTINT (new_value
);
2928 signal_error ("Invalid line-spacing", new_value
);
2929 if (FRAME_VISIBLE_P (f
))
2934 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
2935 the previous value of that parameter, NEW_VALUE is the new value. */
2938 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
2940 Lisp_Object bgcolor
;
2942 if (NILP (new_value
))
2944 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
2945 /* The value 0.4545 is the normal viewing gamma. */
2946 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
2948 signal_error ("Invalid screen-gamma", new_value
);
2950 /* Apply the new gamma value to the frame background. */
2951 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
2952 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
2954 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
2955 if (NATNUMP (parm_index
)
2956 && (XFASTINT (parm_index
)
2957 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2958 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
2959 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
2963 Fclear_face_cache (Qnil
);
2968 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
2970 Lisp_Object font_object
;
2972 #ifdef HAVE_X_WINDOWS
2973 Lisp_Object font_param
= arg
;
2976 /* Set the frame parameter back to the old value because we may
2977 fail to use ARG as the new parameter value. */
2978 store_frame_param (f
, Qfont
, oldval
);
2980 /* ARG is a fontset name, a font name, a cons of fontset name and a
2981 font object, or a font object. In the last case, this function
2985 fontset
= fs_query_fontset (arg
, 0);
2988 font_object
= font_open_by_name (f
, arg
);
2989 if (NILP (font_object
))
2990 error ("Font `%s' is not defined", SSDATA (arg
));
2991 arg
= AREF (font_object
, FONT_NAME_INDEX
);
2993 else if (fontset
> 0)
2995 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
2996 if (NILP (font_object
))
2997 error ("Font `%s' is not defined", SDATA (arg
));
2998 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3001 error ("The default fontset can't be used for a frame font");
3003 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3005 /* This is the case that the ASCII font of F's fontset XCAR
3006 (arg) is changed to the font XCDR (arg) by
3007 `set-fontset-font'. */
3008 fontset
= fs_query_fontset (XCAR (arg
), 0);
3010 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3011 font_object
= XCDR (arg
);
3012 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3013 #ifdef HAVE_X_WINDOWS
3014 font_param
= Ffont_get (font_object
, QCname
);
3017 else if (FONT_OBJECT_P (arg
))
3020 #ifdef HAVE_X_WINDOWS
3021 font_param
= Ffont_get (font_object
, QCname
);
3023 /* This is to store the XLFD font name in the frame parameter for
3024 backward compatibility. We should store the font-object
3025 itself in the future. */
3026 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3027 fontset
= FRAME_FONTSET (f
);
3028 /* Check if we can use the current fontset. If not, set FONTSET
3029 to -1 to generate a new fontset from FONT-OBJECT. */
3032 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3033 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3036 signal_error ("Invalid font name", ascii_font
);
3038 if (! font_match_p (spec
, font_object
))
3043 signal_error ("Invalid font", arg
);
3045 if (! NILP (Fequal (font_object
, oldval
)))
3048 x_new_font (f
, font_object
, fontset
);
3049 store_frame_param (f
, Qfont
, arg
);
3050 #ifdef HAVE_X_WINDOWS
3051 store_frame_param (f
, Qfont_param
, font_param
);
3053 /* Recalculate toolbar height. */
3054 f
->n_tool_bar_rows
= 0;
3055 /* Ensure we redraw it. */
3056 clear_current_matrices (f
);
3058 recompute_basic_faces (f
);
3060 do_pending_window_change (0);
3062 /* We used to call face-set-after-frame-default here, but it leads to
3063 recursive calls (since that function can set the `default' face's
3064 font which in turns changes the frame's `font' parameter).
3065 Also I don't know what this call is meant to do, but it seems the
3066 wrong way to do it anyway (it does a lot more work than what seems
3067 reasonable in response to a change to `font'). */
3072 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3074 if (! NILP (new_value
)
3075 && !CONSP (new_value
))
3079 CHECK_STRING (new_value
);
3080 p0
= p1
= SSDATA (new_value
);
3084 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
3086 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3092 while ((c
= *++p1
) && c_isspace (c
));
3096 new_value
= Fnreverse (new_value
);
3099 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3103 free_all_realized_faces (Qnil
);
3105 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3106 if (NILP (new_value
))
3108 if (NILP (old_value
))
3109 error ("No font backend available");
3110 font_update_drivers (f
, old_value
);
3111 error ("None of specified font backends are available");
3113 store_frame_param (f
, Qfont_backend
, new_value
);
3119 XSETFRAME (frame
, f
);
3120 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3121 ++face_change_count
;
3122 ++windows_or_buffers_changed
;
3128 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3130 compute_fringe_widths (f
, 1);
3131 #ifdef HAVE_X_WINDOWS
3132 /* Must adjust this so window managers report correct number of columns. */
3133 if (FRAME_X_WINDOW (f
) != 0)
3134 x_wm_set_size_hint (f
, 0, 0);
3139 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3141 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3143 if (XINT (arg
) == f
->border_width
)
3146 if (FRAME_X_WINDOW (f
) != 0)
3147 error ("Cannot change the border width of a frame");
3149 f
->border_width
= XINT (arg
);
3153 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3155 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3157 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3158 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3159 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3160 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3162 #ifdef USE_X_TOOLKIT
3163 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3164 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3167 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3170 if (FRAME_X_WINDOW (f
) != 0)
3172 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3173 SET_FRAME_GARBAGED (f
);
3174 do_pending_window_change (0);
3177 SET_FRAME_GARBAGED (f
);
3181 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3184 XSETFRAME (frame
, f
);
3187 Fmake_frame_invisible (frame
, Qt
);
3188 else if (EQ (value
, Qicon
))
3189 Ficonify_frame (frame
);
3191 Fmake_frame_visible (frame
);
3195 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3197 f
->auto_raise
= !EQ (Qnil
, arg
);
3201 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3203 f
->auto_lower
= !EQ (Qnil
, arg
);
3207 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3209 f
->no_split
= !NILP (arg
);
3213 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3215 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3216 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3217 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3218 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3220 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3222 ? vertical_scroll_bar_none
3224 ? vertical_scroll_bar_left
3226 ? vertical_scroll_bar_right
3227 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3228 ? vertical_scroll_bar_left
3229 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3230 ? vertical_scroll_bar_right
3231 : vertical_scroll_bar_none
);
3233 /* We set this parameter before creating the X window for the
3234 frame, so we can get the geometry right from the start.
3235 However, if the window hasn't been created yet, we shouldn't
3236 call x_set_window_size. */
3237 if (FRAME_X_WINDOW (f
))
3238 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3239 do_pending_window_change (0);
3244 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3246 int wid
= FRAME_COLUMN_WIDTH (f
);
3250 x_set_scroll_bar_default_width (f
);
3252 if (FRAME_X_WINDOW (f
))
3253 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3254 do_pending_window_change (0);
3256 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3257 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3259 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3260 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3262 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3263 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3264 if (FRAME_X_WINDOW (f
))
3265 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3266 do_pending_window_change (0);
3269 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3270 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3271 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3276 /* Return non-nil if frame F wants a bitmap icon. */
3279 x_icon_type (FRAME_PTR f
)
3283 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3291 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3298 for (i
= 0; i
< 2; i
++)
3311 else if (FLOATP (item
))
3313 alpha
= XFLOAT_DATA (item
);
3314 if (! (0 <= alpha
&& alpha
<= 1.0))
3315 args_out_of_range (make_float (0.0), make_float (1.0));
3317 else if (INTEGERP (item
))
3319 EMACS_INT ialpha
= XINT (item
);
3320 if (! (0 <= ialpha
&& alpha
<= 100))
3321 args_out_of_range (make_number (0), make_number (100));
3322 alpha
= ialpha
/ 100.0;
3325 wrong_type_argument (Qnumberp
, item
);
3329 for (i
= 0; i
< 2; i
++)
3330 f
->alpha
[i
] = newval
[i
];
3332 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3334 x_set_frame_alpha (f
);
3342 /* Subroutines of creating an X frame. */
3344 /* Make sure that Vx_resource_name is set to a reasonable value.
3345 Fix it up, or set it to `emacs' if it is too hopeless. */
3348 validate_x_resource_name (void)
3351 /* Number of valid characters in the resource name. */
3352 ptrdiff_t good_count
= 0;
3353 /* Number of invalid characters in the resource name. */
3354 ptrdiff_t bad_count
= 0;
3358 if (!STRINGP (Vx_resource_class
))
3359 Vx_resource_class
= build_string (EMACS_CLASS
);
3361 if (STRINGP (Vx_resource_name
))
3363 unsigned char *p
= SDATA (Vx_resource_name
);
3365 len
= SBYTES (Vx_resource_name
);
3367 /* Only letters, digits, - and _ are valid in resource names.
3368 Count the valid characters and count the invalid ones. */
3369 for (i
= 0; i
< len
; i
++)
3372 if (! ((c
>= 'a' && c
<= 'z')
3373 || (c
>= 'A' && c
<= 'Z')
3374 || (c
>= '0' && c
<= '9')
3375 || c
== '-' || c
== '_'))
3382 /* Not a string => completely invalid. */
3383 bad_count
= 5, good_count
= 0;
3385 /* If name is valid already, return. */
3389 /* If name is entirely invalid, or nearly so, or is so implausibly
3390 large that alloca might not work, use `emacs'. */
3391 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
3393 Vx_resource_name
= build_string ("emacs");
3397 /* Name is partly valid. Copy it and replace the invalid characters
3398 with underscores. */
3400 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3402 for (i
= 0; i
< len
; i
++)
3404 int c
= SREF (new, i
);
3405 if (! ((c
>= 'a' && c
<= 'z')
3406 || (c
>= 'A' && c
<= 'Z')
3407 || (c
>= '0' && c
<= '9')
3408 || c
== '-' || c
== '_'))
3414 extern char *x_get_string_resource (XrmDatabase
, const char *, const char *);
3415 extern Display_Info
*check_x_display_info (Lisp_Object
);
3418 /* Get specified attribute from resource database RDB.
3419 See Fx_get_resource below for other parameters. */
3422 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3424 register char *value
;
3428 CHECK_STRING (attribute
);
3429 CHECK_STRING (class);
3431 if (!NILP (component
))
3432 CHECK_STRING (component
);
3433 if (!NILP (subclass
))
3434 CHECK_STRING (subclass
);
3435 if (NILP (component
) != NILP (subclass
))
3436 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3438 validate_x_resource_name ();
3440 /* Allocate space for the components, the dots which separate them,
3441 and the final '\0'. Make them big enough for the worst case. */
3442 name_key
= alloca (SBYTES (Vx_resource_name
)
3443 + (STRINGP (component
)
3444 ? SBYTES (component
) : 0)
3445 + SBYTES (attribute
)
3448 class_key
= alloca (SBYTES (Vx_resource_class
)
3450 + (STRINGP (subclass
)
3451 ? SBYTES (subclass
) : 0)
3454 /* Start with emacs.FRAMENAME for the name (the specific one)
3455 and with `Emacs' for the class key (the general one). */
3456 strcpy (name_key
, SSDATA (Vx_resource_name
));
3457 strcpy (class_key
, SSDATA (Vx_resource_class
));
3459 strcat (class_key
, ".");
3460 strcat (class_key
, SSDATA (class));
3462 if (!NILP (component
))
3464 strcat (class_key
, ".");
3465 strcat (class_key
, SSDATA (subclass
));
3467 strcat (name_key
, ".");
3468 strcat (name_key
, SSDATA (component
));
3471 strcat (name_key
, ".");
3472 strcat (name_key
, SSDATA (attribute
));
3474 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3476 if (value
!= (char *) 0 && *value
)
3477 return build_string (value
);
3483 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3484 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3485 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3486 class, where INSTANCE is the name under which Emacs was invoked, or
3487 the name specified by the `-name' or `-rn' command-line arguments.
3489 The optional arguments COMPONENT and SUBCLASS add to the key and the
3490 class, respectively. You must specify both of them or neither.
3491 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3492 and the class is `Emacs.CLASS.SUBCLASS'. */)
3493 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
,
3494 Lisp_Object subclass
)
3496 check_window_system ();
3498 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3499 attribute
, class, component
, subclass
);
3502 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3505 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
,
3506 Lisp_Object
class, Lisp_Object component
,
3507 Lisp_Object subclass
)
3509 return xrdb_get_resource (dpyinfo
->xrdb
,
3510 attribute
, class, component
, subclass
);
3513 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3514 /* Used when C code wants a resource value. */
3515 /* Called from oldXMenu/Create.c. */
3517 x_get_resource_string (const char *attribute
, const char *class)
3520 struct frame
*sf
= SELECTED_FRAME ();
3521 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
3524 /* Allocate space for the components, the dots which separate them,
3525 and the final '\0'. */
3526 char *name_key
= SAFE_ALLOCA (invocation_namelen
+ strlen (attribute
) + 2);
3527 char *class_key
= alloca ((sizeof (EMACS_CLASS
) - 1) + strlen (class) + 2);
3529 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
3530 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3532 result
= x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3533 name_key
, class_key
);
3539 /* Return the value of parameter PARAM.
3541 First search ALIST, then Vdefault_frame_alist, then the X defaults
3542 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3544 Convert the resource to the type specified by desired_type.
3546 If no default is specified, return Qunbound. If you call
3547 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3548 and don't let it get stored in any Lisp-visible variables! */
3551 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3552 const char *attribute
, const char *class, enum resource_types type
)
3554 register Lisp_Object tem
;
3556 tem
= Fassq (param
, alist
);
3560 /* If we find this parm in ALIST, clear it out
3561 so that it won't be "left over" at the end. */
3563 XSETCAR (tem
, Qnil
);
3564 /* In case the parameter appears more than once in the alist,
3566 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3567 if (CONSP (XCAR (tail
))
3568 && EQ (XCAR (XCAR (tail
)), param
))
3569 XSETCAR (XCAR (tail
), Qnil
);
3572 tem
= Fassq (param
, Vdefault_frame_alist
);
3574 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3575 look in the X resources. */
3578 if (attribute
&& dpyinfo
)
3580 tem
= display_x_get_resource (dpyinfo
,
3581 build_string (attribute
),
3582 build_string (class),
3590 case RES_TYPE_NUMBER
:
3591 return make_number (atoi (SSDATA (tem
)));
3593 case RES_TYPE_BOOLEAN_NUMBER
:
3594 if (!strcmp (SSDATA (tem
), "on")
3595 || !strcmp (SSDATA (tem
), "true"))
3596 return make_number (1);
3597 return make_number (atoi (SSDATA (tem
)));
3600 case RES_TYPE_FLOAT
:
3601 return make_float (atof (SSDATA (tem
)));
3603 case RES_TYPE_BOOLEAN
:
3604 tem
= Fdowncase (tem
);
3605 if (!strcmp (SSDATA (tem
), "on")
3607 || !strcmp (SSDATA (tem
), "yes")
3609 || !strcmp (SSDATA (tem
), "true"))
3614 case RES_TYPE_STRING
:
3617 case RES_TYPE_SYMBOL
:
3618 /* As a special case, we map the values `true' and `on'
3619 to Qt, and `false' and `off' to Qnil. */
3622 lower
= Fdowncase (tem
);
3623 if (!strcmp (SSDATA (lower
), "on")
3625 || !strcmp (SSDATA (lower
), "yes")
3627 || !strcmp (SSDATA (lower
), "true"))
3629 else if (!strcmp (SSDATA (lower
), "off")
3631 || !strcmp (SSDATA (lower
), "no")
3633 || !strcmp (SSDATA (lower
), "false"))
3636 return Fintern (tem
, Qnil
);
3650 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3651 const char *attribute
, const char *class,
3652 enum resource_types type
)
3654 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3655 alist
, param
, attribute
, class, type
);
3658 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3661 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3663 const char *attribute
, const char *class,
3664 enum resource_types type
)
3668 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3669 attribute
, class, type
);
3670 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3671 store_frame_param (f
, param
, value
);
3677 /* Record in frame F the specified or default value according to ALIST
3678 of the parameter named PROP (a Lisp symbol).
3679 If no value is specified for PROP, look for an X default for XPROP
3680 on the frame named NAME.
3681 If that is not found either, use the value DEFLT. */
3684 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
3685 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
3686 enum resource_types type
)
3690 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3691 if (EQ (tem
, Qunbound
))
3693 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3698 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
3701 * XParseGeometry parses strings of the form
3702 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
3703 * width, height, xoffset, and yoffset are unsigned integers.
3704 * Example: "=80x24+300-49"
3705 * The equal sign is optional.
3706 * It returns a bitmask that indicates which of the four values
3707 * were actually found in the string. For each value found,
3708 * the corresponding argument is updated; for each value
3709 * not found, the corresponding argument is left unchanged.
3713 XParseGeometry (char *string
,
3715 unsigned int *width
, unsigned int *height
)
3719 unsigned long int tempWidth
, tempHeight
;
3720 long int tempX
, tempY
;
3721 char *nextCharacter
;
3723 if (string
== NULL
|| *string
== '\0')
3726 string
++; /* ignore possible '=' at beg of geometry spec */
3729 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
3731 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
3732 if (strind
== nextCharacter
)
3734 strind
= nextCharacter
;
3738 if (*strind
== 'x' || *strind
== 'X')
3741 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
3742 if (strind
== nextCharacter
)
3744 strind
= nextCharacter
;
3745 mask
|= HeightValue
;
3748 if (*strind
== '+' || *strind
== '-')
3752 tempX
= strtol (strind
, &nextCharacter
, 10);
3753 if (strind
== nextCharacter
)
3755 strind
= nextCharacter
;
3757 if (*strind
== '+' || *strind
== '-')
3761 tempY
= strtol (strind
, &nextCharacter
, 10);
3762 if (strind
== nextCharacter
)
3764 strind
= nextCharacter
;
3769 /* If strind isn't at the end of the string then it's an invalid
3770 geometry specification. */
3772 if (*strind
!= '\0')
3776 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
3778 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
3779 if (mask
& WidthValue
)
3780 *width
= min (tempWidth
, UINT_MAX
);
3781 if (mask
& HeightValue
)
3782 *height
= min (tempHeight
, UINT_MAX
);
3786 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
3789 /* NS used to define x-parse-geometry in ns-win.el, but that confused
3790 make-docfile: the documentation string in ns-win.el was used for
3791 x-parse-geometry even in non-NS builds.
3793 With two definitions of x-parse-geometry in this file, various
3794 things still get confused (eg M-x apropos documentation), so that
3795 it is best if the two definitions just share the same doc-string.
3797 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3798 doc
: /* Parse a display geometry string STRING.
3799 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3800 The properties returned may include `top', `left', `height', and `width'.
3801 For X, the value of `left' or `top' may be an integer,
3802 or a list (+ N) meaning N pixels relative to top/left corner,
3803 or a list (- N) meaning -N pixels relative to bottom/right corner.
3804 On Nextstep, this just calls `ns-parse-geometry'. */)
3805 (Lisp_Object string
)
3808 unsigned int width
, height
;
3811 CHECK_STRING (string
);
3814 if (strchr (SSDATA (string
), ' ') != NULL
)
3815 return call1 (Qns_parse_geometry
, string
);
3817 geometry
= XParseGeometry (SSDATA (string
),
3818 &x
, &y
, &width
, &height
);
3820 if (geometry
& XValue
)
3822 Lisp_Object element
;
3824 if (x
>= 0 && (geometry
& XNegative
))
3825 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3826 else if (x
< 0 && ! (geometry
& XNegative
))
3827 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3829 element
= Fcons (Qleft
, make_number (x
));
3830 result
= Fcons (element
, result
);
3833 if (geometry
& YValue
)
3835 Lisp_Object element
;
3837 if (y
>= 0 && (geometry
& YNegative
))
3838 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3839 else if (y
< 0 && ! (geometry
& YNegative
))
3840 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3842 element
= Fcons (Qtop
, make_number (y
));
3843 result
= Fcons (element
, result
);
3846 if (geometry
& WidthValue
)
3847 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3848 if (geometry
& HeightValue
)
3849 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3855 /* Calculate the desired size and position of frame F.
3856 Return the flags saying which aspects were specified.
3858 Also set the win_gravity and size_hint_flags of F.
3860 Adjust height for toolbar if TOOLBAR_P is 1.
3862 This function does not make the coordinates positive. */
3864 #define DEFAULT_ROWS 35
3865 #define DEFAULT_COLS 80
3868 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, int toolbar_p
)
3870 register Lisp_Object tem0
, tem1
, tem2
;
3871 long window_prompting
= 0;
3872 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3874 /* Default values if we fall through.
3875 Actually, if that happens we should get
3876 window manager prompting. */
3877 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3878 FRAME_LINES (f
) = DEFAULT_ROWS
;
3879 /* Window managers expect that if program-specified
3880 positions are not (0,0), they're intentional, not defaults. */
3884 /* Ensure that old new_text_cols and new_text_lines will not override the
3886 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3887 f
->new_text_cols
= f
->new_text_lines
= 0;
3889 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3890 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3891 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3892 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3894 if (!EQ (tem0
, Qunbound
))
3896 CHECK_NUMBER (tem0
);
3897 if (! (0 <= XINT (tem0
) && XINT (tem0
) <= INT_MAX
))
3898 xsignal1 (Qargs_out_of_range
, tem0
);
3899 FRAME_LINES (f
) = XINT (tem0
);
3901 if (!EQ (tem1
, Qunbound
))
3903 CHECK_NUMBER (tem1
);
3904 if (! (0 <= XINT (tem1
) && XINT (tem1
) <= INT_MAX
))
3905 xsignal1 (Qargs_out_of_range
, tem1
);
3906 SET_FRAME_COLS (f
, XINT (tem1
));
3908 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
3909 window_prompting
|= USSize
;
3911 window_prompting
|= PSize
;
3914 f
->scroll_bar_actual_width
3915 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
3917 /* This used to be done _before_ calling x_figure_window_size, but
3918 since the height is reset here, this was really a no-op. I
3919 assume that moving it here does what Gerd intended (although he
3920 no longer can remember what that was... ++KFS, 2003-03-25. */
3922 /* Add the tool-bar height to the initial frame height so that the
3923 user gets a text display area of the size he specified with -g or
3924 via .Xdefaults. Later changes of the tool-bar height don't
3925 change the frame size. This is done so that users can create
3926 tall Emacs frames without having to guess how tall the tool-bar
3928 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
3930 int margin
, relief
, bar_height
;
3932 relief
= (tool_bar_button_relief
>= 0
3933 ? tool_bar_button_relief
3934 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
3936 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
3937 margin
= XFASTINT (Vtool_bar_button_margin
);
3938 else if (CONSP (Vtool_bar_button_margin
)
3939 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
3940 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
3944 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
3945 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
3948 compute_fringe_widths (f
, 0);
3950 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
3951 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
3953 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
3954 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
3955 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
3956 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3958 if (EQ (tem0
, Qminus
))
3961 window_prompting
|= YNegative
;
3963 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
3964 && CONSP (XCDR (tem0
))
3965 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem0
)), INT_MAX
))
3967 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
3968 window_prompting
|= YNegative
;
3970 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
3971 && CONSP (XCDR (tem0
))
3972 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0
))))
3974 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
3976 else if (EQ (tem0
, Qunbound
))
3980 CHECK_TYPE_RANGED_INTEGER (int, tem0
);
3981 f
->top_pos
= XINT (tem0
);
3983 window_prompting
|= YNegative
;
3986 if (EQ (tem1
, Qminus
))
3989 window_prompting
|= XNegative
;
3991 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
3992 && CONSP (XCDR (tem1
))
3993 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem1
)), INT_MAX
))
3995 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
3996 window_prompting
|= XNegative
;
3998 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
3999 && CONSP (XCDR (tem1
))
4000 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1
))))
4002 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4004 else if (EQ (tem1
, Qunbound
))
4008 CHECK_TYPE_RANGED_INTEGER (int, tem1
);
4009 f
->left_pos
= XINT (tem1
);
4010 if (f
->left_pos
< 0)
4011 window_prompting
|= XNegative
;
4014 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4015 window_prompting
|= USPosition
;
4017 window_prompting
|= PPosition
;
4020 if (window_prompting
& XNegative
)
4022 if (window_prompting
& YNegative
)
4023 f
->win_gravity
= SouthEastGravity
;
4025 f
->win_gravity
= NorthEastGravity
;
4029 if (window_prompting
& YNegative
)
4030 f
->win_gravity
= SouthWestGravity
;
4032 f
->win_gravity
= NorthWestGravity
;
4035 f
->size_hint_flags
= window_prompting
;
4037 return window_prompting
;
4042 #endif /* HAVE_WINDOW_SYSTEM */
4045 frame_make_pointer_invisible (void)
4047 if (! NILP (Vmake_pointer_invisible
))
4050 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4053 f
= SELECTED_FRAME ();
4054 if (f
&& !f
->pointer_invisible
4055 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4058 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4059 f
->pointer_invisible
= 1;
4065 frame_make_pointer_visible (void)
4067 /* We don't check Vmake_pointer_invisible here in case the
4068 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4071 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4074 f
= SELECTED_FRAME ();
4075 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4076 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4078 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4079 f
->pointer_invisible
= 0;
4083 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4084 Sframe_pointer_visible_p
, 0, 1, 0,
4085 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4086 Otherwise it returns nil. FRAME omitted or nil means the
4087 selected frame. This is useful when `make-pointer-invisible' is set. */)
4090 return decode_any_frame (frame
)->pointer_invisible
? Qnil
: Qt
;
4094 /***********************************************************************
4096 ***********************************************************************/
4099 syms_of_frame (void)
4101 DEFSYM (Qframep
, "framep");
4102 DEFSYM (Qframe_live_p
, "frame-live-p");
4103 DEFSYM (Qexplicit_name
, "explicit-name");
4104 DEFSYM (Qheight
, "height");
4105 DEFSYM (Qicon
, "icon");
4106 DEFSYM (Qminibuffer
, "minibuffer");
4107 DEFSYM (Qmodeline
, "modeline");
4108 DEFSYM (Qonly
, "only");
4109 DEFSYM (Qnone
, "none");
4110 DEFSYM (Qwidth
, "width");
4111 DEFSYM (Qgeometry
, "geometry");
4112 DEFSYM (Qicon_left
, "icon-left");
4113 DEFSYM (Qicon_top
, "icon-top");
4114 DEFSYM (Qtooltip
, "tooltip");
4115 DEFSYM (Qleft
, "left");
4116 DEFSYM (Qright
, "right");
4117 DEFSYM (Quser_position
, "user-position");
4118 DEFSYM (Quser_size
, "user-size");
4119 DEFSYM (Qwindow_id
, "window-id");
4120 #ifdef HAVE_X_WINDOWS
4121 DEFSYM (Qouter_window_id
, "outer-window-id");
4123 DEFSYM (Qparent_id
, "parent-id");
4125 DEFSYM (Qw32
, "w32");
4128 DEFSYM (Qvisible
, "visible");
4129 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4130 DEFSYM (Qbuffer_list
, "buffer-list");
4131 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4132 DEFSYM (Qdisplay_type
, "display-type");
4133 DEFSYM (Qbackground_mode
, "background-mode");
4134 DEFSYM (Qnoelisp
, "noelisp");
4135 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4136 DEFSYM (Qtty
, "tty");
4137 DEFSYM (Qtty_type
, "tty-type");
4139 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4141 DEFSYM (Qfullwidth
, "fullwidth");
4142 DEFSYM (Qfullheight
, "fullheight");
4143 DEFSYM (Qfullboth
, "fullboth");
4144 DEFSYM (Qmaximized
, "maximized");
4145 DEFSYM (Qx_resource_name
, "x-resource-name");
4146 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4148 DEFSYM (Qterminal
, "terminal");
4149 DEFSYM (Qterminal_live_p
, "terminal-live-p");
4152 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4158 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4160 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4161 if (frame_parms
[i
].variable
)
4163 *frame_parms
[i
].variable
= v
;
4164 staticpro (frame_parms
[i
].variable
);
4166 Fput (v
, Qx_frame_parameter
, make_number (i
));
4170 #ifdef HAVE_WINDOW_SYSTEM
4171 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4172 doc
: /* The name Emacs uses to look up X resources.
4173 `x-get-resource' uses this as the first component of the instance name
4174 when requesting resource values.
4175 Emacs initially sets `x-resource-name' to the name under which Emacs
4176 was invoked, or to the value specified with the `-name' or `-rn'
4177 switches, if present.
4179 It may be useful to bind this variable locally around a call
4180 to `x-get-resource'. See also the variable `x-resource-class'. */);
4181 Vx_resource_name
= Qnil
;
4183 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4184 doc
: /* The class Emacs uses to look up X resources.
4185 `x-get-resource' uses this as the first component of the instance class
4186 when requesting resource values.
4188 Emacs initially sets `x-resource-class' to "Emacs".
4190 Setting this variable permanently is not a reasonable thing to do,
4191 but binding this variable locally around a call to `x-get-resource'
4192 is a reasonable practice. See also the variable `x-resource-name'. */);
4193 Vx_resource_class
= build_string (EMACS_CLASS
);
4195 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4196 doc
: /* The lower limit of the frame opacity (alpha transparency).
4197 The value should range from 0 (invisible) to 100 (completely opaque).
4198 You can also use a floating number between 0.0 and 1.0.
4199 The default is 20. */);
4200 Vframe_alpha_lower_limit
= make_number (20);
4203 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4204 doc
: /* Alist of default values for frame creation.
4205 These may be set in your init file, like this:
4206 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4207 These override values given in window system configuration data,
4208 including X Windows' defaults database.
4209 For values specific to the first Emacs frame, see `initial-frame-alist'.
4210 For window-system specific values, see `window-system-default-frame-alist'.
4211 For values specific to the separate minibuffer frame, see
4212 `minibuffer-frame-alist'.
4213 The `menu-bar-lines' element of the list controls whether new frames
4214 have menu bars; `menu-bar-mode' works by altering this element.
4215 Setting this variable does not affect existing frames, only new ones. */);
4216 Vdefault_frame_alist
= Qnil
;
4218 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4219 doc
: /* Default position of scroll bars on this window-system. */);
4220 #ifdef HAVE_WINDOW_SYSTEM
4221 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
4222 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4224 Vdefault_frame_scroll_bars
= Qright
;
4226 Vdefault_frame_scroll_bars
= Qleft
;
4229 Vdefault_frame_scroll_bars
= Qnil
;
4232 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
4233 scroll_bar_adjust_thumb_portion_p
,
4234 doc
: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
4235 Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
4236 even if the end of the buffer is shown (i.e. overscrolling).
4237 Set to nil if you want the thumb to be at the bottom when the end of the buffer
4238 is shown. Also, the thumb fills the whole scroll bar when the entire buffer
4239 is visible. In this case you can not overscroll. */);
4240 scroll_bar_adjust_thumb_portion_p
= 1;
4242 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4243 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4245 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4246 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4247 `mouse-position' calls this function, passing its usual return value as
4248 argument, and returns whatever this function returns.
4249 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4250 which need to do mouse handling at the Lisp level. */);
4251 Vmouse_position_function
= Qnil
;
4253 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4254 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4255 If the value is an integer, highlighting is only shown after moving the
4256 mouse, while keyboard input turns off the highlight even when the mouse
4257 is over the clickable text. However, the mouse shape still indicates
4258 when the mouse is over clickable text. */);
4259 Vmouse_highlight
= Qt
;
4261 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4262 doc
: /* If non-nil, make pointer invisible while typing.
4263 The pointer becomes visible again when the mouse is moved. */);
4264 Vmake_pointer_invisible
= Qt
;
4266 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4267 doc
: /* Functions run before deleting a frame.
4268 The functions are run with one arg, the frame to be deleted.
4271 Note that functions in this list may be called just before the frame is
4272 actually deleted, or some time later (or even both when an earlier function
4273 in `delete-frame-functions' (indirectly) calls `delete-frame'
4275 Vdelete_frame_functions
= Qnil
;
4276 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
4278 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4279 doc
: /* Non-nil if Menu-Bar mode is enabled.
4280 See the command `menu-bar-mode' for a description of this minor mode.
4281 Setting this variable directly does not take effect;
4282 either customize it (see the info node `Easy Customization')
4283 or call the function `menu-bar-mode'. */);
4284 Vmenu_bar_mode
= Qt
;
4286 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4287 doc
: /* Non-nil if Tool-Bar mode is enabled.
4288 See the command `tool-bar-mode' for a description of this minor mode.
4289 Setting this variable directly does not take effect;
4290 either customize it (see the info node `Easy Customization')
4291 or call the function `tool-bar-mode'. */);
4292 #ifdef HAVE_WINDOW_SYSTEM
4293 Vtool_bar_mode
= Qt
;
4295 Vtool_bar_mode
= Qnil
;
4298 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4299 doc
: /* Minibufferless frames use this frame's minibuffer.
4301 Emacs cannot create minibufferless frames unless this is set to an
4302 appropriate surrogate.
4304 Emacs consults this variable only when creating minibufferless
4305 frames; once the frame is created, it sticks with its assigned
4306 minibuffer, no matter what this variable is set to. This means that
4307 this variable doesn't necessarily say anything meaningful about the
4308 current set of frames, or where the minibuffer is currently being
4311 This variable is local to the current terminal and cannot be buffer-local. */);
4313 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
4314 doc
: /* Non-nil if window system changes focus when you move the mouse.
4315 You should set this variable to tell Emacs how your window manager
4316 handles focus, since there is no way in general for Emacs to find out
4317 automatically. See also `mouse-autoselect-window'. */);
4318 focus_follows_mouse
= 0;
4320 staticpro (&Vframe_list
);
4323 defsubr (&Sframe_live_p
);
4324 defsubr (&Swindow_system
);
4325 defsubr (&Smake_terminal_frame
);
4326 defsubr (&Shandle_switch_frame
);
4327 defsubr (&Sselect_frame
);
4328 defsubr (&Sselected_frame
);
4329 defsubr (&Sframe_list
);
4330 defsubr (&Snext_frame
);
4331 defsubr (&Sprevious_frame
);
4332 defsubr (&Sdelete_frame
);
4333 defsubr (&Smouse_position
);
4334 defsubr (&Smouse_pixel_position
);
4335 defsubr (&Sset_mouse_position
);
4336 defsubr (&Sset_mouse_pixel_position
);
4338 defsubr (&Sframe_configuration
);
4339 defsubr (&Srestore_frame_configuration
);
4341 defsubr (&Smake_frame_visible
);
4342 defsubr (&Smake_frame_invisible
);
4343 defsubr (&Siconify_frame
);
4344 defsubr (&Sframe_visible_p
);
4345 defsubr (&Svisible_frame_list
);
4346 defsubr (&Sraise_frame
);
4347 defsubr (&Slower_frame
);
4348 defsubr (&Sredirect_frame_focus
);
4349 defsubr (&Sframe_focus
);
4350 defsubr (&Sframe_parameters
);
4351 defsubr (&Sframe_parameter
);
4352 defsubr (&Smodify_frame_parameters
);
4353 defsubr (&Sframe_char_height
);
4354 defsubr (&Sframe_char_width
);
4355 defsubr (&Sframe_pixel_height
);
4356 defsubr (&Sframe_pixel_width
);
4357 defsubr (&Stool_bar_pixel_width
);
4358 defsubr (&Sset_frame_height
);
4359 defsubr (&Sset_frame_width
);
4360 defsubr (&Sset_frame_size
);
4361 defsubr (&Sset_frame_position
);
4362 defsubr (&Sframe_pointer_visible_p
);
4364 #ifdef HAVE_WINDOW_SYSTEM
4365 defsubr (&Sx_get_resource
);
4366 defsubr (&Sx_parse_geometry
);