1 /* Generic frame functions.
3 Copyright (C) 1993-1995, 1997, 1999-2012 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
28 #include "character.h"
39 /* These help us bind and responding to switch-frame events. */
43 #include "blockinput.h"
45 #include "termhooks.h"
46 #include "dispextern.h"
49 #ifdef HAVE_WINDOW_SYSTEM
58 #ifdef HAVE_WINDOW_SYSTEM
63 Lisp_Object Qns_parse_geometry
;
66 Lisp_Object Qframep
, Qframe_live_p
;
67 Lisp_Object Qicon
, Qmodeline
;
69 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
, Qns
;
71 Lisp_Object Qdisplay_type
;
72 static Lisp_Object Qbackground_mode
;
75 static Lisp_Object Qx_frame_parameter
;
76 Lisp_Object Qx_resource_name
;
77 Lisp_Object Qterminal
;
78 Lisp_Object Qterminal_live_p
;
80 /* Frame parameters (set or reported). */
82 Lisp_Object Qauto_raise
, Qauto_lower
;
83 Lisp_Object Qborder_color
, Qborder_width
;
84 Lisp_Object Qcursor_color
, Qcursor_type
;
85 static Lisp_Object Qgeometry
; /* Not used */
86 Lisp_Object Qheight
, Qwidth
;
87 Lisp_Object Qleft
, Qright
;
88 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
90 Lisp_Object Qinternal_border_width
;
91 Lisp_Object Qmouse_color
;
92 Lisp_Object Qminibuffer
;
93 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
94 Lisp_Object Qvisibility
;
95 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
96 Lisp_Object Qscreen_gamma
;
97 Lisp_Object Qline_spacing
;
98 static Lisp_Object Quser_position
, Quser_size
;
99 Lisp_Object Qwait_for_wm
;
100 static Lisp_Object Qwindow_id
;
101 #ifdef HAVE_X_WINDOWS
102 static Lisp_Object Qouter_window_id
;
104 Lisp_Object Qparent_id
;
105 Lisp_Object Qtitle
, Qname
;
106 static Lisp_Object Qexplicit_name
;
107 Lisp_Object Qunsplittable
;
108 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
, Qtool_bar_position
;
109 Lisp_Object Qleft_fringe
, Qright_fringe
;
110 Lisp_Object Qbuffer_predicate
;
111 static Lisp_Object Qbuffer_list
, Qburied_buffer_list
;
112 Lisp_Object Qtty_color_mode
;
113 Lisp_Object Qtty
, Qtty_type
;
115 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
117 Lisp_Object Qfont_backend
;
120 Lisp_Object Qface_set_after_frame_default
;
122 static Lisp_Object Qdelete_frame_functions
;
124 #ifdef HAVE_WINDOW_SYSTEM
125 static void x_report_frame_params (struct frame
*, Lisp_Object
*);
130 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
132 struct window
*w
= XWINDOW (window
);
134 w
->last_modified
= 0;
135 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
136 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
138 /* Handle just the top child in a vertical split. */
139 if (!NILP (w
->vchild
))
140 set_menu_bar_lines_1 (w
->vchild
, n
);
142 /* Adjust all children in a horizontal split. */
143 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
145 w
= XWINDOW (window
);
146 set_menu_bar_lines_1 (window
, n
);
151 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
154 int olines
= FRAME_MENU_BAR_LINES (f
);
156 /* Right now, menu bars don't work properly in minibuf-only frames;
157 most of the commands try to apply themselves to the minibuffer
158 frame itself, and get an error because you can't switch buffers
159 in or split the minibuffer window. */
160 if (FRAME_MINIBUF_ONLY_P (f
))
163 if (TYPE_RANGED_INTEGERP (int, value
))
164 nlines
= XINT (value
);
168 if (nlines
!= olines
)
170 windows_or_buffers_changed
++;
171 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
172 FRAME_MENU_BAR_LINES (f
) = nlines
;
173 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
178 Lisp_Object Vframe_list
;
181 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
182 doc
: /* Return non-nil if OBJECT is a frame.
184 t for a termcap frame (a character-only terminal),
185 'x' for an Emacs frame that is really an X window,
186 'w32' for an Emacs frame that is a window on MS-Windows display,
187 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
188 'pc' for a direct-write MS-DOS frame.
189 See also `frame-live-p'. */)
192 if (!FRAMEP (object
))
194 switch (XFRAME (object
)->output_method
)
196 case output_initial
: /* The initial frame is like a termcap frame. */
199 case output_x_window
:
203 case output_msdos_raw
:
214 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
215 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
216 Value is nil if OBJECT is not a live frame. If object is a live
217 frame, the return value indicates what sort of terminal device it is
218 displayed on. See the documentation of `framep' for possible
222 return ((FRAMEP (object
)
223 && FRAME_LIVE_P (XFRAME (object
)))
228 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
229 doc
: /* The name of the window system that FRAME is displaying through.
230 The value is a symbol:
231 nil for a termcap frame (a character-only terminal),
232 'x' for an Emacs frame that is really an X window,
233 'w32' for an Emacs frame that is a window on MS-Windows display,
234 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
235 'pc' for a direct-write MS-DOS frame.
237 FRAME defaults to the currently selected frame.
239 Use of this function as a predicate is deprecated. Instead,
240 use `display-graphic-p' or any of the other `display-*-p'
241 predicates which report frame's specific UI-related capabilities. */)
246 frame
= selected_frame
;
248 type
= Fframep (frame
);
251 wrong_type_argument (Qframep
, frame
);
260 make_frame (int mini_p
)
263 register struct frame
*f
;
264 register Lisp_Object root_window
;
265 register Lisp_Object mini_window
;
267 f
= allocate_frame ();
268 XSETFRAME (frame
, f
);
270 /* Initialize Lisp data. Note that allocate_frame initializes all
271 Lisp data to nil, so do it only for slots which should not be nil. */
272 f
->tool_bar_position
= Qtop
;
274 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
275 non-Lisp data, so do it only for slots which should not be zero.
276 To avoid subtle bugs and for the sake of readability, it's better to
277 initialize enum members explicitly even if their values are zero. */
278 f
->wants_modeline
= 1;
280 f
->has_minibuffer
= mini_p
;
281 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
282 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
283 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
284 #ifdef HAVE_WINDOW_SYSTEM
285 f
->want_fullscreen
= FULLSCREEN_NONE
;
288 root_window
= make_window ();
291 mini_window
= make_window ();
292 XWINDOW (root_window
)->next
= mini_window
;
293 XWINDOW (mini_window
)->prev
= root_window
;
294 XWINDOW (mini_window
)->mini
= 1;
295 XWINDOW (mini_window
)->frame
= frame
;
296 f
->minibuffer_window
= mini_window
;
301 XWINDOW (root_window
)->next
= Qnil
;
302 f
->minibuffer_window
= Qnil
;
305 XWINDOW (root_window
)->frame
= frame
;
308 just so that there is "something there."
309 Correct size will be set up later with change_frame_size. */
311 SET_FRAME_COLS (f
, 10);
312 FRAME_LINES (f
) = 10;
314 XSETFASTINT (XWINDOW (root_window
)->total_cols
, 10);
315 XSETFASTINT (XWINDOW (root_window
)->total_lines
, (mini_p
? 9 : 10));
319 XSETFASTINT (XWINDOW (mini_window
)->total_cols
, 10);
320 XSETFASTINT (XWINDOW (mini_window
)->top_line
, 9);
321 XSETFASTINT (XWINDOW (mini_window
)->total_lines
, 1);
324 /* Choose a buffer for the frame's root window. */
328 XWINDOW (root_window
)->buffer
= Qt
;
329 buf
= Fcurrent_buffer ();
330 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
331 a space), try to find another one. */
332 if (SREF (Fbuffer_name (buf
), 0) == ' ')
333 buf
= other_buffer_safely (buf
);
335 /* Use set_window_buffer, not Fset_window_buffer, and don't let
336 hooks be run by it. The reason is that the whole frame/window
337 arrangement is not yet fully initialized at this point. Windows
338 don't have the right size, glyph matrices aren't initialized
339 etc. Running Lisp functions at this point surely ends in a
341 set_window_buffer (root_window
, buf
, 0, 0);
342 f
->buffer_list
= Fcons (buf
, Qnil
);
347 XWINDOW (mini_window
)->buffer
= Qt
;
348 set_window_buffer (mini_window
,
349 (NILP (Vminibuffer_list
)
351 : Fcar (Vminibuffer_list
)),
355 f
->root_window
= root_window
;
356 f
->selected_window
= root_window
;
357 /* Make sure this window seems more recently used than
358 a newly-created, never-selected window. */
359 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
364 #ifdef HAVE_WINDOW_SYSTEM
365 /* Make a frame using a separate minibuffer window on another frame.
366 MINI_WINDOW is the minibuffer window to use. nil means use the
367 default (the global minibuffer). */
370 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
372 register struct frame
*f
;
375 if (!NILP (mini_window
))
376 CHECK_LIVE_WINDOW (mini_window
);
378 if (!NILP (mini_window
)
379 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
380 error ("Frame and minibuffer must be on the same terminal");
382 /* Make a frame containing just a root window. */
385 if (NILP (mini_window
))
387 /* Use default-minibuffer-frame if possible. */
388 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
389 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
391 Lisp_Object frame_dummy
;
393 XSETFRAME (frame_dummy
, f
);
394 GCPRO1 (frame_dummy
);
395 /* If there's no minibuffer frame to use, create one. */
396 KVAR (kb
, Vdefault_minibuffer_frame
) =
397 call1 (intern ("make-initial-minibuffer-frame"), display
);
401 mini_window
= XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
404 f
->minibuffer_window
= mini_window
;
406 /* Make the chosen minibuffer window display the proper minibuffer,
407 unless it is already showing a minibuffer. */
408 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
409 Fset_window_buffer (mini_window
,
410 (NILP (Vminibuffer_list
)
412 : Fcar (Vminibuffer_list
)), Qnil
);
416 /* Make a frame containing only a minibuffer window. */
419 make_minibuffer_frame (void)
421 /* First make a frame containing just a root window, no minibuffer. */
423 register struct frame
*f
= make_frame (0);
424 register Lisp_Object mini_window
;
425 register Lisp_Object frame
;
427 XSETFRAME (frame
, f
);
432 f
->wants_modeline
= 0;
433 f
->has_minibuffer
= 1;
435 /* Now label the root window as also being the minibuffer.
436 Avoid infinite looping on the window chain by marking next pointer
439 mini_window
= f
->minibuffer_window
= f
->root_window
;
440 XWINDOW (mini_window
)->mini
= 1;
441 XWINDOW (mini_window
)->next
= Qnil
;
442 XWINDOW (mini_window
)->prev
= Qnil
;
443 XWINDOW (mini_window
)->frame
= frame
;
445 /* Put the proper buffer in that window. */
447 Fset_window_buffer (mini_window
,
448 (NILP (Vminibuffer_list
)
450 : Fcar (Vminibuffer_list
)), Qnil
);
453 #endif /* HAVE_WINDOW_SYSTEM */
455 /* Construct a frame that refers to a terminal. */
457 static printmax_t tty_frame_count
;
460 make_initial_frame (void)
463 struct terminal
*terminal
;
466 eassert (initial_kboard
);
468 /* The first call must initialize Vframe_list. */
469 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
472 terminal
= init_initial_terminal ();
475 XSETFRAME (frame
, f
);
477 Vframe_list
= Fcons (frame
, Vframe_list
);
480 f
->name
= make_pure_c_string ("F1");
483 f
->async_visible
= 1;
485 f
->output_method
= terminal
->type
;
486 f
->terminal
= terminal
;
487 f
->terminal
->reference_count
++;
488 f
->output_data
.nothing
= 0;
490 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
491 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
493 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
494 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
496 /* The default value of menu-bar-mode is t. */
497 set_menu_bar_lines (f
, make_number (1), Qnil
);
500 init_frame_faces (f
);
506 static struct frame
*
507 make_terminal_frame (struct terminal
*terminal
)
509 register struct frame
*f
;
511 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
514 error ("Terminal is not live, can't create new frames on it");
518 XSETFRAME (frame
, f
);
519 Vframe_list
= Fcons (frame
, Vframe_list
);
522 sprintf (name
, "F%"pMd
, tty_frame_count
);
523 f
->name
= build_string (name
);
525 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
526 f
->async_visible
= 1; /* Don't let visible be cleared later. */
527 f
->terminal
= terminal
;
528 f
->terminal
->reference_count
++;
530 f
->output_data
.tty
->display_info
= &the_only_display_info
;
531 if (!inhibit_window_system
532 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
533 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
534 f
->output_method
= output_msdos_raw
;
536 f
->output_method
= output_termcap
;
537 #else /* not MSDOS */
538 f
->output_method
= output_termcap
;
539 create_tty_output (f
);
540 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
541 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
542 #endif /* not MSDOS */
544 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
545 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
546 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
548 /* Set the top frame to the newly created frame. */
549 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
550 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
551 XFRAME (FRAME_TTY (f
)->top_frame
)->async_visible
= 2; /* obscured */
553 FRAME_TTY (f
)->top_frame
= frame
;
556 init_frame_faces (f
);
561 /* Get a suitable value for frame parameter PARAMETER for a newly
562 created frame, based on (1) the user-supplied frame parameter
563 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
566 get_future_frame_param (Lisp_Object parameter
,
567 Lisp_Object supplied_parms
,
572 result
= Fassq (parameter
, supplied_parms
);
574 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
575 if (NILP (result
) && current_value
!= NULL
)
576 result
= build_string (current_value
);
577 if (!NILP (result
) && !STRINGP (result
))
578 result
= XCDR (result
);
579 if (NILP (result
) || !STRINGP (result
))
585 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
587 doc
: /* Create an additional terminal frame, possibly on another terminal.
588 This function takes one argument, an alist specifying frame parameters.
590 You can create multiple frames on a single text terminal, but only one
591 of them (the selected terminal frame) is actually displayed.
593 In practice, generally you don't need to specify any parameters,
594 except when you want to create a new frame on another terminal.
595 In that case, the `tty' parameter specifies the device file to open,
596 and the `tty-type' parameter specifies the terminal type. Example:
598 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
600 Note that changing the size of one terminal frame automatically
601 affects all frames on the same terminal device. */)
605 struct terminal
*t
= NULL
;
606 Lisp_Object frame
, tem
;
607 struct frame
*sf
= SELECTED_FRAME ();
610 if (sf
->output_method
!= output_msdos_raw
611 && sf
->output_method
!= output_termcap
)
613 #else /* not MSDOS */
615 #ifdef WINDOWSNT /* This should work now! */
616 if (sf
->output_method
!= output_termcap
)
617 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
619 #endif /* not MSDOS */
622 Lisp_Object terminal
;
624 terminal
= Fassq (Qterminal
, parms
);
625 if (!NILP (terminal
))
627 terminal
= XCDR (terminal
);
628 t
= get_terminal (terminal
, 1);
631 if (t
&& t
!= the_only_display_info
.terminal
)
632 /* msdos.c assumes a single tty_display_info object. */
633 error ("Multiple terminals are not supported on this platform");
635 t
= the_only_display_info
.terminal
;
641 char *name
= 0, *type
= 0;
642 Lisp_Object tty
, tty_type
;
644 tty
= get_future_frame_param
645 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
646 ? FRAME_TTY (XFRAME (selected_frame
))->name
650 name
= alloca (SBYTES (tty
) + 1);
651 strncpy (name
, SSDATA (tty
), SBYTES (tty
));
652 name
[SBYTES (tty
)] = 0;
655 tty_type
= get_future_frame_param
656 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
657 ? FRAME_TTY (XFRAME (selected_frame
))->type
659 if (!NILP (tty_type
))
661 type
= alloca (SBYTES (tty_type
) + 1);
662 strncpy (type
, SSDATA (tty_type
), SBYTES (tty_type
));
663 type
[SBYTES (tty_type
)] = 0;
666 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
669 f
= make_terminal_frame (t
);
673 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
674 change_frame_size (f
, height
, width
, 0, 0, 0);
679 XSETFRAME (frame
, f
);
680 Fmodify_frame_parameters (frame
, parms
);
681 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
682 build_string (t
->display_info
.tty
->type
)),
684 if (t
->display_info
.tty
->name
!= NULL
)
685 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
686 build_string (t
->display_info
.tty
->name
)),
689 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
691 /* Make the frame face alist be frame-specific, so that each
692 frame could change its face definitions independently. */
693 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
694 /* Simple Fcopy_alist isn't enough, because we need the contents of
695 the vectors which are the CDRs of associations in face_alist to
696 be copied as well. */
697 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
698 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
703 /* Perform the switch to frame FRAME.
705 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
708 If TRACK is non-zero and the frame that currently has the focus
709 redirects its focus to the selected frame, redirect that focused
710 frame's focus to FRAME instead.
712 FOR_DELETION non-zero means that the selected frame is being
713 deleted, which includes the possibility that the frame's terminal
716 The value of NORECORD is passed as argument to Fselect_window. */
719 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
721 struct frame
*sf
= SELECTED_FRAME ();
723 /* If FRAME is a switch-frame event, extract the frame we should
726 && EQ (XCAR (frame
), Qswitch_frame
)
727 && CONSP (XCDR (frame
)))
728 frame
= XCAR (XCDR (frame
));
730 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
731 a switch-frame event to arrive after a frame is no longer live,
732 especially when deleting the initial frame during startup. */
734 if (! FRAME_LIVE_P (XFRAME (frame
)))
737 if (sf
== XFRAME (frame
))
740 /* This is too greedy; it causes inappropriate focus redirection
741 that's hard to get rid of. */
743 /* If a frame's focus has been redirected toward the currently
744 selected frame, we should change the redirection to point to the
745 newly selected frame. This means that if the focus is redirected
746 from a minibufferless frame to a surrogate minibuffer frame, we
747 can use `other-window' to switch between all the frames using
748 that minibuffer frame, and the focus redirection will follow us
754 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
758 if (!FRAMEP (XCAR (tail
)))
761 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
763 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
764 Fredirect_frame_focus (XCAR (tail
), frame
);
768 /* Instead, apply it only to the frame we're pointing to. */
769 #ifdef HAVE_WINDOW_SYSTEM
770 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
772 Lisp_Object focus
, xfocus
;
774 xfocus
= x_get_focus_frame (XFRAME (frame
));
777 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
778 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
779 Fredirect_frame_focus (xfocus
, frame
);
782 #endif /* HAVE_X_WINDOWS */
785 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
786 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
788 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
790 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
791 /* Mark previously displayed frame as now obscured. */
792 XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
)->async_visible
= 2;
793 XFRAME (frame
)->async_visible
= 1;
794 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
797 selected_frame
= frame
;
798 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
799 last_nonminibuf_frame
= XFRAME (selected_frame
);
801 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
803 /* We want to make sure that the next event generates a frame-switch
804 event to the appropriate frame. This seems kludgy to me, but
805 before you take it out, make sure that evaluating something like
806 (select-window (frame-root-window (new-frame))) doesn't end up
807 with your typing being interpreted in the new frame instead of
808 the one you're actually typing in. */
809 internal_last_event_frame
= Qnil
;
814 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
815 doc
: /* Select FRAME.
816 Subsequent editing commands apply to its selected window.
817 Optional argument NORECORD means to neither change the order of
818 recently selected windows nor the buffer list.
820 The selection of FRAME lasts until the next time the user does
821 something to select a different frame, or until the next time
822 this function is called. If you are using a window system, the
823 previously selected frame may be restored as the selected frame
824 when returning to the command loop, because it still may have
825 the window system's input focus. On a text terminal, the next
826 redisplay will display FRAME.
828 This function returns FRAME, or nil if FRAME has been deleted. */)
829 (Lisp_Object frame
, Lisp_Object norecord
)
831 return do_switch_frame (frame
, 1, 0, norecord
);
835 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
836 doc
: /* Handle a switch-frame event EVENT.
837 Switch-frame events are usually bound to this function.
838 A switch-frame event tells Emacs that the window manager has requested
839 that the user's events be directed to the frame mentioned in the event.
840 This function selects the selected window of the frame of EVENT.
842 If EVENT is frame object, handle it as if it were a switch-frame event
846 /* Preserve prefix arg that the command loop just cleared. */
847 KVAR (current_kboard
, Vprefix_arg
) = Vcurrent_prefix_arg
;
848 Frun_hooks (1, &Qmouse_leave_buffer_hook
);
849 return do_switch_frame (event
, 0, 0, Qnil
);
852 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
853 doc
: /* Return the frame that is now selected. */)
856 return selected_frame
;
859 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
861 doc
: /* Return a list of all live frames. */)
865 frames
= Fcopy_sequence (Vframe_list
);
866 #ifdef HAVE_WINDOW_SYSTEM
867 if (FRAMEP (tip_frame
))
868 frames
= Fdelq (tip_frame
, frames
);
873 /* Return the next frame in the frame list after FRAME.
874 If MINIBUF is nil, exclude minibuffer-only frames.
875 If MINIBUF is a window, include only its own frame
876 and any frame now using that window as the minibuffer.
877 If MINIBUF is `visible', include all visible frames.
878 If MINIBUF is 0, include all visible and iconified frames.
879 Otherwise, include all frames. */
882 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
887 /* There must always be at least one frame in Vframe_list. */
888 if (! CONSP (Vframe_list
))
891 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
892 forever. Forestall that. */
893 CHECK_LIVE_FRAME (frame
);
896 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
903 && ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
904 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
905 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
906 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
)))))
908 /* Decide whether this frame is eligible to be returned. */
910 /* If we've looped all the way around without finding any
911 eligible frames, return the original frame. */
915 /* Let minibuf decide if this frame is acceptable. */
918 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
921 else if (EQ (minibuf
, Qvisible
))
923 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
924 if (FRAME_VISIBLE_P (XFRAME (f
)))
927 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
929 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
930 if (FRAME_VISIBLE_P (XFRAME (f
))
931 || FRAME_ICONIFIED_P (XFRAME (f
)))
934 else if (WINDOWP (minibuf
))
936 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
937 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
938 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
939 FRAME_FOCUS_FRAME (XFRAME (f
))))
951 /* Return the previous frame in the frame list before FRAME.
952 If MINIBUF is nil, exclude minibuffer-only frames.
953 If MINIBUF is a window, include only its own frame
954 and any frame now using that window as the minibuffer.
955 If MINIBUF is `visible', include all visible frames.
956 If MINIBUF is 0, include all visible and iconified frames.
957 Otherwise, include all frames. */
960 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
965 /* There must always be at least one frame in Vframe_list. */
966 if (! CONSP (Vframe_list
))
970 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
978 if (EQ (frame
, f
) && !NILP (prev
))
981 if ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
982 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
983 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
984 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
))))
986 /* Decide whether this frame is eligible to be returned,
987 according to minibuf. */
990 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
993 else if (WINDOWP (minibuf
))
995 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
996 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
997 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
998 FRAME_FOCUS_FRAME (XFRAME (f
))))
1001 else if (EQ (minibuf
, Qvisible
))
1003 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1004 if (FRAME_VISIBLE_P (XFRAME (f
)))
1007 else if (XFASTINT (minibuf
) == 0)
1009 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1010 if (FRAME_VISIBLE_P (XFRAME (f
))
1011 || FRAME_ICONIFIED_P (XFRAME (f
)))
1019 /* We've scanned the entire list. */
1021 /* We went through the whole frame list without finding a single
1022 acceptable frame. Return the original frame. */
1025 /* There were no acceptable frames in the list before FRAME; otherwise,
1026 we would have returned directly from the loop. Since PREV is the last
1027 acceptable frame in the list, return it. */
1032 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1033 doc
: /* Return the next frame in the frame list after FRAME.
1034 It considers only frames on the same terminal as FRAME.
1035 By default, skip minibuffer-only frames.
1036 If omitted, FRAME defaults to the selected frame.
1037 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1038 If MINIFRAME is a window, include only its own frame
1039 and any frame now using that window as the minibuffer.
1040 If MINIFRAME is `visible', include all visible frames.
1041 If MINIFRAME is 0, include all visible and iconified frames.
1042 Otherwise, include all frames. */)
1043 (Lisp_Object frame
, Lisp_Object miniframe
)
1046 frame
= selected_frame
;
1048 CHECK_LIVE_FRAME (frame
);
1049 return next_frame (frame
, miniframe
);
1052 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1053 doc
: /* Return the previous frame in the frame list before FRAME.
1054 It considers only frames on the same terminal as FRAME.
1055 By default, skip minibuffer-only frames.
1056 If omitted, FRAME defaults to the selected frame.
1057 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1058 If MINIFRAME is a window, include only its own frame
1059 and any frame now using that window as the minibuffer.
1060 If MINIFRAME is `visible', include all visible frames.
1061 If MINIFRAME is 0, include all visible and iconified frames.
1062 Otherwise, include all frames. */)
1063 (Lisp_Object frame
, Lisp_Object miniframe
)
1066 frame
= selected_frame
;
1067 CHECK_LIVE_FRAME (frame
);
1068 return prev_frame (frame
, miniframe
);
1071 /* Return 1 if it is ok to delete frame F;
1072 0 if all frames aside from F are invisible.
1073 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1076 other_visible_frames (FRAME_PTR f
)
1080 for (frames
= Vframe_list
; CONSP (frames
); frames
= XCDR (frames
))
1082 Lisp_Object
this = XCAR (frames
);
1083 if (f
== XFRAME (this))
1086 /* Verify that we can still talk to the frame's X window,
1087 and note any recent change in visibility. */
1088 #ifdef HAVE_WINDOW_SYSTEM
1089 if (FRAME_WINDOW_P (XFRAME (this)))
1091 x_sync (XFRAME (this));
1092 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1096 if (FRAME_VISIBLE_P (XFRAME (this))
1097 || FRAME_ICONIFIED_P (XFRAME (this))
1098 /* Allow deleting the terminal frame when at least one X
1100 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1106 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1107 unconditionally. x_connection_closed and delete_terminal use
1108 this. Any other value of FORCE implements the semantics
1109 described for Fdelete_frame. */
1111 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1114 struct frame
*sf
= SELECTED_FRAME ();
1117 int minibuffer_selected
, tooltip_frame
;
1119 if (EQ (frame
, Qnil
))
1122 XSETFRAME (frame
, f
);
1126 CHECK_FRAME (frame
);
1130 if (! FRAME_LIVE_P (f
))
1133 if (NILP (force
) && !other_visible_frames (f
))
1134 error ("Attempt to delete the sole visible or iconified frame");
1136 /* x_connection_closed must have set FORCE to `noelisp' in order
1137 to delete the last frame, if it is gone. */
1138 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1139 error ("Attempt to delete the only frame");
1141 /* Does this frame have a minibuffer, and is it the surrogate
1142 minibuffer for any other frame? */
1143 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1147 for (frames
= Vframe_list
;
1149 frames
= XCDR (frames
))
1152 this = XCAR (frames
);
1154 if (! EQ (this, frame
)
1156 WINDOW_FRAME (XWINDOW
1157 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1159 /* If we MUST delete this frame, delete the other first.
1160 But do this only if FORCE equals `noelisp'. */
1161 if (EQ (force
, Qnoelisp
))
1162 delete_frame (this, Qnoelisp
);
1164 error ("Attempt to delete a surrogate minibuffer frame");
1169 tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1171 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1172 frame is a tooltip. FORCE is set to `noelisp' when handling
1173 a disconnect from the terminal, so we don't dare call Lisp
1175 if (NILP (Vrun_hooks
) || tooltip_frame
)
1177 else if (EQ (force
, Qnoelisp
))
1179 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1183 #ifdef HAVE_X_WINDOWS
1184 /* Also, save clipboard to the clipboard manager. */
1185 x_clipboard_manager_save_frame (frame
);
1188 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1191 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1192 if (! FRAME_LIVE_P (f
))
1195 /* At this point, we are committed to deleting the frame.
1196 There is no more chance for errors to prevent it. */
1198 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1200 /* Don't let the frame remain selected. */
1203 Lisp_Object tail
, frame1
;
1205 /* Look for another visible frame on the same terminal. */
1206 frame1
= next_frame (frame
, Qvisible
);
1208 /* If there is none, find *some* other frame. */
1209 if (NILP (frame1
) || EQ (frame1
, frame
))
1211 FOR_EACH_FRAME (tail
, frame1
)
1213 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1215 /* Do not change a text terminal's top-frame. */
1216 struct frame
*f1
= XFRAME (frame1
);
1217 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1219 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1220 if (!EQ (top_frame
, frame
))
1227 #ifdef NS_IMPL_COCOA
1229 /* Under NS, there is no system mechanism for choosing a new
1230 window to get focus -- it is left to application code.
1231 So the portion of THIS application interfacing with NS
1232 needs to know about it. We call Fraise_frame, but the
1233 purpose is really to transfer focus. */
1234 Fraise_frame (frame1
);
1237 do_switch_frame (frame1
, 0, 1, Qnil
);
1238 sf
= SELECTED_FRAME ();
1241 /* Don't allow minibuf_window to remain on a deleted frame. */
1242 if (EQ (f
->minibuffer_window
, minibuf_window
))
1244 Fset_window_buffer (sf
->minibuffer_window
,
1245 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1246 minibuf_window
= sf
->minibuffer_window
;
1248 /* If the dying minibuffer window was selected,
1249 select the new one. */
1250 if (minibuffer_selected
)
1251 Fselect_window (minibuf_window
, Qnil
);
1254 /* Don't let echo_area_window to remain on a deleted frame. */
1255 if (EQ (f
->minibuffer_window
, echo_area_window
))
1256 echo_area_window
= sf
->minibuffer_window
;
1258 /* Clear any X selections for this frame. */
1259 #ifdef HAVE_X_WINDOWS
1261 x_clear_frame_selections (f
);
1265 This function must be called before the window tree of the
1266 frame is deleted because windows contain dynamically allocated
1270 #ifdef HAVE_WINDOW_SYSTEM
1271 /* Give chance to each font driver to free a frame specific data. */
1272 font_update_drivers (f
, Qnil
);
1275 /* Mark all the windows that used to be on FRAME as deleted, and then
1276 remove the reference to them. */
1277 delete_all_child_windows (f
->root_window
);
1278 f
->root_window
= Qnil
;
1280 Vframe_list
= Fdelq (frame
, Vframe_list
);
1281 FRAME_SET_VISIBLE (f
, 0);
1283 /* Allow the vector of menu bar contents to be freed in the next
1284 garbage collection. The frame object itself may not be garbage
1285 collected until much later, because recent_keys and other data
1286 structures can still refer to it. */
1287 f
->menu_bar_vector
= Qnil
;
1289 free_font_driver_list (f
);
1291 xfree (f
->decode_mode_spec_buffer
);
1292 xfree (FRAME_INSERT_COST (f
));
1293 xfree (FRAME_DELETEN_COST (f
));
1294 xfree (FRAME_INSERTN_COST (f
));
1295 xfree (FRAME_DELETE_COST (f
));
1296 xfree (FRAME_MESSAGE_BUF (f
));
1298 /* Since some events are handled at the interrupt level, we may get
1299 an event for f at any time; if we zero out the frame's terminal
1300 now, then we may trip up the event-handling code. Instead, we'll
1301 promise that the terminal of the frame must be valid until we
1302 have called the window-system-dependent frame destruction
1305 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1306 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1309 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1310 f
->output_data
.nothing
= 0;
1311 f
->terminal
= 0; /* Now the frame is dead. */
1313 /* If needed, delete the terminal that this frame was on.
1314 (This must be done after the frame is killed.) */
1315 terminal
->reference_count
--;
1317 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1319 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1320 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1321 terminal
->reference_count
= 1;
1322 #endif /* USE_GTK */
1323 if (terminal
->reference_count
== 0)
1326 XSETTERMINAL (tmp
, terminal
);
1329 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1332 kb
= terminal
->kboard
;
1335 /* If we've deleted the last_nonminibuf_frame, then try to find
1337 if (f
== last_nonminibuf_frame
)
1341 last_nonminibuf_frame
= 0;
1343 for (frames
= Vframe_list
;
1345 frames
= XCDR (frames
))
1347 f
= XFRAME (XCAR (frames
));
1348 if (!FRAME_MINIBUF_ONLY_P (f
))
1350 last_nonminibuf_frame
= f
;
1356 /* If there's no other frame on the same kboard, get out of
1357 single-kboard state if we're in it for this kboard. */
1361 /* Some frame we found on the same kboard, or nil if there are none. */
1362 Lisp_Object frame_on_same_kboard
;
1364 frame_on_same_kboard
= Qnil
;
1366 for (frames
= Vframe_list
;
1368 frames
= XCDR (frames
))
1373 this = XCAR (frames
);
1378 if (kb
== FRAME_KBOARD (f1
))
1379 frame_on_same_kboard
= this;
1382 if (NILP (frame_on_same_kboard
))
1383 not_single_kboard_state (kb
);
1387 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1388 find another one. Prefer minibuffer-only frames, but also notice
1389 frames with other windows. */
1390 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1394 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1395 Lisp_Object frame_with_minibuf
;
1396 /* Some frame we found on the same kboard, or nil if there are none. */
1397 Lisp_Object frame_on_same_kboard
;
1399 frame_on_same_kboard
= Qnil
;
1400 frame_with_minibuf
= Qnil
;
1402 for (frames
= Vframe_list
;
1404 frames
= XCDR (frames
))
1409 this = XCAR (frames
);
1414 /* Consider only frames on the same kboard
1415 and only those with minibuffers. */
1416 if (kb
== FRAME_KBOARD (f1
)
1417 && FRAME_HAS_MINIBUF_P (f1
))
1419 frame_with_minibuf
= this;
1420 if (FRAME_MINIBUF_ONLY_P (f1
))
1424 if (kb
== FRAME_KBOARD (f1
))
1425 frame_on_same_kboard
= this;
1428 if (!NILP (frame_on_same_kboard
))
1430 /* We know that there must be some frame with a minibuffer out
1431 there. If this were not true, all of the frames present
1432 would have to be minibufferless, which implies that at some
1433 point their minibuffer frames must have been deleted, but
1434 that is prohibited at the top; you can't delete surrogate
1435 minibuffer frames. */
1436 if (NILP (frame_with_minibuf
))
1439 KVAR (kb
, Vdefault_minibuffer_frame
) = frame_with_minibuf
;
1442 /* No frames left on this kboard--say no minibuffer either. */
1443 KVAR (kb
, Vdefault_minibuffer_frame
) = Qnil
;
1446 /* Cause frame titles to update--necessary if we now have just one frame. */
1448 update_mode_lines
= 1;
1453 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1454 doc
: /* Delete FRAME, permanently eliminating it from use.
1455 FRAME defaults to the selected frame.
1457 A frame may not be deleted if its minibuffer is used by other frames.
1458 Normally, you may not delete a frame if all other frames are invisible,
1459 but if the second optional argument FORCE is non-nil, you may do so.
1461 This function runs `delete-frame-functions' before actually
1462 deleting the frame, unless the frame is a tooltip.
1463 The functions are run with one argument, the frame to be deleted. */)
1464 (Lisp_Object frame
, Lisp_Object force
)
1466 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1470 /* Return mouse position in character cell units. */
1472 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1473 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1474 The position is given in character cells, where (0, 0) is the
1475 upper-left corner of the frame, X is the horizontal offset, and Y is
1476 the vertical offset.
1477 If Emacs is running on a mouseless terminal or hasn't been programmed
1478 to read the mouse position, it returns the selected frame for FRAME
1479 and nil for X and Y.
1480 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1481 passing the normal return value to that function as an argument,
1482 and returns whatever that function returns. */)
1486 Lisp_Object lispy_dummy
;
1487 enum scroll_bar_part party_dummy
;
1488 Lisp_Object x
, y
, retval
;
1491 struct gcpro gcpro1
;
1493 f
= SELECTED_FRAME ();
1496 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1497 /* It's okay for the hook to refrain from storing anything. */
1498 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1499 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1500 &lispy_dummy
, &party_dummy
,
1507 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1512 XSETFRAME (lispy_dummy
, f
);
1513 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1515 if (!NILP (Vmouse_position_function
))
1516 retval
= call1 (Vmouse_position_function
, retval
);
1517 RETURN_UNGCPRO (retval
);
1520 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1521 Smouse_pixel_position
, 0, 0, 0,
1522 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1523 The position is given in pixel units, where (0, 0) is the
1524 upper-left corner of the frame, X is the horizontal offset, and Y is
1525 the vertical offset.
1526 If Emacs is running on a mouseless terminal or hasn't been programmed
1527 to read the mouse position, it returns the selected frame for FRAME
1528 and nil for X and Y. */)
1532 Lisp_Object lispy_dummy
;
1533 enum scroll_bar_part party_dummy
;
1537 f
= SELECTED_FRAME ();
1540 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1541 /* It's okay for the hook to refrain from storing anything. */
1542 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1543 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1544 &lispy_dummy
, &party_dummy
,
1548 XSETFRAME (lispy_dummy
, f
);
1549 return Fcons (lispy_dummy
, Fcons (x
, y
));
1552 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1553 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1554 Coordinates are relative to the frame, not a window,
1555 so the coordinates of the top left character in the frame
1556 may be nonzero due to left-hand scroll bars or the menu bar.
1558 The position is given in character cells, where (0, 0) is the
1559 upper-left corner of the frame, X is the horizontal offset, and Y is
1560 the vertical offset.
1562 This function is a no-op for an X frame that is not visible.
1563 If you have just created a frame, you must wait for it to become visible
1564 before calling this function on it, like this.
1565 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1566 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1568 CHECK_LIVE_FRAME (frame
);
1569 CHECK_TYPE_RANGED_INTEGER (int, x
);
1570 CHECK_TYPE_RANGED_INTEGER (int, y
);
1572 /* I think this should be done with a hook. */
1573 #ifdef HAVE_WINDOW_SYSTEM
1574 if (FRAME_WINDOW_P (XFRAME (frame
)))
1575 /* Warping the mouse will cause enternotify and focus events. */
1576 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1578 #if defined (MSDOS) && defined (HAVE_MOUSE)
1579 if (FRAME_MSDOS_P (XFRAME (frame
)))
1581 Fselect_frame (frame
, Qnil
);
1582 mouse_moveto (XINT (x
), XINT (y
));
1587 Fselect_frame (frame
, Qnil
);
1588 term_mouse_moveto (XINT (x
), XINT (y
));
1597 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1598 Sset_mouse_pixel_position
, 3, 3, 0,
1599 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1600 The position is given in pixels, where (0, 0) is the upper-left corner
1601 of the frame, X is the horizontal offset, and Y is the vertical offset.
1603 Note, this is a no-op for an X frame that is not visible.
1604 If you have just created a frame, you must wait for it to become visible
1605 before calling this function on it, like this.
1606 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1607 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1609 CHECK_LIVE_FRAME (frame
);
1610 CHECK_TYPE_RANGED_INTEGER (int, x
);
1611 CHECK_TYPE_RANGED_INTEGER (int, y
);
1613 /* I think this should be done with a hook. */
1614 #ifdef HAVE_WINDOW_SYSTEM
1615 if (FRAME_WINDOW_P (XFRAME (frame
)))
1616 /* Warping the mouse will cause enternotify and focus events. */
1617 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1619 #if defined (MSDOS) && defined (HAVE_MOUSE)
1620 if (FRAME_MSDOS_P (XFRAME (frame
)))
1622 Fselect_frame (frame
, Qnil
);
1623 mouse_moveto (XINT (x
), XINT (y
));
1628 Fselect_frame (frame
, Qnil
);
1629 term_mouse_moveto (XINT (x
), XINT (y
));
1638 static void make_frame_visible_1 (Lisp_Object
);
1640 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1642 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1643 If omitted, FRAME defaults to the currently selected frame. */)
1647 frame
= selected_frame
;
1649 CHECK_LIVE_FRAME (frame
);
1651 /* I think this should be done with a hook. */
1652 #ifdef HAVE_WINDOW_SYSTEM
1653 if (FRAME_WINDOW_P (XFRAME (frame
)))
1655 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1656 x_make_frame_visible (XFRAME (frame
));
1660 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1662 /* Make menu bar update for the Buffers and Frames menus. */
1663 windows_or_buffers_changed
++;
1668 /* Update the display_time slot of the buffers shown in WINDOW
1669 and all its descendants. */
1672 make_frame_visible_1 (Lisp_Object window
)
1676 for (;!NILP (window
); window
= w
->next
)
1678 w
= XWINDOW (window
);
1680 if (!NILP (w
->buffer
))
1681 BVAR (XBUFFER (w
->buffer
), display_time
) = Fcurrent_time ();
1683 if (!NILP (w
->vchild
))
1684 make_frame_visible_1 (w
->vchild
);
1685 if (!NILP (w
->hchild
))
1686 make_frame_visible_1 (w
->hchild
);
1690 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1692 doc
: /* Make the frame FRAME invisible.
1693 If omitted, FRAME defaults to the currently selected frame.
1694 On graphical displays, invisible frames are not updated and are
1695 usually not displayed at all, even in a window system's \"taskbar\".
1697 Normally you may not make FRAME invisible if all other frames are invisible,
1698 but if the second optional argument FORCE is non-nil, you may do so.
1700 This function has no effect on text terminal frames. Such frames are
1701 always considered visible, whether or not they are currently being
1702 displayed in the terminal. */)
1703 (Lisp_Object frame
, Lisp_Object force
)
1706 frame
= selected_frame
;
1708 CHECK_LIVE_FRAME (frame
);
1710 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1711 error ("Attempt to make invisible the sole visible or iconified frame");
1713 /* Don't allow minibuf_window to remain on a deleted frame. */
1714 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1716 struct frame
*sf
= XFRAME (selected_frame
);
1717 Fset_window_buffer (sf
->minibuffer_window
,
1718 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1719 minibuf_window
= sf
->minibuffer_window
;
1722 /* I think this should be done with a hook. */
1723 #ifdef HAVE_WINDOW_SYSTEM
1724 if (FRAME_WINDOW_P (XFRAME (frame
)))
1725 x_make_frame_invisible (XFRAME (frame
));
1728 /* Make menu bar update for the Buffers and Frames menus. */
1729 windows_or_buffers_changed
++;
1734 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1736 doc
: /* Make the frame FRAME into an icon.
1737 If omitted, FRAME defaults to the currently selected frame. */)
1741 frame
= selected_frame
;
1743 CHECK_LIVE_FRAME (frame
);
1745 #if 0 /* This isn't logically necessary, and it can do GC. */
1746 /* Don't let the frame remain selected. */
1747 if (EQ (frame
, selected_frame
))
1748 Fhandle_switch_frame (next_frame (frame
, Qt
));
1751 /* Don't allow minibuf_window to remain on a deleted frame. */
1752 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1754 struct frame
*sf
= XFRAME (selected_frame
);
1755 Fset_window_buffer (sf
->minibuffer_window
,
1756 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1757 minibuf_window
= sf
->minibuffer_window
;
1760 /* I think this should be done with a hook. */
1761 #ifdef HAVE_WINDOW_SYSTEM
1762 if (FRAME_WINDOW_P (XFRAME (frame
)))
1763 x_iconify_frame (XFRAME (frame
));
1766 /* Make menu bar update for the Buffers and Frames menus. */
1767 windows_or_buffers_changed
++;
1772 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1774 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1775 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1776 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1777 On graphical displays, invisible frames are not updated and are
1778 usually not displayed at all, even in a window system's \"taskbar\".
1780 If FRAME is a text terminal frame, this always returns t.
1781 Such frames are always considered visible, whether or not they are
1782 currently being displayed on the terminal. */)
1785 CHECK_LIVE_FRAME (frame
);
1787 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1789 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1791 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1796 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1798 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1801 Lisp_Object tail
, frame
;
1806 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1808 frame
= XCAR (tail
);
1809 if (!FRAMEP (frame
))
1812 if (FRAME_VISIBLE_P (f
))
1813 value
= Fcons (frame
, value
);
1819 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1820 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1821 If FRAME is invisible or iconified, make it visible.
1822 If you don't specify a frame, the selected frame is used.
1823 If Emacs is displaying on an ordinary terminal or some other device which
1824 doesn't support multiple overlapping frames, this function selects FRAME. */)
1829 frame
= selected_frame
;
1831 CHECK_LIVE_FRAME (frame
);
1835 if (FRAME_TERMCAP_P (f
))
1836 /* On a text terminal select FRAME. */
1837 Fselect_frame (frame
, Qnil
);
1839 /* Do like the documentation says. */
1840 Fmake_frame_visible (frame
);
1842 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1843 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
1848 /* Should we have a corresponding function called Flower_Power? */
1849 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1850 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1851 If you don't specify a frame, the selected frame is used.
1852 If Emacs is displaying on an ordinary terminal or some other device which
1853 doesn't support multiple overlapping frames, this function does nothing. */)
1859 frame
= selected_frame
;
1861 CHECK_LIVE_FRAME (frame
);
1865 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1866 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
1872 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1874 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1875 In other words, switch-frame events caused by events in FRAME will
1876 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1877 FOCUS-FRAME after reading an event typed at FRAME.
1879 If FOCUS-FRAME is omitted or nil, any existing redirection is
1880 canceled, and the frame again receives its own keystrokes.
1882 Focus redirection is useful for temporarily redirecting keystrokes to
1883 a surrogate minibuffer frame when a frame doesn't have its own
1886 A frame's focus redirection can be changed by `select-frame'. If frame
1887 FOO is selected, and then a different frame BAR is selected, any
1888 frames redirecting their focus to FOO are shifted to redirect their
1889 focus to BAR. This allows focus redirection to work properly when the
1890 user switches from one frame to another using `select-window'.
1892 This means that a frame whose focus is redirected to itself is treated
1893 differently from a frame whose focus is redirected to nil; the former
1894 is affected by `select-frame', while the latter is not.
1896 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1897 (Lisp_Object frame
, Lisp_Object focus_frame
)
1901 /* Note that we don't check for a live frame here. It's reasonable
1902 to redirect the focus of a frame you're about to delete, if you
1903 know what other frame should receive those keystrokes. */
1904 CHECK_FRAME (frame
);
1906 if (! NILP (focus_frame
))
1907 CHECK_LIVE_FRAME (focus_frame
);
1911 f
->focus_frame
= focus_frame
;
1913 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
1914 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
1920 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1921 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1922 This returns nil if FRAME's focus is not redirected.
1923 See `redirect-frame-focus'. */)
1926 CHECK_LIVE_FRAME (frame
);
1928 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1933 /* Return the value of frame parameter PROP in frame FRAME. */
1935 #ifdef HAVE_WINDOW_SYSTEM
1940 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
1942 register Lisp_Object tem
;
1944 tem
= Fassq (prop
, frame
->param_alist
);
1951 /* Return the buffer-predicate of the selected frame. */
1954 frame_buffer_predicate (Lisp_Object frame
)
1956 return XFRAME (frame
)->buffer_predicate
;
1959 /* Return the buffer-list of the selected frame. */
1962 frame_buffer_list (Lisp_Object frame
)
1964 return XFRAME (frame
)->buffer_list
;
1967 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
1970 frames_discard_buffer (Lisp_Object buffer
)
1972 Lisp_Object frame
, tail
;
1974 FOR_EACH_FRAME (tail
, frame
)
1976 XFRAME (frame
)->buffer_list
1977 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1978 XFRAME (frame
)->buried_buffer_list
1979 = Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
);
1983 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1984 If the alist already has an element for PROP, we change it. */
1987 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
1989 register Lisp_Object tem
;
1991 tem
= Fassq (prop
, *alistptr
);
1993 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1999 frame_name_fnn_p (char *str
, ptrdiff_t len
)
2001 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
2004 while ('0' <= *p
&& *p
<= '9')
2012 /* Set the name of the terminal frame. Also used by MSDOS frames.
2013 Modeled after x_set_name which is used for WINDOW frames. */
2016 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2018 f
->explicit_name
= ! NILP (name
);
2020 /* If NAME is nil, set the name to F<num>. */
2023 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
2025 /* Check for no change needed in this very common case
2026 before we do any consing. */
2027 if (frame_name_fnn_p (SSDATA (f
->name
),
2032 sprintf (namebuf
, "F%"pMd
, tty_frame_count
);
2033 name
= build_string (namebuf
);
2037 CHECK_STRING (name
);
2039 /* Don't change the name if it's already NAME. */
2040 if (! NILP (Fstring_equal (name
, f
->name
)))
2043 /* Don't allow the user to set the frame name to F<num>, so it
2044 doesn't clash with the names we generate for terminal frames. */
2045 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2046 error ("Frame names of the form F<num> are usurped by Emacs");
2050 update_mode_lines
= 1;
2054 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2056 register Lisp_Object old_alist_elt
;
2058 /* The buffer-list parameters are stored in a special place and not
2059 in the alist. All buffers must be live. */
2060 if (EQ (prop
, Qbuffer_list
))
2062 Lisp_Object list
= Qnil
;
2063 for (; CONSP (val
); val
= XCDR (val
))
2064 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2065 list
= Fcons (XCAR (val
), list
);
2066 f
->buffer_list
= Fnreverse (list
);
2069 if (EQ (prop
, Qburied_buffer_list
))
2071 Lisp_Object list
= Qnil
;
2072 for (; CONSP (val
); val
= XCDR (val
))
2073 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2074 list
= Fcons (XCAR (val
), list
);
2075 f
->buried_buffer_list
= Fnreverse (list
);
2079 /* If PROP is a symbol which is supposed to have frame-local values,
2080 and it is set up based on this frame, switch to the global
2081 binding. That way, we can create or alter the frame-local binding
2082 without messing up the symbol's status. */
2085 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2087 switch (sym
->redirect
)
2089 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2090 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2091 case SYMBOL_LOCALIZED
:
2092 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2093 if (blv
->frame_local
&& BLV_FOUND (blv
) && XFRAME (blv
->where
) == f
)
2094 swap_in_global_binding (sym
);
2101 /* The tty color needed to be set before the frame's parameter
2102 alist was updated with the new value. This is not true any more,
2103 but we still do this test early on. */
2104 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2105 && f
== FRAME_TTY (f
)->previous_frame
)
2106 /* Force redisplay of this tty. */
2107 FRAME_TTY (f
)->previous_frame
= NULL
;
2109 /* Update the frame parameter alist. */
2110 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2111 if (EQ (old_alist_elt
, Qnil
))
2112 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2114 Fsetcdr (old_alist_elt
, val
);
2116 /* Update some other special parameters in their special places
2117 in addition to the alist. */
2119 if (EQ (prop
, Qbuffer_predicate
))
2120 f
->buffer_predicate
= val
;
2122 if (! FRAME_WINDOW_P (f
))
2124 if (EQ (prop
, Qmenu_bar_lines
))
2125 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2126 else if (EQ (prop
, Qname
))
2127 set_term_frame_name (f
, val
);
2130 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2132 if (! MINI_WINDOW_P (XWINDOW (val
)))
2133 error ("Surrogate minibuffer windows must be minibuffer windows");
2135 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2136 && !EQ (val
, f
->minibuffer_window
))
2137 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2139 /* Install the chosen minibuffer window, with proper buffer. */
2140 f
->minibuffer_window
= val
;
2144 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2145 doc
: /* Return the parameters-alist of frame FRAME.
2146 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2147 The meaningful PARMs depend on the kind of frame.
2148 If FRAME is omitted, return information on the currently selected frame. */)
2154 struct gcpro gcpro1
;
2157 frame
= selected_frame
;
2159 CHECK_FRAME (frame
);
2162 if (!FRAME_LIVE_P (f
))
2165 alist
= Fcopy_alist (f
->param_alist
);
2168 if (!FRAME_WINDOW_P (f
))
2170 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2171 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2174 /* If the frame's parameter alist says the colors are
2175 unspecified and reversed, take the frame's background pixel
2176 for foreground and vice versa. */
2177 elt
= Fassq (Qforeground_color
, alist
);
2178 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2180 if (strncmp (SSDATA (XCDR (elt
)),
2182 SCHARS (XCDR (elt
))) == 0)
2183 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2184 else if (strncmp (SSDATA (XCDR (elt
)),
2186 SCHARS (XCDR (elt
))) == 0)
2187 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2190 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2191 elt
= Fassq (Qbackground_color
, alist
);
2192 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2194 if (strncmp (SSDATA (XCDR (elt
)),
2196 SCHARS (XCDR (elt
))) == 0)
2197 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2198 else if (strncmp (SSDATA (XCDR (elt
)),
2200 SCHARS (XCDR (elt
))) == 0)
2201 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2204 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2205 store_in_alist (&alist
, intern ("font"),
2206 build_string (FRAME_MSDOS_P (f
)
2208 : FRAME_W32_P (f
) ? "w32term"
2211 store_in_alist (&alist
, Qname
, f
->name
);
2212 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2213 store_in_alist (&alist
, Qheight
, make_number (height
));
2214 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2215 store_in_alist (&alist
, Qwidth
, make_number (width
));
2216 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2217 store_in_alist (&alist
, Qminibuffer
,
2218 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2219 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2220 : FRAME_MINIBUF_WINDOW (f
)));
2221 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2222 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2223 store_in_alist (&alist
, Qburied_buffer_list
, XFRAME (frame
)->buried_buffer_list
);
2225 /* I think this should be done with a hook. */
2226 #ifdef HAVE_WINDOW_SYSTEM
2227 if (FRAME_WINDOW_P (f
))
2228 x_report_frame_params (f
, &alist
);
2232 /* This ought to be correct in f->param_alist for an X frame. */
2234 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2235 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2243 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2244 doc
: /* Return FRAME's value for parameter PARAMETER.
2245 If FRAME is nil, describe the currently selected frame. */)
2246 (Lisp_Object frame
, Lisp_Object parameter
)
2252 frame
= selected_frame
;
2254 CHECK_FRAME (frame
);
2255 CHECK_SYMBOL (parameter
);
2260 if (FRAME_LIVE_P (f
))
2262 /* Avoid consing in frequent cases. */
2263 if (EQ (parameter
, Qname
))
2265 #ifdef HAVE_X_WINDOWS
2266 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2267 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2268 #endif /* HAVE_X_WINDOWS */
2269 else if (EQ (parameter
, Qbackground_color
)
2270 || EQ (parameter
, Qforeground_color
))
2272 value
= Fassq (parameter
, f
->param_alist
);
2275 value
= XCDR (value
);
2276 /* Fframe_parameters puts the actual fg/bg color names,
2277 even if f->param_alist says otherwise. This is
2278 important when param_alist's notion of colors is
2279 "unspecified". We need to do the same here. */
2280 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2282 const char *color_name
;
2285 if (EQ (parameter
, Qbackground_color
))
2287 color_name
= SSDATA (value
);
2288 csz
= SCHARS (value
);
2289 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2290 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2291 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2292 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2294 else if (EQ (parameter
, Qforeground_color
))
2296 color_name
= SSDATA (value
);
2297 csz
= SCHARS (value
);
2298 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2299 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2300 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2301 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2306 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2308 else if (EQ (parameter
, Qdisplay_type
)
2309 || EQ (parameter
, Qbackground_mode
))
2310 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2312 /* FIXME: Avoid this code path at all (as well as code duplication)
2313 by sharing more code with Fframe_parameters. */
2314 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2321 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2322 Smodify_frame_parameters
, 2, 2, 0,
2323 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2324 If FRAME is nil, it defaults to the selected frame.
2325 ALIST is an alist of parameters to change and their new values.
2326 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2327 The meaningful PARMs depend on the kind of frame.
2328 Undefined PARMs are ignored, but stored in the frame's parameter list
2329 so that `frame-parameters' will return them.
2331 The value of frame parameter FOO can also be accessed
2332 as a frame-local binding for the variable FOO, if you have
2333 enabled such bindings for that variable with `make-variable-frame-local'.
2334 Note that this functionality is obsolete as of Emacs 22.2, and its
2335 use is not recommended. Explicitly check for a frame-parameter instead. */)
2336 (Lisp_Object frame
, Lisp_Object alist
)
2339 register Lisp_Object tail
, prop
, val
;
2341 if (EQ (frame
, Qnil
))
2342 frame
= selected_frame
;
2343 CHECK_LIVE_FRAME (frame
);
2346 /* I think this should be done with a hook. */
2347 #ifdef HAVE_WINDOW_SYSTEM
2348 if (FRAME_WINDOW_P (f
))
2349 x_set_frame_parameters (f
, alist
);
2353 if (FRAME_MSDOS_P (f
))
2354 IT_set_frame_parameters (f
, alist
);
2359 EMACS_INT length
= XFASTINT (Flength (alist
));
2362 Lisp_Object
*values
;
2364 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2365 values
= parms
+ length
;
2367 /* Extract parm names and values into those vectors. */
2370 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2375 parms
[i
] = Fcar (elt
);
2376 values
[i
] = Fcdr (elt
);
2380 /* Now process them in reverse of specified order. */
2385 store_frame_param (f
, prop
, val
);
2387 if (EQ (prop
, Qforeground_color
)
2388 || EQ (prop
, Qbackground_color
))
2389 update_face_from_frame_parameter (f
, prop
, val
);
2397 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2399 doc
: /* Height in pixels of a line in the font in frame FRAME.
2400 If FRAME is omitted, the selected frame is used.
2401 For a terminal frame, the value is always 1. */)
2407 frame
= selected_frame
;
2408 CHECK_FRAME (frame
);
2411 #ifdef HAVE_WINDOW_SYSTEM
2412 if (FRAME_WINDOW_P (f
))
2413 return make_number (x_char_height (f
));
2416 return make_number (1);
2420 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2422 doc
: /* Width in pixels of characters in the font in frame FRAME.
2423 If FRAME is omitted, the selected frame is used.
2424 On a graphical screen, the width is the standard width of the default font.
2425 For a terminal screen, the value is always 1. */)
2431 frame
= selected_frame
;
2432 CHECK_FRAME (frame
);
2435 #ifdef HAVE_WINDOW_SYSTEM
2436 if (FRAME_WINDOW_P (f
))
2437 return make_number (x_char_width (f
));
2440 return make_number (1);
2443 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2444 Sframe_pixel_height
, 0, 1, 0,
2445 doc
: /* Return a FRAME's height in pixels.
2446 If FRAME is omitted, the selected frame is used. The exact value
2447 of the result depends on the window-system and toolkit in use:
2449 In the Gtk+ version of Emacs, it includes only any window (including
2450 the minibuffer or echo area), mode line, and header line. It does not
2451 include the tool bar or menu bar.
2453 With the Motif or Lucid toolkits, it also includes the tool bar (but
2456 In a graphical version with no toolkit, it includes both the tool bar
2459 For a text terminal, it includes the menu bar. In this case, the
2460 result is really in characters rather than pixels (i.e., is identical
2461 to `frame-height'). */)
2467 frame
= selected_frame
;
2468 CHECK_FRAME (frame
);
2471 #ifdef HAVE_WINDOW_SYSTEM
2472 if (FRAME_WINDOW_P (f
))
2473 return make_number (x_pixel_height (f
));
2476 return make_number (FRAME_LINES (f
));
2479 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2480 Sframe_pixel_width
, 0, 1, 0,
2481 doc
: /* Return FRAME's width in pixels.
2482 For a terminal frame, the result really gives the width in characters.
2483 If FRAME is omitted, the selected frame is used. */)
2489 frame
= selected_frame
;
2490 CHECK_FRAME (frame
);
2493 #ifdef HAVE_WINDOW_SYSTEM
2494 if (FRAME_WINDOW_P (f
))
2495 return make_number (x_pixel_width (f
));
2498 return make_number (FRAME_COLS (f
));
2501 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2502 Stool_bar_pixel_width
, 0, 1, 0,
2503 doc
: /* Return width in pixels of FRAME's tool bar.
2504 The result is greater than zero only when the tool bar is on the left
2505 or right side of FRAME. If FRAME is omitted, the selected frame is
2510 frame
= selected_frame
;
2511 CHECK_FRAME (frame
);
2513 #ifdef FRAME_TOOLBAR_WIDTH
2514 if (FRAME_WINDOW_P (XFRAME (frame
)))
2515 return make_number (FRAME_TOOLBAR_WIDTH (XFRAME (frame
)));
2517 return make_number (0);
2520 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2521 doc
: /* Specify that the frame FRAME has LINES lines.
2522 Optional third arg non-nil means that redisplay should use LINES lines
2523 but that the idea of the actual height of the frame should not be changed. */)
2524 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2526 register struct frame
*f
;
2528 CHECK_TYPE_RANGED_INTEGER (int, lines
);
2530 frame
= selected_frame
;
2531 CHECK_LIVE_FRAME (frame
);
2534 /* I think this should be done with a hook. */
2535 #ifdef HAVE_WINDOW_SYSTEM
2536 if (FRAME_WINDOW_P (f
))
2538 if (XINT (lines
) != FRAME_LINES (f
))
2539 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2540 do_pending_window_change (0);
2544 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2548 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2549 doc
: /* Specify that the frame FRAME has COLS columns.
2550 Optional third arg non-nil means that redisplay should use COLS columns
2551 but that the idea of the actual width of the frame should not be changed. */)
2552 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2554 register struct frame
*f
;
2555 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2557 frame
= selected_frame
;
2558 CHECK_LIVE_FRAME (frame
);
2561 /* I think this should be done with a hook. */
2562 #ifdef HAVE_WINDOW_SYSTEM
2563 if (FRAME_WINDOW_P (f
))
2565 if (XINT (cols
) != FRAME_COLS (f
))
2566 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2567 do_pending_window_change (0);
2571 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2575 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2576 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2577 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2579 register struct frame
*f
;
2581 CHECK_LIVE_FRAME (frame
);
2582 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2583 CHECK_TYPE_RANGED_INTEGER (int, rows
);
2586 /* I think this should be done with a hook. */
2587 #ifdef HAVE_WINDOW_SYSTEM
2588 if (FRAME_WINDOW_P (f
))
2590 if (XINT (rows
) != FRAME_LINES (f
)
2591 || XINT (cols
) != FRAME_COLS (f
)
2592 || f
->new_text_lines
|| f
->new_text_cols
)
2593 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2594 do_pending_window_change (0);
2598 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2603 DEFUN ("set-frame-position", Fset_frame_position
,
2604 Sset_frame_position
, 3, 3, 0,
2605 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2606 This is actually the position of the upper left corner of the frame.
2607 Negative values for XOFFSET or YOFFSET are interpreted relative to
2608 the rightmost or bottommost possible position (that stays within the screen). */)
2609 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2611 register struct frame
*f
;
2613 CHECK_LIVE_FRAME (frame
);
2614 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2615 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2618 /* I think this should be done with a hook. */
2619 #ifdef HAVE_WINDOW_SYSTEM
2620 if (FRAME_WINDOW_P (f
))
2621 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2628 /***********************************************************************
2630 ***********************************************************************/
2632 /* Connect the frame-parameter names for X frames
2633 to the ways of passing the parameter values to the window system.
2635 The name of a parameter, as a Lisp symbol,
2636 has an `x-frame-parameter' property which is an integer in Lisp
2637 that is an index in this table. */
2639 struct frame_parm_table
{
2641 Lisp_Object
*variable
;
2644 static const struct frame_parm_table frame_parms
[] =
2646 {"auto-raise", &Qauto_raise
},
2647 {"auto-lower", &Qauto_lower
},
2648 {"background-color", 0},
2649 {"border-color", &Qborder_color
},
2650 {"border-width", &Qborder_width
},
2651 {"cursor-color", &Qcursor_color
},
2652 {"cursor-type", &Qcursor_type
},
2654 {"foreground-color", 0},
2655 {"icon-name", &Qicon_name
},
2656 {"icon-type", &Qicon_type
},
2657 {"internal-border-width", &Qinternal_border_width
},
2658 {"menu-bar-lines", &Qmenu_bar_lines
},
2659 {"mouse-color", &Qmouse_color
},
2661 {"scroll-bar-width", &Qscroll_bar_width
},
2663 {"unsplittable", &Qunsplittable
},
2664 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2665 {"visibility", &Qvisibility
},
2666 {"tool-bar-lines", &Qtool_bar_lines
},
2667 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2668 {"scroll-bar-background", &Qscroll_bar_background
},
2669 {"screen-gamma", &Qscreen_gamma
},
2670 {"line-spacing", &Qline_spacing
},
2671 {"left-fringe", &Qleft_fringe
},
2672 {"right-fringe", &Qright_fringe
},
2673 {"wait-for-wm", &Qwait_for_wm
},
2674 {"fullscreen", &Qfullscreen
},
2675 {"font-backend", &Qfont_backend
},
2677 {"sticky", &Qsticky
},
2678 {"tool-bar-position", &Qtool_bar_position
},
2683 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2684 wanted positions of the WM window (not Emacs window).
2685 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2686 window (FRAME_X_WINDOW).
2690 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2692 int newwidth
= FRAME_COLS (f
);
2693 int newheight
= FRAME_LINES (f
);
2694 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2696 *top_pos
= f
->top_pos
;
2697 *left_pos
= f
->left_pos
;
2699 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2703 ph
= x_display_pixel_height (dpyinfo
);
2704 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2705 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2706 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2710 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2714 pw
= x_display_pixel_width (dpyinfo
);
2715 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2716 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2717 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2722 *height
= newheight
;
2725 #endif /* WINDOWSNT */
2727 #ifdef HAVE_WINDOW_SYSTEM
2729 /* Change the parameters of frame F as specified by ALIST.
2730 If a parameter is not specially recognized, do nothing special;
2731 otherwise call the `x_set_...' function for that parameter.
2732 Except for certain geometry properties, always call store_frame_param
2733 to store the new value in the parameter alist. */
2736 x_set_frame_parameters (FRAME_PTR f
, Lisp_Object alist
)
2740 /* If both of these parameters are present, it's more efficient to
2741 set them both at once. So we wait until we've looked at the
2742 entire list before we set them. */
2746 Lisp_Object left
, top
;
2748 /* Same with these. */
2749 Lisp_Object icon_left
, icon_top
;
2751 /* Record in these vectors all the parms specified. */
2753 Lisp_Object
*values
;
2755 int left_no_change
= 0, top_no_change
= 0;
2756 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2757 int size_changed
= 0;
2758 struct gcpro gcpro1
, gcpro2
;
2761 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2764 parms
= alloca (i
* sizeof *parms
);
2765 values
= alloca (i
* sizeof *values
);
2767 /* Extract parm names and values into those vectors. */
2770 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2775 parms
[i
] = Fcar (elt
);
2776 values
[i
] = Fcdr (elt
);
2779 /* TAIL and ALIST are not used again below here. */
2780 alist
= tail
= Qnil
;
2782 GCPRO2 (*parms
, *values
);
2786 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2787 because their values appear in VALUES and strings are not valid. */
2788 top
= left
= Qunbound
;
2789 icon_left
= icon_top
= Qunbound
;
2791 /* Provide default values for HEIGHT and WIDTH. */
2792 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2793 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2795 /* Process foreground_color and background_color before anything else.
2796 They are independent of other properties, but other properties (e.g.,
2797 cursor_color) are dependent upon them. */
2798 /* Process default font as well, since fringe widths depends on it. */
2799 for (p
= 0; p
< i
; p
++)
2801 Lisp_Object prop
, val
;
2805 if (EQ (prop
, Qforeground_color
)
2806 || EQ (prop
, Qbackground_color
)
2807 || EQ (prop
, Qfont
))
2809 register Lisp_Object param_index
, old_value
;
2811 old_value
= get_frame_param (f
, prop
);
2812 if (NILP (Fequal (val
, old_value
)))
2814 store_frame_param (f
, prop
, val
);
2816 param_index
= Fget (prop
, Qx_frame_parameter
);
2817 if (NATNUMP (param_index
)
2818 && (XFASTINT (param_index
)
2819 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2820 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2821 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2826 /* Now process them in reverse of specified order. */
2829 Lisp_Object prop
, val
;
2834 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2837 width
= XFASTINT (val
);
2839 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2842 height
= XFASTINT (val
);
2844 else if (EQ (prop
, Qtop
))
2846 else if (EQ (prop
, Qleft
))
2848 else if (EQ (prop
, Qicon_top
))
2850 else if (EQ (prop
, Qicon_left
))
2852 else if (EQ (prop
, Qforeground_color
)
2853 || EQ (prop
, Qbackground_color
)
2854 || EQ (prop
, Qfont
))
2855 /* Processed above. */
2859 register Lisp_Object param_index
, old_value
;
2861 old_value
= get_frame_param (f
, prop
);
2863 store_frame_param (f
, prop
, val
);
2865 param_index
= Fget (prop
, Qx_frame_parameter
);
2866 if (NATNUMP (param_index
)
2867 && (XFASTINT (param_index
)
2868 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2869 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2870 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2874 /* Don't die if just one of these was set. */
2875 if (! TYPE_RANGED_INTEGERP (int, left
))
2878 if (f
->left_pos
< 0)
2879 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2881 XSETINT (left
, f
->left_pos
);
2883 if (! TYPE_RANGED_INTEGERP (int, top
))
2887 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2889 XSETINT (top
, f
->top_pos
);
2892 /* If one of the icon positions was not set, preserve or default it. */
2893 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
2895 icon_left_no_change
= 1;
2896 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2897 if (NILP (icon_left
))
2898 XSETINT (icon_left
, 0);
2900 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
2902 icon_top_no_change
= 1;
2903 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2904 if (NILP (icon_top
))
2905 XSETINT (icon_top
, 0);
2908 /* Don't set these parameters unless they've been explicitly
2909 specified. The window might be mapped or resized while we're in
2910 this function, and we don't want to override that unless the lisp
2911 code has asked for it.
2913 Don't set these parameters unless they actually differ from the
2914 window's current parameters; the window may not actually exist
2919 check_frame_size (f
, &height
, &width
);
2921 XSETFRAME (frame
, f
);
2924 && (width
!= FRAME_COLS (f
)
2925 || height
!= FRAME_LINES (f
)
2926 || f
->new_text_lines
|| f
->new_text_cols
))
2927 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2929 if ((!NILP (left
) || !NILP (top
))
2930 && ! (left_no_change
&& top_no_change
)
2931 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2932 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2937 /* Record the signs. */
2938 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2939 if (EQ (left
, Qminus
))
2940 f
->size_hint_flags
|= XNegative
;
2941 else if (TYPE_RANGED_INTEGERP (int, left
))
2943 leftpos
= XINT (left
);
2945 f
->size_hint_flags
|= XNegative
;
2947 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2948 && CONSP (XCDR (left
))
2949 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
2951 leftpos
= - XINT (XCAR (XCDR (left
)));
2952 f
->size_hint_flags
|= XNegative
;
2954 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2955 && CONSP (XCDR (left
))
2956 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
2958 leftpos
= XINT (XCAR (XCDR (left
)));
2961 if (EQ (top
, Qminus
))
2962 f
->size_hint_flags
|= YNegative
;
2963 else if (TYPE_RANGED_INTEGERP (int, top
))
2965 toppos
= XINT (top
);
2967 f
->size_hint_flags
|= YNegative
;
2969 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2970 && CONSP (XCDR (top
))
2971 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
2973 toppos
= - XINT (XCAR (XCDR (top
)));
2974 f
->size_hint_flags
|= YNegative
;
2976 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2977 && CONSP (XCDR (top
))
2978 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
2980 toppos
= XINT (XCAR (XCDR (top
)));
2984 /* Store the numeric value of the position. */
2985 f
->top_pos
= toppos
;
2986 f
->left_pos
= leftpos
;
2988 f
->win_gravity
= NorthWestGravity
;
2990 /* Actually set that position, and convert to absolute. */
2991 x_set_offset (f
, leftpos
, toppos
, -1);
2994 if ((!NILP (icon_left
) || !NILP (icon_top
))
2995 && ! (icon_left_no_change
&& icon_top_no_change
))
2996 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3003 /* Insert a description of internally-recorded parameters of frame X
3004 into the parameter alist *ALISTPTR that is to be given to the user.
3005 Only parameters that are specific to the X window system
3006 and whose values are not correctly recorded in the frame's
3007 param_alist need to be considered here. */
3010 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3016 /* Represent negative positions (off the top or left screen edge)
3017 in a way that Fmodify_frame_parameters will understand correctly. */
3018 XSETINT (tem
, f
->left_pos
);
3019 if (f
->left_pos
>= 0)
3020 store_in_alist (alistptr
, Qleft
, tem
);
3022 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3024 XSETINT (tem
, f
->top_pos
);
3025 if (f
->top_pos
>= 0)
3026 store_in_alist (alistptr
, Qtop
, tem
);
3028 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3030 store_in_alist (alistptr
, Qborder_width
,
3031 make_number (f
->border_width
));
3032 store_in_alist (alistptr
, Qinternal_border_width
,
3033 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3034 store_in_alist (alistptr
, Qleft_fringe
,
3035 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3036 store_in_alist (alistptr
, Qright_fringe
,
3037 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3038 store_in_alist (alistptr
, Qscroll_bar_width
,
3039 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3041 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3042 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3043 /* nil means "use default width"
3044 for non-toolkit scroll bar.
3045 ruler-mode.el depends on this. */
3047 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
3048 MS-Windows it returns a value whose type is HANDLE, which is
3049 actually a pointer. Explicit casting avoids compiler
3051 w
= (unsigned long) FRAME_X_WINDOW (f
);
3052 sprintf (buf
, "%lu", w
);
3053 store_in_alist (alistptr
, Qwindow_id
,
3054 build_string (buf
));
3055 #ifdef HAVE_X_WINDOWS
3056 #ifdef USE_X_TOOLKIT
3057 /* Tooltip frame may not have this widget. */
3058 if (FRAME_X_OUTPUT (f
)->widget
)
3061 w
= (unsigned long) FRAME_OUTER_WINDOW (f
);
3062 sprintf (buf
, "%lu", w
);
3064 store_in_alist (alistptr
, Qouter_window_id
,
3065 build_string (buf
));
3067 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3068 FRAME_SAMPLE_VISIBILITY (f
);
3069 store_in_alist (alistptr
, Qvisibility
,
3070 (FRAME_VISIBLE_P (f
) ? Qt
3071 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3072 store_in_alist (alistptr
, Qdisplay
,
3073 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3075 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3078 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3079 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3080 store_in_alist (alistptr
, Qparent_id
, tem
);
3081 store_in_alist (alistptr
, Qtool_bar_position
, f
->tool_bar_position
);
3085 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3086 the previous value of that parameter, NEW_VALUE is the new value. */
3089 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3091 if (NILP (new_value
))
3092 f
->want_fullscreen
= FULLSCREEN_NONE
;
3093 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3094 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3095 else if (EQ (new_value
, Qfullwidth
))
3096 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3097 else if (EQ (new_value
, Qfullheight
))
3098 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3099 else if (EQ (new_value
, Qmaximized
))
3100 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3102 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3103 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3107 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3108 the previous value of that parameter, NEW_VALUE is the new value. */
3111 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3113 if (NILP (new_value
))
3114 f
->extra_line_spacing
= 0;
3115 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
3116 f
->extra_line_spacing
= XFASTINT (new_value
);
3118 signal_error ("Invalid line-spacing", new_value
);
3119 if (FRAME_VISIBLE_P (f
))
3124 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3125 the previous value of that parameter, NEW_VALUE is the new value. */
3128 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3130 Lisp_Object bgcolor
;
3132 if (NILP (new_value
))
3134 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3135 /* The value 0.4545 is the normal viewing gamma. */
3136 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3138 signal_error ("Invalid screen-gamma", new_value
);
3140 /* Apply the new gamma value to the frame background. */
3141 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3142 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3144 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3145 if (NATNUMP (parm_index
)
3146 && (XFASTINT (parm_index
)
3147 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3148 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3149 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3153 Fclear_face_cache (Qnil
);
3158 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3160 Lisp_Object font_object
;
3162 #ifdef HAVE_X_WINDOWS
3163 Lisp_Object font_param
= arg
;
3166 /* Set the frame parameter back to the old value because we may
3167 fail to use ARG as the new parameter value. */
3168 store_frame_param (f
, Qfont
, oldval
);
3170 /* ARG is a fontset name, a font name, a cons of fontset name and a
3171 font object, or a font object. In the last case, this function
3175 fontset
= fs_query_fontset (arg
, 0);
3178 font_object
= font_open_by_name (f
, SSDATA (arg
));
3179 if (NILP (font_object
))
3180 error ("Font `%s' is not defined", SSDATA (arg
));
3181 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3183 else if (fontset
> 0)
3185 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3187 font_object
= font_open_by_name (f
, SSDATA (ascii_font
));
3188 if (NILP (font_object
))
3189 error ("Font `%s' is not defined", SDATA (arg
));
3190 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3193 error ("The default fontset can't be used for a frame font");
3195 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3197 /* This is the case that the ASCII font of F's fontset XCAR
3198 (arg) is changed to the font XCDR (arg) by
3199 `set-fontset-font'. */
3200 fontset
= fs_query_fontset (XCAR (arg
), 0);
3202 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3203 font_object
= XCDR (arg
);
3204 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3205 #ifdef HAVE_X_WINDOWS
3206 font_param
= Ffont_get (font_object
, QCname
);
3209 else if (FONT_OBJECT_P (arg
))
3212 #ifdef HAVE_X_WINDOWS
3213 font_param
= Ffont_get (font_object
, QCname
);
3215 /* This is to store the XLFD font name in the frame parameter for
3216 backward compatibility. We should store the font-object
3217 itself in the future. */
3218 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3219 fontset
= FRAME_FONTSET (f
);
3220 /* Check if we can use the current fontset. If not, set FONTSET
3221 to -1 to generate a new fontset from FONT-OBJECT. */
3224 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3225 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3227 if (! font_match_p (spec
, font_object
))
3232 signal_error ("Invalid font", arg
);
3234 if (! NILP (Fequal (font_object
, oldval
)))
3237 x_new_font (f
, font_object
, fontset
);
3238 store_frame_param (f
, Qfont
, arg
);
3239 #ifdef HAVE_X_WINDOWS
3240 store_frame_param (f
, Qfont_param
, font_param
);
3242 /* Recalculate toolbar height. */
3243 f
->n_tool_bar_rows
= 0;
3244 /* Ensure we redraw it. */
3245 clear_current_matrices (f
);
3247 recompute_basic_faces (f
);
3249 do_pending_window_change (0);
3251 /* We used to call face-set-after-frame-default here, but it leads to
3252 recursive calls (since that function can set the `default' face's
3253 font which in turns changes the frame's `font' parameter).
3254 Also I don't know what this call is meant to do, but it seems the
3255 wrong way to do it anyway (it does a lot more work than what seems
3256 reasonable in response to a change to `font'). */
3261 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3263 if (! NILP (new_value
)
3264 && !CONSP (new_value
))
3268 CHECK_STRING (new_value
);
3269 p0
= p1
= SSDATA (new_value
);
3273 while (*p1
&& ! isspace (*p1
) && *p1
!= ',') p1
++;
3275 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3281 while ((c
= *++p1
) && isspace (c
));
3285 new_value
= Fnreverse (new_value
);
3288 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3292 free_all_realized_faces (Qnil
);
3294 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3295 if (NILP (new_value
))
3297 if (NILP (old_value
))
3298 error ("No font backend available");
3299 font_update_drivers (f
, old_value
);
3300 error ("None of specified font backends are available");
3302 store_frame_param (f
, Qfont_backend
, new_value
);
3308 XSETFRAME (frame
, f
);
3309 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3310 ++face_change_count
;
3311 ++windows_or_buffers_changed
;
3317 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3319 compute_fringe_widths (f
, 1);
3320 #ifdef HAVE_X_WINDOWS
3321 /* Must adjust this so window managers report correct number of columns. */
3322 if (FRAME_X_WINDOW (f
) != 0)
3323 x_wm_set_size_hint (f
, 0, 0);
3328 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3330 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3332 if (XINT (arg
) == f
->border_width
)
3335 if (FRAME_X_WINDOW (f
) != 0)
3336 error ("Cannot change the border width of a frame");
3338 f
->border_width
= XINT (arg
);
3342 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3344 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3346 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3347 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3348 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3349 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3351 #ifdef USE_X_TOOLKIT
3352 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3353 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3356 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3359 if (FRAME_X_WINDOW (f
) != 0)
3361 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3362 SET_FRAME_GARBAGED (f
);
3363 do_pending_window_change (0);
3366 SET_FRAME_GARBAGED (f
);
3370 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3373 XSETFRAME (frame
, f
);
3376 Fmake_frame_invisible (frame
, Qt
);
3377 else if (EQ (value
, Qicon
))
3378 Ficonify_frame (frame
);
3380 Fmake_frame_visible (frame
);
3384 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3386 f
->auto_raise
= !EQ (Qnil
, arg
);
3390 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3392 f
->auto_lower
= !EQ (Qnil
, arg
);
3396 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3398 f
->no_split
= !NILP (arg
);
3402 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3404 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3405 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3406 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3407 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3409 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3411 ? vertical_scroll_bar_none
3413 ? vertical_scroll_bar_left
3415 ? vertical_scroll_bar_right
3416 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3417 ? vertical_scroll_bar_left
3418 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3419 ? vertical_scroll_bar_right
3420 : vertical_scroll_bar_none
);
3422 /* We set this parameter before creating the X window for the
3423 frame, so we can get the geometry right from the start.
3424 However, if the window hasn't been created yet, we shouldn't
3425 call x_set_window_size. */
3426 if (FRAME_X_WINDOW (f
))
3427 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3428 do_pending_window_change (0);
3433 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3435 int wid
= FRAME_COLUMN_WIDTH (f
);
3439 x_set_scroll_bar_default_width (f
);
3441 if (FRAME_X_WINDOW (f
))
3442 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3443 do_pending_window_change (0);
3445 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3446 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3448 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3449 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3451 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3452 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3453 if (FRAME_X_WINDOW (f
))
3454 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3455 do_pending_window_change (0);
3458 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3459 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3460 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3465 /* Return non-nil if frame F wants a bitmap icon. */
3468 x_icon_type (FRAME_PTR f
)
3472 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3480 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3487 for (i
= 0; i
< 2; i
++)
3500 else if (FLOATP (item
))
3502 alpha
= XFLOAT_DATA (item
);
3503 if (alpha
< 0.0 || 1.0 < alpha
)
3504 args_out_of_range (make_float (0.0), make_float (1.0));
3506 else if (INTEGERP (item
))
3508 EMACS_INT ialpha
= XINT (item
);
3509 if (ialpha
< 0 || 100 < ialpha
)
3510 args_out_of_range (make_number (0), make_number (100));
3512 alpha
= ialpha
/ 100.0;
3515 wrong_type_argument (Qnumberp
, item
);
3519 for (i
= 0; i
< 2; i
++)
3520 f
->alpha
[i
] = newval
[i
];
3522 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3524 x_set_frame_alpha (f
);
3532 /* Subroutines of creating an X frame. */
3534 /* Make sure that Vx_resource_name is set to a reasonable value.
3535 Fix it up, or set it to `emacs' if it is too hopeless. */
3538 validate_x_resource_name (void)
3541 /* Number of valid characters in the resource name. */
3542 ptrdiff_t good_count
= 0;
3543 /* Number of invalid characters in the resource name. */
3544 ptrdiff_t bad_count
= 0;
3548 if (!STRINGP (Vx_resource_class
))
3549 Vx_resource_class
= build_string (EMACS_CLASS
);
3551 if (STRINGP (Vx_resource_name
))
3553 unsigned char *p
= SDATA (Vx_resource_name
);
3555 len
= SBYTES (Vx_resource_name
);
3557 /* Only letters, digits, - and _ are valid in resource names.
3558 Count the valid characters and count the invalid ones. */
3559 for (i
= 0; i
< len
; i
++)
3562 if (! ((c
>= 'a' && c
<= 'z')
3563 || (c
>= 'A' && c
<= 'Z')
3564 || (c
>= '0' && c
<= '9')
3565 || c
== '-' || c
== '_'))
3572 /* Not a string => completely invalid. */
3573 bad_count
= 5, good_count
= 0;
3575 /* If name is valid already, return. */
3579 /* If name is entirely invalid, or nearly so, or is so implausibly
3580 large that alloca might not work, use `emacs'. */
3581 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
3583 Vx_resource_name
= build_string ("emacs");
3587 /* Name is partly valid. Copy it and replace the invalid characters
3588 with underscores. */
3590 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3592 for (i
= 0; i
< len
; i
++)
3594 int c
= SREF (new, i
);
3595 if (! ((c
>= 'a' && c
<= 'z')
3596 || (c
>= 'A' && c
<= 'Z')
3597 || (c
>= '0' && c
<= '9')
3598 || c
== '-' || c
== '_'))
3604 extern char *x_get_string_resource (XrmDatabase
, const char *, const char *);
3605 extern Display_Info
*check_x_display_info (Lisp_Object
);
3608 /* Get specified attribute from resource database RDB.
3609 See Fx_get_resource below for other parameters. */
3612 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3614 register char *value
;
3618 CHECK_STRING (attribute
);
3619 CHECK_STRING (class);
3621 if (!NILP (component
))
3622 CHECK_STRING (component
);
3623 if (!NILP (subclass
))
3624 CHECK_STRING (subclass
);
3625 if (NILP (component
) != NILP (subclass
))
3626 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3628 validate_x_resource_name ();
3630 /* Allocate space for the components, the dots which separate them,
3631 and the final '\0'. Make them big enough for the worst case. */
3632 name_key
= alloca (SBYTES (Vx_resource_name
)
3633 + (STRINGP (component
)
3634 ? SBYTES (component
) : 0)
3635 + SBYTES (attribute
)
3638 class_key
= alloca (SBYTES (Vx_resource_class
)
3640 + (STRINGP (subclass
)
3641 ? SBYTES (subclass
) : 0)
3644 /* Start with emacs.FRAMENAME for the name (the specific one)
3645 and with `Emacs' for the class key (the general one). */
3646 strcpy (name_key
, SSDATA (Vx_resource_name
));
3647 strcpy (class_key
, SSDATA (Vx_resource_class
));
3649 strcat (class_key
, ".");
3650 strcat (class_key
, SSDATA (class));
3652 if (!NILP (component
))
3654 strcat (class_key
, ".");
3655 strcat (class_key
, SSDATA (subclass
));
3657 strcat (name_key
, ".");
3658 strcat (name_key
, SSDATA (component
));
3661 strcat (name_key
, ".");
3662 strcat (name_key
, SSDATA (attribute
));
3664 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3666 if (value
!= (char *) 0 && *value
)
3667 return build_string (value
);
3673 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3674 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3675 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3676 class, where INSTANCE is the name under which Emacs was invoked, or
3677 the name specified by the `-name' or `-rn' command-line arguments.
3679 The optional arguments COMPONENT and SUBCLASS add to the key and the
3680 class, respectively. You must specify both of them or neither.
3681 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3682 and the class is `Emacs.CLASS.SUBCLASS'. */)
3683 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3685 #ifdef HAVE_X_WINDOWS
3689 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3690 attribute
, class, component
, subclass
);
3693 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3696 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3698 return xrdb_get_resource (dpyinfo
->xrdb
,
3699 attribute
, class, component
, subclass
);
3702 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3703 /* Used when C code wants a resource value. */
3704 /* Called from oldXMenu/Create.c. */
3706 x_get_resource_string (const char *attribute
, const char *class)
3711 struct frame
*sf
= SELECTED_FRAME ();
3712 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
3715 /* Allocate space for the components, the dots which separate them,
3716 and the final '\0'. */
3717 SAFE_ALLOCA (name_key
, char *, invocation_namelen
+ strlen (attribute
) + 2);
3718 class_key
= alloca ((sizeof (EMACS_CLASS
) - 1) + strlen (class) + 2);
3720 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
3721 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3723 result
= x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3724 name_key
, class_key
);
3730 /* Return the value of parameter PARAM.
3732 First search ALIST, then Vdefault_frame_alist, then the X defaults
3733 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3735 Convert the resource to the type specified by desired_type.
3737 If no default is specified, return Qunbound. If you call
3738 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3739 and don't let it get stored in any Lisp-visible variables! */
3742 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3743 const char *attribute
, const char *class, enum resource_types type
)
3745 register Lisp_Object tem
;
3747 tem
= Fassq (param
, alist
);
3751 /* If we find this parm in ALIST, clear it out
3752 so that it won't be "left over" at the end. */
3754 XSETCAR (tem
, Qnil
);
3755 /* In case the parameter appears more than once in the alist,
3757 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3758 if (CONSP (XCAR (tail
))
3759 && EQ (XCAR (XCAR (tail
)), param
))
3760 XSETCAR (XCAR (tail
), Qnil
);
3763 tem
= Fassq (param
, Vdefault_frame_alist
);
3765 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3766 look in the X resources. */
3769 if (attribute
&& dpyinfo
)
3771 tem
= display_x_get_resource (dpyinfo
,
3772 build_string (attribute
),
3773 build_string (class),
3781 case RES_TYPE_NUMBER
:
3782 return make_number (atoi (SSDATA (tem
)));
3784 case RES_TYPE_BOOLEAN_NUMBER
:
3785 if (!strcmp (SSDATA (tem
), "on")
3786 || !strcmp (SSDATA (tem
), "true"))
3787 return make_number (1);
3788 return make_number (atoi (SSDATA (tem
)));
3791 case RES_TYPE_FLOAT
:
3792 return make_float (atof (SSDATA (tem
)));
3794 case RES_TYPE_BOOLEAN
:
3795 tem
= Fdowncase (tem
);
3796 if (!strcmp (SSDATA (tem
), "on")
3798 || !strcmp (SSDATA (tem
), "yes")
3800 || !strcmp (SSDATA (tem
), "true"))
3805 case RES_TYPE_STRING
:
3808 case RES_TYPE_SYMBOL
:
3809 /* As a special case, we map the values `true' and `on'
3810 to Qt, and `false' and `off' to Qnil. */
3813 lower
= Fdowncase (tem
);
3814 if (!strcmp (SSDATA (lower
), "on")
3816 || !strcmp (SSDATA (lower
), "yes")
3818 || !strcmp (SSDATA (lower
), "true"))
3820 else if (!strcmp (SSDATA (lower
), "off")
3822 || !strcmp (SSDATA (lower
), "no")
3824 || !strcmp (SSDATA (lower
), "false"))
3827 return Fintern (tem
, Qnil
);
3841 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3842 const char *attribute
, const char *class,
3843 enum resource_types type
)
3845 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3846 alist
, param
, attribute
, class, type
);
3849 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3852 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3854 const char *attribute
, const char *class,
3855 enum resource_types type
)
3859 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3860 attribute
, class, type
);
3861 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3862 store_frame_param (f
, param
, value
);
3868 /* Record in frame F the specified or default value according to ALIST
3869 of the parameter named PROP (a Lisp symbol).
3870 If no value is specified for PROP, look for an X default for XPROP
3871 on the frame named NAME.
3872 If that is not found either, use the value DEFLT. */
3875 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
3876 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
3877 enum resource_types type
)
3881 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3882 if (EQ (tem
, Qunbound
))
3884 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3891 /* NS used to define x-parse-geometry in ns-win.el, but that confused
3892 make-docfile: the documentation string in ns-win.el was used for
3893 x-parse-geometry even in non-NS builds.
3895 With two definitions of x-parse-geometry in this file, various
3896 things still get confused (eg M-x apropos documentation), so that
3897 it is best if the two definitions just share the same doc-string.
3899 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3900 doc
: /* Parse a display geometry string STRING.
3901 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3902 The properties returned may include `top', `left', `height', and `width'.
3903 For X, the value of `left' or `top' may be an integer,
3904 or a list (+ N) meaning N pixels relative to top/left corner,
3905 or a list (- N) meaning -N pixels relative to bottom/right corner.
3906 On Nextstep, this just calls `ns-parse-geometry'. */)
3907 (Lisp_Object string
)
3910 return call1 (Qns_parse_geometry
, string
);
3913 unsigned int width
, height
;
3916 CHECK_STRING (string
);
3918 geometry
= XParseGeometry (SSDATA (string
),
3919 &x
, &y
, &width
, &height
);
3921 if (geometry
& XValue
)
3923 Lisp_Object element
;
3925 if (x
>= 0 && (geometry
& XNegative
))
3926 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3927 else if (x
< 0 && ! (geometry
& XNegative
))
3928 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3930 element
= Fcons (Qleft
, make_number (x
));
3931 result
= Fcons (element
, result
);
3934 if (geometry
& YValue
)
3936 Lisp_Object element
;
3938 if (y
>= 0 && (geometry
& YNegative
))
3939 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3940 else if (y
< 0 && ! (geometry
& YNegative
))
3941 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3943 element
= Fcons (Qtop
, make_number (y
));
3944 result
= Fcons (element
, result
);
3947 if (geometry
& WidthValue
)
3948 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3949 if (geometry
& HeightValue
)
3950 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3953 #endif /* HAVE_NS */
3957 /* Calculate the desired size and position of frame F.
3958 Return the flags saying which aspects were specified.
3960 Also set the win_gravity and size_hint_flags of F.
3962 Adjust height for toolbar if TOOLBAR_P is 1.
3964 This function does not make the coordinates positive. */
3966 #define DEFAULT_ROWS 35
3967 #define DEFAULT_COLS 80
3970 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, int toolbar_p
)
3972 register Lisp_Object tem0
, tem1
, tem2
;
3973 long window_prompting
= 0;
3974 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3976 /* Default values if we fall through.
3977 Actually, if that happens we should get
3978 window manager prompting. */
3979 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3980 FRAME_LINES (f
) = DEFAULT_ROWS
;
3981 /* Window managers expect that if program-specified
3982 positions are not (0,0), they're intentional, not defaults. */
3986 /* Ensure that old new_text_cols and new_text_lines will not override the
3988 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3989 f
->new_text_cols
= f
->new_text_lines
= 0;
3991 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3992 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3993 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3994 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3996 if (!EQ (tem0
, Qunbound
))
3998 CHECK_NUMBER (tem0
);
3999 if (! (0 <= XINT (tem0
) && XINT (tem0
) <= INT_MAX
))
4000 xsignal1 (Qargs_out_of_range
, tem0
);
4001 FRAME_LINES (f
) = XINT (tem0
);
4003 if (!EQ (tem1
, Qunbound
))
4005 CHECK_NUMBER (tem1
);
4006 if (! (0 <= XINT (tem1
) && XINT (tem1
) <= INT_MAX
))
4007 xsignal1 (Qargs_out_of_range
, tem1
);
4008 SET_FRAME_COLS (f
, XINT (tem1
));
4010 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4011 window_prompting
|= USSize
;
4013 window_prompting
|= PSize
;
4016 f
->scroll_bar_actual_width
4017 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4019 /* This used to be done _before_ calling x_figure_window_size, but
4020 since the height is reset here, this was really a no-op. I
4021 assume that moving it here does what Gerd intended (although he
4022 no longer can remember what that was... ++KFS, 2003-03-25. */
4024 /* Add the tool-bar height to the initial frame height so that the
4025 user gets a text display area of the size he specified with -g or
4026 via .Xdefaults. Later changes of the tool-bar height don't
4027 change the frame size. This is done so that users can create
4028 tall Emacs frames without having to guess how tall the tool-bar
4030 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4032 int margin
, relief
, bar_height
;
4034 relief
= (tool_bar_button_relief
>= 0
4035 ? tool_bar_button_relief
4036 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4038 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
4039 margin
= XFASTINT (Vtool_bar_button_margin
);
4040 else if (CONSP (Vtool_bar_button_margin
)
4041 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
4042 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4046 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4047 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4050 compute_fringe_widths (f
, 0);
4052 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4053 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4055 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4056 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4057 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4058 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4060 if (EQ (tem0
, Qminus
))
4063 window_prompting
|= YNegative
;
4065 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4066 && CONSP (XCDR (tem0
))
4067 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem0
)), INT_MAX
))
4069 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4070 window_prompting
|= YNegative
;
4072 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4073 && CONSP (XCDR (tem0
))
4074 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0
))))
4076 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4078 else if (EQ (tem0
, Qunbound
))
4082 CHECK_TYPE_RANGED_INTEGER (int, tem0
);
4083 f
->top_pos
= XINT (tem0
);
4085 window_prompting
|= YNegative
;
4088 if (EQ (tem1
, Qminus
))
4091 window_prompting
|= XNegative
;
4093 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4094 && CONSP (XCDR (tem1
))
4095 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem1
)), INT_MAX
))
4097 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4098 window_prompting
|= XNegative
;
4100 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4101 && CONSP (XCDR (tem1
))
4102 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1
))))
4104 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4106 else if (EQ (tem1
, Qunbound
))
4110 CHECK_TYPE_RANGED_INTEGER (int, tem1
);
4111 f
->left_pos
= XINT (tem1
);
4112 if (f
->left_pos
< 0)
4113 window_prompting
|= XNegative
;
4116 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4117 window_prompting
|= USPosition
;
4119 window_prompting
|= PPosition
;
4122 if (window_prompting
& XNegative
)
4124 if (window_prompting
& YNegative
)
4125 f
->win_gravity
= SouthEastGravity
;
4127 f
->win_gravity
= NorthEastGravity
;
4131 if (window_prompting
& YNegative
)
4132 f
->win_gravity
= SouthWestGravity
;
4134 f
->win_gravity
= NorthWestGravity
;
4137 f
->size_hint_flags
= window_prompting
;
4139 return window_prompting
;
4144 #endif /* HAVE_WINDOW_SYSTEM */
4147 frame_make_pointer_invisible (void)
4149 if (! NILP (Vmake_pointer_invisible
))
4152 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4155 f
= SELECTED_FRAME ();
4156 if (f
&& !f
->pointer_invisible
4157 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4160 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4161 f
->pointer_invisible
= 1;
4167 frame_make_pointer_visible (void)
4169 /* We don't check Vmake_pointer_invisible here in case the
4170 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4173 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4176 f
= SELECTED_FRAME ();
4177 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4178 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4180 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4181 f
->pointer_invisible
= 0;
4185 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4186 Sframe_pointer_visible_p
, 0, 1, 0,
4187 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4188 Otherwise it returns nil. FRAME omitted or nil means the
4189 selected frame. This is useful when `make-pointer-invisible' is set. */)
4193 frame
= selected_frame
;
4195 CHECK_FRAME (frame
);
4197 return (XFRAME (frame
)->pointer_invisible
? Qnil
: Qt
);
4201 /***********************************************************************
4203 ***********************************************************************/
4206 syms_of_frame (void)
4208 DEFSYM (Qframep
, "framep");
4209 DEFSYM (Qframe_live_p
, "frame-live-p");
4210 DEFSYM (Qexplicit_name
, "explicit-name");
4211 DEFSYM (Qheight
, "height");
4212 DEFSYM (Qicon
, "icon");
4213 DEFSYM (Qminibuffer
, "minibuffer");
4214 DEFSYM (Qmodeline
, "modeline");
4215 DEFSYM (Qonly
, "only");
4216 DEFSYM (Qwidth
, "width");
4217 DEFSYM (Qgeometry
, "geometry");
4218 DEFSYM (Qicon_left
, "icon-left");
4219 DEFSYM (Qicon_top
, "icon-top");
4220 DEFSYM (Qtooltip
, "tooltip");
4221 DEFSYM (Qleft
, "left");
4222 DEFSYM (Qright
, "right");
4223 DEFSYM (Quser_position
, "user-position");
4224 DEFSYM (Quser_size
, "user-size");
4225 DEFSYM (Qwindow_id
, "window-id");
4226 #ifdef HAVE_X_WINDOWS
4227 DEFSYM (Qouter_window_id
, "outer-window-id");
4229 DEFSYM (Qparent_id
, "parent-id");
4231 DEFSYM (Qw32
, "w32");
4233 DEFSYM (Qmac
, "mac");
4235 DEFSYM (Qvisible
, "visible");
4236 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4237 DEFSYM (Qbuffer_list
, "buffer-list");
4238 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4239 DEFSYM (Qdisplay_type
, "display-type");
4240 DEFSYM (Qbackground_mode
, "background-mode");
4241 DEFSYM (Qnoelisp
, "noelisp");
4242 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4243 DEFSYM (Qtty
, "tty");
4244 DEFSYM (Qtty_type
, "tty-type");
4246 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4248 DEFSYM (Qfullwidth
, "fullwidth");
4249 DEFSYM (Qfullheight
, "fullheight");
4250 DEFSYM (Qfullboth
, "fullboth");
4251 DEFSYM (Qmaximized
, "maximized");
4252 DEFSYM (Qx_resource_name
, "x-resource-name");
4253 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4255 DEFSYM (Qterminal
, "terminal");
4256 DEFSYM (Qterminal_live_p
, "terminal-live-p");
4259 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4265 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4267 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4268 if (frame_parms
[i
].variable
)
4270 *frame_parms
[i
].variable
= v
;
4271 staticpro (frame_parms
[i
].variable
);
4273 Fput (v
, Qx_frame_parameter
, make_number (i
));
4277 #ifdef HAVE_WINDOW_SYSTEM
4278 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4279 doc
: /* The name Emacs uses to look up X resources.
4280 `x-get-resource' uses this as the first component of the instance name
4281 when requesting resource values.
4282 Emacs initially sets `x-resource-name' to the name under which Emacs
4283 was invoked, or to the value specified with the `-name' or `-rn'
4284 switches, if present.
4286 It may be useful to bind this variable locally around a call
4287 to `x-get-resource'. See also the variable `x-resource-class'. */);
4288 Vx_resource_name
= Qnil
;
4290 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4291 doc
: /* The class Emacs uses to look up X resources.
4292 `x-get-resource' uses this as the first component of the instance class
4293 when requesting resource values.
4295 Emacs initially sets `x-resource-class' to "Emacs".
4297 Setting this variable permanently is not a reasonable thing to do,
4298 but binding this variable locally around a call to `x-get-resource'
4299 is a reasonable practice. See also the variable `x-resource-name'. */);
4300 Vx_resource_class
= build_string (EMACS_CLASS
);
4302 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4303 doc
: /* The lower limit of the frame opacity (alpha transparency).
4304 The value should range from 0 (invisible) to 100 (completely opaque).
4305 You can also use a floating number between 0.0 and 1.0.
4306 The default is 20. */);
4307 Vframe_alpha_lower_limit
= make_number (20);
4310 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4311 doc
: /* Alist of default values for frame creation.
4312 These may be set in your init file, like this:
4313 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4314 These override values given in window system configuration data,
4315 including X Windows' defaults database.
4316 For values specific to the first Emacs frame, see `initial-frame-alist'.
4317 For window-system specific values, see `window-system-default-frame-alist'.
4318 For values specific to the separate minibuffer frame, see
4319 `minibuffer-frame-alist'.
4320 The `menu-bar-lines' element of the list controls whether new frames
4321 have menu bars; `menu-bar-mode' works by altering this element.
4322 Setting this variable does not affect existing frames, only new ones. */);
4323 Vdefault_frame_alist
= Qnil
;
4325 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4326 doc
: /* Default position of scroll bars on this window-system. */);
4327 #ifdef HAVE_WINDOW_SYSTEM
4328 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
4329 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4331 Vdefault_frame_scroll_bars
= Qright
;
4333 Vdefault_frame_scroll_bars
= Qleft
;
4336 Vdefault_frame_scroll_bars
= Qnil
;
4339 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4340 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4342 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4343 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4344 `mouse-position' calls this function, passing its usual return value as
4345 argument, and returns whatever this function returns.
4346 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4347 which need to do mouse handling at the Lisp level. */);
4348 Vmouse_position_function
= Qnil
;
4350 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4351 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4352 If the value is an integer, highlighting is only shown after moving the
4353 mouse, while keyboard input turns off the highlight even when the mouse
4354 is over the clickable text. However, the mouse shape still indicates
4355 when the mouse is over clickable text. */);
4356 Vmouse_highlight
= Qt
;
4358 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4359 doc
: /* If non-nil, make pointer invisible while typing.
4360 The pointer becomes visible again when the mouse is moved. */);
4361 Vmake_pointer_invisible
= Qt
;
4363 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4364 doc
: /* Functions to be run before deleting a frame.
4365 The functions are run with one arg, the frame to be deleted.
4368 Note that functions in this list may be called just before the frame is
4369 actually deleted, or some time later (or even both when an earlier function
4370 in `delete-frame-functions' (indirectly) calls `delete-frame'
4372 Vdelete_frame_functions
= Qnil
;
4373 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
4375 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4376 doc
: /* Non-nil if Menu-Bar mode is enabled.
4377 See the command `menu-bar-mode' for a description of this minor mode.
4378 Setting this variable directly does not take effect;
4379 either customize it (see the info node `Easy Customization')
4380 or call the function `menu-bar-mode'. */);
4381 Vmenu_bar_mode
= Qt
;
4383 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4384 doc
: /* Non-nil if Tool-Bar mode is enabled.
4385 See the command `tool-bar-mode' for a description of this minor mode.
4386 Setting this variable directly does not take effect;
4387 either customize it (see the info node `Easy Customization')
4388 or call the function `tool-bar-mode'. */);
4389 #ifdef HAVE_WINDOW_SYSTEM
4390 Vtool_bar_mode
= Qt
;
4392 Vtool_bar_mode
= Qnil
;
4395 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4396 doc
: /* Minibufferless frames use this frame's minibuffer.
4398 Emacs cannot create minibufferless frames unless this is set to an
4399 appropriate surrogate.
4401 Emacs consults this variable only when creating minibufferless
4402 frames; once the frame is created, it sticks with its assigned
4403 minibuffer, no matter what this variable is set to. This means that
4404 this variable doesn't necessarily say anything meaningful about the
4405 current set of frames, or where the minibuffer is currently being
4408 This variable is local to the current terminal and cannot be buffer-local. */);
4410 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
4411 doc
: /* Non-nil if window system changes focus when you move the mouse.
4412 You should set this variable to tell Emacs how your window manager
4413 handles focus, since there is no way in general for Emacs to find out
4414 automatically. See also `mouse-autoselect-window'. */);
4415 focus_follows_mouse
= 0;
4417 staticpro (&Vframe_list
);
4420 defsubr (&Sframe_live_p
);
4421 defsubr (&Swindow_system
);
4422 defsubr (&Smake_terminal_frame
);
4423 defsubr (&Shandle_switch_frame
);
4424 defsubr (&Sselect_frame
);
4425 defsubr (&Sselected_frame
);
4426 defsubr (&Sframe_list
);
4427 defsubr (&Snext_frame
);
4428 defsubr (&Sprevious_frame
);
4429 defsubr (&Sdelete_frame
);
4430 defsubr (&Smouse_position
);
4431 defsubr (&Smouse_pixel_position
);
4432 defsubr (&Sset_mouse_position
);
4433 defsubr (&Sset_mouse_pixel_position
);
4435 defsubr (&Sframe_configuration
);
4436 defsubr (&Srestore_frame_configuration
);
4438 defsubr (&Smake_frame_visible
);
4439 defsubr (&Smake_frame_invisible
);
4440 defsubr (&Siconify_frame
);
4441 defsubr (&Sframe_visible_p
);
4442 defsubr (&Svisible_frame_list
);
4443 defsubr (&Sraise_frame
);
4444 defsubr (&Slower_frame
);
4445 defsubr (&Sredirect_frame_focus
);
4446 defsubr (&Sframe_focus
);
4447 defsubr (&Sframe_parameters
);
4448 defsubr (&Sframe_parameter
);
4449 defsubr (&Smodify_frame_parameters
);
4450 defsubr (&Sframe_char_height
);
4451 defsubr (&Sframe_char_width
);
4452 defsubr (&Sframe_pixel_height
);
4453 defsubr (&Sframe_pixel_width
);
4454 defsubr (&Stool_bar_pixel_width
);
4455 defsubr (&Sset_frame_height
);
4456 defsubr (&Sset_frame_width
);
4457 defsubr (&Sset_frame_size
);
4458 defsubr (&Sset_frame_position
);
4459 defsubr (&Sframe_pointer_visible_p
);
4461 #ifdef HAVE_WINDOW_SYSTEM
4462 defsubr (&Sx_get_resource
);
4463 defsubr (&Sx_parse_geometry
);