1 /* Generic frame functions.
3 Copyright (C) 1993-1995, 1997, 1999-2018 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 (at
10 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 <https://www.gnu.org/licenses/>. */
31 #ifdef HAVE_WINDOW_SYSTEM
33 #endif /* HAVE_WINDOW_SYSTEM */
36 /* These help us bind and responding to switch-frame events. */
38 #include "ptr-bounds.h"
40 #include "blockinput.h"
42 #include "termhooks.h"
43 #include "dispextern.h"
45 #ifdef HAVE_WINDOW_SYSTEM
57 /* The currently selected frame. */
59 Lisp_Object selected_frame
;
61 /* A frame which is not just a mini-buffer, or NULL if there are no such
62 frames. This is usually the most recent such frame that was selected. */
64 static struct frame
*last_nonminibuf_frame
;
66 /* False means there are no visible garbaged frames. */
69 /* The default tool bar height for future frames. */
70 #if defined USE_GTK || defined HAVE_NS
71 enum { frame_default_tool_bar_height
= 0 };
73 int frame_default_tool_bar_height
;
76 #ifdef HAVE_WINDOW_SYSTEM
77 static void x_report_frame_params (struct frame
*, Lisp_Object
*);
80 /* These setters are used only in this file, so they can be private. */
82 fset_buffer_predicate (struct frame
*f
, Lisp_Object val
)
84 f
->buffer_predicate
= val
;
87 fset_minibuffer_window (struct frame
*f
, Lisp_Object val
)
89 f
->minibuffer_window
= val
;
93 decode_live_frame (register Lisp_Object frame
)
96 frame
= selected_frame
;
97 CHECK_LIVE_FRAME (frame
);
98 return XFRAME (frame
);
102 decode_any_frame (register Lisp_Object frame
)
105 frame
= selected_frame
;
107 return XFRAME (frame
);
110 #ifdef HAVE_WINDOW_SYSTEM
112 display_available (void)
114 return x_display_list
!= NULL
;
119 decode_window_system_frame (Lisp_Object frame
)
121 struct frame
*f
= decode_live_frame (frame
);
122 check_window_system (f
);
123 #ifdef HAVE_WINDOW_SYSTEM
129 check_window_system (struct frame
*f
)
131 #ifdef HAVE_WINDOW_SYSTEM
132 if (window_system_available (f
))
135 error (f
? "Window system frame should be used"
136 : "Window system is not in use or not initialized");
139 /* Return the value of frame parameter PROP in frame FRAME. */
142 get_frame_param (struct frame
*frame
, Lisp_Object prop
)
144 return Fcdr (Fassq (prop
, frame
->param_alist
));
149 frame_size_history_add (struct frame
*f
, Lisp_Object fun_symbol
,
150 int width
, int height
, Lisp_Object rest
)
154 XSETFRAME (frame
, f
);
155 if (CONSP (frame_size_history
)
156 && FIXNUMP (XCAR (frame_size_history
))
157 && 0 < XFIXNUM (XCAR (frame_size_history
)))
159 Fcons (make_fixnum (XFIXNUM (XCAR (frame_size_history
)) - 1),
163 ? list4 (make_fixnum (FRAME_TEXT_WIDTH (f
)),
164 make_fixnum (FRAME_TEXT_HEIGHT (f
)),
166 make_fixnum (height
))
169 XCDR (frame_size_history
)));
173 /* Return 1 if `frame-inhibit-implied-resize' is non-nil or fullscreen
174 state of frame F would be affected by a vertical (horizontal if
175 HORIZONTAL is true) resize. PARAMETER is the symbol of the frame
176 parameter that is changed. */
178 frame_inhibit_resize (struct frame
*f
, bool horizontal
, Lisp_Object parameter
)
180 Lisp_Object fullscreen
= get_frame_param (f
, Qfullscreen
);
182 = (f
->after_make_frame
183 ? (EQ (frame_inhibit_implied_resize
, Qt
)
184 || (CONSP (frame_inhibit_implied_resize
)
185 && !NILP (Fmemq (parameter
, frame_inhibit_implied_resize
)))
187 && !NILP (fullscreen
) && !EQ (fullscreen
, Qfullheight
))
189 && !NILP (fullscreen
) && !EQ (fullscreen
, Qfullwidth
))
190 || FRAME_TERMCAP_P (f
) || FRAME_MSDOS_P (f
))
191 : ((horizontal
&& f
->inhibit_horizontal_resize
)
192 || (!horizontal
&& f
->inhibit_vertical_resize
)));
193 if (inhibit
&& !FRAME_TERMCAP_P (f
) && !FRAME_MSDOS_P (f
))
194 frame_size_history_add
195 (f
, Qframe_inhibit_resize
, 0, 0,
196 list5 (horizontal
? Qt
: Qnil
, parameter
,
197 f
->after_make_frame
? Qt
: Qnil
,
198 frame_inhibit_implied_resize
,
205 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
208 int olines
= FRAME_MENU_BAR_LINES (f
);
210 /* Right now, menu bars don't work properly in minibuf-only frames;
211 most of the commands try to apply themselves to the minibuffer
212 frame itself, and get an error because you can't switch buffers
213 in or split the minibuffer window. */
214 if (FRAME_MINIBUF_ONLY_P (f
))
217 if (TYPE_RANGED_FIXNUMP (int, value
))
218 nlines
= XFIXNUM (value
);
222 if (nlines
!= olines
)
224 windows_or_buffers_changed
= 14;
225 FRAME_MENU_BAR_LINES (f
) = nlines
;
226 FRAME_MENU_BAR_HEIGHT (f
) = nlines
* FRAME_LINE_HEIGHT (f
);
227 change_frame_size (f
, FRAME_COLS (f
),
228 FRAME_LINES (f
) + olines
- nlines
,
233 Lisp_Object Vframe_list
;
236 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
237 doc
: /* Return non-nil if OBJECT is a frame.
239 t for a termcap frame (a character-only terminal),
240 `x' for an Emacs frame that is really an X window,
241 `w32' for an Emacs frame that is a window on MS-Windows display,
242 `ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
243 `pc' for a direct-write MS-DOS frame.
244 See also `frame-live-p'. */)
247 if (!FRAMEP (object
))
249 switch (XFRAME (object
)->output_method
)
251 case output_initial
: /* The initial frame is like a termcap frame. */
254 case output_x_window
:
258 case output_msdos_raw
:
267 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
268 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
269 Value is nil if OBJECT is not a live frame. If object is a live
270 frame, the return value indicates what sort of terminal device it is
271 displayed on. See the documentation of `framep' for possible
275 return ((FRAMEP (object
)
276 && FRAME_LIVE_P (XFRAME (object
)))
281 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
282 doc
: /* The name of the window system that FRAME is displaying through.
283 The value is a symbol:
284 nil for a termcap frame (a character-only terminal),
285 `x' for an Emacs frame that is really an X window,
286 `w32' for an Emacs frame that is a window on MS-Windows display,
287 `ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
288 `pc' for a direct-write MS-DOS frame.
290 FRAME defaults to the currently selected frame.
292 Use of this function as a predicate is deprecated. Instead,
293 use `display-graphic-p' or any of the other `display-*-p'
294 predicates which report frame's specific UI-related capabilities. */)
299 frame
= selected_frame
;
301 type
= Fframep (frame
);
304 wrong_type_argument (Qframep
, frame
);
312 /* Placeholder used by temacs -nw before window.el is loaded. */
313 DEFUN ("frame-windows-min-size", Fframe_windows_min_size
,
314 Sframe_windows_min_size
, 4, 4, 0,
315 doc
: /* SKIP: real doc in window.el. */
317 (Lisp_Object frame
, Lisp_Object horizontal
,
318 Lisp_Object ignore
, Lisp_Object pixelwise
)
320 return make_fixnum (0);
324 * frame_windows_min_size:
326 * Return the minimum number of lines (columns if HORIZONTAL is non-nil)
327 * of FRAME. If PIXELWISE is non-nil, return the minimum inner height
328 * (width) of FRAME in pixels.
330 * This value is calculated by the function `frame-windows-min-size' in
331 * window.el unless the `min-height' (`min-width' if HORIZONTAL is
332 * non-nil) parameter of FRAME is non-nil thus explicitly specifying the
333 * value to be returned. In that latter case IGNORE is ignored.
335 * If `frame-windows-min-size' is called, it will make sure that the
336 * return value accommodates all windows of FRAME respecting the values
337 * of `window-min-height' (`window-min-width' if HORIZONTAL is non-nil).
338 * With IGNORE non-nil the values of these variables are ignored.
340 * In either case, never return a value less than 1. For TTY frames,
341 * additionally limit the minimum frame height to a value large enough
342 * to support the menu bar, the mode line, and the echo area.
345 frame_windows_min_size (Lisp_Object frame
, Lisp_Object horizontal
,
346 Lisp_Object ignore
, Lisp_Object pixelwise
)
348 struct frame
*f
= XFRAME (frame
);
349 Lisp_Object par_size
;
352 if ((!NILP (horizontal
)
353 && RANGED_FIXNUMP (INT_MIN
,
354 par_size
= get_frame_param (f
, Qmin_width
),
356 || (NILP (horizontal
)
357 && RANGED_FIXNUMP (INT_MIN
,
358 par_size
= get_frame_param (f
, Qmin_height
),
361 int min_size
= XFIXNUM (par_size
);
363 /* Don't allow phantom frames. */
367 retval
= (NILP (pixelwise
)
369 : min_size
* (NILP (horizontal
)
370 ? FRAME_LINE_HEIGHT (f
)
371 : FRAME_COLUMN_WIDTH (f
)));
374 retval
= XFIXNUM (call4 (Qframe_windows_min_size
, frame
, horizontal
,
376 /* Don't allow too small height of text-mode frames, or else cm.c
377 might abort in cmcheckmagic. */
378 if ((FRAME_TERMCAP_P (f
) || FRAME_MSDOS_P (f
)) && NILP (horizontal
))
380 int min_height
= (FRAME_MENU_BAR_LINES (f
)
381 + FRAME_WANTS_MODELINE_P (f
)
382 + 2); /* one text line and one echo-area line */
383 if (retval
< min_height
)
391 #ifdef HAVE_WINDOW_SYSTEM
395 * Preserve ratios of frame F which usually happens after its parent
396 * frame P got resized. OLD_WIDTH, OLD_HEIGHT specifies the old native
397 * size of F's parent, NEW_WIDTH and NEW_HEIGHT its new size.
399 * Adjust F's width if F's 'keep_ratio' parameter is non-nil and, if
400 * it is a cons, its car is not 'height-only'. Adjust F's height if F's
401 * 'keep_ratio' parameter is non-nil and, if it is a cons, its car
402 * is not 'width-only'.
404 * Adjust F's left position if F's 'keep_ratio' parameter is non-nil
405 * and, if its is a cons, its cdr is non-nil and not 'top-only'. Adjust
406 * F's top position if F's 'keep_ratio' parameter is non-nil and, if
407 * its is a cons, its cdr is non-nil and not 'left-only'.
409 * Note that when positional adjustment is requested but the size of F
410 * should remain unaltered in the corresponding direction, this routine
411 * tries to constrain F to its parent frame - something which usually
412 * happens when the parent frame shrinks. This means, however, that
413 * when the parent frame is re-enlarged later, the child's original
414 * position will not get restored to its pre-shrinking value.
416 * This routine is currently useful for child frames only. It might be
417 * eventually useful when moving non-child frames between monitors with
418 * different resolutions.
421 keep_ratio (struct frame
*f
, struct frame
*p
, int old_width
, int old_height
,
422 int new_width
, int new_height
)
424 Lisp_Object keep_ratio
= get_frame_param (f
, Qkeep_ratio
);
427 if (!NILP (keep_ratio
))
429 double width_factor
= (double)new_width
/ (double)old_width
;
430 double height_factor
= (double)new_height
/ (double)old_height
;
431 int pixel_width
, pixel_height
, pos_x
, pos_y
;
433 if (!CONSP (keep_ratio
) || !NILP (Fcdr (keep_ratio
)))
435 if (CONSP (keep_ratio
) && EQ (Fcdr (keep_ratio
), Qtop_only
))
439 pos_x
= (int)(f
->left_pos
* width_factor
+ 0.5);
441 if (CONSP (keep_ratio
)
442 && (NILP (Fcar (keep_ratio
))
443 || EQ (Fcar (keep_ratio
), Qheight_only
))
444 && p
->pixel_width
- f
->pixel_width
< pos_x
)
446 int p_f_width
= p
->pixel_width
- f
->pixel_width
;
451 pos_x
= (int)(p_f_width
* width_factor
* 0.5 + 0.5);
457 if (CONSP (keep_ratio
) && EQ (Fcdr (keep_ratio
), Qleft_only
))
461 pos_y
= (int)(f
->top_pos
* height_factor
+ 0.5);
463 if (CONSP (keep_ratio
)
464 && (NILP (Fcar (keep_ratio
))
465 || EQ (Fcar (keep_ratio
), Qwidth_only
))
466 && p
->pixel_height
- f
->pixel_height
< pos_y
)
467 /* When positional adjustment was requested and the
468 width of F should remain unaltered, try to constrain
469 F to its parent. This means that when the parent
470 frame is enlarged later the child's original position
471 won't get restored. */
473 int p_f_height
= p
->pixel_height
- f
->pixel_height
;
478 pos_y
= (int)(p_f_height
* height_factor
* 0.5 + 0.5);
484 x_set_offset (f
, pos_x
, pos_y
, -1);
487 if (!CONSP (keep_ratio
) || !NILP (Fcar (keep_ratio
)))
489 if (CONSP (keep_ratio
) && EQ (Fcar (keep_ratio
), Qheight_only
))
493 pixel_width
= (int)(f
->pixel_width
* width_factor
+ 0.5);
494 pixel_width
= FRAME_PIXEL_TO_TEXT_WIDTH (f
, pixel_width
);
497 if (CONSP (keep_ratio
) && EQ (Fcar (keep_ratio
), Qwidth_only
))
501 pixel_height
= (int)(f
->pixel_height
* height_factor
+ 0.5);
502 pixel_height
= FRAME_PIXEL_TO_TEXT_HEIGHT (f
, pixel_height
);
505 adjust_frame_size (f
, pixel_width
, pixel_height
, 1, 0,
516 * Adjust size of frame F. NEW_WIDTH and NEW_HEIGHT specify the new
517 * text size of F in pixels. A value of -1 means no change is requested
518 * for that direction (but the frame may still have to be resized to
519 * accommodate windows with their minimum sizes). This can either issue
520 * a request to resize the frame externally (via x_set_window_size), to
521 * resize the frame internally (via resize_frame_windows) or do nothing
524 * The argument INHIBIT can assume the following values:
526 * 0 means to unconditionally call x_set_window_size even if sizes
527 * apparently do not change. Fx_create_frame uses this to pass the
528 * initial size to the window manager.
530 * 1 means to call x_set_window_size if the native frame size really
531 * changes. Fset_frame_size, Fset_frame_height, ... use this.
533 * 2 means to call x_set_window_size provided frame_inhibit_resize
534 * allows it. The menu and tool bar code use this ("3" won't work
535 * here in general because menu and tool bar are often not counted in
536 * the frame's text height).
538 * 3 means call x_set_window_size if window minimum sizes must be
539 * preserved or frame_inhibit_resize allows it. x_set_left_fringe,
540 * x_set_scroll_bar_width, x_new_font ... use (or should use) this.
542 * 4 means call x_set_window_size only if window minimum sizes must be
543 * preserved. x_set_right_divider_width, x_set_border_width and the
544 * code responsible for wrapping the tool bar use this.
546 * 5 means to never call x_set_window_size. change_frame_size uses
549 * Note that even when x_set_window_size is not called, individual
550 * windows may have to be resized (via `window--sanitize-window-sizes')
551 * in order to support minimum size constraints.
553 * PRETEND is as for change_frame_size. PARAMETER, if non-nil, is the
554 * symbol of the parameter changed (like `menu-bar-lines', `font', ...).
555 * This is passed on to frame_inhibit_resize to let the latter decide on
556 * a case-by-case basis whether the frame may be resized externally.
559 adjust_frame_size (struct frame
*f
, int new_width
, int new_height
, int inhibit
,
560 bool pretend
, Lisp_Object parameter
)
562 int unit_width
= FRAME_COLUMN_WIDTH (f
);
563 int unit_height
= FRAME_LINE_HEIGHT (f
);
564 int old_pixel_width
= FRAME_PIXEL_WIDTH (f
);
565 int old_pixel_height
= FRAME_PIXEL_HEIGHT (f
);
566 int old_cols
= FRAME_COLS (f
);
567 int old_lines
= FRAME_LINES (f
);
568 int new_pixel_width
, new_pixel_height
;
569 /* The following two values are calculated from the old frame pixel
570 sizes and any "new" settings for tool bar, menu bar and internal
571 borders. We do it this way to detect whether we have to call
572 x_set_window_size as consequence of the new settings. */
573 int windows_width
= FRAME_WINDOWS_WIDTH (f
);
574 int windows_height
= FRAME_WINDOWS_HEIGHT (f
);
575 int min_windows_width
, min_windows_height
;
576 /* These are a bit tedious, maybe we should use a macro. */
577 struct window
*r
= XWINDOW (FRAME_ROOT_WINDOW (f
));
578 int old_windows_width
= WINDOW_PIXEL_WIDTH (r
);
579 int old_windows_height
580 = (WINDOW_PIXEL_HEIGHT (r
)
581 + ((FRAME_HAS_MINIBUF_P (f
) && !FRAME_MINIBUF_ONLY_P (f
))
582 ? WINDOW_PIXEL_HEIGHT (XWINDOW (FRAME_MINIBUF_WINDOW (f
)))
584 int new_windows_width
, new_windows_height
;
585 int old_text_width
= FRAME_TEXT_WIDTH (f
);
586 int old_text_height
= FRAME_TEXT_HEIGHT (f
);
587 /* If a size is < 0 use the old value. */
588 int new_text_width
= (new_width
>= 0) ? new_width
: old_text_width
;
589 int new_text_height
= (new_height
>= 0) ? new_height
: old_text_height
;
590 int new_cols
, new_lines
;
591 bool inhibit_horizontal
, inhibit_vertical
;
594 XSETFRAME (frame
, f
);
596 frame_size_history_add
597 (f
, Qadjust_frame_size_1
, new_text_width
, new_text_height
,
598 list2 (parameter
, make_fixnum (inhibit
)));
600 /* The following two values are calculated from the old window body
601 sizes and any "new" settings for scroll bars, dividers, fringes and
602 margins (though the latter should have been processed already). */
604 = frame_windows_min_size (frame
, Qt
, (inhibit
== 5) ? Qt
: Qnil
, Qt
);
606 = frame_windows_min_size (frame
, Qnil
, (inhibit
== 5) ? Qt
: Qnil
, Qt
);
608 if (inhibit
>= 2 && inhibit
<= 4)
609 /* When INHIBIT is in [2..4] inhibit if the "old" window sizes stay
610 within the limits and either resizing is inhibited or INHIBIT
613 inhibit_horizontal
= (windows_width
>= min_windows_width
615 || frame_inhibit_resize (f
, true, parameter
)));
616 inhibit_vertical
= (windows_height
>= min_windows_height
618 || frame_inhibit_resize (f
, false, parameter
)));
621 /* Otherwise inhibit if INHIBIT equals 5. */
622 inhibit_horizontal
= inhibit_vertical
= inhibit
== 5;
624 new_pixel_width
= ((inhibit_horizontal
&& (inhibit
< 5))
626 : max (FRAME_TEXT_TO_PIXEL_WIDTH (f
, new_text_width
),
628 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
629 new_windows_width
= new_pixel_width
- 2 * FRAME_INTERNAL_BORDER_WIDTH (f
);
630 new_text_width
= FRAME_PIXEL_TO_TEXT_WIDTH (f
, new_pixel_width
);
631 new_cols
= new_text_width
/ unit_width
;
633 new_pixel_height
= ((inhibit_vertical
&& (inhibit
< 5))
635 : max (FRAME_TEXT_TO_PIXEL_HEIGHT (f
, new_text_height
),
637 + FRAME_TOP_MARGIN_HEIGHT (f
)
638 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
639 new_windows_height
= (new_pixel_height
640 - FRAME_TOP_MARGIN_HEIGHT (f
)
641 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f
));
642 new_text_height
= FRAME_PIXEL_TO_TEXT_HEIGHT (f
, new_pixel_height
);
643 new_lines
= new_text_height
/ unit_height
;
645 #ifdef HAVE_WINDOW_SYSTEM
646 if (FRAME_WINDOW_P (f
)
647 && f
->can_x_set_window_size
648 && ((!inhibit_horizontal
649 && (new_pixel_width
!= old_pixel_width
650 || inhibit
== 0 || inhibit
== 2))
651 || (!inhibit_vertical
652 && (new_pixel_height
!= old_pixel_height
653 || inhibit
== 0 || inhibit
== 2))))
654 /* We are either allowed to change the frame size or the minimum
655 sizes request such a change. Do not care for fixing minimum
656 sizes here, we do that eventually when we're called from
657 change_frame_size. */
659 /* Make sure we respect fullheight and fullwidth. */
660 if (inhibit_horizontal
)
661 new_text_width
= old_text_width
;
662 else if (inhibit_vertical
)
663 new_text_height
= old_text_height
;
665 frame_size_history_add
666 (f
, Qadjust_frame_size_2
, new_text_width
, new_text_height
,
667 list2 (inhibit_horizontal
? Qt
: Qnil
,
668 inhibit_vertical
? Qt
: Qnil
));
670 x_set_window_size (f
, 0, new_text_width
, new_text_height
, 1);
677 if (new_text_width
== old_text_width
678 && new_text_height
== old_text_height
679 && new_windows_width
== old_windows_width
680 && new_windows_height
== old_windows_height
681 && new_pixel_width
== old_pixel_width
682 && new_pixel_height
== old_pixel_height
683 && new_cols
== old_cols
684 && new_lines
== old_lines
)
685 /* No change. Sanitize window sizes and return. */
687 sanitize_window_sizes (Qt
);
688 sanitize_window_sizes (Qnil
);
696 /* We only can set screen dimensions to certain values supported by
697 our video hardware. Try to find the smallest size greater or
698 equal to the requested dimensions, while accounting for the fact
699 that the menu-bar lines are not counted in the frame height. */
700 int dos_new_lines
= new_lines
+ FRAME_TOP_MARGIN (f
);
701 dos_set_window_size (&dos_new_lines
, &new_cols
);
702 new_lines
= dos_new_lines
- FRAME_TOP_MARGIN (f
);
705 if (new_windows_width
!= old_windows_width
)
707 resize_frame_windows (f
, new_windows_width
, 1, 1);
709 /* MSDOS frames cannot PRETEND, as they change frame size by
710 manipulating video hardware. */
711 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
712 FrameCols (FRAME_TTY (f
)) = new_cols
;
714 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
715 if (WINDOWP (f
->tool_bar_window
))
717 XWINDOW (f
->tool_bar_window
)->pixel_width
= new_windows_width
;
718 XWINDOW (f
->tool_bar_window
)->total_cols
719 = new_windows_width
/ unit_width
;
723 else if (new_cols
!= old_cols
)
724 call2 (Qwindow__pixel_to_total
, frame
, Qt
);
726 if (new_windows_height
!= old_windows_height
727 /* When the top margin has changed we have to recalculate the top
728 edges of all windows. No such calculation is necessary for the
730 || WINDOW_TOP_PIXEL_EDGE (r
) != FRAME_TOP_MARGIN_HEIGHT (f
))
732 resize_frame_windows (f
, new_windows_height
, 0, 1);
734 /* MSDOS frames cannot PRETEND, as they change frame size by
735 manipulating video hardware. */
736 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
737 FrameRows (FRAME_TTY (f
)) = new_lines
+ FRAME_TOP_MARGIN (f
);
739 else if (new_lines
!= old_lines
)
740 call2 (Qwindow__pixel_to_total
, frame
, Qnil
);
742 frame_size_history_add
743 (f
, Qadjust_frame_size_3
, new_text_width
, new_text_height
,
744 list4 (make_fixnum (old_pixel_width
), make_fixnum (old_pixel_height
),
745 make_fixnum (new_pixel_width
), make_fixnum (new_pixel_height
)));
747 /* Assign new sizes. */
748 FRAME_TEXT_WIDTH (f
) = new_text_width
;
749 FRAME_TEXT_HEIGHT (f
) = new_text_height
;
750 FRAME_PIXEL_WIDTH (f
) = new_pixel_width
;
751 FRAME_PIXEL_HEIGHT (f
) = new_pixel_height
;
752 SET_FRAME_COLS (f
, new_cols
);
753 SET_FRAME_LINES (f
, new_lines
);
756 struct window
*w
= XWINDOW (FRAME_SELECTED_WINDOW (f
));
757 int text_area_x
, text_area_y
, text_area_width
, text_area_height
;
759 window_box (w
, TEXT_AREA
, &text_area_x
, &text_area_y
, &text_area_width
,
761 if (w
->cursor
.x
>= text_area_x
+ text_area_width
)
762 w
->cursor
.hpos
= w
->cursor
.x
= 0;
763 if (w
->cursor
.y
>= text_area_y
+ text_area_height
)
764 w
->cursor
.vpos
= w
->cursor
.y
= 0;
767 /* Sanitize window sizes. */
768 sanitize_window_sizes (Qt
);
769 sanitize_window_sizes (Qnil
);
771 adjust_frame_glyphs (f
);
773 SET_FRAME_GARBAGED (f
);
775 /* A frame was "resized" if one of its pixelsizes changed, even if its
776 X window wasn't resized at all. */
777 f
->resized_p
= (new_pixel_width
!= old_pixel_width
778 || new_pixel_height
!= old_pixel_height
);
782 #ifdef HAVE_WINDOW_SYSTEM
784 /* Adjust size of F's child frames. */
785 Lisp_Object frames
, frame1
;
787 FOR_EACH_FRAME (frames
, frame1
)
788 if (FRAME_PARENT_FRAME (XFRAME (frame1
)) == f
)
789 keep_ratio (XFRAME (frame1
), f
, old_pixel_width
, old_pixel_height
,
790 new_pixel_width
, new_pixel_height
);
795 /* Allocate basically initialized frame. */
797 static struct frame
*
798 allocate_frame (void)
800 return ALLOCATE_ZEROED_PSEUDOVECTOR (struct frame
, face_cache
, PVEC_FRAME
);
804 make_frame (bool mini_p
)
808 struct window
*rw
, *mw UNINIT
;
809 Lisp_Object root_window
;
810 Lisp_Object mini_window
;
812 f
= allocate_frame ();
813 XSETFRAME (frame
, f
);
816 /* Initialize Lisp data. Note that allocate_frame initializes all
817 Lisp data to nil, so do it only for slots which should not be nil. */
818 fset_tool_bar_position (f
, Qtop
);
821 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
822 non-Lisp data, so do it only for slots which should not be zero.
823 To avoid subtle bugs and for the sake of readability, it's better to
824 initialize enum members explicitly even if their values are zero. */
825 f
->wants_modeline
= true;
828 f
->can_x_set_window_size
= false;
829 f
->after_make_frame
= false;
830 f
->inhibit_horizontal_resize
= false;
831 f
->inhibit_vertical_resize
= false;
832 f
->tool_bar_redisplayed
= false;
833 f
->tool_bar_resized
= false;
834 f
->column_width
= 1; /* !FRAME_WINDOW_P value. */
835 f
->line_height
= 1; /* !FRAME_WINDOW_P value. */
836 #ifdef HAVE_WINDOW_SYSTEM
837 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
838 f
->horizontal_scroll_bars
= false;
839 f
->want_fullscreen
= FULLSCREEN_NONE
;
840 f
->undecorated
= false;
841 f
->no_special_glyphs
= false;
843 f
->override_redirect
= false;
845 f
->skip_taskbar
= false;
846 f
->no_focus_on_map
= false;
847 f
->no_accept_focus
= false;
848 f
->z_group
= z_group_none
;
850 #if ! defined (USE_GTK) && ! defined (HAVE_NS)
851 f
->last_tool_bar_item
= -1;
854 f
->ns_appearance
= ns_appearance_aqua
;
855 f
->ns_transparent_titlebar
= false;
859 root_window
= make_window ();
860 rw
= XWINDOW (root_window
);
863 mini_window
= make_window ();
864 mw
= XWINDOW (mini_window
);
865 wset_next (rw
, mini_window
);
866 wset_prev (mw
, root_window
);
868 wset_frame (mw
, frame
);
869 fset_minibuffer_window (f
, mini_window
);
870 store_frame_param (f
, Qminibuffer
, Qt
);
875 wset_next (rw
, Qnil
);
876 fset_minibuffer_window (f
, Qnil
);
879 wset_frame (rw
, frame
);
882 just so that there is "something there."
883 Correct size will be set up later with adjust_frame_size. */
885 SET_FRAME_COLS (f
, 10);
886 SET_FRAME_LINES (f
, 10);
887 SET_FRAME_WIDTH (f
, FRAME_COLS (f
) * FRAME_COLUMN_WIDTH (f
));
888 SET_FRAME_HEIGHT (f
, FRAME_LINES (f
) * FRAME_LINE_HEIGHT (f
));
891 rw
->pixel_width
= rw
->total_cols
* FRAME_COLUMN_WIDTH (f
);
892 rw
->total_lines
= mini_p
? 9 : 10;
893 rw
->pixel_height
= rw
->total_lines
* FRAME_LINE_HEIGHT (f
);
897 mw
->top_line
= rw
->total_lines
;
898 mw
->pixel_top
= rw
->pixel_height
;
899 mw
->total_cols
= rw
->total_cols
;
900 mw
->pixel_width
= rw
->pixel_width
;
902 mw
->pixel_height
= FRAME_LINE_HEIGHT (f
);
905 /* Choose a buffer for the frame's root window. */
907 Lisp_Object buf
= Fcurrent_buffer ();
909 /* If current buffer is hidden, try to find another one. */
910 if (BUFFER_HIDDEN_P (XBUFFER (buf
)))
911 buf
= other_buffer_safely (buf
);
913 /* Use set_window_buffer, not Fset_window_buffer, and don't let
914 hooks be run by it. The reason is that the whole frame/window
915 arrangement is not yet fully initialized at this point. Windows
916 don't have the right size, glyph matrices aren't initialized
917 etc. Running Lisp functions at this point surely ends in a
919 set_window_buffer (root_window
, buf
, 0, 0);
920 fset_buffer_list (f
, list1 (buf
));
925 set_window_buffer (mini_window
,
926 (NILP (Vminibuffer_list
)
928 : Fcar (Vminibuffer_list
)),
930 /* No horizontal scroll bars in minibuffers. */
931 wset_horizontal_scroll_bar (mw
, Qnil
);
934 fset_root_window (f
, root_window
);
935 fset_selected_window (f
, root_window
);
936 /* Make sure this window seems more recently used than
937 a newly-created, never-selected window. */
938 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
943 #ifdef HAVE_WINDOW_SYSTEM
944 /* Make a frame using a separate minibuffer window on another frame.
945 MINI_WINDOW is the minibuffer window to use. nil means use the
946 default (the global minibuffer). */
949 make_frame_without_minibuffer (Lisp_Object mini_window
, KBOARD
*kb
,
954 if (!NILP (mini_window
))
955 CHECK_LIVE_WINDOW (mini_window
);
957 if (!NILP (mini_window
)
958 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
959 error ("Frame and minibuffer must be on the same terminal");
961 /* Make a frame containing just a root window. */
964 if (NILP (mini_window
))
966 /* Use default-minibuffer-frame if possible. */
967 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
968 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
970 Lisp_Object frame_dummy
;
972 XSETFRAME (frame_dummy
, f
);
973 /* If there's no minibuffer frame to use, create one. */
974 kset_default_minibuffer_frame
975 (kb
, call1 (intern ("make-initial-minibuffer-frame"), display
));
979 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
982 fset_minibuffer_window (f
, mini_window
);
983 store_frame_param (f
, Qminibuffer
, mini_window
);
985 /* Make the chosen minibuffer window display the proper minibuffer,
986 unless it is already showing a minibuffer. */
987 if (NILP (Fmemq (XWINDOW (mini_window
)->contents
, Vminibuffer_list
)))
988 /* Use set_window_buffer instead of Fset_window_buffer (see
989 discussion of bug#11984, bug#12025, bug#12026). */
990 set_window_buffer (mini_window
,
991 (NILP (Vminibuffer_list
)
993 : Fcar (Vminibuffer_list
)), 0, 0);
997 /* Make a frame containing only a minibuffer window. */
1000 make_minibuffer_frame (void)
1002 /* First make a frame containing just a root window, no minibuffer. */
1004 register struct frame
*f
= make_frame (0);
1005 register Lisp_Object mini_window
;
1006 register Lisp_Object frame
;
1008 XSETFRAME (frame
, f
);
1013 f
->wants_modeline
= 0;
1015 /* Now label the root window as also being the minibuffer.
1016 Avoid infinite looping on the window chain by marking next pointer
1019 mini_window
= f
->root_window
;
1020 fset_minibuffer_window (f
, mini_window
);
1021 store_frame_param (f
, Qminibuffer
, Qonly
);
1022 XWINDOW (mini_window
)->mini
= 1;
1023 wset_next (XWINDOW (mini_window
), Qnil
);
1024 wset_prev (XWINDOW (mini_window
), Qnil
);
1025 wset_frame (XWINDOW (mini_window
), frame
);
1027 /* Put the proper buffer in that window. */
1029 /* Use set_window_buffer instead of Fset_window_buffer (see
1030 discussion of bug#11984, bug#12025, bug#12026). */
1031 set_window_buffer (mini_window
,
1032 (NILP (Vminibuffer_list
)
1033 ? get_minibuffer (0)
1034 : Fcar (Vminibuffer_list
)), 0, 0);
1037 #endif /* HAVE_WINDOW_SYSTEM */
1039 /* Construct a frame that refers to a terminal. */
1041 static printmax_t tty_frame_count
;
1044 make_initial_frame (void)
1047 struct terminal
*terminal
;
1050 eassert (initial_kboard
);
1052 /* The first call must initialize Vframe_list. */
1053 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
1056 terminal
= init_initial_terminal ();
1059 XSETFRAME (frame
, f
);
1061 Vframe_list
= Fcons (frame
, Vframe_list
);
1063 tty_frame_count
= 1;
1064 fset_name (f
, build_pure_c_string ("F1"));
1066 SET_FRAME_VISIBLE (f
, 1);
1068 f
->output_method
= terminal
->type
;
1069 f
->terminal
= terminal
;
1070 f
->terminal
->reference_count
++;
1071 f
->output_data
.nothing
= 0;
1073 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
1074 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
1076 #ifdef HAVE_WINDOW_SYSTEM
1077 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
1078 f
->horizontal_scroll_bars
= false;
1081 /* The default value of menu-bar-mode is t. */
1082 set_menu_bar_lines (f
, make_fixnum (1), Qnil
);
1084 /* Allocate glyph matrices. */
1085 adjust_frame_glyphs (f
);
1087 if (!noninteractive
)
1088 init_frame_faces (f
);
1090 last_nonminibuf_frame
= f
;
1092 f
->can_x_set_window_size
= true;
1093 f
->after_make_frame
= true;
1099 static struct frame
*
1100 make_terminal_frame (struct terminal
*terminal
)
1102 register struct frame
*f
;
1104 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
1106 if (!terminal
->name
)
1107 error ("Terminal is not live, can't create new frames on it");
1111 XSETFRAME (frame
, f
);
1112 Vframe_list
= Fcons (frame
, Vframe_list
);
1114 fset_name (f
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
1116 SET_FRAME_VISIBLE (f
, 1);
1118 f
->terminal
= terminal
;
1119 f
->terminal
->reference_count
++;
1121 f
->output_data
.tty
->display_info
= &the_only_display_info
;
1122 if (!inhibit_window_system
1123 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
1124 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
1125 f
->output_method
= output_msdos_raw
;
1127 f
->output_method
= output_termcap
;
1128 #else /* not MSDOS */
1129 f
->output_method
= output_termcap
;
1130 create_tty_output (f
);
1131 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
1132 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
1133 #endif /* not MSDOS */
1135 #ifdef HAVE_WINDOW_SYSTEM
1136 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
1137 f
->horizontal_scroll_bars
= false;
1140 FRAME_MENU_BAR_LINES (f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
1141 FRAME_LINES (f
) = FRAME_LINES (f
) - FRAME_MENU_BAR_LINES (f
);
1142 FRAME_MENU_BAR_HEIGHT (f
) = FRAME_MENU_BAR_LINES (f
) * FRAME_LINE_HEIGHT (f
);
1143 FRAME_TEXT_HEIGHT (f
) = FRAME_TEXT_HEIGHT (f
) - FRAME_MENU_BAR_HEIGHT (f
);
1145 /* Set the top frame to the newly created frame. */
1146 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
1147 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
1148 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f
)->top_frame
), 2); /* obscured */
1150 FRAME_TTY (f
)->top_frame
= frame
;
1152 if (!noninteractive
)
1153 init_frame_faces (f
);
1158 /* Get a suitable value for frame parameter PARAMETER for a newly
1159 created frame, based on (1) the user-supplied frame parameter
1160 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
1163 get_future_frame_param (Lisp_Object parameter
,
1164 Lisp_Object supplied_parms
,
1165 char *current_value
)
1169 result
= Fassq (parameter
, supplied_parms
);
1171 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
1172 if (NILP (result
) && current_value
!= NULL
)
1173 result
= build_string (current_value
);
1174 if (!NILP (result
) && !STRINGP (result
))
1175 result
= XCDR (result
);
1176 if (NILP (result
) || !STRINGP (result
))
1182 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
1184 doc
: /* Create an additional terminal frame, possibly on another terminal.
1185 This function takes one argument, an alist specifying frame parameters.
1187 You can create multiple frames on a single text terminal, but only one
1188 of them (the selected terminal frame) is actually displayed.
1190 In practice, generally you don't need to specify any parameters,
1191 except when you want to create a new frame on another terminal.
1192 In that case, the `tty' parameter specifies the device file to open,
1193 and the `tty-type' parameter specifies the terminal type. Example:
1195 (make-terminal-frame \\='((tty . "/dev/pts/5") (tty-type . "xterm")))
1197 Note that changing the size of one terminal frame automatically
1198 affects all frames on the same terminal device. */)
1202 struct terminal
*t
= NULL
;
1203 Lisp_Object frame
, tem
;
1204 struct frame
*sf
= SELECTED_FRAME ();
1207 if (sf
->output_method
!= output_msdos_raw
1208 && sf
->output_method
!= output_termcap
)
1210 #else /* not MSDOS */
1212 #ifdef WINDOWSNT /* This should work now! */
1213 if (sf
->output_method
!= output_termcap
)
1214 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
1216 #endif /* not MSDOS */
1219 Lisp_Object terminal
;
1221 terminal
= Fassq (Qterminal
, parms
);
1222 if (CONSP (terminal
))
1224 terminal
= XCDR (terminal
);
1225 t
= decode_live_terminal (terminal
);
1228 if (t
&& t
!= the_only_display_info
.terminal
)
1229 /* msdos.c assumes a single tty_display_info object. */
1230 error ("Multiple terminals are not supported on this platform");
1232 t
= the_only_display_info
.terminal
;
1238 char *name
= 0, *type
= 0;
1239 Lisp_Object tty
, tty_type
;
1242 tty
= get_future_frame_param
1243 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1244 ? FRAME_TTY (XFRAME (selected_frame
))->name
1247 SAFE_ALLOCA_STRING (name
, tty
);
1249 tty_type
= get_future_frame_param
1250 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1251 ? FRAME_TTY (XFRAME (selected_frame
))->type
1253 if (!NILP (tty_type
))
1254 SAFE_ALLOCA_STRING (type
, tty_type
);
1256 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
1260 f
= make_terminal_frame (t
);
1264 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
1265 adjust_frame_size (f
, width
, height
- FRAME_MENU_BAR_LINES (f
),
1266 5, 0, Qterminal_frame
);
1269 adjust_frame_glyphs (f
);
1270 calculate_costs (f
);
1271 XSETFRAME (frame
, f
);
1273 store_in_alist (&parms
, Qtty_type
, build_string (t
->display_info
.tty
->type
));
1274 store_in_alist (&parms
, Qtty
,
1275 (t
->display_info
.tty
->name
1276 ? build_string (t
->display_info
.tty
->name
)
1278 /* On terminal frames the `minibuffer' frame parameter is always
1279 virtually t. Avoid that a different value in parms causes
1280 complaints, see Bug#24758. */
1281 store_in_alist (&parms
, Qminibuffer
, Qt
);
1282 Fmodify_frame_parameters (frame
, parms
);
1284 /* Make the frame face alist be frame-specific, so that each
1285 frame could change its face definitions independently. */
1286 fset_face_alist (f
, Fcopy_alist (sf
->face_alist
));
1287 /* Simple Fcopy_alist isn't enough, because we need the contents of
1288 the vectors which are the CDRs of associations in face_alist to
1289 be copied as well. */
1290 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
1291 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
1293 f
->can_x_set_window_size
= true;
1294 f
->after_make_frame
= true;
1300 /* Perform the switch to frame FRAME.
1302 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
1305 If TRACK is non-zero and the frame that currently has the focus
1306 redirects its focus to the selected frame, redirect that focused
1307 frame's focus to FRAME instead.
1309 FOR_DELETION non-zero means that the selected frame is being
1310 deleted, which includes the possibility that the frame's terminal
1313 The value of NORECORD is passed as argument to Fselect_window. */
1316 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
1318 struct frame
*sf
= SELECTED_FRAME (), *f
;
1320 /* If FRAME is a switch-frame event, extract the frame we should
1323 && EQ (XCAR (frame
), Qswitch_frame
)
1324 && CONSP (XCDR (frame
)))
1325 frame
= XCAR (XCDR (frame
));
1327 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
1328 a switch-frame event to arrive after a frame is no longer live,
1329 especially when deleting the initial frame during startup. */
1330 CHECK_FRAME (frame
);
1332 if (!FRAME_LIVE_P (f
))
1337 /* If a frame's focus has been redirected toward the currently
1338 selected frame, we should change the redirection to point to the
1339 newly selected frame. This means that if the focus is redirected
1340 from a minibufferless frame to a surrogate minibuffer frame, we
1341 can use `other-window' to switch between all the frames using
1342 that minibuffer frame, and the focus redirection will follow us
1345 /* This is too greedy; it causes inappropriate focus redirection
1346 that's hard to get rid of. */
1351 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1355 if (!FRAMEP (XCAR (tail
)))
1358 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
1360 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1361 Fredirect_frame_focus (XCAR (tail
), frame
);
1365 /* Instead, apply it only to the frame we're pointing to. */
1366 #ifdef HAVE_WINDOW_SYSTEM
1367 if (track
&& FRAME_WINDOW_P (f
))
1369 Lisp_Object focus
, xfocus
;
1371 xfocus
= x_get_focus_frame (f
);
1372 if (FRAMEP (xfocus
))
1374 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
1375 if ((FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1376 /* Redirect frame focus also when FRAME has its minibuffer
1377 window on the selected frame (see Bug#24500). */
1379 && EQ (FRAME_MINIBUF_WINDOW (f
), sf
->selected_window
)))
1380 Fredirect_frame_focus (xfocus
, frame
);
1383 #endif /* HAVE_X_WINDOWS */
1386 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
1387 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
1389 if (FRAME_TERMCAP_P (f
) || FRAME_MSDOS_P (f
))
1391 struct tty_display_info
*tty
= FRAME_TTY (f
);
1392 Lisp_Object top_frame
= tty
->top_frame
;
1394 /* Don't mark the frame garbaged and/or obscured if we are
1395 switching to the frame that is already the top frame of that
1397 if (!EQ (frame
, top_frame
))
1399 if (FRAMEP (top_frame
))
1400 /* Mark previously displayed frame as now obscured. */
1401 SET_FRAME_VISIBLE (XFRAME (top_frame
), 2);
1402 SET_FRAME_VISIBLE (f
, 1);
1403 /* If the new TTY frame changed dimensions, we need to
1404 resync term.c's idea of the frame size with the new
1406 if (FRAME_COLS (f
) != FrameCols (tty
))
1407 FrameCols (tty
) = FRAME_COLS (f
);
1408 if (FRAME_TOTAL_LINES (f
) != FrameRows (tty
))
1409 FrameRows (tty
) = FRAME_TOTAL_LINES (f
);
1411 tty
->top_frame
= frame
;
1414 selected_frame
= frame
;
1415 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
1416 last_nonminibuf_frame
= XFRAME (selected_frame
);
1418 Fselect_window (f
->selected_window
, norecord
);
1420 /* We want to make sure that the next event generates a frame-switch
1421 event to the appropriate frame. This seems kludgy to me, but
1422 before you take it out, make sure that evaluating something like
1423 (select-window (frame-root-window (make-frame))) doesn't end up
1424 with your typing being interpreted in the new frame instead of
1425 the one you're actually typing in. */
1426 #ifdef HAVE_WINDOW_SYSTEM
1427 if (!frame_ancestor_p (f
, sf
))
1429 internal_last_event_frame
= Qnil
;
1434 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
1435 doc
: /* Select FRAME.
1436 Subsequent editing commands apply to its selected window.
1437 Optional argument NORECORD means to neither change the order of
1438 recently selected windows nor the buffer list.
1440 The selection of FRAME lasts until the next time the user does
1441 something to select a different frame, or until the next time
1442 this function is called. If you are using a window system, the
1443 previously selected frame may be restored as the selected frame
1444 when returning to the command loop, because it still may have
1445 the window system's input focus. On a text terminal, the next
1446 redisplay will display FRAME.
1448 This function returns FRAME, or nil if FRAME has been deleted. */)
1449 (Lisp_Object frame
, Lisp_Object norecord
)
1451 return do_switch_frame (frame
, 1, 0, norecord
);
1454 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "^e",
1455 doc
: /* Handle a switch-frame event EVENT.
1456 Switch-frame events are usually bound to this function.
1457 A switch-frame event is an event Emacs sends itself to
1458 indicate that input is arriving in a new frame. It does not
1459 necessarily represent user-visible input focus. */)
1462 /* Preserve prefix arg that the command loop just cleared. */
1463 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
1464 run_hook (Qmouse_leave_buffer_hook
);
1465 return do_switch_frame (event
, 0, 0, Qnil
);
1468 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1469 doc
: /* Return the frame that is now selected. */)
1472 return selected_frame
;
1475 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1477 doc
: /* Return a list of all live frames.
1478 The return value does not include any tooltip frame. */)
1481 #ifdef HAVE_WINDOW_SYSTEM
1482 Lisp_Object list
= Qnil
, tail
, frame
;
1484 FOR_EACH_FRAME (tail
, frame
)
1485 if (!FRAME_TOOLTIP_P (XFRAME (frame
)))
1486 list
= Fcons (frame
, list
);
1487 /* Reverse list for consistency with the !HAVE_WINDOW_SYSTEM case. */
1488 return Fnreverse (list
);
1489 #else /* !HAVE_WINDOW_SYSTEM */
1490 return Fcopy_sequence (Vframe_list
);
1491 #endif /* HAVE_WINDOW_SYSTEM */
1494 DEFUN ("frame-parent", Fframe_parent
, Sframe_parent
,
1496 doc
: /* Return the parent frame of FRAME.
1497 The parent frame of FRAME is the Emacs frame whose window-system window
1498 is the parent window of FRAME's window-system window. When such a frame
1499 exists, FRAME is considered a child frame of that frame.
1501 Return nil if FRAME has no parent frame. This means that FRAME's
1502 window-system window is either a "top-level" window (a window whose
1503 parent window is the window-system's root window) or an embedded window
1504 \(a window whose parent window is owned by some other application). */)
1507 struct frame
*f
= decode_live_frame (frame
);
1508 struct frame
*p
= FRAME_PARENT_FRAME (f
);
1511 /* Can't return f->parent_frame directly since it might not be defined
1512 for this platform. */
1515 XSETFRAME (parent
, p
);
1523 #ifdef HAVE_WINDOW_SYSTEM
1525 frame_ancestor_p (struct frame
*af
, struct frame
*df
)
1527 struct frame
*pf
= FRAME_PARENT_FRAME (df
);
1534 pf
= FRAME_PARENT_FRAME (pf
);
1541 DEFUN ("frame-ancestor-p", Fframe_ancestor_p
, Sframe_ancestor_p
,
1543 doc
: /* Return non-nil if ANCESTOR is an ancestor of DESCENDANT.
1544 ANCESTOR is an ancestor of DESCENDANT when it is either DESCENDANT's
1545 parent frame or it is an ancestor of DESCENDANT's parent frame. Both,
1546 ANCESTOR and DESCENDANT must be live frames and default to the selected
1548 (Lisp_Object ancestor
, Lisp_Object descendant
)
1550 #ifdef HAVE_WINDOW_SYSTEM
1551 struct frame
*af
= decode_live_frame (ancestor
);
1552 struct frame
*df
= decode_live_frame (descendant
);
1554 return frame_ancestor_p (af
, df
) ? Qt
: Qnil
;
1560 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
1561 same tty (for tty frames) or among frames which uses FRAME's keyboard.
1562 If MINIBUF is nil, do not consider minibuffer-only candidate.
1563 If MINIBUF is `visible', do not consider an invisible candidate.
1564 If MINIBUF is a window, consider only its own frame and candidate now
1565 using that window as the minibuffer.
1566 If MINIBUF is 0, consider candidate if it is visible or iconified.
1567 Otherwise consider any candidate and return nil if CANDIDATE is not
1571 candidate_frame (Lisp_Object candidate
, Lisp_Object frame
, Lisp_Object minibuf
)
1573 struct frame
*c
= XFRAME (candidate
), *f
= XFRAME (frame
);
1575 if ((!FRAME_TERMCAP_P (c
) && !FRAME_TERMCAP_P (f
)
1576 && FRAME_KBOARD (c
) == FRAME_KBOARD (f
))
1577 || (FRAME_TERMCAP_P (c
) && FRAME_TERMCAP_P (f
)
1578 && FRAME_TTY (c
) == FRAME_TTY (f
)))
1580 if (!NILP (get_frame_param (c
, Qno_other_frame
)))
1582 else if (NILP (minibuf
))
1584 if (!FRAME_MINIBUF_ONLY_P (c
))
1587 else if (EQ (minibuf
, Qvisible
))
1589 if (FRAME_VISIBLE_P (c
))
1592 else if (WINDOWP (minibuf
))
1594 if (EQ (FRAME_MINIBUF_WINDOW (c
), minibuf
)
1595 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), candidate
)
1596 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1597 FRAME_FOCUS_FRAME (c
)))
1600 else if (FIXNUMP (minibuf
) && XFIXNUM (minibuf
) == 0)
1602 if (FRAME_VISIBLE_P (c
) || FRAME_ICONIFIED_P (c
))
1611 /* Return the next frame in the frame list after FRAME. */
1614 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1616 Lisp_Object f
, tail
;
1619 eassume (CONSP (Vframe_list
));
1622 FOR_EACH_FRAME (tail
, f
)
1626 f
= candidate_frame (f
, frame
, minibuf
);
1636 /* Return the previous frame in the frame list before FRAME. */
1639 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1641 Lisp_Object f
, tail
, prev
= Qnil
;
1643 eassume (CONSP (Vframe_list
));
1645 FOR_EACH_FRAME (tail
, f
)
1647 if (EQ (frame
, f
) && !NILP (prev
))
1649 f
= candidate_frame (f
, frame
, minibuf
);
1654 /* We've scanned the entire list. */
1656 /* We went through the whole frame list without finding a single
1657 acceptable frame. Return the original frame. */
1660 /* There were no acceptable frames in the list before FRAME; otherwise,
1661 we would have returned directly from the loop. Since PREV is the last
1662 acceptable frame in the list, return it. */
1667 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1668 doc
: /* Return the next frame in the frame list after FRAME.
1669 It considers only frames on the same terminal as FRAME.
1670 By default, skip minibuffer-only frames.
1671 If omitted, FRAME defaults to the selected frame.
1672 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1673 If MINIFRAME is a window, include only its own frame
1674 and any frame now using that window as the minibuffer.
1675 If MINIFRAME is `visible', include all visible frames.
1676 If MINIFRAME is 0, include all visible and iconified frames.
1677 Otherwise, include all frames. */)
1678 (Lisp_Object frame
, Lisp_Object miniframe
)
1681 frame
= selected_frame
;
1682 CHECK_LIVE_FRAME (frame
);
1683 return next_frame (frame
, miniframe
);
1686 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1687 doc
: /* Return the previous frame in the frame list before FRAME.
1688 It considers only frames on the same terminal as FRAME.
1689 By default, skip minibuffer-only frames.
1690 If omitted, FRAME defaults to the selected frame.
1691 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1692 If MINIFRAME is a window, include only its own frame
1693 and any frame now using that window as the minibuffer.
1694 If MINIFRAME is `visible', include all visible frames.
1695 If MINIFRAME is 0, include all visible and iconified frames.
1696 Otherwise, include all frames. */)
1697 (Lisp_Object frame
, Lisp_Object miniframe
)
1700 frame
= selected_frame
;
1701 CHECK_LIVE_FRAME (frame
);
1702 return prev_frame (frame
, miniframe
);
1705 DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame
,
1706 Slast_nonminibuf_frame
, 0, 0, 0,
1707 doc
: /* Return last non-minibuffer frame selected. */)
1710 Lisp_Object frame
= Qnil
;
1712 if (last_nonminibuf_frame
)
1713 XSETFRAME (frame
, last_nonminibuf_frame
);
1721 * Return true if there exists at least one visible or iconified frame
1722 * but F. Tooltip frames do not qualify as candidates. Return false
1723 * if no such frame exists.
1725 * INVISIBLE true means we are called from make_frame_invisible where
1726 * such a frame must be visible or iconified. INVISIBLE nil means we
1727 * are called from delete_frame. In that case FORCE true means that the
1728 * visibility status of such a frame can be ignored.
1730 * If F is the terminal frame and we are using X, return true if at
1731 * least one X frame exists.
1734 other_frames (struct frame
*f
, bool invisible
, bool force
)
1736 Lisp_Object frames
, frame
, frame1
;
1737 Lisp_Object minibuffer_window
= FRAME_MINIBUF_WINDOW (f
);
1739 XSETFRAME (frame
, f
);
1740 if (WINDOWP (minibuffer_window
)
1741 && !EQ (frame
, WINDOW_FRAME (XWINDOW (minibuffer_window
))))
1742 minibuffer_window
= Qnil
;
1744 FOR_EACH_FRAME (frames
, frame1
)
1746 struct frame
*f1
= XFRAME (frame1
);
1750 /* Verify that we can still talk to the frame's X window, and
1751 note any recent change in visibility. */
1752 #ifdef HAVE_X_WINDOWS
1753 if (FRAME_WINDOW_P (f1
))
1756 if (!FRAME_TOOLTIP_P (f1
)
1757 /* Tooltips and child frames count neither for
1758 invisibility nor for deletions. */
1759 && !FRAME_PARENT_FRAME (f1
)
1760 /* Frames with a non-nil `delete-before' parameter don't
1761 count for deletions. */
1762 && (invisible
|| NILP (get_frame_param (f1
, Qdelete_before
)))
1763 /* For invisibility and normal deletions, at least one
1764 visible or iconified frame must remain (Bug#26682). */
1765 && (FRAME_VISIBLE_P (f1
) || FRAME_ICONIFIED_P (f1
)
1768 /* Allow deleting the terminal frame when at
1769 least one X frame exists. */
1770 || (FRAME_WINDOW_P (f1
) && !FRAME_WINDOW_P (f
))))))
1778 /* Make sure that minibuf_window doesn't refer to FRAME's minibuffer
1779 window. Preferably use the selected frame's minibuffer window
1780 instead. If the selected frame doesn't have one, get some other
1781 frame's minibuffer window. SELECT non-zero means select the new
1782 minibuffer window. */
1784 check_minibuf_window (Lisp_Object frame
, int select
)
1786 struct frame
*f
= decode_live_frame (frame
);
1788 XSETFRAME (frame
, f
);
1790 if (WINDOWP (minibuf_window
) && EQ (f
->minibuffer_window
, minibuf_window
))
1792 Lisp_Object frames
, this, window
= make_fixnum (0);
1794 if (!EQ (frame
, selected_frame
)
1795 && FRAME_HAS_MINIBUF_P (XFRAME (selected_frame
)))
1796 window
= FRAME_MINIBUF_WINDOW (XFRAME (selected_frame
));
1798 FOR_EACH_FRAME (frames
, this)
1800 if (!EQ (this, frame
) && FRAME_HAS_MINIBUF_P (XFRAME (this)))
1802 window
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1807 /* Don't abort if no window was found (Bug#15247). */
1808 if (WINDOWP (window
))
1810 /* Use set_window_buffer instead of Fset_window_buffer (see
1811 discussion of bug#11984, bug#12025, bug#12026). */
1812 set_window_buffer (window
, XWINDOW (minibuf_window
)->contents
, 0, 0);
1813 minibuf_window
= window
;
1815 /* SELECT non-zero usually means that FRAME's minibuffer
1816 window was selected; select the new one. */
1818 Fselect_window (minibuf_window
, Qnil
);
1827 * Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1828 * unconditionally. x_connection_closed and delete_terminal use this.
1829 * Any other value of FORCE implements the semantics described for
1832 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1834 struct frame
*f
= decode_any_frame (frame
);
1837 Lisp_Object frames
, frame1
;
1838 int minibuffer_selected
, is_tooltip_frame
;
1839 bool nochild
= !FRAME_PARENT_FRAME (f
);
1841 if (!FRAME_LIVE_P (f
))
1843 else if (!EQ (force
, Qnoelisp
) && !other_frames (f
, false, !NILP (force
)))
1846 error ("Attempt to delete the sole visible or iconified frame");
1848 error ("Attempt to delete the only frame");
1851 XSETFRAME (frame
, f
);
1853 /* Softly delete all frames with this frame as their parent frame or
1854 as their `delete-before' frame parameter value. */
1855 FOR_EACH_FRAME (frames
, frame1
)
1856 if (FRAME_PARENT_FRAME (XFRAME (frame1
)) == f
1857 /* Process `delete-before' parameter iff FRAME is not a child
1858 frame. This avoids that we enter an infinite chain of mixed
1861 && EQ (get_frame_param (XFRAME (frame1
), Qdelete_before
), frame
)))
1862 delete_frame (frame1
, Qnil
);
1864 /* Does this frame have a minibuffer, and is it the surrogate
1865 minibuffer for any other frame? */
1866 if (FRAME_HAS_MINIBUF_P (f
))
1868 FOR_EACH_FRAME (frames
, frame1
)
1872 if (EQ (frame1
, frame
))
1875 fminiw
= FRAME_MINIBUF_WINDOW (XFRAME (frame1
));
1877 if (WINDOWP (fminiw
) && EQ (frame
, WINDOW_FRAME (XWINDOW (fminiw
))))
1879 /* If we MUST delete this frame, delete the other first.
1880 But do this only if FORCE equals `noelisp'. */
1881 if (EQ (force
, Qnoelisp
))
1882 delete_frame (frame1
, Qnoelisp
);
1884 error ("Attempt to delete a surrogate minibuffer frame");
1889 is_tooltip_frame
= FRAME_TOOLTIP_P (f
);
1891 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1892 frame is a tooltip. FORCE is set to `noelisp' when handling
1893 a disconnect from the terminal, so we don't dare call Lisp
1895 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1897 else if (EQ (force
, Qnoelisp
))
1899 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1903 #ifdef HAVE_X_WINDOWS
1904 /* Also, save clipboard to the clipboard manager. */
1905 x_clipboard_manager_save_frame (frame
);
1908 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1911 /* delete_frame_functions may have deleted any frame, including this
1913 if (!FRAME_LIVE_P (f
))
1915 else if (!EQ (force
, Qnoelisp
) && !other_frames (f
, false, !NILP (force
)))
1918 error ("Attempt to delete the sole visible or iconified frame");
1920 error ("Attempt to delete the only frame");
1923 /* At this point, we are committed to deleting the frame.
1924 There is no more chance for errors to prevent it. */
1925 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1926 sf
= SELECTED_FRAME ();
1927 /* Don't let the frame remain selected. */
1931 Lisp_Object frame1 UNINIT
; /* This line works around GCC bug 85563. */
1932 eassume (CONSP (Vframe_list
));
1934 /* Look for another visible frame on the same terminal.
1935 Do not call next_frame here because it may loop forever.
1936 See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=15025. */
1937 FOR_EACH_FRAME (tail
, frame1
)
1939 struct frame
*f1
= XFRAME (frame1
);
1941 if (!EQ (frame
, frame1
)
1942 && !FRAME_TOOLTIP_P (f1
)
1943 && FRAME_TERMINAL (f
) == FRAME_TERMINAL (f1
)
1944 && FRAME_VISIBLE_P (f1
))
1948 /* If there is none, find *some* other frame. */
1949 if (NILP (frame1
) || EQ (frame1
, frame
))
1951 FOR_EACH_FRAME (tail
, frame1
)
1953 struct frame
*f1
= XFRAME (frame1
);
1955 if (!EQ (frame
, frame1
)
1956 && FRAME_LIVE_P (f1
)
1957 && !FRAME_TOOLTIP_P (f1
))
1959 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1961 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1963 if (!EQ (top_frame
, frame
))
1970 #ifdef NS_IMPL_COCOA
1972 /* Under NS, there is no system mechanism for choosing a new
1973 window to get focus -- it is left to application code.
1974 So the portion of THIS application interfacing with NS
1975 needs to know about it. We call Fraise_frame, but the
1976 purpose is really to transfer focus. */
1977 Fraise_frame (frame1
);
1980 do_switch_frame (frame1
, 0, 1, Qnil
);
1981 sf
= SELECTED_FRAME ();
1984 /* Don't allow minibuf_window to remain on a deleted frame. */
1985 check_minibuf_window (frame
, minibuffer_selected
);
1987 /* Don't let echo_area_window to remain on a deleted frame. */
1988 if (EQ (f
->minibuffer_window
, echo_area_window
))
1989 echo_area_window
= sf
->minibuffer_window
;
1991 /* Clear any X selections for this frame. */
1992 #ifdef HAVE_X_WINDOWS
1994 x_clear_frame_selections (f
);
1998 This function must be called before the window tree of the
1999 frame is deleted because windows contain dynamically allocated
2003 #ifdef HAVE_WINDOW_SYSTEM
2004 /* Give chance to each font driver to free a frame specific data. */
2005 font_update_drivers (f
, Qnil
);
2008 /* Mark all the windows that used to be on FRAME as deleted, and then
2009 remove the reference to them. */
2010 delete_all_child_windows (f
->root_window
);
2011 fset_root_window (f
, Qnil
);
2013 Vframe_list
= Fdelq (frame
, Vframe_list
);
2014 SET_FRAME_VISIBLE (f
, 0);
2016 /* Allow the vector of menu bar contents to be freed in the next
2017 garbage collection. The frame object itself may not be garbage
2018 collected until much later, because recent_keys and other data
2019 structures can still refer to it. */
2020 fset_menu_bar_vector (f
, Qnil
);
2022 /* If FRAME's buffer lists contains killed
2023 buffers, this helps GC to reclaim them. */
2024 fset_buffer_list (f
, Qnil
);
2025 fset_buried_buffer_list (f
, Qnil
);
2027 free_font_driver_list (f
);
2028 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
2031 xfree (f
->decode_mode_spec_buffer
);
2032 xfree (FRAME_INSERT_COST (f
));
2033 xfree (FRAME_DELETEN_COST (f
));
2034 xfree (FRAME_INSERTN_COST (f
));
2035 xfree (FRAME_DELETE_COST (f
));
2037 /* Since some events are handled at the interrupt level, we may get
2038 an event for f at any time; if we zero out the frame's terminal
2039 now, then we may trip up the event-handling code. Instead, we'll
2040 promise that the terminal of the frame must be valid until we
2041 have called the window-system-dependent frame destruction
2044 struct terminal
*terminal
;
2046 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
2047 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
2048 terminal
= FRAME_TERMINAL (f
);
2049 f
->output_data
.nothing
= 0;
2050 f
->terminal
= 0; /* Now the frame is dead. */
2053 /* If needed, delete the terminal that this frame was on.
2054 (This must be done after the frame is killed.) */
2055 terminal
->reference_count
--;
2056 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
2057 /* FIXME: Deleting the terminal crashes emacs because of a GTK
2059 https://lists.gnu.org/r/emacs-devel/2011-10/msg00363.html */
2061 /* Since a similar behavior was observed on the Lucid and Motif
2062 builds (see Bug#5802, Bug#21509, Bug#23499, Bug#27816), we now
2063 don't delete the terminal for these builds either. */
2064 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
2065 terminal
->reference_count
= 1;
2066 #endif /* USE_X_TOOLKIT || USE_GTK */
2067 if (terminal
->reference_count
== 0)
2070 XSETTERMINAL (tmp
, terminal
);
2073 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
2076 kb
= terminal
->kboard
;
2079 /* If we've deleted the last_nonminibuf_frame, then try to find
2081 if (f
== last_nonminibuf_frame
)
2083 last_nonminibuf_frame
= 0;
2085 FOR_EACH_FRAME (frames
, frame1
)
2087 struct frame
*f1
= XFRAME (frame1
);
2089 if (!FRAME_MINIBUF_ONLY_P (f1
))
2091 last_nonminibuf_frame
= f1
;
2097 /* If there's no other frame on the same kboard, get out of
2098 single-kboard state if we're in it for this kboard. */
2101 /* Some frame we found on the same kboard, or nil if there are none. */
2102 Lisp_Object frame_on_same_kboard
= Qnil
;
2104 FOR_EACH_FRAME (frames
, frame1
)
2105 if (kb
== FRAME_KBOARD (XFRAME (frame1
)))
2106 frame_on_same_kboard
= frame1
;
2108 if (NILP (frame_on_same_kboard
))
2109 not_single_kboard_state (kb
);
2113 /* If we've deleted this keyboard's default_minibuffer_frame, try to
2114 find another one. Prefer minibuffer-only frames, but also notice
2115 frames with other windows. */
2116 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
2118 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
2119 Lisp_Object frame_with_minibuf
= Qnil
;
2120 /* Some frame we found on the same kboard, or nil if there are none. */
2121 Lisp_Object frame_on_same_kboard
= Qnil
;
2123 FOR_EACH_FRAME (frames
, frame1
)
2125 struct frame
*f1
= XFRAME (frame1
);
2127 /* Consider only frames on the same kboard
2128 and only those with minibuffers. */
2129 if (kb
== FRAME_KBOARD (f1
)
2130 && FRAME_HAS_MINIBUF_P (f1
))
2132 frame_with_minibuf
= frame1
;
2133 if (FRAME_MINIBUF_ONLY_P (f1
))
2137 if (kb
== FRAME_KBOARD (f1
))
2138 frame_on_same_kboard
= frame1
;
2141 if (!NILP (frame_on_same_kboard
))
2143 /* We know that there must be some frame with a minibuffer out
2144 there. If this were not true, all of the frames present
2145 would have to be minibufferless, which implies that at some
2146 point their minibuffer frames must have been deleted, but
2147 that is prohibited at the top; you can't delete surrogate
2148 minibuffer frames. */
2149 if (NILP (frame_with_minibuf
))
2152 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
2155 /* No frames left on this kboard--say no minibuffer either. */
2156 kset_default_minibuffer_frame (kb
, Qnil
);
2159 /* Cause frame titles to update--necessary if we now have just one frame. */
2160 if (!is_tooltip_frame
)
2161 update_mode_lines
= 15;
2163 /* Now run the post-deletion hooks. */
2164 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
2166 else if (EQ (force
, Qnoelisp
))
2168 = Fcons (list3 (Qrun_hook_with_args
, Qafter_delete_frame_functions
, frame
),
2171 safe_call2 (Qrun_hook_with_args
, Qafter_delete_frame_functions
, frame
);
2176 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
2177 doc
: /* Delete FRAME, permanently eliminating it from use.
2178 FRAME must be a live frame and defaults to the selected one.
2180 A frame may not be deleted if its minibuffer serves as surrogate
2181 minibuffer for another frame. Normally, you may not delete a frame if
2182 all other frames are invisible, but if the second optional argument
2183 FORCE is non-nil, you may do so.
2185 This function runs `delete-frame-functions' before actually
2186 deleting the frame, unless the frame is a tooltip.
2187 The functions are run with one argument, the frame to be deleted. */)
2188 (Lisp_Object frame
, Lisp_Object force
)
2190 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
2193 #ifdef HAVE_WINDOW_SYSTEM
2195 * frame_internal_border_part:
2197 * Return part of internal border the coordinates X and Y relative to
2198 * frame F are on. Return nil if the coordinates are not on the
2199 * internal border of F.
2201 * Return one of INTERNAL_BORDER_LEFT_EDGE, INTERNAL_BORDER_TOP_EDGE,
2202 * INTERNAL_BORDER_RIGHT_EDGE or INTERNAL_BORDER_BOTTOM_EDGE when the
2203 * mouse cursor is on the corresponding border with an offset of at
2204 * least one canonical character height from that border's edges.
2206 * If no border part could be found this way, return one of
2207 * INTERNAL_BORDER_TOP_LEFT_CORNER, INTERNAL_BORDER_TOP_RIGHT_CORNER,
2208 * INTERNAL_BORDER_BOTTOM_LEFT_CORNER or
2209 * INTERNAL_BORDER_BOTTOM_RIGHT_CORNER to indicate that the mouse is in
2210 * one of the corresponding corners. This means that for very small
2211 * frames an `edge' return value is preferred.
2213 enum internal_border_part
2214 frame_internal_border_part (struct frame
*f
, int x
, int y
)
2216 int border
= FRAME_INTERNAL_BORDER_WIDTH (f
);
2217 int offset
= FRAME_LINE_HEIGHT (f
);
2218 int width
= FRAME_PIXEL_WIDTH (f
);
2219 int height
= FRAME_PIXEL_HEIGHT (f
);
2220 enum internal_border_part part
= INTERNAL_BORDER_NONE
;
2222 if (offset
< border
)
2223 /* For very wide borders make offset at least as large as
2227 if (offset
< x
&& x
< width
- offset
)
2228 /* Top or bottom border. */
2230 if (0 <= y
&& y
<= border
)
2231 part
= INTERNAL_BORDER_TOP_EDGE
;
2232 else if (height
- border
<= y
&& y
<= height
)
2233 part
= INTERNAL_BORDER_BOTTOM_EDGE
;
2235 else if (offset
< y
&& y
< height
- offset
)
2236 /* Left or right border. */
2238 if (0 <= x
&& x
<= border
)
2239 part
= INTERNAL_BORDER_LEFT_EDGE
;
2240 else if (width
- border
<= x
&& x
<= width
)
2241 part
= INTERNAL_BORDER_RIGHT_EDGE
;
2246 int half_width
= width
/ 2;
2247 int half_height
= height
/ 2;
2249 if (0 <= x
&& x
<= border
)
2252 if (0 <= y
&& y
<= half_height
)
2253 part
= INTERNAL_BORDER_TOP_LEFT_CORNER
;
2254 else if (half_height
< y
&& y
<= height
)
2255 part
= INTERNAL_BORDER_BOTTOM_LEFT_CORNER
;
2257 else if (width
- border
<= x
&& x
<= width
)
2260 if (0 <= y
&& y
<= half_height
)
2261 part
= INTERNAL_BORDER_TOP_RIGHT_CORNER
;
2262 else if (half_height
< y
&& y
<= height
)
2263 part
= INTERNAL_BORDER_BOTTOM_RIGHT_CORNER
;
2265 else if (0 <= y
&& y
<= border
)
2268 if (0 <= x
&& x
<= half_width
)
2269 part
= INTERNAL_BORDER_TOP_LEFT_CORNER
;
2270 else if (half_width
< x
&& x
<= width
)
2271 part
= INTERNAL_BORDER_TOP_RIGHT_CORNER
;
2273 else if (height
- border
<= y
&& y
<= height
)
2275 /* A bottom edge. */
2276 if (0 <= x
&& x
<= half_width
)
2277 part
= INTERNAL_BORDER_BOTTOM_LEFT_CORNER
;
2278 else if (half_width
< x
&& x
<= width
)
2279 part
= INTERNAL_BORDER_BOTTOM_RIGHT_CORNER
;
2287 /* Return mouse position in character cell units. */
2289 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
2290 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
2291 The position is given in canonical character cells, where (0, 0) is the
2292 upper-left corner of the frame, X is the horizontal offset, and Y is the
2293 vertical offset, measured in units of the frame's default character size.
2294 If Emacs is running on a mouseless terminal or hasn't been programmed
2295 to read the mouse position, it returns the selected frame for FRAME
2296 and nil for X and Y.
2297 If `mouse-position-function' is non-nil, `mouse-position' calls it,
2298 passing the normal return value to that function as an argument,
2299 and returns whatever that function returns. */)
2303 Lisp_Object lispy_dummy
;
2304 Lisp_Object x
, y
, retval
;
2306 f
= SELECTED_FRAME ();
2309 /* It's okay for the hook to refrain from storing anything. */
2310 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
2312 enum scroll_bar_part party_dummy
;
2314 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
2315 &lispy_dummy
, &party_dummy
,
2322 int col
= XFIXNUM (x
);
2323 int row
= XFIXNUM (y
);
2324 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
2328 XSETFRAME (lispy_dummy
, f
);
2329 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
2330 if (!NILP (Vmouse_position_function
))
2331 retval
= call1 (Vmouse_position_function
, retval
);
2335 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
2336 Smouse_pixel_position
, 0, 0, 0,
2337 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
2338 The position is given in pixel units, where (0, 0) is the
2339 upper-left corner of the frame, X is the horizontal offset, and Y is
2340 the vertical offset.
2341 If Emacs is running on a mouseless terminal or hasn't been programmed
2342 to read the mouse position, it returns the selected frame for FRAME
2343 and nil for X and Y. */)
2347 Lisp_Object lispy_dummy
;
2348 Lisp_Object x
, y
, retval
;
2350 f
= SELECTED_FRAME ();
2353 /* It's okay for the hook to refrain from storing anything. */
2354 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
2356 enum scroll_bar_part party_dummy
;
2358 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
2359 &lispy_dummy
, &party_dummy
,
2364 XSETFRAME (lispy_dummy
, f
);
2365 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
2366 if (!NILP (Vmouse_position_function
))
2367 retval
= call1 (Vmouse_position_function
, retval
);
2371 #ifdef HAVE_WINDOW_SYSTEM
2373 /* On frame F, convert character coordinates X and Y to pixel
2374 coordinates *PIX_X and *PIX_Y. */
2377 frame_char_to_pixel_position (struct frame
*f
, int x
, int y
,
2378 int *pix_x
, int *pix_y
)
2380 *pix_x
= FRAME_COL_TO_PIXEL_X (f
, x
) + FRAME_COLUMN_WIDTH (f
) / 2;
2381 *pix_y
= FRAME_LINE_TO_PIXEL_Y (f
, y
) + FRAME_LINE_HEIGHT (f
) / 2;
2385 if (*pix_x
> FRAME_PIXEL_WIDTH (f
))
2386 *pix_x
= FRAME_PIXEL_WIDTH (f
);
2390 if (*pix_y
> FRAME_PIXEL_HEIGHT (f
))
2391 *pix_y
= FRAME_PIXEL_HEIGHT (f
);
2394 /* On frame F, reposition mouse pointer to character coordinates X and Y. */
2397 frame_set_mouse_position (struct frame
*f
, int x
, int y
)
2401 frame_char_to_pixel_position (f
, x
, y
, &pix_x
, &pix_y
);
2402 frame_set_mouse_pixel_position (f
, pix_x
, pix_y
);
2405 #endif /* HAVE_WINDOW_SYSTEM */
2407 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
2408 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
2409 Coordinates are relative to the frame, not a window,
2410 so the coordinates of the top left character in the frame
2411 may be nonzero due to left-hand scroll bars or the menu bar.
2413 The position is given in canonical character cells, where (0, 0) is
2414 the upper-left corner of the frame, X is the horizontal offset, and
2415 Y is the vertical offset, measured in units of the frame's default
2418 This function is a no-op for an X frame that is not visible.
2419 If you have just created a frame, you must wait for it to become visible
2420 before calling this function on it, like this.
2421 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
2422 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
2424 CHECK_LIVE_FRAME (frame
);
2425 CHECK_TYPE_RANGED_INTEGER (int, x
);
2426 CHECK_TYPE_RANGED_INTEGER (int, y
);
2428 /* I think this should be done with a hook. */
2429 #ifdef HAVE_WINDOW_SYSTEM
2430 if (FRAME_WINDOW_P (XFRAME (frame
)))
2431 /* Warping the mouse will cause enternotify and focus events. */
2432 frame_set_mouse_position (XFRAME (frame
), XFIXNUM (x
), XFIXNUM (y
));
2435 if (FRAME_MSDOS_P (XFRAME (frame
)))
2437 Fselect_frame (frame
, Qnil
);
2438 mouse_moveto (XFIXNUM (x
), XFIXNUM (y
));
2443 Fselect_frame (frame
, Qnil
);
2444 term_mouse_moveto (XFIXNUM (x
), XFIXNUM (y
));
2453 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
2454 Sset_mouse_pixel_position
, 3, 3, 0,
2455 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
2456 The position is given in pixels, where (0, 0) is the upper-left corner
2457 of the frame, X is the horizontal offset, and Y is the vertical offset.
2459 Note, this is a no-op for an X frame that is not visible.
2460 If you have just created a frame, you must wait for it to become visible
2461 before calling this function on it, like this.
2462 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
2463 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
2465 CHECK_LIVE_FRAME (frame
);
2466 CHECK_TYPE_RANGED_INTEGER (int, x
);
2467 CHECK_TYPE_RANGED_INTEGER (int, y
);
2469 /* I think this should be done with a hook. */
2470 #ifdef HAVE_WINDOW_SYSTEM
2471 if (FRAME_WINDOW_P (XFRAME (frame
)))
2472 /* Warping the mouse will cause enternotify and focus events. */
2473 frame_set_mouse_pixel_position (XFRAME (frame
), XFIXNUM (x
), XFIXNUM (y
));
2476 if (FRAME_MSDOS_P (XFRAME (frame
)))
2478 Fselect_frame (frame
, Qnil
);
2479 mouse_moveto (XFIXNUM (x
), XFIXNUM (y
));
2484 Fselect_frame (frame
, Qnil
);
2485 term_mouse_moveto (XFIXNUM (x
), XFIXNUM (y
));
2494 static void make_frame_visible_1 (Lisp_Object
);
2496 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
2498 doc
: /* Make the frame FRAME visible (assuming it is an X window).
2499 If omitted, FRAME defaults to the currently selected frame. */)
2502 struct frame
*f
= decode_live_frame (frame
);
2504 /* I think this should be done with a hook. */
2505 #ifdef HAVE_WINDOW_SYSTEM
2506 if (FRAME_WINDOW_P (f
))
2507 x_make_frame_visible (f
);
2510 make_frame_visible_1 (f
->root_window
);
2512 /* Make menu bar update for the Buffers and Frames menus. */
2513 /* windows_or_buffers_changed = 15; FIXME: Why? */
2515 XSETFRAME (frame
, f
);
2519 /* Update the display_time slot of the buffers shown in WINDOW
2520 and all its descendants. */
2523 make_frame_visible_1 (Lisp_Object window
)
2527 for (; !NILP (window
); window
= w
->next
)
2529 w
= XWINDOW (window
);
2530 if (WINDOWP (w
->contents
))
2531 make_frame_visible_1 (w
->contents
);
2533 bset_display_time (XBUFFER (w
->contents
), Fcurrent_time ());
2537 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
2539 doc
: /* Make the frame FRAME invisible.
2540 If omitted, FRAME defaults to the currently selected frame.
2541 On graphical displays, invisible frames are not updated and are
2542 usually not displayed at all, even in a window system's \"taskbar\".
2544 Normally you may not make FRAME invisible if all other frames are invisible,
2545 but if the second optional argument FORCE is non-nil, you may do so.
2547 This function has no effect on text terminal frames. Such frames are
2548 always considered visible, whether or not they are currently being
2549 displayed in the terminal. */)
2550 (Lisp_Object frame
, Lisp_Object force
)
2552 struct frame
*f
= decode_live_frame (frame
);
2554 if (NILP (force
) && !other_frames (f
, true, false))
2555 error ("Attempt to make invisible the sole visible or iconified frame");
2557 /* Don't allow minibuf_window to remain on an invisible frame. */
2558 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2560 /* I think this should be done with a hook. */
2561 #ifdef HAVE_WINDOW_SYSTEM
2562 if (FRAME_WINDOW_P (f
))
2563 x_make_frame_invisible (f
);
2566 /* Make menu bar update for the Buffers and Frames menus. */
2567 windows_or_buffers_changed
= 16;
2572 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
2574 doc
: /* Make the frame FRAME into an icon.
2575 If omitted, FRAME defaults to the currently selected frame.
2577 If FRAME is a child frame, consult the variable `iconify-child-frame'
2578 for how to proceed. */)
2581 struct frame
*f
= decode_live_frame (frame
);
2582 #ifdef HAVE_WINDOW_SYSTEM
2583 Lisp_Object parent
= f
->parent_frame
;
2587 if (NILP (iconify_child_frame
))
2590 else if (EQ (iconify_child_frame
, Qiconify_top_level
))
2592 /* Iconify top level frame instead (the default). */
2593 Ficonify_frame (parent
);
2596 else if (EQ (iconify_child_frame
, Qmake_invisible
))
2598 /* Make frame invisible instead. */
2599 Fmake_frame_invisible (frame
, Qnil
);
2603 #endif /* HAVE_WINDOW_SYSTEM */
2605 /* Don't allow minibuf_window to remain on an iconified frame. */
2606 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2608 /* I think this should be done with a hook. */
2609 if (FRAME_WINDOW_P (f
))
2611 #ifdef HAVE_WINDOW_SYSTEM
2612 x_iconify_frame (f
);
2619 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
2621 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
2622 Return the symbol `icon' if FRAME is iconified or \"minimized\".
2623 Return nil if FRAME was made invisible, via `make-frame-invisible'.
2624 On graphical displays, invisible frames are not updated and are
2625 usually not displayed at all, even in a window system's \"taskbar\".
2627 If FRAME is a text terminal frame, this always returns t.
2628 Such frames are always considered visible, whether or not they are
2629 currently being displayed on the terminal. */)
2632 CHECK_LIVE_FRAME (frame
);
2634 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2636 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
2641 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
2643 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
2646 Lisp_Object tail
, frame
, value
= Qnil
;
2648 FOR_EACH_FRAME (tail
, frame
)
2649 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2650 value
= Fcons (frame
, value
);
2656 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
2657 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
2658 If FRAME is invisible or iconified, make it visible.
2659 If you don't specify a frame, the selected frame is used.
2660 If Emacs is displaying on an ordinary terminal or some other device which
2661 doesn't support multiple overlapping frames, this function selects FRAME. */)
2664 struct frame
*f
= decode_live_frame (frame
);
2666 XSETFRAME (frame
, f
);
2668 if (FRAME_TERMCAP_P (f
))
2669 /* On a text terminal select FRAME. */
2670 Fselect_frame (frame
, Qnil
);
2672 /* Do like the documentation says. */
2673 Fmake_frame_visible (frame
);
2675 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2676 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
2681 /* Should we have a corresponding function called Flower_Power? */
2682 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
2683 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2684 If you don't specify a frame, the selected frame is used.
2685 If Emacs is displaying on an ordinary terminal or some other device which
2686 doesn't support multiple overlapping frames, this function does nothing. */)
2689 struct frame
*f
= decode_live_frame (frame
);
2691 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2692 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2698 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2700 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2701 In other words, switch-frame events caused by events in FRAME will
2702 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2703 FOCUS-FRAME after reading an event typed at FRAME.
2705 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
2706 frame again receives its own keystrokes.
2708 Focus redirection is useful for temporarily redirecting keystrokes to
2709 a surrogate minibuffer frame when a frame doesn't have its own
2712 A frame's focus redirection can be changed by `select-frame'. If frame
2713 FOO is selected, and then a different frame BAR is selected, any
2714 frames redirecting their focus to FOO are shifted to redirect their
2715 focus to BAR. This allows focus redirection to work properly when the
2716 user switches from one frame to another using `select-window'.
2718 This means that a frame whose focus is redirected to itself is treated
2719 differently from a frame whose focus is redirected to nil; the former
2720 is affected by `select-frame', while the latter is not.
2722 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2723 (Lisp_Object frame
, Lisp_Object focus_frame
)
2725 /* Note that we don't check for a live frame here. It's reasonable
2726 to redirect the focus of a frame you're about to delete, if you
2727 know what other frame should receive those keystrokes. */
2728 struct frame
*f
= decode_any_frame (frame
);
2730 if (! NILP (focus_frame
))
2731 CHECK_LIVE_FRAME (focus_frame
);
2733 fset_focus_frame (f
, focus_frame
);
2735 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2736 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2742 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 0, 1, 0,
2743 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2744 If FRAME is omitted or nil, the selected frame is used.
2745 Return nil if FRAME's focus is not redirected.
2746 See `redirect-frame-focus'. */)
2749 return FRAME_FOCUS_FRAME (decode_live_frame (frame
));
2752 DEFUN ("x-focus-frame", Fx_focus_frame
, Sx_focus_frame
, 1, 2, 0,
2753 doc
: /* Set the input focus to FRAME.
2754 FRAME nil means use the selected frame. Optional argument NOACTIVATE
2755 means do not activate FRAME.
2757 If there is no window system support, this function does nothing. */)
2758 (Lisp_Object frame
, Lisp_Object noactivate
)
2760 #ifdef HAVE_WINDOW_SYSTEM
2761 x_focus_frame (decode_window_system_frame (frame
), !NILP (noactivate
));
2766 DEFUN ("frame-after-make-frame",
2767 Fframe_after_make_frame
,
2768 Sframe_after_make_frame
, 2, 2, 0,
2769 doc
: /* Mark FRAME as made.
2770 FRAME nil means use the selected frame. Second argument MADE non-nil
2771 means functions on `window-configuration-change-hook' are called
2772 whenever the window configuration of FRAME changes. MADE nil means
2773 these functions are not called.
2775 This function is currently called by `make-frame' only and should be
2776 otherwise used with utter care to avoid that running functions on
2777 `window-configuration-change-hook' is impeded forever. */)
2778 (Lisp_Object frame
, Lisp_Object made
)
2780 struct frame
*f
= decode_live_frame (frame
);
2781 f
->after_make_frame
= !NILP (made
);
2782 f
->inhibit_horizontal_resize
= false;
2783 f
->inhibit_vertical_resize
= false;
2788 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2791 frames_discard_buffer (Lisp_Object buffer
)
2793 Lisp_Object frame
, tail
;
2795 FOR_EACH_FRAME (tail
, frame
)
2798 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
2799 fset_buried_buffer_list
2800 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
2804 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2805 If the alist already has an element for PROP, we change it. */
2808 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2810 Lisp_Object tem
= Fassq (prop
, *alistptr
);
2812 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2818 frame_name_fnn_p (char *str
, ptrdiff_t len
)
2820 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
2823 while ('0' <= *p
&& *p
<= '9')
2831 /* Set the name of the terminal frame. Also used by MSDOS frames.
2832 Modeled after x_set_name which is used for WINDOW frames. */
2835 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2837 f
->explicit_name
= ! NILP (name
);
2839 /* If NAME is nil, set the name to F<num>. */
2842 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
2844 /* Check for no change needed in this very common case
2845 before we do any consing. */
2846 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
2849 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
2853 CHECK_STRING (name
);
2855 /* Don't change the name if it's already NAME. */
2856 if (! NILP (Fstring_equal (name
, f
->name
)))
2859 /* Don't allow the user to set the frame name to F<num>, so it
2860 doesn't clash with the names we generate for terminal frames. */
2861 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2862 error ("Frame names of the form F<num> are usurped by Emacs");
2865 fset_name (f
, name
);
2866 update_mode_lines
= 16;
2870 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2872 register Lisp_Object old_alist_elt
;
2874 if (EQ (prop
, Qminibuffer
))
2878 if (!MINI_WINDOW_P (XWINDOW (val
)))
2879 error ("The `minibuffer' parameter does not specify a valid minibuffer window");
2880 else if (FRAME_MINIBUF_ONLY_P (f
))
2882 if (EQ (val
, FRAME_MINIBUF_WINDOW (f
)))
2885 error ("Can't change the minibuffer window of a minibuffer-only frame");
2887 else if (FRAME_HAS_MINIBUF_P (f
))
2889 if (EQ (val
, FRAME_MINIBUF_WINDOW (f
)))
2892 error ("Can't change the minibuffer window of a frame with its own minibuffer");
2895 /* Store the chosen minibuffer window. */
2896 fset_minibuffer_window (f
, val
);
2900 Lisp_Object old_val
= Fcdr (Fassq (Qminibuffer
, f
->param_alist
));
2902 if (!NILP (old_val
))
2904 if (WINDOWP (old_val
) && NILP (val
))
2905 /* Don't change the value for a minibuffer-less frame if
2906 only nil was specified as new value. */
2908 else if (!EQ (old_val
, val
))
2909 error ("Can't change the `minibuffer' parameter of this frame");
2914 /* Check each parent-frame and delete-before parameter for a
2915 circular dependency. Do not check between parameters, so you can
2916 still create circular dependencies with different properties, for
2917 example a chain of frames F1->F2->...Fn such that F1 is an ancestor
2918 frame of Fn and thus cannot be deleted before Fn and a second chain
2919 Fn->Fn-1->...F1 such that Fn cannot be deleted before F1. */
2920 else if (EQ (prop
, Qparent_frame
) || EQ (prop
, Qdelete_before
))
2922 Lisp_Object oldval
= Fcdr (Fassq (prop
, f
->param_alist
));
2924 if (!EQ (oldval
, val
) && !NILP (val
))
2927 Lisp_Object frame1
= val
;
2929 if (!FRAMEP (frame1
) || !FRAME_LIVE_P (XFRAME (frame1
)))
2930 error ("Invalid `%s' frame parameter",
2931 SSDATA (SYMBOL_NAME (prop
)));
2933 XSETFRAME (frame
, f
);
2935 while (FRAMEP (frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
2936 if (EQ (frame1
, frame
))
2937 error ("Circular specification of `%s' frame parameter",
2938 SSDATA (SYMBOL_NAME (prop
)));
2940 frame1
= get_frame_param (XFRAME (frame1
), prop
);
2944 /* The buffer-list parameters are stored in a special place and not
2945 in the alist. All buffers must be live. */
2946 else if (EQ (prop
, Qbuffer_list
))
2948 Lisp_Object list
= Qnil
;
2949 for (; CONSP (val
); val
= XCDR (val
))
2950 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2951 list
= Fcons (XCAR (val
), list
);
2952 fset_buffer_list (f
, Fnreverse (list
));
2955 else if (EQ (prop
, Qburied_buffer_list
))
2957 Lisp_Object list
= Qnil
;
2958 for (; CONSP (val
); val
= XCDR (val
))
2959 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2960 list
= Fcons (XCAR (val
), list
);
2961 fset_buried_buffer_list (f
, Fnreverse (list
));
2965 /* The tty color needed to be set before the frame's parameter
2966 alist was updated with the new value. This is not true any more,
2967 but we still do this test early on. */
2968 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2969 && f
== FRAME_TTY (f
)->previous_frame
)
2970 /* Force redisplay of this tty. */
2971 FRAME_TTY (f
)->previous_frame
= NULL
;
2973 /* Update the frame parameter alist. */
2974 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2975 if (NILP (old_alist_elt
))
2976 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2978 Fsetcdr (old_alist_elt
, val
);
2980 /* Update some other special parameters in their special places
2981 in addition to the alist. */
2983 if (EQ (prop
, Qbuffer_predicate
))
2984 fset_buffer_predicate (f
, val
);
2986 if (! FRAME_WINDOW_P (f
))
2988 if (EQ (prop
, Qmenu_bar_lines
))
2989 set_menu_bar_lines (f
, val
, make_fixnum (FRAME_MENU_BAR_LINES (f
)));
2990 else if (EQ (prop
, Qname
))
2991 set_term_frame_name (f
, val
);
2995 /* Return color matches UNSPEC on frame F or nil if UNSPEC
2996 is not an unspecified foreground or background color. */
2999 frame_unspecified_color (struct frame
*f
, Lisp_Object unspec
)
3001 return (!strncmp (SSDATA (unspec
), unspecified_bg
, SBYTES (unspec
))
3002 ? tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
))
3003 : (!strncmp (SSDATA (unspec
), unspecified_fg
, SBYTES (unspec
))
3004 ? tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)) : Qnil
));
3007 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
3008 doc
: /* Return the parameters-alist of frame FRAME.
3009 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
3010 The meaningful PARMs depend on the kind of frame.
3011 If FRAME is omitted or nil, return information on the currently selected frame. */)
3015 struct frame
*f
= decode_any_frame (frame
);
3018 if (!FRAME_LIVE_P (f
))
3021 alist
= Fcopy_alist (f
->param_alist
);
3023 if (!FRAME_WINDOW_P (f
))
3027 /* If the frame's parameter alist says the colors are
3028 unspecified and reversed, take the frame's background pixel
3029 for foreground and vice versa. */
3030 elt
= Fassq (Qforeground_color
, alist
);
3031 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
3033 elt
= frame_unspecified_color (f
, XCDR (elt
));
3035 store_in_alist (&alist
, Qforeground_color
, elt
);
3038 store_in_alist (&alist
, Qforeground_color
,
3039 tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)));
3040 elt
= Fassq (Qbackground_color
, alist
);
3041 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
3043 elt
= frame_unspecified_color (f
, XCDR (elt
));
3045 store_in_alist (&alist
, Qbackground_color
, elt
);
3048 store_in_alist (&alist
, Qbackground_color
,
3049 tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
)));
3050 store_in_alist (&alist
, Qfont
,
3051 build_string (FRAME_MSDOS_P (f
)
3053 : FRAME_W32_P (f
) ? "w32term"
3056 store_in_alist (&alist
, Qname
, f
->name
);
3057 height
= (f
->new_height
3059 ? (f
->new_height
/ FRAME_LINE_HEIGHT (f
))
3062 store_in_alist (&alist
, Qheight
, make_fixnum (height
));
3063 width
= (f
->new_width
3065 ? (f
->new_width
/ FRAME_COLUMN_WIDTH (f
))
3068 store_in_alist (&alist
, Qwidth
, make_fixnum (width
));
3069 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
3070 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
3071 store_in_alist (&alist
, Qbuffer_list
, f
->buffer_list
);
3072 store_in_alist (&alist
, Qburied_buffer_list
, f
->buried_buffer_list
);
3074 /* I think this should be done with a hook. */
3075 #ifdef HAVE_WINDOW_SYSTEM
3076 if (FRAME_WINDOW_P (f
))
3077 x_report_frame_params (f
, &alist
);
3081 /* This ought to be correct in f->param_alist for an X frame. */
3083 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
3084 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
3091 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
3092 doc
: /* Return FRAME's value for parameter PARAMETER.
3093 If FRAME is nil, describe the currently selected frame. */)
3094 (Lisp_Object frame
, Lisp_Object parameter
)
3096 struct frame
*f
= decode_any_frame (frame
);
3097 Lisp_Object value
= Qnil
;
3099 CHECK_SYMBOL (parameter
);
3101 XSETFRAME (frame
, f
);
3103 if (FRAME_LIVE_P (f
))
3105 /* Avoid consing in frequent cases. */
3106 if (EQ (parameter
, Qname
))
3108 #ifdef HAVE_WINDOW_SYSTEM
3109 /* These are used by vertical motion commands. */
3110 else if (EQ (parameter
, Qvertical_scroll_bars
))
3111 value
= (f
->vertical_scroll_bar_type
== vertical_scroll_bar_none
3113 : (f
->vertical_scroll_bar_type
== vertical_scroll_bar_left
3115 else if (EQ (parameter
, Qhorizontal_scroll_bars
))
3116 value
= f
->horizontal_scroll_bars
? Qt
: Qnil
;
3117 else if (EQ (parameter
, Qline_spacing
) && f
->extra_line_spacing
== 0)
3118 /* If this is non-zero, we can't determine whether the user specified
3119 an integer or float value without looking through 'param_alist'. */
3120 value
= make_fixnum (0);
3121 else if (EQ (parameter
, Qfont
) && FRAME_X_P (f
))
3122 value
= FRAME_FONT (f
)->props
[FONT_NAME_INDEX
];
3123 #endif /* HAVE_WINDOW_SYSTEM */
3124 #ifdef HAVE_X_WINDOWS
3125 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
3126 value
= XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
);
3127 #endif /* HAVE_X_WINDOWS */
3128 else if (EQ (parameter
, Qbackground_color
)
3129 || EQ (parameter
, Qforeground_color
))
3131 value
= Fassq (parameter
, f
->param_alist
);
3134 value
= XCDR (value
);
3135 /* Fframe_parameters puts the actual fg/bg color names,
3136 even if f->param_alist says otherwise. This is
3137 important when param_alist's notion of colors is
3138 "unspecified". We need to do the same here. */
3139 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
3141 Lisp_Object tem
= frame_unspecified_color (f
, value
);
3148 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
3150 else if (EQ (parameter
, Qdisplay_type
)
3151 || EQ (parameter
, Qbackground_mode
))
3152 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
3154 /* FIXME: Avoid this code path at all (as well as code duplication)
3155 by sharing more code with Fframe_parameters. */
3156 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
3163 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
3164 Smodify_frame_parameters
, 2, 2, 0,
3165 doc
: /* Modify FRAME according to new values of its parameters in ALIST.
3166 If FRAME is nil, it defaults to the selected frame.
3167 ALIST is an alist of parameters to change and their new values.
3168 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
3169 Which PARMs are meaningful depends on the kind of frame.
3170 The meaningful parameters are acted upon, i.e. the frame is changed
3171 according to their new values, and are also stored in the frame's
3172 parameter list so that `frame-parameters' will return them.
3173 PARMs that are not meaningful are still stored in the frame's parameter
3174 list, but are otherwise ignored. */)
3175 (Lisp_Object frame
, Lisp_Object alist
)
3177 struct frame
*f
= decode_live_frame (frame
);
3178 Lisp_Object prop
, val
;
3180 /* I think this should be done with a hook. */
3181 #ifdef HAVE_WINDOW_SYSTEM
3182 if (FRAME_WINDOW_P (f
))
3183 x_set_frame_parameters (f
, alist
);
3187 if (FRAME_MSDOS_P (f
))
3188 IT_set_frame_parameters (f
, alist
);
3193 EMACS_INT length
= XFIXNAT (Flength (alist
));
3196 Lisp_Object
*values
;
3198 SAFE_ALLOCA_LISP (parms
, 2 * length
);
3199 values
= parms
+ length
;
3201 /* Extract parm names and values into those vectors. */
3203 for (i
= 0; CONSP (alist
); alist
= XCDR (alist
))
3208 parms
[i
] = Fcar (elt
);
3209 values
[i
] = Fcdr (elt
);
3213 /* Now process them in reverse of specified order. */
3218 store_frame_param (f
, prop
, val
);
3220 if (EQ (prop
, Qforeground_color
)
3221 || EQ (prop
, Qbackground_color
))
3222 update_face_from_frame_parameter (f
, prop
, val
);
3230 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
3232 doc
: /* Height in pixels of a line in the font in frame FRAME.
3233 If FRAME is omitted or nil, the selected frame is used.
3234 For a terminal frame, the value is always 1. */)
3237 #ifdef HAVE_WINDOW_SYSTEM
3238 struct frame
*f
= decode_any_frame (frame
);
3240 if (FRAME_WINDOW_P (f
))
3241 return make_fixnum (FRAME_LINE_HEIGHT (f
));
3244 return make_fixnum (1);
3248 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
3250 doc
: /* Width in pixels of characters in the font in frame FRAME.
3251 If FRAME is omitted or nil, the selected frame is used.
3252 On a graphical screen, the width is the standard width of the default font.
3253 For a terminal screen, the value is always 1. */)
3256 #ifdef HAVE_WINDOW_SYSTEM
3257 struct frame
*f
= decode_any_frame (frame
);
3259 if (FRAME_WINDOW_P (f
))
3260 return make_fixnum (FRAME_COLUMN_WIDTH (f
));
3263 return make_fixnum (1);
3266 DEFUN ("frame-native-width", Fframe_native_width
,
3267 Sframe_native_width
, 0, 1, 0,
3268 doc
: /* Return FRAME's native width in pixels.
3269 For a terminal frame, the result really gives the width in characters.
3270 If FRAME is omitted or nil, the selected frame is used. */)
3273 struct frame
*f
= decode_any_frame (frame
);
3275 #ifdef HAVE_WINDOW_SYSTEM
3276 if (FRAME_WINDOW_P (f
))
3277 return make_fixnum (FRAME_PIXEL_WIDTH (f
));
3280 return make_fixnum (FRAME_TOTAL_COLS (f
));
3283 DEFUN ("frame-native-height", Fframe_native_height
,
3284 Sframe_native_height
, 0, 1, 0,
3285 doc
: /* Return FRAME's native height in pixels.
3286 If FRAME is omitted or nil, the selected frame is used. The exact value
3287 of the result depends on the window-system and toolkit in use:
3289 In the Gtk+ and NS versions, it includes only any window (including the
3290 minibuffer or echo area), mode line, and header line. It does not
3291 include the tool bar or menu bar. With other graphical versions, it may
3292 also include the tool bar and the menu bar.
3294 For a text terminal, it includes the menu bar. In this case, the
3295 result is really in characters rather than pixels (i.e., is identical
3296 to `frame-height'). */)
3299 struct frame
*f
= decode_any_frame (frame
);
3301 #ifdef HAVE_WINDOW_SYSTEM
3302 if (FRAME_WINDOW_P (f
))
3303 return make_fixnum (FRAME_PIXEL_HEIGHT (f
));
3306 return make_fixnum (FRAME_TOTAL_LINES (f
));
3309 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
3310 Stool_bar_pixel_width
, 0, 1, 0,
3311 doc
: /* Return width in pixels of FRAME's tool bar.
3312 The result is greater than zero only when the tool bar is on the left
3313 or right side of FRAME. If FRAME is omitted or nil, the selected frame
3317 #ifdef FRAME_TOOLBAR_WIDTH
3318 struct frame
*f
= decode_any_frame (frame
);
3320 if (FRAME_WINDOW_P (f
))
3321 return make_fixnum (FRAME_TOOLBAR_WIDTH (f
));
3323 return make_fixnum (0);
3326 DEFUN ("frame-text-cols", Fframe_text_cols
, Sframe_text_cols
, 0, 1, 0,
3327 doc
: /* Return width in columns of FRAME's text area. */)
3330 return make_fixnum (FRAME_COLS (decode_any_frame (frame
)));
3333 DEFUN ("frame-text-lines", Fframe_text_lines
, Sframe_text_lines
, 0, 1, 0,
3334 doc
: /* Return height in lines of FRAME's text area. */)
3337 return make_fixnum (FRAME_LINES (decode_any_frame (frame
)));
3340 DEFUN ("frame-total-cols", Fframe_total_cols
, Sframe_total_cols
, 0, 1, 0,
3341 doc
: /* Return number of total columns of FRAME. */)
3344 return make_fixnum (FRAME_TOTAL_COLS (decode_any_frame (frame
)));
3347 DEFUN ("frame-total-lines", Fframe_total_lines
, Sframe_total_lines
, 0, 1, 0,
3348 doc
: /* Return number of total lines of FRAME. */)
3351 return make_fixnum (FRAME_TOTAL_LINES (decode_any_frame (frame
)));
3354 DEFUN ("frame-text-width", Fframe_text_width
, Sframe_text_width
, 0, 1, 0,
3355 doc
: /* Return text area width of FRAME in pixels. */)
3358 return make_fixnum (FRAME_TEXT_WIDTH (decode_any_frame (frame
)));
3361 DEFUN ("frame-text-height", Fframe_text_height
, Sframe_text_height
, 0, 1, 0,
3362 doc
: /* Return text area height of FRAME in pixels. */)
3365 return make_fixnum (FRAME_TEXT_HEIGHT (decode_any_frame (frame
)));
3368 DEFUN ("frame-scroll-bar-width", Fscroll_bar_width
, Sscroll_bar_width
, 0, 1, 0,
3369 doc
: /* Return scroll bar width of FRAME in pixels. */)
3372 return make_fixnum (FRAME_SCROLL_BAR_AREA_WIDTH (decode_any_frame (frame
)));
3375 DEFUN ("frame-scroll-bar-height", Fscroll_bar_height
, Sscroll_bar_height
, 0, 1, 0,
3376 doc
: /* Return scroll bar height of FRAME in pixels. */)
3379 return make_fixnum (FRAME_SCROLL_BAR_AREA_HEIGHT (decode_any_frame (frame
)));
3382 DEFUN ("frame-fringe-width", Ffringe_width
, Sfringe_width
, 0, 1, 0,
3383 doc
: /* Return fringe width of FRAME in pixels. */)
3386 return make_fixnum (FRAME_TOTAL_FRINGE_WIDTH (decode_any_frame (frame
)));
3389 DEFUN ("frame-internal-border-width", Fframe_internal_border_width
, Sframe_internal_border_width
, 0, 1, 0,
3390 doc
: /* Return width of FRAME's internal border in pixels. */)
3393 return make_fixnum (FRAME_INTERNAL_BORDER_WIDTH (decode_any_frame (frame
)));
3396 DEFUN ("frame-right-divider-width", Fright_divider_width
, Sright_divider_width
, 0, 1, 0,
3397 doc
: /* Return width (in pixels) of vertical window dividers on FRAME. */)
3400 return make_fixnum (FRAME_RIGHT_DIVIDER_WIDTH (decode_any_frame (frame
)));
3403 DEFUN ("frame-bottom-divider-width", Fbottom_divider_width
, Sbottom_divider_width
, 0, 1, 0,
3404 doc
: /* Return width (in pixels) of horizontal window dividers on FRAME. */)
3407 return make_fixnum (FRAME_BOTTOM_DIVIDER_WIDTH (decode_any_frame (frame
)));
3410 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 4, 0,
3411 doc
: /* Set text height of frame FRAME to HEIGHT lines.
3412 Optional third arg PRETEND non-nil means that redisplay should use
3413 HEIGHT lines but that the idea of the actual height of the frame should
3416 Optional fourth argument PIXELWISE non-nil means that FRAME should be
3417 HEIGHT pixels high. Note: When `frame-resize-pixelwise' is nil, some
3418 window managers may refuse to honor a HEIGHT that is not an integer
3419 multiple of the default frame font height. */)
3420 (Lisp_Object frame
, Lisp_Object height
, Lisp_Object pretend
, Lisp_Object pixelwise
)
3422 struct frame
*f
= decode_live_frame (frame
);
3425 CHECK_TYPE_RANGED_INTEGER (int, height
);
3427 pixel_height
= (!NILP (pixelwise
)
3429 : XFIXNUM (height
) * FRAME_LINE_HEIGHT (f
));
3430 adjust_frame_size (f
, -1, pixel_height
, 1, !NILP (pretend
), Qheight
);
3435 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 4, 0,
3436 doc
: /* Set text width of frame FRAME to WIDTH columns.
3437 Optional third arg PRETEND non-nil means that redisplay should use WIDTH
3438 columns but that the idea of the actual width of the frame should not
3441 Optional fourth argument PIXELWISE non-nil means that FRAME should be
3442 WIDTH pixels wide. Note: When `frame-resize-pixelwise' is nil, some
3443 window managers may refuse to honor a WIDTH that is not an integer
3444 multiple of the default frame font width. */)
3445 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object pretend
, Lisp_Object pixelwise
)
3447 struct frame
*f
= decode_live_frame (frame
);
3450 CHECK_TYPE_RANGED_INTEGER (int, width
);
3452 pixel_width
= (!NILP (pixelwise
)
3454 : XFIXNUM (width
) * FRAME_COLUMN_WIDTH (f
));
3455 adjust_frame_size (f
, pixel_width
, -1, 1, !NILP (pretend
), Qwidth
);
3460 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 4, 0,
3461 doc
: /* Set text size of FRAME to WIDTH by HEIGHT, measured in characters.
3462 Optional argument PIXELWISE non-nil means to measure in pixels. Note:
3463 When `frame-resize-pixelwise' is nil, some window managers may refuse to
3464 honor a WIDTH that is not an integer multiple of the default frame font
3465 width or a HEIGHT that is not an integer multiple of the default frame
3467 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object height
, Lisp_Object pixelwise
)
3469 struct frame
*f
= decode_live_frame (frame
);
3470 int pixel_width
, pixel_height
;
3472 CHECK_TYPE_RANGED_INTEGER (int, width
);
3473 CHECK_TYPE_RANGED_INTEGER (int, height
);
3475 pixel_width
= (!NILP (pixelwise
)
3477 : XFIXNUM (width
) * FRAME_COLUMN_WIDTH (f
));
3478 pixel_height
= (!NILP (pixelwise
)
3480 : XFIXNUM (height
) * FRAME_LINE_HEIGHT (f
));
3481 adjust_frame_size (f
, pixel_width
, pixel_height
, 1, 0, Qsize
);
3486 DEFUN ("frame-position", Fframe_position
,
3487 Sframe_position
, 0, 1, 0,
3488 doc
: /* Return top left corner of FRAME in pixels.
3489 FRAME must be a live frame and defaults to the selected one. The return
3490 value is a cons (x, y) of the coordinates of the top left corner of
3491 FRAME's outer frame, in pixels relative to an origin (0, 0) of FRAME's
3495 register struct frame
*f
= decode_live_frame (frame
);
3497 return Fcons (make_fixnum (f
->left_pos
), make_fixnum (f
->top_pos
));
3500 DEFUN ("set-frame-position", Fset_frame_position
,
3501 Sset_frame_position
, 3, 3, 0,
3502 doc
: /* Set position of FRAME to (X, Y).
3503 FRAME must be a live frame and defaults to the selected one. X and Y,
3504 if positive, specify the coordinate of the left and top edge of FRAME's
3505 outer frame in pixels relative to an origin (0, 0) of FRAME's display.
3506 If any of X or Y is negative, it specifies the coordinates of the right
3507 or bottom edge of the outer frame of FRAME relative to the right or
3508 bottom edge of FRAME's display. */)
3509 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
3511 struct frame
*f
= decode_live_frame (frame
);
3513 CHECK_TYPE_RANGED_INTEGER (int, x
);
3514 CHECK_TYPE_RANGED_INTEGER (int, y
);
3516 /* I think this should be done with a hook. */
3517 if (FRAME_WINDOW_P (f
))
3519 #ifdef HAVE_WINDOW_SYSTEM
3520 x_set_offset (f
, XFIXNUM (x
), XFIXNUM (y
), 1);
3527 /***********************************************************************
3529 ***********************************************************************/
3531 /* Connect the frame-parameter names for X frames
3532 to the ways of passing the parameter values to the window system.
3534 The name of a parameter, as a Lisp symbol,
3535 has an `x-frame-parameter' property which is an integer in Lisp
3536 that is an index in this table. */
3538 struct frame_parm_table
{
3543 static const struct frame_parm_table frame_parms
[] =
3545 {"auto-raise", SYMBOL_INDEX (Qauto_raise
)},
3546 {"auto-lower", SYMBOL_INDEX (Qauto_lower
)},
3547 {"background-color", -1},
3548 {"border-color", SYMBOL_INDEX (Qborder_color
)},
3549 {"border-width", SYMBOL_INDEX (Qborder_width
)},
3550 {"cursor-color", SYMBOL_INDEX (Qcursor_color
)},
3551 {"cursor-type", SYMBOL_INDEX (Qcursor_type
)},
3553 {"foreground-color", -1},
3554 {"icon-name", SYMBOL_INDEX (Qicon_name
)},
3555 {"icon-type", SYMBOL_INDEX (Qicon_type
)},
3556 {"internal-border-width", SYMBOL_INDEX (Qinternal_border_width
)},
3557 {"right-divider-width", SYMBOL_INDEX (Qright_divider_width
)},
3558 {"bottom-divider-width", SYMBOL_INDEX (Qbottom_divider_width
)},
3559 {"menu-bar-lines", SYMBOL_INDEX (Qmenu_bar_lines
)},
3560 {"mouse-color", SYMBOL_INDEX (Qmouse_color
)},
3561 {"name", SYMBOL_INDEX (Qname
)},
3562 {"scroll-bar-width", SYMBOL_INDEX (Qscroll_bar_width
)},
3563 {"scroll-bar-height", SYMBOL_INDEX (Qscroll_bar_height
)},
3564 {"title", SYMBOL_INDEX (Qtitle
)},
3565 {"unsplittable", SYMBOL_INDEX (Qunsplittable
)},
3566 {"vertical-scroll-bars", SYMBOL_INDEX (Qvertical_scroll_bars
)},
3567 {"horizontal-scroll-bars", SYMBOL_INDEX (Qhorizontal_scroll_bars
)},
3568 {"visibility", SYMBOL_INDEX (Qvisibility
)},
3569 {"tool-bar-lines", SYMBOL_INDEX (Qtool_bar_lines
)},
3570 {"scroll-bar-foreground", SYMBOL_INDEX (Qscroll_bar_foreground
)},
3571 {"scroll-bar-background", SYMBOL_INDEX (Qscroll_bar_background
)},
3572 {"screen-gamma", SYMBOL_INDEX (Qscreen_gamma
)},
3573 {"line-spacing", SYMBOL_INDEX (Qline_spacing
)},
3574 {"left-fringe", SYMBOL_INDEX (Qleft_fringe
)},
3575 {"right-fringe", SYMBOL_INDEX (Qright_fringe
)},
3576 {"wait-for-wm", SYMBOL_INDEX (Qwait_for_wm
)},
3577 {"fullscreen", SYMBOL_INDEX (Qfullscreen
)},
3578 {"font-backend", SYMBOL_INDEX (Qfont_backend
)},
3579 {"alpha", SYMBOL_INDEX (Qalpha
)},
3580 {"sticky", SYMBOL_INDEX (Qsticky
)},
3581 {"tool-bar-position", SYMBOL_INDEX (Qtool_bar_position
)},
3582 {"inhibit-double-buffering", SYMBOL_INDEX (Qinhibit_double_buffering
)},
3583 {"undecorated", SYMBOL_INDEX (Qundecorated
)},
3584 {"parent-frame", SYMBOL_INDEX (Qparent_frame
)},
3585 {"skip-taskbar", SYMBOL_INDEX (Qskip_taskbar
)},
3586 {"no-focus-on-map", SYMBOL_INDEX (Qno_focus_on_map
)},
3587 {"no-accept-focus", SYMBOL_INDEX (Qno_accept_focus
)},
3588 {"z-group", SYMBOL_INDEX (Qz_group
)},
3589 {"override-redirect", SYMBOL_INDEX (Qoverride_redirect
)},
3590 {"no-special-glyphs", SYMBOL_INDEX (Qno_special_glyphs
)},
3591 #ifdef NS_IMPL_COCOA
3592 {"ns-appearance", SYMBOL_INDEX (Qns_appearance
)},
3593 {"ns-transparent-titlebar", SYMBOL_INDEX (Qns_transparent_titlebar
)},
3597 #ifdef HAVE_WINDOW_SYSTEM
3599 /* Enumeration type for switch in frame_float. */
3600 enum frame_float_type
3611 * Process the value VAL of the float type frame parameter 'width',
3612 * 'height', 'left', or 'top' specified via a frame_float_type
3613 * enumeration type WHAT for frame F. Such parameters relate the outer
3614 * size or position of F to the size of the F's display or parent frame
3615 * which have to be both available in some way.
3617 * The return value is a size or position value in pixels. VAL must be
3618 * in the range 0.0 to 1.0 where a width/height of 0.0 means to return 0
3619 * and 1.0 means to return the full width/height of the display/parent.
3620 * For positions, 0.0 means position in the left/top corner of the
3621 * display/parent while 1.0 means to position at the right/bottom corner
3622 * of the display/parent frame.
3624 * Set PARENT_DONE and OUTER_DONE to avoid recalculation of the outer
3625 * size or parent or display attributes when more float parameters are
3626 * calculated in a row: -1 means not processed yet, 0 means processing
3627 * failed, 1 means processing succeeded.
3629 * Return DEFAULT_VALUE when processing fails for whatever reason with
3630 * one exception: When calculating F's outer edges fails (probably
3631 * because F has not been created yet) return the difference between F's
3632 * native and text size.
3635 frame_float (struct frame
*f
, Lisp_Object val
, enum frame_float_type what
,
3636 int *parent_done
, int *outer_done
, int default_value
)
3638 double d_val
= XFLOAT_DATA (val
);
3640 if (d_val
< 0.0 || d_val
> 1.0)
3642 return default_value
;
3645 static unsigned parent_width
, parent_height
;
3646 static int parent_left
, parent_top
;
3647 static unsigned outer_minus_text_width
, outer_minus_text_height
;
3648 struct frame
*p
= FRAME_PARENT_FRAME (f
);
3650 if (*parent_done
== 1)
3654 parent_width
= FRAME_PIXEL_WIDTH (p
);
3655 parent_height
= FRAME_PIXEL_HEIGHT (p
);
3660 if (*parent_done
== 0)
3661 /* No workarea available. */
3662 return default_value
;
3663 else if (*parent_done
== -1)
3665 Lisp_Object monitor_attributes
;
3666 Lisp_Object workarea
;
3669 XSETFRAME (frame
, f
);
3670 monitor_attributes
= Fcar (call1 (Qdisplay_monitor_attributes_list
, frame
));
3671 if (NILP (monitor_attributes
))
3673 /* No monitor attributes available. */
3676 return default_value
;
3679 workarea
= Fcdr (Fassq (Qworkarea
, monitor_attributes
));
3680 if (NILP (workarea
))
3682 /* No workarea available. */
3685 return default_value
;
3688 /* Workarea available. */
3689 parent_left
= XFIXNUM (Fnth (make_fixnum (0), workarea
));
3690 parent_top
= XFIXNUM (Fnth (make_fixnum (1), workarea
));
3691 parent_width
= XFIXNUM (Fnth (make_fixnum (2), workarea
));
3692 parent_height
= XFIXNUM (Fnth (make_fixnum (3), workarea
));
3697 if (*outer_done
== 1)
3699 else if (FRAME_UNDECORATED (f
))
3701 outer_minus_text_width
3702 = FRAME_PIXEL_WIDTH (f
) - FRAME_TEXT_WIDTH (f
);
3703 outer_minus_text_height
3704 = FRAME_PIXEL_HEIGHT (f
) - FRAME_TEXT_HEIGHT (f
);
3707 else if (*outer_done
== 0)
3708 /* No outer size available. */
3709 return default_value
;
3710 else if (*outer_done
== -1)
3712 Lisp_Object frame
, outer_edges
;
3714 XSETFRAME (frame
, f
);
3715 outer_edges
= call2 (Qframe_edges
, frame
, Qouter_edges
);
3717 if (!NILP (outer_edges
))
3719 outer_minus_text_width
3720 = (XFIXNUM (Fnth (make_fixnum (2), outer_edges
))
3721 - XFIXNUM (Fnth (make_fixnum (0), outer_edges
))
3722 - FRAME_TEXT_WIDTH (f
));
3723 outer_minus_text_height
3724 = (XFIXNUM (Fnth (make_fixnum (3), outer_edges
))
3725 - XFIXNUM (Fnth (make_fixnum (1), outer_edges
))
3726 - FRAME_TEXT_HEIGHT (f
));
3730 /* If we can't get any outer edges, proceed as if the frame
3731 were undecorated. */
3732 outer_minus_text_width
3733 = FRAME_PIXEL_WIDTH (f
) - FRAME_TEXT_WIDTH (f
);
3734 outer_minus_text_height
3735 = FRAME_PIXEL_HEIGHT (f
) - FRAME_TEXT_HEIGHT (f
);
3743 case FRAME_FLOAT_WIDTH
:
3744 return parent_width
* d_val
- outer_minus_text_width
;
3746 case FRAME_FLOAT_HEIGHT
:
3747 return parent_height
* d_val
- outer_minus_text_height
;
3749 case FRAME_FLOAT_LEFT
:
3751 int rest_width
= (parent_width
3752 - FRAME_TEXT_WIDTH (f
)
3753 - outer_minus_text_width
);
3756 return (rest_width
<= 0 ? 0 : d_val
* rest_width
);
3758 return (rest_width
<= 0
3760 : parent_left
+ d_val
* rest_width
);
3762 case FRAME_FLOAT_TOP
:
3764 int rest_height
= (parent_height
3765 - FRAME_TEXT_HEIGHT (f
)
3766 - outer_minus_text_height
);
3769 return (rest_height
<= 0 ? 0 : d_val
* rest_height
);
3771 return (rest_height
<= 0
3773 : parent_top
+ d_val
* rest_height
);
3781 /* Change the parameters of frame F as specified by ALIST.
3782 If a parameter is not specially recognized, do nothing special;
3783 otherwise call the `x_set_...' function for that parameter.
3784 Except for certain geometry properties, always call store_frame_param
3785 to store the new value in the parameter alist. */
3788 x_set_frame_parameters (struct frame
*f
, Lisp_Object alist
)
3790 Lisp_Object tail
, frame
;
3793 /* If both of these parameters are present, it's more efficient to
3794 set them both at once. So we wait until we've looked at the
3795 entire list before we set them. */
3796 int width
= -1, height
= -1; /* -1 denotes they were not changed. */
3799 Lisp_Object left
, top
;
3801 /* Same with these. */
3802 Lisp_Object icon_left
, icon_top
;
3804 /* And with this. */
3805 Lisp_Object fullscreen UNINIT
;
3806 bool fullscreen_change
= false;
3808 /* Record in these vectors all the parms specified. */
3810 Lisp_Object
*values
;
3811 ptrdiff_t i
, j
, size
;
3812 bool left_no_change
= 0, top_no_change
= 0;
3813 #ifdef HAVE_X_WINDOWS
3814 bool icon_left_no_change
= 0, icon_top_no_change
= 0;
3816 int parent_done
= -1, outer_done
= -1;
3818 XSETFRAME (frame
, f
);
3819 for (size
= 0, tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3821 CHECK_LIST_END (tail
, alist
);
3824 SAFE_ALLOCA_LISP (parms
, 2 * size
);
3825 values
= parms
+ size
;
3827 /* Extract parm names and values into those vectors. */
3829 i
= 0, j
= size
- 1;
3830 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3832 Lisp_Object elt
= XCAR (tail
), prop
= Fcar (elt
), val
= Fcdr (elt
);
3834 /* Some properties are independent of other properties, but other
3835 properties are dependent upon them. These special properties
3836 are foreground_color, background_color (affects cursor_color)
3837 and font (affects fringe widths); they're recorded starting
3838 from the end of PARMS and VALUES to process them first by using
3839 reverse iteration. */
3841 if (EQ (prop
, Qforeground_color
)
3842 || EQ (prop
, Qbackground_color
)
3843 || EQ (prop
, Qfont
))
3857 /* TAIL and ALIST are not used again below here. */
3858 alist
= tail
= Qnil
;
3860 top
= left
= Qunbound
;
3861 icon_left
= icon_top
= Qunbound
;
3863 /* Reverse order is used to make sure that special
3864 properties noticed above are processed first. */
3865 for (i
= size
- 1; i
>= 0; i
--)
3867 Lisp_Object prop
, val
;
3872 if (EQ (prop
, Qwidth
))
3874 if (RANGED_FIXNUMP (0, val
, INT_MAX
))
3875 width
= XFIXNAT (val
) * FRAME_COLUMN_WIDTH (f
) ;
3876 else if (CONSP (val
) && EQ (XCAR (val
), Qtext_pixels
)
3877 && RANGED_FIXNUMP (0, XCDR (val
), INT_MAX
))
3878 width
= XFIXNAT (XCDR (val
));
3879 else if (FLOATP (val
))
3880 width
= frame_float (f
, val
, FRAME_FLOAT_WIDTH
, &parent_done
,
3883 else if (EQ (prop
, Qheight
))
3885 if (RANGED_FIXNUMP (0, val
, INT_MAX
))
3886 height
= XFIXNAT (val
) * FRAME_LINE_HEIGHT (f
);
3887 else if (CONSP (val
) && EQ (XCAR (val
), Qtext_pixels
)
3888 && RANGED_FIXNUMP (0, XCDR (val
), INT_MAX
))
3889 height
= XFIXNAT (XCDR (val
));
3890 else if (FLOATP (val
))
3891 height
= frame_float (f
, val
, FRAME_FLOAT_HEIGHT
, &parent_done
,
3894 else if (EQ (prop
, Qtop
))
3896 else if (EQ (prop
, Qleft
))
3898 else if (EQ (prop
, Qicon_top
))
3900 else if (EQ (prop
, Qicon_left
))
3902 else if (EQ (prop
, Qfullscreen
))
3905 fullscreen_change
= true;
3909 register Lisp_Object param_index
, old_value
;
3911 old_value
= get_frame_param (f
, prop
);
3913 store_frame_param (f
, prop
, val
);
3915 param_index
= Fget (prop
, Qx_frame_parameter
);
3916 if (FIXNATP (param_index
)
3917 && XFIXNAT (param_index
) < ARRAYELTS (frame_parms
)
3918 && FRAME_RIF (f
)->frame_parm_handlers
[XFIXNUM (param_index
)])
3919 (*(FRAME_RIF (f
)->frame_parm_handlers
[XFIXNUM (param_index
)])) (f
, val
, old_value
);
3923 /* Don't die if just one of these was set. */
3924 if (EQ (left
, Qunbound
))
3927 if (f
->left_pos
< 0)
3928 left
= list2 (Qplus
, make_fixnum (f
->left_pos
));
3930 XSETINT (left
, f
->left_pos
);
3932 if (EQ (top
, Qunbound
))
3936 top
= list2 (Qplus
, make_fixnum (f
->top_pos
));
3938 XSETINT (top
, f
->top_pos
);
3941 /* If one of the icon positions was not set, preserve or default it. */
3942 if (! TYPE_RANGED_FIXNUMP (int, icon_left
))
3944 #ifdef HAVE_X_WINDOWS
3945 icon_left_no_change
= 1;
3947 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3948 if (NILP (icon_left
))
3949 XSETINT (icon_left
, 0);
3951 if (! TYPE_RANGED_FIXNUMP (int, icon_top
))
3953 #ifdef HAVE_X_WINDOWS
3954 icon_top_no_change
= 1;
3956 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3957 if (NILP (icon_top
))
3958 XSETINT (icon_top
, 0);
3961 /* Don't set these parameters unless they've been explicitly
3962 specified. The window might be mapped or resized while we're in
3963 this function, and we don't want to override that unless the lisp
3964 code has asked for it.
3966 Don't set these parameters unless they actually differ from the
3967 window's current parameters; the window may not actually exist
3969 if ((width
!= -1 && width
!= FRAME_TEXT_WIDTH (f
))
3970 || (height
!= -1 && height
!= FRAME_TEXT_HEIGHT (f
)))
3971 /* We could consider checking f->after_make_frame here, but I
3972 don't have the faintest idea why the following is needed at
3973 all. With the old setting it can get a Heisenbug when
3974 EmacsFrameResize intermittently provokes a delayed
3975 change_frame_size in the middle of adjust_frame_size. */
3976 /** || (f->can_x_set_window_size && (f->new_height || f->new_width))) **/
3977 adjust_frame_size (f
, width
, height
, 1, 0, Qx_set_frame_parameters
);
3979 if ((!NILP (left
) || !NILP (top
))
3980 && ! (left_no_change
&& top_no_change
)
3981 && ! (FIXNUMP (left
) && XFIXNUM (left
) == f
->left_pos
3982 && FIXNUMP (top
) && XFIXNUM (top
) == f
->top_pos
))
3987 /* Record the signs. */
3988 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3989 if (EQ (left
, Qminus
))
3990 f
->size_hint_flags
|= XNegative
;
3991 else if (TYPE_RANGED_FIXNUMP (int, left
))
3993 leftpos
= XFIXNUM (left
);
3995 f
->size_hint_flags
|= XNegative
;
3997 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3998 && CONSP (XCDR (left
))
3999 && RANGED_FIXNUMP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
4001 leftpos
= - XFIXNUM (XCAR (XCDR (left
)));
4002 f
->size_hint_flags
|= XNegative
;
4004 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
4005 && CONSP (XCDR (left
))
4006 && TYPE_RANGED_FIXNUMP (int, XCAR (XCDR (left
))))
4007 leftpos
= XFIXNUM (XCAR (XCDR (left
)));
4008 else if (FLOATP (left
))
4009 leftpos
= frame_float (f
, left
, FRAME_FLOAT_LEFT
, &parent_done
,
4012 if (EQ (top
, Qminus
))
4013 f
->size_hint_flags
|= YNegative
;
4014 else if (TYPE_RANGED_FIXNUMP (int, top
))
4016 toppos
= XFIXNUM (top
);
4018 f
->size_hint_flags
|= YNegative
;
4020 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
4021 && CONSP (XCDR (top
))
4022 && RANGED_FIXNUMP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
4024 toppos
= - XFIXNUM (XCAR (XCDR (top
)));
4025 f
->size_hint_flags
|= YNegative
;
4027 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
4028 && CONSP (XCDR (top
))
4029 && TYPE_RANGED_FIXNUMP (int, XCAR (XCDR (top
))))
4030 toppos
= XFIXNUM (XCAR (XCDR (top
)));
4031 else if (FLOATP (top
))
4032 toppos
= frame_float (f
, top
, FRAME_FLOAT_TOP
, &parent_done
,
4035 /* Store the numeric value of the position. */
4036 f
->top_pos
= toppos
;
4037 f
->left_pos
= leftpos
;
4039 f
->win_gravity
= NorthWestGravity
;
4041 /* Actually set that position, and convert to absolute. */
4042 x_set_offset (f
, leftpos
, toppos
, -1);
4045 if (fullscreen_change
)
4047 Lisp_Object old_value
= get_frame_param (f
, Qfullscreen
);
4049 frame_size_history_add
4050 (f
, Qx_set_fullscreen
, 0, 0, list2 (old_value
, fullscreen
));
4052 store_frame_param (f
, Qfullscreen
, fullscreen
);
4053 if (!EQ (fullscreen
, old_value
))
4054 x_set_fullscreen (f
, fullscreen
, old_value
);
4058 #ifdef HAVE_X_WINDOWS
4059 if ((!NILP (icon_left
) || !NILP (icon_top
))
4060 && ! (icon_left_no_change
&& icon_top_no_change
))
4061 x_wm_set_icon_position (f
, XFIXNUM (icon_left
), XFIXNUM (icon_top
));
4062 #endif /* HAVE_X_WINDOWS */
4068 /* Insert a description of internally-recorded parameters of frame X
4069 into the parameter alist *ALISTPTR that is to be given to the user.
4070 Only parameters that are specific to the X window system
4071 and whose values are not correctly recorded in the frame's
4072 param_alist need to be considered here. */
4075 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
4079 char buf
[INT_BUFSIZE_BOUND (w
)];
4081 /* Represent negative positions (off the top or left screen edge)
4082 in a way that Fmodify_frame_parameters will understand correctly. */
4083 XSETINT (tem
, f
->left_pos
);
4084 if (f
->left_pos
>= 0)
4085 store_in_alist (alistptr
, Qleft
, tem
);
4087 store_in_alist (alistptr
, Qleft
, list2 (Qplus
, tem
));
4089 XSETINT (tem
, f
->top_pos
);
4090 if (f
->top_pos
>= 0)
4091 store_in_alist (alistptr
, Qtop
, tem
);
4093 store_in_alist (alistptr
, Qtop
, list2 (Qplus
, tem
));
4095 store_in_alist (alistptr
, Qborder_width
,
4096 make_fixnum (f
->border_width
));
4097 store_in_alist (alistptr
, Qinternal_border_width
,
4098 make_fixnum (FRAME_INTERNAL_BORDER_WIDTH (f
)));
4099 store_in_alist (alistptr
, Qright_divider_width
,
4100 make_fixnum (FRAME_RIGHT_DIVIDER_WIDTH (f
)));
4101 store_in_alist (alistptr
, Qbottom_divider_width
,
4102 make_fixnum (FRAME_BOTTOM_DIVIDER_WIDTH (f
)));
4103 store_in_alist (alistptr
, Qleft_fringe
,
4104 make_fixnum (FRAME_LEFT_FRINGE_WIDTH (f
)));
4105 store_in_alist (alistptr
, Qright_fringe
,
4106 make_fixnum (FRAME_RIGHT_FRINGE_WIDTH (f
)));
4107 store_in_alist (alistptr
, Qscroll_bar_width
,
4108 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
4110 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
4111 ? make_fixnum (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
4112 /* nil means "use default width"
4113 for non-toolkit scroll bar.
4114 ruler-mode.el depends on this. */
4116 store_in_alist (alistptr
, Qscroll_bar_height
,
4117 (! FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)
4119 : FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) > 0
4120 ? make_fixnum (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
4121 /* nil means "use default height"
4122 for non-toolkit scroll bar. */
4124 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
4125 MS-Windows it returns a value whose type is HANDLE, which is
4126 actually a pointer. Explicit casting avoids compiler
4128 w
= (uintptr_t) FRAME_X_WINDOW (f
);
4129 store_in_alist (alistptr
, Qwindow_id
,
4130 make_formatted_string (buf
, "%"pMu
, w
));
4131 #ifdef HAVE_X_WINDOWS
4132 #ifdef USE_X_TOOLKIT
4133 /* Tooltip frame may not have this widget. */
4134 if (FRAME_X_OUTPUT (f
)->widget
)
4136 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
4137 store_in_alist (alistptr
, Qouter_window_id
,
4138 make_formatted_string (buf
, "%"pMu
, w
));
4140 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
4141 store_in_alist (alistptr
, Qvisibility
,
4142 (FRAME_VISIBLE_P (f
) ? Qt
4143 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
4144 store_in_alist (alistptr
, Qdisplay
,
4145 XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
));
4147 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_DISPLAY_INFO (f
)->root_window
)
4150 tem
= make_fixed_natnum ((uintptr_t) FRAME_X_OUTPUT (f
)->parent_desc
);
4151 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
4152 store_in_alist (alistptr
, Qparent_id
, tem
);
4153 store_in_alist (alistptr
, Qtool_bar_position
, FRAME_TOOL_BAR_POSITION (f
));
4157 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
4158 the previous value of that parameter, NEW_VALUE is the new value. */
4161 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4163 if (NILP (new_value
))
4164 f
->want_fullscreen
= FULLSCREEN_NONE
;
4165 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
4166 f
->want_fullscreen
= FULLSCREEN_BOTH
;
4167 else if (EQ (new_value
, Qfullwidth
))
4168 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
4169 else if (EQ (new_value
, Qfullheight
))
4170 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
4171 else if (EQ (new_value
, Qmaximized
))
4172 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
4174 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
4175 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
4179 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
4180 the previous value of that parameter, NEW_VALUE is the new value. */
4183 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4185 if (NILP (new_value
))
4186 f
->extra_line_spacing
= 0;
4187 else if (RANGED_FIXNUMP (0, new_value
, INT_MAX
))
4188 f
->extra_line_spacing
= XFIXNAT (new_value
);
4189 else if (FLOATP (new_value
))
4191 int new_spacing
= XFLOAT_DATA (new_value
) * FRAME_LINE_HEIGHT (f
) + 0.5;
4193 if (new_spacing
>= 0)
4194 f
->extra_line_spacing
= new_spacing
;
4196 signal_error ("Invalid line-spacing", new_value
);
4199 signal_error ("Invalid line-spacing", new_value
);
4200 if (FRAME_VISIBLE_P (f
))
4205 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
4206 the previous value of that parameter, NEW_VALUE is the new value. */
4209 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4211 Lisp_Object bgcolor
;
4213 if (NILP (new_value
))
4215 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
4216 /* The value 0.4545 is the normal viewing gamma. */
4217 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
4219 signal_error ("Invalid screen-gamma", new_value
);
4221 /* Apply the new gamma value to the frame background. */
4222 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
4223 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
4225 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
4226 if (FIXNATP (parm_index
)
4227 && XFIXNAT (parm_index
) < ARRAYELTS (frame_parms
)
4228 && FRAME_RIF (f
)->frame_parm_handlers
[XFIXNAT (parm_index
)])
4229 (*FRAME_RIF (f
)->frame_parm_handlers
[XFIXNAT (parm_index
)])
4233 clear_face_cache (true); /* FIXME: Why of all frames? */
4239 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4241 Lisp_Object font_object
;
4243 #ifdef HAVE_X_WINDOWS
4244 Lisp_Object font_param
= arg
;
4247 /* Set the frame parameter back to the old value because we may
4248 fail to use ARG as the new parameter value. */
4249 store_frame_param (f
, Qfont
, oldval
);
4251 /* ARG is a fontset name, a font name, a cons of fontset name and a
4252 font object, or a font object. In the last case, this function
4256 fontset
= fs_query_fontset (arg
, 0);
4259 font_object
= font_open_by_name (f
, arg
);
4260 if (NILP (font_object
))
4261 error ("Font `%s' is not defined", SSDATA (arg
));
4262 arg
= AREF (font_object
, FONT_NAME_INDEX
);
4264 else if (fontset
> 0)
4266 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
4267 if (NILP (font_object
))
4268 error ("Font `%s' is not defined", SDATA (arg
));
4269 arg
= AREF (font_object
, FONT_NAME_INDEX
);
4272 error ("The default fontset can't be used for a frame font");
4274 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
4276 /* This is the case that the ASCII font of F's fontset XCAR
4277 (arg) is changed to the font XCDR (arg) by
4278 `set-fontset-font'. */
4279 fontset
= fs_query_fontset (XCAR (arg
), 0);
4281 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
4282 font_object
= XCDR (arg
);
4283 arg
= AREF (font_object
, FONT_NAME_INDEX
);
4284 #ifdef HAVE_X_WINDOWS
4285 font_param
= Ffont_get (font_object
, QCname
);
4288 else if (FONT_OBJECT_P (arg
))
4291 #ifdef HAVE_X_WINDOWS
4292 font_param
= Ffont_get (font_object
, QCname
);
4294 /* This is to store the XLFD font name in the frame parameter for
4295 backward compatibility. We should store the font-object
4296 itself in the future. */
4297 arg
= AREF (font_object
, FONT_NAME_INDEX
);
4298 fontset
= FRAME_FONTSET (f
);
4299 /* Check if we can use the current fontset. If not, set FONTSET
4300 to -1 to generate a new fontset from FONT-OBJECT. */
4303 Lisp_Object ascii_font
= fontset_ascii (fontset
);
4304 Lisp_Object spec
= font_spec_from_name (ascii_font
);
4306 /* SPEC might be nil because ASCII_FONT's name doesn't parse
4307 according to stupid XLFD rules, which, for example,
4308 disallow font names that include a dash followed by a
4309 number. So in those cases we simply request x_new_font
4310 below to generate a new fontset. */
4311 if (NILP (spec
) || ! font_match_p (spec
, font_object
))
4316 signal_error ("Invalid font", arg
);
4318 if (! NILP (Fequal (font_object
, oldval
)))
4321 x_new_font (f
, font_object
, fontset
);
4322 store_frame_param (f
, Qfont
, arg
);
4323 #ifdef HAVE_X_WINDOWS
4324 store_frame_param (f
, Qfont_parameter
, font_param
);
4326 /* Recalculate toolbar height. */
4327 f
->n_tool_bar_rows
= 0;
4329 /* Ensure we redraw it. */
4330 clear_current_matrices (f
);
4332 /* Attempt to hunt down bug#16028. */
4333 SET_FRAME_GARBAGED (f
);
4335 /* This is important if we are called by some Lisp as part of
4336 redisplaying the frame, see redisplay_internal. */
4337 f
->fonts_changed
= true;
4339 recompute_basic_faces (f
);
4341 do_pending_window_change (0);
4343 /* We used to call face-set-after-frame-default here, but it leads to
4344 recursive calls (since that function can set the `default' face's
4345 font which in turns changes the frame's `font' parameter).
4346 Also I don't know what this call is meant to do, but it seems the
4347 wrong way to do it anyway (it does a lot more work than what seems
4348 reasonable in response to a change to `font'). */
4353 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4355 if (! NILP (new_value
)
4356 && !CONSP (new_value
))
4360 CHECK_STRING (new_value
);
4361 p0
= p1
= SSDATA (new_value
);
4365 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
4367 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
4373 while ((c
= *++p1
) && c_isspace (c
));
4377 new_value
= Fnreverse (new_value
);
4380 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
4384 free_all_realized_faces (Qnil
);
4386 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
4387 if (NILP (new_value
))
4389 if (NILP (old_value
))
4390 error ("No font backend available");
4391 font_update_drivers (f
, old_value
);
4392 error ("None of specified font backends are available");
4394 store_frame_param (f
, Qfont_backend
, new_value
);
4400 XSETFRAME (frame
, f
);
4401 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
4403 windows_or_buffers_changed
= 18;
4408 x_set_left_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4410 int unit
= FRAME_COLUMN_WIDTH (f
);
4411 int old_width
= FRAME_LEFT_FRINGE_WIDTH (f
);
4414 new_width
= (RANGED_FIXNUMP (-INT_MAX
, new_value
, INT_MAX
)
4415 ? eabs (XFIXNUM (new_value
)) : 8);
4417 if (new_width
!= old_width
)
4419 f
->left_fringe_width
= new_width
;
4420 f
->fringe_cols
/* Round up. */
4421 = (new_width
+ FRAME_RIGHT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
4423 if (FRAME_X_WINDOW (f
) != 0)
4424 adjust_frame_size (f
, -1, -1, 3, 0, Qleft_fringe
);
4426 SET_FRAME_GARBAGED (f
);
4432 x_set_right_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4434 int unit
= FRAME_COLUMN_WIDTH (f
);
4435 int old_width
= FRAME_RIGHT_FRINGE_WIDTH (f
);
4438 new_width
= (RANGED_FIXNUMP (-INT_MAX
, new_value
, INT_MAX
)
4439 ? eabs (XFIXNUM (new_value
)) : 8);
4441 if (new_width
!= old_width
)
4443 f
->right_fringe_width
= new_width
;
4444 f
->fringe_cols
/* Round up. */
4445 = (new_width
+ FRAME_LEFT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
4447 if (FRAME_X_WINDOW (f
) != 0)
4448 adjust_frame_size (f
, -1, -1, 3, 0, Qright_fringe
);
4450 SET_FRAME_GARBAGED (f
);
4456 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4458 CHECK_TYPE_RANGED_INTEGER (int, arg
);
4460 if (XFIXNUM (arg
) == f
->border_width
)
4463 if (FRAME_X_WINDOW (f
) != 0)
4464 error ("Cannot change the border width of a frame");
4466 f
->border_width
= XFIXNUM (arg
);
4470 x_set_right_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4472 int old
= FRAME_RIGHT_DIVIDER_WIDTH (f
);
4473 CHECK_TYPE_RANGED_INTEGER (int, arg
);
4474 int new = max (0, XFIXNUM (arg
));
4477 f
->right_divider_width
= new;
4478 adjust_frame_size (f
, -1, -1, 4, 0, Qright_divider_width
);
4479 adjust_frame_glyphs (f
);
4480 SET_FRAME_GARBAGED (f
);
4485 x_set_bottom_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4487 int old
= FRAME_BOTTOM_DIVIDER_WIDTH (f
);
4488 CHECK_TYPE_RANGED_INTEGER (int, arg
);
4489 int new = max (0, XFIXNUM (arg
));
4492 f
->bottom_divider_width
= new;
4493 adjust_frame_size (f
, -1, -1, 4, 0, Qbottom_divider_width
);
4494 adjust_frame_glyphs (f
);
4495 SET_FRAME_GARBAGED (f
);
4500 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
4503 XSETFRAME (frame
, f
);
4506 Fmake_frame_invisible (frame
, Qt
);
4507 else if (EQ (value
, Qicon
))
4508 Ficonify_frame (frame
);
4510 Fmake_frame_visible (frame
);
4514 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4516 f
->auto_raise
= !NILP (arg
);
4520 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4522 f
->auto_lower
= !NILP (arg
);
4526 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4528 f
->no_split
= !NILP (arg
);
4532 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4534 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
4535 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
4536 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
4537 || (!NILP (arg
) && !FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
4539 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
4541 ? vertical_scroll_bar_none
4543 ? vertical_scroll_bar_left
4545 ? vertical_scroll_bar_right
4546 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
4547 ? vertical_scroll_bar_left
4548 : EQ (Qright
, Vdefault_frame_scroll_bars
)
4549 ? vertical_scroll_bar_right
4550 : vertical_scroll_bar_none
);
4552 /* We set this parameter before creating the X window for the
4553 frame, so we can get the geometry right from the start.
4554 However, if the window hasn't been created yet, we shouldn't
4555 call x_set_window_size. */
4556 if (FRAME_X_WINDOW (f
))
4557 adjust_frame_size (f
, -1, -1, 3, 0, Qvertical_scroll_bars
);
4559 SET_FRAME_GARBAGED (f
);
4564 x_set_horizontal_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4566 #if USE_HORIZONTAL_SCROLL_BARS
4567 if ((NILP (arg
) && FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
))
4568 || (!NILP (arg
) && !FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)))
4570 f
->horizontal_scroll_bars
= NILP (arg
) ? false : true;
4572 /* We set this parameter before creating the X window for the
4573 frame, so we can get the geometry right from the start.
4574 However, if the window hasn't been created yet, we shouldn't
4575 call x_set_window_size. */
4576 if (FRAME_X_WINDOW (f
))
4577 adjust_frame_size (f
, -1, -1, 3, 0, Qhorizontal_scroll_bars
);
4579 SET_FRAME_GARBAGED (f
);
4585 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4587 int unit
= FRAME_COLUMN_WIDTH (f
);
4591 x_set_scroll_bar_default_width (f
);
4593 if (FRAME_X_WINDOW (f
))
4594 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_width
);
4596 SET_FRAME_GARBAGED (f
);
4598 else if (RANGED_FIXNUMP (1, arg
, INT_MAX
)
4599 && XFIXNAT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
4601 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFIXNAT (arg
);
4602 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFIXNAT (arg
) + unit
- 1) / unit
;
4603 if (FRAME_X_WINDOW (f
))
4604 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_width
);
4606 SET_FRAME_GARBAGED (f
);
4609 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
4610 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
4614 x_set_scroll_bar_height (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4616 #if USE_HORIZONTAL_SCROLL_BARS
4617 int unit
= FRAME_LINE_HEIGHT (f
);
4621 x_set_scroll_bar_default_height (f
);
4623 if (FRAME_X_WINDOW (f
))
4624 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_height
);
4626 SET_FRAME_GARBAGED (f
);
4628 else if (RANGED_FIXNUMP (1, arg
, INT_MAX
)
4629 && XFIXNAT (arg
) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
4631 FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) = XFIXNAT (arg
);
4632 FRAME_CONFIG_SCROLL_BAR_LINES (f
) = (XFIXNAT (arg
) + unit
- 1) / unit
;
4633 if (FRAME_X_WINDOW (f
))
4634 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_height
);
4636 SET_FRAME_GARBAGED (f
);
4639 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.vpos
= 0;
4640 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.y
= 0;
4645 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4652 for (i
= 0; i
< 2; i
++)
4665 else if (FLOATP (item
))
4667 alpha
= XFLOAT_DATA (item
);
4668 if (! (0 <= alpha
&& alpha
<= 1.0))
4669 args_out_of_range (make_float (0.0), make_float (1.0));
4671 else if (FIXNUMP (item
))
4673 EMACS_INT ialpha
= XFIXNUM (item
);
4674 if (! (0 <= ialpha
&& ialpha
<= 100))
4675 args_out_of_range (make_fixnum (0), make_fixnum (100));
4676 alpha
= ialpha
/ 100.0;
4679 wrong_type_argument (Qnumberp
, item
);
4683 for (i
= 0; i
< 2; i
++)
4684 f
->alpha
[i
] = newval
[i
];
4686 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
4688 x_set_frame_alpha (f
);
4697 * x_set_no_special_glyphs:
4699 * Set frame F's `no-special-glyphs' parameter which, if non-nil,
4700 * suppresses the display of truncation and continuation glyphs
4704 x_set_no_special_glyphs (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4706 if (!EQ (new_value
, old_value
))
4707 FRAME_NO_SPECIAL_GLYPHS (f
) = !NILP (new_value
);
4713 /* Non-zero if mouse is grabbed on DPYINFO
4714 and we know the frame where it is. */
4716 bool x_mouse_grabbed (Display_Info
*dpyinfo
)
4718 return (dpyinfo
->grabbed
4719 && dpyinfo
->last_mouse_frame
4720 && FRAME_LIVE_P (dpyinfo
->last_mouse_frame
));
4723 /* Re-highlight something with mouse-face properties
4724 on DPYINFO using saved frame and mouse position. */
4727 x_redo_mouse_highlight (Display_Info
*dpyinfo
)
4729 if (dpyinfo
->last_mouse_motion_frame
4730 && FRAME_LIVE_P (dpyinfo
->last_mouse_motion_frame
))
4731 note_mouse_highlight (dpyinfo
->last_mouse_motion_frame
,
4732 dpyinfo
->last_mouse_motion_x
,
4733 dpyinfo
->last_mouse_motion_y
);
4736 #endif /* HAVE_NS */
4738 /* Subroutines of creating an X frame. */
4740 /* Make sure that Vx_resource_name is set to a reasonable value.
4741 Fix it up, or set it to `emacs' if it is too hopeless. */
4744 validate_x_resource_name (void)
4747 /* Number of valid characters in the resource name. */
4748 ptrdiff_t good_count
= 0;
4749 /* Number of invalid characters in the resource name. */
4750 ptrdiff_t bad_count
= 0;
4754 if (!STRINGP (Vx_resource_class
))
4755 Vx_resource_class
= build_string (EMACS_CLASS
);
4757 if (STRINGP (Vx_resource_name
))
4759 unsigned char *p
= SDATA (Vx_resource_name
);
4761 len
= SBYTES (Vx_resource_name
);
4763 /* Only letters, digits, - and _ are valid in resource names.
4764 Count the valid characters and count the invalid ones. */
4765 for (i
= 0; i
< len
; i
++)
4768 if (! ((c
>= 'a' && c
<= 'z')
4769 || (c
>= 'A' && c
<= 'Z')
4770 || (c
>= '0' && c
<= '9')
4771 || c
== '-' || c
== '_'))
4778 /* Not a string => completely invalid. */
4779 bad_count
= 5, good_count
= 0;
4781 /* If name is valid already, return. */
4785 /* If name is entirely invalid, or nearly so, or is so implausibly
4786 large that alloca might not work, use `emacs'. */
4787 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
4789 Vx_resource_name
= build_string ("emacs");
4793 /* Name is partly valid. Copy it and replace the invalid characters
4794 with underscores. */
4796 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
4798 for (i
= 0; i
< len
; i
++)
4800 int c
= SREF (new, i
);
4801 if (! ((c
>= 'a' && c
<= 'z')
4802 || (c
>= 'A' && c
<= 'Z')
4803 || (c
>= '0' && c
<= '9')
4804 || c
== '-' || c
== '_'))
4809 /* Get specified attribute from resource database RDB.
4810 See Fx_get_resource below for other parameters. */
4813 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
4815 CHECK_STRING (attribute
);
4816 CHECK_STRING (class);
4818 if (!NILP (component
))
4819 CHECK_STRING (component
);
4820 if (!NILP (subclass
))
4821 CHECK_STRING (subclass
);
4822 if (NILP (component
) != NILP (subclass
))
4823 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
4825 validate_x_resource_name ();
4827 /* Allocate space for the components, the dots which separate them,
4828 and the final '\0'. Make them big enough for the worst case. */
4829 ptrdiff_t name_keysize
= (SBYTES (Vx_resource_name
)
4830 + (STRINGP (component
)
4831 ? SBYTES (component
) : 0)
4832 + SBYTES (attribute
)
4835 ptrdiff_t class_keysize
= (SBYTES (Vx_resource_class
)
4837 + (STRINGP (subclass
)
4838 ? SBYTES (subclass
) : 0)
4841 char *name_key
= SAFE_ALLOCA (name_keysize
+ class_keysize
);
4842 char *class_key
= name_key
+ name_keysize
;
4843 name_key
= ptr_bounds_clip (name_key
, name_keysize
);
4844 class_key
= ptr_bounds_clip (class_key
, class_keysize
);
4846 /* Start with emacs.FRAMENAME for the name (the specific one)
4847 and with `Emacs' for the class key (the general one). */
4848 char *nz
= lispstpcpy (name_key
, Vx_resource_name
);
4849 char *cz
= lispstpcpy (class_key
, Vx_resource_class
);
4852 cz
= lispstpcpy (cz
, class);
4854 if (!NILP (component
))
4857 lispstpcpy (cz
, subclass
);
4860 nz
= lispstpcpy (nz
, component
);
4864 lispstpcpy (nz
, attribute
);
4866 char *value
= x_get_string_resource (rdb
, name_key
, class_key
);
4869 if (value
&& *value
)
4870 return build_string (value
);
4876 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
4877 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
4878 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
4879 class, where INSTANCE is the name under which Emacs was invoked, or
4880 the name specified by the `-name' or `-rn' command-line arguments.
4882 The optional arguments COMPONENT and SUBCLASS add to the key and the
4883 class, respectively. You must specify both of them or neither.
4884 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
4885 and the class is `Emacs.CLASS.SUBCLASS'. */)
4886 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
,
4887 Lisp_Object subclass
)
4889 check_window_system (NULL
);
4891 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
4892 attribute
, class, component
, subclass
);
4895 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
4898 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
,
4899 Lisp_Object
class, Lisp_Object component
,
4900 Lisp_Object subclass
)
4902 return xrdb_get_resource (dpyinfo
->xrdb
,
4903 attribute
, class, component
, subclass
);
4906 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT && !defined USE_GTK
4907 /* Used when C code wants a resource value. */
4908 /* Called from oldXMenu/Create.c. */
4910 x_get_resource_string (const char *attribute
, const char *class)
4913 struct frame
*sf
= SELECTED_FRAME ();
4914 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
4917 /* Allocate space for the components, the dots which separate them,
4918 and the final '\0'. */
4919 ptrdiff_t name_keysize
= invocation_namelen
+ strlen (attribute
) + 2;
4920 ptrdiff_t class_keysize
= sizeof (EMACS_CLASS
) - 1 + strlen (class) + 2;
4921 char *name_key
= SAFE_ALLOCA (name_keysize
+ class_keysize
);
4922 char *class_key
= name_key
+ name_keysize
;
4923 name_key
= ptr_bounds_clip (name_key
, name_keysize
);
4924 class_key
= ptr_bounds_clip (class_key
, class_keysize
);
4926 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
4927 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
4929 result
= x_get_string_resource (FRAME_DISPLAY_INFO (sf
)->xrdb
,
4930 name_key
, class_key
);
4936 /* Return the value of parameter PARAM.
4938 First search ALIST, then Vdefault_frame_alist, then the X defaults
4939 database, using ATTRIBUTE as the attribute name and CLASS as its class.
4941 Convert the resource to the type specified by desired_type.
4943 If no default is specified, return Qunbound. If you call
4944 x_get_arg, make sure you deal with Qunbound in a reasonable way,
4945 and don't let it get stored in any Lisp-visible variables! */
4948 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
4949 const char *attribute
, const char *class, enum resource_types type
)
4953 tem
= Fassq (param
, alist
);
4957 /* If we find this parm in ALIST, clear it out
4958 so that it won't be "left over" at the end. */
4960 XSETCAR (tem
, Qnil
);
4961 /* In case the parameter appears more than once in the alist,
4963 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
4964 if (CONSP (XCAR (tail
))
4965 && EQ (XCAR (XCAR (tail
)), param
))
4966 XSETCAR (XCAR (tail
), Qnil
);
4969 tem
= Fassq (param
, Vdefault_frame_alist
);
4971 /* If it wasn't specified in ALIST or the Lisp-level defaults,
4972 look in the X resources. */
4975 if (attribute
&& dpyinfo
)
4977 AUTO_STRING (at
, attribute
);
4978 AUTO_STRING (cl
, class);
4979 tem
= display_x_get_resource (dpyinfo
, at
, cl
, Qnil
, Qnil
);
4986 case RES_TYPE_NUMBER
:
4987 return make_fixnum (atoi (SSDATA (tem
)));
4989 case RES_TYPE_BOOLEAN_NUMBER
:
4990 if (!strcmp (SSDATA (tem
), "on")
4991 || !strcmp (SSDATA (tem
), "true"))
4992 return make_fixnum (1);
4993 return make_fixnum (atoi (SSDATA (tem
)));
4996 case RES_TYPE_FLOAT
:
4997 return make_float (atof (SSDATA (tem
)));
4999 case RES_TYPE_BOOLEAN
:
5000 tem
= Fdowncase (tem
);
5001 if (!strcmp (SSDATA (tem
), "on")
5003 || !strcmp (SSDATA (tem
), "yes")
5005 || !strcmp (SSDATA (tem
), "true"))
5010 case RES_TYPE_STRING
:
5013 case RES_TYPE_SYMBOL
:
5014 /* As a special case, we map the values `true' and `on'
5015 to Qt, and `false' and `off' to Qnil. */
5018 lower
= Fdowncase (tem
);
5019 if (!strcmp (SSDATA (lower
), "on")
5021 || !strcmp (SSDATA (lower
), "yes")
5023 || !strcmp (SSDATA (lower
), "true"))
5025 else if (!strcmp (SSDATA (lower
), "off")
5027 || !strcmp (SSDATA (lower
), "no")
5029 || !strcmp (SSDATA (lower
), "false"))
5032 return Fintern (tem
, Qnil
);
5046 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
5047 const char *attribute
, const char *class,
5048 enum resource_types type
)
5050 return x_get_arg (FRAME_DISPLAY_INFO (f
),
5051 alist
, param
, attribute
, class, type
);
5054 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
5057 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
5059 const char *attribute
, const char *class,
5060 enum resource_types type
)
5064 value
= x_get_arg (FRAME_DISPLAY_INFO (f
), alist
, param
,
5065 attribute
, class, type
);
5066 if (! NILP (value
) && ! EQ (value
, Qunbound
))
5067 store_frame_param (f
, param
, value
);
5073 /* Record in frame F the specified or default value according to ALIST
5074 of the parameter named PROP (a Lisp symbol).
5075 If no value is specified for PROP, look for an X default for XPROP
5076 on the frame named NAME.
5077 If that is not found either, use the value DEFLT. */
5080 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
5081 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
5082 enum resource_types type
)
5086 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
5087 if (EQ (tem
, Qunbound
))
5089 AUTO_FRAME_ARG (arg
, prop
, tem
);
5090 x_set_frame_parameters (f
, arg
);
5095 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
5098 * XParseGeometry parses strings of the form
5099 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
5100 * width, height, xoffset, and yoffset are unsigned integers.
5101 * Example: "=80x24+300-49"
5102 * The equal sign is optional.
5103 * It returns a bitmask that indicates which of the four values
5104 * were actually found in the string. For each value found,
5105 * the corresponding argument is updated; for each value
5106 * not found, the corresponding argument is left unchanged.
5110 XParseGeometry (char *string
,
5112 unsigned int *width
, unsigned int *height
)
5116 unsigned long tempWidth UNINIT
, tempHeight UNINIT
;
5117 long int tempX UNINIT
, tempY UNINIT
;
5118 char *nextCharacter
;
5120 if (string
== NULL
|| *string
== '\0')
5123 string
++; /* ignore possible '=' at beg of geometry spec */
5126 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
5128 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
5129 if (strind
== nextCharacter
)
5131 strind
= nextCharacter
;
5135 if (*strind
== 'x' || *strind
== 'X')
5138 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
5139 if (strind
== nextCharacter
)
5141 strind
= nextCharacter
;
5142 mask
|= HeightValue
;
5145 if (*strind
== '+' || *strind
== '-')
5149 tempX
= strtol (strind
, &nextCharacter
, 10);
5150 if (strind
== nextCharacter
)
5152 strind
= nextCharacter
;
5154 if (*strind
== '+' || *strind
== '-')
5158 tempY
= strtol (strind
, &nextCharacter
, 10);
5159 if (strind
== nextCharacter
)
5161 strind
= nextCharacter
;
5166 /* If strind isn't at the end of the string then it's an invalid
5167 geometry specification. */
5169 if (*strind
!= '\0')
5173 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
5175 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
5176 if (mask
& WidthValue
)
5177 *width
= min (tempWidth
, UINT_MAX
);
5178 if (mask
& HeightValue
)
5179 *height
= min (tempHeight
, UINT_MAX
);
5183 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
5186 /* NS used to define x-parse-geometry in ns-win.el, but that confused
5187 make-docfile: the documentation string in ns-win.el was used for
5188 x-parse-geometry even in non-NS builds.
5190 With two definitions of x-parse-geometry in this file, various
5191 things still get confused (eg M-x apropos documentation), so that
5192 it is best if the two definitions just share the same doc-string.
5194 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
5195 doc
: /* Parse a display geometry string STRING.
5196 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
5197 The properties returned may include `top', `left', `height', and `width'.
5198 For X, the value of `left' or `top' may be an integer,
5199 or a list (+ N) meaning N pixels relative to top/left corner,
5200 or a list (- N) meaning -N pixels relative to bottom/right corner.
5201 On Nextstep, this just calls `ns-parse-geometry'. */)
5202 (Lisp_Object string
)
5205 unsigned int width
, height
;
5208 CHECK_STRING (string
);
5211 if (strchr (SSDATA (string
), ' ') != NULL
)
5212 return call1 (Qns_parse_geometry
, string
);
5214 geometry
= XParseGeometry (SSDATA (string
),
5215 &x
, &y
, &width
, &height
);
5217 if (geometry
& XValue
)
5219 Lisp_Object element
;
5221 if (x
>= 0 && (geometry
& XNegative
))
5222 element
= list3 (Qleft
, Qminus
, make_fixnum (-x
));
5223 else if (x
< 0 && ! (geometry
& XNegative
))
5224 element
= list3 (Qleft
, Qplus
, make_fixnum (x
));
5226 element
= Fcons (Qleft
, make_fixnum (x
));
5227 result
= Fcons (element
, result
);
5230 if (geometry
& YValue
)
5232 Lisp_Object element
;
5234 if (y
>= 0 && (geometry
& YNegative
))
5235 element
= list3 (Qtop
, Qminus
, make_fixnum (-y
));
5236 else if (y
< 0 && ! (geometry
& YNegative
))
5237 element
= list3 (Qtop
, Qplus
, make_fixnum (y
));
5239 element
= Fcons (Qtop
, make_fixnum (y
));
5240 result
= Fcons (element
, result
);
5243 if (geometry
& WidthValue
)
5244 result
= Fcons (Fcons (Qwidth
, make_fixnum (width
)), result
);
5245 if (geometry
& HeightValue
)
5246 result
= Fcons (Fcons (Qheight
, make_fixnum (height
)), result
);
5252 /* Calculate the desired size and position of frame F.
5253 Return the flags saying which aspects were specified.
5255 Also set the win_gravity and size_hint_flags of F.
5257 Adjust height for toolbar if TOOLBAR_P is 1.
5259 This function does not make the coordinates positive. */
5261 #define DEFAULT_ROWS 36
5262 #define DEFAULT_COLS 80
5265 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, bool toolbar_p
, int *x_width
, int *x_height
)
5267 Lisp_Object height
, width
, user_size
, top
, left
, user_position
;
5268 long window_prompting
= 0;
5269 Display_Info
*dpyinfo
= FRAME_DISPLAY_INFO (f
);
5270 int parent_done
= -1, outer_done
= -1;
5272 /* Default values if we fall through.
5273 Actually, if that happens we should get
5274 window manager prompting. */
5275 SET_FRAME_WIDTH (f
, DEFAULT_COLS
* FRAME_COLUMN_WIDTH (f
));
5276 SET_FRAME_COLS (f
, DEFAULT_COLS
);
5277 SET_FRAME_HEIGHT (f
, DEFAULT_ROWS
* FRAME_LINE_HEIGHT (f
));
5278 SET_FRAME_LINES (f
, DEFAULT_ROWS
);
5280 /* Window managers expect that if program-specified
5281 positions are not (0,0), they're intentional, not defaults. */
5285 /* Calculate a tool bar height so that the user gets a text display
5286 area of the size he specified with -g or via .Xdefaults. Later
5287 changes of the tool bar height don't change the frame size. This
5288 is done so that users can create tall Emacs frames without having
5289 to guess how tall the tool bar will get. */
5290 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
5292 if (frame_default_tool_bar_height
)
5293 FRAME_TOOL_BAR_HEIGHT (f
) = frame_default_tool_bar_height
;
5298 relief
= (tool_bar_button_relief
>= 0
5299 ? tool_bar_button_relief
5300 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
5302 if (RANGED_FIXNUMP (1, Vtool_bar_button_margin
, INT_MAX
))
5303 margin
= XFIXNAT (Vtool_bar_button_margin
);
5304 else if (CONSP (Vtool_bar_button_margin
)
5305 && RANGED_FIXNUMP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
5306 margin
= XFIXNAT (XCDR (Vtool_bar_button_margin
));
5310 FRAME_TOOL_BAR_HEIGHT (f
)
5311 = DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
5315 /* Ensure that earlier new_width and new_height settings won't
5316 override what we specify below. */
5317 f
->new_width
= f
->new_height
= 0;
5319 height
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
5320 width
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
5321 if (!EQ (width
, Qunbound
) || !EQ (height
, Qunbound
))
5323 if (!EQ (width
, Qunbound
))
5325 if (CONSP (width
) && EQ (XCAR (width
), Qtext_pixels
))
5327 CHECK_FIXNUM (XCDR (width
));
5328 if ((XFIXNUM (XCDR (width
)) < 0 || XFIXNUM (XCDR (width
)) > INT_MAX
))
5329 xsignal1 (Qargs_out_of_range
, XCDR (width
));
5331 SET_FRAME_WIDTH (f
, XFIXNUM (XCDR (width
)));
5332 f
->inhibit_horizontal_resize
= true;
5333 *x_width
= XFIXNUM (XCDR (width
));
5335 else if (FLOATP (width
))
5337 double d_width
= XFLOAT_DATA (width
);
5339 if (d_width
< 0.0 || d_width
> 1.0)
5340 xsignal1 (Qargs_out_of_range
, width
);
5343 int new_width
= frame_float (f
, width
, FRAME_FLOAT_WIDTH
,
5344 &parent_done
, &outer_done
, -1);
5347 SET_FRAME_WIDTH (f
, new_width
);
5352 CHECK_FIXNUM (width
);
5353 if ((XFIXNUM (width
) < 0 || XFIXNUM (width
) > INT_MAX
))
5354 xsignal1 (Qargs_out_of_range
, width
);
5356 SET_FRAME_WIDTH (f
, XFIXNUM (width
) * FRAME_COLUMN_WIDTH (f
));
5360 if (!EQ (height
, Qunbound
))
5362 if (CONSP (height
) && EQ (XCAR (height
), Qtext_pixels
))
5364 CHECK_FIXNUM (XCDR (height
));
5365 if ((XFIXNUM (XCDR (height
)) < 0 || XFIXNUM (XCDR (height
)) > INT_MAX
))
5366 xsignal1 (Qargs_out_of_range
, XCDR (height
));
5368 SET_FRAME_HEIGHT (f
, XFIXNUM (XCDR (height
)));
5369 f
->inhibit_vertical_resize
= true;
5370 *x_height
= XFIXNUM (XCDR (height
));
5372 else if (FLOATP (height
))
5374 double d_height
= XFLOAT_DATA (height
);
5376 if (d_height
< 0.0 || d_height
> 1.0)
5377 xsignal1 (Qargs_out_of_range
, height
);
5380 int new_height
= frame_float (f
, height
, FRAME_FLOAT_HEIGHT
,
5381 &parent_done
, &outer_done
, -1);
5383 if (new_height
> -1)
5384 SET_FRAME_HEIGHT (f
, new_height
);
5389 CHECK_FIXNUM (height
);
5390 if ((XFIXNUM (height
) < 0) || (XFIXNUM (height
) > INT_MAX
))
5391 xsignal1 (Qargs_out_of_range
, height
);
5393 SET_FRAME_HEIGHT (f
, XFIXNUM (height
) * FRAME_LINE_HEIGHT (f
));
5397 user_size
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
5398 if (!NILP (user_size
) && !EQ (user_size
, Qunbound
))
5399 window_prompting
|= USSize
;
5401 window_prompting
|= PSize
;
5404 top
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
5405 left
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
5406 user_position
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
5407 if (! EQ (top
, Qunbound
) || ! EQ (left
, Qunbound
))
5409 if (EQ (top
, Qminus
))
5412 window_prompting
|= YNegative
;
5414 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
5415 && CONSP (XCDR (top
))
5416 && RANGED_FIXNUMP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
5418 f
->top_pos
= - XFIXNUM (XCAR (XCDR (top
)));
5419 window_prompting
|= YNegative
;
5421 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
5422 && CONSP (XCDR (top
))
5423 && TYPE_RANGED_FIXNUMP (int, XCAR (XCDR (top
))))
5425 f
->top_pos
= XFIXNUM (XCAR (XCDR (top
)));
5427 else if (FLOATP (top
))
5428 f
->top_pos
= frame_float (f
, top
, FRAME_FLOAT_TOP
, &parent_done
,
5430 else if (EQ (top
, Qunbound
))
5434 CHECK_TYPE_RANGED_INTEGER (int, top
);
5435 f
->top_pos
= XFIXNUM (top
);
5437 window_prompting
|= YNegative
;
5440 if (EQ (left
, Qminus
))
5443 window_prompting
|= XNegative
;
5445 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
5446 && CONSP (XCDR (left
))
5447 && RANGED_FIXNUMP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
5449 f
->left_pos
= - XFIXNUM (XCAR (XCDR (left
)));
5450 window_prompting
|= XNegative
;
5452 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
5453 && CONSP (XCDR (left
))
5454 && TYPE_RANGED_FIXNUMP (int, XCAR (XCDR (left
))))
5456 f
->left_pos
= XFIXNUM (XCAR (XCDR (left
)));
5458 else if (FLOATP (left
))
5459 f
->left_pos
= frame_float (f
, left
, FRAME_FLOAT_LEFT
, &parent_done
,
5461 else if (EQ (left
, Qunbound
))
5465 CHECK_TYPE_RANGED_INTEGER (int, left
);
5466 f
->left_pos
= XFIXNUM (left
);
5467 if (f
->left_pos
< 0)
5468 window_prompting
|= XNegative
;
5471 if (!NILP (user_position
) && ! EQ (user_position
, Qunbound
))
5472 window_prompting
|= USPosition
;
5474 window_prompting
|= PPosition
;
5477 if (window_prompting
& XNegative
)
5479 if (window_prompting
& YNegative
)
5480 f
->win_gravity
= SouthEastGravity
;
5482 f
->win_gravity
= NorthEastGravity
;
5486 if (window_prompting
& YNegative
)
5487 f
->win_gravity
= SouthWestGravity
;
5489 f
->win_gravity
= NorthWestGravity
;
5492 f
->size_hint_flags
= window_prompting
;
5494 return window_prompting
;
5499 #endif /* HAVE_WINDOW_SYSTEM */
5502 frame_make_pointer_invisible (struct frame
*f
)
5504 if (! NILP (Vmake_pointer_invisible
))
5506 if (f
&& FRAME_LIVE_P (f
) && !f
->pointer_invisible
5507 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
5510 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
5511 f
->pointer_invisible
= 1;
5517 frame_make_pointer_visible (struct frame
*f
)
5519 /* We don't check Vmake_pointer_invisible here in case the
5520 pointer was invisible when Vmake_pointer_invisible was set to nil. */
5521 if (f
&& FRAME_LIVE_P (f
) && f
->pointer_invisible
&& f
->mouse_moved
5522 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
5524 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
5525 f
->pointer_invisible
= 0;
5529 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
5530 Sframe_pointer_visible_p
, 0, 1, 0,
5531 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
5532 Otherwise it returns nil. FRAME omitted or nil means the
5533 selected frame. This is useful when `make-pointer-invisible' is set. */)
5536 return decode_any_frame (frame
)->pointer_invisible
? Qnil
: Qt
;
5541 /***********************************************************************
5543 ***********************************************************************/
5545 #ifdef HAVE_WINDOW_SYSTEM
5547 # if (defined HAVE_NS \
5548 || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR)))
5550 free_monitors (struct MonitorInfo
*monitors
, int n_monitors
)
5553 for (i
= 0; i
< n_monitors
; ++i
)
5554 xfree (monitors
[i
].name
);
5560 make_monitor_attribute_list (struct MonitorInfo
*monitors
,
5562 int primary_monitor
,
5563 Lisp_Object monitor_frames
,
5566 Lisp_Object attributes_list
= Qnil
;
5567 Lisp_Object primary_monitor_attributes
= Qnil
;
5570 for (i
= 0; i
< n_monitors
; ++i
)
5572 Lisp_Object geometry
, workarea
, attributes
= Qnil
;
5573 struct MonitorInfo
*mi
= &monitors
[i
];
5575 if (mi
->geom
.width
== 0) continue;
5577 workarea
= list4i (mi
->work
.x
, mi
->work
.y
,
5578 mi
->work
.width
, mi
->work
.height
);
5579 geometry
= list4i (mi
->geom
.x
, mi
->geom
.y
,
5580 mi
->geom
.width
, mi
->geom
.height
);
5581 attributes
= Fcons (Fcons (Qsource
, build_string (source
)),
5583 attributes
= Fcons (Fcons (Qframes
, AREF (monitor_frames
, i
)),
5585 attributes
= Fcons (Fcons (Qmm_size
,
5586 list2i (mi
->mm_width
, mi
->mm_height
)),
5588 attributes
= Fcons (Fcons (Qworkarea
, workarea
), attributes
);
5589 attributes
= Fcons (Fcons (Qgeometry
, geometry
), attributes
);
5591 attributes
= Fcons (Fcons (Qname
, make_string (mi
->name
,
5592 strlen (mi
->name
))),
5595 if (i
== primary_monitor
)
5596 primary_monitor_attributes
= attributes
;
5598 attributes_list
= Fcons (attributes
, attributes_list
);
5601 if (!NILP (primary_monitor_attributes
))
5602 attributes_list
= Fcons (primary_monitor_attributes
, attributes_list
);
5603 return attributes_list
;
5606 #endif /* HAVE_WINDOW_SYSTEM */
5609 /***********************************************************************
5611 ***********************************************************************/
5614 syms_of_frame (void)
5616 DEFSYM (Qframep
, "framep");
5617 DEFSYM (Qframe_live_p
, "frame-live-p");
5618 DEFSYM (Qframe_windows_min_size
, "frame-windows-min-size");
5619 DEFSYM (Qdisplay_monitor_attributes_list
, "display-monitor-attributes-list");
5620 DEFSYM (Qwindow__pixel_to_total
, "window--pixel-to-total");
5621 DEFSYM (Qexplicit_name
, "explicit-name");
5622 DEFSYM (Qheight
, "height");
5623 DEFSYM (Qicon
, "icon");
5624 DEFSYM (Qminibuffer
, "minibuffer");
5625 DEFSYM (Qundecorated
, "undecorated");
5626 DEFSYM (Qno_special_glyphs
, "no-special-glyphs");
5627 DEFSYM (Qparent_frame
, "parent-frame");
5628 DEFSYM (Qskip_taskbar
, "skip-taskbar");
5629 DEFSYM (Qno_focus_on_map
, "no-focus-on-map");
5630 DEFSYM (Qno_accept_focus
, "no-accept-focus");
5631 DEFSYM (Qz_group
, "z-group");
5632 DEFSYM (Qoverride_redirect
, "override-redirect");
5633 DEFSYM (Qdelete_before
, "delete-before");
5634 DEFSYM (Qmodeline
, "modeline");
5635 DEFSYM (Qonly
, "only");
5636 DEFSYM (Qnone
, "none");
5637 DEFSYM (Qwidth
, "width");
5638 DEFSYM (Qtext_pixels
, "text-pixels");
5639 DEFSYM (Qgeometry
, "geometry");
5640 DEFSYM (Qicon_left
, "icon-left");
5641 DEFSYM (Qicon_top
, "icon-top");
5642 DEFSYM (Qtooltip
, "tooltip");
5643 DEFSYM (Quser_position
, "user-position");
5644 DEFSYM (Quser_size
, "user-size");
5645 DEFSYM (Qwindow_id
, "window-id");
5646 #ifdef HAVE_X_WINDOWS
5647 DEFSYM (Qouter_window_id
, "outer-window-id");
5649 DEFSYM (Qparent_id
, "parent-id");
5651 DEFSYM (Qw32
, "w32");
5654 DEFSYM (Qvisible
, "visible");
5655 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
5656 DEFSYM (Qbuffer_list
, "buffer-list");
5657 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
5658 DEFSYM (Qdisplay_type
, "display-type");
5659 DEFSYM (Qbackground_mode
, "background-mode");
5660 DEFSYM (Qnoelisp
, "noelisp");
5661 DEFSYM (Qtty_color_mode
, "tty-color-mode");
5662 DEFSYM (Qtty
, "tty");
5663 DEFSYM (Qtty_type
, "tty-type");
5665 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
5667 DEFSYM (Qfullwidth
, "fullwidth");
5668 DEFSYM (Qfullheight
, "fullheight");
5669 DEFSYM (Qfullboth
, "fullboth");
5670 DEFSYM (Qmaximized
, "maximized");
5671 DEFSYM (Qx_resource_name
, "x-resource-name");
5672 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
5674 DEFSYM (Qworkarea
, "workarea");
5675 DEFSYM (Qmm_size
, "mm-size");
5676 DEFSYM (Qframes
, "frames");
5677 DEFSYM (Qsource
, "source");
5679 DEFSYM (Qframe_edges
, "frame-edges");
5680 DEFSYM (Qouter_edges
, "outer-edges");
5681 DEFSYM (Qouter_position
, "outer-position");
5682 DEFSYM (Qouter_size
, "outer-size");
5683 DEFSYM (Qnative_edges
, "native-edges");
5684 DEFSYM (Qinner_edges
, "inner-edges");
5685 DEFSYM (Qexternal_border_size
, "external-border-size");
5686 DEFSYM (Qtitle_bar_size
, "title-bar-size");
5687 DEFSYM (Qmenu_bar_external
, "menu-bar-external");
5688 DEFSYM (Qmenu_bar_size
, "menu-bar-size");
5689 DEFSYM (Qtool_bar_external
, "tool-bar-external");
5690 DEFSYM (Qtool_bar_size
, "tool-bar-size");
5691 /* The following are used for frame_size_history. */
5692 DEFSYM (Qadjust_frame_size_1
, "adjust-frame-size-1");
5693 DEFSYM (Qadjust_frame_size_2
, "adjust-frame-size-2");
5694 DEFSYM (Qadjust_frame_size_3
, "adjust-frame-size-3");
5695 DEFSYM (Qx_set_frame_parameters
, "x-set-frame-parameters");
5696 DEFSYM (QEmacsFrameResize
, "EmacsFrameResize");
5697 DEFSYM (Qset_frame_size
, "set-frame-size");
5698 DEFSYM (Qframe_inhibit_resize
, "frame-inhibit-resize");
5699 DEFSYM (Qx_set_fullscreen
, "x-set-fullscreen");
5700 DEFSYM (Qx_check_fullscreen
, "x-check-fullscreen");
5701 DEFSYM (Qxg_frame_resized
, "xg-frame-resized");
5702 DEFSYM (Qxg_frame_set_char_size_1
, "xg-frame-set-char-size-1");
5703 DEFSYM (Qxg_frame_set_char_size_2
, "xg-frame-set-char-size-2");
5704 DEFSYM (Qxg_frame_set_char_size_3
, "xg-frame-set-char-size-3");
5705 DEFSYM (Qx_set_window_size_1
, "x-set-window-size-1");
5706 DEFSYM (Qx_set_window_size_2
, "x-set-window-size-2");
5707 DEFSYM (Qx_set_window_size_3
, "x-set-window-size-3");
5708 DEFSYM (Qxg_change_toolbar_position
, "xg-change-toolbar-position");
5709 DEFSYM (Qx_net_wm_state
, "x-net-wm-state");
5710 DEFSYM (Qx_handle_net_wm_state
, "x-handle-net-wm-state");
5711 DEFSYM (Qtb_size_cb
, "tb-size-cb");
5712 DEFSYM (Qupdate_frame_tool_bar
, "update-frame-tool-bar");
5713 DEFSYM (Qfree_frame_tool_bar
, "free-frame-tool-bar");
5714 DEFSYM (Qx_set_menu_bar_lines
, "x-set-menu-bar-lines");
5715 DEFSYM (Qchange_frame_size
, "change-frame-size");
5716 DEFSYM (Qxg_frame_set_char_size
, "xg-frame-set-char-size");
5717 DEFSYM (Qset_window_configuration
, "set-window-configuration");
5718 DEFSYM (Qx_create_frame_1
, "x-create-frame-1");
5719 DEFSYM (Qx_create_frame_2
, "x-create-frame-2");
5720 DEFSYM (Qterminal_frame
, "terminal-frame");
5723 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
5725 #ifdef NS_IMPL_COCOA
5726 DEFSYM (Qns_appearance
, "ns-appearance");
5727 DEFSYM (Qns_transparent_titlebar
, "ns-transparent-titlebar");
5730 DEFSYM (Qalpha
, "alpha");
5731 DEFSYM (Qauto_lower
, "auto-lower");
5732 DEFSYM (Qauto_raise
, "auto-raise");
5733 DEFSYM (Qborder_color
, "border-color");
5734 DEFSYM (Qborder_width
, "border-width");
5735 DEFSYM (Qouter_border_width
, "outer-border-width");
5736 DEFSYM (Qbottom_divider_width
, "bottom-divider-width");
5737 DEFSYM (Qcursor_color
, "cursor-color");
5738 DEFSYM (Qcursor_type
, "cursor-type");
5739 DEFSYM (Qfont_backend
, "font-backend");
5740 DEFSYM (Qfullscreen
, "fullscreen");
5741 DEFSYM (Qhorizontal_scroll_bars
, "horizontal-scroll-bars");
5742 DEFSYM (Qicon_name
, "icon-name");
5743 DEFSYM (Qicon_type
, "icon-type");
5744 DEFSYM (Qinternal_border_width
, "internal-border-width");
5745 DEFSYM (Qleft_fringe
, "left-fringe");
5746 DEFSYM (Qline_spacing
, "line-spacing");
5747 DEFSYM (Qmenu_bar_lines
, "menu-bar-lines");
5748 DEFSYM (Qupdate_frame_menubar
, "update-frame-menubar");
5749 DEFSYM (Qfree_frame_menubar_1
, "free-frame-menubar-1");
5750 DEFSYM (Qfree_frame_menubar_2
, "free-frame-menubar-2");
5751 DEFSYM (Qmouse_color
, "mouse-color");
5752 DEFSYM (Qname
, "name");
5753 DEFSYM (Qright_divider_width
, "right-divider-width");
5754 DEFSYM (Qright_fringe
, "right-fringe");
5755 DEFSYM (Qscreen_gamma
, "screen-gamma");
5756 DEFSYM (Qscroll_bar_background
, "scroll-bar-background");
5757 DEFSYM (Qscroll_bar_foreground
, "scroll-bar-foreground");
5758 DEFSYM (Qscroll_bar_height
, "scroll-bar-height");
5759 DEFSYM (Qscroll_bar_width
, "scroll-bar-width");
5760 DEFSYM (Qsticky
, "sticky");
5761 DEFSYM (Qtitle
, "title");
5762 DEFSYM (Qtool_bar_lines
, "tool-bar-lines");
5763 DEFSYM (Qtool_bar_position
, "tool-bar-position");
5764 DEFSYM (Qunsplittable
, "unsplittable");
5765 DEFSYM (Qvertical_scroll_bars
, "vertical-scroll-bars");
5766 DEFSYM (Qvisibility
, "visibility");
5767 DEFSYM (Qwait_for_wm
, "wait-for-wm");
5768 DEFSYM (Qinhibit_double_buffering
, "inhibit-double-buffering");
5769 DEFSYM (Qno_other_frame
, "no-other-frame");
5770 DEFSYM (Qbelow
, "below");
5771 DEFSYM (Qabove_suspended
, "above-suspended");
5772 DEFSYM (Qmin_width
, "min-width");
5773 DEFSYM (Qmin_height
, "min-height");
5774 DEFSYM (Qmouse_wheel_frame
, "mouse-wheel-frame");
5775 DEFSYM (Qkeep_ratio
, "keep-ratio");
5776 DEFSYM (Qwidth_only
, "width-only");
5777 DEFSYM (Qheight_only
, "height-only");
5778 DEFSYM (Qleft_only
, "left-only");
5779 DEFSYM (Qtop_only
, "top-only");
5780 DEFSYM (Qiconify_top_level
, "iconify-top-level");
5781 DEFSYM (Qmake_invisible
, "make-invisible");
5786 for (i
= 0; i
< ARRAYELTS (frame_parms
); i
++)
5788 Lisp_Object v
= (frame_parms
[i
].sym
< 0
5789 ? intern_c_string (frame_parms
[i
].name
)
5790 : builtin_lisp_symbol (frame_parms
[i
].sym
));
5791 Fput (v
, Qx_frame_parameter
, make_fixnum (i
));
5795 #ifdef HAVE_WINDOW_SYSTEM
5796 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
5797 doc
: /* The name Emacs uses to look up X resources.
5798 `x-get-resource' uses this as the first component of the instance name
5799 when requesting resource values.
5800 Emacs initially sets `x-resource-name' to the name under which Emacs
5801 was invoked, or to the value specified with the `-name' or `-rn'
5802 switches, if present.
5804 It may be useful to bind this variable locally around a call
5805 to `x-get-resource'. See also the variable `x-resource-class'. */);
5806 Vx_resource_name
= Qnil
;
5808 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
5809 doc
: /* The class Emacs uses to look up X resources.
5810 `x-get-resource' uses this as the first component of the instance class
5811 when requesting resource values.
5813 Emacs initially sets `x-resource-class' to "Emacs".
5815 Setting this variable permanently is not a reasonable thing to do,
5816 but binding this variable locally around a call to `x-get-resource'
5817 is a reasonable practice. See also the variable `x-resource-name'. */);
5818 Vx_resource_class
= build_string (EMACS_CLASS
);
5820 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
5821 doc
: /* The lower limit of the frame opacity (alpha transparency).
5822 The value should range from 0 (invisible) to 100 (completely opaque).
5823 You can also use a floating number between 0.0 and 1.0. */);
5824 Vframe_alpha_lower_limit
= make_fixnum (20);
5827 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
5828 doc
: /* Alist of default values for frame creation.
5829 These may be set in your init file, like this:
5830 (setq default-frame-alist \\='((width . 80) (height . 55) (menu-bar-lines . 1)))
5831 These override values given in window system configuration data,
5832 including X Windows' defaults database.
5833 For values specific to the first Emacs frame, see `initial-frame-alist'.
5834 For window-system specific values, see `window-system-default-frame-alist'.
5835 For values specific to the separate minibuffer frame, see
5836 `minibuffer-frame-alist'.
5837 The `menu-bar-lines' element of the list controls whether new frames
5838 have menu bars; `menu-bar-mode' works by altering this element.
5839 Setting this variable does not affect existing frames, only new ones. */);
5840 Vdefault_frame_alist
= Qnil
;
5842 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
5843 doc
: /* Default position of vertical scroll bars on this window-system. */);
5844 #ifdef HAVE_WINDOW_SYSTEM
5845 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
5846 /* MS-Windows, macOS, and GTK have scroll bars on the right by
5848 Vdefault_frame_scroll_bars
= Qright
;
5850 Vdefault_frame_scroll_bars
= Qleft
;
5853 Vdefault_frame_scroll_bars
= Qnil
;
5856 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
5857 scroll_bar_adjust_thumb_portion_p
,
5858 doc
: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
5859 Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
5860 even if the end of the buffer is shown (i.e. overscrolling).
5861 Set to nil if you want the thumb to be at the bottom when the end of the buffer
5862 is shown. Also, the thumb fills the whole scroll bar when the entire buffer
5863 is visible. In this case you can not overscroll. */);
5864 scroll_bar_adjust_thumb_portion_p
= 1;
5866 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
5867 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
5869 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
5870 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
5871 `mouse-position' and `mouse-pixel-position' call this function, passing their
5872 usual return value as argument, and return whatever this function returns.
5873 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
5874 which need to do mouse handling at the Lisp level. */);
5875 Vmouse_position_function
= Qnil
;
5877 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
5878 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
5879 If the value is an integer, highlighting is only shown after moving the
5880 mouse, while keyboard input turns off the highlight even when the mouse
5881 is over the clickable text. However, the mouse shape still indicates
5882 when the mouse is over clickable text. */);
5883 Vmouse_highlight
= Qt
;
5885 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
5886 doc
: /* If non-nil, make pointer invisible while typing.
5887 The pointer becomes visible again when the mouse is moved. */);
5888 Vmake_pointer_invisible
= Qt
;
5890 DEFVAR_LISP ("move-frame-functions", Vmove_frame_functions
,
5891 doc
: /* Functions run after a frame was moved.
5892 The functions are run with one arg, the frame that moved. */);
5893 Vmove_frame_functions
= Qnil
;
5895 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
5896 doc
: /* Functions run before deleting a frame.
5897 The functions are run with one arg, the frame to be deleted.
5900 Note that functions in this list may be called just before the frame is
5901 actually deleted, or some time later (or even both when an earlier function
5902 in `delete-frame-functions' (indirectly) calls `delete-frame'
5904 Vdelete_frame_functions
= Qnil
;
5905 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
5907 DEFVAR_LISP ("after-delete-frame-functions",
5908 Vafter_delete_frame_functions
,
5909 doc
: /* Functions run after deleting a frame.
5910 The functions are run with one arg, the frame that was deleted and
5911 which is now dead. */);
5912 Vafter_delete_frame_functions
= Qnil
;
5913 DEFSYM (Qafter_delete_frame_functions
, "after-delete-frame-functions");
5915 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
5916 doc
: /* Non-nil if Menu-Bar mode is enabled.
5917 See the command `menu-bar-mode' for a description of this minor mode.
5918 Setting this variable directly does not take effect;
5919 either customize it (see the info node `Easy Customization')
5920 or call the function `menu-bar-mode'. */);
5921 Vmenu_bar_mode
= Qt
;
5923 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
5924 doc
: /* Non-nil if Tool-Bar mode is enabled.
5925 See the command `tool-bar-mode' for a description of this minor mode.
5926 Setting this variable directly does not take effect;
5927 either customize it (see the info node `Easy Customization')
5928 or call the function `tool-bar-mode'. */);
5929 #ifdef HAVE_WINDOW_SYSTEM
5930 Vtool_bar_mode
= Qt
;
5932 Vtool_bar_mode
= Qnil
;
5935 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
5936 doc
: /* Minibuffer-less frames by default use this frame's minibuffer.
5937 Emacs consults this variable only when creating a minibuffer-less frame
5938 and no explicit minibuffer window has been specified for that frame via
5939 the `minibuffer' frame parameter. Once such a frame has been created,
5940 setting this variable does not change that frame's previous association.
5942 This variable is local to the current terminal and cannot be buffer-local. */);
5944 DEFVAR_LISP ("focus-follows-mouse", focus_follows_mouse
,
5945 doc
: /* Non-nil if window system changes focus when you move the mouse.
5946 You should set this variable to tell Emacs how your window manager
5947 handles focus, since there is no way in general for Emacs to find out
5950 There are three meaningful values:
5952 - The default nil should be used when your window manager follows a
5953 "click-to-focus" policy where you have to click the mouse inside of a
5954 frame in order for that frame to get focus.
5956 - The value t should be used when your window manager has the focus
5957 automatically follow the position of the mouse pointer but a window
5958 that gains focus is not raised automatically.
5960 - The value `auto-raise' should be used when your window manager has the
5961 focus automatically follow the position of the mouse pointer and a
5962 window that gains focus is raised automatically.
5964 If this option is non-nil, Emacs moves the mouse pointer to the frame
5965 selected by `select-frame-set-input-focus'. This function is used by a
5966 number of commands like, for example, `other-frame' and `pop-to-buffer'.
5967 If this option is nil and your focus follows mouse window manager does
5968 not autonomously move the mouse pointer to the newly selected frame, the
5969 previously selected window manager window might get reselected instead
5972 The distinction between the values t and `auto-raise' is not needed for
5973 "normal" frames because the window manager takes care of raising them.
5974 Setting this to `auto-raise' will, however, override the standard
5975 behavior of a window manager that does not automatically raise the frame
5976 that gets focus. Setting this to `auto-raise' is also necessary to
5977 automatically raise child frames which are usually left alone by the
5980 Note that this option does not distinguish "sloppy" focus (where the
5981 frame that previously had focus retains focus as long as the mouse
5982 pointer does not move into another window manager window) from "strict"
5983 focus (where a frame immediately loses focus when it's left by the mouse
5986 In order to extend a "focus follows mouse" policy to individual Emacs
5987 windows, customize the variable `mouse-autoselect-window'. */);
5988 focus_follows_mouse
= Qnil
;
5990 DEFVAR_BOOL ("frame-resize-pixelwise", frame_resize_pixelwise
,
5991 doc
: /* Non-nil means resize frames pixelwise.
5992 If this option is nil, resizing a frame rounds its sizes to the frame's
5993 current values of `frame-char-height' and `frame-char-width'. If this
5994 is non-nil, no rounding occurs, hence frame sizes can increase/decrease
5997 With some window managers you may have to set this to non-nil in order
5998 to set the size of a frame in pixels, to maximize frames or to make them
5999 fullscreen. To resize your initial frame pixelwise, set this option to
6000 a non-nil value in your init file. */);
6001 frame_resize_pixelwise
= 0;
6003 DEFVAR_LISP ("frame-inhibit-implied-resize", frame_inhibit_implied_resize
,
6004 doc
: /* Whether frames should be resized implicitly.
6005 If this option is nil, setting font, menu bar, tool bar, internal
6006 borders, fringes or scroll bars of a specific frame may resize the frame
6007 in order to preserve the number of columns or lines it displays. If
6008 this option is t, no such resizing is done. Note that the size of
6009 fullscreen and maximized frames, the height of fullheight frames and the
6010 width of fullwidth frames never change implicitly.
6012 The value of this option can be also be a list of frame parameters. In
6013 this case, resizing is inhibited when changing a parameter that appears
6014 in that list. The parameters currently handled by this option include
6015 `font', `font-backend', `internal-border-width', `menu-bar-lines' and
6018 Changing any of the parameters `scroll-bar-width', `scroll-bar-height',
6019 `vertical-scroll-bars', `horizontal-scroll-bars', `left-fringe' and
6020 `right-fringe' is handled as if the frame contained just one live
6021 window. This means, for example, that removing vertical scroll bars on
6022 a frame containing several side by side windows will shrink the frame
6023 width by the width of one scroll bar provided this option is nil and
6024 keep it unchanged if this option is either t or a list containing
6025 `vertical-scroll-bars'.
6027 The default value is \\='(tool-bar-lines) on Lucid, Motif and Windows
6028 \(which means that adding/removing a tool bar does not change the frame
6029 height), nil on all other window systems including GTK+ (which means
6030 that changing any of the parameters listed above may change the size of
6031 the frame), and t otherwise (which means the frame size never changes
6032 implicitly when there's no window system support).
6034 Note that when a frame is not large enough to accommodate a change of
6035 any of the parameters listed above, Emacs may try to enlarge the frame
6036 even if this option is non-nil. */);
6037 #if defined (HAVE_WINDOW_SYSTEM)
6038 #if defined (USE_LUCID) || defined (USE_MOTIF) || defined (HAVE_NTGUI)
6039 frame_inhibit_implied_resize
= list1 (Qtool_bar_lines
);
6041 frame_inhibit_implied_resize
= Qnil
;
6044 frame_inhibit_implied_resize
= Qt
;
6047 DEFVAR_LISP ("frame-size-history", frame_size_history
,
6048 doc
: /* History of frame size adjustments.
6049 If non-nil, list recording frame size adjustment. Adjustments are
6050 recorded only if the first element of this list is a positive number.
6051 Adding an adjustment decrements that number by one.
6053 The remaining elements are the adjustments. Each adjustment is a list
6054 of four elements `frame', `function', `sizes' and `more'. `frame' is
6055 the affected frame and `function' the invoking function. `sizes' is
6056 usually a list of four elements `old-width', `old-height', `new-width'
6057 and `new-height' representing the old and new sizes recorded/requested
6058 by `function'. `more' is a list with additional information.
6060 The function `frame--size-history' displays the value of this variable
6061 in a more readable form. */);
6062 frame_size_history
= Qnil
;
6064 DEFVAR_BOOL ("tooltip-reuse-hidden-frame", tooltip_reuse_hidden_frame
,
6065 doc
: /* Non-nil means reuse hidden tooltip frames.
6066 When this is nil, delete a tooltip frame when hiding the associated
6067 tooltip. When this is non-nil, make the tooltip frame invisible only,
6068 so it can be reused when the next tooltip is shown.
6070 Setting this to non-nil may drastically reduce the consing overhead
6071 incurred by creating new tooltip frames. However, a value of non-nil
6072 means also that intermittent changes of faces or `default-frame-alist'
6073 are not applied when showing a tooltip in a reused frame.
6075 This variable is effective only with the X toolkit (and there only when
6076 Gtk+ tooltips are not used) and on Windows. */);
6077 tooltip_reuse_hidden_frame
= false;
6079 DEFVAR_LISP ("iconify-child-frame", iconify_child_frame
,
6080 doc
: /* How to handle iconification of child frames.
6081 This variable tells Emacs how to proceed when it is asked to iconify a
6082 child frame. If it is nil, `iconify-frame' will do nothing when invoked
6083 on a child frame. If it is `iconify-top-level', Emacs will try to
6084 iconify the top level frame associated with this child frame instead.
6085 If it is `make-invisible', Emacs will try to make this child frame
6088 Any other value means to try iconifying the child frame. Since such an
6089 attempt is not honored by all window managers and may even lead to
6090 making the child frame unresponsive to user actions, the default is to
6091 iconify the top level frame instead. */);
6092 iconify_child_frame
= Qiconify_top_level
;
6094 staticpro (&Vframe_list
);
6097 defsubr (&Sframe_live_p
);
6098 defsubr (&Swindow_system
);
6099 defsubr (&Sframe_windows_min_size
);
6100 defsubr (&Smake_terminal_frame
);
6101 defsubr (&Shandle_switch_frame
);
6102 defsubr (&Sselect_frame
);
6103 defsubr (&Sselected_frame
);
6104 defsubr (&Sframe_list
);
6105 defsubr (&Sframe_parent
);
6106 defsubr (&Sframe_ancestor_p
);
6107 defsubr (&Snext_frame
);
6108 defsubr (&Sprevious_frame
);
6109 defsubr (&Slast_nonminibuf_frame
);
6110 defsubr (&Sdelete_frame
);
6111 defsubr (&Smouse_position
);
6112 defsubr (&Smouse_pixel_position
);
6113 defsubr (&Sset_mouse_position
);
6114 defsubr (&Sset_mouse_pixel_position
);
6116 defsubr (&Sframe_configuration
);
6117 defsubr (&Srestore_frame_configuration
);
6119 defsubr (&Smake_frame_visible
);
6120 defsubr (&Smake_frame_invisible
);
6121 defsubr (&Siconify_frame
);
6122 defsubr (&Sframe_visible_p
);
6123 defsubr (&Svisible_frame_list
);
6124 defsubr (&Sraise_frame
);
6125 defsubr (&Slower_frame
);
6126 defsubr (&Sx_focus_frame
);
6127 defsubr (&Sframe_after_make_frame
);
6128 defsubr (&Sredirect_frame_focus
);
6129 defsubr (&Sframe_focus
);
6130 defsubr (&Sframe_parameters
);
6131 defsubr (&Sframe_parameter
);
6132 defsubr (&Smodify_frame_parameters
);
6133 defsubr (&Sframe_char_height
);
6134 defsubr (&Sframe_char_width
);
6135 defsubr (&Sframe_native_height
);
6136 defsubr (&Sframe_native_width
);
6137 defsubr (&Sframe_text_cols
);
6138 defsubr (&Sframe_text_lines
);
6139 defsubr (&Sframe_total_cols
);
6140 defsubr (&Sframe_total_lines
);
6141 defsubr (&Sframe_text_width
);
6142 defsubr (&Sframe_text_height
);
6143 defsubr (&Sscroll_bar_width
);
6144 defsubr (&Sscroll_bar_height
);
6145 defsubr (&Sfringe_width
);
6146 defsubr (&Sframe_internal_border_width
);
6147 defsubr (&Sright_divider_width
);
6148 defsubr (&Sbottom_divider_width
);
6149 defsubr (&Stool_bar_pixel_width
);
6150 defsubr (&Sset_frame_height
);
6151 defsubr (&Sset_frame_width
);
6152 defsubr (&Sset_frame_size
);
6153 defsubr (&Sframe_position
);
6154 defsubr (&Sset_frame_position
);
6155 defsubr (&Sframe_pointer_visible_p
);
6157 #ifdef HAVE_WINDOW_SYSTEM
6158 defsubr (&Sx_get_resource
);
6159 defsubr (&Sx_parse_geometry
);