1 /* Generic frame functions.
3 Copyright (C) 1993-1995, 1997, 1999-2019 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. */
39 #include "blockinput.h"
41 #include "termhooks.h"
42 #include "dispextern.h"
44 #ifdef HAVE_WINDOW_SYSTEM
56 /* The currently selected frame. */
58 Lisp_Object selected_frame
;
60 /* A frame which is not just a mini-buffer, or NULL if there are no such
61 frames. This is usually the most recent such frame that was selected. */
63 static struct frame
*last_nonminibuf_frame
;
65 /* False means there are no visible garbaged frames. */
68 /* The default tool bar height for future frames. */
69 #if defined USE_GTK || defined HAVE_NS
70 enum { frame_default_tool_bar_height
= 0 };
72 int frame_default_tool_bar_height
;
75 #ifdef HAVE_WINDOW_SYSTEM
76 static void x_report_frame_params (struct frame
*, Lisp_Object
*);
79 /* These setters are used only in this file, so they can be private. */
81 fset_buffer_predicate (struct frame
*f
, Lisp_Object val
)
83 f
->buffer_predicate
= val
;
86 fset_minibuffer_window (struct frame
*f
, Lisp_Object val
)
88 f
->minibuffer_window
= val
;
92 decode_live_frame (register Lisp_Object frame
)
95 frame
= selected_frame
;
96 CHECK_LIVE_FRAME (frame
);
97 return XFRAME (frame
);
101 decode_any_frame (register Lisp_Object frame
)
104 frame
= selected_frame
;
106 return XFRAME (frame
);
109 #ifdef HAVE_WINDOW_SYSTEM
111 display_available (void)
113 return x_display_list
!= NULL
;
118 decode_window_system_frame (Lisp_Object frame
)
120 struct frame
*f
= decode_live_frame (frame
);
121 check_window_system (f
);
122 #ifdef HAVE_WINDOW_SYSTEM
128 check_window_system (struct frame
*f
)
130 #ifdef HAVE_WINDOW_SYSTEM
131 if (window_system_available (f
))
134 error (f
? "Window system frame should be used"
135 : "Window system is not in use or not initialized");
138 /* Return the value of frame parameter PROP in frame FRAME. */
141 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
143 register Lisp_Object tem
;
145 tem
= Fassq (prop
, frame
->param_alist
);
153 frame_size_history_add (struct frame
*f
, Lisp_Object fun_symbol
,
154 int width
, int height
, Lisp_Object rest
)
158 XSETFRAME (frame
, f
);
159 if (CONSP (frame_size_history
)
160 && INTEGERP (XCAR (frame_size_history
))
161 && 0 < XINT (XCAR (frame_size_history
)))
163 Fcons (make_number (XINT (XCAR (frame_size_history
)) - 1),
167 ? list4 (make_number (FRAME_TEXT_WIDTH (f
)),
168 make_number (FRAME_TEXT_HEIGHT (f
)),
170 make_number (height
))
173 XCDR (frame_size_history
)));
177 /* Return 1 if `frame-inhibit-implied-resize' is non-nil or fullscreen
178 state of frame F would be affected by a vertical (horizontal if
179 HORIZONTAL is true) resize. PARAMETER is the symbol of the frame
180 parameter that is changed. */
182 frame_inhibit_resize (struct frame
*f
, bool horizontal
, Lisp_Object parameter
)
184 Lisp_Object fullscreen
= get_frame_param (f
, Qfullscreen
);
186 = (f
->after_make_frame
187 ? (EQ (frame_inhibit_implied_resize
, Qt
)
188 || (CONSP (frame_inhibit_implied_resize
)
189 && !NILP (Fmemq (parameter
, frame_inhibit_implied_resize
)))
191 && !EQ (fullscreen
, Qnil
) && !EQ (fullscreen
, Qfullheight
))
193 && !EQ (fullscreen
, Qnil
) && !EQ (fullscreen
, Qfullwidth
))
194 || FRAME_TERMCAP_P (f
) || FRAME_MSDOS_P (f
))
195 : ((horizontal
&& f
->inhibit_horizontal_resize
)
196 || (!horizontal
&& f
->inhibit_vertical_resize
)));
197 if (inhibit
&& !FRAME_TERMCAP_P (f
) && !FRAME_MSDOS_P (f
))
198 frame_size_history_add
199 (f
, Qframe_inhibit_resize
, 0, 0,
200 list5 (horizontal
? Qt
: Qnil
, parameter
,
201 f
->after_make_frame
? Qt
: Qnil
,
202 frame_inhibit_implied_resize
,
209 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
212 int olines
= FRAME_MENU_BAR_LINES (f
);
214 /* Right now, menu bars don't work properly in minibuf-only frames;
215 most of the commands try to apply themselves to the minibuffer
216 frame itself, and get an error because you can't switch buffers
217 in or split the minibuffer window. */
218 if (FRAME_MINIBUF_ONLY_P (f
))
221 if (TYPE_RANGED_INTEGERP (int, value
))
222 nlines
= XINT (value
);
226 if (nlines
!= olines
)
228 windows_or_buffers_changed
= 14;
229 FRAME_MENU_BAR_LINES (f
) = nlines
;
230 FRAME_MENU_BAR_HEIGHT (f
) = nlines
* FRAME_LINE_HEIGHT (f
);
231 change_frame_size (f
, FRAME_COLS (f
),
232 FRAME_LINES (f
) + olines
- nlines
,
237 Lisp_Object Vframe_list
;
240 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
241 doc
: /* Return non-nil if OBJECT is a frame.
243 t for a termcap frame (a character-only terminal),
244 `x' for an Emacs frame that is really an X window,
245 `w32' for an Emacs frame that is a window on MS-Windows display,
246 `ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
247 `pc' for a direct-write MS-DOS frame.
248 See also `frame-live-p'. */)
251 if (!FRAMEP (object
))
253 switch (XFRAME (object
)->output_method
)
255 case output_initial
: /* The initial frame is like a termcap frame. */
258 case output_x_window
:
262 case output_msdos_raw
:
271 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
272 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
273 Value is nil if OBJECT is not a live frame. If object is a live
274 frame, the return value indicates what sort of terminal device it is
275 displayed on. See the documentation of `framep' for possible
279 return ((FRAMEP (object
)
280 && FRAME_LIVE_P (XFRAME (object
)))
285 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
286 doc
: /* The name of the window system that FRAME is displaying through.
287 The value is a symbol:
288 nil for a termcap frame (a character-only terminal),
289 `x' for an Emacs frame that is really an X window,
290 `w32' for an Emacs frame that is a window on MS-Windows display,
291 `ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
292 `pc' for a direct-write MS-DOS frame.
294 FRAME defaults to the currently selected frame.
296 Use of this function as a predicate is deprecated. Instead,
297 use `display-graphic-p' or any of the other `display-*-p'
298 predicates which report frame's specific UI-related capabilities. */)
303 frame
= selected_frame
;
305 type
= Fframep (frame
);
308 wrong_type_argument (Qframep
, frame
);
316 /* Placeholder used by temacs -nw before window.el is loaded. */
317 DEFUN ("frame-windows-min-size", Fframe_windows_min_size
,
318 Sframe_windows_min_size
, 4, 4, 0,
321 (Lisp_Object frame
, Lisp_Object horizontal
,
322 Lisp_Object ignore
, Lisp_Object pixelwise
)
324 return make_number (0);
328 * frame_windows_min_size:
330 * Return the minimum number of lines (columns if HORIZONTAL is non-nil)
331 * of FRAME. If PIXELWISE is non-nil, return the minimum inner height
332 * (width) of FRAME in pixels.
334 * This value is calculated by the function `frame-windows-min-size' in
335 * window.el unless the `min-height' (`min-width' if HORIZONTAL is
336 * non-nil) parameter of FRAME is non-nil thus explicitly specifying the
337 * value to be returned. In that latter case IGNORE is ignored.
339 * If `frame-windows-min-size' is called, it will make sure that the
340 * return value accommodates all windows of FRAME respecting the values
341 * of `window-min-height' (`window-min-width' if HORIZONTAL is non-nil).
342 * With IGNORE non-nil the values of these variables are ignored.
344 * In either case, never return a value less than 1. For TTY frames,
345 * additionally limit the minimum frame height to a value large enough
346 * to support the menu bar, the mode line, and the echo area.
349 frame_windows_min_size (Lisp_Object frame
, Lisp_Object horizontal
,
350 Lisp_Object ignore
, Lisp_Object pixelwise
)
352 struct frame
*f
= XFRAME (frame
);
353 Lisp_Object par_size
;
356 if ((!NILP (horizontal
)
357 && NUMBERP (par_size
= get_frame_param (f
, Qmin_width
)))
358 || (NILP (horizontal
)
359 && NUMBERP (par_size
= get_frame_param (f
, Qmin_height
))))
361 int min_size
= XINT (par_size
);
363 /* Don't allow phantom frames. */
367 retval
= (NILP (pixelwise
)
369 : min_size
* (NILP (horizontal
)
370 ? FRAME_LINE_HEIGHT (f
)
371 : FRAME_COLUMN_WIDTH (f
)));
374 retval
= XINT (call4 (Qframe_windows_min_size
, frame
, horizontal
,
376 /* Don't allow too small height of text-mode frames, or else cm.c
377 might abort in cmcheckmagic. */
378 if ((FRAME_TERMCAP_P (f
) || FRAME_MSDOS_P (f
)) && NILP (horizontal
))
380 int min_height
= (FRAME_MENU_BAR_LINES (f
)
381 + FRAME_WANTS_MODELINE_P (f
)
382 + 2); /* one text line and one echo-area line */
383 if (retval
< min_height
)
391 #ifdef HAVE_WINDOW_SYSTEM
395 * Preserve ratios of frame F which usually happens after its parent
396 * frame P got resized. OLD_WIDTH, OLD_HEIGHT specifies the old native
397 * size of F's parent, NEW_WIDTH and NEW_HEIGHT its new size.
399 * Adjust F's width if F's 'keep_ratio' parameter is non-nil and, if
400 * it is a cons, its car is not 'height-only'. Adjust F's height if F's
401 * 'keep_ratio' parameter is non-nil and, if it is a cons, its car
402 * is not 'width-only'.
404 * Adjust F's left position if F's 'keep_ratio' parameter is non-nil
405 * and, if its is a cons, its cdr is non-nil and not 'top-only'. Adjust
406 * F's top position if F's 'keep_ratio' parameter is non-nil and, if
407 * its is a cons, its cdr is non-nil and not 'left-only'.
409 * Note that when positional adjustment is requested but the size of F
410 * should remain unaltered in the corresponding direction, this routine
411 * tries to constrain F to its parent frame - something which usually
412 * happens when the parent frame shrinks. This means, however, that
413 * when the parent frame is re-enlarged later, the child's original
414 * position will not get restored to its pre-shrinking value.
416 * This routine is currently useful for child frames only. It might be
417 * eventually useful when moving non-child frames between monitors with
418 * different resolutions.
421 keep_ratio (struct frame
*f
, struct frame
*p
, int old_width
, int old_height
,
422 int new_width
, int new_height
)
424 Lisp_Object keep_ratio
= get_frame_param (f
, Qkeep_ratio
);
427 if (!NILP (keep_ratio
))
429 double width_factor
= (double)new_width
/ (double)old_width
;
430 double height_factor
= (double)new_height
/ (double)old_height
;
431 int pixel_width
, pixel_height
, pos_x
, pos_y
;
433 if (!CONSP (keep_ratio
) || !NILP (Fcdr (keep_ratio
)))
435 if (CONSP (keep_ratio
) && EQ (Fcdr (keep_ratio
), Qtop_only
))
439 pos_x
= (int)(f
->left_pos
* width_factor
+ 0.5);
441 if (CONSP (keep_ratio
)
442 && (NILP (Fcar (keep_ratio
))
443 || EQ (Fcar (keep_ratio
), Qheight_only
))
444 && p
->pixel_width
- f
->pixel_width
< pos_x
)
446 int p_f_width
= p
->pixel_width
- f
->pixel_width
;
451 pos_x
= (int)(p_f_width
* width_factor
* 0.5 + 0.5);
457 if (CONSP (keep_ratio
) && EQ (Fcdr (keep_ratio
), Qleft_only
))
461 pos_y
= (int)(f
->top_pos
* height_factor
+ 0.5);
463 if (CONSP (keep_ratio
)
464 && (NILP (Fcar (keep_ratio
))
465 || EQ (Fcar (keep_ratio
), Qwidth_only
))
466 && p
->pixel_height
- f
->pixel_height
< pos_y
)
467 /* When positional adjustment was requested and the
468 width of F should remain unaltered, try to constrain
469 F to its parent. This means that when the parent
470 frame is enlarged later the child's original position
471 won't get restored. */
473 int p_f_height
= p
->pixel_height
- f
->pixel_height
;
478 pos_y
= (int)(p_f_height
* height_factor
* 0.5 + 0.5);
484 x_set_offset (f
, pos_x
, pos_y
, -1);
487 if (!CONSP (keep_ratio
) || !NILP (Fcar (keep_ratio
)))
489 if (CONSP (keep_ratio
) && EQ (Fcar (keep_ratio
), Qheight_only
))
493 pixel_width
= (int)(f
->pixel_width
* width_factor
+ 0.5);
494 pixel_width
= FRAME_PIXEL_TO_TEXT_WIDTH (f
, pixel_width
);
497 if (CONSP (keep_ratio
) && EQ (Fcar (keep_ratio
), Qwidth_only
))
501 pixel_height
= (int)(f
->pixel_height
* height_factor
+ 0.5);
502 pixel_height
= FRAME_PIXEL_TO_TEXT_HEIGHT (f
, pixel_height
);
505 adjust_frame_size (f
, pixel_width
, pixel_height
, 1, 0,
516 * Adjust size of frame F. NEW_WIDTH and NEW_HEIGHT specify the new
517 * text size of F in pixels. A value of -1 means no change is requested
518 * for that direction (but the frame may still have to be resized to
519 * accommodate windows with their minimum sizes). This can either issue
520 * a request to resize the frame externally (via x_set_window_size), to
521 * resize the frame internally (via resize_frame_windows) or do nothing
524 * The argument INHIBIT can assume the following values:
526 * 0 means to unconditionally call x_set_window_size even if sizes
527 * apparently do not change. Fx_create_frame uses this to pass the
528 * initial size to the window manager.
530 * 1 means to call x_set_window_size if the native frame size really
531 * changes. Fset_frame_size, Fset_frame_height, ... use this.
533 * 2 means to call x_set_window_size provided frame_inhibit_resize
534 * allows it. The menu and tool bar code use this ("3" won't work
535 * here in general because menu and tool bar are often not counted in
536 * the frame's text height).
538 * 3 means call x_set_window_size if window minimum sizes must be
539 * preserved or frame_inhibit_resize allows it. x_set_left_fringe,
540 * x_set_scroll_bar_width, x_new_font ... use (or should use) this.
542 * 4 means call x_set_window_size only if window minimum sizes must be
543 * preserved. x_set_right_divider_width, x_set_border_width and the
544 * code responsible for wrapping the tool bar use this.
546 * 5 means to never call x_set_window_size. change_frame_size uses
549 * Note that even when x_set_window_size is not called, individual
550 * windows may have to be resized (via `window--sanitize-window-sizes')
551 * in order to support minimum size constraints.
553 * PRETEND is as for change_frame_size. PARAMETER, if non-nil, is the
554 * symbol of the parameter changed (like `menu-bar-lines', `font', ...).
555 * This is passed on to frame_inhibit_resize to let the latter decide on
556 * a case-by-case basis whether the frame may be resized externally.
559 adjust_frame_size (struct frame
*f
, int new_width
, int new_height
, int inhibit
,
560 bool pretend
, Lisp_Object parameter
)
562 int unit_width
= FRAME_COLUMN_WIDTH (f
);
563 int unit_height
= FRAME_LINE_HEIGHT (f
);
564 int old_pixel_width
= FRAME_PIXEL_WIDTH (f
);
565 int old_pixel_height
= FRAME_PIXEL_HEIGHT (f
);
566 int old_cols
= FRAME_COLS (f
);
567 int old_lines
= FRAME_LINES (f
);
568 int new_pixel_width
, new_pixel_height
;
569 /* The following two values are calculated from the old frame pixel
570 sizes and any "new" settings for tool bar, menu bar and internal
571 borders. We do it this way to detect whether we have to call
572 x_set_window_size as consequence of the new settings. */
573 int windows_width
= FRAME_WINDOWS_WIDTH (f
);
574 int windows_height
= FRAME_WINDOWS_HEIGHT (f
);
575 int min_windows_width
, min_windows_height
;
576 /* These are a bit tedious, maybe we should use a macro. */
577 struct window
*r
= XWINDOW (FRAME_ROOT_WINDOW (f
));
578 int old_windows_width
= WINDOW_PIXEL_WIDTH (r
);
579 int old_windows_height
580 = (WINDOW_PIXEL_HEIGHT (r
)
581 + ((FRAME_HAS_MINIBUF_P (f
) && !FRAME_MINIBUF_ONLY_P (f
))
582 ? WINDOW_PIXEL_HEIGHT (XWINDOW (FRAME_MINIBUF_WINDOW (f
)))
584 int new_windows_width
, new_windows_height
;
585 int old_text_width
= FRAME_TEXT_WIDTH (f
);
586 int old_text_height
= FRAME_TEXT_HEIGHT (f
);
587 /* If a size is < 0 use the old value. */
588 int new_text_width
= (new_width
>= 0) ? new_width
: old_text_width
;
589 int new_text_height
= (new_height
>= 0) ? new_height
: old_text_height
;
590 int new_cols
, new_lines
;
591 bool inhibit_horizontal
, inhibit_vertical
;
594 XSETFRAME (frame
, f
);
596 frame_size_history_add
597 (f
, Qadjust_frame_size_1
, new_text_width
, new_text_height
,
598 list2 (parameter
, make_number (inhibit
)));
600 /* The following two values are calculated from the old window body
601 sizes and any "new" settings for scroll bars, dividers, fringes and
602 margins (though the latter should have been processed already). */
604 = frame_windows_min_size (frame
, Qt
, (inhibit
== 5) ? Qt
: Qnil
, Qt
);
606 = frame_windows_min_size (frame
, Qnil
, (inhibit
== 5) ? Qt
: Qnil
, Qt
);
608 if (inhibit
>= 2 && inhibit
<= 4)
609 /* When INHIBIT is in [2..4] inhibit if the "old" window sizes stay
610 within the limits and either resizing is inhibited or INHIBIT
613 inhibit_horizontal
= (windows_width
>= min_windows_width
615 || frame_inhibit_resize (f
, true, parameter
)));
616 inhibit_vertical
= (windows_height
>= min_windows_height
618 || frame_inhibit_resize (f
, false, parameter
)));
621 /* Otherwise inhibit if INHIBIT equals 5. */
622 inhibit_horizontal
= inhibit_vertical
= inhibit
== 5;
624 new_pixel_width
= ((inhibit_horizontal
&& (inhibit
< 5))
626 : max (FRAME_TEXT_TO_PIXEL_WIDTH (f
, new_text_width
),
628 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
629 new_windows_width
= new_pixel_width
- 2 * FRAME_INTERNAL_BORDER_WIDTH (f
);
630 new_text_width
= FRAME_PIXEL_TO_TEXT_WIDTH (f
, new_pixel_width
);
631 new_cols
= new_text_width
/ unit_width
;
633 new_pixel_height
= ((inhibit_vertical
&& (inhibit
< 5))
635 : max (FRAME_TEXT_TO_PIXEL_HEIGHT (f
, new_text_height
),
637 + FRAME_TOP_MARGIN_HEIGHT (f
)
638 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
639 new_windows_height
= (new_pixel_height
640 - FRAME_TOP_MARGIN_HEIGHT (f
)
641 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f
));
642 new_text_height
= FRAME_PIXEL_TO_TEXT_HEIGHT (f
, new_pixel_height
);
643 new_lines
= new_text_height
/ unit_height
;
645 #ifdef HAVE_WINDOW_SYSTEM
646 if (FRAME_WINDOW_P (f
)
647 && f
->can_x_set_window_size
648 && ((!inhibit_horizontal
649 && (new_pixel_width
!= old_pixel_width
650 || inhibit
== 0 || inhibit
== 2))
651 || (!inhibit_vertical
652 && (new_pixel_height
!= old_pixel_height
653 || inhibit
== 0 || inhibit
== 2))))
654 /* We are either allowed to change the frame size or the minimum
655 sizes request such a change. Do not care for fixing minimum
656 sizes here, we do that eventually when we're called from
657 change_frame_size. */
659 /* Make sure we respect fullheight and fullwidth. */
660 if (inhibit_horizontal
)
661 new_text_width
= old_text_width
;
662 else if (inhibit_vertical
)
663 new_text_height
= old_text_height
;
665 frame_size_history_add
666 (f
, Qadjust_frame_size_2
, new_text_width
, new_text_height
,
667 list2 (inhibit_horizontal
? Qt
: Qnil
,
668 inhibit_vertical
? Qt
: Qnil
));
670 x_set_window_size (f
, 0, new_text_width
, new_text_height
, 1);
677 if (new_text_width
== old_text_width
678 && new_text_height
== old_text_height
679 && new_windows_width
== old_windows_width
680 && new_windows_height
== old_windows_height
681 && new_pixel_width
== old_pixel_width
682 && new_pixel_height
== old_pixel_height
683 && new_cols
== old_cols
684 && new_lines
== old_lines
)
685 /* No change. Sanitize window sizes and return. */
687 sanitize_window_sizes (Qt
);
688 sanitize_window_sizes (Qnil
);
696 /* We only can set screen dimensions to certain values supported by
697 our video hardware. Try to find the smallest size greater or
698 equal to the requested dimensions, while accounting for the fact
699 that the menu-bar lines are not counted in the frame height. */
700 int dos_new_lines
= new_lines
+ FRAME_TOP_MARGIN (f
);
701 dos_set_window_size (&dos_new_lines
, &new_cols
);
702 new_lines
= dos_new_lines
- FRAME_TOP_MARGIN (f
);
705 if (new_windows_width
!= old_windows_width
)
707 resize_frame_windows (f
, new_windows_width
, 1, 1);
709 /* MSDOS frames cannot PRETEND, as they change frame size by
710 manipulating video hardware. */
711 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
712 FrameCols (FRAME_TTY (f
)) = new_cols
;
714 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
715 if (WINDOWP (f
->tool_bar_window
))
717 XWINDOW (f
->tool_bar_window
)->pixel_width
= new_windows_width
;
718 XWINDOW (f
->tool_bar_window
)->total_cols
719 = new_windows_width
/ unit_width
;
723 else if (new_cols
!= old_cols
)
724 call2 (Qwindow__pixel_to_total
, frame
, Qt
);
726 if (new_windows_height
!= old_windows_height
727 /* When the top margin has changed we have to recalculate the top
728 edges of all windows. No such calculation is necessary for the
730 || WINDOW_TOP_PIXEL_EDGE (r
) != FRAME_TOP_MARGIN_HEIGHT (f
))
732 resize_frame_windows (f
, new_windows_height
, 0, 1);
734 /* MSDOS frames cannot PRETEND, as they change frame size by
735 manipulating video hardware. */
736 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
737 FrameRows (FRAME_TTY (f
)) = new_lines
+ FRAME_TOP_MARGIN (f
);
739 else if (new_lines
!= old_lines
)
740 call2 (Qwindow__pixel_to_total
, frame
, Qnil
);
742 frame_size_history_add
743 (f
, Qadjust_frame_size_3
, new_text_width
, new_text_height
,
744 list4 (make_number (old_pixel_width
), make_number (old_pixel_height
),
745 make_number (new_pixel_width
), make_number (new_pixel_height
)));
747 /* Assign new sizes. */
748 FRAME_TEXT_WIDTH (f
) = new_text_width
;
749 FRAME_TEXT_HEIGHT (f
) = new_text_height
;
750 FRAME_PIXEL_WIDTH (f
) = new_pixel_width
;
751 FRAME_PIXEL_HEIGHT (f
) = new_pixel_height
;
752 SET_FRAME_COLS (f
, new_cols
);
753 SET_FRAME_LINES (f
, new_lines
);
756 struct window
*w
= XWINDOW (FRAME_SELECTED_WINDOW (f
));
757 int text_area_x
, text_area_y
, text_area_width
, text_area_height
;
759 window_box (w
, TEXT_AREA
, &text_area_x
, &text_area_y
, &text_area_width
,
761 if (w
->cursor
.x
>= text_area_x
+ text_area_width
)
762 w
->cursor
.hpos
= w
->cursor
.x
= 0;
763 if (w
->cursor
.y
>= text_area_y
+ text_area_height
)
764 w
->cursor
.vpos
= w
->cursor
.y
= 0;
767 /* Sanitize window sizes. */
768 sanitize_window_sizes (Qt
);
769 sanitize_window_sizes (Qnil
);
771 adjust_frame_glyphs (f
);
773 SET_FRAME_GARBAGED (f
);
775 /* A frame was "resized" if one of its pixelsizes changed, even if its
776 X window wasn't resized at all. */
777 f
->resized_p
= (new_pixel_width
!= old_pixel_width
778 || new_pixel_height
!= old_pixel_height
);
782 #ifdef HAVE_WINDOW_SYSTEM
784 /* Adjust size of F's child frames. */
785 Lisp_Object frames
, frame1
;
787 FOR_EACH_FRAME (frames
, frame1
)
788 if (FRAME_PARENT_FRAME (XFRAME (frame1
)) == f
)
789 keep_ratio (XFRAME (frame1
), f
, old_pixel_width
, old_pixel_height
,
790 new_pixel_width
, new_pixel_height
);
795 /* Allocate basically initialized frame. */
797 static struct frame
*
798 allocate_frame (void)
800 return ALLOCATE_ZEROED_PSEUDOVECTOR (struct frame
, face_cache
, PVEC_FRAME
);
804 make_frame (bool mini_p
)
808 struct window
*rw
, *mw UNINIT
;
809 Lisp_Object root_window
;
810 Lisp_Object mini_window
;
812 f
= allocate_frame ();
813 XSETFRAME (frame
, f
);
816 /* Initialize Lisp data. Note that allocate_frame initializes all
817 Lisp data to nil, so do it only for slots which should not be nil. */
818 fset_tool_bar_position (f
, Qtop
);
821 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
822 non-Lisp data, so do it only for slots which should not be zero.
823 To avoid subtle bugs and for the sake of readability, it's better to
824 initialize enum members explicitly even if their values are zero. */
825 f
->wants_modeline
= true;
828 f
->can_x_set_window_size
= false;
829 f
->after_make_frame
= false;
830 f
->inhibit_horizontal_resize
= false;
831 f
->inhibit_vertical_resize
= false;
832 f
->tool_bar_redisplayed
= false;
833 f
->tool_bar_resized
= false;
834 f
->column_width
= 1; /* !FRAME_WINDOW_P value. */
835 f
->line_height
= 1; /* !FRAME_WINDOW_P value. */
836 #ifdef HAVE_WINDOW_SYSTEM
837 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
838 f
->horizontal_scroll_bars
= false;
839 f
->want_fullscreen
= FULLSCREEN_NONE
;
840 f
->undecorated
= false;
841 f
->no_special_glyphs
= false;
843 f
->override_redirect
= false;
845 f
->skip_taskbar
= false;
846 f
->no_focus_on_map
= false;
847 f
->no_accept_focus
= false;
848 f
->z_group
= z_group_none
;
849 #if ! defined (USE_GTK) && ! defined (HAVE_NS)
850 f
->last_tool_bar_item
= -1;
853 f
->ns_appearance
= ns_appearance_aqua
;
854 f
->ns_transparent_titlebar
= false;
858 root_window
= make_window ();
859 rw
= XWINDOW (root_window
);
862 mini_window
= make_window ();
863 mw
= XWINDOW (mini_window
);
864 wset_next (rw
, mini_window
);
865 wset_prev (mw
, root_window
);
867 wset_frame (mw
, frame
);
868 fset_minibuffer_window (f
, mini_window
);
869 store_frame_param (f
, Qminibuffer
, Qt
);
874 wset_next (rw
, Qnil
);
875 fset_minibuffer_window (f
, Qnil
);
878 wset_frame (rw
, frame
);
881 just so that there is "something there."
882 Correct size will be set up later with adjust_frame_size. */
884 SET_FRAME_COLS (f
, 10);
885 SET_FRAME_LINES (f
, 10);
886 SET_FRAME_WIDTH (f
, FRAME_COLS (f
) * FRAME_COLUMN_WIDTH (f
));
887 SET_FRAME_HEIGHT (f
, FRAME_LINES (f
) * FRAME_LINE_HEIGHT (f
));
890 rw
->pixel_width
= rw
->total_cols
* FRAME_COLUMN_WIDTH (f
);
891 rw
->total_lines
= mini_p
? 9 : 10;
892 rw
->pixel_height
= rw
->total_lines
* FRAME_LINE_HEIGHT (f
);
896 mw
->top_line
= rw
->total_lines
;
897 mw
->pixel_top
= rw
->pixel_height
;
898 mw
->total_cols
= rw
->total_cols
;
899 mw
->pixel_width
= rw
->pixel_width
;
901 mw
->pixel_height
= FRAME_LINE_HEIGHT (f
);
904 /* Choose a buffer for the frame's root window. */
906 Lisp_Object buf
= Fcurrent_buffer ();
908 /* If current buffer is hidden, try to find another one. */
909 if (BUFFER_HIDDEN_P (XBUFFER (buf
)))
910 buf
= other_buffer_safely (buf
);
912 /* Use set_window_buffer, not Fset_window_buffer, and don't let
913 hooks be run by it. The reason is that the whole frame/window
914 arrangement is not yet fully initialized at this point. Windows
915 don't have the right size, glyph matrices aren't initialized
916 etc. Running Lisp functions at this point surely ends in a
918 set_window_buffer (root_window
, buf
, 0, 0);
919 fset_buffer_list (f
, list1 (buf
));
924 set_window_buffer (mini_window
,
925 (NILP (Vminibuffer_list
)
927 : Fcar (Vminibuffer_list
)),
929 /* No horizontal scroll bars in minibuffers. */
930 wset_horizontal_scroll_bar (mw
, Qnil
);
933 fset_root_window (f
, root_window
);
934 fset_selected_window (f
, root_window
);
935 /* Make sure this window seems more recently used than
936 a newly-created, never-selected window. */
937 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
942 #ifdef HAVE_WINDOW_SYSTEM
943 /* Make a frame using a separate minibuffer window on another frame.
944 MINI_WINDOW is the minibuffer window to use. nil means use the
945 default (the global minibuffer). */
948 make_frame_without_minibuffer (Lisp_Object mini_window
, KBOARD
*kb
,
953 if (!NILP (mini_window
))
954 CHECK_LIVE_WINDOW (mini_window
);
956 if (!NILP (mini_window
)
957 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
958 error ("Frame and minibuffer must be on the same terminal");
960 /* Make a frame containing just a root window. */
963 if (NILP (mini_window
))
965 /* Use default-minibuffer-frame if possible. */
966 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
967 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
969 Lisp_Object frame_dummy
;
971 XSETFRAME (frame_dummy
, f
);
972 /* If there's no minibuffer frame to use, create one. */
973 kset_default_minibuffer_frame
974 (kb
, call1 (intern ("make-initial-minibuffer-frame"), display
));
978 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
981 fset_minibuffer_window (f
, mini_window
);
982 store_frame_param (f
, Qminibuffer
, mini_window
);
984 /* Make the chosen minibuffer window display the proper minibuffer,
985 unless it is already showing a minibuffer. */
986 if (NILP (Fmemq (XWINDOW (mini_window
)->contents
, Vminibuffer_list
)))
987 /* Use set_window_buffer instead of Fset_window_buffer (see
988 discussion of bug#11984, bug#12025, bug#12026). */
989 set_window_buffer (mini_window
,
990 (NILP (Vminibuffer_list
)
992 : Fcar (Vminibuffer_list
)), 0, 0);
996 /* Make a frame containing only a minibuffer window. */
999 make_minibuffer_frame (void)
1001 /* First make a frame containing just a root window, no minibuffer. */
1003 register struct frame
*f
= make_frame (0);
1004 register Lisp_Object mini_window
;
1005 register Lisp_Object frame
;
1007 XSETFRAME (frame
, f
);
1012 f
->wants_modeline
= 0;
1014 /* Now label the root window as also being the minibuffer.
1015 Avoid infinite looping on the window chain by marking next pointer
1018 mini_window
= f
->root_window
;
1019 fset_minibuffer_window (f
, mini_window
);
1020 store_frame_param (f
, Qminibuffer
, Qonly
);
1021 XWINDOW (mini_window
)->mini
= 1;
1022 wset_next (XWINDOW (mini_window
), Qnil
);
1023 wset_prev (XWINDOW (mini_window
), Qnil
);
1024 wset_frame (XWINDOW (mini_window
), frame
);
1026 /* Put the proper buffer in that window. */
1028 /* Use set_window_buffer instead of Fset_window_buffer (see
1029 discussion of bug#11984, bug#12025, bug#12026). */
1030 set_window_buffer (mini_window
,
1031 (NILP (Vminibuffer_list
)
1032 ? get_minibuffer (0)
1033 : Fcar (Vminibuffer_list
)), 0, 0);
1036 #endif /* HAVE_WINDOW_SYSTEM */
1038 /* Construct a frame that refers to a terminal. */
1040 static printmax_t tty_frame_count
;
1043 make_initial_frame (void)
1046 struct terminal
*terminal
;
1049 eassert (initial_kboard
);
1051 /* The first call must initialize Vframe_list. */
1052 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
1055 terminal
= init_initial_terminal ();
1058 XSETFRAME (frame
, f
);
1060 Vframe_list
= Fcons (frame
, Vframe_list
);
1062 tty_frame_count
= 1;
1063 fset_name (f
, build_pure_c_string ("F1"));
1065 SET_FRAME_VISIBLE (f
, 1);
1067 f
->output_method
= terminal
->type
;
1068 f
->terminal
= terminal
;
1069 f
->terminal
->reference_count
++;
1070 f
->output_data
.nothing
= 0;
1072 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
1073 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
1075 #ifdef HAVE_WINDOW_SYSTEM
1076 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
1077 f
->horizontal_scroll_bars
= false;
1080 /* The default value of menu-bar-mode is t. */
1081 set_menu_bar_lines (f
, make_number (1), Qnil
);
1083 /* Allocate glyph matrices. */
1084 adjust_frame_glyphs (f
);
1086 if (!noninteractive
)
1087 init_frame_faces (f
);
1089 last_nonminibuf_frame
= f
;
1091 f
->can_x_set_window_size
= true;
1092 f
->after_make_frame
= true;
1098 static struct frame
*
1099 make_terminal_frame (struct terminal
*terminal
)
1101 register struct frame
*f
;
1103 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
1105 if (!terminal
->name
)
1106 error ("Terminal is not live, can't create new frames on it");
1110 XSETFRAME (frame
, f
);
1111 Vframe_list
= Fcons (frame
, Vframe_list
);
1113 fset_name (f
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
1115 SET_FRAME_VISIBLE (f
, 1);
1117 f
->terminal
= terminal
;
1118 f
->terminal
->reference_count
++;
1120 f
->output_data
.tty
= &the_only_tty_output
;
1121 f
->output_data
.tty
->display_info
= &the_only_display_info
;
1122 if (!inhibit_window_system
1123 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
1124 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
1125 f
->output_method
= output_msdos_raw
;
1127 f
->output_method
= output_termcap
;
1128 #else /* not MSDOS */
1129 f
->output_method
= output_termcap
;
1130 create_tty_output (f
);
1131 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
1132 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
1133 #endif /* not MSDOS */
1135 #ifdef HAVE_WINDOW_SYSTEM
1136 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
1137 f
->horizontal_scroll_bars
= false;
1140 FRAME_MENU_BAR_LINES (f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
1141 FRAME_LINES (f
) = FRAME_LINES (f
) - FRAME_MENU_BAR_LINES (f
);
1142 FRAME_MENU_BAR_HEIGHT (f
) = FRAME_MENU_BAR_LINES (f
) * FRAME_LINE_HEIGHT (f
);
1143 FRAME_TEXT_HEIGHT (f
) = FRAME_TEXT_HEIGHT (f
) - FRAME_MENU_BAR_HEIGHT (f
);
1145 /* Set the top frame to the newly created frame. */
1146 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
1147 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
1148 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f
)->top_frame
), 2); /* obscured */
1150 FRAME_TTY (f
)->top_frame
= frame
;
1152 if (!noninteractive
)
1153 init_frame_faces (f
);
1158 /* Get a suitable value for frame parameter PARAMETER for a newly
1159 created frame, based on (1) the user-supplied frame parameter
1160 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
1163 get_future_frame_param (Lisp_Object parameter
,
1164 Lisp_Object supplied_parms
,
1165 char *current_value
)
1169 result
= Fassq (parameter
, supplied_parms
);
1171 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
1172 if (NILP (result
) && current_value
!= NULL
)
1173 result
= build_string (current_value
);
1174 if (!NILP (result
) && !STRINGP (result
))
1175 result
= XCDR (result
);
1176 if (NILP (result
) || !STRINGP (result
))
1182 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
1184 doc
: /* Create an additional terminal frame, possibly on another terminal.
1185 This function takes one argument, an alist specifying frame parameters.
1187 You can create multiple frames on a single text terminal, but only one
1188 of them (the selected terminal frame) is actually displayed.
1190 In practice, generally you don't need to specify any parameters,
1191 except when you want to create a new frame on another terminal.
1192 In that case, the `tty' parameter specifies the device file to open,
1193 and the `tty-type' parameter specifies the terminal type. Example:
1195 (make-terminal-frame \\='((tty . "/dev/pts/5") (tty-type . "xterm")))
1197 Note that changing the size of one terminal frame automatically
1198 affects all frames on the same terminal device. */)
1202 struct terminal
*t
= NULL
;
1203 Lisp_Object frame
, tem
;
1204 struct frame
*sf
= SELECTED_FRAME ();
1207 if (sf
->output_method
!= output_msdos_raw
1208 && sf
->output_method
!= output_termcap
)
1210 #else /* not MSDOS */
1212 #ifdef WINDOWSNT /* This should work now! */
1213 if (sf
->output_method
!= output_termcap
)
1214 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
1216 #endif /* not MSDOS */
1219 Lisp_Object terminal
;
1221 terminal
= Fassq (Qterminal
, parms
);
1222 if (CONSP (terminal
))
1224 terminal
= XCDR (terminal
);
1225 t
= decode_live_terminal (terminal
);
1228 if (t
&& t
!= the_only_display_info
.terminal
)
1229 /* msdos.c assumes a single tty_display_info object. */
1230 error ("Multiple terminals are not supported on this platform");
1232 t
= the_only_display_info
.terminal
;
1238 char *name
= 0, *type
= 0;
1239 Lisp_Object tty
, tty_type
;
1242 tty
= get_future_frame_param
1243 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1244 ? FRAME_TTY (XFRAME (selected_frame
))->name
1247 SAFE_ALLOCA_STRING (name
, tty
);
1249 tty_type
= get_future_frame_param
1250 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1251 ? FRAME_TTY (XFRAME (selected_frame
))->type
1253 if (!NILP (tty_type
))
1254 SAFE_ALLOCA_STRING (type
, tty_type
);
1256 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
1260 f
= make_terminal_frame (t
);
1264 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
1265 adjust_frame_size (f
, width
, height
- FRAME_MENU_BAR_LINES (f
),
1266 5, 0, Qterminal_frame
);
1269 adjust_frame_glyphs (f
);
1270 calculate_costs (f
);
1271 XSETFRAME (frame
, f
);
1273 store_in_alist (&parms
, Qtty_type
, build_string (t
->display_info
.tty
->type
));
1274 store_in_alist (&parms
, Qtty
,
1275 (t
->display_info
.tty
->name
1276 ? build_string (t
->display_info
.tty
->name
)
1278 /* On terminal frames the `minibuffer' frame parameter is always
1279 virtually t. Avoid that a different value in parms causes
1280 complaints, see Bug#24758. */
1281 store_in_alist (&parms
, Qminibuffer
, Qt
);
1282 Fmodify_frame_parameters (frame
, parms
);
1284 /* Make the frame face alist be frame-specific, so that each
1285 frame could change its face definitions independently. */
1286 fset_face_alist (f
, Fcopy_alist (sf
->face_alist
));
1287 /* Simple Fcopy_alist isn't enough, because we need the contents of
1288 the vectors which are the CDRs of associations in face_alist to
1289 be copied as well. */
1290 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
1291 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
1293 f
->can_x_set_window_size
= true;
1294 f
->after_make_frame
= true;
1300 /* Perform the switch to frame FRAME.
1302 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
1305 If TRACK is non-zero and the frame that currently has the focus
1306 redirects its focus to the selected frame, redirect that focused
1307 frame's focus to FRAME instead.
1309 FOR_DELETION non-zero means that the selected frame is being
1310 deleted, which includes the possibility that the frame's terminal
1313 The value of NORECORD is passed as argument to Fselect_window. */
1316 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
1318 struct frame
*sf
= SELECTED_FRAME (), *f
;
1320 /* If FRAME is a switch-frame event, extract the frame we should
1323 && EQ (XCAR (frame
), Qswitch_frame
)
1324 && CONSP (XCDR (frame
)))
1325 frame
= XCAR (XCDR (frame
));
1327 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
1328 a switch-frame event to arrive after a frame is no longer live,
1329 especially when deleting the initial frame during startup. */
1330 CHECK_FRAME (frame
);
1332 if (!FRAME_LIVE_P (f
))
1337 /* If a frame's focus has been redirected toward the currently
1338 selected frame, we should change the redirection to point to the
1339 newly selected frame. This means that if the focus is redirected
1340 from a minibufferless frame to a surrogate minibuffer frame, we
1341 can use `other-window' to switch between all the frames using
1342 that minibuffer frame, and the focus redirection will follow us
1345 /* This is too greedy; it causes inappropriate focus redirection
1346 that's hard to get rid of. */
1351 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1355 if (!FRAMEP (XCAR (tail
)))
1358 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
1360 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1361 Fredirect_frame_focus (XCAR (tail
), frame
);
1365 /* Instead, apply it only to the frame we're pointing to. */
1366 #ifdef HAVE_WINDOW_SYSTEM
1367 if (track
&& FRAME_WINDOW_P (f
))
1369 Lisp_Object focus
, xfocus
;
1371 xfocus
= x_get_focus_frame (f
);
1372 if (FRAMEP (xfocus
))
1374 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
1375 if ((FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1376 /* Redirect frame focus also when FRAME has its minibuffer
1377 window on the selected frame (see Bug#24500). */
1379 && EQ (FRAME_MINIBUF_WINDOW (f
), sf
->selected_window
)))
1380 Fredirect_frame_focus (xfocus
, frame
);
1383 #endif /* HAVE_X_WINDOWS */
1386 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
1387 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
1389 if (FRAME_TERMCAP_P (f
) || FRAME_MSDOS_P (f
))
1391 struct tty_display_info
*tty
= FRAME_TTY (f
);
1392 Lisp_Object top_frame
= tty
->top_frame
;
1394 /* Don't mark the frame garbaged and/or obscured if we are
1395 switching to the frame that is already the top frame of that
1397 if (!EQ (frame
, top_frame
))
1399 if (FRAMEP (top_frame
))
1400 /* Mark previously displayed frame as now obscured. */
1401 SET_FRAME_VISIBLE (XFRAME (top_frame
), 2);
1402 SET_FRAME_VISIBLE (f
, 1);
1403 /* If the new TTY frame changed dimensions, we need to
1404 resync term.c's idea of the frame size with the new
1406 if (FRAME_COLS (f
) != FrameCols (tty
))
1407 FrameCols (tty
) = FRAME_COLS (f
);
1408 if (FRAME_TOTAL_LINES (f
) != FrameRows (tty
))
1409 FrameRows (tty
) = FRAME_TOTAL_LINES (f
);
1411 tty
->top_frame
= frame
;
1414 selected_frame
= frame
;
1415 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
1416 last_nonminibuf_frame
= XFRAME (selected_frame
);
1418 Fselect_window (f
->selected_window
, norecord
);
1420 /* We want to make sure that the next event generates a frame-switch
1421 event to the appropriate frame. This seems kludgy to me, but
1422 before you take it out, make sure that evaluating something like
1423 (select-window (frame-root-window (make-frame))) doesn't end up
1424 with your typing being interpreted in the new frame instead of
1425 the one you're actually typing in. */
1426 #ifdef HAVE_WINDOW_SYSTEM
1427 if (!frame_ancestor_p (f
, sf
))
1429 internal_last_event_frame
= Qnil
;
1434 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
1435 doc
: /* Select FRAME.
1436 Subsequent editing commands apply to its selected window.
1437 Optional argument NORECORD means to neither change the order of
1438 recently selected windows nor the buffer list.
1440 The selection of FRAME lasts until the next time the user does
1441 something to select a different frame, or until the next time
1442 this function is called. If you are using a window system, the
1443 previously selected frame may be restored as the selected frame
1444 when returning to the command loop, because it still may have
1445 the window system's input focus. On a text terminal, the next
1446 redisplay will display FRAME.
1448 This function returns FRAME, or nil if FRAME has been deleted. */)
1449 (Lisp_Object frame
, Lisp_Object norecord
)
1451 return do_switch_frame (frame
, 1, 0, norecord
);
1454 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "^e",
1455 doc
: /* Handle a switch-frame event EVENT.
1456 Switch-frame events are usually bound to this function.
1457 A switch-frame event tells Emacs that the window manager has requested
1458 that the user's events be directed to the frame mentioned in the event.
1459 This function selects the selected window of the frame of EVENT.
1461 If EVENT is frame object, handle it as if it were a switch-frame event
1467 /* Preserve prefix arg that the command loop just cleared. */
1468 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
1469 run_hook (Qmouse_leave_buffer_hook
);
1470 /* `switch-frame' implies a focus in. */
1471 value
= do_switch_frame (event
, 0, 0, Qnil
);
1472 call1 (intern ("handle-focus-in"), event
);
1476 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1477 doc
: /* Return the frame that is now selected. */)
1480 return selected_frame
;
1483 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1485 doc
: /* Return a list of all live frames. */)
1489 frames
= Fcopy_sequence (Vframe_list
);
1490 #ifdef HAVE_WINDOW_SYSTEM
1491 if (FRAMEP (tip_frame
)
1493 && !NILP (Fframe_parameter (tip_frame
, Qtooltip
))
1496 frames
= Fdelq (tip_frame
, frames
);
1501 DEFUN ("frame-parent", Fframe_parent
, Sframe_parent
,
1503 doc
: /* Return the parent frame of FRAME.
1504 The parent frame of FRAME is the Emacs frame whose window-system window
1505 is the parent window of FRAME's window-system window. When such a frame
1506 exists, FRAME is considered a child frame of that frame.
1508 Return nil if FRAME has no parent frame. This means that FRAME's
1509 window-system window is either a "top-level" window (a window whose
1510 parent window is the window-system's root window) or an embedded window
1511 \(a window whose parent window is owned by some other application). */)
1514 struct frame
*f
= decode_live_frame (frame
);
1515 struct frame
*p
= FRAME_PARENT_FRAME (f
);
1518 /* Can't return f->parent_frame directly since it might not be defined
1519 for this platform. */
1522 XSETFRAME (parent
, p
);
1530 #ifdef HAVE_WINDOW_SYSTEM
1532 frame_ancestor_p (struct frame
*af
, struct frame
*df
)
1534 struct frame
*pf
= FRAME_PARENT_FRAME (df
);
1541 pf
= FRAME_PARENT_FRAME (pf
);
1548 DEFUN ("frame-ancestor-p", Fframe_ancestor_p
, Sframe_ancestor_p
,
1550 doc
: /* Return non-nil if ANCESTOR is an ancestor of DESCENDANT.
1551 ANCESTOR is an ancestor of DESCENDANT when it is either DESCENDANT's
1552 parent frame or it is an ancestor of DESCENDANT's parent frame. Both,
1553 ANCESTOR and DESCENDANT must be live frames and default to the selected
1555 (Lisp_Object ancestor
, Lisp_Object descendant
)
1557 #ifdef HAVE_WINDOW_SYSTEM
1558 struct frame
*af
= decode_live_frame (ancestor
);
1559 struct frame
*df
= decode_live_frame (descendant
);
1561 return frame_ancestor_p (af
, df
) ? Qt
: Qnil
;
1567 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
1568 same tty (for tty frames) or among frames which uses FRAME's keyboard.
1569 If MINIBUF is nil, do not consider minibuffer-only candidate.
1570 If MINIBUF is `visible', do not consider an invisible candidate.
1571 If MINIBUF is a window, consider only its own frame and candidate now
1572 using that window as the minibuffer.
1573 If MINIBUF is 0, consider candidate if it is visible or iconified.
1574 Otherwise consider any candidate and return nil if CANDIDATE is not
1578 candidate_frame (Lisp_Object candidate
, Lisp_Object frame
, Lisp_Object minibuf
)
1580 struct frame
*c
= XFRAME (candidate
), *f
= XFRAME (frame
);
1582 if ((!FRAME_TERMCAP_P (c
) && !FRAME_TERMCAP_P (f
)
1583 && FRAME_KBOARD (c
) == FRAME_KBOARD (f
))
1584 || (FRAME_TERMCAP_P (c
) && FRAME_TERMCAP_P (f
)
1585 && FRAME_TTY (c
) == FRAME_TTY (f
)))
1587 if (!NILP (get_frame_param (c
, Qno_other_frame
)))
1589 else if (NILP (minibuf
))
1591 if (!FRAME_MINIBUF_ONLY_P (c
))
1594 else if (EQ (minibuf
, Qvisible
))
1596 if (FRAME_VISIBLE_P (c
))
1599 else if (WINDOWP (minibuf
))
1601 if (EQ (FRAME_MINIBUF_WINDOW (c
), minibuf
)
1602 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), candidate
)
1603 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1604 FRAME_FOCUS_FRAME (c
)))
1607 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
1609 if (FRAME_VISIBLE_P (c
) || FRAME_ICONIFIED_P (c
))
1618 /* Return the next frame in the frame list after FRAME. */
1621 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1623 Lisp_Object f
, tail
;
1626 eassume (CONSP (Vframe_list
));
1629 FOR_EACH_FRAME (tail
, f
)
1633 f
= candidate_frame (f
, frame
, minibuf
);
1643 /* Return the previous frame in the frame list before FRAME. */
1646 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1648 Lisp_Object f
, tail
, prev
= Qnil
;
1650 eassume (CONSP (Vframe_list
));
1652 FOR_EACH_FRAME (tail
, f
)
1654 if (EQ (frame
, f
) && !NILP (prev
))
1656 f
= candidate_frame (f
, frame
, minibuf
);
1661 /* We've scanned the entire list. */
1663 /* We went through the whole frame list without finding a single
1664 acceptable frame. Return the original frame. */
1667 /* There were no acceptable frames in the list before FRAME; otherwise,
1668 we would have returned directly from the loop. Since PREV is the last
1669 acceptable frame in the list, return it. */
1674 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1675 doc
: /* Return the next frame in the frame list after FRAME.
1676 It considers only frames on the same terminal as FRAME.
1677 By default, skip minibuffer-only frames.
1678 If omitted, FRAME defaults to the selected frame.
1679 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1680 If MINIFRAME is a window, include only its own frame
1681 and any frame now using that window as the minibuffer.
1682 If MINIFRAME is `visible', include all visible frames.
1683 If MINIFRAME is 0, include all visible and iconified frames.
1684 Otherwise, include all frames. */)
1685 (Lisp_Object frame
, Lisp_Object miniframe
)
1688 frame
= selected_frame
;
1689 CHECK_LIVE_FRAME (frame
);
1690 return next_frame (frame
, miniframe
);
1693 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1694 doc
: /* Return the previous frame in the frame list before FRAME.
1695 It considers only frames on the same terminal as FRAME.
1696 By default, skip minibuffer-only frames.
1697 If omitted, FRAME defaults to the selected frame.
1698 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1699 If MINIFRAME is a window, include only its own frame
1700 and any frame now using that window as the minibuffer.
1701 If MINIFRAME is `visible', include all visible frames.
1702 If MINIFRAME is 0, include all visible and iconified frames.
1703 Otherwise, include all frames. */)
1704 (Lisp_Object frame
, Lisp_Object miniframe
)
1707 frame
= selected_frame
;
1708 CHECK_LIVE_FRAME (frame
);
1709 return prev_frame (frame
, miniframe
);
1712 DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame
,
1713 Slast_nonminibuf_frame
, 0, 0, 0,
1714 doc
: /* Return last non-minibuffer frame selected. */)
1717 Lisp_Object frame
= Qnil
;
1719 if (last_nonminibuf_frame
)
1720 XSETFRAME (frame
, last_nonminibuf_frame
);
1728 * Return true if there exists at least one visible or iconified frame
1729 * but F. Return false otherwise.
1731 * INVISIBLE true means we are called from make_frame_invisible where
1732 * such a frame must be visible or iconified. INVISIBLE nil means we
1733 * are called from delete_frame. In that case FORCE true means that the
1734 * visibility status of such a frame can be ignored.
1736 * If F is the terminal frame and we are using X, return true if at
1737 * least one X frame exists.
1740 other_frames (struct frame
*f
, bool invisible
, bool force
)
1742 Lisp_Object frames
, frame
, frame1
;
1744 Lisp_Object minibuffer_window
= FRAME_MINIBUF_WINDOW (f
);
1746 XSETFRAME (frame
, f
);
1747 if (WINDOWP (minibuffer_window
)
1748 && !EQ (frame
, WINDOW_FRAME (XWINDOW (minibuffer_window
))))
1749 minibuffer_window
= Qnil
;
1751 FOR_EACH_FRAME (frames
, frame1
)
1753 f1
= XFRAME (frame1
);
1756 /* Verify that we can still talk to the frame's X window, and
1757 note any recent change in visibility. */
1758 #ifdef HAVE_X_WINDOWS
1759 if (FRAME_WINDOW_P (f1
))
1762 if (NILP (Fframe_parameter (frame1
, Qtooltip
))
1763 /* Tooltips and child frames count neither for
1764 invisibility nor for deletions. */
1765 && !FRAME_PARENT_FRAME (f1
)
1766 /* Frames with a non-nil `delete-before' parameter don't
1767 count for deletions. */
1768 && (invisible
|| NILP (get_frame_param (f1
, Qdelete_before
)))
1769 /* For invisibility and normal deletions, at least one
1770 visible or iconified frame must remain (Bug#26682). */
1771 && (FRAME_VISIBLE_P (f1
) || FRAME_ICONIFIED_P (f1
)
1774 /* Allow deleting the terminal frame when at
1775 least one X frame exists. */
1776 || (FRAME_WINDOW_P (f1
) && !FRAME_WINDOW_P (f
))))))
1784 /* Make sure that minibuf_window doesn't refer to FRAME's minibuffer
1785 window. Preferably use the selected frame's minibuffer window
1786 instead. If the selected frame doesn't have one, get some other
1787 frame's minibuffer window. SELECT non-zero means select the new
1788 minibuffer window. */
1790 check_minibuf_window (Lisp_Object frame
, int select
)
1792 struct frame
*f
= decode_live_frame (frame
);
1794 XSETFRAME (frame
, f
);
1796 if (WINDOWP (minibuf_window
) && EQ (f
->minibuffer_window
, minibuf_window
))
1798 Lisp_Object frames
, this, window
= make_number (0);
1800 if (!EQ (frame
, selected_frame
)
1801 && FRAME_HAS_MINIBUF_P (XFRAME (selected_frame
)))
1802 window
= FRAME_MINIBUF_WINDOW (XFRAME (selected_frame
));
1804 FOR_EACH_FRAME (frames
, this)
1806 if (!EQ (this, frame
) && FRAME_HAS_MINIBUF_P (XFRAME (this)))
1808 window
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1813 /* Don't abort if no window was found (Bug#15247). */
1814 if (WINDOWP (window
))
1816 /* Use set_window_buffer instead of Fset_window_buffer (see
1817 discussion of bug#11984, bug#12025, bug#12026). */
1818 set_window_buffer (window
, XWINDOW (minibuf_window
)->contents
, 0, 0);
1819 minibuf_window
= window
;
1821 /* SELECT non-zero usually means that FRAME's minibuffer
1822 window was selected; select the new one. */
1824 Fselect_window (minibuf_window
, Qnil
);
1833 * Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1834 * unconditionally. x_connection_closed and delete_terminal use this.
1835 * Any other value of FORCE implements the semantics described for
1838 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1840 struct frame
*f
= decode_any_frame (frame
);
1843 Lisp_Object frames
, frame1
;
1844 int minibuffer_selected
, is_tooltip_frame
;
1845 bool nochild
= !FRAME_PARENT_FRAME (f
);
1847 if (!FRAME_LIVE_P (f
))
1849 else if (!EQ (force
, Qnoelisp
) && !other_frames (f
, false, !NILP (force
)))
1852 error ("Attempt to delete the sole visible or iconified frame");
1854 error ("Attempt to delete the only frame");
1857 XSETFRAME (frame
, f
);
1859 /* Softly delete all frames with this frame as their parent frame or
1860 as their `delete-before' frame parameter value. */
1861 FOR_EACH_FRAME (frames
, frame1
)
1862 if (FRAME_PARENT_FRAME (XFRAME (frame1
)) == f
1863 /* Process `delete-before' parameter iff FRAME is not a child
1864 frame. This avoids that we enter an infinite chain of mixed
1867 && EQ (get_frame_param (XFRAME (frame1
), Qdelete_before
), frame
)))
1868 delete_frame (frame1
, Qnil
);
1870 /* Does this frame have a minibuffer, and is it the surrogate
1871 minibuffer for any other frame? */
1872 if (FRAME_HAS_MINIBUF_P (f
))
1874 FOR_EACH_FRAME (frames
, frame1
)
1878 if (EQ (frame1
, frame
))
1881 fminiw
= FRAME_MINIBUF_WINDOW (XFRAME (frame1
));
1883 if (WINDOWP (fminiw
) && EQ (frame
, WINDOW_FRAME (XWINDOW (fminiw
))))
1885 /* If we MUST delete this frame, delete the other first.
1886 But do this only if FORCE equals `noelisp'. */
1887 if (EQ (force
, Qnoelisp
))
1888 delete_frame (frame1
, Qnoelisp
);
1890 error ("Attempt to delete a surrogate minibuffer frame");
1895 is_tooltip_frame
= !NILP (Fframe_parameter (frame
, Qtooltip
));
1897 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1898 frame is a tooltip. FORCE is set to `noelisp' when handling
1899 a disconnect from the terminal, so we don't dare call Lisp
1901 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1903 else if (EQ (force
, Qnoelisp
))
1905 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1909 #ifdef HAVE_X_WINDOWS
1910 /* Also, save clipboard to the clipboard manager. */
1911 x_clipboard_manager_save_frame (frame
);
1914 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1917 /* delete_frame_functions may have deleted any frame, including this
1919 if (!FRAME_LIVE_P (f
))
1921 else if (!EQ (force
, Qnoelisp
) && !other_frames (f
, false, !NILP (force
)))
1924 error ("Attempt to delete the sole visible or iconified frame");
1926 error ("Attempt to delete the only frame");
1929 /* At this point, we are committed to deleting the frame.
1930 There is no more chance for errors to prevent it. */
1931 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1932 sf
= SELECTED_FRAME ();
1933 /* Don't let the frame remain selected. */
1937 Lisp_Object frame1 UNINIT
; /* This line works around GCC bug 85563. */
1938 eassume (CONSP (Vframe_list
));
1940 /* Look for another visible frame on the same terminal.
1941 Do not call next_frame here because it may loop forever.
1942 See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=15025. */
1943 FOR_EACH_FRAME (tail
, frame1
)
1944 if (!EQ (frame
, frame1
)
1945 && NILP (Fframe_parameter (frame1
, Qtooltip
))
1946 && (FRAME_TERMINAL (XFRAME (frame
))
1947 == FRAME_TERMINAL (XFRAME (frame1
)))
1948 && FRAME_VISIBLE_P (XFRAME (frame1
)))
1951 /* If there is none, find *some* other frame. */
1952 if (NILP (frame1
) || EQ (frame1
, frame
))
1954 FOR_EACH_FRAME (tail
, frame1
)
1956 if (!EQ (frame
, frame1
)
1957 && FRAME_LIVE_P (XFRAME (frame1
))
1958 && NILP (Fframe_parameter (frame1
, Qtooltip
)))
1960 /* Do not change a text terminal's top-frame. */
1961 struct frame
*f1
= XFRAME (frame1
);
1962 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1964 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1965 if (!EQ (top_frame
, frame
))
1972 #ifdef NS_IMPL_COCOA
1974 /* Under NS, there is no system mechanism for choosing a new
1975 window to get focus -- it is left to application code.
1976 So the portion of THIS application interfacing with NS
1977 needs to know about it. We call Fraise_frame, but the
1978 purpose is really to transfer focus. */
1979 Fraise_frame (frame1
);
1982 do_switch_frame (frame1
, 0, 1, Qnil
);
1983 sf
= SELECTED_FRAME ();
1986 /* Don't allow minibuf_window to remain on a deleted frame. */
1987 check_minibuf_window (frame
, minibuffer_selected
);
1989 /* Don't let echo_area_window to remain on a deleted frame. */
1990 if (EQ (f
->minibuffer_window
, echo_area_window
))
1991 echo_area_window
= sf
->minibuffer_window
;
1993 /* Clear any X selections for this frame. */
1994 #ifdef HAVE_X_WINDOWS
1996 x_clear_frame_selections (f
);
2000 This function must be called before the window tree of the
2001 frame is deleted because windows contain dynamically allocated
2005 #ifdef HAVE_WINDOW_SYSTEM
2006 /* Give chance to each font driver to free a frame specific data. */
2007 font_update_drivers (f
, Qnil
);
2010 /* Mark all the windows that used to be on FRAME as deleted, and then
2011 remove the reference to them. */
2012 delete_all_child_windows (f
->root_window
);
2013 fset_root_window (f
, Qnil
);
2015 Vframe_list
= Fdelq (frame
, Vframe_list
);
2016 SET_FRAME_VISIBLE (f
, 0);
2018 /* Allow the vector of menu bar contents to be freed in the next
2019 garbage collection. The frame object itself may not be garbage
2020 collected until much later, because recent_keys and other data
2021 structures can still refer to it. */
2022 fset_menu_bar_vector (f
, Qnil
);
2024 /* If FRAME's buffer lists contains killed
2025 buffers, this helps GC to reclaim them. */
2026 fset_buffer_list (f
, Qnil
);
2027 fset_buried_buffer_list (f
, Qnil
);
2029 free_font_driver_list (f
);
2030 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
2033 xfree (f
->decode_mode_spec_buffer
);
2034 xfree (FRAME_INSERT_COST (f
));
2035 xfree (FRAME_DELETEN_COST (f
));
2036 xfree (FRAME_INSERTN_COST (f
));
2037 xfree (FRAME_DELETE_COST (f
));
2039 /* Since some events are handled at the interrupt level, we may get
2040 an event for f at any time; if we zero out the frame's terminal
2041 now, then we may trip up the event-handling code. Instead, we'll
2042 promise that the terminal of the frame must be valid until we
2043 have called the window-system-dependent frame destruction
2046 struct terminal
*terminal
;
2048 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
2049 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
2050 terminal
= FRAME_TERMINAL (f
);
2051 f
->output_data
.nothing
= 0;
2052 f
->terminal
= 0; /* Now the frame is dead. */
2055 /* If needed, delete the terminal that this frame was on.
2056 (This must be done after the frame is killed.) */
2057 terminal
->reference_count
--;
2058 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
2059 /* FIXME: Deleting the terminal crashes emacs because of a GTK
2061 https://lists.gnu.org/r/emacs-devel/2011-10/msg00363.html */
2063 /* Since a similar behavior was observed on the Lucid and Motif
2064 builds (see Bug#5802, Bug#21509, Bug#23499, Bug#27816), we now
2065 don't delete the terminal for these builds either. */
2066 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
2067 terminal
->reference_count
= 1;
2068 #endif /* USE_X_TOOLKIT || USE_GTK */
2069 if (terminal
->reference_count
== 0)
2072 XSETTERMINAL (tmp
, terminal
);
2075 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
2078 kb
= terminal
->kboard
;
2081 /* If we've deleted the last_nonminibuf_frame, then try to find
2083 if (f
== last_nonminibuf_frame
)
2085 last_nonminibuf_frame
= 0;
2087 FOR_EACH_FRAME (frames
, frame1
)
2089 struct frame
*f1
= XFRAME (frame1
);
2091 if (!FRAME_MINIBUF_ONLY_P (f1
))
2093 last_nonminibuf_frame
= f1
;
2099 /* If there's no other frame on the same kboard, get out of
2100 single-kboard state if we're in it for this kboard. */
2103 /* Some frame we found on the same kboard, or nil if there are none. */
2104 Lisp_Object frame_on_same_kboard
= Qnil
;
2106 FOR_EACH_FRAME (frames
, frame1
)
2107 if (kb
== FRAME_KBOARD (XFRAME (frame1
)))
2108 frame_on_same_kboard
= frame1
;
2110 if (NILP (frame_on_same_kboard
))
2111 not_single_kboard_state (kb
);
2115 /* If we've deleted this keyboard's default_minibuffer_frame, try to
2116 find another one. Prefer minibuffer-only frames, but also notice
2117 frames with other windows. */
2118 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
2120 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
2121 Lisp_Object frame_with_minibuf
= Qnil
;
2122 /* Some frame we found on the same kboard, or nil if there are none. */
2123 Lisp_Object frame_on_same_kboard
= Qnil
;
2125 FOR_EACH_FRAME (frames
, frame1
)
2127 struct frame
*f1
= XFRAME (frame1
);
2129 /* Consider only frames on the same kboard
2130 and only those with minibuffers. */
2131 if (kb
== FRAME_KBOARD (f1
)
2132 && FRAME_HAS_MINIBUF_P (f1
))
2134 frame_with_minibuf
= frame1
;
2135 if (FRAME_MINIBUF_ONLY_P (f1
))
2139 if (kb
== FRAME_KBOARD (f1
))
2140 frame_on_same_kboard
= frame1
;
2143 if (!NILP (frame_on_same_kboard
))
2145 /* We know that there must be some frame with a minibuffer out
2146 there. If this were not true, all of the frames present
2147 would have to be minibufferless, which implies that at some
2148 point their minibuffer frames must have been deleted, but
2149 that is prohibited at the top; you can't delete surrogate
2150 minibuffer frames. */
2151 if (NILP (frame_with_minibuf
))
2154 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
2157 /* No frames left on this kboard--say no minibuffer either. */
2158 kset_default_minibuffer_frame (kb
, Qnil
);
2161 /* Cause frame titles to update--necessary if we now have just one frame. */
2162 if (!is_tooltip_frame
)
2163 update_mode_lines
= 15;
2168 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
2169 doc
: /* Delete FRAME, permanently eliminating it from use.
2170 FRAME must be a live frame and defaults to the selected one.
2172 A frame may not be deleted if its minibuffer serves as surrogate
2173 minibuffer for another frame. Normally, you may not delete a frame if
2174 all other frames are invisible, but if the second optional argument
2175 FORCE is non-nil, you may do so.
2177 This function runs `delete-frame-functions' before actually
2178 deleting the frame, unless the frame is a tooltip.
2179 The functions are run with one argument, the frame to be deleted. */)
2180 (Lisp_Object frame
, Lisp_Object force
)
2182 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
2185 #ifdef HAVE_WINDOW_SYSTEM
2187 * frame_internal_border_part:
2189 * Return part of internal border the coordinates X and Y relative to
2190 * frame F are on. Return nil if the coordinates are not on the
2191 * internal border of F.
2193 * Return one of INTERNAL_BORDER_LEFT_EDGE, INTERNAL_BORDER_TOP_EDGE,
2194 * INTERNAL_BORDER_RIGHT_EDGE or INTERNAL_BORDER_BOTTOM_EDGE when the
2195 * mouse cursor is on the corresponding border with an offset of at
2196 * least one canonical character height from that border's edges.
2198 * If no border part could be found this way, return one of
2199 * INTERNAL_BORDER_TOP_LEFT_CORNER, INTERNAL_BORDER_TOP_RIGHT_CORNER,
2200 * INTERNAL_BORDER_BOTTOM_LEFT_CORNER or
2201 * INTERNAL_BORDER_BOTTOM_RIGHT_CORNER to indicate that the mouse is in
2202 * one of the corresponding corners. This means that for very small
2203 * frames an `edge' return value is preferred.
2205 enum internal_border_part
2206 frame_internal_border_part (struct frame
*f
, int x
, int y
)
2208 int border
= FRAME_INTERNAL_BORDER_WIDTH (f
);
2209 int offset
= FRAME_LINE_HEIGHT (f
);
2210 int width
= FRAME_PIXEL_WIDTH (f
);
2211 int height
= FRAME_PIXEL_HEIGHT (f
);
2212 enum internal_border_part part
= INTERNAL_BORDER_NONE
;
2214 if (offset
< border
)
2215 /* For very wide borders make offset at least as large as
2219 if (offset
< x
&& x
< width
- offset
)
2220 /* Top or bottom border. */
2222 if (0 <= y
&& y
<= border
)
2223 part
= INTERNAL_BORDER_TOP_EDGE
;
2224 else if (height
- border
<= y
&& y
<= height
)
2225 part
= INTERNAL_BORDER_BOTTOM_EDGE
;
2227 else if (offset
< y
&& y
< height
- offset
)
2228 /* Left or right border. */
2230 if (0 <= x
&& x
<= border
)
2231 part
= INTERNAL_BORDER_LEFT_EDGE
;
2232 else if (width
- border
<= x
&& x
<= width
)
2233 part
= INTERNAL_BORDER_RIGHT_EDGE
;
2238 int half_width
= width
/ 2;
2239 int half_height
= height
/ 2;
2241 if (0 <= x
&& x
<= border
)
2244 if (0 <= y
&& y
<= half_height
)
2245 part
= INTERNAL_BORDER_TOP_LEFT_CORNER
;
2246 else if (half_height
< y
&& y
<= height
)
2247 part
= INTERNAL_BORDER_BOTTOM_LEFT_CORNER
;
2249 else if (width
- border
<= x
&& x
<= width
)
2252 if (0 <= y
&& y
<= half_height
)
2253 part
= INTERNAL_BORDER_TOP_RIGHT_CORNER
;
2254 else if (half_height
< y
&& y
<= height
)
2255 part
= INTERNAL_BORDER_BOTTOM_RIGHT_CORNER
;
2257 else if (0 <= y
&& y
<= border
)
2260 if (0 <= x
&& x
<= half_width
)
2261 part
= INTERNAL_BORDER_TOP_LEFT_CORNER
;
2262 else if (half_width
< x
&& x
<= width
)
2263 part
= INTERNAL_BORDER_TOP_RIGHT_CORNER
;
2265 else if (height
- border
<= y
&& y
<= height
)
2267 /* A bottom edge. */
2268 if (0 <= x
&& x
<= half_width
)
2269 part
= INTERNAL_BORDER_BOTTOM_LEFT_CORNER
;
2270 else if (half_width
< x
&& x
<= width
)
2271 part
= INTERNAL_BORDER_BOTTOM_RIGHT_CORNER
;
2279 /* Return mouse position in character cell units. */
2281 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
2282 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
2283 The position is given in canonical character cells, where (0, 0) is the
2284 upper-left corner of the frame, X is the horizontal offset, and Y is the
2285 vertical offset, measured in units of the frame's default character size.
2286 If Emacs is running on a mouseless terminal or hasn't been programmed
2287 to read the mouse position, it returns the selected frame for FRAME
2288 and nil for X and Y.
2289 If `mouse-position-function' is non-nil, `mouse-position' calls it,
2290 passing the normal return value to that function as an argument,
2291 and returns whatever that function returns. */)
2295 Lisp_Object lispy_dummy
;
2296 Lisp_Object x
, y
, retval
;
2298 f
= SELECTED_FRAME ();
2301 /* It's okay for the hook to refrain from storing anything. */
2302 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
2304 enum scroll_bar_part party_dummy
;
2306 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
2307 &lispy_dummy
, &party_dummy
,
2316 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
2320 XSETFRAME (lispy_dummy
, f
);
2321 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
2322 if (!NILP (Vmouse_position_function
))
2323 retval
= call1 (Vmouse_position_function
, retval
);
2327 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
2328 Smouse_pixel_position
, 0, 0, 0,
2329 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
2330 The position is given in pixel units, where (0, 0) is the
2331 upper-left corner of the frame, X is the horizontal offset, and Y is
2332 the vertical offset.
2333 If Emacs is running on a mouseless terminal or hasn't been programmed
2334 to read the mouse position, it returns the selected frame for FRAME
2335 and nil for X and Y. */)
2339 Lisp_Object lispy_dummy
;
2340 Lisp_Object x
, y
, retval
;
2342 f
= SELECTED_FRAME ();
2345 /* It's okay for the hook to refrain from storing anything. */
2346 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
2348 enum scroll_bar_part party_dummy
;
2350 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
2351 &lispy_dummy
, &party_dummy
,
2356 XSETFRAME (lispy_dummy
, f
);
2357 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
2358 if (!NILP (Vmouse_position_function
))
2359 retval
= call1 (Vmouse_position_function
, retval
);
2363 #ifdef HAVE_WINDOW_SYSTEM
2365 /* On frame F, convert character coordinates X and Y to pixel
2366 coordinates *PIX_X and *PIX_Y. */
2369 frame_char_to_pixel_position (struct frame
*f
, int x
, int y
,
2370 int *pix_x
, int *pix_y
)
2372 *pix_x
= FRAME_COL_TO_PIXEL_X (f
, x
) + FRAME_COLUMN_WIDTH (f
) / 2;
2373 *pix_y
= FRAME_LINE_TO_PIXEL_Y (f
, y
) + FRAME_LINE_HEIGHT (f
) / 2;
2377 if (*pix_x
> FRAME_PIXEL_WIDTH (f
))
2378 *pix_x
= FRAME_PIXEL_WIDTH (f
);
2382 if (*pix_y
> FRAME_PIXEL_HEIGHT (f
))
2383 *pix_y
= FRAME_PIXEL_HEIGHT (f
);
2386 /* On frame F, reposition mouse pointer to character coordinates X and Y. */
2389 frame_set_mouse_position (struct frame
*f
, int x
, int y
)
2393 frame_char_to_pixel_position (f
, x
, y
, &pix_x
, &pix_y
);
2394 frame_set_mouse_pixel_position (f
, pix_x
, pix_y
);
2397 #endif /* HAVE_WINDOW_SYSTEM */
2399 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
2400 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
2401 Coordinates are relative to the frame, not a window,
2402 so the coordinates of the top left character in the frame
2403 may be nonzero due to left-hand scroll bars or the menu bar.
2405 The position is given in canonical character cells, where (0, 0) is
2406 the upper-left corner of the frame, X is the horizontal offset, and
2407 Y is the vertical offset, measured in units of the frame's default
2410 This function is a no-op for an X frame that is not visible.
2411 If you have just created a frame, you must wait for it to become visible
2412 before calling this function on it, like this.
2413 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
2414 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
2416 CHECK_LIVE_FRAME (frame
);
2417 CHECK_TYPE_RANGED_INTEGER (int, x
);
2418 CHECK_TYPE_RANGED_INTEGER (int, y
);
2420 /* I think this should be done with a hook. */
2421 #ifdef HAVE_WINDOW_SYSTEM
2422 if (FRAME_WINDOW_P (XFRAME (frame
)))
2423 /* Warping the mouse will cause enternotify and focus events. */
2424 frame_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
2427 if (FRAME_MSDOS_P (XFRAME (frame
)))
2429 Fselect_frame (frame
, Qnil
);
2430 mouse_moveto (XINT (x
), XINT (y
));
2435 Fselect_frame (frame
, Qnil
);
2436 term_mouse_moveto (XINT (x
), XINT (y
));
2445 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
2446 Sset_mouse_pixel_position
, 3, 3, 0,
2447 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
2448 The position is given in pixels, where (0, 0) is the upper-left corner
2449 of the frame, X is the horizontal offset, and Y is the vertical offset.
2451 Note, this is a no-op for an X frame that is not visible.
2452 If you have just created a frame, you must wait for it to become visible
2453 before calling this function on it, like this.
2454 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
2455 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
2457 CHECK_LIVE_FRAME (frame
);
2458 CHECK_TYPE_RANGED_INTEGER (int, x
);
2459 CHECK_TYPE_RANGED_INTEGER (int, y
);
2461 /* I think this should be done with a hook. */
2462 #ifdef HAVE_WINDOW_SYSTEM
2463 if (FRAME_WINDOW_P (XFRAME (frame
)))
2464 /* Warping the mouse will cause enternotify and focus events. */
2465 frame_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
2468 if (FRAME_MSDOS_P (XFRAME (frame
)))
2470 Fselect_frame (frame
, Qnil
);
2471 mouse_moveto (XINT (x
), XINT (y
));
2476 Fselect_frame (frame
, Qnil
);
2477 term_mouse_moveto (XINT (x
), XINT (y
));
2486 static void make_frame_visible_1 (Lisp_Object
);
2488 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
2490 doc
: /* Make the frame FRAME visible (assuming it is an X window).
2491 If omitted, FRAME defaults to the currently selected frame. */)
2494 struct frame
*f
= decode_live_frame (frame
);
2496 /* I think this should be done with a hook. */
2497 #ifdef HAVE_WINDOW_SYSTEM
2498 if (FRAME_WINDOW_P (f
))
2499 x_make_frame_visible (f
);
2502 make_frame_visible_1 (f
->root_window
);
2504 /* Make menu bar update for the Buffers and Frames menus. */
2505 /* windows_or_buffers_changed = 15; FIXME: Why? */
2507 XSETFRAME (frame
, f
);
2511 /* Update the display_time slot of the buffers shown in WINDOW
2512 and all its descendants. */
2515 make_frame_visible_1 (Lisp_Object window
)
2519 for (; !NILP (window
); window
= w
->next
)
2521 w
= XWINDOW (window
);
2522 if (WINDOWP (w
->contents
))
2523 make_frame_visible_1 (w
->contents
);
2525 bset_display_time (XBUFFER (w
->contents
), Fcurrent_time ());
2529 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
2531 doc
: /* Make the frame FRAME invisible.
2532 If omitted, FRAME defaults to the currently selected frame.
2533 On graphical displays, invisible frames are not updated and are
2534 usually not displayed at all, even in a window system's \"taskbar\".
2536 Normally you may not make FRAME invisible if all other frames are invisible,
2537 but if the second optional argument FORCE is non-nil, you may do so.
2539 This function has no effect on text terminal frames. Such frames are
2540 always considered visible, whether or not they are currently being
2541 displayed in the terminal. */)
2542 (Lisp_Object frame
, Lisp_Object force
)
2544 struct frame
*f
= decode_live_frame (frame
);
2546 if (NILP (force
) && !other_frames (f
, true, false))
2547 error ("Attempt to make invisible the sole visible or iconified frame");
2549 /* Don't allow minibuf_window to remain on an invisible frame. */
2550 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2552 /* I think this should be done with a hook. */
2553 #ifdef HAVE_WINDOW_SYSTEM
2554 if (FRAME_WINDOW_P (f
))
2555 x_make_frame_invisible (f
);
2558 /* Make menu bar update for the Buffers and Frames menus. */
2559 windows_or_buffers_changed
= 16;
2564 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
2566 doc
: /* Make the frame FRAME into an icon.
2567 If omitted, FRAME defaults to the currently selected frame.
2569 If FRAME is a child frame, consult the variable `iconify-child-frame'
2570 for how to proceed. */)
2573 struct frame
*f
= decode_live_frame (frame
);
2574 #ifdef HAVE_WINDOW_SYSTEM
2575 Lisp_Object parent
= f
->parent_frame
;
2579 if (NILP (iconify_child_frame
))
2582 else if (EQ (iconify_child_frame
, Qiconify_top_level
))
2584 /* Iconify top level frame instead (the default). */
2585 Ficonify_frame (parent
);
2588 else if (EQ (iconify_child_frame
, Qmake_invisible
))
2590 /* Make frame invisible instead. */
2591 Fmake_frame_invisible (frame
, Qnil
);
2595 #endif /* HAVE_WINDOW_SYSTEM */
2597 /* Don't allow minibuf_window to remain on an iconified frame. */
2598 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2600 /* I think this should be done with a hook. */
2601 if (FRAME_WINDOW_P (f
))
2603 #ifdef HAVE_WINDOW_SYSTEM
2604 x_iconify_frame (f
);
2611 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
2613 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
2614 Return the symbol `icon' if FRAME is iconified or \"minimized\".
2615 Return nil if FRAME was made invisible, via `make-frame-invisible'.
2616 On graphical displays, invisible frames are not updated and are
2617 usually not displayed at all, even in a window system's \"taskbar\".
2619 If FRAME is a text terminal frame, this always returns t.
2620 Such frames are always considered visible, whether or not they are
2621 currently being displayed on the terminal. */)
2624 CHECK_LIVE_FRAME (frame
);
2626 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2628 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
2633 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
2635 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
2638 Lisp_Object tail
, frame
, value
= Qnil
;
2640 FOR_EACH_FRAME (tail
, frame
)
2641 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2642 value
= Fcons (frame
, value
);
2648 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
2649 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
2650 If FRAME is invisible or iconified, make it visible.
2651 If you don't specify a frame, the selected frame is used.
2652 If Emacs is displaying on an ordinary terminal or some other device which
2653 doesn't support multiple overlapping frames, this function selects FRAME. */)
2656 struct frame
*f
= decode_live_frame (frame
);
2658 XSETFRAME (frame
, f
);
2660 if (FRAME_TERMCAP_P (f
))
2661 /* On a text terminal select FRAME. */
2662 Fselect_frame (frame
, Qnil
);
2664 /* Do like the documentation says. */
2665 Fmake_frame_visible (frame
);
2667 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2668 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
2673 /* Should we have a corresponding function called Flower_Power? */
2674 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
2675 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2676 If you don't specify a frame, the selected frame is used.
2677 If Emacs is displaying on an ordinary terminal or some other device which
2678 doesn't support multiple overlapping frames, this function does nothing. */)
2681 struct frame
*f
= decode_live_frame (frame
);
2683 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2684 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2690 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2692 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2693 In other words, switch-frame events caused by events in FRAME will
2694 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2695 FOCUS-FRAME after reading an event typed at FRAME.
2697 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
2698 frame again receives its own keystrokes.
2700 Focus redirection is useful for temporarily redirecting keystrokes to
2701 a surrogate minibuffer frame when a frame doesn't have its own
2704 A frame's focus redirection can be changed by `select-frame'. If frame
2705 FOO is selected, and then a different frame BAR is selected, any
2706 frames redirecting their focus to FOO are shifted to redirect their
2707 focus to BAR. This allows focus redirection to work properly when the
2708 user switches from one frame to another using `select-window'.
2710 This means that a frame whose focus is redirected to itself is treated
2711 differently from a frame whose focus is redirected to nil; the former
2712 is affected by `select-frame', while the latter is not.
2714 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2715 (Lisp_Object frame
, Lisp_Object focus_frame
)
2717 /* Note that we don't check for a live frame here. It's reasonable
2718 to redirect the focus of a frame you're about to delete, if you
2719 know what other frame should receive those keystrokes. */
2720 struct frame
*f
= decode_any_frame (frame
);
2722 if (! NILP (focus_frame
))
2723 CHECK_LIVE_FRAME (focus_frame
);
2725 fset_focus_frame (f
, focus_frame
);
2727 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2728 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2734 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 0, 1, 0,
2735 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2736 If FRAME is omitted or nil, the selected frame is used.
2737 Return nil if FRAME's focus is not redirected.
2738 See `redirect-frame-focus'. */)
2741 return FRAME_FOCUS_FRAME (decode_live_frame (frame
));
2744 DEFUN ("x-focus-frame", Fx_focus_frame
, Sx_focus_frame
, 1, 2, 0,
2745 doc
: /* Set the input focus to FRAME.
2746 FRAME nil means use the selected frame. Optional argument NOACTIVATE
2747 means do not activate FRAME.
2749 If there is no window system support, this function does nothing. */)
2750 (Lisp_Object frame
, Lisp_Object noactivate
)
2752 #ifdef HAVE_WINDOW_SYSTEM
2753 x_focus_frame (decode_window_system_frame (frame
), !NILP (noactivate
));
2758 DEFUN ("frame-after-make-frame",
2759 Fframe_after_make_frame
,
2760 Sframe_after_make_frame
, 2, 2, 0,
2761 doc
: /* Mark FRAME as made.
2762 FRAME nil means use the selected frame. Second argument MADE non-nil
2763 means functions on `window-configuration-change-hook' are called
2764 whenever the window configuration of FRAME changes. MADE nil means
2765 these functions are not called.
2767 This function is currently called by `make-frame' only and should be
2768 otherwise used with utter care to avoid that running functions on
2769 `window-configuration-change-hook' is impeded forever. */)
2770 (Lisp_Object frame
, Lisp_Object made
)
2772 struct frame
*f
= decode_live_frame (frame
);
2773 f
->after_make_frame
= !NILP (made
);
2774 f
->inhibit_horizontal_resize
= false;
2775 f
->inhibit_vertical_resize
= false;
2780 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2783 frames_discard_buffer (Lisp_Object buffer
)
2785 Lisp_Object frame
, tail
;
2787 FOR_EACH_FRAME (tail
, frame
)
2790 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
2791 fset_buried_buffer_list
2792 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
2796 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2797 If the alist already has an element for PROP, we change it. */
2800 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2802 register Lisp_Object tem
;
2804 tem
= Fassq (prop
, *alistptr
);
2806 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2812 frame_name_fnn_p (char *str
, ptrdiff_t len
)
2814 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
2817 while ('0' <= *p
&& *p
<= '9')
2825 /* Set the name of the terminal frame. Also used by MSDOS frames.
2826 Modeled after x_set_name which is used for WINDOW frames. */
2829 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2831 f
->explicit_name
= ! NILP (name
);
2833 /* If NAME is nil, set the name to F<num>. */
2836 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
2838 /* Check for no change needed in this very common case
2839 before we do any consing. */
2840 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
2843 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
2847 CHECK_STRING (name
);
2849 /* Don't change the name if it's already NAME. */
2850 if (! NILP (Fstring_equal (name
, f
->name
)))
2853 /* Don't allow the user to set the frame name to F<num>, so it
2854 doesn't clash with the names we generate for terminal frames. */
2855 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2856 error ("Frame names of the form F<num> are usurped by Emacs");
2859 fset_name (f
, name
);
2860 update_mode_lines
= 16;
2864 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2866 register Lisp_Object old_alist_elt
;
2868 if (EQ (prop
, Qminibuffer
))
2872 if (!MINI_WINDOW_P (XWINDOW (val
)))
2873 error ("The `minibuffer' parameter does not specify a valid minibuffer window");
2874 else if (FRAME_MINIBUF_ONLY_P (f
))
2876 if (EQ (val
, FRAME_MINIBUF_WINDOW (f
)))
2879 error ("Can't change the minibuffer window of a minibuffer-only frame");
2881 else if (FRAME_HAS_MINIBUF_P (f
))
2883 if (EQ (val
, FRAME_MINIBUF_WINDOW (f
)))
2886 error ("Can't change the minibuffer window of a frame with its own minibuffer");
2889 /* Store the chosen minibuffer window. */
2890 fset_minibuffer_window (f
, val
);
2894 Lisp_Object old_val
= Fcdr (Fassq (Qminibuffer
, f
->param_alist
));
2896 if (!NILP (old_val
))
2898 if (WINDOWP (old_val
) && NILP (val
))
2899 /* Don't change the value for a minibuffer-less frame if
2900 only nil was specified as new value. */
2902 else if (!EQ (old_val
, val
))
2903 error ("Can't change the `minibuffer' parameter of this frame");
2908 /* Check each parent-frame and delete-before parameter for a
2909 circular dependency. Do not check between parameters, so you can
2910 still create circular dependencies with different properties, for
2911 example a chain of frames F1->F2->...Fn such that F1 is an ancestor
2912 frame of Fn and thus cannot be deleted before Fn and a second chain
2913 Fn->Fn-1->...F1 such that Fn cannot be deleted before F1. */
2914 else if (EQ (prop
, Qparent_frame
) || EQ (prop
, Qdelete_before
))
2916 Lisp_Object oldval
= Fcdr (Fassq (prop
, f
->param_alist
));
2918 if (!EQ (oldval
, val
) && !NILP (val
))
2921 Lisp_Object frame1
= val
;
2923 if (!FRAMEP (frame1
) || !FRAME_LIVE_P (XFRAME (frame1
)))
2924 error ("Invalid `%s' frame parameter",
2925 SSDATA (SYMBOL_NAME (prop
)));
2927 XSETFRAME (frame
, f
);
2929 while (FRAMEP (frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
2930 if (EQ (frame1
, frame
))
2931 error ("Circular specification of `%s' frame parameter",
2932 SSDATA (SYMBOL_NAME (prop
)));
2934 frame1
= get_frame_param (XFRAME (frame1
), prop
);
2938 /* The buffer-list parameters are stored in a special place and not
2939 in the alist. All buffers must be live. */
2940 else if (EQ (prop
, Qbuffer_list
))
2942 Lisp_Object list
= Qnil
;
2943 for (; CONSP (val
); val
= XCDR (val
))
2944 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2945 list
= Fcons (XCAR (val
), list
);
2946 fset_buffer_list (f
, Fnreverse (list
));
2949 else if (EQ (prop
, Qburied_buffer_list
))
2951 Lisp_Object list
= Qnil
;
2952 for (; CONSP (val
); val
= XCDR (val
))
2953 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2954 list
= Fcons (XCAR (val
), list
);
2955 fset_buried_buffer_list (f
, Fnreverse (list
));
2959 /* The tty color needed to be set before the frame's parameter
2960 alist was updated with the new value. This is not true any more,
2961 but we still do this test early on. */
2962 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2963 && f
== FRAME_TTY (f
)->previous_frame
)
2964 /* Force redisplay of this tty. */
2965 FRAME_TTY (f
)->previous_frame
= NULL
;
2967 /* Update the frame parameter alist. */
2968 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2969 if (EQ (old_alist_elt
, Qnil
))
2970 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2972 Fsetcdr (old_alist_elt
, val
);
2974 /* Update some other special parameters in their special places
2975 in addition to the alist. */
2977 if (EQ (prop
, Qbuffer_predicate
))
2978 fset_buffer_predicate (f
, val
);
2980 if (! FRAME_WINDOW_P (f
))
2982 if (EQ (prop
, Qmenu_bar_lines
))
2983 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2984 else if (EQ (prop
, Qname
))
2985 set_term_frame_name (f
, val
);
2989 /* Return color matches UNSPEC on frame F or nil if UNSPEC
2990 is not an unspecified foreground or background color. */
2993 frame_unspecified_color (struct frame
*f
, Lisp_Object unspec
)
2995 return (!strncmp (SSDATA (unspec
), unspecified_bg
, SBYTES (unspec
))
2996 ? tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
))
2997 : (!strncmp (SSDATA (unspec
), unspecified_fg
, SBYTES (unspec
))
2998 ? tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)) : Qnil
));
3001 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
3002 doc
: /* Return the parameters-alist of frame FRAME.
3003 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
3004 The meaningful PARMs depend on the kind of frame.
3005 If FRAME is omitted or nil, return information on the currently selected frame. */)
3009 struct frame
*f
= decode_any_frame (frame
);
3012 if (!FRAME_LIVE_P (f
))
3015 alist
= Fcopy_alist (f
->param_alist
);
3017 if (!FRAME_WINDOW_P (f
))
3021 /* If the frame's parameter alist says the colors are
3022 unspecified and reversed, take the frame's background pixel
3023 for foreground and vice versa. */
3024 elt
= Fassq (Qforeground_color
, alist
);
3025 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
3027 elt
= frame_unspecified_color (f
, XCDR (elt
));
3029 store_in_alist (&alist
, Qforeground_color
, elt
);
3032 store_in_alist (&alist
, Qforeground_color
,
3033 tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)));
3034 elt
= Fassq (Qbackground_color
, alist
);
3035 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
3037 elt
= frame_unspecified_color (f
, XCDR (elt
));
3039 store_in_alist (&alist
, Qbackground_color
, elt
);
3042 store_in_alist (&alist
, Qbackground_color
,
3043 tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
)));
3044 store_in_alist (&alist
, Qfont
,
3045 build_string (FRAME_MSDOS_P (f
)
3047 : FRAME_W32_P (f
) ? "w32term"
3050 store_in_alist (&alist
, Qname
, f
->name
);
3051 height
= (f
->new_height
3053 ? (f
->new_height
/ FRAME_LINE_HEIGHT (f
))
3056 store_in_alist (&alist
, Qheight
, make_number (height
));
3057 width
= (f
->new_width
3059 ? (f
->new_width
/ FRAME_COLUMN_WIDTH (f
))
3062 store_in_alist (&alist
, Qwidth
, make_number (width
));
3063 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
3064 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
3065 store_in_alist (&alist
, Qbuffer_list
, f
->buffer_list
);
3066 store_in_alist (&alist
, Qburied_buffer_list
, f
->buried_buffer_list
);
3068 /* I think this should be done with a hook. */
3069 #ifdef HAVE_WINDOW_SYSTEM
3070 if (FRAME_WINDOW_P (f
))
3071 x_report_frame_params (f
, &alist
);
3075 /* This ought to be correct in f->param_alist for an X frame. */
3077 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
3078 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
3085 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
3086 doc
: /* Return FRAME's value for parameter PARAMETER.
3087 If FRAME is nil, describe the currently selected frame. */)
3088 (Lisp_Object frame
, Lisp_Object parameter
)
3090 struct frame
*f
= decode_any_frame (frame
);
3091 Lisp_Object value
= Qnil
;
3093 CHECK_SYMBOL (parameter
);
3095 XSETFRAME (frame
, f
);
3097 if (FRAME_LIVE_P (f
))
3099 /* Avoid consing in frequent cases. */
3100 if (EQ (parameter
, Qname
))
3102 #ifdef HAVE_WINDOW_SYSTEM
3103 /* These are used by vertical motion commands. */
3104 else if (EQ (parameter
, Qvertical_scroll_bars
))
3105 value
= (f
->vertical_scroll_bar_type
== vertical_scroll_bar_none
3107 : (f
->vertical_scroll_bar_type
== vertical_scroll_bar_left
3109 else if (EQ (parameter
, Qhorizontal_scroll_bars
))
3110 value
= f
->horizontal_scroll_bars
? Qt
: Qnil
;
3111 else if (EQ (parameter
, Qline_spacing
) && f
->extra_line_spacing
== 0)
3112 /* If this is non-zero, we can't determine whether the user specified
3113 an integer or float value without looking through 'param_alist'. */
3114 value
= make_number (0);
3115 else if (EQ (parameter
, Qfont
) && FRAME_X_P (f
))
3116 value
= FRAME_FONT (f
)->props
[FONT_NAME_INDEX
];
3117 #endif /* HAVE_WINDOW_SYSTEM */
3118 #ifdef HAVE_X_WINDOWS
3119 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
3120 value
= XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
);
3121 #endif /* HAVE_X_WINDOWS */
3122 else if (EQ (parameter
, Qbackground_color
)
3123 || EQ (parameter
, Qforeground_color
))
3125 value
= Fassq (parameter
, f
->param_alist
);
3128 value
= XCDR (value
);
3129 /* Fframe_parameters puts the actual fg/bg color names,
3130 even if f->param_alist says otherwise. This is
3131 important when param_alist's notion of colors is
3132 "unspecified". We need to do the same here. */
3133 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
3135 Lisp_Object tem
= frame_unspecified_color (f
, value
);
3142 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
3144 else if (EQ (parameter
, Qdisplay_type
)
3145 || EQ (parameter
, Qbackground_mode
))
3146 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
3148 /* FIXME: Avoid this code path at all (as well as code duplication)
3149 by sharing more code with Fframe_parameters. */
3150 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
3157 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
3158 Smodify_frame_parameters
, 2, 2, 0,
3159 doc
: /* Modify FRAME according to new values of its parameters in ALIST.
3160 If FRAME is nil, it defaults to the selected frame.
3161 ALIST is an alist of parameters to change and their new values.
3162 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
3163 Which PARMs are meaningful depends on the kind of frame.
3164 The meaningful parameters are acted upon, i.e. the frame is changed
3165 according to their new values, and are also stored in the frame's
3166 parameter list so that `frame-parameters' will return them.
3167 PARMs that are not meaningful are still stored in the frame's parameter
3168 list, but are otherwise ignored. */)
3169 (Lisp_Object frame
, Lisp_Object alist
)
3171 struct frame
*f
= decode_live_frame (frame
);
3172 Lisp_Object prop
, val
;
3174 /* I think this should be done with a hook. */
3175 #ifdef HAVE_WINDOW_SYSTEM
3176 if (FRAME_WINDOW_P (f
))
3177 x_set_frame_parameters (f
, alist
);
3181 if (FRAME_MSDOS_P (f
))
3182 IT_set_frame_parameters (f
, alist
);
3187 EMACS_INT length
= XFASTINT (Flength (alist
));
3190 Lisp_Object
*values
;
3192 SAFE_ALLOCA_LISP (parms
, 2 * length
);
3193 values
= parms
+ length
;
3195 /* Extract parm names and values into those vectors. */
3197 for (i
= 0; CONSP (alist
); alist
= XCDR (alist
))
3202 parms
[i
] = Fcar (elt
);
3203 values
[i
] = Fcdr (elt
);
3207 /* Now process them in reverse of specified order. */
3212 store_frame_param (f
, prop
, val
);
3214 if (EQ (prop
, Qforeground_color
)
3215 || EQ (prop
, Qbackground_color
))
3216 update_face_from_frame_parameter (f
, prop
, val
);
3224 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
3226 doc
: /* Height in pixels of a line in the font in frame FRAME.
3227 If FRAME is omitted or nil, the selected frame is used.
3228 For a terminal frame, the value is always 1. */)
3231 #ifdef HAVE_WINDOW_SYSTEM
3232 struct frame
*f
= decode_any_frame (frame
);
3234 if (FRAME_WINDOW_P (f
))
3235 return make_number (FRAME_LINE_HEIGHT (f
));
3238 return make_number (1);
3242 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
3244 doc
: /* Width in pixels of characters in the font in frame FRAME.
3245 If FRAME is omitted or nil, the selected frame is used.
3246 On a graphical screen, the width is the standard width of the default font.
3247 For a terminal screen, the value is always 1. */)
3250 #ifdef HAVE_WINDOW_SYSTEM
3251 struct frame
*f
= decode_any_frame (frame
);
3253 if (FRAME_WINDOW_P (f
))
3254 return make_number (FRAME_COLUMN_WIDTH (f
));
3257 return make_number (1);
3260 DEFUN ("frame-native-width", Fframe_native_width
,
3261 Sframe_native_width
, 0, 1, 0,
3262 doc
: /* Return FRAME's native width in pixels.
3263 For a terminal frame, the result really gives the width in characters.
3264 If FRAME is omitted or nil, the selected frame is used. */)
3267 struct frame
*f
= decode_any_frame (frame
);
3269 #ifdef HAVE_WINDOW_SYSTEM
3270 if (FRAME_WINDOW_P (f
))
3271 return make_number (FRAME_PIXEL_WIDTH (f
));
3274 return make_number (FRAME_TOTAL_COLS (f
));
3277 DEFUN ("frame-native-height", Fframe_native_height
,
3278 Sframe_native_height
, 0, 1, 0,
3279 doc
: /* Return FRAME's native height in pixels.
3280 If FRAME is omitted or nil, the selected frame is used. The exact value
3281 of the result depends on the window-system and toolkit in use:
3283 In the Gtk+ and NS versions, it includes only any window (including the
3284 minibuffer or echo area), mode line, and header line. It does not
3285 include the tool bar or menu bar. With other graphical versions, it may
3286 also include the tool bar and the menu bar.
3288 For a text terminal, it includes the menu bar. In this case, the
3289 result is really in characters rather than pixels (i.e., is identical
3290 to `frame-height'). */)
3293 struct frame
*f
= decode_any_frame (frame
);
3295 #ifdef HAVE_WINDOW_SYSTEM
3296 if (FRAME_WINDOW_P (f
))
3297 return make_number (FRAME_PIXEL_HEIGHT (f
));
3300 return make_number (FRAME_TOTAL_LINES (f
));
3303 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
3304 Stool_bar_pixel_width
, 0, 1, 0,
3305 doc
: /* Return width in pixels of FRAME's tool bar.
3306 The result is greater than zero only when the tool bar is on the left
3307 or right side of FRAME. If FRAME is omitted or nil, the selected frame
3311 #ifdef FRAME_TOOLBAR_WIDTH
3312 struct frame
*f
= decode_any_frame (frame
);
3314 if (FRAME_WINDOW_P (f
))
3315 return make_number (FRAME_TOOLBAR_WIDTH (f
));
3317 return make_number (0);
3320 DEFUN ("frame-text-cols", Fframe_text_cols
, Sframe_text_cols
, 0, 1, 0,
3321 doc
: /* Return width in columns of FRAME's text area. */)
3324 return make_number (FRAME_COLS (decode_any_frame (frame
)));
3327 DEFUN ("frame-text-lines", Fframe_text_lines
, Sframe_text_lines
, 0, 1, 0,
3328 doc
: /* Return height in lines of FRAME's text area. */)
3331 return make_number (FRAME_LINES (decode_any_frame (frame
)));
3334 DEFUN ("frame-total-cols", Fframe_total_cols
, Sframe_total_cols
, 0, 1, 0,
3335 doc
: /* Return number of total columns of FRAME. */)
3338 return make_number (FRAME_TOTAL_COLS (decode_any_frame (frame
)));
3341 DEFUN ("frame-total-lines", Fframe_total_lines
, Sframe_total_lines
, 0, 1, 0,
3342 doc
: /* Return number of total lines of FRAME. */)
3345 return make_number (FRAME_TOTAL_LINES (decode_any_frame (frame
)));
3348 DEFUN ("frame-text-width", Fframe_text_width
, Sframe_text_width
, 0, 1, 0,
3349 doc
: /* Return text area width of FRAME in pixels. */)
3352 return make_number (FRAME_TEXT_WIDTH (decode_any_frame (frame
)));
3355 DEFUN ("frame-text-height", Fframe_text_height
, Sframe_text_height
, 0, 1, 0,
3356 doc
: /* Return text area height of FRAME in pixels. */)
3359 return make_number (FRAME_TEXT_HEIGHT (decode_any_frame (frame
)));
3362 DEFUN ("frame-scroll-bar-width", Fscroll_bar_width
, Sscroll_bar_width
, 0, 1, 0,
3363 doc
: /* Return scroll bar width of FRAME in pixels. */)
3366 return make_number (FRAME_SCROLL_BAR_AREA_WIDTH (decode_any_frame (frame
)));
3369 DEFUN ("frame-scroll-bar-height", Fscroll_bar_height
, Sscroll_bar_height
, 0, 1, 0,
3370 doc
: /* Return scroll bar height of FRAME in pixels. */)
3373 return make_number (FRAME_SCROLL_BAR_AREA_HEIGHT (decode_any_frame (frame
)));
3376 DEFUN ("frame-fringe-width", Ffringe_width
, Sfringe_width
, 0, 1, 0,
3377 doc
: /* Return fringe width of FRAME in pixels. */)
3380 return make_number (FRAME_TOTAL_FRINGE_WIDTH (decode_any_frame (frame
)));
3383 DEFUN ("frame-internal-border-width", Fframe_internal_border_width
, Sframe_internal_border_width
, 0, 1, 0,
3384 doc
: /* Return width of FRAME's internal border in pixels. */)
3387 return make_number (FRAME_INTERNAL_BORDER_WIDTH (decode_any_frame (frame
)));
3390 DEFUN ("frame-right-divider-width", Fright_divider_width
, Sright_divider_width
, 0, 1, 0,
3391 doc
: /* Return width (in pixels) of vertical window dividers on FRAME. */)
3394 return make_number (FRAME_RIGHT_DIVIDER_WIDTH (decode_any_frame (frame
)));
3397 DEFUN ("frame-bottom-divider-width", Fbottom_divider_width
, Sbottom_divider_width
, 0, 1, 0,
3398 doc
: /* Return width (in pixels) of horizontal window dividers on FRAME. */)
3401 return make_number (FRAME_BOTTOM_DIVIDER_WIDTH (decode_any_frame (frame
)));
3404 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 4, 0,
3405 doc
: /* Set text height of frame FRAME to HEIGHT lines.
3406 Optional third arg PRETEND non-nil means that redisplay should use
3407 HEIGHT lines but that the idea of the actual height of the frame should
3410 Optional fourth argument PIXELWISE non-nil means that FRAME should be
3411 HEIGHT pixels high. Note: When `frame-resize-pixelwise' is nil, some
3412 window managers may refuse to honor a HEIGHT that is not an integer
3413 multiple of the default frame font height. */)
3414 (Lisp_Object frame
, Lisp_Object height
, Lisp_Object pretend
, Lisp_Object pixelwise
)
3416 struct frame
*f
= decode_live_frame (frame
);
3419 CHECK_TYPE_RANGED_INTEGER (int, height
);
3421 pixel_height
= (!NILP (pixelwise
)
3423 : XINT (height
) * FRAME_LINE_HEIGHT (f
));
3424 adjust_frame_size (f
, -1, pixel_height
, 1, !NILP (pretend
), Qheight
);
3429 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 4, 0,
3430 doc
: /* Set text width of frame FRAME to WIDTH columns.
3431 Optional third arg PRETEND non-nil means that redisplay should use WIDTH
3432 columns but that the idea of the actual width of the frame should not
3435 Optional fourth argument PIXELWISE non-nil means that FRAME should be
3436 WIDTH pixels wide. Note: When `frame-resize-pixelwise' is nil, some
3437 window managers may refuse to honor a WIDTH that is not an integer
3438 multiple of the default frame font width. */)
3439 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object pretend
, Lisp_Object pixelwise
)
3441 struct frame
*f
= decode_live_frame (frame
);
3444 CHECK_TYPE_RANGED_INTEGER (int, width
);
3446 pixel_width
= (!NILP (pixelwise
)
3448 : XINT (width
) * FRAME_COLUMN_WIDTH (f
));
3449 adjust_frame_size (f
, pixel_width
, -1, 1, !NILP (pretend
), Qwidth
);
3454 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 4, 0,
3455 doc
: /* Set text size of FRAME to WIDTH by HEIGHT, measured in characters.
3456 Optional argument PIXELWISE non-nil means to measure in pixels. Note:
3457 When `frame-resize-pixelwise' is nil, some window managers may refuse to
3458 honor a WIDTH that is not an integer multiple of the default frame font
3459 width or a HEIGHT that is not an integer multiple of the default frame
3461 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object height
, Lisp_Object pixelwise
)
3463 struct frame
*f
= decode_live_frame (frame
);
3464 int pixel_width
, pixel_height
;
3466 CHECK_TYPE_RANGED_INTEGER (int, width
);
3467 CHECK_TYPE_RANGED_INTEGER (int, height
);
3469 pixel_width
= (!NILP (pixelwise
)
3471 : XINT (width
) * FRAME_COLUMN_WIDTH (f
));
3472 pixel_height
= (!NILP (pixelwise
)
3474 : XINT (height
) * FRAME_LINE_HEIGHT (f
));
3475 adjust_frame_size (f
, pixel_width
, pixel_height
, 1, 0, Qsize
);
3480 DEFUN ("frame-position", Fframe_position
,
3481 Sframe_position
, 0, 1, 0,
3482 doc
: /* Return top left corner of FRAME in pixels.
3483 FRAME must be a live frame and defaults to the selected one. The return
3484 value is a cons (x, y) of the coordinates of the top left corner of
3485 FRAME's outer frame, in pixels relative to an origin (0, 0) of FRAME's
3489 register struct frame
*f
= decode_live_frame (frame
);
3491 return Fcons (make_number (f
->left_pos
), make_number (f
->top_pos
));
3494 DEFUN ("set-frame-position", Fset_frame_position
,
3495 Sset_frame_position
, 3, 3, 0,
3496 doc
: /* Set position of FRAME to (X, Y).
3497 FRAME must be a live frame and defaults to the selected one. X and Y,
3498 if positive, specify the coordinate of the left and top edge of FRAME's
3499 outer frame in pixels relative to an origin (0, 0) of FRAME's display.
3500 If any of X or Y is negative, it specifies the coordinates of the right
3501 or bottom edge of the outer frame of FRAME relative to the right or
3502 bottom edge of FRAME's display. */)
3503 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
3505 struct frame
*f
= decode_live_frame (frame
);
3507 CHECK_TYPE_RANGED_INTEGER (int, x
);
3508 CHECK_TYPE_RANGED_INTEGER (int, y
);
3510 /* I think this should be done with a hook. */
3511 if (FRAME_WINDOW_P (f
))
3513 #ifdef HAVE_WINDOW_SYSTEM
3514 x_set_offset (f
, XINT (x
), XINT (y
), 1);
3521 /***********************************************************************
3523 ***********************************************************************/
3525 /* Connect the frame-parameter names for X frames
3526 to the ways of passing the parameter values to the window system.
3528 The name of a parameter, as a Lisp symbol,
3529 has an `x-frame-parameter' property which is an integer in Lisp
3530 that is an index in this table. */
3532 struct frame_parm_table
{
3537 static const struct frame_parm_table frame_parms
[] =
3539 {"auto-raise", SYMBOL_INDEX (Qauto_raise
)},
3540 {"auto-lower", SYMBOL_INDEX (Qauto_lower
)},
3541 {"background-color", -1},
3542 {"border-color", SYMBOL_INDEX (Qborder_color
)},
3543 {"border-width", SYMBOL_INDEX (Qborder_width
)},
3544 {"cursor-color", SYMBOL_INDEX (Qcursor_color
)},
3545 {"cursor-type", SYMBOL_INDEX (Qcursor_type
)},
3547 {"foreground-color", -1},
3548 {"icon-name", SYMBOL_INDEX (Qicon_name
)},
3549 {"icon-type", SYMBOL_INDEX (Qicon_type
)},
3550 {"internal-border-width", SYMBOL_INDEX (Qinternal_border_width
)},
3551 {"right-divider-width", SYMBOL_INDEX (Qright_divider_width
)},
3552 {"bottom-divider-width", SYMBOL_INDEX (Qbottom_divider_width
)},
3553 {"menu-bar-lines", SYMBOL_INDEX (Qmenu_bar_lines
)},
3554 {"mouse-color", SYMBOL_INDEX (Qmouse_color
)},
3555 {"name", SYMBOL_INDEX (Qname
)},
3556 {"scroll-bar-width", SYMBOL_INDEX (Qscroll_bar_width
)},
3557 {"scroll-bar-height", SYMBOL_INDEX (Qscroll_bar_height
)},
3558 {"title", SYMBOL_INDEX (Qtitle
)},
3559 {"unsplittable", SYMBOL_INDEX (Qunsplittable
)},
3560 {"vertical-scroll-bars", SYMBOL_INDEX (Qvertical_scroll_bars
)},
3561 {"horizontal-scroll-bars", SYMBOL_INDEX (Qhorizontal_scroll_bars
)},
3562 {"visibility", SYMBOL_INDEX (Qvisibility
)},
3563 {"tool-bar-lines", SYMBOL_INDEX (Qtool_bar_lines
)},
3564 {"scroll-bar-foreground", SYMBOL_INDEX (Qscroll_bar_foreground
)},
3565 {"scroll-bar-background", SYMBOL_INDEX (Qscroll_bar_background
)},
3566 {"screen-gamma", SYMBOL_INDEX (Qscreen_gamma
)},
3567 {"line-spacing", SYMBOL_INDEX (Qline_spacing
)},
3568 {"left-fringe", SYMBOL_INDEX (Qleft_fringe
)},
3569 {"right-fringe", SYMBOL_INDEX (Qright_fringe
)},
3570 {"wait-for-wm", SYMBOL_INDEX (Qwait_for_wm
)},
3571 {"fullscreen", SYMBOL_INDEX (Qfullscreen
)},
3572 {"font-backend", SYMBOL_INDEX (Qfont_backend
)},
3573 {"alpha", SYMBOL_INDEX (Qalpha
)},
3574 {"sticky", SYMBOL_INDEX (Qsticky
)},
3575 {"tool-bar-position", SYMBOL_INDEX (Qtool_bar_position
)},
3576 {"inhibit-double-buffering", SYMBOL_INDEX (Qinhibit_double_buffering
)},
3577 {"undecorated", SYMBOL_INDEX (Qundecorated
)},
3578 {"parent-frame", SYMBOL_INDEX (Qparent_frame
)},
3579 {"skip-taskbar", SYMBOL_INDEX (Qskip_taskbar
)},
3580 {"no-focus-on-map", SYMBOL_INDEX (Qno_focus_on_map
)},
3581 {"no-accept-focus", SYMBOL_INDEX (Qno_accept_focus
)},
3582 {"z-group", SYMBOL_INDEX (Qz_group
)},
3583 {"override-redirect", SYMBOL_INDEX (Qoverride_redirect
)},
3584 {"no-special-glyphs", SYMBOL_INDEX (Qno_special_glyphs
)},
3585 #ifdef NS_IMPL_COCOA
3586 {"ns-appearance", SYMBOL_INDEX (Qns_appearance
)},
3587 {"ns-transparent-titlebar", SYMBOL_INDEX (Qns_transparent_titlebar
)},
3591 #ifdef HAVE_WINDOW_SYSTEM
3593 /* Enumeration type for switch in frame_float. */
3594 enum frame_float_type
3605 * Process the value VAL of the float type frame parameter 'width',
3606 * 'height', 'left', or 'top' specified via a frame_float_type
3607 * enumeration type WHAT for frame F. Such parameters relate the outer
3608 * size or position of F to the size of the F's display or parent frame
3609 * which have to be both available in some way.
3611 * The return value is a size or position value in pixels. VAL must be
3612 * in the range 0.0 to 1.0 where a width/height of 0.0 means to return 0
3613 * and 1.0 means to return the full width/height of the display/parent.
3614 * For positions, 0.0 means position in the left/top corner of the
3615 * display/parent while 1.0 means to position at the right/bottom corner
3616 * of the display/parent frame.
3618 * Set PARENT_DONE and OUTER_DONE to avoid recalculation of the outer
3619 * size or parent or display attributes when more float parameters are
3620 * calculated in a row: -1 means not processed yet, 0 means processing
3621 * failed, 1 means processing succeeded.
3623 * Return DEFAULT_VALUE when processing fails for whatever reason with
3624 * one exception: When calculating F's outer edges fails (probably
3625 * because F has not been created yet) return the difference between F's
3626 * native and text size.
3629 frame_float (struct frame
*f
, Lisp_Object val
, enum frame_float_type what
,
3630 int *parent_done
, int *outer_done
, int default_value
)
3632 double d_val
= XFLOAT_DATA (val
);
3634 if (d_val
< 0.0 || d_val
> 1.0)
3636 return default_value
;
3639 static unsigned parent_width
, parent_height
;
3640 static int parent_left
, parent_top
;
3641 static unsigned outer_minus_text_width
, outer_minus_text_height
;
3642 struct frame
*p
= FRAME_PARENT_FRAME (f
);
3644 if (*parent_done
== 1)
3648 parent_width
= FRAME_PIXEL_WIDTH (p
);
3649 parent_height
= FRAME_PIXEL_HEIGHT (p
);
3654 if (*parent_done
== 0)
3655 /* No workarea available. */
3656 return default_value
;
3657 else if (*parent_done
== -1)
3659 Lisp_Object monitor_attributes
;
3660 Lisp_Object workarea
;
3663 XSETFRAME (frame
, f
);
3664 monitor_attributes
= Fcar (call1 (Qdisplay_monitor_attributes_list
, frame
));
3665 if (NILP (monitor_attributes
))
3667 /* No monitor attributes available. */
3670 return default_value
;
3673 workarea
= Fcdr (Fassq (Qworkarea
, monitor_attributes
));
3674 if (NILP (workarea
))
3676 /* No workarea available. */
3679 return default_value
;
3682 /* Workarea available. */
3683 parent_left
= XINT (Fnth (make_number (0), workarea
));
3684 parent_top
= XINT (Fnth (make_number (1), workarea
));
3685 parent_width
= XINT (Fnth (make_number (2), workarea
));
3686 parent_height
= XINT (Fnth (make_number (3), workarea
));
3691 if (*outer_done
== 1)
3693 else if (FRAME_UNDECORATED (f
))
3695 outer_minus_text_width
3696 = FRAME_PIXEL_WIDTH (f
) - FRAME_TEXT_WIDTH (f
);
3697 outer_minus_text_height
3698 = FRAME_PIXEL_HEIGHT (f
) - FRAME_TEXT_HEIGHT (f
);
3701 else if (*outer_done
== 0)
3702 /* No outer size available. */
3703 return default_value
;
3704 else if (*outer_done
== -1)
3706 Lisp_Object frame
, outer_edges
;
3708 XSETFRAME (frame
, f
);
3709 outer_edges
= call2 (Qframe_edges
, frame
, Qouter_edges
);
3711 if (!NILP (outer_edges
))
3713 outer_minus_text_width
3714 = (XINT (Fnth (make_number (2), outer_edges
))
3715 - XINT (Fnth (make_number (0), outer_edges
))
3716 - FRAME_TEXT_WIDTH (f
));
3717 outer_minus_text_height
3718 = (XINT (Fnth (make_number (3), outer_edges
))
3719 - XINT (Fnth (make_number (1), outer_edges
))
3720 - FRAME_TEXT_HEIGHT (f
));
3724 /* If we can't get any outer edges, proceed as if the frame
3725 were undecorated. */
3726 outer_minus_text_width
3727 = FRAME_PIXEL_WIDTH (f
) - FRAME_TEXT_WIDTH (f
);
3728 outer_minus_text_height
3729 = FRAME_PIXEL_HEIGHT (f
) - FRAME_TEXT_HEIGHT (f
);
3737 case FRAME_FLOAT_WIDTH
:
3738 return parent_width
* d_val
- outer_minus_text_width
;
3740 case FRAME_FLOAT_HEIGHT
:
3741 return parent_height
* d_val
- outer_minus_text_height
;
3743 case FRAME_FLOAT_LEFT
:
3745 int rest_width
= (parent_width
3746 - FRAME_TEXT_WIDTH (f
)
3747 - outer_minus_text_width
);
3750 return (rest_width
<= 0 ? 0 : d_val
* rest_width
);
3752 return (rest_width
<= 0
3754 : parent_left
+ d_val
* rest_width
);
3756 case FRAME_FLOAT_TOP
:
3758 int rest_height
= (parent_height
3759 - FRAME_TEXT_HEIGHT (f
)
3760 - outer_minus_text_height
);
3763 return (rest_height
<= 0 ? 0 : d_val
* rest_height
);
3765 return (rest_height
<= 0
3767 : parent_top
+ d_val
* rest_height
);
3775 /* Change the parameters of frame F as specified by ALIST.
3776 If a parameter is not specially recognized, do nothing special;
3777 otherwise call the `x_set_...' function for that parameter.
3778 Except for certain geometry properties, always call store_frame_param
3779 to store the new value in the parameter alist. */
3782 x_set_frame_parameters (struct frame
*f
, Lisp_Object alist
)
3784 Lisp_Object tail
, frame
;
3787 /* If both of these parameters are present, it's more efficient to
3788 set them both at once. So we wait until we've looked at the
3789 entire list before we set them. */
3790 int width
= -1, height
= -1; /* -1 denotes they were not changed. */
3793 Lisp_Object left
, top
;
3795 /* Same with these. */
3796 Lisp_Object icon_left
, icon_top
;
3798 /* And with this. */
3799 Lisp_Object fullscreen
;
3800 bool fullscreen_change
= false;
3802 /* Record in these vectors all the parms specified. */
3804 Lisp_Object
*values
;
3805 ptrdiff_t i
, j
, size
;
3806 bool left_no_change
= 0, top_no_change
= 0;
3807 #ifdef HAVE_X_WINDOWS
3808 bool icon_left_no_change
= 0, icon_top_no_change
= 0;
3810 int parent_done
= -1, outer_done
= -1;
3812 XSETFRAME (frame
, f
);
3813 for (size
= 0, tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3815 CHECK_LIST_END (tail
, alist
);
3818 SAFE_ALLOCA_LISP (parms
, 2 * size
);
3819 values
= parms
+ size
;
3821 /* Extract parm names and values into those vectors. */
3823 i
= 0, j
= size
- 1;
3824 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3826 Lisp_Object elt
= XCAR (tail
), prop
= Fcar (elt
), val
= Fcdr (elt
);
3828 /* Some properties are independent of other properties, but other
3829 properties are dependent upon them. These special properties
3830 are foreground_color, background_color (affects cursor_color)
3831 and font (affects fringe widths); they're recorded starting
3832 from the end of PARMS and VALUES to process them first by using
3833 reverse iteration. */
3835 if (EQ (prop
, Qforeground_color
)
3836 || EQ (prop
, Qbackground_color
)
3837 || EQ (prop
, Qfont
))
3851 /* TAIL and ALIST are not used again below here. */
3852 alist
= tail
= Qnil
;
3854 top
= left
= Qunbound
;
3855 icon_left
= icon_top
= Qunbound
;
3857 /* Reverse order is used to make sure that special
3858 properties noticed above are processed first. */
3859 for (i
= size
- 1; i
>= 0; i
--)
3861 Lisp_Object prop
, val
;
3866 if (EQ (prop
, Qwidth
))
3868 if (RANGED_INTEGERP (0, val
, INT_MAX
))
3869 width
= XFASTINT (val
) * FRAME_COLUMN_WIDTH (f
) ;
3870 else if (CONSP (val
) && EQ (XCAR (val
), Qtext_pixels
)
3871 && RANGED_INTEGERP (0, XCDR (val
), INT_MAX
))
3872 width
= XFASTINT (XCDR (val
));
3873 else if (FLOATP (val
))
3874 width
= frame_float (f
, val
, FRAME_FLOAT_WIDTH
, &parent_done
,
3877 else if (EQ (prop
, Qheight
))
3879 if (RANGED_INTEGERP (0, val
, INT_MAX
))
3880 height
= XFASTINT (val
) * FRAME_LINE_HEIGHT (f
);
3881 else if (CONSP (val
) && EQ (XCAR (val
), Qtext_pixels
)
3882 && RANGED_INTEGERP (0, XCDR (val
), INT_MAX
))
3883 height
= XFASTINT (XCDR (val
));
3884 else if (FLOATP (val
))
3885 height
= frame_float (f
, val
, FRAME_FLOAT_HEIGHT
, &parent_done
,
3888 else if (EQ (prop
, Qtop
))
3890 else if (EQ (prop
, Qleft
))
3892 else if (EQ (prop
, Qicon_top
))
3894 else if (EQ (prop
, Qicon_left
))
3896 else if (EQ (prop
, Qfullscreen
))
3899 fullscreen_change
= true;
3903 register Lisp_Object param_index
, old_value
;
3905 old_value
= get_frame_param (f
, prop
);
3907 store_frame_param (f
, prop
, val
);
3909 param_index
= Fget (prop
, Qx_frame_parameter
);
3910 if (NATNUMP (param_index
)
3911 && XFASTINT (param_index
) < ARRAYELTS (frame_parms
)
3912 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3913 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3917 /* Don't die if just one of these was set. */
3918 if (EQ (left
, Qunbound
))
3921 if (f
->left_pos
< 0)
3922 left
= list2 (Qplus
, make_number (f
->left_pos
));
3924 XSETINT (left
, f
->left_pos
);
3926 if (EQ (top
, Qunbound
))
3930 top
= list2 (Qplus
, make_number (f
->top_pos
));
3932 XSETINT (top
, f
->top_pos
);
3935 /* If one of the icon positions was not set, preserve or default it. */
3936 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
3938 #ifdef HAVE_X_WINDOWS
3939 icon_left_no_change
= 1;
3941 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3942 if (NILP (icon_left
))
3943 XSETINT (icon_left
, 0);
3945 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
3947 #ifdef HAVE_X_WINDOWS
3948 icon_top_no_change
= 1;
3950 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3951 if (NILP (icon_top
))
3952 XSETINT (icon_top
, 0);
3955 /* Don't set these parameters unless they've been explicitly
3956 specified. The window might be mapped or resized while we're in
3957 this function, and we don't want to override that unless the lisp
3958 code has asked for it.
3960 Don't set these parameters unless they actually differ from the
3961 window's current parameters; the window may not actually exist
3963 if ((width
!= -1 && width
!= FRAME_TEXT_WIDTH (f
))
3964 || (height
!= -1 && height
!= FRAME_TEXT_HEIGHT (f
)))
3965 /* We could consider checking f->after_make_frame here, but I
3966 don't have the faintest idea why the following is needed at
3967 all. With the old setting it can get a Heisenbug when
3968 EmacsFrameResize intermittently provokes a delayed
3969 change_frame_size in the middle of adjust_frame_size. */
3970 /** || (f->can_x_set_window_size && (f->new_height || f->new_width))) **/
3971 adjust_frame_size (f
, width
, height
, 1, 0, Qx_set_frame_parameters
);
3973 if ((!NILP (left
) || !NILP (top
))
3974 && ! (left_no_change
&& top_no_change
)
3975 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3976 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3981 /* Record the signs. */
3982 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3983 if (EQ (left
, Qminus
))
3984 f
->size_hint_flags
|= XNegative
;
3985 else if (TYPE_RANGED_INTEGERP (int, left
))
3987 leftpos
= XINT (left
);
3989 f
->size_hint_flags
|= XNegative
;
3991 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3992 && CONSP (XCDR (left
))
3993 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
3995 leftpos
= - XINT (XCAR (XCDR (left
)));
3996 f
->size_hint_flags
|= XNegative
;
3998 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3999 && CONSP (XCDR (left
))
4000 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
4001 leftpos
= XINT (XCAR (XCDR (left
)));
4002 else if (FLOATP (left
))
4003 leftpos
= frame_float (f
, left
, FRAME_FLOAT_LEFT
, &parent_done
,
4006 if (EQ (top
, Qminus
))
4007 f
->size_hint_flags
|= YNegative
;
4008 else if (TYPE_RANGED_INTEGERP (int, top
))
4010 toppos
= XINT (top
);
4012 f
->size_hint_flags
|= YNegative
;
4014 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
4015 && CONSP (XCDR (top
))
4016 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
4018 toppos
= - XINT (XCAR (XCDR (top
)));
4019 f
->size_hint_flags
|= YNegative
;
4021 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
4022 && CONSP (XCDR (top
))
4023 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
4024 toppos
= XINT (XCAR (XCDR (top
)));
4025 else if (FLOATP (top
))
4026 toppos
= frame_float (f
, top
, FRAME_FLOAT_TOP
, &parent_done
,
4029 /* Store the numeric value of the position. */
4030 f
->top_pos
= toppos
;
4031 f
->left_pos
= leftpos
;
4033 f
->win_gravity
= NorthWestGravity
;
4035 /* Actually set that position, and convert to absolute. */
4036 x_set_offset (f
, leftpos
, toppos
, -1);
4039 if (fullscreen_change
)
4041 Lisp_Object old_value
= get_frame_param (f
, Qfullscreen
);
4043 frame_size_history_add
4044 (f
, Qx_set_fullscreen
, 0, 0, list2 (old_value
, fullscreen
));
4046 store_frame_param (f
, Qfullscreen
, fullscreen
);
4047 if (!EQ (fullscreen
, old_value
))
4048 x_set_fullscreen (f
, fullscreen
, old_value
);
4052 #ifdef HAVE_X_WINDOWS
4053 if ((!NILP (icon_left
) || !NILP (icon_top
))
4054 && ! (icon_left_no_change
&& icon_top_no_change
))
4055 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
4056 #endif /* HAVE_X_WINDOWS */
4062 /* Insert a description of internally-recorded parameters of frame X
4063 into the parameter alist *ALISTPTR that is to be given to the user.
4064 Only parameters that are specific to the X window system
4065 and whose values are not correctly recorded in the frame's
4066 param_alist need to be considered here. */
4069 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
4073 char buf
[INT_BUFSIZE_BOUND (w
)];
4075 /* Represent negative positions (off the top or left screen edge)
4076 in a way that Fmodify_frame_parameters will understand correctly. */
4077 XSETINT (tem
, f
->left_pos
);
4078 if (f
->left_pos
>= 0)
4079 store_in_alist (alistptr
, Qleft
, tem
);
4081 store_in_alist (alistptr
, Qleft
, list2 (Qplus
, tem
));
4083 XSETINT (tem
, f
->top_pos
);
4084 if (f
->top_pos
>= 0)
4085 store_in_alist (alistptr
, Qtop
, tem
);
4087 store_in_alist (alistptr
, Qtop
, list2 (Qplus
, tem
));
4089 store_in_alist (alistptr
, Qborder_width
,
4090 make_number (f
->border_width
));
4091 store_in_alist (alistptr
, Qinternal_border_width
,
4092 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
4093 store_in_alist (alistptr
, Qright_divider_width
,
4094 make_number (FRAME_RIGHT_DIVIDER_WIDTH (f
)));
4095 store_in_alist (alistptr
, Qbottom_divider_width
,
4096 make_number (FRAME_BOTTOM_DIVIDER_WIDTH (f
)));
4097 store_in_alist (alistptr
, Qleft_fringe
,
4098 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
4099 store_in_alist (alistptr
, Qright_fringe
,
4100 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
4101 store_in_alist (alistptr
, Qscroll_bar_width
,
4102 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
4104 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
4105 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
4106 /* nil means "use default width"
4107 for non-toolkit scroll bar.
4108 ruler-mode.el depends on this. */
4110 store_in_alist (alistptr
, Qscroll_bar_height
,
4111 (! FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)
4113 : FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) > 0
4114 ? make_number (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
4115 /* nil means "use default height"
4116 for non-toolkit scroll bar. */
4118 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
4119 MS-Windows it returns a value whose type is HANDLE, which is
4120 actually a pointer. Explicit casting avoids compiler
4122 w
= (uintptr_t) FRAME_X_WINDOW (f
);
4123 store_in_alist (alistptr
, Qwindow_id
,
4124 make_formatted_string (buf
, "%"pMu
, w
));
4125 #ifdef HAVE_X_WINDOWS
4126 #ifdef USE_X_TOOLKIT
4127 /* Tooltip frame may not have this widget. */
4128 if (FRAME_X_OUTPUT (f
)->widget
)
4130 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
4131 store_in_alist (alistptr
, Qouter_window_id
,
4132 make_formatted_string (buf
, "%"pMu
, w
));
4134 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
4135 store_in_alist (alistptr
, Qvisibility
,
4136 (FRAME_VISIBLE_P (f
) ? Qt
4137 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
4138 store_in_alist (alistptr
, Qdisplay
,
4139 XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
));
4141 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_DISPLAY_INFO (f
)->root_window
)
4144 tem
= make_natnum ((uintptr_t) FRAME_X_OUTPUT (f
)->parent_desc
);
4145 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
4146 store_in_alist (alistptr
, Qparent_id
, tem
);
4147 store_in_alist (alistptr
, Qtool_bar_position
, FRAME_TOOL_BAR_POSITION (f
));
4151 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
4152 the previous value of that parameter, NEW_VALUE is the new value. */
4155 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4157 if (NILP (new_value
))
4158 f
->want_fullscreen
= FULLSCREEN_NONE
;
4159 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
4160 f
->want_fullscreen
= FULLSCREEN_BOTH
;
4161 else if (EQ (new_value
, Qfullwidth
))
4162 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
4163 else if (EQ (new_value
, Qfullheight
))
4164 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
4165 else if (EQ (new_value
, Qmaximized
))
4166 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
4168 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
4169 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
4173 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
4174 the previous value of that parameter, NEW_VALUE is the new value. */
4177 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4179 if (NILP (new_value
))
4180 f
->extra_line_spacing
= 0;
4181 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
4182 f
->extra_line_spacing
= XFASTINT (new_value
);
4183 else if (FLOATP (new_value
))
4185 int new_spacing
= XFLOAT_DATA (new_value
) * FRAME_LINE_HEIGHT (f
) + 0.5;
4187 if (new_spacing
>= 0)
4188 f
->extra_line_spacing
= new_spacing
;
4190 signal_error ("Invalid line-spacing", new_value
);
4193 signal_error ("Invalid line-spacing", new_value
);
4194 if (FRAME_VISIBLE_P (f
))
4199 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
4200 the previous value of that parameter, NEW_VALUE is the new value. */
4203 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4205 Lisp_Object bgcolor
;
4207 if (NILP (new_value
))
4209 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
4210 /* The value 0.4545 is the normal viewing gamma. */
4211 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
4213 signal_error ("Invalid screen-gamma", new_value
);
4215 /* Apply the new gamma value to the frame background. */
4216 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
4217 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
4219 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
4220 if (NATNUMP (parm_index
)
4221 && XFASTINT (parm_index
) < ARRAYELTS (frame_parms
)
4222 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
4223 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
4227 clear_face_cache (true); /* FIXME: Why of all frames? */
4233 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4235 Lisp_Object font_object
;
4237 #ifdef HAVE_X_WINDOWS
4238 Lisp_Object font_param
= arg
;
4241 /* Set the frame parameter back to the old value because we may
4242 fail to use ARG as the new parameter value. */
4243 store_frame_param (f
, Qfont
, oldval
);
4245 /* ARG is a fontset name, a font name, a cons of fontset name and a
4246 font object, or a font object. In the last case, this function
4250 fontset
= fs_query_fontset (arg
, 0);
4253 font_object
= font_open_by_name (f
, arg
);
4254 if (NILP (font_object
))
4255 error ("Font `%s' is not defined", SSDATA (arg
));
4256 arg
= AREF (font_object
, FONT_NAME_INDEX
);
4258 else if (fontset
> 0)
4260 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
4261 if (NILP (font_object
))
4262 error ("Font `%s' is not defined", SDATA (arg
));
4263 arg
= AREF (font_object
, FONT_NAME_INDEX
);
4266 error ("The default fontset can't be used for a frame font");
4268 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
4270 /* This is the case that the ASCII font of F's fontset XCAR
4271 (arg) is changed to the font XCDR (arg) by
4272 `set-fontset-font'. */
4273 fontset
= fs_query_fontset (XCAR (arg
), 0);
4275 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
4276 font_object
= XCDR (arg
);
4277 arg
= AREF (font_object
, FONT_NAME_INDEX
);
4278 #ifdef HAVE_X_WINDOWS
4279 font_param
= Ffont_get (font_object
, QCname
);
4282 else if (FONT_OBJECT_P (arg
))
4285 #ifdef HAVE_X_WINDOWS
4286 font_param
= Ffont_get (font_object
, QCname
);
4288 /* This is to store the XLFD font name in the frame parameter for
4289 backward compatibility. We should store the font-object
4290 itself in the future. */
4291 arg
= AREF (font_object
, FONT_NAME_INDEX
);
4292 fontset
= FRAME_FONTSET (f
);
4293 /* Check if we can use the current fontset. If not, set FONTSET
4294 to -1 to generate a new fontset from FONT-OBJECT. */
4297 Lisp_Object ascii_font
= fontset_ascii (fontset
);
4298 Lisp_Object spec
= font_spec_from_name (ascii_font
);
4300 /* SPEC might be nil because ASCII_FONT's name doesn't parse
4301 according to stupid XLFD rules, which, for example,
4302 disallow font names that include a dash followed by a
4303 number. So in those cases we simply request x_new_font
4304 below to generate a new fontset. */
4305 if (NILP (spec
) || ! font_match_p (spec
, font_object
))
4310 signal_error ("Invalid font", arg
);
4312 if (! NILP (Fequal (font_object
, oldval
)))
4315 x_new_font (f
, font_object
, fontset
);
4316 store_frame_param (f
, Qfont
, arg
);
4317 #ifdef HAVE_X_WINDOWS
4318 store_frame_param (f
, Qfont_parameter
, font_param
);
4320 /* Recalculate toolbar height. */
4321 f
->n_tool_bar_rows
= 0;
4323 /* Ensure we redraw it. */
4324 clear_current_matrices (f
);
4326 /* Attempt to hunt down bug#16028. */
4327 SET_FRAME_GARBAGED (f
);
4329 /* This is important if we are called by some Lisp as part of
4330 redisplaying the frame, see redisplay_internal. */
4331 f
->fonts_changed
= true;
4333 recompute_basic_faces (f
);
4335 do_pending_window_change (0);
4337 /* We used to call face-set-after-frame-default here, but it leads to
4338 recursive calls (since that function can set the `default' face's
4339 font which in turns changes the frame's `font' parameter).
4340 Also I don't know what this call is meant to do, but it seems the
4341 wrong way to do it anyway (it does a lot more work than what seems
4342 reasonable in response to a change to `font'). */
4347 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4349 if (! NILP (new_value
)
4350 && !CONSP (new_value
))
4354 CHECK_STRING (new_value
);
4355 p0
= p1
= SSDATA (new_value
);
4359 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
4361 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
4367 while ((c
= *++p1
) && c_isspace (c
));
4371 new_value
= Fnreverse (new_value
);
4374 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
4378 free_all_realized_faces (Qnil
);
4380 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
4381 if (NILP (new_value
))
4383 if (NILP (old_value
))
4384 error ("No font backend available");
4385 font_update_drivers (f
, old_value
);
4386 error ("None of specified font backends are available");
4388 store_frame_param (f
, Qfont_backend
, new_value
);
4394 XSETFRAME (frame
, f
);
4395 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
4397 windows_or_buffers_changed
= 18;
4402 x_set_left_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4404 int unit
= FRAME_COLUMN_WIDTH (f
);
4405 int old_width
= FRAME_LEFT_FRINGE_WIDTH (f
);
4408 new_width
= (RANGED_INTEGERP (-INT_MAX
, new_value
, INT_MAX
)
4409 ? eabs (XINT (new_value
)) : 8);
4411 if (new_width
!= old_width
)
4413 f
->left_fringe_width
= new_width
;
4414 f
->fringe_cols
/* Round up. */
4415 = (new_width
+ FRAME_RIGHT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
4417 if (FRAME_X_WINDOW (f
) != 0)
4418 adjust_frame_size (f
, -1, -1, 3, 0, Qleft_fringe
);
4420 SET_FRAME_GARBAGED (f
);
4426 x_set_right_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4428 int unit
= FRAME_COLUMN_WIDTH (f
);
4429 int old_width
= FRAME_RIGHT_FRINGE_WIDTH (f
);
4432 new_width
= (RANGED_INTEGERP (-INT_MAX
, new_value
, INT_MAX
)
4433 ? eabs (XINT (new_value
)) : 8);
4435 if (new_width
!= old_width
)
4437 f
->right_fringe_width
= new_width
;
4438 f
->fringe_cols
/* Round up. */
4439 = (new_width
+ FRAME_LEFT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
4441 if (FRAME_X_WINDOW (f
) != 0)
4442 adjust_frame_size (f
, -1, -1, 3, 0, Qright_fringe
);
4444 SET_FRAME_GARBAGED (f
);
4450 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4452 CHECK_TYPE_RANGED_INTEGER (int, arg
);
4454 if (XINT (arg
) == f
->border_width
)
4457 if (FRAME_X_WINDOW (f
) != 0)
4458 error ("Cannot change the border width of a frame");
4460 f
->border_width
= XINT (arg
);
4464 x_set_right_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4466 int old
= FRAME_RIGHT_DIVIDER_WIDTH (f
);
4467 CHECK_TYPE_RANGED_INTEGER (int, arg
);
4468 int new = max (0, XINT (arg
));
4471 f
->right_divider_width
= new;
4472 adjust_frame_size (f
, -1, -1, 4, 0, Qright_divider_width
);
4473 adjust_frame_glyphs (f
);
4474 SET_FRAME_GARBAGED (f
);
4479 x_set_bottom_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4481 int old
= FRAME_BOTTOM_DIVIDER_WIDTH (f
);
4482 CHECK_TYPE_RANGED_INTEGER (int, arg
);
4483 int new = max (0, XINT (arg
));
4486 f
->bottom_divider_width
= new;
4487 adjust_frame_size (f
, -1, -1, 4, 0, Qbottom_divider_width
);
4488 adjust_frame_glyphs (f
);
4489 SET_FRAME_GARBAGED (f
);
4494 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
4497 XSETFRAME (frame
, f
);
4500 Fmake_frame_invisible (frame
, Qt
);
4501 else if (EQ (value
, Qicon
))
4502 Ficonify_frame (frame
);
4504 Fmake_frame_visible (frame
);
4508 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4510 f
->auto_raise
= !EQ (Qnil
, arg
);
4514 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4516 f
->auto_lower
= !EQ (Qnil
, arg
);
4520 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4522 f
->no_split
= !NILP (arg
);
4526 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4528 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
4529 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
4530 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
4531 || (!NILP (arg
) && !FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
4533 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
4535 ? vertical_scroll_bar_none
4537 ? vertical_scroll_bar_left
4539 ? vertical_scroll_bar_right
4540 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
4541 ? vertical_scroll_bar_left
4542 : EQ (Qright
, Vdefault_frame_scroll_bars
)
4543 ? vertical_scroll_bar_right
4544 : vertical_scroll_bar_none
);
4546 /* We set this parameter before creating the X window for the
4547 frame, so we can get the geometry right from the start.
4548 However, if the window hasn't been created yet, we shouldn't
4549 call x_set_window_size. */
4550 if (FRAME_X_WINDOW (f
))
4551 adjust_frame_size (f
, -1, -1, 3, 0, Qvertical_scroll_bars
);
4553 SET_FRAME_GARBAGED (f
);
4558 x_set_horizontal_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4560 #if USE_HORIZONTAL_SCROLL_BARS
4561 if ((NILP (arg
) && FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
))
4562 || (!NILP (arg
) && !FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)))
4564 f
->horizontal_scroll_bars
= NILP (arg
) ? false : true;
4566 /* We set this parameter before creating the X window for the
4567 frame, so we can get the geometry right from the start.
4568 However, if the window hasn't been created yet, we shouldn't
4569 call x_set_window_size. */
4570 if (FRAME_X_WINDOW (f
))
4571 adjust_frame_size (f
, -1, -1, 3, 0, Qhorizontal_scroll_bars
);
4573 SET_FRAME_GARBAGED (f
);
4579 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4581 int unit
= FRAME_COLUMN_WIDTH (f
);
4585 x_set_scroll_bar_default_width (f
);
4587 if (FRAME_X_WINDOW (f
))
4588 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_width
);
4590 SET_FRAME_GARBAGED (f
);
4592 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
4593 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
4595 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
4596 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + unit
- 1) / unit
;
4597 if (FRAME_X_WINDOW (f
))
4598 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_width
);
4600 SET_FRAME_GARBAGED (f
);
4603 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
4604 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
4608 x_set_scroll_bar_height (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4610 #if USE_HORIZONTAL_SCROLL_BARS
4611 int unit
= FRAME_LINE_HEIGHT (f
);
4615 x_set_scroll_bar_default_height (f
);
4617 if (FRAME_X_WINDOW (f
))
4618 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_height
);
4620 SET_FRAME_GARBAGED (f
);
4622 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
4623 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
4625 FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) = XFASTINT (arg
);
4626 FRAME_CONFIG_SCROLL_BAR_LINES (f
) = (XFASTINT (arg
) + unit
- 1) / unit
;
4627 if (FRAME_X_WINDOW (f
))
4628 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_height
);
4630 SET_FRAME_GARBAGED (f
);
4633 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.vpos
= 0;
4634 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.y
= 0;
4639 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
4646 for (i
= 0; i
< 2; i
++)
4659 else if (FLOATP (item
))
4661 alpha
= XFLOAT_DATA (item
);
4662 if (! (0 <= alpha
&& alpha
<= 1.0))
4663 args_out_of_range (make_float (0.0), make_float (1.0));
4665 else if (INTEGERP (item
))
4667 EMACS_INT ialpha
= XINT (item
);
4668 if (! (0 <= ialpha
&& ialpha
<= 100))
4669 args_out_of_range (make_number (0), make_number (100));
4670 alpha
= ialpha
/ 100.0;
4673 wrong_type_argument (Qnumberp
, item
);
4677 for (i
= 0; i
< 2; i
++)
4678 f
->alpha
[i
] = newval
[i
];
4680 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
4682 x_set_frame_alpha (f
);
4691 * x_set_no_special_glyphs:
4693 * Set frame F's `no-special-glyphs' parameter which, if non-nil,
4694 * suppresses the display of truncation and continuation glyphs
4698 x_set_no_special_glyphs (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
4700 if (!EQ (new_value
, old_value
))
4701 FRAME_NO_SPECIAL_GLYPHS (f
) = !NILP (new_value
);
4707 /* Non-zero if mouse is grabbed on DPYINFO
4708 and we know the frame where it is. */
4710 bool x_mouse_grabbed (Display_Info
*dpyinfo
)
4712 return (dpyinfo
->grabbed
4713 && dpyinfo
->last_mouse_frame
4714 && FRAME_LIVE_P (dpyinfo
->last_mouse_frame
));
4717 /* Re-highlight something with mouse-face properties
4718 on DPYINFO using saved frame and mouse position. */
4721 x_redo_mouse_highlight (Display_Info
*dpyinfo
)
4723 if (dpyinfo
->last_mouse_motion_frame
4724 && FRAME_LIVE_P (dpyinfo
->last_mouse_motion_frame
))
4725 note_mouse_highlight (dpyinfo
->last_mouse_motion_frame
,
4726 dpyinfo
->last_mouse_motion_x
,
4727 dpyinfo
->last_mouse_motion_y
);
4730 #endif /* HAVE_NS */
4732 /* Subroutines of creating an X frame. */
4734 /* Make sure that Vx_resource_name is set to a reasonable value.
4735 Fix it up, or set it to `emacs' if it is too hopeless. */
4738 validate_x_resource_name (void)
4741 /* Number of valid characters in the resource name. */
4742 ptrdiff_t good_count
= 0;
4743 /* Number of invalid characters in the resource name. */
4744 ptrdiff_t bad_count
= 0;
4748 if (!STRINGP (Vx_resource_class
))
4749 Vx_resource_class
= build_string (EMACS_CLASS
);
4751 if (STRINGP (Vx_resource_name
))
4753 unsigned char *p
= SDATA (Vx_resource_name
);
4755 len
= SBYTES (Vx_resource_name
);
4757 /* Only letters, digits, - and _ are valid in resource names.
4758 Count the valid characters and count the invalid ones. */
4759 for (i
= 0; i
< len
; i
++)
4762 if (! ((c
>= 'a' && c
<= 'z')
4763 || (c
>= 'A' && c
<= 'Z')
4764 || (c
>= '0' && c
<= '9')
4765 || c
== '-' || c
== '_'))
4772 /* Not a string => completely invalid. */
4773 bad_count
= 5, good_count
= 0;
4775 /* If name is valid already, return. */
4779 /* If name is entirely invalid, or nearly so, or is so implausibly
4780 large that alloca might not work, use `emacs'. */
4781 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
4783 Vx_resource_name
= build_string ("emacs");
4787 /* Name is partly valid. Copy it and replace the invalid characters
4788 with underscores. */
4790 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
4792 for (i
= 0; i
< len
; i
++)
4794 int c
= SREF (new, i
);
4795 if (! ((c
>= 'a' && c
<= 'z')
4796 || (c
>= 'A' && c
<= 'Z')
4797 || (c
>= '0' && c
<= '9')
4798 || c
== '-' || c
== '_'))
4803 /* Get specified attribute from resource database RDB.
4804 See Fx_get_resource below for other parameters. */
4807 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
4809 CHECK_STRING (attribute
);
4810 CHECK_STRING (class);
4812 if (!NILP (component
))
4813 CHECK_STRING (component
);
4814 if (!NILP (subclass
))
4815 CHECK_STRING (subclass
);
4816 if (NILP (component
) != NILP (subclass
))
4817 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
4819 validate_x_resource_name ();
4821 /* Allocate space for the components, the dots which separate them,
4822 and the final '\0'. Make them big enough for the worst case. */
4823 ptrdiff_t name_keysize
= (SBYTES (Vx_resource_name
)
4824 + (STRINGP (component
)
4825 ? SBYTES (component
) : 0)
4826 + SBYTES (attribute
)
4829 ptrdiff_t class_keysize
= (SBYTES (Vx_resource_class
)
4831 + (STRINGP (subclass
)
4832 ? SBYTES (subclass
) : 0)
4835 char *name_key
= SAFE_ALLOCA (name_keysize
+ class_keysize
);
4836 char *class_key
= name_key
+ name_keysize
;
4838 /* Start with emacs.FRAMENAME for the name (the specific one)
4839 and with `Emacs' for the class key (the general one). */
4840 char *nz
= lispstpcpy (name_key
, Vx_resource_name
);
4841 char *cz
= lispstpcpy (class_key
, Vx_resource_class
);
4844 cz
= lispstpcpy (cz
, class);
4846 if (!NILP (component
))
4849 lispstpcpy (cz
, subclass
);
4852 nz
= lispstpcpy (nz
, component
);
4856 lispstpcpy (nz
, attribute
);
4858 char *value
= x_get_string_resource (rdb
, name_key
, class_key
);
4861 if (value
&& *value
)
4862 return build_string (value
);
4868 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
4869 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
4870 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
4871 class, where INSTANCE is the name under which Emacs was invoked, or
4872 the name specified by the `-name' or `-rn' command-line arguments.
4874 The optional arguments COMPONENT and SUBCLASS add to the key and the
4875 class, respectively. You must specify both of them or neither.
4876 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
4877 and the class is `Emacs.CLASS.SUBCLASS'. */)
4878 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
,
4879 Lisp_Object subclass
)
4881 check_window_system (NULL
);
4883 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
4884 attribute
, class, component
, subclass
);
4887 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
4890 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
,
4891 Lisp_Object
class, Lisp_Object component
,
4892 Lisp_Object subclass
)
4894 return xrdb_get_resource (dpyinfo
->xrdb
,
4895 attribute
, class, component
, subclass
);
4898 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT && !defined USE_GTK
4899 /* Used when C code wants a resource value. */
4900 /* Called from oldXMenu/Create.c. */
4902 x_get_resource_string (const char *attribute
, const char *class)
4905 struct frame
*sf
= SELECTED_FRAME ();
4906 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
4909 /* Allocate space for the components, the dots which separate them,
4910 and the final '\0'. */
4911 ptrdiff_t name_keysize
= invocation_namelen
+ strlen (attribute
) + 2;
4912 ptrdiff_t class_keysize
= sizeof (EMACS_CLASS
) - 1 + strlen (class) + 2;
4913 char *name_key
= SAFE_ALLOCA (name_keysize
+ class_keysize
);
4914 char *class_key
= name_key
+ name_keysize
;
4916 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
4917 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
4919 result
= x_get_string_resource (FRAME_DISPLAY_INFO (sf
)->xrdb
,
4920 name_key
, class_key
);
4926 /* Return the value of parameter PARAM.
4928 First search ALIST, then Vdefault_frame_alist, then the X defaults
4929 database, using ATTRIBUTE as the attribute name and CLASS as its class.
4931 Convert the resource to the type specified by desired_type.
4933 If no default is specified, return Qunbound. If you call
4934 x_get_arg, make sure you deal with Qunbound in a reasonable way,
4935 and don't let it get stored in any Lisp-visible variables! */
4938 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
4939 const char *attribute
, const char *class, enum resource_types type
)
4943 tem
= Fassq (param
, alist
);
4947 /* If we find this parm in ALIST, clear it out
4948 so that it won't be "left over" at the end. */
4950 XSETCAR (tem
, Qnil
);
4951 /* In case the parameter appears more than once in the alist,
4953 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
4954 if (CONSP (XCAR (tail
))
4955 && EQ (XCAR (XCAR (tail
)), param
))
4956 XSETCAR (XCAR (tail
), Qnil
);
4959 tem
= Fassq (param
, Vdefault_frame_alist
);
4961 /* If it wasn't specified in ALIST or the Lisp-level defaults,
4962 look in the X resources. */
4965 if (attribute
&& dpyinfo
)
4967 AUTO_STRING (at
, attribute
);
4968 AUTO_STRING (cl
, class);
4969 tem
= display_x_get_resource (dpyinfo
, at
, cl
, Qnil
, Qnil
);
4976 case RES_TYPE_NUMBER
:
4977 return make_number (atoi (SSDATA (tem
)));
4979 case RES_TYPE_BOOLEAN_NUMBER
:
4980 if (!strcmp (SSDATA (tem
), "on")
4981 || !strcmp (SSDATA (tem
), "true"))
4982 return make_number (1);
4983 return make_number (atoi (SSDATA (tem
)));
4986 case RES_TYPE_FLOAT
:
4987 return make_float (atof (SSDATA (tem
)));
4989 case RES_TYPE_BOOLEAN
:
4990 tem
= Fdowncase (tem
);
4991 if (!strcmp (SSDATA (tem
), "on")
4993 || !strcmp (SSDATA (tem
), "yes")
4995 || !strcmp (SSDATA (tem
), "true"))
5000 case RES_TYPE_STRING
:
5003 case RES_TYPE_SYMBOL
:
5004 /* As a special case, we map the values `true' and `on'
5005 to Qt, and `false' and `off' to Qnil. */
5008 lower
= Fdowncase (tem
);
5009 if (!strcmp (SSDATA (lower
), "on")
5011 || !strcmp (SSDATA (lower
), "yes")
5013 || !strcmp (SSDATA (lower
), "true"))
5015 else if (!strcmp (SSDATA (lower
), "off")
5017 || !strcmp (SSDATA (lower
), "no")
5019 || !strcmp (SSDATA (lower
), "false"))
5022 return Fintern (tem
, Qnil
);
5036 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
5037 const char *attribute
, const char *class,
5038 enum resource_types type
)
5040 return x_get_arg (FRAME_DISPLAY_INFO (f
),
5041 alist
, param
, attribute
, class, type
);
5044 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
5047 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
5049 const char *attribute
, const char *class,
5050 enum resource_types type
)
5054 value
= x_get_arg (FRAME_DISPLAY_INFO (f
), alist
, param
,
5055 attribute
, class, type
);
5056 if (! NILP (value
) && ! EQ (value
, Qunbound
))
5057 store_frame_param (f
, param
, value
);
5063 /* Record in frame F the specified or default value according to ALIST
5064 of the parameter named PROP (a Lisp symbol).
5065 If no value is specified for PROP, look for an X default for XPROP
5066 on the frame named NAME.
5067 If that is not found either, use the value DEFLT. */
5070 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
5071 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
5072 enum resource_types type
)
5076 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
5077 if (EQ (tem
, Qunbound
))
5079 AUTO_FRAME_ARG (arg
, prop
, tem
);
5080 x_set_frame_parameters (f
, arg
);
5085 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
5088 * XParseGeometry parses strings of the form
5089 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
5090 * width, height, xoffset, and yoffset are unsigned integers.
5091 * Example: "=80x24+300-49"
5092 * The equal sign is optional.
5093 * It returns a bitmask that indicates which of the four values
5094 * were actually found in the string. For each value found,
5095 * the corresponding argument is updated; for each value
5096 * not found, the corresponding argument is left unchanged.
5100 XParseGeometry (char *string
,
5102 unsigned int *width
, unsigned int *height
)
5106 unsigned long tempWidth UNINIT
, tempHeight UNINIT
;
5107 long int tempX UNINIT
, tempY UNINIT
;
5108 char *nextCharacter
;
5110 if (string
== NULL
|| *string
== '\0')
5113 string
++; /* ignore possible '=' at beg of geometry spec */
5116 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
5118 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
5119 if (strind
== nextCharacter
)
5121 strind
= nextCharacter
;
5125 if (*strind
== 'x' || *strind
== 'X')
5128 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
5129 if (strind
== nextCharacter
)
5131 strind
= nextCharacter
;
5132 mask
|= HeightValue
;
5135 if (*strind
== '+' || *strind
== '-')
5139 tempX
= strtol (strind
, &nextCharacter
, 10);
5140 if (strind
== nextCharacter
)
5142 strind
= nextCharacter
;
5144 if (*strind
== '+' || *strind
== '-')
5148 tempY
= strtol (strind
, &nextCharacter
, 10);
5149 if (strind
== nextCharacter
)
5151 strind
= nextCharacter
;
5156 /* If strind isn't at the end of the string then it's an invalid
5157 geometry specification. */
5159 if (*strind
!= '\0')
5163 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
5165 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
5166 if (mask
& WidthValue
)
5167 *width
= min (tempWidth
, UINT_MAX
);
5168 if (mask
& HeightValue
)
5169 *height
= min (tempHeight
, UINT_MAX
);
5173 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
5176 /* NS used to define x-parse-geometry in ns-win.el, but that confused
5177 make-docfile: the documentation string in ns-win.el was used for
5178 x-parse-geometry even in non-NS builds.
5180 With two definitions of x-parse-geometry in this file, various
5181 things still get confused (eg M-x apropos documentation), so that
5182 it is best if the two definitions just share the same doc-string.
5184 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
5185 doc
: /* Parse a display geometry string STRING.
5186 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
5187 The properties returned may include `top', `left', `height', and `width'.
5188 For X, the value of `left' or `top' may be an integer,
5189 or a list (+ N) meaning N pixels relative to top/left corner,
5190 or a list (- N) meaning -N pixels relative to bottom/right corner.
5191 On Nextstep, this just calls `ns-parse-geometry'. */)
5192 (Lisp_Object string
)
5195 unsigned int width
, height
;
5198 CHECK_STRING (string
);
5201 if (strchr (SSDATA (string
), ' ') != NULL
)
5202 return call1 (Qns_parse_geometry
, string
);
5204 geometry
= XParseGeometry (SSDATA (string
),
5205 &x
, &y
, &width
, &height
);
5207 if (geometry
& XValue
)
5209 Lisp_Object element
;
5211 if (x
>= 0 && (geometry
& XNegative
))
5212 element
= list3 (Qleft
, Qminus
, make_number (-x
));
5213 else if (x
< 0 && ! (geometry
& XNegative
))
5214 element
= list3 (Qleft
, Qplus
, make_number (x
));
5216 element
= Fcons (Qleft
, make_number (x
));
5217 result
= Fcons (element
, result
);
5220 if (geometry
& YValue
)
5222 Lisp_Object element
;
5224 if (y
>= 0 && (geometry
& YNegative
))
5225 element
= list3 (Qtop
, Qminus
, make_number (-y
));
5226 else if (y
< 0 && ! (geometry
& YNegative
))
5227 element
= list3 (Qtop
, Qplus
, make_number (y
));
5229 element
= Fcons (Qtop
, make_number (y
));
5230 result
= Fcons (element
, result
);
5233 if (geometry
& WidthValue
)
5234 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
5235 if (geometry
& HeightValue
)
5236 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
5242 /* Calculate the desired size and position of frame F.
5243 Return the flags saying which aspects were specified.
5245 Also set the win_gravity and size_hint_flags of F.
5247 Adjust height for toolbar if TOOLBAR_P is 1.
5249 This function does not make the coordinates positive. */
5251 #define DEFAULT_ROWS 36
5252 #define DEFAULT_COLS 80
5255 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, bool toolbar_p
, int *x_width
, int *x_height
)
5257 Lisp_Object height
, width
, user_size
, top
, left
, user_position
;
5258 long window_prompting
= 0;
5259 Display_Info
*dpyinfo
= FRAME_DISPLAY_INFO (f
);
5260 int parent_done
= -1, outer_done
= -1;
5262 /* Default values if we fall through.
5263 Actually, if that happens we should get
5264 window manager prompting. */
5265 SET_FRAME_WIDTH (f
, DEFAULT_COLS
* FRAME_COLUMN_WIDTH (f
));
5266 SET_FRAME_COLS (f
, DEFAULT_COLS
);
5267 SET_FRAME_HEIGHT (f
, DEFAULT_ROWS
* FRAME_LINE_HEIGHT (f
));
5268 SET_FRAME_LINES (f
, DEFAULT_ROWS
);
5270 /* Window managers expect that if program-specified
5271 positions are not (0,0), they're intentional, not defaults. */
5275 /* Calculate a tool bar height so that the user gets a text display
5276 area of the size he specified with -g or via .Xdefaults. Later
5277 changes of the tool bar height don't change the frame size. This
5278 is done so that users can create tall Emacs frames without having
5279 to guess how tall the tool bar will get. */
5280 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
5282 if (frame_default_tool_bar_height
)
5283 FRAME_TOOL_BAR_HEIGHT (f
) = frame_default_tool_bar_height
;
5288 relief
= (tool_bar_button_relief
>= 0
5289 ? tool_bar_button_relief
5290 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
5292 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
5293 margin
= XFASTINT (Vtool_bar_button_margin
);
5294 else if (CONSP (Vtool_bar_button_margin
)
5295 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
5296 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
5300 FRAME_TOOL_BAR_HEIGHT (f
)
5301 = DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
5305 /* Ensure that earlier new_width and new_height settings won't
5306 override what we specify below. */
5307 f
->new_width
= f
->new_height
= 0;
5309 height
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
5310 width
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
5311 if (!EQ (width
, Qunbound
) || !EQ (height
, Qunbound
))
5313 if (!EQ (width
, Qunbound
))
5315 if (CONSP (width
) && EQ (XCAR (width
), Qtext_pixels
))
5317 CHECK_NUMBER (XCDR (width
));
5318 if ((XINT (XCDR (width
)) < 0 || XINT (XCDR (width
)) > INT_MAX
))
5319 xsignal1 (Qargs_out_of_range
, XCDR (width
));
5321 SET_FRAME_WIDTH (f
, XINT (XCDR (width
)));
5322 f
->inhibit_horizontal_resize
= true;
5323 *x_width
= XINT (XCDR (width
));
5325 else if (FLOATP (width
))
5327 double d_width
= XFLOAT_DATA (width
);
5329 if (d_width
< 0.0 || d_width
> 1.0)
5330 xsignal1 (Qargs_out_of_range
, width
);
5333 int new_width
= frame_float (f
, width
, FRAME_FLOAT_WIDTH
,
5334 &parent_done
, &outer_done
, -1);
5337 SET_FRAME_WIDTH (f
, new_width
);
5342 CHECK_NUMBER (width
);
5343 if ((XINT (width
) < 0 || XINT (width
) > INT_MAX
))
5344 xsignal1 (Qargs_out_of_range
, width
);
5346 SET_FRAME_WIDTH (f
, XINT (width
) * FRAME_COLUMN_WIDTH (f
));
5350 if (!EQ (height
, Qunbound
))
5352 if (CONSP (height
) && EQ (XCAR (height
), Qtext_pixels
))
5354 CHECK_NUMBER (XCDR (height
));
5355 if ((XINT (XCDR (height
)) < 0 || XINT (XCDR (height
)) > INT_MAX
))
5356 xsignal1 (Qargs_out_of_range
, XCDR (height
));
5358 SET_FRAME_HEIGHT (f
, XINT (XCDR (height
)));
5359 f
->inhibit_vertical_resize
= true;
5360 *x_height
= XINT (XCDR (height
));
5362 else if (FLOATP (height
))
5364 double d_height
= XFLOAT_DATA (height
);
5366 if (d_height
< 0.0 || d_height
> 1.0)
5367 xsignal1 (Qargs_out_of_range
, height
);
5370 int new_height
= frame_float (f
, height
, FRAME_FLOAT_HEIGHT
,
5371 &parent_done
, &outer_done
, -1);
5373 if (new_height
> -1)
5374 SET_FRAME_HEIGHT (f
, new_height
);
5379 CHECK_NUMBER (height
);
5380 if ((XINT (height
) < 0) || (XINT (height
) > INT_MAX
))
5381 xsignal1 (Qargs_out_of_range
, height
);
5383 SET_FRAME_HEIGHT (f
, XINT (height
) * FRAME_LINE_HEIGHT (f
));
5387 user_size
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
5388 if (!NILP (user_size
) && !EQ (user_size
, Qunbound
))
5389 window_prompting
|= USSize
;
5391 window_prompting
|= PSize
;
5394 top
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
5395 left
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
5396 user_position
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
5397 if (! EQ (top
, Qunbound
) || ! EQ (left
, Qunbound
))
5399 if (EQ (top
, Qminus
))
5402 window_prompting
|= YNegative
;
5404 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
5405 && CONSP (XCDR (top
))
5406 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
5408 f
->top_pos
= - XINT (XCAR (XCDR (top
)));
5409 window_prompting
|= YNegative
;
5411 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
5412 && CONSP (XCDR (top
))
5413 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
5415 f
->top_pos
= XINT (XCAR (XCDR (top
)));
5417 else if (FLOATP (top
))
5418 f
->top_pos
= frame_float (f
, top
, FRAME_FLOAT_TOP
, &parent_done
,
5420 else if (EQ (top
, Qunbound
))
5424 CHECK_TYPE_RANGED_INTEGER (int, top
);
5425 f
->top_pos
= XINT (top
);
5427 window_prompting
|= YNegative
;
5430 if (EQ (left
, Qminus
))
5433 window_prompting
|= XNegative
;
5435 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
5436 && CONSP (XCDR (left
))
5437 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
5439 f
->left_pos
= - XINT (XCAR (XCDR (left
)));
5440 window_prompting
|= XNegative
;
5442 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
5443 && CONSP (XCDR (left
))
5444 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
5446 f
->left_pos
= XINT (XCAR (XCDR (left
)));
5448 else if (FLOATP (left
))
5449 f
->left_pos
= frame_float (f
, left
, FRAME_FLOAT_LEFT
, &parent_done
,
5451 else if (EQ (left
, Qunbound
))
5455 CHECK_TYPE_RANGED_INTEGER (int, left
);
5456 f
->left_pos
= XINT (left
);
5457 if (f
->left_pos
< 0)
5458 window_prompting
|= XNegative
;
5461 if (!NILP (user_position
) && ! EQ (user_position
, Qunbound
))
5462 window_prompting
|= USPosition
;
5464 window_prompting
|= PPosition
;
5467 if (window_prompting
& XNegative
)
5469 if (window_prompting
& YNegative
)
5470 f
->win_gravity
= SouthEastGravity
;
5472 f
->win_gravity
= NorthEastGravity
;
5476 if (window_prompting
& YNegative
)
5477 f
->win_gravity
= SouthWestGravity
;
5479 f
->win_gravity
= NorthWestGravity
;
5482 f
->size_hint_flags
= window_prompting
;
5484 return window_prompting
;
5489 #endif /* HAVE_WINDOW_SYSTEM */
5492 frame_make_pointer_invisible (struct frame
*f
)
5494 if (! NILP (Vmake_pointer_invisible
))
5496 if (f
&& FRAME_LIVE_P (f
) && !f
->pointer_invisible
5497 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
5500 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
5501 f
->pointer_invisible
= 1;
5507 frame_make_pointer_visible (struct frame
*f
)
5509 /* We don't check Vmake_pointer_invisible here in case the
5510 pointer was invisible when Vmake_pointer_invisible was set to nil. */
5511 if (f
&& FRAME_LIVE_P (f
) && f
->pointer_invisible
&& f
->mouse_moved
5512 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
5514 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
5515 f
->pointer_invisible
= 0;
5519 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
5520 Sframe_pointer_visible_p
, 0, 1, 0,
5521 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
5522 Otherwise it returns nil. FRAME omitted or nil means the
5523 selected frame. This is useful when `make-pointer-invisible' is set. */)
5526 return decode_any_frame (frame
)->pointer_invisible
? Qnil
: Qt
;
5531 /***********************************************************************
5533 ***********************************************************************/
5535 #ifdef HAVE_WINDOW_SYSTEM
5537 # if (defined USE_GTK || defined HAVE_NS || defined HAVE_XINERAMA \
5538 || defined HAVE_XRANDR)
5540 free_monitors (struct MonitorInfo
*monitors
, int n_monitors
)
5543 for (i
= 0; i
< n_monitors
; ++i
)
5544 xfree (monitors
[i
].name
);
5550 make_monitor_attribute_list (struct MonitorInfo
*monitors
,
5552 int primary_monitor
,
5553 Lisp_Object monitor_frames
,
5556 Lisp_Object attributes_list
= Qnil
;
5557 Lisp_Object primary_monitor_attributes
= Qnil
;
5560 for (i
= 0; i
< n_monitors
; ++i
)
5562 Lisp_Object geometry
, workarea
, attributes
= Qnil
;
5563 struct MonitorInfo
*mi
= &monitors
[i
];
5565 if (mi
->geom
.width
== 0) continue;
5567 workarea
= list4i (mi
->work
.x
, mi
->work
.y
,
5568 mi
->work
.width
, mi
->work
.height
);
5569 geometry
= list4i (mi
->geom
.x
, mi
->geom
.y
,
5570 mi
->geom
.width
, mi
->geom
.height
);
5571 attributes
= Fcons (Fcons (Qsource
, build_string (source
)),
5573 attributes
= Fcons (Fcons (Qframes
, AREF (monitor_frames
, i
)),
5575 attributes
= Fcons (Fcons (Qmm_size
,
5576 list2i (mi
->mm_width
, mi
->mm_height
)),
5578 attributes
= Fcons (Fcons (Qworkarea
, workarea
), attributes
);
5579 attributes
= Fcons (Fcons (Qgeometry
, geometry
), attributes
);
5581 attributes
= Fcons (Fcons (Qname
, make_string (mi
->name
,
5582 strlen (mi
->name
))),
5585 if (i
== primary_monitor
)
5586 primary_monitor_attributes
= attributes
;
5588 attributes_list
= Fcons (attributes
, attributes_list
);
5591 if (!NILP (primary_monitor_attributes
))
5592 attributes_list
= Fcons (primary_monitor_attributes
, attributes_list
);
5593 return attributes_list
;
5596 #endif /* HAVE_WINDOW_SYSTEM */
5599 /***********************************************************************
5601 ***********************************************************************/
5604 syms_of_frame (void)
5606 DEFSYM (Qframep
, "framep");
5607 DEFSYM (Qframe_live_p
, "frame-live-p");
5608 DEFSYM (Qframe_windows_min_size
, "frame-windows-min-size");
5609 DEFSYM (Qdisplay_monitor_attributes_list
, "display-monitor-attributes-list");
5610 DEFSYM (Qwindow__pixel_to_total
, "window--pixel-to-total");
5611 DEFSYM (Qexplicit_name
, "explicit-name");
5612 DEFSYM (Qheight
, "height");
5613 DEFSYM (Qicon
, "icon");
5614 DEFSYM (Qminibuffer
, "minibuffer");
5615 DEFSYM (Qundecorated
, "undecorated");
5616 DEFSYM (Qno_special_glyphs
, "no-special-glyphs");
5617 DEFSYM (Qparent_frame
, "parent-frame");
5618 DEFSYM (Qskip_taskbar
, "skip-taskbar");
5619 DEFSYM (Qno_focus_on_map
, "no-focus-on-map");
5620 DEFSYM (Qno_accept_focus
, "no-accept-focus");
5621 DEFSYM (Qz_group
, "z-group");
5622 DEFSYM (Qoverride_redirect
, "override-redirect");
5623 DEFSYM (Qdelete_before
, "delete-before");
5624 DEFSYM (Qmodeline
, "modeline");
5625 DEFSYM (Qonly
, "only");
5626 DEFSYM (Qnone
, "none");
5627 DEFSYM (Qwidth
, "width");
5628 DEFSYM (Qtext_pixels
, "text-pixels");
5629 DEFSYM (Qgeometry
, "geometry");
5630 DEFSYM (Qicon_left
, "icon-left");
5631 DEFSYM (Qicon_top
, "icon-top");
5632 DEFSYM (Qtooltip
, "tooltip");
5633 DEFSYM (Quser_position
, "user-position");
5634 DEFSYM (Quser_size
, "user-size");
5635 DEFSYM (Qwindow_id
, "window-id");
5636 #ifdef HAVE_X_WINDOWS
5637 DEFSYM (Qouter_window_id
, "outer-window-id");
5639 DEFSYM (Qparent_id
, "parent-id");
5641 DEFSYM (Qw32
, "w32");
5644 DEFSYM (Qvisible
, "visible");
5645 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
5646 DEFSYM (Qbuffer_list
, "buffer-list");
5647 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
5648 DEFSYM (Qdisplay_type
, "display-type");
5649 DEFSYM (Qbackground_mode
, "background-mode");
5650 DEFSYM (Qnoelisp
, "noelisp");
5651 DEFSYM (Qtty_color_mode
, "tty-color-mode");
5652 DEFSYM (Qtty
, "tty");
5653 DEFSYM (Qtty_type
, "tty-type");
5655 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
5657 DEFSYM (Qfullwidth
, "fullwidth");
5658 DEFSYM (Qfullheight
, "fullheight");
5659 DEFSYM (Qfullboth
, "fullboth");
5660 DEFSYM (Qmaximized
, "maximized");
5661 DEFSYM (Qx_resource_name
, "x-resource-name");
5662 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
5664 DEFSYM (Qworkarea
, "workarea");
5665 DEFSYM (Qmm_size
, "mm-size");
5666 DEFSYM (Qframes
, "frames");
5667 DEFSYM (Qsource
, "source");
5669 DEFSYM (Qframe_edges
, "frame-edges");
5670 DEFSYM (Qouter_edges
, "outer-edges");
5671 DEFSYM (Qouter_position
, "outer-position");
5672 DEFSYM (Qouter_size
, "outer-size");
5673 DEFSYM (Qnative_edges
, "native-edges");
5674 DEFSYM (Qinner_edges
, "inner-edges");
5675 DEFSYM (Qexternal_border_size
, "external-border-size");
5676 DEFSYM (Qtitle_bar_size
, "title-bar-size");
5677 DEFSYM (Qmenu_bar_external
, "menu-bar-external");
5678 DEFSYM (Qmenu_bar_size
, "menu-bar-size");
5679 DEFSYM (Qtool_bar_external
, "tool-bar-external");
5680 DEFSYM (Qtool_bar_size
, "tool-bar-size");
5681 /* The following are used for frame_size_history. */
5682 DEFSYM (Qadjust_frame_size_1
, "adjust-frame-size-1");
5683 DEFSYM (Qadjust_frame_size_2
, "adjust-frame-size-2");
5684 DEFSYM (Qadjust_frame_size_3
, "adjust-frame-size-3");
5685 DEFSYM (Qx_set_frame_parameters
, "x-set-frame-parameters");
5686 DEFSYM (QEmacsFrameResize
, "EmacsFrameResize");
5687 DEFSYM (Qset_frame_size
, "set-frame-size");
5688 DEFSYM (Qframe_inhibit_resize
, "frame-inhibit-resize");
5689 DEFSYM (Qx_set_fullscreen
, "x-set-fullscreen");
5690 DEFSYM (Qx_check_fullscreen
, "x-check-fullscreen");
5691 DEFSYM (Qxg_frame_resized
, "xg-frame-resized");
5692 DEFSYM (Qxg_frame_set_char_size_1
, "xg-frame-set-char-size-1");
5693 DEFSYM (Qxg_frame_set_char_size_2
, "xg-frame-set-char-size-2");
5694 DEFSYM (Qxg_frame_set_char_size_3
, "xg-frame-set-char-size-3");
5695 DEFSYM (Qx_set_window_size_1
, "x-set-window-size-1");
5696 DEFSYM (Qx_set_window_size_2
, "x-set-window-size-2");
5697 DEFSYM (Qx_set_window_size_3
, "x-set-window-size-3");
5698 DEFSYM (Qxg_change_toolbar_position
, "xg-change-toolbar-position");
5699 DEFSYM (Qx_net_wm_state
, "x-net-wm-state");
5700 DEFSYM (Qx_handle_net_wm_state
, "x-handle-net-wm-state");
5701 DEFSYM (Qtb_size_cb
, "tb-size-cb");
5702 DEFSYM (Qupdate_frame_tool_bar
, "update-frame-tool-bar");
5703 DEFSYM (Qfree_frame_tool_bar
, "free-frame-tool-bar");
5704 DEFSYM (Qx_set_menu_bar_lines
, "x-set-menu-bar-lines");
5705 DEFSYM (Qchange_frame_size
, "change-frame-size");
5706 DEFSYM (Qxg_frame_set_char_size
, "xg-frame-set-char-size");
5707 DEFSYM (Qset_window_configuration
, "set-window-configuration");
5708 DEFSYM (Qx_create_frame_1
, "x-create-frame-1");
5709 DEFSYM (Qx_create_frame_2
, "x-create-frame-2");
5710 DEFSYM (Qterminal_frame
, "terminal-frame");
5713 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
5715 #ifdef NS_IMPL_COCOA
5716 DEFSYM (Qns_appearance
, "ns-appearance");
5717 DEFSYM (Qns_transparent_titlebar
, "ns-transparent-titlebar");
5720 DEFSYM (Qalpha
, "alpha");
5721 DEFSYM (Qauto_lower
, "auto-lower");
5722 DEFSYM (Qauto_raise
, "auto-raise");
5723 DEFSYM (Qborder_color
, "border-color");
5724 DEFSYM (Qborder_width
, "border-width");
5725 DEFSYM (Qouter_border_width
, "outer-border-width");
5726 DEFSYM (Qbottom_divider_width
, "bottom-divider-width");
5727 DEFSYM (Qcursor_color
, "cursor-color");
5728 DEFSYM (Qcursor_type
, "cursor-type");
5729 DEFSYM (Qfont_backend
, "font-backend");
5730 DEFSYM (Qfullscreen
, "fullscreen");
5731 DEFSYM (Qhorizontal_scroll_bars
, "horizontal-scroll-bars");
5732 DEFSYM (Qicon_name
, "icon-name");
5733 DEFSYM (Qicon_type
, "icon-type");
5734 DEFSYM (Qinternal_border_width
, "internal-border-width");
5735 DEFSYM (Qleft_fringe
, "left-fringe");
5736 DEFSYM (Qline_spacing
, "line-spacing");
5737 DEFSYM (Qmenu_bar_lines
, "menu-bar-lines");
5738 DEFSYM (Qupdate_frame_menubar
, "update-frame-menubar");
5739 DEFSYM (Qfree_frame_menubar_1
, "free-frame-menubar-1");
5740 DEFSYM (Qfree_frame_menubar_2
, "free-frame-menubar-2");
5741 DEFSYM (Qmouse_color
, "mouse-color");
5742 DEFSYM (Qname
, "name");
5743 DEFSYM (Qright_divider_width
, "right-divider-width");
5744 DEFSYM (Qright_fringe
, "right-fringe");
5745 DEFSYM (Qscreen_gamma
, "screen-gamma");
5746 DEFSYM (Qscroll_bar_background
, "scroll-bar-background");
5747 DEFSYM (Qscroll_bar_foreground
, "scroll-bar-foreground");
5748 DEFSYM (Qscroll_bar_height
, "scroll-bar-height");
5749 DEFSYM (Qscroll_bar_width
, "scroll-bar-width");
5750 DEFSYM (Qsticky
, "sticky");
5751 DEFSYM (Qtitle
, "title");
5752 DEFSYM (Qtool_bar_lines
, "tool-bar-lines");
5753 DEFSYM (Qtool_bar_position
, "tool-bar-position");
5754 DEFSYM (Qunsplittable
, "unsplittable");
5755 DEFSYM (Qvertical_scroll_bars
, "vertical-scroll-bars");
5756 DEFSYM (Qvisibility
, "visibility");
5757 DEFSYM (Qwait_for_wm
, "wait-for-wm");
5758 DEFSYM (Qinhibit_double_buffering
, "inhibit-double-buffering");
5759 DEFSYM (Qno_other_frame
, "no-other-frame");
5760 DEFSYM (Qbelow
, "below");
5761 DEFSYM (Qabove_suspended
, "above-suspended");
5762 DEFSYM (Qmin_width
, "min-width");
5763 DEFSYM (Qmin_height
, "min-height");
5764 DEFSYM (Qmouse_wheel_frame
, "mouse-wheel-frame");
5765 DEFSYM (Qkeep_ratio
, "keep-ratio");
5766 DEFSYM (Qwidth_only
, "width-only");
5767 DEFSYM (Qheight_only
, "height-only");
5768 DEFSYM (Qleft_only
, "left-only");
5769 DEFSYM (Qtop_only
, "top-only");
5770 DEFSYM (Qiconify_top_level
, "iconify-top-level");
5771 DEFSYM (Qmake_invisible
, "make-invisible");
5776 for (i
= 0; i
< ARRAYELTS (frame_parms
); i
++)
5778 Lisp_Object v
= (frame_parms
[i
].sym
< 0
5779 ? intern_c_string (frame_parms
[i
].name
)
5780 : builtin_lisp_symbol (frame_parms
[i
].sym
));
5781 Fput (v
, Qx_frame_parameter
, make_number (i
));
5785 #ifdef HAVE_WINDOW_SYSTEM
5786 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
5787 doc
: /* The name Emacs uses to look up X resources.
5788 `x-get-resource' uses this as the first component of the instance name
5789 when requesting resource values.
5790 Emacs initially sets `x-resource-name' to the name under which Emacs
5791 was invoked, or to the value specified with the `-name' or `-rn'
5792 switches, if present.
5794 It may be useful to bind this variable locally around a call
5795 to `x-get-resource'. See also the variable `x-resource-class'. */);
5796 Vx_resource_name
= Qnil
;
5798 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
5799 doc
: /* The class Emacs uses to look up X resources.
5800 `x-get-resource' uses this as the first component of the instance class
5801 when requesting resource values.
5803 Emacs initially sets `x-resource-class' to "Emacs".
5805 Setting this variable permanently is not a reasonable thing to do,
5806 but binding this variable locally around a call to `x-get-resource'
5807 is a reasonable practice. See also the variable `x-resource-name'. */);
5808 Vx_resource_class
= build_string (EMACS_CLASS
);
5810 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
5811 doc
: /* The lower limit of the frame opacity (alpha transparency).
5812 The value should range from 0 (invisible) to 100 (completely opaque).
5813 You can also use a floating number between 0.0 and 1.0. */);
5814 Vframe_alpha_lower_limit
= make_number (20);
5817 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
5818 doc
: /* Alist of default values for frame creation.
5819 These may be set in your init file, like this:
5820 (setq default-frame-alist \\='((width . 80) (height . 55) (menu-bar-lines . 1)))
5821 These override values given in window system configuration data,
5822 including X Windows' defaults database.
5823 For values specific to the first Emacs frame, see `initial-frame-alist'.
5824 For window-system specific values, see `window-system-default-frame-alist'.
5825 For values specific to the separate minibuffer frame, see
5826 `minibuffer-frame-alist'.
5827 The `menu-bar-lines' element of the list controls whether new frames
5828 have menu bars; `menu-bar-mode' works by altering this element.
5829 Setting this variable does not affect existing frames, only new ones. */);
5830 Vdefault_frame_alist
= Qnil
;
5832 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
5833 doc
: /* Default position of vertical scroll bars on this window-system. */);
5834 #ifdef HAVE_WINDOW_SYSTEM
5835 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
5836 /* MS-Windows, macOS, and GTK have scroll bars on the right by
5838 Vdefault_frame_scroll_bars
= Qright
;
5840 Vdefault_frame_scroll_bars
= Qleft
;
5843 Vdefault_frame_scroll_bars
= Qnil
;
5846 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
5847 scroll_bar_adjust_thumb_portion_p
,
5848 doc
: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
5849 Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
5850 even if the end of the buffer is shown (i.e. overscrolling).
5851 Set to nil if you want the thumb to be at the bottom when the end of the buffer
5852 is shown. Also, the thumb fills the whole scroll bar when the entire buffer
5853 is visible. In this case you can not overscroll. */);
5854 scroll_bar_adjust_thumb_portion_p
= 1;
5856 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
5857 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
5859 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
5860 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
5861 `mouse-position' and `mouse-pixel-position' call this function, passing their
5862 usual return value as argument, and return whatever this function returns.
5863 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
5864 which need to do mouse handling at the Lisp level. */);
5865 Vmouse_position_function
= Qnil
;
5867 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
5868 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
5869 If the value is an integer, highlighting is only shown after moving the
5870 mouse, while keyboard input turns off the highlight even when the mouse
5871 is over the clickable text. However, the mouse shape still indicates
5872 when the mouse is over clickable text. */);
5873 Vmouse_highlight
= Qt
;
5875 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
5876 doc
: /* If non-nil, make pointer invisible while typing.
5877 The pointer becomes visible again when the mouse is moved. */);
5878 Vmake_pointer_invisible
= Qt
;
5880 DEFVAR_LISP ("focus-in-hook", Vfocus_in_hook
,
5881 doc
: /* Normal hook run when a frame gains input focus.
5882 The frame gaining focus is selected at the time this hook is run. */);
5883 Vfocus_in_hook
= Qnil
;
5885 DEFVAR_LISP ("focus-out-hook", Vfocus_out_hook
,
5886 doc
: /* Normal hook run when all frames lost input focus. */);
5887 Vfocus_out_hook
= Qnil
;
5889 DEFVAR_LISP ("move-frame-functions", Vmove_frame_functions
,
5890 doc
: /* Functions run after a frame was moved.
5891 The functions are run with one arg, the frame that moved. */);
5892 Vmove_frame_functions
= Qnil
;
5894 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
5895 doc
: /* Functions run before deleting a frame.
5896 The functions are run with one arg, the frame to be deleted.
5899 Note that functions in this list may be called just before the frame is
5900 actually deleted, or some time later (or even both when an earlier function
5901 in `delete-frame-functions' (indirectly) calls `delete-frame'
5903 Vdelete_frame_functions
= Qnil
;
5904 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
5906 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
5907 doc
: /* Non-nil if Menu-Bar mode is enabled.
5908 See the command `menu-bar-mode' for a description of this minor mode.
5909 Setting this variable directly does not take effect;
5910 either customize it (see the info node `Easy Customization')
5911 or call the function `menu-bar-mode'. */);
5912 Vmenu_bar_mode
= Qt
;
5914 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
5915 doc
: /* Non-nil if Tool-Bar mode is enabled.
5916 See the command `tool-bar-mode' for a description of this minor mode.
5917 Setting this variable directly does not take effect;
5918 either customize it (see the info node `Easy Customization')
5919 or call the function `tool-bar-mode'. */);
5920 #ifdef HAVE_WINDOW_SYSTEM
5921 Vtool_bar_mode
= Qt
;
5923 Vtool_bar_mode
= Qnil
;
5926 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
5927 doc
: /* Minibuffer-less frames by default use this frame's minibuffer.
5928 Emacs consults this variable only when creating a minibuffer-less frame
5929 and no explicit minibuffer window has been specified for that frame via
5930 the `minibuffer' frame parameter. Once such a frame has been created,
5931 setting this variable does not change that frame's previous association.
5933 This variable is local to the current terminal and cannot be buffer-local. */);
5935 DEFVAR_LISP ("focus-follows-mouse", focus_follows_mouse
,
5936 doc
: /* Non-nil if window system changes focus when you move the mouse.
5937 You should set this variable to tell Emacs how your window manager
5938 handles focus, since there is no way in general for Emacs to find out
5941 There are three meaningful values:
5943 - The default nil should be used when your window manager follows a
5944 "click-to-focus" policy where you have to click the mouse inside of a
5945 frame in order for that frame to get focus.
5947 - The value t should be used when your window manager has the focus
5948 automatically follow the position of the mouse pointer but a window
5949 that gains focus is not raised automatically.
5951 - The value `auto-raise' should be used when your window manager has the
5952 focus automatically follow the position of the mouse pointer and a
5953 window that gains focus is raised automatically.
5955 If this option is non-nil, Emacs moves the mouse pointer to the frame
5956 selected by `select-frame-set-input-focus'. This function is used by a
5957 number of commands like, for example, `other-frame' and `pop-to-buffer'.
5958 If this option is nil and your focus follows mouse window manager does
5959 not autonomously move the mouse pointer to the newly selected frame, the
5960 previously selected window manager window might get reselected instead
5963 The distinction between the values t and `auto-raise' is not needed for
5964 "normal" frames because the window manager takes care of raising them.
5965 Setting this to `auto-raise' will, however, override the standard
5966 behavior of a window manager that does not automatically raise the frame
5967 that gets focus. Setting this to `auto-raise' is also necessary to
5968 automatically raise child frames which are usually left alone by the
5971 Note that this option does not distinguish "sloppy" focus (where the
5972 frame that previously had focus retains focus as long as the mouse
5973 pointer does not move into another window manager window) from "strict"
5974 focus (where a frame immediately loses focus when it's left by the mouse
5977 In order to extend a "focus follows mouse" policy to individual Emacs
5978 windows, customize the variable `mouse-autoselect-window'. */);
5979 focus_follows_mouse
= Qnil
;
5981 DEFVAR_BOOL ("frame-resize-pixelwise", frame_resize_pixelwise
,
5982 doc
: /* Non-nil means resize frames pixelwise.
5983 If this option is nil, resizing a frame rounds its sizes to the frame's
5984 current values of `frame-char-height' and `frame-char-width'. If this
5985 is non-nil, no rounding occurs, hence frame sizes can increase/decrease
5988 With some window managers you may have to set this to non-nil in order
5989 to set the size of a frame in pixels, to maximize frames or to make them
5990 fullscreen. To resize your initial frame pixelwise, set this option to
5991 a non-nil value in your init file. */);
5992 frame_resize_pixelwise
= 0;
5994 DEFVAR_LISP ("frame-inhibit-implied-resize", frame_inhibit_implied_resize
,
5995 doc
: /* Whether frames should be resized implicitly.
5996 If this option is nil, setting font, menu bar, tool bar, internal
5997 borders, fringes or scroll bars of a specific frame may resize the frame
5998 in order to preserve the number of columns or lines it displays. If
5999 this option is t, no such resizing is done. Note that the size of
6000 fullscreen and maximized frames, the height of fullheight frames and the
6001 width of fullwidth frames never change implicitly.
6003 The value of this option can be also be a list of frame parameters. In
6004 this case, resizing is inhibited when changing a parameter that appears
6005 in that list. The parameters currently handled by this option include
6006 `font', `font-backend', `internal-border-width', `menu-bar-lines' and
6009 Changing any of the parameters `scroll-bar-width', `scroll-bar-height',
6010 `vertical-scroll-bars', `horizontal-scroll-bars', `left-fringe' and
6011 `right-fringe' is handled as if the frame contained just one live
6012 window. This means, for example, that removing vertical scroll bars on
6013 a frame containing several side by side windows will shrink the frame
6014 width by the width of one scroll bar provided this option is nil and
6015 keep it unchanged if this option is either t or a list containing
6016 `vertical-scroll-bars'.
6018 The default value is \\='(tool-bar-lines) on Lucid, Motif and Windows
6019 \(which means that adding/removing a tool bar does not change the frame
6020 height), nil on all other window systems including GTK+ (which means
6021 that changing any of the parameters listed above may change the size of
6022 the frame), and t otherwise (which means the frame size never changes
6023 implicitly when there's no window system support).
6025 Note that when a frame is not large enough to accommodate a change of
6026 any of the parameters listed above, Emacs may try to enlarge the frame
6027 even if this option is non-nil. */);
6028 #if defined (HAVE_WINDOW_SYSTEM)
6029 #if defined (USE_LUCID) || defined (USE_MOTIF) || defined (HAVE_NTGUI)
6030 frame_inhibit_implied_resize
= list1 (Qtool_bar_lines
);
6032 frame_inhibit_implied_resize
= Qnil
;
6035 frame_inhibit_implied_resize
= Qt
;
6038 DEFVAR_LISP ("frame-size-history", frame_size_history
,
6039 doc
: /* History of frame size adjustments.
6040 If non-nil, list recording frame size adjustment. Adjustments are
6041 recorded only if the first element of this list is a positive number.
6042 Adding an adjustment decrements that number by one.
6044 The remaining elements are the adjustments. Each adjustment is a list
6045 of four elements `frame', `function', `sizes' and `more'. `frame' is
6046 the affected frame and `function' the invoking function. `sizes' is
6047 usually a list of four elements `old-width', `old-height', `new-width'
6048 and `new-height' representing the old and new sizes recorded/requested
6049 by `function'. `more' is a list with additional information.
6051 The function `frame--size-history' displays the value of this variable
6052 in a more readable form. */);
6053 frame_size_history
= Qnil
;
6055 DEFVAR_BOOL ("tooltip-reuse-hidden-frame", tooltip_reuse_hidden_frame
,
6056 doc
: /* Non-nil means reuse hidden tooltip frames.
6057 When this is nil, delete a tooltip frame when hiding the associated
6058 tooltip. When this is non-nil, make the tooltip frame invisible only,
6059 so it can be reused when the next tooltip is shown.
6061 Setting this to non-nil may drastically reduce the consing overhead
6062 incurred by creating new tooltip frames. However, a value of non-nil
6063 means also that intermittent changes of faces or `default-frame-alist'
6064 are not applied when showing a tooltip in a reused frame.
6066 This variable is effective only with the X toolkit (and there only when
6067 Gtk+ tooltips are not used) and on Windows. */);
6068 tooltip_reuse_hidden_frame
= false;
6070 DEFVAR_LISP ("iconify-child-frame", iconify_child_frame
,
6071 doc
: /* How to handle iconification of child frames.
6072 This variable tells Emacs how to proceed when it is asked to iconify a
6073 child frame. If it is nil, `iconify-frame' will do nothing when invoked
6074 on a child frame. If it is `iconify-top-level', Emacs will try to
6075 iconify the top level frame associated with this child frame instead.
6076 If it is `make-invisible', Emacs will try to make this child frame
6079 Any other value means to try iconifying the child frame. Since such an
6080 attempt is not honored by all window managers and may even lead to
6081 making the child frame unresponsive to user actions, the default is to
6082 iconify the top level frame instead. */);
6083 iconify_child_frame
= Qiconify_top_level
;
6085 staticpro (&Vframe_list
);
6088 defsubr (&Sframe_live_p
);
6089 defsubr (&Swindow_system
);
6090 defsubr (&Sframe_windows_min_size
);
6091 defsubr (&Smake_terminal_frame
);
6092 defsubr (&Shandle_switch_frame
);
6093 defsubr (&Sselect_frame
);
6094 defsubr (&Sselected_frame
);
6095 defsubr (&Sframe_list
);
6096 defsubr (&Sframe_parent
);
6097 defsubr (&Sframe_ancestor_p
);
6098 defsubr (&Snext_frame
);
6099 defsubr (&Sprevious_frame
);
6100 defsubr (&Slast_nonminibuf_frame
);
6101 defsubr (&Sdelete_frame
);
6102 defsubr (&Smouse_position
);
6103 defsubr (&Smouse_pixel_position
);
6104 defsubr (&Sset_mouse_position
);
6105 defsubr (&Sset_mouse_pixel_position
);
6107 defsubr (&Sframe_configuration
);
6108 defsubr (&Srestore_frame_configuration
);
6110 defsubr (&Smake_frame_visible
);
6111 defsubr (&Smake_frame_invisible
);
6112 defsubr (&Siconify_frame
);
6113 defsubr (&Sframe_visible_p
);
6114 defsubr (&Svisible_frame_list
);
6115 defsubr (&Sraise_frame
);
6116 defsubr (&Slower_frame
);
6117 defsubr (&Sx_focus_frame
);
6118 defsubr (&Sframe_after_make_frame
);
6119 defsubr (&Sredirect_frame_focus
);
6120 defsubr (&Sframe_focus
);
6121 defsubr (&Sframe_parameters
);
6122 defsubr (&Sframe_parameter
);
6123 defsubr (&Smodify_frame_parameters
);
6124 defsubr (&Sframe_char_height
);
6125 defsubr (&Sframe_char_width
);
6126 defsubr (&Sframe_native_height
);
6127 defsubr (&Sframe_native_width
);
6128 defsubr (&Sframe_text_cols
);
6129 defsubr (&Sframe_text_lines
);
6130 defsubr (&Sframe_total_cols
);
6131 defsubr (&Sframe_total_lines
);
6132 defsubr (&Sframe_text_width
);
6133 defsubr (&Sframe_text_height
);
6134 defsubr (&Sscroll_bar_width
);
6135 defsubr (&Sscroll_bar_height
);
6136 defsubr (&Sfringe_width
);
6137 defsubr (&Sframe_internal_border_width
);
6138 defsubr (&Sright_divider_width
);
6139 defsubr (&Sbottom_divider_width
);
6140 defsubr (&Stool_bar_pixel_width
);
6141 defsubr (&Sset_frame_height
);
6142 defsubr (&Sset_frame_width
);
6143 defsubr (&Sset_frame_size
);
6144 defsubr (&Sframe_position
);
6145 defsubr (&Sset_frame_position
);
6146 defsubr (&Sframe_pointer_visible_p
);
6148 #ifdef HAVE_WINDOW_SYSTEM
6149 defsubr (&Sx_get_resource
);
6150 defsubr (&Sx_parse_geometry
);