1 /* Generic frame functions.
3 Copyright (C) 1993-1995, 1997, 1999-2013 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/>. */
29 #include "character.h"
31 #ifdef HAVE_WINDOW_SYSTEM
33 #endif /* HAVE_WINDOW_SYSTEM */
36 /* These help us bind and responding to switch-frame events. */
40 #include "blockinput.h"
42 #include "termhooks.h"
43 #include "dispextern.h"
46 #ifdef HAVE_WINDOW_SYSTEM
55 Lisp_Object Qns_parse_geometry
;
58 Lisp_Object Qframep
, Qframe_live_p
;
59 Lisp_Object Qicon
, Qmodeline
;
60 Lisp_Object Qonly
, Qnone
;
61 Lisp_Object Qx
, Qw32
, Qpc
, Qns
;
63 Lisp_Object Qdisplay_type
;
64 static Lisp_Object Qbackground_mode
;
67 static Lisp_Object Qx_frame_parameter
;
68 Lisp_Object Qx_resource_name
;
69 Lisp_Object Qterminal
;
71 /* Frame parameters (set or reported). */
73 Lisp_Object Qauto_raise
, Qauto_lower
;
74 Lisp_Object Qborder_color
, Qborder_width
;
75 Lisp_Object Qcursor_color
, Qcursor_type
;
76 Lisp_Object Qheight
, Qwidth
;
77 Lisp_Object Qleft
, Qright
;
78 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
80 Lisp_Object Qinternal_border_width
;
81 Lisp_Object Qmouse_color
;
82 Lisp_Object Qminibuffer
;
83 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
84 Lisp_Object Qvisibility
;
85 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
86 Lisp_Object Qscreen_gamma
;
87 Lisp_Object Qline_spacing
;
88 static Lisp_Object Quser_position
, Quser_size
;
89 Lisp_Object Qwait_for_wm
;
90 static Lisp_Object Qwindow_id
;
92 static Lisp_Object Qouter_window_id
;
94 Lisp_Object Qparent_id
;
95 Lisp_Object Qtitle
, Qname
;
96 static Lisp_Object Qexplicit_name
;
97 Lisp_Object Qunsplittable
;
98 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
, Qtool_bar_position
;
99 Lisp_Object Qleft_fringe
, Qright_fringe
;
100 Lisp_Object Qbuffer_predicate
;
101 static Lisp_Object Qbuffer_list
, Qburied_buffer_list
;
102 Lisp_Object Qtty_color_mode
;
103 Lisp_Object Qtty
, Qtty_type
;
105 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
107 Lisp_Object Qfont_backend
;
110 Lisp_Object Qface_set_after_frame_default
;
112 static Lisp_Object Qdelete_frame_functions
;
114 static Lisp_Object Qgeometry
, Qworkarea
, Qmm_size
, Qframes
, Qsource
;
116 #ifdef HAVE_WINDOW_SYSTEM
117 static void x_report_frame_params (struct frame
*, Lisp_Object
*);
120 /* These setters are used only in this file, so they can be private. */
122 fset_buffer_predicate (struct frame
*f
, Lisp_Object val
)
124 f
->buffer_predicate
= val
;
127 fset_minibuffer_window (struct frame
*f
, Lisp_Object val
)
129 f
->minibuffer_window
= val
;
133 decode_live_frame (register Lisp_Object frame
)
136 frame
= selected_frame
;
137 CHECK_LIVE_FRAME (frame
);
138 return XFRAME (frame
);
142 decode_any_frame (register Lisp_Object frame
)
145 frame
= selected_frame
;
147 return XFRAME (frame
);
151 window_system_available (struct frame
*f
)
154 return FRAME_WINDOW_P (f
) || FRAME_MSDOS_P (f
);
156 #ifdef HAVE_WINDOW_SYSTEM
157 return x_display_list
!= NULL
;
164 decode_window_system_frame (Lisp_Object frame
)
166 struct frame
*f
= decode_live_frame (frame
);
168 if (!window_system_available (f
))
169 error ("Window system frame should be used");
174 check_window_system (struct frame
*f
)
176 if (!window_system_available (f
))
177 error (f
? "Window system frame should be used"
178 : "Window system is not in use or not initialized");
182 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
184 struct window
*w
= XWINDOW (window
);
189 /* Handle just the top child in a vertical split. */
190 if (WINDOW_VERTICAL_COMBINATION_P (w
))
191 set_menu_bar_lines_1 (w
->contents
, n
);
192 else if (WINDOW_HORIZONTAL_COMBINATION_P (w
))
193 /* Adjust all children in a horizontal split. */
194 for (window
= w
->contents
; !NILP (window
); window
= w
->next
)
196 w
= XWINDOW (window
);
197 set_menu_bar_lines_1 (window
, n
);
202 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
205 int olines
= FRAME_MENU_BAR_LINES (f
);
207 /* Right now, menu bars don't work properly in minibuf-only frames;
208 most of the commands try to apply themselves to the minibuffer
209 frame itself, and get an error because you can't switch buffers
210 in or split the minibuffer window. */
211 if (FRAME_MINIBUF_ONLY_P (f
))
214 if (TYPE_RANGED_INTEGERP (int, value
))
215 nlines
= XINT (value
);
219 if (nlines
!= olines
)
221 windows_or_buffers_changed
++;
222 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
223 FRAME_MENU_BAR_LINES (f
) = nlines
;
224 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
225 adjust_frame_glyphs (f
);
229 Lisp_Object Vframe_list
;
232 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
233 doc
: /* Return non-nil if OBJECT is a frame.
235 t for a termcap frame (a character-only terminal),
236 'x' for an Emacs frame that is really an X window,
237 'w32' for an Emacs frame that is a window on MS-Windows display,
238 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
239 'pc' for a direct-write MS-DOS frame.
240 See also `frame-live-p'. */)
243 if (!FRAMEP (object
))
245 switch (XFRAME (object
)->output_method
)
247 case output_initial
: /* The initial frame is like a termcap frame. */
250 case output_x_window
:
254 case output_msdos_raw
:
263 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
264 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
265 Value is nil if OBJECT is not a live frame. If object is a live
266 frame, the return value indicates what sort of terminal device it is
267 displayed on. See the documentation of `framep' for possible
271 return ((FRAMEP (object
)
272 && FRAME_LIVE_P (XFRAME (object
)))
277 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
278 doc
: /* The name of the window system that FRAME is displaying through.
279 The value is a symbol:
280 nil for a termcap frame (a character-only terminal),
281 'x' for an Emacs frame that is really an X window,
282 'w32' for an Emacs frame that is a window on MS-Windows display,
283 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
284 'pc' for a direct-write MS-DOS frame.
286 FRAME defaults to the currently selected frame.
288 Use of this function as a predicate is deprecated. Instead,
289 use `display-graphic-p' or any of the other `display-*-p'
290 predicates which report frame's specific UI-related capabilities. */)
295 frame
= selected_frame
;
297 type
= Fframep (frame
);
300 wrong_type_argument (Qframep
, frame
);
309 make_frame (bool mini_p
)
312 register struct frame
*f
;
313 register Lisp_Object root_window
;
314 register Lisp_Object mini_window
;
316 f
= allocate_frame ();
317 XSETFRAME (frame
, f
);
319 /* Initialize Lisp data. Note that allocate_frame initializes all
320 Lisp data to nil, so do it only for slots which should not be nil. */
321 fset_tool_bar_position (f
, Qtop
);
323 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
324 non-Lisp data, so do it only for slots which should not be zero.
325 To avoid subtle bugs and for the sake of readability, it's better to
326 initialize enum members explicitly even if their values are zero. */
327 f
->wants_modeline
= 1;
329 f
->has_minibuffer
= mini_p
;
330 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
331 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
332 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
333 #ifdef HAVE_WINDOW_SYSTEM
334 f
->want_fullscreen
= FULLSCREEN_NONE
;
337 root_window
= make_window ();
340 mini_window
= make_window ();
341 wset_next (XWINDOW (root_window
), mini_window
);
342 wset_prev (XWINDOW (mini_window
), root_window
);
343 XWINDOW (mini_window
)->mini
= 1;
344 wset_frame (XWINDOW (mini_window
), frame
);
345 fset_minibuffer_window (f
, mini_window
);
350 wset_next (XWINDOW (root_window
), Qnil
);
351 fset_minibuffer_window (f
, Qnil
);
354 wset_frame (XWINDOW (root_window
), frame
);
357 just so that there is "something there."
358 Correct size will be set up later with change_frame_size. */
360 SET_FRAME_COLS (f
, 10);
361 FRAME_LINES (f
) = 10;
363 XWINDOW (root_window
)->total_cols
= 10;
364 XWINDOW (root_window
)->total_lines
= mini_p
? 9 : 10;
368 XWINDOW (mini_window
)->total_cols
= 10;
369 XWINDOW (mini_window
)->top_line
= 9;
370 XWINDOW (mini_window
)->total_lines
= 1;
373 /* Choose a buffer for the frame's root window. */
375 Lisp_Object buf
= Fcurrent_buffer ();
377 /* If current buffer is hidden, try to find another one. */
378 if (BUFFER_HIDDEN_P (XBUFFER (buf
)))
379 buf
= other_buffer_safely (buf
);
381 /* Use set_window_buffer, not Fset_window_buffer, and don't let
382 hooks be run by it. The reason is that the whole frame/window
383 arrangement is not yet fully initialized at this point. Windows
384 don't have the right size, glyph matrices aren't initialized
385 etc. Running Lisp functions at this point surely ends in a
387 set_window_buffer (root_window
, buf
, 0, 0);
388 fset_buffer_list (f
, list1 (buf
));
392 set_window_buffer (mini_window
,
393 (NILP (Vminibuffer_list
)
395 : Fcar (Vminibuffer_list
)),
398 fset_root_window (f
, root_window
);
399 fset_selected_window (f
, root_window
);
400 /* Make sure this window seems more recently used than
401 a newly-created, never-selected window. */
402 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
407 #ifdef HAVE_WINDOW_SYSTEM
408 /* Make a frame using a separate minibuffer window on another frame.
409 MINI_WINDOW is the minibuffer window to use. nil means use the
410 default (the global minibuffer). */
413 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
415 register struct frame
*f
;
418 if (!NILP (mini_window
))
419 CHECK_LIVE_WINDOW (mini_window
);
421 if (!NILP (mini_window
)
422 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
423 error ("Frame and minibuffer must be on the same terminal");
425 /* Make a frame containing just a root window. */
428 if (NILP (mini_window
))
430 /* Use default-minibuffer-frame if possible. */
431 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
432 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
434 Lisp_Object frame_dummy
;
436 XSETFRAME (frame_dummy
, f
);
437 GCPRO1 (frame_dummy
);
438 /* If there's no minibuffer frame to use, create one. */
439 kset_default_minibuffer_frame
440 (kb
, call1 (intern ("make-initial-minibuffer-frame"), display
));
445 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
448 fset_minibuffer_window (f
, mini_window
);
450 /* Make the chosen minibuffer window display the proper minibuffer,
451 unless it is already showing a minibuffer. */
452 if (NILP (Fmemq (XWINDOW (mini_window
)->contents
, Vminibuffer_list
)))
453 /* Use set_window_buffer instead of Fset_window_buffer (see
454 discussion of bug#11984, bug#12025, bug#12026). */
455 set_window_buffer (mini_window
,
456 (NILP (Vminibuffer_list
)
458 : Fcar (Vminibuffer_list
)), 0, 0);
462 /* Make a frame containing only a minibuffer window. */
465 make_minibuffer_frame (void)
467 /* First make a frame containing just a root window, no minibuffer. */
469 register struct frame
*f
= make_frame (0);
470 register Lisp_Object mini_window
;
471 register Lisp_Object frame
;
473 XSETFRAME (frame
, f
);
478 f
->wants_modeline
= 0;
479 f
->has_minibuffer
= 1;
481 /* Now label the root window as also being the minibuffer.
482 Avoid infinite looping on the window chain by marking next pointer
485 mini_window
= f
->root_window
;
486 fset_minibuffer_window (f
, mini_window
);
487 XWINDOW (mini_window
)->mini
= 1;
488 wset_next (XWINDOW (mini_window
), Qnil
);
489 wset_prev (XWINDOW (mini_window
), Qnil
);
490 wset_frame (XWINDOW (mini_window
), frame
);
492 /* Put the proper buffer in that window. */
494 /* Use set_window_buffer instead of Fset_window_buffer (see
495 discussion of bug#11984, bug#12025, bug#12026). */
496 set_window_buffer (mini_window
,
497 (NILP (Vminibuffer_list
)
499 : Fcar (Vminibuffer_list
)), 0, 0);
502 #endif /* HAVE_WINDOW_SYSTEM */
504 /* Construct a frame that refers to a terminal. */
506 static printmax_t tty_frame_count
;
509 make_initial_frame (void)
512 struct terminal
*terminal
;
515 eassert (initial_kboard
);
517 /* The first call must initialize Vframe_list. */
518 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
521 terminal
= init_initial_terminal ();
524 XSETFRAME (frame
, f
);
526 Vframe_list
= Fcons (frame
, Vframe_list
);
529 fset_name (f
, build_pure_c_string ("F1"));
531 SET_FRAME_VISIBLE (f
, 1);
533 f
->output_method
= terminal
->type
;
534 f
->terminal
= terminal
;
535 f
->terminal
->reference_count
++;
536 f
->output_data
.nothing
= 0;
538 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
539 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
541 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
543 /* The default value of menu-bar-mode is t. */
544 set_menu_bar_lines (f
, make_number (1), Qnil
);
547 init_frame_faces (f
);
553 static struct frame
*
554 make_terminal_frame (struct terminal
*terminal
)
556 register struct frame
*f
;
558 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
561 error ("Terminal is not live, can't create new frames on it");
565 XSETFRAME (frame
, f
);
566 Vframe_list
= Fcons (frame
, Vframe_list
);
568 fset_name (f
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
570 SET_FRAME_VISIBLE (f
, 1);
572 f
->terminal
= terminal
;
573 f
->terminal
->reference_count
++;
575 f
->output_data
.tty
->display_info
= &the_only_display_info
;
576 if (!inhibit_window_system
577 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
578 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
579 f
->output_method
= output_msdos_raw
;
581 f
->output_method
= output_termcap
;
582 #else /* not MSDOS */
583 f
->output_method
= output_termcap
;
584 create_tty_output (f
);
585 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
586 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
587 #endif /* not MSDOS */
589 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
590 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
592 /* Set the top frame to the newly created frame. */
593 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
594 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
595 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f
)->top_frame
), 2); /* obscured */
597 FRAME_TTY (f
)->top_frame
= frame
;
600 init_frame_faces (f
);
605 /* Get a suitable value for frame parameter PARAMETER for a newly
606 created frame, based on (1) the user-supplied frame parameter
607 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
610 get_future_frame_param (Lisp_Object parameter
,
611 Lisp_Object supplied_parms
,
616 result
= Fassq (parameter
, supplied_parms
);
618 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
619 if (NILP (result
) && current_value
!= NULL
)
620 result
= build_string (current_value
);
621 if (!NILP (result
) && !STRINGP (result
))
622 result
= XCDR (result
);
623 if (NILP (result
) || !STRINGP (result
))
629 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
631 doc
: /* Create an additional terminal frame, possibly on another terminal.
632 This function takes one argument, an alist specifying frame parameters.
634 You can create multiple frames on a single text terminal, but only one
635 of them (the selected terminal frame) is actually displayed.
637 In practice, generally you don't need to specify any parameters,
638 except when you want to create a new frame on another terminal.
639 In that case, the `tty' parameter specifies the device file to open,
640 and the `tty-type' parameter specifies the terminal type. Example:
642 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
644 Note that changing the size of one terminal frame automatically
645 affects all frames on the same terminal device. */)
649 struct terminal
*t
= NULL
;
650 Lisp_Object frame
, tem
;
651 struct frame
*sf
= SELECTED_FRAME ();
654 if (sf
->output_method
!= output_msdos_raw
655 && sf
->output_method
!= output_termcap
)
657 #else /* not MSDOS */
659 #ifdef WINDOWSNT /* This should work now! */
660 if (sf
->output_method
!= output_termcap
)
661 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
663 #endif /* not MSDOS */
666 Lisp_Object terminal
;
668 terminal
= Fassq (Qterminal
, parms
);
669 if (CONSP (terminal
))
671 terminal
= XCDR (terminal
);
672 t
= get_terminal (terminal
, 1);
675 if (t
&& t
!= the_only_display_info
.terminal
)
676 /* msdos.c assumes a single tty_display_info object. */
677 error ("Multiple terminals are not supported on this platform");
679 t
= the_only_display_info
.terminal
;
685 char *name
= 0, *type
= 0;
686 Lisp_Object tty
, tty_type
;
688 tty
= get_future_frame_param
689 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
690 ? FRAME_TTY (XFRAME (selected_frame
))->name
693 name
= xlispstrdupa (tty
);
695 tty_type
= get_future_frame_param
696 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
697 ? FRAME_TTY (XFRAME (selected_frame
))->type
699 if (!NILP (tty_type
))
700 type
= xlispstrdupa (tty_type
);
702 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
705 f
= make_terminal_frame (t
);
709 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
710 change_frame_size (f
, height
, width
, 0, 0, 0);
713 adjust_frame_glyphs (f
);
715 XSETFRAME (frame
, f
);
717 store_in_alist (&parms
, Qtty_type
, build_string (t
->display_info
.tty
->type
));
718 store_in_alist (&parms
, Qtty
,
719 (t
->display_info
.tty
->name
720 ? build_string (t
->display_info
.tty
->name
)
722 Fmodify_frame_parameters (frame
, parms
);
724 /* Make the frame face alist be frame-specific, so that each
725 frame could change its face definitions independently. */
726 fset_face_alist (f
, Fcopy_alist (sf
->face_alist
));
727 /* Simple Fcopy_alist isn't enough, because we need the contents of
728 the vectors which are the CDRs of associations in face_alist to
729 be copied as well. */
730 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
731 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
736 /* Perform the switch to frame FRAME.
738 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
741 If TRACK is non-zero and the frame that currently has the focus
742 redirects its focus to the selected frame, redirect that focused
743 frame's focus to FRAME instead.
745 FOR_DELETION non-zero means that the selected frame is being
746 deleted, which includes the possibility that the frame's terminal
749 The value of NORECORD is passed as argument to Fselect_window. */
752 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
754 struct frame
*sf
= SELECTED_FRAME ();
756 /* If FRAME is a switch-frame event, extract the frame we should
759 && EQ (XCAR (frame
), Qswitch_frame
)
760 && CONSP (XCDR (frame
)))
761 frame
= XCAR (XCDR (frame
));
763 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
764 a switch-frame event to arrive after a frame is no longer live,
765 especially when deleting the initial frame during startup. */
767 if (! FRAME_LIVE_P (XFRAME (frame
)))
770 if (sf
== XFRAME (frame
))
773 /* This is too greedy; it causes inappropriate focus redirection
774 that's hard to get rid of. */
776 /* If a frame's focus has been redirected toward the currently
777 selected frame, we should change the redirection to point to the
778 newly selected frame. This means that if the focus is redirected
779 from a minibufferless frame to a surrogate minibuffer frame, we
780 can use `other-window' to switch between all the frames using
781 that minibuffer frame, and the focus redirection will follow us
787 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
791 if (!FRAMEP (XCAR (tail
)))
794 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
796 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
797 Fredirect_frame_focus (XCAR (tail
), frame
);
801 /* Instead, apply it only to the frame we're pointing to. */
802 #ifdef HAVE_WINDOW_SYSTEM
803 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
805 Lisp_Object focus
, xfocus
;
807 xfocus
= x_get_focus_frame (XFRAME (frame
));
810 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
811 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
812 Fredirect_frame_focus (xfocus
, frame
);
815 #endif /* HAVE_X_WINDOWS */
818 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
819 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
821 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
823 Lisp_Object top_frame
= FRAME_TTY (XFRAME (frame
))->top_frame
;
825 /* Don't mark the frame garbaged and/or obscured if we are
826 switching to the frame that is already the top frame of that
828 if (!EQ (frame
, top_frame
))
830 if (FRAMEP (top_frame
))
831 /* Mark previously displayed frame as now obscured. */
832 SET_FRAME_VISIBLE (XFRAME (top_frame
), 2);
833 SET_FRAME_VISIBLE (XFRAME (frame
), 1);
835 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
838 selected_frame
= frame
;
839 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
840 last_nonminibuf_frame
= XFRAME (selected_frame
);
842 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
844 /* We want to make sure that the next event generates a frame-switch
845 event to the appropriate frame. This seems kludgy to me, but
846 before you take it out, make sure that evaluating something like
847 (select-window (frame-root-window (new-frame))) doesn't end up
848 with your typing being interpreted in the new frame instead of
849 the one you're actually typing in. */
850 internal_last_event_frame
= Qnil
;
855 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
856 doc
: /* Select FRAME.
857 Subsequent editing commands apply to its selected window.
858 Optional argument NORECORD means to neither change the order of
859 recently selected windows nor the buffer list.
861 The selection of FRAME lasts until the next time the user does
862 something to select a different frame, or until the next time
863 this function is called. If you are using a window system, the
864 previously selected frame may be restored as the selected frame
865 when returning to the command loop, because it still may have
866 the window system's input focus. On a text terminal, the next
867 redisplay will display FRAME.
869 This function returns FRAME, or nil if FRAME has been deleted. */)
870 (Lisp_Object frame
, Lisp_Object norecord
)
872 return do_switch_frame (frame
, 1, 0, norecord
);
875 DEFUN ("handle-focus-in", Fhandle_focus_in
, Shandle_focus_in
, 1, 1, "e",
876 doc
: /* Handle a focus-in event.
877 Focus in events are usually bound to this function.
878 Focus in events occur when a frame has focus, but a switch-frame event
880 This function checks if blink-cursor timers should be turned on again. */)
883 return call0 (intern ("blink-cursor-check"));
886 DEFUN ("handle-focus-out", Fhandle_focus_out
, Shandle_focus_out
, 1, 1, "e",
887 doc
: /* Handle a focus-out event.
888 Focus out events are usually bound to this function.
889 Focus out events occur when no frame has focus.
890 This function checks if blink-cursor timers should be turned off. */)
893 return call0 (intern ("blink-cursor-suspend"));
896 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
897 doc
: /* Handle a switch-frame event EVENT.
898 Switch-frame events are usually bound to this function.
899 A switch-frame event tells Emacs that the window manager has requested
900 that the user's events be directed to the frame mentioned in the event.
901 This function selects the selected window of the frame of EVENT.
903 If EVENT is frame object, handle it as if it were a switch-frame event
907 /* Preserve prefix arg that the command loop just cleared. */
908 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
909 Frun_hooks (1, &Qmouse_leave_buffer_hook
);
910 Fhandle_focus_in (event
); // switch-frame implies a focus in.
911 return do_switch_frame (event
, 0, 0, Qnil
);
914 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
915 doc
: /* Return the frame that is now selected. */)
918 return selected_frame
;
921 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
923 doc
: /* Return a list of all live frames. */)
927 frames
= Fcopy_sequence (Vframe_list
);
928 #ifdef HAVE_WINDOW_SYSTEM
929 if (FRAMEP (tip_frame
))
930 frames
= Fdelq (tip_frame
, frames
);
935 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
936 same tty (for tty frames) or among frames which uses FRAME's keyboard.
937 If MINIBUF is nil, do not consider minibuffer-only candidate.
938 If MINIBUF is `visible', do not consider an invisible candidate.
939 If MINIBUF is a window, consider only its own frame and candidate now
940 using that window as the minibuffer.
941 If MINIBUF is 0, consider candidate if it is visible or iconified.
942 Otherwise consider any candidate and return nil if CANDIDATE is not
946 candidate_frame (Lisp_Object candidate
, Lisp_Object frame
, Lisp_Object minibuf
)
948 struct frame
*c
= XFRAME (candidate
), *f
= XFRAME (frame
);
950 if ((!FRAME_TERMCAP_P (c
) && !FRAME_TERMCAP_P (f
)
951 && FRAME_KBOARD (c
) == FRAME_KBOARD (f
))
952 || (FRAME_TERMCAP_P (c
) && FRAME_TERMCAP_P (f
)
953 && FRAME_TTY (c
) == FRAME_TTY (f
)))
957 if (!FRAME_MINIBUF_ONLY_P (c
))
960 else if (EQ (minibuf
, Qvisible
))
962 if (FRAME_VISIBLE_P (c
))
965 else if (WINDOWP (minibuf
))
967 if (EQ (FRAME_MINIBUF_WINDOW (c
), minibuf
)
968 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), candidate
)
969 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
970 FRAME_FOCUS_FRAME (c
)))
973 else if (XFASTINT (minibuf
) == 0)
975 if (FRAME_VISIBLE_P (c
) || FRAME_ICONIFIED_P (c
))
984 /* Return the next frame in the frame list after FRAME. */
987 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
992 /* There must always be at least one frame in Vframe_list. */
993 eassert (CONSP (Vframe_list
));
996 FOR_EACH_FRAME (tail
, f
)
1000 f
= candidate_frame (f
, frame
, minibuf
);
1010 /* Return the previous frame in the frame list before FRAME. */
1013 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1015 Lisp_Object f
, tail
, prev
= Qnil
;
1017 /* There must always be at least one frame in Vframe_list. */
1018 eassert (CONSP (Vframe_list
));
1020 FOR_EACH_FRAME (tail
, f
)
1022 if (EQ (frame
, f
) && !NILP (prev
))
1024 f
= candidate_frame (f
, frame
, minibuf
);
1029 /* We've scanned the entire list. */
1031 /* We went through the whole frame list without finding a single
1032 acceptable frame. Return the original frame. */
1035 /* There were no acceptable frames in the list before FRAME; otherwise,
1036 we would have returned directly from the loop. Since PREV is the last
1037 acceptable frame in the list, return it. */
1042 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1043 doc
: /* Return the next frame in the frame list after FRAME.
1044 It considers only frames on the same terminal as FRAME.
1045 By default, skip minibuffer-only frames.
1046 If omitted, FRAME defaults to the selected frame.
1047 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1048 If MINIFRAME is a window, include only its own frame
1049 and any frame now using that window as the minibuffer.
1050 If MINIFRAME is `visible', include all visible frames.
1051 If MINIFRAME is 0, include all visible and iconified frames.
1052 Otherwise, include all frames. */)
1053 (Lisp_Object frame
, Lisp_Object miniframe
)
1056 frame
= selected_frame
;
1057 CHECK_LIVE_FRAME (frame
);
1058 return next_frame (frame
, miniframe
);
1061 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1062 doc
: /* Return the previous frame in the frame list before FRAME.
1063 It considers only frames on the same terminal as FRAME.
1064 By default, skip minibuffer-only frames.
1065 If omitted, FRAME defaults to the selected frame.
1066 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1067 If MINIFRAME is a window, include only its own frame
1068 and any frame now using that window as the minibuffer.
1069 If MINIFRAME is `visible', include all visible frames.
1070 If MINIFRAME is 0, include all visible and iconified frames.
1071 Otherwise, include all frames. */)
1072 (Lisp_Object frame
, Lisp_Object miniframe
)
1075 frame
= selected_frame
;
1076 CHECK_LIVE_FRAME (frame
);
1077 return prev_frame (frame
, miniframe
);
1080 DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame
,
1081 Slast_nonminibuf_frame
, 0, 0, 0,
1082 doc
: /* Return last non-minibuffer frame selected. */)
1085 Lisp_Object frame
= Qnil
;
1087 if (last_nonminibuf_frame
)
1088 XSETFRAME (frame
, last_nonminibuf_frame
);
1093 /* Return 1 if it is ok to delete frame F;
1094 0 if all frames aside from F are invisible.
1095 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1098 other_visible_frames (struct frame
*f
)
1100 Lisp_Object frames
, this;
1102 FOR_EACH_FRAME (frames
, this)
1104 if (f
== XFRAME (this))
1107 /* Verify that we can still talk to the frame's X window,
1108 and note any recent change in visibility. */
1109 #ifdef HAVE_X_WINDOWS
1110 if (FRAME_WINDOW_P (XFRAME (this)))
1111 x_sync (XFRAME (this));
1114 if (FRAME_VISIBLE_P (XFRAME (this))
1115 || FRAME_ICONIFIED_P (XFRAME (this))
1116 /* Allow deleting the terminal frame when at least one X
1118 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1124 /* Make sure that minibuf_window doesn't refer to FRAME's minibuffer
1125 window. Preferably use the selected frame's minibuffer window
1126 instead. If the selected frame doesn't have one, get some other
1127 frame's minibuffer window. SELECT non-zero means select the new
1128 minibuffer window. */
1130 check_minibuf_window (Lisp_Object frame
, int select
)
1132 struct frame
*f
= decode_live_frame (frame
);
1134 XSETFRAME (frame
, f
);
1136 if (WINDOWP (minibuf_window
) && EQ (f
->minibuffer_window
, minibuf_window
))
1138 Lisp_Object frames
, this, window
= make_number (0);
1140 if (!EQ (frame
, selected_frame
)
1141 && FRAME_HAS_MINIBUF_P (XFRAME (selected_frame
)))
1142 window
= FRAME_MINIBUF_WINDOW (XFRAME (selected_frame
));
1144 FOR_EACH_FRAME (frames
, this)
1146 if (!EQ (this, frame
) && FRAME_HAS_MINIBUF_P (XFRAME (this)))
1148 window
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1153 /* Don't abort if no window was found (Bug#15247). */
1154 if (WINDOWP (window
))
1156 /* Use set_window_buffer instead of Fset_window_buffer (see
1157 discussion of bug#11984, bug#12025, bug#12026). */
1158 set_window_buffer (window
, XWINDOW (minibuf_window
)->contents
, 0, 0);
1159 minibuf_window
= window
;
1161 /* SELECT non-zero usually means that FRAME's minibuffer
1162 window was selected; select the new one. */
1164 Fselect_window (minibuf_window
, Qnil
);
1170 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1171 unconditionally. x_connection_closed and delete_terminal use
1172 this. Any other value of FORCE implements the semantics
1173 described for Fdelete_frame. */
1175 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1177 struct frame
*f
= decode_any_frame (frame
);
1178 struct frame
*sf
= SELECTED_FRAME ();
1181 int minibuffer_selected
, is_tooltip_frame
;
1183 if (! FRAME_LIVE_P (f
))
1186 if (NILP (force
) && !other_visible_frames (f
))
1187 error ("Attempt to delete the sole visible or iconified frame");
1189 /* x_connection_closed must have set FORCE to `noelisp' in order
1190 to delete the last frame, if it is gone. */
1191 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1192 error ("Attempt to delete the only frame");
1194 XSETFRAME (frame
, f
);
1196 /* Does this frame have a minibuffer, and is it the surrogate
1197 minibuffer for any other frame? */
1198 if (FRAME_HAS_MINIBUF_P (f
))
1200 Lisp_Object frames
, this;
1202 FOR_EACH_FRAME (frames
, this)
1206 if (EQ (this, frame
))
1209 fminiw
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1211 if (WINDOWP (fminiw
) && EQ (frame
, WINDOW_FRAME (XWINDOW (fminiw
))))
1213 /* If we MUST delete this frame, delete the other first.
1214 But do this only if FORCE equals `noelisp'. */
1215 if (EQ (force
, Qnoelisp
))
1216 delete_frame (this, Qnoelisp
);
1218 error ("Attempt to delete a surrogate minibuffer frame");
1223 is_tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1225 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1226 frame is a tooltip. FORCE is set to `noelisp' when handling
1227 a disconnect from the terminal, so we don't dare call Lisp
1229 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1231 else if (EQ (force
, Qnoelisp
))
1233 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1237 #ifdef HAVE_X_WINDOWS
1238 /* Also, save clipboard to the clipboard manager. */
1239 x_clipboard_manager_save_frame (frame
);
1242 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1245 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1246 if (! FRAME_LIVE_P (f
))
1249 /* At this point, we are committed to deleting the frame.
1250 There is no more chance for errors to prevent it. */
1252 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1254 /* Don't let the frame remain selected. */
1258 Lisp_Object frame1
= Qnil
;
1260 /* Look for another visible frame on the same terminal.
1261 Do not call next_frame here because it may loop forever.
1262 See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15025. */
1263 FOR_EACH_FRAME (tail
, frame1
)
1264 if (!EQ (frame
, frame1
)
1265 && (FRAME_TERMINAL (XFRAME (frame
))
1266 == FRAME_TERMINAL (XFRAME (frame1
)))
1267 && FRAME_VISIBLE_P (XFRAME (frame1
)))
1270 /* If there is none, find *some* other frame. */
1271 if (NILP (frame1
) || EQ (frame1
, frame
))
1273 FOR_EACH_FRAME (tail
, frame1
)
1275 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1277 /* Do not change a text terminal's top-frame. */
1278 struct frame
*f1
= XFRAME (frame1
);
1279 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1281 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1282 if (!EQ (top_frame
, frame
))
1289 #ifdef NS_IMPL_COCOA
1291 /* Under NS, there is no system mechanism for choosing a new
1292 window to get focus -- it is left to application code.
1293 So the portion of THIS application interfacing with NS
1294 needs to know about it. We call Fraise_frame, but the
1295 purpose is really to transfer focus. */
1296 Fraise_frame (frame1
);
1299 do_switch_frame (frame1
, 0, 1, Qnil
);
1300 sf
= SELECTED_FRAME ();
1303 /* Don't allow minibuf_window to remain on a deleted frame. */
1304 check_minibuf_window (frame
, minibuffer_selected
);
1306 /* Don't let echo_area_window to remain on a deleted frame. */
1307 if (EQ (f
->minibuffer_window
, echo_area_window
))
1308 echo_area_window
= sf
->minibuffer_window
;
1310 /* Clear any X selections for this frame. */
1311 #ifdef HAVE_X_WINDOWS
1313 x_clear_frame_selections (f
);
1317 This function must be called before the window tree of the
1318 frame is deleted because windows contain dynamically allocated
1322 #ifdef HAVE_WINDOW_SYSTEM
1323 /* Give chance to each font driver to free a frame specific data. */
1324 font_update_drivers (f
, Qnil
);
1327 /* Mark all the windows that used to be on FRAME as deleted, and then
1328 remove the reference to them. */
1329 delete_all_child_windows (f
->root_window
);
1330 fset_root_window (f
, Qnil
);
1332 Vframe_list
= Fdelq (frame
, Vframe_list
);
1333 SET_FRAME_VISIBLE (f
, 0);
1335 /* Allow the vector of menu bar contents to be freed in the next
1336 garbage collection. The frame object itself may not be garbage
1337 collected until much later, because recent_keys and other data
1338 structures can still refer to it. */
1339 fset_menu_bar_vector (f
, Qnil
);
1341 /* If FRAME's buffer lists contains killed
1342 buffers, this helps GC to reclaim them. */
1343 fset_buffer_list (f
, Qnil
);
1344 fset_buried_buffer_list (f
, Qnil
);
1346 free_font_driver_list (f
);
1348 xfree (f
->decode_mode_spec_buffer
);
1349 xfree (FRAME_INSERT_COST (f
));
1350 xfree (FRAME_DELETEN_COST (f
));
1351 xfree (FRAME_INSERTN_COST (f
));
1352 xfree (FRAME_DELETE_COST (f
));
1354 /* Since some events are handled at the interrupt level, we may get
1355 an event for f at any time; if we zero out the frame's terminal
1356 now, then we may trip up the event-handling code. Instead, we'll
1357 promise that the terminal of the frame must be valid until we
1358 have called the window-system-dependent frame destruction
1361 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1362 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1365 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1366 f
->output_data
.nothing
= 0;
1367 f
->terminal
= 0; /* Now the frame is dead. */
1369 /* If needed, delete the terminal that this frame was on.
1370 (This must be done after the frame is killed.) */
1371 terminal
->reference_count
--;
1373 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1375 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1376 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1377 terminal
->reference_count
= 1;
1378 #endif /* USE_GTK */
1379 if (terminal
->reference_count
== 0)
1382 XSETTERMINAL (tmp
, terminal
);
1385 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1388 kb
= terminal
->kboard
;
1391 /* If we've deleted the last_nonminibuf_frame, then try to find
1393 if (f
== last_nonminibuf_frame
)
1395 Lisp_Object frames
, this;
1397 last_nonminibuf_frame
= 0;
1399 FOR_EACH_FRAME (frames
, this)
1402 if (!FRAME_MINIBUF_ONLY_P (f
))
1404 last_nonminibuf_frame
= f
;
1410 /* If there's no other frame on the same kboard, get out of
1411 single-kboard state if we're in it for this kboard. */
1414 Lisp_Object frames
, this;
1415 /* Some frame we found on the same kboard, or nil if there are none. */
1416 Lisp_Object frame_on_same_kboard
= Qnil
;
1418 FOR_EACH_FRAME (frames
, this)
1419 if (kb
== FRAME_KBOARD (XFRAME (this)))
1420 frame_on_same_kboard
= this;
1422 if (NILP (frame_on_same_kboard
))
1423 not_single_kboard_state (kb
);
1427 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1428 find another one. Prefer minibuffer-only frames, but also notice
1429 frames with other windows. */
1430 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1432 Lisp_Object frames
, this;
1434 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1435 Lisp_Object frame_with_minibuf
= Qnil
;
1436 /* Some frame we found on the same kboard, or nil if there are none. */
1437 Lisp_Object frame_on_same_kboard
= Qnil
;
1439 FOR_EACH_FRAME (frames
, this)
1441 struct frame
*f1
= XFRAME (this);
1443 /* Consider only frames on the same kboard
1444 and only those with minibuffers. */
1445 if (kb
== FRAME_KBOARD (f1
)
1446 && FRAME_HAS_MINIBUF_P (f1
))
1448 frame_with_minibuf
= this;
1449 if (FRAME_MINIBUF_ONLY_P (f1
))
1453 if (kb
== FRAME_KBOARD (f1
))
1454 frame_on_same_kboard
= this;
1457 if (!NILP (frame_on_same_kboard
))
1459 /* We know that there must be some frame with a minibuffer out
1460 there. If this were not true, all of the frames present
1461 would have to be minibufferless, which implies that at some
1462 point their minibuffer frames must have been deleted, but
1463 that is prohibited at the top; you can't delete surrogate
1464 minibuffer frames. */
1465 if (NILP (frame_with_minibuf
))
1468 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
1471 /* No frames left on this kboard--say no minibuffer either. */
1472 kset_default_minibuffer_frame (kb
, Qnil
);
1475 /* Cause frame titles to update--necessary if we now have just one frame. */
1476 if (!is_tooltip_frame
)
1477 update_mode_lines
= 1;
1482 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1483 doc
: /* Delete FRAME, permanently eliminating it from use.
1484 FRAME defaults to the selected frame.
1486 A frame may not be deleted if its minibuffer is used by other frames.
1487 Normally, you may not delete a frame if all other frames are invisible,
1488 but if the second optional argument FORCE is non-nil, you may do so.
1490 This function runs `delete-frame-functions' before actually
1491 deleting the frame, unless the frame is a tooltip.
1492 The functions are run with one argument, the frame to be deleted. */)
1493 (Lisp_Object frame
, Lisp_Object force
)
1495 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1499 /* Return mouse position in character cell units. */
1501 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1502 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1503 The position is given in character cells, where (0, 0) is the
1504 upper-left corner of the frame, X is the horizontal offset, and Y is
1505 the vertical offset.
1506 If Emacs is running on a mouseless terminal or hasn't been programmed
1507 to read the mouse position, it returns the selected frame for FRAME
1508 and nil for X and Y.
1509 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1510 passing the normal return value to that function as an argument,
1511 and returns whatever that function returns. */)
1515 Lisp_Object lispy_dummy
;
1516 Lisp_Object x
, y
, retval
;
1517 struct gcpro gcpro1
;
1519 f
= SELECTED_FRAME ();
1522 /* It's okay for the hook to refrain from storing anything. */
1523 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1525 enum scroll_bar_part party_dummy
;
1527 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1528 &lispy_dummy
, &party_dummy
,
1537 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1541 XSETFRAME (lispy_dummy
, f
);
1542 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1544 if (!NILP (Vmouse_position_function
))
1545 retval
= call1 (Vmouse_position_function
, retval
);
1546 RETURN_UNGCPRO (retval
);
1549 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1550 Smouse_pixel_position
, 0, 0, 0,
1551 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1552 The position is given in pixel units, where (0, 0) is the
1553 upper-left corner of the frame, X is the horizontal offset, and Y is
1554 the vertical offset.
1555 If Emacs is running on a mouseless terminal or hasn't been programmed
1556 to read the mouse position, it returns the selected frame for FRAME
1557 and nil for X and Y. */)
1561 Lisp_Object lispy_dummy
;
1564 f
= SELECTED_FRAME ();
1567 /* It's okay for the hook to refrain from storing anything. */
1568 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1570 enum scroll_bar_part party_dummy
;
1572 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1573 &lispy_dummy
, &party_dummy
,
1578 XSETFRAME (lispy_dummy
, f
);
1579 return Fcons (lispy_dummy
, Fcons (x
, y
));
1582 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1583 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1584 Coordinates are relative to the frame, not a window,
1585 so the coordinates of the top left character in the frame
1586 may be nonzero due to left-hand scroll bars or the menu bar.
1588 The position is given in character cells, where (0, 0) is the
1589 upper-left corner of the frame, X is the horizontal offset, and Y is
1590 the vertical offset.
1592 This function is a no-op for an X frame that is not visible.
1593 If you have just created a frame, you must wait for it to become visible
1594 before calling this function on it, like this.
1595 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1596 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1598 CHECK_LIVE_FRAME (frame
);
1599 CHECK_TYPE_RANGED_INTEGER (int, x
);
1600 CHECK_TYPE_RANGED_INTEGER (int, y
);
1602 /* I think this should be done with a hook. */
1603 #ifdef HAVE_WINDOW_SYSTEM
1604 if (FRAME_WINDOW_P (XFRAME (frame
)))
1605 /* Warping the mouse will cause enternotify and focus events. */
1606 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1609 if (FRAME_MSDOS_P (XFRAME (frame
)))
1611 Fselect_frame (frame
, Qnil
);
1612 mouse_moveto (XINT (x
), XINT (y
));
1617 Fselect_frame (frame
, Qnil
);
1618 term_mouse_moveto (XINT (x
), XINT (y
));
1627 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1628 Sset_mouse_pixel_position
, 3, 3, 0,
1629 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1630 The position is given in pixels, where (0, 0) is the upper-left corner
1631 of the frame, X is the horizontal offset, and Y is the vertical offset.
1633 Note, this is a no-op for an X frame that is not visible.
1634 If you have just created a frame, you must wait for it to become visible
1635 before calling this function on it, like this.
1636 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1637 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1639 CHECK_LIVE_FRAME (frame
);
1640 CHECK_TYPE_RANGED_INTEGER (int, x
);
1641 CHECK_TYPE_RANGED_INTEGER (int, y
);
1643 /* I think this should be done with a hook. */
1644 #ifdef HAVE_WINDOW_SYSTEM
1645 if (FRAME_WINDOW_P (XFRAME (frame
)))
1646 /* Warping the mouse will cause enternotify and focus events. */
1647 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1650 if (FRAME_MSDOS_P (XFRAME (frame
)))
1652 Fselect_frame (frame
, Qnil
);
1653 mouse_moveto (XINT (x
), XINT (y
));
1658 Fselect_frame (frame
, Qnil
);
1659 term_mouse_moveto (XINT (x
), XINT (y
));
1668 static void make_frame_visible_1 (Lisp_Object
);
1670 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1672 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1673 If omitted, FRAME defaults to the currently selected frame. */)
1676 struct frame
*f
= decode_live_frame (frame
);
1678 /* I think this should be done with a hook. */
1679 #ifdef HAVE_WINDOW_SYSTEM
1680 if (FRAME_WINDOW_P (f
))
1681 x_make_frame_visible (f
);
1684 make_frame_visible_1 (f
->root_window
);
1686 /* Make menu bar update for the Buffers and Frames menus. */
1687 windows_or_buffers_changed
++;
1689 XSETFRAME (frame
, f
);
1693 /* Update the display_time slot of the buffers shown in WINDOW
1694 and all its descendants. */
1697 make_frame_visible_1 (Lisp_Object window
)
1701 for (; !NILP (window
); window
= w
->next
)
1703 w
= XWINDOW (window
);
1704 if (WINDOWP (w
->contents
))
1705 make_frame_visible_1 (w
->contents
);
1707 bset_display_time (XBUFFER (w
->contents
), Fcurrent_time ());
1711 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1713 doc
: /* Make the frame FRAME invisible.
1714 If omitted, FRAME defaults to the currently selected frame.
1715 On graphical displays, invisible frames are not updated and are
1716 usually not displayed at all, even in a window system's \"taskbar\".
1718 Normally you may not make FRAME invisible if all other frames are invisible,
1719 but if the second optional argument FORCE is non-nil, you may do so.
1721 This function has no effect on text terminal frames. Such frames are
1722 always considered visible, whether or not they are currently being
1723 displayed in the terminal. */)
1724 (Lisp_Object frame
, Lisp_Object force
)
1726 struct frame
*f
= decode_live_frame (frame
);
1728 if (NILP (force
) && !other_visible_frames (f
))
1729 error ("Attempt to make invisible the sole visible or iconified frame");
1731 /* Don't allow minibuf_window to remain on an invisible frame. */
1732 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
1734 /* I think this should be done with a hook. */
1735 #ifdef HAVE_WINDOW_SYSTEM
1736 if (FRAME_WINDOW_P (f
))
1737 x_make_frame_invisible (f
);
1740 /* Make menu bar update for the Buffers and Frames menus. */
1741 windows_or_buffers_changed
++;
1746 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1748 doc
: /* Make the frame FRAME into an icon.
1749 If omitted, FRAME defaults to the currently selected frame. */)
1752 struct frame
*f
= decode_live_frame (frame
);
1754 /* Don't allow minibuf_window to remain on an iconified frame. */
1755 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
1757 /* I think this should be done with a hook. */
1758 #ifdef HAVE_WINDOW_SYSTEM
1759 if (FRAME_WINDOW_P (f
))
1760 x_iconify_frame (f
);
1763 /* Make menu bar update for the Buffers and Frames menus. */
1764 windows_or_buffers_changed
++;
1769 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1771 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1772 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1773 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1774 On graphical displays, invisible frames are not updated and are
1775 usually not displayed at all, even in a window system's \"taskbar\".
1777 If FRAME is a text terminal frame, this always returns t.
1778 Such frames are always considered visible, whether or not they are
1779 currently being displayed on the terminal. */)
1782 CHECK_LIVE_FRAME (frame
);
1784 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1786 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1791 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1793 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1796 Lisp_Object tail
, frame
, value
= Qnil
;
1798 FOR_EACH_FRAME (tail
, frame
)
1799 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1800 value
= Fcons (frame
, value
);
1806 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1807 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1808 If FRAME is invisible or iconified, make it visible.
1809 If you don't specify a frame, the selected frame is used.
1810 If Emacs is displaying on an ordinary terminal or some other device which
1811 doesn't support multiple overlapping frames, this function selects FRAME. */)
1814 struct frame
*f
= decode_live_frame (frame
);
1816 XSETFRAME (frame
, f
);
1818 if (FRAME_TERMCAP_P (f
))
1819 /* On a text terminal select FRAME. */
1820 Fselect_frame (frame
, Qnil
);
1822 /* Do like the documentation says. */
1823 Fmake_frame_visible (frame
);
1825 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1826 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
1831 /* Should we have a corresponding function called Flower_Power? */
1832 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1833 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1834 If you don't specify a frame, the selected frame is used.
1835 If Emacs is displaying on an ordinary terminal or some other device which
1836 doesn't support multiple overlapping frames, this function does nothing. */)
1839 struct frame
*f
= decode_live_frame (frame
);
1841 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1842 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
1848 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1850 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1851 In other words, switch-frame events caused by events in FRAME will
1852 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1853 FOCUS-FRAME after reading an event typed at FRAME.
1855 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
1856 frame again receives its own keystrokes.
1858 Focus redirection is useful for temporarily redirecting keystrokes to
1859 a surrogate minibuffer frame when a frame doesn't have its own
1862 A frame's focus redirection can be changed by `select-frame'. If frame
1863 FOO is selected, and then a different frame BAR is selected, any
1864 frames redirecting their focus to FOO are shifted to redirect their
1865 focus to BAR. This allows focus redirection to work properly when the
1866 user switches from one frame to another using `select-window'.
1868 This means that a frame whose focus is redirected to itself is treated
1869 differently from a frame whose focus is redirected to nil; the former
1870 is affected by `select-frame', while the latter is not.
1872 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1873 (Lisp_Object frame
, Lisp_Object focus_frame
)
1875 /* Note that we don't check for a live frame here. It's reasonable
1876 to redirect the focus of a frame you're about to delete, if you
1877 know what other frame should receive those keystrokes. */
1878 struct frame
*f
= decode_any_frame (frame
);
1880 if (! NILP (focus_frame
))
1881 CHECK_LIVE_FRAME (focus_frame
);
1883 fset_focus_frame (f
, focus_frame
);
1885 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
1886 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
1892 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 0, 1, 0,
1893 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1894 If FRAME is omitted or nil, the selected frame is used.
1895 Return nil if FRAME's focus is not redirected.
1896 See `redirect-frame-focus'. */)
1899 return FRAME_FOCUS_FRAME (decode_live_frame (frame
));
1902 DEFUN ("x-focus-frame", Fx_focus_frame
, Sx_focus_frame
, 1, 1, 0,
1903 doc
: /* Set the input focus to FRAME.
1904 FRAME nil means use the selected frame.
1905 If there is no window system support, this function does nothing. */)
1908 #ifdef HAVE_WINDOW_SYSTEM
1909 x_focus_frame (decode_window_system_frame (frame
));
1915 /* Return the value of frame parameter PROP in frame FRAME. */
1917 #ifdef HAVE_WINDOW_SYSTEM
1918 #if !HAVE_NS && !defined (WINDOWSNT)
1922 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
1924 register Lisp_Object tem
;
1926 tem
= Fassq (prop
, frame
->param_alist
);
1933 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
1936 frames_discard_buffer (Lisp_Object buffer
)
1938 Lisp_Object frame
, tail
;
1940 FOR_EACH_FRAME (tail
, frame
)
1943 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
1944 fset_buried_buffer_list
1945 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
1949 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1950 If the alist already has an element for PROP, we change it. */
1953 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
1955 register Lisp_Object tem
;
1957 tem
= Fassq (prop
, *alistptr
);
1959 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1965 frame_name_fnn_p (char *str
, ptrdiff_t len
)
1967 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
1970 while ('0' <= *p
&& *p
<= '9')
1978 /* Set the name of the terminal frame. Also used by MSDOS frames.
1979 Modeled after x_set_name which is used for WINDOW frames. */
1982 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
1984 f
->explicit_name
= ! NILP (name
);
1986 /* If NAME is nil, set the name to F<num>. */
1989 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
1991 /* Check for no change needed in this very common case
1992 before we do any consing. */
1993 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
1996 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
2000 CHECK_STRING (name
);
2002 /* Don't change the name if it's already NAME. */
2003 if (! NILP (Fstring_equal (name
, f
->name
)))
2006 /* Don't allow the user to set the frame name to F<num>, so it
2007 doesn't clash with the names we generate for terminal frames. */
2008 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2009 error ("Frame names of the form F<num> are usurped by Emacs");
2012 fset_name (f
, name
);
2013 update_mode_lines
= 1;
2017 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2019 register Lisp_Object old_alist_elt
;
2021 /* The buffer-list parameters are stored in a special place and not
2022 in the alist. All buffers must be live. */
2023 if (EQ (prop
, Qbuffer_list
))
2025 Lisp_Object list
= Qnil
;
2026 for (; CONSP (val
); val
= XCDR (val
))
2027 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2028 list
= Fcons (XCAR (val
), list
);
2029 fset_buffer_list (f
, Fnreverse (list
));
2032 if (EQ (prop
, Qburied_buffer_list
))
2034 Lisp_Object list
= Qnil
;
2035 for (; CONSP (val
); val
= XCDR (val
))
2036 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2037 list
= Fcons (XCAR (val
), list
);
2038 fset_buried_buffer_list (f
, Fnreverse (list
));
2042 /* If PROP is a symbol which is supposed to have frame-local values,
2043 and it is set up based on this frame, switch to the global
2044 binding. That way, we can create or alter the frame-local binding
2045 without messing up the symbol's status. */
2048 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2050 switch (sym
->redirect
)
2052 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2053 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2054 case SYMBOL_LOCALIZED
:
2055 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2056 if (blv
->frame_local
&& blv_found (blv
) && XFRAME (blv
->where
) == f
)
2057 swap_in_global_binding (sym
);
2060 default: emacs_abort ();
2064 /* The tty color needed to be set before the frame's parameter
2065 alist was updated with the new value. This is not true any more,
2066 but we still do this test early on. */
2067 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2068 && f
== FRAME_TTY (f
)->previous_frame
)
2069 /* Force redisplay of this tty. */
2070 FRAME_TTY (f
)->previous_frame
= NULL
;
2072 /* Update the frame parameter alist. */
2073 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2074 if (EQ (old_alist_elt
, Qnil
))
2075 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2077 Fsetcdr (old_alist_elt
, val
);
2079 /* Update some other special parameters in their special places
2080 in addition to the alist. */
2082 if (EQ (prop
, Qbuffer_predicate
))
2083 fset_buffer_predicate (f
, val
);
2085 if (! FRAME_WINDOW_P (f
))
2087 if (EQ (prop
, Qmenu_bar_lines
))
2088 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2089 else if (EQ (prop
, Qname
))
2090 set_term_frame_name (f
, val
);
2093 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2095 if (! MINI_WINDOW_P (XWINDOW (val
)))
2096 error ("Surrogate minibuffer windows must be minibuffer windows");
2098 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2099 && !EQ (val
, f
->minibuffer_window
))
2100 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2102 /* Install the chosen minibuffer window, with proper buffer. */
2103 fset_minibuffer_window (f
, val
);
2107 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2108 doc
: /* Return the parameters-alist of frame FRAME.
2109 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2110 The meaningful PARMs depend on the kind of frame.
2111 If FRAME is omitted or nil, return information on the currently selected frame. */)
2115 struct frame
*f
= decode_any_frame (frame
);
2117 struct gcpro gcpro1
;
2119 if (!FRAME_LIVE_P (f
))
2122 alist
= Fcopy_alist (f
->param_alist
);
2125 if (!FRAME_WINDOW_P (f
))
2127 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2128 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2131 /* If the frame's parameter alist says the colors are
2132 unspecified and reversed, take the frame's background pixel
2133 for foreground and vice versa. */
2134 elt
= Fassq (Qforeground_color
, alist
);
2135 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2137 if (strncmp (SSDATA (XCDR (elt
)),
2139 SCHARS (XCDR (elt
))) == 0)
2140 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2141 else if (strncmp (SSDATA (XCDR (elt
)),
2143 SCHARS (XCDR (elt
))) == 0)
2144 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2147 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2148 elt
= Fassq (Qbackground_color
, alist
);
2149 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2151 if (strncmp (SSDATA (XCDR (elt
)),
2153 SCHARS (XCDR (elt
))) == 0)
2154 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2155 else if (strncmp (SSDATA (XCDR (elt
)),
2157 SCHARS (XCDR (elt
))) == 0)
2158 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2161 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2162 store_in_alist (&alist
, intern ("font"),
2163 build_string (FRAME_MSDOS_P (f
)
2165 : FRAME_W32_P (f
) ? "w32term"
2168 store_in_alist (&alist
, Qname
, f
->name
);
2169 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2170 store_in_alist (&alist
, Qheight
, make_number (height
));
2171 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2172 store_in_alist (&alist
, Qwidth
, make_number (width
));
2173 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2174 store_in_alist (&alist
, Qminibuffer
,
2175 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2176 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2177 : FRAME_MINIBUF_WINDOW (f
)));
2178 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2179 store_in_alist (&alist
, Qbuffer_list
, f
->buffer_list
);
2180 store_in_alist (&alist
, Qburied_buffer_list
, f
->buried_buffer_list
);
2182 /* I think this should be done with a hook. */
2183 #ifdef HAVE_WINDOW_SYSTEM
2184 if (FRAME_WINDOW_P (f
))
2185 x_report_frame_params (f
, &alist
);
2189 /* This ought to be correct in f->param_alist for an X frame. */
2191 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2192 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2200 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2201 doc
: /* Return FRAME's value for parameter PARAMETER.
2202 If FRAME is nil, describe the currently selected frame. */)
2203 (Lisp_Object frame
, Lisp_Object parameter
)
2205 struct frame
*f
= decode_any_frame (frame
);
2206 Lisp_Object value
= Qnil
;
2208 CHECK_SYMBOL (parameter
);
2210 XSETFRAME (frame
, f
);
2212 if (FRAME_LIVE_P (f
))
2214 /* Avoid consing in frequent cases. */
2215 if (EQ (parameter
, Qname
))
2217 #ifdef HAVE_X_WINDOWS
2218 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2219 value
= XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
);
2220 #endif /* HAVE_X_WINDOWS */
2221 else if (EQ (parameter
, Qbackground_color
)
2222 || EQ (parameter
, Qforeground_color
))
2224 value
= Fassq (parameter
, f
->param_alist
);
2227 value
= XCDR (value
);
2228 /* Fframe_parameters puts the actual fg/bg color names,
2229 even if f->param_alist says otherwise. This is
2230 important when param_alist's notion of colors is
2231 "unspecified". We need to do the same here. */
2232 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2234 const char *color_name
;
2237 if (EQ (parameter
, Qbackground_color
))
2239 color_name
= SSDATA (value
);
2240 csz
= SCHARS (value
);
2241 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2242 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2243 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2244 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2246 else if (EQ (parameter
, Qforeground_color
))
2248 color_name
= SSDATA (value
);
2249 csz
= SCHARS (value
);
2250 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2251 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2252 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2253 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2258 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2260 else if (EQ (parameter
, Qdisplay_type
)
2261 || EQ (parameter
, Qbackground_mode
))
2262 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2264 /* FIXME: Avoid this code path at all (as well as code duplication)
2265 by sharing more code with Fframe_parameters. */
2266 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2273 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2274 Smodify_frame_parameters
, 2, 2, 0,
2275 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2276 If FRAME is nil, it defaults to the selected frame.
2277 ALIST is an alist of parameters to change and their new values.
2278 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2279 The meaningful PARMs depend on the kind of frame.
2280 Undefined PARMs are ignored, but stored in the frame's parameter list
2281 so that `frame-parameters' will return them.
2283 The value of frame parameter FOO can also be accessed
2284 as a frame-local binding for the variable FOO, if you have
2285 enabled such bindings for that variable with `make-variable-frame-local'.
2286 Note that this functionality is obsolete as of Emacs 22.2, and its
2287 use is not recommended. Explicitly check for a frame-parameter instead. */)
2288 (Lisp_Object frame
, Lisp_Object alist
)
2290 struct frame
*f
= decode_live_frame (frame
);
2291 register Lisp_Object prop
, val
;
2295 /* I think this should be done with a hook. */
2296 #ifdef HAVE_WINDOW_SYSTEM
2297 if (FRAME_WINDOW_P (f
))
2298 x_set_frame_parameters (f
, alist
);
2302 if (FRAME_MSDOS_P (f
))
2303 IT_set_frame_parameters (f
, alist
);
2308 EMACS_INT length
= XFASTINT (Flength (alist
));
2311 Lisp_Object
*values
;
2313 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2314 values
= parms
+ length
;
2316 /* Extract parm names and values into those vectors. */
2318 for (i
= 0; CONSP (alist
); alist
= XCDR (alist
))
2323 parms
[i
] = Fcar (elt
);
2324 values
[i
] = Fcdr (elt
);
2328 /* Now process them in reverse of specified order. */
2333 store_frame_param (f
, prop
, val
);
2335 if (EQ (prop
, Qforeground_color
)
2336 || EQ (prop
, Qbackground_color
))
2337 update_face_from_frame_parameter (f
, prop
, val
);
2345 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2347 doc
: /* Height in pixels of a line in the font in frame FRAME.
2348 If FRAME is omitted or nil, the selected frame is used.
2349 For a terminal frame, the value is always 1. */)
2352 #ifdef HAVE_WINDOW_SYSTEM
2353 struct frame
*f
= decode_any_frame (frame
);
2355 if (FRAME_WINDOW_P (f
))
2356 return make_number (FRAME_LINE_HEIGHT (f
));
2359 return make_number (1);
2363 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2365 doc
: /* Width in pixels of characters in the font in frame FRAME.
2366 If FRAME is omitted or nil, the selected frame is used.
2367 On a graphical screen, the width is the standard width of the default font.
2368 For a terminal screen, the value is always 1. */)
2371 #ifdef HAVE_WINDOW_SYSTEM
2372 struct frame
*f
= decode_any_frame (frame
);
2374 if (FRAME_WINDOW_P (f
))
2375 return make_number (FRAME_COLUMN_WIDTH (f
));
2378 return make_number (1);
2381 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2382 Sframe_pixel_height
, 0, 1, 0,
2383 doc
: /* Return a FRAME's height in pixels.
2384 If FRAME is omitted or nil, the selected frame is used. The exact value
2385 of the result depends on the window-system and toolkit in use:
2387 In the Gtk+ version of Emacs, it includes only any window (including
2388 the minibuffer or echo area), mode line, and header line. It does not
2389 include the tool bar or menu bar.
2391 With other graphical versions, it also includes the tool bar and the
2394 For a text terminal, it includes the menu bar. In this case, the
2395 result is really in characters rather than pixels (i.e., is identical
2396 to `frame-height'). */)
2399 struct frame
*f
= decode_any_frame (frame
);
2401 #ifdef HAVE_WINDOW_SYSTEM
2402 if (FRAME_WINDOW_P (f
))
2403 return make_number (FRAME_PIXEL_HEIGHT (f
));
2406 return make_number (FRAME_LINES (f
));
2409 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2410 Sframe_pixel_width
, 0, 1, 0,
2411 doc
: /* Return FRAME's width in pixels.
2412 For a terminal frame, the result really gives the width in characters.
2413 If FRAME is omitted or nil, the selected frame is used. */)
2416 struct frame
*f
= decode_any_frame (frame
);
2418 #ifdef HAVE_WINDOW_SYSTEM
2419 if (FRAME_WINDOW_P (f
))
2420 return make_number (FRAME_PIXEL_WIDTH (f
));
2423 return make_number (FRAME_COLS (f
));
2426 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2427 Stool_bar_pixel_width
, 0, 1, 0,
2428 doc
: /* Return width in pixels of FRAME's tool bar.
2429 The result is greater than zero only when the tool bar is on the left
2430 or right side of FRAME. If FRAME is omitted or nil, the selected frame
2434 #ifdef FRAME_TOOLBAR_WIDTH
2435 struct frame
*f
= decode_any_frame (frame
);
2437 if (FRAME_WINDOW_P (f
))
2438 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2440 return make_number (0);
2443 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2444 doc
: /* Specify that the frame FRAME has LINES lines.
2445 If FRAME is nil, the selected frame is used. Optional third arg
2446 non-nil means that redisplay should use LINES lines but that the
2447 idea of the actual height of the frame should not be changed. */)
2448 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2450 register struct frame
*f
= decode_live_frame (frame
);
2452 CHECK_TYPE_RANGED_INTEGER (int, lines
);
2454 /* I think this should be done with a hook. */
2455 #ifdef HAVE_WINDOW_SYSTEM
2456 if (FRAME_WINDOW_P (f
))
2458 if (XINT (lines
) != FRAME_LINES (f
))
2459 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2460 do_pending_window_change (0);
2464 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2468 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2469 doc
: /* Specify that the frame FRAME has COLS columns.
2470 If FRAME is nil, the selected frame is used. Optional third arg
2471 non-nil means that redisplay should use COLS columns but that the
2472 idea of the actual width of the frame should not be changed. */)
2473 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2475 register struct frame
*f
= decode_live_frame (frame
);
2477 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2479 /* I think this should be done with a hook. */
2480 #ifdef HAVE_WINDOW_SYSTEM
2481 if (FRAME_WINDOW_P (f
))
2483 if (XINT (cols
) != FRAME_COLS (f
))
2484 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2485 do_pending_window_change (0);
2489 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2493 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2494 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters.
2495 If FRAME is nil, the selected frame is used. */)
2496 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2498 register struct frame
*f
= decode_live_frame (frame
);
2500 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2501 CHECK_TYPE_RANGED_INTEGER (int, rows
);
2503 /* I think this should be done with a hook. */
2504 #ifdef HAVE_WINDOW_SYSTEM
2505 if (FRAME_WINDOW_P (f
))
2507 if (XINT (rows
) != FRAME_LINES (f
)
2508 || XINT (cols
) != FRAME_COLS (f
)
2509 || f
->new_text_lines
|| f
->new_text_cols
)
2510 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2511 do_pending_window_change (0);
2515 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2520 DEFUN ("set-frame-position", Fset_frame_position
,
2521 Sset_frame_position
, 3, 3, 0,
2522 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2523 If FRAME is nil, the selected frame is used. XOFFSET and YOFFSET are
2524 actually the position of the upper left corner of the frame. Negative
2525 values for XOFFSET or YOFFSET are interpreted relative to the rightmost
2526 or bottommost possible position (that stays within the screen). */)
2527 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2529 register struct frame
*f
= decode_live_frame (frame
);
2531 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2532 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2534 /* I think this should be done with a hook. */
2535 #ifdef HAVE_WINDOW_SYSTEM
2536 if (FRAME_WINDOW_P (f
))
2537 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2544 /***********************************************************************
2546 ***********************************************************************/
2548 /* Connect the frame-parameter names for X frames
2549 to the ways of passing the parameter values to the window system.
2551 The name of a parameter, as a Lisp symbol,
2552 has an `x-frame-parameter' property which is an integer in Lisp
2553 that is an index in this table. */
2555 struct frame_parm_table
{
2557 Lisp_Object
*variable
;
2560 static const struct frame_parm_table frame_parms
[] =
2562 {"auto-raise", &Qauto_raise
},
2563 {"auto-lower", &Qauto_lower
},
2564 {"background-color", 0},
2565 {"border-color", &Qborder_color
},
2566 {"border-width", &Qborder_width
},
2567 {"cursor-color", &Qcursor_color
},
2568 {"cursor-type", &Qcursor_type
},
2570 {"foreground-color", 0},
2571 {"icon-name", &Qicon_name
},
2572 {"icon-type", &Qicon_type
},
2573 {"internal-border-width", &Qinternal_border_width
},
2574 {"menu-bar-lines", &Qmenu_bar_lines
},
2575 {"mouse-color", &Qmouse_color
},
2577 {"scroll-bar-width", &Qscroll_bar_width
},
2579 {"unsplittable", &Qunsplittable
},
2580 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2581 {"visibility", &Qvisibility
},
2582 {"tool-bar-lines", &Qtool_bar_lines
},
2583 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2584 {"scroll-bar-background", &Qscroll_bar_background
},
2585 {"screen-gamma", &Qscreen_gamma
},
2586 {"line-spacing", &Qline_spacing
},
2587 {"left-fringe", &Qleft_fringe
},
2588 {"right-fringe", &Qright_fringe
},
2589 {"wait-for-wm", &Qwait_for_wm
},
2590 {"fullscreen", &Qfullscreen
},
2591 {"font-backend", &Qfont_backend
},
2593 {"sticky", &Qsticky
},
2594 {"tool-bar-position", &Qtool_bar_position
},
2599 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2600 wanted positions of the WM window (not Emacs window).
2601 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2602 window (FRAME_X_WINDOW).
2606 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2608 int newwidth
= FRAME_COLS (f
);
2609 int newheight
= FRAME_LINES (f
);
2610 Display_Info
*dpyinfo
= FRAME_DISPLAY_INFO (f
);
2612 *top_pos
= f
->top_pos
;
2613 *left_pos
= f
->left_pos
;
2615 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2619 ph
= x_display_pixel_height (dpyinfo
);
2620 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2621 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2622 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2626 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2630 pw
= x_display_pixel_width (dpyinfo
);
2631 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2632 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2633 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2638 *height
= newheight
;
2641 #endif /* HAVE_NTGUI */
2643 #ifdef HAVE_WINDOW_SYSTEM
2645 /* Change the parameters of frame F as specified by ALIST.
2646 If a parameter is not specially recognized, do nothing special;
2647 otherwise call the `x_set_...' function for that parameter.
2648 Except for certain geometry properties, always call store_frame_param
2649 to store the new value in the parameter alist. */
2652 x_set_frame_parameters (struct frame
*f
, Lisp_Object alist
)
2656 /* If both of these parameters are present, it's more efficient to
2657 set them both at once. So we wait until we've looked at the
2658 entire list before we set them. */
2662 Lisp_Object left
, top
;
2664 /* Same with these. */
2665 Lisp_Object icon_left
, icon_top
;
2667 /* Record in these vectors all the parms specified. */
2669 Lisp_Object
*values
;
2671 bool left_no_change
= 0, top_no_change
= 0;
2672 bool icon_left_no_change
= 0, icon_top_no_change
= 0;
2673 bool size_changed
= 0;
2674 struct gcpro gcpro1
, gcpro2
;
2677 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2680 parms
= alloca (i
* sizeof *parms
);
2681 values
= alloca (i
* sizeof *values
);
2683 /* Extract parm names and values into those vectors. */
2686 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2691 parms
[i
] = Fcar (elt
);
2692 values
[i
] = Fcdr (elt
);
2695 /* TAIL and ALIST are not used again below here. */
2696 alist
= tail
= Qnil
;
2698 GCPRO2 (*parms
, *values
);
2702 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2703 because their values appear in VALUES and strings are not valid. */
2704 top
= left
= Qunbound
;
2705 icon_left
= icon_top
= Qunbound
;
2707 /* Provide default values for HEIGHT and WIDTH. */
2708 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2709 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2711 /* Process foreground_color and background_color before anything else.
2712 They are independent of other properties, but other properties (e.g.,
2713 cursor_color) are dependent upon them. */
2714 /* Process default font as well, since fringe widths depends on it. */
2715 for (p
= 0; p
< i
; p
++)
2717 Lisp_Object prop
, val
;
2721 if (EQ (prop
, Qforeground_color
)
2722 || EQ (prop
, Qbackground_color
)
2723 || EQ (prop
, Qfont
))
2725 register Lisp_Object param_index
, old_value
;
2727 old_value
= get_frame_param (f
, prop
);
2728 if (NILP (Fequal (val
, old_value
)))
2730 store_frame_param (f
, prop
, val
);
2732 param_index
= Fget (prop
, Qx_frame_parameter
);
2733 if (NATNUMP (param_index
)
2734 && (XFASTINT (param_index
)
2735 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2736 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2737 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2742 /* Now process them in reverse of specified order. */
2745 Lisp_Object prop
, val
;
2750 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2753 width
= XFASTINT (val
);
2755 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2758 height
= XFASTINT (val
);
2760 else if (EQ (prop
, Qtop
))
2762 else if (EQ (prop
, Qleft
))
2764 else if (EQ (prop
, Qicon_top
))
2766 else if (EQ (prop
, Qicon_left
))
2768 else if (EQ (prop
, Qforeground_color
)
2769 || EQ (prop
, Qbackground_color
)
2770 || EQ (prop
, Qfont
))
2771 /* Processed above. */
2775 register Lisp_Object param_index
, old_value
;
2777 old_value
= get_frame_param (f
, prop
);
2779 store_frame_param (f
, prop
, val
);
2781 param_index
= Fget (prop
, Qx_frame_parameter
);
2782 if (NATNUMP (param_index
)
2783 && (XFASTINT (param_index
)
2784 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2785 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2786 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2790 /* Don't die if just one of these was set. */
2791 if (EQ (left
, Qunbound
))
2794 if (f
->left_pos
< 0)
2795 left
= list2 (Qplus
, make_number (f
->left_pos
));
2797 XSETINT (left
, f
->left_pos
);
2799 if (EQ (top
, Qunbound
))
2803 top
= list2 (Qplus
, make_number (f
->top_pos
));
2805 XSETINT (top
, f
->top_pos
);
2808 /* If one of the icon positions was not set, preserve or default it. */
2809 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
2811 icon_left_no_change
= 1;
2812 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2813 if (NILP (icon_left
))
2814 XSETINT (icon_left
, 0);
2816 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
2818 icon_top_no_change
= 1;
2819 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2820 if (NILP (icon_top
))
2821 XSETINT (icon_top
, 0);
2824 /* Don't set these parameters unless they've been explicitly
2825 specified. The window might be mapped or resized while we're in
2826 this function, and we don't want to override that unless the lisp
2827 code has asked for it.
2829 Don't set these parameters unless they actually differ from the
2830 window's current parameters; the window may not actually exist
2835 check_frame_size (f
, &height
, &width
);
2837 XSETFRAME (frame
, f
);
2840 && (width
!= FRAME_COLS (f
)
2841 || height
!= FRAME_LINES (f
)
2842 || f
->new_text_lines
|| f
->new_text_cols
))
2843 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2845 if ((!NILP (left
) || !NILP (top
))
2846 && ! (left_no_change
&& top_no_change
)
2847 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2848 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2853 /* Record the signs. */
2854 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2855 if (EQ (left
, Qminus
))
2856 f
->size_hint_flags
|= XNegative
;
2857 else if (TYPE_RANGED_INTEGERP (int, left
))
2859 leftpos
= XINT (left
);
2861 f
->size_hint_flags
|= XNegative
;
2863 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2864 && CONSP (XCDR (left
))
2865 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
2867 leftpos
= - XINT (XCAR (XCDR (left
)));
2868 f
->size_hint_flags
|= XNegative
;
2870 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2871 && CONSP (XCDR (left
))
2872 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
2874 leftpos
= XINT (XCAR (XCDR (left
)));
2877 if (EQ (top
, Qminus
))
2878 f
->size_hint_flags
|= YNegative
;
2879 else if (TYPE_RANGED_INTEGERP (int, top
))
2881 toppos
= XINT (top
);
2883 f
->size_hint_flags
|= YNegative
;
2885 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2886 && CONSP (XCDR (top
))
2887 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
2889 toppos
= - XINT (XCAR (XCDR (top
)));
2890 f
->size_hint_flags
|= YNegative
;
2892 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2893 && CONSP (XCDR (top
))
2894 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
2896 toppos
= XINT (XCAR (XCDR (top
)));
2900 /* Store the numeric value of the position. */
2901 f
->top_pos
= toppos
;
2902 f
->left_pos
= leftpos
;
2904 f
->win_gravity
= NorthWestGravity
;
2906 /* Actually set that position, and convert to absolute. */
2907 x_set_offset (f
, leftpos
, toppos
, -1);
2909 #ifdef HAVE_X_WINDOWS
2910 if ((!NILP (icon_left
) || !NILP (icon_top
))
2911 && ! (icon_left_no_change
&& icon_top_no_change
))
2912 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2913 #endif /* HAVE_X_WINDOWS */
2920 /* Insert a description of internally-recorded parameters of frame X
2921 into the parameter alist *ALISTPTR that is to be given to the user.
2922 Only parameters that are specific to the X window system
2923 and whose values are not correctly recorded in the frame's
2924 param_alist need to be considered here. */
2927 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
2931 char buf
[INT_BUFSIZE_BOUND (w
)];
2933 /* Represent negative positions (off the top or left screen edge)
2934 in a way that Fmodify_frame_parameters will understand correctly. */
2935 XSETINT (tem
, f
->left_pos
);
2936 if (f
->left_pos
>= 0)
2937 store_in_alist (alistptr
, Qleft
, tem
);
2939 store_in_alist (alistptr
, Qleft
, list2 (Qplus
, tem
));
2941 XSETINT (tem
, f
->top_pos
);
2942 if (f
->top_pos
>= 0)
2943 store_in_alist (alistptr
, Qtop
, tem
);
2945 store_in_alist (alistptr
, Qtop
, list2 (Qplus
, tem
));
2947 store_in_alist (alistptr
, Qborder_width
,
2948 make_number (f
->border_width
));
2949 store_in_alist (alistptr
, Qinternal_border_width
,
2950 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
2951 store_in_alist (alistptr
, Qleft_fringe
,
2952 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
2953 store_in_alist (alistptr
, Qright_fringe
,
2954 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
2955 store_in_alist (alistptr
, Qscroll_bar_width
,
2956 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2958 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
2959 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
2960 /* nil means "use default width"
2961 for non-toolkit scroll bar.
2962 ruler-mode.el depends on this. */
2964 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
2965 MS-Windows it returns a value whose type is HANDLE, which is
2966 actually a pointer. Explicit casting avoids compiler
2968 w
= (uintptr_t) FRAME_X_WINDOW (f
);
2969 store_in_alist (alistptr
, Qwindow_id
,
2970 make_formatted_string (buf
, "%"pMu
, w
));
2971 #ifdef HAVE_X_WINDOWS
2972 #ifdef USE_X_TOOLKIT
2973 /* Tooltip frame may not have this widget. */
2974 if (FRAME_X_OUTPUT (f
)->widget
)
2976 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
2977 store_in_alist (alistptr
, Qouter_window_id
,
2978 make_formatted_string (buf
, "%"pMu
, w
));
2980 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
2981 store_in_alist (alistptr
, Qvisibility
,
2982 (FRAME_VISIBLE_P (f
) ? Qt
2983 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
2984 store_in_alist (alistptr
, Qdisplay
,
2985 XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
));
2987 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_DISPLAY_INFO (f
)->root_window
)
2990 tem
= make_natnum ((uintptr_t) FRAME_X_OUTPUT (f
)->parent_desc
);
2991 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
2992 store_in_alist (alistptr
, Qparent_id
, tem
);
2993 store_in_alist (alistptr
, Qtool_bar_position
, f
->tool_bar_position
);
2997 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
2998 the previous value of that parameter, NEW_VALUE is the new value. */
3001 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3003 if (NILP (new_value
))
3004 f
->want_fullscreen
= FULLSCREEN_NONE
;
3005 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3006 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3007 else if (EQ (new_value
, Qfullwidth
))
3008 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3009 else if (EQ (new_value
, Qfullheight
))
3010 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3011 else if (EQ (new_value
, Qmaximized
))
3012 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3014 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3015 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3019 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3020 the previous value of that parameter, NEW_VALUE is the new value. */
3023 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3025 if (NILP (new_value
))
3026 f
->extra_line_spacing
= 0;
3027 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
3028 f
->extra_line_spacing
= XFASTINT (new_value
);
3029 else if (FLOATP (new_value
))
3031 int new_spacing
= XFLOAT_DATA (new_value
) * FRAME_LINE_HEIGHT (f
) + 0.5;
3033 if (new_spacing
>= 0)
3034 f
->extra_line_spacing
= new_spacing
;
3036 signal_error ("Invalid line-spacing", new_value
);
3039 signal_error ("Invalid line-spacing", new_value
);
3040 if (FRAME_VISIBLE_P (f
))
3045 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3046 the previous value of that parameter, NEW_VALUE is the new value. */
3049 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3051 Lisp_Object bgcolor
;
3053 if (NILP (new_value
))
3055 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3056 /* The value 0.4545 is the normal viewing gamma. */
3057 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3059 signal_error ("Invalid screen-gamma", new_value
);
3061 /* Apply the new gamma value to the frame background. */
3062 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3063 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3065 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3066 if (NATNUMP (parm_index
)
3067 && (XFASTINT (parm_index
)
3068 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3069 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3070 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3074 Fclear_face_cache (Qnil
);
3079 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3081 Lisp_Object font_object
;
3083 #ifdef HAVE_X_WINDOWS
3084 Lisp_Object font_param
= arg
;
3087 /* Set the frame parameter back to the old value because we may
3088 fail to use ARG as the new parameter value. */
3089 store_frame_param (f
, Qfont
, oldval
);
3091 /* ARG is a fontset name, a font name, a cons of fontset name and a
3092 font object, or a font object. In the last case, this function
3096 fontset
= fs_query_fontset (arg
, 0);
3099 font_object
= font_open_by_name (f
, arg
);
3100 if (NILP (font_object
))
3101 error ("Font `%s' is not defined", SSDATA (arg
));
3102 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3104 else if (fontset
> 0)
3106 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
3107 if (NILP (font_object
))
3108 error ("Font `%s' is not defined", SDATA (arg
));
3109 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3112 error ("The default fontset can't be used for a frame font");
3114 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3116 /* This is the case that the ASCII font of F's fontset XCAR
3117 (arg) is changed to the font XCDR (arg) by
3118 `set-fontset-font'. */
3119 fontset
= fs_query_fontset (XCAR (arg
), 0);
3121 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3122 font_object
= XCDR (arg
);
3123 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3124 #ifdef HAVE_X_WINDOWS
3125 font_param
= Ffont_get (font_object
, QCname
);
3128 else if (FONT_OBJECT_P (arg
))
3131 #ifdef HAVE_X_WINDOWS
3132 font_param
= Ffont_get (font_object
, QCname
);
3134 /* This is to store the XLFD font name in the frame parameter for
3135 backward compatibility. We should store the font-object
3136 itself in the future. */
3137 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3138 fontset
= FRAME_FONTSET (f
);
3139 /* Check if we can use the current fontset. If not, set FONTSET
3140 to -1 to generate a new fontset from FONT-OBJECT. */
3143 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3144 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3147 signal_error ("Invalid font name", ascii_font
);
3149 if (! font_match_p (spec
, font_object
))
3154 signal_error ("Invalid font", arg
);
3156 if (! NILP (Fequal (font_object
, oldval
)))
3159 x_new_font (f
, font_object
, fontset
);
3160 store_frame_param (f
, Qfont
, arg
);
3161 #ifdef HAVE_X_WINDOWS
3162 store_frame_param (f
, Qfont_param
, font_param
);
3164 /* Recalculate toolbar height. */
3165 f
->n_tool_bar_rows
= 0;
3166 /* Ensure we redraw it. */
3167 clear_current_matrices (f
);
3169 recompute_basic_faces (f
);
3171 do_pending_window_change (0);
3173 /* We used to call face-set-after-frame-default here, but it leads to
3174 recursive calls (since that function can set the `default' face's
3175 font which in turns changes the frame's `font' parameter).
3176 Also I don't know what this call is meant to do, but it seems the
3177 wrong way to do it anyway (it does a lot more work than what seems
3178 reasonable in response to a change to `font'). */
3183 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3185 if (! NILP (new_value
)
3186 && !CONSP (new_value
))
3190 CHECK_STRING (new_value
);
3191 p0
= p1
= SSDATA (new_value
);
3195 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
3197 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3203 while ((c
= *++p1
) && c_isspace (c
));
3207 new_value
= Fnreverse (new_value
);
3210 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3214 free_all_realized_faces (Qnil
);
3216 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3217 if (NILP (new_value
))
3219 if (NILP (old_value
))
3220 error ("No font backend available");
3221 font_update_drivers (f
, old_value
);
3222 error ("None of specified font backends are available");
3224 store_frame_param (f
, Qfont_backend
, new_value
);
3230 XSETFRAME (frame
, f
);
3231 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3232 ++face_change_count
;
3233 ++windows_or_buffers_changed
;
3239 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3241 compute_fringe_widths (f
, 1);
3242 #ifdef HAVE_X_WINDOWS
3243 /* Must adjust this so window managers report correct number of columns. */
3244 if (FRAME_X_WINDOW (f
) != 0)
3245 x_wm_set_size_hint (f
, 0, 0);
3250 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3252 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3254 if (XINT (arg
) == f
->border_width
)
3257 if (FRAME_X_WINDOW (f
) != 0)
3258 error ("Cannot change the border width of a frame");
3260 f
->border_width
= XINT (arg
);
3264 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3266 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3268 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3269 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3270 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3271 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3273 #ifdef USE_X_TOOLKIT
3274 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3275 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3278 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3281 if (FRAME_X_WINDOW (f
) != 0)
3283 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3284 SET_FRAME_GARBAGED (f
);
3285 do_pending_window_change (0);
3288 SET_FRAME_GARBAGED (f
);
3292 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3295 XSETFRAME (frame
, f
);
3298 Fmake_frame_invisible (frame
, Qt
);
3299 else if (EQ (value
, Qicon
))
3300 Ficonify_frame (frame
);
3302 Fmake_frame_visible (frame
);
3306 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3308 f
->auto_raise
= !EQ (Qnil
, arg
);
3312 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3314 f
->auto_lower
= !EQ (Qnil
, arg
);
3318 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3320 f
->no_split
= !NILP (arg
);
3324 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3326 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3327 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3328 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3329 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3331 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3333 ? vertical_scroll_bar_none
3335 ? vertical_scroll_bar_left
3337 ? vertical_scroll_bar_right
3338 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3339 ? vertical_scroll_bar_left
3340 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3341 ? vertical_scroll_bar_right
3342 : vertical_scroll_bar_none
);
3344 /* We set this parameter before creating the X window for the
3345 frame, so we can get the geometry right from the start.
3346 However, if the window hasn't been created yet, we shouldn't
3347 call x_set_window_size. */
3348 if (FRAME_X_WINDOW (f
))
3349 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3350 do_pending_window_change (0);
3355 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3357 int wid
= FRAME_COLUMN_WIDTH (f
);
3361 x_set_scroll_bar_default_width (f
);
3363 if (FRAME_X_WINDOW (f
))
3364 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3365 do_pending_window_change (0);
3367 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3368 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3370 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3371 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3372 if (FRAME_X_WINDOW (f
))
3373 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3374 do_pending_window_change (0);
3377 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3378 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3379 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3383 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3390 for (i
= 0; i
< 2; i
++)
3403 else if (FLOATP (item
))
3405 alpha
= XFLOAT_DATA (item
);
3406 if (! (0 <= alpha
&& alpha
<= 1.0))
3407 args_out_of_range (make_float (0.0), make_float (1.0));
3409 else if (INTEGERP (item
))
3411 EMACS_INT ialpha
= XINT (item
);
3412 if (! (0 <= ialpha
&& alpha
<= 100))
3413 args_out_of_range (make_number (0), make_number (100));
3414 alpha
= ialpha
/ 100.0;
3417 wrong_type_argument (Qnumberp
, item
);
3421 for (i
= 0; i
< 2; i
++)
3422 f
->alpha
[i
] = newval
[i
];
3424 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3426 x_set_frame_alpha (f
);
3435 /* Non-zero if mouse is grabbed on DPYINFO
3436 and we know the frame where it is. */
3438 bool x_mouse_grabbed (Display_Info
*dpyinfo
)
3440 return (dpyinfo
->grabbed
3441 && dpyinfo
->last_mouse_frame
3442 && FRAME_LIVE_P (dpyinfo
->last_mouse_frame
));
3445 /* Re-highlight something with mouse-face properties
3446 on DPYINFO using saved frame and mouse position. */
3449 x_redo_mouse_highlight (Display_Info
*dpyinfo
)
3451 if (dpyinfo
->last_mouse_motion_frame
3452 && FRAME_LIVE_P (dpyinfo
->last_mouse_motion_frame
))
3453 note_mouse_highlight (dpyinfo
->last_mouse_motion_frame
,
3454 dpyinfo
->last_mouse_motion_x
,
3455 dpyinfo
->last_mouse_motion_y
);
3458 #endif /* HAVE_NS */
3460 /* Subroutines of creating an X frame. */
3462 /* Make sure that Vx_resource_name is set to a reasonable value.
3463 Fix it up, or set it to `emacs' if it is too hopeless. */
3466 validate_x_resource_name (void)
3469 /* Number of valid characters in the resource name. */
3470 ptrdiff_t good_count
= 0;
3471 /* Number of invalid characters in the resource name. */
3472 ptrdiff_t bad_count
= 0;
3476 if (!STRINGP (Vx_resource_class
))
3477 Vx_resource_class
= build_string (EMACS_CLASS
);
3479 if (STRINGP (Vx_resource_name
))
3481 unsigned char *p
= SDATA (Vx_resource_name
);
3483 len
= SBYTES (Vx_resource_name
);
3485 /* Only letters, digits, - and _ are valid in resource names.
3486 Count the valid characters and count the invalid ones. */
3487 for (i
= 0; i
< len
; i
++)
3490 if (! ((c
>= 'a' && c
<= 'z')
3491 || (c
>= 'A' && c
<= 'Z')
3492 || (c
>= '0' && c
<= '9')
3493 || c
== '-' || c
== '_'))
3500 /* Not a string => completely invalid. */
3501 bad_count
= 5, good_count
= 0;
3503 /* If name is valid already, return. */
3507 /* If name is entirely invalid, or nearly so, or is so implausibly
3508 large that alloca might not work, use `emacs'. */
3509 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
3511 Vx_resource_name
= build_string ("emacs");
3515 /* Name is partly valid. Copy it and replace the invalid characters
3516 with underscores. */
3518 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3520 for (i
= 0; i
< len
; i
++)
3522 int c
= SREF (new, i
);
3523 if (! ((c
>= 'a' && c
<= 'z')
3524 || (c
>= 'A' && c
<= 'Z')
3525 || (c
>= '0' && c
<= '9')
3526 || c
== '-' || c
== '_'))
3531 /* Get specified attribute from resource database RDB.
3532 See Fx_get_resource below for other parameters. */
3535 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3537 register char *value
;
3541 CHECK_STRING (attribute
);
3542 CHECK_STRING (class);
3544 if (!NILP (component
))
3545 CHECK_STRING (component
);
3546 if (!NILP (subclass
))
3547 CHECK_STRING (subclass
);
3548 if (NILP (component
) != NILP (subclass
))
3549 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3551 validate_x_resource_name ();
3553 /* Allocate space for the components, the dots which separate them,
3554 and the final '\0'. Make them big enough for the worst case. */
3555 name_key
= alloca (SBYTES (Vx_resource_name
)
3556 + (STRINGP (component
)
3557 ? SBYTES (component
) : 0)
3558 + SBYTES (attribute
)
3561 class_key
= alloca (SBYTES (Vx_resource_class
)
3563 + (STRINGP (subclass
)
3564 ? SBYTES (subclass
) : 0)
3567 /* Start with emacs.FRAMENAME for the name (the specific one)
3568 and with `Emacs' for the class key (the general one). */
3569 strcpy (name_key
, SSDATA (Vx_resource_name
));
3570 strcpy (class_key
, SSDATA (Vx_resource_class
));
3572 strcat (class_key
, ".");
3573 strcat (class_key
, SSDATA (class));
3575 if (!NILP (component
))
3577 strcat (class_key
, ".");
3578 strcat (class_key
, SSDATA (subclass
));
3580 strcat (name_key
, ".");
3581 strcat (name_key
, SSDATA (component
));
3584 strcat (name_key
, ".");
3585 strcat (name_key
, SSDATA (attribute
));
3587 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3589 if (value
&& *value
)
3590 return build_string (value
);
3596 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3597 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3598 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3599 class, where INSTANCE is the name under which Emacs was invoked, or
3600 the name specified by the `-name' or `-rn' command-line arguments.
3602 The optional arguments COMPONENT and SUBCLASS add to the key and the
3603 class, respectively. You must specify both of them or neither.
3604 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3605 and the class is `Emacs.CLASS.SUBCLASS'. */)
3606 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
,
3607 Lisp_Object subclass
)
3609 check_window_system (NULL
);
3611 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3612 attribute
, class, component
, subclass
);
3615 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3618 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
,
3619 Lisp_Object
class, Lisp_Object component
,
3620 Lisp_Object subclass
)
3622 return xrdb_get_resource (dpyinfo
->xrdb
,
3623 attribute
, class, component
, subclass
);
3626 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3627 /* Used when C code wants a resource value. */
3628 /* Called from oldXMenu/Create.c. */
3630 x_get_resource_string (const char *attribute
, const char *class)
3633 struct frame
*sf
= SELECTED_FRAME ();
3634 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
3637 /* Allocate space for the components, the dots which separate them,
3638 and the final '\0'. */
3639 char *name_key
= SAFE_ALLOCA (invocation_namelen
+ strlen (attribute
) + 2);
3640 char *class_key
= alloca ((sizeof (EMACS_CLASS
) - 1) + strlen (class) + 2);
3642 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
3643 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3645 result
= x_get_string_resource (FRAME_DISPLAY_INFO (sf
)->xrdb
,
3646 name_key
, class_key
);
3652 /* Return the value of parameter PARAM.
3654 First search ALIST, then Vdefault_frame_alist, then the X defaults
3655 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3657 Convert the resource to the type specified by desired_type.
3659 If no default is specified, return Qunbound. If you call
3660 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3661 and don't let it get stored in any Lisp-visible variables! */
3664 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3665 const char *attribute
, const char *class, enum resource_types type
)
3667 register Lisp_Object tem
;
3669 tem
= Fassq (param
, alist
);
3673 /* If we find this parm in ALIST, clear it out
3674 so that it won't be "left over" at the end. */
3676 XSETCAR (tem
, Qnil
);
3677 /* In case the parameter appears more than once in the alist,
3679 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3680 if (CONSP (XCAR (tail
))
3681 && EQ (XCAR (XCAR (tail
)), param
))
3682 XSETCAR (XCAR (tail
), Qnil
);
3685 tem
= Fassq (param
, Vdefault_frame_alist
);
3687 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3688 look in the X resources. */
3691 if (attribute
&& dpyinfo
)
3693 tem
= display_x_get_resource (dpyinfo
,
3694 build_string (attribute
),
3695 build_string (class),
3703 case RES_TYPE_NUMBER
:
3704 return make_number (atoi (SSDATA (tem
)));
3706 case RES_TYPE_BOOLEAN_NUMBER
:
3707 if (!strcmp (SSDATA (tem
), "on")
3708 || !strcmp (SSDATA (tem
), "true"))
3709 return make_number (1);
3710 return make_number (atoi (SSDATA (tem
)));
3713 case RES_TYPE_FLOAT
:
3714 return make_float (atof (SSDATA (tem
)));
3716 case RES_TYPE_BOOLEAN
:
3717 tem
= Fdowncase (tem
);
3718 if (!strcmp (SSDATA (tem
), "on")
3720 || !strcmp (SSDATA (tem
), "yes")
3722 || !strcmp (SSDATA (tem
), "true"))
3727 case RES_TYPE_STRING
:
3730 case RES_TYPE_SYMBOL
:
3731 /* As a special case, we map the values `true' and `on'
3732 to Qt, and `false' and `off' to Qnil. */
3735 lower
= Fdowncase (tem
);
3736 if (!strcmp (SSDATA (lower
), "on")
3738 || !strcmp (SSDATA (lower
), "yes")
3740 || !strcmp (SSDATA (lower
), "true"))
3742 else if (!strcmp (SSDATA (lower
), "off")
3744 || !strcmp (SSDATA (lower
), "no")
3746 || !strcmp (SSDATA (lower
), "false"))
3749 return Fintern (tem
, Qnil
);
3763 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3764 const char *attribute
, const char *class,
3765 enum resource_types type
)
3767 return x_get_arg (FRAME_DISPLAY_INFO (f
),
3768 alist
, param
, attribute
, class, type
);
3771 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3774 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3776 const char *attribute
, const char *class,
3777 enum resource_types type
)
3781 value
= x_get_arg (FRAME_DISPLAY_INFO (f
), alist
, param
,
3782 attribute
, class, type
);
3783 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3784 store_frame_param (f
, param
, value
);
3790 /* Record in frame F the specified or default value according to ALIST
3791 of the parameter named PROP (a Lisp symbol).
3792 If no value is specified for PROP, look for an X default for XPROP
3793 on the frame named NAME.
3794 If that is not found either, use the value DEFLT. */
3797 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
3798 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
3799 enum resource_types type
)
3803 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3804 if (EQ (tem
, Qunbound
))
3806 x_set_frame_parameters (f
, list1 (Fcons (prop
, tem
)));
3811 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
3814 * XParseGeometry parses strings of the form
3815 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
3816 * width, height, xoffset, and yoffset are unsigned integers.
3817 * Example: "=80x24+300-49"
3818 * The equal sign is optional.
3819 * It returns a bitmask that indicates which of the four values
3820 * were actually found in the string. For each value found,
3821 * the corresponding argument is updated; for each value
3822 * not found, the corresponding argument is left unchanged.
3826 XParseGeometry (char *string
,
3828 unsigned int *width
, unsigned int *height
)
3832 unsigned long int tempWidth
, tempHeight
;
3833 long int tempX
, tempY
;
3834 char *nextCharacter
;
3836 if (string
== NULL
|| *string
== '\0')
3839 string
++; /* ignore possible '=' at beg of geometry spec */
3842 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
3844 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
3845 if (strind
== nextCharacter
)
3847 strind
= nextCharacter
;
3851 if (*strind
== 'x' || *strind
== 'X')
3854 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
3855 if (strind
== nextCharacter
)
3857 strind
= nextCharacter
;
3858 mask
|= HeightValue
;
3861 if (*strind
== '+' || *strind
== '-')
3865 tempX
= strtol (strind
, &nextCharacter
, 10);
3866 if (strind
== nextCharacter
)
3868 strind
= nextCharacter
;
3870 if (*strind
== '+' || *strind
== '-')
3874 tempY
= strtol (strind
, &nextCharacter
, 10);
3875 if (strind
== nextCharacter
)
3877 strind
= nextCharacter
;
3882 /* If strind isn't at the end of the string then it's an invalid
3883 geometry specification. */
3885 if (*strind
!= '\0')
3889 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
3891 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
3892 if (mask
& WidthValue
)
3893 *width
= min (tempWidth
, UINT_MAX
);
3894 if (mask
& HeightValue
)
3895 *height
= min (tempHeight
, UINT_MAX
);
3899 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
3902 /* NS used to define x-parse-geometry in ns-win.el, but that confused
3903 make-docfile: the documentation string in ns-win.el was used for
3904 x-parse-geometry even in non-NS builds.
3906 With two definitions of x-parse-geometry in this file, various
3907 things still get confused (eg M-x apropos documentation), so that
3908 it is best if the two definitions just share the same doc-string.
3910 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3911 doc
: /* Parse a display geometry string STRING.
3912 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3913 The properties returned may include `top', `left', `height', and `width'.
3914 For X, the value of `left' or `top' may be an integer,
3915 or a list (+ N) meaning N pixels relative to top/left corner,
3916 or a list (- N) meaning -N pixels relative to bottom/right corner.
3917 On Nextstep, this just calls `ns-parse-geometry'. */)
3918 (Lisp_Object string
)
3921 unsigned int width
, height
;
3924 CHECK_STRING (string
);
3927 if (strchr (SSDATA (string
), ' ') != NULL
)
3928 return call1 (Qns_parse_geometry
, string
);
3930 geometry
= XParseGeometry (SSDATA (string
),
3931 &x
, &y
, &width
, &height
);
3933 if (geometry
& XValue
)
3935 Lisp_Object element
;
3937 if (x
>= 0 && (geometry
& XNegative
))
3938 element
= list3 (Qleft
, Qminus
, make_number (-x
));
3939 else if (x
< 0 && ! (geometry
& XNegative
))
3940 element
= list3 (Qleft
, Qplus
, make_number (x
));
3942 element
= Fcons (Qleft
, make_number (x
));
3943 result
= Fcons (element
, result
);
3946 if (geometry
& YValue
)
3948 Lisp_Object element
;
3950 if (y
>= 0 && (geometry
& YNegative
))
3951 element
= list3 (Qtop
, Qminus
, make_number (-y
));
3952 else if (y
< 0 && ! (geometry
& YNegative
))
3953 element
= list3 (Qtop
, Qplus
, make_number (y
));
3955 element
= Fcons (Qtop
, make_number (y
));
3956 result
= Fcons (element
, result
);
3959 if (geometry
& WidthValue
)
3960 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3961 if (geometry
& HeightValue
)
3962 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3968 /* Calculate the desired size and position of frame F.
3969 Return the flags saying which aspects were specified.
3971 Also set the win_gravity and size_hint_flags of F.
3973 Adjust height for toolbar if TOOLBAR_P is 1.
3975 This function does not make the coordinates positive. */
3977 #define DEFAULT_ROWS 35
3978 #define DEFAULT_COLS 80
3981 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, bool toolbar_p
)
3983 register Lisp_Object tem0
, tem1
, tem2
;
3984 long window_prompting
= 0;
3985 Display_Info
*dpyinfo
= FRAME_DISPLAY_INFO (f
);
3987 /* Default values if we fall through.
3988 Actually, if that happens we should get
3989 window manager prompting. */
3990 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3991 FRAME_LINES (f
) = DEFAULT_ROWS
;
3992 /* Window managers expect that if program-specified
3993 positions are not (0,0), they're intentional, not defaults. */
3997 /* Ensure that old new_text_cols and new_text_lines will not override the
3999 /* ++KFS: This was specific to W32, but seems ok for all platforms */
4000 f
->new_text_cols
= f
->new_text_lines
= 0;
4002 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4003 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4004 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4005 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4007 if (!EQ (tem0
, Qunbound
))
4009 CHECK_NUMBER (tem0
);
4010 if (! (0 <= XINT (tem0
) && XINT (tem0
) <= INT_MAX
))
4011 xsignal1 (Qargs_out_of_range
, tem0
);
4012 FRAME_LINES (f
) = XINT (tem0
);
4014 if (!EQ (tem1
, Qunbound
))
4016 CHECK_NUMBER (tem1
);
4017 if (! (0 <= XINT (tem1
) && XINT (tem1
) <= INT_MAX
))
4018 xsignal1 (Qargs_out_of_range
, tem1
);
4019 SET_FRAME_COLS (f
, XINT (tem1
));
4021 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4022 window_prompting
|= USSize
;
4024 window_prompting
|= PSize
;
4027 f
->scroll_bar_actual_width
4028 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4030 /* This used to be done _before_ calling x_figure_window_size, but
4031 since the height is reset here, this was really a no-op. I
4032 assume that moving it here does what Gerd intended (although he
4033 no longer can remember what that was... ++KFS, 2003-03-25. */
4035 /* Add the tool-bar height to the initial frame height so that the
4036 user gets a text display area of the size he specified with -g or
4037 via .Xdefaults. Later changes of the tool-bar height don't
4038 change the frame size. This is done so that users can create
4039 tall Emacs frames without having to guess how tall the tool-bar
4041 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4043 int margin
, relief
, bar_height
;
4045 relief
= (tool_bar_button_relief
>= 0
4046 ? tool_bar_button_relief
4047 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4049 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
4050 margin
= XFASTINT (Vtool_bar_button_margin
);
4051 else if (CONSP (Vtool_bar_button_margin
)
4052 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
4053 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4057 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4058 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4061 compute_fringe_widths (f
, 0);
4063 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4064 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4066 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4067 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4068 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4069 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4071 if (EQ (tem0
, Qminus
))
4074 window_prompting
|= YNegative
;
4076 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4077 && CONSP (XCDR (tem0
))
4078 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem0
)), INT_MAX
))
4080 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4081 window_prompting
|= YNegative
;
4083 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4084 && CONSP (XCDR (tem0
))
4085 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0
))))
4087 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4089 else if (EQ (tem0
, Qunbound
))
4093 CHECK_TYPE_RANGED_INTEGER (int, tem0
);
4094 f
->top_pos
= XINT (tem0
);
4096 window_prompting
|= YNegative
;
4099 if (EQ (tem1
, Qminus
))
4102 window_prompting
|= XNegative
;
4104 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4105 && CONSP (XCDR (tem1
))
4106 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem1
)), INT_MAX
))
4108 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4109 window_prompting
|= XNegative
;
4111 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4112 && CONSP (XCDR (tem1
))
4113 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1
))))
4115 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4117 else if (EQ (tem1
, Qunbound
))
4121 CHECK_TYPE_RANGED_INTEGER (int, tem1
);
4122 f
->left_pos
= XINT (tem1
);
4123 if (f
->left_pos
< 0)
4124 window_prompting
|= XNegative
;
4127 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4128 window_prompting
|= USPosition
;
4130 window_prompting
|= PPosition
;
4133 if (window_prompting
& XNegative
)
4135 if (window_prompting
& YNegative
)
4136 f
->win_gravity
= SouthEastGravity
;
4138 f
->win_gravity
= NorthEastGravity
;
4142 if (window_prompting
& YNegative
)
4143 f
->win_gravity
= SouthWestGravity
;
4145 f
->win_gravity
= NorthWestGravity
;
4148 f
->size_hint_flags
= window_prompting
;
4150 return window_prompting
;
4155 #endif /* HAVE_WINDOW_SYSTEM */
4158 frame_make_pointer_invisible (void)
4160 if (! NILP (Vmake_pointer_invisible
))
4163 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4166 f
= SELECTED_FRAME ();
4167 if (f
&& !f
->pointer_invisible
4168 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4171 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4172 f
->pointer_invisible
= 1;
4178 frame_make_pointer_visible (void)
4180 /* We don't check Vmake_pointer_invisible here in case the
4181 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4184 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4187 f
= SELECTED_FRAME ();
4188 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4189 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4191 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4192 f
->pointer_invisible
= 0;
4196 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4197 Sframe_pointer_visible_p
, 0, 1, 0,
4198 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4199 Otherwise it returns nil. FRAME omitted or nil means the
4200 selected frame. This is useful when `make-pointer-invisible' is set. */)
4203 return decode_any_frame (frame
)->pointer_invisible
? Qnil
: Qt
;
4208 /***********************************************************************
4210 ***********************************************************************/
4212 #ifdef HAVE_WINDOW_SYSTEM
4214 # if (defined HAVE_NS \
4215 || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR)))
4217 free_monitors (struct MonitorInfo
*monitors
, int n_monitors
)
4220 for (i
= 0; i
< n_monitors
; ++i
)
4221 xfree (monitors
[i
].name
);
4227 make_monitor_attribute_list (struct MonitorInfo
*monitors
,
4229 int primary_monitor
,
4230 Lisp_Object monitor_frames
,
4233 Lisp_Object attributes_list
= Qnil
;
4234 Lisp_Object primary_monitor_attributes
= Qnil
;
4237 for (i
= 0; i
< n_monitors
; ++i
)
4239 Lisp_Object geometry
, workarea
, attributes
= Qnil
;
4240 struct MonitorInfo
*mi
= &monitors
[i
];
4242 if (mi
->geom
.width
== 0) continue;
4244 workarea
= list4i (mi
->work
.x
, mi
->work
.y
,
4245 mi
->work
.width
, mi
->work
.height
);
4246 geometry
= list4i (mi
->geom
.x
, mi
->geom
.y
,
4247 mi
->geom
.width
, mi
->geom
.height
);
4248 attributes
= Fcons (Fcons (Qsource
, build_string (source
)),
4250 attributes
= Fcons (Fcons (Qframes
, AREF (monitor_frames
, i
)),
4252 attributes
= Fcons (Fcons (Qmm_size
,
4253 list2i (mi
->mm_width
, mi
->mm_height
)),
4255 attributes
= Fcons (Fcons (Qworkarea
, workarea
), attributes
);
4256 attributes
= Fcons (Fcons (Qgeometry
, geometry
), attributes
);
4258 attributes
= Fcons (Fcons (Qname
, make_string (mi
->name
,
4259 strlen (mi
->name
))),
4262 if (i
== primary_monitor
)
4263 primary_monitor_attributes
= attributes
;
4265 attributes_list
= Fcons (attributes
, attributes_list
);
4268 if (!NILP (primary_monitor_attributes
))
4269 attributes_list
= Fcons (primary_monitor_attributes
, attributes_list
);
4270 return attributes_list
;
4273 #endif /* HAVE_WINDOW_SYSTEM */
4276 /***********************************************************************
4278 ***********************************************************************/
4281 syms_of_frame (void)
4283 DEFSYM (Qframep
, "framep");
4284 DEFSYM (Qframe_live_p
, "frame-live-p");
4285 DEFSYM (Qexplicit_name
, "explicit-name");
4286 DEFSYM (Qheight
, "height");
4287 DEFSYM (Qicon
, "icon");
4288 DEFSYM (Qminibuffer
, "minibuffer");
4289 DEFSYM (Qmodeline
, "modeline");
4290 DEFSYM (Qonly
, "only");
4291 DEFSYM (Qnone
, "none");
4292 DEFSYM (Qwidth
, "width");
4293 DEFSYM (Qgeometry
, "geometry");
4294 DEFSYM (Qicon_left
, "icon-left");
4295 DEFSYM (Qicon_top
, "icon-top");
4296 DEFSYM (Qtooltip
, "tooltip");
4297 DEFSYM (Qleft
, "left");
4298 DEFSYM (Qright
, "right");
4299 DEFSYM (Quser_position
, "user-position");
4300 DEFSYM (Quser_size
, "user-size");
4301 DEFSYM (Qwindow_id
, "window-id");
4302 #ifdef HAVE_X_WINDOWS
4303 DEFSYM (Qouter_window_id
, "outer-window-id");
4305 DEFSYM (Qparent_id
, "parent-id");
4307 DEFSYM (Qw32
, "w32");
4310 DEFSYM (Qvisible
, "visible");
4311 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4312 DEFSYM (Qbuffer_list
, "buffer-list");
4313 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4314 DEFSYM (Qdisplay_type
, "display-type");
4315 DEFSYM (Qbackground_mode
, "background-mode");
4316 DEFSYM (Qnoelisp
, "noelisp");
4317 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4318 DEFSYM (Qtty
, "tty");
4319 DEFSYM (Qtty_type
, "tty-type");
4321 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4323 DEFSYM (Qfullwidth
, "fullwidth");
4324 DEFSYM (Qfullheight
, "fullheight");
4325 DEFSYM (Qfullboth
, "fullboth");
4326 DEFSYM (Qmaximized
, "maximized");
4327 DEFSYM (Qx_resource_name
, "x-resource-name");
4328 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4330 DEFSYM (Qterminal
, "terminal");
4332 DEFSYM (Qgeometry
, "geometry");
4333 DEFSYM (Qworkarea
, "workarea");
4334 DEFSYM (Qmm_size
, "mm-size");
4335 DEFSYM (Qframes
, "frames");
4336 DEFSYM (Qsource
, "source");
4339 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4345 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4347 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4348 if (frame_parms
[i
].variable
)
4350 *frame_parms
[i
].variable
= v
;
4351 staticpro (frame_parms
[i
].variable
);
4353 Fput (v
, Qx_frame_parameter
, make_number (i
));
4357 #ifdef HAVE_WINDOW_SYSTEM
4358 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4359 doc
: /* The name Emacs uses to look up X resources.
4360 `x-get-resource' uses this as the first component of the instance name
4361 when requesting resource values.
4362 Emacs initially sets `x-resource-name' to the name under which Emacs
4363 was invoked, or to the value specified with the `-name' or `-rn'
4364 switches, if present.
4366 It may be useful to bind this variable locally around a call
4367 to `x-get-resource'. See also the variable `x-resource-class'. */);
4368 Vx_resource_name
= Qnil
;
4370 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4371 doc
: /* The class Emacs uses to look up X resources.
4372 `x-get-resource' uses this as the first component of the instance class
4373 when requesting resource values.
4375 Emacs initially sets `x-resource-class' to "Emacs".
4377 Setting this variable permanently is not a reasonable thing to do,
4378 but binding this variable locally around a call to `x-get-resource'
4379 is a reasonable practice. See also the variable `x-resource-name'. */);
4380 Vx_resource_class
= build_string (EMACS_CLASS
);
4382 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4383 doc
: /* The lower limit of the frame opacity (alpha transparency).
4384 The value should range from 0 (invisible) to 100 (completely opaque).
4385 You can also use a floating number between 0.0 and 1.0.
4386 The default is 20. */);
4387 Vframe_alpha_lower_limit
= make_number (20);
4390 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4391 doc
: /* Alist of default values for frame creation.
4392 These may be set in your init file, like this:
4393 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4394 These override values given in window system configuration data,
4395 including X Windows' defaults database.
4396 For values specific to the first Emacs frame, see `initial-frame-alist'.
4397 For window-system specific values, see `window-system-default-frame-alist'.
4398 For values specific to the separate minibuffer frame, see
4399 `minibuffer-frame-alist'.
4400 The `menu-bar-lines' element of the list controls whether new frames
4401 have menu bars; `menu-bar-mode' works by altering this element.
4402 Setting this variable does not affect existing frames, only new ones. */);
4403 Vdefault_frame_alist
= Qnil
;
4405 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4406 doc
: /* Default position of scroll bars on this window-system. */);
4407 #ifdef HAVE_WINDOW_SYSTEM
4408 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
4409 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4411 Vdefault_frame_scroll_bars
= Qright
;
4413 Vdefault_frame_scroll_bars
= Qleft
;
4416 Vdefault_frame_scroll_bars
= Qnil
;
4419 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
4420 scroll_bar_adjust_thumb_portion_p
,
4421 doc
: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
4422 Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
4423 even if the end of the buffer is shown (i.e. overscrolling).
4424 Set to nil if you want the thumb to be at the bottom when the end of the buffer
4425 is shown. Also, the thumb fills the whole scroll bar when the entire buffer
4426 is visible. In this case you can not overscroll. */);
4427 scroll_bar_adjust_thumb_portion_p
= 1;
4429 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4430 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4432 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4433 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4434 `mouse-position' calls this function, passing its usual return value as
4435 argument, and returns whatever this function returns.
4436 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4437 which need to do mouse handling at the Lisp level. */);
4438 Vmouse_position_function
= Qnil
;
4440 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4441 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4442 If the value is an integer, highlighting is only shown after moving the
4443 mouse, while keyboard input turns off the highlight even when the mouse
4444 is over the clickable text. However, the mouse shape still indicates
4445 when the mouse is over clickable text. */);
4446 Vmouse_highlight
= Qt
;
4448 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4449 doc
: /* If non-nil, make pointer invisible while typing.
4450 The pointer becomes visible again when the mouse is moved. */);
4451 Vmake_pointer_invisible
= Qt
;
4453 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4454 doc
: /* Functions run before deleting a frame.
4455 The functions are run with one arg, the frame to be deleted.
4458 Note that functions in this list may be called just before the frame is
4459 actually deleted, or some time later (or even both when an earlier function
4460 in `delete-frame-functions' (indirectly) calls `delete-frame'
4462 Vdelete_frame_functions
= Qnil
;
4463 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
4465 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4466 doc
: /* Non-nil if Menu-Bar mode is enabled.
4467 See the command `menu-bar-mode' for a description of this minor mode.
4468 Setting this variable directly does not take effect;
4469 either customize it (see the info node `Easy Customization')
4470 or call the function `menu-bar-mode'. */);
4471 Vmenu_bar_mode
= Qt
;
4473 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4474 doc
: /* Non-nil if Tool-Bar mode is enabled.
4475 See the command `tool-bar-mode' for a description of this minor mode.
4476 Setting this variable directly does not take effect;
4477 either customize it (see the info node `Easy Customization')
4478 or call the function `tool-bar-mode'. */);
4479 #ifdef HAVE_WINDOW_SYSTEM
4480 Vtool_bar_mode
= Qt
;
4482 Vtool_bar_mode
= Qnil
;
4485 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4486 doc
: /* Minibufferless frames use this frame's minibuffer.
4488 Emacs cannot create minibufferless frames unless this is set to an
4489 appropriate surrogate.
4491 Emacs consults this variable only when creating minibufferless
4492 frames; once the frame is created, it sticks with its assigned
4493 minibuffer, no matter what this variable is set to. This means that
4494 this variable doesn't necessarily say anything meaningful about the
4495 current set of frames, or where the minibuffer is currently being
4498 This variable is local to the current terminal and cannot be buffer-local. */);
4500 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
4501 doc
: /* Non-nil if window system changes focus when you move the mouse.
4502 You should set this variable to tell Emacs how your window manager
4503 handles focus, since there is no way in general for Emacs to find out
4504 automatically. See also `mouse-autoselect-window'. */);
4505 focus_follows_mouse
= 0;
4507 staticpro (&Vframe_list
);
4510 defsubr (&Sframe_live_p
);
4511 defsubr (&Swindow_system
);
4512 defsubr (&Smake_terminal_frame
);
4513 defsubr (&Shandle_switch_frame
);
4514 defsubr (&Shandle_focus_in
);
4515 defsubr (&Shandle_focus_out
);
4516 defsubr (&Sselect_frame
);
4517 defsubr (&Sselected_frame
);
4518 defsubr (&Sframe_list
);
4519 defsubr (&Snext_frame
);
4520 defsubr (&Sprevious_frame
);
4521 defsubr (&Slast_nonminibuf_frame
);
4522 defsubr (&Sdelete_frame
);
4523 defsubr (&Smouse_position
);
4524 defsubr (&Smouse_pixel_position
);
4525 defsubr (&Sset_mouse_position
);
4526 defsubr (&Sset_mouse_pixel_position
);
4528 defsubr (&Sframe_configuration
);
4529 defsubr (&Srestore_frame_configuration
);
4531 defsubr (&Smake_frame_visible
);
4532 defsubr (&Smake_frame_invisible
);
4533 defsubr (&Siconify_frame
);
4534 defsubr (&Sframe_visible_p
);
4535 defsubr (&Svisible_frame_list
);
4536 defsubr (&Sraise_frame
);
4537 defsubr (&Slower_frame
);
4538 defsubr (&Sx_focus_frame
);
4539 defsubr (&Sredirect_frame_focus
);
4540 defsubr (&Sframe_focus
);
4541 defsubr (&Sframe_parameters
);
4542 defsubr (&Sframe_parameter
);
4543 defsubr (&Smodify_frame_parameters
);
4544 defsubr (&Sframe_char_height
);
4545 defsubr (&Sframe_char_width
);
4546 defsubr (&Sframe_pixel_height
);
4547 defsubr (&Sframe_pixel_width
);
4548 defsubr (&Stool_bar_pixel_width
);
4549 defsubr (&Sset_frame_height
);
4550 defsubr (&Sset_frame_width
);
4551 defsubr (&Sset_frame_size
);
4552 defsubr (&Sset_frame_position
);
4553 defsubr (&Sframe_pointer_visible_p
);
4555 #ifdef HAVE_WINDOW_SYSTEM
4556 defsubr (&Sx_get_resource
);
4557 defsubr (&Sx_parse_geometry
);