1 /* Generic frame functions.
3 Copyright (C) 1993-1995, 1997, 1999-2015 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29 #include "character.h"
31 #ifdef HAVE_WINDOW_SYSTEM
33 #endif /* HAVE_WINDOW_SYSTEM */
36 /* These help us bind and responding to switch-frame events. */
40 #include "blockinput.h"
42 #include "termhooks.h"
43 #include "dispextern.h"
46 #ifdef HAVE_WINDOW_SYSTEM
59 Lisp_Object Qns_parse_geometry
;
62 Lisp_Object Qframep
, Qframe_live_p
;
63 Lisp_Object Qicon
, Qmodeline
;
64 Lisp_Object Qonly
, Qnone
;
65 Lisp_Object Qx
, Qw32
, Qpc
, Qns
;
67 Lisp_Object Qdisplay_type
;
68 static Lisp_Object Qbackground_mode
;
71 static Lisp_Object Qx_frame_parameter
;
72 Lisp_Object Qx_resource_name
;
73 Lisp_Object Qterminal
;
75 /* Frame parameters (set or reported). */
77 Lisp_Object Qauto_raise
, Qauto_lower
;
78 Lisp_Object Qborder_color
, Qborder_width
;
79 Lisp_Object Qcursor_color
, Qcursor_type
;
80 Lisp_Object Qheight
, Qwidth
;
81 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
83 Lisp_Object Qinternal_border_width
;
84 Lisp_Object Qright_divider_width
, Qbottom_divider_width
;
85 Lisp_Object Qmouse_color
;
86 Lisp_Object Qminibuffer
;
87 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
88 Lisp_Object Qscroll_bar_height
, Qhorizontal_scroll_bars
;
89 Lisp_Object Qvisibility
;
90 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
91 Lisp_Object Qscreen_gamma
;
92 Lisp_Object Qline_spacing
;
93 static Lisp_Object Quser_position
, Quser_size
;
94 Lisp_Object Qwait_for_wm
;
95 static Lisp_Object Qwindow_id
;
97 static Lisp_Object Qouter_window_id
;
99 Lisp_Object Qparent_id
;
100 Lisp_Object Qtitle
, Qname
;
101 static Lisp_Object Qexplicit_name
;
102 Lisp_Object Qunsplittable
;
103 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
, Qtool_bar_position
;
104 Lisp_Object Qleft_fringe
, Qright_fringe
;
105 Lisp_Object Qbuffer_predicate
;
106 static Lisp_Object Qbuffer_list
, Qburied_buffer_list
;
107 Lisp_Object Qtty_color_mode
;
108 Lisp_Object Qtty
, Qtty_type
;
110 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
112 Lisp_Object Qfont_backend
;
115 Lisp_Object Qface_set_after_frame_default
;
117 static Lisp_Object Qfocus_in_hook
;
118 static Lisp_Object Qfocus_out_hook
;
119 static Lisp_Object Qdelete_frame_functions
;
120 static Lisp_Object Qframe_windows_min_size
;
121 static Lisp_Object Qgeometry
, Qworkarea
, Qmm_size
, Qframes
, Qsource
;
123 Lisp_Object Qframe_position
, Qframe_outer_size
, Qframe_inner_size
;
124 Lisp_Object Qexternal_border_size
, Qtitle_height
;
125 Lisp_Object Qmenu_bar_external
, Qmenu_bar_size
;
126 Lisp_Object Qtool_bar_external
, Qtool_bar_size
;
128 /* The currently selected frame. */
130 Lisp_Object selected_frame
;
132 /* A frame which is not just a mini-buffer, or NULL if there are no such
133 frames. This is usually the most recent such frame that was selected. */
135 static struct frame
*last_nonminibuf_frame
;
137 /* False means there are no visible garbaged frames. */
140 #ifdef HAVE_WINDOW_SYSTEM
141 static void x_report_frame_params (struct frame
*, Lisp_Object
*);
144 /* These setters are used only in this file, so they can be private. */
146 fset_buffer_predicate (struct frame
*f
, Lisp_Object val
)
148 f
->buffer_predicate
= val
;
151 fset_minibuffer_window (struct frame
*f
, Lisp_Object val
)
153 f
->minibuffer_window
= val
;
157 decode_live_frame (register Lisp_Object frame
)
160 frame
= selected_frame
;
161 CHECK_LIVE_FRAME (frame
);
162 return XFRAME (frame
);
166 decode_any_frame (register Lisp_Object frame
)
169 frame
= selected_frame
;
171 return XFRAME (frame
);
174 #ifdef HAVE_WINDOW_SYSTEM
177 window_system_available (struct frame
*f
)
179 return f
? FRAME_WINDOW_P (f
) || FRAME_MSDOS_P (f
) : x_display_list
!= NULL
;
182 #endif /* HAVE_WINDOW_SYSTEM */
185 decode_window_system_frame (Lisp_Object frame
)
187 struct frame
*f
= decode_live_frame (frame
);
189 if (!window_system_available (f
))
190 error ("Window system frame should be used");
195 check_window_system (struct frame
*f
)
197 if (!window_system_available (f
))
198 error (f
? "Window system frame should be used"
199 : "Window system is not in use or not initialized");
202 /* Return the value of frame parameter PROP in frame FRAME. */
205 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
207 register Lisp_Object tem
;
209 tem
= Fassq (prop
, frame
->param_alist
);
215 /* Return 1 if `frame-inhibit-implied-resize' is non-nil or fullscreen
216 state of frame F would be affected by a vertical (horizontal if
217 HORIZONTAL is true) resize. PARAMETER is the symbol of the frame
218 parameter that is changed. */
220 frame_inhibit_resize (struct frame
*f
, bool horizontal
, Lisp_Object parameter
)
222 return (EQ (frame_inhibit_implied_resize
, Qt
)
223 || (CONSP (frame_inhibit_implied_resize
)
224 && !NILP (Fmemq (parameter
, frame_inhibit_implied_resize
)))
225 || !NILP (get_frame_param (f
, Qfullscreen
))
226 || FRAME_TERMCAP_P (f
) || FRAME_MSDOS_P (f
));
230 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
233 int olines
= FRAME_MENU_BAR_LINES (f
);
235 /* Right now, menu bars don't work properly in minibuf-only frames;
236 most of the commands try to apply themselves to the minibuffer
237 frame itself, and get an error because you can't switch buffers
238 in or split the minibuffer window. */
239 if (FRAME_MINIBUF_ONLY_P (f
))
242 if (TYPE_RANGED_INTEGERP (int, value
))
243 nlines
= XINT (value
);
247 if (nlines
!= olines
)
249 windows_or_buffers_changed
= 14;
250 FRAME_MENU_BAR_LINES (f
) = nlines
;
251 FRAME_MENU_BAR_HEIGHT (f
) = nlines
* FRAME_LINE_HEIGHT (f
);
252 change_frame_size (f
, FRAME_COLS (f
),
253 FRAME_LINES (f
) + olines
- nlines
,
258 Lisp_Object Vframe_list
;
261 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
262 doc
: /* Return non-nil if OBJECT is a frame.
264 t for a termcap frame (a character-only terminal),
265 'x' for an Emacs frame that is really an X window,
266 'w32' for an Emacs frame that is a window on MS-Windows display,
267 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
268 'pc' for a direct-write MS-DOS frame.
269 See also `frame-live-p'. */)
272 if (!FRAMEP (object
))
274 switch (XFRAME (object
)->output_method
)
276 case output_initial
: /* The initial frame is like a termcap frame. */
279 case output_x_window
:
283 case output_msdos_raw
:
292 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
293 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
294 Value is nil if OBJECT is not a live frame. If object is a live
295 frame, the return value indicates what sort of terminal device it is
296 displayed on. See the documentation of `framep' for possible
300 return ((FRAMEP (object
)
301 && FRAME_LIVE_P (XFRAME (object
)))
306 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
307 doc
: /* The name of the window system that FRAME is displaying through.
308 The value is a symbol:
309 nil for a termcap frame (a character-only terminal),
310 'x' for an Emacs frame that is really an X window,
311 'w32' for an Emacs frame that is a window on MS-Windows display,
312 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
313 'pc' for a direct-write MS-DOS frame.
315 FRAME defaults to the currently selected frame.
317 Use of this function as a predicate is deprecated. Instead,
318 use `display-graphic-p' or any of the other `display-*-p'
319 predicates which report frame's specific UI-related capabilities. */)
324 frame
= selected_frame
;
326 type
= Fframep (frame
);
329 wrong_type_argument (Qframep
, frame
);
337 /* Placeholder used by temacs -nw before window.el is loaded. */
338 DEFUN ("frame-windows-min-size", Fframe_windows_min_size
,
339 Sframe_windows_min_size
, 4, 4, 0,
341 (Lisp_Object frame
, Lisp_Object horizontal
,
342 Lisp_Object ignore
, Lisp_Object pixelwise
)
344 return make_number (0);
348 frame_windows_min_size (Lisp_Object frame
, Lisp_Object horizontal
,
349 Lisp_Object ignore
, Lisp_Object pixelwise
)
351 return XINT (call4 (Qframe_windows_min_size
, frame
, horizontal
,
356 /* Make sure windows sizes of frame F are OK. new_width and new_height
357 are in pixels. A value of -1 means no change is requested for that
358 size (but the frame may still have to be resized to accommodate
359 windows with their minimum sizes). This can either issue a request
360 to resize the frame externally (via x_set_window_size), to resize the
361 frame internally (via resize_frame_windows) or do nothing at all.
363 The argument INHIBIT can assume the following values:
365 0 means to unconditionally call x_set_window_size even if sizes
366 apparently do not change. Fx_create_frame uses this to pass the
367 initial size to the window manager.
369 1 means to call x_set_window_size if the outer frame size really
370 changes. Fset_frame_size, Fset_frame_height, ... use this.
372 2 means to call x_set_window_size provided frame_inhibit_resize
373 allows it. The menu and tool bar code use this ("3" won't work
374 here in general because menu and tool bar are often not counted in
375 the frame's text height).
377 3 means call x_set_window_size if window minimum sizes must be
378 preserved or frame_inhibit_resize allows it. x_set_left_fringe,
379 x_set_scroll_bar_width, x_new_font ... use (or should use) this.
381 4 means call x_set_window_size only if window minimum sizes must be
382 preserved. x_set_right_divider_width, x_set_border_width and the
383 code responsible for wrapping the tool bar use this.
385 5 means to never call x_set_window_size. change_frame_size uses
388 Note that even when x_set_window_size is not called, individual
389 windows may have to be resized (via `window--sanitize-window-sizes')
390 in order to support minimum size constraints.
392 PRETEND is as for change_frame_size. PARAMETER, if non-nil, is the
393 symbol of the parameter changed (like `menu-bar-lines', `font', ...).
394 This is passed on to frame_inhibit_resize to let the latter decide on
395 a case-by-case basis whether the frame may be resized externally. */
397 adjust_frame_size (struct frame
*f
, int new_width
, int new_height
, int inhibit
,
398 bool pretend
, Lisp_Object parameter
)
400 int unit_width
= FRAME_COLUMN_WIDTH (f
);
401 int unit_height
= FRAME_LINE_HEIGHT (f
);
402 int old_pixel_width
= FRAME_PIXEL_WIDTH (f
);
403 int old_pixel_height
= FRAME_PIXEL_HEIGHT (f
);
404 int new_pixel_width
, new_pixel_height
;
405 /* The following two values are calculated from the old frame pixel
406 sizes and any "new" settings for tool bar, menu bar and internal
407 borders. We do it this way to detect whether we have to call
408 x_set_window_size as consequence of the new settings. */
409 int windows_width
= FRAME_WINDOWS_WIDTH (f
);
410 int windows_height
= FRAME_WINDOWS_HEIGHT (f
);
411 int min_windows_width
, min_windows_height
;
412 /* These are a bit tedious, maybe we should use a macro. */
413 struct window
*r
= XWINDOW (FRAME_ROOT_WINDOW (f
));
414 int old_windows_width
= WINDOW_PIXEL_WIDTH (r
);
415 int old_windows_height
416 = (WINDOW_PIXEL_HEIGHT (r
)
417 + (FRAME_HAS_MINIBUF_P (f
)
418 ? WINDOW_PIXEL_HEIGHT (XWINDOW (FRAME_MINIBUF_WINDOW (f
)))
420 int new_windows_width
, new_windows_height
;
421 int old_text_width
= FRAME_TEXT_WIDTH (f
);
422 int old_text_height
= FRAME_TEXT_HEIGHT (f
);
423 /* If a size is < 0 use the old value. */
424 int new_text_width
= (new_width
>= 0) ? new_width
: old_text_width
;
425 int new_text_height
= (new_height
>= 0) ? new_height
: old_text_height
;
426 int new_cols
, new_lines
;
427 bool inhibit_horizontal
, inhibit_vertical
;
430 XSETFRAME (frame
, f
);
431 /* The following two values are calculated from the old window body
432 sizes and any "new" settings for scroll bars, dividers, fringes and
433 margins (though the latter should have been processed already). */
435 = frame_windows_min_size (frame
, Qt
, (inhibit
== 5) ? Qt
: Qnil
, Qt
);
437 = frame_windows_min_size (frame
, Qnil
, (inhibit
== 5) ? Qt
: Qnil
, Qt
);
439 if (inhibit
>= 2 && inhibit
<= 4)
440 /* If INHIBIT is in [2..4] inhibit if the "old" window sizes stay
441 within the limits and either frame_inhibit_resize tells us to do
442 so or INHIBIT equals 4. */
444 inhibit_horizontal
= ((windows_width
>= min_windows_width
446 || frame_inhibit_resize (f
, true, parameter
)))
448 inhibit_vertical
= ((windows_height
>= min_windows_height
450 || frame_inhibit_resize (f
, false, parameter
)))
454 /* Otherwise inhibit if INHIBIT equals 5. */
455 inhibit_horizontal
= inhibit_vertical
= inhibit
== 5;
457 new_pixel_width
= ((inhibit_horizontal
&& (inhibit
< 5))
459 : max (FRAME_TEXT_TO_PIXEL_WIDTH (f
, new_text_width
),
461 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
462 new_windows_width
= new_pixel_width
- 2 * FRAME_INTERNAL_BORDER_WIDTH (f
);
463 new_text_width
= FRAME_PIXEL_TO_TEXT_WIDTH (f
, new_pixel_width
);
464 new_cols
= new_text_width
/ unit_width
;
466 new_pixel_height
= ((inhibit_vertical
&& (inhibit
< 5))
468 : max (FRAME_TEXT_TO_PIXEL_HEIGHT (f
, new_text_height
),
470 + FRAME_TOP_MARGIN_HEIGHT (f
)
471 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
472 new_windows_height
= (new_pixel_height
473 - FRAME_TOP_MARGIN_HEIGHT (f
)
474 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f
));
475 new_text_height
= FRAME_PIXEL_TO_TEXT_HEIGHT (f
, new_pixel_height
);
476 new_lines
= new_text_height
/ unit_height
;
478 #ifdef HAVE_WINDOW_SYSTEM
479 if (FRAME_WINDOW_P (f
)
480 && f
->can_x_set_window_size
481 && ((!inhibit_horizontal
482 && (new_pixel_width
!= old_pixel_width
483 || inhibit
== 0 || inhibit
== 2))
484 || (!inhibit_vertical
485 && (new_pixel_height
!= old_pixel_height
486 || inhibit
== 0 || inhibit
== 2))))
487 /* We are either allowed to change the frame size or the minimum
488 sizes request such a change. Do not care for fixing minimum
489 sizes here, we do that eventually when we're called from
490 change_frame_size. */
492 /* Make sure we respect fullheight and fullwidth. */
493 if (inhibit_horizontal
)
494 new_text_width
= old_text_width
;
495 else if (inhibit_vertical
)
496 new_text_height
= old_text_height
;
498 x_set_window_size (f
, 0, new_text_width
, new_text_height
, 1);
505 if (new_text_width
== old_text_width
506 && new_text_height
== old_text_height
507 && new_windows_width
== old_windows_width
508 && new_windows_height
== old_windows_height
509 && new_pixel_width
== old_pixel_width
510 && new_pixel_height
== old_pixel_height
)
511 /* No change. Sanitize window sizes and return. */
513 sanitize_window_sizes (frame
, Qt
);
514 sanitize_window_sizes (frame
, Qnil
);
522 /* We only can set screen dimensions to certain values supported
523 by our video hardware. Try to find the smallest size greater
524 or equal to the requested dimensions. */
525 dos_set_window_size (&new_lines
, &new_cols
);
528 if (new_windows_width
!= old_windows_width
)
530 resize_frame_windows (f
, new_windows_width
, 1, 1);
532 /* MSDOS frames cannot PRETEND, as they change frame size by
533 manipulating video hardware. */
534 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
535 FrameCols (FRAME_TTY (f
)) = new_cols
;
537 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
538 if (WINDOWP (f
->tool_bar_window
))
540 XWINDOW (f
->tool_bar_window
)->pixel_width
= new_windows_width
;
541 XWINDOW (f
->tool_bar_window
)->total_cols
542 = new_windows_width
/ unit_width
;
547 if (new_windows_height
!= old_windows_height
548 /* When the top margin has changed we have to recalculate the top
549 edges of all windows. No such calculation is necessary for the
551 || WINDOW_TOP_PIXEL_EDGE (r
) != FRAME_TOP_MARGIN_HEIGHT (f
))
553 resize_frame_windows (f
, new_windows_height
, 0, 1);
555 /* MSDOS frames cannot PRETEND, as they change frame size by
556 manipulating video hardware. */
557 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
558 FrameRows (FRAME_TTY (f
)) = new_lines
+ FRAME_TOP_MARGIN (f
);
561 /* Assign new sizes. */
562 FRAME_TEXT_WIDTH (f
) = new_text_width
;
563 FRAME_TEXT_HEIGHT (f
) = new_text_height
;
564 FRAME_PIXEL_WIDTH (f
) = new_pixel_width
;
565 FRAME_PIXEL_HEIGHT (f
) = new_pixel_height
;
566 SET_FRAME_COLS (f
, new_cols
);
567 SET_FRAME_LINES (f
, new_lines
);
570 struct window
*w
= XWINDOW (FRAME_SELECTED_WINDOW (f
));
571 int text_area_x
, text_area_y
, text_area_width
, text_area_height
;
573 window_box (w
, TEXT_AREA
, &text_area_x
, &text_area_y
, &text_area_width
,
575 if (w
->cursor
.x
>= text_area_x
+ text_area_width
)
576 w
->cursor
.hpos
= w
->cursor
.x
= 0;
577 if (w
->cursor
.y
>= text_area_y
+ text_area_height
)
578 w
->cursor
.vpos
= w
->cursor
.y
= 0;
581 /* Sanitize window sizes. */
582 sanitize_window_sizes (frame
, Qt
);
583 sanitize_window_sizes (frame
, Qnil
);
585 adjust_frame_glyphs (f
);
587 SET_FRAME_GARBAGED (f
);
589 /* A frame was "resized" if one of its pixelsizes changed, even if its
590 X window wasn't resized at all. */
591 f
->resized_p
= (new_pixel_width
!= old_pixel_width
592 || new_pixel_height
!= old_pixel_height
);
596 run_window_configuration_change_hook (f
);
601 make_frame (bool mini_p
)
604 register struct frame
*f
;
605 register struct window
*rw
, *mw
;
606 register Lisp_Object root_window
;
607 register Lisp_Object mini_window
;
609 f
= allocate_frame ();
610 XSETFRAME (frame
, f
);
613 /* Initialize Lisp data. Note that allocate_frame initializes all
614 Lisp data to nil, so do it only for slots which should not be nil. */
615 fset_tool_bar_position (f
, Qtop
);
618 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
619 non-Lisp data, so do it only for slots which should not be zero.
620 To avoid subtle bugs and for the sake of readability, it's better to
621 initialize enum members explicitly even if their values are zero. */
622 f
->wants_modeline
= true;
625 f
->can_x_set_window_size
= false;
626 f
->can_run_window_configuration_change_hook
= false;
627 f
->column_width
= 1; /* !FRAME_WINDOW_P value. */
628 f
->line_height
= 1; /* !FRAME_WINDOW_P value. */
629 #ifdef HAVE_WINDOW_SYSTEM
630 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
631 f
->horizontal_scroll_bars
= false;
632 f
->want_fullscreen
= FULLSCREEN_NONE
;
633 #if ! defined (USE_GTK) && ! defined (HAVE_NS)
634 f
->last_tool_bar_item
= -1;
638 root_window
= make_window ();
639 rw
= XWINDOW (root_window
);
642 mini_window
= make_window ();
643 mw
= XWINDOW (mini_window
);
644 wset_next (rw
, mini_window
);
645 wset_prev (mw
, root_window
);
647 wset_frame (mw
, frame
);
648 fset_minibuffer_window (f
, mini_window
);
653 wset_next (rw
, Qnil
);
654 fset_minibuffer_window (f
, Qnil
);
657 wset_frame (rw
, frame
);
660 just so that there is "something there."
661 Correct size will be set up later with adjust_frame_size. */
663 SET_FRAME_COLS (f
, 10);
664 SET_FRAME_LINES (f
, 10);
665 SET_FRAME_WIDTH (f
, FRAME_COLS (f
) * FRAME_COLUMN_WIDTH (f
));
666 SET_FRAME_HEIGHT (f
, FRAME_LINES (f
) * FRAME_LINE_HEIGHT (f
));
669 rw
->pixel_width
= rw
->total_cols
* FRAME_COLUMN_WIDTH (f
);
670 rw
->total_lines
= mini_p
? 9 : 10;
671 rw
->pixel_height
= rw
->total_lines
* FRAME_LINE_HEIGHT (f
);
675 mw
->top_line
= rw
->total_lines
;
676 mw
->pixel_top
= rw
->pixel_height
;
677 mw
->total_cols
= rw
->total_cols
;
678 mw
->pixel_width
= rw
->pixel_width
;
680 mw
->pixel_height
= FRAME_LINE_HEIGHT (f
);
683 /* Choose a buffer for the frame's root window. */
685 Lisp_Object buf
= Fcurrent_buffer ();
687 /* If current buffer is hidden, try to find another one. */
688 if (BUFFER_HIDDEN_P (XBUFFER (buf
)))
689 buf
= other_buffer_safely (buf
);
691 /* Use set_window_buffer, not Fset_window_buffer, and don't let
692 hooks be run by it. The reason is that the whole frame/window
693 arrangement is not yet fully initialized at this point. Windows
694 don't have the right size, glyph matrices aren't initialized
695 etc. Running Lisp functions at this point surely ends in a
697 set_window_buffer (root_window
, buf
, 0, 0);
698 fset_buffer_list (f
, list1 (buf
));
703 set_window_buffer (mini_window
,
704 (NILP (Vminibuffer_list
)
706 : Fcar (Vminibuffer_list
)),
708 /* No horizontal scroll bars in minibuffers. */
709 wset_horizontal_scroll_bar (mw
, Qnil
);
712 fset_root_window (f
, root_window
);
713 fset_selected_window (f
, root_window
);
714 /* Make sure this window seems more recently used than
715 a newly-created, never-selected window. */
716 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
721 #ifdef HAVE_WINDOW_SYSTEM
722 /* Make a frame using a separate minibuffer window on another frame.
723 MINI_WINDOW is the minibuffer window to use. nil means use the
724 default (the global minibuffer). */
727 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
729 register struct frame
*f
;
732 if (!NILP (mini_window
))
733 CHECK_LIVE_WINDOW (mini_window
);
735 if (!NILP (mini_window
)
736 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
737 error ("Frame and minibuffer must be on the same terminal");
739 /* Make a frame containing just a root window. */
742 if (NILP (mini_window
))
744 /* Use default-minibuffer-frame if possible. */
745 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
746 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
748 Lisp_Object frame_dummy
;
750 XSETFRAME (frame_dummy
, f
);
751 GCPRO1 (frame_dummy
);
752 /* If there's no minibuffer frame to use, create one. */
753 kset_default_minibuffer_frame
754 (kb
, call1 (intern ("make-initial-minibuffer-frame"), display
));
759 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
762 fset_minibuffer_window (f
, mini_window
);
764 /* Make the chosen minibuffer window display the proper minibuffer,
765 unless it is already showing a minibuffer. */
766 if (NILP (Fmemq (XWINDOW (mini_window
)->contents
, Vminibuffer_list
)))
767 /* Use set_window_buffer instead of Fset_window_buffer (see
768 discussion of bug#11984, bug#12025, bug#12026). */
769 set_window_buffer (mini_window
,
770 (NILP (Vminibuffer_list
)
772 : Fcar (Vminibuffer_list
)), 0, 0);
776 /* Make a frame containing only a minibuffer window. */
779 make_minibuffer_frame (void)
781 /* First make a frame containing just a root window, no minibuffer. */
783 register struct frame
*f
= make_frame (0);
784 register Lisp_Object mini_window
;
785 register Lisp_Object frame
;
787 XSETFRAME (frame
, f
);
792 f
->wants_modeline
= 0;
794 /* Now label the root window as also being the minibuffer.
795 Avoid infinite looping on the window chain by marking next pointer
798 mini_window
= f
->root_window
;
799 fset_minibuffer_window (f
, mini_window
);
800 XWINDOW (mini_window
)->mini
= 1;
801 wset_next (XWINDOW (mini_window
), Qnil
);
802 wset_prev (XWINDOW (mini_window
), Qnil
);
803 wset_frame (XWINDOW (mini_window
), frame
);
805 /* Put the proper buffer in that window. */
807 /* Use set_window_buffer instead of Fset_window_buffer (see
808 discussion of bug#11984, bug#12025, bug#12026). */
809 set_window_buffer (mini_window
,
810 (NILP (Vminibuffer_list
)
812 : Fcar (Vminibuffer_list
)), 0, 0);
815 #endif /* HAVE_WINDOW_SYSTEM */
817 /* Construct a frame that refers to a terminal. */
819 static printmax_t tty_frame_count
;
822 make_initial_frame (void)
825 struct terminal
*terminal
;
828 eassert (initial_kboard
);
830 /* The first call must initialize Vframe_list. */
831 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
834 terminal
= init_initial_terminal ();
837 XSETFRAME (frame
, f
);
839 Vframe_list
= Fcons (frame
, Vframe_list
);
842 fset_name (f
, build_pure_c_string ("F1"));
844 SET_FRAME_VISIBLE (f
, 1);
846 f
->output_method
= terminal
->type
;
847 f
->terminal
= terminal
;
848 f
->terminal
->reference_count
++;
849 f
->output_data
.nothing
= 0;
851 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
852 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
854 #ifdef HAVE_WINDOW_SYSTEM
855 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
856 f
->horizontal_scroll_bars
= false;
859 /* The default value of menu-bar-mode is t. */
860 set_menu_bar_lines (f
, make_number (1), Qnil
);
863 init_frame_faces (f
);
865 last_nonminibuf_frame
= f
;
871 static struct frame
*
872 make_terminal_frame (struct terminal
*terminal
)
874 register struct frame
*f
;
876 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
879 error ("Terminal is not live, can't create new frames on it");
883 XSETFRAME (frame
, f
);
884 Vframe_list
= Fcons (frame
, Vframe_list
);
886 fset_name (f
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
888 SET_FRAME_VISIBLE (f
, 1);
890 f
->terminal
= terminal
;
891 f
->terminal
->reference_count
++;
893 f
->output_data
.tty
->display_info
= &the_only_display_info
;
894 if (!inhibit_window_system
895 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
896 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
897 f
->output_method
= output_msdos_raw
;
899 f
->output_method
= output_termcap
;
900 #else /* not MSDOS */
901 f
->output_method
= output_termcap
;
902 create_tty_output (f
);
903 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
904 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
905 #endif /* not MSDOS */
907 #ifdef HAVE_WINDOW_SYSTEM
908 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
909 f
->horizontal_scroll_bars
= false;
912 FRAME_MENU_BAR_LINES (f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
913 FRAME_LINES (f
) = FRAME_LINES (f
) - FRAME_MENU_BAR_LINES (f
);
914 FRAME_MENU_BAR_HEIGHT (f
) = FRAME_MENU_BAR_LINES (f
) * FRAME_LINE_HEIGHT (f
);
915 FRAME_TEXT_HEIGHT (f
) = FRAME_TEXT_HEIGHT (f
) - FRAME_MENU_BAR_HEIGHT (f
);
917 /* Set the top frame to the newly created frame. */
918 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
919 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
920 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f
)->top_frame
), 2); /* obscured */
922 FRAME_TTY (f
)->top_frame
= frame
;
925 init_frame_faces (f
);
930 /* Get a suitable value for frame parameter PARAMETER for a newly
931 created frame, based on (1) the user-supplied frame parameter
932 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
935 get_future_frame_param (Lisp_Object parameter
,
936 Lisp_Object supplied_parms
,
941 result
= Fassq (parameter
, supplied_parms
);
943 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
944 if (NILP (result
) && current_value
!= NULL
)
945 result
= build_string (current_value
);
946 if (!NILP (result
) && !STRINGP (result
))
947 result
= XCDR (result
);
948 if (NILP (result
) || !STRINGP (result
))
954 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
956 doc
: /* Create an additional terminal frame, possibly on another terminal.
957 This function takes one argument, an alist specifying frame parameters.
959 You can create multiple frames on a single text terminal, but only one
960 of them (the selected terminal frame) is actually displayed.
962 In practice, generally you don't need to specify any parameters,
963 except when you want to create a new frame on another terminal.
964 In that case, the `tty' parameter specifies the device file to open,
965 and the `tty-type' parameter specifies the terminal type. Example:
967 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
969 Note that changing the size of one terminal frame automatically
970 affects all frames on the same terminal device. */)
974 struct terminal
*t
= NULL
;
975 Lisp_Object frame
, tem
;
976 struct frame
*sf
= SELECTED_FRAME ();
979 if (sf
->output_method
!= output_msdos_raw
980 && sf
->output_method
!= output_termcap
)
982 #else /* not MSDOS */
984 #ifdef WINDOWSNT /* This should work now! */
985 if (sf
->output_method
!= output_termcap
)
986 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
988 #endif /* not MSDOS */
991 Lisp_Object terminal
;
993 terminal
= Fassq (Qterminal
, parms
);
994 if (CONSP (terminal
))
996 terminal
= XCDR (terminal
);
997 t
= decode_live_terminal (terminal
);
1000 if (t
&& t
!= the_only_display_info
.terminal
)
1001 /* msdos.c assumes a single tty_display_info object. */
1002 error ("Multiple terminals are not supported on this platform");
1004 t
= the_only_display_info
.terminal
;
1010 char *name
= 0, *type
= 0;
1011 Lisp_Object tty
, tty_type
;
1014 tty
= get_future_frame_param
1015 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1016 ? FRAME_TTY (XFRAME (selected_frame
))->name
1019 SAFE_ALLOCA_STRING (name
, tty
);
1021 tty_type
= get_future_frame_param
1022 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1023 ? FRAME_TTY (XFRAME (selected_frame
))->type
1025 if (!NILP (tty_type
))
1026 SAFE_ALLOCA_STRING (type
, tty_type
);
1028 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
1032 f
= make_terminal_frame (t
);
1036 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
1037 adjust_frame_size (f
, width
, height
- FRAME_MENU_BAR_LINES (f
), 5, 0, Qnil
);
1040 adjust_frame_glyphs (f
);
1041 calculate_costs (f
);
1042 XSETFRAME (frame
, f
);
1044 store_in_alist (&parms
, Qtty_type
, build_string (t
->display_info
.tty
->type
));
1045 store_in_alist (&parms
, Qtty
,
1046 (t
->display_info
.tty
->name
1047 ? build_string (t
->display_info
.tty
->name
)
1049 Fmodify_frame_parameters (frame
, parms
);
1051 /* Make the frame face alist be frame-specific, so that each
1052 frame could change its face definitions independently. */
1053 fset_face_alist (f
, Fcopy_alist (sf
->face_alist
));
1054 /* Simple Fcopy_alist isn't enough, because we need the contents of
1055 the vectors which are the CDRs of associations in face_alist to
1056 be copied as well. */
1057 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
1058 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
1063 /* Perform the switch to frame FRAME.
1065 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
1068 If TRACK is non-zero and the frame that currently has the focus
1069 redirects its focus to the selected frame, redirect that focused
1070 frame's focus to FRAME instead.
1072 FOR_DELETION non-zero means that the selected frame is being
1073 deleted, which includes the possibility that the frame's terminal
1076 The value of NORECORD is passed as argument to Fselect_window. */
1079 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
1081 struct frame
*sf
= SELECTED_FRAME ();
1083 /* If FRAME is a switch-frame event, extract the frame we should
1086 && EQ (XCAR (frame
), Qswitch_frame
)
1087 && CONSP (XCDR (frame
)))
1088 frame
= XCAR (XCDR (frame
));
1090 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
1091 a switch-frame event to arrive after a frame is no longer live,
1092 especially when deleting the initial frame during startup. */
1093 CHECK_FRAME (frame
);
1094 if (! FRAME_LIVE_P (XFRAME (frame
)))
1097 if (sf
== XFRAME (frame
))
1100 /* If a frame's focus has been redirected toward the currently
1101 selected frame, we should change the redirection to point to the
1102 newly selected frame. This means that if the focus is redirected
1103 from a minibufferless frame to a surrogate minibuffer frame, we
1104 can use `other-window' to switch between all the frames using
1105 that minibuffer frame, and the focus redirection will follow us
1108 /* This is too greedy; it causes inappropriate focus redirection
1109 that's hard to get rid of. */
1114 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1118 if (!FRAMEP (XCAR (tail
)))
1121 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
1123 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1124 Fredirect_frame_focus (XCAR (tail
), frame
);
1128 /* Instead, apply it only to the frame we're pointing to. */
1129 #ifdef HAVE_WINDOW_SYSTEM
1130 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
1132 Lisp_Object focus
, xfocus
;
1134 xfocus
= x_get_focus_frame (XFRAME (frame
));
1135 if (FRAMEP (xfocus
))
1137 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
1138 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1139 Fredirect_frame_focus (xfocus
, frame
);
1142 #endif /* HAVE_X_WINDOWS */
1145 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
1146 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
1148 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
1150 struct frame
*f
= XFRAME (frame
);
1151 struct tty_display_info
*tty
= FRAME_TTY (f
);
1152 Lisp_Object top_frame
= tty
->top_frame
;
1154 /* Don't mark the frame garbaged and/or obscured if we are
1155 switching to the frame that is already the top frame of that
1157 if (!EQ (frame
, top_frame
))
1159 if (FRAMEP (top_frame
))
1160 /* Mark previously displayed frame as now obscured. */
1161 SET_FRAME_VISIBLE (XFRAME (top_frame
), 2);
1162 SET_FRAME_VISIBLE (f
, 1);
1163 /* If the new TTY frame changed dimensions, we need to
1164 resync term.c's idea of the frame size with the new
1166 if (FRAME_COLS (f
) != FrameCols (tty
))
1167 FrameCols (tty
) = FRAME_COLS (f
);
1168 if (FRAME_TOTAL_LINES (f
) != FrameRows (tty
))
1169 FrameRows (tty
) = FRAME_TOTAL_LINES (f
);
1171 tty
->top_frame
= frame
;
1174 selected_frame
= frame
;
1175 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
1176 last_nonminibuf_frame
= XFRAME (selected_frame
);
1178 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
1180 /* We want to make sure that the next event generates a frame-switch
1181 event to the appropriate frame. This seems kludgy to me, but
1182 before you take it out, make sure that evaluating something like
1183 (select-window (frame-root-window (new-frame))) doesn't end up
1184 with your typing being interpreted in the new frame instead of
1185 the one you're actually typing in. */
1186 internal_last_event_frame
= Qnil
;
1191 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
1192 doc
: /* Select FRAME.
1193 Subsequent editing commands apply to its selected window.
1194 Optional argument NORECORD means to neither change the order of
1195 recently selected windows nor the buffer list.
1197 The selection of FRAME lasts until the next time the user does
1198 something to select a different frame, or until the next time
1199 this function is called. If you are using a window system, the
1200 previously selected frame may be restored as the selected frame
1201 when returning to the command loop, because it still may have
1202 the window system's input focus. On a text terminal, the next
1203 redisplay will display FRAME.
1205 This function returns FRAME, or nil if FRAME has been deleted. */)
1206 (Lisp_Object frame
, Lisp_Object norecord
)
1208 return do_switch_frame (frame
, 1, 0, norecord
);
1211 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "^e",
1212 doc
: /* Handle a switch-frame event EVENT.
1213 Switch-frame events are usually bound to this function.
1214 A switch-frame event tells Emacs that the window manager has requested
1215 that the user's events be directed to the frame mentioned in the event.
1216 This function selects the selected window of the frame of EVENT.
1218 If EVENT is frame object, handle it as if it were a switch-frame event
1222 /* Preserve prefix arg that the command loop just cleared. */
1223 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
1224 Frun_hooks (1, &Qmouse_leave_buffer_hook
);
1225 /* `switch-frame' implies a focus in. */
1226 call1 (intern ("handle-focus-in"), event
);
1227 return do_switch_frame (event
, 0, 0, Qnil
);
1230 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1231 doc
: /* Return the frame that is now selected. */)
1234 return selected_frame
;
1237 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1239 doc
: /* Return a list of all live frames. */)
1243 frames
= Fcopy_sequence (Vframe_list
);
1244 #ifdef HAVE_WINDOW_SYSTEM
1245 if (FRAMEP (tip_frame
))
1246 frames
= Fdelq (tip_frame
, frames
);
1251 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
1252 same tty (for tty frames) or among frames which uses FRAME's keyboard.
1253 If MINIBUF is nil, do not consider minibuffer-only candidate.
1254 If MINIBUF is `visible', do not consider an invisible candidate.
1255 If MINIBUF is a window, consider only its own frame and candidate now
1256 using that window as the minibuffer.
1257 If MINIBUF is 0, consider candidate if it is visible or iconified.
1258 Otherwise consider any candidate and return nil if CANDIDATE is not
1262 candidate_frame (Lisp_Object candidate
, Lisp_Object frame
, Lisp_Object minibuf
)
1264 struct frame
*c
= XFRAME (candidate
), *f
= XFRAME (frame
);
1266 if ((!FRAME_TERMCAP_P (c
) && !FRAME_TERMCAP_P (f
)
1267 && FRAME_KBOARD (c
) == FRAME_KBOARD (f
))
1268 || (FRAME_TERMCAP_P (c
) && FRAME_TERMCAP_P (f
)
1269 && FRAME_TTY (c
) == FRAME_TTY (f
)))
1273 if (!FRAME_MINIBUF_ONLY_P (c
))
1276 else if (EQ (minibuf
, Qvisible
))
1278 if (FRAME_VISIBLE_P (c
))
1281 else if (WINDOWP (minibuf
))
1283 if (EQ (FRAME_MINIBUF_WINDOW (c
), minibuf
)
1284 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), candidate
)
1285 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1286 FRAME_FOCUS_FRAME (c
)))
1289 else if (XFASTINT (minibuf
) == 0)
1291 if (FRAME_VISIBLE_P (c
) || FRAME_ICONIFIED_P (c
))
1300 /* Return the next frame in the frame list after FRAME. */
1303 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1305 Lisp_Object f
, tail
;
1308 /* There must always be at least one frame in Vframe_list. */
1309 eassert (CONSP (Vframe_list
));
1312 FOR_EACH_FRAME (tail
, f
)
1316 f
= candidate_frame (f
, frame
, minibuf
);
1326 /* Return the previous frame in the frame list before FRAME. */
1329 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1331 Lisp_Object f
, tail
, prev
= Qnil
;
1333 /* There must always be at least one frame in Vframe_list. */
1334 eassert (CONSP (Vframe_list
));
1336 FOR_EACH_FRAME (tail
, f
)
1338 if (EQ (frame
, f
) && !NILP (prev
))
1340 f
= candidate_frame (f
, frame
, minibuf
);
1345 /* We've scanned the entire list. */
1347 /* We went through the whole frame list without finding a single
1348 acceptable frame. Return the original frame. */
1351 /* There were no acceptable frames in the list before FRAME; otherwise,
1352 we would have returned directly from the loop. Since PREV is the last
1353 acceptable frame in the list, return it. */
1358 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1359 doc
: /* Return the next frame in the frame list after FRAME.
1360 It considers only frames on the same terminal as FRAME.
1361 By default, skip minibuffer-only frames.
1362 If omitted, FRAME defaults to the selected frame.
1363 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1364 If MINIFRAME is a window, include only its own frame
1365 and any frame now using that window as the minibuffer.
1366 If MINIFRAME is `visible', include all visible frames.
1367 If MINIFRAME is 0, include all visible and iconified frames.
1368 Otherwise, include all frames. */)
1369 (Lisp_Object frame
, Lisp_Object miniframe
)
1372 frame
= selected_frame
;
1373 CHECK_LIVE_FRAME (frame
);
1374 return next_frame (frame
, miniframe
);
1377 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1378 doc
: /* Return the previous frame in the frame list before FRAME.
1379 It considers only frames on the same terminal as FRAME.
1380 By default, skip minibuffer-only frames.
1381 If omitted, FRAME defaults to the selected frame.
1382 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1383 If MINIFRAME is a window, include only its own frame
1384 and any frame now using that window as the minibuffer.
1385 If MINIFRAME is `visible', include all visible frames.
1386 If MINIFRAME is 0, include all visible and iconified frames.
1387 Otherwise, include all frames. */)
1388 (Lisp_Object frame
, Lisp_Object miniframe
)
1391 frame
= selected_frame
;
1392 CHECK_LIVE_FRAME (frame
);
1393 return prev_frame (frame
, miniframe
);
1396 DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame
,
1397 Slast_nonminibuf_frame
, 0, 0, 0,
1398 doc
: /* Return last non-minibuffer frame selected. */)
1401 Lisp_Object frame
= Qnil
;
1403 if (last_nonminibuf_frame
)
1404 XSETFRAME (frame
, last_nonminibuf_frame
);
1409 /* Return 1 if it is ok to delete frame F;
1410 0 if all frames aside from F are invisible.
1411 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1414 other_visible_frames (struct frame
*f
)
1416 Lisp_Object frames
, this;
1418 FOR_EACH_FRAME (frames
, this)
1420 if (f
== XFRAME (this))
1423 /* Verify that we can still talk to the frame's X window,
1424 and note any recent change in visibility. */
1425 #ifdef HAVE_X_WINDOWS
1426 if (FRAME_WINDOW_P (XFRAME (this)))
1427 x_sync (XFRAME (this));
1430 if (FRAME_VISIBLE_P (XFRAME (this))
1431 || FRAME_ICONIFIED_P (XFRAME (this))
1432 /* Allow deleting the terminal frame when at least one X
1434 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1440 /* Make sure that minibuf_window doesn't refer to FRAME's minibuffer
1441 window. Preferably use the selected frame's minibuffer window
1442 instead. If the selected frame doesn't have one, get some other
1443 frame's minibuffer window. SELECT non-zero means select the new
1444 minibuffer window. */
1446 check_minibuf_window (Lisp_Object frame
, int select
)
1448 struct frame
*f
= decode_live_frame (frame
);
1450 XSETFRAME (frame
, f
);
1452 if (WINDOWP (minibuf_window
) && EQ (f
->minibuffer_window
, minibuf_window
))
1454 Lisp_Object frames
, this, window
= make_number (0);
1456 if (!EQ (frame
, selected_frame
)
1457 && FRAME_HAS_MINIBUF_P (XFRAME (selected_frame
)))
1458 window
= FRAME_MINIBUF_WINDOW (XFRAME (selected_frame
));
1460 FOR_EACH_FRAME (frames
, this)
1462 if (!EQ (this, frame
) && FRAME_HAS_MINIBUF_P (XFRAME (this)))
1464 window
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1469 /* Don't abort if no window was found (Bug#15247). */
1470 if (WINDOWP (window
))
1472 /* Use set_window_buffer instead of Fset_window_buffer (see
1473 discussion of bug#11984, bug#12025, bug#12026). */
1474 set_window_buffer (window
, XWINDOW (minibuf_window
)->contents
, 0, 0);
1475 minibuf_window
= window
;
1477 /* SELECT non-zero usually means that FRAME's minibuffer
1478 window was selected; select the new one. */
1480 Fselect_window (minibuf_window
, Qnil
);
1486 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1487 unconditionally. x_connection_closed and delete_terminal use
1488 this. Any other value of FORCE implements the semantics
1489 described for Fdelete_frame. */
1491 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1493 struct frame
*f
= decode_any_frame (frame
);
1497 int minibuffer_selected
, is_tooltip_frame
;
1499 if (! FRAME_LIVE_P (f
))
1502 if (NILP (force
) && !other_visible_frames (f
))
1503 error ("Attempt to delete the sole visible or iconified frame");
1505 /* x_connection_closed must have set FORCE to `noelisp' in order
1506 to delete the last frame, if it is gone. */
1507 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1508 error ("Attempt to delete the only frame");
1510 XSETFRAME (frame
, f
);
1512 /* Does this frame have a minibuffer, and is it the surrogate
1513 minibuffer for any other frame? */
1514 if (FRAME_HAS_MINIBUF_P (f
))
1516 Lisp_Object frames
, this;
1518 FOR_EACH_FRAME (frames
, this)
1522 if (EQ (this, frame
))
1525 fminiw
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1527 if (WINDOWP (fminiw
) && EQ (frame
, WINDOW_FRAME (XWINDOW (fminiw
))))
1529 /* If we MUST delete this frame, delete the other first.
1530 But do this only if FORCE equals `noelisp'. */
1531 if (EQ (force
, Qnoelisp
))
1532 delete_frame (this, Qnoelisp
);
1534 error ("Attempt to delete a surrogate minibuffer frame");
1539 is_tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1541 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1542 frame is a tooltip. FORCE is set to `noelisp' when handling
1543 a disconnect from the terminal, so we don't dare call Lisp
1545 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1547 else if (EQ (force
, Qnoelisp
))
1549 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1553 #ifdef HAVE_X_WINDOWS
1554 /* Also, save clipboard to the clipboard manager. */
1555 x_clipboard_manager_save_frame (frame
);
1558 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1561 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1562 if (! FRAME_LIVE_P (f
))
1565 /* At this point, we are committed to deleting the frame.
1566 There is no more chance for errors to prevent it. */
1568 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1569 sf
= SELECTED_FRAME ();
1570 /* Don't let the frame remain selected. */
1574 Lisp_Object frame1
= Qnil
;
1576 /* Look for another visible frame on the same terminal.
1577 Do not call next_frame here because it may loop forever.
1578 See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15025. */
1579 FOR_EACH_FRAME (tail
, frame1
)
1580 if (!EQ (frame
, frame1
)
1581 && (FRAME_TERMINAL (XFRAME (frame
))
1582 == FRAME_TERMINAL (XFRAME (frame1
)))
1583 && FRAME_VISIBLE_P (XFRAME (frame1
)))
1586 /* If there is none, find *some* other frame. */
1587 if (NILP (frame1
) || EQ (frame1
, frame
))
1589 FOR_EACH_FRAME (tail
, frame1
)
1591 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1593 /* Do not change a text terminal's top-frame. */
1594 struct frame
*f1
= XFRAME (frame1
);
1595 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1597 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1598 if (!EQ (top_frame
, frame
))
1605 #ifdef NS_IMPL_COCOA
1607 /* Under NS, there is no system mechanism for choosing a new
1608 window to get focus -- it is left to application code.
1609 So the portion of THIS application interfacing with NS
1610 needs to know about it. We call Fraise_frame, but the
1611 purpose is really to transfer focus. */
1612 Fraise_frame (frame1
);
1615 do_switch_frame (frame1
, 0, 1, Qnil
);
1616 sf
= SELECTED_FRAME ();
1619 /* Don't allow minibuf_window to remain on a deleted frame. */
1620 check_minibuf_window (frame
, minibuffer_selected
);
1622 /* Don't let echo_area_window to remain on a deleted frame. */
1623 if (EQ (f
->minibuffer_window
, echo_area_window
))
1624 echo_area_window
= sf
->minibuffer_window
;
1626 /* Clear any X selections for this frame. */
1627 #ifdef HAVE_X_WINDOWS
1629 x_clear_frame_selections (f
);
1633 This function must be called before the window tree of the
1634 frame is deleted because windows contain dynamically allocated
1638 #ifdef HAVE_WINDOW_SYSTEM
1639 /* Give chance to each font driver to free a frame specific data. */
1640 font_update_drivers (f
, Qnil
);
1643 /* Mark all the windows that used to be on FRAME as deleted, and then
1644 remove the reference to them. */
1645 delete_all_child_windows (f
->root_window
);
1646 fset_root_window (f
, Qnil
);
1648 Vframe_list
= Fdelq (frame
, Vframe_list
);
1649 SET_FRAME_VISIBLE (f
, 0);
1651 /* Allow the vector of menu bar contents to be freed in the next
1652 garbage collection. The frame object itself may not be garbage
1653 collected until much later, because recent_keys and other data
1654 structures can still refer to it. */
1655 fset_menu_bar_vector (f
, Qnil
);
1657 /* If FRAME's buffer lists contains killed
1658 buffers, this helps GC to reclaim them. */
1659 fset_buffer_list (f
, Qnil
);
1660 fset_buried_buffer_list (f
, Qnil
);
1662 free_font_driver_list (f
);
1663 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1666 xfree (f
->decode_mode_spec_buffer
);
1667 xfree (FRAME_INSERT_COST (f
));
1668 xfree (FRAME_DELETEN_COST (f
));
1669 xfree (FRAME_INSERTN_COST (f
));
1670 xfree (FRAME_DELETE_COST (f
));
1672 /* Since some events are handled at the interrupt level, we may get
1673 an event for f at any time; if we zero out the frame's terminal
1674 now, then we may trip up the event-handling code. Instead, we'll
1675 promise that the terminal of the frame must be valid until we
1676 have called the window-system-dependent frame destruction
1681 struct terminal
*terminal
;
1683 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1684 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1685 terminal
= FRAME_TERMINAL (f
);
1686 f
->output_data
.nothing
= 0;
1687 f
->terminal
= 0; /* Now the frame is dead. */
1690 /* If needed, delete the terminal that this frame was on.
1691 (This must be done after the frame is killed.) */
1692 terminal
->reference_count
--;
1694 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1696 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1697 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1698 terminal
->reference_count
= 1;
1699 #endif /* USE_GTK */
1700 if (terminal
->reference_count
== 0)
1703 XSETTERMINAL (tmp
, terminal
);
1706 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1709 kb
= terminal
->kboard
;
1712 /* If we've deleted the last_nonminibuf_frame, then try to find
1714 if (f
== last_nonminibuf_frame
)
1716 Lisp_Object frames
, this;
1718 last_nonminibuf_frame
= 0;
1720 FOR_EACH_FRAME (frames
, this)
1723 if (!FRAME_MINIBUF_ONLY_P (f
))
1725 last_nonminibuf_frame
= f
;
1731 /* If there's no other frame on the same kboard, get out of
1732 single-kboard state if we're in it for this kboard. */
1735 Lisp_Object frames
, this;
1736 /* Some frame we found on the same kboard, or nil if there are none. */
1737 Lisp_Object frame_on_same_kboard
= Qnil
;
1739 FOR_EACH_FRAME (frames
, this)
1740 if (kb
== FRAME_KBOARD (XFRAME (this)))
1741 frame_on_same_kboard
= this;
1743 if (NILP (frame_on_same_kboard
))
1744 not_single_kboard_state (kb
);
1748 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1749 find another one. Prefer minibuffer-only frames, but also notice
1750 frames with other windows. */
1751 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1753 Lisp_Object frames
, this;
1755 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1756 Lisp_Object frame_with_minibuf
= Qnil
;
1757 /* Some frame we found on the same kboard, or nil if there are none. */
1758 Lisp_Object frame_on_same_kboard
= Qnil
;
1760 FOR_EACH_FRAME (frames
, this)
1762 struct frame
*f1
= XFRAME (this);
1764 /* Consider only frames on the same kboard
1765 and only those with minibuffers. */
1766 if (kb
== FRAME_KBOARD (f1
)
1767 && FRAME_HAS_MINIBUF_P (f1
))
1769 frame_with_minibuf
= this;
1770 if (FRAME_MINIBUF_ONLY_P (f1
))
1774 if (kb
== FRAME_KBOARD (f1
))
1775 frame_on_same_kboard
= this;
1778 if (!NILP (frame_on_same_kboard
))
1780 /* We know that there must be some frame with a minibuffer out
1781 there. If this were not true, all of the frames present
1782 would have to be minibufferless, which implies that at some
1783 point their minibuffer frames must have been deleted, but
1784 that is prohibited at the top; you can't delete surrogate
1785 minibuffer frames. */
1786 if (NILP (frame_with_minibuf
))
1789 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
1792 /* No frames left on this kboard--say no minibuffer either. */
1793 kset_default_minibuffer_frame (kb
, Qnil
);
1796 /* Cause frame titles to update--necessary if we now have just one frame. */
1797 if (!is_tooltip_frame
)
1798 update_mode_lines
= 15;
1803 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1804 doc
: /* Delete FRAME, permanently eliminating it from use.
1805 FRAME defaults to the selected frame.
1807 A frame may not be deleted if its minibuffer is used by other frames.
1808 Normally, you may not delete a frame if all other frames are invisible,
1809 but if the second optional argument FORCE is non-nil, you may do so.
1811 This function runs `delete-frame-functions' before actually
1812 deleting the frame, unless the frame is a tooltip.
1813 The functions are run with one argument, the frame to be deleted. */)
1814 (Lisp_Object frame
, Lisp_Object force
)
1816 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1820 /* Return mouse position in character cell units. */
1822 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1823 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1824 The position is given in canonical character cells, where (0, 0) is the
1825 upper-left corner of the frame, X is the horizontal offset, and Y is the
1826 vertical offset, measured in units of the frame's default character size.
1827 If Emacs is running on a mouseless terminal or hasn't been programmed
1828 to read the mouse position, it returns the selected frame for FRAME
1829 and nil for X and Y.
1830 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1831 passing the normal return value to that function as an argument,
1832 and returns whatever that function returns. */)
1836 Lisp_Object lispy_dummy
;
1837 Lisp_Object x
, y
, retval
;
1838 struct gcpro gcpro1
;
1840 f
= SELECTED_FRAME ();
1843 /* It's okay for the hook to refrain from storing anything. */
1844 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1846 enum scroll_bar_part party_dummy
;
1848 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1849 &lispy_dummy
, &party_dummy
,
1858 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1862 XSETFRAME (lispy_dummy
, f
);
1863 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1865 if (!NILP (Vmouse_position_function
))
1866 retval
= call1 (Vmouse_position_function
, retval
);
1867 RETURN_UNGCPRO (retval
);
1870 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1871 Smouse_pixel_position
, 0, 0, 0,
1872 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1873 The position is given in pixel units, where (0, 0) is the
1874 upper-left corner of the frame, X is the horizontal offset, and Y is
1875 the vertical offset.
1876 If Emacs is running on a mouseless terminal or hasn't been programmed
1877 to read the mouse position, it returns the selected frame for FRAME
1878 and nil for X and Y. */)
1882 Lisp_Object lispy_dummy
;
1883 Lisp_Object x
, y
, retval
;
1884 struct gcpro gcpro1
;
1886 f
= SELECTED_FRAME ();
1889 /* It's okay for the hook to refrain from storing anything. */
1890 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1892 enum scroll_bar_part party_dummy
;
1894 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1895 &lispy_dummy
, &party_dummy
,
1900 XSETFRAME (lispy_dummy
, f
);
1901 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1903 if (!NILP (Vmouse_position_function
))
1904 retval
= call1 (Vmouse_position_function
, retval
);
1905 RETURN_UNGCPRO (retval
);
1908 #ifdef HAVE_WINDOW_SYSTEM
1910 /* On frame F, convert character coordinates X and Y to pixel
1911 coordinates *PIX_X and *PIX_Y. */
1914 frame_char_to_pixel_position (struct frame
*f
, int x
, int y
,
1915 int *pix_x
, int *pix_y
)
1917 *pix_x
= FRAME_COL_TO_PIXEL_X (f
, x
) + FRAME_COLUMN_WIDTH (f
) / 2;
1918 *pix_y
= FRAME_LINE_TO_PIXEL_Y (f
, y
) + FRAME_LINE_HEIGHT (f
) / 2;
1922 if (*pix_x
> FRAME_PIXEL_WIDTH (f
))
1923 *pix_x
= FRAME_PIXEL_WIDTH (f
);
1927 if (*pix_y
> FRAME_PIXEL_HEIGHT (f
))
1928 *pix_y
= FRAME_PIXEL_HEIGHT (f
);
1931 /* On frame F, reposition mouse pointer to character coordinates X and Y. */
1934 frame_set_mouse_position (struct frame
*f
, int x
, int y
)
1938 frame_char_to_pixel_position (f
, x
, y
, &pix_x
, &pix_y
);
1939 frame_set_mouse_pixel_position (f
, pix_x
, pix_y
);
1942 #endif /* HAVE_WINDOW_SYSTEM */
1944 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1945 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1946 Coordinates are relative to the frame, not a window,
1947 so the coordinates of the top left character in the frame
1948 may be nonzero due to left-hand scroll bars or the menu bar.
1950 The position is given in canonical character cells, where (0, 0) is
1951 the upper-left corner of the frame, X is the horizontal offset, and
1952 Y is the vertical offset, measured in units of the frame's default
1955 This function is a no-op for an X frame that is not visible.
1956 If you have just created a frame, you must wait for it to become visible
1957 before calling this function on it, like this.
1958 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1959 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1961 CHECK_LIVE_FRAME (frame
);
1962 CHECK_TYPE_RANGED_INTEGER (int, x
);
1963 CHECK_TYPE_RANGED_INTEGER (int, y
);
1965 /* I think this should be done with a hook. */
1966 #ifdef HAVE_WINDOW_SYSTEM
1967 if (FRAME_WINDOW_P (XFRAME (frame
)))
1968 /* Warping the mouse will cause enternotify and focus events. */
1969 frame_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1972 if (FRAME_MSDOS_P (XFRAME (frame
)))
1974 Fselect_frame (frame
, Qnil
);
1975 mouse_moveto (XINT (x
), XINT (y
));
1980 Fselect_frame (frame
, Qnil
);
1981 term_mouse_moveto (XINT (x
), XINT (y
));
1990 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1991 Sset_mouse_pixel_position
, 3, 3, 0,
1992 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1993 The position is given in pixels, where (0, 0) is the upper-left corner
1994 of the frame, X is the horizontal offset, and Y is the vertical offset.
1996 Note, this is a no-op for an X frame that is not visible.
1997 If you have just created a frame, you must wait for it to become visible
1998 before calling this function on it, like this.
1999 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
2000 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
2002 CHECK_LIVE_FRAME (frame
);
2003 CHECK_TYPE_RANGED_INTEGER (int, x
);
2004 CHECK_TYPE_RANGED_INTEGER (int, y
);
2006 /* I think this should be done with a hook. */
2007 #ifdef HAVE_WINDOW_SYSTEM
2008 if (FRAME_WINDOW_P (XFRAME (frame
)))
2009 /* Warping the mouse will cause enternotify and focus events. */
2010 frame_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
2013 if (FRAME_MSDOS_P (XFRAME (frame
)))
2015 Fselect_frame (frame
, Qnil
);
2016 mouse_moveto (XINT (x
), XINT (y
));
2021 Fselect_frame (frame
, Qnil
);
2022 term_mouse_moveto (XINT (x
), XINT (y
));
2031 static void make_frame_visible_1 (Lisp_Object
);
2033 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
2035 doc
: /* Make the frame FRAME visible (assuming it is an X window).
2036 If omitted, FRAME defaults to the currently selected frame. */)
2039 struct frame
*f
= decode_live_frame (frame
);
2041 /* I think this should be done with a hook. */
2042 #ifdef HAVE_WINDOW_SYSTEM
2043 if (FRAME_WINDOW_P (f
))
2044 x_make_frame_visible (f
);
2047 make_frame_visible_1 (f
->root_window
);
2049 /* Make menu bar update for the Buffers and Frames menus. */
2050 /* windows_or_buffers_changed = 15; FIXME: Why? */
2052 XSETFRAME (frame
, f
);
2056 /* Update the display_time slot of the buffers shown in WINDOW
2057 and all its descendants. */
2060 make_frame_visible_1 (Lisp_Object window
)
2064 for (; !NILP (window
); window
= w
->next
)
2066 w
= XWINDOW (window
);
2067 if (WINDOWP (w
->contents
))
2068 make_frame_visible_1 (w
->contents
);
2070 bset_display_time (XBUFFER (w
->contents
), Fcurrent_time ());
2074 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
2076 doc
: /* Make the frame FRAME invisible.
2077 If omitted, FRAME defaults to the currently selected frame.
2078 On graphical displays, invisible frames are not updated and are
2079 usually not displayed at all, even in a window system's \"taskbar\".
2081 Normally you may not make FRAME invisible if all other frames are invisible,
2082 but if the second optional argument FORCE is non-nil, you may do so.
2084 This function has no effect on text terminal frames. Such frames are
2085 always considered visible, whether or not they are currently being
2086 displayed in the terminal. */)
2087 (Lisp_Object frame
, Lisp_Object force
)
2089 struct frame
*f
= decode_live_frame (frame
);
2091 if (NILP (force
) && !other_visible_frames (f
))
2092 error ("Attempt to make invisible the sole visible or iconified frame");
2094 /* Don't allow minibuf_window to remain on an invisible frame. */
2095 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2097 /* I think this should be done with a hook. */
2098 #ifdef HAVE_WINDOW_SYSTEM
2099 if (FRAME_WINDOW_P (f
))
2100 x_make_frame_invisible (f
);
2103 /* Make menu bar update for the Buffers and Frames menus. */
2104 windows_or_buffers_changed
= 16;
2109 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
2111 doc
: /* Make the frame FRAME into an icon.
2112 If omitted, FRAME defaults to the currently selected frame. */)
2115 struct frame
*f
= decode_live_frame (frame
);
2117 /* Don't allow minibuf_window to remain on an iconified frame. */
2118 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2120 /* I think this should be done with a hook. */
2121 #ifdef HAVE_WINDOW_SYSTEM
2122 if (FRAME_WINDOW_P (f
))
2123 x_iconify_frame (f
);
2126 /* Make menu bar update for the Buffers and Frames menus. */
2127 windows_or_buffers_changed
= 17;
2132 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
2134 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
2135 Return the symbol `icon' if FRAME is iconified or \"minimized\".
2136 Return nil if FRAME was made invisible, via `make-frame-invisible'.
2137 On graphical displays, invisible frames are not updated and are
2138 usually not displayed at all, even in a window system's \"taskbar\".
2140 If FRAME is a text terminal frame, this always returns t.
2141 Such frames are always considered visible, whether or not they are
2142 currently being displayed on the terminal. */)
2145 CHECK_LIVE_FRAME (frame
);
2147 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2149 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
2154 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
2156 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
2159 Lisp_Object tail
, frame
, value
= Qnil
;
2161 FOR_EACH_FRAME (tail
, frame
)
2162 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2163 value
= Fcons (frame
, value
);
2169 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
2170 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
2171 If FRAME is invisible or iconified, make it visible.
2172 If you don't specify a frame, the selected frame is used.
2173 If Emacs is displaying on an ordinary terminal or some other device which
2174 doesn't support multiple overlapping frames, this function selects FRAME. */)
2177 struct frame
*f
= decode_live_frame (frame
);
2179 XSETFRAME (frame
, f
);
2181 if (FRAME_TERMCAP_P (f
))
2182 /* On a text terminal select FRAME. */
2183 Fselect_frame (frame
, Qnil
);
2185 /* Do like the documentation says. */
2186 Fmake_frame_visible (frame
);
2188 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2189 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
2194 /* Should we have a corresponding function called Flower_Power? */
2195 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
2196 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2197 If you don't specify a frame, the selected frame is used.
2198 If Emacs is displaying on an ordinary terminal or some other device which
2199 doesn't support multiple overlapping frames, this function does nothing. */)
2202 struct frame
*f
= decode_live_frame (frame
);
2204 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2205 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2211 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2213 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2214 In other words, switch-frame events caused by events in FRAME will
2215 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2216 FOCUS-FRAME after reading an event typed at FRAME.
2218 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
2219 frame again receives its own keystrokes.
2221 Focus redirection is useful for temporarily redirecting keystrokes to
2222 a surrogate minibuffer frame when a frame doesn't have its own
2225 A frame's focus redirection can be changed by `select-frame'. If frame
2226 FOO is selected, and then a different frame BAR is selected, any
2227 frames redirecting their focus to FOO are shifted to redirect their
2228 focus to BAR. This allows focus redirection to work properly when the
2229 user switches from one frame to another using `select-window'.
2231 This means that a frame whose focus is redirected to itself is treated
2232 differently from a frame whose focus is redirected to nil; the former
2233 is affected by `select-frame', while the latter is not.
2235 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2236 (Lisp_Object frame
, Lisp_Object focus_frame
)
2238 /* Note that we don't check for a live frame here. It's reasonable
2239 to redirect the focus of a frame you're about to delete, if you
2240 know what other frame should receive those keystrokes. */
2241 struct frame
*f
= decode_any_frame (frame
);
2243 if (! NILP (focus_frame
))
2244 CHECK_LIVE_FRAME (focus_frame
);
2246 fset_focus_frame (f
, focus_frame
);
2248 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2249 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2255 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 0, 1, 0,
2256 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2257 If FRAME is omitted or nil, the selected frame is used.
2258 Return nil if FRAME's focus is not redirected.
2259 See `redirect-frame-focus'. */)
2262 return FRAME_FOCUS_FRAME (decode_live_frame (frame
));
2265 DEFUN ("x-focus-frame", Fx_focus_frame
, Sx_focus_frame
, 1, 1, 0,
2266 doc
: /* Set the input focus to FRAME.
2267 FRAME nil means use the selected frame.
2268 If there is no window system support, this function does nothing. */)
2271 #ifdef HAVE_WINDOW_SYSTEM
2272 x_focus_frame (decode_window_system_frame (frame
));
2277 DEFUN ("frame-can-run-window-configuration-change-hook",
2278 Fcan_run_window_configuration_change_hook
,
2279 Scan_run_window_configuration_change_hook
, 2, 2, 0,
2280 doc
: /* Whether `window-configuration-change-hook' is run for frame FRAME.
2281 FRAME nil means use the selected frame. Second argument ALLOW non-nil
2282 means functions on `window-configuration-change-hook' are called
2283 whenever the window configuration of FRAME changes. ALLOW nil means
2284 these functions are not called.
2286 This function is currently called by `face-set-after-frame-default' only
2287 and should be otherwise used with utter care to avoid that running
2288 functions on `window-configuration-change-hook' is impeded forever. */)
2289 (Lisp_Object frame
, Lisp_Object allow
)
2291 struct frame
*f
= decode_live_frame (frame
);
2293 f
->can_run_window_configuration_change_hook
= NILP (allow
) ? false : true;
2298 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2301 frames_discard_buffer (Lisp_Object buffer
)
2303 Lisp_Object frame
, tail
;
2305 FOR_EACH_FRAME (tail
, frame
)
2308 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
2309 fset_buried_buffer_list
2310 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
2314 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2315 If the alist already has an element for PROP, we change it. */
2318 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2320 register Lisp_Object tem
;
2322 tem
= Fassq (prop
, *alistptr
);
2324 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2330 frame_name_fnn_p (char *str
, ptrdiff_t len
)
2332 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
2335 while ('0' <= *p
&& *p
<= '9')
2343 /* Set the name of the terminal frame. Also used by MSDOS frames.
2344 Modeled after x_set_name which is used for WINDOW frames. */
2347 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2349 f
->explicit_name
= ! NILP (name
);
2351 /* If NAME is nil, set the name to F<num>. */
2354 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
2356 /* Check for no change needed in this very common case
2357 before we do any consing. */
2358 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
2361 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
2365 CHECK_STRING (name
);
2367 /* Don't change the name if it's already NAME. */
2368 if (! NILP (Fstring_equal (name
, f
->name
)))
2371 /* Don't allow the user to set the frame name to F<num>, so it
2372 doesn't clash with the names we generate for terminal frames. */
2373 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2374 error ("Frame names of the form F<num> are usurped by Emacs");
2377 fset_name (f
, name
);
2378 update_mode_lines
= 16;
2382 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2384 register Lisp_Object old_alist_elt
;
2386 /* The buffer-list parameters are stored in a special place and not
2387 in the alist. All buffers must be live. */
2388 if (EQ (prop
, Qbuffer_list
))
2390 Lisp_Object list
= Qnil
;
2391 for (; CONSP (val
); val
= XCDR (val
))
2392 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2393 list
= Fcons (XCAR (val
), list
);
2394 fset_buffer_list (f
, Fnreverse (list
));
2397 if (EQ (prop
, Qburied_buffer_list
))
2399 Lisp_Object list
= Qnil
;
2400 for (; CONSP (val
); val
= XCDR (val
))
2401 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2402 list
= Fcons (XCAR (val
), list
);
2403 fset_buried_buffer_list (f
, Fnreverse (list
));
2407 /* If PROP is a symbol which is supposed to have frame-local values,
2408 and it is set up based on this frame, switch to the global
2409 binding. That way, we can create or alter the frame-local binding
2410 without messing up the symbol's status. */
2413 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2415 switch (sym
->redirect
)
2417 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2418 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2419 case SYMBOL_LOCALIZED
:
2420 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2421 if (blv
->frame_local
&& blv_found (blv
) && XFRAME (blv
->where
) == f
)
2422 swap_in_global_binding (sym
);
2425 default: emacs_abort ();
2429 /* The tty color needed to be set before the frame's parameter
2430 alist was updated with the new value. This is not true any more,
2431 but we still do this test early on. */
2432 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2433 && f
== FRAME_TTY (f
)->previous_frame
)
2434 /* Force redisplay of this tty. */
2435 FRAME_TTY (f
)->previous_frame
= NULL
;
2437 /* Update the frame parameter alist. */
2438 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2439 if (EQ (old_alist_elt
, Qnil
))
2440 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2442 Fsetcdr (old_alist_elt
, val
);
2444 /* Update some other special parameters in their special places
2445 in addition to the alist. */
2447 if (EQ (prop
, Qbuffer_predicate
))
2448 fset_buffer_predicate (f
, val
);
2450 if (! FRAME_WINDOW_P (f
))
2452 if (EQ (prop
, Qmenu_bar_lines
))
2453 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2454 else if (EQ (prop
, Qname
))
2455 set_term_frame_name (f
, val
);
2458 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2460 if (! MINI_WINDOW_P (XWINDOW (val
)))
2461 error ("Surrogate minibuffer windows must be minibuffer windows");
2463 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2464 && !EQ (val
, f
->minibuffer_window
))
2465 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2467 /* Install the chosen minibuffer window, with proper buffer. */
2468 fset_minibuffer_window (f
, val
);
2472 /* Return color matches UNSPEC on frame F or nil if UNSPEC
2473 is not an unspecified foreground or background color. */
2476 frame_unspecified_color (struct frame
*f
, Lisp_Object unspec
)
2478 return (!strncmp (SSDATA (unspec
), unspecified_bg
, SBYTES (unspec
))
2479 ? tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
))
2480 : (!strncmp (SSDATA (unspec
), unspecified_fg
, SBYTES (unspec
))
2481 ? tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)) : Qnil
));
2484 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2485 doc
: /* Return the parameters-alist of frame FRAME.
2486 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2487 The meaningful PARMs depend on the kind of frame.
2488 If FRAME is omitted or nil, return information on the currently selected frame. */)
2492 struct frame
*f
= decode_any_frame (frame
);
2494 struct gcpro gcpro1
;
2496 if (!FRAME_LIVE_P (f
))
2499 alist
= Fcopy_alist (f
->param_alist
);
2502 if (!FRAME_WINDOW_P (f
))
2506 /* If the frame's parameter alist says the colors are
2507 unspecified and reversed, take the frame's background pixel
2508 for foreground and vice versa. */
2509 elt
= Fassq (Qforeground_color
, alist
);
2510 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2512 elt
= frame_unspecified_color (f
, XCDR (elt
));
2514 store_in_alist (&alist
, Qforeground_color
, elt
);
2517 store_in_alist (&alist
, Qforeground_color
,
2518 tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)));
2519 elt
= Fassq (Qbackground_color
, alist
);
2520 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2522 elt
= frame_unspecified_color (f
, XCDR (elt
));
2524 store_in_alist (&alist
, Qbackground_color
, elt
);
2527 store_in_alist (&alist
, Qbackground_color
,
2528 tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
)));
2529 store_in_alist (&alist
, intern ("font"),
2530 build_string (FRAME_MSDOS_P (f
)
2532 : FRAME_W32_P (f
) ? "w32term"
2535 store_in_alist (&alist
, Qname
, f
->name
);
2536 height
= (f
->new_height
2538 ? (f
->new_height
/ FRAME_LINE_HEIGHT (f
))
2541 store_in_alist (&alist
, Qheight
, make_number (height
));
2542 width
= (f
->new_width
2544 ? (f
->new_width
/ FRAME_COLUMN_WIDTH (f
))
2547 store_in_alist (&alist
, Qwidth
, make_number (width
));
2548 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2549 store_in_alist (&alist
, Qminibuffer
,
2550 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2551 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2552 : FRAME_MINIBUF_WINDOW (f
)));
2553 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2554 store_in_alist (&alist
, Qbuffer_list
, f
->buffer_list
);
2555 store_in_alist (&alist
, Qburied_buffer_list
, f
->buried_buffer_list
);
2557 /* I think this should be done with a hook. */
2558 #ifdef HAVE_WINDOW_SYSTEM
2559 if (FRAME_WINDOW_P (f
))
2560 x_report_frame_params (f
, &alist
);
2564 /* This ought to be correct in f->param_alist for an X frame. */
2566 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2567 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2575 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2576 doc
: /* Return FRAME's value for parameter PARAMETER.
2577 If FRAME is nil, describe the currently selected frame. */)
2578 (Lisp_Object frame
, Lisp_Object parameter
)
2580 struct frame
*f
= decode_any_frame (frame
);
2581 Lisp_Object value
= Qnil
;
2583 CHECK_SYMBOL (parameter
);
2585 XSETFRAME (frame
, f
);
2587 if (FRAME_LIVE_P (f
))
2589 /* Avoid consing in frequent cases. */
2590 if (EQ (parameter
, Qname
))
2592 #ifdef HAVE_X_WINDOWS
2593 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2594 value
= XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
);
2595 #endif /* HAVE_X_WINDOWS */
2596 else if (EQ (parameter
, Qbackground_color
)
2597 || EQ (parameter
, Qforeground_color
))
2599 value
= Fassq (parameter
, f
->param_alist
);
2602 value
= XCDR (value
);
2603 /* Fframe_parameters puts the actual fg/bg color names,
2604 even if f->param_alist says otherwise. This is
2605 important when param_alist's notion of colors is
2606 "unspecified". We need to do the same here. */
2607 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2608 value
= frame_unspecified_color (f
, value
);
2611 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2613 else if (EQ (parameter
, Qdisplay_type
)
2614 || EQ (parameter
, Qbackground_mode
))
2615 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2617 /* FIXME: Avoid this code path at all (as well as code duplication)
2618 by sharing more code with Fframe_parameters. */
2619 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2626 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2627 Smodify_frame_parameters
, 2, 2, 0,
2628 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2629 If FRAME is nil, it defaults to the selected frame.
2630 ALIST is an alist of parameters to change and their new values.
2631 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2632 The meaningful PARMs depend on the kind of frame.
2633 Undefined PARMs are ignored, but stored in the frame's parameter list
2634 so that `frame-parameters' will return them.
2636 The value of frame parameter FOO can also be accessed
2637 as a frame-local binding for the variable FOO, if you have
2638 enabled such bindings for that variable with `make-variable-frame-local'.
2639 Note that this functionality is obsolete as of Emacs 22.2, and its
2640 use is not recommended. Explicitly check for a frame-parameter instead. */)
2641 (Lisp_Object frame
, Lisp_Object alist
)
2643 struct frame
*f
= decode_live_frame (frame
);
2644 register Lisp_Object prop
, val
;
2648 /* I think this should be done with a hook. */
2649 #ifdef HAVE_WINDOW_SYSTEM
2650 if (FRAME_WINDOW_P (f
))
2651 x_set_frame_parameters (f
, alist
);
2655 if (FRAME_MSDOS_P (f
))
2656 IT_set_frame_parameters (f
, alist
);
2661 EMACS_INT length
= XFASTINT (Flength (alist
));
2664 Lisp_Object
*values
;
2666 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2667 values
= parms
+ length
;
2669 /* Extract parm names and values into those vectors. */
2671 for (i
= 0; CONSP (alist
); alist
= XCDR (alist
))
2676 parms
[i
] = Fcar (elt
);
2677 values
[i
] = Fcdr (elt
);
2681 /* Now process them in reverse of specified order. */
2686 store_frame_param (f
, prop
, val
);
2688 if (EQ (prop
, Qforeground_color
)
2689 || EQ (prop
, Qbackground_color
))
2690 update_face_from_frame_parameter (f
, prop
, val
);
2698 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2700 doc
: /* Height in pixels of a line in the font in frame FRAME.
2701 If FRAME is omitted or nil, the selected frame is used.
2702 For a terminal frame, the value is always 1. */)
2705 #ifdef HAVE_WINDOW_SYSTEM
2706 struct frame
*f
= decode_any_frame (frame
);
2708 if (FRAME_WINDOW_P (f
))
2709 return make_number (FRAME_LINE_HEIGHT (f
));
2712 return make_number (1);
2716 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2718 doc
: /* Width in pixels of characters in the font in frame FRAME.
2719 If FRAME is omitted or nil, the selected frame is used.
2720 On a graphical screen, the width is the standard width of the default font.
2721 For a terminal screen, the value is always 1. */)
2724 #ifdef HAVE_WINDOW_SYSTEM
2725 struct frame
*f
= decode_any_frame (frame
);
2727 if (FRAME_WINDOW_P (f
))
2728 return make_number (FRAME_COLUMN_WIDTH (f
));
2731 return make_number (1);
2734 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2735 Sframe_pixel_height
, 0, 1, 0,
2736 doc
: /* Return a FRAME's height in pixels.
2737 If FRAME is omitted or nil, the selected frame is used. The exact value
2738 of the result depends on the window-system and toolkit in use:
2740 In the Gtk+ version of Emacs, it includes only any window (including
2741 the minibuffer or echo area), mode line, and header line. It does not
2742 include the tool bar or menu bar.
2744 With other graphical versions, it also includes the tool bar and the
2747 For a text terminal, it includes the menu bar. In this case, the
2748 result is really in characters rather than pixels (i.e., is identical
2749 to `frame-height'). */)
2752 struct frame
*f
= decode_any_frame (frame
);
2754 #ifdef HAVE_WINDOW_SYSTEM
2755 if (FRAME_WINDOW_P (f
))
2756 return make_number (FRAME_PIXEL_HEIGHT (f
));
2759 return make_number (FRAME_TOTAL_LINES (f
));
2762 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2763 Sframe_pixel_width
, 0, 1, 0,
2764 doc
: /* Return FRAME's width in pixels.
2765 For a terminal frame, the result really gives the width in characters.
2766 If FRAME is omitted or nil, the selected frame is used. */)
2769 struct frame
*f
= decode_any_frame (frame
);
2771 #ifdef HAVE_WINDOW_SYSTEM
2772 if (FRAME_WINDOW_P (f
))
2773 return make_number (FRAME_PIXEL_WIDTH (f
));
2776 return make_number (FRAME_TOTAL_COLS (f
));
2779 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2780 Stool_bar_pixel_width
, 0, 1, 0,
2781 doc
: /* Return width in pixels of FRAME's tool bar.
2782 The result is greater than zero only when the tool bar is on the left
2783 or right side of FRAME. If FRAME is omitted or nil, the selected frame
2787 #ifdef FRAME_TOOLBAR_WIDTH
2788 struct frame
*f
= decode_any_frame (frame
);
2790 if (FRAME_WINDOW_P (f
))
2791 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2793 return make_number (0);
2796 DEFUN ("frame-text-cols", Fframe_text_cols
, Sframe_text_cols
, 0, 1, 0,
2797 doc
: /* Return width in columns of FRAME's text area. */)
2800 return make_number (FRAME_COLS (decode_any_frame (frame
)));
2803 DEFUN ("frame-text-lines", Fframe_text_lines
, Sframe_text_lines
, 0, 1, 0,
2804 doc
: /* Return height in lines of FRAME's text area. */)
2807 return make_number (FRAME_LINES (decode_any_frame (frame
)));
2810 DEFUN ("frame-total-cols", Fframe_total_cols
, Sframe_total_cols
, 0, 1, 0,
2811 doc
: /* Return number of total columns of FRAME. */)
2814 return make_number (FRAME_TOTAL_COLS (decode_any_frame (frame
)));
2817 DEFUN ("frame-total-lines", Fframe_total_lines
, Sframe_total_lines
, 0, 1, 0,
2818 doc
: /* Return number of total lines of FRAME. */)
2821 return make_number (FRAME_TOTAL_LINES (decode_any_frame (frame
)));
2824 DEFUN ("frame-text-width", Fframe_text_width
, Sframe_text_width
, 0, 1, 0,
2825 doc
: /* Return text area width of FRAME in pixels. */)
2828 return make_number (FRAME_TEXT_WIDTH (decode_any_frame (frame
)));
2831 DEFUN ("frame-text-height", Fframe_text_height
, Sframe_text_height
, 0, 1, 0,
2832 doc
: /* Return text area height of FRAME in pixels. */)
2835 return make_number (FRAME_TEXT_HEIGHT (decode_any_frame (frame
)));
2838 DEFUN ("frame-scroll-bar-width", Fscroll_bar_width
, Sscroll_bar_width
, 0, 1, 0,
2839 doc
: /* Return scroll bar width of FRAME in pixels. */)
2842 return make_number (FRAME_SCROLL_BAR_AREA_WIDTH (decode_any_frame (frame
)));
2845 DEFUN ("frame-scroll-bar-height", Fscroll_bar_height
, Sscroll_bar_height
, 0, 1, 0,
2846 doc
: /* Return scroll bar height of FRAME in pixels. */)
2849 return make_number (FRAME_SCROLL_BAR_AREA_HEIGHT (decode_any_frame (frame
)));
2852 DEFUN ("frame-fringe-width", Ffringe_width
, Sfringe_width
, 0, 1, 0,
2853 doc
: /* Return fringe width of FRAME in pixels. */)
2856 return make_number (FRAME_TOTAL_FRINGE_WIDTH (decode_any_frame (frame
)));
2859 DEFUN ("frame-border-width", Fborder_width
, Sborder_width
, 0, 1, 0,
2860 doc
: /* Return border width of FRAME in pixels. */)
2863 return make_number (FRAME_INTERNAL_BORDER_WIDTH (decode_any_frame (frame
)));
2866 DEFUN ("frame-right-divider-width", Fright_divider_width
, Sright_divider_width
, 0, 1, 0,
2867 doc
: /* Return width (in pixels) of vertical window dividers on FRAME. */)
2870 return make_number (FRAME_RIGHT_DIVIDER_WIDTH (decode_any_frame (frame
)));
2873 DEFUN ("frame-bottom-divider-width", Fbottom_divider_width
, Sbottom_divider_width
, 0, 1, 0,
2874 doc
: /* Return width (in pixels) of horizontal window dividers on FRAME. */)
2877 return make_number (FRAME_BOTTOM_DIVIDER_WIDTH (decode_any_frame (frame
)));
2880 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 4, 0,
2881 doc
: /* Set height of frame FRAME to HEIGHT lines.
2882 Optional third arg PRETEND non-nil means that redisplay should use
2883 HEIGHT lines but that the idea of the actual height of the frame should
2886 Optional fourth argument PIXELWISE non-nil means that FRAME should be
2887 HEIGHT pixels high. Note: When `frame-resize-pixelwise' is nil, some
2888 window managers may refuse to honor a HEIGHT that is not an integer
2889 multiple of the default frame font height. */)
2890 (Lisp_Object frame
, Lisp_Object height
, Lisp_Object pretend
, Lisp_Object pixelwise
)
2892 struct frame
*f
= decode_live_frame (frame
);
2895 CHECK_TYPE_RANGED_INTEGER (int, height
);
2897 pixel_height
= (!NILP (pixelwise
)
2899 : XINT (height
) * FRAME_LINE_HEIGHT (f
));
2900 if (pixel_height
!= FRAME_TEXT_HEIGHT (f
))
2901 adjust_frame_size (f
, -1, pixel_height
, 1, !NILP (pretend
), Qheight
);
2906 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 4, 0,
2907 doc
: /* Set width of frame FRAME to WIDTH columns.
2908 Optional third arg PRETEND non-nil means that redisplay should use WIDTH
2909 columns but that the idea of the actual width of the frame should not
2912 Optional fourth argument PIXELWISE non-nil means that FRAME should be
2913 WIDTH pixels wide. Note: When `frame-resize-pixelwise' is nil, some
2914 window managers may refuse to honor a WIDTH that is not an integer
2915 multiple of the default frame font width. */)
2916 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object pretend
, Lisp_Object pixelwise
)
2918 struct frame
*f
= decode_live_frame (frame
);
2921 CHECK_TYPE_RANGED_INTEGER (int, width
);
2923 pixel_width
= (!NILP (pixelwise
)
2925 : XINT (width
) * FRAME_COLUMN_WIDTH (f
));
2926 if (pixel_width
!= FRAME_TEXT_WIDTH (f
))
2927 adjust_frame_size (f
, pixel_width
, -1, 1, !NILP (pretend
), Qwidth
);
2932 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 4, 0,
2933 doc
: /* Set size of FRAME to WIDTH by HEIGHT, measured in characters.
2934 Optional argument PIXELWISE non-nil means to measure in pixels. Note:
2935 When `frame-resize-pixelwise' is nil, some window managers may refuse to
2936 honor a WIDTH that is not an integer multiple of the default frame font
2937 width or a HEIGHT that is not an integer multiple of the default frame
2939 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object height
, Lisp_Object pixelwise
)
2941 struct frame
*f
= decode_live_frame (frame
);
2942 int pixel_width
, pixel_height
;
2944 CHECK_TYPE_RANGED_INTEGER (int, width
);
2945 CHECK_TYPE_RANGED_INTEGER (int, height
);
2947 pixel_width
= (!NILP (pixelwise
)
2949 : XINT (width
) * FRAME_COLUMN_WIDTH (f
));
2950 pixel_height
= (!NILP (pixelwise
)
2952 : XINT (height
) * FRAME_LINE_HEIGHT (f
));
2954 if (pixel_width
!= FRAME_TEXT_WIDTH (f
)
2955 || pixel_height
!= FRAME_TEXT_HEIGHT (f
))
2956 adjust_frame_size (f
, pixel_width
, pixel_height
, 1, 0, Qsize
);
2961 DEFUN ("set-frame-position", Fset_frame_position
,
2962 Sset_frame_position
, 3, 3, 0,
2963 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2964 If FRAME is nil, the selected frame is used. XOFFSET and YOFFSET are
2965 actually the position of the upper left corner of the frame. Negative
2966 values for XOFFSET or YOFFSET are interpreted relative to the rightmost
2967 or bottommost possible position (that stays within the screen). */)
2968 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2970 register struct frame
*f
= decode_live_frame (frame
);
2972 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2973 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2975 /* I think this should be done with a hook. */
2976 #ifdef HAVE_WINDOW_SYSTEM
2977 if (FRAME_WINDOW_P (f
))
2978 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2985 /***********************************************************************
2987 ***********************************************************************/
2989 /* Connect the frame-parameter names for X frames
2990 to the ways of passing the parameter values to the window system.
2992 The name of a parameter, as a Lisp symbol,
2993 has an `x-frame-parameter' property which is an integer in Lisp
2994 that is an index in this table. */
2996 struct frame_parm_table
{
2998 Lisp_Object
*variable
;
3001 static const struct frame_parm_table frame_parms
[] =
3003 {"auto-raise", &Qauto_raise
},
3004 {"auto-lower", &Qauto_lower
},
3005 {"background-color", 0},
3006 {"border-color", &Qborder_color
},
3007 {"border-width", &Qborder_width
},
3008 {"cursor-color", &Qcursor_color
},
3009 {"cursor-type", &Qcursor_type
},
3011 {"foreground-color", 0},
3012 {"icon-name", &Qicon_name
},
3013 {"icon-type", &Qicon_type
},
3014 {"internal-border-width", &Qinternal_border_width
},
3015 {"right-divider-width", &Qright_divider_width
},
3016 {"bottom-divider-width", &Qbottom_divider_width
},
3017 {"menu-bar-lines", &Qmenu_bar_lines
},
3018 {"mouse-color", &Qmouse_color
},
3020 {"scroll-bar-width", &Qscroll_bar_width
},
3021 {"scroll-bar-height", &Qscroll_bar_height
},
3023 {"unsplittable", &Qunsplittable
},
3024 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
3025 {"horizontal-scroll-bars", &Qhorizontal_scroll_bars
},
3026 {"visibility", &Qvisibility
},
3027 {"tool-bar-lines", &Qtool_bar_lines
},
3028 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
3029 {"scroll-bar-background", &Qscroll_bar_background
},
3030 {"screen-gamma", &Qscreen_gamma
},
3031 {"line-spacing", &Qline_spacing
},
3032 {"left-fringe", &Qleft_fringe
},
3033 {"right-fringe", &Qright_fringe
},
3034 {"wait-for-wm", &Qwait_for_wm
},
3035 {"fullscreen", &Qfullscreen
},
3036 {"font-backend", &Qfont_backend
},
3038 {"sticky", &Qsticky
},
3039 {"tool-bar-position", &Qtool_bar_position
},
3042 #ifdef HAVE_WINDOW_SYSTEM
3044 /* Change the parameters of frame F as specified by ALIST.
3045 If a parameter is not specially recognized, do nothing special;
3046 otherwise call the `x_set_...' function for that parameter.
3047 Except for certain geometry properties, always call store_frame_param
3048 to store the new value in the parameter alist. */
3051 x_set_frame_parameters (struct frame
*f
, Lisp_Object alist
)
3055 /* If both of these parameters are present, it's more efficient to
3056 set them both at once. So we wait until we've looked at the
3057 entire list before we set them. */
3058 int width
IF_LINT (= 0), height
IF_LINT (= 0);
3059 bool width_change
= 0, height_change
= 0;
3062 Lisp_Object left
, top
;
3064 /* Same with these. */
3065 Lisp_Object icon_left
, icon_top
;
3067 /* Record in these vectors all the parms specified. */
3069 Lisp_Object
*values
;
3071 bool left_no_change
= 0, top_no_change
= 0;
3072 #ifdef HAVE_X_WINDOWS
3073 bool icon_left_no_change
= 0, icon_top_no_change
= 0;
3077 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3081 SAFE_ALLOCA_LISP (parms
, 2 * i
);
3084 /* Extract parm names and values into those vectors. */
3087 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3092 parms
[i
] = Fcar (elt
);
3093 values
[i
] = Fcdr (elt
);
3096 /* TAIL and ALIST are not used again below here. */
3097 alist
= tail
= Qnil
;
3099 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
3100 because their values appear in VALUES and strings are not valid. */
3101 top
= left
= Qunbound
;
3102 icon_left
= icon_top
= Qunbound
;
3104 /* Process foreground_color and background_color before anything else.
3105 They are independent of other properties, but other properties (e.g.,
3106 cursor_color) are dependent upon them. */
3107 /* Process default font as well, since fringe widths depends on it. */
3108 for (p
= 0; p
< i
; p
++)
3110 Lisp_Object prop
, val
;
3114 if (EQ (prop
, Qforeground_color
)
3115 || EQ (prop
, Qbackground_color
)
3116 || EQ (prop
, Qfont
))
3118 register Lisp_Object param_index
, old_value
;
3120 old_value
= get_frame_param (f
, prop
);
3121 if (NILP (Fequal (val
, old_value
)))
3123 store_frame_param (f
, prop
, val
);
3125 param_index
= Fget (prop
, Qx_frame_parameter
);
3126 if (NATNUMP (param_index
)
3127 && XFASTINT (param_index
) < ARRAYELTS (frame_parms
)
3128 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3129 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3134 /* Now process them in reverse of specified order. */
3137 Lisp_Object prop
, val
;
3142 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
3145 width
= XFASTINT (val
) * FRAME_COLUMN_WIDTH (f
) ;
3147 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
3150 height
= XFASTINT (val
) * FRAME_LINE_HEIGHT (f
);
3152 else if (EQ (prop
, Qtop
))
3154 else if (EQ (prop
, Qleft
))
3156 else if (EQ (prop
, Qicon_top
))
3158 else if (EQ (prop
, Qicon_left
))
3160 else if (EQ (prop
, Qforeground_color
)
3161 || EQ (prop
, Qbackground_color
)
3162 || EQ (prop
, Qfont
))
3163 /* Processed above. */
3167 register Lisp_Object param_index
, old_value
;
3169 old_value
= get_frame_param (f
, prop
);
3171 store_frame_param (f
, prop
, val
);
3173 param_index
= Fget (prop
, Qx_frame_parameter
);
3174 if (NATNUMP (param_index
)
3175 && XFASTINT (param_index
) < ARRAYELTS (frame_parms
)
3176 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3177 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3181 /* Don't die if just one of these was set. */
3182 if (EQ (left
, Qunbound
))
3185 if (f
->left_pos
< 0)
3186 left
= list2 (Qplus
, make_number (f
->left_pos
));
3188 XSETINT (left
, f
->left_pos
);
3190 if (EQ (top
, Qunbound
))
3194 top
= list2 (Qplus
, make_number (f
->top_pos
));
3196 XSETINT (top
, f
->top_pos
);
3199 /* If one of the icon positions was not set, preserve or default it. */
3200 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
3202 #ifdef HAVE_X_WINDOWS
3203 icon_left_no_change
= 1;
3205 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3206 if (NILP (icon_left
))
3207 XSETINT (icon_left
, 0);
3209 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
3211 #ifdef HAVE_X_WINDOWS
3212 icon_top_no_change
= 1;
3214 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3215 if (NILP (icon_top
))
3216 XSETINT (icon_top
, 0);
3219 /* Don't set these parameters unless they've been explicitly
3220 specified. The window might be mapped or resized while we're in
3221 this function, and we don't want to override that unless the lisp
3222 code has asked for it.
3224 Don't set these parameters unless they actually differ from the
3225 window's current parameters; the window may not actually exist
3230 XSETFRAME (frame
, f
);
3232 if ((width_change
&& width
!= FRAME_TEXT_WIDTH (f
))
3233 || (height_change
&& height
!= FRAME_TEXT_HEIGHT (f
))
3234 || (f
->can_x_set_window_size
&& (f
->new_height
|| f
->new_width
)))
3236 /* If necessary provide default values for HEIGHT and WIDTH. Do
3237 that here since otherwise a size change implied by an
3238 intermittent font change may get lost as in Bug#17142. */
3240 width
= (f
->new_width
3243 : (f
->new_width
* FRAME_COLUMN_WIDTH (f
)))
3244 : FRAME_TEXT_WIDTH (f
));
3247 height
= (f
->new_height
3250 : (f
->new_height
* FRAME_LINE_HEIGHT (f
)))
3251 : FRAME_TEXT_HEIGHT (f
));
3253 Fset_frame_size (frame
, make_number (width
), make_number (height
), Qt
);
3256 if ((!NILP (left
) || !NILP (top
))
3257 && ! (left_no_change
&& top_no_change
)
3258 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3259 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3264 /* Record the signs. */
3265 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3266 if (EQ (left
, Qminus
))
3267 f
->size_hint_flags
|= XNegative
;
3268 else if (TYPE_RANGED_INTEGERP (int, left
))
3270 leftpos
= XINT (left
);
3272 f
->size_hint_flags
|= XNegative
;
3274 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3275 && CONSP (XCDR (left
))
3276 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
3278 leftpos
= - XINT (XCAR (XCDR (left
)));
3279 f
->size_hint_flags
|= XNegative
;
3281 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3282 && CONSP (XCDR (left
))
3283 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
3285 leftpos
= XINT (XCAR (XCDR (left
)));
3288 if (EQ (top
, Qminus
))
3289 f
->size_hint_flags
|= YNegative
;
3290 else if (TYPE_RANGED_INTEGERP (int, top
))
3292 toppos
= XINT (top
);
3294 f
->size_hint_flags
|= YNegative
;
3296 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3297 && CONSP (XCDR (top
))
3298 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
3300 toppos
= - XINT (XCAR (XCDR (top
)));
3301 f
->size_hint_flags
|= YNegative
;
3303 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
3304 && CONSP (XCDR (top
))
3305 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
3307 toppos
= XINT (XCAR (XCDR (top
)));
3311 /* Store the numeric value of the position. */
3312 f
->top_pos
= toppos
;
3313 f
->left_pos
= leftpos
;
3315 f
->win_gravity
= NorthWestGravity
;
3317 /* Actually set that position, and convert to absolute. */
3318 x_set_offset (f
, leftpos
, toppos
, -1);
3320 #ifdef HAVE_X_WINDOWS
3321 if ((!NILP (icon_left
) || !NILP (icon_top
))
3322 && ! (icon_left_no_change
&& icon_top_no_change
))
3323 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3324 #endif /* HAVE_X_WINDOWS */
3331 /* Insert a description of internally-recorded parameters of frame X
3332 into the parameter alist *ALISTPTR that is to be given to the user.
3333 Only parameters that are specific to the X window system
3334 and whose values are not correctly recorded in the frame's
3335 param_alist need to be considered here. */
3338 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3342 char buf
[INT_BUFSIZE_BOUND (w
)];
3344 /* Represent negative positions (off the top or left screen edge)
3345 in a way that Fmodify_frame_parameters will understand correctly. */
3346 XSETINT (tem
, f
->left_pos
);
3347 if (f
->left_pos
>= 0)
3348 store_in_alist (alistptr
, Qleft
, tem
);
3350 store_in_alist (alistptr
, Qleft
, list2 (Qplus
, tem
));
3352 XSETINT (tem
, f
->top_pos
);
3353 if (f
->top_pos
>= 0)
3354 store_in_alist (alistptr
, Qtop
, tem
);
3356 store_in_alist (alistptr
, Qtop
, list2 (Qplus
, tem
));
3358 store_in_alist (alistptr
, Qborder_width
,
3359 make_number (f
->border_width
));
3360 store_in_alist (alistptr
, Qinternal_border_width
,
3361 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3362 store_in_alist (alistptr
, Qright_divider_width
,
3363 make_number (FRAME_RIGHT_DIVIDER_WIDTH (f
)));
3364 store_in_alist (alistptr
, Qbottom_divider_width
,
3365 make_number (FRAME_BOTTOM_DIVIDER_WIDTH (f
)));
3366 store_in_alist (alistptr
, Qleft_fringe
,
3367 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3368 store_in_alist (alistptr
, Qright_fringe
,
3369 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3370 store_in_alist (alistptr
, Qscroll_bar_width
,
3371 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3373 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3374 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3375 /* nil means "use default width"
3376 for non-toolkit scroll bar.
3377 ruler-mode.el depends on this. */
3379 store_in_alist (alistptr
, Qscroll_bar_height
,
3380 (! FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)
3382 : FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) > 0
3383 ? make_number (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
3384 /* nil means "use default height"
3385 for non-toolkit scroll bar. */
3387 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
3388 MS-Windows it returns a value whose type is HANDLE, which is
3389 actually a pointer. Explicit casting avoids compiler
3391 w
= (uintptr_t) FRAME_X_WINDOW (f
);
3392 store_in_alist (alistptr
, Qwindow_id
,
3393 make_formatted_string (buf
, "%"pMu
, w
));
3394 #ifdef HAVE_X_WINDOWS
3395 #ifdef USE_X_TOOLKIT
3396 /* Tooltip frame may not have this widget. */
3397 if (FRAME_X_OUTPUT (f
)->widget
)
3399 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
3400 store_in_alist (alistptr
, Qouter_window_id
,
3401 make_formatted_string (buf
, "%"pMu
, w
));
3403 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3404 store_in_alist (alistptr
, Qvisibility
,
3405 (FRAME_VISIBLE_P (f
) ? Qt
3406 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3407 store_in_alist (alistptr
, Qdisplay
,
3408 XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
));
3410 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_DISPLAY_INFO (f
)->root_window
)
3413 tem
= make_natnum ((uintptr_t) FRAME_X_OUTPUT (f
)->parent_desc
);
3414 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3415 store_in_alist (alistptr
, Qparent_id
, tem
);
3416 store_in_alist (alistptr
, Qtool_bar_position
, FRAME_TOOL_BAR_POSITION (f
));
3420 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3421 the previous value of that parameter, NEW_VALUE is the new value. */
3424 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3426 if (NILP (new_value
))
3427 f
->want_fullscreen
= FULLSCREEN_NONE
;
3428 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3429 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3430 else if (EQ (new_value
, Qfullwidth
))
3431 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3432 else if (EQ (new_value
, Qfullheight
))
3433 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3434 else if (EQ (new_value
, Qmaximized
))
3435 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3437 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3438 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3442 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3443 the previous value of that parameter, NEW_VALUE is the new value. */
3446 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3448 if (NILP (new_value
))
3449 f
->extra_line_spacing
= 0;
3450 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
3451 f
->extra_line_spacing
= XFASTINT (new_value
);
3452 else if (FLOATP (new_value
))
3454 int new_spacing
= XFLOAT_DATA (new_value
) * FRAME_LINE_HEIGHT (f
) + 0.5;
3456 if (new_spacing
>= 0)
3457 f
->extra_line_spacing
= new_spacing
;
3459 signal_error ("Invalid line-spacing", new_value
);
3462 signal_error ("Invalid line-spacing", new_value
);
3463 if (FRAME_VISIBLE_P (f
))
3468 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3469 the previous value of that parameter, NEW_VALUE is the new value. */
3472 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3474 Lisp_Object bgcolor
;
3476 if (NILP (new_value
))
3478 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3479 /* The value 0.4545 is the normal viewing gamma. */
3480 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3482 signal_error ("Invalid screen-gamma", new_value
);
3484 /* Apply the new gamma value to the frame background. */
3485 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3486 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3488 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3489 if (NATNUMP (parm_index
)
3490 && XFASTINT (parm_index
) < ARRAYELTS (frame_parms
)
3491 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3492 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3496 Fclear_face_cache (Qnil
);
3501 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3503 Lisp_Object font_object
;
3505 #ifdef HAVE_X_WINDOWS
3506 Lisp_Object font_param
= arg
;
3509 /* Set the frame parameter back to the old value because we may
3510 fail to use ARG as the new parameter value. */
3511 store_frame_param (f
, Qfont
, oldval
);
3513 /* ARG is a fontset name, a font name, a cons of fontset name and a
3514 font object, or a font object. In the last case, this function
3518 fontset
= fs_query_fontset (arg
, 0);
3521 font_object
= font_open_by_name (f
, arg
);
3522 if (NILP (font_object
))
3523 error ("Font `%s' is not defined", SSDATA (arg
));
3524 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3526 else if (fontset
> 0)
3528 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
3529 if (NILP (font_object
))
3530 error ("Font `%s' is not defined", SDATA (arg
));
3531 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3534 error ("The default fontset can't be used for a frame font");
3536 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3538 /* This is the case that the ASCII font of F's fontset XCAR
3539 (arg) is changed to the font XCDR (arg) by
3540 `set-fontset-font'. */
3541 fontset
= fs_query_fontset (XCAR (arg
), 0);
3543 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3544 font_object
= XCDR (arg
);
3545 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3546 #ifdef HAVE_X_WINDOWS
3547 font_param
= Ffont_get (font_object
, QCname
);
3550 else if (FONT_OBJECT_P (arg
))
3553 #ifdef HAVE_X_WINDOWS
3554 font_param
= Ffont_get (font_object
, QCname
);
3556 /* This is to store the XLFD font name in the frame parameter for
3557 backward compatibility. We should store the font-object
3558 itself in the future. */
3559 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3560 fontset
= FRAME_FONTSET (f
);
3561 /* Check if we can use the current fontset. If not, set FONTSET
3562 to -1 to generate a new fontset from FONT-OBJECT. */
3565 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3566 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3569 signal_error ("Invalid font name", ascii_font
);
3571 if (! font_match_p (spec
, font_object
))
3576 signal_error ("Invalid font", arg
);
3578 if (! NILP (Fequal (font_object
, oldval
)))
3581 x_new_font (f
, font_object
, fontset
);
3582 store_frame_param (f
, Qfont
, arg
);
3583 #ifdef HAVE_X_WINDOWS
3584 store_frame_param (f
, Qfont_param
, font_param
);
3586 /* Recalculate toolbar height. */
3587 f
->n_tool_bar_rows
= 0;
3589 /* Ensure we redraw it. */
3590 clear_current_matrices (f
);
3592 /* Attempt to hunt down bug#16028. */
3593 SET_FRAME_GARBAGED (f
);
3595 recompute_basic_faces (f
);
3597 do_pending_window_change (0);
3599 /* We used to call face-set-after-frame-default here, but it leads to
3600 recursive calls (since that function can set the `default' face's
3601 font which in turns changes the frame's `font' parameter).
3602 Also I don't know what this call is meant to do, but it seems the
3603 wrong way to do it anyway (it does a lot more work than what seems
3604 reasonable in response to a change to `font'). */
3609 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3611 if (! NILP (new_value
)
3612 && !CONSP (new_value
))
3616 CHECK_STRING (new_value
);
3617 p0
= p1
= SSDATA (new_value
);
3621 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
3623 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3629 while ((c
= *++p1
) && c_isspace (c
));
3633 new_value
= Fnreverse (new_value
);
3636 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3640 free_all_realized_faces (Qnil
);
3642 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3643 if (NILP (new_value
))
3645 if (NILP (old_value
))
3646 error ("No font backend available");
3647 font_update_drivers (f
, old_value
);
3648 error ("None of specified font backends are available");
3650 store_frame_param (f
, Qfont_backend
, new_value
);
3656 XSETFRAME (frame
, f
);
3657 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3658 ++face_change_count
;
3659 windows_or_buffers_changed
= 18;
3664 x_set_left_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3666 int unit
= FRAME_COLUMN_WIDTH (f
);
3667 int old_width
= FRAME_LEFT_FRINGE_WIDTH (f
);
3670 new_width
= (RANGED_INTEGERP (-INT_MAX
, new_value
, INT_MAX
)
3671 ? eabs (XINT (new_value
)) : 8);
3673 if (new_width
!= old_width
)
3675 FRAME_LEFT_FRINGE_WIDTH (f
) = new_width
;
3676 FRAME_FRINGE_COLS (f
) /* Round up. */
3677 = (new_width
+ FRAME_RIGHT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
3679 if (FRAME_X_WINDOW (f
) != 0)
3680 adjust_frame_size (f
, -1, -1, 3, 0, Qleft_fringe
);
3682 SET_FRAME_GARBAGED (f
);
3688 x_set_right_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3690 int unit
= FRAME_COLUMN_WIDTH (f
);
3691 int old_width
= FRAME_RIGHT_FRINGE_WIDTH (f
);
3694 new_width
= (RANGED_INTEGERP (-INT_MAX
, new_value
, INT_MAX
)
3695 ? eabs (XINT (new_value
)) : 8);
3697 if (new_width
!= old_width
)
3699 FRAME_RIGHT_FRINGE_WIDTH (f
) = new_width
;
3700 FRAME_FRINGE_COLS (f
) /* Round up. */
3701 = (new_width
+ FRAME_LEFT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
3703 if (FRAME_X_WINDOW (f
) != 0)
3704 adjust_frame_size (f
, -1, -1, 3, 0, Qright_fringe
);
3706 SET_FRAME_GARBAGED (f
);
3712 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3714 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3716 if (XINT (arg
) == f
->border_width
)
3719 if (FRAME_X_WINDOW (f
) != 0)
3720 error ("Cannot change the border width of a frame");
3722 f
->border_width
= XINT (arg
);
3726 x_set_right_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3728 int old
= FRAME_RIGHT_DIVIDER_WIDTH (f
);
3730 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3731 FRAME_RIGHT_DIVIDER_WIDTH (f
) = XINT (arg
);
3732 if (FRAME_RIGHT_DIVIDER_WIDTH (f
) < 0)
3733 FRAME_RIGHT_DIVIDER_WIDTH (f
) = 0;
3734 if (FRAME_RIGHT_DIVIDER_WIDTH (f
) != old
)
3736 adjust_frame_size (f
, -1, -1, 4, 0, Qright_divider_width
);
3737 adjust_frame_glyphs (f
);
3738 SET_FRAME_GARBAGED (f
);
3744 x_set_bottom_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3746 int old
= FRAME_BOTTOM_DIVIDER_WIDTH (f
);
3748 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3749 FRAME_BOTTOM_DIVIDER_WIDTH (f
) = XINT (arg
);
3750 if (FRAME_BOTTOM_DIVIDER_WIDTH (f
) < 0)
3751 FRAME_BOTTOM_DIVIDER_WIDTH (f
) = 0;
3752 if (FRAME_BOTTOM_DIVIDER_WIDTH (f
) != old
)
3754 adjust_frame_size (f
, -1, -1, 4, 0, Qbottom_divider_width
);
3755 adjust_frame_glyphs (f
);
3756 SET_FRAME_GARBAGED (f
);
3761 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3764 XSETFRAME (frame
, f
);
3767 Fmake_frame_invisible (frame
, Qt
);
3768 else if (EQ (value
, Qicon
))
3769 Ficonify_frame (frame
);
3771 Fmake_frame_visible (frame
);
3775 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3777 f
->auto_raise
= !EQ (Qnil
, arg
);
3781 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3783 f
->auto_lower
= !EQ (Qnil
, arg
);
3787 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3789 f
->no_split
= !NILP (arg
);
3793 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3795 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3796 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3797 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3798 || (!NILP (arg
) && !FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3800 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3802 ? vertical_scroll_bar_none
3804 ? vertical_scroll_bar_left
3806 ? vertical_scroll_bar_right
3807 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3808 ? vertical_scroll_bar_left
3809 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3810 ? vertical_scroll_bar_right
3811 : vertical_scroll_bar_none
);
3813 /* We set this parameter before creating the X window for the
3814 frame, so we can get the geometry right from the start.
3815 However, if the window hasn't been created yet, we shouldn't
3816 call x_set_window_size. */
3817 if (FRAME_X_WINDOW (f
))
3818 adjust_frame_size (f
, -1, -1, 3, 0, Qvertical_scroll_bars
);
3820 SET_FRAME_GARBAGED (f
);
3825 x_set_horizontal_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3827 #if USE_HORIZONTAL_SCROLL_BARS
3828 if ((NILP (arg
) && FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
))
3829 || (!NILP (arg
) && !FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)))
3831 f
->horizontal_scroll_bars
= NILP (arg
) ? false : true;
3833 /* We set this parameter before creating the X window for the
3834 frame, so we can get the geometry right from the start.
3835 However, if the window hasn't been created yet, we shouldn't
3836 call x_set_window_size. */
3837 if (FRAME_X_WINDOW (f
))
3838 adjust_frame_size (f
, -1, -1, 3, 0, Qhorizontal_scroll_bars
);
3840 SET_FRAME_GARBAGED (f
);
3846 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3848 int unit
= FRAME_COLUMN_WIDTH (f
);
3852 x_set_scroll_bar_default_width (f
);
3854 if (FRAME_X_WINDOW (f
))
3855 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_width
);
3857 SET_FRAME_GARBAGED (f
);
3859 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3860 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3862 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3863 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + unit
- 1) / unit
;
3864 if (FRAME_X_WINDOW (f
))
3865 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_width
);
3867 SET_FRAME_GARBAGED (f
);
3870 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3871 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3875 x_set_scroll_bar_height (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3877 #if USE_HORIZONTAL_SCROLL_BARS
3878 int unit
= FRAME_LINE_HEIGHT (f
);
3882 x_set_scroll_bar_default_height (f
);
3884 if (FRAME_X_WINDOW (f
))
3885 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_height
);
3887 SET_FRAME_GARBAGED (f
);
3889 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3890 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
3892 FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) = XFASTINT (arg
);
3893 FRAME_CONFIG_SCROLL_BAR_LINES (f
) = (XFASTINT (arg
) + unit
- 1) / unit
;
3894 if (FRAME_X_WINDOW (f
))
3895 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_height
);
3897 SET_FRAME_GARBAGED (f
);
3900 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.vpos
= 0;
3901 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.y
= 0;
3906 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3913 for (i
= 0; i
< 2; i
++)
3926 else if (FLOATP (item
))
3928 alpha
= XFLOAT_DATA (item
);
3929 if (! (0 <= alpha
&& alpha
<= 1.0))
3930 args_out_of_range (make_float (0.0), make_float (1.0));
3932 else if (INTEGERP (item
))
3934 EMACS_INT ialpha
= XINT (item
);
3935 if (! (0 <= ialpha
&& alpha
<= 100))
3936 args_out_of_range (make_number (0), make_number (100));
3937 alpha
= ialpha
/ 100.0;
3940 wrong_type_argument (Qnumberp
, item
);
3944 for (i
= 0; i
< 2; i
++)
3945 f
->alpha
[i
] = newval
[i
];
3947 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3949 x_set_frame_alpha (f
);
3958 /* Non-zero if mouse is grabbed on DPYINFO
3959 and we know the frame where it is. */
3961 bool x_mouse_grabbed (Display_Info
*dpyinfo
)
3963 return (dpyinfo
->grabbed
3964 && dpyinfo
->last_mouse_frame
3965 && FRAME_LIVE_P (dpyinfo
->last_mouse_frame
));
3968 /* Re-highlight something with mouse-face properties
3969 on DPYINFO using saved frame and mouse position. */
3972 x_redo_mouse_highlight (Display_Info
*dpyinfo
)
3974 if (dpyinfo
->last_mouse_motion_frame
3975 && FRAME_LIVE_P (dpyinfo
->last_mouse_motion_frame
))
3976 note_mouse_highlight (dpyinfo
->last_mouse_motion_frame
,
3977 dpyinfo
->last_mouse_motion_x
,
3978 dpyinfo
->last_mouse_motion_y
);
3981 #endif /* HAVE_NS */
3983 /* Subroutines of creating an X frame. */
3985 /* Make sure that Vx_resource_name is set to a reasonable value.
3986 Fix it up, or set it to `emacs' if it is too hopeless. */
3989 validate_x_resource_name (void)
3992 /* Number of valid characters in the resource name. */
3993 ptrdiff_t good_count
= 0;
3994 /* Number of invalid characters in the resource name. */
3995 ptrdiff_t bad_count
= 0;
3999 if (!STRINGP (Vx_resource_class
))
4000 Vx_resource_class
= build_string (EMACS_CLASS
);
4002 if (STRINGP (Vx_resource_name
))
4004 unsigned char *p
= SDATA (Vx_resource_name
);
4006 len
= SBYTES (Vx_resource_name
);
4008 /* Only letters, digits, - and _ are valid in resource names.
4009 Count the valid characters and count the invalid ones. */
4010 for (i
= 0; i
< len
; i
++)
4013 if (! ((c
>= 'a' && c
<= 'z')
4014 || (c
>= 'A' && c
<= 'Z')
4015 || (c
>= '0' && c
<= '9')
4016 || c
== '-' || c
== '_'))
4023 /* Not a string => completely invalid. */
4024 bad_count
= 5, good_count
= 0;
4026 /* If name is valid already, return. */
4030 /* If name is entirely invalid, or nearly so, or is so implausibly
4031 large that alloca might not work, use `emacs'. */
4032 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
4034 Vx_resource_name
= build_string ("emacs");
4038 /* Name is partly valid. Copy it and replace the invalid characters
4039 with underscores. */
4041 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
4043 for (i
= 0; i
< len
; i
++)
4045 int c
= SREF (new, i
);
4046 if (! ((c
>= 'a' && c
<= 'z')
4047 || (c
>= 'A' && c
<= 'Z')
4048 || (c
>= '0' && c
<= '9')
4049 || c
== '-' || c
== '_'))
4054 /* Get specified attribute from resource database RDB.
4055 See Fx_get_resource below for other parameters. */
4058 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
4060 CHECK_STRING (attribute
);
4061 CHECK_STRING (class);
4063 if (!NILP (component
))
4064 CHECK_STRING (component
);
4065 if (!NILP (subclass
))
4066 CHECK_STRING (subclass
);
4067 if (NILP (component
) != NILP (subclass
))
4068 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
4070 validate_x_resource_name ();
4072 /* Allocate space for the components, the dots which separate them,
4073 and the final '\0'. Make them big enough for the worst case. */
4074 ptrdiff_t name_keysize
= (SBYTES (Vx_resource_name
)
4075 + (STRINGP (component
)
4076 ? SBYTES (component
) : 0)
4077 + SBYTES (attribute
)
4080 ptrdiff_t class_keysize
= (SBYTES (Vx_resource_class
)
4082 + (STRINGP (subclass
)
4083 ? SBYTES (subclass
) : 0)
4086 char *name_key
= SAFE_ALLOCA (name_keysize
+ class_keysize
);
4087 char *class_key
= name_key
+ name_keysize
;
4089 /* Start with emacs.FRAMENAME for the name (the specific one)
4090 and with `Emacs' for the class key (the general one). */
4091 char *nz
= lispstpcpy (name_key
, Vx_resource_name
);
4092 char *cz
= lispstpcpy (class_key
, Vx_resource_class
);
4095 cz
= lispstpcpy (cz
, class);
4097 if (!NILP (component
))
4100 lispstpcpy (cz
, subclass
);
4103 nz
= lispstpcpy (nz
, component
);
4107 lispstpcpy (nz
, attribute
);
4109 char *value
= x_get_string_resource (rdb
, name_key
, class_key
);
4112 if (value
&& *value
)
4113 return build_string (value
);
4119 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
4120 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
4121 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
4122 class, where INSTANCE is the name under which Emacs was invoked, or
4123 the name specified by the `-name' or `-rn' command-line arguments.
4125 The optional arguments COMPONENT and SUBCLASS add to the key and the
4126 class, respectively. You must specify both of them or neither.
4127 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
4128 and the class is `Emacs.CLASS.SUBCLASS'. */)
4129 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
,
4130 Lisp_Object subclass
)
4132 check_window_system (NULL
);
4134 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
4135 attribute
, class, component
, subclass
);
4138 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
4141 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
,
4142 Lisp_Object
class, Lisp_Object component
,
4143 Lisp_Object subclass
)
4145 return xrdb_get_resource (dpyinfo
->xrdb
,
4146 attribute
, class, component
, subclass
);
4149 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
4150 /* Used when C code wants a resource value. */
4151 /* Called from oldXMenu/Create.c. */
4153 x_get_resource_string (const char *attribute
, const char *class)
4156 struct frame
*sf
= SELECTED_FRAME ();
4157 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
4160 /* Allocate space for the components, the dots which separate them,
4161 and the final '\0'. */
4162 ptrdiff_t name_keysize
= invocation_namelen
+ strlen (attribute
) + 2;
4163 ptrdiff_t class_keysize
= sizeof (EMACS_CLASS
) - 1 + strlen (class) + 2;
4164 char *name_key
= SAFE_ALLOCA (name_keysize
+ class_keysize
);
4165 char *class_key
= name_key
+ name_keysize
;
4167 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
4168 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
4170 result
= x_get_string_resource (FRAME_DISPLAY_INFO (sf
)->xrdb
,
4171 name_key
, class_key
);
4177 /* Return the value of parameter PARAM.
4179 First search ALIST, then Vdefault_frame_alist, then the X defaults
4180 database, using ATTRIBUTE as the attribute name and CLASS as its class.
4182 Convert the resource to the type specified by desired_type.
4184 If no default is specified, return Qunbound. If you call
4185 x_get_arg, make sure you deal with Qunbound in a reasonable way,
4186 and don't let it get stored in any Lisp-visible variables! */
4189 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
4190 const char *attribute
, const char *class, enum resource_types type
)
4194 tem
= Fassq (param
, alist
);
4198 /* If we find this parm in ALIST, clear it out
4199 so that it won't be "left over" at the end. */
4201 XSETCAR (tem
, Qnil
);
4202 /* In case the parameter appears more than once in the alist,
4204 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
4205 if (CONSP (XCAR (tail
))
4206 && EQ (XCAR (XCAR (tail
)), param
))
4207 XSETCAR (XCAR (tail
), Qnil
);
4210 tem
= Fassq (param
, Vdefault_frame_alist
);
4212 /* If it wasn't specified in ALIST or the Lisp-level defaults,
4213 look in the X resources. */
4216 if (attribute
&& dpyinfo
)
4218 AUTO_STRING (at
, attribute
);
4219 AUTO_STRING (cl
, class);
4220 tem
= display_x_get_resource (dpyinfo
, at
, cl
, Qnil
, Qnil
);
4227 case RES_TYPE_NUMBER
:
4228 return make_number (atoi (SSDATA (tem
)));
4230 case RES_TYPE_BOOLEAN_NUMBER
:
4231 if (!strcmp (SSDATA (tem
), "on")
4232 || !strcmp (SSDATA (tem
), "true"))
4233 return make_number (1);
4234 return make_number (atoi (SSDATA (tem
)));
4237 case RES_TYPE_FLOAT
:
4238 return make_float (atof (SSDATA (tem
)));
4240 case RES_TYPE_BOOLEAN
:
4241 tem
= Fdowncase (tem
);
4242 if (!strcmp (SSDATA (tem
), "on")
4244 || !strcmp (SSDATA (tem
), "yes")
4246 || !strcmp (SSDATA (tem
), "true"))
4251 case RES_TYPE_STRING
:
4254 case RES_TYPE_SYMBOL
:
4255 /* As a special case, we map the values `true' and `on'
4256 to Qt, and `false' and `off' to Qnil. */
4259 lower
= Fdowncase (tem
);
4260 if (!strcmp (SSDATA (lower
), "on")
4262 || !strcmp (SSDATA (lower
), "yes")
4264 || !strcmp (SSDATA (lower
), "true"))
4266 else if (!strcmp (SSDATA (lower
), "off")
4268 || !strcmp (SSDATA (lower
), "no")
4270 || !strcmp (SSDATA (lower
), "false"))
4273 return Fintern (tem
, Qnil
);
4287 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
4288 const char *attribute
, const char *class,
4289 enum resource_types type
)
4291 return x_get_arg (FRAME_DISPLAY_INFO (f
),
4292 alist
, param
, attribute
, class, type
);
4295 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
4298 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
4300 const char *attribute
, const char *class,
4301 enum resource_types type
)
4305 value
= x_get_arg (FRAME_DISPLAY_INFO (f
), alist
, param
,
4306 attribute
, class, type
);
4307 if (! NILP (value
) && ! EQ (value
, Qunbound
))
4308 store_frame_param (f
, param
, value
);
4314 /* Record in frame F the specified or default value according to ALIST
4315 of the parameter named PROP (a Lisp symbol).
4316 If no value is specified for PROP, look for an X default for XPROP
4317 on the frame named NAME.
4318 If that is not found either, use the value DEFLT. */
4321 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
4322 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
4323 enum resource_types type
)
4327 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
4328 if (EQ (tem
, Qunbound
))
4330 AUTO_FRAME_ARG (arg
, prop
, tem
);
4331 x_set_frame_parameters (f
, arg
);
4336 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
4339 * XParseGeometry parses strings of the form
4340 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
4341 * width, height, xoffset, and yoffset are unsigned integers.
4342 * Example: "=80x24+300-49"
4343 * The equal sign is optional.
4344 * It returns a bitmask that indicates which of the four values
4345 * were actually found in the string. For each value found,
4346 * the corresponding argument is updated; for each value
4347 * not found, the corresponding argument is left unchanged.
4351 XParseGeometry (char *string
,
4353 unsigned int *width
, unsigned int *height
)
4357 unsigned long tempWidth
, tempHeight
;
4358 long int tempX
, tempY
;
4359 char *nextCharacter
;
4361 if (string
== NULL
|| *string
== '\0')
4364 string
++; /* ignore possible '=' at beg of geometry spec */
4367 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
4369 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
4370 if (strind
== nextCharacter
)
4372 strind
= nextCharacter
;
4376 if (*strind
== 'x' || *strind
== 'X')
4379 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
4380 if (strind
== nextCharacter
)
4382 strind
= nextCharacter
;
4383 mask
|= HeightValue
;
4386 if (*strind
== '+' || *strind
== '-')
4390 tempX
= strtol (strind
, &nextCharacter
, 10);
4391 if (strind
== nextCharacter
)
4393 strind
= nextCharacter
;
4395 if (*strind
== '+' || *strind
== '-')
4399 tempY
= strtol (strind
, &nextCharacter
, 10);
4400 if (strind
== nextCharacter
)
4402 strind
= nextCharacter
;
4407 /* If strind isn't at the end of the string then it's an invalid
4408 geometry specification. */
4410 if (*strind
!= '\0')
4414 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
4416 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
4417 if (mask
& WidthValue
)
4418 *width
= min (tempWidth
, UINT_MAX
);
4419 if (mask
& HeightValue
)
4420 *height
= min (tempHeight
, UINT_MAX
);
4424 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
4427 /* NS used to define x-parse-geometry in ns-win.el, but that confused
4428 make-docfile: the documentation string in ns-win.el was used for
4429 x-parse-geometry even in non-NS builds.
4431 With two definitions of x-parse-geometry in this file, various
4432 things still get confused (eg M-x apropos documentation), so that
4433 it is best if the two definitions just share the same doc-string.
4435 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4436 doc
: /* Parse a display geometry string STRING.
4437 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4438 The properties returned may include `top', `left', `height', and `width'.
4439 For X, the value of `left' or `top' may be an integer,
4440 or a list (+ N) meaning N pixels relative to top/left corner,
4441 or a list (- N) meaning -N pixels relative to bottom/right corner.
4442 On Nextstep, this just calls `ns-parse-geometry'. */)
4443 (Lisp_Object string
)
4446 unsigned int width
, height
;
4449 CHECK_STRING (string
);
4452 if (strchr (SSDATA (string
), ' ') != NULL
)
4453 return call1 (Qns_parse_geometry
, string
);
4455 geometry
= XParseGeometry (SSDATA (string
),
4456 &x
, &y
, &width
, &height
);
4458 if (geometry
& XValue
)
4460 Lisp_Object element
;
4462 if (x
>= 0 && (geometry
& XNegative
))
4463 element
= list3 (Qleft
, Qminus
, make_number (-x
));
4464 else if (x
< 0 && ! (geometry
& XNegative
))
4465 element
= list3 (Qleft
, Qplus
, make_number (x
));
4467 element
= Fcons (Qleft
, make_number (x
));
4468 result
= Fcons (element
, result
);
4471 if (geometry
& YValue
)
4473 Lisp_Object element
;
4475 if (y
>= 0 && (geometry
& YNegative
))
4476 element
= list3 (Qtop
, Qminus
, make_number (-y
));
4477 else if (y
< 0 && ! (geometry
& YNegative
))
4478 element
= list3 (Qtop
, Qplus
, make_number (y
));
4480 element
= Fcons (Qtop
, make_number (y
));
4481 result
= Fcons (element
, result
);
4484 if (geometry
& WidthValue
)
4485 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
4486 if (geometry
& HeightValue
)
4487 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
4493 /* Calculate the desired size and position of frame F.
4494 Return the flags saying which aspects were specified.
4496 Also set the win_gravity and size_hint_flags of F.
4498 Adjust height for toolbar if TOOLBAR_P is 1.
4500 This function does not make the coordinates positive. */
4502 #define DEFAULT_ROWS 35
4503 #define DEFAULT_COLS 80
4506 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, bool toolbar_p
)
4508 Lisp_Object height
, width
, user_size
, top
, left
, user_position
;
4509 long window_prompting
= 0;
4510 Display_Info
*dpyinfo
= FRAME_DISPLAY_INFO (f
);
4512 /* Default values if we fall through.
4513 Actually, if that happens we should get
4514 window manager prompting. */
4515 SET_FRAME_WIDTH (f
, DEFAULT_COLS
* FRAME_COLUMN_WIDTH (f
));
4516 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4517 SET_FRAME_HEIGHT (f
, DEFAULT_ROWS
* FRAME_LINE_HEIGHT (f
));
4518 SET_FRAME_LINES (f
, DEFAULT_ROWS
);
4520 /* Window managers expect that if program-specified
4521 positions are not (0,0), they're intentional, not defaults. */
4525 /* Ensure that earlier new_width and new_height settings won't
4526 override what we specify below. */
4527 f
->new_width
= f
->new_height
= 0;
4529 height
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4530 width
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4531 if (!EQ (width
, Qunbound
) || !EQ (height
, Qunbound
))
4533 if (!EQ (width
, Qunbound
))
4535 CHECK_NUMBER (width
);
4536 if (! (0 <= XINT (width
) && XINT (width
) <= INT_MAX
))
4537 xsignal1 (Qargs_out_of_range
, width
);
4539 SET_FRAME_WIDTH (f
, XINT (width
) * FRAME_COLUMN_WIDTH (f
));
4542 if (!EQ (height
, Qunbound
))
4544 CHECK_NUMBER (height
);
4545 if (! (0 <= XINT (height
) && XINT (height
) <= INT_MAX
))
4546 xsignal1 (Qargs_out_of_range
, height
);
4548 SET_FRAME_HEIGHT (f
, XINT (height
) * FRAME_LINE_HEIGHT (f
));
4551 user_size
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4552 if (!NILP (user_size
) && !EQ (user_size
, Qunbound
))
4553 window_prompting
|= USSize
;
4555 window_prompting
|= PSize
;
4558 /* Add a tool bar height to the initial frame height so that the user
4559 gets a text display area of the size he specified with -g or via
4560 .Xdefaults. Later changes of the tool bar height don't change the
4561 frame size. This is done so that users can create tall Emacs
4562 frames without having to guess how tall the tool bar will get. */
4563 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4567 relief
= (tool_bar_button_relief
>= 0
4568 ? tool_bar_button_relief
4569 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4571 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
4572 margin
= XFASTINT (Vtool_bar_button_margin
);
4573 else if (CONSP (Vtool_bar_button_margin
)
4574 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
4575 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4579 FRAME_TOOL_BAR_HEIGHT (f
)
4580 = DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4581 Vframe_initial_frame_tool_bar_height
= make_number (FRAME_TOOL_BAR_HEIGHT (f
));
4584 top
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4585 left
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4586 user_position
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4587 if (! EQ (top
, Qunbound
) || ! EQ (left
, Qunbound
))
4589 if (EQ (top
, Qminus
))
4592 window_prompting
|= YNegative
;
4594 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
4595 && CONSP (XCDR (top
))
4596 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
4598 f
->top_pos
= - XINT (XCAR (XCDR (top
)));
4599 window_prompting
|= YNegative
;
4601 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
4602 && CONSP (XCDR (top
))
4603 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
4605 f
->top_pos
= XINT (XCAR (XCDR (top
)));
4607 else if (EQ (top
, Qunbound
))
4611 CHECK_TYPE_RANGED_INTEGER (int, top
);
4612 f
->top_pos
= XINT (top
);
4614 window_prompting
|= YNegative
;
4617 if (EQ (left
, Qminus
))
4620 window_prompting
|= XNegative
;
4622 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
4623 && CONSP (XCDR (left
))
4624 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
4626 f
->left_pos
= - XINT (XCAR (XCDR (left
)));
4627 window_prompting
|= XNegative
;
4629 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
4630 && CONSP (XCDR (left
))
4631 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
4633 f
->left_pos
= XINT (XCAR (XCDR (left
)));
4635 else if (EQ (left
, Qunbound
))
4639 CHECK_TYPE_RANGED_INTEGER (int, left
);
4640 f
->left_pos
= XINT (left
);
4641 if (f
->left_pos
< 0)
4642 window_prompting
|= XNegative
;
4645 if (!NILP (user_position
) && ! EQ (user_position
, Qunbound
))
4646 window_prompting
|= USPosition
;
4648 window_prompting
|= PPosition
;
4651 if (window_prompting
& XNegative
)
4653 if (window_prompting
& YNegative
)
4654 f
->win_gravity
= SouthEastGravity
;
4656 f
->win_gravity
= NorthEastGravity
;
4660 if (window_prompting
& YNegative
)
4661 f
->win_gravity
= SouthWestGravity
;
4663 f
->win_gravity
= NorthWestGravity
;
4666 f
->size_hint_flags
= window_prompting
;
4668 return window_prompting
;
4673 #endif /* HAVE_WINDOW_SYSTEM */
4676 frame_make_pointer_invisible (struct frame
*f
)
4678 if (! NILP (Vmake_pointer_invisible
))
4680 if (f
&& FRAME_LIVE_P (f
) && !f
->pointer_invisible
4681 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4684 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4685 f
->pointer_invisible
= 1;
4691 frame_make_pointer_visible (struct frame
*f
)
4693 /* We don't check Vmake_pointer_invisible here in case the
4694 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4695 if (f
&& FRAME_LIVE_P (f
) && f
->pointer_invisible
&& f
->mouse_moved
4696 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4698 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4699 f
->pointer_invisible
= 0;
4703 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4704 Sframe_pointer_visible_p
, 0, 1, 0,
4705 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4706 Otherwise it returns nil. FRAME omitted or nil means the
4707 selected frame. This is useful when `make-pointer-invisible' is set. */)
4710 return decode_any_frame (frame
)->pointer_invisible
? Qnil
: Qt
;
4715 /***********************************************************************
4717 ***********************************************************************/
4719 #ifdef HAVE_WINDOW_SYSTEM
4721 # if (defined HAVE_NS \
4722 || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR)))
4724 free_monitors (struct MonitorInfo
*monitors
, int n_monitors
)
4727 for (i
= 0; i
< n_monitors
; ++i
)
4728 xfree (monitors
[i
].name
);
4734 make_monitor_attribute_list (struct MonitorInfo
*monitors
,
4736 int primary_monitor
,
4737 Lisp_Object monitor_frames
,
4740 Lisp_Object attributes_list
= Qnil
;
4741 Lisp_Object primary_monitor_attributes
= Qnil
;
4744 for (i
= 0; i
< n_monitors
; ++i
)
4746 Lisp_Object geometry
, workarea
, attributes
= Qnil
;
4747 struct MonitorInfo
*mi
= &monitors
[i
];
4749 if (mi
->geom
.width
== 0) continue;
4751 workarea
= list4i (mi
->work
.x
, mi
->work
.y
,
4752 mi
->work
.width
, mi
->work
.height
);
4753 geometry
= list4i (mi
->geom
.x
, mi
->geom
.y
,
4754 mi
->geom
.width
, mi
->geom
.height
);
4755 attributes
= Fcons (Fcons (Qsource
, build_string (source
)),
4757 attributes
= Fcons (Fcons (Qframes
, AREF (monitor_frames
, i
)),
4759 attributes
= Fcons (Fcons (Qmm_size
,
4760 list2i (mi
->mm_width
, mi
->mm_height
)),
4762 attributes
= Fcons (Fcons (Qworkarea
, workarea
), attributes
);
4763 attributes
= Fcons (Fcons (Qgeometry
, geometry
), attributes
);
4765 attributes
= Fcons (Fcons (Qname
, make_string (mi
->name
,
4766 strlen (mi
->name
))),
4769 if (i
== primary_monitor
)
4770 primary_monitor_attributes
= attributes
;
4772 attributes_list
= Fcons (attributes
, attributes_list
);
4775 if (!NILP (primary_monitor_attributes
))
4776 attributes_list
= Fcons (primary_monitor_attributes
, attributes_list
);
4777 return attributes_list
;
4780 #endif /* HAVE_WINDOW_SYSTEM */
4783 /***********************************************************************
4785 ***********************************************************************/
4788 syms_of_frame (void)
4790 DEFSYM (Qframep
, "framep");
4791 DEFSYM (Qframe_live_p
, "frame-live-p");
4792 DEFSYM (Qframe_windows_min_size
, "frame-windows-min-size");
4793 DEFSYM (Qexplicit_name
, "explicit-name");
4794 DEFSYM (Qheight
, "height");
4795 DEFSYM (Qicon
, "icon");
4796 DEFSYM (Qminibuffer
, "minibuffer");
4797 DEFSYM (Qmodeline
, "modeline");
4798 DEFSYM (Qonly
, "only");
4799 DEFSYM (Qnone
, "none");
4800 DEFSYM (Qwidth
, "width");
4801 DEFSYM (Qgeometry
, "geometry");
4802 DEFSYM (Qicon_left
, "icon-left");
4803 DEFSYM (Qicon_top
, "icon-top");
4804 DEFSYM (Qtooltip
, "tooltip");
4805 DEFSYM (Quser_position
, "user-position");
4806 DEFSYM (Quser_size
, "user-size");
4807 DEFSYM (Qwindow_id
, "window-id");
4808 #ifdef HAVE_X_WINDOWS
4809 DEFSYM (Qouter_window_id
, "outer-window-id");
4811 DEFSYM (Qparent_id
, "parent-id");
4813 DEFSYM (Qw32
, "w32");
4816 DEFSYM (Qvisible
, "visible");
4817 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4818 DEFSYM (Qbuffer_list
, "buffer-list");
4819 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4820 DEFSYM (Qdisplay_type
, "display-type");
4821 DEFSYM (Qbackground_mode
, "background-mode");
4822 DEFSYM (Qnoelisp
, "noelisp");
4823 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4824 DEFSYM (Qtty
, "tty");
4825 DEFSYM (Qtty_type
, "tty-type");
4827 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4829 DEFSYM (Qfullwidth
, "fullwidth");
4830 DEFSYM (Qfullheight
, "fullheight");
4831 DEFSYM (Qfullboth
, "fullboth");
4832 DEFSYM (Qmaximized
, "maximized");
4833 DEFSYM (Qx_resource_name
, "x-resource-name");
4834 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4836 DEFSYM (Qterminal
, "terminal");
4838 DEFSYM (Qworkarea
, "workarea");
4839 DEFSYM (Qmm_size
, "mm-size");
4840 DEFSYM (Qframes
, "frames");
4841 DEFSYM (Qsource
, "source");
4843 DEFSYM (Qframe_position
, "frame-position");
4844 DEFSYM (Qframe_outer_size
, "frame-outer-size");
4845 DEFSYM (Qexternal_border_size
, "external-border-size");
4846 DEFSYM (Qtitle_height
, "title-height");
4847 DEFSYM (Qmenu_bar_external
, "menu-bar-external");
4848 DEFSYM (Qmenu_bar_size
, "menu-bar-size");
4849 DEFSYM (Qtool_bar_external
, "tool-bar-external");
4850 DEFSYM (Qtool_bar_size
, "tool-bar-size");
4851 DEFSYM (Qframe_inner_size
, "frame-inner-size");
4854 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4860 for (i
= 0; i
< ARRAYELTS (frame_parms
); i
++)
4862 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4863 if (frame_parms
[i
].variable
)
4865 *frame_parms
[i
].variable
= v
;
4866 staticpro (frame_parms
[i
].variable
);
4868 Fput (v
, Qx_frame_parameter
, make_number (i
));
4872 #ifdef HAVE_WINDOW_SYSTEM
4873 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4874 doc
: /* The name Emacs uses to look up X resources.
4875 `x-get-resource' uses this as the first component of the instance name
4876 when requesting resource values.
4877 Emacs initially sets `x-resource-name' to the name under which Emacs
4878 was invoked, or to the value specified with the `-name' or `-rn'
4879 switches, if present.
4881 It may be useful to bind this variable locally around a call
4882 to `x-get-resource'. See also the variable `x-resource-class'. */);
4883 Vx_resource_name
= Qnil
;
4885 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4886 doc
: /* The class Emacs uses to look up X resources.
4887 `x-get-resource' uses this as the first component of the instance class
4888 when requesting resource values.
4890 Emacs initially sets `x-resource-class' to "Emacs".
4892 Setting this variable permanently is not a reasonable thing to do,
4893 but binding this variable locally around a call to `x-get-resource'
4894 is a reasonable practice. See also the variable `x-resource-name'. */);
4895 Vx_resource_class
= build_string (EMACS_CLASS
);
4897 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4898 doc
: /* The lower limit of the frame opacity (alpha transparency).
4899 The value should range from 0 (invisible) to 100 (completely opaque).
4900 You can also use a floating number between 0.0 and 1.0. */);
4901 Vframe_alpha_lower_limit
= make_number (20);
4904 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4905 doc
: /* Alist of default values for frame creation.
4906 These may be set in your init file, like this:
4907 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4908 These override values given in window system configuration data,
4909 including X Windows' defaults database.
4910 For values specific to the first Emacs frame, see `initial-frame-alist'.
4911 For window-system specific values, see `window-system-default-frame-alist'.
4912 For values specific to the separate minibuffer frame, see
4913 `minibuffer-frame-alist'.
4914 The `menu-bar-lines' element of the list controls whether new frames
4915 have menu bars; `menu-bar-mode' works by altering this element.
4916 Setting this variable does not affect existing frames, only new ones. */);
4917 Vdefault_frame_alist
= Qnil
;
4919 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4920 doc
: /* Default position of vertical scroll bars on this window-system. */);
4921 #ifdef HAVE_WINDOW_SYSTEM
4922 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
4923 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4925 Vdefault_frame_scroll_bars
= Qright
;
4927 Vdefault_frame_scroll_bars
= Qleft
;
4930 Vdefault_frame_scroll_bars
= Qnil
;
4933 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
4934 scroll_bar_adjust_thumb_portion_p
,
4935 doc
: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
4936 Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
4937 even if the end of the buffer is shown (i.e. overscrolling).
4938 Set to nil if you want the thumb to be at the bottom when the end of the buffer
4939 is shown. Also, the thumb fills the whole scroll bar when the entire buffer
4940 is visible. In this case you can not overscroll. */);
4941 scroll_bar_adjust_thumb_portion_p
= 1;
4943 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4944 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4946 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4947 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4948 `mouse-position' and `mouse-pixel-position' call this function, passing their
4949 usual return value as argument, and return whatever this function returns.
4950 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4951 which need to do mouse handling at the Lisp level. */);
4952 Vmouse_position_function
= Qnil
;
4954 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4955 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4956 If the value is an integer, highlighting is only shown after moving the
4957 mouse, while keyboard input turns off the highlight even when the mouse
4958 is over the clickable text. However, the mouse shape still indicates
4959 when the mouse is over clickable text. */);
4960 Vmouse_highlight
= Qt
;
4962 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4963 doc
: /* If non-nil, make pointer invisible while typing.
4964 The pointer becomes visible again when the mouse is moved. */);
4965 Vmake_pointer_invisible
= Qt
;
4967 DEFVAR_LISP ("focus-in-hook", Vfocus_in_hook
,
4968 doc
: /* Normal hook run when a frame gains input focus. */);
4969 Vfocus_in_hook
= Qnil
;
4970 DEFSYM (Qfocus_in_hook
, "focus-in-hook");
4972 DEFVAR_LISP ("focus-out-hook", Vfocus_out_hook
,
4973 doc
: /* Normal hook run when a frame loses input focus. */);
4974 Vfocus_out_hook
= Qnil
;
4975 DEFSYM (Qfocus_out_hook
, "focus-out-hook");
4977 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4978 doc
: /* Functions run before deleting a frame.
4979 The functions are run with one arg, the frame to be deleted.
4982 Note that functions in this list may be called just before the frame is
4983 actually deleted, or some time later (or even both when an earlier function
4984 in `delete-frame-functions' (indirectly) calls `delete-frame'
4986 Vdelete_frame_functions
= Qnil
;
4987 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
4989 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4990 doc
: /* Non-nil if Menu-Bar mode is enabled.
4991 See the command `menu-bar-mode' for a description of this minor mode.
4992 Setting this variable directly does not take effect;
4993 either customize it (see the info node `Easy Customization')
4994 or call the function `menu-bar-mode'. */);
4995 Vmenu_bar_mode
= Qt
;
4997 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4998 doc
: /* Non-nil if Tool-Bar mode is enabled.
4999 See the command `tool-bar-mode' for a description of this minor mode.
5000 Setting this variable directly does not take effect;
5001 either customize it (see the info node `Easy Customization')
5002 or call the function `tool-bar-mode'. */);
5003 #ifdef HAVE_WINDOW_SYSTEM
5004 Vtool_bar_mode
= Qt
;
5006 Vtool_bar_mode
= Qnil
;
5009 DEFVAR_LISP ("frame-initial-frame-tool-bar-height", Vframe_initial_frame_tool_bar_height
,
5010 doc
: /* Height of tool bar of initial frame. */);
5011 Vframe_initial_frame_tool_bar_height
= make_number (0);
5013 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
5014 doc
: /* Minibufferless frames use this frame's minibuffer.
5015 Emacs cannot create minibufferless frames unless this is set to an
5016 appropriate surrogate.
5018 Emacs consults this variable only when creating minibufferless
5019 frames; once the frame is created, it sticks with its assigned
5020 minibuffer, no matter what this variable is set to. This means that
5021 this variable doesn't necessarily say anything meaningful about the
5022 current set of frames, or where the minibuffer is currently being
5025 This variable is local to the current terminal and cannot be buffer-local. */);
5027 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
5028 doc
: /* Non-nil if window system changes focus when you move the mouse.
5029 You should set this variable to tell Emacs how your window manager
5030 handles focus, since there is no way in general for Emacs to find out
5031 automatically. See also `mouse-autoselect-window'. */);
5032 focus_follows_mouse
= 0;
5034 DEFVAR_BOOL ("frame-resize-pixelwise", frame_resize_pixelwise
,
5035 doc
: /* Non-nil means resize frames pixelwise.
5036 If this option is nil, resizing a frame rounds its sizes to the frame's
5037 current values of `frame-char-height' and `frame-char-width'. If this
5038 is non-nil, no rounding occurs, hence frame sizes can increase/decrease
5041 With some window managers you may have to set this to non-nil in order
5042 to set the size of a frame in pixels, to maximize frames or to make them
5043 fullscreen. To resize your initial frame pixelwise, set this option to
5044 a non-nil value in your init file. */);
5045 frame_resize_pixelwise
= 0;
5047 DEFVAR_LISP ("frame-inhibit-implied-resize", frame_inhibit_implied_resize
,
5048 doc
: /* Whether frames should be resized implicitly.
5049 If this option is nil, setting font, menu bar, tool bar, internal
5050 borders, fringes or scroll bars of a specific frame may resize the frame
5051 in order to preserve the number of columns or lines it displays. If
5052 this option is `t', no such resizing is done. Note that the size of
5053 fullscreen and maximized frames, the height of fullheight frames and the
5054 width of fullwidth frames never change implicitly.
5056 The value of this option can be also be a list of frame parameters. In
5057 this case, resizing is inhibited when changing a parameter that appears
5058 in that list. The parameters currently handled by this option include
5059 `font', `font-backend', `internal-border-width', `menu-bar-lines' and
5062 Changing any of the parameters `scroll-bar-width', `scroll-bar-height',
5063 `vertical-scroll-bars', `horizontal-scroll-bars', `left-fringe' and
5064 `right-fringe' is handled as if the frame contained just one live
5065 window. This means, for example, that removing vertical scroll bars on
5066 a frame containing several side by side windows will shrink the frame
5067 width by the width of one scroll bar provided this option is nil and
5068 keep it unchanged if this option is either `t' or a list containing
5069 `vertical-scroll-bars'.
5071 The default value is '(tool-bar-lines) on Lucid, Motif and Windows
5072 \(which means that adding/removing a tool bar does not change the frame
5073 height), nil on all other window systems including GTK+ (which means
5074 that changing any of the parameters listed above may change the size of
5075 the frame), and `t' otherwise (which means the frame size never changes
5076 implicitly when there's no window system support).
5078 Note that when a frame is not large enough to accommodate a change of
5079 any of the parameters listed above, Emacs may try to enlarge the frame
5080 even if this option is non-nil. */);
5081 #if defined (HAVE_WINDOW_SYSTEM)
5082 #if defined (USE_LUCID) || defined (USE_MOTIF) || defined (HAVE_NTGUI)
5083 frame_inhibit_implied_resize
= list1 (Qtool_bar_lines
);
5085 frame_inhibit_implied_resize
= Qnil
;
5088 frame_inhibit_implied_resize
= Qt
;
5091 staticpro (&Vframe_list
);
5094 defsubr (&Sframe_live_p
);
5095 defsubr (&Swindow_system
);
5096 defsubr (&Sframe_windows_min_size
);
5097 defsubr (&Smake_terminal_frame
);
5098 defsubr (&Shandle_switch_frame
);
5099 defsubr (&Sselect_frame
);
5100 defsubr (&Sselected_frame
);
5101 defsubr (&Sframe_list
);
5102 defsubr (&Snext_frame
);
5103 defsubr (&Sprevious_frame
);
5104 defsubr (&Slast_nonminibuf_frame
);
5105 defsubr (&Sdelete_frame
);
5106 defsubr (&Smouse_position
);
5107 defsubr (&Smouse_pixel_position
);
5108 defsubr (&Sset_mouse_position
);
5109 defsubr (&Sset_mouse_pixel_position
);
5111 defsubr (&Sframe_configuration
);
5112 defsubr (&Srestore_frame_configuration
);
5114 defsubr (&Smake_frame_visible
);
5115 defsubr (&Smake_frame_invisible
);
5116 defsubr (&Siconify_frame
);
5117 defsubr (&Sframe_visible_p
);
5118 defsubr (&Svisible_frame_list
);
5119 defsubr (&Sraise_frame
);
5120 defsubr (&Slower_frame
);
5121 defsubr (&Sx_focus_frame
);
5122 defsubr (&Scan_run_window_configuration_change_hook
);
5123 defsubr (&Sredirect_frame_focus
);
5124 defsubr (&Sframe_focus
);
5125 defsubr (&Sframe_parameters
);
5126 defsubr (&Sframe_parameter
);
5127 defsubr (&Smodify_frame_parameters
);
5128 defsubr (&Sframe_char_height
);
5129 defsubr (&Sframe_char_width
);
5130 defsubr (&Sframe_pixel_height
);
5131 defsubr (&Sframe_pixel_width
);
5132 defsubr (&Sframe_text_cols
);
5133 defsubr (&Sframe_text_lines
);
5134 defsubr (&Sframe_total_cols
);
5135 defsubr (&Sframe_total_lines
);
5136 defsubr (&Sframe_text_width
);
5137 defsubr (&Sframe_text_height
);
5138 defsubr (&Sscroll_bar_width
);
5139 defsubr (&Sscroll_bar_height
);
5140 defsubr (&Sfringe_width
);
5141 defsubr (&Sborder_width
);
5142 defsubr (&Sright_divider_width
);
5143 defsubr (&Sbottom_divider_width
);
5144 defsubr (&Stool_bar_pixel_width
);
5145 defsubr (&Sset_frame_height
);
5146 defsubr (&Sset_frame_width
);
5147 defsubr (&Sset_frame_size
);
5148 defsubr (&Sset_frame_position
);
5149 defsubr (&Sframe_pointer_visible_p
);
5151 #ifdef HAVE_WINDOW_SYSTEM
5152 defsubr (&Sx_get_resource
);
5153 defsubr (&Sx_parse_geometry
);