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/>. */
30 #include "character.h"
41 /* These help us bind and responding to switch-frame events. */
45 #include "blockinput.h"
47 #include "termhooks.h"
48 #include "dispextern.h"
51 #ifdef HAVE_WINDOW_SYSTEM
60 #ifdef HAVE_WINDOW_SYSTEM
65 Lisp_Object Qns_parse_geometry
;
68 Lisp_Object Qframep
, Qframe_live_p
;
69 Lisp_Object Qicon
, Qmodeline
;
70 Lisp_Object Qonly
, Qnone
;
71 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
, Qns
;
73 Lisp_Object Qdisplay_type
;
74 static Lisp_Object Qbackground_mode
;
77 static Lisp_Object Qx_frame_parameter
;
78 Lisp_Object Qx_resource_name
;
79 Lisp_Object Qterminal
;
80 Lisp_Object Qterminal_live_p
;
82 /* Frame parameters (set or reported). */
84 Lisp_Object Qauto_raise
, Qauto_lower
;
85 Lisp_Object Qborder_color
, Qborder_width
;
86 Lisp_Object Qcursor_color
, Qcursor_type
;
87 static Lisp_Object Qgeometry
; /* Not used */
88 Lisp_Object Qheight
, Qwidth
;
89 Lisp_Object Qleft
, Qright
;
90 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
92 Lisp_Object Qinternal_border_width
;
93 Lisp_Object Qmouse_color
;
94 Lisp_Object Qminibuffer
;
95 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
96 Lisp_Object Qvisibility
;
97 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
98 Lisp_Object Qscreen_gamma
;
99 Lisp_Object Qline_spacing
;
100 static Lisp_Object Quser_position
, Quser_size
;
101 Lisp_Object Qwait_for_wm
;
102 static Lisp_Object Qwindow_id
;
103 #ifdef HAVE_X_WINDOWS
104 static Lisp_Object Qouter_window_id
;
106 Lisp_Object Qparent_id
;
107 Lisp_Object Qtitle
, Qname
;
108 static Lisp_Object Qexplicit_name
;
109 Lisp_Object Qunsplittable
;
110 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
, Qtool_bar_position
;
111 Lisp_Object Qleft_fringe
, Qright_fringe
;
112 Lisp_Object Qbuffer_predicate
;
113 static Lisp_Object Qbuffer_list
, Qburied_buffer_list
;
114 Lisp_Object Qtty_color_mode
;
115 Lisp_Object Qtty
, Qtty_type
;
117 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
119 Lisp_Object Qfont_backend
;
122 Lisp_Object Qface_set_after_frame_default
;
124 static Lisp_Object Qdelete_frame_functions
;
126 #ifdef HAVE_WINDOW_SYSTEM
127 static void x_report_frame_params (struct frame
*, Lisp_Object
*);
132 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
134 struct window
*w
= XWINDOW (window
);
136 w
->last_modified
= 0;
137 WSET (w
, top_line
, make_number (XFASTINT (w
->top_line
) + n
));
138 WSET (w
, total_lines
, make_number (XFASTINT (w
->total_lines
) - n
));
140 /* Handle just the top child in a vertical split. */
141 if (!NILP (w
->vchild
))
142 set_menu_bar_lines_1 (w
->vchild
, n
);
144 /* Adjust all children in a horizontal split. */
145 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
147 w
= XWINDOW (window
);
148 set_menu_bar_lines_1 (window
, n
);
153 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
156 int olines
= FRAME_MENU_BAR_LINES (f
);
158 /* Right now, menu bars don't work properly in minibuf-only frames;
159 most of the commands try to apply themselves to the minibuffer
160 frame itself, and get an error because you can't switch buffers
161 in or split the minibuffer window. */
162 if (FRAME_MINIBUF_ONLY_P (f
))
165 if (TYPE_RANGED_INTEGERP (int, value
))
166 nlines
= XINT (value
);
170 if (nlines
!= olines
)
172 windows_or_buffers_changed
++;
173 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
174 FRAME_MENU_BAR_LINES (f
) = nlines
;
175 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
180 Lisp_Object Vframe_list
;
183 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
184 doc
: /* Return non-nil if OBJECT is a frame.
186 t for a termcap frame (a character-only terminal),
187 'x' for an Emacs frame that is really an X window,
188 'w32' for an Emacs frame that is a window on MS-Windows display,
189 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
190 'pc' for a direct-write MS-DOS frame.
191 See also `frame-live-p'. */)
194 if (!FRAMEP (object
))
196 switch (XFRAME (object
)->output_method
)
198 case output_initial
: /* The initial frame is like a termcap frame. */
201 case output_x_window
:
205 case output_msdos_raw
:
216 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
217 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
218 Value is nil if OBJECT is not a live frame. If object is a live
219 frame, the return value indicates what sort of terminal device it is
220 displayed on. See the documentation of `framep' for possible
224 return ((FRAMEP (object
)
225 && FRAME_LIVE_P (XFRAME (object
)))
230 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
231 doc
: /* The name of the window system that FRAME is displaying through.
232 The value is a symbol:
233 nil for a termcap frame (a character-only terminal),
234 'x' for an Emacs frame that is really an X window,
235 'w32' for an Emacs frame that is a window on MS-Windows display,
236 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
237 'pc' for a direct-write MS-DOS frame.
239 FRAME defaults to the currently selected frame.
241 Use of this function as a predicate is deprecated. Instead,
242 use `display-graphic-p' or any of the other `display-*-p'
243 predicates which report frame's specific UI-related capabilities. */)
248 frame
= selected_frame
;
250 type
= Fframep (frame
);
253 wrong_type_argument (Qframep
, frame
);
262 make_frame (int mini_p
)
265 register struct frame
*f
;
266 register Lisp_Object root_window
;
267 register Lisp_Object mini_window
;
269 f
= allocate_frame ();
270 XSETFRAME (frame
, f
);
272 /* Initialize Lisp data. Note that allocate_frame initializes all
273 Lisp data to nil, so do it only for slots which should not be nil. */
274 FSET (f
, tool_bar_position
, Qtop
);
276 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
277 non-Lisp data, so do it only for slots which should not be zero.
278 To avoid subtle bugs and for the sake of readability, it's better to
279 initialize enum members explicitly even if their values are zero. */
280 f
->wants_modeline
= 1;
282 f
->has_minibuffer
= mini_p
;
283 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
284 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
285 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
286 #ifdef HAVE_WINDOW_SYSTEM
287 f
->want_fullscreen
= FULLSCREEN_NONE
;
290 root_window
= make_window ();
293 mini_window
= make_window ();
294 WSET (XWINDOW (root_window
), next
, mini_window
);
295 WSET (XWINDOW (mini_window
), prev
, root_window
);
296 XWINDOW (mini_window
)->mini
= 1;
297 WSET (XWINDOW (mini_window
), frame
, frame
);
298 FSET (f
, minibuffer_window
, mini_window
);
303 WSET (XWINDOW (root_window
), next
, Qnil
);
304 FSET (f
, minibuffer_window
, Qnil
);
307 WSET (XWINDOW (root_window
), frame
, frame
);
310 just so that there is "something there."
311 Correct size will be set up later with change_frame_size. */
313 SET_FRAME_COLS (f
, 10);
314 FRAME_LINES (f
) = 10;
316 WSET (XWINDOW (root_window
), total_cols
, make_number (10));
317 WSET (XWINDOW (root_window
), total_lines
, make_number (mini_p
? 9 : 10));
321 WSET (XWINDOW (mini_window
), total_cols
, make_number (10));
322 WSET (XWINDOW (mini_window
), top_line
, make_number (9));
323 WSET (XWINDOW (mini_window
), total_lines
, make_number (1));
326 /* Choose a buffer for the frame's root window. */
330 WSET (XWINDOW (root_window
), buffer
, Qt
);
331 buf
= Fcurrent_buffer ();
332 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
333 a space), try to find another one. */
334 if (SREF (Fbuffer_name (buf
), 0) == ' ')
335 buf
= other_buffer_safely (buf
);
337 /* Use set_window_buffer, not Fset_window_buffer, and don't let
338 hooks be run by it. The reason is that the whole frame/window
339 arrangement is not yet fully initialized at this point. Windows
340 don't have the right size, glyph matrices aren't initialized
341 etc. Running Lisp functions at this point surely ends in a
343 set_window_buffer (root_window
, buf
, 0, 0);
344 FSET (f
, buffer_list
, Fcons (buf
, Qnil
));
349 WSET (XWINDOW (mini_window
), buffer
, Qt
);
350 set_window_buffer (mini_window
,
351 (NILP (Vminibuffer_list
)
353 : Fcar (Vminibuffer_list
)),
357 FSET (f
, root_window
, root_window
);
358 FSET (f
, selected_window
, root_window
);
359 /* Make sure this window seems more recently used than
360 a newly-created, never-selected window. */
361 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
366 #ifdef HAVE_WINDOW_SYSTEM
367 /* Make a frame using a separate minibuffer window on another frame.
368 MINI_WINDOW is the minibuffer window to use. nil means use the
369 default (the global minibuffer). */
372 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
374 register struct frame
*f
;
377 if (!NILP (mini_window
))
378 CHECK_LIVE_WINDOW (mini_window
);
380 if (!NILP (mini_window
)
381 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
382 error ("Frame and minibuffer must be on the same terminal");
384 /* Make a frame containing just a root window. */
387 if (NILP (mini_window
))
389 /* Use default-minibuffer-frame if possible. */
390 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
391 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
393 Lisp_Object frame_dummy
;
395 XSETFRAME (frame_dummy
, f
);
396 GCPRO1 (frame_dummy
);
397 /* If there's no minibuffer frame to use, create one. */
398 KSET (kb
, Vdefault_minibuffer_frame
,
399 call1 (intern ("make-initial-minibuffer-frame"), display
));
404 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
407 FSET (f
, minibuffer_window
, mini_window
);
409 /* Make the chosen minibuffer window display the proper minibuffer,
410 unless it is already showing a minibuffer. */
411 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
412 /* Use set_window_buffer instead of Fset_window_buffer (see
413 discussion of bug#11984, bug#12025, bug#12026). */
414 set_window_buffer (mini_window
,
415 (NILP (Vminibuffer_list
)
417 : Fcar (Vminibuffer_list
)), 0, 0);
421 /* Make a frame containing only a minibuffer window. */
424 make_minibuffer_frame (void)
426 /* First make a frame containing just a root window, no minibuffer. */
428 register struct frame
*f
= make_frame (0);
429 register Lisp_Object mini_window
;
430 register Lisp_Object frame
;
432 XSETFRAME (frame
, f
);
437 f
->wants_modeline
= 0;
438 f
->has_minibuffer
= 1;
440 /* Now label the root window as also being the minibuffer.
441 Avoid infinite looping on the window chain by marking next pointer
444 mini_window
= FSET (f
, minibuffer_window
, f
->root_window
);
445 XWINDOW (mini_window
)->mini
= 1;
446 WSET (XWINDOW (mini_window
), next
, Qnil
);
447 WSET (XWINDOW (mini_window
), prev
, Qnil
);
448 WSET (XWINDOW (mini_window
), frame
, frame
);
450 /* Put the proper buffer in that window. */
452 /* Use set_window_buffer instead of Fset_window_buffer (see
453 discussion of bug#11984, bug#12025, bug#12026). */
454 set_window_buffer (mini_window
,
455 (NILP (Vminibuffer_list
)
457 : Fcar (Vminibuffer_list
)), 0, 0);
460 #endif /* HAVE_WINDOW_SYSTEM */
462 /* Construct a frame that refers to a terminal. */
464 static printmax_t tty_frame_count
;
467 make_initial_frame (void)
470 struct terminal
*terminal
;
473 eassert (initial_kboard
);
475 /* The first call must initialize Vframe_list. */
476 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
479 terminal
= init_initial_terminal ();
482 XSETFRAME (frame
, f
);
484 Vframe_list
= Fcons (frame
, Vframe_list
);
487 FSET (f
, name
, build_pure_c_string ("F1"));
490 f
->async_visible
= 1;
492 f
->output_method
= terminal
->type
;
493 f
->terminal
= terminal
;
494 f
->terminal
->reference_count
++;
495 f
->output_data
.nothing
= 0;
497 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
498 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
500 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
501 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
503 /* The default value of menu-bar-mode is t. */
504 set_menu_bar_lines (f
, make_number (1), Qnil
);
507 init_frame_faces (f
);
513 static struct frame
*
514 make_terminal_frame (struct terminal
*terminal
)
516 register struct frame
*f
;
518 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
521 error ("Terminal is not live, can't create new frames on it");
525 XSETFRAME (frame
, f
);
526 Vframe_list
= Fcons (frame
, Vframe_list
);
528 FSET (f
, name
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
530 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
531 f
->async_visible
= 1; /* Don't let visible be cleared later. */
532 f
->terminal
= terminal
;
533 f
->terminal
->reference_count
++;
535 f
->output_data
.tty
->display_info
= &the_only_display_info
;
536 if (!inhibit_window_system
537 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
538 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
539 f
->output_method
= output_msdos_raw
;
541 f
->output_method
= output_termcap
;
542 #else /* not MSDOS */
543 f
->output_method
= output_termcap
;
544 create_tty_output (f
);
545 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
546 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
547 #endif /* not MSDOS */
549 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
550 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
551 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
553 /* Set the top frame to the newly created frame. */
554 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
555 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
556 XFRAME (FRAME_TTY (f
)->top_frame
)->async_visible
= 2; /* obscured */
558 FRAME_TTY (f
)->top_frame
= frame
;
561 init_frame_faces (f
);
566 /* Get a suitable value for frame parameter PARAMETER for a newly
567 created frame, based on (1) the user-supplied frame parameter
568 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
571 get_future_frame_param (Lisp_Object parameter
,
572 Lisp_Object supplied_parms
,
577 result
= Fassq (parameter
, supplied_parms
);
579 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
580 if (NILP (result
) && current_value
!= NULL
)
581 result
= build_string (current_value
);
582 if (!NILP (result
) && !STRINGP (result
))
583 result
= XCDR (result
);
584 if (NILP (result
) || !STRINGP (result
))
590 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
592 doc
: /* Create an additional terminal frame, possibly on another terminal.
593 This function takes one argument, an alist specifying frame parameters.
595 You can create multiple frames on a single text terminal, but only one
596 of them (the selected terminal frame) is actually displayed.
598 In practice, generally you don't need to specify any parameters,
599 except when you want to create a new frame on another terminal.
600 In that case, the `tty' parameter specifies the device file to open,
601 and the `tty-type' parameter specifies the terminal type. Example:
603 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
605 Note that changing the size of one terminal frame automatically
606 affects all frames on the same terminal device. */)
610 struct terminal
*t
= NULL
;
611 Lisp_Object frame
, tem
;
612 struct frame
*sf
= SELECTED_FRAME ();
615 if (sf
->output_method
!= output_msdos_raw
616 && sf
->output_method
!= output_termcap
)
618 #else /* not MSDOS */
620 #ifdef WINDOWSNT /* This should work now! */
621 if (sf
->output_method
!= output_termcap
)
622 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
624 #endif /* not MSDOS */
627 Lisp_Object terminal
;
629 terminal
= Fassq (Qterminal
, parms
);
630 if (!NILP (terminal
))
632 terminal
= XCDR (terminal
);
633 t
= get_terminal (terminal
, 1);
636 if (t
&& t
!= the_only_display_info
.terminal
)
637 /* msdos.c assumes a single tty_display_info object. */
638 error ("Multiple terminals are not supported on this platform");
640 t
= the_only_display_info
.terminal
;
646 char *name
= 0, *type
= 0;
647 Lisp_Object tty
, tty_type
;
649 tty
= get_future_frame_param
650 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
651 ? FRAME_TTY (XFRAME (selected_frame
))->name
655 name
= alloca (SBYTES (tty
) + 1);
656 memcpy (name
, SSDATA (tty
), SBYTES (tty
));
657 name
[SBYTES (tty
)] = 0;
660 tty_type
= get_future_frame_param
661 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
662 ? FRAME_TTY (XFRAME (selected_frame
))->type
664 if (!NILP (tty_type
))
666 type
= alloca (SBYTES (tty_type
) + 1);
667 memcpy (type
, SSDATA (tty_type
), SBYTES (tty_type
));
668 type
[SBYTES (tty_type
)] = 0;
671 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
674 f
= make_terminal_frame (t
);
678 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
679 change_frame_size (f
, height
, width
, 0, 0, 0);
684 XSETFRAME (frame
, f
);
685 Fmodify_frame_parameters (frame
, parms
);
686 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
687 build_string (t
->display_info
.tty
->type
)),
689 if (t
->display_info
.tty
->name
!= NULL
)
690 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
691 build_string (t
->display_info
.tty
->name
)),
694 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
696 /* Make the frame face alist be frame-specific, so that each
697 frame could change its face definitions independently. */
698 FSET (f
, face_alist
, Fcopy_alist (sf
->face_alist
));
699 /* Simple Fcopy_alist isn't enough, because we need the contents of
700 the vectors which are the CDRs of associations in face_alist to
701 be copied as well. */
702 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
703 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
708 /* Perform the switch to frame FRAME.
710 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
713 If TRACK is non-zero and the frame that currently has the focus
714 redirects its focus to the selected frame, redirect that focused
715 frame's focus to FRAME instead.
717 FOR_DELETION non-zero means that the selected frame is being
718 deleted, which includes the possibility that the frame's terminal
721 The value of NORECORD is passed as argument to Fselect_window. */
724 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
726 struct frame
*sf
= SELECTED_FRAME ();
728 /* If FRAME is a switch-frame event, extract the frame we should
731 && EQ (XCAR (frame
), Qswitch_frame
)
732 && CONSP (XCDR (frame
)))
733 frame
= XCAR (XCDR (frame
));
735 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
736 a switch-frame event to arrive after a frame is no longer live,
737 especially when deleting the initial frame during startup. */
739 if (! FRAME_LIVE_P (XFRAME (frame
)))
742 if (sf
== XFRAME (frame
))
745 /* This is too greedy; it causes inappropriate focus redirection
746 that's hard to get rid of. */
748 /* If a frame's focus has been redirected toward the currently
749 selected frame, we should change the redirection to point to the
750 newly selected frame. This means that if the focus is redirected
751 from a minibufferless frame to a surrogate minibuffer frame, we
752 can use `other-window' to switch between all the frames using
753 that minibuffer frame, and the focus redirection will follow us
759 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
763 if (!FRAMEP (XCAR (tail
)))
766 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
768 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
769 Fredirect_frame_focus (XCAR (tail
), frame
);
773 /* Instead, apply it only to the frame we're pointing to. */
774 #ifdef HAVE_WINDOW_SYSTEM
775 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
777 Lisp_Object focus
, xfocus
;
779 xfocus
= x_get_focus_frame (XFRAME (frame
));
782 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
783 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
784 Fredirect_frame_focus (xfocus
, frame
);
787 #endif /* HAVE_X_WINDOWS */
790 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
791 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
793 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
795 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
796 /* Mark previously displayed frame as now obscured. */
797 XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
)->async_visible
= 2;
798 XFRAME (frame
)->async_visible
= 1;
799 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
802 selected_frame
= frame
;
803 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
804 last_nonminibuf_frame
= XFRAME (selected_frame
);
806 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
808 /* We want to make sure that the next event generates a frame-switch
809 event to the appropriate frame. This seems kludgy to me, but
810 before you take it out, make sure that evaluating something like
811 (select-window (frame-root-window (new-frame))) doesn't end up
812 with your typing being interpreted in the new frame instead of
813 the one you're actually typing in. */
814 internal_last_event_frame
= Qnil
;
819 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
820 doc
: /* Select FRAME.
821 Subsequent editing commands apply to its selected window.
822 Optional argument NORECORD means to neither change the order of
823 recently selected windows nor the buffer list.
825 The selection of FRAME lasts until the next time the user does
826 something to select a different frame, or until the next time
827 this function is called. If you are using a window system, the
828 previously selected frame may be restored as the selected frame
829 when returning to the command loop, because it still may have
830 the window system's input focus. On a text terminal, the next
831 redisplay will display FRAME.
833 This function returns FRAME, or nil if FRAME has been deleted. */)
834 (Lisp_Object frame
, Lisp_Object norecord
)
836 return do_switch_frame (frame
, 1, 0, norecord
);
840 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
841 doc
: /* Handle a switch-frame event EVENT.
842 Switch-frame events are usually bound to this function.
843 A switch-frame event tells Emacs that the window manager has requested
844 that the user's events be directed to the frame mentioned in the event.
845 This function selects the selected window of the frame of EVENT.
847 If EVENT is frame object, handle it as if it were a switch-frame event
851 /* Preserve prefix arg that the command loop just cleared. */
852 KSET (current_kboard
, Vprefix_arg
, Vcurrent_prefix_arg
);
853 Frun_hooks (1, &Qmouse_leave_buffer_hook
);
854 return do_switch_frame (event
, 0, 0, Qnil
);
857 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
858 doc
: /* Return the frame that is now selected. */)
861 return selected_frame
;
864 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
866 doc
: /* Return a list of all live frames. */)
870 frames
= Fcopy_sequence (Vframe_list
);
871 #ifdef HAVE_WINDOW_SYSTEM
872 if (FRAMEP (tip_frame
))
873 frames
= Fdelq (tip_frame
, frames
);
878 /* Return the next frame in the frame list after FRAME.
879 If MINIBUF is nil, exclude minibuffer-only frames.
880 If MINIBUF is a window, include only its own frame
881 and any frame now using that window as the minibuffer.
882 If MINIBUF is `visible', include all visible frames.
883 If MINIBUF is 0, include all visible and iconified frames.
884 Otherwise, include all frames. */
887 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
892 /* There must always be at least one frame in Vframe_list. */
893 if (! CONSP (Vframe_list
))
896 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
897 forever. Forestall that. */
898 CHECK_LIVE_FRAME (frame
);
901 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
908 && ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
909 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
910 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
911 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
)))))
913 /* Decide whether this frame is eligible to be returned. */
915 /* If we've looped all the way around without finding any
916 eligible frames, return the original frame. */
920 /* Let minibuf decide if this frame is acceptable. */
923 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
926 else if (EQ (minibuf
, Qvisible
))
928 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
929 if (FRAME_VISIBLE_P (XFRAME (f
)))
932 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
934 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
935 if (FRAME_VISIBLE_P (XFRAME (f
))
936 || FRAME_ICONIFIED_P (XFRAME (f
)))
939 else if (WINDOWP (minibuf
))
941 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
942 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
943 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
944 FRAME_FOCUS_FRAME (XFRAME (f
))))
956 /* Return the previous frame in the frame list before FRAME.
957 If MINIBUF is nil, exclude minibuffer-only frames.
958 If MINIBUF is a window, include only its own frame
959 and any frame now using that window as the minibuffer.
960 If MINIBUF is `visible', include all visible frames.
961 If MINIBUF is 0, include all visible and iconified frames.
962 Otherwise, include all frames. */
965 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
970 /* There must always be at least one frame in Vframe_list. */
971 if (! CONSP (Vframe_list
))
975 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
983 if (EQ (frame
, f
) && !NILP (prev
))
986 if ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
987 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
988 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
989 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
))))
991 /* Decide whether this frame is eligible to be returned,
992 according to minibuf. */
995 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
998 else if (WINDOWP (minibuf
))
1000 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1001 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1002 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1003 FRAME_FOCUS_FRAME (XFRAME (f
))))
1006 else if (EQ (minibuf
, Qvisible
))
1008 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1009 if (FRAME_VISIBLE_P (XFRAME (f
)))
1012 else if (XFASTINT (minibuf
) == 0)
1014 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1015 if (FRAME_VISIBLE_P (XFRAME (f
))
1016 || FRAME_ICONIFIED_P (XFRAME (f
)))
1024 /* We've scanned the entire list. */
1026 /* We went through the whole frame list without finding a single
1027 acceptable frame. Return the original frame. */
1030 /* There were no acceptable frames in the list before FRAME; otherwise,
1031 we would have returned directly from the loop. Since PREV is the last
1032 acceptable frame in the list, return it. */
1037 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1038 doc
: /* Return the next frame in the frame list after FRAME.
1039 It considers only frames on the same terminal as FRAME.
1040 By default, skip minibuffer-only frames.
1041 If omitted, FRAME defaults to the selected frame.
1042 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1043 If MINIFRAME is a window, include only its own frame
1044 and any frame now using that window as the minibuffer.
1045 If MINIFRAME is `visible', include all visible frames.
1046 If MINIFRAME is 0, include all visible and iconified frames.
1047 Otherwise, include all frames. */)
1048 (Lisp_Object frame
, Lisp_Object miniframe
)
1051 frame
= selected_frame
;
1053 CHECK_LIVE_FRAME (frame
);
1054 return next_frame (frame
, miniframe
);
1057 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1058 doc
: /* Return the previous frame in the frame list before FRAME.
1059 It considers only frames on the same terminal as FRAME.
1060 By default, skip minibuffer-only frames.
1061 If omitted, FRAME defaults to the selected frame.
1062 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1063 If MINIFRAME is a window, include only its own frame
1064 and any frame now using that window as the minibuffer.
1065 If MINIFRAME is `visible', include all visible frames.
1066 If MINIFRAME is 0, include all visible and iconified frames.
1067 Otherwise, include all frames. */)
1068 (Lisp_Object frame
, Lisp_Object miniframe
)
1071 frame
= selected_frame
;
1072 CHECK_LIVE_FRAME (frame
);
1073 return prev_frame (frame
, miniframe
);
1076 /* Return 1 if it is ok to delete frame F;
1077 0 if all frames aside from F are invisible.
1078 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1081 other_visible_frames (FRAME_PTR f
)
1085 for (frames
= Vframe_list
; CONSP (frames
); frames
= XCDR (frames
))
1087 Lisp_Object
this = XCAR (frames
);
1088 if (f
== XFRAME (this))
1091 /* Verify that we can still talk to the frame's X window,
1092 and note any recent change in visibility. */
1093 #ifdef HAVE_WINDOW_SYSTEM
1094 if (FRAME_WINDOW_P (XFRAME (this)))
1096 x_sync (XFRAME (this));
1097 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1101 if (FRAME_VISIBLE_P (XFRAME (this))
1102 || FRAME_ICONIFIED_P (XFRAME (this))
1103 /* Allow deleting the terminal frame when at least one X
1105 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1111 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1112 unconditionally. x_connection_closed and delete_terminal use
1113 this. Any other value of FORCE implements the semantics
1114 described for Fdelete_frame. */
1116 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1119 struct frame
*sf
= SELECTED_FRAME ();
1122 int minibuffer_selected
, tooltip_frame
;
1124 if (EQ (frame
, Qnil
))
1127 XSETFRAME (frame
, f
);
1131 CHECK_FRAME (frame
);
1135 if (! FRAME_LIVE_P (f
))
1138 if (NILP (force
) && !other_visible_frames (f
))
1139 error ("Attempt to delete the sole visible or iconified frame");
1141 /* x_connection_closed must have set FORCE to `noelisp' in order
1142 to delete the last frame, if it is gone. */
1143 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1144 error ("Attempt to delete the only frame");
1146 /* Does this frame have a minibuffer, and is it the surrogate
1147 minibuffer for any other frame? */
1148 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1152 for (frames
= Vframe_list
;
1154 frames
= XCDR (frames
))
1157 this = XCAR (frames
);
1159 if (! EQ (this, frame
)
1161 WINDOW_FRAME (XWINDOW
1162 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1164 /* If we MUST delete this frame, delete the other first.
1165 But do this only if FORCE equals `noelisp'. */
1166 if (EQ (force
, Qnoelisp
))
1167 delete_frame (this, Qnoelisp
);
1169 error ("Attempt to delete a surrogate minibuffer frame");
1174 tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1176 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1177 frame is a tooltip. FORCE is set to `noelisp' when handling
1178 a disconnect from the terminal, so we don't dare call Lisp
1180 if (NILP (Vrun_hooks
) || tooltip_frame
)
1182 else if (EQ (force
, Qnoelisp
))
1184 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1188 #ifdef HAVE_X_WINDOWS
1189 /* Also, save clipboard to the clipboard manager. */
1190 x_clipboard_manager_save_frame (frame
);
1193 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1196 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1197 if (! FRAME_LIVE_P (f
))
1200 /* At this point, we are committed to deleting the frame.
1201 There is no more chance for errors to prevent it. */
1203 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1205 /* Don't let the frame remain selected. */
1208 Lisp_Object tail
, frame1
;
1210 /* Look for another visible frame on the same terminal. */
1211 frame1
= next_frame (frame
, Qvisible
);
1213 /* If there is none, find *some* other frame. */
1214 if (NILP (frame1
) || EQ (frame1
, frame
))
1216 FOR_EACH_FRAME (tail
, frame1
)
1218 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1220 /* Do not change a text terminal's top-frame. */
1221 struct frame
*f1
= XFRAME (frame1
);
1222 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1224 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1225 if (!EQ (top_frame
, frame
))
1232 #ifdef NS_IMPL_COCOA
1234 /* Under NS, there is no system mechanism for choosing a new
1235 window to get focus -- it is left to application code.
1236 So the portion of THIS application interfacing with NS
1237 needs to know about it. We call Fraise_frame, but the
1238 purpose is really to transfer focus. */
1239 Fraise_frame (frame1
);
1242 do_switch_frame (frame1
, 0, 1, Qnil
);
1243 sf
= SELECTED_FRAME ();
1246 /* Don't allow minibuf_window to remain on a deleted frame. */
1247 if (EQ (f
->minibuffer_window
, minibuf_window
))
1249 /* Use set_window_buffer instead of Fset_window_buffer (see
1250 discussion of bug#11984, bug#12025, bug#12026). */
1251 set_window_buffer (sf
->minibuffer_window
,
1252 XWINDOW (minibuf_window
)->buffer
, 0, 0);
1253 minibuf_window
= sf
->minibuffer_window
;
1255 /* If the dying minibuffer window was selected,
1256 select the new one. */
1257 if (minibuffer_selected
)
1258 Fselect_window (minibuf_window
, Qnil
);
1261 /* Don't let echo_area_window to remain on a deleted frame. */
1262 if (EQ (f
->minibuffer_window
, echo_area_window
))
1263 echo_area_window
= sf
->minibuffer_window
;
1265 /* Clear any X selections for this frame. */
1266 #ifdef HAVE_X_WINDOWS
1268 x_clear_frame_selections (f
);
1272 This function must be called before the window tree of the
1273 frame is deleted because windows contain dynamically allocated
1277 #ifdef HAVE_WINDOW_SYSTEM
1278 /* Give chance to each font driver to free a frame specific data. */
1279 font_update_drivers (f
, Qnil
);
1282 /* Mark all the windows that used to be on FRAME as deleted, and then
1283 remove the reference to them. */
1284 delete_all_child_windows (f
->root_window
);
1285 FSET (f
, root_window
, Qnil
);
1287 Vframe_list
= Fdelq (frame
, Vframe_list
);
1288 FRAME_SET_VISIBLE (f
, 0);
1290 /* Allow the vector of menu bar contents to be freed in the next
1291 garbage collection. The frame object itself may not be garbage
1292 collected until much later, because recent_keys and other data
1293 structures can still refer to it. */
1294 FSET (f
, menu_bar_vector
, Qnil
);
1296 free_font_driver_list (f
);
1298 xfree (f
->decode_mode_spec_buffer
);
1299 xfree (FRAME_INSERT_COST (f
));
1300 xfree (FRAME_DELETEN_COST (f
));
1301 xfree (FRAME_INSERTN_COST (f
));
1302 xfree (FRAME_DELETE_COST (f
));
1303 xfree (FRAME_MESSAGE_BUF (f
));
1305 /* Since some events are handled at the interrupt level, we may get
1306 an event for f at any time; if we zero out the frame's terminal
1307 now, then we may trip up the event-handling code. Instead, we'll
1308 promise that the terminal of the frame must be valid until we
1309 have called the window-system-dependent frame destruction
1312 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1313 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1316 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1317 f
->output_data
.nothing
= 0;
1318 f
->terminal
= 0; /* Now the frame is dead. */
1320 /* If needed, delete the terminal that this frame was on.
1321 (This must be done after the frame is killed.) */
1322 terminal
->reference_count
--;
1324 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1326 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1327 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1328 terminal
->reference_count
= 1;
1329 #endif /* USE_GTK */
1330 if (terminal
->reference_count
== 0)
1333 XSETTERMINAL (tmp
, terminal
);
1336 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1339 kb
= terminal
->kboard
;
1342 /* If we've deleted the last_nonminibuf_frame, then try to find
1344 if (f
== last_nonminibuf_frame
)
1348 last_nonminibuf_frame
= 0;
1350 for (frames
= Vframe_list
;
1352 frames
= XCDR (frames
))
1354 f
= XFRAME (XCAR (frames
));
1355 if (!FRAME_MINIBUF_ONLY_P (f
))
1357 last_nonminibuf_frame
= f
;
1363 /* If there's no other frame on the same kboard, get out of
1364 single-kboard state if we're in it for this kboard. */
1368 /* Some frame we found on the same kboard, or nil if there are none. */
1369 Lisp_Object frame_on_same_kboard
;
1371 frame_on_same_kboard
= Qnil
;
1373 for (frames
= Vframe_list
;
1375 frames
= XCDR (frames
))
1380 this = XCAR (frames
);
1385 if (kb
== FRAME_KBOARD (f1
))
1386 frame_on_same_kboard
= this;
1389 if (NILP (frame_on_same_kboard
))
1390 not_single_kboard_state (kb
);
1394 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1395 find another one. Prefer minibuffer-only frames, but also notice
1396 frames with other windows. */
1397 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1401 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1402 Lisp_Object frame_with_minibuf
;
1403 /* Some frame we found on the same kboard, or nil if there are none. */
1404 Lisp_Object frame_on_same_kboard
;
1406 frame_on_same_kboard
= Qnil
;
1407 frame_with_minibuf
= Qnil
;
1409 for (frames
= Vframe_list
;
1411 frames
= XCDR (frames
))
1416 this = XCAR (frames
);
1421 /* Consider only frames on the same kboard
1422 and only those with minibuffers. */
1423 if (kb
== FRAME_KBOARD (f1
)
1424 && FRAME_HAS_MINIBUF_P (f1
))
1426 frame_with_minibuf
= this;
1427 if (FRAME_MINIBUF_ONLY_P (f1
))
1431 if (kb
== FRAME_KBOARD (f1
))
1432 frame_on_same_kboard
= this;
1435 if (!NILP (frame_on_same_kboard
))
1437 /* We know that there must be some frame with a minibuffer out
1438 there. If this were not true, all of the frames present
1439 would have to be minibufferless, which implies that at some
1440 point their minibuffer frames must have been deleted, but
1441 that is prohibited at the top; you can't delete surrogate
1442 minibuffer frames. */
1443 if (NILP (frame_with_minibuf
))
1446 KSET (kb
, Vdefault_minibuffer_frame
, frame_with_minibuf
);
1449 /* No frames left on this kboard--say no minibuffer either. */
1450 KSET (kb
, Vdefault_minibuffer_frame
, Qnil
);
1453 /* Cause frame titles to update--necessary if we now have just one frame. */
1455 update_mode_lines
= 1;
1460 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1461 doc
: /* Delete FRAME, permanently eliminating it from use.
1462 FRAME defaults to the selected frame.
1464 A frame may not be deleted if its minibuffer is used by other frames.
1465 Normally, you may not delete a frame if all other frames are invisible,
1466 but if the second optional argument FORCE is non-nil, you may do so.
1468 This function runs `delete-frame-functions' before actually
1469 deleting the frame, unless the frame is a tooltip.
1470 The functions are run with one argument, the frame to be deleted. */)
1471 (Lisp_Object frame
, Lisp_Object force
)
1473 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1477 /* Return mouse position in character cell units. */
1479 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1480 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1481 The position is given in character cells, where (0, 0) is the
1482 upper-left corner of the frame, X is the horizontal offset, and Y is
1483 the vertical offset.
1484 If Emacs is running on a mouseless terminal or hasn't been programmed
1485 to read the mouse position, it returns the selected frame for FRAME
1486 and nil for X and Y.
1487 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1488 passing the normal return value to that function as an argument,
1489 and returns whatever that function returns. */)
1493 Lisp_Object lispy_dummy
;
1494 enum scroll_bar_part party_dummy
;
1495 Lisp_Object x
, y
, retval
;
1498 struct gcpro gcpro1
;
1500 f
= SELECTED_FRAME ();
1503 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1504 /* It's okay for the hook to refrain from storing anything. */
1505 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1506 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1507 &lispy_dummy
, &party_dummy
,
1514 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1519 XSETFRAME (lispy_dummy
, f
);
1520 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1522 if (!NILP (Vmouse_position_function
))
1523 retval
= call1 (Vmouse_position_function
, retval
);
1524 RETURN_UNGCPRO (retval
);
1527 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1528 Smouse_pixel_position
, 0, 0, 0,
1529 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1530 The position is given in pixel units, where (0, 0) is the
1531 upper-left corner of the frame, X is the horizontal offset, and Y is
1532 the vertical offset.
1533 If Emacs is running on a mouseless terminal or hasn't been programmed
1534 to read the mouse position, it returns the selected frame for FRAME
1535 and nil for X and Y. */)
1539 Lisp_Object lispy_dummy
;
1540 enum scroll_bar_part party_dummy
;
1544 f
= SELECTED_FRAME ();
1547 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1548 /* It's okay for the hook to refrain from storing anything. */
1549 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1550 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1551 &lispy_dummy
, &party_dummy
,
1555 XSETFRAME (lispy_dummy
, f
);
1556 return Fcons (lispy_dummy
, Fcons (x
, y
));
1559 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1560 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1561 Coordinates are relative to the frame, not a window,
1562 so the coordinates of the top left character in the frame
1563 may be nonzero due to left-hand scroll bars or the menu bar.
1565 The position is given in character cells, where (0, 0) is the
1566 upper-left corner of the frame, X is the horizontal offset, and Y is
1567 the vertical offset.
1569 This function is a no-op for an X frame that is not visible.
1570 If you have just created a frame, you must wait for it to become visible
1571 before calling this function on it, like this.
1572 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1573 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1575 CHECK_LIVE_FRAME (frame
);
1576 CHECK_TYPE_RANGED_INTEGER (int, x
);
1577 CHECK_TYPE_RANGED_INTEGER (int, y
);
1579 /* I think this should be done with a hook. */
1580 #ifdef HAVE_WINDOW_SYSTEM
1581 if (FRAME_WINDOW_P (XFRAME (frame
)))
1582 /* Warping the mouse will cause enternotify and focus events. */
1583 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1585 #if defined (MSDOS) && defined (HAVE_MOUSE)
1586 if (FRAME_MSDOS_P (XFRAME (frame
)))
1588 Fselect_frame (frame
, Qnil
);
1589 mouse_moveto (XINT (x
), XINT (y
));
1594 Fselect_frame (frame
, Qnil
);
1595 term_mouse_moveto (XINT (x
), XINT (y
));
1604 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1605 Sset_mouse_pixel_position
, 3, 3, 0,
1606 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1607 The position is given in pixels, where (0, 0) is the upper-left corner
1608 of the frame, X is the horizontal offset, and Y is the vertical offset.
1610 Note, this is a no-op for an X frame that is not visible.
1611 If you have just created a frame, you must wait for it to become visible
1612 before calling this function on it, like this.
1613 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1614 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1616 CHECK_LIVE_FRAME (frame
);
1617 CHECK_TYPE_RANGED_INTEGER (int, x
);
1618 CHECK_TYPE_RANGED_INTEGER (int, y
);
1620 /* I think this should be done with a hook. */
1621 #ifdef HAVE_WINDOW_SYSTEM
1622 if (FRAME_WINDOW_P (XFRAME (frame
)))
1623 /* Warping the mouse will cause enternotify and focus events. */
1624 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1626 #if defined (MSDOS) && defined (HAVE_MOUSE)
1627 if (FRAME_MSDOS_P (XFRAME (frame
)))
1629 Fselect_frame (frame
, Qnil
);
1630 mouse_moveto (XINT (x
), XINT (y
));
1635 Fselect_frame (frame
, Qnil
);
1636 term_mouse_moveto (XINT (x
), XINT (y
));
1645 static void make_frame_visible_1 (Lisp_Object
);
1647 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1649 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1650 If omitted, FRAME defaults to the currently selected frame. */)
1654 frame
= selected_frame
;
1656 CHECK_LIVE_FRAME (frame
);
1658 /* I think this should be done with a hook. */
1659 #ifdef HAVE_WINDOW_SYSTEM
1660 if (FRAME_WINDOW_P (XFRAME (frame
)))
1662 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1663 x_make_frame_visible (XFRAME (frame
));
1667 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1669 /* Make menu bar update for the Buffers and Frames menus. */
1670 windows_or_buffers_changed
++;
1675 /* Update the display_time slot of the buffers shown in WINDOW
1676 and all its descendants. */
1679 make_frame_visible_1 (Lisp_Object window
)
1683 for (;!NILP (window
); window
= w
->next
)
1685 w
= XWINDOW (window
);
1687 if (!NILP (w
->buffer
))
1688 BSET (XBUFFER (w
->buffer
), display_time
, Fcurrent_time ());
1690 if (!NILP (w
->vchild
))
1691 make_frame_visible_1 (w
->vchild
);
1692 if (!NILP (w
->hchild
))
1693 make_frame_visible_1 (w
->hchild
);
1697 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1699 doc
: /* Make the frame FRAME invisible.
1700 If omitted, FRAME defaults to the currently selected frame.
1701 On graphical displays, invisible frames are not updated and are
1702 usually not displayed at all, even in a window system's \"taskbar\".
1704 Normally you may not make FRAME invisible if all other frames are invisible,
1705 but if the second optional argument FORCE is non-nil, you may do so.
1707 This function has no effect on text terminal frames. Such frames are
1708 always considered visible, whether or not they are currently being
1709 displayed in the terminal. */)
1710 (Lisp_Object frame
, Lisp_Object force
)
1713 frame
= selected_frame
;
1715 CHECK_LIVE_FRAME (frame
);
1717 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1718 error ("Attempt to make invisible the sole visible or iconified frame");
1720 /* Don't allow minibuf_window to remain on a deleted frame. */
1721 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1723 struct frame
*sf
= XFRAME (selected_frame
);
1724 /* Use set_window_buffer instead of Fset_window_buffer (see
1725 discussion of bug#11984, bug#12025, bug#12026). */
1726 set_window_buffer (sf
->minibuffer_window
,
1727 XWINDOW (minibuf_window
)->buffer
, 0, 0);
1728 minibuf_window
= sf
->minibuffer_window
;
1731 /* I think this should be done with a hook. */
1732 #ifdef HAVE_WINDOW_SYSTEM
1733 if (FRAME_WINDOW_P (XFRAME (frame
)))
1734 x_make_frame_invisible (XFRAME (frame
));
1737 /* Make menu bar update for the Buffers and Frames menus. */
1738 windows_or_buffers_changed
++;
1743 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1745 doc
: /* Make the frame FRAME into an icon.
1746 If omitted, FRAME defaults to the currently selected frame. */)
1750 frame
= selected_frame
;
1752 CHECK_LIVE_FRAME (frame
);
1754 #if 0 /* This isn't logically necessary, and it can do GC. */
1755 /* Don't let the frame remain selected. */
1756 if (EQ (frame
, selected_frame
))
1757 Fhandle_switch_frame (next_frame (frame
, Qt
));
1760 /* Don't allow minibuf_window to remain on an iconified frame. */
1761 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1763 struct frame
*sf
= XFRAME (selected_frame
);
1764 /* Use set_window_buffer instead of Fset_window_buffer (see
1765 discussion of bug#11984, bug#12025, bug#12026). */
1766 set_window_buffer (sf
->minibuffer_window
,
1767 XWINDOW (minibuf_window
)->buffer
, 0, 0);
1768 minibuf_window
= sf
->minibuffer_window
;
1771 /* I think this should be done with a hook. */
1772 #ifdef HAVE_WINDOW_SYSTEM
1773 if (FRAME_WINDOW_P (XFRAME (frame
)))
1774 x_iconify_frame (XFRAME (frame
));
1777 /* Make menu bar update for the Buffers and Frames menus. */
1778 windows_or_buffers_changed
++;
1783 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1785 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1786 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1787 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1788 On graphical displays, invisible frames are not updated and are
1789 usually not displayed at all, even in a window system's \"taskbar\".
1791 If FRAME is a text terminal frame, this always returns t.
1792 Such frames are always considered visible, whether or not they are
1793 currently being displayed on the terminal. */)
1796 CHECK_LIVE_FRAME (frame
);
1798 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1800 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1802 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1807 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1809 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1812 Lisp_Object tail
, frame
;
1817 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1819 frame
= XCAR (tail
);
1820 if (!FRAMEP (frame
))
1823 if (FRAME_VISIBLE_P (f
))
1824 value
= Fcons (frame
, value
);
1830 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1831 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1832 If FRAME is invisible or iconified, make it visible.
1833 If you don't specify a frame, the selected frame is used.
1834 If Emacs is displaying on an ordinary terminal or some other device which
1835 doesn't support multiple overlapping frames, this function selects FRAME. */)
1840 frame
= selected_frame
;
1842 CHECK_LIVE_FRAME (frame
);
1846 if (FRAME_TERMCAP_P (f
))
1847 /* On a text terminal select FRAME. */
1848 Fselect_frame (frame
, Qnil
);
1850 /* Do like the documentation says. */
1851 Fmake_frame_visible (frame
);
1853 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1854 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
1859 /* Should we have a corresponding function called Flower_Power? */
1860 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1861 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1862 If you don't specify a frame, the selected frame is used.
1863 If Emacs is displaying on an ordinary terminal or some other device which
1864 doesn't support multiple overlapping frames, this function does nothing. */)
1870 frame
= selected_frame
;
1872 CHECK_LIVE_FRAME (frame
);
1876 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1877 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
1883 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1885 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1886 In other words, switch-frame events caused by events in FRAME will
1887 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1888 FOCUS-FRAME after reading an event typed at FRAME.
1890 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
1891 frame again receives its own keystrokes.
1893 Focus redirection is useful for temporarily redirecting keystrokes to
1894 a surrogate minibuffer frame when a frame doesn't have its own
1897 A frame's focus redirection can be changed by `select-frame'. If frame
1898 FOO is selected, and then a different frame BAR is selected, any
1899 frames redirecting their focus to FOO are shifted to redirect their
1900 focus to BAR. This allows focus redirection to work properly when the
1901 user switches from one frame to another using `select-window'.
1903 This means that a frame whose focus is redirected to itself is treated
1904 differently from a frame whose focus is redirected to nil; the former
1905 is affected by `select-frame', while the latter is not.
1907 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1908 (Lisp_Object frame
, Lisp_Object focus_frame
)
1912 /* Note that we don't check for a live frame here. It's reasonable
1913 to redirect the focus of a frame you're about to delete, if you
1914 know what other frame should receive those keystrokes. */
1915 CHECK_FRAME (frame
);
1917 if (! NILP (focus_frame
))
1918 CHECK_LIVE_FRAME (focus_frame
);
1922 FSET (f
, focus_frame
, focus_frame
);
1924 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
1925 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
1931 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1932 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1933 This returns nil if FRAME's focus is not redirected.
1934 See `redirect-frame-focus'. */)
1937 CHECK_LIVE_FRAME (frame
);
1939 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1944 /* Return the value of frame parameter PROP in frame FRAME. */
1946 #ifdef HAVE_WINDOW_SYSTEM
1951 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
1953 register Lisp_Object tem
;
1955 tem
= Fassq (prop
, frame
->param_alist
);
1962 /* Return the buffer-predicate of the selected frame. */
1965 frame_buffer_predicate (Lisp_Object frame
)
1967 return XFRAME (frame
)->buffer_predicate
;
1970 /* Return the buffer-list of the selected frame. */
1973 frame_buffer_list (Lisp_Object frame
)
1975 return XFRAME (frame
)->buffer_list
;
1978 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
1981 frames_discard_buffer (Lisp_Object buffer
)
1983 Lisp_Object frame
, tail
;
1985 FOR_EACH_FRAME (tail
, frame
)
1987 FSET (XFRAME (frame
), buffer_list
,
1988 Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
1989 FSET (XFRAME (frame
), buried_buffer_list
,
1990 Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
1994 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1995 If the alist already has an element for PROP, we change it. */
1998 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2000 register Lisp_Object tem
;
2002 tem
= Fassq (prop
, *alistptr
);
2004 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2010 frame_name_fnn_p (char *str
, ptrdiff_t len
)
2012 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
2015 while ('0' <= *p
&& *p
<= '9')
2023 /* Set the name of the terminal frame. Also used by MSDOS frames.
2024 Modeled after x_set_name which is used for WINDOW frames. */
2027 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2029 f
->explicit_name
= ! NILP (name
);
2031 /* If NAME is nil, set the name to F<num>. */
2034 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
2036 /* Check for no change needed in this very common case
2037 before we do any consing. */
2038 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
2041 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
2045 CHECK_STRING (name
);
2047 /* Don't change the name if it's already NAME. */
2048 if (! NILP (Fstring_equal (name
, f
->name
)))
2051 /* Don't allow the user to set the frame name to F<num>, so it
2052 doesn't clash with the names we generate for terminal frames. */
2053 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2054 error ("Frame names of the form F<num> are usurped by Emacs");
2057 FSET (f
, name
, name
);
2058 update_mode_lines
= 1;
2062 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2064 register Lisp_Object old_alist_elt
;
2066 /* The buffer-list parameters are stored in a special place and not
2067 in the alist. All buffers must be live. */
2068 if (EQ (prop
, Qbuffer_list
))
2070 Lisp_Object list
= Qnil
;
2071 for (; CONSP (val
); val
= XCDR (val
))
2072 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2073 list
= Fcons (XCAR (val
), list
);
2074 FSET (f
, buffer_list
, Fnreverse (list
));
2077 if (EQ (prop
, Qburied_buffer_list
))
2079 Lisp_Object list
= Qnil
;
2080 for (; CONSP (val
); val
= XCDR (val
))
2081 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2082 list
= Fcons (XCAR (val
), list
);
2083 FSET (f
, buried_buffer_list
, Fnreverse (list
));
2087 /* If PROP is a symbol which is supposed to have frame-local values,
2088 and it is set up based on this frame, switch to the global
2089 binding. That way, we can create or alter the frame-local binding
2090 without messing up the symbol's status. */
2093 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2095 switch (sym
->redirect
)
2097 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2098 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2099 case SYMBOL_LOCALIZED
:
2100 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2101 if (blv
->frame_local
&& BLV_FOUND (blv
) && XFRAME (blv
->where
) == f
)
2102 swap_in_global_binding (sym
);
2109 /* The tty color needed to be set before the frame's parameter
2110 alist was updated with the new value. This is not true any more,
2111 but we still do this test early on. */
2112 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2113 && f
== FRAME_TTY (f
)->previous_frame
)
2114 /* Force redisplay of this tty. */
2115 FRAME_TTY (f
)->previous_frame
= NULL
;
2117 /* Update the frame parameter alist. */
2118 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2119 if (EQ (old_alist_elt
, Qnil
))
2120 FSET (f
, param_alist
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2122 Fsetcdr (old_alist_elt
, val
);
2124 /* Update some other special parameters in their special places
2125 in addition to the alist. */
2127 if (EQ (prop
, Qbuffer_predicate
))
2128 FSET (f
, buffer_predicate
, val
);
2130 if (! FRAME_WINDOW_P (f
))
2132 if (EQ (prop
, Qmenu_bar_lines
))
2133 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2134 else if (EQ (prop
, Qname
))
2135 set_term_frame_name (f
, val
);
2138 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2140 if (! MINI_WINDOW_P (XWINDOW (val
)))
2141 error ("Surrogate minibuffer windows must be minibuffer windows");
2143 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2144 && !EQ (val
, f
->minibuffer_window
))
2145 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2147 /* Install the chosen minibuffer window, with proper buffer. */
2148 FSET (f
, minibuffer_window
, val
);
2152 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2153 doc
: /* Return the parameters-alist of frame FRAME.
2154 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2155 The meaningful PARMs depend on the kind of frame.
2156 If FRAME is omitted, return information on the currently selected frame. */)
2162 struct gcpro gcpro1
;
2165 frame
= selected_frame
;
2167 CHECK_FRAME (frame
);
2170 if (!FRAME_LIVE_P (f
))
2173 alist
= Fcopy_alist (f
->param_alist
);
2176 if (!FRAME_WINDOW_P (f
))
2178 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2179 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2182 /* If the frame's parameter alist says the colors are
2183 unspecified and reversed, take the frame's background pixel
2184 for foreground and vice versa. */
2185 elt
= Fassq (Qforeground_color
, alist
);
2186 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2188 if (strncmp (SSDATA (XCDR (elt
)),
2190 SCHARS (XCDR (elt
))) == 0)
2191 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2192 else if (strncmp (SSDATA (XCDR (elt
)),
2194 SCHARS (XCDR (elt
))) == 0)
2195 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2198 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2199 elt
= Fassq (Qbackground_color
, alist
);
2200 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2202 if (strncmp (SSDATA (XCDR (elt
)),
2204 SCHARS (XCDR (elt
))) == 0)
2205 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2206 else if (strncmp (SSDATA (XCDR (elt
)),
2208 SCHARS (XCDR (elt
))) == 0)
2209 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2212 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2213 store_in_alist (&alist
, intern ("font"),
2214 build_string (FRAME_MSDOS_P (f
)
2216 : FRAME_W32_P (f
) ? "w32term"
2219 store_in_alist (&alist
, Qname
, f
->name
);
2220 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2221 store_in_alist (&alist
, Qheight
, make_number (height
));
2222 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2223 store_in_alist (&alist
, Qwidth
, make_number (width
));
2224 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2225 store_in_alist (&alist
, Qminibuffer
,
2226 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2227 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2228 : FRAME_MINIBUF_WINDOW (f
)));
2229 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2230 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2231 store_in_alist (&alist
, Qburied_buffer_list
,
2232 XFRAME (frame
)->buried_buffer_list
);
2234 /* I think this should be done with a hook. */
2235 #ifdef HAVE_WINDOW_SYSTEM
2236 if (FRAME_WINDOW_P (f
))
2237 x_report_frame_params (f
, &alist
);
2241 /* This ought to be correct in f->param_alist for an X frame. */
2243 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2244 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2252 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2253 doc
: /* Return FRAME's value for parameter PARAMETER.
2254 If FRAME is nil, describe the currently selected frame. */)
2255 (Lisp_Object frame
, Lisp_Object parameter
)
2261 frame
= selected_frame
;
2263 CHECK_FRAME (frame
);
2264 CHECK_SYMBOL (parameter
);
2269 if (FRAME_LIVE_P (f
))
2271 /* Avoid consing in frequent cases. */
2272 if (EQ (parameter
, Qname
))
2274 #ifdef HAVE_X_WINDOWS
2275 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2276 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2277 #endif /* HAVE_X_WINDOWS */
2278 else if (EQ (parameter
, Qbackground_color
)
2279 || EQ (parameter
, Qforeground_color
))
2281 value
= Fassq (parameter
, f
->param_alist
);
2284 value
= XCDR (value
);
2285 /* Fframe_parameters puts the actual fg/bg color names,
2286 even if f->param_alist says otherwise. This is
2287 important when param_alist's notion of colors is
2288 "unspecified". We need to do the same here. */
2289 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2291 const char *color_name
;
2294 if (EQ (parameter
, Qbackground_color
))
2296 color_name
= SSDATA (value
);
2297 csz
= SCHARS (value
);
2298 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2299 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2300 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2301 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2303 else if (EQ (parameter
, Qforeground_color
))
2305 color_name
= SSDATA (value
);
2306 csz
= SCHARS (value
);
2307 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2308 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2309 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2310 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2315 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2317 else if (EQ (parameter
, Qdisplay_type
)
2318 || EQ (parameter
, Qbackground_mode
))
2319 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2321 /* FIXME: Avoid this code path at all (as well as code duplication)
2322 by sharing more code with Fframe_parameters. */
2323 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2330 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2331 Smodify_frame_parameters
, 2, 2, 0,
2332 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2333 If FRAME is nil, it defaults to the selected frame.
2334 ALIST is an alist of parameters to change and their new values.
2335 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2336 The meaningful PARMs depend on the kind of frame.
2337 Undefined PARMs are ignored, but stored in the frame's parameter list
2338 so that `frame-parameters' will return them.
2340 The value of frame parameter FOO can also be accessed
2341 as a frame-local binding for the variable FOO, if you have
2342 enabled such bindings for that variable with `make-variable-frame-local'.
2343 Note that this functionality is obsolete as of Emacs 22.2, and its
2344 use is not recommended. Explicitly check for a frame-parameter instead. */)
2345 (Lisp_Object frame
, Lisp_Object alist
)
2348 register Lisp_Object tail
, prop
, val
;
2350 if (EQ (frame
, Qnil
))
2351 frame
= selected_frame
;
2352 CHECK_LIVE_FRAME (frame
);
2355 /* I think this should be done with a hook. */
2356 #ifdef HAVE_WINDOW_SYSTEM
2357 if (FRAME_WINDOW_P (f
))
2358 x_set_frame_parameters (f
, alist
);
2362 if (FRAME_MSDOS_P (f
))
2363 IT_set_frame_parameters (f
, alist
);
2368 EMACS_INT length
= XFASTINT (Flength (alist
));
2371 Lisp_Object
*values
;
2373 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2374 values
= parms
+ length
;
2376 /* Extract parm names and values into those vectors. */
2379 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2384 parms
[i
] = Fcar (elt
);
2385 values
[i
] = Fcdr (elt
);
2389 /* Now process them in reverse of specified order. */
2394 store_frame_param (f
, prop
, val
);
2396 if (EQ (prop
, Qforeground_color
)
2397 || EQ (prop
, Qbackground_color
))
2398 update_face_from_frame_parameter (f
, prop
, val
);
2406 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2408 doc
: /* Height in pixels of a line in the font in frame FRAME.
2409 If FRAME is omitted, the selected frame is used.
2410 For a terminal frame, the value is always 1. */)
2416 frame
= selected_frame
;
2417 CHECK_FRAME (frame
);
2420 #ifdef HAVE_WINDOW_SYSTEM
2421 if (FRAME_WINDOW_P (f
))
2422 return make_number (x_char_height (f
));
2425 return make_number (1);
2429 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2431 doc
: /* Width in pixels of characters in the font in frame FRAME.
2432 If FRAME is omitted, the selected frame is used.
2433 On a graphical screen, the width is the standard width of the default font.
2434 For a terminal screen, the value is always 1. */)
2440 frame
= selected_frame
;
2441 CHECK_FRAME (frame
);
2444 #ifdef HAVE_WINDOW_SYSTEM
2445 if (FRAME_WINDOW_P (f
))
2446 return make_number (x_char_width (f
));
2449 return make_number (1);
2452 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2453 Sframe_pixel_height
, 0, 1, 0,
2454 doc
: /* Return a FRAME's height in pixels.
2455 If FRAME is omitted, the selected frame is used. The exact value
2456 of the result depends on the window-system and toolkit in use:
2458 In the Gtk+ version of Emacs, it includes only any window (including
2459 the minibuffer or echo area), mode line, and header line. It does not
2460 include the tool bar or menu bar.
2462 With the Motif or Lucid toolkits, it also includes the tool bar (but
2465 In a graphical version with no toolkit, it includes both the tool bar
2468 For a text terminal, it includes the menu bar. In this case, the
2469 result is really in characters rather than pixels (i.e., is identical
2470 to `frame-height'). */)
2476 frame
= selected_frame
;
2477 CHECK_FRAME (frame
);
2480 #ifdef HAVE_WINDOW_SYSTEM
2481 if (FRAME_WINDOW_P (f
))
2482 return make_number (x_pixel_height (f
));
2485 return make_number (FRAME_LINES (f
));
2488 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2489 Sframe_pixel_width
, 0, 1, 0,
2490 doc
: /* Return FRAME's width in pixels.
2491 For a terminal frame, the result really gives the width in characters.
2492 If FRAME is omitted, the selected frame is used. */)
2498 frame
= selected_frame
;
2499 CHECK_FRAME (frame
);
2502 #ifdef HAVE_WINDOW_SYSTEM
2503 if (FRAME_WINDOW_P (f
))
2504 return make_number (x_pixel_width (f
));
2507 return make_number (FRAME_COLS (f
));
2510 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2511 Stool_bar_pixel_width
, 0, 1, 0,
2512 doc
: /* Return width in pixels of FRAME's tool bar.
2513 The result is greater than zero only when the tool bar is on the left
2514 or right side of FRAME. If FRAME is omitted, the selected frame is
2519 frame
= selected_frame
;
2520 CHECK_FRAME (frame
);
2522 #ifdef FRAME_TOOLBAR_WIDTH
2523 if (FRAME_WINDOW_P (XFRAME (frame
)))
2524 return make_number (FRAME_TOOLBAR_WIDTH (XFRAME (frame
)));
2526 return make_number (0);
2529 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2530 doc
: /* Specify that the frame FRAME has LINES lines.
2531 Optional third arg non-nil means that redisplay should use LINES lines
2532 but that the idea of the actual height of the frame should not be changed. */)
2533 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2535 register struct frame
*f
;
2537 CHECK_TYPE_RANGED_INTEGER (int, lines
);
2539 frame
= selected_frame
;
2540 CHECK_LIVE_FRAME (frame
);
2543 /* I think this should be done with a hook. */
2544 #ifdef HAVE_WINDOW_SYSTEM
2545 if (FRAME_WINDOW_P (f
))
2547 if (XINT (lines
) != FRAME_LINES (f
))
2548 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2549 do_pending_window_change (0);
2553 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2557 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2558 doc
: /* Specify that the frame FRAME has COLS columns.
2559 Optional third arg non-nil means that redisplay should use COLS columns
2560 but that the idea of the actual width of the frame should not be changed. */)
2561 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2563 register struct frame
*f
;
2564 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2566 frame
= selected_frame
;
2567 CHECK_LIVE_FRAME (frame
);
2570 /* I think this should be done with a hook. */
2571 #ifdef HAVE_WINDOW_SYSTEM
2572 if (FRAME_WINDOW_P (f
))
2574 if (XINT (cols
) != FRAME_COLS (f
))
2575 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2576 do_pending_window_change (0);
2580 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2584 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2585 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2586 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2588 register struct frame
*f
;
2590 CHECK_LIVE_FRAME (frame
);
2591 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2592 CHECK_TYPE_RANGED_INTEGER (int, rows
);
2595 /* I think this should be done with a hook. */
2596 #ifdef HAVE_WINDOW_SYSTEM
2597 if (FRAME_WINDOW_P (f
))
2599 if (XINT (rows
) != FRAME_LINES (f
)
2600 || XINT (cols
) != FRAME_COLS (f
)
2601 || f
->new_text_lines
|| f
->new_text_cols
)
2602 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2603 do_pending_window_change (0);
2607 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2612 DEFUN ("set-frame-position", Fset_frame_position
,
2613 Sset_frame_position
, 3, 3, 0,
2614 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2615 This is actually the position of the upper left corner of the frame.
2616 Negative values for XOFFSET or YOFFSET are interpreted relative to
2617 the rightmost or bottommost possible position (that stays within the screen). */)
2618 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2620 register struct frame
*f
;
2622 CHECK_LIVE_FRAME (frame
);
2623 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2624 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2627 /* I think this should be done with a hook. */
2628 #ifdef HAVE_WINDOW_SYSTEM
2629 if (FRAME_WINDOW_P (f
))
2630 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2637 /***********************************************************************
2639 ***********************************************************************/
2641 /* Connect the frame-parameter names for X frames
2642 to the ways of passing the parameter values to the window system.
2644 The name of a parameter, as a Lisp symbol,
2645 has an `x-frame-parameter' property which is an integer in Lisp
2646 that is an index in this table. */
2648 struct frame_parm_table
{
2650 Lisp_Object
*variable
;
2653 static const struct frame_parm_table frame_parms
[] =
2655 {"auto-raise", &Qauto_raise
},
2656 {"auto-lower", &Qauto_lower
},
2657 {"background-color", 0},
2658 {"border-color", &Qborder_color
},
2659 {"border-width", &Qborder_width
},
2660 {"cursor-color", &Qcursor_color
},
2661 {"cursor-type", &Qcursor_type
},
2663 {"foreground-color", 0},
2664 {"icon-name", &Qicon_name
},
2665 {"icon-type", &Qicon_type
},
2666 {"internal-border-width", &Qinternal_border_width
},
2667 {"menu-bar-lines", &Qmenu_bar_lines
},
2668 {"mouse-color", &Qmouse_color
},
2670 {"scroll-bar-width", &Qscroll_bar_width
},
2672 {"unsplittable", &Qunsplittable
},
2673 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2674 {"visibility", &Qvisibility
},
2675 {"tool-bar-lines", &Qtool_bar_lines
},
2676 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2677 {"scroll-bar-background", &Qscroll_bar_background
},
2678 {"screen-gamma", &Qscreen_gamma
},
2679 {"line-spacing", &Qline_spacing
},
2680 {"left-fringe", &Qleft_fringe
},
2681 {"right-fringe", &Qright_fringe
},
2682 {"wait-for-wm", &Qwait_for_wm
},
2683 {"fullscreen", &Qfullscreen
},
2684 {"font-backend", &Qfont_backend
},
2686 {"sticky", &Qsticky
},
2687 {"tool-bar-position", &Qtool_bar_position
},
2692 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2693 wanted positions of the WM window (not Emacs window).
2694 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2695 window (FRAME_X_WINDOW).
2699 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2701 int newwidth
= FRAME_COLS (f
);
2702 int newheight
= FRAME_LINES (f
);
2703 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2705 *top_pos
= f
->top_pos
;
2706 *left_pos
= f
->left_pos
;
2708 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2712 ph
= x_display_pixel_height (dpyinfo
);
2713 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2714 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2715 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2719 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2723 pw
= x_display_pixel_width (dpyinfo
);
2724 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2725 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2726 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2731 *height
= newheight
;
2734 #endif /* WINDOWSNT */
2736 #ifdef HAVE_WINDOW_SYSTEM
2738 /* Change the parameters of frame F as specified by ALIST.
2739 If a parameter is not specially recognized, do nothing special;
2740 otherwise call the `x_set_...' function for that parameter.
2741 Except for certain geometry properties, always call store_frame_param
2742 to store the new value in the parameter alist. */
2745 x_set_frame_parameters (FRAME_PTR f
, Lisp_Object alist
)
2749 /* If both of these parameters are present, it's more efficient to
2750 set them both at once. So we wait until we've looked at the
2751 entire list before we set them. */
2755 Lisp_Object left
, top
;
2757 /* Same with these. */
2758 Lisp_Object icon_left
, icon_top
;
2760 /* Record in these vectors all the parms specified. */
2762 Lisp_Object
*values
;
2764 int left_no_change
= 0, top_no_change
= 0;
2765 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2766 int size_changed
= 0;
2767 struct gcpro gcpro1
, gcpro2
;
2770 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2773 parms
= alloca (i
* sizeof *parms
);
2774 values
= alloca (i
* sizeof *values
);
2776 /* Extract parm names and values into those vectors. */
2779 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2784 parms
[i
] = Fcar (elt
);
2785 values
[i
] = Fcdr (elt
);
2788 /* TAIL and ALIST are not used again below here. */
2789 alist
= tail
= Qnil
;
2791 GCPRO2 (*parms
, *values
);
2795 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2796 because their values appear in VALUES and strings are not valid. */
2797 top
= left
= Qunbound
;
2798 icon_left
= icon_top
= Qunbound
;
2800 /* Provide default values for HEIGHT and WIDTH. */
2801 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2802 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2804 /* Process foreground_color and background_color before anything else.
2805 They are independent of other properties, but other properties (e.g.,
2806 cursor_color) are dependent upon them. */
2807 /* Process default font as well, since fringe widths depends on it. */
2808 for (p
= 0; p
< i
; p
++)
2810 Lisp_Object prop
, val
;
2814 if (EQ (prop
, Qforeground_color
)
2815 || EQ (prop
, Qbackground_color
)
2816 || EQ (prop
, Qfont
))
2818 register Lisp_Object param_index
, old_value
;
2820 old_value
= get_frame_param (f
, prop
);
2821 if (NILP (Fequal (val
, old_value
)))
2823 store_frame_param (f
, prop
, val
);
2825 param_index
= Fget (prop
, Qx_frame_parameter
);
2826 if (NATNUMP (param_index
)
2827 && (XFASTINT (param_index
)
2828 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2829 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2830 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2835 /* Now process them in reverse of specified order. */
2838 Lisp_Object prop
, val
;
2843 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2846 width
= XFASTINT (val
);
2848 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2851 height
= XFASTINT (val
);
2853 else if (EQ (prop
, Qtop
))
2855 else if (EQ (prop
, Qleft
))
2857 else if (EQ (prop
, Qicon_top
))
2859 else if (EQ (prop
, Qicon_left
))
2861 else if (EQ (prop
, Qforeground_color
)
2862 || EQ (prop
, Qbackground_color
)
2863 || EQ (prop
, Qfont
))
2864 /* Processed above. */
2868 register Lisp_Object param_index
, old_value
;
2870 old_value
= get_frame_param (f
, prop
);
2872 store_frame_param (f
, prop
, val
);
2874 param_index
= Fget (prop
, Qx_frame_parameter
);
2875 if (NATNUMP (param_index
)
2876 && (XFASTINT (param_index
)
2877 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2878 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2879 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2883 /* Don't die if just one of these was set. */
2884 if (EQ (left
, Qunbound
))
2887 if (f
->left_pos
< 0)
2888 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2890 XSETINT (left
, f
->left_pos
);
2892 if (EQ (top
, Qunbound
))
2896 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2898 XSETINT (top
, f
->top_pos
);
2901 /* If one of the icon positions was not set, preserve or default it. */
2902 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
2904 icon_left_no_change
= 1;
2905 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2906 if (NILP (icon_left
))
2907 XSETINT (icon_left
, 0);
2909 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
2911 icon_top_no_change
= 1;
2912 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2913 if (NILP (icon_top
))
2914 XSETINT (icon_top
, 0);
2917 /* Don't set these parameters unless they've been explicitly
2918 specified. The window might be mapped or resized while we're in
2919 this function, and we don't want to override that unless the lisp
2920 code has asked for it.
2922 Don't set these parameters unless they actually differ from the
2923 window's current parameters; the window may not actually exist
2928 check_frame_size (f
, &height
, &width
);
2930 XSETFRAME (frame
, f
);
2933 && (width
!= FRAME_COLS (f
)
2934 || height
!= FRAME_LINES (f
)
2935 || f
->new_text_lines
|| f
->new_text_cols
))
2936 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2938 if ((!NILP (left
) || !NILP (top
))
2939 && ! (left_no_change
&& top_no_change
)
2940 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2941 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2946 /* Record the signs. */
2947 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2948 if (EQ (left
, Qminus
))
2949 f
->size_hint_flags
|= XNegative
;
2950 else if (TYPE_RANGED_INTEGERP (int, left
))
2952 leftpos
= XINT (left
);
2954 f
->size_hint_flags
|= XNegative
;
2956 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2957 && CONSP (XCDR (left
))
2958 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
2960 leftpos
= - XINT (XCAR (XCDR (left
)));
2961 f
->size_hint_flags
|= XNegative
;
2963 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2964 && CONSP (XCDR (left
))
2965 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
2967 leftpos
= XINT (XCAR (XCDR (left
)));
2970 if (EQ (top
, Qminus
))
2971 f
->size_hint_flags
|= YNegative
;
2972 else if (TYPE_RANGED_INTEGERP (int, top
))
2974 toppos
= XINT (top
);
2976 f
->size_hint_flags
|= YNegative
;
2978 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2979 && CONSP (XCDR (top
))
2980 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
2982 toppos
= - XINT (XCAR (XCDR (top
)));
2983 f
->size_hint_flags
|= YNegative
;
2985 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2986 && CONSP (XCDR (top
))
2987 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
2989 toppos
= XINT (XCAR (XCDR (top
)));
2993 /* Store the numeric value of the position. */
2994 f
->top_pos
= toppos
;
2995 f
->left_pos
= leftpos
;
2997 f
->win_gravity
= NorthWestGravity
;
2999 /* Actually set that position, and convert to absolute. */
3000 x_set_offset (f
, leftpos
, toppos
, -1);
3003 if ((!NILP (icon_left
) || !NILP (icon_top
))
3004 && ! (icon_left_no_change
&& icon_top_no_change
))
3005 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3012 /* Insert a description of internally-recorded parameters of frame X
3013 into the parameter alist *ALISTPTR that is to be given to the user.
3014 Only parameters that are specific to the X window system
3015 and whose values are not correctly recorded in the frame's
3016 param_alist need to be considered here. */
3019 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3025 /* Represent negative positions (off the top or left screen edge)
3026 in a way that Fmodify_frame_parameters will understand correctly. */
3027 XSETINT (tem
, f
->left_pos
);
3028 if (f
->left_pos
>= 0)
3029 store_in_alist (alistptr
, Qleft
, tem
);
3031 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3033 XSETINT (tem
, f
->top_pos
);
3034 if (f
->top_pos
>= 0)
3035 store_in_alist (alistptr
, Qtop
, tem
);
3037 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3039 store_in_alist (alistptr
, Qborder_width
,
3040 make_number (f
->border_width
));
3041 store_in_alist (alistptr
, Qinternal_border_width
,
3042 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3043 store_in_alist (alistptr
, Qleft_fringe
,
3044 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3045 store_in_alist (alistptr
, Qright_fringe
,
3046 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3047 store_in_alist (alistptr
, Qscroll_bar_width
,
3048 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3050 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3051 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3052 /* nil means "use default width"
3053 for non-toolkit scroll bar.
3054 ruler-mode.el depends on this. */
3056 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
3057 MS-Windows it returns a value whose type is HANDLE, which is
3058 actually a pointer. Explicit casting avoids compiler
3060 w
= (unsigned long) FRAME_X_WINDOW (f
);
3061 store_in_alist (alistptr
, Qwindow_id
,
3062 make_formatted_string (buf
, "%lu", w
));
3063 #ifdef HAVE_X_WINDOWS
3064 #ifdef USE_X_TOOLKIT
3065 /* Tooltip frame may not have this widget. */
3066 if (FRAME_X_OUTPUT (f
)->widget
)
3068 w
= (unsigned long) FRAME_OUTER_WINDOW (f
);
3069 store_in_alist (alistptr
, Qouter_window_id
,
3070 make_formatted_string (buf
, "%lu", w
));
3072 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3073 FRAME_SAMPLE_VISIBILITY (f
);
3074 store_in_alist (alistptr
, Qvisibility
,
3075 (FRAME_VISIBLE_P (f
) ? Qt
3076 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3077 store_in_alist (alistptr
, Qdisplay
,
3078 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3080 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3083 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3084 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3085 store_in_alist (alistptr
, Qparent_id
, tem
);
3086 store_in_alist (alistptr
, Qtool_bar_position
, f
->tool_bar_position
);
3090 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3091 the previous value of that parameter, NEW_VALUE is the new value. */
3094 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3096 if (NILP (new_value
))
3097 f
->want_fullscreen
= FULLSCREEN_NONE
;
3098 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3099 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3100 else if (EQ (new_value
, Qfullwidth
))
3101 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3102 else if (EQ (new_value
, Qfullheight
))
3103 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3104 else if (EQ (new_value
, Qmaximized
))
3105 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3107 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3108 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3112 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3113 the previous value of that parameter, NEW_VALUE is the new value. */
3116 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3118 if (NILP (new_value
))
3119 f
->extra_line_spacing
= 0;
3120 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
3121 f
->extra_line_spacing
= XFASTINT (new_value
);
3123 signal_error ("Invalid line-spacing", new_value
);
3124 if (FRAME_VISIBLE_P (f
))
3129 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3130 the previous value of that parameter, NEW_VALUE is the new value. */
3133 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3135 Lisp_Object bgcolor
;
3137 if (NILP (new_value
))
3139 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3140 /* The value 0.4545 is the normal viewing gamma. */
3141 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3143 signal_error ("Invalid screen-gamma", new_value
);
3145 /* Apply the new gamma value to the frame background. */
3146 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3147 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3149 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3150 if (NATNUMP (parm_index
)
3151 && (XFASTINT (parm_index
)
3152 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3153 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3154 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3158 Fclear_face_cache (Qnil
);
3163 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3165 Lisp_Object font_object
;
3167 #ifdef HAVE_X_WINDOWS
3168 Lisp_Object font_param
= arg
;
3171 /* Set the frame parameter back to the old value because we may
3172 fail to use ARG as the new parameter value. */
3173 store_frame_param (f
, Qfont
, oldval
);
3175 /* ARG is a fontset name, a font name, a cons of fontset name and a
3176 font object, or a font object. In the last case, this function
3180 fontset
= fs_query_fontset (arg
, 0);
3183 font_object
= font_open_by_name (f
, arg
);
3184 if (NILP (font_object
))
3185 error ("Font `%s' is not defined", SSDATA (arg
));
3186 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3188 else if (fontset
> 0)
3190 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
3191 if (NILP (font_object
))
3192 error ("Font `%s' is not defined", SDATA (arg
));
3193 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3196 error ("The default fontset can't be used for a frame font");
3198 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3200 /* This is the case that the ASCII font of F's fontset XCAR
3201 (arg) is changed to the font XCDR (arg) by
3202 `set-fontset-font'. */
3203 fontset
= fs_query_fontset (XCAR (arg
), 0);
3205 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3206 font_object
= XCDR (arg
);
3207 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3208 #ifdef HAVE_X_WINDOWS
3209 font_param
= Ffont_get (font_object
, QCname
);
3212 else if (FONT_OBJECT_P (arg
))
3215 #ifdef HAVE_X_WINDOWS
3216 font_param
= Ffont_get (font_object
, QCname
);
3218 /* This is to store the XLFD font name in the frame parameter for
3219 backward compatibility. We should store the font-object
3220 itself in the future. */
3221 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3222 fontset
= FRAME_FONTSET (f
);
3223 /* Check if we can use the current fontset. If not, set FONTSET
3224 to -1 to generate a new fontset from FONT-OBJECT. */
3227 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3228 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3230 if (! font_match_p (spec
, font_object
))
3235 signal_error ("Invalid font", arg
);
3237 if (! NILP (Fequal (font_object
, oldval
)))
3240 x_new_font (f
, font_object
, fontset
);
3241 store_frame_param (f
, Qfont
, arg
);
3242 #ifdef HAVE_X_WINDOWS
3243 store_frame_param (f
, Qfont_param
, font_param
);
3245 /* Recalculate toolbar height. */
3246 f
->n_tool_bar_rows
= 0;
3247 /* Ensure we redraw it. */
3248 clear_current_matrices (f
);
3250 recompute_basic_faces (f
);
3252 do_pending_window_change (0);
3254 /* We used to call face-set-after-frame-default here, but it leads to
3255 recursive calls (since that function can set the `default' face's
3256 font which in turns changes the frame's `font' parameter).
3257 Also I don't know what this call is meant to do, but it seems the
3258 wrong way to do it anyway (it does a lot more work than what seems
3259 reasonable in response to a change to `font'). */
3264 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3266 if (! NILP (new_value
)
3267 && !CONSP (new_value
))
3271 CHECK_STRING (new_value
);
3272 p0
= p1
= SSDATA (new_value
);
3276 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
3278 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3284 while ((c
= *++p1
) && c_isspace (c
));
3288 new_value
= Fnreverse (new_value
);
3291 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3295 free_all_realized_faces (Qnil
);
3297 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3298 if (NILP (new_value
))
3300 if (NILP (old_value
))
3301 error ("No font backend available");
3302 font_update_drivers (f
, old_value
);
3303 error ("None of specified font backends are available");
3305 store_frame_param (f
, Qfont_backend
, new_value
);
3311 XSETFRAME (frame
, f
);
3312 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3313 ++face_change_count
;
3314 ++windows_or_buffers_changed
;
3320 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3322 compute_fringe_widths (f
, 1);
3323 #ifdef HAVE_X_WINDOWS
3324 /* Must adjust this so window managers report correct number of columns. */
3325 if (FRAME_X_WINDOW (f
) != 0)
3326 x_wm_set_size_hint (f
, 0, 0);
3331 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3333 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3335 if (XINT (arg
) == f
->border_width
)
3338 if (FRAME_X_WINDOW (f
) != 0)
3339 error ("Cannot change the border width of a frame");
3341 f
->border_width
= XINT (arg
);
3345 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3347 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3349 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3350 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3351 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3352 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3354 #ifdef USE_X_TOOLKIT
3355 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3356 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3359 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3362 if (FRAME_X_WINDOW (f
) != 0)
3364 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3365 SET_FRAME_GARBAGED (f
);
3366 do_pending_window_change (0);
3369 SET_FRAME_GARBAGED (f
);
3373 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3376 XSETFRAME (frame
, f
);
3379 Fmake_frame_invisible (frame
, Qt
);
3380 else if (EQ (value
, Qicon
))
3381 Ficonify_frame (frame
);
3383 Fmake_frame_visible (frame
);
3387 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3389 f
->auto_raise
= !EQ (Qnil
, arg
);
3393 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3395 f
->auto_lower
= !EQ (Qnil
, arg
);
3399 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3401 f
->no_split
= !NILP (arg
);
3405 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3407 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3408 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3409 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3410 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3412 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3414 ? vertical_scroll_bar_none
3416 ? vertical_scroll_bar_left
3418 ? vertical_scroll_bar_right
3419 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3420 ? vertical_scroll_bar_left
3421 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3422 ? vertical_scroll_bar_right
3423 : vertical_scroll_bar_none
);
3425 /* We set this parameter before creating the X window for the
3426 frame, so we can get the geometry right from the start.
3427 However, if the window hasn't been created yet, we shouldn't
3428 call x_set_window_size. */
3429 if (FRAME_X_WINDOW (f
))
3430 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3431 do_pending_window_change (0);
3436 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3438 int wid
= FRAME_COLUMN_WIDTH (f
);
3442 x_set_scroll_bar_default_width (f
);
3444 if (FRAME_X_WINDOW (f
))
3445 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3446 do_pending_window_change (0);
3448 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3449 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3451 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3452 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3454 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3455 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3456 if (FRAME_X_WINDOW (f
))
3457 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3458 do_pending_window_change (0);
3461 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3462 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3463 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3468 /* Return non-nil if frame F wants a bitmap icon. */
3471 x_icon_type (FRAME_PTR f
)
3475 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3483 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3490 for (i
= 0; i
< 2; i
++)
3503 else if (FLOATP (item
))
3505 alpha
= XFLOAT_DATA (item
);
3506 if (alpha
< 0.0 || 1.0 < alpha
)
3507 args_out_of_range (make_float (0.0), make_float (1.0));
3509 else if (INTEGERP (item
))
3511 EMACS_INT ialpha
= XINT (item
);
3512 if (ialpha
< 0 || 100 < ialpha
)
3513 args_out_of_range (make_number (0), make_number (100));
3515 alpha
= ialpha
/ 100.0;
3518 wrong_type_argument (Qnumberp
, item
);
3522 for (i
= 0; i
< 2; i
++)
3523 f
->alpha
[i
] = newval
[i
];
3525 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3527 x_set_frame_alpha (f
);
3535 /* Subroutines of creating an X frame. */
3537 /* Make sure that Vx_resource_name is set to a reasonable value.
3538 Fix it up, or set it to `emacs' if it is too hopeless. */
3541 validate_x_resource_name (void)
3544 /* Number of valid characters in the resource name. */
3545 ptrdiff_t good_count
= 0;
3546 /* Number of invalid characters in the resource name. */
3547 ptrdiff_t bad_count
= 0;
3551 if (!STRINGP (Vx_resource_class
))
3552 Vx_resource_class
= build_string (EMACS_CLASS
);
3554 if (STRINGP (Vx_resource_name
))
3556 unsigned char *p
= SDATA (Vx_resource_name
);
3558 len
= SBYTES (Vx_resource_name
);
3560 /* Only letters, digits, - and _ are valid in resource names.
3561 Count the valid characters and count the invalid ones. */
3562 for (i
= 0; i
< len
; i
++)
3565 if (! ((c
>= 'a' && c
<= 'z')
3566 || (c
>= 'A' && c
<= 'Z')
3567 || (c
>= '0' && c
<= '9')
3568 || c
== '-' || c
== '_'))
3575 /* Not a string => completely invalid. */
3576 bad_count
= 5, good_count
= 0;
3578 /* If name is valid already, return. */
3582 /* If name is entirely invalid, or nearly so, or is so implausibly
3583 large that alloca might not work, use `emacs'. */
3584 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
3586 Vx_resource_name
= build_string ("emacs");
3590 /* Name is partly valid. Copy it and replace the invalid characters
3591 with underscores. */
3593 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3595 for (i
= 0; i
< len
; i
++)
3597 int c
= SREF (new, i
);
3598 if (! ((c
>= 'a' && c
<= 'z')
3599 || (c
>= 'A' && c
<= 'Z')
3600 || (c
>= '0' && c
<= '9')
3601 || c
== '-' || c
== '_'))
3607 extern char *x_get_string_resource (XrmDatabase
, const char *, const char *);
3608 extern Display_Info
*check_x_display_info (Lisp_Object
);
3611 /* Get specified attribute from resource database RDB.
3612 See Fx_get_resource below for other parameters. */
3615 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3617 register char *value
;
3621 CHECK_STRING (attribute
);
3622 CHECK_STRING (class);
3624 if (!NILP (component
))
3625 CHECK_STRING (component
);
3626 if (!NILP (subclass
))
3627 CHECK_STRING (subclass
);
3628 if (NILP (component
) != NILP (subclass
))
3629 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3631 validate_x_resource_name ();
3633 /* Allocate space for the components, the dots which separate them,
3634 and the final '\0'. Make them big enough for the worst case. */
3635 name_key
= alloca (SBYTES (Vx_resource_name
)
3636 + (STRINGP (component
)
3637 ? SBYTES (component
) : 0)
3638 + SBYTES (attribute
)
3641 class_key
= alloca (SBYTES (Vx_resource_class
)
3643 + (STRINGP (subclass
)
3644 ? SBYTES (subclass
) : 0)
3647 /* Start with emacs.FRAMENAME for the name (the specific one)
3648 and with `Emacs' for the class key (the general one). */
3649 strcpy (name_key
, SSDATA (Vx_resource_name
));
3650 strcpy (class_key
, SSDATA (Vx_resource_class
));
3652 strcat (class_key
, ".");
3653 strcat (class_key
, SSDATA (class));
3655 if (!NILP (component
))
3657 strcat (class_key
, ".");
3658 strcat (class_key
, SSDATA (subclass
));
3660 strcat (name_key
, ".");
3661 strcat (name_key
, SSDATA (component
));
3664 strcat (name_key
, ".");
3665 strcat (name_key
, SSDATA (attribute
));
3667 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3669 if (value
!= (char *) 0 && *value
)
3670 return build_string (value
);
3676 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3677 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3678 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3679 class, where INSTANCE is the name under which Emacs was invoked, or
3680 the name specified by the `-name' or `-rn' command-line arguments.
3682 The optional arguments COMPONENT and SUBCLASS add to the key and the
3683 class, respectively. You must specify both of them or neither.
3684 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3685 and the class is `Emacs.CLASS.SUBCLASS'. */)
3686 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3688 #ifdef HAVE_X_WINDOWS
3692 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3693 attribute
, class, component
, subclass
);
3696 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3699 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3701 return xrdb_get_resource (dpyinfo
->xrdb
,
3702 attribute
, class, component
, subclass
);
3705 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3706 /* Used when C code wants a resource value. */
3707 /* Called from oldXMenu/Create.c. */
3709 x_get_resource_string (const char *attribute
, const char *class)
3712 struct frame
*sf
= SELECTED_FRAME ();
3713 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
3716 /* Allocate space for the components, the dots which separate them,
3717 and the final '\0'. */
3718 char *name_key
= SAFE_ALLOCA (invocation_namelen
+ strlen (attribute
) + 2);
3719 char *class_key
= alloca ((sizeof (EMACS_CLASS
) - 1) + strlen (class) + 2);
3721 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
3722 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3724 result
= x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3725 name_key
, class_key
);
3731 /* Return the value of parameter PARAM.
3733 First search ALIST, then Vdefault_frame_alist, then the X defaults
3734 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3736 Convert the resource to the type specified by desired_type.
3738 If no default is specified, return Qunbound. If you call
3739 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3740 and don't let it get stored in any Lisp-visible variables! */
3743 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3744 const char *attribute
, const char *class, enum resource_types type
)
3746 register Lisp_Object tem
;
3748 tem
= Fassq (param
, alist
);
3752 /* If we find this parm in ALIST, clear it out
3753 so that it won't be "left over" at the end. */
3755 XSETCAR (tem
, Qnil
);
3756 /* In case the parameter appears more than once in the alist,
3758 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3759 if (CONSP (XCAR (tail
))
3760 && EQ (XCAR (XCAR (tail
)), param
))
3761 XSETCAR (XCAR (tail
), Qnil
);
3764 tem
= Fassq (param
, Vdefault_frame_alist
);
3766 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3767 look in the X resources. */
3770 if (attribute
&& dpyinfo
)
3772 tem
= display_x_get_resource (dpyinfo
,
3773 build_string (attribute
),
3774 build_string (class),
3782 case RES_TYPE_NUMBER
:
3783 return make_number (atoi (SSDATA (tem
)));
3785 case RES_TYPE_BOOLEAN_NUMBER
:
3786 if (!strcmp (SSDATA (tem
), "on")
3787 || !strcmp (SSDATA (tem
), "true"))
3788 return make_number (1);
3789 return make_number (atoi (SSDATA (tem
)));
3792 case RES_TYPE_FLOAT
:
3793 return make_float (atof (SSDATA (tem
)));
3795 case RES_TYPE_BOOLEAN
:
3796 tem
= Fdowncase (tem
);
3797 if (!strcmp (SSDATA (tem
), "on")
3799 || !strcmp (SSDATA (tem
), "yes")
3801 || !strcmp (SSDATA (tem
), "true"))
3806 case RES_TYPE_STRING
:
3809 case RES_TYPE_SYMBOL
:
3810 /* As a special case, we map the values `true' and `on'
3811 to Qt, and `false' and `off' to Qnil. */
3814 lower
= Fdowncase (tem
);
3815 if (!strcmp (SSDATA (lower
), "on")
3817 || !strcmp (SSDATA (lower
), "yes")
3819 || !strcmp (SSDATA (lower
), "true"))
3821 else if (!strcmp (SSDATA (lower
), "off")
3823 || !strcmp (SSDATA (lower
), "no")
3825 || !strcmp (SSDATA (lower
), "false"))
3828 return Fintern (tem
, Qnil
);
3842 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3843 const char *attribute
, const char *class,
3844 enum resource_types type
)
3846 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3847 alist
, param
, attribute
, class, type
);
3850 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3853 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3855 const char *attribute
, const char *class,
3856 enum resource_types type
)
3860 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3861 attribute
, class, type
);
3862 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3863 store_frame_param (f
, param
, value
);
3869 /* Record in frame F the specified or default value according to ALIST
3870 of the parameter named PROP (a Lisp symbol).
3871 If no value is specified for PROP, look for an X default for XPROP
3872 on the frame named NAME.
3873 If that is not found either, use the value DEFLT. */
3876 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
3877 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
3878 enum resource_types type
)
3882 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3883 if (EQ (tem
, Qunbound
))
3885 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3892 /* NS used to define x-parse-geometry in ns-win.el, but that confused
3893 make-docfile: the documentation string in ns-win.el was used for
3894 x-parse-geometry even in non-NS builds.
3896 With two definitions of x-parse-geometry in this file, various
3897 things still get confused (eg M-x apropos documentation), so that
3898 it is best if the two definitions just share the same doc-string.
3900 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3901 doc
: /* Parse a display geometry string STRING.
3902 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3903 The properties returned may include `top', `left', `height', and `width'.
3904 For X, the value of `left' or `top' may be an integer,
3905 or a list (+ N) meaning N pixels relative to top/left corner,
3906 or a list (- N) meaning -N pixels relative to bottom/right corner.
3907 On Nextstep, this just calls `ns-parse-geometry'. */)
3908 (Lisp_Object string
)
3911 return call1 (Qns_parse_geometry
, string
);
3914 unsigned int width
, height
;
3917 CHECK_STRING (string
);
3919 geometry
= XParseGeometry (SSDATA (string
),
3920 &x
, &y
, &width
, &height
);
3922 if (geometry
& XValue
)
3924 Lisp_Object element
;
3926 if (x
>= 0 && (geometry
& XNegative
))
3927 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3928 else if (x
< 0 && ! (geometry
& XNegative
))
3929 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3931 element
= Fcons (Qleft
, make_number (x
));
3932 result
= Fcons (element
, result
);
3935 if (geometry
& YValue
)
3937 Lisp_Object element
;
3939 if (y
>= 0 && (geometry
& YNegative
))
3940 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3941 else if (y
< 0 && ! (geometry
& YNegative
))
3942 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3944 element
= Fcons (Qtop
, make_number (y
));
3945 result
= Fcons (element
, result
);
3948 if (geometry
& WidthValue
)
3949 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3950 if (geometry
& HeightValue
)
3951 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3954 #endif /* HAVE_NS */
3958 /* Calculate the desired size and position of frame F.
3959 Return the flags saying which aspects were specified.
3961 Also set the win_gravity and size_hint_flags of F.
3963 Adjust height for toolbar if TOOLBAR_P is 1.
3965 This function does not make the coordinates positive. */
3967 #define DEFAULT_ROWS 35
3968 #define DEFAULT_COLS 80
3971 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, int toolbar_p
)
3973 register Lisp_Object tem0
, tem1
, tem2
;
3974 long window_prompting
= 0;
3975 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3977 /* Default values if we fall through.
3978 Actually, if that happens we should get
3979 window manager prompting. */
3980 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3981 FRAME_LINES (f
) = DEFAULT_ROWS
;
3982 /* Window managers expect that if program-specified
3983 positions are not (0,0), they're intentional, not defaults. */
3987 /* Ensure that old new_text_cols and new_text_lines will not override the
3989 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3990 f
->new_text_cols
= f
->new_text_lines
= 0;
3992 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3993 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3994 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3995 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3997 if (!EQ (tem0
, Qunbound
))
3999 CHECK_NUMBER (tem0
);
4000 if (! (0 <= XINT (tem0
) && XINT (tem0
) <= INT_MAX
))
4001 xsignal1 (Qargs_out_of_range
, tem0
);
4002 FRAME_LINES (f
) = XINT (tem0
);
4004 if (!EQ (tem1
, Qunbound
))
4006 CHECK_NUMBER (tem1
);
4007 if (! (0 <= XINT (tem1
) && XINT (tem1
) <= INT_MAX
))
4008 xsignal1 (Qargs_out_of_range
, tem1
);
4009 SET_FRAME_COLS (f
, XINT (tem1
));
4011 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4012 window_prompting
|= USSize
;
4014 window_prompting
|= PSize
;
4017 f
->scroll_bar_actual_width
4018 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4020 /* This used to be done _before_ calling x_figure_window_size, but
4021 since the height is reset here, this was really a no-op. I
4022 assume that moving it here does what Gerd intended (although he
4023 no longer can remember what that was... ++KFS, 2003-03-25. */
4025 /* Add the tool-bar height to the initial frame height so that the
4026 user gets a text display area of the size he specified with -g or
4027 via .Xdefaults. Later changes of the tool-bar height don't
4028 change the frame size. This is done so that users can create
4029 tall Emacs frames without having to guess how tall the tool-bar
4031 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4033 int margin
, relief
, bar_height
;
4035 relief
= (tool_bar_button_relief
>= 0
4036 ? tool_bar_button_relief
4037 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4039 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
4040 margin
= XFASTINT (Vtool_bar_button_margin
);
4041 else if (CONSP (Vtool_bar_button_margin
)
4042 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
4043 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4047 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4048 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4051 compute_fringe_widths (f
, 0);
4053 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4054 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4056 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4057 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4058 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4059 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4061 if (EQ (tem0
, Qminus
))
4064 window_prompting
|= YNegative
;
4066 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4067 && CONSP (XCDR (tem0
))
4068 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem0
)), INT_MAX
))
4070 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4071 window_prompting
|= YNegative
;
4073 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4074 && CONSP (XCDR (tem0
))
4075 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0
))))
4077 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4079 else if (EQ (tem0
, Qunbound
))
4083 CHECK_TYPE_RANGED_INTEGER (int, tem0
);
4084 f
->top_pos
= XINT (tem0
);
4086 window_prompting
|= YNegative
;
4089 if (EQ (tem1
, Qminus
))
4092 window_prompting
|= XNegative
;
4094 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4095 && CONSP (XCDR (tem1
))
4096 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem1
)), INT_MAX
))
4098 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4099 window_prompting
|= XNegative
;
4101 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4102 && CONSP (XCDR (tem1
))
4103 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1
))))
4105 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4107 else if (EQ (tem1
, Qunbound
))
4111 CHECK_TYPE_RANGED_INTEGER (int, tem1
);
4112 f
->left_pos
= XINT (tem1
);
4113 if (f
->left_pos
< 0)
4114 window_prompting
|= XNegative
;
4117 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4118 window_prompting
|= USPosition
;
4120 window_prompting
|= PPosition
;
4123 if (window_prompting
& XNegative
)
4125 if (window_prompting
& YNegative
)
4126 f
->win_gravity
= SouthEastGravity
;
4128 f
->win_gravity
= NorthEastGravity
;
4132 if (window_prompting
& YNegative
)
4133 f
->win_gravity
= SouthWestGravity
;
4135 f
->win_gravity
= NorthWestGravity
;
4138 f
->size_hint_flags
= window_prompting
;
4140 return window_prompting
;
4145 #endif /* HAVE_WINDOW_SYSTEM */
4148 frame_make_pointer_invisible (void)
4150 if (! NILP (Vmake_pointer_invisible
))
4153 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4156 f
= SELECTED_FRAME ();
4157 if (f
&& !f
->pointer_invisible
4158 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4161 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4162 f
->pointer_invisible
= 1;
4168 frame_make_pointer_visible (void)
4170 /* We don't check Vmake_pointer_invisible here in case the
4171 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4174 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4177 f
= SELECTED_FRAME ();
4178 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4179 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4181 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4182 f
->pointer_invisible
= 0;
4186 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4187 Sframe_pointer_visible_p
, 0, 1, 0,
4188 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4189 Otherwise it returns nil. FRAME omitted or nil means the
4190 selected frame. This is useful when `make-pointer-invisible' is set. */)
4194 frame
= selected_frame
;
4196 CHECK_FRAME (frame
);
4198 return (XFRAME (frame
)->pointer_invisible
? Qnil
: Qt
);
4202 /***********************************************************************
4204 ***********************************************************************/
4207 syms_of_frame (void)
4209 DEFSYM (Qframep
, "framep");
4210 DEFSYM (Qframe_live_p
, "frame-live-p");
4211 DEFSYM (Qexplicit_name
, "explicit-name");
4212 DEFSYM (Qheight
, "height");
4213 DEFSYM (Qicon
, "icon");
4214 DEFSYM (Qminibuffer
, "minibuffer");
4215 DEFSYM (Qmodeline
, "modeline");
4216 DEFSYM (Qonly
, "only");
4217 DEFSYM (Qnone
, "none");
4218 DEFSYM (Qwidth
, "width");
4219 DEFSYM (Qgeometry
, "geometry");
4220 DEFSYM (Qicon_left
, "icon-left");
4221 DEFSYM (Qicon_top
, "icon-top");
4222 DEFSYM (Qtooltip
, "tooltip");
4223 DEFSYM (Qleft
, "left");
4224 DEFSYM (Qright
, "right");
4225 DEFSYM (Quser_position
, "user-position");
4226 DEFSYM (Quser_size
, "user-size");
4227 DEFSYM (Qwindow_id
, "window-id");
4228 #ifdef HAVE_X_WINDOWS
4229 DEFSYM (Qouter_window_id
, "outer-window-id");
4231 DEFSYM (Qparent_id
, "parent-id");
4233 DEFSYM (Qw32
, "w32");
4235 DEFSYM (Qmac
, "mac");
4237 DEFSYM (Qvisible
, "visible");
4238 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4239 DEFSYM (Qbuffer_list
, "buffer-list");
4240 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4241 DEFSYM (Qdisplay_type
, "display-type");
4242 DEFSYM (Qbackground_mode
, "background-mode");
4243 DEFSYM (Qnoelisp
, "noelisp");
4244 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4245 DEFSYM (Qtty
, "tty");
4246 DEFSYM (Qtty_type
, "tty-type");
4248 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4250 DEFSYM (Qfullwidth
, "fullwidth");
4251 DEFSYM (Qfullheight
, "fullheight");
4252 DEFSYM (Qfullboth
, "fullboth");
4253 DEFSYM (Qmaximized
, "maximized");
4254 DEFSYM (Qx_resource_name
, "x-resource-name");
4255 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4257 DEFSYM (Qterminal
, "terminal");
4258 DEFSYM (Qterminal_live_p
, "terminal-live-p");
4261 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4267 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4269 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4270 if (frame_parms
[i
].variable
)
4272 *frame_parms
[i
].variable
= v
;
4273 staticpro (frame_parms
[i
].variable
);
4275 Fput (v
, Qx_frame_parameter
, make_number (i
));
4279 #ifdef HAVE_WINDOW_SYSTEM
4280 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4281 doc
: /* The name Emacs uses to look up X resources.
4282 `x-get-resource' uses this as the first component of the instance name
4283 when requesting resource values.
4284 Emacs initially sets `x-resource-name' to the name under which Emacs
4285 was invoked, or to the value specified with the `-name' or `-rn'
4286 switches, if present.
4288 It may be useful to bind this variable locally around a call
4289 to `x-get-resource'. See also the variable `x-resource-class'. */);
4290 Vx_resource_name
= Qnil
;
4292 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4293 doc
: /* The class Emacs uses to look up X resources.
4294 `x-get-resource' uses this as the first component of the instance class
4295 when requesting resource values.
4297 Emacs initially sets `x-resource-class' to "Emacs".
4299 Setting this variable permanently is not a reasonable thing to do,
4300 but binding this variable locally around a call to `x-get-resource'
4301 is a reasonable practice. See also the variable `x-resource-name'. */);
4302 Vx_resource_class
= build_string (EMACS_CLASS
);
4304 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4305 doc
: /* The lower limit of the frame opacity (alpha transparency).
4306 The value should range from 0 (invisible) to 100 (completely opaque).
4307 You can also use a floating number between 0.0 and 1.0.
4308 The default is 20. */);
4309 Vframe_alpha_lower_limit
= make_number (20);
4312 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4313 doc
: /* Alist of default values for frame creation.
4314 These may be set in your init file, like this:
4315 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4316 These override values given in window system configuration data,
4317 including X Windows' defaults database.
4318 For values specific to the first Emacs frame, see `initial-frame-alist'.
4319 For window-system specific values, see `window-system-default-frame-alist'.
4320 For values specific to the separate minibuffer frame, see
4321 `minibuffer-frame-alist'.
4322 The `menu-bar-lines' element of the list controls whether new frames
4323 have menu bars; `menu-bar-mode' works by altering this element.
4324 Setting this variable does not affect existing frames, only new ones. */);
4325 Vdefault_frame_alist
= Qnil
;
4327 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4328 doc
: /* Default position of scroll bars on this window-system. */);
4329 #ifdef HAVE_WINDOW_SYSTEM
4330 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
4331 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4333 Vdefault_frame_scroll_bars
= Qright
;
4335 Vdefault_frame_scroll_bars
= Qleft
;
4338 Vdefault_frame_scroll_bars
= Qnil
;
4341 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4342 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4344 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4345 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4346 `mouse-position' calls this function, passing its usual return value as
4347 argument, and returns whatever this function returns.
4348 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4349 which need to do mouse handling at the Lisp level. */);
4350 Vmouse_position_function
= Qnil
;
4352 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4353 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4354 If the value is an integer, highlighting is only shown after moving the
4355 mouse, while keyboard input turns off the highlight even when the mouse
4356 is over the clickable text. However, the mouse shape still indicates
4357 when the mouse is over clickable text. */);
4358 Vmouse_highlight
= Qt
;
4360 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4361 doc
: /* If non-nil, make pointer invisible while typing.
4362 The pointer becomes visible again when the mouse is moved. */);
4363 Vmake_pointer_invisible
= Qt
;
4365 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4366 doc
: /* Functions run before deleting a frame.
4367 The functions are run with one arg, the frame to be deleted.
4370 Note that functions in this list may be called just before the frame is
4371 actually deleted, or some time later (or even both when an earlier function
4372 in `delete-frame-functions' (indirectly) calls `delete-frame'
4374 Vdelete_frame_functions
= Qnil
;
4375 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
4377 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4378 doc
: /* Non-nil if Menu-Bar mode is enabled.
4379 See the command `menu-bar-mode' for a description of this minor mode.
4380 Setting this variable directly does not take effect;
4381 either customize it (see the info node `Easy Customization')
4382 or call the function `menu-bar-mode'. */);
4383 Vmenu_bar_mode
= Qt
;
4385 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4386 doc
: /* Non-nil if Tool-Bar mode is enabled.
4387 See the command `tool-bar-mode' for a description of this minor mode.
4388 Setting this variable directly does not take effect;
4389 either customize it (see the info node `Easy Customization')
4390 or call the function `tool-bar-mode'. */);
4391 #ifdef HAVE_WINDOW_SYSTEM
4392 Vtool_bar_mode
= Qt
;
4394 Vtool_bar_mode
= Qnil
;
4397 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4398 doc
: /* Minibufferless frames use this frame's minibuffer.
4400 Emacs cannot create minibufferless frames unless this is set to an
4401 appropriate surrogate.
4403 Emacs consults this variable only when creating minibufferless
4404 frames; once the frame is created, it sticks with its assigned
4405 minibuffer, no matter what this variable is set to. This means that
4406 this variable doesn't necessarily say anything meaningful about the
4407 current set of frames, or where the minibuffer is currently being
4410 This variable is local to the current terminal and cannot be buffer-local. */);
4412 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
4413 doc
: /* Non-nil if window system changes focus when you move the mouse.
4414 You should set this variable to tell Emacs how your window manager
4415 handles focus, since there is no way in general for Emacs to find out
4416 automatically. See also `mouse-autoselect-window'. */);
4417 focus_follows_mouse
= 0;
4419 staticpro (&Vframe_list
);
4422 defsubr (&Sframe_live_p
);
4423 defsubr (&Swindow_system
);
4424 defsubr (&Smake_terminal_frame
);
4425 defsubr (&Shandle_switch_frame
);
4426 defsubr (&Sselect_frame
);
4427 defsubr (&Sselected_frame
);
4428 defsubr (&Sframe_list
);
4429 defsubr (&Snext_frame
);
4430 defsubr (&Sprevious_frame
);
4431 defsubr (&Sdelete_frame
);
4432 defsubr (&Smouse_position
);
4433 defsubr (&Smouse_pixel_position
);
4434 defsubr (&Sset_mouse_position
);
4435 defsubr (&Sset_mouse_pixel_position
);
4437 defsubr (&Sframe_configuration
);
4438 defsubr (&Srestore_frame_configuration
);
4440 defsubr (&Smake_frame_visible
);
4441 defsubr (&Smake_frame_invisible
);
4442 defsubr (&Siconify_frame
);
4443 defsubr (&Sframe_visible_p
);
4444 defsubr (&Svisible_frame_list
);
4445 defsubr (&Sraise_frame
);
4446 defsubr (&Slower_frame
);
4447 defsubr (&Sredirect_frame_focus
);
4448 defsubr (&Sframe_focus
);
4449 defsubr (&Sframe_parameters
);
4450 defsubr (&Sframe_parameter
);
4451 defsubr (&Smodify_frame_parameters
);
4452 defsubr (&Sframe_char_height
);
4453 defsubr (&Sframe_char_width
);
4454 defsubr (&Sframe_pixel_height
);
4455 defsubr (&Sframe_pixel_width
);
4456 defsubr (&Stool_bar_pixel_width
);
4457 defsubr (&Sset_frame_height
);
4458 defsubr (&Sset_frame_width
);
4459 defsubr (&Sset_frame_size
);
4460 defsubr (&Sset_frame_position
);
4461 defsubr (&Sframe_pointer_visible_p
);
4463 #ifdef HAVE_WINDOW_SYSTEM
4464 defsubr (&Sx_get_resource
);
4465 defsubr (&Sx_parse_geometry
);