1 /* Generic frame functions.
3 Copyright (C) 1993-1995, 1997, 1999-2013 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29 #include "character.h"
31 #ifdef HAVE_WINDOW_SYSTEM
33 #endif /* HAVE_WINDOW_SYSTEM */
36 /* These help us bind and responding to switch-frame events. */
40 #include "blockinput.h"
42 #include "termhooks.h"
43 #include "dispextern.h"
46 #ifdef HAVE_WINDOW_SYSTEM
55 Lisp_Object Qns_parse_geometry
;
58 Lisp_Object Qframep
, Qframe_live_p
;
59 Lisp_Object Qicon
, Qmodeline
;
60 Lisp_Object Qonly
, Qnone
;
61 Lisp_Object Qx
, Qw32
, Qpc
, Qns
;
63 Lisp_Object Qdisplay_type
;
64 static Lisp_Object Qbackground_mode
;
67 static Lisp_Object Qx_frame_parameter
;
68 Lisp_Object Qx_resource_name
;
69 Lisp_Object Qterminal
;
71 /* Frame parameters (set or reported). */
73 Lisp_Object Qauto_raise
, Qauto_lower
;
74 Lisp_Object Qborder_color
, Qborder_width
;
75 Lisp_Object Qcursor_color
, Qcursor_type
;
76 Lisp_Object Qheight
, Qwidth
;
77 Lisp_Object Qleft
, Qright
;
78 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
80 Lisp_Object Qinternal_border_width
;
81 Lisp_Object Qmouse_color
;
82 Lisp_Object Qminibuffer
;
83 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
84 Lisp_Object Qvisibility
;
85 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
86 Lisp_Object Qscreen_gamma
;
87 Lisp_Object Qline_spacing
;
88 static Lisp_Object Quser_position
, Quser_size
;
89 Lisp_Object Qwait_for_wm
;
90 static Lisp_Object Qwindow_id
;
92 static Lisp_Object Qouter_window_id
;
94 Lisp_Object Qparent_id
;
95 Lisp_Object Qtitle
, Qname
;
96 static Lisp_Object Qexplicit_name
;
97 Lisp_Object Qunsplittable
;
98 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
, Qtool_bar_position
;
99 Lisp_Object Qleft_fringe
, Qright_fringe
;
100 Lisp_Object Qbuffer_predicate
;
101 static Lisp_Object Qbuffer_list
, Qburied_buffer_list
;
102 Lisp_Object Qtty_color_mode
;
103 Lisp_Object Qtty
, Qtty_type
;
105 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
107 Lisp_Object Qfont_backend
;
110 Lisp_Object Qface_set_after_frame_default
;
112 static Lisp_Object Qfocus_in_hook
;
113 static Lisp_Object Qfocus_out_hook
;
114 static Lisp_Object Qdelete_frame_functions
;
116 static Lisp_Object Qgeometry
, Qworkarea
, Qmm_size
, Qframes
, Qsource
;
118 /* The currently selected frame. */
120 Lisp_Object selected_frame
;
122 /* A frame which is not just a mini-buffer, or NULL if there are no such
123 frames. This is usually the most recent such frame that was selected. */
125 static struct frame
*last_nonminibuf_frame
;
127 /* Nonzero means there is at least one garbaged frame. */
131 #ifdef HAVE_WINDOW_SYSTEM
132 static void x_report_frame_params (struct frame
*, Lisp_Object
*);
135 /* These setters are used only in this file, so they can be private. */
137 fset_buffer_predicate (struct frame
*f
, Lisp_Object val
)
139 f
->buffer_predicate
= val
;
142 fset_minibuffer_window (struct frame
*f
, Lisp_Object val
)
144 f
->minibuffer_window
= val
;
148 decode_live_frame (register Lisp_Object frame
)
151 frame
= selected_frame
;
152 CHECK_LIVE_FRAME (frame
);
153 return XFRAME (frame
);
157 decode_any_frame (register Lisp_Object frame
)
160 frame
= selected_frame
;
162 return XFRAME (frame
);
166 window_system_available (struct frame
*f
)
169 return FRAME_WINDOW_P (f
) || FRAME_MSDOS_P (f
);
171 #ifdef HAVE_WINDOW_SYSTEM
172 return x_display_list
!= NULL
;
179 decode_window_system_frame (Lisp_Object frame
)
181 struct frame
*f
= decode_live_frame (frame
);
183 if (!window_system_available (f
))
184 error ("Window system frame should be used");
189 check_window_system (struct frame
*f
)
191 if (!window_system_available (f
))
192 error (f
? "Window system frame should be used"
193 : "Window system is not in use or not initialized");
197 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
199 struct window
*w
= XWINDOW (window
);
204 /* Handle just the top child in a vertical split. */
205 if (WINDOW_VERTICAL_COMBINATION_P (w
))
206 set_menu_bar_lines_1 (w
->contents
, n
);
207 else if (WINDOW_HORIZONTAL_COMBINATION_P (w
))
208 /* Adjust all children in a horizontal split. */
209 for (window
= w
->contents
; !NILP (window
); window
= w
->next
)
211 w
= XWINDOW (window
);
212 set_menu_bar_lines_1 (window
, n
);
217 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
220 int olines
= FRAME_MENU_BAR_LINES (f
);
222 /* Right now, menu bars don't work properly in minibuf-only frames;
223 most of the commands try to apply themselves to the minibuffer
224 frame itself, and get an error because you can't switch buffers
225 in or split the minibuffer window. */
226 if (FRAME_MINIBUF_ONLY_P (f
))
229 if (TYPE_RANGED_INTEGERP (int, value
))
230 nlines
= XINT (value
);
234 if (nlines
!= olines
)
236 windows_or_buffers_changed
= 14;
237 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
238 FRAME_MENU_BAR_LINES (f
) = nlines
;
239 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
240 adjust_frame_glyphs (f
);
244 Lisp_Object Vframe_list
;
247 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
248 doc
: /* Return non-nil if OBJECT is a frame.
250 t for a termcap frame (a character-only terminal),
251 'x' for an Emacs frame that is really an X window,
252 'w32' for an Emacs frame that is a window on MS-Windows display,
253 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
254 'pc' for a direct-write MS-DOS frame.
255 See also `frame-live-p'. */)
258 if (!FRAMEP (object
))
260 switch (XFRAME (object
)->output_method
)
262 case output_initial
: /* The initial frame is like a termcap frame. */
265 case output_x_window
:
269 case output_msdos_raw
:
278 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
279 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
280 Value is nil if OBJECT is not a live frame. If object is a live
281 frame, the return value indicates what sort of terminal device it is
282 displayed on. See the documentation of `framep' for possible
286 return ((FRAMEP (object
)
287 && FRAME_LIVE_P (XFRAME (object
)))
292 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
293 doc
: /* The name of the window system that FRAME is displaying through.
294 The value is a symbol:
295 nil for a termcap frame (a character-only terminal),
296 'x' for an Emacs frame that is really an X window,
297 'w32' for an Emacs frame that is a window on MS-Windows display,
298 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
299 'pc' for a direct-write MS-DOS frame.
301 FRAME defaults to the currently selected frame.
303 Use of this function as a predicate is deprecated. Instead,
304 use `display-graphic-p' or any of the other `display-*-p'
305 predicates which report frame's specific UI-related capabilities. */)
310 frame
= selected_frame
;
312 type
= Fframep (frame
);
315 wrong_type_argument (Qframep
, frame
);
324 make_frame (bool mini_p
)
327 register struct frame
*f
;
328 register Lisp_Object root_window
;
329 register Lisp_Object mini_window
;
331 f
= allocate_frame ();
332 XSETFRAME (frame
, f
);
334 /* Initialize Lisp data. Note that allocate_frame initializes all
335 Lisp data to nil, so do it only for slots which should not be nil. */
336 fset_tool_bar_position (f
, Qtop
);
338 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
339 non-Lisp data, so do it only for slots which should not be zero.
340 To avoid subtle bugs and for the sake of readability, it's better to
341 initialize enum members explicitly even if their values are zero. */
342 f
->wants_modeline
= 1;
344 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
345 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
346 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
347 #ifdef HAVE_WINDOW_SYSTEM
348 f
->want_fullscreen
= FULLSCREEN_NONE
;
351 root_window
= make_window ();
354 mini_window
= make_window ();
355 wset_next (XWINDOW (root_window
), mini_window
);
356 wset_prev (XWINDOW (mini_window
), root_window
);
357 XWINDOW (mini_window
)->mini
= 1;
358 wset_frame (XWINDOW (mini_window
), frame
);
359 fset_minibuffer_window (f
, mini_window
);
364 wset_next (XWINDOW (root_window
), Qnil
);
365 fset_minibuffer_window (f
, Qnil
);
368 wset_frame (XWINDOW (root_window
), frame
);
371 just so that there is "something there."
372 Correct size will be set up later with change_frame_size. */
374 SET_FRAME_COLS (f
, 10);
375 FRAME_LINES (f
) = 10;
377 XWINDOW (root_window
)->total_cols
= 10;
378 XWINDOW (root_window
)->total_lines
= mini_p
? 9 : 10;
382 XWINDOW (mini_window
)->total_cols
= 10;
383 XWINDOW (mini_window
)->top_line
= 9;
384 XWINDOW (mini_window
)->total_lines
= 1;
387 /* Choose a buffer for the frame's root window. */
389 Lisp_Object buf
= Fcurrent_buffer ();
391 /* If current buffer is hidden, try to find another one. */
392 if (BUFFER_HIDDEN_P (XBUFFER (buf
)))
393 buf
= other_buffer_safely (buf
);
395 /* Use set_window_buffer, not Fset_window_buffer, and don't let
396 hooks be run by it. The reason is that the whole frame/window
397 arrangement is not yet fully initialized at this point. Windows
398 don't have the right size, glyph matrices aren't initialized
399 etc. Running Lisp functions at this point surely ends in a
401 set_window_buffer (root_window
, buf
, 0, 0);
402 fset_buffer_list (f
, list1 (buf
));
406 set_window_buffer (mini_window
,
407 (NILP (Vminibuffer_list
)
409 : Fcar (Vminibuffer_list
)),
412 fset_root_window (f
, root_window
);
413 fset_selected_window (f
, root_window
);
414 /* Make sure this window seems more recently used than
415 a newly-created, never-selected window. */
416 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
421 #ifdef HAVE_WINDOW_SYSTEM
422 /* Make a frame using a separate minibuffer window on another frame.
423 MINI_WINDOW is the minibuffer window to use. nil means use the
424 default (the global minibuffer). */
427 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
429 register struct frame
*f
;
432 if (!NILP (mini_window
))
433 CHECK_LIVE_WINDOW (mini_window
);
435 if (!NILP (mini_window
)
436 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
437 error ("Frame and minibuffer must be on the same terminal");
439 /* Make a frame containing just a root window. */
442 if (NILP (mini_window
))
444 /* Use default-minibuffer-frame if possible. */
445 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
446 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
448 Lisp_Object frame_dummy
;
450 XSETFRAME (frame_dummy
, f
);
451 GCPRO1 (frame_dummy
);
452 /* If there's no minibuffer frame to use, create one. */
453 kset_default_minibuffer_frame
454 (kb
, call1 (intern ("make-initial-minibuffer-frame"), display
));
459 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
462 fset_minibuffer_window (f
, mini_window
);
464 /* Make the chosen minibuffer window display the proper minibuffer,
465 unless it is already showing a minibuffer. */
466 if (NILP (Fmemq (XWINDOW (mini_window
)->contents
, Vminibuffer_list
)))
467 /* Use set_window_buffer instead of Fset_window_buffer (see
468 discussion of bug#11984, bug#12025, bug#12026). */
469 set_window_buffer (mini_window
,
470 (NILP (Vminibuffer_list
)
472 : Fcar (Vminibuffer_list
)), 0, 0);
476 /* Make a frame containing only a minibuffer window. */
479 make_minibuffer_frame (void)
481 /* First make a frame containing just a root window, no minibuffer. */
483 register struct frame
*f
= make_frame (0);
484 register Lisp_Object mini_window
;
485 register Lisp_Object frame
;
487 XSETFRAME (frame
, f
);
492 f
->wants_modeline
= 0;
494 /* Now label the root window as also being the minibuffer.
495 Avoid infinite looping on the window chain by marking next pointer
498 mini_window
= f
->root_window
;
499 fset_minibuffer_window (f
, mini_window
);
500 XWINDOW (mini_window
)->mini
= 1;
501 wset_next (XWINDOW (mini_window
), Qnil
);
502 wset_prev (XWINDOW (mini_window
), Qnil
);
503 wset_frame (XWINDOW (mini_window
), frame
);
505 /* Put the proper buffer in that window. */
507 /* Use set_window_buffer instead of Fset_window_buffer (see
508 discussion of bug#11984, bug#12025, bug#12026). */
509 set_window_buffer (mini_window
,
510 (NILP (Vminibuffer_list
)
512 : Fcar (Vminibuffer_list
)), 0, 0);
515 #endif /* HAVE_WINDOW_SYSTEM */
517 /* Construct a frame that refers to a terminal. */
519 static printmax_t tty_frame_count
;
522 make_initial_frame (void)
525 struct terminal
*terminal
;
528 eassert (initial_kboard
);
530 /* The first call must initialize Vframe_list. */
531 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
534 terminal
= init_initial_terminal ();
537 XSETFRAME (frame
, f
);
539 Vframe_list
= Fcons (frame
, Vframe_list
);
542 fset_name (f
, build_pure_c_string ("F1"));
544 SET_FRAME_VISIBLE (f
, 1);
546 f
->output_method
= terminal
->type
;
547 f
->terminal
= terminal
;
548 f
->terminal
->reference_count
++;
549 f
->output_data
.nothing
= 0;
551 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
552 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
554 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
556 /* The default value of menu-bar-mode is t. */
557 set_menu_bar_lines (f
, make_number (1), Qnil
);
560 init_frame_faces (f
);
562 last_nonminibuf_frame
= f
;
568 static struct frame
*
569 make_terminal_frame (struct terminal
*terminal
)
571 register struct frame
*f
;
573 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
576 error ("Terminal is not live, can't create new frames on it");
580 XSETFRAME (frame
, f
);
581 Vframe_list
= Fcons (frame
, Vframe_list
);
583 fset_name (f
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
585 SET_FRAME_VISIBLE (f
, 1);
587 f
->terminal
= terminal
;
588 f
->terminal
->reference_count
++;
590 f
->output_data
.tty
->display_info
= &the_only_display_info
;
591 if (!inhibit_window_system
592 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
593 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
594 f
->output_method
= output_msdos_raw
;
596 f
->output_method
= output_termcap
;
597 #else /* not MSDOS */
598 f
->output_method
= output_termcap
;
599 create_tty_output (f
);
600 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
601 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
602 #endif /* not MSDOS */
604 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
605 FRAME_MENU_BAR_LINES(f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
607 /* Set the top frame to the newly created frame. */
608 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
609 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
610 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f
)->top_frame
), 2); /* obscured */
612 FRAME_TTY (f
)->top_frame
= frame
;
615 init_frame_faces (f
);
620 /* Get a suitable value for frame parameter PARAMETER for a newly
621 created frame, based on (1) the user-supplied frame parameter
622 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
625 get_future_frame_param (Lisp_Object parameter
,
626 Lisp_Object supplied_parms
,
631 result
= Fassq (parameter
, supplied_parms
);
633 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
634 if (NILP (result
) && current_value
!= NULL
)
635 result
= build_string (current_value
);
636 if (!NILP (result
) && !STRINGP (result
))
637 result
= XCDR (result
);
638 if (NILP (result
) || !STRINGP (result
))
644 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
646 doc
: /* Create an additional terminal frame, possibly on another terminal.
647 This function takes one argument, an alist specifying frame parameters.
649 You can create multiple frames on a single text terminal, but only one
650 of them (the selected terminal frame) is actually displayed.
652 In practice, generally you don't need to specify any parameters,
653 except when you want to create a new frame on another terminal.
654 In that case, the `tty' parameter specifies the device file to open,
655 and the `tty-type' parameter specifies the terminal type. Example:
657 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
659 Note that changing the size of one terminal frame automatically
660 affects all frames on the same terminal device. */)
664 struct terminal
*t
= NULL
;
665 Lisp_Object frame
, tem
;
666 struct frame
*sf
= SELECTED_FRAME ();
669 if (sf
->output_method
!= output_msdos_raw
670 && sf
->output_method
!= output_termcap
)
672 #else /* not MSDOS */
674 #ifdef WINDOWSNT /* This should work now! */
675 if (sf
->output_method
!= output_termcap
)
676 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
678 #endif /* not MSDOS */
681 Lisp_Object terminal
;
683 terminal
= Fassq (Qterminal
, parms
);
684 if (CONSP (terminal
))
686 terminal
= XCDR (terminal
);
687 t
= get_terminal (terminal
, 1);
690 if (t
&& t
!= the_only_display_info
.terminal
)
691 /* msdos.c assumes a single tty_display_info object. */
692 error ("Multiple terminals are not supported on this platform");
694 t
= the_only_display_info
.terminal
;
700 char *name
= 0, *type
= 0;
701 Lisp_Object tty
, tty_type
;
703 tty
= get_future_frame_param
704 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
705 ? FRAME_TTY (XFRAME (selected_frame
))->name
708 name
= xlispstrdupa (tty
);
710 tty_type
= get_future_frame_param
711 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
712 ? FRAME_TTY (XFRAME (selected_frame
))->type
714 if (!NILP (tty_type
))
715 type
= xlispstrdupa (tty_type
);
717 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
720 f
= make_terminal_frame (t
);
724 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
725 change_frame_size (f
, height
, width
, 0, 0, 0);
728 adjust_frame_glyphs (f
);
730 XSETFRAME (frame
, f
);
732 store_in_alist (&parms
, Qtty_type
, build_string (t
->display_info
.tty
->type
));
733 store_in_alist (&parms
, Qtty
,
734 (t
->display_info
.tty
->name
735 ? build_string (t
->display_info
.tty
->name
)
737 Fmodify_frame_parameters (frame
, parms
);
739 /* Make the frame face alist be frame-specific, so that each
740 frame could change its face definitions independently. */
741 fset_face_alist (f
, Fcopy_alist (sf
->face_alist
));
742 /* Simple Fcopy_alist isn't enough, because we need the contents of
743 the vectors which are the CDRs of associations in face_alist to
744 be copied as well. */
745 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
746 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
751 /* Perform the switch to frame FRAME.
753 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
756 If TRACK is non-zero and the frame that currently has the focus
757 redirects its focus to the selected frame, redirect that focused
758 frame's focus to FRAME instead.
760 FOR_DELETION non-zero means that the selected frame is being
761 deleted, which includes the possibility that the frame's terminal
764 The value of NORECORD is passed as argument to Fselect_window. */
767 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
769 struct frame
*sf
= SELECTED_FRAME ();
771 /* If FRAME is a switch-frame event, extract the frame we should
774 && EQ (XCAR (frame
), Qswitch_frame
)
775 && CONSP (XCDR (frame
)))
776 frame
= XCAR (XCDR (frame
));
778 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
779 a switch-frame event to arrive after a frame is no longer live,
780 especially when deleting the initial frame during startup. */
782 if (! FRAME_LIVE_P (XFRAME (frame
)))
785 if (sf
== XFRAME (frame
))
788 /* This is too greedy; it causes inappropriate focus redirection
789 that's hard to get rid of. */
791 /* If a frame's focus has been redirected toward the currently
792 selected frame, we should change the redirection to point to the
793 newly selected frame. This means that if the focus is redirected
794 from a minibufferless frame to a surrogate minibuffer frame, we
795 can use `other-window' to switch between all the frames using
796 that minibuffer frame, and the focus redirection will follow us
802 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
806 if (!FRAMEP (XCAR (tail
)))
809 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
811 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
812 Fredirect_frame_focus (XCAR (tail
), frame
);
816 /* Instead, apply it only to the frame we're pointing to. */
817 #ifdef HAVE_WINDOW_SYSTEM
818 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
820 Lisp_Object focus
, xfocus
;
822 xfocus
= x_get_focus_frame (XFRAME (frame
));
825 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
826 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
827 Fredirect_frame_focus (xfocus
, frame
);
830 #endif /* HAVE_X_WINDOWS */
833 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
834 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
836 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
838 Lisp_Object top_frame
= FRAME_TTY (XFRAME (frame
))->top_frame
;
840 /* Don't mark the frame garbaged and/or obscured if we are
841 switching to the frame that is already the top frame of that
843 if (!EQ (frame
, top_frame
))
845 if (FRAMEP (top_frame
))
846 /* Mark previously displayed frame as now obscured. */
847 SET_FRAME_VISIBLE (XFRAME (top_frame
), 2);
848 SET_FRAME_VISIBLE (XFRAME (frame
), 1);
850 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
853 selected_frame
= frame
;
854 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
855 last_nonminibuf_frame
= XFRAME (selected_frame
);
857 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
859 /* We want to make sure that the next event generates a frame-switch
860 event to the appropriate frame. This seems kludgy to me, but
861 before you take it out, make sure that evaluating something like
862 (select-window (frame-root-window (new-frame))) doesn't end up
863 with your typing being interpreted in the new frame instead of
864 the one you're actually typing in. */
865 internal_last_event_frame
= Qnil
;
870 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
871 doc
: /* Select FRAME.
872 Subsequent editing commands apply to its selected window.
873 Optional argument NORECORD means to neither change the order of
874 recently selected windows nor the buffer list.
876 The selection of FRAME lasts until the next time the user does
877 something to select a different frame, or until the next time
878 this function is called. If you are using a window system, the
879 previously selected frame may be restored as the selected frame
880 when returning to the command loop, because it still may have
881 the window system's input focus. On a text terminal, the next
882 redisplay will display FRAME.
884 This function returns FRAME, or nil if FRAME has been deleted. */)
885 (Lisp_Object frame
, Lisp_Object norecord
)
887 return do_switch_frame (frame
, 1, 0, norecord
);
890 DEFUN ("handle-focus-in", Fhandle_focus_in
, Shandle_focus_in
, 1, 1, "e",
891 doc
: /* Handle a focus-in event.
892 Focus in events are usually bound to this function.
893 Focus in events occur when a frame has focus, but a switch-frame event
895 This function runs the hook `focus-in-hook'.
896 It also checks if blink-cursor timers should be turned on again. */)
899 Frun_hooks (1, &Qfocus_in_hook
);
900 return call0 (intern ("blink-cursor-check"));
903 DEFUN ("handle-focus-out", Fhandle_focus_out
, Shandle_focus_out
, 1, 1, "e",
904 doc
: /* Handle a focus-out event.
905 Focus out events are usually bound to this function.
906 Focus out events occur when no frame has focus.
907 This function runs the hook `focus-out-hook'.
908 It also checks if blink-cursor timers should be turned off. */)
911 Frun_hooks (1, &Qfocus_out_hook
);
912 return call0 (intern ("blink-cursor-suspend"));
915 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
916 doc
: /* Handle a switch-frame event EVENT.
917 Switch-frame events are usually bound to this function.
918 A switch-frame event tells Emacs that the window manager has requested
919 that the user's events be directed to the frame mentioned in the event.
920 This function selects the selected window of the frame of EVENT.
922 If EVENT is frame object, handle it as if it were a switch-frame event
926 /* Preserve prefix arg that the command loop just cleared. */
927 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
928 Frun_hooks (1, &Qmouse_leave_buffer_hook
);
929 Fhandle_focus_in (event
); // switch-frame implies a focus in.
930 return do_switch_frame (event
, 0, 0, Qnil
);
933 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
934 doc
: /* Return the frame that is now selected. */)
937 return selected_frame
;
940 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
942 doc
: /* Return a list of all live frames. */)
946 frames
= Fcopy_sequence (Vframe_list
);
947 #ifdef HAVE_WINDOW_SYSTEM
948 if (FRAMEP (tip_frame
))
949 frames
= Fdelq (tip_frame
, frames
);
954 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
955 same tty (for tty frames) or among frames which uses FRAME's keyboard.
956 If MINIBUF is nil, do not consider minibuffer-only candidate.
957 If MINIBUF is `visible', do not consider an invisible candidate.
958 If MINIBUF is a window, consider only its own frame and candidate now
959 using that window as the minibuffer.
960 If MINIBUF is 0, consider candidate if it is visible or iconified.
961 Otherwise consider any candidate and return nil if CANDIDATE is not
965 candidate_frame (Lisp_Object candidate
, Lisp_Object frame
, Lisp_Object minibuf
)
967 struct frame
*c
= XFRAME (candidate
), *f
= XFRAME (frame
);
969 if ((!FRAME_TERMCAP_P (c
) && !FRAME_TERMCAP_P (f
)
970 && FRAME_KBOARD (c
) == FRAME_KBOARD (f
))
971 || (FRAME_TERMCAP_P (c
) && FRAME_TERMCAP_P (f
)
972 && FRAME_TTY (c
) == FRAME_TTY (f
)))
976 if (!FRAME_MINIBUF_ONLY_P (c
))
979 else if (EQ (minibuf
, Qvisible
))
981 if (FRAME_VISIBLE_P (c
))
984 else if (WINDOWP (minibuf
))
986 if (EQ (FRAME_MINIBUF_WINDOW (c
), minibuf
)
987 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), candidate
)
988 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
989 FRAME_FOCUS_FRAME (c
)))
992 else if (XFASTINT (minibuf
) == 0)
994 if (FRAME_VISIBLE_P (c
) || FRAME_ICONIFIED_P (c
))
1003 /* Return the next frame in the frame list after FRAME. */
1006 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1008 Lisp_Object f
, tail
;
1011 /* There must always be at least one frame in Vframe_list. */
1012 eassert (CONSP (Vframe_list
));
1015 FOR_EACH_FRAME (tail
, f
)
1019 f
= candidate_frame (f
, frame
, minibuf
);
1029 /* Return the previous frame in the frame list before FRAME. */
1032 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1034 Lisp_Object f
, tail
, prev
= Qnil
;
1036 /* There must always be at least one frame in Vframe_list. */
1037 eassert (CONSP (Vframe_list
));
1039 FOR_EACH_FRAME (tail
, f
)
1041 if (EQ (frame
, f
) && !NILP (prev
))
1043 f
= candidate_frame (f
, frame
, minibuf
);
1048 /* We've scanned the entire list. */
1050 /* We went through the whole frame list without finding a single
1051 acceptable frame. Return the original frame. */
1054 /* There were no acceptable frames in the list before FRAME; otherwise,
1055 we would have returned directly from the loop. Since PREV is the last
1056 acceptable frame in the list, return it. */
1061 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1062 doc
: /* Return the next frame in the frame list after FRAME.
1063 It considers only frames on the same terminal as FRAME.
1064 By default, skip minibuffer-only frames.
1065 If omitted, FRAME defaults to the selected frame.
1066 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1067 If MINIFRAME is a window, include only its own frame
1068 and any frame now using that window as the minibuffer.
1069 If MINIFRAME is `visible', include all visible frames.
1070 If MINIFRAME is 0, include all visible and iconified frames.
1071 Otherwise, include all frames. */)
1072 (Lisp_Object frame
, Lisp_Object miniframe
)
1075 frame
= selected_frame
;
1076 CHECK_LIVE_FRAME (frame
);
1077 return next_frame (frame
, miniframe
);
1080 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1081 doc
: /* Return the previous frame in the frame list before FRAME.
1082 It considers only frames on the same terminal as FRAME.
1083 By default, skip minibuffer-only frames.
1084 If omitted, FRAME defaults to the selected frame.
1085 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1086 If MINIFRAME is a window, include only its own frame
1087 and any frame now using that window as the minibuffer.
1088 If MINIFRAME is `visible', include all visible frames.
1089 If MINIFRAME is 0, include all visible and iconified frames.
1090 Otherwise, include all frames. */)
1091 (Lisp_Object frame
, Lisp_Object miniframe
)
1094 frame
= selected_frame
;
1095 CHECK_LIVE_FRAME (frame
);
1096 return prev_frame (frame
, miniframe
);
1099 DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame
,
1100 Slast_nonminibuf_frame
, 0, 0, 0,
1101 doc
: /* Return last non-minibuffer frame selected. */)
1104 Lisp_Object frame
= Qnil
;
1106 if (last_nonminibuf_frame
)
1107 XSETFRAME (frame
, last_nonminibuf_frame
);
1112 /* Return 1 if it is ok to delete frame F;
1113 0 if all frames aside from F are invisible.
1114 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1117 other_visible_frames (struct frame
*f
)
1119 Lisp_Object frames
, this;
1121 FOR_EACH_FRAME (frames
, this)
1123 if (f
== XFRAME (this))
1126 /* Verify that we can still talk to the frame's X window,
1127 and note any recent change in visibility. */
1128 #ifdef HAVE_X_WINDOWS
1129 if (FRAME_WINDOW_P (XFRAME (this)))
1130 x_sync (XFRAME (this));
1133 if (FRAME_VISIBLE_P (XFRAME (this))
1134 || FRAME_ICONIFIED_P (XFRAME (this))
1135 /* Allow deleting the terminal frame when at least one X
1137 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1143 /* Make sure that minibuf_window doesn't refer to FRAME's minibuffer
1144 window. Preferably use the selected frame's minibuffer window
1145 instead. If the selected frame doesn't have one, get some other
1146 frame's minibuffer window. SELECT non-zero means select the new
1147 minibuffer window. */
1149 check_minibuf_window (Lisp_Object frame
, int select
)
1151 struct frame
*f
= decode_live_frame (frame
);
1153 XSETFRAME (frame
, f
);
1155 if (WINDOWP (minibuf_window
) && EQ (f
->minibuffer_window
, minibuf_window
))
1157 Lisp_Object frames
, this, window
= make_number (0);
1159 if (!EQ (frame
, selected_frame
)
1160 && FRAME_HAS_MINIBUF_P (XFRAME (selected_frame
)))
1161 window
= FRAME_MINIBUF_WINDOW (XFRAME (selected_frame
));
1163 FOR_EACH_FRAME (frames
, this)
1165 if (!EQ (this, frame
) && FRAME_HAS_MINIBUF_P (XFRAME (this)))
1167 window
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1172 /* Don't abort if no window was found (Bug#15247). */
1173 if (WINDOWP (window
))
1175 /* Use set_window_buffer instead of Fset_window_buffer (see
1176 discussion of bug#11984, bug#12025, bug#12026). */
1177 set_window_buffer (window
, XWINDOW (minibuf_window
)->contents
, 0, 0);
1178 minibuf_window
= window
;
1180 /* SELECT non-zero usually means that FRAME's minibuffer
1181 window was selected; select the new one. */
1183 Fselect_window (minibuf_window
, Qnil
);
1189 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1190 unconditionally. x_connection_closed and delete_terminal use
1191 this. Any other value of FORCE implements the semantics
1192 described for Fdelete_frame. */
1194 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1196 struct frame
*f
= decode_any_frame (frame
);
1200 int minibuffer_selected
, is_tooltip_frame
;
1202 if (! FRAME_LIVE_P (f
))
1205 if (NILP (force
) && !other_visible_frames (f
))
1206 error ("Attempt to delete the sole visible or iconified frame");
1208 /* x_connection_closed must have set FORCE to `noelisp' in order
1209 to delete the last frame, if it is gone. */
1210 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1211 error ("Attempt to delete the only frame");
1213 XSETFRAME (frame
, f
);
1215 /* Does this frame have a minibuffer, and is it the surrogate
1216 minibuffer for any other frame? */
1217 if (FRAME_HAS_MINIBUF_P (f
))
1219 Lisp_Object frames
, this;
1221 FOR_EACH_FRAME (frames
, this)
1225 if (EQ (this, frame
))
1228 fminiw
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1230 if (WINDOWP (fminiw
) && EQ (frame
, WINDOW_FRAME (XWINDOW (fminiw
))))
1232 /* If we MUST delete this frame, delete the other first.
1233 But do this only if FORCE equals `noelisp'. */
1234 if (EQ (force
, Qnoelisp
))
1235 delete_frame (this, Qnoelisp
);
1237 error ("Attempt to delete a surrogate minibuffer frame");
1242 is_tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1244 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1245 frame is a tooltip. FORCE is set to `noelisp' when handling
1246 a disconnect from the terminal, so we don't dare call Lisp
1248 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1250 else if (EQ (force
, Qnoelisp
))
1252 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1256 #ifdef HAVE_X_WINDOWS
1257 /* Also, save clipboard to the clipboard manager. */
1258 x_clipboard_manager_save_frame (frame
);
1261 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1264 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1265 if (! FRAME_LIVE_P (f
))
1268 /* At this point, we are committed to deleting the frame.
1269 There is no more chance for errors to prevent it. */
1271 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1272 sf
= SELECTED_FRAME ();
1273 /* Don't let the frame remain selected. */
1277 Lisp_Object frame1
= Qnil
;
1279 /* Look for another visible frame on the same terminal.
1280 Do not call next_frame here because it may loop forever.
1281 See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15025. */
1282 FOR_EACH_FRAME (tail
, frame1
)
1283 if (!EQ (frame
, frame1
)
1284 && (FRAME_TERMINAL (XFRAME (frame
))
1285 == FRAME_TERMINAL (XFRAME (frame1
)))
1286 && FRAME_VISIBLE_P (XFRAME (frame1
)))
1289 /* If there is none, find *some* other frame. */
1290 if (NILP (frame1
) || EQ (frame1
, frame
))
1292 FOR_EACH_FRAME (tail
, frame1
)
1294 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1296 /* Do not change a text terminal's top-frame. */
1297 struct frame
*f1
= XFRAME (frame1
);
1298 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1300 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1301 if (!EQ (top_frame
, frame
))
1308 #ifdef NS_IMPL_COCOA
1310 /* Under NS, there is no system mechanism for choosing a new
1311 window to get focus -- it is left to application code.
1312 So the portion of THIS application interfacing with NS
1313 needs to know about it. We call Fraise_frame, but the
1314 purpose is really to transfer focus. */
1315 Fraise_frame (frame1
);
1318 do_switch_frame (frame1
, 0, 1, Qnil
);
1319 sf
= SELECTED_FRAME ();
1322 /* Don't allow minibuf_window to remain on a deleted frame. */
1323 check_minibuf_window (frame
, minibuffer_selected
);
1325 /* Don't let echo_area_window to remain on a deleted frame. */
1326 if (EQ (f
->minibuffer_window
, echo_area_window
))
1327 echo_area_window
= sf
->minibuffer_window
;
1329 /* Clear any X selections for this frame. */
1330 #ifdef HAVE_X_WINDOWS
1332 x_clear_frame_selections (f
);
1336 This function must be called before the window tree of the
1337 frame is deleted because windows contain dynamically allocated
1341 #ifdef HAVE_WINDOW_SYSTEM
1342 /* Give chance to each font driver to free a frame specific data. */
1343 font_update_drivers (f
, Qnil
);
1346 /* Mark all the windows that used to be on FRAME as deleted, and then
1347 remove the reference to them. */
1348 delete_all_child_windows (f
->root_window
);
1349 fset_root_window (f
, Qnil
);
1351 Vframe_list
= Fdelq (frame
, Vframe_list
);
1352 SET_FRAME_VISIBLE (f
, 0);
1354 /* Allow the vector of menu bar contents to be freed in the next
1355 garbage collection. The frame object itself may not be garbage
1356 collected until much later, because recent_keys and other data
1357 structures can still refer to it. */
1358 fset_menu_bar_vector (f
, Qnil
);
1360 /* If FRAME's buffer lists contains killed
1361 buffers, this helps GC to reclaim them. */
1362 fset_buffer_list (f
, Qnil
);
1363 fset_buried_buffer_list (f
, Qnil
);
1365 free_font_driver_list (f
);
1367 xfree (f
->decode_mode_spec_buffer
);
1368 xfree (FRAME_INSERT_COST (f
));
1369 xfree (FRAME_DELETEN_COST (f
));
1370 xfree (FRAME_INSERTN_COST (f
));
1371 xfree (FRAME_DELETE_COST (f
));
1373 /* Since some events are handled at the interrupt level, we may get
1374 an event for f at any time; if we zero out the frame's terminal
1375 now, then we may trip up the event-handling code. Instead, we'll
1376 promise that the terminal of the frame must be valid until we
1377 have called the window-system-dependent frame destruction
1383 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1384 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1385 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1386 f
->output_data
.nothing
= 0;
1387 f
->terminal
= 0; /* Now the frame is dead. */
1390 /* If needed, delete the terminal that this frame was on.
1391 (This must be done after the frame is killed.) */
1392 terminal
->reference_count
--;
1394 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1396 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1397 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1398 terminal
->reference_count
= 1;
1399 #endif /* USE_GTK */
1400 if (terminal
->reference_count
== 0)
1403 XSETTERMINAL (tmp
, terminal
);
1406 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1409 kb
= terminal
->kboard
;
1412 /* If we've deleted the last_nonminibuf_frame, then try to find
1414 if (f
== last_nonminibuf_frame
)
1416 Lisp_Object frames
, this;
1418 last_nonminibuf_frame
= 0;
1420 FOR_EACH_FRAME (frames
, this)
1423 if (!FRAME_MINIBUF_ONLY_P (f
))
1425 last_nonminibuf_frame
= f
;
1431 /* If there's no other frame on the same kboard, get out of
1432 single-kboard state if we're in it for this kboard. */
1435 Lisp_Object frames
, this;
1436 /* Some frame we found on the same kboard, or nil if there are none. */
1437 Lisp_Object frame_on_same_kboard
= Qnil
;
1439 FOR_EACH_FRAME (frames
, this)
1440 if (kb
== FRAME_KBOARD (XFRAME (this)))
1441 frame_on_same_kboard
= this;
1443 if (NILP (frame_on_same_kboard
))
1444 not_single_kboard_state (kb
);
1448 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1449 find another one. Prefer minibuffer-only frames, but also notice
1450 frames with other windows. */
1451 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1453 Lisp_Object frames
, this;
1455 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1456 Lisp_Object frame_with_minibuf
= Qnil
;
1457 /* Some frame we found on the same kboard, or nil if there are none. */
1458 Lisp_Object frame_on_same_kboard
= Qnil
;
1460 FOR_EACH_FRAME (frames
, this)
1462 struct frame
*f1
= XFRAME (this);
1464 /* Consider only frames on the same kboard
1465 and only those with minibuffers. */
1466 if (kb
== FRAME_KBOARD (f1
)
1467 && FRAME_HAS_MINIBUF_P (f1
))
1469 frame_with_minibuf
= this;
1470 if (FRAME_MINIBUF_ONLY_P (f1
))
1474 if (kb
== FRAME_KBOARD (f1
))
1475 frame_on_same_kboard
= this;
1478 if (!NILP (frame_on_same_kboard
))
1480 /* We know that there must be some frame with a minibuffer out
1481 there. If this were not true, all of the frames present
1482 would have to be minibufferless, which implies that at some
1483 point their minibuffer frames must have been deleted, but
1484 that is prohibited at the top; you can't delete surrogate
1485 minibuffer frames. */
1486 if (NILP (frame_with_minibuf
))
1489 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
1492 /* No frames left on this kboard--say no minibuffer either. */
1493 kset_default_minibuffer_frame (kb
, Qnil
);
1496 /* Cause frame titles to update--necessary if we now have just one frame. */
1497 if (!is_tooltip_frame
)
1498 update_mode_lines
= 15;
1503 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1504 doc
: /* Delete FRAME, permanently eliminating it from use.
1505 FRAME defaults to the selected frame.
1507 A frame may not be deleted if its minibuffer is used by other frames.
1508 Normally, you may not delete a frame if all other frames are invisible,
1509 but if the second optional argument FORCE is non-nil, you may do so.
1511 This function runs `delete-frame-functions' before actually
1512 deleting the frame, unless the frame is a tooltip.
1513 The functions are run with one argument, the frame to be deleted. */)
1514 (Lisp_Object frame
, Lisp_Object force
)
1516 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1520 /* Return mouse position in character cell units. */
1522 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1523 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1524 The position is given in character cells, where (0, 0) is the
1525 upper-left corner of the frame, X is the horizontal offset, and Y is
1526 the vertical offset.
1527 If Emacs is running on a mouseless terminal or hasn't been programmed
1528 to read the mouse position, it returns the selected frame for FRAME
1529 and nil for X and Y.
1530 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1531 passing the normal return value to that function as an argument,
1532 and returns whatever that function returns. */)
1536 Lisp_Object lispy_dummy
;
1537 Lisp_Object x
, y
, retval
;
1538 struct gcpro gcpro1
;
1540 f
= SELECTED_FRAME ();
1543 /* It's okay for the hook to refrain from storing anything. */
1544 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1546 enum scroll_bar_part party_dummy
;
1548 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1549 &lispy_dummy
, &party_dummy
,
1558 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1562 XSETFRAME (lispy_dummy
, f
);
1563 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1565 if (!NILP (Vmouse_position_function
))
1566 retval
= call1 (Vmouse_position_function
, retval
);
1567 RETURN_UNGCPRO (retval
);
1570 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1571 Smouse_pixel_position
, 0, 0, 0,
1572 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1573 The position is given in pixel units, where (0, 0) is the
1574 upper-left corner of the frame, X is the horizontal offset, and Y is
1575 the vertical offset.
1576 If Emacs is running on a mouseless terminal or hasn't been programmed
1577 to read the mouse position, it returns the selected frame for FRAME
1578 and nil for X and Y. */)
1582 Lisp_Object lispy_dummy
;
1585 f
= SELECTED_FRAME ();
1588 /* It's okay for the hook to refrain from storing anything. */
1589 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1591 enum scroll_bar_part party_dummy
;
1593 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1594 &lispy_dummy
, &party_dummy
,
1599 XSETFRAME (lispy_dummy
, f
);
1600 return Fcons (lispy_dummy
, Fcons (x
, y
));
1603 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1604 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1605 Coordinates are relative to the frame, not a window,
1606 so the coordinates of the top left character in the frame
1607 may be nonzero due to left-hand scroll bars or the menu bar.
1609 The position is given in character cells, where (0, 0) is the
1610 upper-left corner of the frame, X is the horizontal offset, and Y is
1611 the vertical offset.
1613 This function is a no-op for an X frame that is not visible.
1614 If you have just created a frame, you must wait for it to become visible
1615 before calling this function on it, like this.
1616 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1617 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1619 CHECK_LIVE_FRAME (frame
);
1620 CHECK_TYPE_RANGED_INTEGER (int, x
);
1621 CHECK_TYPE_RANGED_INTEGER (int, y
);
1623 /* I think this should be done with a hook. */
1624 #ifdef HAVE_WINDOW_SYSTEM
1625 if (FRAME_WINDOW_P (XFRAME (frame
)))
1626 /* Warping the mouse will cause enternotify and focus events. */
1627 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1630 if (FRAME_MSDOS_P (XFRAME (frame
)))
1632 Fselect_frame (frame
, Qnil
);
1633 mouse_moveto (XINT (x
), XINT (y
));
1638 Fselect_frame (frame
, Qnil
);
1639 term_mouse_moveto (XINT (x
), XINT (y
));
1648 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1649 Sset_mouse_pixel_position
, 3, 3, 0,
1650 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1651 The position is given in pixels, where (0, 0) is the upper-left corner
1652 of the frame, X is the horizontal offset, and Y is the vertical offset.
1654 Note, this is a no-op for an X frame that is not visible.
1655 If you have just created a frame, you must wait for it to become visible
1656 before calling this function on it, like this.
1657 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1658 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1660 CHECK_LIVE_FRAME (frame
);
1661 CHECK_TYPE_RANGED_INTEGER (int, x
);
1662 CHECK_TYPE_RANGED_INTEGER (int, y
);
1664 /* I think this should be done with a hook. */
1665 #ifdef HAVE_WINDOW_SYSTEM
1666 if (FRAME_WINDOW_P (XFRAME (frame
)))
1667 /* Warping the mouse will cause enternotify and focus events. */
1668 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1671 if (FRAME_MSDOS_P (XFRAME (frame
)))
1673 Fselect_frame (frame
, Qnil
);
1674 mouse_moveto (XINT (x
), XINT (y
));
1679 Fselect_frame (frame
, Qnil
);
1680 term_mouse_moveto (XINT (x
), XINT (y
));
1689 static void make_frame_visible_1 (Lisp_Object
);
1691 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1693 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1694 If omitted, FRAME defaults to the currently selected frame. */)
1697 struct frame
*f
= decode_live_frame (frame
);
1699 /* I think this should be done with a hook. */
1700 #ifdef HAVE_WINDOW_SYSTEM
1701 if (FRAME_WINDOW_P (f
))
1702 x_make_frame_visible (f
);
1705 make_frame_visible_1 (f
->root_window
);
1707 /* Make menu bar update for the Buffers and Frames menus. */
1708 windows_or_buffers_changed
= 15;
1710 XSETFRAME (frame
, f
);
1714 /* Update the display_time slot of the buffers shown in WINDOW
1715 and all its descendants. */
1718 make_frame_visible_1 (Lisp_Object window
)
1722 for (; !NILP (window
); window
= w
->next
)
1724 w
= XWINDOW (window
);
1725 if (WINDOWP (w
->contents
))
1726 make_frame_visible_1 (w
->contents
);
1728 bset_display_time (XBUFFER (w
->contents
), Fcurrent_time ());
1732 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1734 doc
: /* Make the frame FRAME invisible.
1735 If omitted, FRAME defaults to the currently selected frame.
1736 On graphical displays, invisible frames are not updated and are
1737 usually not displayed at all, even in a window system's \"taskbar\".
1739 Normally you may not make FRAME invisible if all other frames are invisible,
1740 but if the second optional argument FORCE is non-nil, you may do so.
1742 This function has no effect on text terminal frames. Such frames are
1743 always considered visible, whether or not they are currently being
1744 displayed in the terminal. */)
1745 (Lisp_Object frame
, Lisp_Object force
)
1747 struct frame
*f
= decode_live_frame (frame
);
1749 if (NILP (force
) && !other_visible_frames (f
))
1750 error ("Attempt to make invisible the sole visible or iconified frame");
1752 /* Don't allow minibuf_window to remain on an invisible frame. */
1753 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
1755 /* I think this should be done with a hook. */
1756 #ifdef HAVE_WINDOW_SYSTEM
1757 if (FRAME_WINDOW_P (f
))
1758 x_make_frame_invisible (f
);
1761 /* Make menu bar update for the Buffers and Frames menus. */
1762 windows_or_buffers_changed
= 16;
1767 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1769 doc
: /* Make the frame FRAME into an icon.
1770 If omitted, FRAME defaults to the currently selected frame. */)
1773 struct frame
*f
= decode_live_frame (frame
);
1775 /* Don't allow minibuf_window to remain on an iconified frame. */
1776 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
1778 /* I think this should be done with a hook. */
1779 #ifdef HAVE_WINDOW_SYSTEM
1780 if (FRAME_WINDOW_P (f
))
1781 x_iconify_frame (f
);
1784 /* Make menu bar update for the Buffers and Frames menus. */
1785 windows_or_buffers_changed
= 17;
1790 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1792 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
1793 Return the symbol `icon' if FRAME is iconified or \"minimized\".
1794 Return nil if FRAME was made invisible, via `make-frame-invisible'.
1795 On graphical displays, invisible frames are not updated and are
1796 usually not displayed at all, even in a window system's \"taskbar\".
1798 If FRAME is a text terminal frame, this always returns t.
1799 Such frames are always considered visible, whether or not they are
1800 currently being displayed on the terminal. */)
1803 CHECK_LIVE_FRAME (frame
);
1805 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1807 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1812 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1814 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1817 Lisp_Object tail
, frame
, value
= Qnil
;
1819 FOR_EACH_FRAME (tail
, frame
)
1820 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1821 value
= Fcons (frame
, value
);
1827 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1828 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1829 If FRAME is invisible or iconified, make it visible.
1830 If you don't specify a frame, the selected frame is used.
1831 If Emacs is displaying on an ordinary terminal or some other device which
1832 doesn't support multiple overlapping frames, this function selects FRAME. */)
1835 struct frame
*f
= decode_live_frame (frame
);
1837 XSETFRAME (frame
, f
);
1839 if (FRAME_TERMCAP_P (f
))
1840 /* On a text terminal select FRAME. */
1841 Fselect_frame (frame
, Qnil
);
1843 /* Do like the documentation says. */
1844 Fmake_frame_visible (frame
);
1846 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1847 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
1852 /* Should we have a corresponding function called Flower_Power? */
1853 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1854 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1855 If you don't specify a frame, the selected frame is used.
1856 If Emacs is displaying on an ordinary terminal or some other device which
1857 doesn't support multiple overlapping frames, this function does nothing. */)
1860 struct frame
*f
= decode_live_frame (frame
);
1862 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
1863 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
1869 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1871 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1872 In other words, switch-frame events caused by events in FRAME will
1873 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1874 FOCUS-FRAME after reading an event typed at FRAME.
1876 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
1877 frame again receives its own keystrokes.
1879 Focus redirection is useful for temporarily redirecting keystrokes to
1880 a surrogate minibuffer frame when a frame doesn't have its own
1883 A frame's focus redirection can be changed by `select-frame'. If frame
1884 FOO is selected, and then a different frame BAR is selected, any
1885 frames redirecting their focus to FOO are shifted to redirect their
1886 focus to BAR. This allows focus redirection to work properly when the
1887 user switches from one frame to another using `select-window'.
1889 This means that a frame whose focus is redirected to itself is treated
1890 differently from a frame whose focus is redirected to nil; the former
1891 is affected by `select-frame', while the latter is not.
1893 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1894 (Lisp_Object frame
, Lisp_Object focus_frame
)
1896 /* Note that we don't check for a live frame here. It's reasonable
1897 to redirect the focus of a frame you're about to delete, if you
1898 know what other frame should receive those keystrokes. */
1899 struct frame
*f
= decode_any_frame (frame
);
1901 if (! NILP (focus_frame
))
1902 CHECK_LIVE_FRAME (focus_frame
);
1904 fset_focus_frame (f
, focus_frame
);
1906 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
1907 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
1913 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 0, 1, 0,
1914 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1915 If FRAME is omitted or nil, the selected frame is used.
1916 Return nil if FRAME's focus is not redirected.
1917 See `redirect-frame-focus'. */)
1920 return FRAME_FOCUS_FRAME (decode_live_frame (frame
));
1923 DEFUN ("x-focus-frame", Fx_focus_frame
, Sx_focus_frame
, 1, 1, 0,
1924 doc
: /* Set the input focus to FRAME.
1925 FRAME nil means use the selected frame.
1926 If there is no window system support, this function does nothing. */)
1929 #ifdef HAVE_WINDOW_SYSTEM
1930 x_focus_frame (decode_window_system_frame (frame
));
1936 /* Return the value of frame parameter PROP in frame FRAME. */
1938 #ifdef HAVE_WINDOW_SYSTEM
1939 #if !HAVE_NS && !defined (WINDOWSNT)
1943 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
1945 register Lisp_Object tem
;
1947 tem
= Fassq (prop
, frame
->param_alist
);
1954 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
1957 frames_discard_buffer (Lisp_Object buffer
)
1959 Lisp_Object frame
, tail
;
1961 FOR_EACH_FRAME (tail
, frame
)
1964 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
1965 fset_buried_buffer_list
1966 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
1970 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1971 If the alist already has an element for PROP, we change it. */
1974 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
1976 register Lisp_Object tem
;
1978 tem
= Fassq (prop
, *alistptr
);
1980 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1986 frame_name_fnn_p (char *str
, ptrdiff_t len
)
1988 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
1991 while ('0' <= *p
&& *p
<= '9')
1999 /* Set the name of the terminal frame. Also used by MSDOS frames.
2000 Modeled after x_set_name which is used for WINDOW frames. */
2003 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2005 f
->explicit_name
= ! NILP (name
);
2007 /* If NAME is nil, set the name to F<num>. */
2010 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
2012 /* Check for no change needed in this very common case
2013 before we do any consing. */
2014 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
2017 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
2021 CHECK_STRING (name
);
2023 /* Don't change the name if it's already NAME. */
2024 if (! NILP (Fstring_equal (name
, f
->name
)))
2027 /* Don't allow the user to set the frame name to F<num>, so it
2028 doesn't clash with the names we generate for terminal frames. */
2029 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2030 error ("Frame names of the form F<num> are usurped by Emacs");
2033 fset_name (f
, name
);
2034 update_mode_lines
= 16;
2038 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2040 register Lisp_Object old_alist_elt
;
2042 /* The buffer-list parameters are stored in a special place and not
2043 in the alist. All buffers must be live. */
2044 if (EQ (prop
, Qbuffer_list
))
2046 Lisp_Object list
= Qnil
;
2047 for (; CONSP (val
); val
= XCDR (val
))
2048 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2049 list
= Fcons (XCAR (val
), list
);
2050 fset_buffer_list (f
, Fnreverse (list
));
2053 if (EQ (prop
, Qburied_buffer_list
))
2055 Lisp_Object list
= Qnil
;
2056 for (; CONSP (val
); val
= XCDR (val
))
2057 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2058 list
= Fcons (XCAR (val
), list
);
2059 fset_buried_buffer_list (f
, Fnreverse (list
));
2063 /* If PROP is a symbol which is supposed to have frame-local values,
2064 and it is set up based on this frame, switch to the global
2065 binding. That way, we can create or alter the frame-local binding
2066 without messing up the symbol's status. */
2069 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2071 switch (sym
->redirect
)
2073 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2074 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2075 case SYMBOL_LOCALIZED
:
2076 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2077 if (blv
->frame_local
&& blv_found (blv
) && XFRAME (blv
->where
) == f
)
2078 swap_in_global_binding (sym
);
2081 default: emacs_abort ();
2085 /* The tty color needed to be set before the frame's parameter
2086 alist was updated with the new value. This is not true any more,
2087 but we still do this test early on. */
2088 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2089 && f
== FRAME_TTY (f
)->previous_frame
)
2090 /* Force redisplay of this tty. */
2091 FRAME_TTY (f
)->previous_frame
= NULL
;
2093 /* Update the frame parameter alist. */
2094 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2095 if (EQ (old_alist_elt
, Qnil
))
2096 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2098 Fsetcdr (old_alist_elt
, val
);
2100 /* Update some other special parameters in their special places
2101 in addition to the alist. */
2103 if (EQ (prop
, Qbuffer_predicate
))
2104 fset_buffer_predicate (f
, val
);
2106 if (! FRAME_WINDOW_P (f
))
2108 if (EQ (prop
, Qmenu_bar_lines
))
2109 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2110 else if (EQ (prop
, Qname
))
2111 set_term_frame_name (f
, val
);
2114 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2116 if (! MINI_WINDOW_P (XWINDOW (val
)))
2117 error ("Surrogate minibuffer windows must be minibuffer windows");
2119 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2120 && !EQ (val
, f
->minibuffer_window
))
2121 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2123 /* Install the chosen minibuffer window, with proper buffer. */
2124 fset_minibuffer_window (f
, val
);
2128 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2129 doc
: /* Return the parameters-alist of frame FRAME.
2130 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2131 The meaningful PARMs depend on the kind of frame.
2132 If FRAME is omitted or nil, return information on the currently selected frame. */)
2136 struct frame
*f
= decode_any_frame (frame
);
2138 struct gcpro gcpro1
;
2140 if (!FRAME_LIVE_P (f
))
2143 alist
= Fcopy_alist (f
->param_alist
);
2146 if (!FRAME_WINDOW_P (f
))
2148 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2149 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2152 /* If the frame's parameter alist says the colors are
2153 unspecified and reversed, take the frame's background pixel
2154 for foreground and vice versa. */
2155 elt
= Fassq (Qforeground_color
, alist
);
2156 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2158 if (strncmp (SSDATA (XCDR (elt
)),
2160 SCHARS (XCDR (elt
))) == 0)
2161 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2162 else if (strncmp (SSDATA (XCDR (elt
)),
2164 SCHARS (XCDR (elt
))) == 0)
2165 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2168 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2169 elt
= Fassq (Qbackground_color
, alist
);
2170 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2172 if (strncmp (SSDATA (XCDR (elt
)),
2174 SCHARS (XCDR (elt
))) == 0)
2175 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2176 else if (strncmp (SSDATA (XCDR (elt
)),
2178 SCHARS (XCDR (elt
))) == 0)
2179 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2182 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2183 store_in_alist (&alist
, intern ("font"),
2184 build_string (FRAME_MSDOS_P (f
)
2186 : FRAME_W32_P (f
) ? "w32term"
2189 store_in_alist (&alist
, Qname
, f
->name
);
2190 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2191 store_in_alist (&alist
, Qheight
, make_number (height
));
2192 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2193 store_in_alist (&alist
, Qwidth
, make_number (width
));
2194 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2195 store_in_alist (&alist
, Qminibuffer
,
2196 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2197 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2198 : FRAME_MINIBUF_WINDOW (f
)));
2199 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2200 store_in_alist (&alist
, Qbuffer_list
, f
->buffer_list
);
2201 store_in_alist (&alist
, Qburied_buffer_list
, f
->buried_buffer_list
);
2203 /* I think this should be done with a hook. */
2204 #ifdef HAVE_WINDOW_SYSTEM
2205 if (FRAME_WINDOW_P (f
))
2206 x_report_frame_params (f
, &alist
);
2210 /* This ought to be correct in f->param_alist for an X frame. */
2212 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2213 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2221 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2222 doc
: /* Return FRAME's value for parameter PARAMETER.
2223 If FRAME is nil, describe the currently selected frame. */)
2224 (Lisp_Object frame
, Lisp_Object parameter
)
2226 struct frame
*f
= decode_any_frame (frame
);
2227 Lisp_Object value
= Qnil
;
2229 CHECK_SYMBOL (parameter
);
2231 XSETFRAME (frame
, f
);
2233 if (FRAME_LIVE_P (f
))
2235 /* Avoid consing in frequent cases. */
2236 if (EQ (parameter
, Qname
))
2238 #ifdef HAVE_X_WINDOWS
2239 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2240 value
= XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
);
2241 #endif /* HAVE_X_WINDOWS */
2242 else if (EQ (parameter
, Qbackground_color
)
2243 || EQ (parameter
, Qforeground_color
))
2245 value
= Fassq (parameter
, f
->param_alist
);
2248 value
= XCDR (value
);
2249 /* Fframe_parameters puts the actual fg/bg color names,
2250 even if f->param_alist says otherwise. This is
2251 important when param_alist's notion of colors is
2252 "unspecified". We need to do the same here. */
2253 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2255 const char *color_name
;
2258 if (EQ (parameter
, Qbackground_color
))
2260 color_name
= SSDATA (value
);
2261 csz
= SCHARS (value
);
2262 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2263 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2264 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2265 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2267 else if (EQ (parameter
, Qforeground_color
))
2269 color_name
= SSDATA (value
);
2270 csz
= SCHARS (value
);
2271 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2272 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2273 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2274 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2279 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2281 else if (EQ (parameter
, Qdisplay_type
)
2282 || EQ (parameter
, Qbackground_mode
))
2283 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2285 /* FIXME: Avoid this code path at all (as well as code duplication)
2286 by sharing more code with Fframe_parameters. */
2287 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2294 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2295 Smodify_frame_parameters
, 2, 2, 0,
2296 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2297 If FRAME is nil, it defaults to the selected frame.
2298 ALIST is an alist of parameters to change and their new values.
2299 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2300 The meaningful PARMs depend on the kind of frame.
2301 Undefined PARMs are ignored, but stored in the frame's parameter list
2302 so that `frame-parameters' will return them.
2304 The value of frame parameter FOO can also be accessed
2305 as a frame-local binding for the variable FOO, if you have
2306 enabled such bindings for that variable with `make-variable-frame-local'.
2307 Note that this functionality is obsolete as of Emacs 22.2, and its
2308 use is not recommended. Explicitly check for a frame-parameter instead. */)
2309 (Lisp_Object frame
, Lisp_Object alist
)
2311 struct frame
*f
= decode_live_frame (frame
);
2312 register Lisp_Object prop
, val
;
2316 /* I think this should be done with a hook. */
2317 #ifdef HAVE_WINDOW_SYSTEM
2318 if (FRAME_WINDOW_P (f
))
2319 x_set_frame_parameters (f
, alist
);
2323 if (FRAME_MSDOS_P (f
))
2324 IT_set_frame_parameters (f
, alist
);
2329 EMACS_INT length
= XFASTINT (Flength (alist
));
2332 Lisp_Object
*values
;
2334 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2335 values
= parms
+ length
;
2337 /* Extract parm names and values into those vectors. */
2339 for (i
= 0; CONSP (alist
); alist
= XCDR (alist
))
2344 parms
[i
] = Fcar (elt
);
2345 values
[i
] = Fcdr (elt
);
2349 /* Now process them in reverse of specified order. */
2354 store_frame_param (f
, prop
, val
);
2356 if (EQ (prop
, Qforeground_color
)
2357 || EQ (prop
, Qbackground_color
))
2358 update_face_from_frame_parameter (f
, prop
, val
);
2366 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2368 doc
: /* Height in pixels of a line in the font in frame FRAME.
2369 If FRAME is omitted or nil, the selected frame is used.
2370 For a terminal frame, the value is always 1. */)
2373 #ifdef HAVE_WINDOW_SYSTEM
2374 struct frame
*f
= decode_any_frame (frame
);
2376 if (FRAME_WINDOW_P (f
))
2377 return make_number (FRAME_LINE_HEIGHT (f
));
2380 return make_number (1);
2384 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2386 doc
: /* Width in pixels of characters in the font in frame FRAME.
2387 If FRAME is omitted or nil, the selected frame is used.
2388 On a graphical screen, the width is the standard width of the default font.
2389 For a terminal screen, the value is always 1. */)
2392 #ifdef HAVE_WINDOW_SYSTEM
2393 struct frame
*f
= decode_any_frame (frame
);
2395 if (FRAME_WINDOW_P (f
))
2396 return make_number (FRAME_COLUMN_WIDTH (f
));
2399 return make_number (1);
2402 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2403 Sframe_pixel_height
, 0, 1, 0,
2404 doc
: /* Return a FRAME's height in pixels.
2405 If FRAME is omitted or nil, the selected frame is used. The exact value
2406 of the result depends on the window-system and toolkit in use:
2408 In the Gtk+ version of Emacs, it includes only any window (including
2409 the minibuffer or echo area), mode line, and header line. It does not
2410 include the tool bar or menu bar.
2412 With other graphical versions, it also includes the tool bar and the
2415 For a text terminal, it includes the menu bar. In this case, the
2416 result is really in characters rather than pixels (i.e., is identical
2417 to `frame-height'). */)
2420 struct frame
*f
= decode_any_frame (frame
);
2422 #ifdef HAVE_WINDOW_SYSTEM
2423 if (FRAME_WINDOW_P (f
))
2424 return make_number (FRAME_PIXEL_HEIGHT (f
));
2427 return make_number (FRAME_LINES (f
));
2430 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2431 Sframe_pixel_width
, 0, 1, 0,
2432 doc
: /* Return FRAME's width in pixels.
2433 For a terminal frame, the result really gives the width in characters.
2434 If FRAME is omitted or nil, the selected frame is used. */)
2437 struct frame
*f
= decode_any_frame (frame
);
2439 #ifdef HAVE_WINDOW_SYSTEM
2440 if (FRAME_WINDOW_P (f
))
2441 return make_number (FRAME_PIXEL_WIDTH (f
));
2444 return make_number (FRAME_COLS (f
));
2447 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2448 Stool_bar_pixel_width
, 0, 1, 0,
2449 doc
: /* Return width in pixels of FRAME's tool bar.
2450 The result is greater than zero only when the tool bar is on the left
2451 or right side of FRAME. If FRAME is omitted or nil, the selected frame
2455 #ifdef FRAME_TOOLBAR_WIDTH
2456 struct frame
*f
= decode_any_frame (frame
);
2458 if (FRAME_WINDOW_P (f
))
2459 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2461 return make_number (0);
2464 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2465 doc
: /* Specify that the frame FRAME has LINES lines.
2466 If FRAME is nil, the selected frame is used. Optional third arg
2467 non-nil means that redisplay should use LINES lines but that the
2468 idea of the actual height of the frame should not be changed. */)
2469 (Lisp_Object frame
, Lisp_Object lines
, Lisp_Object pretend
)
2471 register struct frame
*f
= decode_live_frame (frame
);
2473 CHECK_TYPE_RANGED_INTEGER (int, lines
);
2475 /* I think this should be done with a hook. */
2476 #ifdef HAVE_WINDOW_SYSTEM
2477 if (FRAME_WINDOW_P (f
))
2479 if (XINT (lines
) != FRAME_LINES (f
))
2480 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2481 do_pending_window_change (0);
2485 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2489 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2490 doc
: /* Specify that the frame FRAME has COLS columns.
2491 If FRAME is nil, the selected frame is used. Optional third arg
2492 non-nil means that redisplay should use COLS columns but that the
2493 idea of the actual width of the frame should not be changed. */)
2494 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object pretend
)
2496 register struct frame
*f
= decode_live_frame (frame
);
2498 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2500 /* I think this should be done with a hook. */
2501 #ifdef HAVE_WINDOW_SYSTEM
2502 if (FRAME_WINDOW_P (f
))
2504 if (XINT (cols
) != FRAME_COLS (f
))
2505 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2506 do_pending_window_change (0);
2510 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2514 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2515 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters.
2516 If FRAME is nil, the selected frame is used. */)
2517 (Lisp_Object frame
, Lisp_Object cols
, Lisp_Object rows
)
2519 register struct frame
*f
= decode_live_frame (frame
);
2521 CHECK_TYPE_RANGED_INTEGER (int, cols
);
2522 CHECK_TYPE_RANGED_INTEGER (int, rows
);
2524 /* I think this should be done with a hook. */
2525 #ifdef HAVE_WINDOW_SYSTEM
2526 if (FRAME_WINDOW_P (f
))
2528 if (XINT (rows
) != FRAME_LINES (f
)
2529 || XINT (cols
) != FRAME_COLS (f
)
2530 || f
->new_text_lines
|| f
->new_text_cols
)
2531 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2532 do_pending_window_change (0);
2536 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2541 DEFUN ("set-frame-position", Fset_frame_position
,
2542 Sset_frame_position
, 3, 3, 0,
2543 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2544 If FRAME is nil, the selected frame is used. XOFFSET and YOFFSET are
2545 actually the position of the upper left corner of the frame. Negative
2546 values for XOFFSET or YOFFSET are interpreted relative to the rightmost
2547 or bottommost possible position (that stays within the screen). */)
2548 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2550 register struct frame
*f
= decode_live_frame (frame
);
2552 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2553 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2555 /* I think this should be done with a hook. */
2556 #ifdef HAVE_WINDOW_SYSTEM
2557 if (FRAME_WINDOW_P (f
))
2558 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2565 /***********************************************************************
2567 ***********************************************************************/
2569 /* Connect the frame-parameter names for X frames
2570 to the ways of passing the parameter values to the window system.
2572 The name of a parameter, as a Lisp symbol,
2573 has an `x-frame-parameter' property which is an integer in Lisp
2574 that is an index in this table. */
2576 struct frame_parm_table
{
2578 Lisp_Object
*variable
;
2581 static const struct frame_parm_table frame_parms
[] =
2583 {"auto-raise", &Qauto_raise
},
2584 {"auto-lower", &Qauto_lower
},
2585 {"background-color", 0},
2586 {"border-color", &Qborder_color
},
2587 {"border-width", &Qborder_width
},
2588 {"cursor-color", &Qcursor_color
},
2589 {"cursor-type", &Qcursor_type
},
2591 {"foreground-color", 0},
2592 {"icon-name", &Qicon_name
},
2593 {"icon-type", &Qicon_type
},
2594 {"internal-border-width", &Qinternal_border_width
},
2595 {"menu-bar-lines", &Qmenu_bar_lines
},
2596 {"mouse-color", &Qmouse_color
},
2598 {"scroll-bar-width", &Qscroll_bar_width
},
2600 {"unsplittable", &Qunsplittable
},
2601 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2602 {"visibility", &Qvisibility
},
2603 {"tool-bar-lines", &Qtool_bar_lines
},
2604 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2605 {"scroll-bar-background", &Qscroll_bar_background
},
2606 {"screen-gamma", &Qscreen_gamma
},
2607 {"line-spacing", &Qline_spacing
},
2608 {"left-fringe", &Qleft_fringe
},
2609 {"right-fringe", &Qright_fringe
},
2610 {"wait-for-wm", &Qwait_for_wm
},
2611 {"fullscreen", &Qfullscreen
},
2612 {"font-backend", &Qfont_backend
},
2614 {"sticky", &Qsticky
},
2615 {"tool-bar-position", &Qtool_bar_position
},
2620 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2621 wanted positions of the WM window (not Emacs window).
2622 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2623 window (FRAME_X_WINDOW).
2627 x_fullscreen_adjust (struct frame
*f
, int *width
, int *height
, int *top_pos
, int *left_pos
)
2629 int newwidth
= FRAME_COLS (f
);
2630 int newheight
= FRAME_LINES (f
);
2631 Display_Info
*dpyinfo
= FRAME_DISPLAY_INFO (f
);
2633 *top_pos
= f
->top_pos
;
2634 *left_pos
= f
->left_pos
;
2636 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2640 ph
= x_display_pixel_height (dpyinfo
);
2641 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2642 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2643 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2647 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2651 pw
= x_display_pixel_width (dpyinfo
);
2652 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2653 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2654 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2659 *height
= newheight
;
2662 #endif /* HAVE_NTGUI */
2664 #ifdef HAVE_WINDOW_SYSTEM
2666 /* Change the parameters of frame F as specified by ALIST.
2667 If a parameter is not specially recognized, do nothing special;
2668 otherwise call the `x_set_...' function for that parameter.
2669 Except for certain geometry properties, always call store_frame_param
2670 to store the new value in the parameter alist. */
2673 x_set_frame_parameters (struct frame
*f
, Lisp_Object alist
)
2677 /* If both of these parameters are present, it's more efficient to
2678 set them both at once. So we wait until we've looked at the
2679 entire list before we set them. */
2683 Lisp_Object left
, top
;
2685 /* Same with these. */
2686 Lisp_Object icon_left
, icon_top
;
2688 /* Record in these vectors all the parms specified. */
2690 Lisp_Object
*values
;
2692 bool left_no_change
= 0, top_no_change
= 0;
2693 bool icon_left_no_change
= 0, icon_top_no_change
= 0;
2694 bool size_changed
= 0;
2695 struct gcpro gcpro1
, gcpro2
;
2698 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2701 parms
= alloca (i
* sizeof *parms
);
2702 values
= alloca (i
* sizeof *values
);
2704 /* Extract parm names and values into those vectors. */
2707 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2712 parms
[i
] = Fcar (elt
);
2713 values
[i
] = Fcdr (elt
);
2716 /* TAIL and ALIST are not used again below here. */
2717 alist
= tail
= Qnil
;
2719 GCPRO2 (*parms
, *values
);
2723 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2724 because their values appear in VALUES and strings are not valid. */
2725 top
= left
= Qunbound
;
2726 icon_left
= icon_top
= Qunbound
;
2728 /* Provide default values for HEIGHT and WIDTH. */
2729 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2730 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2732 /* Process foreground_color and background_color before anything else.
2733 They are independent of other properties, but other properties (e.g.,
2734 cursor_color) are dependent upon them. */
2735 /* Process default font as well, since fringe widths depends on it. */
2736 for (p
= 0; p
< i
; p
++)
2738 Lisp_Object prop
, val
;
2742 if (EQ (prop
, Qforeground_color
)
2743 || EQ (prop
, Qbackground_color
)
2744 || EQ (prop
, Qfont
))
2746 register Lisp_Object param_index
, old_value
;
2748 old_value
= get_frame_param (f
, prop
);
2749 if (NILP (Fequal (val
, old_value
)))
2751 store_frame_param (f
, prop
, val
);
2753 param_index
= Fget (prop
, Qx_frame_parameter
);
2754 if (NATNUMP (param_index
)
2755 && (XFASTINT (param_index
)
2756 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2757 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2758 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2763 /* Now process them in reverse of specified order. */
2766 Lisp_Object prop
, val
;
2771 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2774 width
= XFASTINT (val
);
2776 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
2779 height
= XFASTINT (val
);
2781 else if (EQ (prop
, Qtop
))
2783 else if (EQ (prop
, Qleft
))
2785 else if (EQ (prop
, Qicon_top
))
2787 else if (EQ (prop
, Qicon_left
))
2789 else if (EQ (prop
, Qforeground_color
)
2790 || EQ (prop
, Qbackground_color
)
2791 || EQ (prop
, Qfont
))
2792 /* Processed above. */
2796 register Lisp_Object param_index
, old_value
;
2798 old_value
= get_frame_param (f
, prop
);
2800 store_frame_param (f
, prop
, val
);
2802 param_index
= Fget (prop
, Qx_frame_parameter
);
2803 if (NATNUMP (param_index
)
2804 && (XFASTINT (param_index
)
2805 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2806 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2807 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2811 /* Don't die if just one of these was set. */
2812 if (EQ (left
, Qunbound
))
2815 if (f
->left_pos
< 0)
2816 left
= list2 (Qplus
, make_number (f
->left_pos
));
2818 XSETINT (left
, f
->left_pos
);
2820 if (EQ (top
, Qunbound
))
2824 top
= list2 (Qplus
, make_number (f
->top_pos
));
2826 XSETINT (top
, f
->top_pos
);
2829 /* If one of the icon positions was not set, preserve or default it. */
2830 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
2832 icon_left_no_change
= 1;
2833 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2834 if (NILP (icon_left
))
2835 XSETINT (icon_left
, 0);
2837 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
2839 icon_top_no_change
= 1;
2840 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2841 if (NILP (icon_top
))
2842 XSETINT (icon_top
, 0);
2845 /* Don't set these parameters unless they've been explicitly
2846 specified. The window might be mapped or resized while we're in
2847 this function, and we don't want to override that unless the lisp
2848 code has asked for it.
2850 Don't set these parameters unless they actually differ from the
2851 window's current parameters; the window may not actually exist
2856 check_frame_size (f
, &height
, &width
);
2858 XSETFRAME (frame
, f
);
2861 && (width
!= FRAME_COLS (f
)
2862 || height
!= FRAME_LINES (f
)
2863 || f
->new_text_lines
|| f
->new_text_cols
))
2864 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2866 if ((!NILP (left
) || !NILP (top
))
2867 && ! (left_no_change
&& top_no_change
)
2868 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2869 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2874 /* Record the signs. */
2875 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2876 if (EQ (left
, Qminus
))
2877 f
->size_hint_flags
|= XNegative
;
2878 else if (TYPE_RANGED_INTEGERP (int, left
))
2880 leftpos
= XINT (left
);
2882 f
->size_hint_flags
|= XNegative
;
2884 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2885 && CONSP (XCDR (left
))
2886 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
2888 leftpos
= - XINT (XCAR (XCDR (left
)));
2889 f
->size_hint_flags
|= XNegative
;
2891 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2892 && CONSP (XCDR (left
))
2893 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
2895 leftpos
= XINT (XCAR (XCDR (left
)));
2898 if (EQ (top
, Qminus
))
2899 f
->size_hint_flags
|= YNegative
;
2900 else if (TYPE_RANGED_INTEGERP (int, top
))
2902 toppos
= XINT (top
);
2904 f
->size_hint_flags
|= YNegative
;
2906 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2907 && CONSP (XCDR (top
))
2908 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
2910 toppos
= - XINT (XCAR (XCDR (top
)));
2911 f
->size_hint_flags
|= YNegative
;
2913 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2914 && CONSP (XCDR (top
))
2915 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
2917 toppos
= XINT (XCAR (XCDR (top
)));
2921 /* Store the numeric value of the position. */
2922 f
->top_pos
= toppos
;
2923 f
->left_pos
= leftpos
;
2925 f
->win_gravity
= NorthWestGravity
;
2927 /* Actually set that position, and convert to absolute. */
2928 x_set_offset (f
, leftpos
, toppos
, -1);
2930 #ifdef HAVE_X_WINDOWS
2931 if ((!NILP (icon_left
) || !NILP (icon_top
))
2932 && ! (icon_left_no_change
&& icon_top_no_change
))
2933 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2934 #endif /* HAVE_X_WINDOWS */
2941 /* Insert a description of internally-recorded parameters of frame X
2942 into the parameter alist *ALISTPTR that is to be given to the user.
2943 Only parameters that are specific to the X window system
2944 and whose values are not correctly recorded in the frame's
2945 param_alist need to be considered here. */
2948 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
2952 char buf
[INT_BUFSIZE_BOUND (w
)];
2954 /* Represent negative positions (off the top or left screen edge)
2955 in a way that Fmodify_frame_parameters will understand correctly. */
2956 XSETINT (tem
, f
->left_pos
);
2957 if (f
->left_pos
>= 0)
2958 store_in_alist (alistptr
, Qleft
, tem
);
2960 store_in_alist (alistptr
, Qleft
, list2 (Qplus
, tem
));
2962 XSETINT (tem
, f
->top_pos
);
2963 if (f
->top_pos
>= 0)
2964 store_in_alist (alistptr
, Qtop
, tem
);
2966 store_in_alist (alistptr
, Qtop
, list2 (Qplus
, tem
));
2968 store_in_alist (alistptr
, Qborder_width
,
2969 make_number (f
->border_width
));
2970 store_in_alist (alistptr
, Qinternal_border_width
,
2971 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
2972 store_in_alist (alistptr
, Qleft_fringe
,
2973 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
2974 store_in_alist (alistptr
, Qright_fringe
,
2975 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
2976 store_in_alist (alistptr
, Qscroll_bar_width
,
2977 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2979 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
2980 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
2981 /* nil means "use default width"
2982 for non-toolkit scroll bar.
2983 ruler-mode.el depends on this. */
2985 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
2986 MS-Windows it returns a value whose type is HANDLE, which is
2987 actually a pointer. Explicit casting avoids compiler
2989 w
= (uintptr_t) FRAME_X_WINDOW (f
);
2990 store_in_alist (alistptr
, Qwindow_id
,
2991 make_formatted_string (buf
, "%"pMu
, w
));
2992 #ifdef HAVE_X_WINDOWS
2993 #ifdef USE_X_TOOLKIT
2994 /* Tooltip frame may not have this widget. */
2995 if (FRAME_X_OUTPUT (f
)->widget
)
2997 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
2998 store_in_alist (alistptr
, Qouter_window_id
,
2999 make_formatted_string (buf
, "%"pMu
, w
));
3001 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3002 store_in_alist (alistptr
, Qvisibility
,
3003 (FRAME_VISIBLE_P (f
) ? Qt
3004 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3005 store_in_alist (alistptr
, Qdisplay
,
3006 XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
));
3008 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_DISPLAY_INFO (f
)->root_window
)
3011 tem
= make_natnum ((uintptr_t) FRAME_X_OUTPUT (f
)->parent_desc
);
3012 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3013 store_in_alist (alistptr
, Qparent_id
, tem
);
3014 store_in_alist (alistptr
, Qtool_bar_position
, f
->tool_bar_position
);
3018 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3019 the previous value of that parameter, NEW_VALUE is the new value. */
3022 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3024 if (NILP (new_value
))
3025 f
->want_fullscreen
= FULLSCREEN_NONE
;
3026 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3027 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3028 else if (EQ (new_value
, Qfullwidth
))
3029 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3030 else if (EQ (new_value
, Qfullheight
))
3031 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3032 else if (EQ (new_value
, Qmaximized
))
3033 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3035 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3036 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3040 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3041 the previous value of that parameter, NEW_VALUE is the new value. */
3044 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3046 if (NILP (new_value
))
3047 f
->extra_line_spacing
= 0;
3048 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
3049 f
->extra_line_spacing
= XFASTINT (new_value
);
3050 else if (FLOATP (new_value
))
3052 int new_spacing
= XFLOAT_DATA (new_value
) * FRAME_LINE_HEIGHT (f
) + 0.5;
3054 if (new_spacing
>= 0)
3055 f
->extra_line_spacing
= new_spacing
;
3057 signal_error ("Invalid line-spacing", new_value
);
3060 signal_error ("Invalid line-spacing", new_value
);
3061 if (FRAME_VISIBLE_P (f
))
3066 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3067 the previous value of that parameter, NEW_VALUE is the new value. */
3070 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3072 Lisp_Object bgcolor
;
3074 if (NILP (new_value
))
3076 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3077 /* The value 0.4545 is the normal viewing gamma. */
3078 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3080 signal_error ("Invalid screen-gamma", new_value
);
3082 /* Apply the new gamma value to the frame background. */
3083 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3084 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3086 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3087 if (NATNUMP (parm_index
)
3088 && (XFASTINT (parm_index
)
3089 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3090 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3091 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3095 Fclear_face_cache (Qnil
);
3100 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3102 Lisp_Object font_object
;
3104 #ifdef HAVE_X_WINDOWS
3105 Lisp_Object font_param
= arg
;
3108 /* Set the frame parameter back to the old value because we may
3109 fail to use ARG as the new parameter value. */
3110 store_frame_param (f
, Qfont
, oldval
);
3112 /* ARG is a fontset name, a font name, a cons of fontset name and a
3113 font object, or a font object. In the last case, this function
3117 fontset
= fs_query_fontset (arg
, 0);
3120 font_object
= font_open_by_name (f
, arg
);
3121 if (NILP (font_object
))
3122 error ("Font `%s' is not defined", SSDATA (arg
));
3123 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3125 else if (fontset
> 0)
3127 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
3128 if (NILP (font_object
))
3129 error ("Font `%s' is not defined", SDATA (arg
));
3130 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3133 error ("The default fontset can't be used for a frame font");
3135 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3137 /* This is the case that the ASCII font of F's fontset XCAR
3138 (arg) is changed to the font XCDR (arg) by
3139 `set-fontset-font'. */
3140 fontset
= fs_query_fontset (XCAR (arg
), 0);
3142 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3143 font_object
= XCDR (arg
);
3144 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3145 #ifdef HAVE_X_WINDOWS
3146 font_param
= Ffont_get (font_object
, QCname
);
3149 else if (FONT_OBJECT_P (arg
))
3152 #ifdef HAVE_X_WINDOWS
3153 font_param
= Ffont_get (font_object
, QCname
);
3155 /* This is to store the XLFD font name in the frame parameter for
3156 backward compatibility. We should store the font-object
3157 itself in the future. */
3158 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3159 fontset
= FRAME_FONTSET (f
);
3160 /* Check if we can use the current fontset. If not, set FONTSET
3161 to -1 to generate a new fontset from FONT-OBJECT. */
3164 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3165 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3168 signal_error ("Invalid font name", ascii_font
);
3170 if (! font_match_p (spec
, font_object
))
3175 signal_error ("Invalid font", arg
);
3177 if (! NILP (Fequal (font_object
, oldval
)))
3180 x_new_font (f
, font_object
, fontset
);
3181 store_frame_param (f
, Qfont
, arg
);
3182 #ifdef HAVE_X_WINDOWS
3183 store_frame_param (f
, Qfont_param
, font_param
);
3185 /* Recalculate toolbar height. */
3186 f
->n_tool_bar_rows
= 0;
3187 /* Ensure we redraw it. */
3188 clear_current_matrices (f
);
3190 recompute_basic_faces (f
);
3192 do_pending_window_change (0);
3194 /* We used to call face-set-after-frame-default here, but it leads to
3195 recursive calls (since that function can set the `default' face's
3196 font which in turns changes the frame's `font' parameter).
3197 Also I don't know what this call is meant to do, but it seems the
3198 wrong way to do it anyway (it does a lot more work than what seems
3199 reasonable in response to a change to `font'). */
3204 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3206 if (! NILP (new_value
)
3207 && !CONSP (new_value
))
3211 CHECK_STRING (new_value
);
3212 p0
= p1
= SSDATA (new_value
);
3216 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
3218 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3224 while ((c
= *++p1
) && c_isspace (c
));
3228 new_value
= Fnreverse (new_value
);
3231 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3235 free_all_realized_faces (Qnil
);
3237 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3238 if (NILP (new_value
))
3240 if (NILP (old_value
))
3241 error ("No font backend available");
3242 font_update_drivers (f
, old_value
);
3243 error ("None of specified font backends are available");
3245 store_frame_param (f
, Qfont_backend
, new_value
);
3251 XSETFRAME (frame
, f
);
3252 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3253 ++face_change_count
;
3254 windows_or_buffers_changed
= 18;
3260 x_set_fringe_width (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3262 compute_fringe_widths (f
, 1);
3263 #ifdef HAVE_X_WINDOWS
3264 /* Must adjust this so window managers report correct number of columns. */
3265 if (FRAME_X_WINDOW (f
) != 0)
3266 x_wm_set_size_hint (f
, 0, 0);
3271 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3273 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3275 if (XINT (arg
) == f
->border_width
)
3278 if (FRAME_X_WINDOW (f
) != 0)
3279 error ("Cannot change the border width of a frame");
3281 f
->border_width
= XINT (arg
);
3285 x_set_internal_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3287 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3289 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3290 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3291 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3292 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3294 #ifdef USE_X_TOOLKIT
3295 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3296 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3299 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3302 if (FRAME_X_WINDOW (f
) != 0)
3304 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3305 SET_FRAME_GARBAGED (f
);
3306 do_pending_window_change (0);
3309 SET_FRAME_GARBAGED (f
);
3313 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3316 XSETFRAME (frame
, f
);
3319 Fmake_frame_invisible (frame
, Qt
);
3320 else if (EQ (value
, Qicon
))
3321 Ficonify_frame (frame
);
3323 Fmake_frame_visible (frame
);
3327 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3329 f
->auto_raise
= !EQ (Qnil
, arg
);
3333 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3335 f
->auto_lower
= !EQ (Qnil
, arg
);
3339 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3341 f
->no_split
= !NILP (arg
);
3345 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3347 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3348 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3349 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3350 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3352 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3354 ? vertical_scroll_bar_none
3356 ? vertical_scroll_bar_left
3358 ? vertical_scroll_bar_right
3359 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3360 ? vertical_scroll_bar_left
3361 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3362 ? vertical_scroll_bar_right
3363 : vertical_scroll_bar_none
);
3365 /* We set this parameter before creating the X window for the
3366 frame, so we can get the geometry right from the start.
3367 However, if the window hasn't been created yet, we shouldn't
3368 call x_set_window_size. */
3369 if (FRAME_X_WINDOW (f
))
3370 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3371 do_pending_window_change (0);
3376 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3378 int wid
= FRAME_COLUMN_WIDTH (f
);
3382 x_set_scroll_bar_default_width (f
);
3384 if (FRAME_X_WINDOW (f
))
3385 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3386 do_pending_window_change (0);
3388 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3389 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3391 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3392 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3393 if (FRAME_X_WINDOW (f
))
3394 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3395 do_pending_window_change (0);
3398 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3399 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3400 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3404 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3411 for (i
= 0; i
< 2; i
++)
3424 else if (FLOATP (item
))
3426 alpha
= XFLOAT_DATA (item
);
3427 if (! (0 <= alpha
&& alpha
<= 1.0))
3428 args_out_of_range (make_float (0.0), make_float (1.0));
3430 else if (INTEGERP (item
))
3432 EMACS_INT ialpha
= XINT (item
);
3433 if (! (0 <= ialpha
&& alpha
<= 100))
3434 args_out_of_range (make_number (0), make_number (100));
3435 alpha
= ialpha
/ 100.0;
3438 wrong_type_argument (Qnumberp
, item
);
3442 for (i
= 0; i
< 2; i
++)
3443 f
->alpha
[i
] = newval
[i
];
3445 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3447 x_set_frame_alpha (f
);
3456 /* Non-zero if mouse is grabbed on DPYINFO
3457 and we know the frame where it is. */
3459 bool x_mouse_grabbed (Display_Info
*dpyinfo
)
3461 return (dpyinfo
->grabbed
3462 && dpyinfo
->last_mouse_frame
3463 && FRAME_LIVE_P (dpyinfo
->last_mouse_frame
));
3466 /* Re-highlight something with mouse-face properties
3467 on DPYINFO using saved frame and mouse position. */
3470 x_redo_mouse_highlight (Display_Info
*dpyinfo
)
3472 if (dpyinfo
->last_mouse_motion_frame
3473 && FRAME_LIVE_P (dpyinfo
->last_mouse_motion_frame
))
3474 note_mouse_highlight (dpyinfo
->last_mouse_motion_frame
,
3475 dpyinfo
->last_mouse_motion_x
,
3476 dpyinfo
->last_mouse_motion_y
);
3479 #endif /* HAVE_NS */
3481 /* Subroutines of creating an X frame. */
3483 /* Make sure that Vx_resource_name is set to a reasonable value.
3484 Fix it up, or set it to `emacs' if it is too hopeless. */
3487 validate_x_resource_name (void)
3490 /* Number of valid characters in the resource name. */
3491 ptrdiff_t good_count
= 0;
3492 /* Number of invalid characters in the resource name. */
3493 ptrdiff_t bad_count
= 0;
3497 if (!STRINGP (Vx_resource_class
))
3498 Vx_resource_class
= build_string (EMACS_CLASS
);
3500 if (STRINGP (Vx_resource_name
))
3502 unsigned char *p
= SDATA (Vx_resource_name
);
3504 len
= SBYTES (Vx_resource_name
);
3506 /* Only letters, digits, - and _ are valid in resource names.
3507 Count the valid characters and count the invalid ones. */
3508 for (i
= 0; i
< len
; i
++)
3511 if (! ((c
>= 'a' && c
<= 'z')
3512 || (c
>= 'A' && c
<= 'Z')
3513 || (c
>= '0' && c
<= '9')
3514 || c
== '-' || c
== '_'))
3521 /* Not a string => completely invalid. */
3522 bad_count
= 5, good_count
= 0;
3524 /* If name is valid already, return. */
3528 /* If name is entirely invalid, or nearly so, or is so implausibly
3529 large that alloca might not work, use `emacs'. */
3530 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
3532 Vx_resource_name
= build_string ("emacs");
3536 /* Name is partly valid. Copy it and replace the invalid characters
3537 with underscores. */
3539 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3541 for (i
= 0; i
< len
; i
++)
3543 int c
= SREF (new, i
);
3544 if (! ((c
>= 'a' && c
<= 'z')
3545 || (c
>= 'A' && c
<= 'Z')
3546 || (c
>= '0' && c
<= '9')
3547 || c
== '-' || c
== '_'))
3552 /* Get specified attribute from resource database RDB.
3553 See Fx_get_resource below for other parameters. */
3556 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
3558 register char *value
;
3562 CHECK_STRING (attribute
);
3563 CHECK_STRING (class);
3565 if (!NILP (component
))
3566 CHECK_STRING (component
);
3567 if (!NILP (subclass
))
3568 CHECK_STRING (subclass
);
3569 if (NILP (component
) != NILP (subclass
))
3570 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3572 validate_x_resource_name ();
3574 /* Allocate space for the components, the dots which separate them,
3575 and the final '\0'. Make them big enough for the worst case. */
3576 name_key
= alloca (SBYTES (Vx_resource_name
)
3577 + (STRINGP (component
)
3578 ? SBYTES (component
) : 0)
3579 + SBYTES (attribute
)
3582 class_key
= alloca (SBYTES (Vx_resource_class
)
3584 + (STRINGP (subclass
)
3585 ? SBYTES (subclass
) : 0)
3588 /* Start with emacs.FRAMENAME for the name (the specific one)
3589 and with `Emacs' for the class key (the general one). */
3590 strcpy (name_key
, SSDATA (Vx_resource_name
));
3591 strcpy (class_key
, SSDATA (Vx_resource_class
));
3593 strcat (class_key
, ".");
3594 strcat (class_key
, SSDATA (class));
3596 if (!NILP (component
))
3598 strcat (class_key
, ".");
3599 strcat (class_key
, SSDATA (subclass
));
3601 strcat (name_key
, ".");
3602 strcat (name_key
, SSDATA (component
));
3605 strcat (name_key
, ".");
3606 strcat (name_key
, SSDATA (attribute
));
3608 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3610 if (value
&& *value
)
3611 return build_string (value
);
3617 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3618 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3619 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3620 class, where INSTANCE is the name under which Emacs was invoked, or
3621 the name specified by the `-name' or `-rn' command-line arguments.
3623 The optional arguments COMPONENT and SUBCLASS add to the key and the
3624 class, respectively. You must specify both of them or neither.
3625 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3626 and the class is `Emacs.CLASS.SUBCLASS'. */)
3627 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
,
3628 Lisp_Object subclass
)
3630 check_window_system (NULL
);
3632 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3633 attribute
, class, component
, subclass
);
3636 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3639 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
,
3640 Lisp_Object
class, Lisp_Object component
,
3641 Lisp_Object subclass
)
3643 return xrdb_get_resource (dpyinfo
->xrdb
,
3644 attribute
, class, component
, subclass
);
3647 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
3648 /* Used when C code wants a resource value. */
3649 /* Called from oldXMenu/Create.c. */
3651 x_get_resource_string (const char *attribute
, const char *class)
3654 struct frame
*sf
= SELECTED_FRAME ();
3655 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
3658 /* Allocate space for the components, the dots which separate them,
3659 and the final '\0'. */
3660 char *name_key
= SAFE_ALLOCA (invocation_namelen
+ strlen (attribute
) + 2);
3661 char *class_key
= alloca ((sizeof (EMACS_CLASS
) - 1) + strlen (class) + 2);
3663 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
3664 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3666 result
= x_get_string_resource (FRAME_DISPLAY_INFO (sf
)->xrdb
,
3667 name_key
, class_key
);
3673 /* Return the value of parameter PARAM.
3675 First search ALIST, then Vdefault_frame_alist, then the X defaults
3676 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3678 Convert the resource to the type specified by desired_type.
3680 If no default is specified, return Qunbound. If you call
3681 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3682 and don't let it get stored in any Lisp-visible variables! */
3685 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
3686 const char *attribute
, const char *class, enum resource_types type
)
3688 register Lisp_Object tem
;
3690 tem
= Fassq (param
, alist
);
3694 /* If we find this parm in ALIST, clear it out
3695 so that it won't be "left over" at the end. */
3697 XSETCAR (tem
, Qnil
);
3698 /* In case the parameter appears more than once in the alist,
3700 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3701 if (CONSP (XCAR (tail
))
3702 && EQ (XCAR (XCAR (tail
)), param
))
3703 XSETCAR (XCAR (tail
), Qnil
);
3706 tem
= Fassq (param
, Vdefault_frame_alist
);
3708 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3709 look in the X resources. */
3712 if (attribute
&& dpyinfo
)
3714 tem
= display_x_get_resource (dpyinfo
,
3715 build_string (attribute
),
3716 build_string (class),
3724 case RES_TYPE_NUMBER
:
3725 return make_number (atoi (SSDATA (tem
)));
3727 case RES_TYPE_BOOLEAN_NUMBER
:
3728 if (!strcmp (SSDATA (tem
), "on")
3729 || !strcmp (SSDATA (tem
), "true"))
3730 return make_number (1);
3731 return make_number (atoi (SSDATA (tem
)));
3734 case RES_TYPE_FLOAT
:
3735 return make_float (atof (SSDATA (tem
)));
3737 case RES_TYPE_BOOLEAN
:
3738 tem
= Fdowncase (tem
);
3739 if (!strcmp (SSDATA (tem
), "on")
3741 || !strcmp (SSDATA (tem
), "yes")
3743 || !strcmp (SSDATA (tem
), "true"))
3748 case RES_TYPE_STRING
:
3751 case RES_TYPE_SYMBOL
:
3752 /* As a special case, we map the values `true' and `on'
3753 to Qt, and `false' and `off' to Qnil. */
3756 lower
= Fdowncase (tem
);
3757 if (!strcmp (SSDATA (lower
), "on")
3759 || !strcmp (SSDATA (lower
), "yes")
3761 || !strcmp (SSDATA (lower
), "true"))
3763 else if (!strcmp (SSDATA (lower
), "off")
3765 || !strcmp (SSDATA (lower
), "no")
3767 || !strcmp (SSDATA (lower
), "false"))
3770 return Fintern (tem
, Qnil
);
3784 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
3785 const char *attribute
, const char *class,
3786 enum resource_types type
)
3788 return x_get_arg (FRAME_DISPLAY_INFO (f
),
3789 alist
, param
, attribute
, class, type
);
3792 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3795 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
3797 const char *attribute
, const char *class,
3798 enum resource_types type
)
3802 value
= x_get_arg (FRAME_DISPLAY_INFO (f
), alist
, param
,
3803 attribute
, class, type
);
3804 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3805 store_frame_param (f
, param
, value
);
3811 /* Record in frame F the specified or default value according to ALIST
3812 of the parameter named PROP (a Lisp symbol).
3813 If no value is specified for PROP, look for an X default for XPROP
3814 on the frame named NAME.
3815 If that is not found either, use the value DEFLT. */
3818 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
3819 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
3820 enum resource_types type
)
3824 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3825 if (EQ (tem
, Qunbound
))
3827 x_set_frame_parameters (f
, list1 (Fcons (prop
, tem
)));
3832 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
3835 * XParseGeometry parses strings of the form
3836 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
3837 * width, height, xoffset, and yoffset are unsigned integers.
3838 * Example: "=80x24+300-49"
3839 * The equal sign is optional.
3840 * It returns a bitmask that indicates which of the four values
3841 * were actually found in the string. For each value found,
3842 * the corresponding argument is updated; for each value
3843 * not found, the corresponding argument is left unchanged.
3847 XParseGeometry (char *string
,
3849 unsigned int *width
, unsigned int *height
)
3853 unsigned long tempWidth
, tempHeight
;
3854 long int tempX
, tempY
;
3855 char *nextCharacter
;
3857 if (string
== NULL
|| *string
== '\0')
3860 string
++; /* ignore possible '=' at beg of geometry spec */
3863 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
3865 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
3866 if (strind
== nextCharacter
)
3868 strind
= nextCharacter
;
3872 if (*strind
== 'x' || *strind
== 'X')
3875 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
3876 if (strind
== nextCharacter
)
3878 strind
= nextCharacter
;
3879 mask
|= HeightValue
;
3882 if (*strind
== '+' || *strind
== '-')
3886 tempX
= strtol (strind
, &nextCharacter
, 10);
3887 if (strind
== nextCharacter
)
3889 strind
= nextCharacter
;
3891 if (*strind
== '+' || *strind
== '-')
3895 tempY
= strtol (strind
, &nextCharacter
, 10);
3896 if (strind
== nextCharacter
)
3898 strind
= nextCharacter
;
3903 /* If strind isn't at the end of the string then it's an invalid
3904 geometry specification. */
3906 if (*strind
!= '\0')
3910 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
3912 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
3913 if (mask
& WidthValue
)
3914 *width
= min (tempWidth
, UINT_MAX
);
3915 if (mask
& HeightValue
)
3916 *height
= min (tempHeight
, UINT_MAX
);
3920 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
3923 /* NS used to define x-parse-geometry in ns-win.el, but that confused
3924 make-docfile: the documentation string in ns-win.el was used for
3925 x-parse-geometry even in non-NS builds.
3927 With two definitions of x-parse-geometry in this file, various
3928 things still get confused (eg M-x apropos documentation), so that
3929 it is best if the two definitions just share the same doc-string.
3931 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3932 doc
: /* Parse a display geometry string STRING.
3933 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3934 The properties returned may include `top', `left', `height', and `width'.
3935 For X, the value of `left' or `top' may be an integer,
3936 or a list (+ N) meaning N pixels relative to top/left corner,
3937 or a list (- N) meaning -N pixels relative to bottom/right corner.
3938 On Nextstep, this just calls `ns-parse-geometry'. */)
3939 (Lisp_Object string
)
3942 unsigned int width
, height
;
3945 CHECK_STRING (string
);
3948 if (strchr (SSDATA (string
), ' ') != NULL
)
3949 return call1 (Qns_parse_geometry
, string
);
3951 geometry
= XParseGeometry (SSDATA (string
),
3952 &x
, &y
, &width
, &height
);
3954 if (geometry
& XValue
)
3956 Lisp_Object element
;
3958 if (x
>= 0 && (geometry
& XNegative
))
3959 element
= list3 (Qleft
, Qminus
, make_number (-x
));
3960 else if (x
< 0 && ! (geometry
& XNegative
))
3961 element
= list3 (Qleft
, Qplus
, make_number (x
));
3963 element
= Fcons (Qleft
, make_number (x
));
3964 result
= Fcons (element
, result
);
3967 if (geometry
& YValue
)
3969 Lisp_Object element
;
3971 if (y
>= 0 && (geometry
& YNegative
))
3972 element
= list3 (Qtop
, Qminus
, make_number (-y
));
3973 else if (y
< 0 && ! (geometry
& YNegative
))
3974 element
= list3 (Qtop
, Qplus
, make_number (y
));
3976 element
= Fcons (Qtop
, make_number (y
));
3977 result
= Fcons (element
, result
);
3980 if (geometry
& WidthValue
)
3981 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3982 if (geometry
& HeightValue
)
3983 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3989 /* Calculate the desired size and position of frame F.
3990 Return the flags saying which aspects were specified.
3992 Also set the win_gravity and size_hint_flags of F.
3994 Adjust height for toolbar if TOOLBAR_P is 1.
3996 This function does not make the coordinates positive. */
3998 #define DEFAULT_ROWS 35
3999 #define DEFAULT_COLS 80
4002 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, bool toolbar_p
)
4004 register Lisp_Object tem0
, tem1
, tem2
;
4005 long window_prompting
= 0;
4006 Display_Info
*dpyinfo
= FRAME_DISPLAY_INFO (f
);
4008 /* Default values if we fall through.
4009 Actually, if that happens we should get
4010 window manager prompting. */
4011 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4012 FRAME_LINES (f
) = DEFAULT_ROWS
;
4013 /* Window managers expect that if program-specified
4014 positions are not (0,0), they're intentional, not defaults. */
4018 /* Ensure that old new_text_cols and new_text_lines will not override the
4020 /* ++KFS: This was specific to W32, but seems ok for all platforms */
4021 f
->new_text_cols
= f
->new_text_lines
= 0;
4023 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4024 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4025 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4026 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4028 if (!EQ (tem0
, Qunbound
))
4030 CHECK_NUMBER (tem0
);
4031 if (! (0 <= XINT (tem0
) && XINT (tem0
) <= INT_MAX
))
4032 xsignal1 (Qargs_out_of_range
, tem0
);
4033 FRAME_LINES (f
) = XINT (tem0
);
4035 if (!EQ (tem1
, Qunbound
))
4037 CHECK_NUMBER (tem1
);
4038 if (! (0 <= XINT (tem1
) && XINT (tem1
) <= INT_MAX
))
4039 xsignal1 (Qargs_out_of_range
, tem1
);
4040 SET_FRAME_COLS (f
, XINT (tem1
));
4042 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4043 window_prompting
|= USSize
;
4045 window_prompting
|= PSize
;
4048 f
->scroll_bar_actual_width
4049 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4051 /* This used to be done _before_ calling x_figure_window_size, but
4052 since the height is reset here, this was really a no-op. I
4053 assume that moving it here does what Gerd intended (although he
4054 no longer can remember what that was... ++KFS, 2003-03-25. */
4056 /* Add the tool-bar height to the initial frame height so that the
4057 user gets a text display area of the size he specified with -g or
4058 via .Xdefaults. Later changes of the tool-bar height don't
4059 change the frame size. This is done so that users can create
4060 tall Emacs frames without having to guess how tall the tool-bar
4062 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4064 int margin
, relief
, bar_height
;
4066 relief
= (tool_bar_button_relief
>= 0
4067 ? tool_bar_button_relief
4068 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4070 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
4071 margin
= XFASTINT (Vtool_bar_button_margin
);
4072 else if (CONSP (Vtool_bar_button_margin
)
4073 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
4074 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4078 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4079 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4082 compute_fringe_widths (f
, 0);
4084 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4085 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4087 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4088 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4089 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4090 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4092 if (EQ (tem0
, Qminus
))
4095 window_prompting
|= YNegative
;
4097 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4098 && CONSP (XCDR (tem0
))
4099 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem0
)), INT_MAX
))
4101 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4102 window_prompting
|= YNegative
;
4104 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4105 && CONSP (XCDR (tem0
))
4106 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0
))))
4108 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4110 else if (EQ (tem0
, Qunbound
))
4114 CHECK_TYPE_RANGED_INTEGER (int, tem0
);
4115 f
->top_pos
= XINT (tem0
);
4117 window_prompting
|= YNegative
;
4120 if (EQ (tem1
, Qminus
))
4123 window_prompting
|= XNegative
;
4125 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4126 && CONSP (XCDR (tem1
))
4127 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (tem1
)), INT_MAX
))
4129 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4130 window_prompting
|= XNegative
;
4132 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4133 && CONSP (XCDR (tem1
))
4134 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1
))))
4136 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4138 else if (EQ (tem1
, Qunbound
))
4142 CHECK_TYPE_RANGED_INTEGER (int, tem1
);
4143 f
->left_pos
= XINT (tem1
);
4144 if (f
->left_pos
< 0)
4145 window_prompting
|= XNegative
;
4148 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4149 window_prompting
|= USPosition
;
4151 window_prompting
|= PPosition
;
4154 if (window_prompting
& XNegative
)
4156 if (window_prompting
& YNegative
)
4157 f
->win_gravity
= SouthEastGravity
;
4159 f
->win_gravity
= NorthEastGravity
;
4163 if (window_prompting
& YNegative
)
4164 f
->win_gravity
= SouthWestGravity
;
4166 f
->win_gravity
= NorthWestGravity
;
4169 f
->size_hint_flags
= window_prompting
;
4171 return window_prompting
;
4176 #endif /* HAVE_WINDOW_SYSTEM */
4179 frame_make_pointer_invisible (void)
4181 if (! NILP (Vmake_pointer_invisible
))
4184 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4187 f
= SELECTED_FRAME ();
4188 if (f
&& !f
->pointer_invisible
4189 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4192 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4193 f
->pointer_invisible
= 1;
4199 frame_make_pointer_visible (void)
4201 /* We don't check Vmake_pointer_invisible here in case the
4202 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4205 if (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
4208 f
= SELECTED_FRAME ();
4209 if (f
&& f
->pointer_invisible
&& f
->mouse_moved
4210 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4212 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4213 f
->pointer_invisible
= 0;
4217 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4218 Sframe_pointer_visible_p
, 0, 1, 0,
4219 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4220 Otherwise it returns nil. FRAME omitted or nil means the
4221 selected frame. This is useful when `make-pointer-invisible' is set. */)
4224 return decode_any_frame (frame
)->pointer_invisible
? Qnil
: Qt
;
4229 /***********************************************************************
4231 ***********************************************************************/
4233 #ifdef HAVE_WINDOW_SYSTEM
4235 # if (defined HAVE_NS \
4236 || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR)))
4238 free_monitors (struct MonitorInfo
*monitors
, int n_monitors
)
4241 for (i
= 0; i
< n_monitors
; ++i
)
4242 xfree (monitors
[i
].name
);
4248 make_monitor_attribute_list (struct MonitorInfo
*monitors
,
4250 int primary_monitor
,
4251 Lisp_Object monitor_frames
,
4254 Lisp_Object attributes_list
= Qnil
;
4255 Lisp_Object primary_monitor_attributes
= Qnil
;
4258 for (i
= 0; i
< n_monitors
; ++i
)
4260 Lisp_Object geometry
, workarea
, attributes
= Qnil
;
4261 struct MonitorInfo
*mi
= &monitors
[i
];
4263 if (mi
->geom
.width
== 0) continue;
4265 workarea
= list4i (mi
->work
.x
, mi
->work
.y
,
4266 mi
->work
.width
, mi
->work
.height
);
4267 geometry
= list4i (mi
->geom
.x
, mi
->geom
.y
,
4268 mi
->geom
.width
, mi
->geom
.height
);
4269 attributes
= Fcons (Fcons (Qsource
, build_string (source
)),
4271 attributes
= Fcons (Fcons (Qframes
, AREF (monitor_frames
, i
)),
4273 attributes
= Fcons (Fcons (Qmm_size
,
4274 list2i (mi
->mm_width
, mi
->mm_height
)),
4276 attributes
= Fcons (Fcons (Qworkarea
, workarea
), attributes
);
4277 attributes
= Fcons (Fcons (Qgeometry
, geometry
), attributes
);
4279 attributes
= Fcons (Fcons (Qname
, make_string (mi
->name
,
4280 strlen (mi
->name
))),
4283 if (i
== primary_monitor
)
4284 primary_monitor_attributes
= attributes
;
4286 attributes_list
= Fcons (attributes
, attributes_list
);
4289 if (!NILP (primary_monitor_attributes
))
4290 attributes_list
= Fcons (primary_monitor_attributes
, attributes_list
);
4291 return attributes_list
;
4294 #endif /* HAVE_WINDOW_SYSTEM */
4297 /***********************************************************************
4299 ***********************************************************************/
4302 syms_of_frame (void)
4304 DEFSYM (Qframep
, "framep");
4305 DEFSYM (Qframe_live_p
, "frame-live-p");
4306 DEFSYM (Qexplicit_name
, "explicit-name");
4307 DEFSYM (Qheight
, "height");
4308 DEFSYM (Qicon
, "icon");
4309 DEFSYM (Qminibuffer
, "minibuffer");
4310 DEFSYM (Qmodeline
, "modeline");
4311 DEFSYM (Qonly
, "only");
4312 DEFSYM (Qnone
, "none");
4313 DEFSYM (Qwidth
, "width");
4314 DEFSYM (Qgeometry
, "geometry");
4315 DEFSYM (Qicon_left
, "icon-left");
4316 DEFSYM (Qicon_top
, "icon-top");
4317 DEFSYM (Qtooltip
, "tooltip");
4318 DEFSYM (Qleft
, "left");
4319 DEFSYM (Qright
, "right");
4320 DEFSYM (Quser_position
, "user-position");
4321 DEFSYM (Quser_size
, "user-size");
4322 DEFSYM (Qwindow_id
, "window-id");
4323 #ifdef HAVE_X_WINDOWS
4324 DEFSYM (Qouter_window_id
, "outer-window-id");
4326 DEFSYM (Qparent_id
, "parent-id");
4328 DEFSYM (Qw32
, "w32");
4331 DEFSYM (Qvisible
, "visible");
4332 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4333 DEFSYM (Qbuffer_list
, "buffer-list");
4334 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4335 DEFSYM (Qdisplay_type
, "display-type");
4336 DEFSYM (Qbackground_mode
, "background-mode");
4337 DEFSYM (Qnoelisp
, "noelisp");
4338 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4339 DEFSYM (Qtty
, "tty");
4340 DEFSYM (Qtty_type
, "tty-type");
4342 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4344 DEFSYM (Qfullwidth
, "fullwidth");
4345 DEFSYM (Qfullheight
, "fullheight");
4346 DEFSYM (Qfullboth
, "fullboth");
4347 DEFSYM (Qmaximized
, "maximized");
4348 DEFSYM (Qx_resource_name
, "x-resource-name");
4349 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4351 DEFSYM (Qterminal
, "terminal");
4353 DEFSYM (Qgeometry
, "geometry");
4354 DEFSYM (Qworkarea
, "workarea");
4355 DEFSYM (Qmm_size
, "mm-size");
4356 DEFSYM (Qframes
, "frames");
4357 DEFSYM (Qsource
, "source");
4360 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4366 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4368 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4369 if (frame_parms
[i
].variable
)
4371 *frame_parms
[i
].variable
= v
;
4372 staticpro (frame_parms
[i
].variable
);
4374 Fput (v
, Qx_frame_parameter
, make_number (i
));
4378 #ifdef HAVE_WINDOW_SYSTEM
4379 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4380 doc
: /* The name Emacs uses to look up X resources.
4381 `x-get-resource' uses this as the first component of the instance name
4382 when requesting resource values.
4383 Emacs initially sets `x-resource-name' to the name under which Emacs
4384 was invoked, or to the value specified with the `-name' or `-rn'
4385 switches, if present.
4387 It may be useful to bind this variable locally around a call
4388 to `x-get-resource'. See also the variable `x-resource-class'. */);
4389 Vx_resource_name
= Qnil
;
4391 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4392 doc
: /* The class Emacs uses to look up X resources.
4393 `x-get-resource' uses this as the first component of the instance class
4394 when requesting resource values.
4396 Emacs initially sets `x-resource-class' to "Emacs".
4398 Setting this variable permanently is not a reasonable thing to do,
4399 but binding this variable locally around a call to `x-get-resource'
4400 is a reasonable practice. See also the variable `x-resource-name'. */);
4401 Vx_resource_class
= build_string (EMACS_CLASS
);
4403 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4404 doc
: /* The lower limit of the frame opacity (alpha transparency).
4405 The value should range from 0 (invisible) to 100 (completely opaque).
4406 You can also use a floating number between 0.0 and 1.0.
4407 The default is 20. */);
4408 Vframe_alpha_lower_limit
= make_number (20);
4411 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4412 doc
: /* Alist of default values for frame creation.
4413 These may be set in your init file, like this:
4414 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4415 These override values given in window system configuration data,
4416 including X Windows' defaults database.
4417 For values specific to the first Emacs frame, see `initial-frame-alist'.
4418 For window-system specific values, see `window-system-default-frame-alist'.
4419 For values specific to the separate minibuffer frame, see
4420 `minibuffer-frame-alist'.
4421 The `menu-bar-lines' element of the list controls whether new frames
4422 have menu bars; `menu-bar-mode' works by altering this element.
4423 Setting this variable does not affect existing frames, only new ones. */);
4424 Vdefault_frame_alist
= Qnil
;
4426 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4427 doc
: /* Default position of scroll bars on this window-system. */);
4428 #ifdef HAVE_WINDOW_SYSTEM
4429 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
4430 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4432 Vdefault_frame_scroll_bars
= Qright
;
4434 Vdefault_frame_scroll_bars
= Qleft
;
4437 Vdefault_frame_scroll_bars
= Qnil
;
4440 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
4441 scroll_bar_adjust_thumb_portion_p
,
4442 doc
: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
4443 Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
4444 even if the end of the buffer is shown (i.e. overscrolling).
4445 Set to nil if you want the thumb to be at the bottom when the end of the buffer
4446 is shown. Also, the thumb fills the whole scroll bar when the entire buffer
4447 is visible. In this case you can not overscroll. */);
4448 scroll_bar_adjust_thumb_portion_p
= 1;
4450 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4451 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4453 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4454 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4455 `mouse-position' calls this function, passing its usual return value as
4456 argument, and returns whatever this function returns.
4457 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4458 which need to do mouse handling at the Lisp level. */);
4459 Vmouse_position_function
= Qnil
;
4461 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4462 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4463 If the value is an integer, highlighting is only shown after moving the
4464 mouse, while keyboard input turns off the highlight even when the mouse
4465 is over the clickable text. However, the mouse shape still indicates
4466 when the mouse is over clickable text. */);
4467 Vmouse_highlight
= Qt
;
4469 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4470 doc
: /* If non-nil, make pointer invisible while typing.
4471 The pointer becomes visible again when the mouse is moved. */);
4472 Vmake_pointer_invisible
= Qt
;
4474 DEFVAR_LISP ("focus-in-hook", Vfocus_in_hook
,
4475 doc
: /* Normal hook run when a frame gains input focus. */);
4476 Vfocus_in_hook
= Qnil
;
4477 DEFSYM (Qfocus_in_hook
, "focus-in-hook");
4479 DEFVAR_LISP ("focus-out-hook", Vfocus_out_hook
,
4480 doc
: /* Normal hook run when a frame loses input focus. */);
4481 Vfocus_out_hook
= Qnil
;
4482 DEFSYM (Qfocus_out_hook
, "focus-out-hook");
4484 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4485 doc
: /* Functions run before deleting a frame.
4486 The functions are run with one arg, the frame to be deleted.
4489 Note that functions in this list may be called just before the frame is
4490 actually deleted, or some time later (or even both when an earlier function
4491 in `delete-frame-functions' (indirectly) calls `delete-frame'
4493 Vdelete_frame_functions
= Qnil
;
4494 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
4496 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4497 doc
: /* Non-nil if Menu-Bar mode is enabled.
4498 See the command `menu-bar-mode' for a description of this minor mode.
4499 Setting this variable directly does not take effect;
4500 either customize it (see the info node `Easy Customization')
4501 or call the function `menu-bar-mode'. */);
4502 Vmenu_bar_mode
= Qt
;
4504 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4505 doc
: /* Non-nil if Tool-Bar mode is enabled.
4506 See the command `tool-bar-mode' for a description of this minor mode.
4507 Setting this variable directly does not take effect;
4508 either customize it (see the info node `Easy Customization')
4509 or call the function `tool-bar-mode'. */);
4510 #ifdef HAVE_WINDOW_SYSTEM
4511 Vtool_bar_mode
= Qt
;
4513 Vtool_bar_mode
= Qnil
;
4516 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4517 doc
: /* Minibufferless frames use this frame's minibuffer.
4519 Emacs cannot create minibufferless frames unless this is set to an
4520 appropriate surrogate.
4522 Emacs consults this variable only when creating minibufferless
4523 frames; once the frame is created, it sticks with its assigned
4524 minibuffer, no matter what this variable is set to. This means that
4525 this variable doesn't necessarily say anything meaningful about the
4526 current set of frames, or where the minibuffer is currently being
4529 This variable is local to the current terminal and cannot be buffer-local. */);
4531 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
4532 doc
: /* Non-nil if window system changes focus when you move the mouse.
4533 You should set this variable to tell Emacs how your window manager
4534 handles focus, since there is no way in general for Emacs to find out
4535 automatically. See also `mouse-autoselect-window'. */);
4536 focus_follows_mouse
= 0;
4538 staticpro (&Vframe_list
);
4541 defsubr (&Sframe_live_p
);
4542 defsubr (&Swindow_system
);
4543 defsubr (&Smake_terminal_frame
);
4544 defsubr (&Shandle_switch_frame
);
4545 defsubr (&Shandle_focus_in
);
4546 defsubr (&Shandle_focus_out
);
4547 defsubr (&Sselect_frame
);
4548 defsubr (&Sselected_frame
);
4549 defsubr (&Sframe_list
);
4550 defsubr (&Snext_frame
);
4551 defsubr (&Sprevious_frame
);
4552 defsubr (&Slast_nonminibuf_frame
);
4553 defsubr (&Sdelete_frame
);
4554 defsubr (&Smouse_position
);
4555 defsubr (&Smouse_pixel_position
);
4556 defsubr (&Sset_mouse_position
);
4557 defsubr (&Sset_mouse_pixel_position
);
4559 defsubr (&Sframe_configuration
);
4560 defsubr (&Srestore_frame_configuration
);
4562 defsubr (&Smake_frame_visible
);
4563 defsubr (&Smake_frame_invisible
);
4564 defsubr (&Siconify_frame
);
4565 defsubr (&Sframe_visible_p
);
4566 defsubr (&Svisible_frame_list
);
4567 defsubr (&Sraise_frame
);
4568 defsubr (&Slower_frame
);
4569 defsubr (&Sx_focus_frame
);
4570 defsubr (&Sredirect_frame_focus
);
4571 defsubr (&Sframe_focus
);
4572 defsubr (&Sframe_parameters
);
4573 defsubr (&Sframe_parameter
);
4574 defsubr (&Smodify_frame_parameters
);
4575 defsubr (&Sframe_char_height
);
4576 defsubr (&Sframe_char_width
);
4577 defsubr (&Sframe_pixel_height
);
4578 defsubr (&Sframe_pixel_width
);
4579 defsubr (&Stool_bar_pixel_width
);
4580 defsubr (&Sset_frame_height
);
4581 defsubr (&Sset_frame_width
);
4582 defsubr (&Sset_frame_size
);
4583 defsubr (&Sset_frame_position
);
4584 defsubr (&Sframe_pointer_visible_p
);
4586 #ifdef HAVE_WINDOW_SYSTEM
4587 defsubr (&Sx_get_resource
);
4588 defsubr (&Sx_parse_geometry
);