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 (register struct frame
*frame
, Lisp_Object prop
)
144 register Lisp_Object tem
;
146 tem
= Fassq (prop
, frame
->param_alist
);
154 frame_size_history_add (struct frame
*f
, Lisp_Object fun_symbol
,
155 int width
, int height
, Lisp_Object rest
)
159 XSETFRAME (frame
, f
);
160 if (CONSP (frame_size_history
)
161 && INTEGERP (XCAR (frame_size_history
))
162 && 0 < XINT (XCAR (frame_size_history
)))
164 Fcons (make_number (XINT (XCAR (frame_size_history
)) - 1),
168 ? list4 (make_number (FRAME_TEXT_WIDTH (f
)),
169 make_number (FRAME_TEXT_HEIGHT (f
)),
171 make_number (height
))
174 XCDR (frame_size_history
)));
178 /* Return 1 if `frame-inhibit-implied-resize' is non-nil or fullscreen
179 state of frame F would be affected by a vertical (horizontal if
180 HORIZONTAL is true) resize. PARAMETER is the symbol of the frame
181 parameter that is changed. */
183 frame_inhibit_resize (struct frame
*f
, bool horizontal
, Lisp_Object parameter
)
185 Lisp_Object fullscreen
= get_frame_param (f
, Qfullscreen
);
187 = (f
->after_make_frame
188 ? (EQ (frame_inhibit_implied_resize
, Qt
)
189 || (CONSP (frame_inhibit_implied_resize
)
190 && !NILP (Fmemq (parameter
, frame_inhibit_implied_resize
)))
192 && !EQ (fullscreen
, Qnil
) && !EQ (fullscreen
, Qfullheight
))
194 && !EQ (fullscreen
, Qnil
) && !EQ (fullscreen
, Qfullwidth
))
195 || FRAME_TERMCAP_P (f
) || FRAME_MSDOS_P (f
))
196 : ((horizontal
&& f
->inhibit_horizontal_resize
)
197 || (!horizontal
&& f
->inhibit_vertical_resize
)));
198 if (inhibit
&& !FRAME_TERMCAP_P (f
) && !FRAME_MSDOS_P (f
))
199 frame_size_history_add
200 (f
, Qframe_inhibit_resize
, 0, 0,
201 list5 (horizontal
? Qt
: Qnil
, parameter
,
202 f
->after_make_frame
? Qt
: Qnil
,
203 frame_inhibit_implied_resize
,
210 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
213 int olines
= FRAME_MENU_BAR_LINES (f
);
215 /* Right now, menu bars don't work properly in minibuf-only frames;
216 most of the commands try to apply themselves to the minibuffer
217 frame itself, and get an error because you can't switch buffers
218 in or split the minibuffer window. */
219 if (FRAME_MINIBUF_ONLY_P (f
))
222 if (TYPE_RANGED_INTEGERP (int, value
))
223 nlines
= XINT (value
);
227 if (nlines
!= olines
)
229 windows_or_buffers_changed
= 14;
230 FRAME_MENU_BAR_LINES (f
) = nlines
;
231 FRAME_MENU_BAR_HEIGHT (f
) = nlines
* FRAME_LINE_HEIGHT (f
);
232 change_frame_size (f
, FRAME_COLS (f
),
233 FRAME_LINES (f
) + olines
- nlines
,
238 Lisp_Object Vframe_list
;
241 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
242 doc
: /* Return non-nil if OBJECT is a frame.
244 t for a termcap frame (a character-only terminal),
245 `x' for an Emacs frame that is really an X window,
246 `w32' for an Emacs frame that is a window on MS-Windows display,
247 `ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
248 `pc' for a direct-write MS-DOS frame.
249 See also `frame-live-p'. */)
252 if (!FRAMEP (object
))
254 switch (XFRAME (object
)->output_method
)
256 case output_initial
: /* The initial frame is like a termcap frame. */
259 case output_x_window
:
263 case output_msdos_raw
:
272 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
273 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
274 Value is nil if OBJECT is not a live frame. If object is a live
275 frame, the return value indicates what sort of terminal device it is
276 displayed on. See the documentation of `framep' for possible
280 return ((FRAMEP (object
)
281 && FRAME_LIVE_P (XFRAME (object
)))
286 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
287 doc
: /* The name of the window system that FRAME is displaying through.
288 The value is a symbol:
289 nil for a termcap frame (a character-only terminal),
290 `x' for an Emacs frame that is really an X window,
291 `w32' for an Emacs frame that is a window on MS-Windows display,
292 `ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
293 `pc' for a direct-write MS-DOS frame.
295 FRAME defaults to the currently selected frame.
297 Use of this function as a predicate is deprecated. Instead,
298 use `display-graphic-p' or any of the other `display-*-p'
299 predicates which report frame's specific UI-related capabilities. */)
304 frame
= selected_frame
;
306 type
= Fframep (frame
);
309 wrong_type_argument (Qframep
, frame
);
317 /* Placeholder used by temacs -nw before window.el is loaded. */
318 DEFUN ("frame-windows-min-size", Fframe_windows_min_size
,
319 Sframe_windows_min_size
, 4, 4, 0,
322 (Lisp_Object frame
, Lisp_Object horizontal
,
323 Lisp_Object ignore
, Lisp_Object pixelwise
)
325 return make_number (0);
329 * frame_windows_min_size:
331 * Return the minimum number of lines (columns if HORIZONTAL is non-nil)
332 * of FRAME. If PIXELWISE is non-nil, return the minimum inner height
333 * (width) of FRAME in pixels.
335 * This value is calculated by the function `frame-windows-min-size' in
336 * window.el unless the `min-height' (`min-width' if HORIZONTAL is
337 * non-nil) parameter of FRAME is non-nil thus explicitly specifying the
338 * value to be returned. In that latter case IGNORE is ignored.
340 * If `frame-windows-min-size' is called, it will make sure that the
341 * return value accommodates all windows of FRAME respecting the values
342 * of `window-min-height' (`window-min-width' if HORIZONTAL is non-nil).
343 * With IGNORE non-nil the values of these variables are ignored.
345 * In either case, never return a value less than 1.
348 frame_windows_min_size (Lisp_Object frame
, Lisp_Object horizontal
,
349 Lisp_Object ignore
, Lisp_Object pixelwise
)
351 struct frame
*f
= XFRAME (frame
);
352 Lisp_Object par_size
;
354 if ((!NILP (horizontal
)
355 && NUMBERP (par_size
= get_frame_param (f
, Qmin_width
)))
356 || (NILP (horizontal
)
357 && NUMBERP (par_size
= get_frame_param (f
, Qmin_height
))))
359 int min_size
= XINT (par_size
);
361 /* Don't allow phantom frames. */
365 return (NILP (pixelwise
)
367 : min_size
* (NILP (horizontal
)
368 ? FRAME_LINE_HEIGHT (f
)
369 : FRAME_COLUMN_WIDTH (f
)));
372 return XINT (call4 (Qframe_windows_min_size
, frame
, horizontal
,
377 #ifdef HAVE_WINDOW_SYSTEM
381 * Preserve ratios of frame F which usually happens after its parent
382 * frame P got resized. OLD_WIDTH, OLD_HEIGHT specifies the old native
383 * size of F's parent, NEW_WIDTH and NEW_HEIGHT its new size.
385 * Adjust F's width if F's 'keep_ratio' parameter is non-nil and, if
386 * it is a cons, its car is not 'height-only'. Adjust F's height if F's
387 * 'keep_ratio' parameter is non-nil and, if it is a cons, its car
388 * is not 'width-only'.
390 * Adjust F's left position if F's 'keep_ratio' parameter is non-nil
391 * and, if its is a cons, its cdr is non-nil and not 'top-only'. Adjust
392 * F's top position if F's 'keep_ratio' parameter is non-nil and, if
393 * its is a cons, its cdr is non-nil and not 'left-only'.
395 * Note that when positional adjustment is requested but the size of F
396 * should remain unaltered in the corresponding direction, this routine
397 * tries to constrain F to its parent frame - something which usually
398 * happens when the parent frame shrinks. This means, however, that
399 * when the parent frame is re-enlarged later, the child's original
400 * position will not get restored to its pre-shrinking value.
402 * This routine is currently useful for child frames only. It might be
403 * eventually useful when moving non-child frames between monitors with
404 * different resolutions.
407 keep_ratio (struct frame
*f
, struct frame
*p
, int old_width
, int old_height
,
408 int new_width
, int new_height
)
410 Lisp_Object keep_ratio
= get_frame_param (f
, Qkeep_ratio
);
413 if (!NILP (keep_ratio
))
415 double width_factor
= (double)new_width
/ (double)old_width
;
416 double height_factor
= (double)new_height
/ (double)old_height
;
417 int pixel_width
, pixel_height
, pos_x
, pos_y
;
419 if (!CONSP (keep_ratio
) || !NILP (Fcdr (keep_ratio
)))
421 if (CONSP (keep_ratio
) && EQ (Fcdr (keep_ratio
), Qtop_only
))
425 pos_x
= (int)(f
->left_pos
* width_factor
+ 0.5);
427 if (CONSP (keep_ratio
)
428 && (NILP (Fcar (keep_ratio
))
429 || EQ (Fcar (keep_ratio
), Qheight_only
))
430 && p
->pixel_width
- f
->pixel_width
< pos_x
)
432 int p_f_width
= p
->pixel_width
- f
->pixel_width
;
437 pos_x
= (int)(p_f_width
* width_factor
* 0.5 + 0.5);
443 if (CONSP (keep_ratio
) && EQ (Fcdr (keep_ratio
), Qleft_only
))
447 pos_y
= (int)(f
->top_pos
* height_factor
+ 0.5);
449 if (CONSP (keep_ratio
)
450 && (NILP (Fcar (keep_ratio
))
451 || EQ (Fcar (keep_ratio
), Qwidth_only
))
452 && p
->pixel_height
- f
->pixel_height
< pos_y
)
453 /* When positional adjustment was requested and the
454 width of F should remain unaltered, try to constrain
455 F to its parent. This means that when the parent
456 frame is enlarged later the child's original position
457 won't get restored. */
459 int p_f_height
= p
->pixel_height
- f
->pixel_height
;
464 pos_y
= (int)(p_f_height
* height_factor
* 0.5 + 0.5);
470 x_set_offset (f
, pos_x
, pos_y
, -1);
473 if (!CONSP (keep_ratio
) || !NILP (Fcar (keep_ratio
)))
475 if (CONSP (keep_ratio
) && EQ (Fcar (keep_ratio
), Qheight_only
))
479 pixel_width
= (int)(f
->pixel_width
* width_factor
+ 0.5);
480 pixel_width
= FRAME_PIXEL_TO_TEXT_WIDTH (f
, pixel_width
);
483 if (CONSP (keep_ratio
) && EQ (Fcar (keep_ratio
), Qwidth_only
))
487 pixel_height
= (int)(f
->pixel_height
* height_factor
+ 0.5);
488 pixel_height
= FRAME_PIXEL_TO_TEXT_HEIGHT (f
, pixel_height
);
491 adjust_frame_size (f
, pixel_width
, pixel_height
, 1, 0,
502 * Adjust size of frame F. NEW_WIDTH and NEW_HEIGHT specify the new
503 * text size of F in pixels. A value of -1 means no change is requested
504 * for that direction (but the frame may still have to be resized to
505 * accommodate windows with their minimum sizes). This can either issue
506 * a request to resize the frame externally (via x_set_window_size), to
507 * resize the frame internally (via resize_frame_windows) or do nothing
510 * The argument INHIBIT can assume the following values:
512 * 0 means to unconditionally call x_set_window_size even if sizes
513 * apparently do not change. Fx_create_frame uses this to pass the
514 * initial size to the window manager.
516 * 1 means to call x_set_window_size if the native frame size really
517 * changes. Fset_frame_size, Fset_frame_height, ... use this.
519 * 2 means to call x_set_window_size provided frame_inhibit_resize
520 * allows it. The menu and tool bar code use this ("3" won't work
521 * here in general because menu and tool bar are often not counted in
522 * the frame's text height).
524 * 3 means call x_set_window_size if window minimum sizes must be
525 * preserved or frame_inhibit_resize allows it. x_set_left_fringe,
526 * x_set_scroll_bar_width, x_new_font ... use (or should use) this.
528 * 4 means call x_set_window_size only if window minimum sizes must be
529 * preserved. x_set_right_divider_width, x_set_border_width and the
530 * code responsible for wrapping the tool bar use this.
532 * 5 means to never call x_set_window_size. change_frame_size uses
535 * Note that even when x_set_window_size is not called, individual
536 * windows may have to be resized (via `window--sanitize-window-sizes')
537 * in order to support minimum size constraints.
539 * PRETEND is as for change_frame_size. PARAMETER, if non-nil, is the
540 * symbol of the parameter changed (like `menu-bar-lines', `font', ...).
541 * This is passed on to frame_inhibit_resize to let the latter decide on
542 * a case-by-case basis whether the frame may be resized externally.
545 adjust_frame_size (struct frame
*f
, int new_width
, int new_height
, int inhibit
,
546 bool pretend
, Lisp_Object parameter
)
548 int unit_width
= FRAME_COLUMN_WIDTH (f
);
549 int unit_height
= FRAME_LINE_HEIGHT (f
);
550 int old_pixel_width
= FRAME_PIXEL_WIDTH (f
);
551 int old_pixel_height
= FRAME_PIXEL_HEIGHT (f
);
552 int old_cols
= FRAME_COLS (f
);
553 int old_lines
= FRAME_LINES (f
);
554 int new_pixel_width
, new_pixel_height
;
555 /* The following two values are calculated from the old frame pixel
556 sizes and any "new" settings for tool bar, menu bar and internal
557 borders. We do it this way to detect whether we have to call
558 x_set_window_size as consequence of the new settings. */
559 int windows_width
= FRAME_WINDOWS_WIDTH (f
);
560 int windows_height
= FRAME_WINDOWS_HEIGHT (f
);
561 int min_windows_width
, min_windows_height
;
562 /* These are a bit tedious, maybe we should use a macro. */
563 struct window
*r
= XWINDOW (FRAME_ROOT_WINDOW (f
));
564 int old_windows_width
= WINDOW_PIXEL_WIDTH (r
);
565 int old_windows_height
566 = (WINDOW_PIXEL_HEIGHT (r
)
567 + ((FRAME_HAS_MINIBUF_P (f
) && !FRAME_MINIBUF_ONLY_P (f
))
568 ? WINDOW_PIXEL_HEIGHT (XWINDOW (FRAME_MINIBUF_WINDOW (f
)))
570 int new_windows_width
, new_windows_height
;
571 int old_text_width
= FRAME_TEXT_WIDTH (f
);
572 int old_text_height
= FRAME_TEXT_HEIGHT (f
);
573 /* If a size is < 0 use the old value. */
574 int new_text_width
= (new_width
>= 0) ? new_width
: old_text_width
;
575 int new_text_height
= (new_height
>= 0) ? new_height
: old_text_height
;
576 int new_cols
, new_lines
;
577 bool inhibit_horizontal
, inhibit_vertical
;
580 XSETFRAME (frame
, f
);
582 frame_size_history_add
583 (f
, Qadjust_frame_size_1
, new_text_width
, new_text_height
,
584 list2 (parameter
, make_number (inhibit
)));
586 /* The following two values are calculated from the old window body
587 sizes and any "new" settings for scroll bars, dividers, fringes and
588 margins (though the latter should have been processed already). */
590 = frame_windows_min_size (frame
, Qt
, (inhibit
== 5) ? Qt
: Qnil
, Qt
);
592 = frame_windows_min_size (frame
, Qnil
, (inhibit
== 5) ? Qt
: Qnil
, Qt
);
594 if (inhibit
>= 2 && inhibit
<= 4)
595 /* When INHIBIT is in [2..4] inhibit if the "old" window sizes stay
596 within the limits and either resizing is inhibited or INHIBIT
599 inhibit_horizontal
= (windows_width
>= min_windows_width
601 || frame_inhibit_resize (f
, true, parameter
)));
602 inhibit_vertical
= (windows_height
>= min_windows_height
604 || frame_inhibit_resize (f
, false, parameter
)));
607 /* Otherwise inhibit if INHIBIT equals 5. */
608 inhibit_horizontal
= inhibit_vertical
= inhibit
== 5;
610 new_pixel_width
= ((inhibit_horizontal
&& (inhibit
< 5))
612 : max (FRAME_TEXT_TO_PIXEL_WIDTH (f
, new_text_width
),
614 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
615 new_windows_width
= new_pixel_width
- 2 * FRAME_INTERNAL_BORDER_WIDTH (f
);
616 new_text_width
= FRAME_PIXEL_TO_TEXT_WIDTH (f
, new_pixel_width
);
617 new_cols
= new_text_width
/ unit_width
;
619 new_pixel_height
= ((inhibit_vertical
&& (inhibit
< 5))
621 : max (FRAME_TEXT_TO_PIXEL_HEIGHT (f
, new_text_height
),
623 + FRAME_TOP_MARGIN_HEIGHT (f
)
624 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
625 new_windows_height
= (new_pixel_height
626 - FRAME_TOP_MARGIN_HEIGHT (f
)
627 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f
));
628 new_text_height
= FRAME_PIXEL_TO_TEXT_HEIGHT (f
, new_pixel_height
);
629 new_lines
= new_text_height
/ unit_height
;
631 #ifdef HAVE_WINDOW_SYSTEM
632 if (FRAME_WINDOW_P (f
)
633 && f
->can_x_set_window_size
634 && ((!inhibit_horizontal
635 && (new_pixel_width
!= old_pixel_width
636 || inhibit
== 0 || inhibit
== 2))
637 || (!inhibit_vertical
638 && (new_pixel_height
!= old_pixel_height
639 || inhibit
== 0 || inhibit
== 2))))
640 /* We are either allowed to change the frame size or the minimum
641 sizes request such a change. Do not care for fixing minimum
642 sizes here, we do that eventually when we're called from
643 change_frame_size. */
645 /* Make sure we respect fullheight and fullwidth. */
646 if (inhibit_horizontal
)
647 new_text_width
= old_text_width
;
648 else if (inhibit_vertical
)
649 new_text_height
= old_text_height
;
651 frame_size_history_add
652 (f
, Qadjust_frame_size_2
, new_text_width
, new_text_height
,
653 list2 (inhibit_horizontal
? Qt
: Qnil
,
654 inhibit_vertical
? Qt
: Qnil
));
656 x_set_window_size (f
, 0, new_text_width
, new_text_height
, 1);
663 if (new_text_width
== old_text_width
664 && new_text_height
== old_text_height
665 && new_windows_width
== old_windows_width
666 && new_windows_height
== old_windows_height
667 && new_pixel_width
== old_pixel_width
668 && new_pixel_height
== old_pixel_height
669 && new_cols
== old_cols
670 && new_lines
== old_lines
)
671 /* No change. Sanitize window sizes and return. */
673 sanitize_window_sizes (Qt
);
674 sanitize_window_sizes (Qnil
);
682 /* We only can set screen dimensions to certain values supported by
683 our video hardware. Try to find the smallest size greater or
684 equal to the requested dimensions, while accounting for the fact
685 that the menu-bar lines are not counted in the frame height. */
686 int dos_new_lines
= new_lines
+ FRAME_TOP_MARGIN (f
);
687 dos_set_window_size (&dos_new_lines
, &new_cols
);
688 new_lines
= dos_new_lines
- FRAME_TOP_MARGIN (f
);
691 if (new_windows_width
!= old_windows_width
)
693 resize_frame_windows (f
, new_windows_width
, 1, 1);
695 /* MSDOS frames cannot PRETEND, as they change frame size by
696 manipulating video hardware. */
697 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
698 FrameCols (FRAME_TTY (f
)) = new_cols
;
700 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
701 if (WINDOWP (f
->tool_bar_window
))
703 XWINDOW (f
->tool_bar_window
)->pixel_width
= new_windows_width
;
704 XWINDOW (f
->tool_bar_window
)->total_cols
705 = new_windows_width
/ unit_width
;
709 else if (new_cols
!= old_cols
)
710 call2 (Qwindow__pixel_to_total
, frame
, Qt
);
712 if (new_windows_height
!= old_windows_height
713 /* When the top margin has changed we have to recalculate the top
714 edges of all windows. No such calculation is necessary for the
716 || WINDOW_TOP_PIXEL_EDGE (r
) != FRAME_TOP_MARGIN_HEIGHT (f
))
718 resize_frame_windows (f
, new_windows_height
, 0, 1);
720 /* MSDOS frames cannot PRETEND, as they change frame size by
721 manipulating video hardware. */
722 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
723 FrameRows (FRAME_TTY (f
)) = new_lines
+ FRAME_TOP_MARGIN (f
);
725 else if (new_lines
!= old_lines
)
726 call2 (Qwindow__pixel_to_total
, frame
, Qnil
);
728 frame_size_history_add
729 (f
, Qadjust_frame_size_3
, new_text_width
, new_text_height
,
730 list4 (make_number (old_pixel_width
), make_number (old_pixel_height
),
731 make_number (new_pixel_width
), make_number (new_pixel_height
)));
733 /* Assign new sizes. */
734 FRAME_TEXT_WIDTH (f
) = new_text_width
;
735 FRAME_TEXT_HEIGHT (f
) = new_text_height
;
736 FRAME_PIXEL_WIDTH (f
) = new_pixel_width
;
737 FRAME_PIXEL_HEIGHT (f
) = new_pixel_height
;
738 SET_FRAME_COLS (f
, new_cols
);
739 SET_FRAME_LINES (f
, new_lines
);
742 struct window
*w
= XWINDOW (FRAME_SELECTED_WINDOW (f
));
743 int text_area_x
, text_area_y
, text_area_width
, text_area_height
;
745 window_box (w
, TEXT_AREA
, &text_area_x
, &text_area_y
, &text_area_width
,
747 if (w
->cursor
.x
>= text_area_x
+ text_area_width
)
748 w
->cursor
.hpos
= w
->cursor
.x
= 0;
749 if (w
->cursor
.y
>= text_area_y
+ text_area_height
)
750 w
->cursor
.vpos
= w
->cursor
.y
= 0;
753 /* Sanitize window sizes. */
754 sanitize_window_sizes (Qt
);
755 sanitize_window_sizes (Qnil
);
757 adjust_frame_glyphs (f
);
759 SET_FRAME_GARBAGED (f
);
761 /* A frame was "resized" if one of its pixelsizes changed, even if its
762 X window wasn't resized at all. */
763 f
->resized_p
= (new_pixel_width
!= old_pixel_width
764 || new_pixel_height
!= old_pixel_height
);
768 #ifdef HAVE_WINDOW_SYSTEM
770 /* Adjust size of F's child frames. */
771 Lisp_Object frames
, frame1
;
773 FOR_EACH_FRAME (frames
, frame1
)
774 if (FRAME_PARENT_FRAME (XFRAME (frame1
)) == f
)
775 keep_ratio (XFRAME (frame1
), f
, old_pixel_width
, old_pixel_height
,
776 new_pixel_width
, new_pixel_height
);
781 /* Allocate basically initialized frame. */
783 static struct frame
*
784 allocate_frame (void)
786 return ALLOCATE_ZEROED_PSEUDOVECTOR (struct frame
, face_cache
, PVEC_FRAME
);
790 make_frame (bool mini_p
)
794 struct window
*rw
, *mw UNINIT
;
795 Lisp_Object root_window
;
796 Lisp_Object mini_window
;
798 f
= allocate_frame ();
799 XSETFRAME (frame
, f
);
802 /* Initialize Lisp data. Note that allocate_frame initializes all
803 Lisp data to nil, so do it only for slots which should not be nil. */
804 fset_tool_bar_position (f
, Qtop
);
807 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
808 non-Lisp data, so do it only for slots which should not be zero.
809 To avoid subtle bugs and for the sake of readability, it's better to
810 initialize enum members explicitly even if their values are zero. */
811 f
->wants_modeline
= true;
814 f
->can_x_set_window_size
= false;
815 f
->after_make_frame
= false;
816 f
->inhibit_horizontal_resize
= false;
817 f
->inhibit_vertical_resize
= false;
818 f
->tool_bar_redisplayed
= false;
819 f
->tool_bar_resized
= false;
820 f
->column_width
= 1; /* !FRAME_WINDOW_P value. */
821 f
->line_height
= 1; /* !FRAME_WINDOW_P value. */
822 #ifdef HAVE_WINDOW_SYSTEM
823 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
824 f
->horizontal_scroll_bars
= false;
825 f
->want_fullscreen
= FULLSCREEN_NONE
;
826 f
->undecorated
= false;
827 f
->no_special_glyphs
= false;
829 f
->override_redirect
= false;
831 f
->skip_taskbar
= false;
832 f
->no_focus_on_map
= false;
833 f
->no_accept_focus
= false;
834 f
->z_group
= z_group_none
;
835 #if ! defined (USE_GTK) && ! defined (HAVE_NS)
836 f
->last_tool_bar_item
= -1;
839 f
->ns_appearance
= ns_appearance_aqua
;
840 f
->ns_transparent_titlebar
= false;
844 root_window
= make_window ();
845 rw
= XWINDOW (root_window
);
848 mini_window
= make_window ();
849 mw
= XWINDOW (mini_window
);
850 wset_next (rw
, mini_window
);
851 wset_prev (mw
, root_window
);
853 wset_frame (mw
, frame
);
854 fset_minibuffer_window (f
, mini_window
);
855 store_frame_param (f
, Qminibuffer
, Qt
);
860 wset_next (rw
, Qnil
);
861 fset_minibuffer_window (f
, Qnil
);
864 wset_frame (rw
, frame
);
867 just so that there is "something there."
868 Correct size will be set up later with adjust_frame_size. */
870 SET_FRAME_COLS (f
, 10);
871 SET_FRAME_LINES (f
, 10);
872 SET_FRAME_WIDTH (f
, FRAME_COLS (f
) * FRAME_COLUMN_WIDTH (f
));
873 SET_FRAME_HEIGHT (f
, FRAME_LINES (f
) * FRAME_LINE_HEIGHT (f
));
876 rw
->pixel_width
= rw
->total_cols
* FRAME_COLUMN_WIDTH (f
);
877 rw
->total_lines
= mini_p
? 9 : 10;
878 rw
->pixel_height
= rw
->total_lines
* FRAME_LINE_HEIGHT (f
);
882 mw
->top_line
= rw
->total_lines
;
883 mw
->pixel_top
= rw
->pixel_height
;
884 mw
->total_cols
= rw
->total_cols
;
885 mw
->pixel_width
= rw
->pixel_width
;
887 mw
->pixel_height
= FRAME_LINE_HEIGHT (f
);
890 /* Choose a buffer for the frame's root window. */
892 Lisp_Object buf
= Fcurrent_buffer ();
894 /* If current buffer is hidden, try to find another one. */
895 if (BUFFER_HIDDEN_P (XBUFFER (buf
)))
896 buf
= other_buffer_safely (buf
);
898 /* Use set_window_buffer, not Fset_window_buffer, and don't let
899 hooks be run by it. The reason is that the whole frame/window
900 arrangement is not yet fully initialized at this point. Windows
901 don't have the right size, glyph matrices aren't initialized
902 etc. Running Lisp functions at this point surely ends in a
904 set_window_buffer (root_window
, buf
, 0, 0);
905 fset_buffer_list (f
, list1 (buf
));
910 set_window_buffer (mini_window
,
911 (NILP (Vminibuffer_list
)
913 : Fcar (Vminibuffer_list
)),
915 /* No horizontal scroll bars in minibuffers. */
916 wset_horizontal_scroll_bar (mw
, Qnil
);
919 fset_root_window (f
, root_window
);
920 fset_selected_window (f
, root_window
);
921 /* Make sure this window seems more recently used than
922 a newly-created, never-selected window. */
923 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
928 #ifdef HAVE_WINDOW_SYSTEM
929 /* Make a frame using a separate minibuffer window on another frame.
930 MINI_WINDOW is the minibuffer window to use. nil means use the
931 default (the global minibuffer). */
934 make_frame_without_minibuffer (Lisp_Object mini_window
, KBOARD
*kb
,
939 if (!NILP (mini_window
))
940 CHECK_LIVE_WINDOW (mini_window
);
942 if (!NILP (mini_window
)
943 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
944 error ("Frame and minibuffer must be on the same terminal");
946 /* Make a frame containing just a root window. */
949 if (NILP (mini_window
))
951 /* Use default-minibuffer-frame if possible. */
952 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
953 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
955 Lisp_Object frame_dummy
;
957 XSETFRAME (frame_dummy
, f
);
958 /* If there's no minibuffer frame to use, create one. */
959 kset_default_minibuffer_frame
960 (kb
, call1 (intern ("make-initial-minibuffer-frame"), display
));
964 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
967 fset_minibuffer_window (f
, mini_window
);
968 store_frame_param (f
, Qminibuffer
, mini_window
);
970 /* Make the chosen minibuffer window display the proper minibuffer,
971 unless it is already showing a minibuffer. */
972 if (NILP (Fmemq (XWINDOW (mini_window
)->contents
, Vminibuffer_list
)))
973 /* Use set_window_buffer instead of Fset_window_buffer (see
974 discussion of bug#11984, bug#12025, bug#12026). */
975 set_window_buffer (mini_window
,
976 (NILP (Vminibuffer_list
)
978 : Fcar (Vminibuffer_list
)), 0, 0);
982 /* Make a frame containing only a minibuffer window. */
985 make_minibuffer_frame (void)
987 /* First make a frame containing just a root window, no minibuffer. */
989 register struct frame
*f
= make_frame (0);
990 register Lisp_Object mini_window
;
991 register Lisp_Object frame
;
993 XSETFRAME (frame
, f
);
998 f
->wants_modeline
= 0;
1000 /* Now label the root window as also being the minibuffer.
1001 Avoid infinite looping on the window chain by marking next pointer
1004 mini_window
= f
->root_window
;
1005 fset_minibuffer_window (f
, mini_window
);
1006 store_frame_param (f
, Qminibuffer
, Qonly
);
1007 XWINDOW (mini_window
)->mini
= 1;
1008 wset_next (XWINDOW (mini_window
), Qnil
);
1009 wset_prev (XWINDOW (mini_window
), Qnil
);
1010 wset_frame (XWINDOW (mini_window
), frame
);
1012 /* Put the proper buffer in that window. */
1014 /* Use set_window_buffer instead of Fset_window_buffer (see
1015 discussion of bug#11984, bug#12025, bug#12026). */
1016 set_window_buffer (mini_window
,
1017 (NILP (Vminibuffer_list
)
1018 ? get_minibuffer (0)
1019 : Fcar (Vminibuffer_list
)), 0, 0);
1022 #endif /* HAVE_WINDOW_SYSTEM */
1024 /* Construct a frame that refers to a terminal. */
1026 static printmax_t tty_frame_count
;
1029 make_initial_frame (void)
1032 struct terminal
*terminal
;
1035 eassert (initial_kboard
);
1037 /* The first call must initialize Vframe_list. */
1038 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
1041 terminal
= init_initial_terminal ();
1044 XSETFRAME (frame
, f
);
1046 Vframe_list
= Fcons (frame
, Vframe_list
);
1048 tty_frame_count
= 1;
1049 fset_name (f
, build_pure_c_string ("F1"));
1051 SET_FRAME_VISIBLE (f
, 1);
1053 f
->output_method
= terminal
->type
;
1054 f
->terminal
= terminal
;
1055 f
->terminal
->reference_count
++;
1056 f
->output_data
.nothing
= 0;
1058 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
1059 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
1061 #ifdef HAVE_WINDOW_SYSTEM
1062 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
1063 f
->horizontal_scroll_bars
= false;
1066 /* The default value of menu-bar-mode is t. */
1067 set_menu_bar_lines (f
, make_number (1), Qnil
);
1069 /* Allocate glyph matrices. */
1070 adjust_frame_glyphs (f
);
1072 if (!noninteractive
)
1073 init_frame_faces (f
);
1075 last_nonminibuf_frame
= f
;
1077 f
->can_x_set_window_size
= true;
1078 f
->after_make_frame
= true;
1084 static struct frame
*
1085 make_terminal_frame (struct terminal
*terminal
)
1087 register struct frame
*f
;
1089 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
1091 if (!terminal
->name
)
1092 error ("Terminal is not live, can't create new frames on it");
1096 XSETFRAME (frame
, f
);
1097 Vframe_list
= Fcons (frame
, Vframe_list
);
1099 fset_name (f
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
1101 SET_FRAME_VISIBLE (f
, 1);
1103 f
->terminal
= terminal
;
1104 f
->terminal
->reference_count
++;
1106 f
->output_data
.tty
->display_info
= &the_only_display_info
;
1107 if (!inhibit_window_system
1108 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
1109 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
1110 f
->output_method
= output_msdos_raw
;
1112 f
->output_method
= output_termcap
;
1113 #else /* not MSDOS */
1114 f
->output_method
= output_termcap
;
1115 create_tty_output (f
);
1116 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
1117 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
1118 #endif /* not MSDOS */
1120 #ifdef HAVE_WINDOW_SYSTEM
1121 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
1122 f
->horizontal_scroll_bars
= false;
1125 FRAME_MENU_BAR_LINES (f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
1126 FRAME_LINES (f
) = FRAME_LINES (f
) - FRAME_MENU_BAR_LINES (f
);
1127 FRAME_MENU_BAR_HEIGHT (f
) = FRAME_MENU_BAR_LINES (f
) * FRAME_LINE_HEIGHT (f
);
1128 FRAME_TEXT_HEIGHT (f
) = FRAME_TEXT_HEIGHT (f
) - FRAME_MENU_BAR_HEIGHT (f
);
1130 /* Set the top frame to the newly created frame. */
1131 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
1132 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
1133 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f
)->top_frame
), 2); /* obscured */
1135 FRAME_TTY (f
)->top_frame
= frame
;
1137 if (!noninteractive
)
1138 init_frame_faces (f
);
1143 /* Get a suitable value for frame parameter PARAMETER for a newly
1144 created frame, based on (1) the user-supplied frame parameter
1145 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
1148 get_future_frame_param (Lisp_Object parameter
,
1149 Lisp_Object supplied_parms
,
1150 char *current_value
)
1154 result
= Fassq (parameter
, supplied_parms
);
1156 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
1157 if (NILP (result
) && current_value
!= NULL
)
1158 result
= build_string (current_value
);
1159 if (!NILP (result
) && !STRINGP (result
))
1160 result
= XCDR (result
);
1161 if (NILP (result
) || !STRINGP (result
))
1167 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
1169 doc
: /* Create an additional terminal frame, possibly on another terminal.
1170 This function takes one argument, an alist specifying frame parameters.
1172 You can create multiple frames on a single text terminal, but only one
1173 of them (the selected terminal frame) is actually displayed.
1175 In practice, generally you don't need to specify any parameters,
1176 except when you want to create a new frame on another terminal.
1177 In that case, the `tty' parameter specifies the device file to open,
1178 and the `tty-type' parameter specifies the terminal type. Example:
1180 (make-terminal-frame \\='((tty . "/dev/pts/5") (tty-type . "xterm")))
1182 Note that changing the size of one terminal frame automatically
1183 affects all frames on the same terminal device. */)
1187 struct terminal
*t
= NULL
;
1188 Lisp_Object frame
, tem
;
1189 struct frame
*sf
= SELECTED_FRAME ();
1192 if (sf
->output_method
!= output_msdos_raw
1193 && sf
->output_method
!= output_termcap
)
1195 #else /* not MSDOS */
1197 #ifdef WINDOWSNT /* This should work now! */
1198 if (sf
->output_method
!= output_termcap
)
1199 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
1201 #endif /* not MSDOS */
1204 Lisp_Object terminal
;
1206 terminal
= Fassq (Qterminal
, parms
);
1207 if (CONSP (terminal
))
1209 terminal
= XCDR (terminal
);
1210 t
= decode_live_terminal (terminal
);
1213 if (t
&& t
!= the_only_display_info
.terminal
)
1214 /* msdos.c assumes a single tty_display_info object. */
1215 error ("Multiple terminals are not supported on this platform");
1217 t
= the_only_display_info
.terminal
;
1223 char *name
= 0, *type
= 0;
1224 Lisp_Object tty
, tty_type
;
1227 tty
= get_future_frame_param
1228 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1229 ? FRAME_TTY (XFRAME (selected_frame
))->name
1232 SAFE_ALLOCA_STRING (name
, tty
);
1234 tty_type
= get_future_frame_param
1235 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1236 ? FRAME_TTY (XFRAME (selected_frame
))->type
1238 if (!NILP (tty_type
))
1239 SAFE_ALLOCA_STRING (type
, tty_type
);
1241 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
1245 f
= make_terminal_frame (t
);
1249 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
1250 adjust_frame_size (f
, width
, height
- FRAME_MENU_BAR_LINES (f
),
1251 5, 0, Qterminal_frame
);
1254 adjust_frame_glyphs (f
);
1255 calculate_costs (f
);
1256 XSETFRAME (frame
, f
);
1258 store_in_alist (&parms
, Qtty_type
, build_string (t
->display_info
.tty
->type
));
1259 store_in_alist (&parms
, Qtty
,
1260 (t
->display_info
.tty
->name
1261 ? build_string (t
->display_info
.tty
->name
)
1263 /* On terminal frames the `minibuffer' frame parameter is always
1264 virtually t. Avoid that a different value in parms causes
1265 complaints, see Bug#24758. */
1266 store_in_alist (&parms
, Qminibuffer
, Qt
);
1267 Fmodify_frame_parameters (frame
, parms
);
1269 /* Make the frame face alist be frame-specific, so that each
1270 frame could change its face definitions independently. */
1271 fset_face_alist (f
, Fcopy_alist (sf
->face_alist
));
1272 /* Simple Fcopy_alist isn't enough, because we need the contents of
1273 the vectors which are the CDRs of associations in face_alist to
1274 be copied as well. */
1275 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
1276 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
1278 f
->can_x_set_window_size
= true;
1279 f
->after_make_frame
= true;
1285 /* Perform the switch to frame FRAME.
1287 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
1290 If TRACK is non-zero and the frame that currently has the focus
1291 redirects its focus to the selected frame, redirect that focused
1292 frame's focus to FRAME instead.
1294 FOR_DELETION non-zero means that the selected frame is being
1295 deleted, which includes the possibility that the frame's terminal
1298 The value of NORECORD is passed as argument to Fselect_window. */
1301 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
1303 struct frame
*sf
= SELECTED_FRAME (), *f
;
1305 /* If FRAME is a switch-frame event, extract the frame we should
1308 && EQ (XCAR (frame
), Qswitch_frame
)
1309 && CONSP (XCDR (frame
)))
1310 frame
= XCAR (XCDR (frame
));
1312 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
1313 a switch-frame event to arrive after a frame is no longer live,
1314 especially when deleting the initial frame during startup. */
1315 CHECK_FRAME (frame
);
1317 if (!FRAME_LIVE_P (f
))
1322 /* If a frame's focus has been redirected toward the currently
1323 selected frame, we should change the redirection to point to the
1324 newly selected frame. This means that if the focus is redirected
1325 from a minibufferless frame to a surrogate minibuffer frame, we
1326 can use `other-window' to switch between all the frames using
1327 that minibuffer frame, and the focus redirection will follow us
1330 /* This is too greedy; it causes inappropriate focus redirection
1331 that's hard to get rid of. */
1336 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1340 if (!FRAMEP (XCAR (tail
)))
1343 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
1345 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1346 Fredirect_frame_focus (XCAR (tail
), frame
);
1350 /* Instead, apply it only to the frame we're pointing to. */
1351 #ifdef HAVE_WINDOW_SYSTEM
1352 if (track
&& FRAME_WINDOW_P (f
))
1354 Lisp_Object focus
, xfocus
;
1356 xfocus
= x_get_focus_frame (f
);
1357 if (FRAMEP (xfocus
))
1359 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
1360 if ((FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1361 /* Redirect frame focus also when FRAME has its minibuffer
1362 window on the selected frame (see Bug#24500). */
1364 && EQ (FRAME_MINIBUF_WINDOW (f
), sf
->selected_window
)))
1365 Fredirect_frame_focus (xfocus
, frame
);
1368 #endif /* HAVE_X_WINDOWS */
1371 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
1372 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
1374 if (FRAME_TERMCAP_P (f
) || FRAME_MSDOS_P (f
))
1376 struct tty_display_info
*tty
= FRAME_TTY (f
);
1377 Lisp_Object top_frame
= tty
->top_frame
;
1379 /* Don't mark the frame garbaged and/or obscured if we are
1380 switching to the frame that is already the top frame of that
1382 if (!EQ (frame
, top_frame
))
1384 if (FRAMEP (top_frame
))
1385 /* Mark previously displayed frame as now obscured. */
1386 SET_FRAME_VISIBLE (XFRAME (top_frame
), 2);
1387 SET_FRAME_VISIBLE (f
, 1);
1388 /* If the new TTY frame changed dimensions, we need to
1389 resync term.c's idea of the frame size with the new
1391 if (FRAME_COLS (f
) != FrameCols (tty
))
1392 FrameCols (tty
) = FRAME_COLS (f
);
1393 if (FRAME_TOTAL_LINES (f
) != FrameRows (tty
))
1394 FrameRows (tty
) = FRAME_TOTAL_LINES (f
);
1396 tty
->top_frame
= frame
;
1399 selected_frame
= frame
;
1400 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
1401 last_nonminibuf_frame
= XFRAME (selected_frame
);
1403 Fselect_window (f
->selected_window
, norecord
);
1405 /* We want to make sure that the next event generates a frame-switch
1406 event to the appropriate frame. This seems kludgy to me, but
1407 before you take it out, make sure that evaluating something like
1408 (select-window (frame-root-window (new-frame))) doesn't end up
1409 with your typing being interpreted in the new frame instead of
1410 the one you're actually typing in. */
1411 #ifdef HAVE_WINDOW_SYSTEM
1412 if (!frame_ancestor_p (f
, sf
))
1414 internal_last_event_frame
= Qnil
;
1419 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
1420 doc
: /* Select FRAME.
1421 Subsequent editing commands apply to its selected window.
1422 Optional argument NORECORD means to neither change the order of
1423 recently selected windows nor the buffer list.
1425 The selection of FRAME lasts until the next time the user does
1426 something to select a different frame, or until the next time
1427 this function is called. If you are using a window system, the
1428 previously selected frame may be restored as the selected frame
1429 when returning to the command loop, because it still may have
1430 the window system's input focus. On a text terminal, the next
1431 redisplay will display FRAME.
1433 This function returns FRAME, or nil if FRAME has been deleted. */)
1434 (Lisp_Object frame
, Lisp_Object norecord
)
1436 return do_switch_frame (frame
, 1, 0, norecord
);
1439 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "^e",
1440 doc
: /* Handle a switch-frame event EVENT.
1441 Switch-frame events are usually bound to this function.
1442 A switch-frame event tells Emacs that the window manager has requested
1443 that the user's events be directed to the frame mentioned in the event.
1444 This function selects the selected window of the frame of EVENT.
1446 If EVENT is frame object, handle it as if it were a switch-frame event
1452 /* Preserve prefix arg that the command loop just cleared. */
1453 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
1454 run_hook (Qmouse_leave_buffer_hook
);
1455 /* `switch-frame' implies a focus in. */
1456 value
= do_switch_frame (event
, 0, 0, Qnil
);
1457 call1 (intern ("handle-focus-in"), event
);
1461 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1462 doc
: /* Return the frame that is now selected. */)
1465 return selected_frame
;
1468 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1470 doc
: /* Return a list of all live frames. */)
1474 frames
= Fcopy_sequence (Vframe_list
);
1475 #ifdef HAVE_WINDOW_SYSTEM
1476 if (FRAMEP (tip_frame
)
1478 && !NILP (Fframe_parameter (tip_frame
, Qtooltip
))
1481 frames
= Fdelq (tip_frame
, frames
);
1486 DEFUN ("frame-parent", Fframe_parent
, Sframe_parent
,
1488 doc
: /* Return the parent frame of FRAME.
1489 The parent frame of FRAME is the Emacs frame whose window-system window
1490 is the parent window of FRAME's window-system window. When such a frame
1491 exists, FRAME is considered a child frame of that frame.
1493 Return nil if FRAME has no parent frame. This means that FRAME's
1494 window-system window is either a "top-level" window (a window whose
1495 parent window is the window-system's root window) or an embedded window
1496 \(a window whose parent window is owned by some other application). */)
1499 struct frame
*f
= decode_live_frame (frame
);
1500 struct frame
*p
= FRAME_PARENT_FRAME (f
);
1503 /* Can't return f->parent_frame directly since it might not be defined
1504 for this platform. */
1507 XSETFRAME (parent
, p
);
1515 #ifdef HAVE_WINDOW_SYSTEM
1517 frame_ancestor_p (struct frame
*af
, struct frame
*df
)
1519 struct frame
*pf
= FRAME_PARENT_FRAME (df
);
1526 pf
= FRAME_PARENT_FRAME (pf
);
1533 DEFUN ("frame-ancestor-p", Fframe_ancestor_p
, Sframe_ancestor_p
,
1535 doc
: /* Return non-nil if ANCESTOR is an ancestor of DESCENDANT.
1536 ANCESTOR is an ancestor of DESCENDANT when it is either DESCENDANT's
1537 parent frame or it is an ancestor of DESCENDANT's parent frame. Both,
1538 ANCESTOR and DESCENDANT must be live frames and default to the selected
1540 (Lisp_Object ancestor
, Lisp_Object descendant
)
1542 #ifdef HAVE_WINDOW_SYSTEM
1543 struct frame
*af
= decode_live_frame (ancestor
);
1544 struct frame
*df
= decode_live_frame (descendant
);
1546 return frame_ancestor_p (af
, df
) ? Qt
: Qnil
;
1552 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
1553 same tty (for tty frames) or among frames which uses FRAME's keyboard.
1554 If MINIBUF is nil, do not consider minibuffer-only candidate.
1555 If MINIBUF is `visible', do not consider an invisible candidate.
1556 If MINIBUF is a window, consider only its own frame and candidate now
1557 using that window as the minibuffer.
1558 If MINIBUF is 0, consider candidate if it is visible or iconified.
1559 Otherwise consider any candidate and return nil if CANDIDATE is not
1563 candidate_frame (Lisp_Object candidate
, Lisp_Object frame
, Lisp_Object minibuf
)
1565 struct frame
*c
= XFRAME (candidate
), *f
= XFRAME (frame
);
1567 if ((!FRAME_TERMCAP_P (c
) && !FRAME_TERMCAP_P (f
)
1568 && FRAME_KBOARD (c
) == FRAME_KBOARD (f
))
1569 || (FRAME_TERMCAP_P (c
) && FRAME_TERMCAP_P (f
)
1570 && FRAME_TTY (c
) == FRAME_TTY (f
)))
1572 if (!NILP (get_frame_param (c
, Qno_other_frame
)))
1574 else if (NILP (minibuf
))
1576 if (!FRAME_MINIBUF_ONLY_P (c
))
1579 else if (EQ (minibuf
, Qvisible
))
1581 if (FRAME_VISIBLE_P (c
))
1584 else if (WINDOWP (minibuf
))
1586 if (EQ (FRAME_MINIBUF_WINDOW (c
), minibuf
)
1587 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), candidate
)
1588 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1589 FRAME_FOCUS_FRAME (c
)))
1592 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
1594 if (FRAME_VISIBLE_P (c
) || FRAME_ICONIFIED_P (c
))
1603 /* Return the next frame in the frame list after FRAME. */
1606 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1608 Lisp_Object f
, tail
;
1611 eassume (CONSP (Vframe_list
));
1614 FOR_EACH_FRAME (tail
, f
)
1618 f
= candidate_frame (f
, frame
, minibuf
);
1628 /* Return the previous frame in the frame list before FRAME. */
1631 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1633 Lisp_Object f
, tail
, prev
= Qnil
;
1635 eassume (CONSP (Vframe_list
));
1637 FOR_EACH_FRAME (tail
, f
)
1639 if (EQ (frame
, f
) && !NILP (prev
))
1641 f
= candidate_frame (f
, frame
, minibuf
);
1646 /* We've scanned the entire list. */
1648 /* We went through the whole frame list without finding a single
1649 acceptable frame. Return the original frame. */
1652 /* There were no acceptable frames in the list before FRAME; otherwise,
1653 we would have returned directly from the loop. Since PREV is the last
1654 acceptable frame in the list, return it. */
1659 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1660 doc
: /* Return the next frame in the frame list after FRAME.
1661 It considers only frames on the same terminal as FRAME.
1662 By default, skip minibuffer-only frames.
1663 If omitted, FRAME defaults to the selected frame.
1664 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1665 If MINIFRAME is a window, include only its own frame
1666 and any frame now using that window as the minibuffer.
1667 If MINIFRAME is `visible', include all visible frames.
1668 If MINIFRAME is 0, include all visible and iconified frames.
1669 Otherwise, include all frames. */)
1670 (Lisp_Object frame
, Lisp_Object miniframe
)
1673 frame
= selected_frame
;
1674 CHECK_LIVE_FRAME (frame
);
1675 return next_frame (frame
, miniframe
);
1678 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1679 doc
: /* Return the previous frame in the frame list before FRAME.
1680 It considers only frames on the same terminal as FRAME.
1681 By default, skip minibuffer-only frames.
1682 If omitted, FRAME defaults to the selected frame.
1683 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1684 If MINIFRAME is a window, include only its own frame
1685 and any frame now using that window as the minibuffer.
1686 If MINIFRAME is `visible', include all visible frames.
1687 If MINIFRAME is 0, include all visible and iconified frames.
1688 Otherwise, include all frames. */)
1689 (Lisp_Object frame
, Lisp_Object miniframe
)
1692 frame
= selected_frame
;
1693 CHECK_LIVE_FRAME (frame
);
1694 return prev_frame (frame
, miniframe
);
1697 DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame
,
1698 Slast_nonminibuf_frame
, 0, 0, 0,
1699 doc
: /* Return last non-minibuffer frame selected. */)
1702 Lisp_Object frame
= Qnil
;
1704 if (last_nonminibuf_frame
)
1705 XSETFRAME (frame
, last_nonminibuf_frame
);
1713 * Return true if there exists at least one visible or iconified frame
1714 * but F. Return false otherwise.
1716 * INVISIBLE true means we are called from make_frame_invisible where
1717 * such a frame must be visible or iconified. INVISIBLE nil means we
1718 * are called from delete_frame. In that case FORCE true means that the
1719 * visibility status of such a frame can be ignored.
1721 * If F is the terminal frame and we are using X, return true if at
1722 * least one X frame exists.
1725 other_frames (struct frame
*f
, bool invisible
, bool force
)
1727 Lisp_Object frames
, frame
, frame1
;
1729 Lisp_Object minibuffer_window
= FRAME_MINIBUF_WINDOW (f
);
1731 XSETFRAME (frame
, f
);
1732 if (WINDOWP (minibuffer_window
)
1733 && !EQ (frame
, WINDOW_FRAME (XWINDOW (minibuffer_window
))))
1734 minibuffer_window
= Qnil
;
1736 FOR_EACH_FRAME (frames
, frame1
)
1738 f1
= XFRAME (frame1
);
1741 /* Verify that we can still talk to the frame's X window, and
1742 note any recent change in visibility. */
1743 #ifdef HAVE_X_WINDOWS
1744 if (FRAME_WINDOW_P (f1
))
1747 if (NILP (Fframe_parameter (frame1
, Qtooltip
))
1748 /* Tooltips and child frames count neither for
1749 invisibility nor for deletions. */
1750 && !FRAME_PARENT_FRAME (f1
)
1751 /* Frames with a non-nil `delete-before' parameter don't
1752 count for deletions. */
1753 && (invisible
|| NILP (get_frame_param (f1
, Qdelete_before
)))
1754 /* For invisibility and normal deletions, at least one
1755 visible or iconified frame must remain (Bug#26682). */
1756 && (FRAME_VISIBLE_P (f1
) || FRAME_ICONIFIED_P (f1
)
1759 /* Allow deleting the terminal frame when at
1760 least one X frame exists. */
1761 || (FRAME_WINDOW_P (f1
) && !FRAME_WINDOW_P (f
))))))
1769 /* Make sure that minibuf_window doesn't refer to FRAME's minibuffer
1770 window. Preferably use the selected frame's minibuffer window
1771 instead. If the selected frame doesn't have one, get some other
1772 frame's minibuffer window. SELECT non-zero means select the new
1773 minibuffer window. */
1775 check_minibuf_window (Lisp_Object frame
, int select
)
1777 struct frame
*f
= decode_live_frame (frame
);
1779 XSETFRAME (frame
, f
);
1781 if (WINDOWP (minibuf_window
) && EQ (f
->minibuffer_window
, minibuf_window
))
1783 Lisp_Object frames
, this, window
= make_number (0);
1785 if (!EQ (frame
, selected_frame
)
1786 && FRAME_HAS_MINIBUF_P (XFRAME (selected_frame
)))
1787 window
= FRAME_MINIBUF_WINDOW (XFRAME (selected_frame
));
1789 FOR_EACH_FRAME (frames
, this)
1791 if (!EQ (this, frame
) && FRAME_HAS_MINIBUF_P (XFRAME (this)))
1793 window
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1798 /* Don't abort if no window was found (Bug#15247). */
1799 if (WINDOWP (window
))
1801 /* Use set_window_buffer instead of Fset_window_buffer (see
1802 discussion of bug#11984, bug#12025, bug#12026). */
1803 set_window_buffer (window
, XWINDOW (minibuf_window
)->contents
, 0, 0);
1804 minibuf_window
= window
;
1806 /* SELECT non-zero usually means that FRAME's minibuffer
1807 window was selected; select the new one. */
1809 Fselect_window (minibuf_window
, Qnil
);
1818 * Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1819 * unconditionally. x_connection_closed and delete_terminal use this.
1820 * Any other value of FORCE implements the semantics described for
1823 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1825 struct frame
*f
= decode_any_frame (frame
);
1828 Lisp_Object frames
, frame1
;
1829 int minibuffer_selected
, is_tooltip_frame
;
1830 bool nochild
= !FRAME_PARENT_FRAME (f
);
1832 if (!FRAME_LIVE_P (f
))
1834 else if (!EQ (force
, Qnoelisp
) && !other_frames (f
, false, !NILP (force
)))
1837 error ("Attempt to delete the sole visible or iconified frame");
1839 error ("Attempt to delete the only frame");
1842 XSETFRAME (frame
, f
);
1844 /* Softly delete all frames with this frame as their parent frame or
1845 as their `delete-before' frame parameter value. */
1846 FOR_EACH_FRAME (frames
, frame1
)
1847 if (FRAME_PARENT_FRAME (XFRAME (frame1
)) == f
1848 /* Process `delete-before' parameter iff FRAME is not a child
1849 frame. This avoids that we enter an infinite chain of mixed
1852 && EQ (get_frame_param (XFRAME (frame1
), Qdelete_before
), frame
)))
1853 delete_frame (frame1
, Qnil
);
1855 /* Does this frame have a minibuffer, and is it the surrogate
1856 minibuffer for any other frame? */
1857 if (FRAME_HAS_MINIBUF_P (f
))
1859 FOR_EACH_FRAME (frames
, frame1
)
1863 if (EQ (frame1
, frame
))
1866 fminiw
= FRAME_MINIBUF_WINDOW (XFRAME (frame1
));
1868 if (WINDOWP (fminiw
) && EQ (frame
, WINDOW_FRAME (XWINDOW (fminiw
))))
1870 /* If we MUST delete this frame, delete the other first.
1871 But do this only if FORCE equals `noelisp'. */
1872 if (EQ (force
, Qnoelisp
))
1873 delete_frame (frame1
, Qnoelisp
);
1875 error ("Attempt to delete a surrogate minibuffer frame");
1880 is_tooltip_frame
= !NILP (Fframe_parameter (frame
, Qtooltip
));
1882 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1883 frame is a tooltip. FORCE is set to `noelisp' when handling
1884 a disconnect from the terminal, so we don't dare call Lisp
1886 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1888 else if (EQ (force
, Qnoelisp
))
1890 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1894 #ifdef HAVE_X_WINDOWS
1895 /* Also, save clipboard to the clipboard manager. */
1896 x_clipboard_manager_save_frame (frame
);
1899 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1902 /* delete_frame_functions may have deleted any frame, including this
1904 if (!FRAME_LIVE_P (f
))
1906 else if (!EQ (force
, Qnoelisp
) && !other_frames (f
, false, !NILP (force
)))
1909 error ("Attempt to delete the sole visible or iconified frame");
1911 error ("Attempt to delete the only frame");
1914 /* At this point, we are committed to deleting the frame.
1915 There is no more chance for errors to prevent it. */
1916 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1917 sf
= SELECTED_FRAME ();
1918 /* Don't let the frame remain selected. */
1922 eassume (CONSP (Vframe_list
));
1924 /* Look for another visible frame on the same terminal.
1925 Do not call next_frame here because it may loop forever.
1926 See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=15025. */
1927 FOR_EACH_FRAME (tail
, frame1
)
1928 if (!EQ (frame
, frame1
)
1929 && NILP (Fframe_parameter (frame1
, Qtooltip
))
1930 && (FRAME_TERMINAL (XFRAME (frame
))
1931 == FRAME_TERMINAL (XFRAME (frame1
)))
1932 && FRAME_VISIBLE_P (XFRAME (frame1
)))
1935 /* If there is none, find *some* other frame. */
1936 if (NILP (frame1
) || EQ (frame1
, frame
))
1938 FOR_EACH_FRAME (tail
, frame1
)
1940 if (!EQ (frame
, frame1
)
1941 && FRAME_LIVE_P (XFRAME (frame1
))
1942 && NILP (Fframe_parameter (frame1
, Qtooltip
)))
1944 /* Do not change a text terminal's top-frame. */
1945 struct frame
*f1
= XFRAME (frame1
);
1946 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1948 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1949 if (!EQ (top_frame
, frame
))
1956 #ifdef NS_IMPL_COCOA
1958 /* Under NS, there is no system mechanism for choosing a new
1959 window to get focus -- it is left to application code.
1960 So the portion of THIS application interfacing with NS
1961 needs to know about it. We call Fraise_frame, but the
1962 purpose is really to transfer focus. */
1963 Fraise_frame (frame1
);
1966 do_switch_frame (frame1
, 0, 1, Qnil
);
1967 sf
= SELECTED_FRAME ();
1970 /* Don't allow minibuf_window to remain on a deleted frame. */
1971 check_minibuf_window (frame
, minibuffer_selected
);
1973 /* Don't let echo_area_window to remain on a deleted frame. */
1974 if (EQ (f
->minibuffer_window
, echo_area_window
))
1975 echo_area_window
= sf
->minibuffer_window
;
1977 /* Clear any X selections for this frame. */
1978 #ifdef HAVE_X_WINDOWS
1980 x_clear_frame_selections (f
);
1984 This function must be called before the window tree of the
1985 frame is deleted because windows contain dynamically allocated
1989 #ifdef HAVE_WINDOW_SYSTEM
1990 /* Give chance to each font driver to free a frame specific data. */
1991 font_update_drivers (f
, Qnil
);
1994 /* Mark all the windows that used to be on FRAME as deleted, and then
1995 remove the reference to them. */
1996 delete_all_child_windows (f
->root_window
);
1997 fset_root_window (f
, Qnil
);
1999 Vframe_list
= Fdelq (frame
, Vframe_list
);
2000 SET_FRAME_VISIBLE (f
, 0);
2002 /* Allow the vector of menu bar contents to be freed in the next
2003 garbage collection. The frame object itself may not be garbage
2004 collected until much later, because recent_keys and other data
2005 structures can still refer to it. */
2006 fset_menu_bar_vector (f
, Qnil
);
2008 /* If FRAME's buffer lists contains killed
2009 buffers, this helps GC to reclaim them. */
2010 fset_buffer_list (f
, Qnil
);
2011 fset_buried_buffer_list (f
, Qnil
);
2013 free_font_driver_list (f
);
2014 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
2017 xfree (f
->decode_mode_spec_buffer
);
2018 xfree (FRAME_INSERT_COST (f
));
2019 xfree (FRAME_DELETEN_COST (f
));
2020 xfree (FRAME_INSERTN_COST (f
));
2021 xfree (FRAME_DELETE_COST (f
));
2023 /* Since some events are handled at the interrupt level, we may get
2024 an event for f at any time; if we zero out the frame's terminal
2025 now, then we may trip up the event-handling code. Instead, we'll
2026 promise that the terminal of the frame must be valid until we
2027 have called the window-system-dependent frame destruction
2030 struct terminal
*terminal
;
2032 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
2033 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
2034 terminal
= FRAME_TERMINAL (f
);
2035 f
->output_data
.nothing
= 0;
2036 f
->terminal
= 0; /* Now the frame is dead. */
2039 /* If needed, delete the terminal that this frame was on.
2040 (This must be done after the frame is killed.) */
2041 terminal
->reference_count
--;
2042 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
2043 /* FIXME: Deleting the terminal crashes emacs because of a GTK
2045 https://lists.gnu.org/r/emacs-devel/2011-10/msg00363.html */
2047 /* Since a similar behavior was observed on the Lucid and Motif
2048 builds (see Bug#5802, Bug#21509, Bug#23499, Bug#27816), we now
2049 don't delete the terminal for these builds either. */
2050 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
2051 terminal
->reference_count
= 1;
2052 #endif /* USE_X_TOOLKIT || USE_GTK */
2053 if (terminal
->reference_count
== 0)
2056 XSETTERMINAL (tmp
, terminal
);
2059 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
2062 kb
= terminal
->kboard
;
2065 /* If we've deleted the last_nonminibuf_frame, then try to find
2067 if (f
== last_nonminibuf_frame
)
2069 last_nonminibuf_frame
= 0;
2071 FOR_EACH_FRAME (frames
, frame1
)
2073 struct frame
*f1
= XFRAME (frame1
);
2075 if (!FRAME_MINIBUF_ONLY_P (f1
))
2077 last_nonminibuf_frame
= f1
;
2083 /* If there's no other frame on the same kboard, get out of
2084 single-kboard state if we're in it for this kboard. */
2087 /* Some frame we found on the same kboard, or nil if there are none. */
2088 Lisp_Object frame_on_same_kboard
= Qnil
;
2090 FOR_EACH_FRAME (frames
, frame1
)
2091 if (kb
== FRAME_KBOARD (XFRAME (frame1
)))
2092 frame_on_same_kboard
= frame1
;
2094 if (NILP (frame_on_same_kboard
))
2095 not_single_kboard_state (kb
);
2099 /* If we've deleted this keyboard's default_minibuffer_frame, try to
2100 find another one. Prefer minibuffer-only frames, but also notice
2101 frames with other windows. */
2102 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
2104 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
2105 Lisp_Object frame_with_minibuf
= Qnil
;
2106 /* Some frame we found on the same kboard, or nil if there are none. */
2107 Lisp_Object frame_on_same_kboard
= Qnil
;
2109 FOR_EACH_FRAME (frames
, frame1
)
2111 struct frame
*f1
= XFRAME (frame1
);
2113 /* Consider only frames on the same kboard
2114 and only those with minibuffers. */
2115 if (kb
== FRAME_KBOARD (f1
)
2116 && FRAME_HAS_MINIBUF_P (f1
))
2118 frame_with_minibuf
= frame1
;
2119 if (FRAME_MINIBUF_ONLY_P (f1
))
2123 if (kb
== FRAME_KBOARD (f1
))
2124 frame_on_same_kboard
= frame1
;
2127 if (!NILP (frame_on_same_kboard
))
2129 /* We know that there must be some frame with a minibuffer out
2130 there. If this were not true, all of the frames present
2131 would have to be minibufferless, which implies that at some
2132 point their minibuffer frames must have been deleted, but
2133 that is prohibited at the top; you can't delete surrogate
2134 minibuffer frames. */
2135 if (NILP (frame_with_minibuf
))
2138 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
2141 /* No frames left on this kboard--say no minibuffer either. */
2142 kset_default_minibuffer_frame (kb
, Qnil
);
2145 /* Cause frame titles to update--necessary if we now have just one frame. */
2146 if (!is_tooltip_frame
)
2147 update_mode_lines
= 15;
2152 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
2153 doc
: /* Delete FRAME, permanently eliminating it from use.
2154 FRAME must be a live frame and defaults to the selected one.
2156 A frame may not be deleted if its minibuffer serves as surrogate
2157 minibuffer for another frame. Normally, you may not delete a frame if
2158 all other frames are invisible, but if the second optional argument
2159 FORCE is non-nil, you may do so.
2161 This function runs `delete-frame-functions' before actually
2162 deleting the frame, unless the frame is a tooltip.
2163 The functions are run with one argument, the frame to be deleted. */)
2164 (Lisp_Object frame
, Lisp_Object force
)
2166 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
2169 #ifdef HAVE_WINDOW_SYSTEM
2171 * frame_internal_border_part:
2173 * Return part of internal border the coordinates X and Y relative to
2174 * frame F are on. Return nil if the coordinates are not on the
2175 * internal border of F.
2177 * Return one of INTERNAL_BORDER_LEFT_EDGE, INTERNAL_BORDER_TOP_EDGE,
2178 * INTERNAL_BORDER_RIGHT_EDGE or INTERNAL_BORDER_BOTTOM_EDGE when the
2179 * mouse cursor is on the corresponding border with an offset of at
2180 * least one canonical character height from that border's edges.
2182 * If no border part could be found this way, return one of
2183 * INTERNAL_BORDER_TOP_LEFT_CORNER, INTERNAL_BORDER_TOP_RIGHT_CORNER,
2184 * INTERNAL_BORDER_BOTTOM_LEFT_CORNER or
2185 * INTERNAL_BORDER_BOTTOM_RIGHT_CORNER to indicate that the mouse is in
2186 * one of the corresponding corners. This means that for very small
2187 * frames an `edge' return value is preferred.
2189 enum internal_border_part
2190 frame_internal_border_part (struct frame
*f
, int x
, int y
)
2192 int border
= FRAME_INTERNAL_BORDER_WIDTH (f
);
2193 int offset
= FRAME_LINE_HEIGHT (f
);
2194 int width
= FRAME_PIXEL_WIDTH (f
);
2195 int height
= FRAME_PIXEL_HEIGHT (f
);
2196 enum internal_border_part part
= INTERNAL_BORDER_NONE
;
2198 if (offset
< border
)
2199 /* For very wide borders make offset at least as large as
2203 if (offset
< x
&& x
< width
- offset
)
2204 /* Top or bottom border. */
2206 if (0 <= y
&& y
<= border
)
2207 part
= INTERNAL_BORDER_TOP_EDGE
;
2208 else if (height
- border
<= y
&& y
<= height
)
2209 part
= INTERNAL_BORDER_BOTTOM_EDGE
;
2211 else if (offset
< y
&& y
< height
- offset
)
2212 /* Left or right border. */
2214 if (0 <= x
&& x
<= border
)
2215 part
= INTERNAL_BORDER_LEFT_EDGE
;
2216 else if (width
- border
<= x
&& x
<= width
)
2217 part
= INTERNAL_BORDER_RIGHT_EDGE
;
2222 int half_width
= width
/ 2;
2223 int half_height
= height
/ 2;
2225 if (0 <= x
&& x
<= border
)
2228 if (0 <= y
&& y
<= half_height
)
2229 part
= INTERNAL_BORDER_TOP_LEFT_CORNER
;
2230 else if (half_height
< y
&& y
<= height
)
2231 part
= INTERNAL_BORDER_BOTTOM_LEFT_CORNER
;
2233 else if (width
- border
<= x
&& x
<= width
)
2236 if (0 <= y
&& y
<= half_height
)
2237 part
= INTERNAL_BORDER_TOP_RIGHT_CORNER
;
2238 else if (half_height
< y
&& y
<= height
)
2239 part
= INTERNAL_BORDER_BOTTOM_RIGHT_CORNER
;
2241 else if (0 <= y
&& y
<= border
)
2244 if (0 <= x
&& x
<= half_width
)
2245 part
= INTERNAL_BORDER_TOP_LEFT_CORNER
;
2246 else if (half_width
< x
&& x
<= width
)
2247 part
= INTERNAL_BORDER_TOP_RIGHT_CORNER
;
2249 else if (height
- border
<= y
&& y
<= height
)
2251 /* A bottom edge. */
2252 if (0 <= x
&& x
<= half_width
)
2253 part
= INTERNAL_BORDER_BOTTOM_LEFT_CORNER
;
2254 else if (half_width
< x
&& x
<= width
)
2255 part
= INTERNAL_BORDER_BOTTOM_RIGHT_CORNER
;
2263 /* Return mouse position in character cell units. */
2265 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
2266 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
2267 The position is given in canonical character cells, where (0, 0) is the
2268 upper-left corner of the frame, X is the horizontal offset, and Y is the
2269 vertical offset, measured in units of the frame's default character size.
2270 If Emacs is running on a mouseless terminal or hasn't been programmed
2271 to read the mouse position, it returns the selected frame for FRAME
2272 and nil for X and Y.
2273 If `mouse-position-function' is non-nil, `mouse-position' calls it,
2274 passing the normal return value to that function as an argument,
2275 and returns whatever that function returns. */)
2279 Lisp_Object lispy_dummy
;
2280 Lisp_Object x
, y
, retval
;
2282 f
= SELECTED_FRAME ();
2285 /* It's okay for the hook to refrain from storing anything. */
2286 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
2288 enum scroll_bar_part party_dummy
;
2290 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
2291 &lispy_dummy
, &party_dummy
,
2300 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
2304 XSETFRAME (lispy_dummy
, f
);
2305 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
2306 if (!NILP (Vmouse_position_function
))
2307 retval
= call1 (Vmouse_position_function
, retval
);
2311 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
2312 Smouse_pixel_position
, 0, 0, 0,
2313 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
2314 The position is given in pixel units, where (0, 0) is the
2315 upper-left corner of the frame, X is the horizontal offset, and Y is
2316 the vertical offset.
2317 If Emacs is running on a mouseless terminal or hasn't been programmed
2318 to read the mouse position, it returns the selected frame for FRAME
2319 and nil for X and Y. */)
2323 Lisp_Object lispy_dummy
;
2324 Lisp_Object x
, y
, retval
;
2326 f
= SELECTED_FRAME ();
2329 /* It's okay for the hook to refrain from storing anything. */
2330 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
2332 enum scroll_bar_part party_dummy
;
2334 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
2335 &lispy_dummy
, &party_dummy
,
2340 XSETFRAME (lispy_dummy
, f
);
2341 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
2342 if (!NILP (Vmouse_position_function
))
2343 retval
= call1 (Vmouse_position_function
, retval
);
2347 #ifdef HAVE_WINDOW_SYSTEM
2349 /* On frame F, convert character coordinates X and Y to pixel
2350 coordinates *PIX_X and *PIX_Y. */
2353 frame_char_to_pixel_position (struct frame
*f
, int x
, int y
,
2354 int *pix_x
, int *pix_y
)
2356 *pix_x
= FRAME_COL_TO_PIXEL_X (f
, x
) + FRAME_COLUMN_WIDTH (f
) / 2;
2357 *pix_y
= FRAME_LINE_TO_PIXEL_Y (f
, y
) + FRAME_LINE_HEIGHT (f
) / 2;
2361 if (*pix_x
> FRAME_PIXEL_WIDTH (f
))
2362 *pix_x
= FRAME_PIXEL_WIDTH (f
);
2366 if (*pix_y
> FRAME_PIXEL_HEIGHT (f
))
2367 *pix_y
= FRAME_PIXEL_HEIGHT (f
);
2370 /* On frame F, reposition mouse pointer to character coordinates X and Y. */
2373 frame_set_mouse_position (struct frame
*f
, int x
, int y
)
2377 frame_char_to_pixel_position (f
, x
, y
, &pix_x
, &pix_y
);
2378 frame_set_mouse_pixel_position (f
, pix_x
, pix_y
);
2381 #endif /* HAVE_WINDOW_SYSTEM */
2383 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
2384 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
2385 Coordinates are relative to the frame, not a window,
2386 so the coordinates of the top left character in the frame
2387 may be nonzero due to left-hand scroll bars or the menu bar.
2389 The position is given in canonical character cells, where (0, 0) is
2390 the upper-left corner of the frame, X is the horizontal offset, and
2391 Y is the vertical offset, measured in units of the frame's default
2394 This function is a no-op for an X frame that is not visible.
2395 If you have just created a frame, you must wait for it to become visible
2396 before calling this function on it, like this.
2397 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
2398 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
2400 CHECK_LIVE_FRAME (frame
);
2401 CHECK_TYPE_RANGED_INTEGER (int, x
);
2402 CHECK_TYPE_RANGED_INTEGER (int, y
);
2404 /* I think this should be done with a hook. */
2405 #ifdef HAVE_WINDOW_SYSTEM
2406 if (FRAME_WINDOW_P (XFRAME (frame
)))
2407 /* Warping the mouse will cause enternotify and focus events. */
2408 frame_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
2411 if (FRAME_MSDOS_P (XFRAME (frame
)))
2413 Fselect_frame (frame
, Qnil
);
2414 mouse_moveto (XINT (x
), XINT (y
));
2419 Fselect_frame (frame
, Qnil
);
2420 term_mouse_moveto (XINT (x
), XINT (y
));
2429 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
2430 Sset_mouse_pixel_position
, 3, 3, 0,
2431 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
2432 The position is given in pixels, where (0, 0) is the upper-left corner
2433 of the frame, X is the horizontal offset, and Y is the vertical offset.
2435 Note, this is a no-op for an X frame that is not visible.
2436 If you have just created a frame, you must wait for it to become visible
2437 before calling this function on it, like this.
2438 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
2439 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
2441 CHECK_LIVE_FRAME (frame
);
2442 CHECK_TYPE_RANGED_INTEGER (int, x
);
2443 CHECK_TYPE_RANGED_INTEGER (int, y
);
2445 /* I think this should be done with a hook. */
2446 #ifdef HAVE_WINDOW_SYSTEM
2447 if (FRAME_WINDOW_P (XFRAME (frame
)))
2448 /* Warping the mouse will cause enternotify and focus events. */
2449 frame_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
2452 if (FRAME_MSDOS_P (XFRAME (frame
)))
2454 Fselect_frame (frame
, Qnil
);
2455 mouse_moveto (XINT (x
), XINT (y
));
2460 Fselect_frame (frame
, Qnil
);
2461 term_mouse_moveto (XINT (x
), XINT (y
));
2470 static void make_frame_visible_1 (Lisp_Object
);
2472 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
2474 doc
: /* Make the frame FRAME visible (assuming it is an X window).
2475 If omitted, FRAME defaults to the currently selected frame. */)
2478 struct frame
*f
= decode_live_frame (frame
);
2480 /* I think this should be done with a hook. */
2481 #ifdef HAVE_WINDOW_SYSTEM
2482 if (FRAME_WINDOW_P (f
))
2483 x_make_frame_visible (f
);
2486 make_frame_visible_1 (f
->root_window
);
2488 /* Make menu bar update for the Buffers and Frames menus. */
2489 /* windows_or_buffers_changed = 15; FIXME: Why? */
2491 XSETFRAME (frame
, f
);
2495 /* Update the display_time slot of the buffers shown in WINDOW
2496 and all its descendants. */
2499 make_frame_visible_1 (Lisp_Object window
)
2503 for (; !NILP (window
); window
= w
->next
)
2505 w
= XWINDOW (window
);
2506 if (WINDOWP (w
->contents
))
2507 make_frame_visible_1 (w
->contents
);
2509 bset_display_time (XBUFFER (w
->contents
), Fcurrent_time ());
2513 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
2515 doc
: /* Make the frame FRAME invisible.
2516 If omitted, FRAME defaults to the currently selected frame.
2517 On graphical displays, invisible frames are not updated and are
2518 usually not displayed at all, even in a window system's \"taskbar\".
2520 Normally you may not make FRAME invisible if all other frames are invisible,
2521 but if the second optional argument FORCE is non-nil, you may do so.
2523 This function has no effect on text terminal frames. Such frames are
2524 always considered visible, whether or not they are currently being
2525 displayed in the terminal. */)
2526 (Lisp_Object frame
, Lisp_Object force
)
2528 struct frame
*f
= decode_live_frame (frame
);
2530 if (NILP (force
) && !other_frames (f
, true, false))
2531 error ("Attempt to make invisible the sole visible or iconified frame");
2533 /* Don't allow minibuf_window to remain on an invisible frame. */
2534 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2536 /* I think this should be done with a hook. */
2537 #ifdef HAVE_WINDOW_SYSTEM
2538 if (FRAME_WINDOW_P (f
))
2539 x_make_frame_invisible (f
);
2542 /* Make menu bar update for the Buffers and Frames menus. */
2543 windows_or_buffers_changed
= 16;
2548 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
2550 doc
: /* Make the frame FRAME into an icon.
2551 If omitted, FRAME defaults to the currently selected frame.
2553 If FRAME is a child frame, consult the variable `iconify-child-frame'
2554 for how to proceed. */)
2557 struct frame
*f
= decode_live_frame (frame
);
2558 #ifdef HAVE_WINDOW_SYSTEM
2559 Lisp_Object parent
= f
->parent_frame
;
2563 if (NILP (iconify_child_frame
))
2566 else if (EQ (iconify_child_frame
, Qiconify_top_level
))
2568 /* Iconify top level frame instead (the default). */
2569 Ficonify_frame (parent
);
2572 else if (EQ (iconify_child_frame
, Qmake_invisible
))
2574 /* Make frame invisible instead. */
2575 Fmake_frame_invisible (frame
, Qnil
);
2579 #endif /* HAVE_WINDOW_SYSTEM */
2581 /* Don't allow minibuf_window to remain on an iconified frame. */
2582 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2584 /* I think this should be done with a hook. */
2585 if (FRAME_WINDOW_P (f
))
2587 #ifdef HAVE_WINDOW_SYSTEM
2588 x_iconify_frame (f
);
2595 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
2597 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
2598 Return the symbol `icon' if FRAME is iconified or \"minimized\".
2599 Return nil if FRAME was made invisible, via `make-frame-invisible'.
2600 On graphical displays, invisible frames are not updated and are
2601 usually not displayed at all, even in a window system's \"taskbar\".
2603 If FRAME is a text terminal frame, this always returns t.
2604 Such frames are always considered visible, whether or not they are
2605 currently being displayed on the terminal. */)
2608 CHECK_LIVE_FRAME (frame
);
2610 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2612 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
2617 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
2619 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
2622 Lisp_Object tail
, frame
, value
= Qnil
;
2624 FOR_EACH_FRAME (tail
, frame
)
2625 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2626 value
= Fcons (frame
, value
);
2632 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
2633 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
2634 If FRAME is invisible or iconified, make it visible.
2635 If you don't specify a frame, the selected frame is used.
2636 If Emacs is displaying on an ordinary terminal or some other device which
2637 doesn't support multiple overlapping frames, this function selects FRAME. */)
2640 struct frame
*f
= decode_live_frame (frame
);
2642 XSETFRAME (frame
, f
);
2644 if (FRAME_TERMCAP_P (f
))
2645 /* On a text terminal select FRAME. */
2646 Fselect_frame (frame
, Qnil
);
2648 /* Do like the documentation says. */
2649 Fmake_frame_visible (frame
);
2651 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2652 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
2657 /* Should we have a corresponding function called Flower_Power? */
2658 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
2659 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2660 If you don't specify a frame, the selected frame is used.
2661 If Emacs is displaying on an ordinary terminal or some other device which
2662 doesn't support multiple overlapping frames, this function does nothing. */)
2665 struct frame
*f
= decode_live_frame (frame
);
2667 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2668 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2674 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2676 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2677 In other words, switch-frame events caused by events in FRAME will
2678 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2679 FOCUS-FRAME after reading an event typed at FRAME.
2681 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
2682 frame again receives its own keystrokes.
2684 Focus redirection is useful for temporarily redirecting keystrokes to
2685 a surrogate minibuffer frame when a frame doesn't have its own
2688 A frame's focus redirection can be changed by `select-frame'. If frame
2689 FOO is selected, and then a different frame BAR is selected, any
2690 frames redirecting their focus to FOO are shifted to redirect their
2691 focus to BAR. This allows focus redirection to work properly when the
2692 user switches from one frame to another using `select-window'.
2694 This means that a frame whose focus is redirected to itself is treated
2695 differently from a frame whose focus is redirected to nil; the former
2696 is affected by `select-frame', while the latter is not.
2698 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2699 (Lisp_Object frame
, Lisp_Object focus_frame
)
2701 /* Note that we don't check for a live frame here. It's reasonable
2702 to redirect the focus of a frame you're about to delete, if you
2703 know what other frame should receive those keystrokes. */
2704 struct frame
*f
= decode_any_frame (frame
);
2706 if (! NILP (focus_frame
))
2707 CHECK_LIVE_FRAME (focus_frame
);
2709 fset_focus_frame (f
, focus_frame
);
2711 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2712 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2718 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 0, 1, 0,
2719 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2720 If FRAME is omitted or nil, the selected frame is used.
2721 Return nil if FRAME's focus is not redirected.
2722 See `redirect-frame-focus'. */)
2725 return FRAME_FOCUS_FRAME (decode_live_frame (frame
));
2728 DEFUN ("x-focus-frame", Fx_focus_frame
, Sx_focus_frame
, 1, 2, 0,
2729 doc
: /* Set the input focus to FRAME.
2730 FRAME nil means use the selected frame. Optional argument NOACTIVATE
2731 means do not activate FRAME.
2733 If there is no window system support, this function does nothing. */)
2734 (Lisp_Object frame
, Lisp_Object noactivate
)
2736 #ifdef HAVE_WINDOW_SYSTEM
2737 x_focus_frame (decode_window_system_frame (frame
), !NILP (noactivate
));
2742 DEFUN ("frame-after-make-frame",
2743 Fframe_after_make_frame
,
2744 Sframe_after_make_frame
, 2, 2, 0,
2745 doc
: /* Mark FRAME as made.
2746 FRAME nil means use the selected frame. Second argument MADE non-nil
2747 means functions on `window-configuration-change-hook' are called
2748 whenever the window configuration of FRAME changes. MADE nil means
2749 these functions are not called.
2751 This function is currently called by `make-frame' only and should be
2752 otherwise used with utter care to avoid that running functions on
2753 `window-configuration-change-hook' is impeded forever. */)
2754 (Lisp_Object frame
, Lisp_Object made
)
2756 struct frame
*f
= decode_live_frame (frame
);
2757 f
->after_make_frame
= !NILP (made
);
2758 f
->inhibit_horizontal_resize
= false;
2759 f
->inhibit_vertical_resize
= false;
2764 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2767 frames_discard_buffer (Lisp_Object buffer
)
2769 Lisp_Object frame
, tail
;
2771 FOR_EACH_FRAME (tail
, frame
)
2774 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
2775 fset_buried_buffer_list
2776 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
2780 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2781 If the alist already has an element for PROP, we change it. */
2784 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2786 register Lisp_Object tem
;
2788 tem
= Fassq (prop
, *alistptr
);
2790 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2796 frame_name_fnn_p (char *str
, ptrdiff_t len
)
2798 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
2801 while ('0' <= *p
&& *p
<= '9')
2809 /* Set the name of the terminal frame. Also used by MSDOS frames.
2810 Modeled after x_set_name which is used for WINDOW frames. */
2813 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2815 f
->explicit_name
= ! NILP (name
);
2817 /* If NAME is nil, set the name to F<num>. */
2820 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
2822 /* Check for no change needed in this very common case
2823 before we do any consing. */
2824 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
2827 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
2831 CHECK_STRING (name
);
2833 /* Don't change the name if it's already NAME. */
2834 if (! NILP (Fstring_equal (name
, f
->name
)))
2837 /* Don't allow the user to set the frame name to F<num>, so it
2838 doesn't clash with the names we generate for terminal frames. */
2839 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2840 error ("Frame names of the form F<num> are usurped by Emacs");
2843 fset_name (f
, name
);
2844 update_mode_lines
= 16;
2848 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2850 register Lisp_Object old_alist_elt
;
2852 if (EQ (prop
, Qminibuffer
))
2856 if (!MINI_WINDOW_P (XWINDOW (val
)))
2857 error ("The `minibuffer' parameter does not specify a valid minibuffer window");
2858 else if (FRAME_MINIBUF_ONLY_P (f
))
2860 if (EQ (val
, FRAME_MINIBUF_WINDOW (f
)))
2863 error ("Can't change the minibuffer window of a minibuffer-only frame");
2865 else if (FRAME_HAS_MINIBUF_P (f
))
2867 if (EQ (val
, FRAME_MINIBUF_WINDOW (f
)))
2870 error ("Can't change the minibuffer window of a frame with its own minibuffer");
2873 /* Store the chosen minibuffer window. */
2874 fset_minibuffer_window (f
, val
);
2878 Lisp_Object old_val
= Fcdr (Fassq (Qminibuffer
, f
->param_alist
));
2880 if (!NILP (old_val
))
2882 if (WINDOWP (old_val
) && NILP (val
))
2883 /* Don't change the value for a minibuffer-less frame if
2884 only nil was specified as new value. */
2886 else if (!EQ (old_val
, val
))
2887 error ("Can't change the `minibuffer' parameter of this frame");
2892 /* Check each parent-frame and delete-before parameter for a
2893 circular dependency. Do not check between parameters, so you can
2894 still create circular dependencies with different properties, for
2895 example a chain of frames F1->F2->...Fn such that F1 is an ancestor
2896 frame of Fn and thus cannot be deleted before Fn and a second chain
2897 Fn->Fn-1->...F1 such that Fn cannot be deleted before F1. */
2898 else if (EQ (prop
, Qparent_frame
) || EQ (prop
, Qdelete_before
))
2900 Lisp_Object oldval
= Fcdr (Fassq (prop
, f
->param_alist
));
2902 if (!EQ (oldval
, val
) && !NILP (val
))
2905 Lisp_Object frame1
= val
;
2907 if (!FRAMEP (frame1
) || !FRAME_LIVE_P (XFRAME (frame1
)))
2908 error ("Invalid `%s' frame parameter",
2909 SSDATA (SYMBOL_NAME (prop
)));
2911 XSETFRAME (frame
, f
);
2913 while (FRAMEP (frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
2914 if (EQ (frame1
, frame
))
2915 error ("Circular specification of `%s' frame parameter",
2916 SSDATA (SYMBOL_NAME (prop
)));
2918 frame1
= get_frame_param (XFRAME (frame1
), prop
);
2922 /* The buffer-list parameters are stored in a special place and not
2923 in the alist. All buffers must be live. */
2924 else if (EQ (prop
, Qbuffer_list
))
2926 Lisp_Object list
= Qnil
;
2927 for (; CONSP (val
); val
= XCDR (val
))
2928 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2929 list
= Fcons (XCAR (val
), list
);
2930 fset_buffer_list (f
, Fnreverse (list
));
2933 else if (EQ (prop
, Qburied_buffer_list
))
2935 Lisp_Object list
= Qnil
;
2936 for (; CONSP (val
); val
= XCDR (val
))
2937 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2938 list
= Fcons (XCAR (val
), list
);
2939 fset_buried_buffer_list (f
, Fnreverse (list
));
2943 /* The tty color needed to be set before the frame's parameter
2944 alist was updated with the new value. This is not true any more,
2945 but we still do this test early on. */
2946 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2947 && f
== FRAME_TTY (f
)->previous_frame
)
2948 /* Force redisplay of this tty. */
2949 FRAME_TTY (f
)->previous_frame
= NULL
;
2951 /* Update the frame parameter alist. */
2952 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2953 if (EQ (old_alist_elt
, Qnil
))
2954 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2956 Fsetcdr (old_alist_elt
, val
);
2958 /* Update some other special parameters in their special places
2959 in addition to the alist. */
2961 if (EQ (prop
, Qbuffer_predicate
))
2962 fset_buffer_predicate (f
, val
);
2964 if (! FRAME_WINDOW_P (f
))
2966 if (EQ (prop
, Qmenu_bar_lines
))
2967 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2968 else if (EQ (prop
, Qname
))
2969 set_term_frame_name (f
, val
);
2973 /* Return color matches UNSPEC on frame F or nil if UNSPEC
2974 is not an unspecified foreground or background color. */
2977 frame_unspecified_color (struct frame
*f
, Lisp_Object unspec
)
2979 return (!strncmp (SSDATA (unspec
), unspecified_bg
, SBYTES (unspec
))
2980 ? tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
))
2981 : (!strncmp (SSDATA (unspec
), unspecified_fg
, SBYTES (unspec
))
2982 ? tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)) : Qnil
));
2985 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2986 doc
: /* Return the parameters-alist of frame FRAME.
2987 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2988 The meaningful PARMs depend on the kind of frame.
2989 If FRAME is omitted or nil, return information on the currently selected frame. */)
2993 struct frame
*f
= decode_any_frame (frame
);
2996 if (!FRAME_LIVE_P (f
))
2999 alist
= Fcopy_alist (f
->param_alist
);
3001 if (!FRAME_WINDOW_P (f
))
3005 /* If the frame's parameter alist says the colors are
3006 unspecified and reversed, take the frame's background pixel
3007 for foreground and vice versa. */
3008 elt
= Fassq (Qforeground_color
, alist
);
3009 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
3011 elt
= frame_unspecified_color (f
, XCDR (elt
));
3013 store_in_alist (&alist
, Qforeground_color
, elt
);
3016 store_in_alist (&alist
, Qforeground_color
,
3017 tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)));
3018 elt
= Fassq (Qbackground_color
, alist
);
3019 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
3021 elt
= frame_unspecified_color (f
, XCDR (elt
));
3023 store_in_alist (&alist
, Qbackground_color
, elt
);
3026 store_in_alist (&alist
, Qbackground_color
,
3027 tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
)));
3028 store_in_alist (&alist
, Qfont
,
3029 build_string (FRAME_MSDOS_P (f
)
3031 : FRAME_W32_P (f
) ? "w32term"
3034 store_in_alist (&alist
, Qname
, f
->name
);
3035 height
= (f
->new_height
3037 ? (f
->new_height
/ FRAME_LINE_HEIGHT (f
))
3040 store_in_alist (&alist
, Qheight
, make_number (height
));
3041 width
= (f
->new_width
3043 ? (f
->new_width
/ FRAME_COLUMN_WIDTH (f
))
3046 store_in_alist (&alist
, Qwidth
, make_number (width
));
3047 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
3048 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
3049 store_in_alist (&alist
, Qbuffer_list
, f
->buffer_list
);
3050 store_in_alist (&alist
, Qburied_buffer_list
, f
->buried_buffer_list
);
3052 /* I think this should be done with a hook. */
3053 #ifdef HAVE_WINDOW_SYSTEM
3054 if (FRAME_WINDOW_P (f
))
3055 x_report_frame_params (f
, &alist
);
3059 /* This ought to be correct in f->param_alist for an X frame. */
3061 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
3062 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
3069 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
3070 doc
: /* Return FRAME's value for parameter PARAMETER.
3071 If FRAME is nil, describe the currently selected frame. */)
3072 (Lisp_Object frame
, Lisp_Object parameter
)
3074 struct frame
*f
= decode_any_frame (frame
);
3075 Lisp_Object value
= Qnil
;
3077 CHECK_SYMBOL (parameter
);
3079 XSETFRAME (frame
, f
);
3081 if (FRAME_LIVE_P (f
))
3083 /* Avoid consing in frequent cases. */
3084 if (EQ (parameter
, Qname
))
3086 #ifdef HAVE_WINDOW_SYSTEM
3087 /* These are used by vertical motion commands. */
3088 else if (EQ (parameter
, Qvertical_scroll_bars
))
3089 value
= (f
->vertical_scroll_bar_type
== vertical_scroll_bar_none
3091 : (f
->vertical_scroll_bar_type
== vertical_scroll_bar_left
3093 else if (EQ (parameter
, Qhorizontal_scroll_bars
))
3094 value
= f
->horizontal_scroll_bars
? Qt
: Qnil
;
3095 else if (EQ (parameter
, Qline_spacing
) && f
->extra_line_spacing
== 0)
3096 /* If this is non-zero, we can't determine whether the user specified
3097 an integer or float value without looking through 'param_alist'. */
3098 value
= make_number (0);
3099 else if (EQ (parameter
, Qfont
) && FRAME_X_P (f
))
3100 value
= FRAME_FONT (f
)->props
[FONT_NAME_INDEX
];
3101 #endif /* HAVE_WINDOW_SYSTEM */
3102 #ifdef HAVE_X_WINDOWS
3103 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
3104 value
= XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
);
3105 #endif /* HAVE_X_WINDOWS */
3106 else if (EQ (parameter
, Qbackground_color
)
3107 || EQ (parameter
, Qforeground_color
))
3109 value
= Fassq (parameter
, f
->param_alist
);
3112 value
= XCDR (value
);
3113 /* Fframe_parameters puts the actual fg/bg color names,
3114 even if f->param_alist says otherwise. This is
3115 important when param_alist's notion of colors is
3116 "unspecified". We need to do the same here. */
3117 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
3119 Lisp_Object tem
= frame_unspecified_color (f
, value
);
3126 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
3128 else if (EQ (parameter
, Qdisplay_type
)
3129 || EQ (parameter
, Qbackground_mode
))
3130 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
3132 /* FIXME: Avoid this code path at all (as well as code duplication)
3133 by sharing more code with Fframe_parameters. */
3134 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
3141 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
3142 Smodify_frame_parameters
, 2, 2, 0,
3143 doc
: /* Modify FRAME according to new values of its parameters in ALIST.
3144 If FRAME is nil, it defaults to the selected frame.
3145 ALIST is an alist of parameters to change and their new values.
3146 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
3147 Which PARMs are meaningful depends on the kind of frame.
3148 The meaningful parameters are acted upon, i.e. the frame is changed
3149 according to their new values, and are also stored in the frame's
3150 parameter list so that `frame-parameters' will return them.
3151 PARMs that are not meaningful are still stored in the frame's parameter
3152 list, but are otherwise ignored. */)
3153 (Lisp_Object frame
, Lisp_Object alist
)
3155 struct frame
*f
= decode_live_frame (frame
);
3156 Lisp_Object prop
, val
;
3158 /* I think this should be done with a hook. */
3159 #ifdef HAVE_WINDOW_SYSTEM
3160 if (FRAME_WINDOW_P (f
))
3161 x_set_frame_parameters (f
, alist
);
3165 if (FRAME_MSDOS_P (f
))
3166 IT_set_frame_parameters (f
, alist
);
3171 EMACS_INT length
= XFASTINT (Flength (alist
));
3174 Lisp_Object
*values
;
3176 SAFE_ALLOCA_LISP (parms
, 2 * length
);
3177 values
= parms
+ length
;
3179 /* Extract parm names and values into those vectors. */
3181 for (i
= 0; CONSP (alist
); alist
= XCDR (alist
))
3186 parms
[i
] = Fcar (elt
);
3187 values
[i
] = Fcdr (elt
);
3191 /* Now process them in reverse of specified order. */
3196 store_frame_param (f
, prop
, val
);
3198 if (EQ (prop
, Qforeground_color
)
3199 || EQ (prop
, Qbackground_color
))
3200 update_face_from_frame_parameter (f
, prop
, val
);
3208 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
3210 doc
: /* Height in pixels of a line in the font in frame FRAME.
3211 If FRAME is omitted or nil, the selected frame is used.
3212 For a terminal frame, the value is always 1. */)
3215 #ifdef HAVE_WINDOW_SYSTEM
3216 struct frame
*f
= decode_any_frame (frame
);
3218 if (FRAME_WINDOW_P (f
))
3219 return make_number (FRAME_LINE_HEIGHT (f
));
3222 return make_number (1);
3226 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
3228 doc
: /* Width in pixels of characters in the font in frame FRAME.
3229 If FRAME is omitted or nil, the selected frame is used.
3230 On a graphical screen, the width is the standard width of the default font.
3231 For a terminal screen, the value is always 1. */)
3234 #ifdef HAVE_WINDOW_SYSTEM
3235 struct frame
*f
= decode_any_frame (frame
);
3237 if (FRAME_WINDOW_P (f
))
3238 return make_number (FRAME_COLUMN_WIDTH (f
));
3241 return make_number (1);
3244 DEFUN ("frame-native-width", Fframe_native_width
,
3245 Sframe_native_width
, 0, 1, 0,
3246 doc
: /* Return FRAME's native width in pixels.
3247 For a terminal frame, the result really gives the width in characters.
3248 If FRAME is omitted or nil, the selected frame is used. */)
3251 struct frame
*f
= decode_any_frame (frame
);
3253 #ifdef HAVE_WINDOW_SYSTEM
3254 if (FRAME_WINDOW_P (f
))
3255 return make_number (FRAME_PIXEL_WIDTH (f
));
3258 return make_number (FRAME_TOTAL_COLS (f
));
3261 DEFUN ("frame-native-height", Fframe_native_height
,
3262 Sframe_native_height
, 0, 1, 0,
3263 doc
: /* Return FRAME's native height in pixels.
3264 If FRAME is omitted or nil, the selected frame is used. The exact value
3265 of the result depends on the window-system and toolkit in use:
3267 In the Gtk+ and NS versions, it includes only any window (including the
3268 minibuffer or echo area), mode line, and header line. It does not
3269 include the tool bar or menu bar. With other graphical versions, it may
3270 also include the tool bar and the menu bar.
3272 For a text terminal, it includes the menu bar. In this case, the
3273 result is really in characters rather than pixels (i.e., is identical
3274 to `frame-height'). */)
3277 struct frame
*f
= decode_any_frame (frame
);
3279 #ifdef HAVE_WINDOW_SYSTEM
3280 if (FRAME_WINDOW_P (f
))
3281 return make_number (FRAME_PIXEL_HEIGHT (f
));
3284 return make_number (FRAME_TOTAL_LINES (f
));
3287 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
3288 Stool_bar_pixel_width
, 0, 1, 0,
3289 doc
: /* Return width in pixels of FRAME's tool bar.
3290 The result is greater than zero only when the tool bar is on the left
3291 or right side of FRAME. If FRAME is omitted or nil, the selected frame
3295 #ifdef FRAME_TOOLBAR_WIDTH
3296 struct frame
*f
= decode_any_frame (frame
);
3298 if (FRAME_WINDOW_P (f
))
3299 return make_number (FRAME_TOOLBAR_WIDTH (f
));
3301 return make_number (0);
3304 DEFUN ("frame-text-cols", Fframe_text_cols
, Sframe_text_cols
, 0, 1, 0,
3305 doc
: /* Return width in columns of FRAME's text area. */)
3308 return make_number (FRAME_COLS (decode_any_frame (frame
)));
3311 DEFUN ("frame-text-lines", Fframe_text_lines
, Sframe_text_lines
, 0, 1, 0,
3312 doc
: /* Return height in lines of FRAME's text area. */)
3315 return make_number (FRAME_LINES (decode_any_frame (frame
)));
3318 DEFUN ("frame-total-cols", Fframe_total_cols
, Sframe_total_cols
, 0, 1, 0,
3319 doc
: /* Return number of total columns of FRAME. */)
3322 return make_number (FRAME_TOTAL_COLS (decode_any_frame (frame
)));
3325 DEFUN ("frame-total-lines", Fframe_total_lines
, Sframe_total_lines
, 0, 1, 0,
3326 doc
: /* Return number of total lines of FRAME. */)
3329 return make_number (FRAME_TOTAL_LINES (decode_any_frame (frame
)));
3332 DEFUN ("frame-text-width", Fframe_text_width
, Sframe_text_width
, 0, 1, 0,
3333 doc
: /* Return text area width of FRAME in pixels. */)
3336 return make_number (FRAME_TEXT_WIDTH (decode_any_frame (frame
)));
3339 DEFUN ("frame-text-height", Fframe_text_height
, Sframe_text_height
, 0, 1, 0,
3340 doc
: /* Return text area height of FRAME in pixels. */)
3343 return make_number (FRAME_TEXT_HEIGHT (decode_any_frame (frame
)));
3346 DEFUN ("frame-scroll-bar-width", Fscroll_bar_width
, Sscroll_bar_width
, 0, 1, 0,
3347 doc
: /* Return scroll bar width of FRAME in pixels. */)
3350 return make_number (FRAME_SCROLL_BAR_AREA_WIDTH (decode_any_frame (frame
)));
3353 DEFUN ("frame-scroll-bar-height", Fscroll_bar_height
, Sscroll_bar_height
, 0, 1, 0,
3354 doc
: /* Return scroll bar height of FRAME in pixels. */)
3357 return make_number (FRAME_SCROLL_BAR_AREA_HEIGHT (decode_any_frame (frame
)));
3360 DEFUN ("frame-fringe-width", Ffringe_width
, Sfringe_width
, 0, 1, 0,
3361 doc
: /* Return fringe width of FRAME in pixels. */)
3364 return make_number (FRAME_TOTAL_FRINGE_WIDTH (decode_any_frame (frame
)));
3367 DEFUN ("frame-internal-border-width", Fframe_internal_border_width
, Sframe_internal_border_width
, 0, 1, 0,
3368 doc
: /* Return width of FRAME's internal border in pixels. */)
3371 return make_number (FRAME_INTERNAL_BORDER_WIDTH (decode_any_frame (frame
)));
3374 DEFUN ("frame-right-divider-width", Fright_divider_width
, Sright_divider_width
, 0, 1, 0,
3375 doc
: /* Return width (in pixels) of vertical window dividers on FRAME. */)
3378 return make_number (FRAME_RIGHT_DIVIDER_WIDTH (decode_any_frame (frame
)));
3381 DEFUN ("frame-bottom-divider-width", Fbottom_divider_width
, Sbottom_divider_width
, 0, 1, 0,
3382 doc
: /* Return width (in pixels) of horizontal window dividers on FRAME. */)
3385 return make_number (FRAME_BOTTOM_DIVIDER_WIDTH (decode_any_frame (frame
)));
3388 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 4, 0,
3389 doc
: /* Set text height of frame FRAME to HEIGHT lines.
3390 Optional third arg PRETEND non-nil means that redisplay should use
3391 HEIGHT lines but that the idea of the actual height of the frame should
3394 Optional fourth argument PIXELWISE non-nil means that FRAME should be
3395 HEIGHT pixels high. Note: When `frame-resize-pixelwise' is nil, some
3396 window managers may refuse to honor a HEIGHT that is not an integer
3397 multiple of the default frame font height. */)
3398 (Lisp_Object frame
, Lisp_Object height
, Lisp_Object pretend
, Lisp_Object pixelwise
)
3400 struct frame
*f
= decode_live_frame (frame
);
3403 CHECK_TYPE_RANGED_INTEGER (int, height
);
3405 pixel_height
= (!NILP (pixelwise
)
3407 : XINT (height
) * FRAME_LINE_HEIGHT (f
));
3408 adjust_frame_size (f
, -1, pixel_height
, 1, !NILP (pretend
), Qheight
);
3413 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 4, 0,
3414 doc
: /* Set text width of frame FRAME to WIDTH columns.
3415 Optional third arg PRETEND non-nil means that redisplay should use WIDTH
3416 columns but that the idea of the actual width of the frame should not
3419 Optional fourth argument PIXELWISE non-nil means that FRAME should be
3420 WIDTH pixels wide. Note: When `frame-resize-pixelwise' is nil, some
3421 window managers may refuse to honor a WIDTH that is not an integer
3422 multiple of the default frame font width. */)
3423 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object pretend
, Lisp_Object pixelwise
)
3425 struct frame
*f
= decode_live_frame (frame
);
3428 CHECK_TYPE_RANGED_INTEGER (int, width
);
3430 pixel_width
= (!NILP (pixelwise
)
3432 : XINT (width
) * FRAME_COLUMN_WIDTH (f
));
3433 adjust_frame_size (f
, pixel_width
, -1, 1, !NILP (pretend
), Qwidth
);
3438 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 4, 0,
3439 doc
: /* Set text size of FRAME to WIDTH by HEIGHT, measured in characters.
3440 Optional argument PIXELWISE non-nil means to measure in pixels. Note:
3441 When `frame-resize-pixelwise' is nil, some window managers may refuse to
3442 honor a WIDTH that is not an integer multiple of the default frame font
3443 width or a HEIGHT that is not an integer multiple of the default frame
3445 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object height
, Lisp_Object pixelwise
)
3447 struct frame
*f
= decode_live_frame (frame
);
3448 int pixel_width
, pixel_height
;
3450 CHECK_TYPE_RANGED_INTEGER (int, width
);
3451 CHECK_TYPE_RANGED_INTEGER (int, height
);
3453 pixel_width
= (!NILP (pixelwise
)
3455 : XINT (width
) * FRAME_COLUMN_WIDTH (f
));
3456 pixel_height
= (!NILP (pixelwise
)
3458 : XINT (height
) * FRAME_LINE_HEIGHT (f
));
3459 adjust_frame_size (f
, pixel_width
, pixel_height
, 1, 0, Qsize
);
3464 DEFUN ("frame-position", Fframe_position
,
3465 Sframe_position
, 0, 1, 0,
3466 doc
: /* Return top left corner of FRAME in pixels.
3467 FRAME must be a live frame and defaults to the selected one. The return
3468 value is a cons (x, y) of the coordinates of the top left corner of
3469 FRAME's outer frame, in pixels relative to an origin (0, 0) of FRAME's
3473 register struct frame
*f
= decode_live_frame (frame
);
3475 return Fcons (make_number (f
->left_pos
), make_number (f
->top_pos
));
3478 DEFUN ("set-frame-position", Fset_frame_position
,
3479 Sset_frame_position
, 3, 3, 0,
3480 doc
: /* Set position of FRAME to (X, Y).
3481 FRAME must be a live frame and defaults to the selected one. X and Y,
3482 if positive, specify the coordinate of the left and top edge of FRAME's
3483 outer frame in pixels relative to an origin (0, 0) of FRAME's display.
3484 If any of X or Y is negative, it specifies the coordinates of the right
3485 or bottom edge of the outer frame of FRAME relative to the right or
3486 bottom edge of FRAME's display. */)
3487 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
3489 struct frame
*f
= decode_live_frame (frame
);
3491 CHECK_TYPE_RANGED_INTEGER (int, x
);
3492 CHECK_TYPE_RANGED_INTEGER (int, y
);
3494 /* I think this should be done with a hook. */
3495 if (FRAME_WINDOW_P (f
))
3497 #ifdef HAVE_WINDOW_SYSTEM
3498 x_set_offset (f
, XINT (x
), XINT (y
), 1);
3505 /***********************************************************************
3507 ***********************************************************************/
3509 /* Connect the frame-parameter names for X frames
3510 to the ways of passing the parameter values to the window system.
3512 The name of a parameter, as a Lisp symbol,
3513 has an `x-frame-parameter' property which is an integer in Lisp
3514 that is an index in this table. */
3516 struct frame_parm_table
{
3521 static const struct frame_parm_table frame_parms
[] =
3523 {"auto-raise", SYMBOL_INDEX (Qauto_raise
)},
3524 {"auto-lower", SYMBOL_INDEX (Qauto_lower
)},
3525 {"background-color", -1},
3526 {"border-color", SYMBOL_INDEX (Qborder_color
)},
3527 {"border-width", SYMBOL_INDEX (Qborder_width
)},
3528 {"cursor-color", SYMBOL_INDEX (Qcursor_color
)},
3529 {"cursor-type", SYMBOL_INDEX (Qcursor_type
)},
3531 {"foreground-color", -1},
3532 {"icon-name", SYMBOL_INDEX (Qicon_name
)},
3533 {"icon-type", SYMBOL_INDEX (Qicon_type
)},
3534 {"internal-border-width", SYMBOL_INDEX (Qinternal_border_width
)},
3535 {"right-divider-width", SYMBOL_INDEX (Qright_divider_width
)},
3536 {"bottom-divider-width", SYMBOL_INDEX (Qbottom_divider_width
)},
3537 {"menu-bar-lines", SYMBOL_INDEX (Qmenu_bar_lines
)},
3538 {"mouse-color", SYMBOL_INDEX (Qmouse_color
)},
3539 {"name", SYMBOL_INDEX (Qname
)},
3540 {"scroll-bar-width", SYMBOL_INDEX (Qscroll_bar_width
)},
3541 {"scroll-bar-height", SYMBOL_INDEX (Qscroll_bar_height
)},
3542 {"title", SYMBOL_INDEX (Qtitle
)},
3543 {"unsplittable", SYMBOL_INDEX (Qunsplittable
)},
3544 {"vertical-scroll-bars", SYMBOL_INDEX (Qvertical_scroll_bars
)},
3545 {"horizontal-scroll-bars", SYMBOL_INDEX (Qhorizontal_scroll_bars
)},
3546 {"visibility", SYMBOL_INDEX (Qvisibility
)},
3547 {"tool-bar-lines", SYMBOL_INDEX (Qtool_bar_lines
)},
3548 {"scroll-bar-foreground", SYMBOL_INDEX (Qscroll_bar_foreground
)},
3549 {"scroll-bar-background", SYMBOL_INDEX (Qscroll_bar_background
)},
3550 {"screen-gamma", SYMBOL_INDEX (Qscreen_gamma
)},
3551 {"line-spacing", SYMBOL_INDEX (Qline_spacing
)},
3552 {"left-fringe", SYMBOL_INDEX (Qleft_fringe
)},
3553 {"right-fringe", SYMBOL_INDEX (Qright_fringe
)},
3554 {"wait-for-wm", SYMBOL_INDEX (Qwait_for_wm
)},
3555 {"fullscreen", SYMBOL_INDEX (Qfullscreen
)},
3556 {"font-backend", SYMBOL_INDEX (Qfont_backend
)},
3557 {"alpha", SYMBOL_INDEX (Qalpha
)},
3558 {"sticky", SYMBOL_INDEX (Qsticky
)},
3559 {"tool-bar-position", SYMBOL_INDEX (Qtool_bar_position
)},
3560 {"inhibit-double-buffering", SYMBOL_INDEX (Qinhibit_double_buffering
)},
3561 {"undecorated", SYMBOL_INDEX (Qundecorated
)},
3562 {"parent-frame", SYMBOL_INDEX (Qparent_frame
)},
3563 {"skip-taskbar", SYMBOL_INDEX (Qskip_taskbar
)},
3564 {"no-focus-on-map", SYMBOL_INDEX (Qno_focus_on_map
)},
3565 {"no-accept-focus", SYMBOL_INDEX (Qno_accept_focus
)},
3566 {"z-group", SYMBOL_INDEX (Qz_group
)},
3567 {"override-redirect", SYMBOL_INDEX (Qoverride_redirect
)},
3568 {"no-special-glyphs", SYMBOL_INDEX (Qno_special_glyphs
)},
3569 #ifdef NS_IMPL_COCOA
3570 {"ns-appearance", SYMBOL_INDEX (Qns_appearance
)},
3571 {"ns-transparent-titlebar", SYMBOL_INDEX (Qns_transparent_titlebar
)},
3575 #ifdef HAVE_WINDOW_SYSTEM
3577 /* Enumeration type for switch in frame_float. */
3578 enum frame_float_type
3589 * Process the value VAL of the float type frame parameter 'width',
3590 * 'height', 'left', or 'top' specified via a frame_float_type
3591 * enumeration type WHAT for frame F. Such parameters relate the outer
3592 * size or position of F to the size of the F's display or parent frame
3593 * which have to be both available in some way.
3595 * The return value is a size or position value in pixels. VAL must be
3596 * in the range 0.0 to 1.0 where a width/height of 0.0 means to return 0
3597 * and 1.0 means to return the full width/height of the display/parent.
3598 * For positions, 0.0 means position in the left/top corner of the
3599 * display/parent while 1.0 means to position at the right/bottom corner
3600 * of the display/parent frame.
3602 * Set PARENT_DONE and OUTER_DONE to avoid recalculation of the outer
3603 * size or parent or display attributes when more float parameters are
3604 * calculated in a row: -1 means not processed yet, 0 means processing
3605 * failed, 1 means processing succeeded.
3607 * Return DEFAULT_VALUE when processing fails for whatever reason with
3608 * one exception: When calculating F's outer edges fails (probably
3609 * because F has not been created yet) return the difference between F's
3610 * native and text size.
3613 frame_float (struct frame
*f
, Lisp_Object val
, enum frame_float_type what
,
3614 int *parent_done
, int *outer_done
, int default_value
)
3616 double d_val
= XFLOAT_DATA (val
);
3618 if (d_val
< 0.0 || d_val
> 1.0)
3620 return default_value
;
3623 static unsigned parent_width
, parent_height
;
3624 static int parent_left
, parent_top
;
3625 static unsigned outer_minus_text_width
, outer_minus_text_height
;
3626 struct frame
*p
= FRAME_PARENT_FRAME (f
);
3628 if (*parent_done
== 1)
3632 parent_width
= FRAME_PIXEL_WIDTH (p
);
3633 parent_height
= FRAME_PIXEL_HEIGHT (p
);
3638 if (*parent_done
== 0)
3639 /* No workarea available. */
3640 return default_value
;
3641 else if (*parent_done
== -1)
3643 Lisp_Object monitor_attributes
;
3644 Lisp_Object workarea
;
3647 XSETFRAME (frame
, f
);
3648 monitor_attributes
= Fcar (call1 (Qdisplay_monitor_attributes_list
, frame
));
3649 if (NILP (monitor_attributes
))
3651 /* No monitor attributes available. */
3654 return default_value
;
3657 workarea
= Fcdr (Fassq (Qworkarea
, monitor_attributes
));
3658 if (NILP (workarea
))
3660 /* No workarea available. */
3663 return default_value
;
3666 /* Workarea available. */
3667 parent_left
= XINT (Fnth (make_number (0), workarea
));
3668 parent_top
= XINT (Fnth (make_number (1), workarea
));
3669 parent_width
= XINT (Fnth (make_number (2), workarea
));
3670 parent_height
= XINT (Fnth (make_number (3), workarea
));
3675 if (*outer_done
== 1)
3677 else if (FRAME_UNDECORATED (f
))
3679 outer_minus_text_width
3680 = FRAME_PIXEL_WIDTH (f
) - FRAME_TEXT_WIDTH (f
);
3681 outer_minus_text_height
3682 = FRAME_PIXEL_HEIGHT (f
) - FRAME_TEXT_HEIGHT (f
);
3685 else if (*outer_done
== 0)
3686 /* No outer size available. */
3687 return default_value
;
3688 else if (*outer_done
== -1)
3690 Lisp_Object frame
, outer_edges
;
3692 XSETFRAME (frame
, f
);
3693 outer_edges
= call2 (Qframe_edges
, frame
, Qouter_edges
);
3695 if (!NILP (outer_edges
))
3697 outer_minus_text_width
3698 = (XINT (Fnth (make_number (2), outer_edges
))
3699 - XINT (Fnth (make_number (0), outer_edges
))
3700 - FRAME_TEXT_WIDTH (f
));
3701 outer_minus_text_height
3702 = (XINT (Fnth (make_number (3), outer_edges
))
3703 - XINT (Fnth (make_number (1), outer_edges
))
3704 - FRAME_TEXT_HEIGHT (f
));
3708 /* If we can't get any outer edges, proceed as if the frame
3709 were undecorated. */
3710 outer_minus_text_width
3711 = FRAME_PIXEL_WIDTH (f
) - FRAME_TEXT_WIDTH (f
);
3712 outer_minus_text_height
3713 = FRAME_PIXEL_HEIGHT (f
) - FRAME_TEXT_HEIGHT (f
);
3721 case FRAME_FLOAT_WIDTH
:
3722 return parent_width
* d_val
- outer_minus_text_width
;
3724 case FRAME_FLOAT_HEIGHT
:
3725 return parent_height
* d_val
- outer_minus_text_height
;
3727 case FRAME_FLOAT_LEFT
:
3729 int rest_width
= (parent_width
3730 - FRAME_TEXT_WIDTH (f
)
3731 - outer_minus_text_width
);
3734 return (rest_width
<= 0 ? 0 : d_val
* rest_width
);
3736 return (rest_width
<= 0
3738 : parent_left
+ d_val
* rest_width
);
3740 case FRAME_FLOAT_TOP
:
3742 int rest_height
= (parent_height
3743 - FRAME_TEXT_HEIGHT (f
)
3744 - outer_minus_text_height
);
3747 return (rest_height
<= 0 ? 0 : d_val
* rest_height
);
3749 return (rest_height
<= 0
3751 : parent_top
+ d_val
* rest_height
);
3759 /* Change the parameters of frame F as specified by ALIST.
3760 If a parameter is not specially recognized, do nothing special;
3761 otherwise call the `x_set_...' function for that parameter.
3762 Except for certain geometry properties, always call store_frame_param
3763 to store the new value in the parameter alist. */
3766 x_set_frame_parameters (struct frame
*f
, Lisp_Object alist
)
3768 Lisp_Object tail
, frame
;
3771 /* If both of these parameters are present, it's more efficient to
3772 set them both at once. So we wait until we've looked at the
3773 entire list before we set them. */
3774 int width
= -1, height
= -1; /* -1 denotes they were not changed. */
3777 Lisp_Object left
, top
;
3779 /* Same with these. */
3780 Lisp_Object icon_left
, icon_top
;
3782 /* And with this. */
3783 Lisp_Object fullscreen
;
3784 bool fullscreen_change
= false;
3786 /* Record in these vectors all the parms specified. */
3788 Lisp_Object
*values
;
3789 ptrdiff_t i
, j
, size
;
3790 bool left_no_change
= 0, top_no_change
= 0;
3791 #ifdef HAVE_X_WINDOWS
3792 bool icon_left_no_change
= 0, icon_top_no_change
= 0;
3794 int parent_done
= -1, outer_done
= -1;
3796 XSETFRAME (frame
, f
);
3797 for (size
= 0, tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3799 CHECK_LIST_END (tail
, alist
);
3802 SAFE_ALLOCA_LISP (parms
, 2 * size
);
3803 values
= parms
+ size
;
3805 /* Extract parm names and values into those vectors. */
3807 i
= 0, j
= size
- 1;
3808 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3810 Lisp_Object elt
= XCAR (tail
), prop
= Fcar (elt
), val
= Fcdr (elt
);
3812 /* Some properties are independent of other properties, but other
3813 properties are dependent upon them. These special properties
3814 are foreground_color, background_color (affects cursor_color)
3815 and font (affects fringe widths); they're recorded starting
3816 from the end of PARMS and VALUES to process them first by using
3817 reverse iteration. */
3819 if (EQ (prop
, Qforeground_color
)
3820 || EQ (prop
, Qbackground_color
)
3821 || EQ (prop
, Qfont
))
3835 /* TAIL and ALIST are not used again below here. */
3836 alist
= tail
= Qnil
;
3838 top
= left
= Qunbound
;
3839 icon_left
= icon_top
= Qunbound
;
3841 /* Reverse order is used to make sure that special
3842 properties noticed above are processed first. */
3843 for (i
= size
- 1; i
>= 0; i
--)
3845 Lisp_Object prop
, val
;
3850 if (EQ (prop
, Qwidth
))
3852 if (RANGED_INTEGERP (0, val
, INT_MAX
))
3853 width
= XFASTINT (val
) * FRAME_COLUMN_WIDTH (f
) ;
3854 else if (CONSP (val
) && EQ (XCAR (val
), Qtext_pixels
)
3855 && RANGED_INTEGERP (0, XCDR (val
), INT_MAX
))
3856 width
= XFASTINT (XCDR (val
));
3857 else if (FLOATP (val
))
3858 width
= frame_float (f
, val
, FRAME_FLOAT_WIDTH
, &parent_done
,
3861 else if (EQ (prop
, Qheight
))
3863 if (RANGED_INTEGERP (0, val
, INT_MAX
))
3864 height
= XFASTINT (val
) * FRAME_LINE_HEIGHT (f
);
3865 else if (CONSP (val
) && EQ (XCAR (val
), Qtext_pixels
)
3866 && RANGED_INTEGERP (0, XCDR (val
), INT_MAX
))
3867 height
= XFASTINT (XCDR (val
));
3868 else if (FLOATP (val
))
3869 height
= frame_float (f
, val
, FRAME_FLOAT_HEIGHT
, &parent_done
,
3872 else if (EQ (prop
, Qtop
))
3874 else if (EQ (prop
, Qleft
))
3876 else if (EQ (prop
, Qicon_top
))
3878 else if (EQ (prop
, Qicon_left
))
3880 else if (EQ (prop
, Qfullscreen
))
3883 fullscreen_change
= true;
3887 register Lisp_Object param_index
, old_value
;
3889 old_value
= get_frame_param (f
, prop
);
3891 store_frame_param (f
, prop
, val
);
3893 param_index
= Fget (prop
, Qx_frame_parameter
);
3894 if (NATNUMP (param_index
)
3895 && XFASTINT (param_index
) < ARRAYELTS (frame_parms
)
3896 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3897 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3901 /* Don't die if just one of these was set. */
3902 if (EQ (left
, Qunbound
))
3905 if (f
->left_pos
< 0)
3906 left
= list2 (Qplus
, make_number (f
->left_pos
));
3908 XSETINT (left
, f
->left_pos
);
3910 if (EQ (top
, Qunbound
))
3914 top
= list2 (Qplus
, make_number (f
->top_pos
));
3916 XSETINT (top
, f
->top_pos
);
3919 /* If one of the icon positions was not set, preserve or default it. */
3920 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
3922 #ifdef HAVE_X_WINDOWS
3923 icon_left_no_change
= 1;
3925 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3926 if (NILP (icon_left
))
3927 XSETINT (icon_left
, 0);
3929 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
3931 #ifdef HAVE_X_WINDOWS
3932 icon_top_no_change
= 1;
3934 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3935 if (NILP (icon_top
))
3936 XSETINT (icon_top
, 0);
3939 /* Don't set these parameters unless they've been explicitly
3940 specified. The window might be mapped or resized while we're in
3941 this function, and we don't want to override that unless the lisp
3942 code has asked for it.
3944 Don't set these parameters unless they actually differ from the
3945 window's current parameters; the window may not actually exist
3947 if ((width
!= -1 && width
!= FRAME_TEXT_WIDTH (f
))
3948 || (height
!= -1 && height
!= FRAME_TEXT_HEIGHT (f
)))
3949 /* We could consider checking f->after_make_frame here, but I
3950 don't have the faintest idea why the following is needed at
3951 all. With the old setting it can get a Heisenbug when
3952 EmacsFrameResize intermittently provokes a delayed
3953 change_frame_size in the middle of adjust_frame_size. */
3954 /** || (f->can_x_set_window_size && (f->new_height || f->new_width))) **/
3955 adjust_frame_size (f
, width
, height
, 1, 0, Qx_set_frame_parameters
);
3957 if ((!NILP (left
) || !NILP (top
))
3958 && ! (left_no_change
&& top_no_change
)
3959 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3960 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3965 /* Record the signs. */
3966 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3967 if (EQ (left
, Qminus
))
3968 f
->size_hint_flags
|= XNegative
;
3969 else if (TYPE_RANGED_INTEGERP (int, left
))
3971 leftpos
= XINT (left
);
3973 f
->size_hint_flags
|= XNegative
;
3975 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3976 && CONSP (XCDR (left
))
3977 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
3979 leftpos
= - XINT (XCAR (XCDR (left
)));
3980 f
->size_hint_flags
|= XNegative
;
3982 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3983 && CONSP (XCDR (left
))
3984 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
3985 leftpos
= XINT (XCAR (XCDR (left
)));
3986 else if (FLOATP (left
))
3987 leftpos
= frame_float (f
, left
, FRAME_FLOAT_LEFT
, &parent_done
,
3990 if (EQ (top
, Qminus
))
3991 f
->size_hint_flags
|= YNegative
;
3992 else if (TYPE_RANGED_INTEGERP (int, top
))
3994 toppos
= XINT (top
);
3996 f
->size_hint_flags
|= YNegative
;
3998 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3999 && CONSP (XCDR (top
))
4000 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
4002 toppos
= - XINT (XCAR (XCDR (top
)));
4003 f
->size_hint_flags
|= YNegative
;
4005 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
4006 && CONSP (XCDR (top
))
4007 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
4008 toppos
= XINT (XCAR (XCDR (top
)));
4009 else if (FLOATP (top
))
4010 toppos
= frame_float (f
, top
, FRAME_FLOAT_TOP
, &parent_done
,
4013 /* Store the numeric value of the position. */
4014 f
->top_pos
= toppos
;
4015 f
->left_pos
= leftpos
;
4017 f
->win_gravity
= NorthWestGravity
;
4019 /* Actually set that position, and convert to absolute. */
4020 x_set_offset (f
, leftpos
, toppos
, -1);
4023 if (fullscreen_change
)
4025 Lisp_Object old_value
= get_frame_param (f
, Qfullscreen
);
4027 frame_size_history_add
4028 (f
, Qx_set_fullscreen
, 0, 0, list2 (old_value
, fullscreen
));
4030 store_frame_param (f
, Qfullscreen
, fullscreen
);
4031 if (!EQ (fullscreen
, old_value
))
4032 x_set_fullscreen (f
, fullscreen
, old_value
);
4036 #ifdef HAVE_X_WINDOWS
4037 if ((!NILP (icon_left
) || !NILP (icon_top
))
4038 && ! (icon_left_no_change
&& icon_top_no_change
))
4039 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
4040 #endif /* HAVE_X_WINDOWS */
4046 /* Insert a description of internally-recorded parameters of frame X
4047 into the parameter alist *ALISTPTR that is to be given to the user.
4048 Only parameters that are specific to the X window system
4049 and whose values are not correctly recorded in the frame's
4050 param_alist need to be considered here. */
4053 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
4057 char buf
[INT_BUFSIZE_BOUND (w
)];
4059 /* Represent negative positions (off the top or left screen edge)
4060 in a way that Fmodify_frame_parameters will understand correctly. */
4061 XSETINT (tem
, f
->left_pos
);
4062 if (f
->left_pos
>= 0)
4063 store_in_alist (alistptr
, Qleft
, tem
);
4065 store_in_alist (alistptr
, Qleft
, list2 (Qplus
, tem
));
4067 XSETINT (tem
, f
->top_pos
);
4068 if (f
->top_pos
>= 0)
4069 store_in_alist (alistptr
, Qtop
, tem
);
4071 store_in_alist (alistptr
, Qtop
, list2 (Qplus
, tem
));
4073 store_in_alist (alistptr
, Qborder_width
,
4074 make_number (f
->border_width
));
4075 store_in_alist (alistptr
, Qinternal_border_width
,
4076 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
4077 store_in_alist (alistptr
, Qright_divider_width
,
4078 make_number (FRAME_RIGHT_DIVIDER_WIDTH (f
)));
4079 store_in_alist (alistptr
, Qbottom_divider_width
,
4080 make_number (FRAME_BOTTOM_DIVIDER_WIDTH (f
)));
4081 store_in_alist (alistptr
, Qleft_fringe
,
4082 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
4083 store_in_alist (alistptr
, Qright_fringe
,
4084 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
4085 store_in_alist (alistptr
, Qscroll_bar_width
,
4086 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
4088 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
4089 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
4090 /* nil means "use default width"
4091 for non-toolkit scroll bar.
4092 ruler-mode.el depends on this. */
4094 store_in_alist (alistptr
, Qscroll_bar_height
,
4095 (! FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)
4097 : FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) > 0
4098 ? make_number (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
4099 /* nil means "use default height"
4100 for non-toolkit scroll bar. */
4102 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
4103 MS-Windows it returns a value whose type is HANDLE, which is
4104 actually a pointer. Explicit casting avoids compiler
4106 w
= (uintptr_t) FRAME_X_WINDOW (f
);
4107 store_in_alist (alistptr
, Qwindow_id
,
4108 make_formatted_string (buf
, "%"pMu
, w
));
4109 #ifdef HAVE_X_WINDOWS
4110 #ifdef USE_X_TOOLKIT
4111 /* Tooltip frame may not have this widget. */
4112 if (FRAME_X_OUTPUT (f
)->widget
)
4114 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
4115 store_in_alist (alistptr
, Qouter_window_id
,
4116 make_formatted_string (buf
, "%"pMu
, w
));
4118 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
4119 store_in_alist (alistptr
, Qvisibility
,
4120 (FRAME_VISIBLE_P (f
) ? Qt
4121 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
4122 store_in_alist (alistptr
, Qdisplay
,
4123 XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
));
4125 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_DISPLAY_INFO (f
)->root_window
)
4128 tem
= make_natnum ((uintptr_t) FRAME_X_OUTPUT (f
)->parent_desc
);
4129 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
4130 store_in_alist (alistptr
, Qparent_id
, tem
);
4131 store_in_alist (alistptr
, Qtool_bar_position
, FRAME_TOOL_BAR_POSITION (f
));
4135 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
4136 the previous value of that parameter, NEW_VALUE is the new value. */
4139 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4141 if (NILP (new_value
))
4142 f
->want_fullscreen
= FULLSCREEN_NONE
;
4143 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
4144 f
->want_fullscreen
= FULLSCREEN_BOTH
;
4145 else if (EQ (new_value
, Qfullwidth
))
4146 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
4147 else if (EQ (new_value
, Qfullheight
))
4148 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
4149 else if (EQ (new_value
, Qmaximized
))
4150 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
4152 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
4153 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
4157 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
4158 the previous value of that parameter, NEW_VALUE is the new value. */
4161 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4163 if (NILP (new_value
))
4164 f
->extra_line_spacing
= 0;
4165 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
4166 f
->extra_line_spacing
= XFASTINT (new_value
);
4167 else if (FLOATP (new_value
))
4169 int new_spacing
= XFLOAT_DATA (new_value
) * FRAME_LINE_HEIGHT (f
) + 0.5;
4171 if (new_spacing
>= 0)
4172 f
->extra_line_spacing
= new_spacing
;
4174 signal_error ("Invalid line-spacing", new_value
);
4177 signal_error ("Invalid line-spacing", new_value
);
4178 if (FRAME_VISIBLE_P (f
))
4183 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
4184 the previous value of that parameter, NEW_VALUE is the new value. */
4187 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4189 Lisp_Object bgcolor
;
4191 if (NILP (new_value
))
4193 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
4194 /* The value 0.4545 is the normal viewing gamma. */
4195 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
4197 signal_error ("Invalid screen-gamma", new_value
);
4199 /* Apply the new gamma value to the frame background. */
4200 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
4201 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
4203 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
4204 if (NATNUMP (parm_index
)
4205 && XFASTINT (parm_index
) < ARRAYELTS (frame_parms
)
4206 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
4207 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
4211 clear_face_cache (true); /* FIXME: Why of all frames? */
4217 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4219 Lisp_Object font_object
;
4221 #ifdef HAVE_X_WINDOWS
4222 Lisp_Object font_param
= arg
;
4225 /* Set the frame parameter back to the old value because we may
4226 fail to use ARG as the new parameter value. */
4227 store_frame_param (f
, Qfont
, oldval
);
4229 /* ARG is a fontset name, a font name, a cons of fontset name and a
4230 font object, or a font object. In the last case, this function
4234 fontset
= fs_query_fontset (arg
, 0);
4237 font_object
= font_open_by_name (f
, arg
);
4238 if (NILP (font_object
))
4239 error ("Font `%s' is not defined", SSDATA (arg
));
4240 arg
= AREF (font_object
, FONT_NAME_INDEX
);
4242 else if (fontset
> 0)
4244 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
4245 if (NILP (font_object
))
4246 error ("Font `%s' is not defined", SDATA (arg
));
4247 arg
= AREF (font_object
, FONT_NAME_INDEX
);
4250 error ("The default fontset can't be used for a frame font");
4252 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
4254 /* This is the case that the ASCII font of F's fontset XCAR
4255 (arg) is changed to the font XCDR (arg) by
4256 `set-fontset-font'. */
4257 fontset
= fs_query_fontset (XCAR (arg
), 0);
4259 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
4260 font_object
= XCDR (arg
);
4261 arg
= AREF (font_object
, FONT_NAME_INDEX
);
4262 #ifdef HAVE_X_WINDOWS
4263 font_param
= Ffont_get (font_object
, QCname
);
4266 else if (FONT_OBJECT_P (arg
))
4269 #ifdef HAVE_X_WINDOWS
4270 font_param
= Ffont_get (font_object
, QCname
);
4272 /* This is to store the XLFD font name in the frame parameter for
4273 backward compatibility. We should store the font-object
4274 itself in the future. */
4275 arg
= AREF (font_object
, FONT_NAME_INDEX
);
4276 fontset
= FRAME_FONTSET (f
);
4277 /* Check if we can use the current fontset. If not, set FONTSET
4278 to -1 to generate a new fontset from FONT-OBJECT. */
4281 Lisp_Object ascii_font
= fontset_ascii (fontset
);
4282 Lisp_Object spec
= font_spec_from_name (ascii_font
);
4284 /* SPEC might be nil because ASCII_FONT's name doesn't parse
4285 according to stupid XLFD rules, which, for example,
4286 disallow font names that include a dash followed by a
4287 number. So in those cases we simply request x_new_font
4288 below to generate a new fontset. */
4289 if (NILP (spec
) || ! font_match_p (spec
, font_object
))
4294 signal_error ("Invalid font", arg
);
4296 if (! NILP (Fequal (font_object
, oldval
)))
4299 x_new_font (f
, font_object
, fontset
);
4300 store_frame_param (f
, Qfont
, arg
);
4301 #ifdef HAVE_X_WINDOWS
4302 store_frame_param (f
, Qfont_parameter
, font_param
);
4304 /* Recalculate toolbar height. */
4305 f
->n_tool_bar_rows
= 0;
4307 /* Ensure we redraw it. */
4308 clear_current_matrices (f
);
4310 /* Attempt to hunt down bug#16028. */
4311 SET_FRAME_GARBAGED (f
);
4313 /* This is important if we are called by some Lisp as part of
4314 redisplaying the frame, see redisplay_internal. */
4315 f
->fonts_changed
= true;
4317 recompute_basic_faces (f
);
4319 do_pending_window_change (0);
4321 /* We used to call face-set-after-frame-default here, but it leads to
4322 recursive calls (since that function can set the `default' face's
4323 font which in turns changes the frame's `font' parameter).
4324 Also I don't know what this call is meant to do, but it seems the
4325 wrong way to do it anyway (it does a lot more work than what seems
4326 reasonable in response to a change to `font'). */
4331 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4333 if (! NILP (new_value
)
4334 && !CONSP (new_value
))
4338 CHECK_STRING (new_value
);
4339 p0
= p1
= SSDATA (new_value
);
4343 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
4345 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
4351 while ((c
= *++p1
) && c_isspace (c
));
4355 new_value
= Fnreverse (new_value
);
4358 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
4362 free_all_realized_faces (Qnil
);
4364 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
4365 if (NILP (new_value
))
4367 if (NILP (old_value
))
4368 error ("No font backend available");
4369 font_update_drivers (f
, old_value
);
4370 error ("None of specified font backends are available");
4372 store_frame_param (f
, Qfont_backend
, new_value
);
4378 XSETFRAME (frame
, f
);
4379 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
4381 windows_or_buffers_changed
= 18;
4386 x_set_left_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4388 int unit
= FRAME_COLUMN_WIDTH (f
);
4389 int old_width
= FRAME_LEFT_FRINGE_WIDTH (f
);
4392 new_width
= (RANGED_INTEGERP (-INT_MAX
, new_value
, INT_MAX
)
4393 ? eabs (XINT (new_value
)) : 8);
4395 if (new_width
!= old_width
)
4397 f
->left_fringe_width
= new_width
;
4398 f
->fringe_cols
/* Round up. */
4399 = (new_width
+ FRAME_RIGHT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
4401 if (FRAME_X_WINDOW (f
) != 0)
4402 adjust_frame_size (f
, -1, -1, 3, 0, Qleft_fringe
);
4404 SET_FRAME_GARBAGED (f
);
4410 x_set_right_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4412 int unit
= FRAME_COLUMN_WIDTH (f
);
4413 int old_width
= FRAME_RIGHT_FRINGE_WIDTH (f
);
4416 new_width
= (RANGED_INTEGERP (-INT_MAX
, new_value
, INT_MAX
)
4417 ? eabs (XINT (new_value
)) : 8);
4419 if (new_width
!= old_width
)
4421 f
->right_fringe_width
= new_width
;
4422 f
->fringe_cols
/* Round up. */
4423 = (new_width
+ FRAME_LEFT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
4425 if (FRAME_X_WINDOW (f
) != 0)
4426 adjust_frame_size (f
, -1, -1, 3, 0, Qright_fringe
);
4428 SET_FRAME_GARBAGED (f
);
4434 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4436 CHECK_TYPE_RANGED_INTEGER (int, arg
);
4438 if (XINT (arg
) == f
->border_width
)
4441 if (FRAME_X_WINDOW (f
) != 0)
4442 error ("Cannot change the border width of a frame");
4444 f
->border_width
= XINT (arg
);
4448 x_set_right_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4450 int old
= FRAME_RIGHT_DIVIDER_WIDTH (f
);
4451 CHECK_TYPE_RANGED_INTEGER (int, arg
);
4452 int new = max (0, XINT (arg
));
4455 f
->right_divider_width
= new;
4456 adjust_frame_size (f
, -1, -1, 4, 0, Qright_divider_width
);
4457 adjust_frame_glyphs (f
);
4458 SET_FRAME_GARBAGED (f
);
4463 x_set_bottom_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4465 int old
= FRAME_BOTTOM_DIVIDER_WIDTH (f
);
4466 CHECK_TYPE_RANGED_INTEGER (int, arg
);
4467 int new = max (0, XINT (arg
));
4470 f
->bottom_divider_width
= new;
4471 adjust_frame_size (f
, -1, -1, 4, 0, Qbottom_divider_width
);
4472 adjust_frame_glyphs (f
);
4473 SET_FRAME_GARBAGED (f
);
4478 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
4481 XSETFRAME (frame
, f
);
4484 Fmake_frame_invisible (frame
, Qt
);
4485 else if (EQ (value
, Qicon
))
4486 Ficonify_frame (frame
);
4488 Fmake_frame_visible (frame
);
4492 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4494 f
->auto_raise
= !EQ (Qnil
, arg
);
4498 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4500 f
->auto_lower
= !EQ (Qnil
, arg
);
4504 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4506 f
->no_split
= !NILP (arg
);
4510 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4512 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
4513 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
4514 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
4515 || (!NILP (arg
) && !FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
4517 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
4519 ? vertical_scroll_bar_none
4521 ? vertical_scroll_bar_left
4523 ? vertical_scroll_bar_right
4524 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
4525 ? vertical_scroll_bar_left
4526 : EQ (Qright
, Vdefault_frame_scroll_bars
)
4527 ? vertical_scroll_bar_right
4528 : vertical_scroll_bar_none
);
4530 /* We set this parameter before creating the X window for the
4531 frame, so we can get the geometry right from the start.
4532 However, if the window hasn't been created yet, we shouldn't
4533 call x_set_window_size. */
4534 if (FRAME_X_WINDOW (f
))
4535 adjust_frame_size (f
, -1, -1, 3, 0, Qvertical_scroll_bars
);
4537 SET_FRAME_GARBAGED (f
);
4542 x_set_horizontal_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4544 #if USE_HORIZONTAL_SCROLL_BARS
4545 if ((NILP (arg
) && FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
))
4546 || (!NILP (arg
) && !FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)))
4548 f
->horizontal_scroll_bars
= NILP (arg
) ? false : true;
4550 /* We set this parameter before creating the X window for the
4551 frame, so we can get the geometry right from the start.
4552 However, if the window hasn't been created yet, we shouldn't
4553 call x_set_window_size. */
4554 if (FRAME_X_WINDOW (f
))
4555 adjust_frame_size (f
, -1, -1, 3, 0, Qhorizontal_scroll_bars
);
4557 SET_FRAME_GARBAGED (f
);
4563 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4565 int unit
= FRAME_COLUMN_WIDTH (f
);
4569 x_set_scroll_bar_default_width (f
);
4571 if (FRAME_X_WINDOW (f
))
4572 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_width
);
4574 SET_FRAME_GARBAGED (f
);
4576 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
4577 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
4579 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
4580 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + unit
- 1) / unit
;
4581 if (FRAME_X_WINDOW (f
))
4582 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_width
);
4584 SET_FRAME_GARBAGED (f
);
4587 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
4588 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
4592 x_set_scroll_bar_height (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4594 #if USE_HORIZONTAL_SCROLL_BARS
4595 int unit
= FRAME_LINE_HEIGHT (f
);
4599 x_set_scroll_bar_default_height (f
);
4601 if (FRAME_X_WINDOW (f
))
4602 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_height
);
4604 SET_FRAME_GARBAGED (f
);
4606 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
4607 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
4609 FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) = XFASTINT (arg
);
4610 FRAME_CONFIG_SCROLL_BAR_LINES (f
) = (XFASTINT (arg
) + unit
- 1) / unit
;
4611 if (FRAME_X_WINDOW (f
))
4612 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_height
);
4614 SET_FRAME_GARBAGED (f
);
4617 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.vpos
= 0;
4618 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.y
= 0;
4623 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4630 for (i
= 0; i
< 2; i
++)
4643 else if (FLOATP (item
))
4645 alpha
= XFLOAT_DATA (item
);
4646 if (! (0 <= alpha
&& alpha
<= 1.0))
4647 args_out_of_range (make_float (0.0), make_float (1.0));
4649 else if (INTEGERP (item
))
4651 EMACS_INT ialpha
= XINT (item
);
4652 if (! (0 <= ialpha
&& ialpha
<= 100))
4653 args_out_of_range (make_number (0), make_number (100));
4654 alpha
= ialpha
/ 100.0;
4657 wrong_type_argument (Qnumberp
, item
);
4661 for (i
= 0; i
< 2; i
++)
4662 f
->alpha
[i
] = newval
[i
];
4664 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
4666 x_set_frame_alpha (f
);
4675 * x_set_no_special_glyphs:
4677 * Set frame F's `no-special-glyphs' parameter which, if non-nil,
4678 * suppresses the display of truncation and continuation glyphs
4682 x_set_no_special_glyphs (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4684 if (!EQ (new_value
, old_value
))
4685 FRAME_NO_SPECIAL_GLYPHS (f
) = !NILP (new_value
);
4691 /* Non-zero if mouse is grabbed on DPYINFO
4692 and we know the frame where it is. */
4694 bool x_mouse_grabbed (Display_Info
*dpyinfo
)
4696 return (dpyinfo
->grabbed
4697 && dpyinfo
->last_mouse_frame
4698 && FRAME_LIVE_P (dpyinfo
->last_mouse_frame
));
4701 /* Re-highlight something with mouse-face properties
4702 on DPYINFO using saved frame and mouse position. */
4705 x_redo_mouse_highlight (Display_Info
*dpyinfo
)
4707 if (dpyinfo
->last_mouse_motion_frame
4708 && FRAME_LIVE_P (dpyinfo
->last_mouse_motion_frame
))
4709 note_mouse_highlight (dpyinfo
->last_mouse_motion_frame
,
4710 dpyinfo
->last_mouse_motion_x
,
4711 dpyinfo
->last_mouse_motion_y
);
4714 #endif /* HAVE_NS */
4716 /* Subroutines of creating an X frame. */
4718 /* Make sure that Vx_resource_name is set to a reasonable value.
4719 Fix it up, or set it to `emacs' if it is too hopeless. */
4722 validate_x_resource_name (void)
4725 /* Number of valid characters in the resource name. */
4726 ptrdiff_t good_count
= 0;
4727 /* Number of invalid characters in the resource name. */
4728 ptrdiff_t bad_count
= 0;
4732 if (!STRINGP (Vx_resource_class
))
4733 Vx_resource_class
= build_string (EMACS_CLASS
);
4735 if (STRINGP (Vx_resource_name
))
4737 unsigned char *p
= SDATA (Vx_resource_name
);
4739 len
= SBYTES (Vx_resource_name
);
4741 /* Only letters, digits, - and _ are valid in resource names.
4742 Count the valid characters and count the invalid ones. */
4743 for (i
= 0; i
< len
; i
++)
4746 if (! ((c
>= 'a' && c
<= 'z')
4747 || (c
>= 'A' && c
<= 'Z')
4748 || (c
>= '0' && c
<= '9')
4749 || c
== '-' || c
== '_'))
4756 /* Not a string => completely invalid. */
4757 bad_count
= 5, good_count
= 0;
4759 /* If name is valid already, return. */
4763 /* If name is entirely invalid, or nearly so, or is so implausibly
4764 large that alloca might not work, use `emacs'. */
4765 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
4767 Vx_resource_name
= build_string ("emacs");
4771 /* Name is partly valid. Copy it and replace the invalid characters
4772 with underscores. */
4774 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
4776 for (i
= 0; i
< len
; i
++)
4778 int c
= SREF (new, i
);
4779 if (! ((c
>= 'a' && c
<= 'z')
4780 || (c
>= 'A' && c
<= 'Z')
4781 || (c
>= '0' && c
<= '9')
4782 || c
== '-' || c
== '_'))
4787 /* Get specified attribute from resource database RDB.
4788 See Fx_get_resource below for other parameters. */
4791 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
4793 CHECK_STRING (attribute
);
4794 CHECK_STRING (class);
4796 if (!NILP (component
))
4797 CHECK_STRING (component
);
4798 if (!NILP (subclass
))
4799 CHECK_STRING (subclass
);
4800 if (NILP (component
) != NILP (subclass
))
4801 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
4803 validate_x_resource_name ();
4805 /* Allocate space for the components, the dots which separate them,
4806 and the final '\0'. Make them big enough for the worst case. */
4807 ptrdiff_t name_keysize
= (SBYTES (Vx_resource_name
)
4808 + (STRINGP (component
)
4809 ? SBYTES (component
) : 0)
4810 + SBYTES (attribute
)
4813 ptrdiff_t class_keysize
= (SBYTES (Vx_resource_class
)
4815 + (STRINGP (subclass
)
4816 ? SBYTES (subclass
) : 0)
4819 char *name_key
= SAFE_ALLOCA (name_keysize
+ class_keysize
);
4820 char *class_key
= name_key
+ name_keysize
;
4821 name_key
= ptr_bounds_clip (name_key
, name_keysize
);
4822 class_key
= ptr_bounds_clip (class_key
, class_keysize
);
4824 /* Start with emacs.FRAMENAME for the name (the specific one)
4825 and with `Emacs' for the class key (the general one). */
4826 char *nz
= lispstpcpy (name_key
, Vx_resource_name
);
4827 char *cz
= lispstpcpy (class_key
, Vx_resource_class
);
4830 cz
= lispstpcpy (cz
, class);
4832 if (!NILP (component
))
4835 lispstpcpy (cz
, subclass
);
4838 nz
= lispstpcpy (nz
, component
);
4842 lispstpcpy (nz
, attribute
);
4844 char *value
= x_get_string_resource (rdb
, name_key
, class_key
);
4847 if (value
&& *value
)
4848 return build_string (value
);
4854 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
4855 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
4856 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
4857 class, where INSTANCE is the name under which Emacs was invoked, or
4858 the name specified by the `-name' or `-rn' command-line arguments.
4860 The optional arguments COMPONENT and SUBCLASS add to the key and the
4861 class, respectively. You must specify both of them or neither.
4862 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
4863 and the class is `Emacs.CLASS.SUBCLASS'. */)
4864 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
,
4865 Lisp_Object subclass
)
4867 check_window_system (NULL
);
4869 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
4870 attribute
, class, component
, subclass
);
4873 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
4876 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
,
4877 Lisp_Object
class, Lisp_Object component
,
4878 Lisp_Object subclass
)
4880 return xrdb_get_resource (dpyinfo
->xrdb
,
4881 attribute
, class, component
, subclass
);
4884 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT && !defined USE_GTK
4885 /* Used when C code wants a resource value. */
4886 /* Called from oldXMenu/Create.c. */
4888 x_get_resource_string (const char *attribute
, const char *class)
4891 struct frame
*sf
= SELECTED_FRAME ();
4892 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
4895 /* Allocate space for the components, the dots which separate them,
4896 and the final '\0'. */
4897 ptrdiff_t name_keysize
= invocation_namelen
+ strlen (attribute
) + 2;
4898 ptrdiff_t class_keysize
= sizeof (EMACS_CLASS
) - 1 + strlen (class) + 2;
4899 char *name_key
= SAFE_ALLOCA (name_keysize
+ class_keysize
);
4900 char *class_key
= name_key
+ name_keysize
;
4901 name_key
= ptr_bounds_clip (name_key
, name_keysize
);
4902 class_key
= ptr_bounds_clip (class_key
, class_keysize
);
4904 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
4905 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
4907 result
= x_get_string_resource (FRAME_DISPLAY_INFO (sf
)->xrdb
,
4908 name_key
, class_key
);
4914 /* Return the value of parameter PARAM.
4916 First search ALIST, then Vdefault_frame_alist, then the X defaults
4917 database, using ATTRIBUTE as the attribute name and CLASS as its class.
4919 Convert the resource to the type specified by desired_type.
4921 If no default is specified, return Qunbound. If you call
4922 x_get_arg, make sure you deal with Qunbound in a reasonable way,
4923 and don't let it get stored in any Lisp-visible variables! */
4926 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
4927 const char *attribute
, const char *class, enum resource_types type
)
4931 tem
= Fassq (param
, alist
);
4935 /* If we find this parm in ALIST, clear it out
4936 so that it won't be "left over" at the end. */
4938 XSETCAR (tem
, Qnil
);
4939 /* In case the parameter appears more than once in the alist,
4941 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
4942 if (CONSP (XCAR (tail
))
4943 && EQ (XCAR (XCAR (tail
)), param
))
4944 XSETCAR (XCAR (tail
), Qnil
);
4947 tem
= Fassq (param
, Vdefault_frame_alist
);
4949 /* If it wasn't specified in ALIST or the Lisp-level defaults,
4950 look in the X resources. */
4953 if (attribute
&& dpyinfo
)
4955 AUTO_STRING (at
, attribute
);
4956 AUTO_STRING (cl
, class);
4957 tem
= display_x_get_resource (dpyinfo
, at
, cl
, Qnil
, Qnil
);
4964 case RES_TYPE_NUMBER
:
4965 return make_number (atoi (SSDATA (tem
)));
4967 case RES_TYPE_BOOLEAN_NUMBER
:
4968 if (!strcmp (SSDATA (tem
), "on")
4969 || !strcmp (SSDATA (tem
), "true"))
4970 return make_number (1);
4971 return make_number (atoi (SSDATA (tem
)));
4974 case RES_TYPE_FLOAT
:
4975 return make_float (atof (SSDATA (tem
)));
4977 case RES_TYPE_BOOLEAN
:
4978 tem
= Fdowncase (tem
);
4979 if (!strcmp (SSDATA (tem
), "on")
4981 || !strcmp (SSDATA (tem
), "yes")
4983 || !strcmp (SSDATA (tem
), "true"))
4988 case RES_TYPE_STRING
:
4991 case RES_TYPE_SYMBOL
:
4992 /* As a special case, we map the values `true' and `on'
4993 to Qt, and `false' and `off' to Qnil. */
4996 lower
= Fdowncase (tem
);
4997 if (!strcmp (SSDATA (lower
), "on")
4999 || !strcmp (SSDATA (lower
), "yes")
5001 || !strcmp (SSDATA (lower
), "true"))
5003 else if (!strcmp (SSDATA (lower
), "off")
5005 || !strcmp (SSDATA (lower
), "no")
5007 || !strcmp (SSDATA (lower
), "false"))
5010 return Fintern (tem
, Qnil
);
5024 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
5025 const char *attribute
, const char *class,
5026 enum resource_types type
)
5028 return x_get_arg (FRAME_DISPLAY_INFO (f
),
5029 alist
, param
, attribute
, class, type
);
5032 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
5035 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
5037 const char *attribute
, const char *class,
5038 enum resource_types type
)
5042 value
= x_get_arg (FRAME_DISPLAY_INFO (f
), alist
, param
,
5043 attribute
, class, type
);
5044 if (! NILP (value
) && ! EQ (value
, Qunbound
))
5045 store_frame_param (f
, param
, value
);
5051 /* Record in frame F the specified or default value according to ALIST
5052 of the parameter named PROP (a Lisp symbol).
5053 If no value is specified for PROP, look for an X default for XPROP
5054 on the frame named NAME.
5055 If that is not found either, use the value DEFLT. */
5058 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
5059 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
5060 enum resource_types type
)
5064 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
5065 if (EQ (tem
, Qunbound
))
5067 AUTO_FRAME_ARG (arg
, prop
, tem
);
5068 x_set_frame_parameters (f
, arg
);
5073 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
5076 * XParseGeometry parses strings of the form
5077 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
5078 * width, height, xoffset, and yoffset are unsigned integers.
5079 * Example: "=80x24+300-49"
5080 * The equal sign is optional.
5081 * It returns a bitmask that indicates which of the four values
5082 * were actually found in the string. For each value found,
5083 * the corresponding argument is updated; for each value
5084 * not found, the corresponding argument is left unchanged.
5088 XParseGeometry (char *string
,
5090 unsigned int *width
, unsigned int *height
)
5094 unsigned long tempWidth UNINIT
, tempHeight UNINIT
;
5095 long int tempX UNINIT
, tempY UNINIT
;
5096 char *nextCharacter
;
5098 if (string
== NULL
|| *string
== '\0')
5101 string
++; /* ignore possible '=' at beg of geometry spec */
5104 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
5106 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
5107 if (strind
== nextCharacter
)
5109 strind
= nextCharacter
;
5113 if (*strind
== 'x' || *strind
== 'X')
5116 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
5117 if (strind
== nextCharacter
)
5119 strind
= nextCharacter
;
5120 mask
|= HeightValue
;
5123 if (*strind
== '+' || *strind
== '-')
5127 tempX
= strtol (strind
, &nextCharacter
, 10);
5128 if (strind
== nextCharacter
)
5130 strind
= nextCharacter
;
5132 if (*strind
== '+' || *strind
== '-')
5136 tempY
= strtol (strind
, &nextCharacter
, 10);
5137 if (strind
== nextCharacter
)
5139 strind
= nextCharacter
;
5144 /* If strind isn't at the end of the string then it's an invalid
5145 geometry specification. */
5147 if (*strind
!= '\0')
5151 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
5153 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
5154 if (mask
& WidthValue
)
5155 *width
= min (tempWidth
, UINT_MAX
);
5156 if (mask
& HeightValue
)
5157 *height
= min (tempHeight
, UINT_MAX
);
5161 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
5164 /* NS used to define x-parse-geometry in ns-win.el, but that confused
5165 make-docfile: the documentation string in ns-win.el was used for
5166 x-parse-geometry even in non-NS builds.
5168 With two definitions of x-parse-geometry in this file, various
5169 things still get confused (eg M-x apropos documentation), so that
5170 it is best if the two definitions just share the same doc-string.
5172 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
5173 doc
: /* Parse a display geometry string STRING.
5174 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
5175 The properties returned may include `top', `left', `height', and `width'.
5176 For X, the value of `left' or `top' may be an integer,
5177 or a list (+ N) meaning N pixels relative to top/left corner,
5178 or a list (- N) meaning -N pixels relative to bottom/right corner.
5179 On Nextstep, this just calls `ns-parse-geometry'. */)
5180 (Lisp_Object string
)
5183 unsigned int width
, height
;
5186 CHECK_STRING (string
);
5189 if (strchr (SSDATA (string
), ' ') != NULL
)
5190 return call1 (Qns_parse_geometry
, string
);
5192 geometry
= XParseGeometry (SSDATA (string
),
5193 &x
, &y
, &width
, &height
);
5195 if (geometry
& XValue
)
5197 Lisp_Object element
;
5199 if (x
>= 0 && (geometry
& XNegative
))
5200 element
= list3 (Qleft
, Qminus
, make_number (-x
));
5201 else if (x
< 0 && ! (geometry
& XNegative
))
5202 element
= list3 (Qleft
, Qplus
, make_number (x
));
5204 element
= Fcons (Qleft
, make_number (x
));
5205 result
= Fcons (element
, result
);
5208 if (geometry
& YValue
)
5210 Lisp_Object element
;
5212 if (y
>= 0 && (geometry
& YNegative
))
5213 element
= list3 (Qtop
, Qminus
, make_number (-y
));
5214 else if (y
< 0 && ! (geometry
& YNegative
))
5215 element
= list3 (Qtop
, Qplus
, make_number (y
));
5217 element
= Fcons (Qtop
, make_number (y
));
5218 result
= Fcons (element
, result
);
5221 if (geometry
& WidthValue
)
5222 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
5223 if (geometry
& HeightValue
)
5224 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
5230 /* Calculate the desired size and position of frame F.
5231 Return the flags saying which aspects were specified.
5233 Also set the win_gravity and size_hint_flags of F.
5235 Adjust height for toolbar if TOOLBAR_P is 1.
5237 This function does not make the coordinates positive. */
5239 #define DEFAULT_ROWS 36
5240 #define DEFAULT_COLS 80
5243 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, bool toolbar_p
, int *x_width
, int *x_height
)
5245 Lisp_Object height
, width
, user_size
, top
, left
, user_position
;
5246 long window_prompting
= 0;
5247 Display_Info
*dpyinfo
= FRAME_DISPLAY_INFO (f
);
5248 int parent_done
= -1, outer_done
= -1;
5250 /* Default values if we fall through.
5251 Actually, if that happens we should get
5252 window manager prompting. */
5253 SET_FRAME_WIDTH (f
, DEFAULT_COLS
* FRAME_COLUMN_WIDTH (f
));
5254 SET_FRAME_COLS (f
, DEFAULT_COLS
);
5255 SET_FRAME_HEIGHT (f
, DEFAULT_ROWS
* FRAME_LINE_HEIGHT (f
));
5256 SET_FRAME_LINES (f
, DEFAULT_ROWS
);
5258 /* Window managers expect that if program-specified
5259 positions are not (0,0), they're intentional, not defaults. */
5263 /* Calculate a tool bar height so that the user gets a text display
5264 area of the size he specified with -g or via .Xdefaults. Later
5265 changes of the tool bar height don't change the frame size. This
5266 is done so that users can create tall Emacs frames without having
5267 to guess how tall the tool bar will get. */
5268 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
5270 if (frame_default_tool_bar_height
)
5271 FRAME_TOOL_BAR_HEIGHT (f
) = frame_default_tool_bar_height
;
5276 relief
= (tool_bar_button_relief
>= 0
5277 ? tool_bar_button_relief
5278 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
5280 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
5281 margin
= XFASTINT (Vtool_bar_button_margin
);
5282 else if (CONSP (Vtool_bar_button_margin
)
5283 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
5284 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
5288 FRAME_TOOL_BAR_HEIGHT (f
)
5289 = DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
5293 /* Ensure that earlier new_width and new_height settings won't
5294 override what we specify below. */
5295 f
->new_width
= f
->new_height
= 0;
5297 height
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
5298 width
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
5299 if (!EQ (width
, Qunbound
) || !EQ (height
, Qunbound
))
5301 if (!EQ (width
, Qunbound
))
5303 if (CONSP (width
) && EQ (XCAR (width
), Qtext_pixels
))
5305 CHECK_NUMBER (XCDR (width
));
5306 if ((XINT (XCDR (width
)) < 0 || XINT (XCDR (width
)) > INT_MAX
))
5307 xsignal1 (Qargs_out_of_range
, XCDR (width
));
5309 SET_FRAME_WIDTH (f
, XINT (XCDR (width
)));
5310 f
->inhibit_horizontal_resize
= true;
5311 *x_width
= XINT (XCDR (width
));
5313 else if (FLOATP (width
))
5315 double d_width
= XFLOAT_DATA (width
);
5317 if (d_width
< 0.0 || d_width
> 1.0)
5318 xsignal1 (Qargs_out_of_range
, width
);
5321 int new_width
= frame_float (f
, width
, FRAME_FLOAT_WIDTH
,
5322 &parent_done
, &outer_done
, -1);
5325 SET_FRAME_WIDTH (f
, new_width
);
5330 CHECK_NUMBER (width
);
5331 if ((XINT (width
) < 0 || XINT (width
) > INT_MAX
))
5332 xsignal1 (Qargs_out_of_range
, width
);
5334 SET_FRAME_WIDTH (f
, XINT (width
) * FRAME_COLUMN_WIDTH (f
));
5338 if (!EQ (height
, Qunbound
))
5340 if (CONSP (height
) && EQ (XCAR (height
), Qtext_pixels
))
5342 CHECK_NUMBER (XCDR (height
));
5343 if ((XINT (XCDR (height
)) < 0 || XINT (XCDR (height
)) > INT_MAX
))
5344 xsignal1 (Qargs_out_of_range
, XCDR (height
));
5346 SET_FRAME_HEIGHT (f
, XINT (XCDR (height
)));
5347 f
->inhibit_vertical_resize
= true;
5348 *x_height
= XINT (XCDR (height
));
5350 else if (FLOATP (height
))
5352 double d_height
= XFLOAT_DATA (height
);
5354 if (d_height
< 0.0 || d_height
> 1.0)
5355 xsignal1 (Qargs_out_of_range
, height
);
5358 int new_height
= frame_float (f
, height
, FRAME_FLOAT_HEIGHT
,
5359 &parent_done
, &outer_done
, -1);
5361 if (new_height
> -1)
5362 SET_FRAME_HEIGHT (f
, new_height
);
5367 CHECK_NUMBER (height
);
5368 if ((XINT (height
) < 0) || (XINT (height
) > INT_MAX
))
5369 xsignal1 (Qargs_out_of_range
, height
);
5371 SET_FRAME_HEIGHT (f
, XINT (height
) * FRAME_LINE_HEIGHT (f
));
5375 user_size
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
5376 if (!NILP (user_size
) && !EQ (user_size
, Qunbound
))
5377 window_prompting
|= USSize
;
5379 window_prompting
|= PSize
;
5382 top
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
5383 left
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
5384 user_position
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
5385 if (! EQ (top
, Qunbound
) || ! EQ (left
, Qunbound
))
5387 if (EQ (top
, Qminus
))
5390 window_prompting
|= YNegative
;
5392 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
5393 && CONSP (XCDR (top
))
5394 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
5396 f
->top_pos
= - XINT (XCAR (XCDR (top
)));
5397 window_prompting
|= YNegative
;
5399 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
5400 && CONSP (XCDR (top
))
5401 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
5403 f
->top_pos
= XINT (XCAR (XCDR (top
)));
5405 else if (FLOATP (top
))
5406 f
->top_pos
= frame_float (f
, top
, FRAME_FLOAT_TOP
, &parent_done
,
5408 else if (EQ (top
, Qunbound
))
5412 CHECK_TYPE_RANGED_INTEGER (int, top
);
5413 f
->top_pos
= XINT (top
);
5415 window_prompting
|= YNegative
;
5418 if (EQ (left
, Qminus
))
5421 window_prompting
|= XNegative
;
5423 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
5424 && CONSP (XCDR (left
))
5425 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
5427 f
->left_pos
= - XINT (XCAR (XCDR (left
)));
5428 window_prompting
|= XNegative
;
5430 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
5431 && CONSP (XCDR (left
))
5432 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
5434 f
->left_pos
= XINT (XCAR (XCDR (left
)));
5436 else if (FLOATP (left
))
5437 f
->left_pos
= frame_float (f
, left
, FRAME_FLOAT_LEFT
, &parent_done
,
5439 else if (EQ (left
, Qunbound
))
5443 CHECK_TYPE_RANGED_INTEGER (int, left
);
5444 f
->left_pos
= XINT (left
);
5445 if (f
->left_pos
< 0)
5446 window_prompting
|= XNegative
;
5449 if (!NILP (user_position
) && ! EQ (user_position
, Qunbound
))
5450 window_prompting
|= USPosition
;
5452 window_prompting
|= PPosition
;
5455 if (window_prompting
& XNegative
)
5457 if (window_prompting
& YNegative
)
5458 f
->win_gravity
= SouthEastGravity
;
5460 f
->win_gravity
= NorthEastGravity
;
5464 if (window_prompting
& YNegative
)
5465 f
->win_gravity
= SouthWestGravity
;
5467 f
->win_gravity
= NorthWestGravity
;
5470 f
->size_hint_flags
= window_prompting
;
5472 return window_prompting
;
5477 #endif /* HAVE_WINDOW_SYSTEM */
5480 frame_make_pointer_invisible (struct frame
*f
)
5482 if (! NILP (Vmake_pointer_invisible
))
5484 if (f
&& FRAME_LIVE_P (f
) && !f
->pointer_invisible
5485 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
5488 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
5489 f
->pointer_invisible
= 1;
5495 frame_make_pointer_visible (struct frame
*f
)
5497 /* We don't check Vmake_pointer_invisible here in case the
5498 pointer was invisible when Vmake_pointer_invisible was set to nil. */
5499 if (f
&& FRAME_LIVE_P (f
) && f
->pointer_invisible
&& f
->mouse_moved
5500 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
5502 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
5503 f
->pointer_invisible
= 0;
5507 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
5508 Sframe_pointer_visible_p
, 0, 1, 0,
5509 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
5510 Otherwise it returns nil. FRAME omitted or nil means the
5511 selected frame. This is useful when `make-pointer-invisible' is set. */)
5514 return decode_any_frame (frame
)->pointer_invisible
? Qnil
: Qt
;
5519 /***********************************************************************
5521 ***********************************************************************/
5523 #ifdef HAVE_WINDOW_SYSTEM
5525 # if (defined HAVE_NS \
5526 || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR)))
5528 free_monitors (struct MonitorInfo
*monitors
, int n_monitors
)
5531 for (i
= 0; i
< n_monitors
; ++i
)
5532 xfree (monitors
[i
].name
);
5538 make_monitor_attribute_list (struct MonitorInfo
*monitors
,
5540 int primary_monitor
,
5541 Lisp_Object monitor_frames
,
5544 Lisp_Object attributes_list
= Qnil
;
5545 Lisp_Object primary_monitor_attributes
= Qnil
;
5548 for (i
= 0; i
< n_monitors
; ++i
)
5550 Lisp_Object geometry
, workarea
, attributes
= Qnil
;
5551 struct MonitorInfo
*mi
= &monitors
[i
];
5553 if (mi
->geom
.width
== 0) continue;
5555 workarea
= list4i (mi
->work
.x
, mi
->work
.y
,
5556 mi
->work
.width
, mi
->work
.height
);
5557 geometry
= list4i (mi
->geom
.x
, mi
->geom
.y
,
5558 mi
->geom
.width
, mi
->geom
.height
);
5559 attributes
= Fcons (Fcons (Qsource
, build_string (source
)),
5561 attributes
= Fcons (Fcons (Qframes
, AREF (monitor_frames
, i
)),
5563 attributes
= Fcons (Fcons (Qmm_size
,
5564 list2i (mi
->mm_width
, mi
->mm_height
)),
5566 attributes
= Fcons (Fcons (Qworkarea
, workarea
), attributes
);
5567 attributes
= Fcons (Fcons (Qgeometry
, geometry
), attributes
);
5569 attributes
= Fcons (Fcons (Qname
, make_string (mi
->name
,
5570 strlen (mi
->name
))),
5573 if (i
== primary_monitor
)
5574 primary_monitor_attributes
= attributes
;
5576 attributes_list
= Fcons (attributes
, attributes_list
);
5579 if (!NILP (primary_monitor_attributes
))
5580 attributes_list
= Fcons (primary_monitor_attributes
, attributes_list
);
5581 return attributes_list
;
5584 #endif /* HAVE_WINDOW_SYSTEM */
5587 /***********************************************************************
5589 ***********************************************************************/
5592 syms_of_frame (void)
5594 DEFSYM (Qframep
, "framep");
5595 DEFSYM (Qframe_live_p
, "frame-live-p");
5596 DEFSYM (Qframe_windows_min_size
, "frame-windows-min-size");
5597 DEFSYM (Qdisplay_monitor_attributes_list
, "display-monitor-attributes-list");
5598 DEFSYM (Qwindow__pixel_to_total
, "window--pixel-to-total");
5599 DEFSYM (Qexplicit_name
, "explicit-name");
5600 DEFSYM (Qheight
, "height");
5601 DEFSYM (Qicon
, "icon");
5602 DEFSYM (Qminibuffer
, "minibuffer");
5603 DEFSYM (Qundecorated
, "undecorated");
5604 DEFSYM (Qno_special_glyphs
, "no-special-glyphs");
5605 DEFSYM (Qparent_frame
, "parent-frame");
5606 DEFSYM (Qskip_taskbar
, "skip-taskbar");
5607 DEFSYM (Qno_focus_on_map
, "no-focus-on-map");
5608 DEFSYM (Qno_accept_focus
, "no-accept-focus");
5609 DEFSYM (Qz_group
, "z-group");
5610 DEFSYM (Qoverride_redirect
, "override-redirect");
5611 DEFSYM (Qdelete_before
, "delete-before");
5612 DEFSYM (Qmodeline
, "modeline");
5613 DEFSYM (Qonly
, "only");
5614 DEFSYM (Qnone
, "none");
5615 DEFSYM (Qwidth
, "width");
5616 DEFSYM (Qtext_pixels
, "text-pixels");
5617 DEFSYM (Qgeometry
, "geometry");
5618 DEFSYM (Qicon_left
, "icon-left");
5619 DEFSYM (Qicon_top
, "icon-top");
5620 DEFSYM (Qtooltip
, "tooltip");
5621 DEFSYM (Quser_position
, "user-position");
5622 DEFSYM (Quser_size
, "user-size");
5623 DEFSYM (Qwindow_id
, "window-id");
5624 #ifdef HAVE_X_WINDOWS
5625 DEFSYM (Qouter_window_id
, "outer-window-id");
5627 DEFSYM (Qparent_id
, "parent-id");
5629 DEFSYM (Qw32
, "w32");
5632 DEFSYM (Qvisible
, "visible");
5633 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
5634 DEFSYM (Qbuffer_list
, "buffer-list");
5635 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
5636 DEFSYM (Qdisplay_type
, "display-type");
5637 DEFSYM (Qbackground_mode
, "background-mode");
5638 DEFSYM (Qnoelisp
, "noelisp");
5639 DEFSYM (Qtty_color_mode
, "tty-color-mode");
5640 DEFSYM (Qtty
, "tty");
5641 DEFSYM (Qtty_type
, "tty-type");
5643 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
5645 DEFSYM (Qfullwidth
, "fullwidth");
5646 DEFSYM (Qfullheight
, "fullheight");
5647 DEFSYM (Qfullboth
, "fullboth");
5648 DEFSYM (Qmaximized
, "maximized");
5649 DEFSYM (Qx_resource_name
, "x-resource-name");
5650 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
5652 DEFSYM (Qworkarea
, "workarea");
5653 DEFSYM (Qmm_size
, "mm-size");
5654 DEFSYM (Qframes
, "frames");
5655 DEFSYM (Qsource
, "source");
5657 DEFSYM (Qframe_edges
, "frame-edges");
5658 DEFSYM (Qouter_edges
, "outer-edges");
5659 DEFSYM (Qouter_position
, "outer-position");
5660 DEFSYM (Qouter_size
, "outer-size");
5661 DEFSYM (Qnative_edges
, "native-edges");
5662 DEFSYM (Qinner_edges
, "inner-edges");
5663 DEFSYM (Qexternal_border_size
, "external-border-size");
5664 DEFSYM (Qtitle_bar_size
, "title-bar-size");
5665 DEFSYM (Qmenu_bar_external
, "menu-bar-external");
5666 DEFSYM (Qmenu_bar_size
, "menu-bar-size");
5667 DEFSYM (Qtool_bar_external
, "tool-bar-external");
5668 DEFSYM (Qtool_bar_size
, "tool-bar-size");
5669 /* The following are used for frame_size_history. */
5670 DEFSYM (Qadjust_frame_size_1
, "adjust-frame-size-1");
5671 DEFSYM (Qadjust_frame_size_2
, "adjust-frame-size-2");
5672 DEFSYM (Qadjust_frame_size_3
, "adjust-frame-size-3");
5673 DEFSYM (Qx_set_frame_parameters
, "x-set-frame-parameters");
5674 DEFSYM (QEmacsFrameResize
, "EmacsFrameResize");
5675 DEFSYM (Qset_frame_size
, "set-frame-size");
5676 DEFSYM (Qframe_inhibit_resize
, "frame-inhibit-resize");
5677 DEFSYM (Qx_set_fullscreen
, "x-set-fullscreen");
5678 DEFSYM (Qx_check_fullscreen
, "x-check-fullscreen");
5679 DEFSYM (Qxg_frame_resized
, "xg-frame-resized");
5680 DEFSYM (Qxg_frame_set_char_size_1
, "xg-frame-set-char-size-1");
5681 DEFSYM (Qxg_frame_set_char_size_2
, "xg-frame-set-char-size-2");
5682 DEFSYM (Qxg_frame_set_char_size_3
, "xg-frame-set-char-size-3");
5683 DEFSYM (Qx_set_window_size_1
, "x-set-window-size-1");
5684 DEFSYM (Qx_set_window_size_2
, "x-set-window-size-2");
5685 DEFSYM (Qx_set_window_size_3
, "x-set-window-size-3");
5686 DEFSYM (Qxg_change_toolbar_position
, "xg-change-toolbar-position");
5687 DEFSYM (Qx_net_wm_state
, "x-net-wm-state");
5688 DEFSYM (Qx_handle_net_wm_state
, "x-handle-net-wm-state");
5689 DEFSYM (Qtb_size_cb
, "tb-size-cb");
5690 DEFSYM (Qupdate_frame_tool_bar
, "update-frame-tool-bar");
5691 DEFSYM (Qfree_frame_tool_bar
, "free-frame-tool-bar");
5692 DEFSYM (Qx_set_menu_bar_lines
, "x-set-menu-bar-lines");
5693 DEFSYM (Qchange_frame_size
, "change-frame-size");
5694 DEFSYM (Qxg_frame_set_char_size
, "xg-frame-set-char-size");
5695 DEFSYM (Qset_window_configuration
, "set-window-configuration");
5696 DEFSYM (Qx_create_frame_1
, "x-create-frame-1");
5697 DEFSYM (Qx_create_frame_2
, "x-create-frame-2");
5698 DEFSYM (Qterminal_frame
, "terminal-frame");
5701 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
5703 #ifdef NS_IMPL_COCOA
5704 DEFSYM (Qns_appearance
, "ns-appearance");
5705 DEFSYM (Qns_transparent_titlebar
, "ns-transparent-titlebar");
5708 DEFSYM (Qalpha
, "alpha");
5709 DEFSYM (Qauto_lower
, "auto-lower");
5710 DEFSYM (Qauto_raise
, "auto-raise");
5711 DEFSYM (Qborder_color
, "border-color");
5712 DEFSYM (Qborder_width
, "border-width");
5713 DEFSYM (Qouter_border_width
, "outer-border-width");
5714 DEFSYM (Qbottom_divider_width
, "bottom-divider-width");
5715 DEFSYM (Qcursor_color
, "cursor-color");
5716 DEFSYM (Qcursor_type
, "cursor-type");
5717 DEFSYM (Qfont_backend
, "font-backend");
5718 DEFSYM (Qfullscreen
, "fullscreen");
5719 DEFSYM (Qhorizontal_scroll_bars
, "horizontal-scroll-bars");
5720 DEFSYM (Qicon_name
, "icon-name");
5721 DEFSYM (Qicon_type
, "icon-type");
5722 DEFSYM (Qinternal_border_width
, "internal-border-width");
5723 DEFSYM (Qleft_fringe
, "left-fringe");
5724 DEFSYM (Qline_spacing
, "line-spacing");
5725 DEFSYM (Qmenu_bar_lines
, "menu-bar-lines");
5726 DEFSYM (Qupdate_frame_menubar
, "update-frame-menubar");
5727 DEFSYM (Qfree_frame_menubar_1
, "free-frame-menubar-1");
5728 DEFSYM (Qfree_frame_menubar_2
, "free-frame-menubar-2");
5729 DEFSYM (Qmouse_color
, "mouse-color");
5730 DEFSYM (Qname
, "name");
5731 DEFSYM (Qright_divider_width
, "right-divider-width");
5732 DEFSYM (Qright_fringe
, "right-fringe");
5733 DEFSYM (Qscreen_gamma
, "screen-gamma");
5734 DEFSYM (Qscroll_bar_background
, "scroll-bar-background");
5735 DEFSYM (Qscroll_bar_foreground
, "scroll-bar-foreground");
5736 DEFSYM (Qscroll_bar_height
, "scroll-bar-height");
5737 DEFSYM (Qscroll_bar_width
, "scroll-bar-width");
5738 DEFSYM (Qsticky
, "sticky");
5739 DEFSYM (Qtitle
, "title");
5740 DEFSYM (Qtool_bar_lines
, "tool-bar-lines");
5741 DEFSYM (Qtool_bar_position
, "tool-bar-position");
5742 DEFSYM (Qunsplittable
, "unsplittable");
5743 DEFSYM (Qvertical_scroll_bars
, "vertical-scroll-bars");
5744 DEFSYM (Qvisibility
, "visibility");
5745 DEFSYM (Qwait_for_wm
, "wait-for-wm");
5746 DEFSYM (Qinhibit_double_buffering
, "inhibit-double-buffering");
5747 DEFSYM (Qno_other_frame
, "no-other-frame");
5748 DEFSYM (Qbelow
, "below");
5749 DEFSYM (Qabove_suspended
, "above-suspended");
5750 DEFSYM (Qmin_width
, "min-width");
5751 DEFSYM (Qmin_height
, "min-height");
5752 DEFSYM (Qmouse_wheel_frame
, "mouse-wheel-frame");
5753 DEFSYM (Qkeep_ratio
, "keep-ratio");
5754 DEFSYM (Qwidth_only
, "width-only");
5755 DEFSYM (Qheight_only
, "height-only");
5756 DEFSYM (Qleft_only
, "left-only");
5757 DEFSYM (Qtop_only
, "top-only");
5758 DEFSYM (Qiconify_top_level
, "iconify-top-level");
5759 DEFSYM (Qmake_invisible
, "make-invisible");
5764 for (i
= 0; i
< ARRAYELTS (frame_parms
); i
++)
5766 Lisp_Object v
= (frame_parms
[i
].sym
< 0
5767 ? intern_c_string (frame_parms
[i
].name
)
5768 : builtin_lisp_symbol (frame_parms
[i
].sym
));
5769 Fput (v
, Qx_frame_parameter
, make_number (i
));
5773 #ifdef HAVE_WINDOW_SYSTEM
5774 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
5775 doc
: /* The name Emacs uses to look up X resources.
5776 `x-get-resource' uses this as the first component of the instance name
5777 when requesting resource values.
5778 Emacs initially sets `x-resource-name' to the name under which Emacs
5779 was invoked, or to the value specified with the `-name' or `-rn'
5780 switches, if present.
5782 It may be useful to bind this variable locally around a call
5783 to `x-get-resource'. See also the variable `x-resource-class'. */);
5784 Vx_resource_name
= Qnil
;
5786 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
5787 doc
: /* The class Emacs uses to look up X resources.
5788 `x-get-resource' uses this as the first component of the instance class
5789 when requesting resource values.
5791 Emacs initially sets `x-resource-class' to "Emacs".
5793 Setting this variable permanently is not a reasonable thing to do,
5794 but binding this variable locally around a call to `x-get-resource'
5795 is a reasonable practice. See also the variable `x-resource-name'. */);
5796 Vx_resource_class
= build_string (EMACS_CLASS
);
5798 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
5799 doc
: /* The lower limit of the frame opacity (alpha transparency).
5800 The value should range from 0 (invisible) to 100 (completely opaque).
5801 You can also use a floating number between 0.0 and 1.0. */);
5802 Vframe_alpha_lower_limit
= make_number (20);
5805 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
5806 doc
: /* Alist of default values for frame creation.
5807 These may be set in your init file, like this:
5808 (setq default-frame-alist \\='((width . 80) (height . 55) (menu-bar-lines . 1)))
5809 These override values given in window system configuration data,
5810 including X Windows' defaults database.
5811 For values specific to the first Emacs frame, see `initial-frame-alist'.
5812 For window-system specific values, see `window-system-default-frame-alist'.
5813 For values specific to the separate minibuffer frame, see
5814 `minibuffer-frame-alist'.
5815 The `menu-bar-lines' element of the list controls whether new frames
5816 have menu bars; `menu-bar-mode' works by altering this element.
5817 Setting this variable does not affect existing frames, only new ones. */);
5818 Vdefault_frame_alist
= Qnil
;
5820 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
5821 doc
: /* Default position of vertical scroll bars on this window-system. */);
5822 #ifdef HAVE_WINDOW_SYSTEM
5823 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
5824 /* MS-Windows, macOS, and GTK have scroll bars on the right by
5826 Vdefault_frame_scroll_bars
= Qright
;
5828 Vdefault_frame_scroll_bars
= Qleft
;
5831 Vdefault_frame_scroll_bars
= Qnil
;
5834 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
5835 scroll_bar_adjust_thumb_portion_p
,
5836 doc
: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
5837 Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
5838 even if the end of the buffer is shown (i.e. overscrolling).
5839 Set to nil if you want the thumb to be at the bottom when the end of the buffer
5840 is shown. Also, the thumb fills the whole scroll bar when the entire buffer
5841 is visible. In this case you can not overscroll. */);
5842 scroll_bar_adjust_thumb_portion_p
= 1;
5844 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
5845 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
5847 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
5848 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
5849 `mouse-position' and `mouse-pixel-position' call this function, passing their
5850 usual return value as argument, and return whatever this function returns.
5851 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
5852 which need to do mouse handling at the Lisp level. */);
5853 Vmouse_position_function
= Qnil
;
5855 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
5856 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
5857 If the value is an integer, highlighting is only shown after moving the
5858 mouse, while keyboard input turns off the highlight even when the mouse
5859 is over the clickable text. However, the mouse shape still indicates
5860 when the mouse is over clickable text. */);
5861 Vmouse_highlight
= Qt
;
5863 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
5864 doc
: /* If non-nil, make pointer invisible while typing.
5865 The pointer becomes visible again when the mouse is moved. */);
5866 Vmake_pointer_invisible
= Qt
;
5868 DEFVAR_LISP ("focus-in-hook", Vfocus_in_hook
,
5869 doc
: /* Normal hook run when a frame gains input focus.
5870 The frame gaining focus is selected at the time this hook is run. */);
5871 Vfocus_in_hook
= Qnil
;
5873 DEFVAR_LISP ("focus-out-hook", Vfocus_out_hook
,
5874 doc
: /* Normal hook run when all frames lost input focus. */);
5875 Vfocus_out_hook
= Qnil
;
5877 DEFVAR_LISP ("move-frame-functions", Vmove_frame_functions
,
5878 doc
: /* Functions run after a frame was moved.
5879 The functions are run with one arg, the frame that moved. */);
5880 Vmove_frame_functions
= Qnil
;
5882 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
5883 doc
: /* Functions run before deleting a frame.
5884 The functions are run with one arg, the frame to be deleted.
5887 Note that functions in this list may be called just before the frame is
5888 actually deleted, or some time later (or even both when an earlier function
5889 in `delete-frame-functions' (indirectly) calls `delete-frame'
5891 Vdelete_frame_functions
= Qnil
;
5892 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
5894 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
5895 doc
: /* Non-nil if Menu-Bar mode is enabled.
5896 See the command `menu-bar-mode' for a description of this minor mode.
5897 Setting this variable directly does not take effect;
5898 either customize it (see the info node `Easy Customization')
5899 or call the function `menu-bar-mode'. */);
5900 Vmenu_bar_mode
= Qt
;
5902 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
5903 doc
: /* Non-nil if Tool-Bar mode is enabled.
5904 See the command `tool-bar-mode' for a description of this minor mode.
5905 Setting this variable directly does not take effect;
5906 either customize it (see the info node `Easy Customization')
5907 or call the function `tool-bar-mode'. */);
5908 #ifdef HAVE_WINDOW_SYSTEM
5909 Vtool_bar_mode
= Qt
;
5911 Vtool_bar_mode
= Qnil
;
5914 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
5915 doc
: /* Minibuffer-less frames by default use this frame's minibuffer.
5916 Emacs consults this variable only when creating a minibuffer-less frame
5917 and no explicit minibuffer window has been specified for that frame via
5918 the `minibuffer' frame parameter. Once such a frame has been created,
5919 setting this variable does not change that frame's previous association.
5921 This variable is local to the current terminal and cannot be buffer-local. */);
5923 DEFVAR_LISP ("focus-follows-mouse", focus_follows_mouse
,
5924 doc
: /* Non-nil if window system changes focus when you move the mouse.
5925 You should set this variable to tell Emacs how your window manager
5926 handles focus, since there is no way in general for Emacs to find out
5929 There are three meaningful values:
5931 - The default nil should be used when your window manager follows a
5932 "click-to-focus" policy where you have to click the mouse inside of a
5933 frame in order for that frame to get focus.
5935 - The value t should be used when your window manager has the focus
5936 automatically follow the position of the mouse pointer but a window
5937 that gains focus is not raised automatically.
5939 - The value `auto-raise' should be used when your window manager has the
5940 focus automatically follow the position of the mouse pointer and a
5941 window that gains focus is raised automatically.
5943 If this option is non-nil, Emacs moves the mouse pointer to the frame
5944 selected by `select-frame-set-input-focus'. This function is used by a
5945 number of commands like, for example, `other-frame' and `pop-to-buffer'.
5946 If this option is nil and your focus follows mouse window manager does
5947 not autonomously move the mouse pointer to the newly selected frame, the
5948 previously selected window manager window might get reselected instead
5951 The distinction between the values t and `auto-raise' is not needed for
5952 "normal" frames because the window manager takes care of raising them.
5953 Setting this to `auto-raise' will, however, override the standard
5954 behavior of a window manager that does not automatically raise the frame
5955 that gets focus. Setting this to `auto-raise' is also necessary to
5956 automatically raise child frames which are usually left alone by the
5959 Note that this option does not distinguish "sloppy" focus (where the
5960 frame that previously had focus retains focus as long as the mouse
5961 pointer does not move into another window manager window) from "strict"
5962 focus (where a frame immediately loses focus when it's left by the mouse
5965 In order to extend a "focus follows mouse" policy to individual Emacs
5966 windows, customize the variable `mouse-autoselect-window'. */);
5967 focus_follows_mouse
= Qnil
;
5969 DEFVAR_BOOL ("frame-resize-pixelwise", frame_resize_pixelwise
,
5970 doc
: /* Non-nil means resize frames pixelwise.
5971 If this option is nil, resizing a frame rounds its sizes to the frame's
5972 current values of `frame-char-height' and `frame-char-width'. If this
5973 is non-nil, no rounding occurs, hence frame sizes can increase/decrease
5976 With some window managers you may have to set this to non-nil in order
5977 to set the size of a frame in pixels, to maximize frames or to make them
5978 fullscreen. To resize your initial frame pixelwise, set this option to
5979 a non-nil value in your init file. */);
5980 frame_resize_pixelwise
= 0;
5982 DEFVAR_LISP ("frame-inhibit-implied-resize", frame_inhibit_implied_resize
,
5983 doc
: /* Whether frames should be resized implicitly.
5984 If this option is nil, setting font, menu bar, tool bar, internal
5985 borders, fringes or scroll bars of a specific frame may resize the frame
5986 in order to preserve the number of columns or lines it displays. If
5987 this option is t, no such resizing is done. Note that the size of
5988 fullscreen and maximized frames, the height of fullheight frames and the
5989 width of fullwidth frames never change implicitly.
5991 The value of this option can be also be a list of frame parameters. In
5992 this case, resizing is inhibited when changing a parameter that appears
5993 in that list. The parameters currently handled by this option include
5994 `font', `font-backend', `internal-border-width', `menu-bar-lines' and
5997 Changing any of the parameters `scroll-bar-width', `scroll-bar-height',
5998 `vertical-scroll-bars', `horizontal-scroll-bars', `left-fringe' and
5999 `right-fringe' is handled as if the frame contained just one live
6000 window. This means, for example, that removing vertical scroll bars on
6001 a frame containing several side by side windows will shrink the frame
6002 width by the width of one scroll bar provided this option is nil and
6003 keep it unchanged if this option is either t or a list containing
6004 `vertical-scroll-bars'.
6006 The default value is \\='(tool-bar-lines) on Lucid, Motif and Windows
6007 \(which means that adding/removing a tool bar does not change the frame
6008 height), nil on all other window systems including GTK+ (which means
6009 that changing any of the parameters listed above may change the size of
6010 the frame), and t otherwise (which means the frame size never changes
6011 implicitly when there's no window system support).
6013 Note that when a frame is not large enough to accommodate a change of
6014 any of the parameters listed above, Emacs may try to enlarge the frame
6015 even if this option is non-nil. */);
6016 #if defined (HAVE_WINDOW_SYSTEM)
6017 #if defined (USE_LUCID) || defined (USE_MOTIF) || defined (HAVE_NTGUI)
6018 frame_inhibit_implied_resize
= list1 (Qtool_bar_lines
);
6020 frame_inhibit_implied_resize
= Qnil
;
6023 frame_inhibit_implied_resize
= Qt
;
6026 DEFVAR_LISP ("frame-size-history", frame_size_history
,
6027 doc
: /* History of frame size adjustments.
6028 If non-nil, list recording frame size adjustment. Adjustments are
6029 recorded only if the first element of this list is a positive number.
6030 Adding an adjustment decrements that number by one.
6032 The remaining elements are the adjustments. Each adjustment is a list
6033 of four elements `frame', `function', `sizes' and `more'. `frame' is
6034 the affected frame and `function' the invoking function. `sizes' is
6035 usually a list of four elements `old-width', `old-height', `new-width'
6036 and `new-height' representing the old and new sizes recorded/requested
6037 by `function'. `more' is a list with additional information.
6039 The function `frame--size-history' displays the value of this variable
6040 in a more readable form. */);
6041 frame_size_history
= Qnil
;
6043 DEFVAR_BOOL ("tooltip-reuse-hidden-frame", tooltip_reuse_hidden_frame
,
6044 doc
: /* Non-nil means reuse hidden tooltip frames.
6045 When this is nil, delete a tooltip frame when hiding the associated
6046 tooltip. When this is non-nil, make the tooltip frame invisible only,
6047 so it can be reused when the next tooltip is shown.
6049 Setting this to non-nil may drastically reduce the consing overhead
6050 incurred by creating new tooltip frames. However, a value of non-nil
6051 means also that intermittent changes of faces or `default-frame-alist'
6052 are not applied when showing a tooltip in a reused frame.
6054 This variable is effective only with the X toolkit (and there only when
6055 Gtk+ tooltips are not used) and on Windows. */);
6056 tooltip_reuse_hidden_frame
= false;
6058 DEFVAR_LISP ("iconify-child-frame", iconify_child_frame
,
6059 doc
: /* How to handle iconification of child frames.
6060 This variable tells Emacs how to proceed when it is asked to iconify a
6061 child frame. If it is nil, `iconify-frame' will do nothing when invoked
6062 on a child frame. If it is `iconify-top-level', Emacs will try to
6063 iconify the top level frame associated with this child frame instead.
6064 If it is `make-invisible', Emacs will try to make this child frame
6067 Any other value means to try iconifying the child frame. Since such an
6068 attempt is not honored by all window managers and may even lead to
6069 making the child frame unresponsive to user actions, the default is to
6070 iconify the top level frame instead. */);
6071 iconify_child_frame
= Qiconify_top_level
;
6073 staticpro (&Vframe_list
);
6076 defsubr (&Sframe_live_p
);
6077 defsubr (&Swindow_system
);
6078 defsubr (&Sframe_windows_min_size
);
6079 defsubr (&Smake_terminal_frame
);
6080 defsubr (&Shandle_switch_frame
);
6081 defsubr (&Sselect_frame
);
6082 defsubr (&Sselected_frame
);
6083 defsubr (&Sframe_list
);
6084 defsubr (&Sframe_parent
);
6085 defsubr (&Sframe_ancestor_p
);
6086 defsubr (&Snext_frame
);
6087 defsubr (&Sprevious_frame
);
6088 defsubr (&Slast_nonminibuf_frame
);
6089 defsubr (&Sdelete_frame
);
6090 defsubr (&Smouse_position
);
6091 defsubr (&Smouse_pixel_position
);
6092 defsubr (&Sset_mouse_position
);
6093 defsubr (&Sset_mouse_pixel_position
);
6095 defsubr (&Sframe_configuration
);
6096 defsubr (&Srestore_frame_configuration
);
6098 defsubr (&Smake_frame_visible
);
6099 defsubr (&Smake_frame_invisible
);
6100 defsubr (&Siconify_frame
);
6101 defsubr (&Sframe_visible_p
);
6102 defsubr (&Svisible_frame_list
);
6103 defsubr (&Sraise_frame
);
6104 defsubr (&Slower_frame
);
6105 defsubr (&Sx_focus_frame
);
6106 defsubr (&Sframe_after_make_frame
);
6107 defsubr (&Sredirect_frame_focus
);
6108 defsubr (&Sframe_focus
);
6109 defsubr (&Sframe_parameters
);
6110 defsubr (&Sframe_parameter
);
6111 defsubr (&Smodify_frame_parameters
);
6112 defsubr (&Sframe_char_height
);
6113 defsubr (&Sframe_char_width
);
6114 defsubr (&Sframe_native_height
);
6115 defsubr (&Sframe_native_width
);
6116 defsubr (&Sframe_text_cols
);
6117 defsubr (&Sframe_text_lines
);
6118 defsubr (&Sframe_total_cols
);
6119 defsubr (&Sframe_total_lines
);
6120 defsubr (&Sframe_text_width
);
6121 defsubr (&Sframe_text_height
);
6122 defsubr (&Sscroll_bar_width
);
6123 defsubr (&Sscroll_bar_height
);
6124 defsubr (&Sfringe_width
);
6125 defsubr (&Sframe_internal_border_width
);
6126 defsubr (&Sright_divider_width
);
6127 defsubr (&Sbottom_divider_width
);
6128 defsubr (&Stool_bar_pixel_width
);
6129 defsubr (&Sset_frame_height
);
6130 defsubr (&Sset_frame_width
);
6131 defsubr (&Sset_frame_size
);
6132 defsubr (&Sframe_position
);
6133 defsubr (&Sset_frame_position
);
6134 defsubr (&Sframe_pointer_visible_p
);
6136 #ifdef HAVE_WINDOW_SYSTEM
6137 defsubr (&Sx_get_resource
);
6138 defsubr (&Sx_parse_geometry
);