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
= (char *) 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
= (char *) 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. */
1939 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
1941 register Lisp_Object tem
;
1943 tem
= Fassq (prop
, frame
->param_alist
);
1949 /* Return the buffer-predicate of the selected frame. */
1952 frame_buffer_predicate (Lisp_Object frame
)
1954 return XFRAME (frame
)->buffer_predicate
;
1957 /* Return the buffer-list of the selected frame. */
1960 frame_buffer_list (Lisp_Object frame
)
1962 return XFRAME (frame
)->buffer_list
;
1965 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
1968 frames_discard_buffer (Lisp_Object buffer
)
1970 Lisp_Object frame
, tail
;
1972 FOR_EACH_FRAME (tail
, frame
)
1974 XFRAME (frame
)->buffer_list
1975 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1976 XFRAME (frame
)->buried_buffer_list
1977 = Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
);
1981 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1982 If the alist already has an element for PROP, we change it. */
1985 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
1987 register Lisp_Object tem
;
1989 tem
= Fassq (prop
, *alistptr
);
1991 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1997 frame_name_fnn_p (char *str
, ptrdiff_t len
)
1999 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
2002 while ('0' <= *p
&& *p
<= '9')
2010 /* Set the name of the terminal frame. Also used by MSDOS frames.
2011 Modeled after x_set_name which is used for WINDOW frames. */
2014 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2016 f
->explicit_name
= ! NILP (name
);
2018 /* If NAME is nil, set the name to F<num>. */
2021 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
2023 /* Check for no change needed in this very common case
2024 before we do any consing. */
2025 if (frame_name_fnn_p (SSDATA (f
->name
),
2030 sprintf (namebuf
, "F%"pMd
, tty_frame_count
);
2031 name
= build_string (namebuf
);
2035 CHECK_STRING (name
);
2037 /* Don't change the name if it's already NAME. */
2038 if (! NILP (Fstring_equal (name
, f
->name
)))
2041 /* Don't allow the user to set the frame name to F<num>, so it
2042 doesn't clash with the names we generate for terminal frames. */
2043 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2044 error ("Frame names of the form F<num> are usurped by Emacs");
2048 update_mode_lines
= 1;
2052 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2054 register Lisp_Object old_alist_elt
;
2056 /* The buffer-list parameters are stored in a special place and not
2057 in the alist. All buffers must be live. */
2058 if (EQ (prop
, Qbuffer_list
))
2060 Lisp_Object list
= Qnil
;
2061 for (; CONSP (val
); val
= XCDR (val
))
2062 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2063 list
= Fcons (XCAR (val
), list
);
2064 f
->buffer_list
= Fnreverse (list
);
2067 if (EQ (prop
, Qburied_buffer_list
))
2069 Lisp_Object list
= Qnil
;
2070 for (; CONSP (val
); val
= XCDR (val
))
2071 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2072 list
= Fcons (XCAR (val
), list
);
2073 f
->buried_buffer_list
= Fnreverse (list
);
2077 /* If PROP is a symbol which is supposed to have frame-local values,
2078 and it is set up based on this frame, switch to the global
2079 binding. That way, we can create or alter the frame-local binding
2080 without messing up the symbol's status. */
2083 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2085 switch (sym
->redirect
)
2087 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2088 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2089 case SYMBOL_LOCALIZED
:
2090 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2091 if (blv
->frame_local
&& BLV_FOUND (blv
) && XFRAME (blv
->where
) == f
)
2092 swap_in_global_binding (sym
);
2099 /* The tty color needed to be set before the frame's parameter
2100 alist was updated with the new value. This is not true any more,
2101 but we still do this test early on. */
2102 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2103 && f
== FRAME_TTY (f
)->previous_frame
)
2104 /* Force redisplay of this tty. */
2105 FRAME_TTY (f
)->previous_frame
= NULL
;
2107 /* Update the frame parameter alist. */
2108 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2109 if (EQ (old_alist_elt
, Qnil
))
2110 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2112 Fsetcdr (old_alist_elt
, val
);
2114 /* Update some other special parameters in their special places
2115 in addition to the alist. */
2117 if (EQ (prop
, Qbuffer_predicate
))
2118 f
->buffer_predicate
= val
;
2120 if (! FRAME_WINDOW_P (f
))
2122 if (EQ (prop
, Qmenu_bar_lines
))
2123 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2124 else if (EQ (prop
, Qname
))
2125 set_term_frame_name (f
, val
);
2128 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2130 if (! MINI_WINDOW_P (XWINDOW (val
)))
2131 error ("Surrogate minibuffer windows must be minibuffer windows");
2133 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2134 && !EQ (val
, f
->minibuffer_window
))
2135 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2137 /* Install the chosen minibuffer window, with proper buffer. */
2138 f
->minibuffer_window
= val
;
2142 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2143 doc
: /* Return the parameters-alist of frame FRAME.
2144 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2145 The meaningful PARMs depend on the kind of frame.
2146 If FRAME is omitted, return information on the currently selected frame. */)
2152 struct gcpro gcpro1
;
2155 frame
= selected_frame
;
2157 CHECK_FRAME (frame
);
2160 if (!FRAME_LIVE_P (f
))
2163 alist
= Fcopy_alist (f
->param_alist
);
2166 if (!FRAME_WINDOW_P (f
))
2168 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2169 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2172 /* If the frame's parameter alist says the colors are
2173 unspecified and reversed, take the frame's background pixel
2174 for foreground and vice versa. */
2175 elt
= Fassq (Qforeground_color
, alist
);
2176 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2178 if (strncmp (SSDATA (XCDR (elt
)),
2180 SCHARS (XCDR (elt
))) == 0)
2181 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2182 else if (strncmp (SSDATA (XCDR (elt
)),
2184 SCHARS (XCDR (elt
))) == 0)
2185 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2188 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2189 elt
= Fassq (Qbackground_color
, alist
);
2190 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2192 if (strncmp (SSDATA (XCDR (elt
)),
2194 SCHARS (XCDR (elt
))) == 0)
2195 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2196 else if (strncmp (SSDATA (XCDR (elt
)),
2198 SCHARS (XCDR (elt
))) == 0)
2199 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2202 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2203 store_in_alist (&alist
, intern ("font"),
2204 build_string (FRAME_MSDOS_P (f
)
2206 : FRAME_W32_P (f
) ? "w32term"
2209 store_in_alist (&alist
, Qname
, f
->name
);
2210 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2211 store_in_alist (&alist
, Qheight
, make_number (height
));
2212 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2213 store_in_alist (&alist
, Qwidth
, make_number (width
));
2214 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2215 store_in_alist (&alist
, Qminibuffer
,
2216 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2217 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2218 : FRAME_MINIBUF_WINDOW (f
)));
2219 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2220 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2221 store_in_alist (&alist
, Qburied_buffer_list
, XFRAME (frame
)->buried_buffer_list
);
2223 /* I think this should be done with a hook. */
2224 #ifdef HAVE_WINDOW_SYSTEM
2225 if (FRAME_WINDOW_P (f
))
2226 x_report_frame_params (f
, &alist
);
2230 /* This ought to be correct in f->param_alist for an X frame. */
2232 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2233 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2241 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2242 doc
: /* Return FRAME's value for parameter PARAMETER.
2243 If FRAME is nil, describe the currently selected frame. */)
2244 (Lisp_Object frame
, Lisp_Object parameter
)
2250 frame
= selected_frame
;
2252 CHECK_FRAME (frame
);
2253 CHECK_SYMBOL (parameter
);
2258 if (FRAME_LIVE_P (f
))
2260 /* Avoid consing in frequent cases. */
2261 if (EQ (parameter
, Qname
))
2263 #ifdef HAVE_X_WINDOWS
2264 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2265 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2266 #endif /* HAVE_X_WINDOWS */
2267 else if (EQ (parameter
, Qbackground_color
)
2268 || EQ (parameter
, Qforeground_color
))
2270 value
= Fassq (parameter
, f
->param_alist
);
2273 value
= XCDR (value
);
2274 /* Fframe_parameters puts the actual fg/bg color names,
2275 even if f->param_alist says otherwise. This is
2276 important when param_alist's notion of colors is
2277 "unspecified". We need to do the same here. */
2278 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2280 const char *color_name
;
2283 if (EQ (parameter
, Qbackground_color
))
2285 color_name
= SSDATA (value
);
2286 csz
= SCHARS (value
);
2287 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2288 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2289 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2290 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2292 else if (EQ (parameter
, Qforeground_color
))
2294 color_name
= SSDATA (value
);
2295 csz
= SCHARS (value
);
2296 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2297 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2298 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2299 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2304 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2306 else if (EQ (parameter
, Qdisplay_type
)
2307 || EQ (parameter
, Qbackground_mode
))
2308 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2310 /* FIXME: Avoid this code path at all (as well as code duplication)
2311 by sharing more code with Fframe_parameters. */
2312 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2319 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2320 Smodify_frame_parameters
, 2, 2, 0,
2321 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2322 If FRAME is nil, it defaults to the selected frame.
2323 ALIST is an alist of parameters to change and their new values.
2324 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2325 The meaningful PARMs depend on the kind of frame.
2326 Undefined PARMs are ignored, but stored in the frame's parameter list
2327 so that `frame-parameters' will return them.
2329 The value of frame parameter FOO can also be accessed
2330 as a frame-local binding for the variable FOO, if you have
2331 enabled such bindings for that variable with `make-variable-frame-local'.
2332 Note that this functionality is obsolete as of Emacs 22.2, and its
2333 use is not recommended. Explicitly check for a frame-parameter instead. */)
2334 (Lisp_Object frame
, Lisp_Object alist
)
2337 register Lisp_Object tail
, prop
, val
;
2339 if (EQ (frame
, Qnil
))
2340 frame
= selected_frame
;
2341 CHECK_LIVE_FRAME (frame
);
2344 /* I think this should be done with a hook. */
2345 #ifdef HAVE_WINDOW_SYSTEM
2346 if (FRAME_WINDOW_P (f
))
2347 x_set_frame_parameters (f
, alist
);
2351 if (FRAME_MSDOS_P (f
))
2352 IT_set_frame_parameters (f
, alist
);
2357 EMACS_INT length
= XFASTINT (Flength (alist
));
2360 Lisp_Object
*values
;
2362 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2363 values
= parms
+ length
;
2365 /* Extract parm names and values into those vectors. */
2368 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2373 parms
[i
] = Fcar (elt
);
2374 values
[i
] = Fcdr (elt
);
2378 /* Now process them in reverse of specified order. */
2383 store_frame_param (f
, prop
, val
);
2385 if (EQ (prop
, Qforeground_color
)
2386 || EQ (prop
, Qbackground_color
))
2387 update_face_from_frame_parameter (f
, prop
, val
);
2395 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2397 doc
: /* Height in pixels of a line in the font in frame FRAME.
2398 If FRAME is omitted, the selected frame is used.
2399 For a terminal frame, the value is always 1. */)
2405 frame
= selected_frame
;
2406 CHECK_FRAME (frame
);
2409 #ifdef HAVE_WINDOW_SYSTEM
2410 if (FRAME_WINDOW_P (f
))
2411 return make_number (x_char_height (f
));
2414 return make_number (1);
2418 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2420 doc
: /* Width in pixels of characters in the font in frame FRAME.
2421 If FRAME is omitted, the selected frame is used.
2422 On a graphical screen, the width is the standard width of the default font.
2423 For a terminal screen, the value is always 1. */)
2429 frame
= selected_frame
;
2430 CHECK_FRAME (frame
);
2433 #ifdef HAVE_WINDOW_SYSTEM
2434 if (FRAME_WINDOW_P (f
))
2435 return make_number (x_char_width (f
));
2438 return make_number (1);
2441 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2442 Sframe_pixel_height
, 0, 1, 0,
2443 doc
: /* Return a FRAME's height in pixels.
2444 If FRAME is omitted, the selected frame is used. The exact value
2445 of the result depends on the window-system and toolkit in use:
2447 In the Gtk+ version of Emacs, it includes only any window (including
2448 the minibuffer or echo area), mode line, and header line. It does not
2449 include the tool bar or menu bar.
2451 With the Motif or Lucid toolkits, it also includes the tool bar (but
2454 In a graphical version with no toolkit, it includes both the tool bar
2457 For a text terminal, it includes the menu bar. In this case, the
2458 result is really in characters rather than pixels (i.e., is identical
2459 to `frame-height'). */)
2465 frame
= selected_frame
;
2466 CHECK_FRAME (frame
);
2469 #ifdef HAVE_WINDOW_SYSTEM
2470 if (FRAME_WINDOW_P (f
))
2471 return make_number (x_pixel_height (f
));
2474 return make_number (FRAME_LINES (f
));
2477 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2478 Sframe_pixel_width
, 0, 1, 0,
2479 doc
: /* Return FRAME's width in pixels.
2480 For a terminal frame, the result really gives the width in characters.
2481 If FRAME is omitted, the selected frame is used. */)
2487 frame
= selected_frame
;
2488 CHECK_FRAME (frame
);
2491 #ifdef HAVE_WINDOW_SYSTEM
2492 if (FRAME_WINDOW_P (f
))
2493 return make_number (x_pixel_width (f
));
2496 return make_number (FRAME_COLS (f
));
2499 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2500 Stool_bar_pixel_width
, 0, 1, 0,
2501 doc
: /* Return width in pixels of FRAME's tool bar.
2502 The result is greater than zero only when the tool bar is on the left
2503 or right side of FRAME. If FRAME is omitted, the selected frame is
2510 frame
= selected_frame
;
2511 CHECK_FRAME (frame
);
2514 #ifdef FRAME_TOOLBAR_WIDTH
2515 if (FRAME_WINDOW_P (f
))
2516 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2518 return make_number (0);
2521 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2522 doc
: /* Specify that the frame FRAME has LINES lines.
2523 Optional third arg non-nil means that redisplay should use LINES lines
2524 but that the idea of the actual height of the frame should not be changed. */)
2525 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2527 register struct frame
*f
;
2529 CHECK_TYPE_RANGED_INTEGER (int, lines
);
2531 frame
= selected_frame
;
2532 CHECK_LIVE_FRAME (frame
);
2535 /* I think this should be done with a hook. */
2536 #ifdef HAVE_WINDOW_SYSTEM
2537 if (FRAME_WINDOW_P (f
))
2539 if (XINT (lines
) != FRAME_LINES (f
))
2540 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2541 do_pending_window_change (0);
2545 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2549 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2550 doc
: /* Specify that the frame FRAME has COLS columns.
2551 Optional third arg non-nil means that redisplay should use COLS columns
2552 but that the idea of the actual width of the frame should not be changed. */)
2553 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2555 register struct frame
*f
;
2556 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2558 frame
= selected_frame
;
2559 CHECK_LIVE_FRAME (frame
);
2562 /* I think this should be done with a hook. */
2563 #ifdef HAVE_WINDOW_SYSTEM
2564 if (FRAME_WINDOW_P (f
))
2566 if (XINT (cols
) != FRAME_COLS (f
))
2567 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2568 do_pending_window_change (0);
2572 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2576 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2577 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2578 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2580 register struct frame
*f
;
2582 CHECK_LIVE_FRAME (frame
);
2583 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2584 CHECK_TYPE_RANGED_INTEGER (int, rows
);
2587 /* I think this should be done with a hook. */
2588 #ifdef HAVE_WINDOW_SYSTEM
2589 if (FRAME_WINDOW_P (f
))
2591 if (XINT (rows
) != FRAME_LINES (f
)
2592 || XINT (cols
) != FRAME_COLS (f
)
2593 || f
->new_text_lines
|| f
->new_text_cols
)
2594 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2595 do_pending_window_change (0);
2599 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2604 DEFUN ("set-frame-position", Fset_frame_position
,
2605 Sset_frame_position
, 3, 3, 0,
2606 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2607 This is actually the position of the upper left corner of the frame.
2608 Negative values for XOFFSET or YOFFSET are interpreted relative to
2609 the rightmost or bottommost possible position (that stays within the screen). */)
2610 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2612 register struct frame
*f
;
2614 CHECK_LIVE_FRAME (frame
);
2615 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2616 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2619 /* I think this should be done with a hook. */
2620 #ifdef HAVE_WINDOW_SYSTEM
2621 if (FRAME_WINDOW_P (f
))
2622 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2629 /***********************************************************************
2631 ***********************************************************************/
2633 /* Connect the frame-parameter names for X frames
2634 to the ways of passing the parameter values to the window system.
2636 The name of a parameter, as a Lisp symbol,
2637 has an `x-frame-parameter' property which is an integer in Lisp
2638 that is an index in this table. */
2640 struct frame_parm_table
{
2642 Lisp_Object
*variable
;
2645 static const struct frame_parm_table frame_parms
[] =
2647 {"auto-raise", &Qauto_raise
},
2648 {"auto-lower", &Qauto_lower
},
2649 {"background-color", 0},
2650 {"border-color", &Qborder_color
},
2651 {"border-width", &Qborder_width
},
2652 {"cursor-color", &Qcursor_color
},
2653 {"cursor-type", &Qcursor_type
},
2655 {"foreground-color", 0},
2656 {"icon-name", &Qicon_name
},
2657 {"icon-type", &Qicon_type
},
2658 {"internal-border-width", &Qinternal_border_width
},
2659 {"menu-bar-lines", &Qmenu_bar_lines
},
2660 {"mouse-color", &Qmouse_color
},
2662 {"scroll-bar-width", &Qscroll_bar_width
},
2664 {"unsplittable", &Qunsplittable
},
2665 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2666 {"visibility", &Qvisibility
},
2667 {"tool-bar-lines", &Qtool_bar_lines
},
2668 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2669 {"scroll-bar-background", &Qscroll_bar_background
},
2670 {"screen-gamma", &Qscreen_gamma
},
2671 {"line-spacing", &Qline_spacing
},
2672 {"left-fringe", &Qleft_fringe
},
2673 {"right-fringe", &Qright_fringe
},
2674 {"wait-for-wm", &Qwait_for_wm
},
2675 {"fullscreen", &Qfullscreen
},
2676 {"font-backend", &Qfont_backend
},
2678 {"sticky", &Qsticky
},
2679 {"tool-bar-position", &Qtool_bar_position
},
2684 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2685 wanted positions of the WM window (not Emacs window).
2686 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2687 window (FRAME_X_WINDOW).
2691 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2693 int newwidth
= FRAME_COLS (f
);
2694 int newheight
= FRAME_LINES (f
);
2695 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2697 *top_pos
= f
->top_pos
;
2698 *left_pos
= f
->left_pos
;
2700 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2704 ph
= x_display_pixel_height (dpyinfo
);
2705 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2706 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2707 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2711 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2715 pw
= x_display_pixel_width (dpyinfo
);
2716 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2717 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2718 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2723 *height
= newheight
;
2726 #endif /* WINDOWSNT */
2728 #ifdef HAVE_WINDOW_SYSTEM
2730 /* Change the parameters of frame F as specified by ALIST.
2731 If a parameter is not specially recognized, do nothing special;
2732 otherwise call the `x_set_...' function for that parameter.
2733 Except for certain geometry properties, always call store_frame_param
2734 to store the new value in the parameter alist. */
2737 x_set_frame_parameters (FRAME_PTR f
, Lisp_Object alist
)
2741 /* If both of these parameters are present, it's more efficient to
2742 set them both at once. So we wait until we've looked at the
2743 entire list before we set them. */
2747 Lisp_Object left
, top
;
2749 /* Same with these. */
2750 Lisp_Object icon_left
, icon_top
;
2752 /* Record in these vectors all the parms specified. */
2754 Lisp_Object
*values
;
2756 int left_no_change
= 0, top_no_change
= 0;
2757 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2758 int size_changed
= 0;
2759 struct gcpro gcpro1
, gcpro2
;
2762 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2765 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2766 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2768 /* Extract parm names and values into those vectors. */
2771 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2776 parms
[i
] = Fcar (elt
);
2777 values
[i
] = Fcdr (elt
);
2780 /* TAIL and ALIST are not used again below here. */
2781 alist
= tail
= Qnil
;
2783 GCPRO2 (*parms
, *values
);
2787 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2788 because their values appear in VALUES and strings are not valid. */
2789 top
= left
= Qunbound
;
2790 icon_left
= icon_top
= Qunbound
;
2792 /* Provide default values for HEIGHT and WIDTH. */
2793 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2794 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2796 /* Process foreground_color and background_color before anything else.
2797 They are independent of other properties, but other properties (e.g.,
2798 cursor_color) are dependent upon them. */
2799 /* Process default font as well, since fringe widths depends on it. */
2800 for (p
= 0; p
< i
; p
++)
2802 Lisp_Object prop
, val
;
2806 if (EQ (prop
, Qforeground_color
)
2807 || EQ (prop
, Qbackground_color
)
2808 || EQ (prop
, Qfont
))
2810 register Lisp_Object param_index
, old_value
;
2812 old_value
= get_frame_param (f
, prop
);
2813 if (NILP (Fequal (val
, old_value
)))
2815 store_frame_param (f
, prop
, val
);
2817 param_index
= Fget (prop
, Qx_frame_parameter
);
2818 if (NATNUMP (param_index
)
2819 && (XFASTINT (param_index
)
2820 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2821 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2822 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2827 /* Now process them in reverse of specified order. */
2830 Lisp_Object prop
, val
;
2835 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2838 width
= XFASTINT (val
);
2840 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2843 height
= XFASTINT (val
);
2845 else if (EQ (prop
, Qtop
))
2847 else if (EQ (prop
, Qleft
))
2849 else if (EQ (prop
, Qicon_top
))
2851 else if (EQ (prop
, Qicon_left
))
2853 else if (EQ (prop
, Qforeground_color
)
2854 || EQ (prop
, Qbackground_color
)
2855 || EQ (prop
, Qfont
))
2856 /* Processed above. */
2860 register Lisp_Object param_index
, old_value
;
2862 old_value
= get_frame_param (f
, prop
);
2864 store_frame_param (f
, prop
, val
);
2866 param_index
= Fget (prop
, Qx_frame_parameter
);
2867 if (NATNUMP (param_index
)
2868 && (XFASTINT (param_index
)
2869 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2870 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2871 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2875 /* Don't die if just one of these was set. */
2876 if (! TYPE_RANGED_INTEGERP (int, left
))
2879 if (f
->left_pos
< 0)
2880 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2882 XSETINT (left
, f
->left_pos
);
2884 if (! TYPE_RANGED_INTEGERP (int, top
))
2888 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2890 XSETINT (top
, f
->top_pos
);
2893 /* If one of the icon positions was not set, preserve or default it. */
2894 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
2896 icon_left_no_change
= 1;
2897 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2898 if (NILP (icon_left
))
2899 XSETINT (icon_left
, 0);
2901 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
2903 icon_top_no_change
= 1;
2904 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2905 if (NILP (icon_top
))
2906 XSETINT (icon_top
, 0);
2909 /* Don't set these parameters unless they've been explicitly
2910 specified. The window might be mapped or resized while we're in
2911 this function, and we don't want to override that unless the lisp
2912 code has asked for it.
2914 Don't set these parameters unless they actually differ from the
2915 window's current parameters; the window may not actually exist
2920 check_frame_size (f
, &height
, &width
);
2922 XSETFRAME (frame
, f
);
2925 && (width
!= FRAME_COLS (f
)
2926 || height
!= FRAME_LINES (f
)
2927 || f
->new_text_lines
|| f
->new_text_cols
))
2928 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2930 if ((!NILP (left
) || !NILP (top
))
2931 && ! (left_no_change
&& top_no_change
)
2932 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2933 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2938 /* Record the signs. */
2939 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2940 if (EQ (left
, Qminus
))
2941 f
->size_hint_flags
|= XNegative
;
2942 else if (TYPE_RANGED_INTEGERP (int, left
))
2944 leftpos
= XINT (left
);
2946 f
->size_hint_flags
|= XNegative
;
2948 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2949 && CONSP (XCDR (left
))
2950 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
2952 leftpos
= - XINT (XCAR (XCDR (left
)));
2953 f
->size_hint_flags
|= XNegative
;
2955 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2956 && CONSP (XCDR (left
))
2957 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
2959 leftpos
= XINT (XCAR (XCDR (left
)));
2962 if (EQ (top
, Qminus
))
2963 f
->size_hint_flags
|= YNegative
;
2964 else if (TYPE_RANGED_INTEGERP (int, top
))
2966 toppos
= XINT (top
);
2968 f
->size_hint_flags
|= YNegative
;
2970 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2971 && CONSP (XCDR (top
))
2972 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
2974 toppos
= - XINT (XCAR (XCDR (top
)));
2975 f
->size_hint_flags
|= YNegative
;
2977 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2978 && CONSP (XCDR (top
))
2979 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
2981 toppos
= XINT (XCAR (XCDR (top
)));
2985 /* Store the numeric value of the position. */
2986 f
->top_pos
= toppos
;
2987 f
->left_pos
= leftpos
;
2989 f
->win_gravity
= NorthWestGravity
;
2991 /* Actually set that position, and convert to absolute. */
2992 x_set_offset (f
, leftpos
, toppos
, -1);
2995 if ((!NILP (icon_left
) || !NILP (icon_top
))
2996 && ! (icon_left_no_change
&& icon_top_no_change
))
2997 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3004 /* Insert a description of internally-recorded parameters of frame X
3005 into the parameter alist *ALISTPTR that is to be given to the user.
3006 Only parameters that are specific to the X window system
3007 and whose values are not correctly recorded in the frame's
3008 param_alist need to be considered here. */
3011 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3017 /* Represent negative positions (off the top or left screen edge)
3018 in a way that Fmodify_frame_parameters will understand correctly. */
3019 XSETINT (tem
, f
->left_pos
);
3020 if (f
->left_pos
>= 0)
3021 store_in_alist (alistptr
, Qleft
, tem
);
3023 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3025 XSETINT (tem
, f
->top_pos
);
3026 if (f
->top_pos
>= 0)
3027 store_in_alist (alistptr
, Qtop
, tem
);
3029 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3031 store_in_alist (alistptr
, Qborder_width
,
3032 make_number (f
->border_width
));
3033 store_in_alist (alistptr
, Qinternal_border_width
,
3034 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3035 store_in_alist (alistptr
, Qleft_fringe
,
3036 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3037 store_in_alist (alistptr
, Qright_fringe
,
3038 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3039 store_in_alist (alistptr
, Qscroll_bar_width
,
3040 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3042 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3043 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3044 /* nil means "use default width"
3045 for non-toolkit scroll bar.
3046 ruler-mode.el depends on this. */
3048 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
3049 MS-Windows it returns a value whose type is HANDLE, which is
3050 actually a pointer. Explicit casting avoids compiler
3052 w
= (unsigned long) FRAME_X_WINDOW (f
);
3053 sprintf (buf
, "%lu", w
);
3054 store_in_alist (alistptr
, Qwindow_id
,
3055 build_string (buf
));
3056 #ifdef HAVE_X_WINDOWS
3057 #ifdef USE_X_TOOLKIT
3058 /* Tooltip frame may not have this widget. */
3059 if (FRAME_X_OUTPUT (f
)->widget
)
3062 w
= (unsigned long) FRAME_OUTER_WINDOW (f
);
3063 sprintf (buf
, "%lu", w
);
3065 store_in_alist (alistptr
, Qouter_window_id
,
3066 build_string (buf
));
3068 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3069 FRAME_SAMPLE_VISIBILITY (f
);
3070 store_in_alist (alistptr
, Qvisibility
,
3071 (FRAME_VISIBLE_P (f
) ? Qt
3072 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3073 store_in_alist (alistptr
, Qdisplay
,
3074 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3076 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3079 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3080 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3081 store_in_alist (alistptr
, Qparent_id
, tem
);
3082 store_in_alist (alistptr
, Qtool_bar_position
, f
->tool_bar_position
);
3086 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3087 the previous value of that parameter, NEW_VALUE is the new value. */
3090 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3092 if (NILP (new_value
))
3093 f
->want_fullscreen
= FULLSCREEN_NONE
;
3094 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3095 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3096 else if (EQ (new_value
, Qfullwidth
))
3097 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3098 else if (EQ (new_value
, Qfullheight
))
3099 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3100 else if (EQ (new_value
, Qmaximized
))
3101 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3103 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3104 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3108 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3109 the previous value of that parameter, NEW_VALUE is the new value. */
3112 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3114 if (NILP (new_value
))
3115 f
->extra_line_spacing
= 0;
3116 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
3117 f
->extra_line_spacing
= XFASTINT (new_value
);
3119 signal_error ("Invalid line-spacing", new_value
);
3120 if (FRAME_VISIBLE_P (f
))
3125 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3126 the previous value of that parameter, NEW_VALUE is the new value. */
3129 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3131 Lisp_Object bgcolor
;
3133 if (NILP (new_value
))
3135 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3136 /* The value 0.4545 is the normal viewing gamma. */
3137 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3139 signal_error ("Invalid screen-gamma", new_value
);
3141 /* Apply the new gamma value to the frame background. */
3142 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3143 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3145 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3146 if (NATNUMP (parm_index
)
3147 && (XFASTINT (parm_index
)
3148 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3149 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3150 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3154 Fclear_face_cache (Qnil
);
3159 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3161 Lisp_Object font_object
, font_param
= Qnil
;
3164 /* Set the frame parameter back to the old value because we may
3165 fail to use ARG as the new parameter value. */
3166 store_frame_param (f
, Qfont
, oldval
);
3168 /* ARG is a fontset name, a font name, a cons of fontset name and a
3169 font object, or a font object. In the last case, this function
3174 fontset
= fs_query_fontset (arg
, 0);
3177 font_object
= font_open_by_name (f
, SSDATA (arg
));
3178 if (NILP (font_object
))
3179 error ("Font `%s' is not defined", SSDATA (arg
));
3180 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3182 else if (fontset
> 0)
3184 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3186 font_object
= font_open_by_name (f
, SSDATA (ascii_font
));
3187 if (NILP (font_object
))
3188 error ("Font `%s' is not defined", SDATA (arg
));
3189 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3192 error ("The default fontset can't be used for a frame font");
3194 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3196 /* This is the case that the ASCII font of F's fontset XCAR
3197 (arg) is changed to the font XCDR (arg) by
3198 `set-fontset-font'. */
3199 fontset
= fs_query_fontset (XCAR (arg
), 0);
3201 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3202 font_object
= XCDR (arg
);
3203 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3204 font_param
= Ffont_get (font_object
, QCname
);
3206 else if (FONT_OBJECT_P (arg
))
3209 font_param
= Ffont_get (font_object
, QCname
);
3210 /* This is to store the XLFD font name in the frame parameter for
3211 backward compatibility. We should store the font-object
3212 itself in the future. */
3213 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3214 fontset
= FRAME_FONTSET (f
);
3215 /* Check if we can use the current fontset. If not, set FONTSET
3216 to -1 to generate a new fontset from FONT-OBJECT. */
3219 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3220 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3222 if (! font_match_p (spec
, font_object
))
3227 signal_error ("Invalid font", arg
);
3229 if (! NILP (Fequal (font_object
, oldval
)))
3232 x_new_font (f
, font_object
, fontset
);
3233 store_frame_param (f
, Qfont
, arg
);
3234 #ifdef HAVE_X_WINDOWS
3235 store_frame_param (f
, Qfont_param
, font_param
);
3237 /* Recalculate toolbar height. */
3238 f
->n_tool_bar_rows
= 0;
3239 /* Ensure we redraw it. */
3240 clear_current_matrices (f
);
3242 recompute_basic_faces (f
);
3244 do_pending_window_change (0);
3246 /* We used to call face-set-after-frame-default here, but it leads to
3247 recursive calls (since that function can set the `default' face's
3248 font which in turns changes the frame's `font' parameter).
3249 Also I don't know what this call is meant to do, but it seems the
3250 wrong way to do it anyway (it does a lot more work than what seems
3251 reasonable in response to a change to `font'). */
3256 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3258 if (! NILP (new_value
)
3259 && !CONSP (new_value
))
3263 CHECK_STRING (new_value
);
3264 p0
= p1
= SSDATA (new_value
);
3268 while (*p1
&& ! isspace (*p1
) && *p1
!= ',') p1
++;
3270 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3276 while ((c
= *++p1
) && isspace (c
));
3280 new_value
= Fnreverse (new_value
);
3283 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3287 free_all_realized_faces (Qnil
);
3289 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3290 if (NILP (new_value
))
3292 if (NILP (old_value
))
3293 error ("No font backend available");
3294 font_update_drivers (f
, old_value
);
3295 error ("None of specified font backends are available");
3297 store_frame_param (f
, Qfont_backend
, new_value
);
3303 XSETFRAME (frame
, f
);
3304 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3305 ++face_change_count
;
3306 ++windows_or_buffers_changed
;
3312 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3314 compute_fringe_widths (f
, 1);
3315 #ifdef HAVE_X_WINDOWS
3316 /* Must adjust this so window managers report correct number of columns. */
3317 if (FRAME_X_WINDOW (f
) != 0)
3318 x_wm_set_size_hint (f
, 0, 0);
3323 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3325 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3327 if (XINT (arg
) == f
->border_width
)
3330 if (FRAME_X_WINDOW (f
) != 0)
3331 error ("Cannot change the border width of a frame");
3333 f
->border_width
= XINT (arg
);
3337 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3339 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3341 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3342 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3343 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3344 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3346 #ifdef USE_X_TOOLKIT
3347 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3348 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3351 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3354 if (FRAME_X_WINDOW (f
) != 0)
3356 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3357 SET_FRAME_GARBAGED (f
);
3358 do_pending_window_change (0);
3361 SET_FRAME_GARBAGED (f
);
3365 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3368 XSETFRAME (frame
, f
);
3371 Fmake_frame_invisible (frame
, Qt
);
3372 else if (EQ (value
, Qicon
))
3373 Ficonify_frame (frame
);
3375 Fmake_frame_visible (frame
);
3379 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3381 f
->auto_raise
= !EQ (Qnil
, arg
);
3385 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3387 f
->auto_lower
= !EQ (Qnil
, arg
);
3391 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3393 f
->no_split
= !NILP (arg
);
3397 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3399 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3400 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3401 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3402 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3404 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3406 ? vertical_scroll_bar_none
3408 ? vertical_scroll_bar_left
3410 ? vertical_scroll_bar_right
3411 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3412 ? vertical_scroll_bar_left
3413 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3414 ? vertical_scroll_bar_right
3415 : vertical_scroll_bar_none
);
3417 /* We set this parameter before creating the X window for the
3418 frame, so we can get the geometry right from the start.
3419 However, if the window hasn't been created yet, we shouldn't
3420 call x_set_window_size. */
3421 if (FRAME_X_WINDOW (f
))
3422 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3423 do_pending_window_change (0);
3428 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3430 int wid
= FRAME_COLUMN_WIDTH (f
);
3434 x_set_scroll_bar_default_width (f
);
3436 if (FRAME_X_WINDOW (f
))
3437 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3438 do_pending_window_change (0);
3440 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3441 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3443 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3444 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3446 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3447 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3448 if (FRAME_X_WINDOW (f
))
3449 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3450 do_pending_window_change (0);
3453 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3454 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3455 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3460 /* Return non-nil if frame F wants a bitmap icon. */
3463 x_icon_type (FRAME_PTR f
)
3467 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3475 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3482 for (i
= 0; i
< 2; i
++)
3495 else if (FLOATP (item
))
3497 alpha
= XFLOAT_DATA (item
);
3498 if (alpha
< 0.0 || 1.0 < alpha
)
3499 args_out_of_range (make_float (0.0), make_float (1.0));
3501 else if (INTEGERP (item
))
3503 EMACS_INT ialpha
= XINT (item
);
3504 if (ialpha
< 0 || 100 < ialpha
)
3505 args_out_of_range (make_number (0), make_number (100));
3507 alpha
= ialpha
/ 100.0;
3510 wrong_type_argument (Qnumberp
, item
);
3514 for (i
= 0; i
< 2; i
++)
3515 f
->alpha
[i
] = newval
[i
];
3517 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3519 x_set_frame_alpha (f
);
3527 /* Subroutines of creating an X frame. */
3529 /* Make sure that Vx_resource_name is set to a reasonable value.
3530 Fix it up, or set it to `emacs' if it is too hopeless. */
3533 validate_x_resource_name (void)
3536 /* Number of valid characters in the resource name. */
3537 ptrdiff_t good_count
= 0;
3538 /* Number of invalid characters in the resource name. */
3539 ptrdiff_t bad_count
= 0;
3543 if (!STRINGP (Vx_resource_class
))
3544 Vx_resource_class
= build_string (EMACS_CLASS
);
3546 if (STRINGP (Vx_resource_name
))
3548 unsigned char *p
= SDATA (Vx_resource_name
);
3550 len
= SBYTES (Vx_resource_name
);
3552 /* Only letters, digits, - and _ are valid in resource names.
3553 Count the valid characters and count the invalid ones. */
3554 for (i
= 0; i
< len
; i
++)
3557 if (! ((c
>= 'a' && c
<= 'z')
3558 || (c
>= 'A' && c
<= 'Z')
3559 || (c
>= '0' && c
<= '9')
3560 || c
== '-' || c
== '_'))
3567 /* Not a string => completely invalid. */
3568 bad_count
= 5, good_count
= 0;
3570 /* If name is valid already, return. */
3574 /* If name is entirely invalid, or nearly so, or is so implausibly
3575 large that alloca might not work, use `emacs'. */
3576 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
3578 Vx_resource_name
= build_string ("emacs");
3582 /* Name is partly valid. Copy it and replace the invalid characters
3583 with underscores. */
3585 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3587 for (i
= 0; i
< len
; i
++)
3589 int c
= SREF (new, i
);
3590 if (! ((c
>= 'a' && c
<= 'z')
3591 || (c
>= 'A' && c
<= 'Z')
3592 || (c
>= '0' && c
<= '9')
3593 || c
== '-' || c
== '_'))
3599 extern char *x_get_string_resource (XrmDatabase
, const char *, const char *);
3600 extern Display_Info
*check_x_display_info (Lisp_Object
);
3603 /* Get specified attribute from resource database RDB.
3604 See Fx_get_resource below for other parameters. */
3607 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3609 register char *value
;
3613 CHECK_STRING (attribute
);
3614 CHECK_STRING (class);
3616 if (!NILP (component
))
3617 CHECK_STRING (component
);
3618 if (!NILP (subclass
))
3619 CHECK_STRING (subclass
);
3620 if (NILP (component
) != NILP (subclass
))
3621 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3623 validate_x_resource_name ();
3625 /* Allocate space for the components, the dots which separate them,
3626 and the final '\0'. Make them big enough for the worst case. */
3627 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3628 + (STRINGP (component
)
3629 ? SBYTES (component
) : 0)
3630 + SBYTES (attribute
)
3633 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3635 + (STRINGP (subclass
)
3636 ? SBYTES (subclass
) : 0)
3639 /* Start with emacs.FRAMENAME for the name (the specific one)
3640 and with `Emacs' for the class key (the general one). */
3641 strcpy (name_key
, SSDATA (Vx_resource_name
));
3642 strcpy (class_key
, SSDATA (Vx_resource_class
));
3644 strcat (class_key
, ".");
3645 strcat (class_key
, SSDATA (class));
3647 if (!NILP (component
))
3649 strcat (class_key
, ".");
3650 strcat (class_key
, SSDATA (subclass
));
3652 strcat (name_key
, ".");
3653 strcat (name_key
, SSDATA (component
));
3656 strcat (name_key
, ".");
3657 strcat (name_key
, SSDATA (attribute
));
3659 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3661 if (value
!= (char *) 0 && *value
)
3662 return build_string (value
);
3668 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3669 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3670 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3671 class, where INSTANCE is the name under which Emacs was invoked, or
3672 the name specified by the `-name' or `-rn' command-line arguments.
3674 The optional arguments COMPONENT and SUBCLASS add to the key and the
3675 class, respectively. You must specify both of them or neither.
3676 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3677 and the class is `Emacs.CLASS.SUBCLASS'. */)
3678 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3680 #ifdef HAVE_X_WINDOWS
3684 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3685 attribute
, class, component
, subclass
);
3688 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3691 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3693 return xrdb_get_resource (dpyinfo
->xrdb
,
3694 attribute
, class, component
, subclass
);
3697 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3698 /* Used when C code wants a resource value. */
3699 /* Called from oldXMenu/Create.c. */
3701 x_get_resource_string (const char *attribute
, const char *class)
3706 struct frame
*sf
= SELECTED_FRAME ();
3707 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
3710 /* Allocate space for the components, the dots which separate them,
3711 and the final '\0'. */
3712 SAFE_ALLOCA (name_key
, char *, invocation_namelen
+ strlen (attribute
) + 2);
3713 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3714 + strlen (class) + 2);
3716 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
3717 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3719 result
= x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3720 name_key
, class_key
);
3726 /* Return the value of parameter PARAM.
3728 First search ALIST, then Vdefault_frame_alist, then the X defaults
3729 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3731 Convert the resource to the type specified by desired_type.
3733 If no default is specified, return Qunbound. If you call
3734 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3735 and don't let it get stored in any Lisp-visible variables! */
3738 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3739 const char *attribute
, const char *class, enum resource_types type
)
3741 register Lisp_Object tem
;
3743 tem
= Fassq (param
, alist
);
3747 /* If we find this parm in ALIST, clear it out
3748 so that it won't be "left over" at the end. */
3750 XSETCAR (tem
, Qnil
);
3751 /* In case the parameter appears more than once in the alist,
3753 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3754 if (CONSP (XCAR (tail
))
3755 && EQ (XCAR (XCAR (tail
)), param
))
3756 XSETCAR (XCAR (tail
), Qnil
);
3759 tem
= Fassq (param
, Vdefault_frame_alist
);
3761 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3762 look in the X resources. */
3765 if (attribute
&& dpyinfo
)
3767 tem
= display_x_get_resource (dpyinfo
,
3768 build_string (attribute
),
3769 build_string (class),
3777 case RES_TYPE_NUMBER
:
3778 return make_number (atoi (SSDATA (tem
)));
3780 case RES_TYPE_BOOLEAN_NUMBER
:
3781 if (!strcmp (SSDATA (tem
), "on")
3782 || !strcmp (SSDATA (tem
), "true"))
3783 return make_number (1);
3784 return make_number (atoi (SSDATA (tem
)));
3787 case RES_TYPE_FLOAT
:
3788 return make_float (atof (SSDATA (tem
)));
3790 case RES_TYPE_BOOLEAN
:
3791 tem
= Fdowncase (tem
);
3792 if (!strcmp (SSDATA (tem
), "on")
3794 || !strcmp (SSDATA (tem
), "yes")
3796 || !strcmp (SSDATA (tem
), "true"))
3801 case RES_TYPE_STRING
:
3804 case RES_TYPE_SYMBOL
:
3805 /* As a special case, we map the values `true' and `on'
3806 to Qt, and `false' and `off' to Qnil. */
3809 lower
= Fdowncase (tem
);
3810 if (!strcmp (SSDATA (lower
), "on")
3812 || !strcmp (SSDATA (lower
), "yes")
3814 || !strcmp (SSDATA (lower
), "true"))
3816 else if (!strcmp (SSDATA (lower
), "off")
3818 || !strcmp (SSDATA (lower
), "no")
3820 || !strcmp (SSDATA (lower
), "false"))
3823 return Fintern (tem
, Qnil
);
3837 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3838 const char *attribute
, const char *class,
3839 enum resource_types type
)
3841 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3842 alist
, param
, attribute
, class, type
);
3845 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3848 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3850 const char *attribute
, const char *class,
3851 enum resource_types type
)
3855 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3856 attribute
, class, type
);
3857 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3858 store_frame_param (f
, param
, value
);
3864 /* Record in frame F the specified or default value according to ALIST
3865 of the parameter named PROP (a Lisp symbol).
3866 If no value is specified for PROP, look for an X default for XPROP
3867 on the frame named NAME.
3868 If that is not found either, use the value DEFLT. */
3871 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
3872 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
3873 enum resource_types type
)
3877 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3878 if (EQ (tem
, Qunbound
))
3880 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3887 /* NS used to define x-parse-geometry in ns-win.el, but that confused
3888 make-docfile: the documentation string in ns-win.el was used for
3889 x-parse-geometry even in non-NS builds.
3891 With two definitions of x-parse-geometry in this file, various
3892 things still get confused (eg M-x apropos documentation), so that
3893 it is best if the two definitions just share the same doc-string.
3895 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3896 doc
: /* Parse a display geometry string STRING.
3897 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3898 The properties returned may include `top', `left', `height', and `width'.
3899 For X, the value of `left' or `top' may be an integer,
3900 or a list (+ N) meaning N pixels relative to top/left corner,
3901 or a list (- N) meaning -N pixels relative to bottom/right corner.
3902 On Nextstep, this just calls `ns-parse-geometry'. */)
3903 (Lisp_Object string
)
3906 call1 (Qns_parse_geometry
, string
);
3909 unsigned int width
, height
;
3912 CHECK_STRING (string
);
3914 geometry
= XParseGeometry (SSDATA (string
),
3915 &x
, &y
, &width
, &height
);
3917 if (geometry
& XValue
)
3919 Lisp_Object element
;
3921 if (x
>= 0 && (geometry
& XNegative
))
3922 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3923 else if (x
< 0 && ! (geometry
& XNegative
))
3924 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3926 element
= Fcons (Qleft
, make_number (x
));
3927 result
= Fcons (element
, result
);
3930 if (geometry
& YValue
)
3932 Lisp_Object element
;
3934 if (y
>= 0 && (geometry
& YNegative
))
3935 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3936 else if (y
< 0 && ! (geometry
& YNegative
))
3937 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3939 element
= Fcons (Qtop
, make_number (y
));
3940 result
= Fcons (element
, result
);
3943 if (geometry
& WidthValue
)
3944 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3945 if (geometry
& HeightValue
)
3946 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3949 #endif /* HAVE_NS */
3953 /* Calculate the desired size and position of frame F.
3954 Return the flags saying which aspects were specified.
3956 Also set the win_gravity and size_hint_flags of F.
3958 Adjust height for toolbar if TOOLBAR_P is 1.
3960 This function does not make the coordinates positive. */
3962 #define DEFAULT_ROWS 35
3963 #define DEFAULT_COLS 80
3966 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, int toolbar_p
)
3968 register Lisp_Object tem0
, tem1
, tem2
;
3969 long window_prompting
= 0;
3970 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3972 /* Default values if we fall through.
3973 Actually, if that happens we should get
3974 window manager prompting. */
3975 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3976 FRAME_LINES (f
) = DEFAULT_ROWS
;
3977 /* Window managers expect that if program-specified
3978 positions are not (0,0), they're intentional, not defaults. */
3982 /* Ensure that old new_text_cols and new_text_lines will not override the
3984 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3985 f
->new_text_cols
= f
->new_text_lines
= 0;
3987 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3988 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3989 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3990 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3992 if (!EQ (tem0
, Qunbound
))
3994 CHECK_NUMBER (tem0
);
3995 if (! (0 <= XINT (tem0
) && XINT (tem0
) <= INT_MAX
))
3996 xsignal1 (Qargs_out_of_range
, tem0
);
3997 FRAME_LINES (f
) = XINT (tem0
);
3999 if (!EQ (tem1
, Qunbound
))
4001 CHECK_NUMBER (tem1
);
4002 if (! (0 <= XINT (tem1
) && XINT (tem1
) <= INT_MAX
))
4003 xsignal1 (Qargs_out_of_range
, tem1
);
4004 SET_FRAME_COLS (f
, XINT (tem1
));
4006 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4007 window_prompting
|= USSize
;
4009 window_prompting
|= PSize
;
4012 f
->scroll_bar_actual_width
4013 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4015 /* This used to be done _before_ calling x_figure_window_size, but
4016 since the height is reset here, this was really a no-op. I
4017 assume that moving it here does what Gerd intended (although he
4018 no longer can remember what that was... ++KFS, 2003-03-25. */
4020 /* Add the tool-bar height to the initial frame height so that the
4021 user gets a text display area of the size he specified with -g or
4022 via .Xdefaults. Later changes of the tool-bar height don't
4023 change the frame size. This is done so that users can create
4024 tall Emacs frames without having to guess how tall the tool-bar
4026 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4028 int margin
, relief
, bar_height
;
4030 relief
= (tool_bar_button_relief
>= 0
4031 ? tool_bar_button_relief
4032 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4034 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
4035 margin
= XFASTINT (Vtool_bar_button_margin
);
4036 else if (CONSP (Vtool_bar_button_margin
)
4037 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
4038 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4042 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4043 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4046 compute_fringe_widths (f
, 0);
4048 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4049 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4051 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4052 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4053 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4054 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4056 if (EQ (tem0
, Qminus
))
4059 window_prompting
|= YNegative
;
4061 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4062 && CONSP (XCDR (tem0
))
4063 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem0
)), INT_MAX
))
4065 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4066 window_prompting
|= YNegative
;
4068 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4069 && CONSP (XCDR (tem0
))
4070 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0
))))
4072 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4074 else if (EQ (tem0
, Qunbound
))
4078 CHECK_TYPE_RANGED_INTEGER (int, tem0
);
4079 f
->top_pos
= XINT (tem0
);
4081 window_prompting
|= YNegative
;
4084 if (EQ (tem1
, Qminus
))
4087 window_prompting
|= XNegative
;
4089 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4090 && CONSP (XCDR (tem1
))
4091 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem1
)), INT_MAX
))
4093 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4094 window_prompting
|= XNegative
;
4096 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4097 && CONSP (XCDR (tem1
))
4098 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1
))))
4100 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4102 else if (EQ (tem1
, Qunbound
))
4106 CHECK_TYPE_RANGED_INTEGER (int, tem1
);
4107 f
->left_pos
= XINT (tem1
);
4108 if (f
->left_pos
< 0)
4109 window_prompting
|= XNegative
;
4112 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4113 window_prompting
|= USPosition
;
4115 window_prompting
|= PPosition
;
4118 if (window_prompting
& XNegative
)
4120 if (window_prompting
& YNegative
)
4121 f
->win_gravity
= SouthEastGravity
;
4123 f
->win_gravity
= NorthEastGravity
;
4127 if (window_prompting
& YNegative
)
4128 f
->win_gravity
= SouthWestGravity
;
4130 f
->win_gravity
= NorthWestGravity
;
4133 f
->size_hint_flags
= window_prompting
;
4135 return window_prompting
;
4140 #endif /* HAVE_WINDOW_SYSTEM */
4143 frame_make_pointer_invisible (void)
4145 if (! NILP (Vmake_pointer_invisible
))
4148 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4151 f
= SELECTED_FRAME ();
4152 if (f
&& !f
->pointer_invisible
4153 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4156 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4157 f
->pointer_invisible
= 1;
4163 frame_make_pointer_visible (void)
4165 /* We don't check Vmake_pointer_invisible here in case the
4166 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4169 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4172 f
= SELECTED_FRAME ();
4173 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4174 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4176 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4177 f
->pointer_invisible
= 0;
4181 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4182 Sframe_pointer_visible_p
, 0, 1, 0,
4183 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4184 Otherwise it returns nil. FRAME omitted or nil means the
4185 selected frame. This is useful when `make-pointer-invisible' is set. */)
4189 frame
= selected_frame
;
4191 CHECK_FRAME (frame
);
4193 return (XFRAME (frame
)->pointer_invisible
? Qnil
: Qt
);
4197 /***********************************************************************
4199 ***********************************************************************/
4202 syms_of_frame (void)
4204 DEFSYM (Qframep
, "framep");
4205 DEFSYM (Qframe_live_p
, "frame-live-p");
4206 DEFSYM (Qexplicit_name
, "explicit-name");
4207 DEFSYM (Qheight
, "height");
4208 DEFSYM (Qicon
, "icon");
4209 DEFSYM (Qminibuffer
, "minibuffer");
4210 DEFSYM (Qmodeline
, "modeline");
4211 DEFSYM (Qonly
, "only");
4212 DEFSYM (Qwidth
, "width");
4213 DEFSYM (Qgeometry
, "geometry");
4214 DEFSYM (Qicon_left
, "icon-left");
4215 DEFSYM (Qicon_top
, "icon-top");
4216 DEFSYM (Qtooltip
, "tooltip");
4217 DEFSYM (Qleft
, "left");
4218 DEFSYM (Qright
, "right");
4219 DEFSYM (Quser_position
, "user-position");
4220 DEFSYM (Quser_size
, "user-size");
4221 DEFSYM (Qwindow_id
, "window-id");
4222 #ifdef HAVE_X_WINDOWS
4223 DEFSYM (Qouter_window_id
, "outer-window-id");
4225 DEFSYM (Qparent_id
, "parent-id");
4227 DEFSYM (Qw32
, "w32");
4229 DEFSYM (Qmac
, "mac");
4231 DEFSYM (Qvisible
, "visible");
4232 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4233 DEFSYM (Qbuffer_list
, "buffer-list");
4234 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4235 DEFSYM (Qdisplay_type
, "display-type");
4236 DEFSYM (Qbackground_mode
, "background-mode");
4237 DEFSYM (Qnoelisp
, "noelisp");
4238 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4239 DEFSYM (Qtty
, "tty");
4240 DEFSYM (Qtty_type
, "tty-type");
4242 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4244 DEFSYM (Qfullwidth
, "fullwidth");
4245 DEFSYM (Qfullheight
, "fullheight");
4246 DEFSYM (Qfullboth
, "fullboth");
4247 DEFSYM (Qmaximized
, "maximized");
4248 DEFSYM (Qx_resource_name
, "x-resource-name");
4249 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4251 DEFSYM (Qterminal
, "terminal");
4252 DEFSYM (Qterminal_live_p
, "terminal-live-p");
4255 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4261 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4263 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4264 if (frame_parms
[i
].variable
)
4266 *frame_parms
[i
].variable
= v
;
4267 staticpro (frame_parms
[i
].variable
);
4269 Fput (v
, Qx_frame_parameter
, make_number (i
));
4273 #ifdef HAVE_WINDOW_SYSTEM
4274 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4275 doc
: /* The name Emacs uses to look up X resources.
4276 `x-get-resource' uses this as the first component of the instance name
4277 when requesting resource values.
4278 Emacs initially sets `x-resource-name' to the name under which Emacs
4279 was invoked, or to the value specified with the `-name' or `-rn'
4280 switches, if present.
4282 It may be useful to bind this variable locally around a call
4283 to `x-get-resource'. See also the variable `x-resource-class'. */);
4284 Vx_resource_name
= Qnil
;
4286 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4287 doc
: /* The class Emacs uses to look up X resources.
4288 `x-get-resource' uses this as the first component of the instance class
4289 when requesting resource values.
4291 Emacs initially sets `x-resource-class' to "Emacs".
4293 Setting this variable permanently is not a reasonable thing to do,
4294 but binding this variable locally around a call to `x-get-resource'
4295 is a reasonable practice. See also the variable `x-resource-name'. */);
4296 Vx_resource_class
= build_string (EMACS_CLASS
);
4298 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4299 doc
: /* The lower limit of the frame opacity (alpha transparency).
4300 The value should range from 0 (invisible) to 100 (completely opaque).
4301 You can also use a floating number between 0.0 and 1.0.
4302 The default is 20. */);
4303 Vframe_alpha_lower_limit
= make_number (20);
4306 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4307 doc
: /* Alist of default values for frame creation.
4308 These may be set in your init file, like this:
4309 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4310 These override values given in window system configuration data,
4311 including X Windows' defaults database.
4312 For values specific to the first Emacs frame, see `initial-frame-alist'.
4313 For window-system specific values, see `window-system-default-frame-alist'.
4314 For values specific to the separate minibuffer frame, see
4315 `minibuffer-frame-alist'.
4316 The `menu-bar-lines' element of the list controls whether new frames
4317 have menu bars; `menu-bar-mode' works by altering this element.
4318 Setting this variable does not affect existing frames, only new ones. */);
4319 Vdefault_frame_alist
= Qnil
;
4321 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4322 doc
: /* Default position of scroll bars on this window-system. */);
4323 #ifdef HAVE_WINDOW_SYSTEM
4324 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
4325 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4327 Vdefault_frame_scroll_bars
= Qright
;
4329 Vdefault_frame_scroll_bars
= Qleft
;
4332 Vdefault_frame_scroll_bars
= Qnil
;
4335 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4336 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4338 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4339 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4340 `mouse-position' calls this function, passing its usual return value as
4341 argument, and returns whatever this function returns.
4342 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4343 which need to do mouse handling at the Lisp level. */);
4344 Vmouse_position_function
= Qnil
;
4346 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4347 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4348 If the value is an integer, highlighting is only shown after moving the
4349 mouse, while keyboard input turns off the highlight even when the mouse
4350 is over the clickable text. However, the mouse shape still indicates
4351 when the mouse is over clickable text. */);
4352 Vmouse_highlight
= Qt
;
4354 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4355 doc
: /* If non-nil, make pointer invisible while typing.
4356 The pointer becomes visible again when the mouse is moved. */);
4357 Vmake_pointer_invisible
= Qt
;
4359 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4360 doc
: /* Functions to be run before deleting a frame.
4361 The functions are run with one arg, the frame to be deleted.
4364 Note that functions in this list may be called just before the frame is
4365 actually deleted, or some time later (or even both when an earlier function
4366 in `delete-frame-functions' (indirectly) calls `delete-frame'
4368 Vdelete_frame_functions
= Qnil
;
4369 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
4371 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4372 doc
: /* Non-nil if Menu-Bar mode is enabled.
4373 See the command `menu-bar-mode' for a description of this minor mode.
4374 Setting this variable directly does not take effect;
4375 either customize it (see the info node `Easy Customization')
4376 or call the function `menu-bar-mode'. */);
4377 Vmenu_bar_mode
= Qt
;
4379 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4380 doc
: /* Non-nil if Tool-Bar mode is enabled.
4381 See the command `tool-bar-mode' for a description of this minor mode.
4382 Setting this variable directly does not take effect;
4383 either customize it (see the info node `Easy Customization')
4384 or call the function `tool-bar-mode'. */);
4385 #ifdef HAVE_WINDOW_SYSTEM
4386 Vtool_bar_mode
= Qt
;
4388 Vtool_bar_mode
= Qnil
;
4391 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4392 doc
: /* Minibufferless frames use this frame's minibuffer.
4394 Emacs cannot create minibufferless frames unless this is set to an
4395 appropriate surrogate.
4397 Emacs consults this variable only when creating minibufferless
4398 frames; once the frame is created, it sticks with its assigned
4399 minibuffer, no matter what this variable is set to. This means that
4400 this variable doesn't necessarily say anything meaningful about the
4401 current set of frames, or where the minibuffer is currently being
4404 This variable is local to the current terminal and cannot be buffer-local. */);
4406 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
4407 doc
: /* Non-nil if window system changes focus when you move the mouse.
4408 You should set this variable to tell Emacs how your window manager
4409 handles focus, since there is no way in general for Emacs to find out
4410 automatically. See also `mouse-autoselect-window'. */);
4411 focus_follows_mouse
= 0;
4413 staticpro (&Vframe_list
);
4416 defsubr (&Sframe_live_p
);
4417 defsubr (&Swindow_system
);
4418 defsubr (&Smake_terminal_frame
);
4419 defsubr (&Shandle_switch_frame
);
4420 defsubr (&Sselect_frame
);
4421 defsubr (&Sselected_frame
);
4422 defsubr (&Sframe_list
);
4423 defsubr (&Snext_frame
);
4424 defsubr (&Sprevious_frame
);
4425 defsubr (&Sdelete_frame
);
4426 defsubr (&Smouse_position
);
4427 defsubr (&Smouse_pixel_position
);
4428 defsubr (&Sset_mouse_position
);
4429 defsubr (&Sset_mouse_pixel_position
);
4431 defsubr (&Sframe_configuration
);
4432 defsubr (&Srestore_frame_configuration
);
4434 defsubr (&Smake_frame_visible
);
4435 defsubr (&Smake_frame_invisible
);
4436 defsubr (&Siconify_frame
);
4437 defsubr (&Sframe_visible_p
);
4438 defsubr (&Svisible_frame_list
);
4439 defsubr (&Sraise_frame
);
4440 defsubr (&Slower_frame
);
4441 defsubr (&Sredirect_frame_focus
);
4442 defsubr (&Sframe_focus
);
4443 defsubr (&Sframe_parameters
);
4444 defsubr (&Sframe_parameter
);
4445 defsubr (&Smodify_frame_parameters
);
4446 defsubr (&Sframe_char_height
);
4447 defsubr (&Sframe_char_width
);
4448 defsubr (&Sframe_pixel_height
);
4449 defsubr (&Sframe_pixel_width
);
4450 defsubr (&Stool_bar_pixel_width
);
4451 defsubr (&Sset_frame_height
);
4452 defsubr (&Sset_frame_width
);
4453 defsubr (&Sset_frame_size
);
4454 defsubr (&Sset_frame_position
);
4455 defsubr (&Sframe_pointer_visible_p
);
4457 #ifdef HAVE_WINDOW_SYSTEM
4458 defsubr (&Sx_get_resource
);
4459 defsubr (&Sx_parse_geometry
);