1 /* Generic frame functions.
3 Copyright (C) 1993-1995, 1997, 1999-2012 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/>. */
28 #include "character.h"
39 /* These help us bind and responding to switch-frame events. */
43 #include "blockinput.h"
45 #include "termhooks.h"
46 #include "dispextern.h"
49 #ifdef HAVE_WINDOW_SYSTEM
58 #ifdef HAVE_WINDOW_SYSTEM
63 Lisp_Object Qns_parse_geometry
;
66 Lisp_Object Qframep
, Qframe_live_p
;
67 Lisp_Object Qicon
, Qmodeline
;
68 Lisp_Object Qonly
, Qnone
;
69 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
, Qns
;
71 Lisp_Object Qdisplay_type
;
72 static Lisp_Object Qbackground_mode
;
75 static Lisp_Object Qx_frame_parameter
;
76 Lisp_Object Qx_resource_name
;
77 Lisp_Object Qterminal
;
78 Lisp_Object Qterminal_live_p
;
80 /* Frame parameters (set or reported). */
82 Lisp_Object Qauto_raise
, Qauto_lower
;
83 Lisp_Object Qborder_color
, Qborder_width
;
84 Lisp_Object Qcursor_color
, Qcursor_type
;
85 static Lisp_Object Qgeometry
; /* Not used */
86 Lisp_Object Qheight
, Qwidth
;
87 Lisp_Object Qleft
, Qright
;
88 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
90 Lisp_Object Qinternal_border_width
;
91 Lisp_Object Qmouse_color
;
92 Lisp_Object Qminibuffer
;
93 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
94 Lisp_Object Qvisibility
;
95 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
96 Lisp_Object Qscreen_gamma
;
97 Lisp_Object Qline_spacing
;
98 static Lisp_Object Quser_position
, Quser_size
;
99 Lisp_Object Qwait_for_wm
;
100 static Lisp_Object Qwindow_id
;
101 #ifdef HAVE_X_WINDOWS
102 static Lisp_Object Qouter_window_id
;
104 Lisp_Object Qparent_id
;
105 Lisp_Object Qtitle
, Qname
;
106 static Lisp_Object Qexplicit_name
;
107 Lisp_Object Qunsplittable
;
108 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
, Qtool_bar_position
;
109 Lisp_Object Qleft_fringe
, Qright_fringe
;
110 Lisp_Object Qbuffer_predicate
;
111 static Lisp_Object Qbuffer_list
, Qburied_buffer_list
;
112 Lisp_Object Qtty_color_mode
;
113 Lisp_Object Qtty
, Qtty_type
;
115 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
117 Lisp_Object Qfont_backend
;
120 Lisp_Object Qface_set_after_frame_default
;
122 static Lisp_Object Qdelete_frame_functions
;
124 #ifdef HAVE_WINDOW_SYSTEM
125 static void x_report_frame_params (struct frame
*, Lisp_Object
*);
130 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
132 struct window
*w
= XWINDOW (window
);
134 w
->last_modified
= 0;
135 WSET (w
, top_line
, make_number (XFASTINT (w
->top_line
) + n
));
136 WSET (w
, total_lines
, make_number (XFASTINT (w
->total_lines
) - n
));
138 /* Handle just the top child in a vertical split. */
139 if (!NILP (w
->vchild
))
140 set_menu_bar_lines_1 (w
->vchild
, n
);
142 /* Adjust all children in a horizontal split. */
143 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
145 w
= XWINDOW (window
);
146 set_menu_bar_lines_1 (window
, n
);
151 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
154 int olines
= FRAME_MENU_BAR_LINES (f
);
156 /* Right now, menu bars don't work properly in minibuf-only frames;
157 most of the commands try to apply themselves to the minibuffer
158 frame itself, and get an error because you can't switch buffers
159 in or split the minibuffer window. */
160 if (FRAME_MINIBUF_ONLY_P (f
))
163 if (TYPE_RANGED_INTEGERP (int, value
))
164 nlines
= XINT (value
);
168 if (nlines
!= olines
)
170 windows_or_buffers_changed
++;
171 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
172 FRAME_MENU_BAR_LINES (f
) = nlines
;
173 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
178 Lisp_Object Vframe_list
;
181 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
182 doc
: /* Return non-nil if OBJECT is a frame.
184 t for a termcap frame (a character-only terminal),
185 'x' for an Emacs frame that is really an X window,
186 'w32' for an Emacs frame that is a window on MS-Windows display,
187 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
188 'pc' for a direct-write MS-DOS frame.
189 See also `frame-live-p'. */)
192 if (!FRAMEP (object
))
194 switch (XFRAME (object
)->output_method
)
196 case output_initial
: /* The initial frame is like a termcap frame. */
199 case output_x_window
:
203 case output_msdos_raw
:
214 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
215 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
216 Value is nil if OBJECT is not a live frame. If object is a live
217 frame, the return value indicates what sort of terminal device it is
218 displayed on. See the documentation of `framep' for possible
222 return ((FRAMEP (object
)
223 && FRAME_LIVE_P (XFRAME (object
)))
228 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
229 doc
: /* The name of the window system that FRAME is displaying through.
230 The value is a symbol:
231 nil for a termcap frame (a character-only terminal),
232 'x' for an Emacs frame that is really an X window,
233 'w32' for an Emacs frame that is a window on MS-Windows display,
234 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
235 'pc' for a direct-write MS-DOS frame.
237 FRAME defaults to the currently selected frame.
239 Use of this function as a predicate is deprecated. Instead,
240 use `display-graphic-p' or any of the other `display-*-p'
241 predicates which report frame's specific UI-related capabilities. */)
246 frame
= selected_frame
;
248 type
= Fframep (frame
);
251 wrong_type_argument (Qframep
, frame
);
260 make_frame (int mini_p
)
263 register struct frame
*f
;
264 register Lisp_Object root_window
;
265 register Lisp_Object mini_window
;
267 f
= allocate_frame ();
268 XSETFRAME (frame
, f
);
270 /* Initialize Lisp data. Note that allocate_frame initializes all
271 Lisp data to nil, so do it only for slots which should not be nil. */
272 FSET (f
, tool_bar_position
, Qtop
);
274 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
275 non-Lisp data, so do it only for slots which should not be zero.
276 To avoid subtle bugs and for the sake of readability, it's better to
277 initialize enum members explicitly even if their values are zero. */
278 f
->wants_modeline
= 1;
280 f
->has_minibuffer
= mini_p
;
281 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
282 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
283 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
284 #ifdef HAVE_WINDOW_SYSTEM
285 f
->want_fullscreen
= FULLSCREEN_NONE
;
288 root_window
= make_window ();
291 mini_window
= make_window ();
292 WSET (XWINDOW (root_window
), next
, mini_window
);
293 WSET (XWINDOW (mini_window
), prev
, root_window
);
294 XWINDOW (mini_window
)->mini
= 1;
295 WSET (XWINDOW (mini_window
), frame
, frame
);
296 FSET (f
, minibuffer_window
, mini_window
);
301 WSET (XWINDOW (root_window
), next
, Qnil
);
302 FSET (f
, minibuffer_window
, Qnil
);
305 WSET (XWINDOW (root_window
), frame
, frame
);
308 just so that there is "something there."
309 Correct size will be set up later with change_frame_size. */
311 SET_FRAME_COLS (f
, 10);
312 FRAME_LINES (f
) = 10;
314 WSET (XWINDOW (root_window
), total_cols
, make_number (10));
315 WSET (XWINDOW (root_window
), total_lines
, make_number (mini_p
? 9 : 10));
319 WSET (XWINDOW (mini_window
), total_cols
, make_number (10));
320 WSET (XWINDOW (mini_window
), top_line
, make_number (9));
321 WSET (XWINDOW (mini_window
), total_lines
, make_number (1));
324 /* Choose a buffer for the frame's root window. */
328 WSET (XWINDOW (root_window
), buffer
, Qt
);
329 buf
= Fcurrent_buffer ();
330 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
331 a space), try to find another one. */
332 if (SREF (Fbuffer_name (buf
), 0) == ' ')
333 buf
= other_buffer_safely (buf
);
335 /* Use set_window_buffer, not Fset_window_buffer, and don't let
336 hooks be run by it. The reason is that the whole frame/window
337 arrangement is not yet fully initialized at this point. Windows
338 don't have the right size, glyph matrices aren't initialized
339 etc. Running Lisp functions at this point surely ends in a
341 set_window_buffer (root_window
, buf
, 0, 0);
342 FSET (f
, buffer_list
, Fcons (buf
, Qnil
));
347 WSET (XWINDOW (mini_window
), buffer
, Qt
);
348 set_window_buffer (mini_window
,
349 (NILP (Vminibuffer_list
)
351 : Fcar (Vminibuffer_list
)),
355 FSET (f
, root_window
, root_window
);
356 FSET (f
, selected_window
, root_window
);
357 /* Make sure this window seems more recently used than
358 a newly-created, never-selected window. */
359 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
364 #ifdef HAVE_WINDOW_SYSTEM
365 /* Make a frame using a separate minibuffer window on another frame.
366 MINI_WINDOW is the minibuffer window to use. nil means use the
367 default (the global minibuffer). */
370 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
372 register struct frame
*f
;
375 if (!NILP (mini_window
))
376 CHECK_LIVE_WINDOW (mini_window
);
378 if (!NILP (mini_window
)
379 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
380 error ("Frame and minibuffer must be on the same terminal");
382 /* Make a frame containing just a root window. */
385 if (NILP (mini_window
))
387 /* Use default-minibuffer-frame if possible. */
388 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
389 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
391 Lisp_Object frame_dummy
;
393 XSETFRAME (frame_dummy
, f
);
394 GCPRO1 (frame_dummy
);
395 /* If there's no minibuffer frame to use, create one. */
396 KSET (kb
, Vdefault_minibuffer_frame
,
397 call1 (intern ("make-initial-minibuffer-frame"), display
));
402 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
405 FSET (f
, minibuffer_window
, mini_window
);
407 /* Make the chosen minibuffer window display the proper minibuffer,
408 unless it is already showing a minibuffer. */
409 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
410 /* Use set_window_buffer instead of Fset_window_buffer (see
411 discussion of bug#11984, bug#12025, bug#12026). */
412 set_window_buffer (mini_window
,
413 (NILP (Vminibuffer_list
)
415 : Fcar (Vminibuffer_list
)), 0, 0);
419 /* Make a frame containing only a minibuffer window. */
422 make_minibuffer_frame (void)
424 /* First make a frame containing just a root window, no minibuffer. */
426 register struct frame
*f
= make_frame (0);
427 register Lisp_Object mini_window
;
428 register Lisp_Object frame
;
430 XSETFRAME (frame
, f
);
435 f
->wants_modeline
= 0;
436 f
->has_minibuffer
= 1;
438 /* Now label the root window as also being the minibuffer.
439 Avoid infinite looping on the window chain by marking next pointer
442 mini_window
= FSET (f
, minibuffer_window
, f
->root_window
);
443 XWINDOW (mini_window
)->mini
= 1;
444 WSET (XWINDOW (mini_window
), next
, Qnil
);
445 WSET (XWINDOW (mini_window
), prev
, Qnil
);
446 WSET (XWINDOW (mini_window
), frame
, frame
);
448 /* Put the proper buffer in that window. */
450 /* Use set_window_buffer instead of Fset_window_buffer (see
451 discussion of bug#11984, bug#12025, bug#12026). */
452 set_window_buffer (mini_window
,
453 (NILP (Vminibuffer_list
)
455 : Fcar (Vminibuffer_list
)), 0, 0);
458 #endif /* HAVE_WINDOW_SYSTEM */
460 /* Construct a frame that refers to a terminal. */
462 static printmax_t tty_frame_count
;
465 make_initial_frame (void)
468 struct terminal
*terminal
;
471 eassert (initial_kboard
);
473 /* The first call must initialize Vframe_list. */
474 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
477 terminal
= init_initial_terminal ();
480 XSETFRAME (frame
, f
);
482 Vframe_list
= Fcons (frame
, Vframe_list
);
485 FSET (f
, name
, build_pure_c_string ("F1"));
488 f
->async_visible
= 1;
490 f
->output_method
= terminal
->type
;
491 f
->terminal
= terminal
;
492 f
->terminal
->reference_count
++;
493 f
->output_data
.nothing
= 0;
495 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
496 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
498 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
499 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
501 /* The default value of menu-bar-mode is t. */
502 set_menu_bar_lines (f
, make_number (1), Qnil
);
505 init_frame_faces (f
);
511 static struct frame
*
512 make_terminal_frame (struct terminal
*terminal
)
514 register struct frame
*f
;
516 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
519 error ("Terminal is not live, can't create new frames on it");
523 XSETFRAME (frame
, f
);
524 Vframe_list
= Fcons (frame
, Vframe_list
);
526 FSET (f
, name
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
528 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
529 f
->async_visible
= 1; /* Don't let visible be cleared later. */
530 f
->terminal
= terminal
;
531 f
->terminal
->reference_count
++;
533 f
->output_data
.tty
->display_info
= &the_only_display_info
;
534 if (!inhibit_window_system
535 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
536 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
537 f
->output_method
= output_msdos_raw
;
539 f
->output_method
= output_termcap
;
540 #else /* not MSDOS */
541 f
->output_method
= output_termcap
;
542 create_tty_output (f
);
543 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
544 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
545 #endif /* not MSDOS */
547 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
548 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
549 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
551 /* Set the top frame to the newly created frame. */
552 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
553 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
554 XFRAME (FRAME_TTY (f
)->top_frame
)->async_visible
= 2; /* obscured */
556 FRAME_TTY (f
)->top_frame
= frame
;
559 init_frame_faces (f
);
564 /* Get a suitable value for frame parameter PARAMETER for a newly
565 created frame, based on (1) the user-supplied frame parameter
566 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
569 get_future_frame_param (Lisp_Object parameter
,
570 Lisp_Object supplied_parms
,
575 result
= Fassq (parameter
, supplied_parms
);
577 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
578 if (NILP (result
) && current_value
!= NULL
)
579 result
= build_string (current_value
);
580 if (!NILP (result
) && !STRINGP (result
))
581 result
= XCDR (result
);
582 if (NILP (result
) || !STRINGP (result
))
588 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
590 doc
: /* Create an additional terminal frame, possibly on another terminal.
591 This function takes one argument, an alist specifying frame parameters.
593 You can create multiple frames on a single text terminal, but only one
594 of them (the selected terminal frame) is actually displayed.
596 In practice, generally you don't need to specify any parameters,
597 except when you want to create a new frame on another terminal.
598 In that case, the `tty' parameter specifies the device file to open,
599 and the `tty-type' parameter specifies the terminal type. Example:
601 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
603 Note that changing the size of one terminal frame automatically
604 affects all frames on the same terminal device. */)
608 struct terminal
*t
= NULL
;
609 Lisp_Object frame
, tem
;
610 struct frame
*sf
= SELECTED_FRAME ();
613 if (sf
->output_method
!= output_msdos_raw
614 && sf
->output_method
!= output_termcap
)
616 #else /* not MSDOS */
618 #ifdef WINDOWSNT /* This should work now! */
619 if (sf
->output_method
!= output_termcap
)
620 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
622 #endif /* not MSDOS */
625 Lisp_Object terminal
;
627 terminal
= Fassq (Qterminal
, parms
);
628 if (!NILP (terminal
))
630 terminal
= XCDR (terminal
);
631 t
= get_terminal (terminal
, 1);
634 if (t
&& t
!= the_only_display_info
.terminal
)
635 /* msdos.c assumes a single tty_display_info object. */
636 error ("Multiple terminals are not supported on this platform");
638 t
= the_only_display_info
.terminal
;
644 char *name
= 0, *type
= 0;
645 Lisp_Object tty
, tty_type
;
647 tty
= get_future_frame_param
648 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
649 ? FRAME_TTY (XFRAME (selected_frame
))->name
653 name
= alloca (SBYTES (tty
) + 1);
654 memcpy (name
, SSDATA (tty
), SBYTES (tty
));
655 name
[SBYTES (tty
)] = 0;
658 tty_type
= get_future_frame_param
659 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
660 ? FRAME_TTY (XFRAME (selected_frame
))->type
662 if (!NILP (tty_type
))
664 type
= alloca (SBYTES (tty_type
) + 1);
665 memcpy (type
, SSDATA (tty_type
), SBYTES (tty_type
));
666 type
[SBYTES (tty_type
)] = 0;
669 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
672 f
= make_terminal_frame (t
);
676 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
677 change_frame_size (f
, height
, width
, 0, 0, 0);
682 XSETFRAME (frame
, f
);
683 Fmodify_frame_parameters (frame
, parms
);
684 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
685 build_string (t
->display_info
.tty
->type
)),
687 if (t
->display_info
.tty
->name
!= NULL
)
688 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
689 build_string (t
->display_info
.tty
->name
)),
692 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
694 /* Make the frame face alist be frame-specific, so that each
695 frame could change its face definitions independently. */
696 FSET (f
, face_alist
, Fcopy_alist (sf
->face_alist
));
697 /* Simple Fcopy_alist isn't enough, because we need the contents of
698 the vectors which are the CDRs of associations in face_alist to
699 be copied as well. */
700 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
701 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
706 /* Perform the switch to frame FRAME.
708 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
711 If TRACK is non-zero and the frame that currently has the focus
712 redirects its focus to the selected frame, redirect that focused
713 frame's focus to FRAME instead.
715 FOR_DELETION non-zero means that the selected frame is being
716 deleted, which includes the possibility that the frame's terminal
719 The value of NORECORD is passed as argument to Fselect_window. */
722 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
724 struct frame
*sf
= SELECTED_FRAME ();
726 /* If FRAME is a switch-frame event, extract the frame we should
729 && EQ (XCAR (frame
), Qswitch_frame
)
730 && CONSP (XCDR (frame
)))
731 frame
= XCAR (XCDR (frame
));
733 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
734 a switch-frame event to arrive after a frame is no longer live,
735 especially when deleting the initial frame during startup. */
737 if (! FRAME_LIVE_P (XFRAME (frame
)))
740 if (sf
== XFRAME (frame
))
743 /* This is too greedy; it causes inappropriate focus redirection
744 that's hard to get rid of. */
746 /* If a frame's focus has been redirected toward the currently
747 selected frame, we should change the redirection to point to the
748 newly selected frame. This means that if the focus is redirected
749 from a minibufferless frame to a surrogate minibuffer frame, we
750 can use `other-window' to switch between all the frames using
751 that minibuffer frame, and the focus redirection will follow us
757 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
761 if (!FRAMEP (XCAR (tail
)))
764 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
766 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
767 Fredirect_frame_focus (XCAR (tail
), frame
);
771 /* Instead, apply it only to the frame we're pointing to. */
772 #ifdef HAVE_WINDOW_SYSTEM
773 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
775 Lisp_Object focus
, xfocus
;
777 xfocus
= x_get_focus_frame (XFRAME (frame
));
780 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
781 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
782 Fredirect_frame_focus (xfocus
, frame
);
785 #endif /* HAVE_X_WINDOWS */
788 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
789 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
791 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
793 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
794 /* Mark previously displayed frame as now obscured. */
795 XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
)->async_visible
= 2;
796 XFRAME (frame
)->async_visible
= 1;
797 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
800 selected_frame
= frame
;
801 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
802 last_nonminibuf_frame
= XFRAME (selected_frame
);
804 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
806 /* We want to make sure that the next event generates a frame-switch
807 event to the appropriate frame. This seems kludgy to me, but
808 before you take it out, make sure that evaluating something like
809 (select-window (frame-root-window (new-frame))) doesn't end up
810 with your typing being interpreted in the new frame instead of
811 the one you're actually typing in. */
812 internal_last_event_frame
= Qnil
;
817 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
818 doc
: /* Select FRAME.
819 Subsequent editing commands apply to its selected window.
820 Optional argument NORECORD means to neither change the order of
821 recently selected windows nor the buffer list.
823 The selection of FRAME lasts until the next time the user does
824 something to select a different frame, or until the next time
825 this function is called. If you are using a window system, the
826 previously selected frame may be restored as the selected frame
827 when returning to the command loop, because it still may have
828 the window system's input focus. On a text terminal, the next
829 redisplay will display FRAME.
831 This function returns FRAME, or nil if FRAME has been deleted. */)
832 (Lisp_Object frame
, Lisp_Object norecord
)
834 return do_switch_frame (frame
, 1, 0, norecord
);
838 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
839 doc
: /* Handle a switch-frame event EVENT.
840 Switch-frame events are usually bound to this function.
841 A switch-frame event tells Emacs that the window manager has requested
842 that the user's events be directed to the frame mentioned in the event.
843 This function selects the selected window of the frame of EVENT.
845 If EVENT is frame object, handle it as if it were a switch-frame event
849 /* Preserve prefix arg that the command loop just cleared. */
850 KSET (current_kboard
, Vprefix_arg
, Vcurrent_prefix_arg
);
851 Frun_hooks (1, &Qmouse_leave_buffer_hook
);
852 return do_switch_frame (event
, 0, 0, Qnil
);
855 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
856 doc
: /* Return the frame that is now selected. */)
859 return selected_frame
;
862 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
864 doc
: /* Return a list of all live frames. */)
868 frames
= Fcopy_sequence (Vframe_list
);
869 #ifdef HAVE_WINDOW_SYSTEM
870 if (FRAMEP (tip_frame
))
871 frames
= Fdelq (tip_frame
, frames
);
876 /* Return the next frame in the frame list after FRAME.
877 If MINIBUF is nil, exclude minibuffer-only frames.
878 If MINIBUF is a window, include only its own frame
879 and any frame now using that window as the minibuffer.
880 If MINIBUF is `visible', include all visible frames.
881 If MINIBUF is 0, include all visible and iconified frames.
882 Otherwise, include all frames. */
885 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
890 /* There must always be at least one frame in Vframe_list. */
891 if (! CONSP (Vframe_list
))
894 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
895 forever. Forestall that. */
896 CHECK_LIVE_FRAME (frame
);
899 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
906 && ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
907 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
908 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
909 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
)))))
911 /* Decide whether this frame is eligible to be returned. */
913 /* If we've looped all the way around without finding any
914 eligible frames, return the original frame. */
918 /* Let minibuf decide if this frame is acceptable. */
921 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
924 else if (EQ (minibuf
, Qvisible
))
926 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
927 if (FRAME_VISIBLE_P (XFRAME (f
)))
930 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
932 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
933 if (FRAME_VISIBLE_P (XFRAME (f
))
934 || FRAME_ICONIFIED_P (XFRAME (f
)))
937 else if (WINDOWP (minibuf
))
939 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
940 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
941 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
942 FRAME_FOCUS_FRAME (XFRAME (f
))))
954 /* Return the previous frame in the frame list before FRAME.
955 If MINIBUF is nil, exclude minibuffer-only frames.
956 If MINIBUF is a window, include only its own frame
957 and any frame now using that window as the minibuffer.
958 If MINIBUF is `visible', include all visible frames.
959 If MINIBUF is 0, include all visible and iconified frames.
960 Otherwise, include all frames. */
963 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
968 /* There must always be at least one frame in Vframe_list. */
969 if (! CONSP (Vframe_list
))
973 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
981 if (EQ (frame
, f
) && !NILP (prev
))
984 if ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
985 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
986 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
987 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
))))
989 /* Decide whether this frame is eligible to be returned,
990 according to minibuf. */
993 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
996 else if (WINDOWP (minibuf
))
998 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
999 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1000 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1001 FRAME_FOCUS_FRAME (XFRAME (f
))))
1004 else if (EQ (minibuf
, Qvisible
))
1006 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1007 if (FRAME_VISIBLE_P (XFRAME (f
)))
1010 else if (XFASTINT (minibuf
) == 0)
1012 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1013 if (FRAME_VISIBLE_P (XFRAME (f
))
1014 || FRAME_ICONIFIED_P (XFRAME (f
)))
1022 /* We've scanned the entire list. */
1024 /* We went through the whole frame list without finding a single
1025 acceptable frame. Return the original frame. */
1028 /* There were no acceptable frames in the list before FRAME; otherwise,
1029 we would have returned directly from the loop. Since PREV is the last
1030 acceptable frame in the list, return it. */
1035 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1036 doc
: /* Return the next frame in the frame list after FRAME.
1037 It considers only frames on the same terminal as FRAME.
1038 By default, skip minibuffer-only frames.
1039 If omitted, FRAME defaults to the selected frame.
1040 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1041 If MINIFRAME is a window, include only its own frame
1042 and any frame now using that window as the minibuffer.
1043 If MINIFRAME is `visible', include all visible frames.
1044 If MINIFRAME is 0, include all visible and iconified frames.
1045 Otherwise, include all frames. */)
1046 (Lisp_Object frame
, Lisp_Object miniframe
)
1049 frame
= selected_frame
;
1051 CHECK_LIVE_FRAME (frame
);
1052 return next_frame (frame
, miniframe
);
1055 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1056 doc
: /* Return the previous frame in the frame list before FRAME.
1057 It considers only frames on the same terminal as FRAME.
1058 By default, skip minibuffer-only frames.
1059 If omitted, FRAME defaults to the selected frame.
1060 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1061 If MINIFRAME is a window, include only its own frame
1062 and any frame now using that window as the minibuffer.
1063 If MINIFRAME is `visible', include all visible frames.
1064 If MINIFRAME is 0, include all visible and iconified frames.
1065 Otherwise, include all frames. */)
1066 (Lisp_Object frame
, Lisp_Object miniframe
)
1069 frame
= selected_frame
;
1070 CHECK_LIVE_FRAME (frame
);
1071 return prev_frame (frame
, miniframe
);
1074 /* Return 1 if it is ok to delete frame F;
1075 0 if all frames aside from F are invisible.
1076 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1079 other_visible_frames (FRAME_PTR f
)
1083 for (frames
= Vframe_list
; CONSP (frames
); frames
= XCDR (frames
))
1085 Lisp_Object
this = XCAR (frames
);
1086 if (f
== XFRAME (this))
1089 /* Verify that we can still talk to the frame's X window,
1090 and note any recent change in visibility. */
1091 #ifdef HAVE_WINDOW_SYSTEM
1092 if (FRAME_WINDOW_P (XFRAME (this)))
1094 x_sync (XFRAME (this));
1095 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1099 if (FRAME_VISIBLE_P (XFRAME (this))
1100 || FRAME_ICONIFIED_P (XFRAME (this))
1101 /* Allow deleting the terminal frame when at least one X
1103 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1109 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1110 unconditionally. x_connection_closed and delete_terminal use
1111 this. Any other value of FORCE implements the semantics
1112 described for Fdelete_frame. */
1114 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1117 struct frame
*sf
= SELECTED_FRAME ();
1120 int minibuffer_selected
, tooltip_frame
;
1122 if (EQ (frame
, Qnil
))
1125 XSETFRAME (frame
, f
);
1129 CHECK_FRAME (frame
);
1133 if (! FRAME_LIVE_P (f
))
1136 if (NILP (force
) && !other_visible_frames (f
))
1137 error ("Attempt to delete the sole visible or iconified frame");
1139 /* x_connection_closed must have set FORCE to `noelisp' in order
1140 to delete the last frame, if it is gone. */
1141 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1142 error ("Attempt to delete the only frame");
1144 /* Does this frame have a minibuffer, and is it the surrogate
1145 minibuffer for any other frame? */
1146 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1150 for (frames
= Vframe_list
;
1152 frames
= XCDR (frames
))
1155 this = XCAR (frames
);
1157 if (! EQ (this, frame
)
1159 WINDOW_FRAME (XWINDOW
1160 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1162 /* If we MUST delete this frame, delete the other first.
1163 But do this only if FORCE equals `noelisp'. */
1164 if (EQ (force
, Qnoelisp
))
1165 delete_frame (this, Qnoelisp
);
1167 error ("Attempt to delete a surrogate minibuffer frame");
1172 tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1174 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1175 frame is a tooltip. FORCE is set to `noelisp' when handling
1176 a disconnect from the terminal, so we don't dare call Lisp
1178 if (NILP (Vrun_hooks
) || tooltip_frame
)
1180 else if (EQ (force
, Qnoelisp
))
1182 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1186 #ifdef HAVE_X_WINDOWS
1187 /* Also, save clipboard to the clipboard manager. */
1188 x_clipboard_manager_save_frame (frame
);
1191 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1194 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1195 if (! FRAME_LIVE_P (f
))
1198 /* At this point, we are committed to deleting the frame.
1199 There is no more chance for errors to prevent it. */
1201 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1203 /* Don't let the frame remain selected. */
1206 Lisp_Object tail
, frame1
;
1208 /* Look for another visible frame on the same terminal. */
1209 frame1
= next_frame (frame
, Qvisible
);
1211 /* If there is none, find *some* other frame. */
1212 if (NILP (frame1
) || EQ (frame1
, frame
))
1214 FOR_EACH_FRAME (tail
, frame1
)
1216 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1218 /* Do not change a text terminal's top-frame. */
1219 struct frame
*f1
= XFRAME (frame1
);
1220 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1222 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1223 if (!EQ (top_frame
, frame
))
1230 #ifdef NS_IMPL_COCOA
1232 /* Under NS, there is no system mechanism for choosing a new
1233 window to get focus -- it is left to application code.
1234 So the portion of THIS application interfacing with NS
1235 needs to know about it. We call Fraise_frame, but the
1236 purpose is really to transfer focus. */
1237 Fraise_frame (frame1
);
1240 do_switch_frame (frame1
, 0, 1, Qnil
);
1241 sf
= SELECTED_FRAME ();
1244 /* Don't allow minibuf_window to remain on a deleted frame. */
1245 if (EQ (f
->minibuffer_window
, minibuf_window
))
1247 /* Use set_window_buffer instead of Fset_window_buffer (see
1248 discussion of bug#11984, bug#12025, bug#12026). */
1249 set_window_buffer (sf
->minibuffer_window
,
1250 XWINDOW (minibuf_window
)->buffer
, 0, 0);
1251 minibuf_window
= sf
->minibuffer_window
;
1253 /* If the dying minibuffer window was selected,
1254 select the new one. */
1255 if (minibuffer_selected
)
1256 Fselect_window (minibuf_window
, Qnil
);
1259 /* Don't let echo_area_window to remain on a deleted frame. */
1260 if (EQ (f
->minibuffer_window
, echo_area_window
))
1261 echo_area_window
= sf
->minibuffer_window
;
1263 /* Clear any X selections for this frame. */
1264 #ifdef HAVE_X_WINDOWS
1266 x_clear_frame_selections (f
);
1270 This function must be called before the window tree of the
1271 frame is deleted because windows contain dynamically allocated
1275 #ifdef HAVE_WINDOW_SYSTEM
1276 /* Give chance to each font driver to free a frame specific data. */
1277 font_update_drivers (f
, Qnil
);
1280 /* Mark all the windows that used to be on FRAME as deleted, and then
1281 remove the reference to them. */
1282 delete_all_child_windows (f
->root_window
);
1283 FSET (f
, root_window
, Qnil
);
1285 Vframe_list
= Fdelq (frame
, Vframe_list
);
1286 FRAME_SET_VISIBLE (f
, 0);
1288 /* Allow the vector of menu bar contents to be freed in the next
1289 garbage collection. The frame object itself may not be garbage
1290 collected until much later, because recent_keys and other data
1291 structures can still refer to it. */
1292 FSET (f
, menu_bar_vector
, Qnil
);
1294 free_font_driver_list (f
);
1296 xfree (f
->decode_mode_spec_buffer
);
1297 xfree (FRAME_INSERT_COST (f
));
1298 xfree (FRAME_DELETEN_COST (f
));
1299 xfree (FRAME_INSERTN_COST (f
));
1300 xfree (FRAME_DELETE_COST (f
));
1301 xfree (FRAME_MESSAGE_BUF (f
));
1303 /* Since some events are handled at the interrupt level, we may get
1304 an event for f at any time; if we zero out the frame's terminal
1305 now, then we may trip up the event-handling code. Instead, we'll
1306 promise that the terminal of the frame must be valid until we
1307 have called the window-system-dependent frame destruction
1310 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1311 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1314 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1315 f
->output_data
.nothing
= 0;
1316 f
->terminal
= 0; /* Now the frame is dead. */
1318 /* If needed, delete the terminal that this frame was on.
1319 (This must be done after the frame is killed.) */
1320 terminal
->reference_count
--;
1322 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1324 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1325 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1326 terminal
->reference_count
= 1;
1327 #endif /* USE_GTK */
1328 if (terminal
->reference_count
== 0)
1331 XSETTERMINAL (tmp
, terminal
);
1334 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1337 kb
= terminal
->kboard
;
1340 /* If we've deleted the last_nonminibuf_frame, then try to find
1342 if (f
== last_nonminibuf_frame
)
1346 last_nonminibuf_frame
= 0;
1348 for (frames
= Vframe_list
;
1350 frames
= XCDR (frames
))
1352 f
= XFRAME (XCAR (frames
));
1353 if (!FRAME_MINIBUF_ONLY_P (f
))
1355 last_nonminibuf_frame
= f
;
1361 /* If there's no other frame on the same kboard, get out of
1362 single-kboard state if we're in it for this kboard. */
1366 /* Some frame we found on the same kboard, or nil if there are none. */
1367 Lisp_Object frame_on_same_kboard
;
1369 frame_on_same_kboard
= Qnil
;
1371 for (frames
= Vframe_list
;
1373 frames
= XCDR (frames
))
1378 this = XCAR (frames
);
1383 if (kb
== FRAME_KBOARD (f1
))
1384 frame_on_same_kboard
= this;
1387 if (NILP (frame_on_same_kboard
))
1388 not_single_kboard_state (kb
);
1392 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1393 find another one. Prefer minibuffer-only frames, but also notice
1394 frames with other windows. */
1395 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1399 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1400 Lisp_Object frame_with_minibuf
;
1401 /* Some frame we found on the same kboard, or nil if there are none. */
1402 Lisp_Object frame_on_same_kboard
;
1404 frame_on_same_kboard
= Qnil
;
1405 frame_with_minibuf
= Qnil
;
1407 for (frames
= Vframe_list
;
1409 frames
= XCDR (frames
))
1414 this = XCAR (frames
);
1419 /* Consider only frames on the same kboard
1420 and only those with minibuffers. */
1421 if (kb
== FRAME_KBOARD (f1
)
1422 && FRAME_HAS_MINIBUF_P (f1
))
1424 frame_with_minibuf
= this;
1425 if (FRAME_MINIBUF_ONLY_P (f1
))
1429 if (kb
== FRAME_KBOARD (f1
))
1430 frame_on_same_kboard
= this;
1433 if (!NILP (frame_on_same_kboard
))
1435 /* We know that there must be some frame with a minibuffer out
1436 there. If this were not true, all of the frames present
1437 would have to be minibufferless, which implies that at some
1438 point their minibuffer frames must have been deleted, but
1439 that is prohibited at the top; you can't delete surrogate
1440 minibuffer frames. */
1441 if (NILP (frame_with_minibuf
))
1444 KSET (kb
, Vdefault_minibuffer_frame
, frame_with_minibuf
);
1447 /* No frames left on this kboard--say no minibuffer either. */
1448 KSET (kb
, Vdefault_minibuffer_frame
, Qnil
);
1451 /* Cause frame titles to update--necessary if we now have just one frame. */
1453 update_mode_lines
= 1;
1458 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1459 doc
: /* Delete FRAME, permanently eliminating it from use.
1460 FRAME defaults to the selected frame.
1462 A frame may not be deleted if its minibuffer is used by other frames.
1463 Normally, you may not delete a frame if all other frames are invisible,
1464 but if the second optional argument FORCE is non-nil, you may do so.
1466 This function runs `delete-frame-functions' before actually
1467 deleting the frame, unless the frame is a tooltip.
1468 The functions are run with one argument, the frame to be deleted. */)
1469 (Lisp_Object frame
, Lisp_Object force
)
1471 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1475 /* Return mouse position in character cell units. */
1477 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1478 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1479 The position is given in character cells, where (0, 0) is the
1480 upper-left corner of the frame, X is the horizontal offset, and Y is
1481 the vertical offset.
1482 If Emacs is running on a mouseless terminal or hasn't been programmed
1483 to read the mouse position, it returns the selected frame for FRAME
1484 and nil for X and Y.
1485 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1486 passing the normal return value to that function as an argument,
1487 and returns whatever that function returns. */)
1491 Lisp_Object lispy_dummy
;
1492 enum scroll_bar_part party_dummy
;
1493 Lisp_Object x
, y
, retval
;
1496 struct gcpro gcpro1
;
1498 f
= SELECTED_FRAME ();
1501 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1502 /* It's okay for the hook to refrain from storing anything. */
1503 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1504 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1505 &lispy_dummy
, &party_dummy
,
1512 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1517 XSETFRAME (lispy_dummy
, f
);
1518 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1520 if (!NILP (Vmouse_position_function
))
1521 retval
= call1 (Vmouse_position_function
, retval
);
1522 RETURN_UNGCPRO (retval
);
1525 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1526 Smouse_pixel_position
, 0, 0, 0,
1527 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1528 The position is given in pixel units, where (0, 0) is the
1529 upper-left corner of the frame, X is the horizontal offset, and Y is
1530 the vertical offset.
1531 If Emacs is running on a mouseless terminal or hasn't been programmed
1532 to read the mouse position, it returns the selected frame for FRAME
1533 and nil for X and Y. */)
1537 Lisp_Object lispy_dummy
;
1538 enum scroll_bar_part party_dummy
;
1542 f
= SELECTED_FRAME ();
1545 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1546 /* It's okay for the hook to refrain from storing anything. */
1547 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1548 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1549 &lispy_dummy
, &party_dummy
,
1553 XSETFRAME (lispy_dummy
, f
);
1554 return Fcons (lispy_dummy
, Fcons (x
, y
));
1557 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1558 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1559 Coordinates are relative to the frame, not a window,
1560 so the coordinates of the top left character in the frame
1561 may be nonzero due to left-hand scroll bars or the menu bar.
1563 The position is given in character cells, where (0, 0) is the
1564 upper-left corner of the frame, X is the horizontal offset, and Y is
1565 the vertical offset.
1567 This function is a no-op for an X frame that is not visible.
1568 If you have just created a frame, you must wait for it to become visible
1569 before calling this function on it, like this.
1570 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1571 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1573 CHECK_LIVE_FRAME (frame
);
1574 CHECK_TYPE_RANGED_INTEGER (int, x
);
1575 CHECK_TYPE_RANGED_INTEGER (int, y
);
1577 /* I think this should be done with a hook. */
1578 #ifdef HAVE_WINDOW_SYSTEM
1579 if (FRAME_WINDOW_P (XFRAME (frame
)))
1580 /* Warping the mouse will cause enternotify and focus events. */
1581 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1583 #if defined (MSDOS) && defined (HAVE_MOUSE)
1584 if (FRAME_MSDOS_P (XFRAME (frame
)))
1586 Fselect_frame (frame
, Qnil
);
1587 mouse_moveto (XINT (x
), XINT (y
));
1592 Fselect_frame (frame
, Qnil
);
1593 term_mouse_moveto (XINT (x
), XINT (y
));
1602 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1603 Sset_mouse_pixel_position
, 3, 3, 0,
1604 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1605 The position is given in pixels, where (0, 0) is the upper-left corner
1606 of the frame, X is the horizontal offset, and Y is the vertical offset.
1608 Note, this is a no-op for an X frame that is not visible.
1609 If you have just created a frame, you must wait for it to become visible
1610 before calling this function on it, like this.
1611 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1612 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1614 CHECK_LIVE_FRAME (frame
);
1615 CHECK_TYPE_RANGED_INTEGER (int, x
);
1616 CHECK_TYPE_RANGED_INTEGER (int, y
);
1618 /* I think this should be done with a hook. */
1619 #ifdef HAVE_WINDOW_SYSTEM
1620 if (FRAME_WINDOW_P (XFRAME (frame
)))
1621 /* Warping the mouse will cause enternotify and focus events. */
1622 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1624 #if defined (MSDOS) && defined (HAVE_MOUSE)
1625 if (FRAME_MSDOS_P (XFRAME (frame
)))
1627 Fselect_frame (frame
, Qnil
);
1628 mouse_moveto (XINT (x
), XINT (y
));
1633 Fselect_frame (frame
, Qnil
);
1634 term_mouse_moveto (XINT (x
), XINT (y
));
1643 static void make_frame_visible_1 (Lisp_Object
);
1645 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1647 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1648 If omitted, FRAME defaults to the currently selected frame. */)
1652 frame
= selected_frame
;
1654 CHECK_LIVE_FRAME (frame
);
1656 /* I think this should be done with a hook. */
1657 #ifdef HAVE_WINDOW_SYSTEM
1658 if (FRAME_WINDOW_P (XFRAME (frame
)))
1660 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1661 x_make_frame_visible (XFRAME (frame
));
1665 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1667 /* Make menu bar update for the Buffers and Frames menus. */
1668 windows_or_buffers_changed
++;
1673 /* Update the display_time slot of the buffers shown in WINDOW
1674 and all its descendants. */
1677 make_frame_visible_1 (Lisp_Object window
)
1681 for (;!NILP (window
); window
= w
->next
)
1683 w
= XWINDOW (window
);
1685 if (!NILP (w
->buffer
))
1686 BSET (XBUFFER (w
->buffer
), display_time
, Fcurrent_time ());
1688 if (!NILP (w
->vchild
))
1689 make_frame_visible_1 (w
->vchild
);
1690 if (!NILP (w
->hchild
))
1691 make_frame_visible_1 (w
->hchild
);
1695 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1697 doc
: /* Make the frame FRAME invisible.
1698 If omitted, FRAME defaults to the currently selected frame.
1699 On graphical displays, invisible frames are not updated and are
1700 usually not displayed at all, even in a window system's \"taskbar\".
1702 Normally you may not make FRAME invisible if all other frames are invisible,
1703 but if the second optional argument FORCE is non-nil, you may do so.
1705 This function has no effect on text terminal frames. Such frames are
1706 always considered visible, whether or not they are currently being
1707 displayed in the terminal. */)
1708 (Lisp_Object frame
, Lisp_Object force
)
1711 frame
= selected_frame
;
1713 CHECK_LIVE_FRAME (frame
);
1715 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1716 error ("Attempt to make invisible the sole visible or iconified frame");
1718 /* Don't allow minibuf_window to remain on a deleted frame. */
1719 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1721 struct frame
*sf
= XFRAME (selected_frame
);
1722 /* Use set_window_buffer instead of Fset_window_buffer (see
1723 discussion of bug#11984, bug#12025, bug#12026). */
1724 set_window_buffer (sf
->minibuffer_window
,
1725 XWINDOW (minibuf_window
)->buffer
, 0, 0);
1726 minibuf_window
= sf
->minibuffer_window
;
1729 /* I think this should be done with a hook. */
1730 #ifdef HAVE_WINDOW_SYSTEM
1731 if (FRAME_WINDOW_P (XFRAME (frame
)))
1732 x_make_frame_invisible (XFRAME (frame
));
1735 /* Make menu bar update for the Buffers and Frames menus. */
1736 windows_or_buffers_changed
++;
1741 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1743 doc
: /* Make the frame FRAME into an icon.
1744 If omitted, FRAME defaults to the currently selected frame. */)
1748 frame
= selected_frame
;
1750 CHECK_LIVE_FRAME (frame
);
1752 #if 0 /* This isn't logically necessary, and it can do GC. */
1753 /* Don't let the frame remain selected. */
1754 if (EQ (frame
, selected_frame
))
1755 Fhandle_switch_frame (next_frame (frame
, Qt
));
1758 /* Don't allow minibuf_window to remain on an iconified frame. */
1759 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1761 struct frame
*sf
= XFRAME (selected_frame
);
1762 /* Use set_window_buffer instead of Fset_window_buffer (see
1763 discussion of bug#11984, bug#12025, bug#12026). */
1764 set_window_buffer (sf
->minibuffer_window
,
1765 XWINDOW (minibuf_window
)->buffer
, 0, 0);
1766 minibuf_window
= sf
->minibuffer_window
;
1769 /* I think this should be done with a hook. */
1770 #ifdef HAVE_WINDOW_SYSTEM
1771 if (FRAME_WINDOW_P (XFRAME (frame
)))
1772 x_iconify_frame (XFRAME (frame
));
1775 /* Make menu bar update for the Buffers and Frames menus. */
1776 windows_or_buffers_changed
++;
1781 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1783 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1784 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1785 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1786 On graphical displays, invisible frames are not updated and are
1787 usually not displayed at all, even in a window system's \"taskbar\".
1789 If FRAME is a text terminal frame, this always returns t.
1790 Such frames are always considered visible, whether or not they are
1791 currently being displayed on the terminal. */)
1794 CHECK_LIVE_FRAME (frame
);
1796 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1798 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1800 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1805 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1807 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1810 Lisp_Object tail
, frame
;
1815 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1817 frame
= XCAR (tail
);
1818 if (!FRAMEP (frame
))
1821 if (FRAME_VISIBLE_P (f
))
1822 value
= Fcons (frame
, value
);
1828 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1829 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1830 If FRAME is invisible or iconified, make it visible.
1831 If you don't specify a frame, the selected frame is used.
1832 If Emacs is displaying on an ordinary terminal or some other device which
1833 doesn't support multiple overlapping frames, this function selects FRAME. */)
1838 frame
= selected_frame
;
1840 CHECK_LIVE_FRAME (frame
);
1844 if (FRAME_TERMCAP_P (f
))
1845 /* On a text terminal select FRAME. */
1846 Fselect_frame (frame
, Qnil
);
1848 /* Do like the documentation says. */
1849 Fmake_frame_visible (frame
);
1851 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1852 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
1857 /* Should we have a corresponding function called Flower_Power? */
1858 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1859 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1860 If you don't specify a frame, the selected frame is used.
1861 If Emacs is displaying on an ordinary terminal or some other device which
1862 doesn't support multiple overlapping frames, this function does nothing. */)
1868 frame
= selected_frame
;
1870 CHECK_LIVE_FRAME (frame
);
1874 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1875 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
1881 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1883 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1884 In other words, switch-frame events caused by events in FRAME will
1885 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1886 FOCUS-FRAME after reading an event typed at FRAME.
1888 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
1889 frame again receives its own keystrokes.
1891 Focus redirection is useful for temporarily redirecting keystrokes to
1892 a surrogate minibuffer frame when a frame doesn't have its own
1895 A frame's focus redirection can be changed by `select-frame'. If frame
1896 FOO is selected, and then a different frame BAR is selected, any
1897 frames redirecting their focus to FOO are shifted to redirect their
1898 focus to BAR. This allows focus redirection to work properly when the
1899 user switches from one frame to another using `select-window'.
1901 This means that a frame whose focus is redirected to itself is treated
1902 differently from a frame whose focus is redirected to nil; the former
1903 is affected by `select-frame', while the latter is not.
1905 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1906 (Lisp_Object frame
, Lisp_Object focus_frame
)
1910 /* Note that we don't check for a live frame here. It's reasonable
1911 to redirect the focus of a frame you're about to delete, if you
1912 know what other frame should receive those keystrokes. */
1913 CHECK_FRAME (frame
);
1915 if (! NILP (focus_frame
))
1916 CHECK_LIVE_FRAME (focus_frame
);
1920 FSET (f
, focus_frame
, focus_frame
);
1922 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
1923 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
1929 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1930 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1931 This returns nil if FRAME's focus is not redirected.
1932 See `redirect-frame-focus'. */)
1935 CHECK_LIVE_FRAME (frame
);
1937 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1942 /* Return the value of frame parameter PROP in frame FRAME. */
1944 #ifdef HAVE_WINDOW_SYSTEM
1949 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
1951 register Lisp_Object tem
;
1953 tem
= Fassq (prop
, frame
->param_alist
);
1960 /* Return the buffer-predicate of the selected frame. */
1963 frame_buffer_predicate (Lisp_Object frame
)
1965 return XFRAME (frame
)->buffer_predicate
;
1968 /* Return the buffer-list of the selected frame. */
1971 frame_buffer_list (Lisp_Object frame
)
1973 return XFRAME (frame
)->buffer_list
;
1976 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
1979 frames_discard_buffer (Lisp_Object buffer
)
1981 Lisp_Object frame
, tail
;
1983 FOR_EACH_FRAME (tail
, frame
)
1985 FSET (XFRAME (frame
), buffer_list
,
1986 Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
1987 FSET (XFRAME (frame
), buried_buffer_list
,
1988 Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
1992 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1993 If the alist already has an element for PROP, we change it. */
1996 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
1998 register Lisp_Object tem
;
2000 tem
= Fassq (prop
, *alistptr
);
2002 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2008 frame_name_fnn_p (char *str
, ptrdiff_t len
)
2010 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
2013 while ('0' <= *p
&& *p
<= '9')
2021 /* Set the name of the terminal frame. Also used by MSDOS frames.
2022 Modeled after x_set_name which is used for WINDOW frames. */
2025 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2027 f
->explicit_name
= ! NILP (name
);
2029 /* If NAME is nil, set the name to F<num>. */
2032 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
2034 /* Check for no change needed in this very common case
2035 before we do any consing. */
2036 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
2039 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
2043 CHECK_STRING (name
);
2045 /* Don't change the name if it's already NAME. */
2046 if (! NILP (Fstring_equal (name
, f
->name
)))
2049 /* Don't allow the user to set the frame name to F<num>, so it
2050 doesn't clash with the names we generate for terminal frames. */
2051 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2052 error ("Frame names of the form F<num> are usurped by Emacs");
2055 FSET (f
, name
, name
);
2056 update_mode_lines
= 1;
2060 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2062 register Lisp_Object old_alist_elt
;
2064 /* The buffer-list parameters are stored in a special place and not
2065 in the alist. All buffers must be live. */
2066 if (EQ (prop
, Qbuffer_list
))
2068 Lisp_Object list
= Qnil
;
2069 for (; CONSP (val
); val
= XCDR (val
))
2070 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2071 list
= Fcons (XCAR (val
), list
);
2072 FSET (f
, buffer_list
, Fnreverse (list
));
2075 if (EQ (prop
, Qburied_buffer_list
))
2077 Lisp_Object list
= Qnil
;
2078 for (; CONSP (val
); val
= XCDR (val
))
2079 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2080 list
= Fcons (XCAR (val
), list
);
2081 FSET (f
, buried_buffer_list
, Fnreverse (list
));
2085 /* If PROP is a symbol which is supposed to have frame-local values,
2086 and it is set up based on this frame, switch to the global
2087 binding. That way, we can create or alter the frame-local binding
2088 without messing up the symbol's status. */
2091 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2093 switch (sym
->redirect
)
2095 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2096 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2097 case SYMBOL_LOCALIZED
:
2098 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2099 if (blv
->frame_local
&& BLV_FOUND (blv
) && XFRAME (blv
->where
) == f
)
2100 swap_in_global_binding (sym
);
2107 /* The tty color needed to be set before the frame's parameter
2108 alist was updated with the new value. This is not true any more,
2109 but we still do this test early on. */
2110 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2111 && f
== FRAME_TTY (f
)->previous_frame
)
2112 /* Force redisplay of this tty. */
2113 FRAME_TTY (f
)->previous_frame
= NULL
;
2115 /* Update the frame parameter alist. */
2116 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2117 if (EQ (old_alist_elt
, Qnil
))
2118 FSET (f
, param_alist
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2120 Fsetcdr (old_alist_elt
, val
);
2122 /* Update some other special parameters in their special places
2123 in addition to the alist. */
2125 if (EQ (prop
, Qbuffer_predicate
))
2126 FSET (f
, buffer_predicate
, val
);
2128 if (! FRAME_WINDOW_P (f
))
2130 if (EQ (prop
, Qmenu_bar_lines
))
2131 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2132 else if (EQ (prop
, Qname
))
2133 set_term_frame_name (f
, val
);
2136 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2138 if (! MINI_WINDOW_P (XWINDOW (val
)))
2139 error ("Surrogate minibuffer windows must be minibuffer windows");
2141 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2142 && !EQ (val
, f
->minibuffer_window
))
2143 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2145 /* Install the chosen minibuffer window, with proper buffer. */
2146 FSET (f
, minibuffer_window
, val
);
2150 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2151 doc
: /* Return the parameters-alist of frame FRAME.
2152 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2153 The meaningful PARMs depend on the kind of frame.
2154 If FRAME is omitted, return information on the currently selected frame. */)
2160 struct gcpro gcpro1
;
2163 frame
= selected_frame
;
2165 CHECK_FRAME (frame
);
2168 if (!FRAME_LIVE_P (f
))
2171 alist
= Fcopy_alist (f
->param_alist
);
2174 if (!FRAME_WINDOW_P (f
))
2176 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2177 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2180 /* If the frame's parameter alist says the colors are
2181 unspecified and reversed, take the frame's background pixel
2182 for foreground and vice versa. */
2183 elt
= Fassq (Qforeground_color
, alist
);
2184 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2186 if (strncmp (SSDATA (XCDR (elt
)),
2188 SCHARS (XCDR (elt
))) == 0)
2189 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2190 else if (strncmp (SSDATA (XCDR (elt
)),
2192 SCHARS (XCDR (elt
))) == 0)
2193 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2196 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2197 elt
= Fassq (Qbackground_color
, alist
);
2198 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2200 if (strncmp (SSDATA (XCDR (elt
)),
2202 SCHARS (XCDR (elt
))) == 0)
2203 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2204 else if (strncmp (SSDATA (XCDR (elt
)),
2206 SCHARS (XCDR (elt
))) == 0)
2207 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2210 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2211 store_in_alist (&alist
, intern ("font"),
2212 build_string (FRAME_MSDOS_P (f
)
2214 : FRAME_W32_P (f
) ? "w32term"
2217 store_in_alist (&alist
, Qname
, f
->name
);
2218 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2219 store_in_alist (&alist
, Qheight
, make_number (height
));
2220 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2221 store_in_alist (&alist
, Qwidth
, make_number (width
));
2222 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2223 store_in_alist (&alist
, Qminibuffer
,
2224 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2225 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2226 : FRAME_MINIBUF_WINDOW (f
)));
2227 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2228 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2229 store_in_alist (&alist
, Qburied_buffer_list
,
2230 XFRAME (frame
)->buried_buffer_list
);
2232 /* I think this should be done with a hook. */
2233 #ifdef HAVE_WINDOW_SYSTEM
2234 if (FRAME_WINDOW_P (f
))
2235 x_report_frame_params (f
, &alist
);
2239 /* This ought to be correct in f->param_alist for an X frame. */
2241 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2242 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2250 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2251 doc
: /* Return FRAME's value for parameter PARAMETER.
2252 If FRAME is nil, describe the currently selected frame. */)
2253 (Lisp_Object frame
, Lisp_Object parameter
)
2259 frame
= selected_frame
;
2261 CHECK_FRAME (frame
);
2262 CHECK_SYMBOL (parameter
);
2267 if (FRAME_LIVE_P (f
))
2269 /* Avoid consing in frequent cases. */
2270 if (EQ (parameter
, Qname
))
2272 #ifdef HAVE_X_WINDOWS
2273 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2274 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2275 #endif /* HAVE_X_WINDOWS */
2276 else if (EQ (parameter
, Qbackground_color
)
2277 || EQ (parameter
, Qforeground_color
))
2279 value
= Fassq (parameter
, f
->param_alist
);
2282 value
= XCDR (value
);
2283 /* Fframe_parameters puts the actual fg/bg color names,
2284 even if f->param_alist says otherwise. This is
2285 important when param_alist's notion of colors is
2286 "unspecified". We need to do the same here. */
2287 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2289 const char *color_name
;
2292 if (EQ (parameter
, Qbackground_color
))
2294 color_name
= SSDATA (value
);
2295 csz
= SCHARS (value
);
2296 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2297 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2298 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2299 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2301 else if (EQ (parameter
, Qforeground_color
))
2303 color_name
= SSDATA (value
);
2304 csz
= SCHARS (value
);
2305 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2306 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2307 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2308 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2313 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2315 else if (EQ (parameter
, Qdisplay_type
)
2316 || EQ (parameter
, Qbackground_mode
))
2317 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2319 /* FIXME: Avoid this code path at all (as well as code duplication)
2320 by sharing more code with Fframe_parameters. */
2321 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2328 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2329 Smodify_frame_parameters
, 2, 2, 0,
2330 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2331 If FRAME is nil, it defaults to the selected frame.
2332 ALIST is an alist of parameters to change and their new values.
2333 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2334 The meaningful PARMs depend on the kind of frame.
2335 Undefined PARMs are ignored, but stored in the frame's parameter list
2336 so that `frame-parameters' will return them.
2338 The value of frame parameter FOO can also be accessed
2339 as a frame-local binding for the variable FOO, if you have
2340 enabled such bindings for that variable with `make-variable-frame-local'.
2341 Note that this functionality is obsolete as of Emacs 22.2, and its
2342 use is not recommended. Explicitly check for a frame-parameter instead. */)
2343 (Lisp_Object frame
, Lisp_Object alist
)
2346 register Lisp_Object tail
, prop
, val
;
2348 if (EQ (frame
, Qnil
))
2349 frame
= selected_frame
;
2350 CHECK_LIVE_FRAME (frame
);
2353 /* I think this should be done with a hook. */
2354 #ifdef HAVE_WINDOW_SYSTEM
2355 if (FRAME_WINDOW_P (f
))
2356 x_set_frame_parameters (f
, alist
);
2360 if (FRAME_MSDOS_P (f
))
2361 IT_set_frame_parameters (f
, alist
);
2366 EMACS_INT length
= XFASTINT (Flength (alist
));
2369 Lisp_Object
*values
;
2371 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2372 values
= parms
+ length
;
2374 /* Extract parm names and values into those vectors. */
2377 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2382 parms
[i
] = Fcar (elt
);
2383 values
[i
] = Fcdr (elt
);
2387 /* Now process them in reverse of specified order. */
2392 store_frame_param (f
, prop
, val
);
2394 if (EQ (prop
, Qforeground_color
)
2395 || EQ (prop
, Qbackground_color
))
2396 update_face_from_frame_parameter (f
, prop
, val
);
2404 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2406 doc
: /* Height in pixels of a line in the font in frame FRAME.
2407 If FRAME is omitted, the selected frame is used.
2408 For a terminal frame, the value is always 1. */)
2414 frame
= selected_frame
;
2415 CHECK_FRAME (frame
);
2418 #ifdef HAVE_WINDOW_SYSTEM
2419 if (FRAME_WINDOW_P (f
))
2420 return make_number (x_char_height (f
));
2423 return make_number (1);
2427 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2429 doc
: /* Width in pixels of characters in the font in frame FRAME.
2430 If FRAME is omitted, the selected frame is used.
2431 On a graphical screen, the width is the standard width of the default font.
2432 For a terminal screen, the value is always 1. */)
2438 frame
= selected_frame
;
2439 CHECK_FRAME (frame
);
2442 #ifdef HAVE_WINDOW_SYSTEM
2443 if (FRAME_WINDOW_P (f
))
2444 return make_number (x_char_width (f
));
2447 return make_number (1);
2450 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2451 Sframe_pixel_height
, 0, 1, 0,
2452 doc
: /* Return a FRAME's height in pixels.
2453 If FRAME is omitted, the selected frame is used. The exact value
2454 of the result depends on the window-system and toolkit in use:
2456 In the Gtk+ version of Emacs, it includes only any window (including
2457 the minibuffer or echo area), mode line, and header line. It does not
2458 include the tool bar or menu bar.
2460 With the Motif or Lucid toolkits, it also includes the tool bar (but
2463 In a graphical version with no toolkit, it includes both the tool bar
2466 For a text terminal, it includes the menu bar. In this case, the
2467 result is really in characters rather than pixels (i.e., is identical
2468 to `frame-height'). */)
2474 frame
= selected_frame
;
2475 CHECK_FRAME (frame
);
2478 #ifdef HAVE_WINDOW_SYSTEM
2479 if (FRAME_WINDOW_P (f
))
2480 return make_number (x_pixel_height (f
));
2483 return make_number (FRAME_LINES (f
));
2486 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2487 Sframe_pixel_width
, 0, 1, 0,
2488 doc
: /* Return FRAME's width in pixels.
2489 For a terminal frame, the result really gives the width in characters.
2490 If FRAME is omitted, the selected frame is used. */)
2496 frame
= selected_frame
;
2497 CHECK_FRAME (frame
);
2500 #ifdef HAVE_WINDOW_SYSTEM
2501 if (FRAME_WINDOW_P (f
))
2502 return make_number (x_pixel_width (f
));
2505 return make_number (FRAME_COLS (f
));
2508 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2509 Stool_bar_pixel_width
, 0, 1, 0,
2510 doc
: /* Return width in pixels of FRAME's tool bar.
2511 The result is greater than zero only when the tool bar is on the left
2512 or right side of FRAME. If FRAME is omitted, the selected frame is
2517 frame
= selected_frame
;
2518 CHECK_FRAME (frame
);
2520 #ifdef FRAME_TOOLBAR_WIDTH
2521 if (FRAME_WINDOW_P (XFRAME (frame
)))
2522 return make_number (FRAME_TOOLBAR_WIDTH (XFRAME (frame
)));
2524 return make_number (0);
2527 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2528 doc
: /* Specify that the frame FRAME has LINES lines.
2529 Optional third arg non-nil means that redisplay should use LINES lines
2530 but that the idea of the actual height of the frame should not be changed. */)
2531 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2533 register struct frame
*f
;
2535 CHECK_TYPE_RANGED_INTEGER (int, lines
);
2537 frame
= selected_frame
;
2538 CHECK_LIVE_FRAME (frame
);
2541 /* I think this should be done with a hook. */
2542 #ifdef HAVE_WINDOW_SYSTEM
2543 if (FRAME_WINDOW_P (f
))
2545 if (XINT (lines
) != FRAME_LINES (f
))
2546 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2547 do_pending_window_change (0);
2551 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2555 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2556 doc
: /* Specify that the frame FRAME has COLS columns.
2557 Optional third arg non-nil means that redisplay should use COLS columns
2558 but that the idea of the actual width of the frame should not be changed. */)
2559 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2561 register struct frame
*f
;
2562 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2564 frame
= selected_frame
;
2565 CHECK_LIVE_FRAME (frame
);
2568 /* I think this should be done with a hook. */
2569 #ifdef HAVE_WINDOW_SYSTEM
2570 if (FRAME_WINDOW_P (f
))
2572 if (XINT (cols
) != FRAME_COLS (f
))
2573 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2574 do_pending_window_change (0);
2578 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2582 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2583 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2584 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2586 register struct frame
*f
;
2588 CHECK_LIVE_FRAME (frame
);
2589 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2590 CHECK_TYPE_RANGED_INTEGER (int, rows
);
2593 /* I think this should be done with a hook. */
2594 #ifdef HAVE_WINDOW_SYSTEM
2595 if (FRAME_WINDOW_P (f
))
2597 if (XINT (rows
) != FRAME_LINES (f
)
2598 || XINT (cols
) != FRAME_COLS (f
)
2599 || f
->new_text_lines
|| f
->new_text_cols
)
2600 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2601 do_pending_window_change (0);
2605 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2610 DEFUN ("set-frame-position", Fset_frame_position
,
2611 Sset_frame_position
, 3, 3, 0,
2612 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2613 This is actually the position of the upper left corner of the frame.
2614 Negative values for XOFFSET or YOFFSET are interpreted relative to
2615 the rightmost or bottommost possible position (that stays within the screen). */)
2616 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2618 register struct frame
*f
;
2620 CHECK_LIVE_FRAME (frame
);
2621 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2622 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2625 /* I think this should be done with a hook. */
2626 #ifdef HAVE_WINDOW_SYSTEM
2627 if (FRAME_WINDOW_P (f
))
2628 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2635 /***********************************************************************
2637 ***********************************************************************/
2639 /* Connect the frame-parameter names for X frames
2640 to the ways of passing the parameter values to the window system.
2642 The name of a parameter, as a Lisp symbol,
2643 has an `x-frame-parameter' property which is an integer in Lisp
2644 that is an index in this table. */
2646 struct frame_parm_table
{
2648 Lisp_Object
*variable
;
2651 static const struct frame_parm_table frame_parms
[] =
2653 {"auto-raise", &Qauto_raise
},
2654 {"auto-lower", &Qauto_lower
},
2655 {"background-color", 0},
2656 {"border-color", &Qborder_color
},
2657 {"border-width", &Qborder_width
},
2658 {"cursor-color", &Qcursor_color
},
2659 {"cursor-type", &Qcursor_type
},
2661 {"foreground-color", 0},
2662 {"icon-name", &Qicon_name
},
2663 {"icon-type", &Qicon_type
},
2664 {"internal-border-width", &Qinternal_border_width
},
2665 {"menu-bar-lines", &Qmenu_bar_lines
},
2666 {"mouse-color", &Qmouse_color
},
2668 {"scroll-bar-width", &Qscroll_bar_width
},
2670 {"unsplittable", &Qunsplittable
},
2671 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2672 {"visibility", &Qvisibility
},
2673 {"tool-bar-lines", &Qtool_bar_lines
},
2674 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2675 {"scroll-bar-background", &Qscroll_bar_background
},
2676 {"screen-gamma", &Qscreen_gamma
},
2677 {"line-spacing", &Qline_spacing
},
2678 {"left-fringe", &Qleft_fringe
},
2679 {"right-fringe", &Qright_fringe
},
2680 {"wait-for-wm", &Qwait_for_wm
},
2681 {"fullscreen", &Qfullscreen
},
2682 {"font-backend", &Qfont_backend
},
2684 {"sticky", &Qsticky
},
2685 {"tool-bar-position", &Qtool_bar_position
},
2690 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2691 wanted positions of the WM window (not Emacs window).
2692 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2693 window (FRAME_X_WINDOW).
2697 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2699 int newwidth
= FRAME_COLS (f
);
2700 int newheight
= FRAME_LINES (f
);
2701 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2703 *top_pos
= f
->top_pos
;
2704 *left_pos
= f
->left_pos
;
2706 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2710 ph
= x_display_pixel_height (dpyinfo
);
2711 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2712 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2713 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2717 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2721 pw
= x_display_pixel_width (dpyinfo
);
2722 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2723 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2724 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2729 *height
= newheight
;
2732 #endif /* WINDOWSNT */
2734 #ifdef HAVE_WINDOW_SYSTEM
2736 /* Change the parameters of frame F as specified by ALIST.
2737 If a parameter is not specially recognized, do nothing special;
2738 otherwise call the `x_set_...' function for that parameter.
2739 Except for certain geometry properties, always call store_frame_param
2740 to store the new value in the parameter alist. */
2743 x_set_frame_parameters (FRAME_PTR f
, Lisp_Object alist
)
2747 /* If both of these parameters are present, it's more efficient to
2748 set them both at once. So we wait until we've looked at the
2749 entire list before we set them. */
2753 Lisp_Object left
, top
;
2755 /* Same with these. */
2756 Lisp_Object icon_left
, icon_top
;
2758 /* Record in these vectors all the parms specified. */
2760 Lisp_Object
*values
;
2762 int left_no_change
= 0, top_no_change
= 0;
2763 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2764 int size_changed
= 0;
2765 struct gcpro gcpro1
, gcpro2
;
2768 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2771 parms
= alloca (i
* sizeof *parms
);
2772 values
= alloca (i
* sizeof *values
);
2774 /* Extract parm names and values into those vectors. */
2777 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2782 parms
[i
] = Fcar (elt
);
2783 values
[i
] = Fcdr (elt
);
2786 /* TAIL and ALIST are not used again below here. */
2787 alist
= tail
= Qnil
;
2789 GCPRO2 (*parms
, *values
);
2793 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2794 because their values appear in VALUES and strings are not valid. */
2795 top
= left
= Qunbound
;
2796 icon_left
= icon_top
= Qunbound
;
2798 /* Provide default values for HEIGHT and WIDTH. */
2799 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2800 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2802 /* Process foreground_color and background_color before anything else.
2803 They are independent of other properties, but other properties (e.g.,
2804 cursor_color) are dependent upon them. */
2805 /* Process default font as well, since fringe widths depends on it. */
2806 for (p
= 0; p
< i
; p
++)
2808 Lisp_Object prop
, val
;
2812 if (EQ (prop
, Qforeground_color
)
2813 || EQ (prop
, Qbackground_color
)
2814 || EQ (prop
, Qfont
))
2816 register Lisp_Object param_index
, old_value
;
2818 old_value
= get_frame_param (f
, prop
);
2819 if (NILP (Fequal (val
, old_value
)))
2821 store_frame_param (f
, prop
, val
);
2823 param_index
= Fget (prop
, Qx_frame_parameter
);
2824 if (NATNUMP (param_index
)
2825 && (XFASTINT (param_index
)
2826 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2827 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2828 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2833 /* Now process them in reverse of specified order. */
2836 Lisp_Object prop
, val
;
2841 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2844 width
= XFASTINT (val
);
2846 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2849 height
= XFASTINT (val
);
2851 else if (EQ (prop
, Qtop
))
2853 else if (EQ (prop
, Qleft
))
2855 else if (EQ (prop
, Qicon_top
))
2857 else if (EQ (prop
, Qicon_left
))
2859 else if (EQ (prop
, Qforeground_color
)
2860 || EQ (prop
, Qbackground_color
)
2861 || EQ (prop
, Qfont
))
2862 /* Processed above. */
2866 register Lisp_Object param_index
, old_value
;
2868 old_value
= get_frame_param (f
, prop
);
2870 store_frame_param (f
, prop
, val
);
2872 param_index
= Fget (prop
, Qx_frame_parameter
);
2873 if (NATNUMP (param_index
)
2874 && (XFASTINT (param_index
)
2875 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2876 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2877 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2881 /* Don't die if just one of these was set. */
2882 if (EQ (left
, Qunbound
))
2885 if (f
->left_pos
< 0)
2886 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2888 XSETINT (left
, f
->left_pos
);
2890 if (EQ (top
, Qunbound
))
2894 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2896 XSETINT (top
, f
->top_pos
);
2899 /* If one of the icon positions was not set, preserve or default it. */
2900 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
2902 icon_left_no_change
= 1;
2903 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2904 if (NILP (icon_left
))
2905 XSETINT (icon_left
, 0);
2907 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
2909 icon_top_no_change
= 1;
2910 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2911 if (NILP (icon_top
))
2912 XSETINT (icon_top
, 0);
2915 /* Don't set these parameters unless they've been explicitly
2916 specified. The window might be mapped or resized while we're in
2917 this function, and we don't want to override that unless the lisp
2918 code has asked for it.
2920 Don't set these parameters unless they actually differ from the
2921 window's current parameters; the window may not actually exist
2926 check_frame_size (f
, &height
, &width
);
2928 XSETFRAME (frame
, f
);
2931 && (width
!= FRAME_COLS (f
)
2932 || height
!= FRAME_LINES (f
)
2933 || f
->new_text_lines
|| f
->new_text_cols
))
2934 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2936 if ((!NILP (left
) || !NILP (top
))
2937 && ! (left_no_change
&& top_no_change
)
2938 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2939 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2944 /* Record the signs. */
2945 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2946 if (EQ (left
, Qminus
))
2947 f
->size_hint_flags
|= XNegative
;
2948 else if (TYPE_RANGED_INTEGERP (int, left
))
2950 leftpos
= XINT (left
);
2952 f
->size_hint_flags
|= XNegative
;
2954 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2955 && CONSP (XCDR (left
))
2956 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
2958 leftpos
= - XINT (XCAR (XCDR (left
)));
2959 f
->size_hint_flags
|= XNegative
;
2961 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2962 && CONSP (XCDR (left
))
2963 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
2965 leftpos
= XINT (XCAR (XCDR (left
)));
2968 if (EQ (top
, Qminus
))
2969 f
->size_hint_flags
|= YNegative
;
2970 else if (TYPE_RANGED_INTEGERP (int, top
))
2972 toppos
= XINT (top
);
2974 f
->size_hint_flags
|= YNegative
;
2976 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2977 && CONSP (XCDR (top
))
2978 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
2980 toppos
= - XINT (XCAR (XCDR (top
)));
2981 f
->size_hint_flags
|= YNegative
;
2983 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2984 && CONSP (XCDR (top
))
2985 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
2987 toppos
= XINT (XCAR (XCDR (top
)));
2991 /* Store the numeric value of the position. */
2992 f
->top_pos
= toppos
;
2993 f
->left_pos
= leftpos
;
2995 f
->win_gravity
= NorthWestGravity
;
2997 /* Actually set that position, and convert to absolute. */
2998 x_set_offset (f
, leftpos
, toppos
, -1);
3001 if ((!NILP (icon_left
) || !NILP (icon_top
))
3002 && ! (icon_left_no_change
&& icon_top_no_change
))
3003 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3010 /* Insert a description of internally-recorded parameters of frame X
3011 into the parameter alist *ALISTPTR that is to be given to the user.
3012 Only parameters that are specific to the X window system
3013 and whose values are not correctly recorded in the frame's
3014 param_alist need to be considered here. */
3017 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3023 /* Represent negative positions (off the top or left screen edge)
3024 in a way that Fmodify_frame_parameters will understand correctly. */
3025 XSETINT (tem
, f
->left_pos
);
3026 if (f
->left_pos
>= 0)
3027 store_in_alist (alistptr
, Qleft
, tem
);
3029 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3031 XSETINT (tem
, f
->top_pos
);
3032 if (f
->top_pos
>= 0)
3033 store_in_alist (alistptr
, Qtop
, tem
);
3035 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3037 store_in_alist (alistptr
, Qborder_width
,
3038 make_number (f
->border_width
));
3039 store_in_alist (alistptr
, Qinternal_border_width
,
3040 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3041 store_in_alist (alistptr
, Qleft_fringe
,
3042 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3043 store_in_alist (alistptr
, Qright_fringe
,
3044 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3045 store_in_alist (alistptr
, Qscroll_bar_width
,
3046 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3048 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3049 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3050 /* nil means "use default width"
3051 for non-toolkit scroll bar.
3052 ruler-mode.el depends on this. */
3054 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
3055 MS-Windows it returns a value whose type is HANDLE, which is
3056 actually a pointer. Explicit casting avoids compiler
3058 w
= (unsigned long) FRAME_X_WINDOW (f
);
3059 store_in_alist (alistptr
, Qwindow_id
,
3060 make_formatted_string (buf
, "%lu", w
));
3061 #ifdef HAVE_X_WINDOWS
3062 #ifdef USE_X_TOOLKIT
3063 /* Tooltip frame may not have this widget. */
3064 if (FRAME_X_OUTPUT (f
)->widget
)
3066 w
= (unsigned long) FRAME_OUTER_WINDOW (f
);
3067 store_in_alist (alistptr
, Qouter_window_id
,
3068 make_formatted_string (buf
, "%lu", w
));
3070 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3071 FRAME_SAMPLE_VISIBILITY (f
);
3072 store_in_alist (alistptr
, Qvisibility
,
3073 (FRAME_VISIBLE_P (f
) ? Qt
3074 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3075 store_in_alist (alistptr
, Qdisplay
,
3076 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3078 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3081 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3082 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3083 store_in_alist (alistptr
, Qparent_id
, tem
);
3084 store_in_alist (alistptr
, Qtool_bar_position
, f
->tool_bar_position
);
3088 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3089 the previous value of that parameter, NEW_VALUE is the new value. */
3092 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3094 if (NILP (new_value
))
3095 f
->want_fullscreen
= FULLSCREEN_NONE
;
3096 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3097 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3098 else if (EQ (new_value
, Qfullwidth
))
3099 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3100 else if (EQ (new_value
, Qfullheight
))
3101 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3102 else if (EQ (new_value
, Qmaximized
))
3103 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3105 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3106 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3110 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3111 the previous value of that parameter, NEW_VALUE is the new value. */
3114 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3116 if (NILP (new_value
))
3117 f
->extra_line_spacing
= 0;
3118 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
3119 f
->extra_line_spacing
= XFASTINT (new_value
);
3121 signal_error ("Invalid line-spacing", new_value
);
3122 if (FRAME_VISIBLE_P (f
))
3127 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3128 the previous value of that parameter, NEW_VALUE is the new value. */
3131 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3133 Lisp_Object bgcolor
;
3135 if (NILP (new_value
))
3137 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3138 /* The value 0.4545 is the normal viewing gamma. */
3139 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3141 signal_error ("Invalid screen-gamma", new_value
);
3143 /* Apply the new gamma value to the frame background. */
3144 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3145 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3147 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3148 if (NATNUMP (parm_index
)
3149 && (XFASTINT (parm_index
)
3150 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3151 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3152 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3156 Fclear_face_cache (Qnil
);
3161 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3163 Lisp_Object font_object
;
3165 #ifdef HAVE_X_WINDOWS
3166 Lisp_Object font_param
= arg
;
3169 /* Set the frame parameter back to the old value because we may
3170 fail to use ARG as the new parameter value. */
3171 store_frame_param (f
, Qfont
, oldval
);
3173 /* ARG is a fontset name, a font name, a cons of fontset name and a
3174 font object, or a font object. In the last case, this function
3178 fontset
= fs_query_fontset (arg
, 0);
3181 font_object
= font_open_by_name (f
, arg
);
3182 if (NILP (font_object
))
3183 error ("Font `%s' is not defined", SSDATA (arg
));
3184 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3186 else if (fontset
> 0)
3188 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
3189 if (NILP (font_object
))
3190 error ("Font `%s' is not defined", SDATA (arg
));
3191 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3194 error ("The default fontset can't be used for a frame font");
3196 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3198 /* This is the case that the ASCII font of F's fontset XCAR
3199 (arg) is changed to the font XCDR (arg) by
3200 `set-fontset-font'. */
3201 fontset
= fs_query_fontset (XCAR (arg
), 0);
3203 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3204 font_object
= XCDR (arg
);
3205 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3206 #ifdef HAVE_X_WINDOWS
3207 font_param
= Ffont_get (font_object
, QCname
);
3210 else if (FONT_OBJECT_P (arg
))
3213 #ifdef HAVE_X_WINDOWS
3214 font_param
= Ffont_get (font_object
, QCname
);
3216 /* This is to store the XLFD font name in the frame parameter for
3217 backward compatibility. We should store the font-object
3218 itself in the future. */
3219 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3220 fontset
= FRAME_FONTSET (f
);
3221 /* Check if we can use the current fontset. If not, set FONTSET
3222 to -1 to generate a new fontset from FONT-OBJECT. */
3225 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3226 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3228 if (! font_match_p (spec
, font_object
))
3233 signal_error ("Invalid font", arg
);
3235 if (! NILP (Fequal (font_object
, oldval
)))
3238 x_new_font (f
, font_object
, fontset
);
3239 store_frame_param (f
, Qfont
, arg
);
3240 #ifdef HAVE_X_WINDOWS
3241 store_frame_param (f
, Qfont_param
, font_param
);
3243 /* Recalculate toolbar height. */
3244 f
->n_tool_bar_rows
= 0;
3245 /* Ensure we redraw it. */
3246 clear_current_matrices (f
);
3248 recompute_basic_faces (f
);
3250 do_pending_window_change (0);
3252 /* We used to call face-set-after-frame-default here, but it leads to
3253 recursive calls (since that function can set the `default' face's
3254 font which in turns changes the frame's `font' parameter).
3255 Also I don't know what this call is meant to do, but it seems the
3256 wrong way to do it anyway (it does a lot more work than what seems
3257 reasonable in response to a change to `font'). */
3262 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3264 if (! NILP (new_value
)
3265 && !CONSP (new_value
))
3269 CHECK_STRING (new_value
);
3270 p0
= p1
= SSDATA (new_value
);
3274 while (*p1
&& ! isspace (*p1
) && *p1
!= ',') p1
++;
3276 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3282 while ((c
= *++p1
) && isspace (c
));
3286 new_value
= Fnreverse (new_value
);
3289 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3293 free_all_realized_faces (Qnil
);
3295 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3296 if (NILP (new_value
))
3298 if (NILP (old_value
))
3299 error ("No font backend available");
3300 font_update_drivers (f
, old_value
);
3301 error ("None of specified font backends are available");
3303 store_frame_param (f
, Qfont_backend
, new_value
);
3309 XSETFRAME (frame
, f
);
3310 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3311 ++face_change_count
;
3312 ++windows_or_buffers_changed
;
3318 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3320 compute_fringe_widths (f
, 1);
3321 #ifdef HAVE_X_WINDOWS
3322 /* Must adjust this so window managers report correct number of columns. */
3323 if (FRAME_X_WINDOW (f
) != 0)
3324 x_wm_set_size_hint (f
, 0, 0);
3329 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3331 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3333 if (XINT (arg
) == f
->border_width
)
3336 if (FRAME_X_WINDOW (f
) != 0)
3337 error ("Cannot change the border width of a frame");
3339 f
->border_width
= XINT (arg
);
3343 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3345 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3347 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3348 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3349 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3350 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3352 #ifdef USE_X_TOOLKIT
3353 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3354 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3357 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3360 if (FRAME_X_WINDOW (f
) != 0)
3362 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3363 SET_FRAME_GARBAGED (f
);
3364 do_pending_window_change (0);
3367 SET_FRAME_GARBAGED (f
);
3371 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3374 XSETFRAME (frame
, f
);
3377 Fmake_frame_invisible (frame
, Qt
);
3378 else if (EQ (value
, Qicon
))
3379 Ficonify_frame (frame
);
3381 Fmake_frame_visible (frame
);
3385 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3387 f
->auto_raise
= !EQ (Qnil
, arg
);
3391 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3393 f
->auto_lower
= !EQ (Qnil
, arg
);
3397 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3399 f
->no_split
= !NILP (arg
);
3403 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3405 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3406 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3407 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3408 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3410 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3412 ? vertical_scroll_bar_none
3414 ? vertical_scroll_bar_left
3416 ? vertical_scroll_bar_right
3417 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3418 ? vertical_scroll_bar_left
3419 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3420 ? vertical_scroll_bar_right
3421 : vertical_scroll_bar_none
);
3423 /* We set this parameter before creating the X window for the
3424 frame, so we can get the geometry right from the start.
3425 However, if the window hasn't been created yet, we shouldn't
3426 call x_set_window_size. */
3427 if (FRAME_X_WINDOW (f
))
3428 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3429 do_pending_window_change (0);
3434 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3436 int wid
= FRAME_COLUMN_WIDTH (f
);
3440 x_set_scroll_bar_default_width (f
);
3442 if (FRAME_X_WINDOW (f
))
3443 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3444 do_pending_window_change (0);
3446 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3447 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3449 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3450 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3452 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3453 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3454 if (FRAME_X_WINDOW (f
))
3455 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3456 do_pending_window_change (0);
3459 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3460 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3461 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3466 /* Return non-nil if frame F wants a bitmap icon. */
3469 x_icon_type (FRAME_PTR f
)
3473 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3481 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3488 for (i
= 0; i
< 2; i
++)
3501 else if (FLOATP (item
))
3503 alpha
= XFLOAT_DATA (item
);
3504 if (alpha
< 0.0 || 1.0 < alpha
)
3505 args_out_of_range (make_float (0.0), make_float (1.0));
3507 else if (INTEGERP (item
))
3509 EMACS_INT ialpha
= XINT (item
);
3510 if (ialpha
< 0 || 100 < ialpha
)
3511 args_out_of_range (make_number (0), make_number (100));
3513 alpha
= ialpha
/ 100.0;
3516 wrong_type_argument (Qnumberp
, item
);
3520 for (i
= 0; i
< 2; i
++)
3521 f
->alpha
[i
] = newval
[i
];
3523 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3525 x_set_frame_alpha (f
);
3533 /* Subroutines of creating an X frame. */
3535 /* Make sure that Vx_resource_name is set to a reasonable value.
3536 Fix it up, or set it to `emacs' if it is too hopeless. */
3539 validate_x_resource_name (void)
3542 /* Number of valid characters in the resource name. */
3543 ptrdiff_t good_count
= 0;
3544 /* Number of invalid characters in the resource name. */
3545 ptrdiff_t bad_count
= 0;
3549 if (!STRINGP (Vx_resource_class
))
3550 Vx_resource_class
= build_string (EMACS_CLASS
);
3552 if (STRINGP (Vx_resource_name
))
3554 unsigned char *p
= SDATA (Vx_resource_name
);
3556 len
= SBYTES (Vx_resource_name
);
3558 /* Only letters, digits, - and _ are valid in resource names.
3559 Count the valid characters and count the invalid ones. */
3560 for (i
= 0; i
< len
; i
++)
3563 if (! ((c
>= 'a' && c
<= 'z')
3564 || (c
>= 'A' && c
<= 'Z')
3565 || (c
>= '0' && c
<= '9')
3566 || c
== '-' || c
== '_'))
3573 /* Not a string => completely invalid. */
3574 bad_count
= 5, good_count
= 0;
3576 /* If name is valid already, return. */
3580 /* If name is entirely invalid, or nearly so, or is so implausibly
3581 large that alloca might not work, use `emacs'. */
3582 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
3584 Vx_resource_name
= build_string ("emacs");
3588 /* Name is partly valid. Copy it and replace the invalid characters
3589 with underscores. */
3591 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3593 for (i
= 0; i
< len
; i
++)
3595 int c
= SREF (new, i
);
3596 if (! ((c
>= 'a' && c
<= 'z')
3597 || (c
>= 'A' && c
<= 'Z')
3598 || (c
>= '0' && c
<= '9')
3599 || c
== '-' || c
== '_'))
3605 extern char *x_get_string_resource (XrmDatabase
, const char *, const char *);
3606 extern Display_Info
*check_x_display_info (Lisp_Object
);
3609 /* Get specified attribute from resource database RDB.
3610 See Fx_get_resource below for other parameters. */
3613 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3615 register char *value
;
3619 CHECK_STRING (attribute
);
3620 CHECK_STRING (class);
3622 if (!NILP (component
))
3623 CHECK_STRING (component
);
3624 if (!NILP (subclass
))
3625 CHECK_STRING (subclass
);
3626 if (NILP (component
) != NILP (subclass
))
3627 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3629 validate_x_resource_name ();
3631 /* Allocate space for the components, the dots which separate them,
3632 and the final '\0'. Make them big enough for the worst case. */
3633 name_key
= alloca (SBYTES (Vx_resource_name
)
3634 + (STRINGP (component
)
3635 ? SBYTES (component
) : 0)
3636 + SBYTES (attribute
)
3639 class_key
= alloca (SBYTES (Vx_resource_class
)
3641 + (STRINGP (subclass
)
3642 ? SBYTES (subclass
) : 0)
3645 /* Start with emacs.FRAMENAME for the name (the specific one)
3646 and with `Emacs' for the class key (the general one). */
3647 strcpy (name_key
, SSDATA (Vx_resource_name
));
3648 strcpy (class_key
, SSDATA (Vx_resource_class
));
3650 strcat (class_key
, ".");
3651 strcat (class_key
, SSDATA (class));
3653 if (!NILP (component
))
3655 strcat (class_key
, ".");
3656 strcat (class_key
, SSDATA (subclass
));
3658 strcat (name_key
, ".");
3659 strcat (name_key
, SSDATA (component
));
3662 strcat (name_key
, ".");
3663 strcat (name_key
, SSDATA (attribute
));
3665 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3667 if (value
!= (char *) 0 && *value
)
3668 return build_string (value
);
3674 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3675 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3676 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3677 class, where INSTANCE is the name under which Emacs was invoked, or
3678 the name specified by the `-name' or `-rn' command-line arguments.
3680 The optional arguments COMPONENT and SUBCLASS add to the key and the
3681 class, respectively. You must specify both of them or neither.
3682 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3683 and the class is `Emacs.CLASS.SUBCLASS'. */)
3684 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3686 #ifdef HAVE_X_WINDOWS
3690 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3691 attribute
, class, component
, subclass
);
3694 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3697 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3699 return xrdb_get_resource (dpyinfo
->xrdb
,
3700 attribute
, class, component
, subclass
);
3703 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3704 /* Used when C code wants a resource value. */
3705 /* Called from oldXMenu/Create.c. */
3707 x_get_resource_string (const char *attribute
, const char *class)
3710 struct frame
*sf
= SELECTED_FRAME ();
3711 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
3714 /* Allocate space for the components, the dots which separate them,
3715 and the final '\0'. */
3716 char *name_key
= SAFE_ALLOCA (invocation_namelen
+ strlen (attribute
) + 2);
3717 char *class_key
= alloca ((sizeof (EMACS_CLASS
) - 1) + strlen (class) + 2);
3719 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
3720 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3722 result
= x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3723 name_key
, class_key
);
3729 /* Return the value of parameter PARAM.
3731 First search ALIST, then Vdefault_frame_alist, then the X defaults
3732 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3734 Convert the resource to the type specified by desired_type.
3736 If no default is specified, return Qunbound. If you call
3737 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3738 and don't let it get stored in any Lisp-visible variables! */
3741 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3742 const char *attribute
, const char *class, enum resource_types type
)
3744 register Lisp_Object tem
;
3746 tem
= Fassq (param
, alist
);
3750 /* If we find this parm in ALIST, clear it out
3751 so that it won't be "left over" at the end. */
3753 XSETCAR (tem
, Qnil
);
3754 /* In case the parameter appears more than once in the alist,
3756 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3757 if (CONSP (XCAR (tail
))
3758 && EQ (XCAR (XCAR (tail
)), param
))
3759 XSETCAR (XCAR (tail
), Qnil
);
3762 tem
= Fassq (param
, Vdefault_frame_alist
);
3764 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3765 look in the X resources. */
3768 if (attribute
&& dpyinfo
)
3770 tem
= display_x_get_resource (dpyinfo
,
3771 build_string (attribute
),
3772 build_string (class),
3780 case RES_TYPE_NUMBER
:
3781 return make_number (atoi (SSDATA (tem
)));
3783 case RES_TYPE_BOOLEAN_NUMBER
:
3784 if (!strcmp (SSDATA (tem
), "on")
3785 || !strcmp (SSDATA (tem
), "true"))
3786 return make_number (1);
3787 return make_number (atoi (SSDATA (tem
)));
3790 case RES_TYPE_FLOAT
:
3791 return make_float (atof (SSDATA (tem
)));
3793 case RES_TYPE_BOOLEAN
:
3794 tem
= Fdowncase (tem
);
3795 if (!strcmp (SSDATA (tem
), "on")
3797 || !strcmp (SSDATA (tem
), "yes")
3799 || !strcmp (SSDATA (tem
), "true"))
3804 case RES_TYPE_STRING
:
3807 case RES_TYPE_SYMBOL
:
3808 /* As a special case, we map the values `true' and `on'
3809 to Qt, and `false' and `off' to Qnil. */
3812 lower
= Fdowncase (tem
);
3813 if (!strcmp (SSDATA (lower
), "on")
3815 || !strcmp (SSDATA (lower
), "yes")
3817 || !strcmp (SSDATA (lower
), "true"))
3819 else if (!strcmp (SSDATA (lower
), "off")
3821 || !strcmp (SSDATA (lower
), "no")
3823 || !strcmp (SSDATA (lower
), "false"))
3826 return Fintern (tem
, Qnil
);
3840 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3841 const char *attribute
, const char *class,
3842 enum resource_types type
)
3844 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3845 alist
, param
, attribute
, class, type
);
3848 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3851 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3853 const char *attribute
, const char *class,
3854 enum resource_types type
)
3858 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3859 attribute
, class, type
);
3860 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3861 store_frame_param (f
, param
, value
);
3867 /* Record in frame F the specified or default value according to ALIST
3868 of the parameter named PROP (a Lisp symbol).
3869 If no value is specified for PROP, look for an X default for XPROP
3870 on the frame named NAME.
3871 If that is not found either, use the value DEFLT. */
3874 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
3875 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
3876 enum resource_types type
)
3880 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3881 if (EQ (tem
, Qunbound
))
3883 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3890 /* NS used to define x-parse-geometry in ns-win.el, but that confused
3891 make-docfile: the documentation string in ns-win.el was used for
3892 x-parse-geometry even in non-NS builds.
3894 With two definitions of x-parse-geometry in this file, various
3895 things still get confused (eg M-x apropos documentation), so that
3896 it is best if the two definitions just share the same doc-string.
3898 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3899 doc
: /* Parse a display geometry string STRING.
3900 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3901 The properties returned may include `top', `left', `height', and `width'.
3902 For X, the value of `left' or `top' may be an integer,
3903 or a list (+ N) meaning N pixels relative to top/left corner,
3904 or a list (- N) meaning -N pixels relative to bottom/right corner.
3905 On Nextstep, this just calls `ns-parse-geometry'. */)
3906 (Lisp_Object string
)
3909 return call1 (Qns_parse_geometry
, string
);
3912 unsigned int width
, height
;
3915 CHECK_STRING (string
);
3917 geometry
= XParseGeometry (SSDATA (string
),
3918 &x
, &y
, &width
, &height
);
3920 if (geometry
& XValue
)
3922 Lisp_Object element
;
3924 if (x
>= 0 && (geometry
& XNegative
))
3925 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3926 else if (x
< 0 && ! (geometry
& XNegative
))
3927 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3929 element
= Fcons (Qleft
, make_number (x
));
3930 result
= Fcons (element
, result
);
3933 if (geometry
& YValue
)
3935 Lisp_Object element
;
3937 if (y
>= 0 && (geometry
& YNegative
))
3938 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3939 else if (y
< 0 && ! (geometry
& YNegative
))
3940 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3942 element
= Fcons (Qtop
, make_number (y
));
3943 result
= Fcons (element
, result
);
3946 if (geometry
& WidthValue
)
3947 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3948 if (geometry
& HeightValue
)
3949 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3952 #endif /* HAVE_NS */
3956 /* Calculate the desired size and position of frame F.
3957 Return the flags saying which aspects were specified.
3959 Also set the win_gravity and size_hint_flags of F.
3961 Adjust height for toolbar if TOOLBAR_P is 1.
3963 This function does not make the coordinates positive. */
3965 #define DEFAULT_ROWS 35
3966 #define DEFAULT_COLS 80
3969 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, int toolbar_p
)
3971 register Lisp_Object tem0
, tem1
, tem2
;
3972 long window_prompting
= 0;
3973 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3975 /* Default values if we fall through.
3976 Actually, if that happens we should get
3977 window manager prompting. */
3978 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3979 FRAME_LINES (f
) = DEFAULT_ROWS
;
3980 /* Window managers expect that if program-specified
3981 positions are not (0,0), they're intentional, not defaults. */
3985 /* Ensure that old new_text_cols and new_text_lines will not override the
3987 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3988 f
->new_text_cols
= f
->new_text_lines
= 0;
3990 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3991 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3992 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3993 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3995 if (!EQ (tem0
, Qunbound
))
3997 CHECK_NUMBER (tem0
);
3998 if (! (0 <= XINT (tem0
) && XINT (tem0
) <= INT_MAX
))
3999 xsignal1 (Qargs_out_of_range
, tem0
);
4000 FRAME_LINES (f
) = XINT (tem0
);
4002 if (!EQ (tem1
, Qunbound
))
4004 CHECK_NUMBER (tem1
);
4005 if (! (0 <= XINT (tem1
) && XINT (tem1
) <= INT_MAX
))
4006 xsignal1 (Qargs_out_of_range
, tem1
);
4007 SET_FRAME_COLS (f
, XINT (tem1
));
4009 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4010 window_prompting
|= USSize
;
4012 window_prompting
|= PSize
;
4015 f
->scroll_bar_actual_width
4016 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4018 /* This used to be done _before_ calling x_figure_window_size, but
4019 since the height is reset here, this was really a no-op. I
4020 assume that moving it here does what Gerd intended (although he
4021 no longer can remember what that was... ++KFS, 2003-03-25. */
4023 /* Add the tool-bar height to the initial frame height so that the
4024 user gets a text display area of the size he specified with -g or
4025 via .Xdefaults. Later changes of the tool-bar height don't
4026 change the frame size. This is done so that users can create
4027 tall Emacs frames without having to guess how tall the tool-bar
4029 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4031 int margin
, relief
, bar_height
;
4033 relief
= (tool_bar_button_relief
>= 0
4034 ? tool_bar_button_relief
4035 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4037 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
4038 margin
= XFASTINT (Vtool_bar_button_margin
);
4039 else if (CONSP (Vtool_bar_button_margin
)
4040 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
4041 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4045 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4046 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4049 compute_fringe_widths (f
, 0);
4051 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4052 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4054 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4055 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4056 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4057 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4059 if (EQ (tem0
, Qminus
))
4062 window_prompting
|= YNegative
;
4064 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4065 && CONSP (XCDR (tem0
))
4066 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem0
)), INT_MAX
))
4068 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4069 window_prompting
|= YNegative
;
4071 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4072 && CONSP (XCDR (tem0
))
4073 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0
))))
4075 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4077 else if (EQ (tem0
, Qunbound
))
4081 CHECK_TYPE_RANGED_INTEGER (int, tem0
);
4082 f
->top_pos
= XINT (tem0
);
4084 window_prompting
|= YNegative
;
4087 if (EQ (tem1
, Qminus
))
4090 window_prompting
|= XNegative
;
4092 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4093 && CONSP (XCDR (tem1
))
4094 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem1
)), INT_MAX
))
4096 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4097 window_prompting
|= XNegative
;
4099 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4100 && CONSP (XCDR (tem1
))
4101 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1
))))
4103 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4105 else if (EQ (tem1
, Qunbound
))
4109 CHECK_TYPE_RANGED_INTEGER (int, tem1
);
4110 f
->left_pos
= XINT (tem1
);
4111 if (f
->left_pos
< 0)
4112 window_prompting
|= XNegative
;
4115 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4116 window_prompting
|= USPosition
;
4118 window_prompting
|= PPosition
;
4121 if (window_prompting
& XNegative
)
4123 if (window_prompting
& YNegative
)
4124 f
->win_gravity
= SouthEastGravity
;
4126 f
->win_gravity
= NorthEastGravity
;
4130 if (window_prompting
& YNegative
)
4131 f
->win_gravity
= SouthWestGravity
;
4133 f
->win_gravity
= NorthWestGravity
;
4136 f
->size_hint_flags
= window_prompting
;
4138 return window_prompting
;
4143 #endif /* HAVE_WINDOW_SYSTEM */
4146 frame_make_pointer_invisible (void)
4148 if (! NILP (Vmake_pointer_invisible
))
4151 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4154 f
= SELECTED_FRAME ();
4155 if (f
&& !f
->pointer_invisible
4156 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4159 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4160 f
->pointer_invisible
= 1;
4166 frame_make_pointer_visible (void)
4168 /* We don't check Vmake_pointer_invisible here in case the
4169 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4172 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4175 f
= SELECTED_FRAME ();
4176 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4177 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4179 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4180 f
->pointer_invisible
= 0;
4184 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4185 Sframe_pointer_visible_p
, 0, 1, 0,
4186 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4187 Otherwise it returns nil. FRAME omitted or nil means the
4188 selected frame. This is useful when `make-pointer-invisible' is set. */)
4192 frame
= selected_frame
;
4194 CHECK_FRAME (frame
);
4196 return (XFRAME (frame
)->pointer_invisible
? Qnil
: Qt
);
4200 /***********************************************************************
4202 ***********************************************************************/
4205 syms_of_frame (void)
4207 DEFSYM (Qframep
, "framep");
4208 DEFSYM (Qframe_live_p
, "frame-live-p");
4209 DEFSYM (Qexplicit_name
, "explicit-name");
4210 DEFSYM (Qheight
, "height");
4211 DEFSYM (Qicon
, "icon");
4212 DEFSYM (Qminibuffer
, "minibuffer");
4213 DEFSYM (Qmodeline
, "modeline");
4214 DEFSYM (Qonly
, "only");
4215 DEFSYM (Qnone
, "none");
4216 DEFSYM (Qwidth
, "width");
4217 DEFSYM (Qgeometry
, "geometry");
4218 DEFSYM (Qicon_left
, "icon-left");
4219 DEFSYM (Qicon_top
, "icon-top");
4220 DEFSYM (Qtooltip
, "tooltip");
4221 DEFSYM (Qleft
, "left");
4222 DEFSYM (Qright
, "right");
4223 DEFSYM (Quser_position
, "user-position");
4224 DEFSYM (Quser_size
, "user-size");
4225 DEFSYM (Qwindow_id
, "window-id");
4226 #ifdef HAVE_X_WINDOWS
4227 DEFSYM (Qouter_window_id
, "outer-window-id");
4229 DEFSYM (Qparent_id
, "parent-id");
4231 DEFSYM (Qw32
, "w32");
4233 DEFSYM (Qmac
, "mac");
4235 DEFSYM (Qvisible
, "visible");
4236 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4237 DEFSYM (Qbuffer_list
, "buffer-list");
4238 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4239 DEFSYM (Qdisplay_type
, "display-type");
4240 DEFSYM (Qbackground_mode
, "background-mode");
4241 DEFSYM (Qnoelisp
, "noelisp");
4242 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4243 DEFSYM (Qtty
, "tty");
4244 DEFSYM (Qtty_type
, "tty-type");
4246 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4248 DEFSYM (Qfullwidth
, "fullwidth");
4249 DEFSYM (Qfullheight
, "fullheight");
4250 DEFSYM (Qfullboth
, "fullboth");
4251 DEFSYM (Qmaximized
, "maximized");
4252 DEFSYM (Qx_resource_name
, "x-resource-name");
4253 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4255 DEFSYM (Qterminal
, "terminal");
4256 DEFSYM (Qterminal_live_p
, "terminal-live-p");
4259 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4265 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4267 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4268 if (frame_parms
[i
].variable
)
4270 *frame_parms
[i
].variable
= v
;
4271 staticpro (frame_parms
[i
].variable
);
4273 Fput (v
, Qx_frame_parameter
, make_number (i
));
4277 #ifdef HAVE_WINDOW_SYSTEM
4278 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4279 doc
: /* The name Emacs uses to look up X resources.
4280 `x-get-resource' uses this as the first component of the instance name
4281 when requesting resource values.
4282 Emacs initially sets `x-resource-name' to the name under which Emacs
4283 was invoked, or to the value specified with the `-name' or `-rn'
4284 switches, if present.
4286 It may be useful to bind this variable locally around a call
4287 to `x-get-resource'. See also the variable `x-resource-class'. */);
4288 Vx_resource_name
= Qnil
;
4290 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4291 doc
: /* The class Emacs uses to look up X resources.
4292 `x-get-resource' uses this as the first component of the instance class
4293 when requesting resource values.
4295 Emacs initially sets `x-resource-class' to "Emacs".
4297 Setting this variable permanently is not a reasonable thing to do,
4298 but binding this variable locally around a call to `x-get-resource'
4299 is a reasonable practice. See also the variable `x-resource-name'. */);
4300 Vx_resource_class
= build_string (EMACS_CLASS
);
4302 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4303 doc
: /* The lower limit of the frame opacity (alpha transparency).
4304 The value should range from 0 (invisible) to 100 (completely opaque).
4305 You can also use a floating number between 0.0 and 1.0.
4306 The default is 20. */);
4307 Vframe_alpha_lower_limit
= make_number (20);
4310 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4311 doc
: /* Alist of default values for frame creation.
4312 These may be set in your init file, like this:
4313 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4314 These override values given in window system configuration data,
4315 including X Windows' defaults database.
4316 For values specific to the first Emacs frame, see `initial-frame-alist'.
4317 For window-system specific values, see `window-system-default-frame-alist'.
4318 For values specific to the separate minibuffer frame, see
4319 `minibuffer-frame-alist'.
4320 The `menu-bar-lines' element of the list controls whether new frames
4321 have menu bars; `menu-bar-mode' works by altering this element.
4322 Setting this variable does not affect existing frames, only new ones. */);
4323 Vdefault_frame_alist
= Qnil
;
4325 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4326 doc
: /* Default position of scroll bars on this window-system. */);
4327 #ifdef HAVE_WINDOW_SYSTEM
4328 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
4329 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4331 Vdefault_frame_scroll_bars
= Qright
;
4333 Vdefault_frame_scroll_bars
= Qleft
;
4336 Vdefault_frame_scroll_bars
= Qnil
;
4339 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4340 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4342 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4343 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4344 `mouse-position' calls this function, passing its usual return value as
4345 argument, and returns whatever this function returns.
4346 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4347 which need to do mouse handling at the Lisp level. */);
4348 Vmouse_position_function
= Qnil
;
4350 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4351 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4352 If the value is an integer, highlighting is only shown after moving the
4353 mouse, while keyboard input turns off the highlight even when the mouse
4354 is over the clickable text. However, the mouse shape still indicates
4355 when the mouse is over clickable text. */);
4356 Vmouse_highlight
= Qt
;
4358 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4359 doc
: /* If non-nil, make pointer invisible while typing.
4360 The pointer becomes visible again when the mouse is moved. */);
4361 Vmake_pointer_invisible
= Qt
;
4363 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4364 doc
: /* Functions run before deleting a frame.
4365 The functions are run with one arg, the frame to be deleted.
4368 Note that functions in this list may be called just before the frame is
4369 actually deleted, or some time later (or even both when an earlier function
4370 in `delete-frame-functions' (indirectly) calls `delete-frame'
4372 Vdelete_frame_functions
= Qnil
;
4373 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
4375 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4376 doc
: /* Non-nil if Menu-Bar mode is enabled.
4377 See the command `menu-bar-mode' for a description of this minor mode.
4378 Setting this variable directly does not take effect;
4379 either customize it (see the info node `Easy Customization')
4380 or call the function `menu-bar-mode'. */);
4381 Vmenu_bar_mode
= Qt
;
4383 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4384 doc
: /* Non-nil if Tool-Bar mode is enabled.
4385 See the command `tool-bar-mode' for a description of this minor mode.
4386 Setting this variable directly does not take effect;
4387 either customize it (see the info node `Easy Customization')
4388 or call the function `tool-bar-mode'. */);
4389 #ifdef HAVE_WINDOW_SYSTEM
4390 Vtool_bar_mode
= Qt
;
4392 Vtool_bar_mode
= Qnil
;
4395 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4396 doc
: /* Minibufferless frames use this frame's minibuffer.
4398 Emacs cannot create minibufferless frames unless this is set to an
4399 appropriate surrogate.
4401 Emacs consults this variable only when creating minibufferless
4402 frames; once the frame is created, it sticks with its assigned
4403 minibuffer, no matter what this variable is set to. This means that
4404 this variable doesn't necessarily say anything meaningful about the
4405 current set of frames, or where the minibuffer is currently being
4408 This variable is local to the current terminal and cannot be buffer-local. */);
4410 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
4411 doc
: /* Non-nil if window system changes focus when you move the mouse.
4412 You should set this variable to tell Emacs how your window manager
4413 handles focus, since there is no way in general for Emacs to find out
4414 automatically. See also `mouse-autoselect-window'. */);
4415 focus_follows_mouse
= 0;
4417 staticpro (&Vframe_list
);
4420 defsubr (&Sframe_live_p
);
4421 defsubr (&Swindow_system
);
4422 defsubr (&Smake_terminal_frame
);
4423 defsubr (&Shandle_switch_frame
);
4424 defsubr (&Sselect_frame
);
4425 defsubr (&Sselected_frame
);
4426 defsubr (&Sframe_list
);
4427 defsubr (&Snext_frame
);
4428 defsubr (&Sprevious_frame
);
4429 defsubr (&Sdelete_frame
);
4430 defsubr (&Smouse_position
);
4431 defsubr (&Smouse_pixel_position
);
4432 defsubr (&Sset_mouse_position
);
4433 defsubr (&Sset_mouse_pixel_position
);
4435 defsubr (&Sframe_configuration
);
4436 defsubr (&Srestore_frame_configuration
);
4438 defsubr (&Smake_frame_visible
);
4439 defsubr (&Smake_frame_invisible
);
4440 defsubr (&Siconify_frame
);
4441 defsubr (&Sframe_visible_p
);
4442 defsubr (&Svisible_frame_list
);
4443 defsubr (&Sraise_frame
);
4444 defsubr (&Slower_frame
);
4445 defsubr (&Sredirect_frame_focus
);
4446 defsubr (&Sframe_focus
);
4447 defsubr (&Sframe_parameters
);
4448 defsubr (&Sframe_parameter
);
4449 defsubr (&Smodify_frame_parameters
);
4450 defsubr (&Sframe_char_height
);
4451 defsubr (&Sframe_char_width
);
4452 defsubr (&Sframe_pixel_height
);
4453 defsubr (&Sframe_pixel_width
);
4454 defsubr (&Stool_bar_pixel_width
);
4455 defsubr (&Sset_frame_height
);
4456 defsubr (&Sset_frame_width
);
4457 defsubr (&Sset_frame_size
);
4458 defsubr (&Sset_frame_position
);
4459 defsubr (&Sframe_pointer_visible_p
);
4461 #ifdef HAVE_WINDOW_SYSTEM
4462 defsubr (&Sx_get_resource
);
4463 defsubr (&Sx_parse_geometry
);