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/>. */
22 #define FRAME_INLINE EXTERN_INLINE
31 #include "character.h"
33 #ifdef HAVE_WINDOW_SYSTEM
35 #endif /* HAVE_WINDOW_SYSTEM */
38 /* These help us bind and responding to switch-frame events. */
42 #include "blockinput.h"
44 #include "termhooks.h"
45 #include "dispextern.h"
48 #ifdef HAVE_WINDOW_SYSTEM
57 Lisp_Object Qns_parse_geometry
;
60 Lisp_Object Qframep
, Qframe_live_p
;
61 Lisp_Object Qicon
, Qmodeline
;
62 Lisp_Object Qonly
, Qnone
;
63 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
, Qns
;
65 Lisp_Object Qdisplay_type
;
66 static Lisp_Object Qbackground_mode
;
69 static Lisp_Object Qx_frame_parameter
;
70 Lisp_Object Qx_resource_name
;
71 Lisp_Object Qterminal
;
72 Lisp_Object Qterminal_live_p
;
74 /* Frame parameters (set or reported). */
76 Lisp_Object Qauto_raise
, Qauto_lower
;
77 Lisp_Object Qborder_color
, Qborder_width
;
78 Lisp_Object Qcursor_color
, Qcursor_type
;
79 static Lisp_Object Qgeometry
; /* Not used */
80 Lisp_Object Qheight
, Qwidth
;
81 Lisp_Object Qleft
, Qright
;
82 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
84 Lisp_Object Qinternal_border_width
;
85 Lisp_Object Qmouse_color
;
86 Lisp_Object Qminibuffer
;
87 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
88 Lisp_Object Qvisibility
;
89 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
90 Lisp_Object Qscreen_gamma
;
91 Lisp_Object Qline_spacing
;
92 static Lisp_Object Quser_position
, Quser_size
;
93 Lisp_Object Qwait_for_wm
;
94 static Lisp_Object Qwindow_id
;
96 static Lisp_Object Qouter_window_id
;
98 Lisp_Object Qparent_id
;
99 Lisp_Object Qtitle
, Qname
;
100 static Lisp_Object Qexplicit_name
;
101 Lisp_Object Qunsplittable
;
102 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
, Qtool_bar_position
;
103 Lisp_Object Qleft_fringe
, Qright_fringe
;
104 Lisp_Object Qbuffer_predicate
;
105 static Lisp_Object Qbuffer_list
, Qburied_buffer_list
;
106 Lisp_Object Qtty_color_mode
;
107 Lisp_Object Qtty
, Qtty_type
;
109 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
111 Lisp_Object Qfont_backend
;
114 Lisp_Object Qface_set_after_frame_default
;
116 static Lisp_Object Qdelete_frame_functions
;
118 #ifdef HAVE_WINDOW_SYSTEM
119 static void x_report_frame_params (struct frame
*, Lisp_Object
*);
122 /* These setters are used only in this file, so they can be private. */
124 fset_buffer_predicate (struct frame
*f
, Lisp_Object val
)
126 f
->buffer_predicate
= val
;
129 fset_minibuffer_window (struct frame
*f
, Lisp_Object val
)
131 f
->minibuffer_window
= val
;
136 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
138 struct window
*w
= XWINDOW (window
);
140 w
->last_modified
= 0;
141 wset_top_line (w
, make_number (XFASTINT (w
->top_line
) + n
));
142 wset_total_lines (w
, make_number (XFASTINT (w
->total_lines
) - n
));
144 /* Handle just the top child in a vertical split. */
145 if (!NILP (w
->vchild
))
146 set_menu_bar_lines_1 (w
->vchild
, n
);
148 /* Adjust all children in a horizontal split. */
149 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
151 w
= XWINDOW (window
);
152 set_menu_bar_lines_1 (window
, n
);
157 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
160 int olines
= FRAME_MENU_BAR_LINES (f
);
162 /* Right now, menu bars don't work properly in minibuf-only frames;
163 most of the commands try to apply themselves to the minibuffer
164 frame itself, and get an error because you can't switch buffers
165 in or split the minibuffer window. */
166 if (FRAME_MINIBUF_ONLY_P (f
))
169 if (TYPE_RANGED_INTEGERP (int, value
))
170 nlines
= XINT (value
);
174 if (nlines
!= olines
)
176 windows_or_buffers_changed
++;
177 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
178 FRAME_MENU_BAR_LINES (f
) = nlines
;
179 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
184 Lisp_Object Vframe_list
;
187 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
188 doc
: /* Return non-nil if OBJECT is a frame.
190 t for a termcap frame (a character-only terminal),
191 'x' for an Emacs frame that is really an X window,
192 'w32' for an Emacs frame that is a window on MS-Windows display,
193 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
194 'pc' for a direct-write MS-DOS frame.
195 See also `frame-live-p'. */)
198 if (!FRAMEP (object
))
200 switch (XFRAME (object
)->output_method
)
202 case output_initial
: /* The initial frame is like a termcap frame. */
205 case output_x_window
:
209 case output_msdos_raw
:
220 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
221 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
222 Value is nil if OBJECT is not a live frame. If object is a live
223 frame, the return value indicates what sort of terminal device it is
224 displayed on. See the documentation of `framep' for possible
228 return ((FRAMEP (object
)
229 && FRAME_LIVE_P (XFRAME (object
)))
234 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
235 doc
: /* The name of the window system that FRAME is displaying through.
236 The value is a symbol:
237 nil for a termcap frame (a character-only terminal),
238 'x' for an Emacs frame that is really an X window,
239 'w32' for an Emacs frame that is a window on MS-Windows display,
240 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
241 'pc' for a direct-write MS-DOS frame.
243 FRAME defaults to the currently selected frame.
245 Use of this function as a predicate is deprecated. Instead,
246 use `display-graphic-p' or any of the other `display-*-p'
247 predicates which report frame's specific UI-related capabilities. */)
252 frame
= selected_frame
;
254 type
= Fframep (frame
);
257 wrong_type_argument (Qframep
, frame
);
266 make_frame (int mini_p
)
269 register struct frame
*f
;
270 register Lisp_Object root_window
;
271 register Lisp_Object mini_window
;
273 f
= allocate_frame ();
274 XSETFRAME (frame
, f
);
276 /* Initialize Lisp data. Note that allocate_frame initializes all
277 Lisp data to nil, so do it only for slots which should not be nil. */
278 fset_tool_bar_position (f
, Qtop
);
280 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
281 non-Lisp data, so do it only for slots which should not be zero.
282 To avoid subtle bugs and for the sake of readability, it's better to
283 initialize enum members explicitly even if their values are zero. */
284 f
->wants_modeline
= 1;
286 f
->has_minibuffer
= mini_p
;
287 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
288 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
289 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
290 #ifdef HAVE_WINDOW_SYSTEM
291 f
->want_fullscreen
= FULLSCREEN_NONE
;
294 root_window
= make_window ();
297 mini_window
= make_window ();
298 wset_next (XWINDOW (root_window
), mini_window
);
299 wset_prev (XWINDOW (mini_window
), root_window
);
300 XWINDOW (mini_window
)->mini
= 1;
301 wset_frame (XWINDOW (mini_window
), frame
);
302 fset_minibuffer_window (f
, mini_window
);
307 wset_next (XWINDOW (root_window
), Qnil
);
308 fset_minibuffer_window (f
, Qnil
);
311 wset_frame (XWINDOW (root_window
), frame
);
314 just so that there is "something there."
315 Correct size will be set up later with change_frame_size. */
317 SET_FRAME_COLS (f
, 10);
318 FRAME_LINES (f
) = 10;
320 wset_total_cols (XWINDOW (root_window
), make_number (10));
321 wset_total_lines (XWINDOW (root_window
), make_number (mini_p
? 9 : 10));
325 wset_total_cols (XWINDOW (mini_window
), make_number (10));
326 wset_top_line (XWINDOW (mini_window
), make_number (9));
327 wset_total_lines (XWINDOW (mini_window
), make_number (1));
330 /* Choose a buffer for the frame's root window. */
334 wset_buffer (XWINDOW (root_window
), Qt
);
335 buf
= Fcurrent_buffer ();
336 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
337 a space), try to find another one. */
338 if (SREF (Fbuffer_name (buf
), 0) == ' ')
339 buf
= other_buffer_safely (buf
);
341 /* Use set_window_buffer, not Fset_window_buffer, and don't let
342 hooks be run by it. The reason is that the whole frame/window
343 arrangement is not yet fully initialized at this point. Windows
344 don't have the right size, glyph matrices aren't initialized
345 etc. Running Lisp functions at this point surely ends in a
347 set_window_buffer (root_window
, buf
, 0, 0);
348 fset_buffer_list (f
, Fcons (buf
, Qnil
));
353 wset_buffer (XWINDOW (mini_window
), Qt
);
354 set_window_buffer (mini_window
,
355 (NILP (Vminibuffer_list
)
357 : Fcar (Vminibuffer_list
)),
361 fset_root_window (f
, root_window
);
362 fset_selected_window (f
, root_window
);
363 /* Make sure this window seems more recently used than
364 a newly-created, never-selected window. */
365 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
370 #ifdef HAVE_WINDOW_SYSTEM
371 /* Make a frame using a separate minibuffer window on another frame.
372 MINI_WINDOW is the minibuffer window to use. nil means use the
373 default (the global minibuffer). */
376 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
378 register struct frame
*f
;
381 if (!NILP (mini_window
))
382 CHECK_LIVE_WINDOW (mini_window
);
384 if (!NILP (mini_window
)
385 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
386 error ("Frame and minibuffer must be on the same terminal");
388 /* Make a frame containing just a root window. */
391 if (NILP (mini_window
))
393 /* Use default-minibuffer-frame if possible. */
394 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
395 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
397 Lisp_Object frame_dummy
;
399 XSETFRAME (frame_dummy
, f
);
400 GCPRO1 (frame_dummy
);
401 /* If there's no minibuffer frame to use, create one. */
402 kset_default_minibuffer_frame
403 (kb
, call1 (intern ("make-initial-minibuffer-frame"), display
));
408 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
411 fset_minibuffer_window (f
, mini_window
);
413 /* Make the chosen minibuffer window display the proper minibuffer,
414 unless it is already showing a minibuffer. */
415 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
416 /* Use set_window_buffer instead of Fset_window_buffer (see
417 discussion of bug#11984, bug#12025, bug#12026). */
418 set_window_buffer (mini_window
,
419 (NILP (Vminibuffer_list
)
421 : Fcar (Vminibuffer_list
)), 0, 0);
425 /* Make a frame containing only a minibuffer window. */
428 make_minibuffer_frame (void)
430 /* First make a frame containing just a root window, no minibuffer. */
432 register struct frame
*f
= make_frame (0);
433 register Lisp_Object mini_window
;
434 register Lisp_Object frame
;
436 XSETFRAME (frame
, f
);
441 f
->wants_modeline
= 0;
442 f
->has_minibuffer
= 1;
444 /* Now label the root window as also being the minibuffer.
445 Avoid infinite looping on the window chain by marking next pointer
448 mini_window
= f
->root_window
;
449 fset_minibuffer_window (f
, mini_window
);
450 XWINDOW (mini_window
)->mini
= 1;
451 wset_next (XWINDOW (mini_window
), Qnil
);
452 wset_prev (XWINDOW (mini_window
), Qnil
);
453 wset_frame (XWINDOW (mini_window
), frame
);
455 /* Put the proper buffer in that window. */
457 /* Use set_window_buffer instead of Fset_window_buffer (see
458 discussion of bug#11984, bug#12025, bug#12026). */
459 set_window_buffer (mini_window
,
460 (NILP (Vminibuffer_list
)
462 : Fcar (Vminibuffer_list
)), 0, 0);
465 #endif /* HAVE_WINDOW_SYSTEM */
467 /* Construct a frame that refers to a terminal. */
469 static printmax_t tty_frame_count
;
472 make_initial_frame (void)
475 struct terminal
*terminal
;
478 eassert (initial_kboard
);
480 /* The first call must initialize Vframe_list. */
481 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
484 terminal
= init_initial_terminal ();
487 XSETFRAME (frame
, f
);
489 Vframe_list
= Fcons (frame
, Vframe_list
);
492 fset_name (f
, build_pure_c_string ("F1"));
495 f
->async_visible
= 1;
497 f
->output_method
= terminal
->type
;
498 f
->terminal
= terminal
;
499 f
->terminal
->reference_count
++;
500 f
->output_data
.nothing
= 0;
502 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
503 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
505 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
506 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
508 /* The default value of menu-bar-mode is t. */
509 set_menu_bar_lines (f
, make_number (1), Qnil
);
512 init_frame_faces (f
);
518 static struct frame
*
519 make_terminal_frame (struct terminal
*terminal
)
521 register struct frame
*f
;
523 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
526 error ("Terminal is not live, can't create new frames on it");
530 XSETFRAME (frame
, f
);
531 Vframe_list
= Fcons (frame
, Vframe_list
);
533 fset_name (f
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
535 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
536 f
->async_visible
= 1; /* Don't let visible be cleared later. */
537 f
->terminal
= terminal
;
538 f
->terminal
->reference_count
++;
540 f
->output_data
.tty
->display_info
= &the_only_display_info
;
541 if (!inhibit_window_system
542 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
543 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
544 f
->output_method
= output_msdos_raw
;
546 f
->output_method
= output_termcap
;
547 #else /* not MSDOS */
548 f
->output_method
= output_termcap
;
549 create_tty_output (f
);
550 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
551 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
552 #endif /* not MSDOS */
554 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
555 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
556 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
558 /* Set the top frame to the newly created frame. */
559 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
560 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
561 XFRAME (FRAME_TTY (f
)->top_frame
)->async_visible
= 2; /* obscured */
563 FRAME_TTY (f
)->top_frame
= frame
;
566 init_frame_faces (f
);
571 /* Get a suitable value for frame parameter PARAMETER for a newly
572 created frame, based on (1) the user-supplied frame parameter
573 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
576 get_future_frame_param (Lisp_Object parameter
,
577 Lisp_Object supplied_parms
,
582 result
= Fassq (parameter
, supplied_parms
);
584 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
585 if (NILP (result
) && current_value
!= NULL
)
586 result
= build_string (current_value
);
587 if (!NILP (result
) && !STRINGP (result
))
588 result
= XCDR (result
);
589 if (NILP (result
) || !STRINGP (result
))
595 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
597 doc
: /* Create an additional terminal frame, possibly on another terminal.
598 This function takes one argument, an alist specifying frame parameters.
600 You can create multiple frames on a single text terminal, but only one
601 of them (the selected terminal frame) is actually displayed.
603 In practice, generally you don't need to specify any parameters,
604 except when you want to create a new frame on another terminal.
605 In that case, the `tty' parameter specifies the device file to open,
606 and the `tty-type' parameter specifies the terminal type. Example:
608 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
610 Note that changing the size of one terminal frame automatically
611 affects all frames on the same terminal device. */)
615 struct terminal
*t
= NULL
;
616 Lisp_Object frame
, tem
;
617 struct frame
*sf
= SELECTED_FRAME ();
620 if (sf
->output_method
!= output_msdos_raw
621 && sf
->output_method
!= output_termcap
)
623 #else /* not MSDOS */
625 #ifdef WINDOWSNT /* This should work now! */
626 if (sf
->output_method
!= output_termcap
)
627 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
629 #endif /* not MSDOS */
632 Lisp_Object terminal
;
634 terminal
= Fassq (Qterminal
, parms
);
635 if (CONSP (terminal
))
637 terminal
= XCDR (terminal
);
638 t
= get_terminal (terminal
, 1);
641 if (t
&& t
!= the_only_display_info
.terminal
)
642 /* msdos.c assumes a single tty_display_info object. */
643 error ("Multiple terminals are not supported on this platform");
645 t
= the_only_display_info
.terminal
;
651 char *name
= 0, *type
= 0;
652 Lisp_Object tty
, tty_type
;
654 tty
= get_future_frame_param
655 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
656 ? FRAME_TTY (XFRAME (selected_frame
))->name
660 name
= alloca (SBYTES (tty
) + 1);
661 memcpy (name
, SSDATA (tty
), SBYTES (tty
));
662 name
[SBYTES (tty
)] = 0;
665 tty_type
= get_future_frame_param
666 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
667 ? FRAME_TTY (XFRAME (selected_frame
))->type
669 if (!NILP (tty_type
))
671 type
= alloca (SBYTES (tty_type
) + 1);
672 memcpy (type
, SSDATA (tty_type
), SBYTES (tty_type
));
673 type
[SBYTES (tty_type
)] = 0;
676 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
679 f
= make_terminal_frame (t
);
683 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
684 change_frame_size (f
, height
, width
, 0, 0, 0);
689 XSETFRAME (frame
, f
);
690 Fmodify_frame_parameters (frame
, parms
);
691 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
692 build_string (t
->display_info
.tty
->type
)),
694 if (t
->display_info
.tty
->name
!= NULL
)
695 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
696 build_string (t
->display_info
.tty
->name
)),
699 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
701 /* Make the frame face alist be frame-specific, so that each
702 frame could change its face definitions independently. */
703 fset_face_alist (f
, Fcopy_alist (sf
->face_alist
));
704 /* Simple Fcopy_alist isn't enough, because we need the contents of
705 the vectors which are the CDRs of associations in face_alist to
706 be copied as well. */
707 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
708 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
713 /* Perform the switch to frame FRAME.
715 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
718 If TRACK is non-zero and the frame that currently has the focus
719 redirects its focus to the selected frame, redirect that focused
720 frame's focus to FRAME instead.
722 FOR_DELETION non-zero means that the selected frame is being
723 deleted, which includes the possibility that the frame's terminal
726 The value of NORECORD is passed as argument to Fselect_window. */
729 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
731 struct frame
*sf
= SELECTED_FRAME ();
733 /* If FRAME is a switch-frame event, extract the frame we should
736 && EQ (XCAR (frame
), Qswitch_frame
)
737 && CONSP (XCDR (frame
)))
738 frame
= XCAR (XCDR (frame
));
740 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
741 a switch-frame event to arrive after a frame is no longer live,
742 especially when deleting the initial frame during startup. */
744 if (! FRAME_LIVE_P (XFRAME (frame
)))
747 if (sf
== XFRAME (frame
))
750 /* This is too greedy; it causes inappropriate focus redirection
751 that's hard to get rid of. */
753 /* If a frame's focus has been redirected toward the currently
754 selected frame, we should change the redirection to point to the
755 newly selected frame. This means that if the focus is redirected
756 from a minibufferless frame to a surrogate minibuffer frame, we
757 can use `other-window' to switch between all the frames using
758 that minibuffer frame, and the focus redirection will follow us
764 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
768 if (!FRAMEP (XCAR (tail
)))
771 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
773 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
774 Fredirect_frame_focus (XCAR (tail
), frame
);
778 /* Instead, apply it only to the frame we're pointing to. */
779 #ifdef HAVE_WINDOW_SYSTEM
780 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
782 Lisp_Object focus
, xfocus
;
784 xfocus
= x_get_focus_frame (XFRAME (frame
));
787 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
788 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
789 Fredirect_frame_focus (xfocus
, frame
);
792 #endif /* HAVE_X_WINDOWS */
795 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
796 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
798 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
800 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
801 /* Mark previously displayed frame as now obscured. */
802 XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
)->async_visible
= 2;
803 XFRAME (frame
)->async_visible
= 1;
804 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
807 selected_frame
= frame
;
808 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
809 last_nonminibuf_frame
= XFRAME (selected_frame
);
811 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
813 /* We want to make sure that the next event generates a frame-switch
814 event to the appropriate frame. This seems kludgy to me, but
815 before you take it out, make sure that evaluating something like
816 (select-window (frame-root-window (new-frame))) doesn't end up
817 with your typing being interpreted in the new frame instead of
818 the one you're actually typing in. */
819 internal_last_event_frame
= Qnil
;
824 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
825 doc
: /* Select FRAME.
826 Subsequent editing commands apply to its selected window.
827 Optional argument NORECORD means to neither change the order of
828 recently selected windows nor the buffer list.
830 The selection of FRAME lasts until the next time the user does
831 something to select a different frame, or until the next time
832 this function is called. If you are using a window system, the
833 previously selected frame may be restored as the selected frame
834 when returning to the command loop, because it still may have
835 the window system's input focus. On a text terminal, the next
836 redisplay will display FRAME.
838 This function returns FRAME, or nil if FRAME has been deleted. */)
839 (Lisp_Object frame
, Lisp_Object norecord
)
841 return do_switch_frame (frame
, 1, 0, norecord
);
845 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
846 doc
: /* Handle a switch-frame event EVENT.
847 Switch-frame events are usually bound to this function.
848 A switch-frame event tells Emacs that the window manager has requested
849 that the user's events be directed to the frame mentioned in the event.
850 This function selects the selected window of the frame of EVENT.
852 If EVENT is frame object, handle it as if it were a switch-frame event
856 /* Preserve prefix arg that the command loop just cleared. */
857 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
858 Frun_hooks (1, &Qmouse_leave_buffer_hook
);
859 return do_switch_frame (event
, 0, 0, Qnil
);
862 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
863 doc
: /* Return the frame that is now selected. */)
866 return selected_frame
;
869 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
871 doc
: /* Return a list of all live frames. */)
875 frames
= Fcopy_sequence (Vframe_list
);
876 #ifdef HAVE_WINDOW_SYSTEM
877 if (FRAMEP (tip_frame
))
878 frames
= Fdelq (tip_frame
, frames
);
883 /* Return the next frame in the frame list after FRAME.
884 If MINIBUF is nil, exclude minibuffer-only frames.
885 If MINIBUF is a window, include only its own frame
886 and any frame now using that window as the minibuffer.
887 If MINIBUF is `visible', include all visible frames.
888 If MINIBUF is 0, include all visible and iconified frames.
889 Otherwise, include all frames. */
892 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
897 /* There must always be at least one frame in Vframe_list. */
898 if (! CONSP (Vframe_list
))
901 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
902 forever. Forestall that. */
903 CHECK_LIVE_FRAME (frame
);
906 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
913 && ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
914 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
915 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
916 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
)))))
918 /* Decide whether this frame is eligible to be returned. */
920 /* If we've looped all the way around without finding any
921 eligible frames, return the original frame. */
925 /* Let minibuf decide if this frame is acceptable. */
928 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
931 else if (EQ (minibuf
, Qvisible
))
933 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
934 if (FRAME_VISIBLE_P (XFRAME (f
)))
937 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
939 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
940 if (FRAME_VISIBLE_P (XFRAME (f
))
941 || FRAME_ICONIFIED_P (XFRAME (f
)))
944 else if (WINDOWP (minibuf
))
946 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
947 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
948 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
949 FRAME_FOCUS_FRAME (XFRAME (f
))))
961 /* Return the previous frame in the frame list before FRAME.
962 If MINIBUF is nil, exclude minibuffer-only frames.
963 If MINIBUF is a window, include only its own frame
964 and any frame now using that window as the minibuffer.
965 If MINIBUF is `visible', include all visible frames.
966 If MINIBUF is 0, include all visible and iconified frames.
967 Otherwise, include all frames. */
970 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
975 /* There must always be at least one frame in Vframe_list. */
976 if (! CONSP (Vframe_list
))
980 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
988 if (EQ (frame
, f
) && !NILP (prev
))
991 if ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
992 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
993 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
994 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
))))
996 /* Decide whether this frame is eligible to be returned,
997 according to minibuf. */
1000 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1003 else if (WINDOWP (minibuf
))
1005 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1006 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1007 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1008 FRAME_FOCUS_FRAME (XFRAME (f
))))
1011 else if (EQ (minibuf
, Qvisible
))
1013 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1014 if (FRAME_VISIBLE_P (XFRAME (f
)))
1017 else if (XFASTINT (minibuf
) == 0)
1019 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1020 if (FRAME_VISIBLE_P (XFRAME (f
))
1021 || FRAME_ICONIFIED_P (XFRAME (f
)))
1029 /* We've scanned the entire list. */
1031 /* We went through the whole frame list without finding a single
1032 acceptable frame. Return the original frame. */
1035 /* There were no acceptable frames in the list before FRAME; otherwise,
1036 we would have returned directly from the loop. Since PREV is the last
1037 acceptable frame in the list, return it. */
1042 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1043 doc
: /* Return the next frame in the frame list after FRAME.
1044 It considers only frames on the same terminal as FRAME.
1045 By default, skip minibuffer-only frames.
1046 If omitted, FRAME defaults to the selected frame.
1047 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1048 If MINIFRAME is a window, include only its own frame
1049 and any frame now using that window as the minibuffer.
1050 If MINIFRAME is `visible', include all visible frames.
1051 If MINIFRAME is 0, include all visible and iconified frames.
1052 Otherwise, include all frames. */)
1053 (Lisp_Object frame
, Lisp_Object miniframe
)
1056 frame
= selected_frame
;
1058 CHECK_LIVE_FRAME (frame
);
1059 return next_frame (frame
, miniframe
);
1062 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1063 doc
: /* Return the previous frame in the frame list before FRAME.
1064 It considers only frames on the same terminal as FRAME.
1065 By default, skip minibuffer-only frames.
1066 If omitted, FRAME defaults to the selected frame.
1067 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1068 If MINIFRAME is a window, include only its own frame
1069 and any frame now using that window as the minibuffer.
1070 If MINIFRAME is `visible', include all visible frames.
1071 If MINIFRAME is 0, include all visible and iconified frames.
1072 Otherwise, include all frames. */)
1073 (Lisp_Object frame
, Lisp_Object miniframe
)
1076 frame
= selected_frame
;
1077 CHECK_LIVE_FRAME (frame
);
1078 return prev_frame (frame
, miniframe
);
1081 /* Return 1 if it is ok to delete frame F;
1082 0 if all frames aside from F are invisible.
1083 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1086 other_visible_frames (FRAME_PTR f
)
1090 for (frames
= Vframe_list
; CONSP (frames
); frames
= XCDR (frames
))
1092 Lisp_Object
this = XCAR (frames
);
1093 if (f
== XFRAME (this))
1096 /* Verify that we can still talk to the frame's X window,
1097 and note any recent change in visibility. */
1098 #ifdef HAVE_WINDOW_SYSTEM
1099 if (FRAME_WINDOW_P (XFRAME (this)))
1101 x_sync (XFRAME (this));
1102 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1106 if (FRAME_VISIBLE_P (XFRAME (this))
1107 || FRAME_ICONIFIED_P (XFRAME (this))
1108 /* Allow deleting the terminal frame when at least one X
1110 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1116 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1117 unconditionally. x_connection_closed and delete_terminal use
1118 this. Any other value of FORCE implements the semantics
1119 described for Fdelete_frame. */
1121 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1124 struct frame
*sf
= SELECTED_FRAME ();
1127 int minibuffer_selected
, is_tooltip_frame
;
1129 if (EQ (frame
, Qnil
))
1132 XSETFRAME (frame
, f
);
1136 CHECK_FRAME (frame
);
1140 if (! FRAME_LIVE_P (f
))
1143 if (NILP (force
) && !other_visible_frames (f
))
1144 error ("Attempt to delete the sole visible or iconified frame");
1146 /* x_connection_closed must have set FORCE to `noelisp' in order
1147 to delete the last frame, if it is gone. */
1148 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1149 error ("Attempt to delete the only frame");
1151 /* Does this frame have a minibuffer, and is it the surrogate
1152 minibuffer for any other frame? */
1153 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1157 for (frames
= Vframe_list
;
1159 frames
= XCDR (frames
))
1162 this = XCAR (frames
);
1164 if (! EQ (this, frame
)
1166 WINDOW_FRAME (XWINDOW
1167 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1169 /* If we MUST delete this frame, delete the other first.
1170 But do this only if FORCE equals `noelisp'. */
1171 if (EQ (force
, Qnoelisp
))
1172 delete_frame (this, Qnoelisp
);
1174 error ("Attempt to delete a surrogate minibuffer frame");
1179 is_tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1181 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1182 frame is a tooltip. FORCE is set to `noelisp' when handling
1183 a disconnect from the terminal, so we don't dare call Lisp
1185 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1187 else if (EQ (force
, Qnoelisp
))
1189 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1193 #ifdef HAVE_X_WINDOWS
1194 /* Also, save clipboard to the clipboard manager. */
1195 x_clipboard_manager_save_frame (frame
);
1198 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1201 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1202 if (! FRAME_LIVE_P (f
))
1205 /* At this point, we are committed to deleting the frame.
1206 There is no more chance for errors to prevent it. */
1208 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1210 /* Don't let the frame remain selected. */
1213 Lisp_Object tail
, frame1
;
1215 /* Look for another visible frame on the same terminal. */
1216 frame1
= next_frame (frame
, Qvisible
);
1218 /* If there is none, find *some* other frame. */
1219 if (NILP (frame1
) || EQ (frame1
, frame
))
1221 FOR_EACH_FRAME (tail
, frame1
)
1223 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1225 /* Do not change a text terminal's top-frame. */
1226 struct frame
*f1
= XFRAME (frame1
);
1227 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1229 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1230 if (!EQ (top_frame
, frame
))
1237 #ifdef NS_IMPL_COCOA
1239 /* Under NS, there is no system mechanism for choosing a new
1240 window to get focus -- it is left to application code.
1241 So the portion of THIS application interfacing with NS
1242 needs to know about it. We call Fraise_frame, but the
1243 purpose is really to transfer focus. */
1244 Fraise_frame (frame1
);
1247 do_switch_frame (frame1
, 0, 1, Qnil
);
1248 sf
= SELECTED_FRAME ();
1251 /* Don't allow minibuf_window to remain on a deleted frame. */
1252 if (EQ (f
->minibuffer_window
, minibuf_window
))
1254 /* Use set_window_buffer instead of Fset_window_buffer (see
1255 discussion of bug#11984, bug#12025, bug#12026). */
1256 set_window_buffer (sf
->minibuffer_window
,
1257 XWINDOW (minibuf_window
)->buffer
, 0, 0);
1258 minibuf_window
= sf
->minibuffer_window
;
1260 /* If the dying minibuffer window was selected,
1261 select the new one. */
1262 if (minibuffer_selected
)
1263 Fselect_window (minibuf_window
, Qnil
);
1266 /* Don't let echo_area_window to remain on a deleted frame. */
1267 if (EQ (f
->minibuffer_window
, echo_area_window
))
1268 echo_area_window
= sf
->minibuffer_window
;
1270 /* Clear any X selections for this frame. */
1271 #ifdef HAVE_X_WINDOWS
1273 x_clear_frame_selections (f
);
1277 This function must be called before the window tree of the
1278 frame is deleted because windows contain dynamically allocated
1282 #ifdef HAVE_WINDOW_SYSTEM
1283 /* Give chance to each font driver to free a frame specific data. */
1284 font_update_drivers (f
, Qnil
);
1287 /* Mark all the windows that used to be on FRAME as deleted, and then
1288 remove the reference to them. */
1289 delete_all_child_windows (f
->root_window
);
1290 fset_root_window (f
, Qnil
);
1292 Vframe_list
= Fdelq (frame
, Vframe_list
);
1293 FRAME_SET_VISIBLE (f
, 0);
1295 /* Allow the vector of menu bar contents to be freed in the next
1296 garbage collection. The frame object itself may not be garbage
1297 collected until much later, because recent_keys and other data
1298 structures can still refer to it. */
1299 fset_menu_bar_vector (f
, Qnil
);
1301 /* If FRAME's buffer lists contains killed
1302 buffers, this helps GC to reclaim them. */
1303 fset_buffer_list (f
, Qnil
);
1304 fset_buried_buffer_list (f
, Qnil
);
1306 free_font_driver_list (f
);
1308 xfree (f
->decode_mode_spec_buffer
);
1309 xfree (FRAME_INSERT_COST (f
));
1310 xfree (FRAME_DELETEN_COST (f
));
1311 xfree (FRAME_INSERTN_COST (f
));
1312 xfree (FRAME_DELETE_COST (f
));
1313 xfree (FRAME_MESSAGE_BUF (f
));
1315 /* Since some events are handled at the interrupt level, we may get
1316 an event for f at any time; if we zero out the frame's terminal
1317 now, then we may trip up the event-handling code. Instead, we'll
1318 promise that the terminal of the frame must be valid until we
1319 have called the window-system-dependent frame destruction
1322 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1323 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1326 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1327 f
->output_data
.nothing
= 0;
1328 f
->terminal
= 0; /* Now the frame is dead. */
1330 /* If needed, delete the terminal that this frame was on.
1331 (This must be done after the frame is killed.) */
1332 terminal
->reference_count
--;
1334 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1336 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1337 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1338 terminal
->reference_count
= 1;
1339 #endif /* USE_GTK */
1340 if (terminal
->reference_count
== 0)
1343 XSETTERMINAL (tmp
, terminal
);
1346 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1349 kb
= terminal
->kboard
;
1352 /* If we've deleted the last_nonminibuf_frame, then try to find
1354 if (f
== last_nonminibuf_frame
)
1358 last_nonminibuf_frame
= 0;
1360 for (frames
= Vframe_list
;
1362 frames
= XCDR (frames
))
1364 f
= XFRAME (XCAR (frames
));
1365 if (!FRAME_MINIBUF_ONLY_P (f
))
1367 last_nonminibuf_frame
= f
;
1373 /* If there's no other frame on the same kboard, get out of
1374 single-kboard state if we're in it for this kboard. */
1378 /* Some frame we found on the same kboard, or nil if there are none. */
1379 Lisp_Object frame_on_same_kboard
;
1381 frame_on_same_kboard
= Qnil
;
1383 for (frames
= Vframe_list
;
1385 frames
= XCDR (frames
))
1390 this = XCAR (frames
);
1395 if (kb
== FRAME_KBOARD (f1
))
1396 frame_on_same_kboard
= this;
1399 if (NILP (frame_on_same_kboard
))
1400 not_single_kboard_state (kb
);
1404 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1405 find another one. Prefer minibuffer-only frames, but also notice
1406 frames with other windows. */
1407 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1411 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1412 Lisp_Object frame_with_minibuf
;
1413 /* Some frame we found on the same kboard, or nil if there are none. */
1414 Lisp_Object frame_on_same_kboard
;
1416 frame_on_same_kboard
= Qnil
;
1417 frame_with_minibuf
= Qnil
;
1419 for (frames
= Vframe_list
;
1421 frames
= XCDR (frames
))
1426 this = XCAR (frames
);
1431 /* Consider only frames on the same kboard
1432 and only those with minibuffers. */
1433 if (kb
== FRAME_KBOARD (f1
)
1434 && FRAME_HAS_MINIBUF_P (f1
))
1436 frame_with_minibuf
= this;
1437 if (FRAME_MINIBUF_ONLY_P (f1
))
1441 if (kb
== FRAME_KBOARD (f1
))
1442 frame_on_same_kboard
= this;
1445 if (!NILP (frame_on_same_kboard
))
1447 /* We know that there must be some frame with a minibuffer out
1448 there. If this were not true, all of the frames present
1449 would have to be minibufferless, which implies that at some
1450 point their minibuffer frames must have been deleted, but
1451 that is prohibited at the top; you can't delete surrogate
1452 minibuffer frames. */
1453 if (NILP (frame_with_minibuf
))
1456 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
1459 /* No frames left on this kboard--say no minibuffer either. */
1460 kset_default_minibuffer_frame (kb
, Qnil
);
1463 /* Cause frame titles to update--necessary if we now have just one frame. */
1464 if (!is_tooltip_frame
)
1465 update_mode_lines
= 1;
1470 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1471 doc
: /* Delete FRAME, permanently eliminating it from use.
1472 FRAME defaults to the selected frame.
1474 A frame may not be deleted if its minibuffer is used by other frames.
1475 Normally, you may not delete a frame if all other frames are invisible,
1476 but if the second optional argument FORCE is non-nil, you may do so.
1478 This function runs `delete-frame-functions' before actually
1479 deleting the frame, unless the frame is a tooltip.
1480 The functions are run with one argument, the frame to be deleted. */)
1481 (Lisp_Object frame
, Lisp_Object force
)
1483 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1487 /* Return mouse position in character cell units. */
1489 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1490 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1491 The position is given in character cells, where (0, 0) is the
1492 upper-left corner of the frame, X is the horizontal offset, and Y is
1493 the vertical offset.
1494 If Emacs is running on a mouseless terminal or hasn't been programmed
1495 to read the mouse position, it returns the selected frame for FRAME
1496 and nil for X and Y.
1497 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1498 passing the normal return value to that function as an argument,
1499 and returns whatever that function returns. */)
1503 Lisp_Object lispy_dummy
;
1504 enum scroll_bar_part party_dummy
;
1505 Lisp_Object x
, y
, retval
;
1508 struct gcpro gcpro1
;
1510 f
= SELECTED_FRAME ();
1513 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1514 /* It's okay for the hook to refrain from storing anything. */
1515 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1516 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1517 &lispy_dummy
, &party_dummy
,
1524 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1529 XSETFRAME (lispy_dummy
, f
);
1530 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1532 if (!NILP (Vmouse_position_function
))
1533 retval
= call1 (Vmouse_position_function
, retval
);
1534 RETURN_UNGCPRO (retval
);
1537 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1538 Smouse_pixel_position
, 0, 0, 0,
1539 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1540 The position is given in pixel units, where (0, 0) is the
1541 upper-left corner of the frame, X is the horizontal offset, and Y is
1542 the vertical offset.
1543 If Emacs is running on a mouseless terminal or hasn't been programmed
1544 to read the mouse position, it returns the selected frame for FRAME
1545 and nil for X and Y. */)
1549 Lisp_Object lispy_dummy
;
1550 enum scroll_bar_part party_dummy
;
1554 f
= SELECTED_FRAME ();
1557 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1558 /* It's okay for the hook to refrain from storing anything. */
1559 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1560 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1561 &lispy_dummy
, &party_dummy
,
1565 XSETFRAME (lispy_dummy
, f
);
1566 return Fcons (lispy_dummy
, Fcons (x
, y
));
1569 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1570 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1571 Coordinates are relative to the frame, not a window,
1572 so the coordinates of the top left character in the frame
1573 may be nonzero due to left-hand scroll bars or the menu bar.
1575 The position is given in character cells, where (0, 0) is the
1576 upper-left corner of the frame, X is the horizontal offset, and Y is
1577 the vertical offset.
1579 This function is a no-op for an X frame that is not visible.
1580 If you have just created a frame, you must wait for it to become visible
1581 before calling this function on it, like this.
1582 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1583 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1585 CHECK_LIVE_FRAME (frame
);
1586 CHECK_TYPE_RANGED_INTEGER (int, x
);
1587 CHECK_TYPE_RANGED_INTEGER (int, y
);
1589 /* I think this should be done with a hook. */
1590 #ifdef HAVE_WINDOW_SYSTEM
1591 if (FRAME_WINDOW_P (XFRAME (frame
)))
1592 /* Warping the mouse will cause enternotify and focus events. */
1593 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1595 #if defined (MSDOS) && defined (HAVE_MOUSE)
1596 if (FRAME_MSDOS_P (XFRAME (frame
)))
1598 Fselect_frame (frame
, Qnil
);
1599 mouse_moveto (XINT (x
), XINT (y
));
1604 Fselect_frame (frame
, Qnil
);
1605 term_mouse_moveto (XINT (x
), XINT (y
));
1614 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1615 Sset_mouse_pixel_position
, 3, 3, 0,
1616 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1617 The position is given in pixels, where (0, 0) is the upper-left corner
1618 of the frame, X is the horizontal offset, and Y is the vertical offset.
1620 Note, this is a no-op for an X frame that is not visible.
1621 If you have just created a frame, you must wait for it to become visible
1622 before calling this function on it, like this.
1623 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1624 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1626 CHECK_LIVE_FRAME (frame
);
1627 CHECK_TYPE_RANGED_INTEGER (int, x
);
1628 CHECK_TYPE_RANGED_INTEGER (int, y
);
1630 /* I think this should be done with a hook. */
1631 #ifdef HAVE_WINDOW_SYSTEM
1632 if (FRAME_WINDOW_P (XFRAME (frame
)))
1633 /* Warping the mouse will cause enternotify and focus events. */
1634 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1636 #if defined (MSDOS) && defined (HAVE_MOUSE)
1637 if (FRAME_MSDOS_P (XFRAME (frame
)))
1639 Fselect_frame (frame
, Qnil
);
1640 mouse_moveto (XINT (x
), XINT (y
));
1645 Fselect_frame (frame
, Qnil
);
1646 term_mouse_moveto (XINT (x
), XINT (y
));
1655 static void make_frame_visible_1 (Lisp_Object
);
1657 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1659 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1660 If omitted, FRAME defaults to the currently selected frame. */)
1664 frame
= selected_frame
;
1666 CHECK_LIVE_FRAME (frame
);
1668 /* I think this should be done with a hook. */
1669 #ifdef HAVE_WINDOW_SYSTEM
1670 if (FRAME_WINDOW_P (XFRAME (frame
)))
1672 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1673 x_make_frame_visible (XFRAME (frame
));
1677 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1679 /* Make menu bar update for the Buffers and Frames menus. */
1680 windows_or_buffers_changed
++;
1685 /* Update the display_time slot of the buffers shown in WINDOW
1686 and all its descendants. */
1689 make_frame_visible_1 (Lisp_Object window
)
1693 for (;!NILP (window
); window
= w
->next
)
1695 w
= XWINDOW (window
);
1697 if (!NILP (w
->buffer
))
1698 bset_display_time (XBUFFER (w
->buffer
), Fcurrent_time ());
1700 if (!NILP (w
->vchild
))
1701 make_frame_visible_1 (w
->vchild
);
1702 if (!NILP (w
->hchild
))
1703 make_frame_visible_1 (w
->hchild
);
1707 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1709 doc
: /* Make the frame FRAME invisible.
1710 If omitted, FRAME defaults to the currently selected frame.
1711 On graphical displays, invisible frames are not updated and are
1712 usually not displayed at all, even in a window system's \"taskbar\".
1714 Normally you may not make FRAME invisible if all other frames are invisible,
1715 but if the second optional argument FORCE is non-nil, you may do so.
1717 This function has no effect on text terminal frames. Such frames are
1718 always considered visible, whether or not they are currently being
1719 displayed in the terminal. */)
1720 (Lisp_Object frame
, Lisp_Object force
)
1723 frame
= selected_frame
;
1725 CHECK_LIVE_FRAME (frame
);
1727 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1728 error ("Attempt to make invisible the sole visible or iconified frame");
1730 /* Don't allow minibuf_window to remain on a deleted frame. */
1731 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1733 struct frame
*sf
= XFRAME (selected_frame
);
1734 /* Use set_window_buffer instead of Fset_window_buffer (see
1735 discussion of bug#11984, bug#12025, bug#12026). */
1736 set_window_buffer (sf
->minibuffer_window
,
1737 XWINDOW (minibuf_window
)->buffer
, 0, 0);
1738 minibuf_window
= sf
->minibuffer_window
;
1741 /* I think this should be done with a hook. */
1742 #ifdef HAVE_WINDOW_SYSTEM
1743 if (FRAME_WINDOW_P (XFRAME (frame
)))
1744 x_make_frame_invisible (XFRAME (frame
));
1747 /* Make menu bar update for the Buffers and Frames menus. */
1748 windows_or_buffers_changed
++;
1753 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1755 doc
: /* Make the frame FRAME into an icon.
1756 If omitted, FRAME defaults to the currently selected frame. */)
1760 frame
= selected_frame
;
1762 CHECK_LIVE_FRAME (frame
);
1764 #if 0 /* This isn't logically necessary, and it can do GC. */
1765 /* Don't let the frame remain selected. */
1766 if (EQ (frame
, selected_frame
))
1767 Fhandle_switch_frame (next_frame (frame
, Qt
));
1770 /* Don't allow minibuf_window to remain on an iconified frame. */
1771 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1773 struct frame
*sf
= XFRAME (selected_frame
);
1774 /* Use set_window_buffer instead of Fset_window_buffer (see
1775 discussion of bug#11984, bug#12025, bug#12026). */
1776 set_window_buffer (sf
->minibuffer_window
,
1777 XWINDOW (minibuf_window
)->buffer
, 0, 0);
1778 minibuf_window
= sf
->minibuffer_window
;
1781 /* I think this should be done with a hook. */
1782 #ifdef HAVE_WINDOW_SYSTEM
1783 if (FRAME_WINDOW_P (XFRAME (frame
)))
1784 x_iconify_frame (XFRAME (frame
));
1787 /* Make menu bar update for the Buffers and Frames menus. */
1788 windows_or_buffers_changed
++;
1793 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1795 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1796 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1797 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1798 On graphical displays, invisible frames are not updated and are
1799 usually not displayed at all, even in a window system's \"taskbar\".
1801 If FRAME is a text terminal frame, this always returns t.
1802 Such frames are always considered visible, whether or not they are
1803 currently being displayed on the terminal. */)
1806 CHECK_LIVE_FRAME (frame
);
1808 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1810 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1812 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1817 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1819 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1822 Lisp_Object tail
, frame
;
1827 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1829 frame
= XCAR (tail
);
1830 if (!FRAMEP (frame
))
1833 if (FRAME_VISIBLE_P (f
))
1834 value
= Fcons (frame
, value
);
1840 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1841 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1842 If FRAME is invisible or iconified, make it visible.
1843 If you don't specify a frame, the selected frame is used.
1844 If Emacs is displaying on an ordinary terminal or some other device which
1845 doesn't support multiple overlapping frames, this function selects FRAME. */)
1850 frame
= selected_frame
;
1852 CHECK_LIVE_FRAME (frame
);
1856 if (FRAME_TERMCAP_P (f
))
1857 /* On a text terminal select FRAME. */
1858 Fselect_frame (frame
, Qnil
);
1860 /* Do like the documentation says. */
1861 Fmake_frame_visible (frame
);
1863 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1864 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
1869 /* Should we have a corresponding function called Flower_Power? */
1870 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1871 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1872 If you don't specify a frame, the selected frame is used.
1873 If Emacs is displaying on an ordinary terminal or some other device which
1874 doesn't support multiple overlapping frames, this function does nothing. */)
1880 frame
= selected_frame
;
1882 CHECK_LIVE_FRAME (frame
);
1886 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1887 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
1893 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1895 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1896 In other words, switch-frame events caused by events in FRAME will
1897 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1898 FOCUS-FRAME after reading an event typed at FRAME.
1900 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
1901 frame again receives its own keystrokes.
1903 Focus redirection is useful for temporarily redirecting keystrokes to
1904 a surrogate minibuffer frame when a frame doesn't have its own
1907 A frame's focus redirection can be changed by `select-frame'. If frame
1908 FOO is selected, and then a different frame BAR is selected, any
1909 frames redirecting their focus to FOO are shifted to redirect their
1910 focus to BAR. This allows focus redirection to work properly when the
1911 user switches from one frame to another using `select-window'.
1913 This means that a frame whose focus is redirected to itself is treated
1914 differently from a frame whose focus is redirected to nil; the former
1915 is affected by `select-frame', while the latter is not.
1917 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1918 (Lisp_Object frame
, Lisp_Object focus_frame
)
1922 /* Note that we don't check for a live frame here. It's reasonable
1923 to redirect the focus of a frame you're about to delete, if you
1924 know what other frame should receive those keystrokes. */
1925 CHECK_FRAME (frame
);
1927 if (! NILP (focus_frame
))
1928 CHECK_LIVE_FRAME (focus_frame
);
1932 fset_focus_frame (f
, focus_frame
);
1934 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
1935 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
1941 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1942 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1943 This returns nil if FRAME's focus is not redirected.
1944 See `redirect-frame-focus'. */)
1947 CHECK_LIVE_FRAME (frame
);
1949 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1954 /* Return the value of frame parameter PROP in frame FRAME. */
1956 #ifdef HAVE_WINDOW_SYSTEM
1961 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
1963 register Lisp_Object tem
;
1965 tem
= Fassq (prop
, frame
->param_alist
);
1972 /* Return the buffer-predicate of the selected frame. */
1975 frame_buffer_predicate (Lisp_Object frame
)
1977 return XFRAME (frame
)->buffer_predicate
;
1980 /* Return the buffer-list of the selected frame. */
1983 frame_buffer_list (Lisp_Object frame
)
1985 return XFRAME (frame
)->buffer_list
;
1988 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
1991 frames_discard_buffer (Lisp_Object buffer
)
1993 Lisp_Object frame
, tail
;
1995 FOR_EACH_FRAME (tail
, frame
)
1998 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
1999 fset_buried_buffer_list
2000 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
2004 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2005 If the alist already has an element for PROP, we change it. */
2008 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2010 register Lisp_Object tem
;
2012 tem
= Fassq (prop
, *alistptr
);
2014 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2020 frame_name_fnn_p (char *str
, ptrdiff_t len
)
2022 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
2025 while ('0' <= *p
&& *p
<= '9')
2033 /* Set the name of the terminal frame. Also used by MSDOS frames.
2034 Modeled after x_set_name which is used for WINDOW frames. */
2037 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2039 f
->explicit_name
= ! NILP (name
);
2041 /* If NAME is nil, set the name to F<num>. */
2044 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
2046 /* Check for no change needed in this very common case
2047 before we do any consing. */
2048 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
2051 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
2055 CHECK_STRING (name
);
2057 /* Don't change the name if it's already NAME. */
2058 if (! NILP (Fstring_equal (name
, f
->name
)))
2061 /* Don't allow the user to set the frame name to F<num>, so it
2062 doesn't clash with the names we generate for terminal frames. */
2063 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2064 error ("Frame names of the form F<num> are usurped by Emacs");
2067 fset_name (f
, name
);
2068 update_mode_lines
= 1;
2072 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2074 register Lisp_Object old_alist_elt
;
2076 /* The buffer-list parameters are stored in a special place and not
2077 in the alist. All buffers must be live. */
2078 if (EQ (prop
, Qbuffer_list
))
2080 Lisp_Object list
= Qnil
;
2081 for (; CONSP (val
); val
= XCDR (val
))
2082 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2083 list
= Fcons (XCAR (val
), list
);
2084 fset_buffer_list (f
, Fnreverse (list
));
2087 if (EQ (prop
, Qburied_buffer_list
))
2089 Lisp_Object list
= Qnil
;
2090 for (; CONSP (val
); val
= XCDR (val
))
2091 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2092 list
= Fcons (XCAR (val
), list
);
2093 fset_buried_buffer_list (f
, Fnreverse (list
));
2097 /* If PROP is a symbol which is supposed to have frame-local values,
2098 and it is set up based on this frame, switch to the global
2099 binding. That way, we can create or alter the frame-local binding
2100 without messing up the symbol's status. */
2103 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2105 switch (sym
->redirect
)
2107 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2108 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2109 case SYMBOL_LOCALIZED
:
2110 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2111 if (blv
->frame_local
&& blv_found (blv
) && XFRAME (blv
->where
) == f
)
2112 swap_in_global_binding (sym
);
2115 default: emacs_abort ();
2119 /* The tty color needed to be set before the frame's parameter
2120 alist was updated with the new value. This is not true any more,
2121 but we still do this test early on. */
2122 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2123 && f
== FRAME_TTY (f
)->previous_frame
)
2124 /* Force redisplay of this tty. */
2125 FRAME_TTY (f
)->previous_frame
= NULL
;
2127 /* Update the frame parameter alist. */
2128 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2129 if (EQ (old_alist_elt
, Qnil
))
2130 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2132 Fsetcdr (old_alist_elt
, val
);
2134 /* Update some other special parameters in their special places
2135 in addition to the alist. */
2137 if (EQ (prop
, Qbuffer_predicate
))
2138 fset_buffer_predicate (f
, val
);
2140 if (! FRAME_WINDOW_P (f
))
2142 if (EQ (prop
, Qmenu_bar_lines
))
2143 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2144 else if (EQ (prop
, Qname
))
2145 set_term_frame_name (f
, val
);
2148 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2150 if (! MINI_WINDOW_P (XWINDOW (val
)))
2151 error ("Surrogate minibuffer windows must be minibuffer windows");
2153 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2154 && !EQ (val
, f
->minibuffer_window
))
2155 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2157 /* Install the chosen minibuffer window, with proper buffer. */
2158 fset_minibuffer_window (f
, val
);
2162 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2163 doc
: /* Return the parameters-alist of frame FRAME.
2164 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2165 The meaningful PARMs depend on the kind of frame.
2166 If FRAME is omitted, return information on the currently selected frame. */)
2172 struct gcpro gcpro1
;
2175 frame
= selected_frame
;
2177 CHECK_FRAME (frame
);
2180 if (!FRAME_LIVE_P (f
))
2183 alist
= Fcopy_alist (f
->param_alist
);
2186 if (!FRAME_WINDOW_P (f
))
2188 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2189 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2192 /* If the frame's parameter alist says the colors are
2193 unspecified and reversed, take the frame's background pixel
2194 for foreground and vice versa. */
2195 elt
= Fassq (Qforeground_color
, alist
);
2196 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2198 if (strncmp (SSDATA (XCDR (elt
)),
2200 SCHARS (XCDR (elt
))) == 0)
2201 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2202 else if (strncmp (SSDATA (XCDR (elt
)),
2204 SCHARS (XCDR (elt
))) == 0)
2205 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2208 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2209 elt
= Fassq (Qbackground_color
, alist
);
2210 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2212 if (strncmp (SSDATA (XCDR (elt
)),
2214 SCHARS (XCDR (elt
))) == 0)
2215 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2216 else if (strncmp (SSDATA (XCDR (elt
)),
2218 SCHARS (XCDR (elt
))) == 0)
2219 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2222 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2223 store_in_alist (&alist
, intern ("font"),
2224 build_string (FRAME_MSDOS_P (f
)
2226 : FRAME_W32_P (f
) ? "w32term"
2229 store_in_alist (&alist
, Qname
, f
->name
);
2230 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2231 store_in_alist (&alist
, Qheight
, make_number (height
));
2232 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2233 store_in_alist (&alist
, Qwidth
, make_number (width
));
2234 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2235 store_in_alist (&alist
, Qminibuffer
,
2236 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2237 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2238 : FRAME_MINIBUF_WINDOW (f
)));
2239 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2240 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2241 store_in_alist (&alist
, Qburied_buffer_list
,
2242 XFRAME (frame
)->buried_buffer_list
);
2244 /* I think this should be done with a hook. */
2245 #ifdef HAVE_WINDOW_SYSTEM
2246 if (FRAME_WINDOW_P (f
))
2247 x_report_frame_params (f
, &alist
);
2251 /* This ought to be correct in f->param_alist for an X frame. */
2253 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2254 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2262 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2263 doc
: /* Return FRAME's value for parameter PARAMETER.
2264 If FRAME is nil, describe the currently selected frame. */)
2265 (Lisp_Object frame
, Lisp_Object parameter
)
2271 frame
= selected_frame
;
2273 CHECK_FRAME (frame
);
2274 CHECK_SYMBOL (parameter
);
2279 if (FRAME_LIVE_P (f
))
2281 /* Avoid consing in frequent cases. */
2282 if (EQ (parameter
, Qname
))
2284 #ifdef HAVE_X_WINDOWS
2285 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2286 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2287 #endif /* HAVE_X_WINDOWS */
2288 else if (EQ (parameter
, Qbackground_color
)
2289 || EQ (parameter
, Qforeground_color
))
2291 value
= Fassq (parameter
, f
->param_alist
);
2294 value
= XCDR (value
);
2295 /* Fframe_parameters puts the actual fg/bg color names,
2296 even if f->param_alist says otherwise. This is
2297 important when param_alist's notion of colors is
2298 "unspecified". We need to do the same here. */
2299 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2301 const char *color_name
;
2304 if (EQ (parameter
, Qbackground_color
))
2306 color_name
= SSDATA (value
);
2307 csz
= SCHARS (value
);
2308 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2309 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2310 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2311 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2313 else if (EQ (parameter
, Qforeground_color
))
2315 color_name
= SSDATA (value
);
2316 csz
= SCHARS (value
);
2317 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2318 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2319 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2320 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2325 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2327 else if (EQ (parameter
, Qdisplay_type
)
2328 || EQ (parameter
, Qbackground_mode
))
2329 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2331 /* FIXME: Avoid this code path at all (as well as code duplication)
2332 by sharing more code with Fframe_parameters. */
2333 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2340 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2341 Smodify_frame_parameters
, 2, 2, 0,
2342 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2343 If FRAME is nil, it defaults to the selected frame.
2344 ALIST is an alist of parameters to change and their new values.
2345 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2346 The meaningful PARMs depend on the kind of frame.
2347 Undefined PARMs are ignored, but stored in the frame's parameter list
2348 so that `frame-parameters' will return them.
2350 The value of frame parameter FOO can also be accessed
2351 as a frame-local binding for the variable FOO, if you have
2352 enabled such bindings for that variable with `make-variable-frame-local'.
2353 Note that this functionality is obsolete as of Emacs 22.2, and its
2354 use is not recommended. Explicitly check for a frame-parameter instead. */)
2355 (Lisp_Object frame
, Lisp_Object alist
)
2358 register Lisp_Object tail
, prop
, val
;
2360 if (EQ (frame
, Qnil
))
2361 frame
= selected_frame
;
2362 CHECK_LIVE_FRAME (frame
);
2365 /* I think this should be done with a hook. */
2366 #ifdef HAVE_WINDOW_SYSTEM
2367 if (FRAME_WINDOW_P (f
))
2368 x_set_frame_parameters (f
, alist
);
2372 if (FRAME_MSDOS_P (f
))
2373 IT_set_frame_parameters (f
, alist
);
2378 EMACS_INT length
= XFASTINT (Flength (alist
));
2381 Lisp_Object
*values
;
2383 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2384 values
= parms
+ length
;
2386 /* Extract parm names and values into those vectors. */
2389 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2394 parms
[i
] = Fcar (elt
);
2395 values
[i
] = Fcdr (elt
);
2399 /* Now process them in reverse of specified order. */
2404 store_frame_param (f
, prop
, val
);
2406 if (EQ (prop
, Qforeground_color
)
2407 || EQ (prop
, Qbackground_color
))
2408 update_face_from_frame_parameter (f
, prop
, val
);
2416 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2418 doc
: /* Height in pixels of a line in the font in frame FRAME.
2419 If FRAME is omitted, the selected frame is used.
2420 For a terminal frame, the value is always 1. */)
2426 frame
= selected_frame
;
2427 CHECK_FRAME (frame
);
2430 #ifdef HAVE_WINDOW_SYSTEM
2431 if (FRAME_WINDOW_P (f
))
2432 return make_number (x_char_height (f
));
2435 return make_number (1);
2439 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2441 doc
: /* Width in pixels of characters in the font in frame FRAME.
2442 If FRAME is omitted, the selected frame is used.
2443 On a graphical screen, the width is the standard width of the default font.
2444 For a terminal screen, the value is always 1. */)
2450 frame
= selected_frame
;
2451 CHECK_FRAME (frame
);
2454 #ifdef HAVE_WINDOW_SYSTEM
2455 if (FRAME_WINDOW_P (f
))
2456 return make_number (x_char_width (f
));
2459 return make_number (1);
2462 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2463 Sframe_pixel_height
, 0, 1, 0,
2464 doc
: /* Return a FRAME's height in pixels.
2465 If FRAME is omitted, the selected frame is used. The exact value
2466 of the result depends on the window-system and toolkit in use:
2468 In the Gtk+ version of Emacs, it includes only any window (including
2469 the minibuffer or echo area), mode line, and header line. It does not
2470 include the tool bar or menu bar.
2472 With the Motif or Lucid toolkits, it also includes the tool bar (but
2475 In a graphical version with no toolkit, it includes both the tool bar
2478 For a text terminal, it includes the menu bar. In this case, the
2479 result is really in characters rather than pixels (i.e., is identical
2480 to `frame-height'). */)
2486 frame
= selected_frame
;
2487 CHECK_FRAME (frame
);
2490 #ifdef HAVE_WINDOW_SYSTEM
2491 if (FRAME_WINDOW_P (f
))
2492 return make_number (x_pixel_height (f
));
2495 return make_number (FRAME_LINES (f
));
2498 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2499 Sframe_pixel_width
, 0, 1, 0,
2500 doc
: /* Return FRAME's width in pixels.
2501 For a terminal frame, the result really gives the width in characters.
2502 If FRAME is omitted, the selected frame is used. */)
2508 frame
= selected_frame
;
2509 CHECK_FRAME (frame
);
2512 #ifdef HAVE_WINDOW_SYSTEM
2513 if (FRAME_WINDOW_P (f
))
2514 return make_number (x_pixel_width (f
));
2517 return make_number (FRAME_COLS (f
));
2520 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2521 Stool_bar_pixel_width
, 0, 1, 0,
2522 doc
: /* Return width in pixels of FRAME's tool bar.
2523 The result is greater than zero only when the tool bar is on the left
2524 or right side of FRAME. If FRAME is omitted, the selected frame is
2529 frame
= selected_frame
;
2530 CHECK_FRAME (frame
);
2532 #ifdef FRAME_TOOLBAR_WIDTH
2533 if (FRAME_WINDOW_P (XFRAME (frame
)))
2534 return make_number (FRAME_TOOLBAR_WIDTH (XFRAME (frame
)));
2536 return make_number (0);
2539 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2540 doc
: /* Specify that the frame FRAME has LINES lines.
2541 Optional third arg non-nil means that redisplay should use LINES lines
2542 but that the idea of the actual height of the frame should not be changed. */)
2543 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2545 register struct frame
*f
;
2547 CHECK_TYPE_RANGED_INTEGER (int, lines
);
2549 frame
= selected_frame
;
2550 CHECK_LIVE_FRAME (frame
);
2553 /* I think this should be done with a hook. */
2554 #ifdef HAVE_WINDOW_SYSTEM
2555 if (FRAME_WINDOW_P (f
))
2557 if (XINT (lines
) != FRAME_LINES (f
))
2558 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2559 do_pending_window_change (0);
2563 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2567 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2568 doc
: /* Specify that the frame FRAME has COLS columns.
2569 Optional third arg non-nil means that redisplay should use COLS columns
2570 but that the idea of the actual width of the frame should not be changed. */)
2571 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2573 register struct frame
*f
;
2574 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2576 frame
= selected_frame
;
2577 CHECK_LIVE_FRAME (frame
);
2580 /* I think this should be done with a hook. */
2581 #ifdef HAVE_WINDOW_SYSTEM
2582 if (FRAME_WINDOW_P (f
))
2584 if (XINT (cols
) != FRAME_COLS (f
))
2585 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2586 do_pending_window_change (0);
2590 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2594 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2595 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2596 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2598 register struct frame
*f
;
2600 CHECK_LIVE_FRAME (frame
);
2601 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2602 CHECK_TYPE_RANGED_INTEGER (int, rows
);
2605 /* I think this should be done with a hook. */
2606 #ifdef HAVE_WINDOW_SYSTEM
2607 if (FRAME_WINDOW_P (f
))
2609 if (XINT (rows
) != FRAME_LINES (f
)
2610 || XINT (cols
) != FRAME_COLS (f
)
2611 || f
->new_text_lines
|| f
->new_text_cols
)
2612 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2613 do_pending_window_change (0);
2617 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2622 DEFUN ("set-frame-position", Fset_frame_position
,
2623 Sset_frame_position
, 3, 3, 0,
2624 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2625 This is actually the position of the upper left corner of the frame.
2626 Negative values for XOFFSET or YOFFSET are interpreted relative to
2627 the rightmost or bottommost possible position (that stays within the screen). */)
2628 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2630 register struct frame
*f
;
2632 CHECK_LIVE_FRAME (frame
);
2633 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2634 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2637 /* I think this should be done with a hook. */
2638 #ifdef HAVE_WINDOW_SYSTEM
2639 if (FRAME_WINDOW_P (f
))
2640 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2647 /***********************************************************************
2649 ***********************************************************************/
2651 /* Connect the frame-parameter names for X frames
2652 to the ways of passing the parameter values to the window system.
2654 The name of a parameter, as a Lisp symbol,
2655 has an `x-frame-parameter' property which is an integer in Lisp
2656 that is an index in this table. */
2658 struct frame_parm_table
{
2660 Lisp_Object
*variable
;
2663 static const struct frame_parm_table frame_parms
[] =
2665 {"auto-raise", &Qauto_raise
},
2666 {"auto-lower", &Qauto_lower
},
2667 {"background-color", 0},
2668 {"border-color", &Qborder_color
},
2669 {"border-width", &Qborder_width
},
2670 {"cursor-color", &Qcursor_color
},
2671 {"cursor-type", &Qcursor_type
},
2673 {"foreground-color", 0},
2674 {"icon-name", &Qicon_name
},
2675 {"icon-type", &Qicon_type
},
2676 {"internal-border-width", &Qinternal_border_width
},
2677 {"menu-bar-lines", &Qmenu_bar_lines
},
2678 {"mouse-color", &Qmouse_color
},
2680 {"scroll-bar-width", &Qscroll_bar_width
},
2682 {"unsplittable", &Qunsplittable
},
2683 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2684 {"visibility", &Qvisibility
},
2685 {"tool-bar-lines", &Qtool_bar_lines
},
2686 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2687 {"scroll-bar-background", &Qscroll_bar_background
},
2688 {"screen-gamma", &Qscreen_gamma
},
2689 {"line-spacing", &Qline_spacing
},
2690 {"left-fringe", &Qleft_fringe
},
2691 {"right-fringe", &Qright_fringe
},
2692 {"wait-for-wm", &Qwait_for_wm
},
2693 {"fullscreen", &Qfullscreen
},
2694 {"font-backend", &Qfont_backend
},
2696 {"sticky", &Qsticky
},
2697 {"tool-bar-position", &Qtool_bar_position
},
2702 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2703 wanted positions of the WM window (not Emacs window).
2704 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2705 window (FRAME_X_WINDOW).
2709 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2711 int newwidth
= FRAME_COLS (f
);
2712 int newheight
= FRAME_LINES (f
);
2713 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2715 *top_pos
= f
->top_pos
;
2716 *left_pos
= f
->left_pos
;
2718 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2722 ph
= x_display_pixel_height (dpyinfo
);
2723 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2724 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2725 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2729 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2733 pw
= x_display_pixel_width (dpyinfo
);
2734 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2735 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2736 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2741 *height
= newheight
;
2744 #endif /* HAVE_NTGUI */
2746 #ifdef HAVE_WINDOW_SYSTEM
2748 /* Change the parameters of frame F as specified by ALIST.
2749 If a parameter is not specially recognized, do nothing special;
2750 otherwise call the `x_set_...' function for that parameter.
2751 Except for certain geometry properties, always call store_frame_param
2752 to store the new value in the parameter alist. */
2755 x_set_frame_parameters (FRAME_PTR f
, Lisp_Object alist
)
2759 /* If both of these parameters are present, it's more efficient to
2760 set them both at once. So we wait until we've looked at the
2761 entire list before we set them. */
2765 Lisp_Object left
, top
;
2767 /* Same with these. */
2768 Lisp_Object icon_left
, icon_top
;
2770 /* Record in these vectors all the parms specified. */
2772 Lisp_Object
*values
;
2774 int left_no_change
= 0, top_no_change
= 0;
2775 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2776 int size_changed
= 0;
2777 struct gcpro gcpro1
, gcpro2
;
2780 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2783 parms
= alloca (i
* sizeof *parms
);
2784 values
= alloca (i
* sizeof *values
);
2786 /* Extract parm names and values into those vectors. */
2789 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2794 parms
[i
] = Fcar (elt
);
2795 values
[i
] = Fcdr (elt
);
2798 /* TAIL and ALIST are not used again below here. */
2799 alist
= tail
= Qnil
;
2801 GCPRO2 (*parms
, *values
);
2805 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2806 because their values appear in VALUES and strings are not valid. */
2807 top
= left
= Qunbound
;
2808 icon_left
= icon_top
= Qunbound
;
2810 /* Provide default values for HEIGHT and WIDTH. */
2811 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2812 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2814 /* Process foreground_color and background_color before anything else.
2815 They are independent of other properties, but other properties (e.g.,
2816 cursor_color) are dependent upon them. */
2817 /* Process default font as well, since fringe widths depends on it. */
2818 for (p
= 0; p
< i
; p
++)
2820 Lisp_Object prop
, val
;
2824 if (EQ (prop
, Qforeground_color
)
2825 || EQ (prop
, Qbackground_color
)
2826 || EQ (prop
, Qfont
))
2828 register Lisp_Object param_index
, old_value
;
2830 old_value
= get_frame_param (f
, prop
);
2831 if (NILP (Fequal (val
, old_value
)))
2833 store_frame_param (f
, prop
, val
);
2835 param_index
= Fget (prop
, Qx_frame_parameter
);
2836 if (NATNUMP (param_index
)
2837 && (XFASTINT (param_index
)
2838 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2839 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2840 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2845 /* Now process them in reverse of specified order. */
2848 Lisp_Object prop
, val
;
2853 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2856 width
= XFASTINT (val
);
2858 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2861 height
= XFASTINT (val
);
2863 else if (EQ (prop
, Qtop
))
2865 else if (EQ (prop
, Qleft
))
2867 else if (EQ (prop
, Qicon_top
))
2869 else if (EQ (prop
, Qicon_left
))
2871 else if (EQ (prop
, Qforeground_color
)
2872 || EQ (prop
, Qbackground_color
)
2873 || EQ (prop
, Qfont
))
2874 /* Processed above. */
2878 register Lisp_Object param_index
, old_value
;
2880 old_value
= get_frame_param (f
, prop
);
2882 store_frame_param (f
, prop
, val
);
2884 param_index
= Fget (prop
, Qx_frame_parameter
);
2885 if (NATNUMP (param_index
)
2886 && (XFASTINT (param_index
)
2887 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2888 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2889 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2893 /* Don't die if just one of these was set. */
2894 if (EQ (left
, Qunbound
))
2897 if (f
->left_pos
< 0)
2898 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2900 XSETINT (left
, f
->left_pos
);
2902 if (EQ (top
, Qunbound
))
2906 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2908 XSETINT (top
, f
->top_pos
);
2911 /* If one of the icon positions was not set, preserve or default it. */
2912 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
2914 icon_left_no_change
= 1;
2915 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2916 if (NILP (icon_left
))
2917 XSETINT (icon_left
, 0);
2919 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
2921 icon_top_no_change
= 1;
2922 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2923 if (NILP (icon_top
))
2924 XSETINT (icon_top
, 0);
2927 /* Don't set these parameters unless they've been explicitly
2928 specified. The window might be mapped or resized while we're in
2929 this function, and we don't want to override that unless the lisp
2930 code has asked for it.
2932 Don't set these parameters unless they actually differ from the
2933 window's current parameters; the window may not actually exist
2938 check_frame_size (f
, &height
, &width
);
2940 XSETFRAME (frame
, f
);
2943 && (width
!= FRAME_COLS (f
)
2944 || height
!= FRAME_LINES (f
)
2945 || f
->new_text_lines
|| f
->new_text_cols
))
2946 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2948 if ((!NILP (left
) || !NILP (top
))
2949 && ! (left_no_change
&& top_no_change
)
2950 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2951 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2956 /* Record the signs. */
2957 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2958 if (EQ (left
, Qminus
))
2959 f
->size_hint_flags
|= XNegative
;
2960 else if (TYPE_RANGED_INTEGERP (int, left
))
2962 leftpos
= XINT (left
);
2964 f
->size_hint_flags
|= XNegative
;
2966 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2967 && CONSP (XCDR (left
))
2968 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
2970 leftpos
= - XINT (XCAR (XCDR (left
)));
2971 f
->size_hint_flags
|= XNegative
;
2973 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2974 && CONSP (XCDR (left
))
2975 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
2977 leftpos
= XINT (XCAR (XCDR (left
)));
2980 if (EQ (top
, Qminus
))
2981 f
->size_hint_flags
|= YNegative
;
2982 else if (TYPE_RANGED_INTEGERP (int, top
))
2984 toppos
= XINT (top
);
2986 f
->size_hint_flags
|= YNegative
;
2988 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2989 && CONSP (XCDR (top
))
2990 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
2992 toppos
= - XINT (XCAR (XCDR (top
)));
2993 f
->size_hint_flags
|= YNegative
;
2995 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2996 && CONSP (XCDR (top
))
2997 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
2999 toppos
= XINT (XCAR (XCDR (top
)));
3003 /* Store the numeric value of the position. */
3004 f
->top_pos
= toppos
;
3005 f
->left_pos
= leftpos
;
3007 f
->win_gravity
= NorthWestGravity
;
3009 /* Actually set that position, and convert to absolute. */
3010 x_set_offset (f
, leftpos
, toppos
, -1);
3013 if ((!NILP (icon_left
) || !NILP (icon_top
))
3014 && ! (icon_left_no_change
&& icon_top_no_change
))
3015 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3022 /* Insert a description of internally-recorded parameters of frame X
3023 into the parameter alist *ALISTPTR that is to be given to the user.
3024 Only parameters that are specific to the X window system
3025 and whose values are not correctly recorded in the frame's
3026 param_alist need to be considered here. */
3029 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3033 char buf
[INT_BUFSIZE_BOUND (w
)];
3035 /* Represent negative positions (off the top or left screen edge)
3036 in a way that Fmodify_frame_parameters will understand correctly. */
3037 XSETINT (tem
, f
->left_pos
);
3038 if (f
->left_pos
>= 0)
3039 store_in_alist (alistptr
, Qleft
, tem
);
3041 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3043 XSETINT (tem
, f
->top_pos
);
3044 if (f
->top_pos
>= 0)
3045 store_in_alist (alistptr
, Qtop
, tem
);
3047 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3049 store_in_alist (alistptr
, Qborder_width
,
3050 make_number (f
->border_width
));
3051 store_in_alist (alistptr
, Qinternal_border_width
,
3052 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3053 store_in_alist (alistptr
, Qleft_fringe
,
3054 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3055 store_in_alist (alistptr
, Qright_fringe
,
3056 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3057 store_in_alist (alistptr
, Qscroll_bar_width
,
3058 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3060 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3061 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3062 /* nil means "use default width"
3063 for non-toolkit scroll bar.
3064 ruler-mode.el depends on this. */
3066 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
3067 MS-Windows it returns a value whose type is HANDLE, which is
3068 actually a pointer. Explicit casting avoids compiler
3070 w
= (uintptr_t) FRAME_X_WINDOW (f
);
3071 store_in_alist (alistptr
, Qwindow_id
,
3072 make_formatted_string (buf
, "%"pMu
, w
));
3073 #ifdef HAVE_X_WINDOWS
3074 #ifdef USE_X_TOOLKIT
3075 /* Tooltip frame may not have this widget. */
3076 if (FRAME_X_OUTPUT (f
)->widget
)
3078 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
3079 store_in_alist (alistptr
, Qouter_window_id
,
3080 make_formatted_string (buf
, "%"pMu
, w
));
3082 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3083 FRAME_SAMPLE_VISIBILITY (f
);
3084 store_in_alist (alistptr
, Qvisibility
,
3085 (FRAME_VISIBLE_P (f
) ? Qt
3086 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3087 store_in_alist (alistptr
, Qdisplay
,
3088 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3090 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3093 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3094 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3095 store_in_alist (alistptr
, Qparent_id
, tem
);
3096 store_in_alist (alistptr
, Qtool_bar_position
, f
->tool_bar_position
);
3100 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3101 the previous value of that parameter, NEW_VALUE is the new value. */
3104 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3106 if (NILP (new_value
))
3107 f
->want_fullscreen
= FULLSCREEN_NONE
;
3108 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3109 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3110 else if (EQ (new_value
, Qfullwidth
))
3111 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3112 else if (EQ (new_value
, Qfullheight
))
3113 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3114 else if (EQ (new_value
, Qmaximized
))
3115 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3117 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3118 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3122 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3123 the previous value of that parameter, NEW_VALUE is the new value. */
3126 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3128 if (NILP (new_value
))
3129 f
->extra_line_spacing
= 0;
3130 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
3131 f
->extra_line_spacing
= XFASTINT (new_value
);
3133 signal_error ("Invalid line-spacing", new_value
);
3134 if (FRAME_VISIBLE_P (f
))
3139 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3140 the previous value of that parameter, NEW_VALUE is the new value. */
3143 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3145 Lisp_Object bgcolor
;
3147 if (NILP (new_value
))
3149 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3150 /* The value 0.4545 is the normal viewing gamma. */
3151 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3153 signal_error ("Invalid screen-gamma", new_value
);
3155 /* Apply the new gamma value to the frame background. */
3156 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3157 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3159 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3160 if (NATNUMP (parm_index
)
3161 && (XFASTINT (parm_index
)
3162 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3163 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3164 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3168 Fclear_face_cache (Qnil
);
3173 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3175 Lisp_Object font_object
;
3177 #ifdef HAVE_X_WINDOWS
3178 Lisp_Object font_param
= arg
;
3181 /* Set the frame parameter back to the old value because we may
3182 fail to use ARG as the new parameter value. */
3183 store_frame_param (f
, Qfont
, oldval
);
3185 /* ARG is a fontset name, a font name, a cons of fontset name and a
3186 font object, or a font object. In the last case, this function
3190 fontset
= fs_query_fontset (arg
, 0);
3193 font_object
= font_open_by_name (f
, arg
);
3194 if (NILP (font_object
))
3195 error ("Font `%s' is not defined", SSDATA (arg
));
3196 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3198 else if (fontset
> 0)
3200 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
3201 if (NILP (font_object
))
3202 error ("Font `%s' is not defined", SDATA (arg
));
3203 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3206 error ("The default fontset can't be used for a frame font");
3208 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3210 /* This is the case that the ASCII font of F's fontset XCAR
3211 (arg) is changed to the font XCDR (arg) by
3212 `set-fontset-font'. */
3213 fontset
= fs_query_fontset (XCAR (arg
), 0);
3215 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3216 font_object
= XCDR (arg
);
3217 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3218 #ifdef HAVE_X_WINDOWS
3219 font_param
= Ffont_get (font_object
, QCname
);
3222 else if (FONT_OBJECT_P (arg
))
3225 #ifdef HAVE_X_WINDOWS
3226 font_param
= Ffont_get (font_object
, QCname
);
3228 /* This is to store the XLFD font name in the frame parameter for
3229 backward compatibility. We should store the font-object
3230 itself in the future. */
3231 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3232 fontset
= FRAME_FONTSET (f
);
3233 /* Check if we can use the current fontset. If not, set FONTSET
3234 to -1 to generate a new fontset from FONT-OBJECT. */
3237 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3238 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3240 if (! font_match_p (spec
, font_object
))
3245 signal_error ("Invalid font", arg
);
3247 if (! NILP (Fequal (font_object
, oldval
)))
3250 x_new_font (f
, font_object
, fontset
);
3251 store_frame_param (f
, Qfont
, arg
);
3252 #ifdef HAVE_X_WINDOWS
3253 store_frame_param (f
, Qfont_param
, font_param
);
3255 /* Recalculate toolbar height. */
3256 f
->n_tool_bar_rows
= 0;
3257 /* Ensure we redraw it. */
3258 clear_current_matrices (f
);
3260 recompute_basic_faces (f
);
3262 do_pending_window_change (0);
3264 /* We used to call face-set-after-frame-default here, but it leads to
3265 recursive calls (since that function can set the `default' face's
3266 font which in turns changes the frame's `font' parameter).
3267 Also I don't know what this call is meant to do, but it seems the
3268 wrong way to do it anyway (it does a lot more work than what seems
3269 reasonable in response to a change to `font'). */
3274 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3276 if (! NILP (new_value
)
3277 && !CONSP (new_value
))
3281 CHECK_STRING (new_value
);
3282 p0
= p1
= SSDATA (new_value
);
3286 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
3288 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3294 while ((c
= *++p1
) && c_isspace (c
));
3298 new_value
= Fnreverse (new_value
);
3301 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3305 free_all_realized_faces (Qnil
);
3307 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3308 if (NILP (new_value
))
3310 if (NILP (old_value
))
3311 error ("No font backend available");
3312 font_update_drivers (f
, old_value
);
3313 error ("None of specified font backends are available");
3315 store_frame_param (f
, Qfont_backend
, new_value
);
3321 XSETFRAME (frame
, f
);
3322 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3323 ++face_change_count
;
3324 ++windows_or_buffers_changed
;
3330 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3332 compute_fringe_widths (f
, 1);
3333 #ifdef HAVE_X_WINDOWS
3334 /* Must adjust this so window managers report correct number of columns. */
3335 if (FRAME_X_WINDOW (f
) != 0)
3336 x_wm_set_size_hint (f
, 0, 0);
3341 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3343 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3345 if (XINT (arg
) == f
->border_width
)
3348 if (FRAME_X_WINDOW (f
) != 0)
3349 error ("Cannot change the border width of a frame");
3351 f
->border_width
= XINT (arg
);
3355 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3357 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3359 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3360 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3361 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3362 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3364 #ifdef USE_X_TOOLKIT
3365 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3366 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3369 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3372 if (FRAME_X_WINDOW (f
) != 0)
3374 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3375 SET_FRAME_GARBAGED (f
);
3376 do_pending_window_change (0);
3379 SET_FRAME_GARBAGED (f
);
3383 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3386 XSETFRAME (frame
, f
);
3389 Fmake_frame_invisible (frame
, Qt
);
3390 else if (EQ (value
, Qicon
))
3391 Ficonify_frame (frame
);
3393 Fmake_frame_visible (frame
);
3397 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3399 f
->auto_raise
= !EQ (Qnil
, arg
);
3403 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3405 f
->auto_lower
= !EQ (Qnil
, arg
);
3409 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3411 f
->no_split
= !NILP (arg
);
3415 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3417 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3418 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3419 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3420 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3422 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3424 ? vertical_scroll_bar_none
3426 ? vertical_scroll_bar_left
3428 ? vertical_scroll_bar_right
3429 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3430 ? vertical_scroll_bar_left
3431 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3432 ? vertical_scroll_bar_right
3433 : vertical_scroll_bar_none
);
3435 /* We set this parameter before creating the X window for the
3436 frame, so we can get the geometry right from the start.
3437 However, if the window hasn't been created yet, we shouldn't
3438 call x_set_window_size. */
3439 if (FRAME_X_WINDOW (f
))
3440 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3441 do_pending_window_change (0);
3446 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3448 int wid
= FRAME_COLUMN_WIDTH (f
);
3452 x_set_scroll_bar_default_width (f
);
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);
3458 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3459 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3461 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3462 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3464 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3465 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3466 if (FRAME_X_WINDOW (f
))
3467 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3468 do_pending_window_change (0);
3471 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3472 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3473 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3478 /* Return non-nil if frame F wants a bitmap icon. */
3481 x_icon_type (FRAME_PTR f
)
3485 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3493 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3500 for (i
= 0; i
< 2; i
++)
3513 else if (FLOATP (item
))
3515 alpha
= XFLOAT_DATA (item
);
3516 if (alpha
< 0.0 || 1.0 < alpha
)
3517 args_out_of_range (make_float (0.0), make_float (1.0));
3519 else if (INTEGERP (item
))
3521 EMACS_INT ialpha
= XINT (item
);
3522 if (ialpha
< 0 || 100 < ialpha
)
3523 args_out_of_range (make_number (0), make_number (100));
3525 alpha
= ialpha
/ 100.0;
3528 wrong_type_argument (Qnumberp
, item
);
3532 for (i
= 0; i
< 2; i
++)
3533 f
->alpha
[i
] = newval
[i
];
3535 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3537 x_set_frame_alpha (f
);
3545 /* Subroutines of creating an X frame. */
3547 /* Make sure that Vx_resource_name is set to a reasonable value.
3548 Fix it up, or set it to `emacs' if it is too hopeless. */
3551 validate_x_resource_name (void)
3554 /* Number of valid characters in the resource name. */
3555 ptrdiff_t good_count
= 0;
3556 /* Number of invalid characters in the resource name. */
3557 ptrdiff_t bad_count
= 0;
3561 if (!STRINGP (Vx_resource_class
))
3562 Vx_resource_class
= build_string (EMACS_CLASS
);
3564 if (STRINGP (Vx_resource_name
))
3566 unsigned char *p
= SDATA (Vx_resource_name
);
3568 len
= SBYTES (Vx_resource_name
);
3570 /* Only letters, digits, - and _ are valid in resource names.
3571 Count the valid characters and count the invalid ones. */
3572 for (i
= 0; i
< len
; i
++)
3575 if (! ((c
>= 'a' && c
<= 'z')
3576 || (c
>= 'A' && c
<= 'Z')
3577 || (c
>= '0' && c
<= '9')
3578 || c
== '-' || c
== '_'))
3585 /* Not a string => completely invalid. */
3586 bad_count
= 5, good_count
= 0;
3588 /* If name is valid already, return. */
3592 /* If name is entirely invalid, or nearly so, or is so implausibly
3593 large that alloca might not work, use `emacs'. */
3594 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
3596 Vx_resource_name
= build_string ("emacs");
3600 /* Name is partly valid. Copy it and replace the invalid characters
3601 with underscores. */
3603 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3605 for (i
= 0; i
< len
; i
++)
3607 int c
= SREF (new, i
);
3608 if (! ((c
>= 'a' && c
<= 'z')
3609 || (c
>= 'A' && c
<= 'Z')
3610 || (c
>= '0' && c
<= '9')
3611 || c
== '-' || c
== '_'))
3617 extern char *x_get_string_resource (XrmDatabase
, const char *, const char *);
3618 extern Display_Info
*check_x_display_info (Lisp_Object
);
3621 /* Get specified attribute from resource database RDB.
3622 See Fx_get_resource below for other parameters. */
3625 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3627 register char *value
;
3631 CHECK_STRING (attribute
);
3632 CHECK_STRING (class);
3634 if (!NILP (component
))
3635 CHECK_STRING (component
);
3636 if (!NILP (subclass
))
3637 CHECK_STRING (subclass
);
3638 if (NILP (component
) != NILP (subclass
))
3639 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3641 validate_x_resource_name ();
3643 /* Allocate space for the components, the dots which separate them,
3644 and the final '\0'. Make them big enough for the worst case. */
3645 name_key
= alloca (SBYTES (Vx_resource_name
)
3646 + (STRINGP (component
)
3647 ? SBYTES (component
) : 0)
3648 + SBYTES (attribute
)
3651 class_key
= alloca (SBYTES (Vx_resource_class
)
3653 + (STRINGP (subclass
)
3654 ? SBYTES (subclass
) : 0)
3657 /* Start with emacs.FRAMENAME for the name (the specific one)
3658 and with `Emacs' for the class key (the general one). */
3659 strcpy (name_key
, SSDATA (Vx_resource_name
));
3660 strcpy (class_key
, SSDATA (Vx_resource_class
));
3662 strcat (class_key
, ".");
3663 strcat (class_key
, SSDATA (class));
3665 if (!NILP (component
))
3667 strcat (class_key
, ".");
3668 strcat (class_key
, SSDATA (subclass
));
3670 strcat (name_key
, ".");
3671 strcat (name_key
, SSDATA (component
));
3674 strcat (name_key
, ".");
3675 strcat (name_key
, SSDATA (attribute
));
3677 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3679 if (value
!= (char *) 0 && *value
)
3680 return build_string (value
);
3686 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3687 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3688 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3689 class, where INSTANCE is the name under which Emacs was invoked, or
3690 the name specified by the `-name' or `-rn' command-line arguments.
3692 The optional arguments COMPONENT and SUBCLASS add to the key and the
3693 class, respectively. You must specify both of them or neither.
3694 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3695 and the class is `Emacs.CLASS.SUBCLASS'. */)
3696 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3698 #ifdef HAVE_X_WINDOWS
3702 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3703 attribute
, class, component
, subclass
);
3706 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3709 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3711 return xrdb_get_resource (dpyinfo
->xrdb
,
3712 attribute
, class, component
, subclass
);
3715 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3716 /* Used when C code wants a resource value. */
3717 /* Called from oldXMenu/Create.c. */
3719 x_get_resource_string (const char *attribute
, const char *class)
3722 struct frame
*sf
= SELECTED_FRAME ();
3723 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
3726 /* Allocate space for the components, the dots which separate them,
3727 and the final '\0'. */
3728 char *name_key
= SAFE_ALLOCA (invocation_namelen
+ strlen (attribute
) + 2);
3729 char *class_key
= alloca ((sizeof (EMACS_CLASS
) - 1) + strlen (class) + 2);
3731 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
3732 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3734 result
= x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3735 name_key
, class_key
);
3741 /* Return the value of parameter PARAM.
3743 First search ALIST, then Vdefault_frame_alist, then the X defaults
3744 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3746 Convert the resource to the type specified by desired_type.
3748 If no default is specified, return Qunbound. If you call
3749 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3750 and don't let it get stored in any Lisp-visible variables! */
3753 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3754 const char *attribute
, const char *class, enum resource_types type
)
3756 register Lisp_Object tem
;
3758 tem
= Fassq (param
, alist
);
3762 /* If we find this parm in ALIST, clear it out
3763 so that it won't be "left over" at the end. */
3765 XSETCAR (tem
, Qnil
);
3766 /* In case the parameter appears more than once in the alist,
3768 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3769 if (CONSP (XCAR (tail
))
3770 && EQ (XCAR (XCAR (tail
)), param
))
3771 XSETCAR (XCAR (tail
), Qnil
);
3774 tem
= Fassq (param
, Vdefault_frame_alist
);
3776 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3777 look in the X resources. */
3780 if (attribute
&& dpyinfo
)
3782 tem
= display_x_get_resource (dpyinfo
,
3783 build_string (attribute
),
3784 build_string (class),
3792 case RES_TYPE_NUMBER
:
3793 return make_number (atoi (SSDATA (tem
)));
3795 case RES_TYPE_BOOLEAN_NUMBER
:
3796 if (!strcmp (SSDATA (tem
), "on")
3797 || !strcmp (SSDATA (tem
), "true"))
3798 return make_number (1);
3799 return make_number (atoi (SSDATA (tem
)));
3802 case RES_TYPE_FLOAT
:
3803 return make_float (atof (SSDATA (tem
)));
3805 case RES_TYPE_BOOLEAN
:
3806 tem
= Fdowncase (tem
);
3807 if (!strcmp (SSDATA (tem
), "on")
3809 || !strcmp (SSDATA (tem
), "yes")
3811 || !strcmp (SSDATA (tem
), "true"))
3816 case RES_TYPE_STRING
:
3819 case RES_TYPE_SYMBOL
:
3820 /* As a special case, we map the values `true' and `on'
3821 to Qt, and `false' and `off' to Qnil. */
3824 lower
= Fdowncase (tem
);
3825 if (!strcmp (SSDATA (lower
), "on")
3827 || !strcmp (SSDATA (lower
), "yes")
3829 || !strcmp (SSDATA (lower
), "true"))
3831 else if (!strcmp (SSDATA (lower
), "off")
3833 || !strcmp (SSDATA (lower
), "no")
3835 || !strcmp (SSDATA (lower
), "false"))
3838 return Fintern (tem
, Qnil
);
3852 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3853 const char *attribute
, const char *class,
3854 enum resource_types type
)
3856 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3857 alist
, param
, attribute
, class, type
);
3860 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3863 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3865 const char *attribute
, const char *class,
3866 enum resource_types type
)
3870 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3871 attribute
, class, type
);
3872 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3873 store_frame_param (f
, param
, value
);
3879 /* Record in frame F the specified or default value according to ALIST
3880 of the parameter named PROP (a Lisp symbol).
3881 If no value is specified for PROP, look for an X default for XPROP
3882 on the frame named NAME.
3883 If that is not found either, use the value DEFLT. */
3886 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
3887 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
3888 enum resource_types type
)
3892 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3893 if (EQ (tem
, Qunbound
))
3895 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3900 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
3903 * XParseGeometry parses strings of the form
3904 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
3905 * width, height, xoffset, and yoffset are unsigned integers.
3906 * Example: "=80x24+300-49"
3907 * The equal sign is optional.
3908 * It returns a bitmask that indicates which of the four values
3909 * were actually found in the string. For each value found,
3910 * the corresponding argument is updated; for each value
3911 * not found, the corresponding argument is left unchanged.
3915 XParseGeometry (char *string
,
3917 unsigned int *width
, unsigned int *height
)
3921 unsigned long int tempWidth
, tempHeight
;
3922 long int tempX
, tempY
;
3923 char *nextCharacter
;
3925 if (string
== NULL
|| *string
== '\0')
3928 string
++; /* ignore possible '=' at beg of geometry spec */
3931 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
3933 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
3934 if (strind
== nextCharacter
)
3936 strind
= nextCharacter
;
3940 if (*strind
== 'x' || *strind
== 'X')
3943 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
3944 if (strind
== nextCharacter
)
3946 strind
= nextCharacter
;
3947 mask
|= HeightValue
;
3950 if (*strind
== '+' || *strind
== '-')
3954 tempX
= strtol (strind
, &nextCharacter
, 10);
3955 if (strind
== nextCharacter
)
3957 strind
= nextCharacter
;
3959 if (*strind
== '+' || *strind
== '-')
3963 tempY
= strtol (strind
, &nextCharacter
, 10);
3964 if (strind
== nextCharacter
)
3966 strind
= nextCharacter
;
3971 /* If strind isn't at the end of the string then it's an invalid
3972 geometry specification. */
3974 if (*strind
!= '\0')
3978 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
3980 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
3981 if (mask
& WidthValue
)
3982 *width
= min (tempWidth
, UINT_MAX
);
3983 if (mask
& HeightValue
)
3984 *height
= min (tempHeight
, UINT_MAX
);
3988 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
3991 /* NS used to define x-parse-geometry in ns-win.el, but that confused
3992 make-docfile: the documentation string in ns-win.el was used for
3993 x-parse-geometry even in non-NS builds.
3995 With two definitions of x-parse-geometry in this file, various
3996 things still get confused (eg M-x apropos documentation), so that
3997 it is best if the two definitions just share the same doc-string.
3999 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4000 doc
: /* Parse a display geometry string STRING.
4001 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4002 The properties returned may include `top', `left', `height', and `width'.
4003 For X, the value of `left' or `top' may be an integer,
4004 or a list (+ N) meaning N pixels relative to top/left corner,
4005 or a list (- N) meaning -N pixels relative to bottom/right corner.
4006 On Nextstep, this just calls `ns-parse-geometry'. */)
4007 (Lisp_Object string
)
4010 unsigned int width
, height
;
4013 CHECK_STRING (string
);
4016 if (strchr (SSDATA (string
), ' ') != NULL
)
4017 return call1 (Qns_parse_geometry
, string
);
4019 geometry
= XParseGeometry (SSDATA (string
),
4020 &x
, &y
, &width
, &height
);
4022 if (geometry
& XValue
)
4024 Lisp_Object element
;
4026 if (x
>= 0 && (geometry
& XNegative
))
4027 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
4028 else if (x
< 0 && ! (geometry
& XNegative
))
4029 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
4031 element
= Fcons (Qleft
, make_number (x
));
4032 result
= Fcons (element
, result
);
4035 if (geometry
& YValue
)
4037 Lisp_Object element
;
4039 if (y
>= 0 && (geometry
& YNegative
))
4040 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
4041 else if (y
< 0 && ! (geometry
& YNegative
))
4042 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
4044 element
= Fcons (Qtop
, make_number (y
));
4045 result
= Fcons (element
, result
);
4048 if (geometry
& WidthValue
)
4049 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
4050 if (geometry
& HeightValue
)
4051 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
4057 /* Calculate the desired size and position of frame F.
4058 Return the flags saying which aspects were specified.
4060 Also set the win_gravity and size_hint_flags of F.
4062 Adjust height for toolbar if TOOLBAR_P is 1.
4064 This function does not make the coordinates positive. */
4066 #define DEFAULT_ROWS 35
4067 #define DEFAULT_COLS 80
4070 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, int toolbar_p
)
4072 register Lisp_Object tem0
, tem1
, tem2
;
4073 long window_prompting
= 0;
4074 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
4076 /* Default values if we fall through.
4077 Actually, if that happens we should get
4078 window manager prompting. */
4079 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4080 FRAME_LINES (f
) = DEFAULT_ROWS
;
4081 /* Window managers expect that if program-specified
4082 positions are not (0,0), they're intentional, not defaults. */
4086 /* Ensure that old new_text_cols and new_text_lines will not override the
4088 /* ++KFS: This was specific to W32, but seems ok for all platforms */
4089 f
->new_text_cols
= f
->new_text_lines
= 0;
4091 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4092 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4093 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4094 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4096 if (!EQ (tem0
, Qunbound
))
4098 CHECK_NUMBER (tem0
);
4099 if (! (0 <= XINT (tem0
) && XINT (tem0
) <= INT_MAX
))
4100 xsignal1 (Qargs_out_of_range
, tem0
);
4101 FRAME_LINES (f
) = XINT (tem0
);
4103 if (!EQ (tem1
, Qunbound
))
4105 CHECK_NUMBER (tem1
);
4106 if (! (0 <= XINT (tem1
) && XINT (tem1
) <= INT_MAX
))
4107 xsignal1 (Qargs_out_of_range
, tem1
);
4108 SET_FRAME_COLS (f
, XINT (tem1
));
4110 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4111 window_prompting
|= USSize
;
4113 window_prompting
|= PSize
;
4116 f
->scroll_bar_actual_width
4117 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4119 /* This used to be done _before_ calling x_figure_window_size, but
4120 since the height is reset here, this was really a no-op. I
4121 assume that moving it here does what Gerd intended (although he
4122 no longer can remember what that was... ++KFS, 2003-03-25. */
4124 /* Add the tool-bar height to the initial frame height so that the
4125 user gets a text display area of the size he specified with -g or
4126 via .Xdefaults. Later changes of the tool-bar height don't
4127 change the frame size. This is done so that users can create
4128 tall Emacs frames without having to guess how tall the tool-bar
4130 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4132 int margin
, relief
, bar_height
;
4134 relief
= (tool_bar_button_relief
>= 0
4135 ? tool_bar_button_relief
4136 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4138 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
4139 margin
= XFASTINT (Vtool_bar_button_margin
);
4140 else if (CONSP (Vtool_bar_button_margin
)
4141 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
4142 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4146 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4147 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4150 compute_fringe_widths (f
, 0);
4152 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4153 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4155 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4156 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4157 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4158 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4160 if (EQ (tem0
, Qminus
))
4163 window_prompting
|= YNegative
;
4165 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4166 && CONSP (XCDR (tem0
))
4167 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem0
)), INT_MAX
))
4169 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4170 window_prompting
|= YNegative
;
4172 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4173 && CONSP (XCDR (tem0
))
4174 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0
))))
4176 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4178 else if (EQ (tem0
, Qunbound
))
4182 CHECK_TYPE_RANGED_INTEGER (int, tem0
);
4183 f
->top_pos
= XINT (tem0
);
4185 window_prompting
|= YNegative
;
4188 if (EQ (tem1
, Qminus
))
4191 window_prompting
|= XNegative
;
4193 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4194 && CONSP (XCDR (tem1
))
4195 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem1
)), INT_MAX
))
4197 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4198 window_prompting
|= XNegative
;
4200 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4201 && CONSP (XCDR (tem1
))
4202 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1
))))
4204 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4206 else if (EQ (tem1
, Qunbound
))
4210 CHECK_TYPE_RANGED_INTEGER (int, tem1
);
4211 f
->left_pos
= XINT (tem1
);
4212 if (f
->left_pos
< 0)
4213 window_prompting
|= XNegative
;
4216 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4217 window_prompting
|= USPosition
;
4219 window_prompting
|= PPosition
;
4222 if (window_prompting
& XNegative
)
4224 if (window_prompting
& YNegative
)
4225 f
->win_gravity
= SouthEastGravity
;
4227 f
->win_gravity
= NorthEastGravity
;
4231 if (window_prompting
& YNegative
)
4232 f
->win_gravity
= SouthWestGravity
;
4234 f
->win_gravity
= NorthWestGravity
;
4237 f
->size_hint_flags
= window_prompting
;
4239 return window_prompting
;
4244 #endif /* HAVE_WINDOW_SYSTEM */
4247 frame_make_pointer_invisible (void)
4249 if (! NILP (Vmake_pointer_invisible
))
4252 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4255 f
= SELECTED_FRAME ();
4256 if (f
&& !f
->pointer_invisible
4257 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4260 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4261 f
->pointer_invisible
= 1;
4267 frame_make_pointer_visible (void)
4269 /* We don't check Vmake_pointer_invisible here in case the
4270 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4273 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4276 f
= SELECTED_FRAME ();
4277 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4278 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4280 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4281 f
->pointer_invisible
= 0;
4285 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4286 Sframe_pointer_visible_p
, 0, 1, 0,
4287 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4288 Otherwise it returns nil. FRAME omitted or nil means the
4289 selected frame. This is useful when `make-pointer-invisible' is set. */)
4293 frame
= selected_frame
;
4295 CHECK_FRAME (frame
);
4297 return (XFRAME (frame
)->pointer_invisible
? Qnil
: Qt
);
4301 /***********************************************************************
4303 ***********************************************************************/
4306 syms_of_frame (void)
4308 DEFSYM (Qframep
, "framep");
4309 DEFSYM (Qframe_live_p
, "frame-live-p");
4310 DEFSYM (Qexplicit_name
, "explicit-name");
4311 DEFSYM (Qheight
, "height");
4312 DEFSYM (Qicon
, "icon");
4313 DEFSYM (Qminibuffer
, "minibuffer");
4314 DEFSYM (Qmodeline
, "modeline");
4315 DEFSYM (Qonly
, "only");
4316 DEFSYM (Qnone
, "none");
4317 DEFSYM (Qwidth
, "width");
4318 DEFSYM (Qgeometry
, "geometry");
4319 DEFSYM (Qicon_left
, "icon-left");
4320 DEFSYM (Qicon_top
, "icon-top");
4321 DEFSYM (Qtooltip
, "tooltip");
4322 DEFSYM (Qleft
, "left");
4323 DEFSYM (Qright
, "right");
4324 DEFSYM (Quser_position
, "user-position");
4325 DEFSYM (Quser_size
, "user-size");
4326 DEFSYM (Qwindow_id
, "window-id");
4327 #ifdef HAVE_X_WINDOWS
4328 DEFSYM (Qouter_window_id
, "outer-window-id");
4330 DEFSYM (Qparent_id
, "parent-id");
4332 DEFSYM (Qw32
, "w32");
4335 DEFSYM (Qvisible
, "visible");
4336 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4337 DEFSYM (Qbuffer_list
, "buffer-list");
4338 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4339 DEFSYM (Qdisplay_type
, "display-type");
4340 DEFSYM (Qbackground_mode
, "background-mode");
4341 DEFSYM (Qnoelisp
, "noelisp");
4342 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4343 DEFSYM (Qtty
, "tty");
4344 DEFSYM (Qtty_type
, "tty-type");
4346 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4348 DEFSYM (Qfullwidth
, "fullwidth");
4349 DEFSYM (Qfullheight
, "fullheight");
4350 DEFSYM (Qfullboth
, "fullboth");
4351 DEFSYM (Qmaximized
, "maximized");
4352 DEFSYM (Qx_resource_name
, "x-resource-name");
4353 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4355 DEFSYM (Qterminal
, "terminal");
4356 DEFSYM (Qterminal_live_p
, "terminal-live-p");
4359 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4365 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4367 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4368 if (frame_parms
[i
].variable
)
4370 *frame_parms
[i
].variable
= v
;
4371 staticpro (frame_parms
[i
].variable
);
4373 Fput (v
, Qx_frame_parameter
, make_number (i
));
4377 #ifdef HAVE_WINDOW_SYSTEM
4378 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4379 doc
: /* The name Emacs uses to look up X resources.
4380 `x-get-resource' uses this as the first component of the instance name
4381 when requesting resource values.
4382 Emacs initially sets `x-resource-name' to the name under which Emacs
4383 was invoked, or to the value specified with the `-name' or `-rn'
4384 switches, if present.
4386 It may be useful to bind this variable locally around a call
4387 to `x-get-resource'. See also the variable `x-resource-class'. */);
4388 Vx_resource_name
= Qnil
;
4390 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4391 doc
: /* The class Emacs uses to look up X resources.
4392 `x-get-resource' uses this as the first component of the instance class
4393 when requesting resource values.
4395 Emacs initially sets `x-resource-class' to "Emacs".
4397 Setting this variable permanently is not a reasonable thing to do,
4398 but binding this variable locally around a call to `x-get-resource'
4399 is a reasonable practice. See also the variable `x-resource-name'. */);
4400 Vx_resource_class
= build_string (EMACS_CLASS
);
4402 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4403 doc
: /* The lower limit of the frame opacity (alpha transparency).
4404 The value should range from 0 (invisible) to 100 (completely opaque).
4405 You can also use a floating number between 0.0 and 1.0.
4406 The default is 20. */);
4407 Vframe_alpha_lower_limit
= make_number (20);
4410 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4411 doc
: /* Alist of default values for frame creation.
4412 These may be set in your init file, like this:
4413 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4414 These override values given in window system configuration data,
4415 including X Windows' defaults database.
4416 For values specific to the first Emacs frame, see `initial-frame-alist'.
4417 For window-system specific values, see `window-system-default-frame-alist'.
4418 For values specific to the separate minibuffer frame, see
4419 `minibuffer-frame-alist'.
4420 The `menu-bar-lines' element of the list controls whether new frames
4421 have menu bars; `menu-bar-mode' works by altering this element.
4422 Setting this variable does not affect existing frames, only new ones. */);
4423 Vdefault_frame_alist
= Qnil
;
4425 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4426 doc
: /* Default position of scroll bars on this window-system. */);
4427 #ifdef HAVE_WINDOW_SYSTEM
4428 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
4429 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4431 Vdefault_frame_scroll_bars
= Qright
;
4433 Vdefault_frame_scroll_bars
= Qleft
;
4436 Vdefault_frame_scroll_bars
= Qnil
;
4439 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4440 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4442 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4443 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4444 `mouse-position' calls this function, passing its usual return value as
4445 argument, and returns whatever this function returns.
4446 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4447 which need to do mouse handling at the Lisp level. */);
4448 Vmouse_position_function
= Qnil
;
4450 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4451 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4452 If the value is an integer, highlighting is only shown after moving the
4453 mouse, while keyboard input turns off the highlight even when the mouse
4454 is over the clickable text. However, the mouse shape still indicates
4455 when the mouse is over clickable text. */);
4456 Vmouse_highlight
= Qt
;
4458 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4459 doc
: /* If non-nil, make pointer invisible while typing.
4460 The pointer becomes visible again when the mouse is moved. */);
4461 Vmake_pointer_invisible
= Qt
;
4463 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4464 doc
: /* Functions run before deleting a frame.
4465 The functions are run with one arg, the frame to be deleted.
4468 Note that functions in this list may be called just before the frame is
4469 actually deleted, or some time later (or even both when an earlier function
4470 in `delete-frame-functions' (indirectly) calls `delete-frame'
4472 Vdelete_frame_functions
= Qnil
;
4473 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
4475 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4476 doc
: /* Non-nil if Menu-Bar mode is enabled.
4477 See the command `menu-bar-mode' for a description of this minor mode.
4478 Setting this variable directly does not take effect;
4479 either customize it (see the info node `Easy Customization')
4480 or call the function `menu-bar-mode'. */);
4481 Vmenu_bar_mode
= Qt
;
4483 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4484 doc
: /* Non-nil if Tool-Bar mode is enabled.
4485 See the command `tool-bar-mode' for a description of this minor mode.
4486 Setting this variable directly does not take effect;
4487 either customize it (see the info node `Easy Customization')
4488 or call the function `tool-bar-mode'. */);
4489 #ifdef HAVE_WINDOW_SYSTEM
4490 Vtool_bar_mode
= Qt
;
4492 Vtool_bar_mode
= Qnil
;
4495 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4496 doc
: /* Minibufferless frames use this frame's minibuffer.
4498 Emacs cannot create minibufferless frames unless this is set to an
4499 appropriate surrogate.
4501 Emacs consults this variable only when creating minibufferless
4502 frames; once the frame is created, it sticks with its assigned
4503 minibuffer, no matter what this variable is set to. This means that
4504 this variable doesn't necessarily say anything meaningful about the
4505 current set of frames, or where the minibuffer is currently being
4508 This variable is local to the current terminal and cannot be buffer-local. */);
4510 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
4511 doc
: /* Non-nil if window system changes focus when you move the mouse.
4512 You should set this variable to tell Emacs how your window manager
4513 handles focus, since there is no way in general for Emacs to find out
4514 automatically. See also `mouse-autoselect-window'. */);
4515 focus_follows_mouse
= 0;
4517 staticpro (&Vframe_list
);
4520 defsubr (&Sframe_live_p
);
4521 defsubr (&Swindow_system
);
4522 defsubr (&Smake_terminal_frame
);
4523 defsubr (&Shandle_switch_frame
);
4524 defsubr (&Sselect_frame
);
4525 defsubr (&Sselected_frame
);
4526 defsubr (&Sframe_list
);
4527 defsubr (&Snext_frame
);
4528 defsubr (&Sprevious_frame
);
4529 defsubr (&Sdelete_frame
);
4530 defsubr (&Smouse_position
);
4531 defsubr (&Smouse_pixel_position
);
4532 defsubr (&Sset_mouse_position
);
4533 defsubr (&Sset_mouse_pixel_position
);
4535 defsubr (&Sframe_configuration
);
4536 defsubr (&Srestore_frame_configuration
);
4538 defsubr (&Smake_frame_visible
);
4539 defsubr (&Smake_frame_invisible
);
4540 defsubr (&Siconify_frame
);
4541 defsubr (&Sframe_visible_p
);
4542 defsubr (&Svisible_frame_list
);
4543 defsubr (&Sraise_frame
);
4544 defsubr (&Slower_frame
);
4545 defsubr (&Sredirect_frame_focus
);
4546 defsubr (&Sframe_focus
);
4547 defsubr (&Sframe_parameters
);
4548 defsubr (&Sframe_parameter
);
4549 defsubr (&Smodify_frame_parameters
);
4550 defsubr (&Sframe_char_height
);
4551 defsubr (&Sframe_char_width
);
4552 defsubr (&Sframe_pixel_height
);
4553 defsubr (&Sframe_pixel_width
);
4554 defsubr (&Stool_bar_pixel_width
);
4555 defsubr (&Sset_frame_height
);
4556 defsubr (&Sset_frame_width
);
4557 defsubr (&Sset_frame_size
);
4558 defsubr (&Sset_frame_position
);
4559 defsubr (&Sframe_pointer_visible_p
);
4561 #ifdef HAVE_WINDOW_SYSTEM
4562 defsubr (&Sx_get_resource
);
4563 defsubr (&Sx_parse_geometry
);