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/>. */
22 #define FRAME_INLINE EXTERN_INLINE
31 #include "character.h"
33 #ifdef HAVE_WINDOW_SYSTEM
35 #endif /* HAVE_WINDOW_SYSTEM */
38 /* These help us bind and responding to switch-frame events. */
42 #include "blockinput.h"
44 #include "termhooks.h"
45 #include "dispextern.h"
48 #ifdef HAVE_WINDOW_SYSTEM
57 Lisp_Object Qns_parse_geometry
;
60 Lisp_Object Qframep
, Qframe_live_p
;
61 Lisp_Object Qicon
, Qmodeline
;
62 Lisp_Object Qonly
, Qnone
;
63 Lisp_Object Qx
, Qw32
, Qpc
, Qns
;
65 Lisp_Object Qdisplay_type
;
66 static Lisp_Object Qbackground_mode
;
69 static Lisp_Object Qx_frame_parameter
;
70 Lisp_Object Qx_resource_name
;
71 Lisp_Object Qterminal
;
73 /* Frame parameters (set or reported). */
75 Lisp_Object Qauto_raise
, Qauto_lower
;
76 Lisp_Object Qborder_color
, Qborder_width
;
77 Lisp_Object Qcursor_color
, Qcursor_type
;
78 Lisp_Object Qheight
, Qwidth
;
79 Lisp_Object Qleft
, Qright
;
80 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
82 Lisp_Object Qinternal_border_width
;
83 Lisp_Object Qmouse_color
;
84 Lisp_Object Qminibuffer
;
85 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
86 Lisp_Object Qvisibility
;
87 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
88 Lisp_Object Qscreen_gamma
;
89 Lisp_Object Qline_spacing
;
90 static Lisp_Object Quser_position
, Quser_size
;
91 Lisp_Object Qwait_for_wm
;
92 static Lisp_Object Qwindow_id
;
94 static Lisp_Object Qouter_window_id
;
96 Lisp_Object Qparent_id
;
97 Lisp_Object Qtitle
, Qname
;
98 static Lisp_Object Qexplicit_name
;
99 Lisp_Object Qunsplittable
;
100 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
, Qtool_bar_position
;
101 Lisp_Object Qleft_fringe
, Qright_fringe
;
102 Lisp_Object Qbuffer_predicate
;
103 static Lisp_Object Qbuffer_list
, Qburied_buffer_list
;
104 Lisp_Object Qtty_color_mode
;
105 Lisp_Object Qtty
, Qtty_type
;
107 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
109 Lisp_Object Qfont_backend
;
112 Lisp_Object Qface_set_after_frame_default
;
114 static Lisp_Object Qdelete_frame_functions
;
116 static Lisp_Object Qgeometry
, Qworkarea
, Qmm_size
, Qframes
, Qsource
;
118 #ifdef HAVE_WINDOW_SYSTEM
119 static void x_report_frame_params (struct frame
*, Lisp_Object
*);
122 /* These setters are used only in this file, so they can be private. */
124 fset_buffer_predicate (struct frame
*f
, Lisp_Object val
)
126 f
->buffer_predicate
= val
;
129 fset_minibuffer_window (struct frame
*f
, Lisp_Object val
)
131 f
->minibuffer_window
= val
;
135 decode_live_frame (register Lisp_Object frame
)
138 frame
= selected_frame
;
139 CHECK_LIVE_FRAME (frame
);
140 return XFRAME (frame
);
144 decode_any_frame (register Lisp_Object frame
)
147 frame
= selected_frame
;
149 return XFRAME (frame
);
153 window_system_available (struct frame
*f
)
156 return FRAME_WINDOW_P (f
) || FRAME_MSDOS_P (f
);
158 #ifdef HAVE_WINDOW_SYSTEM
159 return x_display_list
!= NULL
;
166 decode_window_system_frame (Lisp_Object frame
)
168 struct frame
*f
= decode_live_frame (frame
);
170 if (!window_system_available (f
))
171 error ("Window system frame should be used");
176 check_window_system (struct frame
*f
)
178 if (!window_system_available (f
))
179 error (f
? "Window system frame should be used"
180 : "Window system is not in use or not initialized");
184 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
186 struct window
*w
= XWINDOW (window
);
191 /* Handle just the top child in a vertical split. */
192 if (WINDOW_VERTICAL_COMBINATION_P (w
))
193 set_menu_bar_lines_1 (w
->contents
, n
);
194 else if (WINDOW_HORIZONTAL_COMBINATION_P (w
))
195 /* Adjust all children in a horizontal split. */
196 for (window
= w
->contents
; !NILP (window
); window
= w
->next
)
198 w
= XWINDOW (window
);
199 set_menu_bar_lines_1 (window
, n
);
204 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
207 int olines
= FRAME_MENU_BAR_LINES (f
);
209 /* Right now, menu bars don't work properly in minibuf-only frames;
210 most of the commands try to apply themselves to the minibuffer
211 frame itself, and get an error because you can't switch buffers
212 in or split the minibuffer window. */
213 if (FRAME_MINIBUF_ONLY_P (f
))
216 if (TYPE_RANGED_INTEGERP (int, value
))
217 nlines
= XINT (value
);
221 if (nlines
!= olines
)
223 windows_or_buffers_changed
++;
224 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
225 FRAME_MENU_BAR_LINES (f
) = nlines
;
226 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
231 Lisp_Object Vframe_list
;
234 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
235 doc
: /* Return non-nil if OBJECT is a frame.
237 t for a termcap frame (a character-only terminal),
238 'x' for an Emacs frame that is really an X window,
239 'w32' for an Emacs frame that is a window on MS-Windows display,
240 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
241 'pc' for a direct-write MS-DOS frame.
242 See also `frame-live-p'. */)
245 if (!FRAMEP (object
))
247 switch (XFRAME (object
)->output_method
)
249 case output_initial
: /* The initial frame is like a termcap frame. */
252 case output_x_window
:
256 case output_msdos_raw
:
265 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
266 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
267 Value is nil if OBJECT is not a live frame. If object is a live
268 frame, the return value indicates what sort of terminal device it is
269 displayed on. See the documentation of `framep' for possible
273 return ((FRAMEP (object
)
274 && FRAME_LIVE_P (XFRAME (object
)))
279 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
280 doc
: /* The name of the window system that FRAME is displaying through.
281 The value is a symbol:
282 nil for a termcap frame (a character-only terminal),
283 'x' for an Emacs frame that is really an X window,
284 'w32' for an Emacs frame that is a window on MS-Windows display,
285 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
286 'pc' for a direct-write MS-DOS frame.
288 FRAME defaults to the currently selected frame.
290 Use of this function as a predicate is deprecated. Instead,
291 use `display-graphic-p' or any of the other `display-*-p'
292 predicates which report frame's specific UI-related capabilities. */)
297 frame
= selected_frame
;
299 type
= Fframep (frame
);
302 wrong_type_argument (Qframep
, frame
);
311 make_frame (bool mini_p
)
314 register struct frame
*f
;
315 register Lisp_Object root_window
;
316 register Lisp_Object mini_window
;
318 f
= allocate_frame ();
319 XSETFRAME (frame
, f
);
321 /* Initialize Lisp data. Note that allocate_frame initializes all
322 Lisp data to nil, so do it only for slots which should not be nil. */
323 fset_tool_bar_position (f
, Qtop
);
325 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
326 non-Lisp data, so do it only for slots which should not be zero.
327 To avoid subtle bugs and for the sake of readability, it's better to
328 initialize enum members explicitly even if their values are zero. */
329 f
->wants_modeline
= 1;
331 f
->has_minibuffer
= mini_p
;
332 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
333 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
334 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
335 #ifdef HAVE_WINDOW_SYSTEM
336 f
->want_fullscreen
= FULLSCREEN_NONE
;
339 root_window
= make_window ();
342 mini_window
= make_window ();
343 wset_next (XWINDOW (root_window
), mini_window
);
344 wset_prev (XWINDOW (mini_window
), root_window
);
345 XWINDOW (mini_window
)->mini
= 1;
346 wset_frame (XWINDOW (mini_window
), frame
);
347 fset_minibuffer_window (f
, mini_window
);
352 wset_next (XWINDOW (root_window
), Qnil
);
353 fset_minibuffer_window (f
, Qnil
);
356 wset_frame (XWINDOW (root_window
), frame
);
359 just so that there is "something there."
360 Correct size will be set up later with change_frame_size. */
362 SET_FRAME_COLS (f
, 10);
363 FRAME_LINES (f
) = 10;
365 XWINDOW (root_window
)->total_cols
= 10;
366 XWINDOW (root_window
)->total_lines
= mini_p
? 9 : 10;
370 XWINDOW (mini_window
)->total_cols
= 10;
371 XWINDOW (mini_window
)->top_line
= 9;
372 XWINDOW (mini_window
)->total_lines
= 1;
375 /* Choose a buffer for the frame's root window. */
377 Lisp_Object buf
= Fcurrent_buffer ();
379 /* If current buffer is hidden, try to find another one. */
380 if (BUFFER_HIDDEN_P (XBUFFER (buf
)))
381 buf
= other_buffer_safely (buf
);
383 /* Use set_window_buffer, not Fset_window_buffer, and don't let
384 hooks be run by it. The reason is that the whole frame/window
385 arrangement is not yet fully initialized at this point. Windows
386 don't have the right size, glyph matrices aren't initialized
387 etc. Running Lisp functions at this point surely ends in a
389 set_window_buffer (root_window
, buf
, 0, 0);
390 fset_buffer_list (f
, list1 (buf
));
394 set_window_buffer (mini_window
,
395 (NILP (Vminibuffer_list
)
397 : Fcar (Vminibuffer_list
)),
400 fset_root_window (f
, root_window
);
401 fset_selected_window (f
, root_window
);
402 /* Make sure this window seems more recently used than
403 a newly-created, never-selected window. */
404 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
409 #ifdef HAVE_WINDOW_SYSTEM
410 /* Make a frame using a separate minibuffer window on another frame.
411 MINI_WINDOW is the minibuffer window to use. nil means use the
412 default (the global minibuffer). */
415 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
417 register struct frame
*f
;
420 if (!NILP (mini_window
))
421 CHECK_LIVE_WINDOW (mini_window
);
423 if (!NILP (mini_window
)
424 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
425 error ("Frame and minibuffer must be on the same terminal");
427 /* Make a frame containing just a root window. */
430 if (NILP (mini_window
))
432 /* Use default-minibuffer-frame if possible. */
433 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
434 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
436 Lisp_Object frame_dummy
;
438 XSETFRAME (frame_dummy
, f
);
439 GCPRO1 (frame_dummy
);
440 /* If there's no minibuffer frame to use, create one. */
441 kset_default_minibuffer_frame
442 (kb
, call1 (intern ("make-initial-minibuffer-frame"), display
));
447 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
450 fset_minibuffer_window (f
, mini_window
);
452 /* Make the chosen minibuffer window display the proper minibuffer,
453 unless it is already showing a minibuffer. */
454 if (NILP (Fmemq (XWINDOW (mini_window
)->contents
, Vminibuffer_list
)))
455 /* Use set_window_buffer instead of Fset_window_buffer (see
456 discussion of bug#11984, bug#12025, bug#12026). */
457 set_window_buffer (mini_window
,
458 (NILP (Vminibuffer_list
)
460 : Fcar (Vminibuffer_list
)), 0, 0);
464 /* Make a frame containing only a minibuffer window. */
467 make_minibuffer_frame (void)
469 /* First make a frame containing just a root window, no minibuffer. */
471 register struct frame
*f
= make_frame (0);
472 register Lisp_Object mini_window
;
473 register Lisp_Object frame
;
475 XSETFRAME (frame
, f
);
480 f
->wants_modeline
= 0;
481 f
->has_minibuffer
= 1;
483 /* Now label the root window as also being the minibuffer.
484 Avoid infinite looping on the window chain by marking next pointer
487 mini_window
= f
->root_window
;
488 fset_minibuffer_window (f
, mini_window
);
489 XWINDOW (mini_window
)->mini
= 1;
490 wset_next (XWINDOW (mini_window
), Qnil
);
491 wset_prev (XWINDOW (mini_window
), Qnil
);
492 wset_frame (XWINDOW (mini_window
), frame
);
494 /* Put the proper buffer in that window. */
496 /* Use set_window_buffer instead of Fset_window_buffer (see
497 discussion of bug#11984, bug#12025, bug#12026). */
498 set_window_buffer (mini_window
,
499 (NILP (Vminibuffer_list
)
501 : Fcar (Vminibuffer_list
)), 0, 0);
504 #endif /* HAVE_WINDOW_SYSTEM */
506 /* Construct a frame that refers to a terminal. */
508 static printmax_t tty_frame_count
;
511 make_initial_frame (void)
514 struct terminal
*terminal
;
517 eassert (initial_kboard
);
519 /* The first call must initialize Vframe_list. */
520 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
523 terminal
= init_initial_terminal ();
526 XSETFRAME (frame
, f
);
528 Vframe_list
= Fcons (frame
, Vframe_list
);
531 fset_name (f
, build_pure_c_string ("F1"));
533 SET_FRAME_VISIBLE (f
, 1);
535 f
->output_method
= terminal
->type
;
536 f
->terminal
= terminal
;
537 f
->terminal
->reference_count
++;
538 f
->output_data
.nothing
= 0;
540 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
541 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
543 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
545 /* The default value of menu-bar-mode is t. */
546 set_menu_bar_lines (f
, make_number (1), Qnil
);
549 init_frame_faces (f
);
555 static struct frame
*
556 make_terminal_frame (struct terminal
*terminal
)
558 register struct frame
*f
;
560 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
563 error ("Terminal is not live, can't create new frames on it");
567 XSETFRAME (frame
, f
);
568 Vframe_list
= Fcons (frame
, Vframe_list
);
570 fset_name (f
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
572 SET_FRAME_VISIBLE (f
, 1);
574 f
->terminal
= terminal
;
575 f
->terminal
->reference_count
++;
577 f
->output_data
.tty
->display_info
= &the_only_display_info
;
578 if (!inhibit_window_system
579 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
580 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
581 f
->output_method
= output_msdos_raw
;
583 f
->output_method
= output_termcap
;
584 #else /* not MSDOS */
585 f
->output_method
= output_termcap
;
586 create_tty_output (f
);
587 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
588 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
589 #endif /* not MSDOS */
591 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
592 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
594 /* Set the top frame to the newly created frame. */
595 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
596 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
597 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f
)->top_frame
), 2); /* obscured */
599 FRAME_TTY (f
)->top_frame
= frame
;
602 init_frame_faces (f
);
607 /* Get a suitable value for frame parameter PARAMETER for a newly
608 created frame, based on (1) the user-supplied frame parameter
609 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
612 get_future_frame_param (Lisp_Object parameter
,
613 Lisp_Object supplied_parms
,
618 result
= Fassq (parameter
, supplied_parms
);
620 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
621 if (NILP (result
) && current_value
!= NULL
)
622 result
= build_string (current_value
);
623 if (!NILP (result
) && !STRINGP (result
))
624 result
= XCDR (result
);
625 if (NILP (result
) || !STRINGP (result
))
631 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
633 doc
: /* Create an additional terminal frame, possibly on another terminal.
634 This function takes one argument, an alist specifying frame parameters.
636 You can create multiple frames on a single text terminal, but only one
637 of them (the selected terminal frame) is actually displayed.
639 In practice, generally you don't need to specify any parameters,
640 except when you want to create a new frame on another terminal.
641 In that case, the `tty' parameter specifies the device file to open,
642 and the `tty-type' parameter specifies the terminal type. Example:
644 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
646 Note that changing the size of one terminal frame automatically
647 affects all frames on the same terminal device. */)
651 struct terminal
*t
= NULL
;
652 Lisp_Object frame
, tem
;
653 struct frame
*sf
= SELECTED_FRAME ();
656 if (sf
->output_method
!= output_msdos_raw
657 && sf
->output_method
!= output_termcap
)
659 #else /* not MSDOS */
661 #ifdef WINDOWSNT /* This should work now! */
662 if (sf
->output_method
!= output_termcap
)
663 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
665 #endif /* not MSDOS */
668 Lisp_Object terminal
;
670 terminal
= Fassq (Qterminal
, parms
);
671 if (CONSP (terminal
))
673 terminal
= XCDR (terminal
);
674 t
= get_terminal (terminal
, 1);
677 if (t
&& t
!= the_only_display_info
.terminal
)
678 /* msdos.c assumes a single tty_display_info object. */
679 error ("Multiple terminals are not supported on this platform");
681 t
= the_only_display_info
.terminal
;
687 char *name
= 0, *type
= 0;
688 Lisp_Object tty
, tty_type
;
690 tty
= get_future_frame_param
691 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
692 ? FRAME_TTY (XFRAME (selected_frame
))->name
695 name
= xlispstrdupa (tty
);
697 tty_type
= get_future_frame_param
698 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
699 ? FRAME_TTY (XFRAME (selected_frame
))->type
701 if (!NILP (tty_type
))
702 type
= xlispstrdupa (tty_type
);
704 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
707 f
= make_terminal_frame (t
);
711 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
712 change_frame_size (f
, height
, width
, 0, 0, 0);
717 XSETFRAME (frame
, f
);
719 store_in_alist (&parms
, Qtty_type
, build_string (t
->display_info
.tty
->type
));
720 store_in_alist (&parms
, Qtty
,
721 (t
->display_info
.tty
->name
722 ? build_string (t
->display_info
.tty
->name
)
724 Fmodify_frame_parameters (frame
, parms
);
726 /* Make the frame face alist be frame-specific, so that each
727 frame could change its face definitions independently. */
728 fset_face_alist (f
, Fcopy_alist (sf
->face_alist
));
729 /* Simple Fcopy_alist isn't enough, because we need the contents of
730 the vectors which are the CDRs of associations in face_alist to
731 be copied as well. */
732 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
733 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
738 /* Perform the switch to frame FRAME.
740 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
743 If TRACK is non-zero and the frame that currently has the focus
744 redirects its focus to the selected frame, redirect that focused
745 frame's focus to FRAME instead.
747 FOR_DELETION non-zero means that the selected frame is being
748 deleted, which includes the possibility that the frame's terminal
751 The value of NORECORD is passed as argument to Fselect_window. */
754 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
756 struct frame
*sf
= SELECTED_FRAME ();
758 /* If FRAME is a switch-frame event, extract the frame we should
761 && EQ (XCAR (frame
), Qswitch_frame
)
762 && CONSP (XCDR (frame
)))
763 frame
= XCAR (XCDR (frame
));
765 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
766 a switch-frame event to arrive after a frame is no longer live,
767 especially when deleting the initial frame during startup. */
769 if (! FRAME_LIVE_P (XFRAME (frame
)))
772 if (sf
== XFRAME (frame
))
775 /* This is too greedy; it causes inappropriate focus redirection
776 that's hard to get rid of. */
778 /* If a frame's focus has been redirected toward the currently
779 selected frame, we should change the redirection to point to the
780 newly selected frame. This means that if the focus is redirected
781 from a minibufferless frame to a surrogate minibuffer frame, we
782 can use `other-window' to switch between all the frames using
783 that minibuffer frame, and the focus redirection will follow us
789 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
793 if (!FRAMEP (XCAR (tail
)))
796 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
798 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
799 Fredirect_frame_focus (XCAR (tail
), frame
);
803 /* Instead, apply it only to the frame we're pointing to. */
804 #ifdef HAVE_WINDOW_SYSTEM
805 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
807 Lisp_Object focus
, xfocus
;
809 xfocus
= x_get_focus_frame (XFRAME (frame
));
812 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
813 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
814 Fredirect_frame_focus (xfocus
, frame
);
817 #endif /* HAVE_X_WINDOWS */
820 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
821 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
823 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
825 Lisp_Object top_frame
= FRAME_TTY (XFRAME (frame
))->top_frame
;
827 /* Don't mark the frame garbaged and/or obscured if we are
828 switching to the frame that is already the top frame of that
830 if (!EQ (frame
, top_frame
))
832 if (FRAMEP (top_frame
))
833 /* Mark previously displayed frame as now obscured. */
834 SET_FRAME_VISIBLE (XFRAME (top_frame
), 2);
835 SET_FRAME_VISIBLE (XFRAME (frame
), 1);
837 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
840 selected_frame
= frame
;
841 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
842 last_nonminibuf_frame
= XFRAME (selected_frame
);
844 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
846 /* We want to make sure that the next event generates a frame-switch
847 event to the appropriate frame. This seems kludgy to me, but
848 before you take it out, make sure that evaluating something like
849 (select-window (frame-root-window (new-frame))) doesn't end up
850 with your typing being interpreted in the new frame instead of
851 the one you're actually typing in. */
852 internal_last_event_frame
= Qnil
;
857 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
858 doc
: /* Select FRAME.
859 Subsequent editing commands apply to its selected window.
860 Optional argument NORECORD means to neither change the order of
861 recently selected windows nor the buffer list.
863 The selection of FRAME lasts until the next time the user does
864 something to select a different frame, or until the next time
865 this function is called. If you are using a window system, the
866 previously selected frame may be restored as the selected frame
867 when returning to the command loop, because it still may have
868 the window system's input focus. On a text terminal, the next
869 redisplay will display FRAME.
871 This function returns FRAME, or nil if FRAME has been deleted. */)
872 (Lisp_Object frame
, Lisp_Object norecord
)
874 return do_switch_frame (frame
, 1, 0, norecord
);
877 DEFUN ("handle-focus-in", Fhandle_focus_in
, Shandle_focus_in
, 1, 1, "e",
878 doc
: /* Handle a focus-in event.
879 Focus in events are usually bound to this function.
880 Focus in events occur when a frame has focus, but a switch-frame event
882 This function checks if blink-cursor timers should be turned on again. */)
885 return call0 (intern ("blink-cursor-check"));
888 DEFUN ("handle-focus-out", Fhandle_focus_out
, Shandle_focus_out
, 1, 1, "e",
889 doc
: /* Handle a focus-out event.
890 Focus out events are usually bound to this function.
891 Focus out events occur when no frame has focus.
892 This function checks if blink-cursor timers should be turned off. */)
895 return call0 (intern ("blink-cursor-suspend"));
898 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
899 doc
: /* Handle a switch-frame event EVENT.
900 Switch-frame events are usually bound to this function.
901 A switch-frame event tells Emacs that the window manager has requested
902 that the user's events be directed to the frame mentioned in the event.
903 This function selects the selected window of the frame of EVENT.
905 If EVENT is frame object, handle it as if it were a switch-frame event
909 /* Preserve prefix arg that the command loop just cleared. */
910 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
911 Frun_hooks (1, &Qmouse_leave_buffer_hook
);
912 Fhandle_focus_in (event
); // switch-frame implies a focus in.
913 return do_switch_frame (event
, 0, 0, Qnil
);
916 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
917 doc
: /* Return the frame that is now selected. */)
920 return selected_frame
;
923 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
925 doc
: /* Return a list of all live frames. */)
929 frames
= Fcopy_sequence (Vframe_list
);
930 #ifdef HAVE_WINDOW_SYSTEM
931 if (FRAMEP (tip_frame
))
932 frames
= Fdelq (tip_frame
, frames
);
937 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
938 same tty (for tty frames) or among frames which uses FRAME's keyboard.
939 If MINIBUF is nil, do not consider minibuffer-only candidate.
940 If MINIBUF is `visible', do not consider an invisible candidate.
941 If MINIBUF is a window, consider only its own frame and candidate now
942 using that window as the minibuffer.
943 If MINIBUF is 0, consider candidate if it is visible or iconified.
944 Otherwise consider any candidate and return nil if CANDIDATE is not
948 candidate_frame (Lisp_Object candidate
, Lisp_Object frame
, Lisp_Object minibuf
)
950 struct frame
*c
= XFRAME (candidate
), *f
= XFRAME (frame
);
952 if ((!FRAME_TERMCAP_P (c
) && !FRAME_TERMCAP_P (f
)
953 && FRAME_KBOARD (c
) == FRAME_KBOARD (f
))
954 || (FRAME_TERMCAP_P (c
) && FRAME_TERMCAP_P (f
)
955 && FRAME_TTY (c
) == FRAME_TTY (f
)))
959 if (!FRAME_MINIBUF_ONLY_P (c
))
962 else if (EQ (minibuf
, Qvisible
))
964 if (FRAME_VISIBLE_P (c
))
967 else if (WINDOWP (minibuf
))
969 if (EQ (FRAME_MINIBUF_WINDOW (c
), minibuf
)
970 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), candidate
)
971 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
972 FRAME_FOCUS_FRAME (c
)))
975 else if (XFASTINT (minibuf
) == 0)
977 if (FRAME_VISIBLE_P (c
) || FRAME_ICONIFIED_P (c
))
986 /* Return the next frame in the frame list after FRAME. */
989 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
994 /* There must always be at least one frame in Vframe_list. */
995 eassert (CONSP (Vframe_list
));
998 FOR_EACH_FRAME (tail
, f
)
1002 f
= candidate_frame (f
, frame
, minibuf
);
1012 /* Return the previous frame in the frame list before FRAME. */
1015 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1017 Lisp_Object f
, tail
, prev
= Qnil
;
1019 /* There must always be at least one frame in Vframe_list. */
1020 eassert (CONSP (Vframe_list
));
1022 FOR_EACH_FRAME (tail
, f
)
1024 if (EQ (frame
, f
) && !NILP (prev
))
1026 f
= candidate_frame (f
, frame
, minibuf
);
1031 /* We've scanned the entire list. */
1033 /* We went through the whole frame list without finding a single
1034 acceptable frame. Return the original frame. */
1037 /* There were no acceptable frames in the list before FRAME; otherwise,
1038 we would have returned directly from the loop. Since PREV is the last
1039 acceptable frame in the list, return it. */
1044 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1045 doc
: /* Return the next frame in the frame list after FRAME.
1046 It considers only frames on the same terminal as FRAME.
1047 By default, skip minibuffer-only frames.
1048 If omitted, FRAME defaults to the selected frame.
1049 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1050 If MINIFRAME is a window, include only its own frame
1051 and any frame now using that window as the minibuffer.
1052 If MINIFRAME is `visible', include all visible frames.
1053 If MINIFRAME is 0, include all visible and iconified frames.
1054 Otherwise, include all frames. */)
1055 (Lisp_Object frame
, Lisp_Object miniframe
)
1058 frame
= selected_frame
;
1059 CHECK_LIVE_FRAME (frame
);
1060 return next_frame (frame
, miniframe
);
1063 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1064 doc
: /* Return the previous frame in the frame list before FRAME.
1065 It considers only frames on the same terminal as FRAME.
1066 By default, skip minibuffer-only frames.
1067 If omitted, FRAME defaults to the selected frame.
1068 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1069 If MINIFRAME is a window, include only its own frame
1070 and any frame now using that window as the minibuffer.
1071 If MINIFRAME is `visible', include all visible frames.
1072 If MINIFRAME is 0, include all visible and iconified frames.
1073 Otherwise, include all frames. */)
1074 (Lisp_Object frame
, Lisp_Object miniframe
)
1077 frame
= selected_frame
;
1078 CHECK_LIVE_FRAME (frame
);
1079 return prev_frame (frame
, miniframe
);
1082 /* Return 1 if it is ok to delete frame F;
1083 0 if all frames aside from F are invisible.
1084 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1087 other_visible_frames (struct frame
*f
)
1089 Lisp_Object frames
, this;
1091 FOR_EACH_FRAME (frames
, this)
1093 if (f
== XFRAME (this))
1096 /* Verify that we can still talk to the frame's X window,
1097 and note any recent change in visibility. */
1098 #ifdef HAVE_WINDOW_SYSTEM
1099 if (FRAME_WINDOW_P (XFRAME (this)))
1100 x_sync (XFRAME (this));
1103 if (FRAME_VISIBLE_P (XFRAME (this))
1104 || FRAME_ICONIFIED_P (XFRAME (this))
1105 /* Allow deleting the terminal frame when at least one X
1107 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1113 /* Make sure that minibuf_window doesn't refer to FRAME's minibuffer
1114 window. Preferably use the selected frame's minibuffer window
1115 instead. If the selected frame doesn't have one, get some other
1116 frame's minibuffer window. SELECT non-zero means select the new
1117 minibuffer window. */
1119 check_minibuf_window (Lisp_Object frame
, int select
)
1121 struct frame
*f
= decode_live_frame (frame
);
1123 if (WINDOWP (minibuf_window
) && EQ (f
->minibuffer_window
, minibuf_window
))
1125 Lisp_Object frames
, this, window
= make_number (0);
1127 if (!EQ (frame
, selected_frame
)
1128 && FRAME_HAS_MINIBUF_P (XFRAME (selected_frame
)))
1129 window
= FRAME_MINIBUF_WINDOW (XFRAME (selected_frame
));
1131 FOR_EACH_FRAME (frames
, this)
1133 if (!EQ (this, frame
) && FRAME_HAS_MINIBUF_P (XFRAME (this)))
1135 window
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1140 if (!WINDOWP (window
))
1144 /* Use set_window_buffer instead of Fset_window_buffer (see
1145 discussion of bug#11984, bug#12025, bug#12026). */
1146 set_window_buffer (window
, XWINDOW (minibuf_window
)->contents
, 0, 0);
1147 minibuf_window
= window
;
1149 /* SELECT non-zero usually means that FRAME's minibuffer
1150 window was selected; select the new one. */
1152 Fselect_window (minibuf_window
, Qnil
);
1158 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1159 unconditionally. x_connection_closed and delete_terminal use
1160 this. Any other value of FORCE implements the semantics
1161 described for Fdelete_frame. */
1163 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1165 struct frame
*f
= decode_any_frame (frame
);
1166 struct frame
*sf
= SELECTED_FRAME ();
1169 int minibuffer_selected
, is_tooltip_frame
;
1171 if (! FRAME_LIVE_P (f
))
1174 if (NILP (force
) && !other_visible_frames (f
))
1175 error ("Attempt to delete the sole visible or iconified frame");
1177 /* x_connection_closed must have set FORCE to `noelisp' in order
1178 to delete the last frame, if it is gone. */
1179 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1180 error ("Attempt to delete the only frame");
1182 XSETFRAME (frame
, f
);
1184 /* Does this frame have a minibuffer, and is it the surrogate
1185 minibuffer for any other frame? */
1186 if (FRAME_HAS_MINIBUF_P (f
))
1188 Lisp_Object frames
, this;
1190 FOR_EACH_FRAME (frames
, this)
1194 if (EQ (this, frame
))
1197 fminiw
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1199 if (WINDOWP (fminiw
) && EQ (frame
, WINDOW_FRAME (XWINDOW (fminiw
))))
1201 /* If we MUST delete this frame, delete the other first.
1202 But do this only if FORCE equals `noelisp'. */
1203 if (EQ (force
, Qnoelisp
))
1204 delete_frame (this, Qnoelisp
);
1206 error ("Attempt to delete a surrogate minibuffer frame");
1211 is_tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1213 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1214 frame is a tooltip. FORCE is set to `noelisp' when handling
1215 a disconnect from the terminal, so we don't dare call Lisp
1217 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1219 else if (EQ (force
, Qnoelisp
))
1221 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1225 #ifdef HAVE_X_WINDOWS
1226 /* Also, save clipboard to the clipboard manager. */
1227 x_clipboard_manager_save_frame (frame
);
1230 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1233 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1234 if (! FRAME_LIVE_P (f
))
1237 /* At this point, we are committed to deleting the frame.
1238 There is no more chance for errors to prevent it. */
1240 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1242 /* Don't let the frame remain selected. */
1246 Lisp_Object frame1
= Qnil
;
1248 /* Look for another visible frame on the same terminal.
1249 Do not call next_frame here because it may loop forever.
1250 See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15025. */
1251 FOR_EACH_FRAME (tail
, frame1
)
1252 if (!EQ (frame
, frame1
)
1253 && (FRAME_TERMINAL (XFRAME (frame
))
1254 == FRAME_TERMINAL (XFRAME (frame1
)))
1255 && FRAME_VISIBLE_P (XFRAME (frame1
)))
1258 /* If there is none, find *some* other frame. */
1259 if (NILP (frame1
) || EQ (frame1
, frame
))
1261 FOR_EACH_FRAME (tail
, frame1
)
1263 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1265 /* Do not change a text terminal's top-frame. */
1266 struct frame
*f1
= XFRAME (frame1
);
1267 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1269 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1270 if (!EQ (top_frame
, frame
))
1277 #ifdef NS_IMPL_COCOA
1279 /* Under NS, there is no system mechanism for choosing a new
1280 window to get focus -- it is left to application code.
1281 So the portion of THIS application interfacing with NS
1282 needs to know about it. We call Fraise_frame, but the
1283 purpose is really to transfer focus. */
1284 Fraise_frame (frame1
);
1287 do_switch_frame (frame1
, 0, 1, Qnil
);
1288 sf
= SELECTED_FRAME ();
1291 /* Don't allow minibuf_window to remain on a deleted frame. */
1292 check_minibuf_window (frame
, minibuffer_selected
);
1294 /* Don't let echo_area_window to remain on a deleted frame. */
1295 if (EQ (f
->minibuffer_window
, echo_area_window
))
1296 echo_area_window
= sf
->minibuffer_window
;
1298 /* Clear any X selections for this frame. */
1299 #ifdef HAVE_X_WINDOWS
1301 x_clear_frame_selections (f
);
1305 This function must be called before the window tree of the
1306 frame is deleted because windows contain dynamically allocated
1310 #ifdef HAVE_WINDOW_SYSTEM
1311 /* Give chance to each font driver to free a frame specific data. */
1312 font_update_drivers (f
, Qnil
);
1315 /* Mark all the windows that used to be on FRAME as deleted, and then
1316 remove the reference to them. */
1317 delete_all_child_windows (f
->root_window
);
1318 fset_root_window (f
, Qnil
);
1320 Vframe_list
= Fdelq (frame
, Vframe_list
);
1321 SET_FRAME_VISIBLE (f
, 0);
1323 /* Allow the vector of menu bar contents to be freed in the next
1324 garbage collection. The frame object itself may not be garbage
1325 collected until much later, because recent_keys and other data
1326 structures can still refer to it. */
1327 fset_menu_bar_vector (f
, Qnil
);
1329 /* If FRAME's buffer lists contains killed
1330 buffers, this helps GC to reclaim them. */
1331 fset_buffer_list (f
, Qnil
);
1332 fset_buried_buffer_list (f
, Qnil
);
1334 free_font_driver_list (f
);
1336 xfree (f
->decode_mode_spec_buffer
);
1337 xfree (FRAME_INSERT_COST (f
));
1338 xfree (FRAME_DELETEN_COST (f
));
1339 xfree (FRAME_INSERTN_COST (f
));
1340 xfree (FRAME_DELETE_COST (f
));
1342 /* Since some events are handled at the interrupt level, we may get
1343 an event for f at any time; if we zero out the frame's terminal
1344 now, then we may trip up the event-handling code. Instead, we'll
1345 promise that the terminal of the frame must be valid until we
1346 have called the window-system-dependent frame destruction
1349 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1350 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1353 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1354 f
->output_data
.nothing
= 0;
1355 f
->terminal
= 0; /* Now the frame is dead. */
1357 /* If needed, delete the terminal that this frame was on.
1358 (This must be done after the frame is killed.) */
1359 terminal
->reference_count
--;
1361 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1363 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1364 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1365 terminal
->reference_count
= 1;
1366 #endif /* USE_GTK */
1367 if (terminal
->reference_count
== 0)
1370 XSETTERMINAL (tmp
, terminal
);
1373 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1376 kb
= terminal
->kboard
;
1379 /* If we've deleted the last_nonminibuf_frame, then try to find
1381 if (f
== last_nonminibuf_frame
)
1383 Lisp_Object frames
, this;
1385 last_nonminibuf_frame
= 0;
1387 FOR_EACH_FRAME (frames
, this)
1390 if (!FRAME_MINIBUF_ONLY_P (f
))
1392 last_nonminibuf_frame
= f
;
1398 /* If there's no other frame on the same kboard, get out of
1399 single-kboard state if we're in it for this kboard. */
1402 Lisp_Object frames
, this;
1403 /* Some frame we found on the same kboard, or nil if there are none. */
1404 Lisp_Object frame_on_same_kboard
= Qnil
;
1406 FOR_EACH_FRAME (frames
, this)
1407 if (kb
== FRAME_KBOARD (XFRAME (this)))
1408 frame_on_same_kboard
= this;
1410 if (NILP (frame_on_same_kboard
))
1411 not_single_kboard_state (kb
);
1415 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1416 find another one. Prefer minibuffer-only frames, but also notice
1417 frames with other windows. */
1418 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1420 Lisp_Object frames
, this;
1422 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1423 Lisp_Object frame_with_minibuf
= Qnil
;
1424 /* Some frame we found on the same kboard, or nil if there are none. */
1425 Lisp_Object frame_on_same_kboard
= Qnil
;
1427 FOR_EACH_FRAME (frames
, this)
1429 struct frame
*f1
= XFRAME (this);
1431 /* Consider only frames on the same kboard
1432 and only those with minibuffers. */
1433 if (kb
== FRAME_KBOARD (f1
)
1434 && FRAME_HAS_MINIBUF_P (f1
))
1436 frame_with_minibuf
= this;
1437 if (FRAME_MINIBUF_ONLY_P (f1
))
1441 if (kb
== FRAME_KBOARD (f1
))
1442 frame_on_same_kboard
= this;
1445 if (!NILP (frame_on_same_kboard
))
1447 /* We know that there must be some frame with a minibuffer out
1448 there. If this were not true, all of the frames present
1449 would have to be minibufferless, which implies that at some
1450 point their minibuffer frames must have been deleted, but
1451 that is prohibited at the top; you can't delete surrogate
1452 minibuffer frames. */
1453 if (NILP (frame_with_minibuf
))
1456 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
1459 /* No frames left on this kboard--say no minibuffer either. */
1460 kset_default_minibuffer_frame (kb
, Qnil
);
1463 /* Cause frame titles to update--necessary if we now have just one frame. */
1464 if (!is_tooltip_frame
)
1465 update_mode_lines
= 1;
1470 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1471 doc
: /* Delete FRAME, permanently eliminating it from use.
1472 FRAME defaults to the selected frame.
1474 A frame may not be deleted if its minibuffer is used by other frames.
1475 Normally, you may not delete a frame if all other frames are invisible,
1476 but if the second optional argument FORCE is non-nil, you may do so.
1478 This function runs `delete-frame-functions' before actually
1479 deleting the frame, unless the frame is a tooltip.
1480 The functions are run with one argument, the frame to be deleted. */)
1481 (Lisp_Object frame
, Lisp_Object force
)
1483 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1487 /* Return mouse position in character cell units. */
1489 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1490 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1491 The position is given in character cells, where (0, 0) is the
1492 upper-left corner of the frame, X is the horizontal offset, and Y is
1493 the vertical offset.
1494 If Emacs is running on a mouseless terminal or hasn't been programmed
1495 to read the mouse position, it returns the selected frame for FRAME
1496 and nil for X and Y.
1497 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1498 passing the normal return value to that function as an argument,
1499 and returns whatever that function returns. */)
1503 Lisp_Object lispy_dummy
;
1504 Lisp_Object x
, y
, retval
;
1505 struct gcpro gcpro1
;
1507 f
= SELECTED_FRAME ();
1510 /* It's okay for the hook to refrain from storing anything. */
1511 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1513 enum scroll_bar_part party_dummy
;
1515 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1516 &lispy_dummy
, &party_dummy
,
1525 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1529 XSETFRAME (lispy_dummy
, f
);
1530 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1532 if (!NILP (Vmouse_position_function
))
1533 retval
= call1 (Vmouse_position_function
, retval
);
1534 RETURN_UNGCPRO (retval
);
1537 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1538 Smouse_pixel_position
, 0, 0, 0,
1539 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1540 The position is given in pixel units, where (0, 0) is the
1541 upper-left corner of the frame, X is the horizontal offset, and Y is
1542 the vertical offset.
1543 If Emacs is running on a mouseless terminal or hasn't been programmed
1544 to read the mouse position, it returns the selected frame for FRAME
1545 and nil for X and Y. */)
1549 Lisp_Object lispy_dummy
;
1552 f
= SELECTED_FRAME ();
1555 /* It's okay for the hook to refrain from storing anything. */
1556 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1558 enum scroll_bar_part party_dummy
;
1560 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1561 &lispy_dummy
, &party_dummy
,
1566 XSETFRAME (lispy_dummy
, f
);
1567 return Fcons (lispy_dummy
, Fcons (x
, y
));
1570 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1571 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1572 Coordinates are relative to the frame, not a window,
1573 so the coordinates of the top left character in the frame
1574 may be nonzero due to left-hand scroll bars or the menu bar.
1576 The position is given in character cells, where (0, 0) is the
1577 upper-left corner of the frame, X is the horizontal offset, and Y is
1578 the vertical offset.
1580 This function is a no-op for an X frame that is not visible.
1581 If you have just created a frame, you must wait for it to become visible
1582 before calling this function on it, like this.
1583 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1584 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1586 CHECK_LIVE_FRAME (frame
);
1587 CHECK_TYPE_RANGED_INTEGER (int, x
);
1588 CHECK_TYPE_RANGED_INTEGER (int, y
);
1590 /* I think this should be done with a hook. */
1591 #ifdef HAVE_WINDOW_SYSTEM
1592 if (FRAME_WINDOW_P (XFRAME (frame
)))
1593 /* Warping the mouse will cause enternotify and focus events. */
1594 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1597 if (FRAME_MSDOS_P (XFRAME (frame
)))
1599 Fselect_frame (frame
, Qnil
);
1600 mouse_moveto (XINT (x
), XINT (y
));
1605 Fselect_frame (frame
, Qnil
);
1606 term_mouse_moveto (XINT (x
), XINT (y
));
1615 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1616 Sset_mouse_pixel_position
, 3, 3, 0,
1617 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1618 The position is given in pixels, where (0, 0) is the upper-left corner
1619 of the frame, X is the horizontal offset, and Y is the vertical offset.
1621 Note, this is a no-op for an X frame that is not visible.
1622 If you have just created a frame, you must wait for it to become visible
1623 before calling this function on it, like this.
1624 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1625 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1627 CHECK_LIVE_FRAME (frame
);
1628 CHECK_TYPE_RANGED_INTEGER (int, x
);
1629 CHECK_TYPE_RANGED_INTEGER (int, y
);
1631 /* I think this should be done with a hook. */
1632 #ifdef HAVE_WINDOW_SYSTEM
1633 if (FRAME_WINDOW_P (XFRAME (frame
)))
1634 /* Warping the mouse will cause enternotify and focus events. */
1635 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1638 if (FRAME_MSDOS_P (XFRAME (frame
)))
1640 Fselect_frame (frame
, Qnil
);
1641 mouse_moveto (XINT (x
), XINT (y
));
1646 Fselect_frame (frame
, Qnil
);
1647 term_mouse_moveto (XINT (x
), XINT (y
));
1656 static void make_frame_visible_1 (Lisp_Object
);
1658 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1660 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1661 If omitted, FRAME defaults to the currently selected frame. */)
1664 struct frame
*f
= decode_live_frame (frame
);
1666 /* I think this should be done with a hook. */
1667 #ifdef HAVE_WINDOW_SYSTEM
1668 if (FRAME_WINDOW_P (f
))
1669 x_make_frame_visible (f
);
1672 make_frame_visible_1 (f
->root_window
);
1674 /* Make menu bar update for the Buffers and Frames menus. */
1675 windows_or_buffers_changed
++;
1677 XSETFRAME (frame
, f
);
1681 /* Update the display_time slot of the buffers shown in WINDOW
1682 and all its descendants. */
1685 make_frame_visible_1 (Lisp_Object window
)
1689 for (; !NILP (window
); window
= w
->next
)
1691 w
= XWINDOW (window
);
1692 if (WINDOWP (w
->contents
))
1693 make_frame_visible_1 (w
->contents
);
1695 bset_display_time (XBUFFER (w
->contents
), Fcurrent_time ());
1699 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1701 doc
: /* Make the frame FRAME invisible.
1702 If omitted, FRAME defaults to the currently selected frame.
1703 On graphical displays, invisible frames are not updated and are
1704 usually not displayed at all, even in a window system's \"taskbar\".
1706 Normally you may not make FRAME invisible if all other frames are invisible,
1707 but if the second optional argument FORCE is non-nil, you may do so.
1709 This function has no effect on text terminal frames. Such frames are
1710 always considered visible, whether or not they are currently being
1711 displayed in the terminal. */)
1712 (Lisp_Object frame
, Lisp_Object force
)
1714 struct frame
*f
= decode_live_frame (frame
);
1716 if (NILP (force
) && !other_visible_frames (f
))
1717 error ("Attempt to make invisible the sole visible or iconified frame");
1719 /* Don't allow minibuf_window to remain on an invisible frame. */
1720 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
1722 /* I think this should be done with a hook. */
1723 #ifdef HAVE_WINDOW_SYSTEM
1724 if (FRAME_WINDOW_P (f
))
1725 x_make_frame_invisible (f
);
1728 /* Make menu bar update for the Buffers and Frames menus. */
1729 windows_or_buffers_changed
++;
1734 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1736 doc
: /* Make the frame FRAME into an icon.
1737 If omitted, FRAME defaults to the currently selected frame. */)
1740 struct frame
*f
= decode_live_frame (frame
);
1742 /* Don't allow minibuf_window to remain on an iconified frame. */
1743 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
1745 /* I think this should be done with a hook. */
1746 #ifdef HAVE_WINDOW_SYSTEM
1747 if (FRAME_WINDOW_P (f
))
1748 x_iconify_frame (f
);
1751 /* Make menu bar update for the Buffers and Frames menus. */
1752 windows_or_buffers_changed
++;
1757 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1759 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1760 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1761 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1762 On graphical displays, invisible frames are not updated and are
1763 usually not displayed at all, even in a window system's \"taskbar\".
1765 If FRAME is a text terminal frame, this always returns t.
1766 Such frames are always considered visible, whether or not they are
1767 currently being displayed on the terminal. */)
1770 CHECK_LIVE_FRAME (frame
);
1772 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1774 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1779 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1781 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1784 Lisp_Object tail
, frame
, value
= Qnil
;
1786 FOR_EACH_FRAME (tail
, frame
)
1787 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1788 value
= Fcons (frame
, value
);
1794 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1795 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1796 If FRAME is invisible or iconified, make it visible.
1797 If you don't specify a frame, the selected frame is used.
1798 If Emacs is displaying on an ordinary terminal or some other device which
1799 doesn't support multiple overlapping frames, this function selects FRAME. */)
1802 struct frame
*f
= decode_live_frame (frame
);
1804 XSETFRAME (frame
, f
);
1806 if (FRAME_TERMCAP_P (f
))
1807 /* On a text terminal select FRAME. */
1808 Fselect_frame (frame
, Qnil
);
1810 /* Do like the documentation says. */
1811 Fmake_frame_visible (frame
);
1813 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1814 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
1819 /* Should we have a corresponding function called Flower_Power? */
1820 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1821 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1822 If you don't specify a frame, the selected frame is used.
1823 If Emacs is displaying on an ordinary terminal or some other device which
1824 doesn't support multiple overlapping frames, this function does nothing. */)
1827 struct frame
*f
= decode_live_frame (frame
);
1829 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1830 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
1836 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1838 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1839 In other words, switch-frame events caused by events in FRAME will
1840 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1841 FOCUS-FRAME after reading an event typed at FRAME.
1843 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
1844 frame again receives its own keystrokes.
1846 Focus redirection is useful for temporarily redirecting keystrokes to
1847 a surrogate minibuffer frame when a frame doesn't have its own
1850 A frame's focus redirection can be changed by `select-frame'. If frame
1851 FOO is selected, and then a different frame BAR is selected, any
1852 frames redirecting their focus to FOO are shifted to redirect their
1853 focus to BAR. This allows focus redirection to work properly when the
1854 user switches from one frame to another using `select-window'.
1856 This means that a frame whose focus is redirected to itself is treated
1857 differently from a frame whose focus is redirected to nil; the former
1858 is affected by `select-frame', while the latter is not.
1860 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1861 (Lisp_Object frame
, Lisp_Object focus_frame
)
1863 /* Note that we don't check for a live frame here. It's reasonable
1864 to redirect the focus of a frame you're about to delete, if you
1865 know what other frame should receive those keystrokes. */
1866 struct frame
*f
= decode_any_frame (frame
);
1868 if (! NILP (focus_frame
))
1869 CHECK_LIVE_FRAME (focus_frame
);
1871 fset_focus_frame (f
, focus_frame
);
1873 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
1874 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
1880 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 0, 1, 0,
1881 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1882 If FRAME is omitted or nil, the selected frame is used.
1883 Return nil if FRAME's focus is not redirected.
1884 See `redirect-frame-focus'. */)
1887 return FRAME_FOCUS_FRAME (decode_live_frame (frame
));
1892 /* Return the value of frame parameter PROP in frame FRAME. */
1894 #ifdef HAVE_WINDOW_SYSTEM
1895 #if !HAVE_NS && !defined (WINDOWSNT)
1899 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
1901 register Lisp_Object tem
;
1903 tem
= Fassq (prop
, frame
->param_alist
);
1910 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
1913 frames_discard_buffer (Lisp_Object buffer
)
1915 Lisp_Object frame
, tail
;
1917 FOR_EACH_FRAME (tail
, frame
)
1920 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
1921 fset_buried_buffer_list
1922 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
1926 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1927 If the alist already has an element for PROP, we change it. */
1930 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
1932 register Lisp_Object tem
;
1934 tem
= Fassq (prop
, *alistptr
);
1936 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1942 frame_name_fnn_p (char *str
, ptrdiff_t len
)
1944 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
1947 while ('0' <= *p
&& *p
<= '9')
1955 /* Set the name of the terminal frame. Also used by MSDOS frames.
1956 Modeled after x_set_name which is used for WINDOW frames. */
1959 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
1961 f
->explicit_name
= ! NILP (name
);
1963 /* If NAME is nil, set the name to F<num>. */
1966 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
1968 /* Check for no change needed in this very common case
1969 before we do any consing. */
1970 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
1973 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
1977 CHECK_STRING (name
);
1979 /* Don't change the name if it's already NAME. */
1980 if (! NILP (Fstring_equal (name
, f
->name
)))
1983 /* Don't allow the user to set the frame name to F<num>, so it
1984 doesn't clash with the names we generate for terminal frames. */
1985 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
1986 error ("Frame names of the form F<num> are usurped by Emacs");
1989 fset_name (f
, name
);
1990 update_mode_lines
= 1;
1994 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
1996 register Lisp_Object old_alist_elt
;
1998 /* The buffer-list parameters are stored in a special place and not
1999 in the alist. All buffers must be live. */
2000 if (EQ (prop
, Qbuffer_list
))
2002 Lisp_Object list
= Qnil
;
2003 for (; CONSP (val
); val
= XCDR (val
))
2004 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2005 list
= Fcons (XCAR (val
), list
);
2006 fset_buffer_list (f
, Fnreverse (list
));
2009 if (EQ (prop
, Qburied_buffer_list
))
2011 Lisp_Object list
= Qnil
;
2012 for (; CONSP (val
); val
= XCDR (val
))
2013 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2014 list
= Fcons (XCAR (val
), list
);
2015 fset_buried_buffer_list (f
, Fnreverse (list
));
2019 /* If PROP is a symbol which is supposed to have frame-local values,
2020 and it is set up based on this frame, switch to the global
2021 binding. That way, we can create or alter the frame-local binding
2022 without messing up the symbol's status. */
2025 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2027 switch (sym
->redirect
)
2029 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2030 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2031 case SYMBOL_LOCALIZED
:
2032 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2033 if (blv
->frame_local
&& blv_found (blv
) && XFRAME (blv
->where
) == f
)
2034 swap_in_global_binding (sym
);
2037 default: emacs_abort ();
2041 /* The tty color needed to be set before the frame's parameter
2042 alist was updated with the new value. This is not true any more,
2043 but we still do this test early on. */
2044 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2045 && f
== FRAME_TTY (f
)->previous_frame
)
2046 /* Force redisplay of this tty. */
2047 FRAME_TTY (f
)->previous_frame
= NULL
;
2049 /* Update the frame parameter alist. */
2050 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2051 if (EQ (old_alist_elt
, Qnil
))
2052 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2054 Fsetcdr (old_alist_elt
, val
);
2056 /* Update some other special parameters in their special places
2057 in addition to the alist. */
2059 if (EQ (prop
, Qbuffer_predicate
))
2060 fset_buffer_predicate (f
, val
);
2062 if (! FRAME_WINDOW_P (f
))
2064 if (EQ (prop
, Qmenu_bar_lines
))
2065 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2066 else if (EQ (prop
, Qname
))
2067 set_term_frame_name (f
, val
);
2070 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2072 if (! MINI_WINDOW_P (XWINDOW (val
)))
2073 error ("Surrogate minibuffer windows must be minibuffer windows");
2075 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2076 && !EQ (val
, f
->minibuffer_window
))
2077 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2079 /* Install the chosen minibuffer window, with proper buffer. */
2080 fset_minibuffer_window (f
, val
);
2084 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2085 doc
: /* Return the parameters-alist of frame FRAME.
2086 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2087 The meaningful PARMs depend on the kind of frame.
2088 If FRAME is omitted or nil, return information on the currently selected frame. */)
2092 struct frame
*f
= decode_any_frame (frame
);
2094 struct gcpro gcpro1
;
2096 if (!FRAME_LIVE_P (f
))
2099 alist
= Fcopy_alist (f
->param_alist
);
2102 if (!FRAME_WINDOW_P (f
))
2104 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2105 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2108 /* If the frame's parameter alist says the colors are
2109 unspecified and reversed, take the frame's background pixel
2110 for foreground and vice versa. */
2111 elt
= Fassq (Qforeground_color
, alist
);
2112 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2114 if (strncmp (SSDATA (XCDR (elt
)),
2116 SCHARS (XCDR (elt
))) == 0)
2117 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2118 else if (strncmp (SSDATA (XCDR (elt
)),
2120 SCHARS (XCDR (elt
))) == 0)
2121 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2124 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2125 elt
= Fassq (Qbackground_color
, alist
);
2126 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2128 if (strncmp (SSDATA (XCDR (elt
)),
2130 SCHARS (XCDR (elt
))) == 0)
2131 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2132 else if (strncmp (SSDATA (XCDR (elt
)),
2134 SCHARS (XCDR (elt
))) == 0)
2135 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2138 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2139 store_in_alist (&alist
, intern ("font"),
2140 build_string (FRAME_MSDOS_P (f
)
2142 : FRAME_W32_P (f
) ? "w32term"
2145 store_in_alist (&alist
, Qname
, f
->name
);
2146 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2147 store_in_alist (&alist
, Qheight
, make_number (height
));
2148 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2149 store_in_alist (&alist
, Qwidth
, make_number (width
));
2150 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2151 store_in_alist (&alist
, Qminibuffer
,
2152 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2153 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2154 : FRAME_MINIBUF_WINDOW (f
)));
2155 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2156 store_in_alist (&alist
, Qbuffer_list
, f
->buffer_list
);
2157 store_in_alist (&alist
, Qburied_buffer_list
, f
->buried_buffer_list
);
2159 /* I think this should be done with a hook. */
2160 #ifdef HAVE_WINDOW_SYSTEM
2161 if (FRAME_WINDOW_P (f
))
2162 x_report_frame_params (f
, &alist
);
2166 /* This ought to be correct in f->param_alist for an X frame. */
2168 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2169 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2177 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2178 doc
: /* Return FRAME's value for parameter PARAMETER.
2179 If FRAME is nil, describe the currently selected frame. */)
2180 (Lisp_Object frame
, Lisp_Object parameter
)
2182 struct frame
*f
= decode_any_frame (frame
);
2183 Lisp_Object value
= Qnil
;
2185 CHECK_SYMBOL (parameter
);
2187 XSETFRAME (frame
, f
);
2189 if (FRAME_LIVE_P (f
))
2191 /* Avoid consing in frequent cases. */
2192 if (EQ (parameter
, Qname
))
2194 #ifdef HAVE_X_WINDOWS
2195 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2196 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2197 #endif /* HAVE_X_WINDOWS */
2198 else if (EQ (parameter
, Qbackground_color
)
2199 || EQ (parameter
, Qforeground_color
))
2201 value
= Fassq (parameter
, f
->param_alist
);
2204 value
= XCDR (value
);
2205 /* Fframe_parameters puts the actual fg/bg color names,
2206 even if f->param_alist says otherwise. This is
2207 important when param_alist's notion of colors is
2208 "unspecified". We need to do the same here. */
2209 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2211 const char *color_name
;
2214 if (EQ (parameter
, Qbackground_color
))
2216 color_name
= SSDATA (value
);
2217 csz
= SCHARS (value
);
2218 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2219 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2220 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2221 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2223 else if (EQ (parameter
, Qforeground_color
))
2225 color_name
= SSDATA (value
);
2226 csz
= SCHARS (value
);
2227 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2228 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2229 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2230 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2235 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2237 else if (EQ (parameter
, Qdisplay_type
)
2238 || EQ (parameter
, Qbackground_mode
))
2239 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2241 /* FIXME: Avoid this code path at all (as well as code duplication)
2242 by sharing more code with Fframe_parameters. */
2243 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2250 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2251 Smodify_frame_parameters
, 2, 2, 0,
2252 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2253 If FRAME is nil, it defaults to the selected frame.
2254 ALIST is an alist of parameters to change and their new values.
2255 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2256 The meaningful PARMs depend on the kind of frame.
2257 Undefined PARMs are ignored, but stored in the frame's parameter list
2258 so that `frame-parameters' will return them.
2260 The value of frame parameter FOO can also be accessed
2261 as a frame-local binding for the variable FOO, if you have
2262 enabled such bindings for that variable with `make-variable-frame-local'.
2263 Note that this functionality is obsolete as of Emacs 22.2, and its
2264 use is not recommended. Explicitly check for a frame-parameter instead. */)
2265 (Lisp_Object frame
, Lisp_Object alist
)
2267 struct frame
*f
= decode_live_frame (frame
);
2268 register Lisp_Object prop
, val
;
2272 /* I think this should be done with a hook. */
2273 #ifdef HAVE_WINDOW_SYSTEM
2274 if (FRAME_WINDOW_P (f
))
2275 x_set_frame_parameters (f
, alist
);
2279 if (FRAME_MSDOS_P (f
))
2280 IT_set_frame_parameters (f
, alist
);
2285 EMACS_INT length
= XFASTINT (Flength (alist
));
2288 Lisp_Object
*values
;
2290 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2291 values
= parms
+ length
;
2293 /* Extract parm names and values into those vectors. */
2295 for (i
= 0; CONSP (alist
); alist
= XCDR (alist
))
2300 parms
[i
] = Fcar (elt
);
2301 values
[i
] = Fcdr (elt
);
2305 /* Now process them in reverse of specified order. */
2310 store_frame_param (f
, prop
, val
);
2312 if (EQ (prop
, Qforeground_color
)
2313 || EQ (prop
, Qbackground_color
))
2314 update_face_from_frame_parameter (f
, prop
, val
);
2322 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2324 doc
: /* Height in pixels of a line in the font in frame FRAME.
2325 If FRAME is omitted or nil, the selected frame is used.
2326 For a terminal frame, the value is always 1. */)
2329 #ifdef HAVE_WINDOW_SYSTEM
2330 struct frame
*f
= decode_any_frame (frame
);
2332 if (FRAME_WINDOW_P (f
))
2333 return make_number (FRAME_LINE_HEIGHT (f
));
2336 return make_number (1);
2340 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2342 doc
: /* Width in pixels of characters in the font in frame FRAME.
2343 If FRAME is omitted or nil, the selected frame is used.
2344 On a graphical screen, the width is the standard width of the default font.
2345 For a terminal screen, the value is always 1. */)
2348 #ifdef HAVE_WINDOW_SYSTEM
2349 struct frame
*f
= decode_any_frame (frame
);
2351 if (FRAME_WINDOW_P (f
))
2352 return make_number (FRAME_COLUMN_WIDTH (f
));
2355 return make_number (1);
2358 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2359 Sframe_pixel_height
, 0, 1, 0,
2360 doc
: /* Return a FRAME's height in pixels.
2361 If FRAME is omitted or nil, the selected frame is used. The exact value
2362 of the result depends on the window-system and toolkit in use:
2364 In the Gtk+ version of Emacs, it includes only any window (including
2365 the minibuffer or echo area), mode line, and header line. It does not
2366 include the tool bar or menu bar.
2368 With other graphical versions, it also includes the tool bar and the
2371 For a text terminal, it includes the menu bar. In this case, the
2372 result is really in characters rather than pixels (i.e., is identical
2373 to `frame-height'). */)
2376 struct frame
*f
= decode_any_frame (frame
);
2378 #ifdef HAVE_WINDOW_SYSTEM
2379 if (FRAME_WINDOW_P (f
))
2380 return make_number (FRAME_PIXEL_HEIGHT (f
));
2383 return make_number (FRAME_LINES (f
));
2386 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2387 Sframe_pixel_width
, 0, 1, 0,
2388 doc
: /* Return FRAME's width in pixels.
2389 For a terminal frame, the result really gives the width in characters.
2390 If FRAME is omitted or nil, the selected frame is used. */)
2393 struct frame
*f
= decode_any_frame (frame
);
2395 #ifdef HAVE_WINDOW_SYSTEM
2396 if (FRAME_WINDOW_P (f
))
2397 return make_number (FRAME_PIXEL_WIDTH (f
));
2400 return make_number (FRAME_COLS (f
));
2403 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2404 Stool_bar_pixel_width
, 0, 1, 0,
2405 doc
: /* Return width in pixels of FRAME's tool bar.
2406 The result is greater than zero only when the tool bar is on the left
2407 or right side of FRAME. If FRAME is omitted or nil, the selected frame
2411 #ifdef FRAME_TOOLBAR_WIDTH
2412 struct frame
*f
= decode_any_frame (frame
);
2414 if (FRAME_WINDOW_P (f
))
2415 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2417 return make_number (0);
2420 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2421 doc
: /* Specify that the frame FRAME has LINES lines.
2422 If FRAME is nil, the selected frame is used. Optional third arg
2423 non-nil means that redisplay should use LINES lines but that the
2424 idea of the actual height of the frame should not be changed. */)
2425 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2427 register struct frame
*f
= decode_live_frame (frame
);
2429 CHECK_TYPE_RANGED_INTEGER (int, lines
);
2431 /* I think this should be done with a hook. */
2432 #ifdef HAVE_WINDOW_SYSTEM
2433 if (FRAME_WINDOW_P (f
))
2435 if (XINT (lines
) != FRAME_LINES (f
))
2436 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2437 do_pending_window_change (0);
2441 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2445 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2446 doc
: /* Specify that the frame FRAME has COLS columns.
2447 If FRAME is nil, the selected frame is used. Optional third arg
2448 non-nil means that redisplay should use COLS columns but that the
2449 idea of the actual width of the frame should not be changed. */)
2450 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2452 register struct frame
*f
= decode_live_frame (frame
);
2454 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2456 /* I think this should be done with a hook. */
2457 #ifdef HAVE_WINDOW_SYSTEM
2458 if (FRAME_WINDOW_P (f
))
2460 if (XINT (cols
) != FRAME_COLS (f
))
2461 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2462 do_pending_window_change (0);
2466 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2470 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2471 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters.
2472 If FRAME is nil, the selected frame is used. */)
2473 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2475 register struct frame
*f
= decode_live_frame (frame
);
2477 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2478 CHECK_TYPE_RANGED_INTEGER (int, rows
);
2480 /* I think this should be done with a hook. */
2481 #ifdef HAVE_WINDOW_SYSTEM
2482 if (FRAME_WINDOW_P (f
))
2484 if (XINT (rows
) != FRAME_LINES (f
)
2485 || XINT (cols
) != FRAME_COLS (f
)
2486 || f
->new_text_lines
|| f
->new_text_cols
)
2487 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2488 do_pending_window_change (0);
2492 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2497 DEFUN ("set-frame-position", Fset_frame_position
,
2498 Sset_frame_position
, 3, 3, 0,
2499 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2500 If FRAME is nil, the selected frame is used. XOFFSET and YOFFSET are
2501 actually the position of the upper left corner of the frame. Negative
2502 values for XOFFSET or YOFFSET are interpreted relative to the rightmost
2503 or bottommost possible position (that stays within the screen). */)
2504 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2506 register struct frame
*f
= decode_live_frame (frame
);
2508 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2509 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2511 /* I think this should be done with a hook. */
2512 #ifdef HAVE_WINDOW_SYSTEM
2513 if (FRAME_WINDOW_P (f
))
2514 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2521 /***********************************************************************
2523 ***********************************************************************/
2525 /* Connect the frame-parameter names for X frames
2526 to the ways of passing the parameter values to the window system.
2528 The name of a parameter, as a Lisp symbol,
2529 has an `x-frame-parameter' property which is an integer in Lisp
2530 that is an index in this table. */
2532 struct frame_parm_table
{
2534 Lisp_Object
*variable
;
2537 static const struct frame_parm_table frame_parms
[] =
2539 {"auto-raise", &Qauto_raise
},
2540 {"auto-lower", &Qauto_lower
},
2541 {"background-color", 0},
2542 {"border-color", &Qborder_color
},
2543 {"border-width", &Qborder_width
},
2544 {"cursor-color", &Qcursor_color
},
2545 {"cursor-type", &Qcursor_type
},
2547 {"foreground-color", 0},
2548 {"icon-name", &Qicon_name
},
2549 {"icon-type", &Qicon_type
},
2550 {"internal-border-width", &Qinternal_border_width
},
2551 {"menu-bar-lines", &Qmenu_bar_lines
},
2552 {"mouse-color", &Qmouse_color
},
2554 {"scroll-bar-width", &Qscroll_bar_width
},
2556 {"unsplittable", &Qunsplittable
},
2557 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2558 {"visibility", &Qvisibility
},
2559 {"tool-bar-lines", &Qtool_bar_lines
},
2560 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2561 {"scroll-bar-background", &Qscroll_bar_background
},
2562 {"screen-gamma", &Qscreen_gamma
},
2563 {"line-spacing", &Qline_spacing
},
2564 {"left-fringe", &Qleft_fringe
},
2565 {"right-fringe", &Qright_fringe
},
2566 {"wait-for-wm", &Qwait_for_wm
},
2567 {"fullscreen", &Qfullscreen
},
2568 {"font-backend", &Qfont_backend
},
2570 {"sticky", &Qsticky
},
2571 {"tool-bar-position", &Qtool_bar_position
},
2576 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2577 wanted positions of the WM window (not Emacs window).
2578 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2579 window (FRAME_X_WINDOW).
2583 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2585 int newwidth
= FRAME_COLS (f
);
2586 int newheight
= FRAME_LINES (f
);
2587 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2589 *top_pos
= f
->top_pos
;
2590 *left_pos
= f
->left_pos
;
2592 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2596 ph
= x_display_pixel_height (dpyinfo
);
2597 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2598 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2599 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2603 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2607 pw
= x_display_pixel_width (dpyinfo
);
2608 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2609 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2610 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2615 *height
= newheight
;
2618 #endif /* HAVE_NTGUI */
2620 #ifdef HAVE_WINDOW_SYSTEM
2622 /* Change the parameters of frame F as specified by ALIST.
2623 If a parameter is not specially recognized, do nothing special;
2624 otherwise call the `x_set_...' function for that parameter.
2625 Except for certain geometry properties, always call store_frame_param
2626 to store the new value in the parameter alist. */
2629 x_set_frame_parameters (struct frame
*f
, Lisp_Object alist
)
2633 /* If both of these parameters are present, it's more efficient to
2634 set them both at once. So we wait until we've looked at the
2635 entire list before we set them. */
2639 Lisp_Object left
, top
;
2641 /* Same with these. */
2642 Lisp_Object icon_left
, icon_top
;
2644 /* Record in these vectors all the parms specified. */
2646 Lisp_Object
*values
;
2648 bool left_no_change
= 0, top_no_change
= 0;
2649 bool icon_left_no_change
= 0, icon_top_no_change
= 0;
2650 bool size_changed
= 0;
2651 struct gcpro gcpro1
, gcpro2
;
2654 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2657 parms
= alloca (i
* sizeof *parms
);
2658 values
= alloca (i
* sizeof *values
);
2660 /* Extract parm names and values into those vectors. */
2663 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2668 parms
[i
] = Fcar (elt
);
2669 values
[i
] = Fcdr (elt
);
2672 /* TAIL and ALIST are not used again below here. */
2673 alist
= tail
= Qnil
;
2675 GCPRO2 (*parms
, *values
);
2679 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2680 because their values appear in VALUES and strings are not valid. */
2681 top
= left
= Qunbound
;
2682 icon_left
= icon_top
= Qunbound
;
2684 /* Provide default values for HEIGHT and WIDTH. */
2685 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2686 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2688 /* Process foreground_color and background_color before anything else.
2689 They are independent of other properties, but other properties (e.g.,
2690 cursor_color) are dependent upon them. */
2691 /* Process default font as well, since fringe widths depends on it. */
2692 for (p
= 0; p
< i
; p
++)
2694 Lisp_Object prop
, val
;
2698 if (EQ (prop
, Qforeground_color
)
2699 || EQ (prop
, Qbackground_color
)
2700 || EQ (prop
, Qfont
))
2702 register Lisp_Object param_index
, old_value
;
2704 old_value
= get_frame_param (f
, prop
);
2705 if (NILP (Fequal (val
, old_value
)))
2707 store_frame_param (f
, prop
, val
);
2709 param_index
= Fget (prop
, Qx_frame_parameter
);
2710 if (NATNUMP (param_index
)
2711 && (XFASTINT (param_index
)
2712 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2713 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2714 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2719 /* Now process them in reverse of specified order. */
2722 Lisp_Object prop
, val
;
2727 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2730 width
= XFASTINT (val
);
2732 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2735 height
= XFASTINT (val
);
2737 else if (EQ (prop
, Qtop
))
2739 else if (EQ (prop
, Qleft
))
2741 else if (EQ (prop
, Qicon_top
))
2743 else if (EQ (prop
, Qicon_left
))
2745 else if (EQ (prop
, Qforeground_color
)
2746 || EQ (prop
, Qbackground_color
)
2747 || EQ (prop
, Qfont
))
2748 /* Processed above. */
2752 register Lisp_Object param_index
, old_value
;
2754 old_value
= get_frame_param (f
, prop
);
2756 store_frame_param (f
, prop
, val
);
2758 param_index
= Fget (prop
, Qx_frame_parameter
);
2759 if (NATNUMP (param_index
)
2760 && (XFASTINT (param_index
)
2761 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2762 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2763 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2767 /* Don't die if just one of these was set. */
2768 if (EQ (left
, Qunbound
))
2771 if (f
->left_pos
< 0)
2772 left
= list2 (Qplus
, make_number (f
->left_pos
));
2774 XSETINT (left
, f
->left_pos
);
2776 if (EQ (top
, Qunbound
))
2780 top
= list2 (Qplus
, make_number (f
->top_pos
));
2782 XSETINT (top
, f
->top_pos
);
2785 /* If one of the icon positions was not set, preserve or default it. */
2786 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
2788 icon_left_no_change
= 1;
2789 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2790 if (NILP (icon_left
))
2791 XSETINT (icon_left
, 0);
2793 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
2795 icon_top_no_change
= 1;
2796 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2797 if (NILP (icon_top
))
2798 XSETINT (icon_top
, 0);
2801 /* Don't set these parameters unless they've been explicitly
2802 specified. The window might be mapped or resized while we're in
2803 this function, and we don't want to override that unless the lisp
2804 code has asked for it.
2806 Don't set these parameters unless they actually differ from the
2807 window's current parameters; the window may not actually exist
2812 check_frame_size (f
, &height
, &width
);
2814 XSETFRAME (frame
, f
);
2817 && (width
!= FRAME_COLS (f
)
2818 || height
!= FRAME_LINES (f
)
2819 || f
->new_text_lines
|| f
->new_text_cols
))
2820 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2822 if ((!NILP (left
) || !NILP (top
))
2823 && ! (left_no_change
&& top_no_change
)
2824 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2825 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2830 /* Record the signs. */
2831 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2832 if (EQ (left
, Qminus
))
2833 f
->size_hint_flags
|= XNegative
;
2834 else if (TYPE_RANGED_INTEGERP (int, left
))
2836 leftpos
= XINT (left
);
2838 f
->size_hint_flags
|= XNegative
;
2840 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2841 && CONSP (XCDR (left
))
2842 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
2844 leftpos
= - XINT (XCAR (XCDR (left
)));
2845 f
->size_hint_flags
|= XNegative
;
2847 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2848 && CONSP (XCDR (left
))
2849 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
2851 leftpos
= XINT (XCAR (XCDR (left
)));
2854 if (EQ (top
, Qminus
))
2855 f
->size_hint_flags
|= YNegative
;
2856 else if (TYPE_RANGED_INTEGERP (int, top
))
2858 toppos
= XINT (top
);
2860 f
->size_hint_flags
|= YNegative
;
2862 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2863 && CONSP (XCDR (top
))
2864 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
2866 toppos
= - XINT (XCAR (XCDR (top
)));
2867 f
->size_hint_flags
|= YNegative
;
2869 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2870 && CONSP (XCDR (top
))
2871 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
2873 toppos
= XINT (XCAR (XCDR (top
)));
2877 /* Store the numeric value of the position. */
2878 f
->top_pos
= toppos
;
2879 f
->left_pos
= leftpos
;
2881 f
->win_gravity
= NorthWestGravity
;
2883 /* Actually set that position, and convert to absolute. */
2884 x_set_offset (f
, leftpos
, toppos
, -1);
2886 #ifdef HAVE_X_WINDOWS
2887 if ((!NILP (icon_left
) || !NILP (icon_top
))
2888 && ! (icon_left_no_change
&& icon_top_no_change
))
2889 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2890 #endif /* HAVE_X_WINDOWS */
2897 /* Insert a description of internally-recorded parameters of frame X
2898 into the parameter alist *ALISTPTR that is to be given to the user.
2899 Only parameters that are specific to the X window system
2900 and whose values are not correctly recorded in the frame's
2901 param_alist need to be considered here. */
2904 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
2908 char buf
[INT_BUFSIZE_BOUND (w
)];
2910 /* Represent negative positions (off the top or left screen edge)
2911 in a way that Fmodify_frame_parameters will understand correctly. */
2912 XSETINT (tem
, f
->left_pos
);
2913 if (f
->left_pos
>= 0)
2914 store_in_alist (alistptr
, Qleft
, tem
);
2916 store_in_alist (alistptr
, Qleft
, list2 (Qplus
, tem
));
2918 XSETINT (tem
, f
->top_pos
);
2919 if (f
->top_pos
>= 0)
2920 store_in_alist (alistptr
, Qtop
, tem
);
2922 store_in_alist (alistptr
, Qtop
, list2 (Qplus
, tem
));
2924 store_in_alist (alistptr
, Qborder_width
,
2925 make_number (f
->border_width
));
2926 store_in_alist (alistptr
, Qinternal_border_width
,
2927 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
2928 store_in_alist (alistptr
, Qleft_fringe
,
2929 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
2930 store_in_alist (alistptr
, Qright_fringe
,
2931 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
2932 store_in_alist (alistptr
, Qscroll_bar_width
,
2933 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2935 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
2936 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
2937 /* nil means "use default width"
2938 for non-toolkit scroll bar.
2939 ruler-mode.el depends on this. */
2941 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
2942 MS-Windows it returns a value whose type is HANDLE, which is
2943 actually a pointer. Explicit casting avoids compiler
2945 w
= (uintptr_t) FRAME_X_WINDOW (f
);
2946 store_in_alist (alistptr
, Qwindow_id
,
2947 make_formatted_string (buf
, "%"pMu
, w
));
2948 #ifdef HAVE_X_WINDOWS
2949 #ifdef USE_X_TOOLKIT
2950 /* Tooltip frame may not have this widget. */
2951 if (FRAME_X_OUTPUT (f
)->widget
)
2953 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
2954 store_in_alist (alistptr
, Qouter_window_id
,
2955 make_formatted_string (buf
, "%"pMu
, w
));
2957 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
2958 store_in_alist (alistptr
, Qvisibility
,
2959 (FRAME_VISIBLE_P (f
) ? Qt
2960 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
2961 store_in_alist (alistptr
, Qdisplay
,
2962 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
2964 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
2967 tem
= make_natnum ((uintptr_t) FRAME_X_OUTPUT (f
)->parent_desc
);
2968 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
2969 store_in_alist (alistptr
, Qparent_id
, tem
);
2970 store_in_alist (alistptr
, Qtool_bar_position
, f
->tool_bar_position
);
2974 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
2975 the previous value of that parameter, NEW_VALUE is the new value. */
2978 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
2980 if (NILP (new_value
))
2981 f
->want_fullscreen
= FULLSCREEN_NONE
;
2982 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
2983 f
->want_fullscreen
= FULLSCREEN_BOTH
;
2984 else if (EQ (new_value
, Qfullwidth
))
2985 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
2986 else if (EQ (new_value
, Qfullheight
))
2987 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
2988 else if (EQ (new_value
, Qmaximized
))
2989 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
2991 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
2992 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
2996 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
2997 the previous value of that parameter, NEW_VALUE is the new value. */
3000 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3002 if (NILP (new_value
))
3003 f
->extra_line_spacing
= 0;
3004 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
3005 f
->extra_line_spacing
= XFASTINT (new_value
);
3006 else if (FLOATP (new_value
))
3008 int new_spacing
= XFLOAT_DATA (new_value
) * FRAME_LINE_HEIGHT (f
) + 0.5;
3010 if (new_spacing
>= 0)
3011 f
->extra_line_spacing
= new_spacing
;
3013 signal_error ("Invalid line-spacing", new_value
);
3016 signal_error ("Invalid line-spacing", new_value
);
3017 if (FRAME_VISIBLE_P (f
))
3022 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3023 the previous value of that parameter, NEW_VALUE is the new value. */
3026 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3028 Lisp_Object bgcolor
;
3030 if (NILP (new_value
))
3032 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3033 /* The value 0.4545 is the normal viewing gamma. */
3034 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3036 signal_error ("Invalid screen-gamma", new_value
);
3038 /* Apply the new gamma value to the frame background. */
3039 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3040 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3042 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3043 if (NATNUMP (parm_index
)
3044 && (XFASTINT (parm_index
)
3045 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3046 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3047 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3051 Fclear_face_cache (Qnil
);
3056 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3058 Lisp_Object font_object
;
3060 #ifdef HAVE_X_WINDOWS
3061 Lisp_Object font_param
= arg
;
3064 /* Set the frame parameter back to the old value because we may
3065 fail to use ARG as the new parameter value. */
3066 store_frame_param (f
, Qfont
, oldval
);
3068 /* ARG is a fontset name, a font name, a cons of fontset name and a
3069 font object, or a font object. In the last case, this function
3073 fontset
= fs_query_fontset (arg
, 0);
3076 font_object
= font_open_by_name (f
, arg
);
3077 if (NILP (font_object
))
3078 error ("Font `%s' is not defined", SSDATA (arg
));
3079 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3081 else if (fontset
> 0)
3083 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
3084 if (NILP (font_object
))
3085 error ("Font `%s' is not defined", SDATA (arg
));
3086 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3089 error ("The default fontset can't be used for a frame font");
3091 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3093 /* This is the case that the ASCII font of F's fontset XCAR
3094 (arg) is changed to the font XCDR (arg) by
3095 `set-fontset-font'. */
3096 fontset
= fs_query_fontset (XCAR (arg
), 0);
3098 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3099 font_object
= XCDR (arg
);
3100 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3101 #ifdef HAVE_X_WINDOWS
3102 font_param
= Ffont_get (font_object
, QCname
);
3105 else if (FONT_OBJECT_P (arg
))
3108 #ifdef HAVE_X_WINDOWS
3109 font_param
= Ffont_get (font_object
, QCname
);
3111 /* This is to store the XLFD font name in the frame parameter for
3112 backward compatibility. We should store the font-object
3113 itself in the future. */
3114 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3115 fontset
= FRAME_FONTSET (f
);
3116 /* Check if we can use the current fontset. If not, set FONTSET
3117 to -1 to generate a new fontset from FONT-OBJECT. */
3120 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3121 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3124 signal_error ("Invalid font name", ascii_font
);
3126 if (! font_match_p (spec
, font_object
))
3131 signal_error ("Invalid font", arg
);
3133 if (! NILP (Fequal (font_object
, oldval
)))
3136 x_new_font (f
, font_object
, fontset
);
3137 store_frame_param (f
, Qfont
, arg
);
3138 #ifdef HAVE_X_WINDOWS
3139 store_frame_param (f
, Qfont_param
, font_param
);
3141 /* Recalculate toolbar height. */
3142 f
->n_tool_bar_rows
= 0;
3143 /* Ensure we redraw it. */
3144 clear_current_matrices (f
);
3146 recompute_basic_faces (f
);
3148 do_pending_window_change (0);
3150 /* We used to call face-set-after-frame-default here, but it leads to
3151 recursive calls (since that function can set the `default' face's
3152 font which in turns changes the frame's `font' parameter).
3153 Also I don't know what this call is meant to do, but it seems the
3154 wrong way to do it anyway (it does a lot more work than what seems
3155 reasonable in response to a change to `font'). */
3160 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3162 if (! NILP (new_value
)
3163 && !CONSP (new_value
))
3167 CHECK_STRING (new_value
);
3168 p0
= p1
= SSDATA (new_value
);
3172 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
3174 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3180 while ((c
= *++p1
) && c_isspace (c
));
3184 new_value
= Fnreverse (new_value
);
3187 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3191 free_all_realized_faces (Qnil
);
3193 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3194 if (NILP (new_value
))
3196 if (NILP (old_value
))
3197 error ("No font backend available");
3198 font_update_drivers (f
, old_value
);
3199 error ("None of specified font backends are available");
3201 store_frame_param (f
, Qfont_backend
, new_value
);
3207 XSETFRAME (frame
, f
);
3208 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3209 ++face_change_count
;
3210 ++windows_or_buffers_changed
;
3216 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3218 compute_fringe_widths (f
, 1);
3219 #ifdef HAVE_X_WINDOWS
3220 /* Must adjust this so window managers report correct number of columns. */
3221 if (FRAME_X_WINDOW (f
) != 0)
3222 x_wm_set_size_hint (f
, 0, 0);
3227 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3229 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3231 if (XINT (arg
) == f
->border_width
)
3234 if (FRAME_X_WINDOW (f
) != 0)
3235 error ("Cannot change the border width of a frame");
3237 f
->border_width
= XINT (arg
);
3241 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3243 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3245 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3246 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3247 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3248 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3250 #ifdef USE_X_TOOLKIT
3251 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3252 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3255 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3258 if (FRAME_X_WINDOW (f
) != 0)
3260 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3261 SET_FRAME_GARBAGED (f
);
3262 do_pending_window_change (0);
3265 SET_FRAME_GARBAGED (f
);
3269 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3272 XSETFRAME (frame
, f
);
3275 Fmake_frame_invisible (frame
, Qt
);
3276 else if (EQ (value
, Qicon
))
3277 Ficonify_frame (frame
);
3279 Fmake_frame_visible (frame
);
3283 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3285 f
->auto_raise
= !EQ (Qnil
, arg
);
3289 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3291 f
->auto_lower
= !EQ (Qnil
, arg
);
3295 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3297 f
->no_split
= !NILP (arg
);
3301 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3303 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3304 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3305 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3306 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3308 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3310 ? vertical_scroll_bar_none
3312 ? vertical_scroll_bar_left
3314 ? vertical_scroll_bar_right
3315 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3316 ? vertical_scroll_bar_left
3317 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3318 ? vertical_scroll_bar_right
3319 : vertical_scroll_bar_none
);
3321 /* We set this parameter before creating the X window for the
3322 frame, so we can get the geometry right from the start.
3323 However, if the window hasn't been created yet, we shouldn't
3324 call x_set_window_size. */
3325 if (FRAME_X_WINDOW (f
))
3326 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3327 do_pending_window_change (0);
3332 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3334 int wid
= FRAME_COLUMN_WIDTH (f
);
3338 x_set_scroll_bar_default_width (f
);
3340 if (FRAME_X_WINDOW (f
))
3341 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3342 do_pending_window_change (0);
3344 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3345 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3347 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3348 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3350 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3351 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3352 if (FRAME_X_WINDOW (f
))
3353 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3354 do_pending_window_change (0);
3357 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3358 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3359 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3364 /* Return non-nil if frame F wants a bitmap icon. */
3367 x_icon_type (struct frame
*f
)
3371 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3379 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3386 for (i
= 0; i
< 2; i
++)
3399 else if (FLOATP (item
))
3401 alpha
= XFLOAT_DATA (item
);
3402 if (! (0 <= alpha
&& alpha
<= 1.0))
3403 args_out_of_range (make_float (0.0), make_float (1.0));
3405 else if (INTEGERP (item
))
3407 EMACS_INT ialpha
= XINT (item
);
3408 if (! (0 <= ialpha
&& alpha
<= 100))
3409 args_out_of_range (make_number (0), make_number (100));
3410 alpha
= ialpha
/ 100.0;
3413 wrong_type_argument (Qnumberp
, item
);
3417 for (i
= 0; i
< 2; i
++)
3418 f
->alpha
[i
] = newval
[i
];
3420 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3422 x_set_frame_alpha (f
);
3430 /* Subroutines of creating an X frame. */
3432 /* Make sure that Vx_resource_name is set to a reasonable value.
3433 Fix it up, or set it to `emacs' if it is too hopeless. */
3436 validate_x_resource_name (void)
3439 /* Number of valid characters in the resource name. */
3440 ptrdiff_t good_count
= 0;
3441 /* Number of invalid characters in the resource name. */
3442 ptrdiff_t bad_count
= 0;
3446 if (!STRINGP (Vx_resource_class
))
3447 Vx_resource_class
= build_string (EMACS_CLASS
);
3449 if (STRINGP (Vx_resource_name
))
3451 unsigned char *p
= SDATA (Vx_resource_name
);
3453 len
= SBYTES (Vx_resource_name
);
3455 /* Only letters, digits, - and _ are valid in resource names.
3456 Count the valid characters and count the invalid ones. */
3457 for (i
= 0; i
< len
; i
++)
3460 if (! ((c
>= 'a' && c
<= 'z')
3461 || (c
>= 'A' && c
<= 'Z')
3462 || (c
>= '0' && c
<= '9')
3463 || c
== '-' || c
== '_'))
3470 /* Not a string => completely invalid. */
3471 bad_count
= 5, good_count
= 0;
3473 /* If name is valid already, return. */
3477 /* If name is entirely invalid, or nearly so, or is so implausibly
3478 large that alloca might not work, use `emacs'. */
3479 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
3481 Vx_resource_name
= build_string ("emacs");
3485 /* Name is partly valid. Copy it and replace the invalid characters
3486 with underscores. */
3488 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3490 for (i
= 0; i
< len
; i
++)
3492 int c
= SREF (new, i
);
3493 if (! ((c
>= 'a' && c
<= 'z')
3494 || (c
>= 'A' && c
<= 'Z')
3495 || (c
>= '0' && c
<= '9')
3496 || c
== '-' || c
== '_'))
3502 extern char *x_get_string_resource (XrmDatabase
, const char *, const char *);
3503 extern Display_Info
*check_x_display_info (Lisp_Object
);
3506 /* Get specified attribute from resource database RDB.
3507 See Fx_get_resource below for other parameters. */
3510 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3512 register char *value
;
3516 CHECK_STRING (attribute
);
3517 CHECK_STRING (class);
3519 if (!NILP (component
))
3520 CHECK_STRING (component
);
3521 if (!NILP (subclass
))
3522 CHECK_STRING (subclass
);
3523 if (NILP (component
) != NILP (subclass
))
3524 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3526 validate_x_resource_name ();
3528 /* Allocate space for the components, the dots which separate them,
3529 and the final '\0'. Make them big enough for the worst case. */
3530 name_key
= alloca (SBYTES (Vx_resource_name
)
3531 + (STRINGP (component
)
3532 ? SBYTES (component
) : 0)
3533 + SBYTES (attribute
)
3536 class_key
= alloca (SBYTES (Vx_resource_class
)
3538 + (STRINGP (subclass
)
3539 ? SBYTES (subclass
) : 0)
3542 /* Start with emacs.FRAMENAME for the name (the specific one)
3543 and with `Emacs' for the class key (the general one). */
3544 strcpy (name_key
, SSDATA (Vx_resource_name
));
3545 strcpy (class_key
, SSDATA (Vx_resource_class
));
3547 strcat (class_key
, ".");
3548 strcat (class_key
, SSDATA (class));
3550 if (!NILP (component
))
3552 strcat (class_key
, ".");
3553 strcat (class_key
, SSDATA (subclass
));
3555 strcat (name_key
, ".");
3556 strcat (name_key
, SSDATA (component
));
3559 strcat (name_key
, ".");
3560 strcat (name_key
, SSDATA (attribute
));
3562 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3564 if (value
&& *value
)
3565 return build_string (value
);
3571 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3572 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3573 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3574 class, where INSTANCE is the name under which Emacs was invoked, or
3575 the name specified by the `-name' or `-rn' command-line arguments.
3577 The optional arguments COMPONENT and SUBCLASS add to the key and the
3578 class, respectively. You must specify both of them or neither.
3579 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3580 and the class is `Emacs.CLASS.SUBCLASS'. */)
3581 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
,
3582 Lisp_Object subclass
)
3584 check_window_system (NULL
);
3586 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3587 attribute
, class, component
, subclass
);
3590 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3593 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
,
3594 Lisp_Object
class, Lisp_Object component
,
3595 Lisp_Object subclass
)
3597 return xrdb_get_resource (dpyinfo
->xrdb
,
3598 attribute
, class, component
, subclass
);
3601 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3602 /* Used when C code wants a resource value. */
3603 /* Called from oldXMenu/Create.c. */
3605 x_get_resource_string (const char *attribute
, const char *class)
3608 struct frame
*sf
= SELECTED_FRAME ();
3609 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
3612 /* Allocate space for the components, the dots which separate them,
3613 and the final '\0'. */
3614 char *name_key
= SAFE_ALLOCA (invocation_namelen
+ strlen (attribute
) + 2);
3615 char *class_key
= alloca ((sizeof (EMACS_CLASS
) - 1) + strlen (class) + 2);
3617 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
3618 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3620 result
= x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3621 name_key
, class_key
);
3627 /* Return the value of parameter PARAM.
3629 First search ALIST, then Vdefault_frame_alist, then the X defaults
3630 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3632 Convert the resource to the type specified by desired_type.
3634 If no default is specified, return Qunbound. If you call
3635 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3636 and don't let it get stored in any Lisp-visible variables! */
3639 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3640 const char *attribute
, const char *class, enum resource_types type
)
3642 register Lisp_Object tem
;
3644 tem
= Fassq (param
, alist
);
3648 /* If we find this parm in ALIST, clear it out
3649 so that it won't be "left over" at the end. */
3651 XSETCAR (tem
, Qnil
);
3652 /* In case the parameter appears more than once in the alist,
3654 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3655 if (CONSP (XCAR (tail
))
3656 && EQ (XCAR (XCAR (tail
)), param
))
3657 XSETCAR (XCAR (tail
), Qnil
);
3660 tem
= Fassq (param
, Vdefault_frame_alist
);
3662 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3663 look in the X resources. */
3666 if (attribute
&& dpyinfo
)
3668 tem
= display_x_get_resource (dpyinfo
,
3669 build_string (attribute
),
3670 build_string (class),
3678 case RES_TYPE_NUMBER
:
3679 return make_number (atoi (SSDATA (tem
)));
3681 case RES_TYPE_BOOLEAN_NUMBER
:
3682 if (!strcmp (SSDATA (tem
), "on")
3683 || !strcmp (SSDATA (tem
), "true"))
3684 return make_number (1);
3685 return make_number (atoi (SSDATA (tem
)));
3688 case RES_TYPE_FLOAT
:
3689 return make_float (atof (SSDATA (tem
)));
3691 case RES_TYPE_BOOLEAN
:
3692 tem
= Fdowncase (tem
);
3693 if (!strcmp (SSDATA (tem
), "on")
3695 || !strcmp (SSDATA (tem
), "yes")
3697 || !strcmp (SSDATA (tem
), "true"))
3702 case RES_TYPE_STRING
:
3705 case RES_TYPE_SYMBOL
:
3706 /* As a special case, we map the values `true' and `on'
3707 to Qt, and `false' and `off' to Qnil. */
3710 lower
= Fdowncase (tem
);
3711 if (!strcmp (SSDATA (lower
), "on")
3713 || !strcmp (SSDATA (lower
), "yes")
3715 || !strcmp (SSDATA (lower
), "true"))
3717 else if (!strcmp (SSDATA (lower
), "off")
3719 || !strcmp (SSDATA (lower
), "no")
3721 || !strcmp (SSDATA (lower
), "false"))
3724 return Fintern (tem
, Qnil
);
3738 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3739 const char *attribute
, const char *class,
3740 enum resource_types type
)
3742 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3743 alist
, param
, attribute
, class, type
);
3746 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3749 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3751 const char *attribute
, const char *class,
3752 enum resource_types type
)
3756 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3757 attribute
, class, type
);
3758 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3759 store_frame_param (f
, param
, value
);
3765 /* Record in frame F the specified or default value according to ALIST
3766 of the parameter named PROP (a Lisp symbol).
3767 If no value is specified for PROP, look for an X default for XPROP
3768 on the frame named NAME.
3769 If that is not found either, use the value DEFLT. */
3772 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
3773 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
3774 enum resource_types type
)
3778 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3779 if (EQ (tem
, Qunbound
))
3781 x_set_frame_parameters (f
, list1 (Fcons (prop
, tem
)));
3786 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
3789 * XParseGeometry parses strings of the form
3790 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
3791 * width, height, xoffset, and yoffset are unsigned integers.
3792 * Example: "=80x24+300-49"
3793 * The equal sign is optional.
3794 * It returns a bitmask that indicates which of the four values
3795 * were actually found in the string. For each value found,
3796 * the corresponding argument is updated; for each value
3797 * not found, the corresponding argument is left unchanged.
3801 XParseGeometry (char *string
,
3803 unsigned int *width
, unsigned int *height
)
3807 unsigned long int tempWidth
, tempHeight
;
3808 long int tempX
, tempY
;
3809 char *nextCharacter
;
3811 if (string
== NULL
|| *string
== '\0')
3814 string
++; /* ignore possible '=' at beg of geometry spec */
3817 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
3819 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
3820 if (strind
== nextCharacter
)
3822 strind
= nextCharacter
;
3826 if (*strind
== 'x' || *strind
== 'X')
3829 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
3830 if (strind
== nextCharacter
)
3832 strind
= nextCharacter
;
3833 mask
|= HeightValue
;
3836 if (*strind
== '+' || *strind
== '-')
3840 tempX
= strtol (strind
, &nextCharacter
, 10);
3841 if (strind
== nextCharacter
)
3843 strind
= nextCharacter
;
3845 if (*strind
== '+' || *strind
== '-')
3849 tempY
= strtol (strind
, &nextCharacter
, 10);
3850 if (strind
== nextCharacter
)
3852 strind
= nextCharacter
;
3857 /* If strind isn't at the end of the string then it's an invalid
3858 geometry specification. */
3860 if (*strind
!= '\0')
3864 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
3866 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
3867 if (mask
& WidthValue
)
3868 *width
= min (tempWidth
, UINT_MAX
);
3869 if (mask
& HeightValue
)
3870 *height
= min (tempHeight
, UINT_MAX
);
3874 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
3877 /* NS used to define x-parse-geometry in ns-win.el, but that confused
3878 make-docfile: the documentation string in ns-win.el was used for
3879 x-parse-geometry even in non-NS builds.
3881 With two definitions of x-parse-geometry in this file, various
3882 things still get confused (eg M-x apropos documentation), so that
3883 it is best if the two definitions just share the same doc-string.
3885 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3886 doc
: /* Parse a display geometry string STRING.
3887 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3888 The properties returned may include `top', `left', `height', and `width'.
3889 For X, the value of `left' or `top' may be an integer,
3890 or a list (+ N) meaning N pixels relative to top/left corner,
3891 or a list (- N) meaning -N pixels relative to bottom/right corner.
3892 On Nextstep, this just calls `ns-parse-geometry'. */)
3893 (Lisp_Object string
)
3896 unsigned int width
, height
;
3899 CHECK_STRING (string
);
3902 if (strchr (SSDATA (string
), ' ') != NULL
)
3903 return call1 (Qns_parse_geometry
, string
);
3905 geometry
= XParseGeometry (SSDATA (string
),
3906 &x
, &y
, &width
, &height
);
3908 if (geometry
& XValue
)
3910 Lisp_Object element
;
3912 if (x
>= 0 && (geometry
& XNegative
))
3913 element
= list3 (Qleft
, Qminus
, make_number (-x
));
3914 else if (x
< 0 && ! (geometry
& XNegative
))
3915 element
= list3 (Qleft
, Qplus
, make_number (x
));
3917 element
= Fcons (Qleft
, make_number (x
));
3918 result
= Fcons (element
, result
);
3921 if (geometry
& YValue
)
3923 Lisp_Object element
;
3925 if (y
>= 0 && (geometry
& YNegative
))
3926 element
= list3 (Qtop
, Qminus
, make_number (-y
));
3927 else if (y
< 0 && ! (geometry
& YNegative
))
3928 element
= list3 (Qtop
, Qplus
, make_number (y
));
3930 element
= Fcons (Qtop
, make_number (y
));
3931 result
= Fcons (element
, result
);
3934 if (geometry
& WidthValue
)
3935 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3936 if (geometry
& HeightValue
)
3937 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3943 /* Calculate the desired size and position of frame F.
3944 Return the flags saying which aspects were specified.
3946 Also set the win_gravity and size_hint_flags of F.
3948 Adjust height for toolbar if TOOLBAR_P is 1.
3950 This function does not make the coordinates positive. */
3952 #define DEFAULT_ROWS 35
3953 #define DEFAULT_COLS 80
3956 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, bool toolbar_p
)
3958 register Lisp_Object tem0
, tem1
, tem2
;
3959 long window_prompting
= 0;
3960 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3962 /* Default values if we fall through.
3963 Actually, if that happens we should get
3964 window manager prompting. */
3965 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3966 FRAME_LINES (f
) = DEFAULT_ROWS
;
3967 /* Window managers expect that if program-specified
3968 positions are not (0,0), they're intentional, not defaults. */
3972 /* Ensure that old new_text_cols and new_text_lines will not override the
3974 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3975 f
->new_text_cols
= f
->new_text_lines
= 0;
3977 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3978 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3979 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3980 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3982 if (!EQ (tem0
, Qunbound
))
3984 CHECK_NUMBER (tem0
);
3985 if (! (0 <= XINT (tem0
) && XINT (tem0
) <= INT_MAX
))
3986 xsignal1 (Qargs_out_of_range
, tem0
);
3987 FRAME_LINES (f
) = XINT (tem0
);
3989 if (!EQ (tem1
, Qunbound
))
3991 CHECK_NUMBER (tem1
);
3992 if (! (0 <= XINT (tem1
) && XINT (tem1
) <= INT_MAX
))
3993 xsignal1 (Qargs_out_of_range
, tem1
);
3994 SET_FRAME_COLS (f
, XINT (tem1
));
3996 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
3997 window_prompting
|= USSize
;
3999 window_prompting
|= PSize
;
4002 f
->scroll_bar_actual_width
4003 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4005 /* This used to be done _before_ calling x_figure_window_size, but
4006 since the height is reset here, this was really a no-op. I
4007 assume that moving it here does what Gerd intended (although he
4008 no longer can remember what that was... ++KFS, 2003-03-25. */
4010 /* Add the tool-bar height to the initial frame height so that the
4011 user gets a text display area of the size he specified with -g or
4012 via .Xdefaults. Later changes of the tool-bar height don't
4013 change the frame size. This is done so that users can create
4014 tall Emacs frames without having to guess how tall the tool-bar
4016 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4018 int margin
, relief
, bar_height
;
4020 relief
= (tool_bar_button_relief
>= 0
4021 ? tool_bar_button_relief
4022 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4024 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
4025 margin
= XFASTINT (Vtool_bar_button_margin
);
4026 else if (CONSP (Vtool_bar_button_margin
)
4027 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
4028 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4032 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4033 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4036 compute_fringe_widths (f
, 0);
4038 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4039 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4041 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4042 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4043 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4044 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4046 if (EQ (tem0
, Qminus
))
4049 window_prompting
|= YNegative
;
4051 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4052 && CONSP (XCDR (tem0
))
4053 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem0
)), INT_MAX
))
4055 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4056 window_prompting
|= YNegative
;
4058 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4059 && CONSP (XCDR (tem0
))
4060 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0
))))
4062 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4064 else if (EQ (tem0
, Qunbound
))
4068 CHECK_TYPE_RANGED_INTEGER (int, tem0
);
4069 f
->top_pos
= XINT (tem0
);
4071 window_prompting
|= YNegative
;
4074 if (EQ (tem1
, Qminus
))
4077 window_prompting
|= XNegative
;
4079 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4080 && CONSP (XCDR (tem1
))
4081 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem1
)), INT_MAX
))
4083 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4084 window_prompting
|= XNegative
;
4086 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4087 && CONSP (XCDR (tem1
))
4088 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1
))))
4090 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4092 else if (EQ (tem1
, Qunbound
))
4096 CHECK_TYPE_RANGED_INTEGER (int, tem1
);
4097 f
->left_pos
= XINT (tem1
);
4098 if (f
->left_pos
< 0)
4099 window_prompting
|= XNegative
;
4102 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4103 window_prompting
|= USPosition
;
4105 window_prompting
|= PPosition
;
4108 if (window_prompting
& XNegative
)
4110 if (window_prompting
& YNegative
)
4111 f
->win_gravity
= SouthEastGravity
;
4113 f
->win_gravity
= NorthEastGravity
;
4117 if (window_prompting
& YNegative
)
4118 f
->win_gravity
= SouthWestGravity
;
4120 f
->win_gravity
= NorthWestGravity
;
4123 f
->size_hint_flags
= window_prompting
;
4125 return window_prompting
;
4130 #endif /* HAVE_WINDOW_SYSTEM */
4133 frame_make_pointer_invisible (void)
4135 if (! NILP (Vmake_pointer_invisible
))
4138 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4141 f
= SELECTED_FRAME ();
4142 if (f
&& !f
->pointer_invisible
4143 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4146 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4147 f
->pointer_invisible
= 1;
4153 frame_make_pointer_visible (void)
4155 /* We don't check Vmake_pointer_invisible here in case the
4156 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4159 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4162 f
= SELECTED_FRAME ();
4163 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4164 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4166 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4167 f
->pointer_invisible
= 0;
4171 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4172 Sframe_pointer_visible_p
, 0, 1, 0,
4173 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4174 Otherwise it returns nil. FRAME omitted or nil means the
4175 selected frame. This is useful when `make-pointer-invisible' is set. */)
4178 return decode_any_frame (frame
)->pointer_invisible
? Qnil
: Qt
;
4183 /***********************************************************************
4185 ***********************************************************************/
4187 #ifdef HAVE_WINDOW_SYSTEM
4189 # if (defined HAVE_NS \
4190 || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR)))
4192 free_monitors (struct MonitorInfo
*monitors
, int n_monitors
)
4195 for (i
= 0; i
< n_monitors
; ++i
)
4196 xfree (monitors
[i
].name
);
4202 make_monitor_attribute_list (struct MonitorInfo
*monitors
,
4204 int primary_monitor
,
4205 Lisp_Object monitor_frames
,
4208 Lisp_Object attributes_list
= Qnil
;
4209 Lisp_Object primary_monitor_attributes
= Qnil
;
4212 for (i
= 0; i
< n_monitors
; ++i
)
4214 Lisp_Object geometry
, workarea
, attributes
= Qnil
;
4215 struct MonitorInfo
*mi
= &monitors
[i
];
4217 if (mi
->geom
.width
== 0) continue;
4219 workarea
= list4i (mi
->work
.x
, mi
->work
.y
,
4220 mi
->work
.width
, mi
->work
.height
);
4221 geometry
= list4i (mi
->geom
.x
, mi
->geom
.y
,
4222 mi
->geom
.width
, mi
->geom
.height
);
4223 attributes
= Fcons (Fcons (Qsource
, build_string (source
)),
4225 attributes
= Fcons (Fcons (Qframes
, AREF (monitor_frames
, i
)),
4227 attributes
= Fcons (Fcons (Qmm_size
,
4228 list2i (mi
->mm_width
, mi
->mm_height
)),
4230 attributes
= Fcons (Fcons (Qworkarea
, workarea
), attributes
);
4231 attributes
= Fcons (Fcons (Qgeometry
, geometry
), attributes
);
4233 attributes
= Fcons (Fcons (Qname
, make_string (mi
->name
,
4234 strlen (mi
->name
))),
4237 if (i
== primary_monitor
)
4238 primary_monitor_attributes
= attributes
;
4240 attributes_list
= Fcons (attributes
, attributes_list
);
4243 if (!NILP (primary_monitor_attributes
))
4244 attributes_list
= Fcons (primary_monitor_attributes
, attributes_list
);
4245 return attributes_list
;
4248 #endif /* HAVE_WINDOW_SYSTEM */
4251 /***********************************************************************
4253 ***********************************************************************/
4256 syms_of_frame (void)
4258 DEFSYM (Qframep
, "framep");
4259 DEFSYM (Qframe_live_p
, "frame-live-p");
4260 DEFSYM (Qexplicit_name
, "explicit-name");
4261 DEFSYM (Qheight
, "height");
4262 DEFSYM (Qicon
, "icon");
4263 DEFSYM (Qminibuffer
, "minibuffer");
4264 DEFSYM (Qmodeline
, "modeline");
4265 DEFSYM (Qonly
, "only");
4266 DEFSYM (Qnone
, "none");
4267 DEFSYM (Qwidth
, "width");
4268 DEFSYM (Qgeometry
, "geometry");
4269 DEFSYM (Qicon_left
, "icon-left");
4270 DEFSYM (Qicon_top
, "icon-top");
4271 DEFSYM (Qtooltip
, "tooltip");
4272 DEFSYM (Qleft
, "left");
4273 DEFSYM (Qright
, "right");
4274 DEFSYM (Quser_position
, "user-position");
4275 DEFSYM (Quser_size
, "user-size");
4276 DEFSYM (Qwindow_id
, "window-id");
4277 #ifdef HAVE_X_WINDOWS
4278 DEFSYM (Qouter_window_id
, "outer-window-id");
4280 DEFSYM (Qparent_id
, "parent-id");
4282 DEFSYM (Qw32
, "w32");
4285 DEFSYM (Qvisible
, "visible");
4286 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4287 DEFSYM (Qbuffer_list
, "buffer-list");
4288 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4289 DEFSYM (Qdisplay_type
, "display-type");
4290 DEFSYM (Qbackground_mode
, "background-mode");
4291 DEFSYM (Qnoelisp
, "noelisp");
4292 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4293 DEFSYM (Qtty
, "tty");
4294 DEFSYM (Qtty_type
, "tty-type");
4296 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4298 DEFSYM (Qfullwidth
, "fullwidth");
4299 DEFSYM (Qfullheight
, "fullheight");
4300 DEFSYM (Qfullboth
, "fullboth");
4301 DEFSYM (Qmaximized
, "maximized");
4302 DEFSYM (Qx_resource_name
, "x-resource-name");
4303 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4305 DEFSYM (Qterminal
, "terminal");
4307 DEFSYM (Qgeometry
, "geometry");
4308 DEFSYM (Qworkarea
, "workarea");
4309 DEFSYM (Qmm_size
, "mm-size");
4310 DEFSYM (Qframes
, "frames");
4311 DEFSYM (Qsource
, "source");
4314 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4320 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4322 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4323 if (frame_parms
[i
].variable
)
4325 *frame_parms
[i
].variable
= v
;
4326 staticpro (frame_parms
[i
].variable
);
4328 Fput (v
, Qx_frame_parameter
, make_number (i
));
4332 #ifdef HAVE_WINDOW_SYSTEM
4333 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4334 doc
: /* The name Emacs uses to look up X resources.
4335 `x-get-resource' uses this as the first component of the instance name
4336 when requesting resource values.
4337 Emacs initially sets `x-resource-name' to the name under which Emacs
4338 was invoked, or to the value specified with the `-name' or `-rn'
4339 switches, if present.
4341 It may be useful to bind this variable locally around a call
4342 to `x-get-resource'. See also the variable `x-resource-class'. */);
4343 Vx_resource_name
= Qnil
;
4345 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4346 doc
: /* The class Emacs uses to look up X resources.
4347 `x-get-resource' uses this as the first component of the instance class
4348 when requesting resource values.
4350 Emacs initially sets `x-resource-class' to "Emacs".
4352 Setting this variable permanently is not a reasonable thing to do,
4353 but binding this variable locally around a call to `x-get-resource'
4354 is a reasonable practice. See also the variable `x-resource-name'. */);
4355 Vx_resource_class
= build_string (EMACS_CLASS
);
4357 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4358 doc
: /* The lower limit of the frame opacity (alpha transparency).
4359 The value should range from 0 (invisible) to 100 (completely opaque).
4360 You can also use a floating number between 0.0 and 1.0.
4361 The default is 20. */);
4362 Vframe_alpha_lower_limit
= make_number (20);
4365 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4366 doc
: /* Alist of default values for frame creation.
4367 These may be set in your init file, like this:
4368 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4369 These override values given in window system configuration data,
4370 including X Windows' defaults database.
4371 For values specific to the first Emacs frame, see `initial-frame-alist'.
4372 For window-system specific values, see `window-system-default-frame-alist'.
4373 For values specific to the separate minibuffer frame, see
4374 `minibuffer-frame-alist'.
4375 The `menu-bar-lines' element of the list controls whether new frames
4376 have menu bars; `menu-bar-mode' works by altering this element.
4377 Setting this variable does not affect existing frames, only new ones. */);
4378 Vdefault_frame_alist
= Qnil
;
4380 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4381 doc
: /* Default position of scroll bars on this window-system. */);
4382 #ifdef HAVE_WINDOW_SYSTEM
4383 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
4384 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4386 Vdefault_frame_scroll_bars
= Qright
;
4388 Vdefault_frame_scroll_bars
= Qleft
;
4391 Vdefault_frame_scroll_bars
= Qnil
;
4394 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
4395 scroll_bar_adjust_thumb_portion_p
,
4396 doc
: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
4397 Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
4398 even if the end of the buffer is shown (i.e. overscrolling).
4399 Set to nil if you want the thumb to be at the bottom when the end of the buffer
4400 is shown. Also, the thumb fills the whole scroll bar when the entire buffer
4401 is visible. In this case you can not overscroll. */);
4402 scroll_bar_adjust_thumb_portion_p
= 1;
4404 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4405 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4407 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4408 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4409 `mouse-position' calls this function, passing its usual return value as
4410 argument, and returns whatever this function returns.
4411 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4412 which need to do mouse handling at the Lisp level. */);
4413 Vmouse_position_function
= Qnil
;
4415 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4416 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4417 If the value is an integer, highlighting is only shown after moving the
4418 mouse, while keyboard input turns off the highlight even when the mouse
4419 is over the clickable text. However, the mouse shape still indicates
4420 when the mouse is over clickable text. */);
4421 Vmouse_highlight
= Qt
;
4423 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4424 doc
: /* If non-nil, make pointer invisible while typing.
4425 The pointer becomes visible again when the mouse is moved. */);
4426 Vmake_pointer_invisible
= Qt
;
4428 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4429 doc
: /* Functions run before deleting a frame.
4430 The functions are run with one arg, the frame to be deleted.
4433 Note that functions in this list may be called just before the frame is
4434 actually deleted, or some time later (or even both when an earlier function
4435 in `delete-frame-functions' (indirectly) calls `delete-frame'
4437 Vdelete_frame_functions
= Qnil
;
4438 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
4440 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4441 doc
: /* Non-nil if Menu-Bar mode is enabled.
4442 See the command `menu-bar-mode' for a description of this minor mode.
4443 Setting this variable directly does not take effect;
4444 either customize it (see the info node `Easy Customization')
4445 or call the function `menu-bar-mode'. */);
4446 Vmenu_bar_mode
= Qt
;
4448 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4449 doc
: /* Non-nil if Tool-Bar mode is enabled.
4450 See the command `tool-bar-mode' for a description of this minor mode.
4451 Setting this variable directly does not take effect;
4452 either customize it (see the info node `Easy Customization')
4453 or call the function `tool-bar-mode'. */);
4454 #ifdef HAVE_WINDOW_SYSTEM
4455 Vtool_bar_mode
= Qt
;
4457 Vtool_bar_mode
= Qnil
;
4460 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4461 doc
: /* Minibufferless frames use this frame's minibuffer.
4463 Emacs cannot create minibufferless frames unless this is set to an
4464 appropriate surrogate.
4466 Emacs consults this variable only when creating minibufferless
4467 frames; once the frame is created, it sticks with its assigned
4468 minibuffer, no matter what this variable is set to. This means that
4469 this variable doesn't necessarily say anything meaningful about the
4470 current set of frames, or where the minibuffer is currently being
4473 This variable is local to the current terminal and cannot be buffer-local. */);
4475 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
4476 doc
: /* Non-nil if window system changes focus when you move the mouse.
4477 You should set this variable to tell Emacs how your window manager
4478 handles focus, since there is no way in general for Emacs to find out
4479 automatically. See also `mouse-autoselect-window'. */);
4480 focus_follows_mouse
= 0;
4482 staticpro (&Vframe_list
);
4485 defsubr (&Sframe_live_p
);
4486 defsubr (&Swindow_system
);
4487 defsubr (&Smake_terminal_frame
);
4488 defsubr (&Shandle_switch_frame
);
4489 defsubr (&Shandle_focus_in
);
4490 defsubr (&Shandle_focus_out
);
4491 defsubr (&Sselect_frame
);
4492 defsubr (&Sselected_frame
);
4493 defsubr (&Sframe_list
);
4494 defsubr (&Snext_frame
);
4495 defsubr (&Sprevious_frame
);
4496 defsubr (&Sdelete_frame
);
4497 defsubr (&Smouse_position
);
4498 defsubr (&Smouse_pixel_position
);
4499 defsubr (&Sset_mouse_position
);
4500 defsubr (&Sset_mouse_pixel_position
);
4502 defsubr (&Sframe_configuration
);
4503 defsubr (&Srestore_frame_configuration
);
4505 defsubr (&Smake_frame_visible
);
4506 defsubr (&Smake_frame_invisible
);
4507 defsubr (&Siconify_frame
);
4508 defsubr (&Sframe_visible_p
);
4509 defsubr (&Svisible_frame_list
);
4510 defsubr (&Sraise_frame
);
4511 defsubr (&Slower_frame
);
4512 defsubr (&Sredirect_frame_focus
);
4513 defsubr (&Sframe_focus
);
4514 defsubr (&Sframe_parameters
);
4515 defsubr (&Sframe_parameter
);
4516 defsubr (&Smodify_frame_parameters
);
4517 defsubr (&Sframe_char_height
);
4518 defsubr (&Sframe_char_width
);
4519 defsubr (&Sframe_pixel_height
);
4520 defsubr (&Sframe_pixel_width
);
4521 defsubr (&Stool_bar_pixel_width
);
4522 defsubr (&Sset_frame_height
);
4523 defsubr (&Sset_frame_width
);
4524 defsubr (&Sset_frame_size
);
4525 defsubr (&Sset_frame_position
);
4526 defsubr (&Sframe_pointer_visible_p
);
4528 #ifdef HAVE_WINDOW_SYSTEM
4529 defsubr (&Sx_get_resource
);
4530 defsubr (&Sx_parse_geometry
);