1 /* Generic frame functions.
3 Copyright (C) 1993-1995, 1997, 1999-2014 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 /* The currently selected frame. */
125 Lisp_Object selected_frame
;
127 /* A frame which is not just a mini-buffer, or NULL if there are no such
128 frames. This is usually the most recent such frame that was selected. */
130 static struct frame
*last_nonminibuf_frame
;
132 /* False means there are no visible garbaged frames. */
135 #ifdef HAVE_WINDOW_SYSTEM
136 static void x_report_frame_params (struct frame
*, Lisp_Object
*);
139 /* These setters are used only in this file, so they can be private. */
141 fset_buffer_predicate (struct frame
*f
, Lisp_Object val
)
143 f
->buffer_predicate
= val
;
146 fset_minibuffer_window (struct frame
*f
, Lisp_Object val
)
148 f
->minibuffer_window
= val
;
152 decode_live_frame (register Lisp_Object frame
)
155 frame
= selected_frame
;
156 CHECK_LIVE_FRAME (frame
);
157 return XFRAME (frame
);
161 decode_any_frame (register Lisp_Object frame
)
164 frame
= selected_frame
;
166 return XFRAME (frame
);
169 #ifdef HAVE_WINDOW_SYSTEM
172 window_system_available (struct frame
*f
)
174 return f
? FRAME_WINDOW_P (f
) || FRAME_MSDOS_P (f
) : x_display_list
!= NULL
;
177 #endif /* HAVE_WINDOW_SYSTEM */
180 decode_window_system_frame (Lisp_Object frame
)
182 struct frame
*f
= decode_live_frame (frame
);
184 if (!window_system_available (f
))
185 error ("Window system frame should be used");
190 check_window_system (struct frame
*f
)
192 if (!window_system_available (f
))
193 error (f
? "Window system frame should be used"
194 : "Window system is not in use or not initialized");
197 /* Return the value of frame parameter PROP in frame FRAME. */
200 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
202 register Lisp_Object tem
;
204 tem
= Fassq (prop
, frame
->param_alist
);
210 /* Return 1 if `frame-inhibit-implied-resize' is non-nil or fullscreen
211 state of frame F would be affected by a vertical (horizontal if
212 HORIZONTAL is true) resize. */
214 frame_inhibit_resize (struct frame
*f
, bool horizontal
)
217 return (frame_inhibit_implied_resize
218 || !NILP (get_frame_param (f
, Qfullscreen
)));
223 frame_inhibit_resize (struct frame
*f
, bool horizontal
)
225 Lisp_Object fullscreen
= get_frame_param (f
, Qfullscreen
);
227 return (frame_inhibit_implied_resize
228 || EQ (fullscreen
, Qfullboth
)
229 || EQ (fullscreen
, Qfullscreen
)
230 || EQ (fullscreen
, Qmaximized
)
231 || (horizontal
&& EQ (fullscreen
, Qfullwidth
))
232 || (!horizontal
&& EQ (fullscreen
, Qfullheight
)));
237 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
239 struct window
*w
= XWINDOW (window
);
240 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
243 w
->pixel_top
+= n
* FRAME_LINE_HEIGHT (f
);
245 w
->pixel_height
-= n
* FRAME_LINE_HEIGHT (f
);
247 /* Handle just the top child in a vertical split. */
248 if (WINDOW_VERTICAL_COMBINATION_P (w
))
249 set_menu_bar_lines_1 (w
->contents
, n
);
250 else if (WINDOW_HORIZONTAL_COMBINATION_P (w
))
251 /* Adjust all children in a horizontal split. */
252 for (window
= w
->contents
; !NILP (window
); window
= w
->next
)
254 w
= XWINDOW (window
);
255 set_menu_bar_lines_1 (window
, n
);
260 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
263 int olines
= FRAME_MENU_BAR_LINES (f
);
265 /* Right now, menu bars don't work properly in minibuf-only frames;
266 most of the commands try to apply themselves to the minibuffer
267 frame itself, and get an error because you can't switch buffers
268 in or split the minibuffer window. */
269 if (FRAME_MINIBUF_ONLY_P (f
))
272 if (TYPE_RANGED_INTEGERP (int, value
))
273 nlines
= XINT (value
);
277 if (nlines
!= olines
)
279 windows_or_buffers_changed
= 14;
280 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
281 FRAME_MENU_BAR_LINES (f
) = nlines
;
282 FRAME_MENU_BAR_HEIGHT (f
) = nlines
* FRAME_LINE_HEIGHT (f
);
283 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
284 adjust_frame_glyphs (f
);
288 Lisp_Object Vframe_list
;
291 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
292 doc
: /* Return non-nil if OBJECT is a frame.
294 t for a termcap frame (a character-only terminal),
295 'x' for an Emacs frame that is really an X window,
296 'w32' for an Emacs frame that is a window on MS-Windows display,
297 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
298 'pc' for a direct-write MS-DOS frame.
299 See also `frame-live-p'. */)
302 if (!FRAMEP (object
))
304 switch (XFRAME (object
)->output_method
)
306 case output_initial
: /* The initial frame is like a termcap frame. */
309 case output_x_window
:
313 case output_msdos_raw
:
322 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
323 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
324 Value is nil if OBJECT is not a live frame. If object is a live
325 frame, the return value indicates what sort of terminal device it is
326 displayed on. See the documentation of `framep' for possible
330 return ((FRAMEP (object
)
331 && FRAME_LIVE_P (XFRAME (object
)))
336 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
337 doc
: /* The name of the window system that FRAME is displaying through.
338 The value is a symbol:
339 nil for a termcap frame (a character-only terminal),
340 'x' for an Emacs frame that is really an X window,
341 'w32' for an Emacs frame that is a window on MS-Windows display,
342 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
343 'pc' for a direct-write MS-DOS frame.
345 FRAME defaults to the currently selected frame.
347 Use of this function as a predicate is deprecated. Instead,
348 use `display-graphic-p' or any of the other `display-*-p'
349 predicates which report frame's specific UI-related capabilities. */)
354 frame
= selected_frame
;
356 type
= Fframep (frame
);
359 wrong_type_argument (Qframep
, frame
);
368 frame_windows_min_size (Lisp_Object frame
, Lisp_Object horizontal
, Lisp_Object pixelwise
)
370 return XINT (call3 (Qframe_windows_min_size
, frame
, horizontal
, pixelwise
));
374 /* Make sure windows sizes of frame F are OK. new_width and new_height
375 are in pixels. A value of -1 means no change is requested for that
376 size (but the frame may still have to be resized to accomodate
377 windows with their minimum sizes.
379 The argument INHIBIT can assume the following values:
381 0 means to unconditionally call x_set_window_size even if sizes
382 apparently do not change. Fx_create_frame uses this to pass the
383 initial size to the window manager.
385 1 means to call x_set_window_size iff the pixel size really changes.
386 Fset_frame_size, Fset_frame_height, ... use this.
388 2 means to unconditionally call x_set_window_size provided
389 frame_inhibit_resize allows it. The menu bar code uses this.
391 3 means call x_set_window_size iff window minimum sizes must be
392 preserved or frame_inhibit_resize allows it, x_set_left_fringe,
393 x_set_scroll_bar_width, ... use this.
395 4 means call x_set_window_size iff window minimum sizes must be
396 preserved. x_set_tool_bar_lines, x_set_right_divider_width, ... use
397 this. BUT maybe the toolbar code shouldn't ....
399 5 means to never call x_set_window_size. change_frame_size uses
402 For 2 and 3 note that if frame_inhibit_resize inhibits resizing and
403 minimum sizes are not violated no internal resizing takes place
404 either. For 2, 3, 4 and 5 note that even if no x_set_window_size
405 call is issued, window sizes may have to be adjusted in order to
406 support minimum size constraints for the frame's windows.
408 PRETEND is as for change_frame_size. */
410 adjust_frame_size (struct frame
*f
, int new_width
, int new_height
, int inhibit
, bool pretend
)
412 int unit_width
= FRAME_COLUMN_WIDTH (f
);
413 int unit_height
= FRAME_LINE_HEIGHT (f
);
414 int old_pixel_width
= FRAME_PIXEL_WIDTH (f
);
415 int old_pixel_height
= FRAME_PIXEL_HEIGHT (f
);
416 int new_pixel_width
, new_pixel_height
;
417 /* The following two values are calculated from the old frame pixel
418 sizes and any "new" settings for tool bar, menu bar and internal
419 borders. We do it this way to detect whether we have to call
420 x_set_window_size as consequence of the new settings. */
421 int windows_width
= FRAME_WINDOWS_WIDTH (f
);
422 int windows_height
= FRAME_WINDOWS_HEIGHT (f
);
423 int min_windows_width
, min_windows_height
;
424 /* These are a bit tedious, maybe we should use a macro. */
425 struct window
*r
= XWINDOW (FRAME_ROOT_WINDOW (f
));
426 int old_windows_width
= WINDOW_PIXEL_WIDTH (r
);
427 int old_windows_height
428 = (WINDOW_PIXEL_HEIGHT (r
)
429 + (FRAME_HAS_MINIBUF_P (f
)
430 ? WINDOW_PIXEL_HEIGHT (XWINDOW (FRAME_MINIBUF_WINDOW (f
)))
432 int new_windows_width
, new_windows_height
;
433 int old_text_width
= FRAME_TEXT_WIDTH (f
);
434 int old_text_height
= FRAME_TEXT_HEIGHT (f
);
435 /* If a size is < 0 use the old value. */
436 int new_text_width
= (new_width
>= 0) ? new_width
: old_text_width
;
437 int new_text_height
= (new_height
>= 0) ? new_height
: old_text_height
;
438 int new_cols
, new_lines
;
439 bool inhibit_horizontal
, inhibit_vertical
;
442 XSETFRAME (frame
, f
);
443 /* The following two values are calculated from the old window body
444 sizes and any "new" settings for scroll bars, dividers, fringes and
445 margins (though the latter should have been processed already). */
446 min_windows_width
= frame_windows_min_size (frame
, Qt
, Qt
);
447 min_windows_height
= frame_windows_min_size (frame
, Qnil
, Qt
);
449 if (inhibit
>= 2 && inhibit
<= 4)
450 /* If INHIBIT is in [2..4] inhibit if the "old" window sizes stay
451 within the limits and either frame_inhibit_resize tells us to do
452 so or INHIBIT equals 4. */
454 inhibit_horizontal
= ((windows_width
>= min_windows_width
455 && (inhibit
== 4 || frame_inhibit_resize (f
, true)))
457 inhibit_vertical
= ((windows_height
>= min_windows_height
458 && (inhibit
== 4 || frame_inhibit_resize (f
, false)))
462 /* Otherwise inhibit if INHIBIT equals 5. */
463 inhibit_horizontal
= inhibit_vertical
= inhibit
== 5;
465 new_pixel_width
= ((inhibit_horizontal
&& (inhibit
< 5))
467 : max (FRAME_TEXT_TO_PIXEL_WIDTH (f
, new_text_width
),
469 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
470 new_windows_width
= new_pixel_width
- 2 * FRAME_INTERNAL_BORDER_WIDTH (f
);
471 new_text_width
= FRAME_PIXEL_TO_TEXT_WIDTH (f
, new_pixel_width
);
472 new_cols
= new_text_width
/ unit_width
;
474 new_pixel_height
= ((inhibit_vertical
&& (inhibit
< 5))
476 : max (FRAME_TEXT_TO_PIXEL_HEIGHT (f
, new_text_height
),
478 + FRAME_TOP_MARGIN_HEIGHT (f
)
479 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
480 new_windows_height
= (new_pixel_height
481 - FRAME_TOP_MARGIN_HEIGHT (f
)
482 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f
));
483 new_text_height
= FRAME_PIXEL_TO_TEXT_HEIGHT (f
, new_pixel_height
);
484 new_lines
= new_text_height
/ unit_height
;
486 #ifdef HAVE_WINDOW_SYSTEM
487 if (FRAME_WINDOW_P (f
)
489 && ((!inhibit_horizontal
490 && (new_pixel_width
!= old_pixel_width
491 || inhibit
== 0 || inhibit
== 2))
492 || (!inhibit_vertical
493 && (new_pixel_height
!= old_pixel_height
494 || inhibit
== 0 || inhibit
== 2))))
495 /* We are either allowed to change the frame size or the minimum
496 sizes request such a change. Do not care for fixing minimum
497 sizes here, we do that eventually when we're called from
498 change_frame_size. */
500 /* Make sure we respect fullheight and fullwidth. */
501 if (inhibit_horizontal
)
502 new_text_width
= old_text_width
;
503 else if (inhibit_vertical
)
504 new_text_height
= old_text_height
;
506 x_set_window_size (f
, 0, new_text_width
, new_text_height
, 1);
513 if (new_text_width
== old_text_width
514 && new_text_height
== old_text_height
515 && new_windows_width
== old_windows_width
516 && new_windows_height
== old_windows_height
517 && new_pixel_width
== old_pixel_width
518 && new_pixel_height
== old_pixel_height
)
519 /* No change. Sanitize window sizes and return. */
521 sanitize_window_sizes (frame
, Qt
);
522 sanitize_window_sizes (frame
, Qnil
);
530 /* We only can set screen dimensions to certain values supported
531 by our video hardware. Try to find the smallest size greater
532 or equal to the requested dimensions. */
533 dos_set_window_size (&new_lines
, &new_cols
);
536 if (new_windows_width
!= old_windows_width
)
538 resize_frame_windows (f
, new_windows_width
, 1, 1);
540 /* MSDOS frames cannot PRETEND, as they change frame size by
541 manipulating video hardware. */
542 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
543 FrameCols (FRAME_TTY (f
)) = new_cols
;
545 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
546 if (WINDOWP (f
->tool_bar_window
))
548 XWINDOW (f
->tool_bar_window
)->pixel_width
= new_windows_width
;
549 XWINDOW (f
->tool_bar_window
)->total_cols
550 = new_windows_width
/ unit_width
;
555 if (new_windows_height
!= old_windows_height
556 /* When the top margin has changed we have to recalculate the top
557 edges of all windows. No such calculation is necessary for the
559 || WINDOW_TOP_PIXEL_EDGE (r
) != FRAME_TOP_MARGIN_HEIGHT (f
))
561 resize_frame_windows (f
, new_windows_height
, 0, 1);
563 /* MSDOS frames cannot PRETEND, as they change frame size by
564 manipulating video hardware. */
565 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
566 FrameRows (FRAME_TTY (f
)) = new_lines
;
569 /* Assign new sizes. */
570 FRAME_TEXT_WIDTH (f
) = new_text_width
;
571 FRAME_TEXT_HEIGHT (f
) = new_text_height
;
572 FRAME_PIXEL_WIDTH (f
) = new_pixel_width
;
573 FRAME_PIXEL_HEIGHT (f
) = new_pixel_height
;
574 SET_FRAME_COLS (f
, new_cols
);
575 SET_FRAME_LINES (f
, new_lines
);
578 struct window
*w
= XWINDOW (FRAME_SELECTED_WINDOW (f
));
579 int text_area_x
, text_area_y
, text_area_width
, text_area_height
;
581 window_box (w
, TEXT_AREA
, &text_area_x
, &text_area_y
, &text_area_width
,
583 if (w
->cursor
.x
>= text_area_x
+ text_area_width
)
584 w
->cursor
.hpos
= w
->cursor
.x
= 0;
585 if (w
->cursor
.y
>= text_area_y
+ text_area_height
)
586 w
->cursor
.vpos
= w
->cursor
.y
= 0;
589 /* Sanitize window sizes. */
590 sanitize_window_sizes (frame
, Qt
);
591 sanitize_window_sizes (frame
, Qnil
);
593 adjust_frame_glyphs (f
);
595 SET_FRAME_GARBAGED (f
);
597 /* A frame was "resized" if one of its pixelsizes changed, even if its
598 X window wasn't resized at all. */
599 f
->resized_p
= (new_pixel_width
!= old_pixel_width
600 || new_pixel_height
!= old_pixel_height
);
604 run_window_configuration_change_hook (f
);
609 make_frame (bool mini_p
)
612 register struct frame
*f
;
613 register struct window
*rw
, *mw
;
614 register Lisp_Object root_window
;
615 register Lisp_Object mini_window
;
617 f
= allocate_frame ();
618 XSETFRAME (frame
, f
);
621 /* Initialize Lisp data. Note that allocate_frame initializes all
622 Lisp data to nil, so do it only for slots which should not be nil. */
623 fset_tool_bar_position (f
, Qtop
);
626 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
627 non-Lisp data, so do it only for slots which should not be zero.
628 To avoid subtle bugs and for the sake of readability, it's better to
629 initialize enum members explicitly even if their values are zero. */
630 f
->wants_modeline
= true;
634 f
->column_width
= 1; /* !FRAME_WINDOW_P value. */
635 f
->line_height
= 1; /* !FRAME_WINDOW_P value. */
636 #ifdef HAVE_WINDOW_SYSTEM
637 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
638 f
->horizontal_scroll_bars
= false;
639 f
->want_fullscreen
= FULLSCREEN_NONE
;
640 #if ! defined (USE_GTK) && ! defined (HAVE_NS)
641 f
->last_tool_bar_item
= -1;
645 root_window
= make_window ();
646 rw
= XWINDOW (root_window
);
649 mini_window
= make_window ();
650 mw
= XWINDOW (mini_window
);
651 wset_next (rw
, mini_window
);
652 wset_prev (mw
, root_window
);
654 wset_frame (mw
, frame
);
655 fset_minibuffer_window (f
, mini_window
);
660 wset_next (rw
, Qnil
);
661 fset_minibuffer_window (f
, Qnil
);
664 wset_frame (rw
, frame
);
667 just so that there is "something there."
668 Correct size will be set up later with adjust_frame_size. */
670 SET_FRAME_COLS (f
, 10);
671 SET_FRAME_LINES (f
, 10);
672 SET_FRAME_WIDTH (f
, FRAME_COLS (f
) * FRAME_COLUMN_WIDTH (f
));
673 SET_FRAME_HEIGHT (f
, FRAME_LINES (f
) * FRAME_LINE_HEIGHT (f
));
676 rw
->pixel_width
= rw
->total_cols
* FRAME_COLUMN_WIDTH (f
);
677 rw
->total_lines
= mini_p
? 9 : 10;
678 rw
->pixel_height
= rw
->total_lines
* FRAME_LINE_HEIGHT (f
);
682 mw
->top_line
= rw
->total_lines
;
683 mw
->pixel_top
= rw
->pixel_height
;
684 mw
->total_cols
= rw
->total_cols
;
685 mw
->pixel_width
= rw
->pixel_width
;
687 mw
->pixel_height
= FRAME_LINE_HEIGHT (f
);
690 /* Choose a buffer for the frame's root window. */
692 Lisp_Object buf
= Fcurrent_buffer ();
694 /* If current buffer is hidden, try to find another one. */
695 if (BUFFER_HIDDEN_P (XBUFFER (buf
)))
696 buf
= other_buffer_safely (buf
);
698 /* Use set_window_buffer, not Fset_window_buffer, and don't let
699 hooks be run by it. The reason is that the whole frame/window
700 arrangement is not yet fully initialized at this point. Windows
701 don't have the right size, glyph matrices aren't initialized
702 etc. Running Lisp functions at this point surely ends in a
704 set_window_buffer (root_window
, buf
, 0, 0);
705 fset_buffer_list (f
, list1 (buf
));
710 set_window_buffer (mini_window
,
711 (NILP (Vminibuffer_list
)
713 : Fcar (Vminibuffer_list
)),
715 /* No horizontal scroll bars in minibuffers. */
716 wset_horizontal_scroll_bar (mw
, Qnil
);
719 fset_root_window (f
, root_window
);
720 fset_selected_window (f
, root_window
);
721 /* Make sure this window seems more recently used than
722 a newly-created, never-selected window. */
723 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
728 #ifdef HAVE_WINDOW_SYSTEM
729 /* Make a frame using a separate minibuffer window on another frame.
730 MINI_WINDOW is the minibuffer window to use. nil means use the
731 default (the global minibuffer). */
734 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
736 register struct frame
*f
;
739 if (!NILP (mini_window
))
740 CHECK_LIVE_WINDOW (mini_window
);
742 if (!NILP (mini_window
)
743 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
744 error ("Frame and minibuffer must be on the same terminal");
746 /* Make a frame containing just a root window. */
749 if (NILP (mini_window
))
751 /* Use default-minibuffer-frame if possible. */
752 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
753 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
755 Lisp_Object frame_dummy
;
757 XSETFRAME (frame_dummy
, f
);
758 GCPRO1 (frame_dummy
);
759 /* If there's no minibuffer frame to use, create one. */
760 kset_default_minibuffer_frame
761 (kb
, call1 (intern ("make-initial-minibuffer-frame"), display
));
766 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
769 fset_minibuffer_window (f
, mini_window
);
771 /* Make the chosen minibuffer window display the proper minibuffer,
772 unless it is already showing a minibuffer. */
773 if (NILP (Fmemq (XWINDOW (mini_window
)->contents
, Vminibuffer_list
)))
774 /* Use set_window_buffer instead of Fset_window_buffer (see
775 discussion of bug#11984, bug#12025, bug#12026). */
776 set_window_buffer (mini_window
,
777 (NILP (Vminibuffer_list
)
779 : Fcar (Vminibuffer_list
)), 0, 0);
783 /* Make a frame containing only a minibuffer window. */
786 make_minibuffer_frame (void)
788 /* First make a frame containing just a root window, no minibuffer. */
790 register struct frame
*f
= make_frame (0);
791 register Lisp_Object mini_window
;
792 register Lisp_Object frame
;
794 XSETFRAME (frame
, f
);
799 f
->wants_modeline
= 0;
801 /* Now label the root window as also being the minibuffer.
802 Avoid infinite looping on the window chain by marking next pointer
805 mini_window
= f
->root_window
;
806 fset_minibuffer_window (f
, mini_window
);
807 XWINDOW (mini_window
)->mini
= 1;
808 wset_next (XWINDOW (mini_window
), Qnil
);
809 wset_prev (XWINDOW (mini_window
), Qnil
);
810 wset_frame (XWINDOW (mini_window
), frame
);
812 /* Put the proper buffer in that window. */
814 /* Use set_window_buffer instead of Fset_window_buffer (see
815 discussion of bug#11984, bug#12025, bug#12026). */
816 set_window_buffer (mini_window
,
817 (NILP (Vminibuffer_list
)
819 : Fcar (Vminibuffer_list
)), 0, 0);
822 #endif /* HAVE_WINDOW_SYSTEM */
824 /* Construct a frame that refers to a terminal. */
826 static printmax_t tty_frame_count
;
829 make_initial_frame (void)
832 struct terminal
*terminal
;
835 eassert (initial_kboard
);
837 /* The first call must initialize Vframe_list. */
838 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
841 terminal
= init_initial_terminal ();
844 XSETFRAME (frame
, f
);
846 Vframe_list
= Fcons (frame
, Vframe_list
);
849 fset_name (f
, build_pure_c_string ("F1"));
851 SET_FRAME_VISIBLE (f
, 1);
853 f
->output_method
= terminal
->type
;
854 f
->terminal
= terminal
;
855 f
->terminal
->reference_count
++;
856 f
->output_data
.nothing
= 0;
858 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
859 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
861 #ifdef HAVE_WINDOW_SYSTEM
862 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
863 FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
) = false;
866 /* The default value of menu-bar-mode is t. */
867 set_menu_bar_lines (f
, make_number (1), Qnil
);
870 init_frame_faces (f
);
872 last_nonminibuf_frame
= f
;
878 static struct frame
*
879 make_terminal_frame (struct terminal
*terminal
)
881 register struct frame
*f
;
883 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
886 error ("Terminal is not live, can't create new frames on it");
890 XSETFRAME (frame
, f
);
891 Vframe_list
= Fcons (frame
, Vframe_list
);
893 fset_name (f
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
895 SET_FRAME_VISIBLE (f
, 1);
897 f
->terminal
= terminal
;
898 f
->terminal
->reference_count
++;
900 f
->output_data
.tty
->display_info
= &the_only_display_info
;
901 if (!inhibit_window_system
902 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
903 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
904 f
->output_method
= output_msdos_raw
;
906 f
->output_method
= output_termcap
;
907 #else /* not MSDOS */
908 f
->output_method
= output_termcap
;
909 create_tty_output (f
);
910 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
911 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
912 #endif /* not MSDOS */
914 #ifdef HAVE_WINDOW_SYSTEM
915 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
916 FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
) = false;
919 FRAME_MENU_BAR_LINES (f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
920 FRAME_MENU_BAR_HEIGHT (f
) = FRAME_MENU_BAR_LINES (f
) * FRAME_LINE_HEIGHT (f
);
922 /* Set the top frame to the newly created frame. */
923 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
924 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
925 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f
)->top_frame
), 2); /* obscured */
927 FRAME_TTY (f
)->top_frame
= frame
;
930 init_frame_faces (f
);
935 /* Get a suitable value for frame parameter PARAMETER for a newly
936 created frame, based on (1) the user-supplied frame parameter
937 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
940 get_future_frame_param (Lisp_Object parameter
,
941 Lisp_Object supplied_parms
,
946 result
= Fassq (parameter
, supplied_parms
);
948 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
949 if (NILP (result
) && current_value
!= NULL
)
950 result
= build_string (current_value
);
951 if (!NILP (result
) && !STRINGP (result
))
952 result
= XCDR (result
);
953 if (NILP (result
) || !STRINGP (result
))
959 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
961 doc
: /* Create an additional terminal frame, possibly on another terminal.
962 This function takes one argument, an alist specifying frame parameters.
964 You can create multiple frames on a single text terminal, but only one
965 of them (the selected terminal frame) is actually displayed.
967 In practice, generally you don't need to specify any parameters,
968 except when you want to create a new frame on another terminal.
969 In that case, the `tty' parameter specifies the device file to open,
970 and the `tty-type' parameter specifies the terminal type. Example:
972 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
974 Note that changing the size of one terminal frame automatically
975 affects all frames on the same terminal device. */)
979 struct terminal
*t
= NULL
;
980 Lisp_Object frame
, tem
;
981 struct frame
*sf
= SELECTED_FRAME ();
984 if (sf
->output_method
!= output_msdos_raw
985 && sf
->output_method
!= output_termcap
)
987 #else /* not MSDOS */
989 #ifdef WINDOWSNT /* This should work now! */
990 if (sf
->output_method
!= output_termcap
)
991 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
993 #endif /* not MSDOS */
996 Lisp_Object terminal
;
998 terminal
= Fassq (Qterminal
, parms
);
999 if (CONSP (terminal
))
1001 terminal
= XCDR (terminal
);
1002 t
= get_terminal (terminal
, 1);
1005 if (t
&& t
!= the_only_display_info
.terminal
)
1006 /* msdos.c assumes a single tty_display_info object. */
1007 error ("Multiple terminals are not supported on this platform");
1009 t
= the_only_display_info
.terminal
;
1015 char *name
= 0, *type
= 0;
1016 Lisp_Object tty
, tty_type
;
1018 tty
= get_future_frame_param
1019 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1020 ? FRAME_TTY (XFRAME (selected_frame
))->name
1023 name
= xlispstrdupa (tty
);
1025 tty_type
= get_future_frame_param
1026 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1027 ? FRAME_TTY (XFRAME (selected_frame
))->type
1029 if (!NILP (tty_type
))
1030 type
= xlispstrdupa (tty_type
);
1032 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
1035 f
= make_terminal_frame (t
);
1039 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
1040 adjust_frame_size (f
, width
, height
, 5, 0);
1043 adjust_frame_glyphs (f
);
1044 calculate_costs (f
);
1045 XSETFRAME (frame
, f
);
1047 store_in_alist (&parms
, Qtty_type
, build_string (t
->display_info
.tty
->type
));
1048 store_in_alist (&parms
, Qtty
,
1049 (t
->display_info
.tty
->name
1050 ? build_string (t
->display_info
.tty
->name
)
1052 Fmodify_frame_parameters (frame
, parms
);
1054 /* Make the frame face alist be frame-specific, so that each
1055 frame could change its face definitions independently. */
1056 fset_face_alist (f
, Fcopy_alist (sf
->face_alist
));
1057 /* Simple Fcopy_alist isn't enough, because we need the contents of
1058 the vectors which are the CDRs of associations in face_alist to
1059 be copied as well. */
1060 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
1061 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
1066 /* Perform the switch to frame FRAME.
1068 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
1071 If TRACK is non-zero and the frame that currently has the focus
1072 redirects its focus to the selected frame, redirect that focused
1073 frame's focus to FRAME instead.
1075 FOR_DELETION non-zero means that the selected frame is being
1076 deleted, which includes the possibility that the frame's terminal
1079 The value of NORECORD is passed as argument to Fselect_window. */
1082 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
1084 struct frame
*sf
= SELECTED_FRAME ();
1086 /* If FRAME is a switch-frame event, extract the frame we should
1089 && EQ (XCAR (frame
), Qswitch_frame
)
1090 && CONSP (XCDR (frame
)))
1091 frame
= XCAR (XCDR (frame
));
1093 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
1094 a switch-frame event to arrive after a frame is no longer live,
1095 especially when deleting the initial frame during startup. */
1096 CHECK_FRAME (frame
);
1097 if (! FRAME_LIVE_P (XFRAME (frame
)))
1100 if (sf
== XFRAME (frame
))
1103 /* If a frame's focus has been redirected toward the currently
1104 selected frame, we should change the redirection to point to the
1105 newly selected frame. This means that if the focus is redirected
1106 from a minibufferless frame to a surrogate minibuffer frame, we
1107 can use `other-window' to switch between all the frames using
1108 that minibuffer frame, and the focus redirection will follow us
1111 /* This is too greedy; it causes inappropriate focus redirection
1112 that's hard to get rid of. */
1117 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1121 if (!FRAMEP (XCAR (tail
)))
1124 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
1126 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1127 Fredirect_frame_focus (XCAR (tail
), frame
);
1131 /* Instead, apply it only to the frame we're pointing to. */
1132 #ifdef HAVE_WINDOW_SYSTEM
1133 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
1135 Lisp_Object focus
, xfocus
;
1137 xfocus
= x_get_focus_frame (XFRAME (frame
));
1138 if (FRAMEP (xfocus
))
1140 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
1141 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1142 Fredirect_frame_focus (xfocus
, frame
);
1145 #endif /* HAVE_X_WINDOWS */
1148 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
1149 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
1151 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
1153 struct frame
*f
= XFRAME (frame
);
1154 struct tty_display_info
*tty
= FRAME_TTY (f
);
1155 Lisp_Object top_frame
= tty
->top_frame
;
1157 /* Don't mark the frame garbaged and/or obscured if we are
1158 switching to the frame that is already the top frame of that
1160 if (!EQ (frame
, top_frame
))
1162 if (FRAMEP (top_frame
))
1163 /* Mark previously displayed frame as now obscured. */
1164 SET_FRAME_VISIBLE (XFRAME (top_frame
), 2);
1165 SET_FRAME_VISIBLE (f
, 1);
1166 /* If the new TTY frame changed dimensions, we need to
1167 resync term.c's idea of the frame size with the new
1169 if (FRAME_COLS (f
) != FrameCols (tty
))
1170 FrameCols (tty
) = FRAME_COLS (f
);
1171 if (FRAME_LINES (f
) != FrameRows (tty
))
1172 FrameRows (tty
) = FRAME_LINES (f
);
1174 tty
->top_frame
= frame
;
1177 selected_frame
= frame
;
1178 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
1179 last_nonminibuf_frame
= XFRAME (selected_frame
);
1181 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
1183 /* We want to make sure that the next event generates a frame-switch
1184 event to the appropriate frame. This seems kludgy to me, but
1185 before you take it out, make sure that evaluating something like
1186 (select-window (frame-root-window (new-frame))) doesn't end up
1187 with your typing being interpreted in the new frame instead of
1188 the one you're actually typing in. */
1189 internal_last_event_frame
= Qnil
;
1194 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
1195 doc
: /* Select FRAME.
1196 Subsequent editing commands apply to its selected window.
1197 Optional argument NORECORD means to neither change the order of
1198 recently selected windows nor the buffer list.
1200 The selection of FRAME lasts until the next time the user does
1201 something to select a different frame, or until the next time
1202 this function is called. If you are using a window system, the
1203 previously selected frame may be restored as the selected frame
1204 when returning to the command loop, because it still may have
1205 the window system's input focus. On a text terminal, the next
1206 redisplay will display FRAME.
1208 This function returns FRAME, or nil if FRAME has been deleted. */)
1209 (Lisp_Object frame
, Lisp_Object norecord
)
1211 return do_switch_frame (frame
, 1, 0, norecord
);
1214 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
1215 doc
: /* Handle a switch-frame event EVENT.
1216 Switch-frame events are usually bound to this function.
1217 A switch-frame event tells Emacs that the window manager has requested
1218 that the user's events be directed to the frame mentioned in the event.
1219 This function selects the selected window of the frame of EVENT.
1221 If EVENT is frame object, handle it as if it were a switch-frame event
1225 /* Preserve prefix arg that the command loop just cleared. */
1226 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
1227 Frun_hooks (1, &Qmouse_leave_buffer_hook
);
1228 /* `switch-frame' implies a focus in. */
1229 call1 (intern ("handle-focus-in"), event
);
1230 return do_switch_frame (event
, 0, 0, Qnil
);
1233 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1234 doc
: /* Return the frame that is now selected. */)
1237 return selected_frame
;
1240 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1242 doc
: /* Return a list of all live frames. */)
1246 frames
= Fcopy_sequence (Vframe_list
);
1247 #ifdef HAVE_WINDOW_SYSTEM
1248 if (FRAMEP (tip_frame
))
1249 frames
= Fdelq (tip_frame
, frames
);
1254 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
1255 same tty (for tty frames) or among frames which uses FRAME's keyboard.
1256 If MINIBUF is nil, do not consider minibuffer-only candidate.
1257 If MINIBUF is `visible', do not consider an invisible candidate.
1258 If MINIBUF is a window, consider only its own frame and candidate now
1259 using that window as the minibuffer.
1260 If MINIBUF is 0, consider candidate if it is visible or iconified.
1261 Otherwise consider any candidate and return nil if CANDIDATE is not
1265 candidate_frame (Lisp_Object candidate
, Lisp_Object frame
, Lisp_Object minibuf
)
1267 struct frame
*c
= XFRAME (candidate
), *f
= XFRAME (frame
);
1269 if ((!FRAME_TERMCAP_P (c
) && !FRAME_TERMCAP_P (f
)
1270 && FRAME_KBOARD (c
) == FRAME_KBOARD (f
))
1271 || (FRAME_TERMCAP_P (c
) && FRAME_TERMCAP_P (f
)
1272 && FRAME_TTY (c
) == FRAME_TTY (f
)))
1276 if (!FRAME_MINIBUF_ONLY_P (c
))
1279 else if (EQ (minibuf
, Qvisible
))
1281 if (FRAME_VISIBLE_P (c
))
1284 else if (WINDOWP (minibuf
))
1286 if (EQ (FRAME_MINIBUF_WINDOW (c
), minibuf
)
1287 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), candidate
)
1288 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1289 FRAME_FOCUS_FRAME (c
)))
1292 else if (XFASTINT (minibuf
) == 0)
1294 if (FRAME_VISIBLE_P (c
) || FRAME_ICONIFIED_P (c
))
1303 /* Return the next frame in the frame list after FRAME. */
1306 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1308 Lisp_Object f
, tail
;
1311 /* There must always be at least one frame in Vframe_list. */
1312 eassert (CONSP (Vframe_list
));
1315 FOR_EACH_FRAME (tail
, f
)
1319 f
= candidate_frame (f
, frame
, minibuf
);
1329 /* Return the previous frame in the frame list before FRAME. */
1332 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1334 Lisp_Object f
, tail
, prev
= Qnil
;
1336 /* There must always be at least one frame in Vframe_list. */
1337 eassert (CONSP (Vframe_list
));
1339 FOR_EACH_FRAME (tail
, f
)
1341 if (EQ (frame
, f
) && !NILP (prev
))
1343 f
= candidate_frame (f
, frame
, minibuf
);
1348 /* We've scanned the entire list. */
1350 /* We went through the whole frame list without finding a single
1351 acceptable frame. Return the original frame. */
1354 /* There were no acceptable frames in the list before FRAME; otherwise,
1355 we would have returned directly from the loop. Since PREV is the last
1356 acceptable frame in the list, return it. */
1361 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1362 doc
: /* Return the next frame in the frame list after FRAME.
1363 It considers only frames on the same terminal as FRAME.
1364 By default, skip minibuffer-only frames.
1365 If omitted, FRAME defaults to the selected frame.
1366 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1367 If MINIFRAME is a window, include only its own frame
1368 and any frame now using that window as the minibuffer.
1369 If MINIFRAME is `visible', include all visible frames.
1370 If MINIFRAME is 0, include all visible and iconified frames.
1371 Otherwise, include all frames. */)
1372 (Lisp_Object frame
, Lisp_Object miniframe
)
1375 frame
= selected_frame
;
1376 CHECK_LIVE_FRAME (frame
);
1377 return next_frame (frame
, miniframe
);
1380 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1381 doc
: /* Return the previous frame in the frame list before FRAME.
1382 It considers only frames on the same terminal as FRAME.
1383 By default, skip minibuffer-only frames.
1384 If omitted, FRAME defaults to the selected frame.
1385 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1386 If MINIFRAME is a window, include only its own frame
1387 and any frame now using that window as the minibuffer.
1388 If MINIFRAME is `visible', include all visible frames.
1389 If MINIFRAME is 0, include all visible and iconified frames.
1390 Otherwise, include all frames. */)
1391 (Lisp_Object frame
, Lisp_Object miniframe
)
1394 frame
= selected_frame
;
1395 CHECK_LIVE_FRAME (frame
);
1396 return prev_frame (frame
, miniframe
);
1399 DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame
,
1400 Slast_nonminibuf_frame
, 0, 0, 0,
1401 doc
: /* Return last non-minibuffer frame selected. */)
1404 Lisp_Object frame
= Qnil
;
1406 if (last_nonminibuf_frame
)
1407 XSETFRAME (frame
, last_nonminibuf_frame
);
1412 /* Return 1 if it is ok to delete frame F;
1413 0 if all frames aside from F are invisible.
1414 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1417 other_visible_frames (struct frame
*f
)
1419 Lisp_Object frames
, this;
1421 FOR_EACH_FRAME (frames
, this)
1423 if (f
== XFRAME (this))
1426 /* Verify that we can still talk to the frame's X window,
1427 and note any recent change in visibility. */
1428 #ifdef HAVE_X_WINDOWS
1429 if (FRAME_WINDOW_P (XFRAME (this)))
1430 x_sync (XFRAME (this));
1433 if (FRAME_VISIBLE_P (XFRAME (this))
1434 || FRAME_ICONIFIED_P (XFRAME (this))
1435 /* Allow deleting the terminal frame when at least one X
1437 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1443 /* Make sure that minibuf_window doesn't refer to FRAME's minibuffer
1444 window. Preferably use the selected frame's minibuffer window
1445 instead. If the selected frame doesn't have one, get some other
1446 frame's minibuffer window. SELECT non-zero means select the new
1447 minibuffer window. */
1449 check_minibuf_window (Lisp_Object frame
, int select
)
1451 struct frame
*f
= decode_live_frame (frame
);
1453 XSETFRAME (frame
, f
);
1455 if (WINDOWP (minibuf_window
) && EQ (f
->minibuffer_window
, minibuf_window
))
1457 Lisp_Object frames
, this, window
= make_number (0);
1459 if (!EQ (frame
, selected_frame
)
1460 && FRAME_HAS_MINIBUF_P (XFRAME (selected_frame
)))
1461 window
= FRAME_MINIBUF_WINDOW (XFRAME (selected_frame
));
1463 FOR_EACH_FRAME (frames
, this)
1465 if (!EQ (this, frame
) && FRAME_HAS_MINIBUF_P (XFRAME (this)))
1467 window
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1472 /* Don't abort if no window was found (Bug#15247). */
1473 if (WINDOWP (window
))
1475 /* Use set_window_buffer instead of Fset_window_buffer (see
1476 discussion of bug#11984, bug#12025, bug#12026). */
1477 set_window_buffer (window
, XWINDOW (minibuf_window
)->contents
, 0, 0);
1478 minibuf_window
= window
;
1480 /* SELECT non-zero usually means that FRAME's minibuffer
1481 window was selected; select the new one. */
1483 Fselect_window (minibuf_window
, Qnil
);
1489 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1490 unconditionally. x_connection_closed and delete_terminal use
1491 this. Any other value of FORCE implements the semantics
1492 described for Fdelete_frame. */
1494 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1496 struct frame
*f
= decode_any_frame (frame
);
1500 int minibuffer_selected
, is_tooltip_frame
;
1502 if (! FRAME_LIVE_P (f
))
1505 if (NILP (force
) && !other_visible_frames (f
))
1506 error ("Attempt to delete the sole visible or iconified frame");
1508 /* x_connection_closed must have set FORCE to `noelisp' in order
1509 to delete the last frame, if it is gone. */
1510 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1511 error ("Attempt to delete the only frame");
1513 XSETFRAME (frame
, f
);
1515 /* Does this frame have a minibuffer, and is it the surrogate
1516 minibuffer for any other frame? */
1517 if (FRAME_HAS_MINIBUF_P (f
))
1519 Lisp_Object frames
, this;
1521 FOR_EACH_FRAME (frames
, this)
1525 if (EQ (this, frame
))
1528 fminiw
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1530 if (WINDOWP (fminiw
) && EQ (frame
, WINDOW_FRAME (XWINDOW (fminiw
))))
1532 /* If we MUST delete this frame, delete the other first.
1533 But do this only if FORCE equals `noelisp'. */
1534 if (EQ (force
, Qnoelisp
))
1535 delete_frame (this, Qnoelisp
);
1537 error ("Attempt to delete a surrogate minibuffer frame");
1542 is_tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1544 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1545 frame is a tooltip. FORCE is set to `noelisp' when handling
1546 a disconnect from the terminal, so we don't dare call Lisp
1548 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1550 else if (EQ (force
, Qnoelisp
))
1552 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1556 #ifdef HAVE_X_WINDOWS
1557 /* Also, save clipboard to the clipboard manager. */
1558 x_clipboard_manager_save_frame (frame
);
1561 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1564 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1565 if (! FRAME_LIVE_P (f
))
1568 /* At this point, we are committed to deleting the frame.
1569 There is no more chance for errors to prevent it. */
1571 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1572 sf
= SELECTED_FRAME ();
1573 /* Don't let the frame remain selected. */
1577 Lisp_Object frame1
= Qnil
;
1579 /* Look for another visible frame on the same terminal.
1580 Do not call next_frame here because it may loop forever.
1581 See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15025. */
1582 FOR_EACH_FRAME (tail
, frame1
)
1583 if (!EQ (frame
, frame1
)
1584 && (FRAME_TERMINAL (XFRAME (frame
))
1585 == FRAME_TERMINAL (XFRAME (frame1
)))
1586 && FRAME_VISIBLE_P (XFRAME (frame1
)))
1589 /* If there is none, find *some* other frame. */
1590 if (NILP (frame1
) || EQ (frame1
, frame
))
1592 FOR_EACH_FRAME (tail
, frame1
)
1594 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1596 /* Do not change a text terminal's top-frame. */
1597 struct frame
*f1
= XFRAME (frame1
);
1598 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1600 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1601 if (!EQ (top_frame
, frame
))
1608 #ifdef NS_IMPL_COCOA
1610 /* Under NS, there is no system mechanism for choosing a new
1611 window to get focus -- it is left to application code.
1612 So the portion of THIS application interfacing with NS
1613 needs to know about it. We call Fraise_frame, but the
1614 purpose is really to transfer focus. */
1615 Fraise_frame (frame1
);
1618 do_switch_frame (frame1
, 0, 1, Qnil
);
1619 sf
= SELECTED_FRAME ();
1622 /* Don't allow minibuf_window to remain on a deleted frame. */
1623 check_minibuf_window (frame
, minibuffer_selected
);
1625 /* Don't let echo_area_window to remain on a deleted frame. */
1626 if (EQ (f
->minibuffer_window
, echo_area_window
))
1627 echo_area_window
= sf
->minibuffer_window
;
1629 /* Clear any X selections for this frame. */
1630 #ifdef HAVE_X_WINDOWS
1632 x_clear_frame_selections (f
);
1636 This function must be called before the window tree of the
1637 frame is deleted because windows contain dynamically allocated
1641 #ifdef HAVE_WINDOW_SYSTEM
1642 /* Give chance to each font driver to free a frame specific data. */
1643 font_update_drivers (f
, Qnil
);
1646 /* Mark all the windows that used to be on FRAME as deleted, and then
1647 remove the reference to them. */
1648 delete_all_child_windows (f
->root_window
);
1649 fset_root_window (f
, Qnil
);
1651 Vframe_list
= Fdelq (frame
, Vframe_list
);
1652 SET_FRAME_VISIBLE (f
, 0);
1654 /* Allow the vector of menu bar contents to be freed in the next
1655 garbage collection. The frame object itself may not be garbage
1656 collected until much later, because recent_keys and other data
1657 structures can still refer to it. */
1658 fset_menu_bar_vector (f
, Qnil
);
1660 /* If FRAME's buffer lists contains killed
1661 buffers, this helps GC to reclaim them. */
1662 fset_buffer_list (f
, Qnil
);
1663 fset_buried_buffer_list (f
, Qnil
);
1665 free_font_driver_list (f
);
1666 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1669 xfree (f
->decode_mode_spec_buffer
);
1670 xfree (FRAME_INSERT_COST (f
));
1671 xfree (FRAME_DELETEN_COST (f
));
1672 xfree (FRAME_INSERTN_COST (f
));
1673 xfree (FRAME_DELETE_COST (f
));
1675 /* Since some events are handled at the interrupt level, we may get
1676 an event for f at any time; if we zero out the frame's terminal
1677 now, then we may trip up the event-handling code. Instead, we'll
1678 promise that the terminal of the frame must be valid until we
1679 have called the window-system-dependent frame destruction
1684 struct terminal
*terminal
;
1686 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1687 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1688 terminal
= FRAME_TERMINAL (f
);
1689 f
->output_data
.nothing
= 0;
1690 f
->terminal
= 0; /* Now the frame is dead. */
1693 /* If needed, delete the terminal that this frame was on.
1694 (This must be done after the frame is killed.) */
1695 terminal
->reference_count
--;
1697 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1699 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1700 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1701 terminal
->reference_count
= 1;
1702 #endif /* USE_GTK */
1703 if (terminal
->reference_count
== 0)
1706 XSETTERMINAL (tmp
, terminal
);
1709 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1712 kb
= terminal
->kboard
;
1715 /* If we've deleted the last_nonminibuf_frame, then try to find
1717 if (f
== last_nonminibuf_frame
)
1719 Lisp_Object frames
, this;
1721 last_nonminibuf_frame
= 0;
1723 FOR_EACH_FRAME (frames
, this)
1726 if (!FRAME_MINIBUF_ONLY_P (f
))
1728 last_nonminibuf_frame
= f
;
1734 /* If there's no other frame on the same kboard, get out of
1735 single-kboard state if we're in it for this kboard. */
1738 Lisp_Object frames
, this;
1739 /* Some frame we found on the same kboard, or nil if there are none. */
1740 Lisp_Object frame_on_same_kboard
= Qnil
;
1742 FOR_EACH_FRAME (frames
, this)
1743 if (kb
== FRAME_KBOARD (XFRAME (this)))
1744 frame_on_same_kboard
= this;
1746 if (NILP (frame_on_same_kboard
))
1747 not_single_kboard_state (kb
);
1751 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1752 find another one. Prefer minibuffer-only frames, but also notice
1753 frames with other windows. */
1754 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1756 Lisp_Object frames
, this;
1758 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1759 Lisp_Object frame_with_minibuf
= Qnil
;
1760 /* Some frame we found on the same kboard, or nil if there are none. */
1761 Lisp_Object frame_on_same_kboard
= Qnil
;
1763 FOR_EACH_FRAME (frames
, this)
1765 struct frame
*f1
= XFRAME (this);
1767 /* Consider only frames on the same kboard
1768 and only those with minibuffers. */
1769 if (kb
== FRAME_KBOARD (f1
)
1770 && FRAME_HAS_MINIBUF_P (f1
))
1772 frame_with_minibuf
= this;
1773 if (FRAME_MINIBUF_ONLY_P (f1
))
1777 if (kb
== FRAME_KBOARD (f1
))
1778 frame_on_same_kboard
= this;
1781 if (!NILP (frame_on_same_kboard
))
1783 /* We know that there must be some frame with a minibuffer out
1784 there. If this were not true, all of the frames present
1785 would have to be minibufferless, which implies that at some
1786 point their minibuffer frames must have been deleted, but
1787 that is prohibited at the top; you can't delete surrogate
1788 minibuffer frames. */
1789 if (NILP (frame_with_minibuf
))
1792 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
1795 /* No frames left on this kboard--say no minibuffer either. */
1796 kset_default_minibuffer_frame (kb
, Qnil
);
1799 /* Cause frame titles to update--necessary if we now have just one frame. */
1800 if (!is_tooltip_frame
)
1801 update_mode_lines
= 15;
1806 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1807 doc
: /* Delete FRAME, permanently eliminating it from use.
1808 FRAME defaults to the selected frame.
1810 A frame may not be deleted if its minibuffer is used by other frames.
1811 Normally, you may not delete a frame if all other frames are invisible,
1812 but if the second optional argument FORCE is non-nil, you may do so.
1814 This function runs `delete-frame-functions' before actually
1815 deleting the frame, unless the frame is a tooltip.
1816 The functions are run with one argument, the frame to be deleted. */)
1817 (Lisp_Object frame
, Lisp_Object force
)
1819 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1823 /* Return mouse position in character cell units. */
1825 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1826 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1827 The position is given in character cells, where (0, 0) is the
1828 upper-left corner of the frame, X is the horizontal offset, and Y is
1829 the vertical offset.
1830 If Emacs is running on a mouseless terminal or hasn't been programmed
1831 to read the mouse position, it returns the selected frame for FRAME
1832 and nil for X and Y.
1833 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1834 passing the normal return value to that function as an argument,
1835 and returns whatever that function returns. */)
1839 Lisp_Object lispy_dummy
;
1840 Lisp_Object x
, y
, retval
;
1841 struct gcpro gcpro1
;
1843 f
= SELECTED_FRAME ();
1846 /* It's okay for the hook to refrain from storing anything. */
1847 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1849 enum scroll_bar_part party_dummy
;
1851 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1852 &lispy_dummy
, &party_dummy
,
1861 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1865 XSETFRAME (lispy_dummy
, f
);
1866 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1868 if (!NILP (Vmouse_position_function
))
1869 retval
= call1 (Vmouse_position_function
, retval
);
1870 RETURN_UNGCPRO (retval
);
1873 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1874 Smouse_pixel_position
, 0, 0, 0,
1875 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1876 The position is given in pixel units, where (0, 0) is the
1877 upper-left corner of the frame, X is the horizontal offset, and Y is
1878 the vertical offset.
1879 If Emacs is running on a mouseless terminal or hasn't been programmed
1880 to read the mouse position, it returns the selected frame for FRAME
1881 and nil for X and Y. */)
1885 Lisp_Object lispy_dummy
;
1888 f
= SELECTED_FRAME ();
1891 /* It's okay for the hook to refrain from storing anything. */
1892 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1894 enum scroll_bar_part party_dummy
;
1896 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1897 &lispy_dummy
, &party_dummy
,
1902 XSETFRAME (lispy_dummy
, f
);
1903 return Fcons (lispy_dummy
, Fcons (x
, y
));
1906 #ifdef HAVE_WINDOW_SYSTEM
1908 /* On frame F, convert character coordinates X and Y to pixel
1909 coordinates *PIX_X and *PIX_Y. */
1912 frame_char_to_pixel_position (struct frame
*f
, int x
, int y
,
1913 int *pix_x
, int *pix_y
)
1915 *pix_x
= FRAME_COL_TO_PIXEL_X (f
, x
) + FRAME_COLUMN_WIDTH (f
) / 2;
1916 *pix_y
= FRAME_LINE_TO_PIXEL_Y (f
, y
) + FRAME_LINE_HEIGHT (f
) / 2;
1920 if (*pix_x
> FRAME_PIXEL_WIDTH (f
))
1921 *pix_x
= FRAME_PIXEL_WIDTH (f
);
1925 if (*pix_y
> FRAME_PIXEL_HEIGHT (f
))
1926 *pix_y
= FRAME_PIXEL_HEIGHT (f
);
1929 /* On frame F, reposition mouse pointer to character coordinates X and Y. */
1932 frame_set_mouse_position (struct frame
*f
, int x
, int y
)
1936 frame_char_to_pixel_position (f
, x
, y
, &pix_x
, &pix_y
);
1937 frame_set_mouse_pixel_position (f
, pix_x
, pix_y
);
1940 #endif /* HAVE_WINDOW_SYSTEM */
1942 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1943 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1944 Coordinates are relative to the frame, not a window,
1945 so the coordinates of the top left character in the frame
1946 may be nonzero due to left-hand scroll bars or the menu bar.
1948 The position is given in character cells, where (0, 0) is the
1949 upper-left corner of the frame, X is the horizontal offset, and Y is
1950 the vertical offset.
1952 This function is a no-op for an X frame that is not visible.
1953 If you have just created a frame, you must wait for it to become visible
1954 before calling this function on it, like this.
1955 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1956 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1958 CHECK_LIVE_FRAME (frame
);
1959 CHECK_TYPE_RANGED_INTEGER (int, x
);
1960 CHECK_TYPE_RANGED_INTEGER (int, y
);
1962 /* I think this should be done with a hook. */
1963 #ifdef HAVE_WINDOW_SYSTEM
1964 if (FRAME_WINDOW_P (XFRAME (frame
)))
1965 /* Warping the mouse will cause enternotify and focus events. */
1966 frame_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1969 if (FRAME_MSDOS_P (XFRAME (frame
)))
1971 Fselect_frame (frame
, Qnil
);
1972 mouse_moveto (XINT (x
), XINT (y
));
1977 Fselect_frame (frame
, Qnil
);
1978 term_mouse_moveto (XINT (x
), XINT (y
));
1987 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1988 Sset_mouse_pixel_position
, 3, 3, 0,
1989 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1990 The position is given in pixels, where (0, 0) is the upper-left corner
1991 of the frame, X is the horizontal offset, and Y is the vertical offset.
1993 Note, this is a no-op for an X frame that is not visible.
1994 If you have just created a frame, you must wait for it to become visible
1995 before calling this function on it, like this.
1996 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1997 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1999 CHECK_LIVE_FRAME (frame
);
2000 CHECK_TYPE_RANGED_INTEGER (int, x
);
2001 CHECK_TYPE_RANGED_INTEGER (int, y
);
2003 /* I think this should be done with a hook. */
2004 #ifdef HAVE_WINDOW_SYSTEM
2005 if (FRAME_WINDOW_P (XFRAME (frame
)))
2006 /* Warping the mouse will cause enternotify and focus events. */
2007 frame_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
2010 if (FRAME_MSDOS_P (XFRAME (frame
)))
2012 Fselect_frame (frame
, Qnil
);
2013 mouse_moveto (XINT (x
), XINT (y
));
2018 Fselect_frame (frame
, Qnil
);
2019 term_mouse_moveto (XINT (x
), XINT (y
));
2028 static void make_frame_visible_1 (Lisp_Object
);
2030 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
2032 doc
: /* Make the frame FRAME visible (assuming it is an X window).
2033 If omitted, FRAME defaults to the currently selected frame. */)
2036 struct frame
*f
= decode_live_frame (frame
);
2038 /* I think this should be done with a hook. */
2039 #ifdef HAVE_WINDOW_SYSTEM
2040 if (FRAME_WINDOW_P (f
))
2041 x_make_frame_visible (f
);
2044 make_frame_visible_1 (f
->root_window
);
2046 /* Make menu bar update for the Buffers and Frames menus. */
2047 /* windows_or_buffers_changed = 15; FIXME: Why? */
2049 XSETFRAME (frame
, f
);
2053 /* Update the display_time slot of the buffers shown in WINDOW
2054 and all its descendants. */
2057 make_frame_visible_1 (Lisp_Object window
)
2061 for (; !NILP (window
); window
= w
->next
)
2063 w
= XWINDOW (window
);
2064 if (WINDOWP (w
->contents
))
2065 make_frame_visible_1 (w
->contents
);
2067 bset_display_time (XBUFFER (w
->contents
), Fcurrent_time ());
2071 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
2073 doc
: /* Make the frame FRAME invisible.
2074 If omitted, FRAME defaults to the currently selected frame.
2075 On graphical displays, invisible frames are not updated and are
2076 usually not displayed at all, even in a window system's \"taskbar\".
2078 Normally you may not make FRAME invisible if all other frames are invisible,
2079 but if the second optional argument FORCE is non-nil, you may do so.
2081 This function has no effect on text terminal frames. Such frames are
2082 always considered visible, whether or not they are currently being
2083 displayed in the terminal. */)
2084 (Lisp_Object frame
, Lisp_Object force
)
2086 struct frame
*f
= decode_live_frame (frame
);
2088 if (NILP (force
) && !other_visible_frames (f
))
2089 error ("Attempt to make invisible the sole visible or iconified frame");
2091 /* Don't allow minibuf_window to remain on an invisible frame. */
2092 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2094 /* I think this should be done with a hook. */
2095 #ifdef HAVE_WINDOW_SYSTEM
2096 if (FRAME_WINDOW_P (f
))
2097 x_make_frame_invisible (f
);
2100 /* Make menu bar update for the Buffers and Frames menus. */
2101 windows_or_buffers_changed
= 16;
2106 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
2108 doc
: /* Make the frame FRAME into an icon.
2109 If omitted, FRAME defaults to the currently selected frame. */)
2112 struct frame
*f
= decode_live_frame (frame
);
2114 /* Don't allow minibuf_window to remain on an iconified frame. */
2115 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2117 /* I think this should be done with a hook. */
2118 #ifdef HAVE_WINDOW_SYSTEM
2119 if (FRAME_WINDOW_P (f
))
2120 x_iconify_frame (f
);
2123 /* Make menu bar update for the Buffers and Frames menus. */
2124 windows_or_buffers_changed
= 17;
2129 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
2131 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
2132 Return the symbol `icon' if FRAME is iconified or \"minimized\".
2133 Return nil if FRAME was made invisible, via `make-frame-invisible'.
2134 On graphical displays, invisible frames are not updated and are
2135 usually not displayed at all, even in a window system's \"taskbar\".
2137 If FRAME is a text terminal frame, this always returns t.
2138 Such frames are always considered visible, whether or not they are
2139 currently being displayed on the terminal. */)
2142 CHECK_LIVE_FRAME (frame
);
2144 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2146 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
2151 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
2153 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
2156 Lisp_Object tail
, frame
, value
= Qnil
;
2158 FOR_EACH_FRAME (tail
, frame
)
2159 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2160 value
= Fcons (frame
, value
);
2166 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
2167 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
2168 If FRAME is invisible or iconified, make it visible.
2169 If you don't specify a frame, the selected frame is used.
2170 If Emacs is displaying on an ordinary terminal or some other device which
2171 doesn't support multiple overlapping frames, this function selects FRAME. */)
2174 struct frame
*f
= decode_live_frame (frame
);
2176 XSETFRAME (frame
, f
);
2178 if (FRAME_TERMCAP_P (f
))
2179 /* On a text terminal select FRAME. */
2180 Fselect_frame (frame
, Qnil
);
2182 /* Do like the documentation says. */
2183 Fmake_frame_visible (frame
);
2185 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2186 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
2191 /* Should we have a corresponding function called Flower_Power? */
2192 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
2193 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2194 If you don't specify a frame, the selected frame is used.
2195 If Emacs is displaying on an ordinary terminal or some other device which
2196 doesn't support multiple overlapping frames, this function does nothing. */)
2199 struct frame
*f
= decode_live_frame (frame
);
2201 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2202 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2208 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2210 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2211 In other words, switch-frame events caused by events in FRAME will
2212 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2213 FOCUS-FRAME after reading an event typed at FRAME.
2215 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
2216 frame again receives its own keystrokes.
2218 Focus redirection is useful for temporarily redirecting keystrokes to
2219 a surrogate minibuffer frame when a frame doesn't have its own
2222 A frame's focus redirection can be changed by `select-frame'. If frame
2223 FOO is selected, and then a different frame BAR is selected, any
2224 frames redirecting their focus to FOO are shifted to redirect their
2225 focus to BAR. This allows focus redirection to work properly when the
2226 user switches from one frame to another using `select-window'.
2228 This means that a frame whose focus is redirected to itself is treated
2229 differently from a frame whose focus is redirected to nil; the former
2230 is affected by `select-frame', while the latter is not.
2232 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2233 (Lisp_Object frame
, Lisp_Object focus_frame
)
2235 /* Note that we don't check for a live frame here. It's reasonable
2236 to redirect the focus of a frame you're about to delete, if you
2237 know what other frame should receive those keystrokes. */
2238 struct frame
*f
= decode_any_frame (frame
);
2240 if (! NILP (focus_frame
))
2241 CHECK_LIVE_FRAME (focus_frame
);
2243 fset_focus_frame (f
, focus_frame
);
2245 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2246 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2252 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 0, 1, 0,
2253 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2254 If FRAME is omitted or nil, the selected frame is used.
2255 Return nil if FRAME's focus is not redirected.
2256 See `redirect-frame-focus'. */)
2259 return FRAME_FOCUS_FRAME (decode_live_frame (frame
));
2262 DEFUN ("x-focus-frame", Fx_focus_frame
, Sx_focus_frame
, 1, 1, 0,
2263 doc
: /* Set the input focus to FRAME.
2264 FRAME nil means use the selected frame.
2265 If there is no window system support, this function does nothing. */)
2268 #ifdef HAVE_WINDOW_SYSTEM
2269 x_focus_frame (decode_window_system_frame (frame
));
2275 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2278 frames_discard_buffer (Lisp_Object buffer
)
2280 Lisp_Object frame
, tail
;
2282 FOR_EACH_FRAME (tail
, frame
)
2285 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
2286 fset_buried_buffer_list
2287 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
2291 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2292 If the alist already has an element for PROP, we change it. */
2295 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2297 register Lisp_Object tem
;
2299 tem
= Fassq (prop
, *alistptr
);
2301 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2307 frame_name_fnn_p (char *str
, ptrdiff_t len
)
2309 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
2312 while ('0' <= *p
&& *p
<= '9')
2320 /* Set the name of the terminal frame. Also used by MSDOS frames.
2321 Modeled after x_set_name which is used for WINDOW frames. */
2324 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2326 f
->explicit_name
= ! NILP (name
);
2328 /* If NAME is nil, set the name to F<num>. */
2331 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
2333 /* Check for no change needed in this very common case
2334 before we do any consing. */
2335 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
2338 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
2342 CHECK_STRING (name
);
2344 /* Don't change the name if it's already NAME. */
2345 if (! NILP (Fstring_equal (name
, f
->name
)))
2348 /* Don't allow the user to set the frame name to F<num>, so it
2349 doesn't clash with the names we generate for terminal frames. */
2350 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2351 error ("Frame names of the form F<num> are usurped by Emacs");
2354 fset_name (f
, name
);
2355 update_mode_lines
= 16;
2359 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2361 register Lisp_Object old_alist_elt
;
2363 /* The buffer-list parameters are stored in a special place and not
2364 in the alist. All buffers must be live. */
2365 if (EQ (prop
, Qbuffer_list
))
2367 Lisp_Object list
= Qnil
;
2368 for (; CONSP (val
); val
= XCDR (val
))
2369 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2370 list
= Fcons (XCAR (val
), list
);
2371 fset_buffer_list (f
, Fnreverse (list
));
2374 if (EQ (prop
, Qburied_buffer_list
))
2376 Lisp_Object list
= Qnil
;
2377 for (; CONSP (val
); val
= XCDR (val
))
2378 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2379 list
= Fcons (XCAR (val
), list
);
2380 fset_buried_buffer_list (f
, Fnreverse (list
));
2384 /* If PROP is a symbol which is supposed to have frame-local values,
2385 and it is set up based on this frame, switch to the global
2386 binding. That way, we can create or alter the frame-local binding
2387 without messing up the symbol's status. */
2390 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2392 switch (sym
->redirect
)
2394 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2395 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2396 case SYMBOL_LOCALIZED
:
2397 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2398 if (blv
->frame_local
&& blv_found (blv
) && XFRAME (blv
->where
) == f
)
2399 swap_in_global_binding (sym
);
2402 default: emacs_abort ();
2406 /* The tty color needed to be set before the frame's parameter
2407 alist was updated with the new value. This is not true any more,
2408 but we still do this test early on. */
2409 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2410 && f
== FRAME_TTY (f
)->previous_frame
)
2411 /* Force redisplay of this tty. */
2412 FRAME_TTY (f
)->previous_frame
= NULL
;
2414 /* Update the frame parameter alist. */
2415 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2416 if (EQ (old_alist_elt
, Qnil
))
2417 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2419 Fsetcdr (old_alist_elt
, val
);
2421 /* Update some other special parameters in their special places
2422 in addition to the alist. */
2424 if (EQ (prop
, Qbuffer_predicate
))
2425 fset_buffer_predicate (f
, val
);
2427 if (! FRAME_WINDOW_P (f
))
2429 if (EQ (prop
, Qmenu_bar_lines
))
2430 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2431 else if (EQ (prop
, Qname
))
2432 set_term_frame_name (f
, val
);
2435 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2437 if (! MINI_WINDOW_P (XWINDOW (val
)))
2438 error ("Surrogate minibuffer windows must be minibuffer windows");
2440 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2441 && !EQ (val
, f
->minibuffer_window
))
2442 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2444 /* Install the chosen minibuffer window, with proper buffer. */
2445 fset_minibuffer_window (f
, val
);
2449 /* Return color matches UNSPEC on frame F or nil if UNSPEC
2450 is not an unspecified foreground or background color. */
2453 frame_unspecified_color (struct frame
*f
, Lisp_Object unspec
)
2455 return (!strncmp (SSDATA (unspec
), unspecified_bg
, SBYTES (unspec
))
2456 ? tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
))
2457 : (!strncmp (SSDATA (unspec
), unspecified_fg
, SBYTES (unspec
))
2458 ? tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)) : Qnil
));
2461 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2462 doc
: /* Return the parameters-alist of frame FRAME.
2463 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2464 The meaningful PARMs depend on the kind of frame.
2465 If FRAME is omitted or nil, return information on the currently selected frame. */)
2469 struct frame
*f
= decode_any_frame (frame
);
2471 struct gcpro gcpro1
;
2473 if (!FRAME_LIVE_P (f
))
2476 alist
= Fcopy_alist (f
->param_alist
);
2479 if (!FRAME_WINDOW_P (f
))
2483 /* If the frame's parameter alist says the colors are
2484 unspecified and reversed, take the frame's background pixel
2485 for foreground and vice versa. */
2486 elt
= Fassq (Qforeground_color
, alist
);
2487 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2489 elt
= frame_unspecified_color (f
, XCDR (elt
));
2491 store_in_alist (&alist
, Qforeground_color
, elt
);
2494 store_in_alist (&alist
, Qforeground_color
,
2495 tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)));
2496 elt
= Fassq (Qbackground_color
, alist
);
2497 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2499 elt
= frame_unspecified_color (f
, XCDR (elt
));
2501 store_in_alist (&alist
, Qbackground_color
, elt
);
2504 store_in_alist (&alist
, Qbackground_color
,
2505 tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
)));
2506 store_in_alist (&alist
, intern ("font"),
2507 build_string (FRAME_MSDOS_P (f
)
2509 : FRAME_W32_P (f
) ? "w32term"
2512 store_in_alist (&alist
, Qname
, f
->name
);
2513 height
= (f
->new_height
2515 ? (f
->new_height
/ FRAME_LINE_HEIGHT (f
))
2518 store_in_alist (&alist
, Qheight
, make_number (height
));
2519 width
= (f
->new_width
2521 ? (f
->new_width
/ FRAME_COLUMN_WIDTH (f
))
2524 store_in_alist (&alist
, Qwidth
, make_number (width
));
2525 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2526 store_in_alist (&alist
, Qminibuffer
,
2527 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2528 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2529 : FRAME_MINIBUF_WINDOW (f
)));
2530 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2531 store_in_alist (&alist
, Qbuffer_list
, f
->buffer_list
);
2532 store_in_alist (&alist
, Qburied_buffer_list
, f
->buried_buffer_list
);
2534 /* I think this should be done with a hook. */
2535 #ifdef HAVE_WINDOW_SYSTEM
2536 if (FRAME_WINDOW_P (f
))
2537 x_report_frame_params (f
, &alist
);
2541 /* This ought to be correct in f->param_alist for an X frame. */
2543 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2544 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2552 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2553 doc
: /* Return FRAME's value for parameter PARAMETER.
2554 If FRAME is nil, describe the currently selected frame. */)
2555 (Lisp_Object frame
, Lisp_Object parameter
)
2557 struct frame
*f
= decode_any_frame (frame
);
2558 Lisp_Object value
= Qnil
;
2560 CHECK_SYMBOL (parameter
);
2562 XSETFRAME (frame
, f
);
2564 if (FRAME_LIVE_P (f
))
2566 /* Avoid consing in frequent cases. */
2567 if (EQ (parameter
, Qname
))
2569 #ifdef HAVE_X_WINDOWS
2570 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2571 value
= XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
);
2572 #endif /* HAVE_X_WINDOWS */
2573 else if (EQ (parameter
, Qbackground_color
)
2574 || EQ (parameter
, Qforeground_color
))
2576 value
= Fassq (parameter
, f
->param_alist
);
2579 value
= XCDR (value
);
2580 /* Fframe_parameters puts the actual fg/bg color names,
2581 even if f->param_alist says otherwise. This is
2582 important when param_alist's notion of colors is
2583 "unspecified". We need to do the same here. */
2584 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2585 value
= frame_unspecified_color (f
, value
);
2588 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2590 else if (EQ (parameter
, Qdisplay_type
)
2591 || EQ (parameter
, Qbackground_mode
))
2592 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2594 /* FIXME: Avoid this code path at all (as well as code duplication)
2595 by sharing more code with Fframe_parameters. */
2596 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2603 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2604 Smodify_frame_parameters
, 2, 2, 0,
2605 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2606 If FRAME is nil, it defaults to the selected frame.
2607 ALIST is an alist of parameters to change and their new values.
2608 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2609 The meaningful PARMs depend on the kind of frame.
2610 Undefined PARMs are ignored, but stored in the frame's parameter list
2611 so that `frame-parameters' will return them.
2613 The value of frame parameter FOO can also be accessed
2614 as a frame-local binding for the variable FOO, if you have
2615 enabled such bindings for that variable with `make-variable-frame-local'.
2616 Note that this functionality is obsolete as of Emacs 22.2, and its
2617 use is not recommended. Explicitly check for a frame-parameter instead. */)
2618 (Lisp_Object frame
, Lisp_Object alist
)
2620 struct frame
*f
= decode_live_frame (frame
);
2621 register Lisp_Object prop
, val
;
2625 /* I think this should be done with a hook. */
2626 #ifdef HAVE_WINDOW_SYSTEM
2627 if (FRAME_WINDOW_P (f
))
2628 x_set_frame_parameters (f
, alist
);
2632 if (FRAME_MSDOS_P (f
))
2633 IT_set_frame_parameters (f
, alist
);
2638 EMACS_INT length
= XFASTINT (Flength (alist
));
2641 Lisp_Object
*values
;
2643 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2644 values
= parms
+ length
;
2646 /* Extract parm names and values into those vectors. */
2648 for (i
= 0; CONSP (alist
); alist
= XCDR (alist
))
2653 parms
[i
] = Fcar (elt
);
2654 values
[i
] = Fcdr (elt
);
2658 /* Now process them in reverse of specified order. */
2663 store_frame_param (f
, prop
, val
);
2665 if (EQ (prop
, Qforeground_color
)
2666 || EQ (prop
, Qbackground_color
))
2667 update_face_from_frame_parameter (f
, prop
, val
);
2675 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2677 doc
: /* Height in pixels of a line in the font in frame FRAME.
2678 If FRAME is omitted or nil, the selected frame is used.
2679 For a terminal frame, the value is always 1. */)
2682 #ifdef HAVE_WINDOW_SYSTEM
2683 struct frame
*f
= decode_any_frame (frame
);
2685 if (FRAME_WINDOW_P (f
))
2686 return make_number (FRAME_LINE_HEIGHT (f
));
2689 return make_number (1);
2693 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2695 doc
: /* Width in pixels of characters in the font in frame FRAME.
2696 If FRAME is omitted or nil, the selected frame is used.
2697 On a graphical screen, the width is the standard width of the default font.
2698 For a terminal screen, the value is always 1. */)
2701 #ifdef HAVE_WINDOW_SYSTEM
2702 struct frame
*f
= decode_any_frame (frame
);
2704 if (FRAME_WINDOW_P (f
))
2705 return make_number (FRAME_COLUMN_WIDTH (f
));
2708 return make_number (1);
2711 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2712 Sframe_pixel_height
, 0, 1, 0,
2713 doc
: /* Return a FRAME's height in pixels.
2714 If FRAME is omitted or nil, the selected frame is used. The exact value
2715 of the result depends on the window-system and toolkit in use:
2717 In the Gtk+ version of Emacs, it includes only any window (including
2718 the minibuffer or echo area), mode line, and header line. It does not
2719 include the tool bar or menu bar.
2721 With other graphical versions, it also includes the tool bar and the
2724 For a text terminal, it includes the menu bar. In this case, the
2725 result is really in characters rather than pixels (i.e., is identical
2726 to `frame-height'). */)
2729 struct frame
*f
= decode_any_frame (frame
);
2731 #ifdef HAVE_WINDOW_SYSTEM
2732 if (FRAME_WINDOW_P (f
))
2733 return make_number (FRAME_PIXEL_HEIGHT (f
));
2736 return make_number (FRAME_LINES (f
));
2739 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2740 Sframe_pixel_width
, 0, 1, 0,
2741 doc
: /* Return FRAME's width in pixels.
2742 For a terminal frame, the result really gives the width in characters.
2743 If FRAME is omitted or nil, the selected frame is used. */)
2746 struct frame
*f
= decode_any_frame (frame
);
2748 #ifdef HAVE_WINDOW_SYSTEM
2749 if (FRAME_WINDOW_P (f
))
2750 return make_number (FRAME_PIXEL_WIDTH (f
));
2753 return make_number (FRAME_COLS (f
));
2756 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2757 Stool_bar_pixel_width
, 0, 1, 0,
2758 doc
: /* Return width in pixels of FRAME's tool bar.
2759 The result is greater than zero only when the tool bar is on the left
2760 or right side of FRAME. If FRAME is omitted or nil, the selected frame
2764 #ifdef FRAME_TOOLBAR_WIDTH
2765 struct frame
*f
= decode_any_frame (frame
);
2767 if (FRAME_WINDOW_P (f
))
2768 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2770 return make_number (0);
2773 DEFUN ("frame-text-cols", Fframe_text_cols
, Sframe_text_cols
, 0, 1, 0,
2774 doc
: /* Return width in columns of FRAME's text area. */)
2777 return make_number (FRAME_COLS (decode_any_frame (frame
)));
2780 DEFUN ("frame-text-lines", Fframe_text_lines
, Sframe_text_lines
, 0, 1, 0,
2781 doc
: /* Return height in lines of FRAME's text area. */)
2784 return make_number (FRAME_LINES (decode_any_frame (frame
)));
2787 DEFUN ("frame-total-cols", Fframe_total_cols
, Sframe_total_cols
, 0, 1, 0,
2788 doc
: /* Return number of total columns of FRAME. */)
2791 return make_number (FRAME_TOTAL_COLS (decode_any_frame (frame
)));
2794 DEFUN ("frame-total-lines", Fframe_total_lines
, Sframe_total_lines
, 0, 1, 0,
2795 doc
: /* Return number of total lines of FRAME. */)
2798 return make_number (FRAME_TOTAL_LINES (decode_any_frame (frame
)));
2801 DEFUN ("frame-text-width", Fframe_text_width
, Sframe_text_width
, 0, 1, 0,
2802 doc
: /* Return text area width of FRAME in pixels. */)
2805 return make_number (FRAME_TEXT_WIDTH (decode_any_frame (frame
)));
2808 DEFUN ("frame-text-height", Fframe_text_height
, Sframe_text_height
, 0, 1, 0,
2809 doc
: /* Return text area height of FRAME in pixels. */)
2812 return make_number (FRAME_TEXT_HEIGHT (decode_any_frame (frame
)));
2815 DEFUN ("frame-scroll-bar-width", Fscroll_bar_width
, Sscroll_bar_width
, 0, 1, 0,
2816 doc
: /* Return scroll bar width of FRAME in pixels. */)
2819 return make_number (FRAME_SCROLL_BAR_AREA_WIDTH (decode_any_frame (frame
)));
2822 DEFUN ("frame-scroll-bar-height", Fscroll_bar_height
, Sscroll_bar_height
, 0, 1, 0,
2823 doc
: /* Return scroll bar height of FRAME in pixels. */)
2826 return make_number (FRAME_SCROLL_BAR_AREA_HEIGHT (decode_any_frame (frame
)));
2829 DEFUN ("frame-fringe-width", Ffringe_width
, Sfringe_width
, 0, 1, 0,
2830 doc
: /* Return fringe width of FRAME in pixels. */)
2833 return make_number (FRAME_TOTAL_FRINGE_WIDTH (decode_any_frame (frame
)));
2836 DEFUN ("frame-border-width", Fborder_width
, Sborder_width
, 0, 1, 0,
2837 doc
: /* Return border width of FRAME in pixels. */)
2840 return make_number (FRAME_INTERNAL_BORDER_WIDTH (decode_any_frame (frame
)));
2843 DEFUN ("frame-right-divider-width", Fright_divider_width
, Sright_divider_width
, 0, 1, 0,
2844 doc
: /* Return width (in pixels) of vertical window dividers on FRAME. */)
2847 return make_number (FRAME_RIGHT_DIVIDER_WIDTH (decode_any_frame (frame
)));
2850 DEFUN ("frame-bottom-divider-width", Fbottom_divider_width
, Sbottom_divider_width
, 0, 1, 0,
2851 doc
: /* Return width (in pixels) of horizontal window dividers on FRAME. */)
2854 return make_number (FRAME_BOTTOM_DIVIDER_WIDTH (decode_any_frame (frame
)));
2857 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 4, 0,
2858 doc
: /* Specify that the frame FRAME has HEIGHT text lines.
2859 Optional third arg PRETEND non-nil means that redisplay should use
2860 HEIGHT lines but that the idea of the actual height of the frame should
2861 not be changed. Optional fourth argument PIXELWISE non-nil means that
2862 FRAME should be HEIGHT pixels high. */)
2863 (Lisp_Object frame
, Lisp_Object height
, Lisp_Object pretend
, Lisp_Object pixelwise
)
2865 struct frame
*f
= decode_live_frame (frame
);
2868 CHECK_TYPE_RANGED_INTEGER (int, height
);
2870 pixel_height
= (!NILP (pixelwise
)
2872 : XINT (height
) * FRAME_LINE_HEIGHT (f
));
2873 if (pixel_height
!= FRAME_TEXT_HEIGHT (f
))
2874 adjust_frame_size (f
, -1, pixel_height
, 1, !NILP (pretend
));
2879 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 4, 0,
2880 doc
: /* Specify that the frame FRAME has WIDTH columns.
2881 Optional third arg PRETEND non-nil means that redisplay should use WIDTH
2882 columns but that the idea of the actual width of the frame should not
2883 be changed. Optional fourth argument PIXELWISE non-nil means that FRAME
2884 should be WIDTH pixels wide. */)
2885 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object pretend
, Lisp_Object pixelwise
)
2887 struct frame
*f
= decode_live_frame (frame
);
2890 CHECK_TYPE_RANGED_INTEGER (int, width
);
2892 pixel_width
= (!NILP (pixelwise
)
2894 : XINT (width
) * FRAME_COLUMN_WIDTH (f
));
2895 if (pixel_width
!= FRAME_TEXT_WIDTH (f
))
2896 adjust_frame_size (f
, pixel_width
, -1, 1, !NILP (pretend
));
2901 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 4, 0,
2902 doc
: /* Sets size of FRAME to WIDTH by HEIGHT, measured in characters.
2903 Optional argument PIXELWISE non-nil means to measure in pixels. */)
2904 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object height
, Lisp_Object pixelwise
)
2906 struct frame
*f
= decode_live_frame (frame
);
2907 int pixel_width
, pixel_height
;
2909 CHECK_TYPE_RANGED_INTEGER (int, width
);
2910 CHECK_TYPE_RANGED_INTEGER (int, height
);
2912 pixel_width
= (!NILP (pixelwise
)
2914 : XINT (width
) * FRAME_COLUMN_WIDTH (f
));
2915 pixel_height
= (!NILP (pixelwise
)
2917 : XINT (height
) * FRAME_LINE_HEIGHT (f
));
2919 if (pixel_width
!= FRAME_TEXT_WIDTH (f
)
2920 || pixel_height
!= FRAME_TEXT_HEIGHT (f
))
2921 adjust_frame_size (f
, pixel_width
, pixel_height
, 1, 0);
2926 DEFUN ("set-frame-position", Fset_frame_position
,
2927 Sset_frame_position
, 3, 3, 0,
2928 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2929 If FRAME is nil, the selected frame is used. XOFFSET and YOFFSET are
2930 actually the position of the upper left corner of the frame. Negative
2931 values for XOFFSET or YOFFSET are interpreted relative to the rightmost
2932 or bottommost possible position (that stays within the screen). */)
2933 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2935 register struct frame
*f
= decode_live_frame (frame
);
2937 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2938 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2940 /* I think this should be done with a hook. */
2941 #ifdef HAVE_WINDOW_SYSTEM
2942 if (FRAME_WINDOW_P (f
))
2943 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2950 /***********************************************************************
2952 ***********************************************************************/
2954 /* Connect the frame-parameter names for X frames
2955 to the ways of passing the parameter values to the window system.
2957 The name of a parameter, as a Lisp symbol,
2958 has an `x-frame-parameter' property which is an integer in Lisp
2959 that is an index in this table. */
2961 struct frame_parm_table
{
2963 Lisp_Object
*variable
;
2966 static const struct frame_parm_table frame_parms
[] =
2968 {"auto-raise", &Qauto_raise
},
2969 {"auto-lower", &Qauto_lower
},
2970 {"background-color", 0},
2971 {"border-color", &Qborder_color
},
2972 {"border-width", &Qborder_width
},
2973 {"cursor-color", &Qcursor_color
},
2974 {"cursor-type", &Qcursor_type
},
2976 {"foreground-color", 0},
2977 {"icon-name", &Qicon_name
},
2978 {"icon-type", &Qicon_type
},
2979 {"internal-border-width", &Qinternal_border_width
},
2980 {"right-divider-width", &Qright_divider_width
},
2981 {"bottom-divider-width", &Qbottom_divider_width
},
2982 {"menu-bar-lines", &Qmenu_bar_lines
},
2983 {"mouse-color", &Qmouse_color
},
2985 {"scroll-bar-width", &Qscroll_bar_width
},
2986 {"scroll-bar-height", &Qscroll_bar_height
},
2988 {"unsplittable", &Qunsplittable
},
2989 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2990 {"horizontal-scroll-bars", &Qhorizontal_scroll_bars
},
2991 {"visibility", &Qvisibility
},
2992 {"tool-bar-lines", &Qtool_bar_lines
},
2993 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2994 {"scroll-bar-background", &Qscroll_bar_background
},
2995 {"screen-gamma", &Qscreen_gamma
},
2996 {"line-spacing", &Qline_spacing
},
2997 {"left-fringe", &Qleft_fringe
},
2998 {"right-fringe", &Qright_fringe
},
2999 {"wait-for-wm", &Qwait_for_wm
},
3000 {"fullscreen", &Qfullscreen
},
3001 {"font-backend", &Qfont_backend
},
3003 {"sticky", &Qsticky
},
3004 {"tool-bar-position", &Qtool_bar_position
},
3007 #ifdef HAVE_WINDOW_SYSTEM
3009 /* Change the parameters of frame F as specified by ALIST.
3010 If a parameter is not specially recognized, do nothing special;
3011 otherwise call the `x_set_...' function for that parameter.
3012 Except for certain geometry properties, always call store_frame_param
3013 to store the new value in the parameter alist. */
3016 x_set_frame_parameters (struct frame
*f
, Lisp_Object alist
)
3020 /* If both of these parameters are present, it's more efficient to
3021 set them both at once. So we wait until we've looked at the
3022 entire list before we set them. */
3024 bool width_change
= 0, height_change
= 0;
3027 Lisp_Object left
, top
;
3029 /* Same with these. */
3030 Lisp_Object icon_left
, icon_top
;
3032 /* Record in these vectors all the parms specified. */
3034 Lisp_Object
*values
;
3036 bool left_no_change
= 0, top_no_change
= 0;
3037 #ifdef HAVE_X_WINDOWS
3038 bool icon_left_no_change
= 0, icon_top_no_change
= 0;
3040 struct gcpro gcpro1
, gcpro2
;
3043 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3046 parms
= alloca (i
* sizeof *parms
);
3047 values
= alloca (i
* sizeof *values
);
3049 /* Extract parm names and values into those vectors. */
3052 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3057 parms
[i
] = Fcar (elt
);
3058 values
[i
] = Fcdr (elt
);
3061 /* TAIL and ALIST are not used again below here. */
3062 alist
= tail
= Qnil
;
3064 GCPRO2 (*parms
, *values
);
3068 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
3069 because their values appear in VALUES and strings are not valid. */
3070 top
= left
= Qunbound
;
3071 icon_left
= icon_top
= Qunbound
;
3073 /* Process foreground_color and background_color before anything else.
3074 They are independent of other properties, but other properties (e.g.,
3075 cursor_color) are dependent upon them. */
3076 /* Process default font as well, since fringe widths depends on it. */
3077 for (p
= 0; p
< i
; p
++)
3079 Lisp_Object prop
, val
;
3083 if (EQ (prop
, Qforeground_color
)
3084 || EQ (prop
, Qbackground_color
)
3085 || EQ (prop
, Qfont
))
3087 register Lisp_Object param_index
, old_value
;
3089 old_value
= get_frame_param (f
, prop
);
3090 if (NILP (Fequal (val
, old_value
)))
3092 store_frame_param (f
, prop
, val
);
3094 param_index
= Fget (prop
, Qx_frame_parameter
);
3095 if (NATNUMP (param_index
)
3096 && XFASTINT (param_index
) < ARRAYELTS (frame_parms
)
3097 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3098 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3103 /* Now process them in reverse of specified order. */
3106 Lisp_Object prop
, val
;
3111 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
3114 width
= XFASTINT (val
) * FRAME_COLUMN_WIDTH (f
) ;
3116 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
3119 height
= XFASTINT (val
) * FRAME_LINE_HEIGHT (f
);
3121 else if (EQ (prop
, Qtop
))
3123 else if (EQ (prop
, Qleft
))
3125 else if (EQ (prop
, Qicon_top
))
3127 else if (EQ (prop
, Qicon_left
))
3129 else if (EQ (prop
, Qforeground_color
)
3130 || EQ (prop
, Qbackground_color
)
3131 || EQ (prop
, Qfont
))
3132 /* Processed above. */
3136 register Lisp_Object param_index
, old_value
;
3138 old_value
= get_frame_param (f
, prop
);
3140 store_frame_param (f
, prop
, val
);
3142 param_index
= Fget (prop
, Qx_frame_parameter
);
3143 if (NATNUMP (param_index
)
3144 && XFASTINT (param_index
) < ARRAYELTS (frame_parms
)
3145 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3146 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3150 /* Don't die if just one of these was set. */
3151 if (EQ (left
, Qunbound
))
3154 if (f
->left_pos
< 0)
3155 left
= list2 (Qplus
, make_number (f
->left_pos
));
3157 XSETINT (left
, f
->left_pos
);
3159 if (EQ (top
, Qunbound
))
3163 top
= list2 (Qplus
, make_number (f
->top_pos
));
3165 XSETINT (top
, f
->top_pos
);
3168 /* If one of the icon positions was not set, preserve or default it. */
3169 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
3171 #ifdef HAVE_X_WINDOWS
3172 icon_left_no_change
= 1;
3174 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3175 if (NILP (icon_left
))
3176 XSETINT (icon_left
, 0);
3178 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
3180 #ifdef HAVE_X_WINDOWS
3181 icon_top_no_change
= 1;
3183 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3184 if (NILP (icon_top
))
3185 XSETINT (icon_top
, 0);
3188 /* Don't set these parameters unless they've been explicitly
3189 specified. The window might be mapped or resized while we're in
3190 this function, and we don't want to override that unless the lisp
3191 code has asked for it.
3193 Don't set these parameters unless they actually differ from the
3194 window's current parameters; the window may not actually exist
3199 XSETFRAME (frame
, f
);
3201 if ((width_change
&& width
!= FRAME_TEXT_WIDTH (f
))
3202 || (height_change
&& height
!= FRAME_TEXT_HEIGHT (f
))
3203 || f
->new_height
|| f
->new_width
)
3205 /* If necessary provide default values for HEIGHT and WIDTH. Do
3206 that here since otherwise a size change implied by an
3207 intermittent font change may get lost as in Bug#17142. */
3209 width
= (f
->new_width
3212 : (f
->new_width
* FRAME_COLUMN_WIDTH (f
)))
3213 : FRAME_TEXT_WIDTH (f
));
3216 height
= (f
->new_height
3219 : (f
->new_height
* FRAME_LINE_HEIGHT (f
)))
3220 : FRAME_TEXT_HEIGHT (f
));
3222 Fset_frame_size (frame
, make_number (width
), make_number (height
), Qt
);
3225 if ((!NILP (left
) || !NILP (top
))
3226 && ! (left_no_change
&& top_no_change
)
3227 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3228 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3233 /* Record the signs. */
3234 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3235 if (EQ (left
, Qminus
))
3236 f
->size_hint_flags
|= XNegative
;
3237 else if (TYPE_RANGED_INTEGERP (int, left
))
3239 leftpos
= XINT (left
);
3241 f
->size_hint_flags
|= XNegative
;
3243 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3244 && CONSP (XCDR (left
))
3245 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
3247 leftpos
= - XINT (XCAR (XCDR (left
)));
3248 f
->size_hint_flags
|= XNegative
;
3250 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3251 && CONSP (XCDR (left
))
3252 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
3254 leftpos
= XINT (XCAR (XCDR (left
)));
3257 if (EQ (top
, Qminus
))
3258 f
->size_hint_flags
|= YNegative
;
3259 else if (TYPE_RANGED_INTEGERP (int, top
))
3261 toppos
= XINT (top
);
3263 f
->size_hint_flags
|= YNegative
;
3265 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3266 && CONSP (XCDR (top
))
3267 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
3269 toppos
= - XINT (XCAR (XCDR (top
)));
3270 f
->size_hint_flags
|= YNegative
;
3272 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
3273 && CONSP (XCDR (top
))
3274 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
3276 toppos
= XINT (XCAR (XCDR (top
)));
3280 /* Store the numeric value of the position. */
3281 f
->top_pos
= toppos
;
3282 f
->left_pos
= leftpos
;
3284 f
->win_gravity
= NorthWestGravity
;
3286 /* Actually set that position, and convert to absolute. */
3287 x_set_offset (f
, leftpos
, toppos
, -1);
3289 #ifdef HAVE_X_WINDOWS
3290 if ((!NILP (icon_left
) || !NILP (icon_top
))
3291 && ! (icon_left_no_change
&& icon_top_no_change
))
3292 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3293 #endif /* HAVE_X_WINDOWS */
3300 /* Insert a description of internally-recorded parameters of frame X
3301 into the parameter alist *ALISTPTR that is to be given to the user.
3302 Only parameters that are specific to the X window system
3303 and whose values are not correctly recorded in the frame's
3304 param_alist need to be considered here. */
3307 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3311 char buf
[INT_BUFSIZE_BOUND (w
)];
3313 /* Represent negative positions (off the top or left screen edge)
3314 in a way that Fmodify_frame_parameters will understand correctly. */
3315 XSETINT (tem
, f
->left_pos
);
3316 if (f
->left_pos
>= 0)
3317 store_in_alist (alistptr
, Qleft
, tem
);
3319 store_in_alist (alistptr
, Qleft
, list2 (Qplus
, tem
));
3321 XSETINT (tem
, f
->top_pos
);
3322 if (f
->top_pos
>= 0)
3323 store_in_alist (alistptr
, Qtop
, tem
);
3325 store_in_alist (alistptr
, Qtop
, list2 (Qplus
, tem
));
3327 store_in_alist (alistptr
, Qborder_width
,
3328 make_number (f
->border_width
));
3329 store_in_alist (alistptr
, Qinternal_border_width
,
3330 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3331 store_in_alist (alistptr
, Qright_divider_width
,
3332 make_number (FRAME_RIGHT_DIVIDER_WIDTH (f
)));
3333 store_in_alist (alistptr
, Qbottom_divider_width
,
3334 make_number (FRAME_BOTTOM_DIVIDER_WIDTH (f
)));
3335 store_in_alist (alistptr
, Qleft_fringe
,
3336 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3337 store_in_alist (alistptr
, Qright_fringe
,
3338 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3339 store_in_alist (alistptr
, Qscroll_bar_width
,
3340 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3342 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3343 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3344 /* nil means "use default width"
3345 for non-toolkit scroll bar.
3346 ruler-mode.el depends on this. */
3348 store_in_alist (alistptr
, Qscroll_bar_height
,
3349 (! FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)
3351 : FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) > 0
3352 ? make_number (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
3353 /* nil means "use default height"
3354 for non-toolkit scroll bar. */
3356 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
3357 MS-Windows it returns a value whose type is HANDLE, which is
3358 actually a pointer. Explicit casting avoids compiler
3360 w
= (uintptr_t) FRAME_X_WINDOW (f
);
3361 store_in_alist (alistptr
, Qwindow_id
,
3362 make_formatted_string (buf
, "%"pMu
, w
));
3363 #ifdef HAVE_X_WINDOWS
3364 #ifdef USE_X_TOOLKIT
3365 /* Tooltip frame may not have this widget. */
3366 if (FRAME_X_OUTPUT (f
)->widget
)
3368 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
3369 store_in_alist (alistptr
, Qouter_window_id
,
3370 make_formatted_string (buf
, "%"pMu
, w
));
3372 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3373 store_in_alist (alistptr
, Qvisibility
,
3374 (FRAME_VISIBLE_P (f
) ? Qt
3375 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3376 store_in_alist (alistptr
, Qdisplay
,
3377 XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
));
3379 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_DISPLAY_INFO (f
)->root_window
)
3382 tem
= make_natnum ((uintptr_t) FRAME_X_OUTPUT (f
)->parent_desc
);
3383 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3384 store_in_alist (alistptr
, Qparent_id
, tem
);
3385 store_in_alist (alistptr
, Qtool_bar_position
, FRAME_TOOL_BAR_POSITION (f
));
3389 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3390 the previous value of that parameter, NEW_VALUE is the new value. */
3393 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3395 if (NILP (new_value
))
3396 f
->want_fullscreen
= FULLSCREEN_NONE
;
3397 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3398 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3399 else if (EQ (new_value
, Qfullwidth
))
3400 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3401 else if (EQ (new_value
, Qfullheight
))
3402 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3403 else if (EQ (new_value
, Qmaximized
))
3404 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3406 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3407 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3411 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3412 the previous value of that parameter, NEW_VALUE is the new value. */
3415 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3417 if (NILP (new_value
))
3418 f
->extra_line_spacing
= 0;
3419 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
3420 f
->extra_line_spacing
= XFASTINT (new_value
);
3421 else if (FLOATP (new_value
))
3423 int new_spacing
= XFLOAT_DATA (new_value
) * FRAME_LINE_HEIGHT (f
) + 0.5;
3425 if (new_spacing
>= 0)
3426 f
->extra_line_spacing
= new_spacing
;
3428 signal_error ("Invalid line-spacing", new_value
);
3431 signal_error ("Invalid line-spacing", new_value
);
3432 if (FRAME_VISIBLE_P (f
))
3437 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3438 the previous value of that parameter, NEW_VALUE is the new value. */
3441 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3443 Lisp_Object bgcolor
;
3445 if (NILP (new_value
))
3447 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3448 /* The value 0.4545 is the normal viewing gamma. */
3449 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3451 signal_error ("Invalid screen-gamma", new_value
);
3453 /* Apply the new gamma value to the frame background. */
3454 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3455 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3457 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3458 if (NATNUMP (parm_index
)
3459 && XFASTINT (parm_index
) < ARRAYELTS (frame_parms
)
3460 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3461 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3465 Fclear_face_cache (Qnil
);
3470 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3472 Lisp_Object font_object
;
3474 #ifdef HAVE_X_WINDOWS
3475 Lisp_Object font_param
= arg
;
3478 /* Set the frame parameter back to the old value because we may
3479 fail to use ARG as the new parameter value. */
3480 store_frame_param (f
, Qfont
, oldval
);
3482 /* ARG is a fontset name, a font name, a cons of fontset name and a
3483 font object, or a font object. In the last case, this function
3487 fontset
= fs_query_fontset (arg
, 0);
3490 font_object
= font_open_by_name (f
, arg
);
3491 if (NILP (font_object
))
3492 error ("Font `%s' is not defined", SSDATA (arg
));
3493 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3495 else if (fontset
> 0)
3497 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
3498 if (NILP (font_object
))
3499 error ("Font `%s' is not defined", SDATA (arg
));
3500 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3503 error ("The default fontset can't be used for a frame font");
3505 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3507 /* This is the case that the ASCII font of F's fontset XCAR
3508 (arg) is changed to the font XCDR (arg) by
3509 `set-fontset-font'. */
3510 fontset
= fs_query_fontset (XCAR (arg
), 0);
3512 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3513 font_object
= XCDR (arg
);
3514 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3515 #ifdef HAVE_X_WINDOWS
3516 font_param
= Ffont_get (font_object
, QCname
);
3519 else if (FONT_OBJECT_P (arg
))
3522 #ifdef HAVE_X_WINDOWS
3523 font_param
= Ffont_get (font_object
, QCname
);
3525 /* This is to store the XLFD font name in the frame parameter for
3526 backward compatibility. We should store the font-object
3527 itself in the future. */
3528 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3529 fontset
= FRAME_FONTSET (f
);
3530 /* Check if we can use the current fontset. If not, set FONTSET
3531 to -1 to generate a new fontset from FONT-OBJECT. */
3534 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3535 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3538 signal_error ("Invalid font name", ascii_font
);
3540 if (! font_match_p (spec
, font_object
))
3545 signal_error ("Invalid font", arg
);
3547 if (! NILP (Fequal (font_object
, oldval
)))
3550 x_new_font (f
, font_object
, fontset
);
3551 store_frame_param (f
, Qfont
, arg
);
3552 #ifdef HAVE_X_WINDOWS
3553 store_frame_param (f
, Qfont_param
, font_param
);
3555 /* Recalculate toolbar height. */
3556 f
->n_tool_bar_rows
= 0;
3558 /* Ensure we redraw it. */
3559 clear_current_matrices (f
);
3561 /* Attempt to hunt down bug#16028. */
3562 SET_FRAME_GARBAGED (f
);
3564 recompute_basic_faces (f
);
3566 do_pending_window_change (0);
3568 /* We used to call face-set-after-frame-default here, but it leads to
3569 recursive calls (since that function can set the `default' face's
3570 font which in turns changes the frame's `font' parameter).
3571 Also I don't know what this call is meant to do, but it seems the
3572 wrong way to do it anyway (it does a lot more work than what seems
3573 reasonable in response to a change to `font'). */
3578 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3580 if (! NILP (new_value
)
3581 && !CONSP (new_value
))
3585 CHECK_STRING (new_value
);
3586 p0
= p1
= SSDATA (new_value
);
3590 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
3592 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3598 while ((c
= *++p1
) && c_isspace (c
));
3602 new_value
= Fnreverse (new_value
);
3605 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3609 free_all_realized_faces (Qnil
);
3611 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3612 if (NILP (new_value
))
3614 if (NILP (old_value
))
3615 error ("No font backend available");
3616 font_update_drivers (f
, old_value
);
3617 error ("None of specified font backends are available");
3619 store_frame_param (f
, Qfont_backend
, new_value
);
3625 XSETFRAME (frame
, f
);
3626 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3627 ++face_change_count
;
3628 windows_or_buffers_changed
= 18;
3633 x_set_left_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3635 int unit
= FRAME_COLUMN_WIDTH (f
);
3636 int old_width
= FRAME_LEFT_FRINGE_WIDTH (f
);
3639 new_width
= (RANGED_INTEGERP (-INT_MAX
, new_value
, INT_MAX
)
3640 ? eabs (XINT (new_value
)) : 8);
3642 if (new_width
!= old_width
)
3644 FRAME_LEFT_FRINGE_WIDTH (f
) = new_width
;
3645 FRAME_FRINGE_COLS (f
) /* Round up. */
3646 = (new_width
+ FRAME_RIGHT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
3648 if (FRAME_X_WINDOW (f
) != 0)
3649 adjust_frame_size (f
, -1, -1, 3, 0);
3651 SET_FRAME_GARBAGED (f
);
3657 x_set_right_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3659 int unit
= FRAME_COLUMN_WIDTH (f
);
3660 int old_width
= FRAME_RIGHT_FRINGE_WIDTH (f
);
3663 new_width
= (RANGED_INTEGERP (-INT_MAX
, new_value
, INT_MAX
)
3664 ? eabs (XINT (new_value
)) : 8);
3666 if (new_width
!= old_width
)
3668 FRAME_RIGHT_FRINGE_WIDTH (f
) = new_width
;
3669 FRAME_FRINGE_COLS (f
) /* Round up. */
3670 = (new_width
+ FRAME_LEFT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
3672 if (FRAME_X_WINDOW (f
) != 0)
3673 adjust_frame_size (f
, -1, -1, 3, 0);
3675 SET_FRAME_GARBAGED (f
);
3681 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3683 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3685 if (XINT (arg
) == f
->border_width
)
3688 if (FRAME_X_WINDOW (f
) != 0)
3689 error ("Cannot change the border width of a frame");
3691 f
->border_width
= XINT (arg
);
3695 x_set_right_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3697 int old
= FRAME_RIGHT_DIVIDER_WIDTH (f
);
3699 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3700 FRAME_RIGHT_DIVIDER_WIDTH (f
) = XINT (arg
);
3701 if (FRAME_RIGHT_DIVIDER_WIDTH (f
) < 0)
3702 FRAME_RIGHT_DIVIDER_WIDTH (f
) = 0;
3703 if (FRAME_RIGHT_DIVIDER_WIDTH (f
) != old
)
3705 adjust_frame_size (f
, -1, -1, 4, 0);
3706 adjust_frame_glyphs (f
);
3707 SET_FRAME_GARBAGED (f
);
3713 x_set_bottom_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3715 int old
= FRAME_BOTTOM_DIVIDER_WIDTH (f
);
3717 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3718 FRAME_BOTTOM_DIVIDER_WIDTH (f
) = XINT (arg
);
3719 if (FRAME_BOTTOM_DIVIDER_WIDTH (f
) < 0)
3720 FRAME_BOTTOM_DIVIDER_WIDTH (f
) = 0;
3721 if (FRAME_BOTTOM_DIVIDER_WIDTH (f
) != old
)
3723 adjust_frame_size (f
, -1, -1, 4, 0);
3724 adjust_frame_glyphs (f
);
3725 SET_FRAME_GARBAGED (f
);
3730 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3733 XSETFRAME (frame
, f
);
3736 Fmake_frame_invisible (frame
, Qt
);
3737 else if (EQ (value
, Qicon
))
3738 Ficonify_frame (frame
);
3740 Fmake_frame_visible (frame
);
3744 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3746 f
->auto_raise
= !EQ (Qnil
, arg
);
3750 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3752 f
->auto_lower
= !EQ (Qnil
, arg
);
3756 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3758 f
->no_split
= !NILP (arg
);
3762 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3764 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3765 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3766 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3767 || (!NILP (arg
) && !FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3769 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3771 ? vertical_scroll_bar_none
3773 ? vertical_scroll_bar_left
3775 ? vertical_scroll_bar_right
3776 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3777 ? vertical_scroll_bar_left
3778 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3779 ? vertical_scroll_bar_right
3780 : vertical_scroll_bar_none
);
3782 /* We set this parameter before creating the X window for the
3783 frame, so we can get the geometry right from the start.
3784 However, if the window hasn't been created yet, we shouldn't
3785 call x_set_window_size. */
3786 if (FRAME_X_WINDOW (f
))
3787 adjust_frame_size (f
, -1, -1, 3, 0);
3789 SET_FRAME_GARBAGED (f
);
3794 x_set_horizontal_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3796 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI)
3797 if ((NILP (arg
) && FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
))
3798 || (!NILP (arg
) && !FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)))
3800 FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)
3801 = NILP (arg
) ? false : true;
3803 /* We set this parameter before creating the X window for the
3804 frame, so we can get the geometry right from the start.
3805 However, if the window hasn't been created yet, we shouldn't
3806 call x_set_window_size. */
3807 if (FRAME_X_WINDOW (f
))
3808 adjust_frame_size (f
, -1, -1, 3, 0);
3810 SET_FRAME_GARBAGED (f
);
3816 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3818 int unit
= FRAME_COLUMN_WIDTH (f
);
3822 x_set_scroll_bar_default_width (f
);
3824 if (FRAME_X_WINDOW (f
))
3825 adjust_frame_size (f
, -1, -1, 3, 0);
3827 SET_FRAME_GARBAGED (f
);
3829 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3830 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3832 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3833 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + unit
- 1) / unit
;
3834 if (FRAME_X_WINDOW (f
))
3835 adjust_frame_size (f
, -1, -1, 3, 0);
3837 SET_FRAME_GARBAGED (f
);
3840 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3841 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3845 x_set_scroll_bar_height (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3847 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI)
3848 int unit
= FRAME_LINE_HEIGHT (f
);
3852 x_set_scroll_bar_default_height (f
);
3854 if (FRAME_X_WINDOW (f
))
3855 adjust_frame_size (f
, -1, -1, 3, 0);
3857 SET_FRAME_GARBAGED (f
);
3859 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3860 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
3862 FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) = XFASTINT (arg
);
3863 FRAME_CONFIG_SCROLL_BAR_LINES (f
) = (XFASTINT (arg
) + unit
- 1) / unit
;
3864 if (FRAME_X_WINDOW (f
))
3865 adjust_frame_size (f
, -1, -1, 3, 0);
3867 SET_FRAME_GARBAGED (f
);
3870 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.vpos
= 0;
3871 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.y
= 0;
3876 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3883 for (i
= 0; i
< 2; i
++)
3896 else if (FLOATP (item
))
3898 alpha
= XFLOAT_DATA (item
);
3899 if (! (0 <= alpha
&& alpha
<= 1.0))
3900 args_out_of_range (make_float (0.0), make_float (1.0));
3902 else if (INTEGERP (item
))
3904 EMACS_INT ialpha
= XINT (item
);
3905 if (! (0 <= ialpha
&& alpha
<= 100))
3906 args_out_of_range (make_number (0), make_number (100));
3907 alpha
= ialpha
/ 100.0;
3910 wrong_type_argument (Qnumberp
, item
);
3914 for (i
= 0; i
< 2; i
++)
3915 f
->alpha
[i
] = newval
[i
];
3917 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3919 x_set_frame_alpha (f
);
3928 /* Non-zero if mouse is grabbed on DPYINFO
3929 and we know the frame where it is. */
3931 bool x_mouse_grabbed (Display_Info
*dpyinfo
)
3933 return (dpyinfo
->grabbed
3934 && dpyinfo
->last_mouse_frame
3935 && FRAME_LIVE_P (dpyinfo
->last_mouse_frame
));
3938 /* Re-highlight something with mouse-face properties
3939 on DPYINFO using saved frame and mouse position. */
3942 x_redo_mouse_highlight (Display_Info
*dpyinfo
)
3944 if (dpyinfo
->last_mouse_motion_frame
3945 && FRAME_LIVE_P (dpyinfo
->last_mouse_motion_frame
))
3946 note_mouse_highlight (dpyinfo
->last_mouse_motion_frame
,
3947 dpyinfo
->last_mouse_motion_x
,
3948 dpyinfo
->last_mouse_motion_y
);
3951 #endif /* HAVE_NS */
3953 /* Subroutines of creating an X frame. */
3955 /* Make sure that Vx_resource_name is set to a reasonable value.
3956 Fix it up, or set it to `emacs' if it is too hopeless. */
3959 validate_x_resource_name (void)
3962 /* Number of valid characters in the resource name. */
3963 ptrdiff_t good_count
= 0;
3964 /* Number of invalid characters in the resource name. */
3965 ptrdiff_t bad_count
= 0;
3969 if (!STRINGP (Vx_resource_class
))
3970 Vx_resource_class
= build_string (EMACS_CLASS
);
3972 if (STRINGP (Vx_resource_name
))
3974 unsigned char *p
= SDATA (Vx_resource_name
);
3976 len
= SBYTES (Vx_resource_name
);
3978 /* Only letters, digits, - and _ are valid in resource names.
3979 Count the valid characters and count the invalid ones. */
3980 for (i
= 0; i
< len
; i
++)
3983 if (! ((c
>= 'a' && c
<= 'z')
3984 || (c
>= 'A' && c
<= 'Z')
3985 || (c
>= '0' && c
<= '9')
3986 || c
== '-' || c
== '_'))
3993 /* Not a string => completely invalid. */
3994 bad_count
= 5, good_count
= 0;
3996 /* If name is valid already, return. */
4000 /* If name is entirely invalid, or nearly so, or is so implausibly
4001 large that alloca might not work, use `emacs'. */
4002 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
4004 Vx_resource_name
= build_string ("emacs");
4008 /* Name is partly valid. Copy it and replace the invalid characters
4009 with underscores. */
4011 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
4013 for (i
= 0; i
< len
; i
++)
4015 int c
= SREF (new, i
);
4016 if (! ((c
>= 'a' && c
<= 'z')
4017 || (c
>= 'A' && c
<= 'Z')
4018 || (c
>= '0' && c
<= '9')
4019 || c
== '-' || c
== '_'))
4024 /* Get specified attribute from resource database RDB.
4025 See Fx_get_resource below for other parameters. */
4028 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
4030 register char *value
;
4034 CHECK_STRING (attribute
);
4035 CHECK_STRING (class);
4037 if (!NILP (component
))
4038 CHECK_STRING (component
);
4039 if (!NILP (subclass
))
4040 CHECK_STRING (subclass
);
4041 if (NILP (component
) != NILP (subclass
))
4042 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
4044 validate_x_resource_name ();
4046 /* Allocate space for the components, the dots which separate them,
4047 and the final '\0'. Make them big enough for the worst case. */
4048 name_key
= alloca (SBYTES (Vx_resource_name
)
4049 + (STRINGP (component
)
4050 ? SBYTES (component
) : 0)
4051 + SBYTES (attribute
)
4054 class_key
= alloca (SBYTES (Vx_resource_class
)
4056 + (STRINGP (subclass
)
4057 ? SBYTES (subclass
) : 0)
4060 /* Start with emacs.FRAMENAME for the name (the specific one)
4061 and with `Emacs' for the class key (the general one). */
4062 strcpy (name_key
, SSDATA (Vx_resource_name
));
4063 strcpy (class_key
, SSDATA (Vx_resource_class
));
4065 strcat (class_key
, ".");
4066 strcat (class_key
, SSDATA (class));
4068 if (!NILP (component
))
4070 strcat (class_key
, ".");
4071 strcat (class_key
, SSDATA (subclass
));
4073 strcat (name_key
, ".");
4074 strcat (name_key
, SSDATA (component
));
4077 strcat (name_key
, ".");
4078 strcat (name_key
, SSDATA (attribute
));
4080 value
= x_get_string_resource (rdb
, name_key
, class_key
);
4082 if (value
&& *value
)
4083 return build_string (value
);
4089 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
4090 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
4091 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
4092 class, where INSTANCE is the name under which Emacs was invoked, or
4093 the name specified by the `-name' or `-rn' command-line arguments.
4095 The optional arguments COMPONENT and SUBCLASS add to the key and the
4096 class, respectively. You must specify both of them or neither.
4097 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
4098 and the class is `Emacs.CLASS.SUBCLASS'. */)
4099 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
,
4100 Lisp_Object subclass
)
4102 check_window_system (NULL
);
4104 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
4105 attribute
, class, component
, subclass
);
4108 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
4111 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
,
4112 Lisp_Object
class, Lisp_Object component
,
4113 Lisp_Object subclass
)
4115 return xrdb_get_resource (dpyinfo
->xrdb
,
4116 attribute
, class, component
, subclass
);
4119 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
4120 /* Used when C code wants a resource value. */
4121 /* Called from oldXMenu/Create.c. */
4123 x_get_resource_string (const char *attribute
, const char *class)
4126 struct frame
*sf
= SELECTED_FRAME ();
4127 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
4130 /* Allocate space for the components, the dots which separate them,
4131 and the final '\0'. */
4132 char *name_key
= SAFE_ALLOCA (invocation_namelen
+ strlen (attribute
) + 2);
4133 char *class_key
= alloca ((sizeof (EMACS_CLASS
) - 1) + strlen (class) + 2);
4135 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
4136 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
4138 result
= x_get_string_resource (FRAME_DISPLAY_INFO (sf
)->xrdb
,
4139 name_key
, class_key
);
4145 /* Return the value of parameter PARAM.
4147 First search ALIST, then Vdefault_frame_alist, then the X defaults
4148 database, using ATTRIBUTE as the attribute name and CLASS as its class.
4150 Convert the resource to the type specified by desired_type.
4152 If no default is specified, return Qunbound. If you call
4153 x_get_arg, make sure you deal with Qunbound in a reasonable way,
4154 and don't let it get stored in any Lisp-visible variables! */
4157 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
4158 const char *attribute
, const char *class, enum resource_types type
)
4160 register Lisp_Object tem
;
4162 tem
= Fassq (param
, alist
);
4166 /* If we find this parm in ALIST, clear it out
4167 so that it won't be "left over" at the end. */
4169 XSETCAR (tem
, Qnil
);
4170 /* In case the parameter appears more than once in the alist,
4172 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
4173 if (CONSP (XCAR (tail
))
4174 && EQ (XCAR (XCAR (tail
)), param
))
4175 XSETCAR (XCAR (tail
), Qnil
);
4178 tem
= Fassq (param
, Vdefault_frame_alist
);
4180 /* If it wasn't specified in ALIST or the Lisp-level defaults,
4181 look in the X resources. */
4184 if (attribute
&& dpyinfo
)
4186 tem
= display_x_get_resource (dpyinfo
,
4187 build_string (attribute
),
4188 build_string (class),
4196 case RES_TYPE_NUMBER
:
4197 return make_number (atoi (SSDATA (tem
)));
4199 case RES_TYPE_BOOLEAN_NUMBER
:
4200 if (!strcmp (SSDATA (tem
), "on")
4201 || !strcmp (SSDATA (tem
), "true"))
4202 return make_number (1);
4203 return make_number (atoi (SSDATA (tem
)));
4206 case RES_TYPE_FLOAT
:
4207 return make_float (atof (SSDATA (tem
)));
4209 case RES_TYPE_BOOLEAN
:
4210 tem
= Fdowncase (tem
);
4211 if (!strcmp (SSDATA (tem
), "on")
4213 || !strcmp (SSDATA (tem
), "yes")
4215 || !strcmp (SSDATA (tem
), "true"))
4220 case RES_TYPE_STRING
:
4223 case RES_TYPE_SYMBOL
:
4224 /* As a special case, we map the values `true' and `on'
4225 to Qt, and `false' and `off' to Qnil. */
4228 lower
= Fdowncase (tem
);
4229 if (!strcmp (SSDATA (lower
), "on")
4231 || !strcmp (SSDATA (lower
), "yes")
4233 || !strcmp (SSDATA (lower
), "true"))
4235 else if (!strcmp (SSDATA (lower
), "off")
4237 || !strcmp (SSDATA (lower
), "no")
4239 || !strcmp (SSDATA (lower
), "false"))
4242 return Fintern (tem
, Qnil
);
4256 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
4257 const char *attribute
, const char *class,
4258 enum resource_types type
)
4260 return x_get_arg (FRAME_DISPLAY_INFO (f
),
4261 alist
, param
, attribute
, class, type
);
4264 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
4267 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
4269 const char *attribute
, const char *class,
4270 enum resource_types type
)
4274 value
= x_get_arg (FRAME_DISPLAY_INFO (f
), alist
, param
,
4275 attribute
, class, type
);
4276 if (! NILP (value
) && ! EQ (value
, Qunbound
))
4277 store_frame_param (f
, param
, value
);
4283 /* Record in frame F the specified or default value according to ALIST
4284 of the parameter named PROP (a Lisp symbol).
4285 If no value is specified for PROP, look for an X default for XPROP
4286 on the frame named NAME.
4287 If that is not found either, use the value DEFLT. */
4290 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
4291 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
4292 enum resource_types type
)
4296 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
4297 if (EQ (tem
, Qunbound
))
4299 x_set_frame_parameters (f
, list1 (Fcons (prop
, tem
)));
4304 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
4307 * XParseGeometry parses strings of the form
4308 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
4309 * width, height, xoffset, and yoffset are unsigned integers.
4310 * Example: "=80x24+300-49"
4311 * The equal sign is optional.
4312 * It returns a bitmask that indicates which of the four values
4313 * were actually found in the string. For each value found,
4314 * the corresponding argument is updated; for each value
4315 * not found, the corresponding argument is left unchanged.
4319 XParseGeometry (char *string
,
4321 unsigned int *width
, unsigned int *height
)
4325 unsigned long tempWidth
, tempHeight
;
4326 long int tempX
, tempY
;
4327 char *nextCharacter
;
4329 if (string
== NULL
|| *string
== '\0')
4332 string
++; /* ignore possible '=' at beg of geometry spec */
4335 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
4337 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
4338 if (strind
== nextCharacter
)
4340 strind
= nextCharacter
;
4344 if (*strind
== 'x' || *strind
== 'X')
4347 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
4348 if (strind
== nextCharacter
)
4350 strind
= nextCharacter
;
4351 mask
|= HeightValue
;
4354 if (*strind
== '+' || *strind
== '-')
4358 tempX
= strtol (strind
, &nextCharacter
, 10);
4359 if (strind
== nextCharacter
)
4361 strind
= nextCharacter
;
4363 if (*strind
== '+' || *strind
== '-')
4367 tempY
= strtol (strind
, &nextCharacter
, 10);
4368 if (strind
== nextCharacter
)
4370 strind
= nextCharacter
;
4375 /* If strind isn't at the end of the string then it's an invalid
4376 geometry specification. */
4378 if (*strind
!= '\0')
4382 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
4384 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
4385 if (mask
& WidthValue
)
4386 *width
= min (tempWidth
, UINT_MAX
);
4387 if (mask
& HeightValue
)
4388 *height
= min (tempHeight
, UINT_MAX
);
4392 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
4395 /* NS used to define x-parse-geometry in ns-win.el, but that confused
4396 make-docfile: the documentation string in ns-win.el was used for
4397 x-parse-geometry even in non-NS builds.
4399 With two definitions of x-parse-geometry in this file, various
4400 things still get confused (eg M-x apropos documentation), so that
4401 it is best if the two definitions just share the same doc-string.
4403 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4404 doc
: /* Parse a display geometry string STRING.
4405 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4406 The properties returned may include `top', `left', `height', and `width'.
4407 For X, the value of `left' or `top' may be an integer,
4408 or a list (+ N) meaning N pixels relative to top/left corner,
4409 or a list (- N) meaning -N pixels relative to bottom/right corner.
4410 On Nextstep, this just calls `ns-parse-geometry'. */)
4411 (Lisp_Object string
)
4414 unsigned int width
, height
;
4417 CHECK_STRING (string
);
4420 if (strchr (SSDATA (string
), ' ') != NULL
)
4421 return call1 (Qns_parse_geometry
, string
);
4423 geometry
= XParseGeometry (SSDATA (string
),
4424 &x
, &y
, &width
, &height
);
4426 if (geometry
& XValue
)
4428 Lisp_Object element
;
4430 if (x
>= 0 && (geometry
& XNegative
))
4431 element
= list3 (Qleft
, Qminus
, make_number (-x
));
4432 else if (x
< 0 && ! (geometry
& XNegative
))
4433 element
= list3 (Qleft
, Qplus
, make_number (x
));
4435 element
= Fcons (Qleft
, make_number (x
));
4436 result
= Fcons (element
, result
);
4439 if (geometry
& YValue
)
4441 Lisp_Object element
;
4443 if (y
>= 0 && (geometry
& YNegative
))
4444 element
= list3 (Qtop
, Qminus
, make_number (-y
));
4445 else if (y
< 0 && ! (geometry
& YNegative
))
4446 element
= list3 (Qtop
, Qplus
, make_number (y
));
4448 element
= Fcons (Qtop
, make_number (y
));
4449 result
= Fcons (element
, result
);
4452 if (geometry
& WidthValue
)
4453 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
4454 if (geometry
& HeightValue
)
4455 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
4461 /* Calculate the desired size and position of frame F.
4462 Return the flags saying which aspects were specified.
4464 Also set the win_gravity and size_hint_flags of F.
4466 Adjust height for toolbar if TOOLBAR_P is 1.
4468 This function does not make the coordinates positive. */
4470 #define DEFAULT_ROWS 35
4471 #define DEFAULT_COLS 80
4474 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, bool toolbar_p
)
4476 Lisp_Object height
, width
, user_size
, top
, left
, user_position
;
4477 long window_prompting
= 0;
4478 Display_Info
*dpyinfo
= FRAME_DISPLAY_INFO (f
);
4480 /* Default values if we fall through.
4481 Actually, if that happens we should get
4482 window manager prompting. */
4483 SET_FRAME_WIDTH (f
, DEFAULT_COLS
* FRAME_COLUMN_WIDTH (f
));
4484 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4485 SET_FRAME_HEIGHT (f
, DEFAULT_ROWS
* FRAME_LINE_HEIGHT (f
));
4486 SET_FRAME_LINES (f
, DEFAULT_ROWS
);
4488 /* Window managers expect that if program-specified
4489 positions are not (0,0), they're intentional, not defaults. */
4493 /* Ensure that earlier new_width and new_height settings won't
4494 override what we specify below. */
4495 f
->new_width
= f
->new_height
= 0;
4497 height
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4498 width
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4499 if (!EQ (width
, Qunbound
) || !EQ (height
, Qunbound
))
4501 if (!EQ (width
, Qunbound
))
4503 CHECK_NUMBER (width
);
4504 if (! (0 <= XINT (width
) && XINT (width
) <= INT_MAX
))
4505 xsignal1 (Qargs_out_of_range
, width
);
4507 SET_FRAME_WIDTH (f
, XINT (width
) * FRAME_COLUMN_WIDTH (f
));
4510 if (!EQ (height
, Qunbound
))
4512 CHECK_NUMBER (height
);
4513 if (! (0 <= XINT (height
) && XINT (height
) <= INT_MAX
))
4514 xsignal1 (Qargs_out_of_range
, height
);
4516 SET_FRAME_HEIGHT (f
, XINT (height
) * FRAME_LINE_HEIGHT (f
));
4519 user_size
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4520 if (!NILP (user_size
) && !EQ (user_size
, Qunbound
))
4521 window_prompting
|= USSize
;
4523 window_prompting
|= PSize
;
4526 /* Add a tool bar height to the initial frame height so that the user
4527 gets a text display area of the size he specified with -g or via
4528 .Xdefaults. Later changes of the tool bar height don't change the
4529 frame size. This is done so that users can create tall Emacs
4530 frames without having to guess how tall the tool bar will get. */
4531 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4535 relief
= (tool_bar_button_relief
>= 0
4536 ? tool_bar_button_relief
4537 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4539 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
4540 margin
= XFASTINT (Vtool_bar_button_margin
);
4541 else if (CONSP (Vtool_bar_button_margin
)
4542 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
4543 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4547 FRAME_TOOL_BAR_HEIGHT (f
)
4548 = DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4549 Vframe_initial_frame_tool_bar_height
= make_number (FRAME_TOOL_BAR_HEIGHT (f
));
4552 top
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4553 left
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4554 user_position
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4555 if (! EQ (top
, Qunbound
) || ! EQ (left
, Qunbound
))
4557 if (EQ (top
, Qminus
))
4560 window_prompting
|= YNegative
;
4562 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
4563 && CONSP (XCDR (top
))
4564 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
4566 f
->top_pos
= - XINT (XCAR (XCDR (top
)));
4567 window_prompting
|= YNegative
;
4569 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
4570 && CONSP (XCDR (top
))
4571 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
4573 f
->top_pos
= XINT (XCAR (XCDR (top
)));
4575 else if (EQ (top
, Qunbound
))
4579 CHECK_TYPE_RANGED_INTEGER (int, top
);
4580 f
->top_pos
= XINT (top
);
4582 window_prompting
|= YNegative
;
4585 if (EQ (left
, Qminus
))
4588 window_prompting
|= XNegative
;
4590 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
4591 && CONSP (XCDR (left
))
4592 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
4594 f
->left_pos
= - XINT (XCAR (XCDR (left
)));
4595 window_prompting
|= XNegative
;
4597 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
4598 && CONSP (XCDR (left
))
4599 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
4601 f
->left_pos
= XINT (XCAR (XCDR (left
)));
4603 else if (EQ (left
, Qunbound
))
4607 CHECK_TYPE_RANGED_INTEGER (int, left
);
4608 f
->left_pos
= XINT (left
);
4609 if (f
->left_pos
< 0)
4610 window_prompting
|= XNegative
;
4613 if (!NILP (user_position
) && ! EQ (user_position
, Qunbound
))
4614 window_prompting
|= USPosition
;
4616 window_prompting
|= PPosition
;
4619 if (window_prompting
& XNegative
)
4621 if (window_prompting
& YNegative
)
4622 f
->win_gravity
= SouthEastGravity
;
4624 f
->win_gravity
= NorthEastGravity
;
4628 if (window_prompting
& YNegative
)
4629 f
->win_gravity
= SouthWestGravity
;
4631 f
->win_gravity
= NorthWestGravity
;
4634 f
->size_hint_flags
= window_prompting
;
4636 return window_prompting
;
4641 #endif /* HAVE_WINDOW_SYSTEM */
4644 frame_make_pointer_invisible (struct frame
*f
)
4646 if (! NILP (Vmake_pointer_invisible
))
4648 if (f
&& FRAME_LIVE_P (f
) && !f
->pointer_invisible
4649 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4652 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4653 f
->pointer_invisible
= 1;
4659 frame_make_pointer_visible (struct frame
*f
)
4661 /* We don't check Vmake_pointer_invisible here in case the
4662 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4663 if (f
&& FRAME_LIVE_P (f
) && f
->pointer_invisible
&& f
->mouse_moved
4664 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4666 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4667 f
->pointer_invisible
= 0;
4671 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4672 Sframe_pointer_visible_p
, 0, 1, 0,
4673 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4674 Otherwise it returns nil. FRAME omitted or nil means the
4675 selected frame. This is useful when `make-pointer-invisible' is set. */)
4678 return decode_any_frame (frame
)->pointer_invisible
? Qnil
: Qt
;
4683 /***********************************************************************
4685 ***********************************************************************/
4687 #ifdef HAVE_WINDOW_SYSTEM
4689 # if (defined HAVE_NS \
4690 || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR)))
4692 free_monitors (struct MonitorInfo
*monitors
, int n_monitors
)
4695 for (i
= 0; i
< n_monitors
; ++i
)
4696 xfree (monitors
[i
].name
);
4702 make_monitor_attribute_list (struct MonitorInfo
*monitors
,
4704 int primary_monitor
,
4705 Lisp_Object monitor_frames
,
4708 Lisp_Object attributes_list
= Qnil
;
4709 Lisp_Object primary_monitor_attributes
= Qnil
;
4712 for (i
= 0; i
< n_monitors
; ++i
)
4714 Lisp_Object geometry
, workarea
, attributes
= Qnil
;
4715 struct MonitorInfo
*mi
= &monitors
[i
];
4717 if (mi
->geom
.width
== 0) continue;
4719 workarea
= list4i (mi
->work
.x
, mi
->work
.y
,
4720 mi
->work
.width
, mi
->work
.height
);
4721 geometry
= list4i (mi
->geom
.x
, mi
->geom
.y
,
4722 mi
->geom
.width
, mi
->geom
.height
);
4723 attributes
= Fcons (Fcons (Qsource
, build_string (source
)),
4725 attributes
= Fcons (Fcons (Qframes
, AREF (monitor_frames
, i
)),
4727 attributes
= Fcons (Fcons (Qmm_size
,
4728 list2i (mi
->mm_width
, mi
->mm_height
)),
4730 attributes
= Fcons (Fcons (Qworkarea
, workarea
), attributes
);
4731 attributes
= Fcons (Fcons (Qgeometry
, geometry
), attributes
);
4733 attributes
= Fcons (Fcons (Qname
, make_string (mi
->name
,
4734 strlen (mi
->name
))),
4737 if (i
== primary_monitor
)
4738 primary_monitor_attributes
= attributes
;
4740 attributes_list
= Fcons (attributes
, attributes_list
);
4743 if (!NILP (primary_monitor_attributes
))
4744 attributes_list
= Fcons (primary_monitor_attributes
, attributes_list
);
4745 return attributes_list
;
4748 #endif /* HAVE_WINDOW_SYSTEM */
4751 /***********************************************************************
4753 ***********************************************************************/
4756 syms_of_frame (void)
4758 DEFSYM (Qframep
, "framep");
4759 DEFSYM (Qframe_live_p
, "frame-live-p");
4760 DEFSYM (Qframe_windows_min_size
, "frame-windows-min-size");
4761 DEFSYM (Qexplicit_name
, "explicit-name");
4762 DEFSYM (Qheight
, "height");
4763 DEFSYM (Qicon
, "icon");
4764 DEFSYM (Qminibuffer
, "minibuffer");
4765 DEFSYM (Qmodeline
, "modeline");
4766 DEFSYM (Qonly
, "only");
4767 DEFSYM (Qnone
, "none");
4768 DEFSYM (Qwidth
, "width");
4769 DEFSYM (Qgeometry
, "geometry");
4770 DEFSYM (Qicon_left
, "icon-left");
4771 DEFSYM (Qicon_top
, "icon-top");
4772 DEFSYM (Qtooltip
, "tooltip");
4773 DEFSYM (Quser_position
, "user-position");
4774 DEFSYM (Quser_size
, "user-size");
4775 DEFSYM (Qwindow_id
, "window-id");
4776 #ifdef HAVE_X_WINDOWS
4777 DEFSYM (Qouter_window_id
, "outer-window-id");
4779 DEFSYM (Qparent_id
, "parent-id");
4781 DEFSYM (Qw32
, "w32");
4784 DEFSYM (Qvisible
, "visible");
4785 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4786 DEFSYM (Qbuffer_list
, "buffer-list");
4787 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4788 DEFSYM (Qdisplay_type
, "display-type");
4789 DEFSYM (Qbackground_mode
, "background-mode");
4790 DEFSYM (Qnoelisp
, "noelisp");
4791 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4792 DEFSYM (Qtty
, "tty");
4793 DEFSYM (Qtty_type
, "tty-type");
4795 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4797 DEFSYM (Qfullwidth
, "fullwidth");
4798 DEFSYM (Qfullheight
, "fullheight");
4799 DEFSYM (Qfullboth
, "fullboth");
4800 DEFSYM (Qmaximized
, "maximized");
4801 DEFSYM (Qx_resource_name
, "x-resource-name");
4802 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4804 DEFSYM (Qterminal
, "terminal");
4806 DEFSYM (Qgeometry
, "geometry");
4807 DEFSYM (Qworkarea
, "workarea");
4808 DEFSYM (Qmm_size
, "mm-size");
4809 DEFSYM (Qframes
, "frames");
4810 DEFSYM (Qsource
, "source");
4813 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4819 for (i
= 0; i
< ARRAYELTS (frame_parms
); i
++)
4821 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4822 if (frame_parms
[i
].variable
)
4824 *frame_parms
[i
].variable
= v
;
4825 staticpro (frame_parms
[i
].variable
);
4827 Fput (v
, Qx_frame_parameter
, make_number (i
));
4831 #ifdef HAVE_WINDOW_SYSTEM
4832 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4833 doc
: /* The name Emacs uses to look up X resources.
4834 `x-get-resource' uses this as the first component of the instance name
4835 when requesting resource values.
4836 Emacs initially sets `x-resource-name' to the name under which Emacs
4837 was invoked, or to the value specified with the `-name' or `-rn'
4838 switches, if present.
4840 It may be useful to bind this variable locally around a call
4841 to `x-get-resource'. See also the variable `x-resource-class'. */);
4842 Vx_resource_name
= Qnil
;
4844 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4845 doc
: /* The class Emacs uses to look up X resources.
4846 `x-get-resource' uses this as the first component of the instance class
4847 when requesting resource values.
4849 Emacs initially sets `x-resource-class' to "Emacs".
4851 Setting this variable permanently is not a reasonable thing to do,
4852 but binding this variable locally around a call to `x-get-resource'
4853 is a reasonable practice. See also the variable `x-resource-name'. */);
4854 Vx_resource_class
= build_string (EMACS_CLASS
);
4856 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4857 doc
: /* The lower limit of the frame opacity (alpha transparency).
4858 The value should range from 0 (invisible) to 100 (completely opaque).
4859 You can also use a floating number between 0.0 and 1.0. */);
4860 Vframe_alpha_lower_limit
= make_number (20);
4863 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4864 doc
: /* Alist of default values for frame creation.
4865 These may be set in your init file, like this:
4866 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4867 These override values given in window system configuration data,
4868 including X Windows' defaults database.
4869 For values specific to the first Emacs frame, see `initial-frame-alist'.
4870 For window-system specific values, see `window-system-default-frame-alist'.
4871 For values specific to the separate minibuffer frame, see
4872 `minibuffer-frame-alist'.
4873 The `menu-bar-lines' element of the list controls whether new frames
4874 have menu bars; `menu-bar-mode' works by altering this element.
4875 Setting this variable does not affect existing frames, only new ones. */);
4876 Vdefault_frame_alist
= Qnil
;
4878 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4879 doc
: /* Default position of vertical scroll bars on this window-system. */);
4880 #ifdef HAVE_WINDOW_SYSTEM
4881 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
4882 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4884 Vdefault_frame_scroll_bars
= Qright
;
4886 Vdefault_frame_scroll_bars
= Qleft
;
4889 Vdefault_frame_scroll_bars
= Qnil
;
4892 DEFVAR_LISP ("default-frame-horizontal-scroll-bars", Vdefault_frame_horizontal_scroll_bars
,
4893 doc
: /* Default value for horizontal scroll bars on this window-system. */);
4894 #ifdef HAVE_WINDOW_SYSTEM
4895 Vdefault_frame_horizontal_scroll_bars
= Qt
;
4897 Vdefault_frame_horizontal_scroll_bars
= Qnil
;
4900 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
4901 scroll_bar_adjust_thumb_portion_p
,
4902 doc
: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
4903 Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
4904 even if the end of the buffer is shown (i.e. overscrolling).
4905 Set to nil if you want the thumb to be at the bottom when the end of the buffer
4906 is shown. Also, the thumb fills the whole scroll bar when the entire buffer
4907 is visible. In this case you can not overscroll. */);
4908 scroll_bar_adjust_thumb_portion_p
= 1;
4910 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4911 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4913 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4914 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4915 `mouse-position' calls this function, passing its usual return value as
4916 argument, and returns whatever this function returns.
4917 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4918 which need to do mouse handling at the Lisp level. */);
4919 Vmouse_position_function
= Qnil
;
4921 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4922 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4923 If the value is an integer, highlighting is only shown after moving the
4924 mouse, while keyboard input turns off the highlight even when the mouse
4925 is over the clickable text. However, the mouse shape still indicates
4926 when the mouse is over clickable text. */);
4927 Vmouse_highlight
= Qt
;
4929 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4930 doc
: /* If non-nil, make pointer invisible while typing.
4931 The pointer becomes visible again when the mouse is moved. */);
4932 Vmake_pointer_invisible
= Qt
;
4934 DEFVAR_LISP ("focus-in-hook", Vfocus_in_hook
,
4935 doc
: /* Normal hook run when a frame gains input focus. */);
4936 Vfocus_in_hook
= Qnil
;
4937 DEFSYM (Qfocus_in_hook
, "focus-in-hook");
4939 DEFVAR_LISP ("focus-out-hook", Vfocus_out_hook
,
4940 doc
: /* Normal hook run when a frame loses input focus. */);
4941 Vfocus_out_hook
= Qnil
;
4942 DEFSYM (Qfocus_out_hook
, "focus-out-hook");
4944 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4945 doc
: /* Functions run before deleting a frame.
4946 The functions are run with one arg, the frame to be deleted.
4949 Note that functions in this list may be called just before the frame is
4950 actually deleted, or some time later (or even both when an earlier function
4951 in `delete-frame-functions' (indirectly) calls `delete-frame'
4953 Vdelete_frame_functions
= Qnil
;
4954 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
4956 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4957 doc
: /* Non-nil if Menu-Bar mode is enabled.
4958 See the command `menu-bar-mode' for a description of this minor mode.
4959 Setting this variable directly does not take effect;
4960 either customize it (see the info node `Easy Customization')
4961 or call the function `menu-bar-mode'. */);
4962 Vmenu_bar_mode
= Qt
;
4964 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4965 doc
: /* Non-nil if Tool-Bar mode is enabled.
4966 See the command `tool-bar-mode' for a description of this minor mode.
4967 Setting this variable directly does not take effect;
4968 either customize it (see the info node `Easy Customization')
4969 or call the function `tool-bar-mode'. */);
4970 #ifdef HAVE_WINDOW_SYSTEM
4971 Vtool_bar_mode
= Qt
;
4973 Vtool_bar_mode
= Qnil
;
4976 DEFVAR_LISP ("frame-initial-frame-tool-bar-height", Vframe_initial_frame_tool_bar_height
,
4977 doc
: /* Height of tool bar of initial frame. */);
4978 Vframe_initial_frame_tool_bar_height
= make_number (0);
4980 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4981 doc
: /* Minibufferless frames use this frame's minibuffer.
4982 Emacs cannot create minibufferless frames unless this is set to an
4983 appropriate surrogate.
4985 Emacs consults this variable only when creating minibufferless
4986 frames; once the frame is created, it sticks with its assigned
4987 minibuffer, no matter what this variable is set to. This means that
4988 this variable doesn't necessarily say anything meaningful about the
4989 current set of frames, or where the minibuffer is currently being
4992 This variable is local to the current terminal and cannot be buffer-local. */);
4994 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
4995 doc
: /* Non-nil if window system changes focus when you move the mouse.
4996 You should set this variable to tell Emacs how your window manager
4997 handles focus, since there is no way in general for Emacs to find out
4998 automatically. See also `mouse-autoselect-window'. */);
4999 focus_follows_mouse
= 0;
5001 DEFVAR_BOOL ("frame-resize-pixelwise", frame_resize_pixelwise
,
5002 doc
: /* Non-nil means resize frames pixelwise.
5003 If this option is nil, resizing a frame rounds its sizes to the frame's
5004 current values of `frame-char-height' and `frame-char-width'. If this
5005 is non-nil, no rounding occurs, hence frame sizes can increase/decrease
5008 With some window managers you may have to set this to non-nil in order
5009 to fully maximize frames. To resize your initial frame pixelwise, set
5010 this option to a non-nil value in your init file. */);
5011 frame_resize_pixelwise
= 0;
5013 DEFVAR_BOOL ("frame-inhibit-implied-resize", frame_inhibit_implied_resize
,
5014 doc
: /* Non-nil means do not resize frame implicitly.
5015 If this option is nil, setting default font, menubar mode, fringe width,
5016 or scroll bar mode of a specific frame may resize the frame in order to
5017 preserve the number of columns or lines it displays. If this option is
5018 non-nil, no such resizing is done. */);
5019 frame_inhibit_implied_resize
= 0;
5021 staticpro (&Vframe_list
);
5024 defsubr (&Sframe_live_p
);
5025 defsubr (&Swindow_system
);
5026 defsubr (&Smake_terminal_frame
);
5027 defsubr (&Shandle_switch_frame
);
5028 defsubr (&Sselect_frame
);
5029 defsubr (&Sselected_frame
);
5030 defsubr (&Sframe_list
);
5031 defsubr (&Snext_frame
);
5032 defsubr (&Sprevious_frame
);
5033 defsubr (&Slast_nonminibuf_frame
);
5034 defsubr (&Sdelete_frame
);
5035 defsubr (&Smouse_position
);
5036 defsubr (&Smouse_pixel_position
);
5037 defsubr (&Sset_mouse_position
);
5038 defsubr (&Sset_mouse_pixel_position
);
5040 defsubr (&Sframe_configuration
);
5041 defsubr (&Srestore_frame_configuration
);
5043 defsubr (&Smake_frame_visible
);
5044 defsubr (&Smake_frame_invisible
);
5045 defsubr (&Siconify_frame
);
5046 defsubr (&Sframe_visible_p
);
5047 defsubr (&Svisible_frame_list
);
5048 defsubr (&Sraise_frame
);
5049 defsubr (&Slower_frame
);
5050 defsubr (&Sx_focus_frame
);
5051 defsubr (&Sredirect_frame_focus
);
5052 defsubr (&Sframe_focus
);
5053 defsubr (&Sframe_parameters
);
5054 defsubr (&Sframe_parameter
);
5055 defsubr (&Smodify_frame_parameters
);
5056 defsubr (&Sframe_char_height
);
5057 defsubr (&Sframe_char_width
);
5058 defsubr (&Sframe_pixel_height
);
5059 defsubr (&Sframe_pixel_width
);
5060 defsubr (&Sframe_text_cols
);
5061 defsubr (&Sframe_text_lines
);
5062 defsubr (&Sframe_total_cols
);
5063 defsubr (&Sframe_total_lines
);
5064 defsubr (&Sframe_text_width
);
5065 defsubr (&Sframe_text_height
);
5066 defsubr (&Sscroll_bar_width
);
5067 defsubr (&Sscroll_bar_height
);
5068 defsubr (&Sfringe_width
);
5069 defsubr (&Sborder_width
);
5070 defsubr (&Sright_divider_width
);
5071 defsubr (&Sbottom_divider_width
);
5072 defsubr (&Stool_bar_pixel_width
);
5073 defsubr (&Sset_frame_height
);
5074 defsubr (&Sset_frame_width
);
5075 defsubr (&Sset_frame_size
);
5076 defsubr (&Sset_frame_position
);
5077 defsubr (&Sframe_pointer_visible_p
);
5079 #ifdef HAVE_WINDOW_SYSTEM
5080 defsubr (&Sx_get_resource
);
5081 defsubr (&Sx_parse_geometry
);