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");
198 /* Return the value of frame parameter PROP in frame FRAME. */
199 #ifdef HAVE_WINDOW_SYSTEM
201 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
203 register Lisp_Object tem
;
205 tem
= Fassq (prop
, frame
->param_alist
);
213 /* Return 1 if `frame-inhibit-implied-resize' is non-nil or fullscreen
214 state of frame F would be affected by a vertical (horizontal if
215 HORIZONTAL is true) resize. */
217 frame_inhibit_resize (struct frame
*f
, bool horizontal
)
220 return (frame_inhibit_implied_resize
221 || !NILP (get_frame_param (f
, Qfullscreen
)));
226 frame_inhibit_resize (struct frame
*f
, bool horizontal
)
228 Lisp_Object fullscreen
= get_frame_param (f
, Qfullscreen
);
230 return (frame_inhibit_implied_resize
231 || EQ (fullscreen
, Qfullboth
)
232 || EQ (fullscreen
, Qfullscreen
)
233 || EQ (fullscreen
, Qmaximized
)
234 || (horizontal
&& EQ (fullscreen
, Qfullwidth
))
235 || (!horizontal
&& EQ (fullscreen
, Qfullheight
)));
240 set_menu_bar_lines_1 (Lisp_Object window
, int n
)
242 struct window
*w
= XWINDOW (window
);
243 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
246 w
->pixel_top
+= n
* FRAME_LINE_HEIGHT (f
);
248 w
->pixel_height
-= n
* FRAME_LINE_HEIGHT (f
);
250 /* Handle just the top child in a vertical split. */
251 if (WINDOW_VERTICAL_COMBINATION_P (w
))
252 set_menu_bar_lines_1 (w
->contents
, n
);
253 else if (WINDOW_HORIZONTAL_COMBINATION_P (w
))
254 /* Adjust all children in a horizontal split. */
255 for (window
= w
->contents
; !NILP (window
); window
= w
->next
)
257 w
= XWINDOW (window
);
258 set_menu_bar_lines_1 (window
, n
);
263 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
266 int olines
= FRAME_MENU_BAR_LINES (f
);
268 /* Right now, menu bars don't work properly in minibuf-only frames;
269 most of the commands try to apply themselves to the minibuffer
270 frame itself, and get an error because you can't switch buffers
271 in or split the minibuffer window. */
272 if (FRAME_MINIBUF_ONLY_P (f
))
275 if (TYPE_RANGED_INTEGERP (int, value
))
276 nlines
= XINT (value
);
280 if (nlines
!= olines
)
282 windows_or_buffers_changed
= 14;
283 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
284 FRAME_MENU_BAR_LINES (f
) = nlines
;
285 FRAME_MENU_BAR_HEIGHT (f
) = nlines
* FRAME_LINE_HEIGHT (f
);
286 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
287 adjust_frame_glyphs (f
);
291 Lisp_Object Vframe_list
;
294 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
295 doc
: /* Return non-nil if OBJECT is a frame.
297 t for a termcap frame (a character-only terminal),
298 'x' for an Emacs frame that is really an X window,
299 'w32' for an Emacs frame that is a window on MS-Windows display,
300 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
301 'pc' for a direct-write MS-DOS frame.
302 See also `frame-live-p'. */)
305 if (!FRAMEP (object
))
307 switch (XFRAME (object
)->output_method
)
309 case output_initial
: /* The initial frame is like a termcap frame. */
312 case output_x_window
:
316 case output_msdos_raw
:
325 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
326 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
327 Value is nil if OBJECT is not a live frame. If object is a live
328 frame, the return value indicates what sort of terminal device it is
329 displayed on. See the documentation of `framep' for possible
333 return ((FRAMEP (object
)
334 && FRAME_LIVE_P (XFRAME (object
)))
339 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
340 doc
: /* The name of the window system that FRAME is displaying through.
341 The value is a symbol:
342 nil for a termcap frame (a character-only terminal),
343 'x' for an Emacs frame that is really an X window,
344 'w32' for an Emacs frame that is a window on MS-Windows display,
345 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
346 'pc' for a direct-write MS-DOS frame.
348 FRAME defaults to the currently selected frame.
350 Use of this function as a predicate is deprecated. Instead,
351 use `display-graphic-p' or any of the other `display-*-p'
352 predicates which report frame's specific UI-related capabilities. */)
357 frame
= selected_frame
;
359 type
= Fframep (frame
);
362 wrong_type_argument (Qframep
, frame
);
371 frame_windows_min_size (Lisp_Object frame
, Lisp_Object horizontal
, Lisp_Object pixelwise
)
373 return XINT (call3 (Qframe_windows_min_size
, frame
, horizontal
, pixelwise
));
377 /* Make sure windows sizes of frame F are OK. new_width and new_height
378 are in pixels. A value of -1 means no change is requested for that
379 size (but the frame may still have to be resized to accomodate
380 windows with their minimum sizes.
382 The argument INHIBIT can assume the following values:
384 0 means to unconditionally call x_set_window_size even if sizes
385 apparently do not change. Fx_create_frame uses this to pass the
386 initial size to the window manager.
388 1 means to call x_set_window_size iff the pixel size really changes.
389 Fset_frame_size, Fset_frame_height, ... use this.
391 2 means to unconditionally call x_set_window_size provided
392 frame_inhibit_resize allows it. The menu bar code uses this.
394 3 means call x_set_window_size iff window minimum sizes must be
395 preserved or frame_inhibit_resize allows it, x_set_left_fringe,
396 x_set_scroll_bar_width, ... use this.
398 4 means call x_set_window_size iff window minimum sizes must be
399 preserved. x_set_tool_bar_lines, x_set_right_divider_width, ... use
400 this. BUT maybe the toolbar code shouldn't ....
402 5 means to never call x_set_window_size. change_frame_size uses
405 For 2 and 3 note that if frame_inhibit_resize inhibits resizing and
406 minimum sizes are not violated no internal resizing takes place
407 either. For 2, 3, 4 and 5 note that even if no x_set_window_size
408 call is issued, window sizes may have to be adjusted in order to
409 support minimum size constraints for the frame's windows.
411 PRETEND is as for change_frame_size. */
413 adjust_frame_size (struct frame
*f
, int new_width
, int new_height
, int inhibit
, bool pretend
)
415 int unit_width
= FRAME_COLUMN_WIDTH (f
);
416 int unit_height
= FRAME_LINE_HEIGHT (f
);
417 int old_pixel_width
= FRAME_PIXEL_WIDTH (f
);
418 int old_pixel_height
= FRAME_PIXEL_HEIGHT (f
);
419 int new_pixel_width
, new_pixel_height
;
420 /* The following two values are calculated from the old frame pixel
421 sizes and any "new" settings for tool bar, menu bar and internal
422 borders. We do it this way to detect whether we have to call
423 x_set_window_size as consequence of the new settings. */
424 int windows_width
= FRAME_WINDOWS_WIDTH (f
);
425 int windows_height
= FRAME_WINDOWS_HEIGHT (f
);
426 int min_windows_width
, min_windows_height
;
427 /* These are a bit tedious, maybe we should use a macro. */
428 struct window
*r
= XWINDOW (FRAME_ROOT_WINDOW (f
));
429 int old_windows_width
= WINDOW_PIXEL_WIDTH (r
);
430 int old_windows_height
431 = (WINDOW_PIXEL_HEIGHT (r
)
432 + (FRAME_HAS_MINIBUF_P (f
)
433 ? WINDOW_PIXEL_HEIGHT (XWINDOW (FRAME_MINIBUF_WINDOW (f
)))
435 int new_windows_width
, new_windows_height
;
436 int old_text_width
= FRAME_TEXT_WIDTH (f
);
437 int old_text_height
= FRAME_TEXT_HEIGHT (f
);
438 /* If a size is < 0 use the old value. */
439 int new_text_width
= (new_width
>= 0) ? new_width
: old_text_width
;
440 int new_text_height
= (new_height
>= 0) ? new_height
: old_text_height
;
441 int new_cols
, new_lines
;
442 bool inhibit_horizontal
, inhibit_vertical
;
445 XSETFRAME (frame
, f
);
446 /* The following two values are calculated from the old window body
447 sizes and any "new" settings for scroll bars, dividers, fringes and
448 margins (though the latter should have been processed already). */
449 min_windows_width
= frame_windows_min_size (frame
, Qt
, Qt
);
450 min_windows_height
= frame_windows_min_size (frame
, Qnil
, Qt
);
452 if (inhibit
>= 2 && inhibit
<= 4)
453 /* If INHIBIT is in [2..4] inhibit if the "old" window sizes stay
454 within the limits and either frame_inhibit_resize tells us to do
455 so or INHIBIT equals 4. */
457 inhibit_horizontal
= ((windows_width
>= min_windows_width
458 && (inhibit
== 4 || frame_inhibit_resize (f
, true)))
460 inhibit_vertical
= ((windows_height
>= min_windows_height
461 && (inhibit
== 4 || frame_inhibit_resize (f
, false)))
465 /* Otherwise inhibit if INHIBIT equals 5. */
466 inhibit_horizontal
= inhibit_vertical
= inhibit
== 5;
468 new_pixel_width
= ((inhibit_horizontal
&& (inhibit
< 5))
470 : max (FRAME_TEXT_TO_PIXEL_WIDTH (f
, new_text_width
),
472 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
473 new_windows_width
= new_pixel_width
- 2 * FRAME_INTERNAL_BORDER_WIDTH (f
);
474 new_text_width
= FRAME_PIXEL_TO_TEXT_WIDTH (f
, new_pixel_width
);
475 new_cols
= new_text_width
/ unit_width
;
477 new_pixel_height
= ((inhibit_vertical
&& (inhibit
< 5))
479 : max (FRAME_TEXT_TO_PIXEL_HEIGHT (f
, new_text_height
),
481 + FRAME_TOP_MARGIN_HEIGHT (f
)
482 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
483 new_windows_height
= (new_pixel_height
484 - FRAME_TOP_MARGIN_HEIGHT (f
)
485 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f
));
486 new_text_height
= FRAME_PIXEL_TO_TEXT_HEIGHT (f
, new_pixel_height
);
487 new_lines
= new_text_height
/ unit_height
;
489 #ifdef HAVE_WINDOW_SYSTEM
490 if (FRAME_X_WINDOW (f
)
492 && ((!inhibit_horizontal
493 && (new_pixel_width
!= old_pixel_width
494 || inhibit
== 0 || inhibit
== 2))
495 || (!inhibit_vertical
496 && (new_pixel_height
!= old_pixel_height
497 || inhibit
== 0 || inhibit
== 2))))
498 /* We are either allowed to change the frame size or the minimum
499 sizes request such a change. Do not care for fixing minimum
500 sizes here, we do that eventually when we're called from
501 change_frame_size. */
503 /* Make sure we respect fullheight and fullwidth. */
504 if (inhibit_horizontal
)
505 new_text_width
= old_text_width
;
506 else if (inhibit_vertical
)
507 new_text_height
= old_text_height
;
509 x_set_window_size (f
, 0, new_text_width
, new_text_height
, 1);
516 if (new_text_width
== old_text_width
517 && new_text_height
== old_text_height
518 && new_windows_width
== old_windows_width
519 && new_windows_height
== old_windows_height
520 && new_pixel_width
== old_pixel_width
521 && new_pixel_height
== old_pixel_height
)
522 /* No change. Sanitize window sizes and return. */
524 sanitize_window_sizes (frame
, Qt
);
525 sanitize_window_sizes (frame
, Qnil
);
533 /* We only can set screen dimensions to certain values supported
534 by our video hardware. Try to find the smallest size greater
535 or equal to the requested dimensions. */
536 dos_set_window_size (&new_lines
, &new_cols
);
539 if (new_windows_width
!= old_windows_width
)
541 resize_frame_windows (f
, new_windows_width
, 1, 1);
543 /* MSDOS frames cannot PRETEND, as they change frame size by
544 manipulating video hardware. */
545 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
546 FrameCols (FRAME_TTY (f
)) = new_cols
;
548 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
549 if (WINDOWP (f
->tool_bar_window
))
551 XWINDOW (f
->tool_bar_window
)->pixel_width
= new_windows_width
;
552 XWINDOW (f
->tool_bar_window
)->total_cols
553 = new_windows_width
/ unit_width
;
558 if (new_windows_height
!= old_windows_height
559 /* When the top margin has changed we have to recalculate the top
560 edges of all windows. No such calculation is necessary for the
562 || WINDOW_TOP_PIXEL_EDGE (r
) != FRAME_TOP_MARGIN_HEIGHT (f
))
564 resize_frame_windows (f
, new_windows_height
, 0, 1);
566 /* MSDOS frames cannot PRETEND, as they change frame size by
567 manipulating video hardware. */
568 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
569 FrameRows (FRAME_TTY (f
)) = new_lines
;
572 /* Assign new sizes. */
573 FRAME_TEXT_WIDTH (f
) = new_text_width
;
574 FRAME_TEXT_HEIGHT (f
) = new_text_height
;
575 FRAME_PIXEL_WIDTH (f
) = new_pixel_width
;
576 FRAME_PIXEL_HEIGHT (f
) = new_pixel_height
;
577 SET_FRAME_COLS (f
, new_cols
);
578 SET_FRAME_LINES (f
, new_lines
);
581 struct window
*w
= XWINDOW (FRAME_SELECTED_WINDOW (f
));
582 int text_area_x
, text_area_y
, text_area_width
, text_area_height
;
584 window_box (w
, TEXT_AREA
, &text_area_x
, &text_area_y
, &text_area_width
,
586 if (w
->cursor
.x
>= text_area_x
+ text_area_width
)
587 w
->cursor
.hpos
= w
->cursor
.x
= 0;
588 if (w
->cursor
.y
>= text_area_y
+ text_area_height
)
589 w
->cursor
.vpos
= w
->cursor
.y
= 0;
592 /* Sanitize window sizes. */
593 sanitize_window_sizes (frame
, Qt
);
594 sanitize_window_sizes (frame
, Qnil
);
596 adjust_frame_glyphs (f
);
598 SET_FRAME_GARBAGED (f
);
600 /* A frame was "resized" if one of its pixelsizes changed, even if its
601 X window wasn't resized at all. */
602 f
->resized_p
= (new_pixel_width
!= old_pixel_width
603 || new_pixel_height
!= old_pixel_height
);
607 run_window_configuration_change_hook (f
);
612 make_frame (bool mini_p
)
615 register struct frame
*f
;
616 register struct window
*rw
, *mw
;
617 register Lisp_Object root_window
;
618 register Lisp_Object mini_window
;
620 f
= allocate_frame ();
621 XSETFRAME (frame
, f
);
624 /* Initialize Lisp data. Note that allocate_frame initializes all
625 Lisp data to nil, so do it only for slots which should not be nil. */
626 fset_tool_bar_position (f
, Qtop
);
629 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
630 non-Lisp data, so do it only for slots which should not be zero.
631 To avoid subtle bugs and for the sake of readability, it's better to
632 initialize enum members explicitly even if their values are zero. */
633 f
->wants_modeline
= true;
637 f
->column_width
= 1; /* !FRAME_WINDOW_P value. */
638 f
->line_height
= 1; /* !FRAME_WINDOW_P value. */
639 #ifdef HAVE_WINDOW_SYSTEM
640 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
641 f
->horizontal_scroll_bars
= false;
642 f
->want_fullscreen
= FULLSCREEN_NONE
;
643 #if ! defined (USE_GTK) && ! defined (HAVE_NS)
644 f
->last_tool_bar_item
= -1;
648 root_window
= make_window ();
649 rw
= XWINDOW (root_window
);
652 mini_window
= make_window ();
653 mw
= XWINDOW (mini_window
);
654 wset_next (rw
, mini_window
);
655 wset_prev (mw
, root_window
);
657 wset_frame (mw
, frame
);
658 fset_minibuffer_window (f
, mini_window
);
663 wset_next (rw
, Qnil
);
664 fset_minibuffer_window (f
, Qnil
);
667 wset_frame (rw
, frame
);
670 just so that there is "something there."
671 Correct size will be set up later with adjust_frame_size. */
673 SET_FRAME_COLS (f
, 10);
674 SET_FRAME_LINES (f
, 10);
675 SET_FRAME_WIDTH (f
, FRAME_COLS (f
) * FRAME_COLUMN_WIDTH (f
));
676 SET_FRAME_HEIGHT (f
, FRAME_LINES (f
) * FRAME_LINE_HEIGHT (f
));
679 rw
->pixel_width
= rw
->total_cols
* FRAME_COLUMN_WIDTH (f
);
680 rw
->total_lines
= mini_p
? 9 : 10;
681 rw
->pixel_height
= rw
->total_lines
* FRAME_LINE_HEIGHT (f
);
685 mw
->top_line
= rw
->total_lines
;
686 mw
->pixel_top
= rw
->pixel_height
;
687 mw
->total_cols
= rw
->total_cols
;
688 mw
->pixel_width
= rw
->pixel_width
;
690 mw
->pixel_height
= FRAME_LINE_HEIGHT (f
);
693 /* Choose a buffer for the frame's root window. */
695 Lisp_Object buf
= Fcurrent_buffer ();
697 /* If current buffer is hidden, try to find another one. */
698 if (BUFFER_HIDDEN_P (XBUFFER (buf
)))
699 buf
= other_buffer_safely (buf
);
701 /* Use set_window_buffer, not Fset_window_buffer, and don't let
702 hooks be run by it. The reason is that the whole frame/window
703 arrangement is not yet fully initialized at this point. Windows
704 don't have the right size, glyph matrices aren't initialized
705 etc. Running Lisp functions at this point surely ends in a
707 set_window_buffer (root_window
, buf
, 0, 0);
708 fset_buffer_list (f
, list1 (buf
));
713 set_window_buffer (mini_window
,
714 (NILP (Vminibuffer_list
)
716 : Fcar (Vminibuffer_list
)),
718 /* No horizontal scroll bars in minibuffers. */
719 wset_horizontal_scroll_bar (mw
, Qnil
);
722 fset_root_window (f
, root_window
);
723 fset_selected_window (f
, root_window
);
724 /* Make sure this window seems more recently used than
725 a newly-created, never-selected window. */
726 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
731 #ifdef HAVE_WINDOW_SYSTEM
732 /* Make a frame using a separate minibuffer window on another frame.
733 MINI_WINDOW is the minibuffer window to use. nil means use the
734 default (the global minibuffer). */
737 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
739 register struct frame
*f
;
742 if (!NILP (mini_window
))
743 CHECK_LIVE_WINDOW (mini_window
);
745 if (!NILP (mini_window
)
746 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
747 error ("Frame and minibuffer must be on the same terminal");
749 /* Make a frame containing just a root window. */
752 if (NILP (mini_window
))
754 /* Use default-minibuffer-frame if possible. */
755 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
756 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
758 Lisp_Object frame_dummy
;
760 XSETFRAME (frame_dummy
, f
);
761 GCPRO1 (frame_dummy
);
762 /* If there's no minibuffer frame to use, create one. */
763 kset_default_minibuffer_frame
764 (kb
, call1 (intern ("make-initial-minibuffer-frame"), display
));
769 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
772 fset_minibuffer_window (f
, mini_window
);
774 /* Make the chosen minibuffer window display the proper minibuffer,
775 unless it is already showing a minibuffer. */
776 if (NILP (Fmemq (XWINDOW (mini_window
)->contents
, Vminibuffer_list
)))
777 /* Use set_window_buffer instead of Fset_window_buffer (see
778 discussion of bug#11984, bug#12025, bug#12026). */
779 set_window_buffer (mini_window
,
780 (NILP (Vminibuffer_list
)
782 : Fcar (Vminibuffer_list
)), 0, 0);
786 /* Make a frame containing only a minibuffer window. */
789 make_minibuffer_frame (void)
791 /* First make a frame containing just a root window, no minibuffer. */
793 register struct frame
*f
= make_frame (0);
794 register Lisp_Object mini_window
;
795 register Lisp_Object frame
;
797 XSETFRAME (frame
, f
);
802 f
->wants_modeline
= 0;
804 /* Now label the root window as also being the minibuffer.
805 Avoid infinite looping on the window chain by marking next pointer
808 mini_window
= f
->root_window
;
809 fset_minibuffer_window (f
, mini_window
);
810 XWINDOW (mini_window
)->mini
= 1;
811 wset_next (XWINDOW (mini_window
), Qnil
);
812 wset_prev (XWINDOW (mini_window
), Qnil
);
813 wset_frame (XWINDOW (mini_window
), frame
);
815 /* Put the proper buffer in that window. */
817 /* Use set_window_buffer instead of Fset_window_buffer (see
818 discussion of bug#11984, bug#12025, bug#12026). */
819 set_window_buffer (mini_window
,
820 (NILP (Vminibuffer_list
)
822 : Fcar (Vminibuffer_list
)), 0, 0);
825 #endif /* HAVE_WINDOW_SYSTEM */
827 /* Construct a frame that refers to a terminal. */
829 static printmax_t tty_frame_count
;
832 make_initial_frame (void)
835 struct terminal
*terminal
;
838 eassert (initial_kboard
);
840 /* The first call must initialize Vframe_list. */
841 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
844 terminal
= init_initial_terminal ();
847 XSETFRAME (frame
, f
);
849 Vframe_list
= Fcons (frame
, Vframe_list
);
852 fset_name (f
, build_pure_c_string ("F1"));
854 SET_FRAME_VISIBLE (f
, 1);
856 f
->output_method
= terminal
->type
;
857 f
->terminal
= terminal
;
858 f
->terminal
->reference_count
++;
859 f
->output_data
.nothing
= 0;
861 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
862 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
864 #ifdef HAVE_WINDOW_SYSTEM
865 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
866 FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
) = false;
869 /* The default value of menu-bar-mode is t. */
870 set_menu_bar_lines (f
, make_number (1), Qnil
);
873 init_frame_faces (f
);
875 last_nonminibuf_frame
= f
;
881 static struct frame
*
882 make_terminal_frame (struct terminal
*terminal
)
884 register struct frame
*f
;
886 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
889 error ("Terminal is not live, can't create new frames on it");
893 XSETFRAME (frame
, f
);
894 Vframe_list
= Fcons (frame
, Vframe_list
);
896 fset_name (f
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
898 SET_FRAME_VISIBLE (f
, 1);
900 f
->terminal
= terminal
;
901 f
->terminal
->reference_count
++;
903 f
->output_data
.tty
->display_info
= &the_only_display_info
;
904 if (!inhibit_window_system
905 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
906 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
907 f
->output_method
= output_msdos_raw
;
909 f
->output_method
= output_termcap
;
910 #else /* not MSDOS */
911 f
->output_method
= output_termcap
;
912 create_tty_output (f
);
913 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
914 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
915 #endif /* not MSDOS */
917 #ifdef HAVE_WINDOW_SYSTEM
918 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
919 FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
) = false;
922 FRAME_MENU_BAR_LINES (f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
923 FRAME_MENU_BAR_HEIGHT (f
) = FRAME_MENU_BAR_LINES (f
) * FRAME_LINE_HEIGHT (f
);
925 /* Set the top frame to the newly created frame. */
926 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
927 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
928 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f
)->top_frame
), 2); /* obscured */
930 FRAME_TTY (f
)->top_frame
= frame
;
933 init_frame_faces (f
);
938 /* Get a suitable value for frame parameter PARAMETER for a newly
939 created frame, based on (1) the user-supplied frame parameter
940 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
943 get_future_frame_param (Lisp_Object parameter
,
944 Lisp_Object supplied_parms
,
949 result
= Fassq (parameter
, supplied_parms
);
951 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
952 if (NILP (result
) && current_value
!= NULL
)
953 result
= build_string (current_value
);
954 if (!NILP (result
) && !STRINGP (result
))
955 result
= XCDR (result
);
956 if (NILP (result
) || !STRINGP (result
))
962 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
964 doc
: /* Create an additional terminal frame, possibly on another terminal.
965 This function takes one argument, an alist specifying frame parameters.
967 You can create multiple frames on a single text terminal, but only one
968 of them (the selected terminal frame) is actually displayed.
970 In practice, generally you don't need to specify any parameters,
971 except when you want to create a new frame on another terminal.
972 In that case, the `tty' parameter specifies the device file to open,
973 and the `tty-type' parameter specifies the terminal type. Example:
975 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
977 Note that changing the size of one terminal frame automatically
978 affects all frames on the same terminal device. */)
982 struct terminal
*t
= NULL
;
983 Lisp_Object frame
, tem
;
984 struct frame
*sf
= SELECTED_FRAME ();
987 if (sf
->output_method
!= output_msdos_raw
988 && sf
->output_method
!= output_termcap
)
990 #else /* not MSDOS */
992 #ifdef WINDOWSNT /* This should work now! */
993 if (sf
->output_method
!= output_termcap
)
994 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
996 #endif /* not MSDOS */
999 Lisp_Object terminal
;
1001 terminal
= Fassq (Qterminal
, parms
);
1002 if (CONSP (terminal
))
1004 terminal
= XCDR (terminal
);
1005 t
= get_terminal (terminal
, 1);
1008 if (t
&& t
!= the_only_display_info
.terminal
)
1009 /* msdos.c assumes a single tty_display_info object. */
1010 error ("Multiple terminals are not supported on this platform");
1012 t
= the_only_display_info
.terminal
;
1018 char *name
= 0, *type
= 0;
1019 Lisp_Object tty
, tty_type
;
1021 tty
= get_future_frame_param
1022 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1023 ? FRAME_TTY (XFRAME (selected_frame
))->name
1026 name
= xlispstrdupa (tty
);
1028 tty_type
= get_future_frame_param
1029 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1030 ? FRAME_TTY (XFRAME (selected_frame
))->type
1032 if (!NILP (tty_type
))
1033 type
= xlispstrdupa (tty_type
);
1035 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
1038 f
= make_terminal_frame (t
);
1042 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
1043 adjust_frame_size (f
, width
, height
, 5, 0);
1046 adjust_frame_glyphs (f
);
1047 calculate_costs (f
);
1048 XSETFRAME (frame
, f
);
1050 store_in_alist (&parms
, Qtty_type
, build_string (t
->display_info
.tty
->type
));
1051 store_in_alist (&parms
, Qtty
,
1052 (t
->display_info
.tty
->name
1053 ? build_string (t
->display_info
.tty
->name
)
1055 Fmodify_frame_parameters (frame
, parms
);
1057 /* Make the frame face alist be frame-specific, so that each
1058 frame could change its face definitions independently. */
1059 fset_face_alist (f
, Fcopy_alist (sf
->face_alist
));
1060 /* Simple Fcopy_alist isn't enough, because we need the contents of
1061 the vectors which are the CDRs of associations in face_alist to
1062 be copied as well. */
1063 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
1064 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
1069 /* Perform the switch to frame FRAME.
1071 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
1074 If TRACK is non-zero and the frame that currently has the focus
1075 redirects its focus to the selected frame, redirect that focused
1076 frame's focus to FRAME instead.
1078 FOR_DELETION non-zero means that the selected frame is being
1079 deleted, which includes the possibility that the frame's terminal
1082 The value of NORECORD is passed as argument to Fselect_window. */
1085 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
1087 struct frame
*sf
= SELECTED_FRAME ();
1089 /* If FRAME is a switch-frame event, extract the frame we should
1092 && EQ (XCAR (frame
), Qswitch_frame
)
1093 && CONSP (XCDR (frame
)))
1094 frame
= XCAR (XCDR (frame
));
1096 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
1097 a switch-frame event to arrive after a frame is no longer live,
1098 especially when deleting the initial frame during startup. */
1099 CHECK_FRAME (frame
);
1100 if (! FRAME_LIVE_P (XFRAME (frame
)))
1103 if (sf
== XFRAME (frame
))
1106 /* If a frame's focus has been redirected toward the currently
1107 selected frame, we should change the redirection to point to the
1108 newly selected frame. This means that if the focus is redirected
1109 from a minibufferless frame to a surrogate minibuffer frame, we
1110 can use `other-window' to switch between all the frames using
1111 that minibuffer frame, and the focus redirection will follow us
1114 /* This is too greedy; it causes inappropriate focus redirection
1115 that's hard to get rid of. */
1120 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1124 if (!FRAMEP (XCAR (tail
)))
1127 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
1129 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1130 Fredirect_frame_focus (XCAR (tail
), frame
);
1134 /* Instead, apply it only to the frame we're pointing to. */
1135 #ifdef HAVE_WINDOW_SYSTEM
1136 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
1138 Lisp_Object focus
, xfocus
;
1140 xfocus
= x_get_focus_frame (XFRAME (frame
));
1141 if (FRAMEP (xfocus
))
1143 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
1144 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1145 Fredirect_frame_focus (xfocus
, frame
);
1148 #endif /* HAVE_X_WINDOWS */
1151 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
1152 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
1154 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
1156 struct frame
*f
= XFRAME (frame
);
1157 struct tty_display_info
*tty
= FRAME_TTY (f
);
1158 Lisp_Object top_frame
= tty
->top_frame
;
1160 /* Don't mark the frame garbaged and/or obscured if we are
1161 switching to the frame that is already the top frame of that
1163 if (!EQ (frame
, top_frame
))
1165 if (FRAMEP (top_frame
))
1166 /* Mark previously displayed frame as now obscured. */
1167 SET_FRAME_VISIBLE (XFRAME (top_frame
), 2);
1168 SET_FRAME_VISIBLE (f
, 1);
1169 /* If the new TTY frame changed dimensions, we need to
1170 resync term.c's idea of the frame size with the new
1172 if (FRAME_COLS (f
) != FrameCols (tty
))
1173 FrameCols (tty
) = FRAME_COLS (f
);
1174 if (FRAME_LINES (f
) != FrameRows (tty
))
1175 FrameRows (tty
) = FRAME_LINES (f
);
1177 tty
->top_frame
= frame
;
1180 selected_frame
= frame
;
1181 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
1182 last_nonminibuf_frame
= XFRAME (selected_frame
);
1184 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
1186 /* We want to make sure that the next event generates a frame-switch
1187 event to the appropriate frame. This seems kludgy to me, but
1188 before you take it out, make sure that evaluating something like
1189 (select-window (frame-root-window (new-frame))) doesn't end up
1190 with your typing being interpreted in the new frame instead of
1191 the one you're actually typing in. */
1192 internal_last_event_frame
= Qnil
;
1197 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
1198 doc
: /* Select FRAME.
1199 Subsequent editing commands apply to its selected window.
1200 Optional argument NORECORD means to neither change the order of
1201 recently selected windows nor the buffer list.
1203 The selection of FRAME lasts until the next time the user does
1204 something to select a different frame, or until the next time
1205 this function is called. If you are using a window system, the
1206 previously selected frame may be restored as the selected frame
1207 when returning to the command loop, because it still may have
1208 the window system's input focus. On a text terminal, the next
1209 redisplay will display FRAME.
1211 This function returns FRAME, or nil if FRAME has been deleted. */)
1212 (Lisp_Object frame
, Lisp_Object norecord
)
1214 return do_switch_frame (frame
, 1, 0, norecord
);
1217 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
1218 doc
: /* Handle a switch-frame event EVENT.
1219 Switch-frame events are usually bound to this function.
1220 A switch-frame event tells Emacs that the window manager has requested
1221 that the user's events be directed to the frame mentioned in the event.
1222 This function selects the selected window of the frame of EVENT.
1224 If EVENT is frame object, handle it as if it were a switch-frame event
1228 /* Preserve prefix arg that the command loop just cleared. */
1229 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
1230 Frun_hooks (1, &Qmouse_leave_buffer_hook
);
1231 /* `switch-frame' implies a focus in. */
1232 call1 (intern ("handle-focus-in"), event
);
1233 return do_switch_frame (event
, 0, 0, Qnil
);
1236 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1237 doc
: /* Return the frame that is now selected. */)
1240 return selected_frame
;
1243 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1245 doc
: /* Return a list of all live frames. */)
1249 frames
= Fcopy_sequence (Vframe_list
);
1250 #ifdef HAVE_WINDOW_SYSTEM
1251 if (FRAMEP (tip_frame
))
1252 frames
= Fdelq (tip_frame
, frames
);
1257 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
1258 same tty (for tty frames) or among frames which uses FRAME's keyboard.
1259 If MINIBUF is nil, do not consider minibuffer-only candidate.
1260 If MINIBUF is `visible', do not consider an invisible candidate.
1261 If MINIBUF is a window, consider only its own frame and candidate now
1262 using that window as the minibuffer.
1263 If MINIBUF is 0, consider candidate if it is visible or iconified.
1264 Otherwise consider any candidate and return nil if CANDIDATE is not
1268 candidate_frame (Lisp_Object candidate
, Lisp_Object frame
, Lisp_Object minibuf
)
1270 struct frame
*c
= XFRAME (candidate
), *f
= XFRAME (frame
);
1272 if ((!FRAME_TERMCAP_P (c
) && !FRAME_TERMCAP_P (f
)
1273 && FRAME_KBOARD (c
) == FRAME_KBOARD (f
))
1274 || (FRAME_TERMCAP_P (c
) && FRAME_TERMCAP_P (f
)
1275 && FRAME_TTY (c
) == FRAME_TTY (f
)))
1279 if (!FRAME_MINIBUF_ONLY_P (c
))
1282 else if (EQ (minibuf
, Qvisible
))
1284 if (FRAME_VISIBLE_P (c
))
1287 else if (WINDOWP (minibuf
))
1289 if (EQ (FRAME_MINIBUF_WINDOW (c
), minibuf
)
1290 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), candidate
)
1291 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1292 FRAME_FOCUS_FRAME (c
)))
1295 else if (XFASTINT (minibuf
) == 0)
1297 if (FRAME_VISIBLE_P (c
) || FRAME_ICONIFIED_P (c
))
1306 /* Return the next frame in the frame list after FRAME. */
1309 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1311 Lisp_Object f
, tail
;
1314 /* There must always be at least one frame in Vframe_list. */
1315 eassert (CONSP (Vframe_list
));
1318 FOR_EACH_FRAME (tail
, f
)
1322 f
= candidate_frame (f
, frame
, minibuf
);
1332 /* Return the previous frame in the frame list before FRAME. */
1335 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1337 Lisp_Object f
, tail
, prev
= Qnil
;
1339 /* There must always be at least one frame in Vframe_list. */
1340 eassert (CONSP (Vframe_list
));
1342 FOR_EACH_FRAME (tail
, f
)
1344 if (EQ (frame
, f
) && !NILP (prev
))
1346 f
= candidate_frame (f
, frame
, minibuf
);
1351 /* We've scanned the entire list. */
1353 /* We went through the whole frame list without finding a single
1354 acceptable frame. Return the original frame. */
1357 /* There were no acceptable frames in the list before FRAME; otherwise,
1358 we would have returned directly from the loop. Since PREV is the last
1359 acceptable frame in the list, return it. */
1364 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1365 doc
: /* Return the next frame in the frame list after FRAME.
1366 It considers only frames on the same terminal as FRAME.
1367 By default, skip minibuffer-only frames.
1368 If omitted, FRAME defaults to the selected frame.
1369 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1370 If MINIFRAME is a window, include only its own frame
1371 and any frame now using that window as the minibuffer.
1372 If MINIFRAME is `visible', include all visible frames.
1373 If MINIFRAME is 0, include all visible and iconified frames.
1374 Otherwise, include all frames. */)
1375 (Lisp_Object frame
, Lisp_Object miniframe
)
1378 frame
= selected_frame
;
1379 CHECK_LIVE_FRAME (frame
);
1380 return next_frame (frame
, miniframe
);
1383 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1384 doc
: /* Return the previous frame in the frame list before FRAME.
1385 It considers only frames on the same terminal as FRAME.
1386 By default, skip minibuffer-only frames.
1387 If omitted, FRAME defaults to the selected frame.
1388 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1389 If MINIFRAME is a window, include only its own frame
1390 and any frame now using that window as the minibuffer.
1391 If MINIFRAME is `visible', include all visible frames.
1392 If MINIFRAME is 0, include all visible and iconified frames.
1393 Otherwise, include all frames. */)
1394 (Lisp_Object frame
, Lisp_Object miniframe
)
1397 frame
= selected_frame
;
1398 CHECK_LIVE_FRAME (frame
);
1399 return prev_frame (frame
, miniframe
);
1402 DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame
,
1403 Slast_nonminibuf_frame
, 0, 0, 0,
1404 doc
: /* Return last non-minibuffer frame selected. */)
1407 Lisp_Object frame
= Qnil
;
1409 if (last_nonminibuf_frame
)
1410 XSETFRAME (frame
, last_nonminibuf_frame
);
1415 /* Return 1 if it is ok to delete frame F;
1416 0 if all frames aside from F are invisible.
1417 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1420 other_visible_frames (struct frame
*f
)
1422 Lisp_Object frames
, this;
1424 FOR_EACH_FRAME (frames
, this)
1426 if (f
== XFRAME (this))
1429 /* Verify that we can still talk to the frame's X window,
1430 and note any recent change in visibility. */
1431 #ifdef HAVE_X_WINDOWS
1432 if (FRAME_WINDOW_P (XFRAME (this)))
1433 x_sync (XFRAME (this));
1436 if (FRAME_VISIBLE_P (XFRAME (this))
1437 || FRAME_ICONIFIED_P (XFRAME (this))
1438 /* Allow deleting the terminal frame when at least one X
1440 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1446 /* Make sure that minibuf_window doesn't refer to FRAME's minibuffer
1447 window. Preferably use the selected frame's minibuffer window
1448 instead. If the selected frame doesn't have one, get some other
1449 frame's minibuffer window. SELECT non-zero means select the new
1450 minibuffer window. */
1452 check_minibuf_window (Lisp_Object frame
, int select
)
1454 struct frame
*f
= decode_live_frame (frame
);
1456 XSETFRAME (frame
, f
);
1458 if (WINDOWP (minibuf_window
) && EQ (f
->minibuffer_window
, minibuf_window
))
1460 Lisp_Object frames
, this, window
= make_number (0);
1462 if (!EQ (frame
, selected_frame
)
1463 && FRAME_HAS_MINIBUF_P (XFRAME (selected_frame
)))
1464 window
= FRAME_MINIBUF_WINDOW (XFRAME (selected_frame
));
1466 FOR_EACH_FRAME (frames
, this)
1468 if (!EQ (this, frame
) && FRAME_HAS_MINIBUF_P (XFRAME (this)))
1470 window
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1475 /* Don't abort if no window was found (Bug#15247). */
1476 if (WINDOWP (window
))
1478 /* Use set_window_buffer instead of Fset_window_buffer (see
1479 discussion of bug#11984, bug#12025, bug#12026). */
1480 set_window_buffer (window
, XWINDOW (minibuf_window
)->contents
, 0, 0);
1481 minibuf_window
= window
;
1483 /* SELECT non-zero usually means that FRAME's minibuffer
1484 window was selected; select the new one. */
1486 Fselect_window (minibuf_window
, Qnil
);
1492 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1493 unconditionally. x_connection_closed and delete_terminal use
1494 this. Any other value of FORCE implements the semantics
1495 described for Fdelete_frame. */
1497 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1499 struct frame
*f
= decode_any_frame (frame
);
1503 int minibuffer_selected
, is_tooltip_frame
;
1505 if (! FRAME_LIVE_P (f
))
1508 if (NILP (force
) && !other_visible_frames (f
))
1509 error ("Attempt to delete the sole visible or iconified frame");
1511 /* x_connection_closed must have set FORCE to `noelisp' in order
1512 to delete the last frame, if it is gone. */
1513 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1514 error ("Attempt to delete the only frame");
1516 XSETFRAME (frame
, f
);
1518 /* Does this frame have a minibuffer, and is it the surrogate
1519 minibuffer for any other frame? */
1520 if (FRAME_HAS_MINIBUF_P (f
))
1522 Lisp_Object frames
, this;
1524 FOR_EACH_FRAME (frames
, this)
1528 if (EQ (this, frame
))
1531 fminiw
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1533 if (WINDOWP (fminiw
) && EQ (frame
, WINDOW_FRAME (XWINDOW (fminiw
))))
1535 /* If we MUST delete this frame, delete the other first.
1536 But do this only if FORCE equals `noelisp'. */
1537 if (EQ (force
, Qnoelisp
))
1538 delete_frame (this, Qnoelisp
);
1540 error ("Attempt to delete a surrogate minibuffer frame");
1545 is_tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1547 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1548 frame is a tooltip. FORCE is set to `noelisp' when handling
1549 a disconnect from the terminal, so we don't dare call Lisp
1551 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1553 else if (EQ (force
, Qnoelisp
))
1555 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1559 #ifdef HAVE_X_WINDOWS
1560 /* Also, save clipboard to the clipboard manager. */
1561 x_clipboard_manager_save_frame (frame
);
1564 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1567 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1568 if (! FRAME_LIVE_P (f
))
1571 /* At this point, we are committed to deleting the frame.
1572 There is no more chance for errors to prevent it. */
1574 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1575 sf
= SELECTED_FRAME ();
1576 /* Don't let the frame remain selected. */
1580 Lisp_Object frame1
= Qnil
;
1582 /* Look for another visible frame on the same terminal.
1583 Do not call next_frame here because it may loop forever.
1584 See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15025. */
1585 FOR_EACH_FRAME (tail
, frame1
)
1586 if (!EQ (frame
, frame1
)
1587 && (FRAME_TERMINAL (XFRAME (frame
))
1588 == FRAME_TERMINAL (XFRAME (frame1
)))
1589 && FRAME_VISIBLE_P (XFRAME (frame1
)))
1592 /* If there is none, find *some* other frame. */
1593 if (NILP (frame1
) || EQ (frame1
, frame
))
1595 FOR_EACH_FRAME (tail
, frame1
)
1597 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1599 /* Do not change a text terminal's top-frame. */
1600 struct frame
*f1
= XFRAME (frame1
);
1601 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1603 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1604 if (!EQ (top_frame
, frame
))
1611 #ifdef NS_IMPL_COCOA
1613 /* Under NS, there is no system mechanism for choosing a new
1614 window to get focus -- it is left to application code.
1615 So the portion of THIS application interfacing with NS
1616 needs to know about it. We call Fraise_frame, but the
1617 purpose is really to transfer focus. */
1618 Fraise_frame (frame1
);
1621 do_switch_frame (frame1
, 0, 1, Qnil
);
1622 sf
= SELECTED_FRAME ();
1625 /* Don't allow minibuf_window to remain on a deleted frame. */
1626 check_minibuf_window (frame
, minibuffer_selected
);
1628 /* Don't let echo_area_window to remain on a deleted frame. */
1629 if (EQ (f
->minibuffer_window
, echo_area_window
))
1630 echo_area_window
= sf
->minibuffer_window
;
1632 /* Clear any X selections for this frame. */
1633 #ifdef HAVE_X_WINDOWS
1635 x_clear_frame_selections (f
);
1639 This function must be called before the window tree of the
1640 frame is deleted because windows contain dynamically allocated
1644 #ifdef HAVE_WINDOW_SYSTEM
1645 /* Give chance to each font driver to free a frame specific data. */
1646 font_update_drivers (f
, Qnil
);
1649 /* Mark all the windows that used to be on FRAME as deleted, and then
1650 remove the reference to them. */
1651 delete_all_child_windows (f
->root_window
);
1652 fset_root_window (f
, Qnil
);
1654 Vframe_list
= Fdelq (frame
, Vframe_list
);
1655 SET_FRAME_VISIBLE (f
, 0);
1657 /* Allow the vector of menu bar contents to be freed in the next
1658 garbage collection. The frame object itself may not be garbage
1659 collected until much later, because recent_keys and other data
1660 structures can still refer to it. */
1661 fset_menu_bar_vector (f
, Qnil
);
1663 /* If FRAME's buffer lists contains killed
1664 buffers, this helps GC to reclaim them. */
1665 fset_buffer_list (f
, Qnil
);
1666 fset_buried_buffer_list (f
, Qnil
);
1668 free_font_driver_list (f
);
1669 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1672 xfree (f
->decode_mode_spec_buffer
);
1673 xfree (FRAME_INSERT_COST (f
));
1674 xfree (FRAME_DELETEN_COST (f
));
1675 xfree (FRAME_INSERTN_COST (f
));
1676 xfree (FRAME_DELETE_COST (f
));
1678 /* Since some events are handled at the interrupt level, we may get
1679 an event for f at any time; if we zero out the frame's terminal
1680 now, then we may trip up the event-handling code. Instead, we'll
1681 promise that the terminal of the frame must be valid until we
1682 have called the window-system-dependent frame destruction
1687 struct terminal
*terminal
;
1689 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1690 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1691 terminal
= FRAME_TERMINAL (f
);
1692 f
->output_data
.nothing
= 0;
1693 f
->terminal
= 0; /* Now the frame is dead. */
1696 /* If needed, delete the terminal that this frame was on.
1697 (This must be done after the frame is killed.) */
1698 terminal
->reference_count
--;
1700 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1702 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1703 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1704 terminal
->reference_count
= 1;
1705 #endif /* USE_GTK */
1706 if (terminal
->reference_count
== 0)
1709 XSETTERMINAL (tmp
, terminal
);
1712 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1715 kb
= terminal
->kboard
;
1718 /* If we've deleted the last_nonminibuf_frame, then try to find
1720 if (f
== last_nonminibuf_frame
)
1722 Lisp_Object frames
, this;
1724 last_nonminibuf_frame
= 0;
1726 FOR_EACH_FRAME (frames
, this)
1729 if (!FRAME_MINIBUF_ONLY_P (f
))
1731 last_nonminibuf_frame
= f
;
1737 /* If there's no other frame on the same kboard, get out of
1738 single-kboard state if we're in it for this kboard. */
1741 Lisp_Object frames
, this;
1742 /* Some frame we found on the same kboard, or nil if there are none. */
1743 Lisp_Object frame_on_same_kboard
= Qnil
;
1745 FOR_EACH_FRAME (frames
, this)
1746 if (kb
== FRAME_KBOARD (XFRAME (this)))
1747 frame_on_same_kboard
= this;
1749 if (NILP (frame_on_same_kboard
))
1750 not_single_kboard_state (kb
);
1754 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1755 find another one. Prefer minibuffer-only frames, but also notice
1756 frames with other windows. */
1757 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1759 Lisp_Object frames
, this;
1761 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1762 Lisp_Object frame_with_minibuf
= Qnil
;
1763 /* Some frame we found on the same kboard, or nil if there are none. */
1764 Lisp_Object frame_on_same_kboard
= Qnil
;
1766 FOR_EACH_FRAME (frames
, this)
1768 struct frame
*f1
= XFRAME (this);
1770 /* Consider only frames on the same kboard
1771 and only those with minibuffers. */
1772 if (kb
== FRAME_KBOARD (f1
)
1773 && FRAME_HAS_MINIBUF_P (f1
))
1775 frame_with_minibuf
= this;
1776 if (FRAME_MINIBUF_ONLY_P (f1
))
1780 if (kb
== FRAME_KBOARD (f1
))
1781 frame_on_same_kboard
= this;
1784 if (!NILP (frame_on_same_kboard
))
1786 /* We know that there must be some frame with a minibuffer out
1787 there. If this were not true, all of the frames present
1788 would have to be minibufferless, which implies that at some
1789 point their minibuffer frames must have been deleted, but
1790 that is prohibited at the top; you can't delete surrogate
1791 minibuffer frames. */
1792 if (NILP (frame_with_minibuf
))
1795 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
1798 /* No frames left on this kboard--say no minibuffer either. */
1799 kset_default_minibuffer_frame (kb
, Qnil
);
1802 /* Cause frame titles to update--necessary if we now have just one frame. */
1803 if (!is_tooltip_frame
)
1804 update_mode_lines
= 15;
1809 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1810 doc
: /* Delete FRAME, permanently eliminating it from use.
1811 FRAME defaults to the selected frame.
1813 A frame may not be deleted if its minibuffer is used by other frames.
1814 Normally, you may not delete a frame if all other frames are invisible,
1815 but if the second optional argument FORCE is non-nil, you may do so.
1817 This function runs `delete-frame-functions' before actually
1818 deleting the frame, unless the frame is a tooltip.
1819 The functions are run with one argument, the frame to be deleted. */)
1820 (Lisp_Object frame
, Lisp_Object force
)
1822 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1826 /* Return mouse position in character cell units. */
1828 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1829 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1830 The position is given in character cells, where (0, 0) is the
1831 upper-left corner of the frame, X is the horizontal offset, and Y is
1832 the vertical offset.
1833 If Emacs is running on a mouseless terminal or hasn't been programmed
1834 to read the mouse position, it returns the selected frame for FRAME
1835 and nil for X and Y.
1836 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1837 passing the normal return value to that function as an argument,
1838 and returns whatever that function returns. */)
1842 Lisp_Object lispy_dummy
;
1843 Lisp_Object x
, y
, retval
;
1844 struct gcpro gcpro1
;
1846 f
= SELECTED_FRAME ();
1849 /* It's okay for the hook to refrain from storing anything. */
1850 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1852 enum scroll_bar_part party_dummy
;
1854 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1855 &lispy_dummy
, &party_dummy
,
1864 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1868 XSETFRAME (lispy_dummy
, f
);
1869 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1871 if (!NILP (Vmouse_position_function
))
1872 retval
= call1 (Vmouse_position_function
, retval
);
1873 RETURN_UNGCPRO (retval
);
1876 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1877 Smouse_pixel_position
, 0, 0, 0,
1878 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1879 The position is given in pixel units, where (0, 0) is the
1880 upper-left corner of the frame, X is the horizontal offset, and Y is
1881 the vertical offset.
1882 If Emacs is running on a mouseless terminal or hasn't been programmed
1883 to read the mouse position, it returns the selected frame for FRAME
1884 and nil for X and Y. */)
1888 Lisp_Object lispy_dummy
;
1891 f
= SELECTED_FRAME ();
1894 /* It's okay for the hook to refrain from storing anything. */
1895 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1897 enum scroll_bar_part party_dummy
;
1899 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1900 &lispy_dummy
, &party_dummy
,
1905 XSETFRAME (lispy_dummy
, f
);
1906 return Fcons (lispy_dummy
, Fcons (x
, y
));
1909 #ifdef HAVE_WINDOW_SYSTEM
1911 /* On frame F, convert character coordinates X and Y to pixel
1912 coordinates *PIX_X and *PIX_Y. */
1915 frame_char_to_pixel_position (struct frame
*f
, int x
, int y
,
1916 int *pix_x
, int *pix_y
)
1918 *pix_x
= FRAME_COL_TO_PIXEL_X (f
, x
) + FRAME_COLUMN_WIDTH (f
) / 2;
1919 *pix_y
= FRAME_LINE_TO_PIXEL_Y (f
, y
) + FRAME_LINE_HEIGHT (f
) / 2;
1923 if (*pix_x
> FRAME_PIXEL_WIDTH (f
))
1924 *pix_x
= FRAME_PIXEL_WIDTH (f
);
1928 if (*pix_y
> FRAME_PIXEL_HEIGHT (f
))
1929 *pix_y
= FRAME_PIXEL_HEIGHT (f
);
1932 /* On frame F, reposition mouse pointer to character coordinates X and Y. */
1935 frame_set_mouse_position (struct frame
*f
, int x
, int y
)
1939 frame_char_to_pixel_position (f
, x
, y
, &pix_x
, &pix_y
);
1940 frame_set_mouse_pixel_position (f
, pix_x
, pix_y
);
1943 #endif /* HAVE_WINDOW_SYSTEM */
1945 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1946 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1947 Coordinates are relative to the frame, not a window,
1948 so the coordinates of the top left character in the frame
1949 may be nonzero due to left-hand scroll bars or the menu bar.
1951 The position is given in character cells, where (0, 0) is the
1952 upper-left corner of the frame, X is the horizontal offset, and Y is
1953 the vertical offset.
1955 This function is a no-op for an X frame that is not visible.
1956 If you have just created a frame, you must wait for it to become visible
1957 before calling this function on it, like this.
1958 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1959 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1961 CHECK_LIVE_FRAME (frame
);
1962 CHECK_TYPE_RANGED_INTEGER (int, x
);
1963 CHECK_TYPE_RANGED_INTEGER (int, y
);
1965 /* I think this should be done with a hook. */
1966 #ifdef HAVE_WINDOW_SYSTEM
1967 if (FRAME_WINDOW_P (XFRAME (frame
)))
1968 /* Warping the mouse will cause enternotify and focus events. */
1969 frame_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1972 if (FRAME_MSDOS_P (XFRAME (frame
)))
1974 Fselect_frame (frame
, Qnil
);
1975 mouse_moveto (XINT (x
), XINT (y
));
1980 Fselect_frame (frame
, Qnil
);
1981 term_mouse_moveto (XINT (x
), XINT (y
));
1990 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1991 Sset_mouse_pixel_position
, 3, 3, 0,
1992 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1993 The position is given in pixels, where (0, 0) is the upper-left corner
1994 of the frame, X is the horizontal offset, and Y is the vertical offset.
1996 Note, this is a no-op for an X frame that is not visible.
1997 If you have just created a frame, you must wait for it to become visible
1998 before calling this function on it, like this.
1999 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
2000 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
2002 CHECK_LIVE_FRAME (frame
);
2003 CHECK_TYPE_RANGED_INTEGER (int, x
);
2004 CHECK_TYPE_RANGED_INTEGER (int, y
);
2006 /* I think this should be done with a hook. */
2007 #ifdef HAVE_WINDOW_SYSTEM
2008 if (FRAME_WINDOW_P (XFRAME (frame
)))
2009 /* Warping the mouse will cause enternotify and focus events. */
2010 frame_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
2013 if (FRAME_MSDOS_P (XFRAME (frame
)))
2015 Fselect_frame (frame
, Qnil
);
2016 mouse_moveto (XINT (x
), XINT (y
));
2021 Fselect_frame (frame
, Qnil
);
2022 term_mouse_moveto (XINT (x
), XINT (y
));
2031 static void make_frame_visible_1 (Lisp_Object
);
2033 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
2035 doc
: /* Make the frame FRAME visible (assuming it is an X window).
2036 If omitted, FRAME defaults to the currently selected frame. */)
2039 struct frame
*f
= decode_live_frame (frame
);
2041 /* I think this should be done with a hook. */
2042 #ifdef HAVE_WINDOW_SYSTEM
2043 if (FRAME_WINDOW_P (f
))
2044 x_make_frame_visible (f
);
2047 make_frame_visible_1 (f
->root_window
);
2049 /* Make menu bar update for the Buffers and Frames menus. */
2050 /* windows_or_buffers_changed = 15; FIXME: Why? */
2052 XSETFRAME (frame
, f
);
2056 /* Update the display_time slot of the buffers shown in WINDOW
2057 and all its descendants. */
2060 make_frame_visible_1 (Lisp_Object window
)
2064 for (; !NILP (window
); window
= w
->next
)
2066 w
= XWINDOW (window
);
2067 if (WINDOWP (w
->contents
))
2068 make_frame_visible_1 (w
->contents
);
2070 bset_display_time (XBUFFER (w
->contents
), Fcurrent_time ());
2074 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
2076 doc
: /* Make the frame FRAME invisible.
2077 If omitted, FRAME defaults to the currently selected frame.
2078 On graphical displays, invisible frames are not updated and are
2079 usually not displayed at all, even in a window system's \"taskbar\".
2081 Normally you may not make FRAME invisible if all other frames are invisible,
2082 but if the second optional argument FORCE is non-nil, you may do so.
2084 This function has no effect on text terminal frames. Such frames are
2085 always considered visible, whether or not they are currently being
2086 displayed in the terminal. */)
2087 (Lisp_Object frame
, Lisp_Object force
)
2089 struct frame
*f
= decode_live_frame (frame
);
2091 if (NILP (force
) && !other_visible_frames (f
))
2092 error ("Attempt to make invisible the sole visible or iconified frame");
2094 /* Don't allow minibuf_window to remain on an invisible frame. */
2095 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2097 /* I think this should be done with a hook. */
2098 #ifdef HAVE_WINDOW_SYSTEM
2099 if (FRAME_WINDOW_P (f
))
2100 x_make_frame_invisible (f
);
2103 /* Make menu bar update for the Buffers and Frames menus. */
2104 windows_or_buffers_changed
= 16;
2109 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
2111 doc
: /* Make the frame FRAME into an icon.
2112 If omitted, FRAME defaults to the currently selected frame. */)
2115 struct frame
*f
= decode_live_frame (frame
);
2117 /* Don't allow minibuf_window to remain on an iconified frame. */
2118 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2120 /* I think this should be done with a hook. */
2121 #ifdef HAVE_WINDOW_SYSTEM
2122 if (FRAME_WINDOW_P (f
))
2123 x_iconify_frame (f
);
2126 /* Make menu bar update for the Buffers and Frames menus. */
2127 windows_or_buffers_changed
= 17;
2132 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
2134 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
2135 Return the symbol `icon' if FRAME is iconified or \"minimized\".
2136 Return nil if FRAME was made invisible, via `make-frame-invisible'.
2137 On graphical displays, invisible frames are not updated and are
2138 usually not displayed at all, even in a window system's \"taskbar\".
2140 If FRAME is a text terminal frame, this always returns t.
2141 Such frames are always considered visible, whether or not they are
2142 currently being displayed on the terminal. */)
2145 CHECK_LIVE_FRAME (frame
);
2147 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2149 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
2154 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
2156 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
2159 Lisp_Object tail
, frame
, value
= Qnil
;
2161 FOR_EACH_FRAME (tail
, frame
)
2162 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2163 value
= Fcons (frame
, value
);
2169 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
2170 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
2171 If FRAME is invisible or iconified, make it visible.
2172 If you don't specify a frame, the selected frame is used.
2173 If Emacs is displaying on an ordinary terminal or some other device which
2174 doesn't support multiple overlapping frames, this function selects FRAME. */)
2177 struct frame
*f
= decode_live_frame (frame
);
2179 XSETFRAME (frame
, f
);
2181 if (FRAME_TERMCAP_P (f
))
2182 /* On a text terminal select FRAME. */
2183 Fselect_frame (frame
, Qnil
);
2185 /* Do like the documentation says. */
2186 Fmake_frame_visible (frame
);
2188 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2189 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
2194 /* Should we have a corresponding function called Flower_Power? */
2195 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
2196 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2197 If you don't specify a frame, the selected frame is used.
2198 If Emacs is displaying on an ordinary terminal or some other device which
2199 doesn't support multiple overlapping frames, this function does nothing. */)
2202 struct frame
*f
= decode_live_frame (frame
);
2204 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2205 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2211 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2213 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2214 In other words, switch-frame events caused by events in FRAME will
2215 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2216 FOCUS-FRAME after reading an event typed at FRAME.
2218 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
2219 frame again receives its own keystrokes.
2221 Focus redirection is useful for temporarily redirecting keystrokes to
2222 a surrogate minibuffer frame when a frame doesn't have its own
2225 A frame's focus redirection can be changed by `select-frame'. If frame
2226 FOO is selected, and then a different frame BAR is selected, any
2227 frames redirecting their focus to FOO are shifted to redirect their
2228 focus to BAR. This allows focus redirection to work properly when the
2229 user switches from one frame to another using `select-window'.
2231 This means that a frame whose focus is redirected to itself is treated
2232 differently from a frame whose focus is redirected to nil; the former
2233 is affected by `select-frame', while the latter is not.
2235 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2236 (Lisp_Object frame
, Lisp_Object focus_frame
)
2238 /* Note that we don't check for a live frame here. It's reasonable
2239 to redirect the focus of a frame you're about to delete, if you
2240 know what other frame should receive those keystrokes. */
2241 struct frame
*f
= decode_any_frame (frame
);
2243 if (! NILP (focus_frame
))
2244 CHECK_LIVE_FRAME (focus_frame
);
2246 fset_focus_frame (f
, focus_frame
);
2248 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2249 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2255 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 0, 1, 0,
2256 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2257 If FRAME is omitted or nil, the selected frame is used.
2258 Return nil if FRAME's focus is not redirected.
2259 See `redirect-frame-focus'. */)
2262 return FRAME_FOCUS_FRAME (decode_live_frame (frame
));
2265 DEFUN ("x-focus-frame", Fx_focus_frame
, Sx_focus_frame
, 1, 1, 0,
2266 doc
: /* Set the input focus to FRAME.
2267 FRAME nil means use the selected frame.
2268 If there is no window system support, this function does nothing. */)
2271 #ifdef HAVE_WINDOW_SYSTEM
2272 x_focus_frame (decode_window_system_frame (frame
));
2278 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2281 frames_discard_buffer (Lisp_Object buffer
)
2283 Lisp_Object frame
, tail
;
2285 FOR_EACH_FRAME (tail
, frame
)
2288 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
2289 fset_buried_buffer_list
2290 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
2294 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2295 If the alist already has an element for PROP, we change it. */
2298 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2300 register Lisp_Object tem
;
2302 tem
= Fassq (prop
, *alistptr
);
2304 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2310 frame_name_fnn_p (char *str
, ptrdiff_t len
)
2312 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
2315 while ('0' <= *p
&& *p
<= '9')
2323 /* Set the name of the terminal frame. Also used by MSDOS frames.
2324 Modeled after x_set_name which is used for WINDOW frames. */
2327 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2329 f
->explicit_name
= ! NILP (name
);
2331 /* If NAME is nil, set the name to F<num>. */
2334 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
2336 /* Check for no change needed in this very common case
2337 before we do any consing. */
2338 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
2341 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
2345 CHECK_STRING (name
);
2347 /* Don't change the name if it's already NAME. */
2348 if (! NILP (Fstring_equal (name
, f
->name
)))
2351 /* Don't allow the user to set the frame name to F<num>, so it
2352 doesn't clash with the names we generate for terminal frames. */
2353 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2354 error ("Frame names of the form F<num> are usurped by Emacs");
2357 fset_name (f
, name
);
2358 update_mode_lines
= 16;
2362 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2364 register Lisp_Object old_alist_elt
;
2366 /* The buffer-list parameters are stored in a special place and not
2367 in the alist. All buffers must be live. */
2368 if (EQ (prop
, Qbuffer_list
))
2370 Lisp_Object list
= Qnil
;
2371 for (; CONSP (val
); val
= XCDR (val
))
2372 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2373 list
= Fcons (XCAR (val
), list
);
2374 fset_buffer_list (f
, Fnreverse (list
));
2377 if (EQ (prop
, Qburied_buffer_list
))
2379 Lisp_Object list
= Qnil
;
2380 for (; CONSP (val
); val
= XCDR (val
))
2381 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2382 list
= Fcons (XCAR (val
), list
);
2383 fset_buried_buffer_list (f
, Fnreverse (list
));
2387 /* If PROP is a symbol which is supposed to have frame-local values,
2388 and it is set up based on this frame, switch to the global
2389 binding. That way, we can create or alter the frame-local binding
2390 without messing up the symbol's status. */
2393 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2395 switch (sym
->redirect
)
2397 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2398 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2399 case SYMBOL_LOCALIZED
:
2400 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2401 if (blv
->frame_local
&& blv_found (blv
) && XFRAME (blv
->where
) == f
)
2402 swap_in_global_binding (sym
);
2405 default: emacs_abort ();
2409 /* The tty color needed to be set before the frame's parameter
2410 alist was updated with the new value. This is not true any more,
2411 but we still do this test early on. */
2412 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2413 && f
== FRAME_TTY (f
)->previous_frame
)
2414 /* Force redisplay of this tty. */
2415 FRAME_TTY (f
)->previous_frame
= NULL
;
2417 /* Update the frame parameter alist. */
2418 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2419 if (EQ (old_alist_elt
, Qnil
))
2420 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2422 Fsetcdr (old_alist_elt
, val
);
2424 /* Update some other special parameters in their special places
2425 in addition to the alist. */
2427 if (EQ (prop
, Qbuffer_predicate
))
2428 fset_buffer_predicate (f
, val
);
2430 if (! FRAME_WINDOW_P (f
))
2432 if (EQ (prop
, Qmenu_bar_lines
))
2433 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2434 else if (EQ (prop
, Qname
))
2435 set_term_frame_name (f
, val
);
2438 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2440 if (! MINI_WINDOW_P (XWINDOW (val
)))
2441 error ("Surrogate minibuffer windows must be minibuffer windows");
2443 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2444 && !EQ (val
, f
->minibuffer_window
))
2445 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2447 /* Install the chosen minibuffer window, with proper buffer. */
2448 fset_minibuffer_window (f
, val
);
2452 /* Return color matches UNSPEC on frame F or nil if UNSPEC
2453 is not an unspecified foreground or background color. */
2456 frame_unspecified_color (struct frame
*f
, Lisp_Object unspec
)
2458 return (!strncmp (SSDATA (unspec
), unspecified_bg
, SBYTES (unspec
))
2459 ? tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
))
2460 : (!strncmp (SSDATA (unspec
), unspecified_fg
, SBYTES (unspec
))
2461 ? tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)) : Qnil
));
2464 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2465 doc
: /* Return the parameters-alist of frame FRAME.
2466 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2467 The meaningful PARMs depend on the kind of frame.
2468 If FRAME is omitted or nil, return information on the currently selected frame. */)
2472 struct frame
*f
= decode_any_frame (frame
);
2474 struct gcpro gcpro1
;
2476 if (!FRAME_LIVE_P (f
))
2479 alist
= Fcopy_alist (f
->param_alist
);
2482 if (!FRAME_WINDOW_P (f
))
2486 /* If the frame's parameter alist says the colors are
2487 unspecified and reversed, take the frame's background pixel
2488 for foreground and vice versa. */
2489 elt
= Fassq (Qforeground_color
, alist
);
2490 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2492 elt
= frame_unspecified_color (f
, XCDR (elt
));
2494 store_in_alist (&alist
, Qforeground_color
, elt
);
2497 store_in_alist (&alist
, Qforeground_color
,
2498 tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)));
2499 elt
= Fassq (Qbackground_color
, alist
);
2500 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2502 elt
= frame_unspecified_color (f
, XCDR (elt
));
2504 store_in_alist (&alist
, Qbackground_color
, elt
);
2507 store_in_alist (&alist
, Qbackground_color
,
2508 tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
)));
2509 store_in_alist (&alist
, intern ("font"),
2510 build_string (FRAME_MSDOS_P (f
)
2512 : FRAME_W32_P (f
) ? "w32term"
2515 store_in_alist (&alist
, Qname
, f
->name
);
2516 height
= (f
->new_height
2518 ? (f
->new_height
/ FRAME_LINE_HEIGHT (f
))
2521 store_in_alist (&alist
, Qheight
, make_number (height
));
2522 width
= (f
->new_width
2524 ? (f
->new_width
/ FRAME_COLUMN_WIDTH (f
))
2527 store_in_alist (&alist
, Qwidth
, make_number (width
));
2528 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2529 store_in_alist (&alist
, Qminibuffer
,
2530 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2531 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2532 : FRAME_MINIBUF_WINDOW (f
)));
2533 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2534 store_in_alist (&alist
, Qbuffer_list
, f
->buffer_list
);
2535 store_in_alist (&alist
, Qburied_buffer_list
, f
->buried_buffer_list
);
2537 /* I think this should be done with a hook. */
2538 #ifdef HAVE_WINDOW_SYSTEM
2539 if (FRAME_WINDOW_P (f
))
2540 x_report_frame_params (f
, &alist
);
2544 /* This ought to be correct in f->param_alist for an X frame. */
2546 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2547 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2555 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2556 doc
: /* Return FRAME's value for parameter PARAMETER.
2557 If FRAME is nil, describe the currently selected frame. */)
2558 (Lisp_Object frame
, Lisp_Object parameter
)
2560 struct frame
*f
= decode_any_frame (frame
);
2561 Lisp_Object value
= Qnil
;
2563 CHECK_SYMBOL (parameter
);
2565 XSETFRAME (frame
, f
);
2567 if (FRAME_LIVE_P (f
))
2569 /* Avoid consing in frequent cases. */
2570 if (EQ (parameter
, Qname
))
2572 #ifdef HAVE_X_WINDOWS
2573 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2574 value
= XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
);
2575 #endif /* HAVE_X_WINDOWS */
2576 else if (EQ (parameter
, Qbackground_color
)
2577 || EQ (parameter
, Qforeground_color
))
2579 value
= Fassq (parameter
, f
->param_alist
);
2582 value
= XCDR (value
);
2583 /* Fframe_parameters puts the actual fg/bg color names,
2584 even if f->param_alist says otherwise. This is
2585 important when param_alist's notion of colors is
2586 "unspecified". We need to do the same here. */
2587 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2588 value
= frame_unspecified_color (f
, value
);
2591 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2593 else if (EQ (parameter
, Qdisplay_type
)
2594 || EQ (parameter
, Qbackground_mode
))
2595 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2597 /* FIXME: Avoid this code path at all (as well as code duplication)
2598 by sharing more code with Fframe_parameters. */
2599 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2606 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2607 Smodify_frame_parameters
, 2, 2, 0,
2608 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2609 If FRAME is nil, it defaults to the selected frame.
2610 ALIST is an alist of parameters to change and their new values.
2611 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2612 The meaningful PARMs depend on the kind of frame.
2613 Undefined PARMs are ignored, but stored in the frame's parameter list
2614 so that `frame-parameters' will return them.
2616 The value of frame parameter FOO can also be accessed
2617 as a frame-local binding for the variable FOO, if you have
2618 enabled such bindings for that variable with `make-variable-frame-local'.
2619 Note that this functionality is obsolete as of Emacs 22.2, and its
2620 use is not recommended. Explicitly check for a frame-parameter instead. */)
2621 (Lisp_Object frame
, Lisp_Object alist
)
2623 struct frame
*f
= decode_live_frame (frame
);
2624 register Lisp_Object prop
, val
;
2628 /* I think this should be done with a hook. */
2629 #ifdef HAVE_WINDOW_SYSTEM
2630 if (FRAME_WINDOW_P (f
))
2631 x_set_frame_parameters (f
, alist
);
2635 if (FRAME_MSDOS_P (f
))
2636 IT_set_frame_parameters (f
, alist
);
2641 EMACS_INT length
= XFASTINT (Flength (alist
));
2644 Lisp_Object
*values
;
2646 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2647 values
= parms
+ length
;
2649 /* Extract parm names and values into those vectors. */
2651 for (i
= 0; CONSP (alist
); alist
= XCDR (alist
))
2656 parms
[i
] = Fcar (elt
);
2657 values
[i
] = Fcdr (elt
);
2661 /* Now process them in reverse of specified order. */
2666 store_frame_param (f
, prop
, val
);
2668 if (EQ (prop
, Qforeground_color
)
2669 || EQ (prop
, Qbackground_color
))
2670 update_face_from_frame_parameter (f
, prop
, val
);
2678 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2680 doc
: /* Height in pixels of a line in the font in frame FRAME.
2681 If FRAME is omitted or nil, the selected frame is used.
2682 For a terminal frame, the value is always 1. */)
2685 #ifdef HAVE_WINDOW_SYSTEM
2686 struct frame
*f
= decode_any_frame (frame
);
2688 if (FRAME_WINDOW_P (f
))
2689 return make_number (FRAME_LINE_HEIGHT (f
));
2692 return make_number (1);
2696 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2698 doc
: /* Width in pixels of characters in the font in frame FRAME.
2699 If FRAME is omitted or nil, the selected frame is used.
2700 On a graphical screen, the width is the standard width of the default font.
2701 For a terminal screen, the value is always 1. */)
2704 #ifdef HAVE_WINDOW_SYSTEM
2705 struct frame
*f
= decode_any_frame (frame
);
2707 if (FRAME_WINDOW_P (f
))
2708 return make_number (FRAME_COLUMN_WIDTH (f
));
2711 return make_number (1);
2714 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2715 Sframe_pixel_height
, 0, 1, 0,
2716 doc
: /* Return a FRAME's height in pixels.
2717 If FRAME is omitted or nil, the selected frame is used. The exact value
2718 of the result depends on the window-system and toolkit in use:
2720 In the Gtk+ version of Emacs, it includes only any window (including
2721 the minibuffer or echo area), mode line, and header line. It does not
2722 include the tool bar or menu bar.
2724 With other graphical versions, it also includes the tool bar and the
2727 For a text terminal, it includes the menu bar. In this case, the
2728 result is really in characters rather than pixels (i.e., is identical
2729 to `frame-height'). */)
2732 struct frame
*f
= decode_any_frame (frame
);
2734 #ifdef HAVE_WINDOW_SYSTEM
2735 if (FRAME_WINDOW_P (f
))
2736 return make_number (FRAME_PIXEL_HEIGHT (f
));
2739 return make_number (FRAME_LINES (f
));
2742 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2743 Sframe_pixel_width
, 0, 1, 0,
2744 doc
: /* Return FRAME's width in pixels.
2745 For a terminal frame, the result really gives the width in characters.
2746 If FRAME is omitted or nil, the selected frame is used. */)
2749 struct frame
*f
= decode_any_frame (frame
);
2751 #ifdef HAVE_WINDOW_SYSTEM
2752 if (FRAME_WINDOW_P (f
))
2753 return make_number (FRAME_PIXEL_WIDTH (f
));
2756 return make_number (FRAME_COLS (f
));
2759 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2760 Stool_bar_pixel_width
, 0, 1, 0,
2761 doc
: /* Return width in pixels of FRAME's tool bar.
2762 The result is greater than zero only when the tool bar is on the left
2763 or right side of FRAME. If FRAME is omitted or nil, the selected frame
2767 #ifdef FRAME_TOOLBAR_WIDTH
2768 struct frame
*f
= decode_any_frame (frame
);
2770 if (FRAME_WINDOW_P (f
))
2771 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2773 return make_number (0);
2776 DEFUN ("frame-text-cols", Fframe_text_cols
, Sframe_text_cols
, 0, 1, 0,
2777 doc
: /* Return width in columns of FRAME's text area. */)
2780 return make_number (FRAME_COLS (decode_any_frame (frame
)));
2783 DEFUN ("frame-text-lines", Fframe_text_lines
, Sframe_text_lines
, 0, 1, 0,
2784 doc
: /* Return height in lines of FRAME's text area. */)
2787 return make_number (FRAME_LINES (decode_any_frame (frame
)));
2790 DEFUN ("frame-total-cols", Fframe_total_cols
, Sframe_total_cols
, 0, 1, 0,
2791 doc
: /* Return number of total columns of FRAME. */)
2794 return make_number (FRAME_TOTAL_COLS (decode_any_frame (frame
)));
2797 DEFUN ("frame-total-lines", Fframe_total_lines
, Sframe_total_lines
, 0, 1, 0,
2798 doc
: /* Return number of total lines of FRAME. */)
2801 return make_number (FRAME_TOTAL_LINES (decode_any_frame (frame
)));
2804 DEFUN ("frame-text-width", Fframe_text_width
, Sframe_text_width
, 0, 1, 0,
2805 doc
: /* Return text area width of FRAME in pixels. */)
2808 return make_number (FRAME_TEXT_WIDTH (decode_any_frame (frame
)));
2811 DEFUN ("frame-text-height", Fframe_text_height
, Sframe_text_height
, 0, 1, 0,
2812 doc
: /* Return text area height of FRAME in pixels. */)
2815 return make_number (FRAME_TEXT_HEIGHT (decode_any_frame (frame
)));
2818 DEFUN ("frame-scroll-bar-width", Fscroll_bar_width
, Sscroll_bar_width
, 0, 1, 0,
2819 doc
: /* Return scroll bar width of FRAME in pixels. */)
2822 return make_number (FRAME_SCROLL_BAR_AREA_WIDTH (decode_any_frame (frame
)));
2825 DEFUN ("frame-scroll-bar-height", Fscroll_bar_height
, Sscroll_bar_height
, 0, 1, 0,
2826 doc
: /* Return scroll bar height of FRAME in pixels. */)
2829 return make_number (FRAME_SCROLL_BAR_AREA_HEIGHT (decode_any_frame (frame
)));
2832 DEFUN ("frame-fringe-width", Ffringe_width
, Sfringe_width
, 0, 1, 0,
2833 doc
: /* Return fringe width of FRAME in pixels. */)
2836 return make_number (FRAME_TOTAL_FRINGE_WIDTH (decode_any_frame (frame
)));
2839 DEFUN ("frame-border-width", Fborder_width
, Sborder_width
, 0, 1, 0,
2840 doc
: /* Return border width of FRAME in pixels. */)
2843 return make_number (FRAME_INTERNAL_BORDER_WIDTH (decode_any_frame (frame
)));
2846 DEFUN ("frame-right-divider-width", Fright_divider_width
, Sright_divider_width
, 0, 1, 0,
2847 doc
: /* Return width (in pixels) of vertical window dividers on FRAME. */)
2850 return make_number (FRAME_RIGHT_DIVIDER_WIDTH (decode_any_frame (frame
)));
2853 DEFUN ("frame-bottom-divider-width", Fbottom_divider_width
, Sbottom_divider_width
, 0, 1, 0,
2854 doc
: /* Return width (in pixels) of horizontal window dividers on FRAME. */)
2857 return make_number (FRAME_BOTTOM_DIVIDER_WIDTH (decode_any_frame (frame
)));
2860 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 4, 0,
2861 doc
: /* Specify that the frame FRAME has HEIGHT text lines.
2862 Optional third arg PRETEND non-nil means that redisplay should use
2863 HEIGHT lines but that the idea of the actual height of the frame should
2864 not be changed. Optional fourth argument PIXELWISE non-nil means that
2865 FRAME should be HEIGHT pixels high. */)
2866 (Lisp_Object frame
, Lisp_Object height
, Lisp_Object pretend
, Lisp_Object pixelwise
)
2868 struct frame
*f
= decode_live_frame (frame
);
2871 CHECK_TYPE_RANGED_INTEGER (int, height
);
2873 pixel_height
= (!NILP (pixelwise
)
2875 : XINT (height
) * FRAME_LINE_HEIGHT (f
));
2876 if (pixel_height
!= FRAME_TEXT_HEIGHT (f
))
2877 adjust_frame_size (f
, -1, pixel_height
, 1, !NILP (pretend
));
2882 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 4, 0,
2883 doc
: /* Specify that the frame FRAME has WIDTH columns.
2884 Optional third arg PRETEND non-nil means that redisplay should use WIDTH
2885 columns but that the idea of the actual width of the frame should not
2886 be changed. Optional fourth argument PIXELWISE non-nil means that FRAME
2887 should be WIDTH pixels wide. */)
2888 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object pretend
, Lisp_Object pixelwise
)
2890 struct frame
*f
= decode_live_frame (frame
);
2893 CHECK_TYPE_RANGED_INTEGER (int, width
);
2895 pixel_width
= (!NILP (pixelwise
)
2897 : XINT (width
) * FRAME_COLUMN_WIDTH (f
));
2898 if (pixel_width
!= FRAME_TEXT_WIDTH (f
))
2899 adjust_frame_size (f
, pixel_width
, -1, 1, !NILP (pretend
));
2904 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 4, 0,
2905 doc
: /* Sets size of FRAME to WIDTH by HEIGHT, measured in characters.
2906 Optional argument PIXELWISE non-nil means to measure in pixels. */)
2907 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object height
, Lisp_Object pixelwise
)
2909 struct frame
*f
= decode_live_frame (frame
);
2910 int pixel_width
, pixel_height
;
2912 CHECK_TYPE_RANGED_INTEGER (int, width
);
2913 CHECK_TYPE_RANGED_INTEGER (int, height
);
2915 pixel_width
= (!NILP (pixelwise
)
2917 : XINT (width
) * FRAME_COLUMN_WIDTH (f
));
2918 pixel_height
= (!NILP (pixelwise
)
2920 : XINT (height
) * FRAME_LINE_HEIGHT (f
));
2922 if (pixel_width
!= FRAME_TEXT_WIDTH (f
)
2923 || pixel_height
!= FRAME_TEXT_HEIGHT (f
))
2924 adjust_frame_size (f
, pixel_width
, pixel_height
, 1, 0);
2929 DEFUN ("set-frame-position", Fset_frame_position
,
2930 Sset_frame_position
, 3, 3, 0,
2931 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2932 If FRAME is nil, the selected frame is used. XOFFSET and YOFFSET are
2933 actually the position of the upper left corner of the frame. Negative
2934 values for XOFFSET or YOFFSET are interpreted relative to the rightmost
2935 or bottommost possible position (that stays within the screen). */)
2936 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2938 register struct frame
*f
= decode_live_frame (frame
);
2940 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2941 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2943 /* I think this should be done with a hook. */
2944 #ifdef HAVE_WINDOW_SYSTEM
2945 if (FRAME_WINDOW_P (f
))
2946 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2953 /***********************************************************************
2955 ***********************************************************************/
2957 /* Connect the frame-parameter names for X frames
2958 to the ways of passing the parameter values to the window system.
2960 The name of a parameter, as a Lisp symbol,
2961 has an `x-frame-parameter' property which is an integer in Lisp
2962 that is an index in this table. */
2964 struct frame_parm_table
{
2966 Lisp_Object
*variable
;
2969 static const struct frame_parm_table frame_parms
[] =
2971 {"auto-raise", &Qauto_raise
},
2972 {"auto-lower", &Qauto_lower
},
2973 {"background-color", 0},
2974 {"border-color", &Qborder_color
},
2975 {"border-width", &Qborder_width
},
2976 {"cursor-color", &Qcursor_color
},
2977 {"cursor-type", &Qcursor_type
},
2979 {"foreground-color", 0},
2980 {"icon-name", &Qicon_name
},
2981 {"icon-type", &Qicon_type
},
2982 {"internal-border-width", &Qinternal_border_width
},
2983 {"right-divider-width", &Qright_divider_width
},
2984 {"bottom-divider-width", &Qbottom_divider_width
},
2985 {"menu-bar-lines", &Qmenu_bar_lines
},
2986 {"mouse-color", &Qmouse_color
},
2988 {"scroll-bar-width", &Qscroll_bar_width
},
2989 {"scroll-bar-height", &Qscroll_bar_height
},
2991 {"unsplittable", &Qunsplittable
},
2992 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2993 {"horizontal-scroll-bars", &Qhorizontal_scroll_bars
},
2994 {"visibility", &Qvisibility
},
2995 {"tool-bar-lines", &Qtool_bar_lines
},
2996 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2997 {"scroll-bar-background", &Qscroll_bar_background
},
2998 {"screen-gamma", &Qscreen_gamma
},
2999 {"line-spacing", &Qline_spacing
},
3000 {"left-fringe", &Qleft_fringe
},
3001 {"right-fringe", &Qright_fringe
},
3002 {"wait-for-wm", &Qwait_for_wm
},
3003 {"fullscreen", &Qfullscreen
},
3004 {"font-backend", &Qfont_backend
},
3006 {"sticky", &Qsticky
},
3007 {"tool-bar-position", &Qtool_bar_position
},
3010 #ifdef HAVE_WINDOW_SYSTEM
3012 /* Change the parameters of frame F as specified by ALIST.
3013 If a parameter is not specially recognized, do nothing special;
3014 otherwise call the `x_set_...' function for that parameter.
3015 Except for certain geometry properties, always call store_frame_param
3016 to store the new value in the parameter alist. */
3019 x_set_frame_parameters (struct frame
*f
, Lisp_Object alist
)
3023 /* If both of these parameters are present, it's more efficient to
3024 set them both at once. So we wait until we've looked at the
3025 entire list before we set them. */
3027 bool width_change
= 0, height_change
= 0;
3030 Lisp_Object left
, top
;
3032 /* Same with these. */
3033 Lisp_Object icon_left
, icon_top
;
3035 /* Record in these vectors all the parms specified. */
3037 Lisp_Object
*values
;
3039 bool left_no_change
= 0, top_no_change
= 0;
3040 #ifdef HAVE_X_WINDOWS
3041 bool icon_left_no_change
= 0, icon_top_no_change
= 0;
3043 struct gcpro gcpro1
, gcpro2
;
3046 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3049 parms
= alloca (i
* sizeof *parms
);
3050 values
= alloca (i
* sizeof *values
);
3052 /* Extract parm names and values into those vectors. */
3055 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3060 parms
[i
] = Fcar (elt
);
3061 values
[i
] = Fcdr (elt
);
3064 /* TAIL and ALIST are not used again below here. */
3065 alist
= tail
= Qnil
;
3067 GCPRO2 (*parms
, *values
);
3071 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
3072 because their values appear in VALUES and strings are not valid. */
3073 top
= left
= Qunbound
;
3074 icon_left
= icon_top
= Qunbound
;
3076 /* Process foreground_color and background_color before anything else.
3077 They are independent of other properties, but other properties (e.g.,
3078 cursor_color) are dependent upon them. */
3079 /* Process default font as well, since fringe widths depends on it. */
3080 for (p
= 0; p
< i
; p
++)
3082 Lisp_Object prop
, val
;
3086 if (EQ (prop
, Qforeground_color
)
3087 || EQ (prop
, Qbackground_color
)
3088 || EQ (prop
, Qfont
))
3090 register Lisp_Object param_index
, old_value
;
3092 old_value
= get_frame_param (f
, prop
);
3093 if (NILP (Fequal (val
, old_value
)))
3095 store_frame_param (f
, prop
, val
);
3097 param_index
= Fget (prop
, Qx_frame_parameter
);
3098 if (NATNUMP (param_index
)
3099 && XFASTINT (param_index
) < ARRAYELTS (frame_parms
)
3100 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3101 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3106 /* Now process them in reverse of specified order. */
3109 Lisp_Object prop
, val
;
3114 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
3117 width
= XFASTINT (val
) * FRAME_COLUMN_WIDTH (f
) ;
3119 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
3122 /* Add menu and tool bar lines to correctly resize F pixelwise. */
3124 = (XFASTINT (val
) + FRAME_TOP_MARGIN (f
)) * FRAME_LINE_HEIGHT (f
);
3126 else if (EQ (prop
, Qtop
))
3128 else if (EQ (prop
, Qleft
))
3130 else if (EQ (prop
, Qicon_top
))
3132 else if (EQ (prop
, Qicon_left
))
3134 else if (EQ (prop
, Qforeground_color
)
3135 || EQ (prop
, Qbackground_color
)
3136 || EQ (prop
, Qfont
))
3137 /* Processed above. */
3141 register Lisp_Object param_index
, old_value
;
3143 old_value
= get_frame_param (f
, prop
);
3145 store_frame_param (f
, prop
, val
);
3147 param_index
= Fget (prop
, Qx_frame_parameter
);
3148 if (NATNUMP (param_index
)
3149 && XFASTINT (param_index
) < ARRAYELTS (frame_parms
)
3150 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3151 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3155 /* Don't die if just one of these was set. */
3156 if (EQ (left
, Qunbound
))
3159 if (f
->left_pos
< 0)
3160 left
= list2 (Qplus
, make_number (f
->left_pos
));
3162 XSETINT (left
, f
->left_pos
);
3164 if (EQ (top
, Qunbound
))
3168 top
= list2 (Qplus
, make_number (f
->top_pos
));
3170 XSETINT (top
, f
->top_pos
);
3173 /* If one of the icon positions was not set, preserve or default it. */
3174 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
3176 #ifdef HAVE_X_WINDOWS
3177 icon_left_no_change
= 1;
3179 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3180 if (NILP (icon_left
))
3181 XSETINT (icon_left
, 0);
3183 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
3185 #ifdef HAVE_X_WINDOWS
3186 icon_top_no_change
= 1;
3188 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3189 if (NILP (icon_top
))
3190 XSETINT (icon_top
, 0);
3193 /* Don't set these parameters unless they've been explicitly
3194 specified. The window might be mapped or resized while we're in
3195 this function, and we don't want to override that unless the lisp
3196 code has asked for it.
3198 Don't set these parameters unless they actually differ from the
3199 window's current parameters; the window may not actually exist
3204 XSETFRAME (frame
, f
);
3206 if (((width_change
&& width
!= FRAME_TEXT_WIDTH (f
))
3207 || (height_change
&& height
!= FRAME_TEXT_HEIGHT (f
)))
3208 && (f
->new_height
|| f
->new_width
))
3210 /* If necessary provide default values for HEIGHT and WIDTH. Do
3211 that here since otherwise a size change implied by an
3212 intermittent font change may get lost as in Bug#17142. */
3214 width
= (f
->new_width
3217 : (f
->new_width
* FRAME_COLUMN_WIDTH (f
)))
3218 : FRAME_TEXT_WIDTH (f
));
3221 height
= (f
->new_height
3224 : (f
->new_height
* FRAME_LINE_HEIGHT (f
)))
3225 : FRAME_TEXT_HEIGHT (f
));
3227 Fset_frame_size (frame
, make_number (width
), make_number (height
), Qt
);
3230 if ((!NILP (left
) || !NILP (top
))
3231 && ! (left_no_change
&& top_no_change
)
3232 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3233 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3238 /* Record the signs. */
3239 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3240 if (EQ (left
, Qminus
))
3241 f
->size_hint_flags
|= XNegative
;
3242 else if (TYPE_RANGED_INTEGERP (int, left
))
3244 leftpos
= XINT (left
);
3246 f
->size_hint_flags
|= XNegative
;
3248 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3249 && CONSP (XCDR (left
))
3250 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
3252 leftpos
= - XINT (XCAR (XCDR (left
)));
3253 f
->size_hint_flags
|= XNegative
;
3255 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3256 && CONSP (XCDR (left
))
3257 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
3259 leftpos
= XINT (XCAR (XCDR (left
)));
3262 if (EQ (top
, Qminus
))
3263 f
->size_hint_flags
|= YNegative
;
3264 else if (TYPE_RANGED_INTEGERP (int, top
))
3266 toppos
= XINT (top
);
3268 f
->size_hint_flags
|= YNegative
;
3270 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3271 && CONSP (XCDR (top
))
3272 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
3274 toppos
= - XINT (XCAR (XCDR (top
)));
3275 f
->size_hint_flags
|= YNegative
;
3277 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
3278 && CONSP (XCDR (top
))
3279 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
3281 toppos
= XINT (XCAR (XCDR (top
)));
3285 /* Store the numeric value of the position. */
3286 f
->top_pos
= toppos
;
3287 f
->left_pos
= leftpos
;
3289 f
->win_gravity
= NorthWestGravity
;
3291 /* Actually set that position, and convert to absolute. */
3292 x_set_offset (f
, leftpos
, toppos
, -1);
3294 #ifdef HAVE_X_WINDOWS
3295 if ((!NILP (icon_left
) || !NILP (icon_top
))
3296 && ! (icon_left_no_change
&& icon_top_no_change
))
3297 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3298 #endif /* HAVE_X_WINDOWS */
3305 /* Insert a description of internally-recorded parameters of frame X
3306 into the parameter alist *ALISTPTR that is to be given to the user.
3307 Only parameters that are specific to the X window system
3308 and whose values are not correctly recorded in the frame's
3309 param_alist need to be considered here. */
3312 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3316 char buf
[INT_BUFSIZE_BOUND (w
)];
3318 /* Represent negative positions (off the top or left screen edge)
3319 in a way that Fmodify_frame_parameters will understand correctly. */
3320 XSETINT (tem
, f
->left_pos
);
3321 if (f
->left_pos
>= 0)
3322 store_in_alist (alistptr
, Qleft
, tem
);
3324 store_in_alist (alistptr
, Qleft
, list2 (Qplus
, tem
));
3326 XSETINT (tem
, f
->top_pos
);
3327 if (f
->top_pos
>= 0)
3328 store_in_alist (alistptr
, Qtop
, tem
);
3330 store_in_alist (alistptr
, Qtop
, list2 (Qplus
, tem
));
3332 store_in_alist (alistptr
, Qborder_width
,
3333 make_number (f
->border_width
));
3334 store_in_alist (alistptr
, Qinternal_border_width
,
3335 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3336 store_in_alist (alistptr
, Qright_divider_width
,
3337 make_number (FRAME_RIGHT_DIVIDER_WIDTH (f
)));
3338 store_in_alist (alistptr
, Qbottom_divider_width
,
3339 make_number (FRAME_BOTTOM_DIVIDER_WIDTH (f
)));
3340 store_in_alist (alistptr
, Qleft_fringe
,
3341 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3342 store_in_alist (alistptr
, Qright_fringe
,
3343 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3344 store_in_alist (alistptr
, Qscroll_bar_width
,
3345 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3347 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3348 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3349 /* nil means "use default width"
3350 for non-toolkit scroll bar.
3351 ruler-mode.el depends on this. */
3353 store_in_alist (alistptr
, Qscroll_bar_height
,
3354 (! FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)
3356 : FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) > 0
3357 ? make_number (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
3358 /* nil means "use default height"
3359 for non-toolkit scroll bar. */
3361 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
3362 MS-Windows it returns a value whose type is HANDLE, which is
3363 actually a pointer. Explicit casting avoids compiler
3365 w
= (uintptr_t) FRAME_X_WINDOW (f
);
3366 store_in_alist (alistptr
, Qwindow_id
,
3367 make_formatted_string (buf
, "%"pMu
, w
));
3368 #ifdef HAVE_X_WINDOWS
3369 #ifdef USE_X_TOOLKIT
3370 /* Tooltip frame may not have this widget. */
3371 if (FRAME_X_OUTPUT (f
)->widget
)
3373 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
3374 store_in_alist (alistptr
, Qouter_window_id
,
3375 make_formatted_string (buf
, "%"pMu
, w
));
3377 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3378 store_in_alist (alistptr
, Qvisibility
,
3379 (FRAME_VISIBLE_P (f
) ? Qt
3380 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3381 store_in_alist (alistptr
, Qdisplay
,
3382 XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
));
3384 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_DISPLAY_INFO (f
)->root_window
)
3387 tem
= make_natnum ((uintptr_t) FRAME_X_OUTPUT (f
)->parent_desc
);
3388 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3389 store_in_alist (alistptr
, Qparent_id
, tem
);
3390 store_in_alist (alistptr
, Qtool_bar_position
, FRAME_TOOL_BAR_POSITION (f
));
3394 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3395 the previous value of that parameter, NEW_VALUE is the new value. */
3398 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3400 if (NILP (new_value
))
3401 f
->want_fullscreen
= FULLSCREEN_NONE
;
3402 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3403 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3404 else if (EQ (new_value
, Qfullwidth
))
3405 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3406 else if (EQ (new_value
, Qfullheight
))
3407 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3408 else if (EQ (new_value
, Qmaximized
))
3409 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3411 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3412 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3416 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3417 the previous value of that parameter, NEW_VALUE is the new value. */
3420 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3422 if (NILP (new_value
))
3423 f
->extra_line_spacing
= 0;
3424 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
3425 f
->extra_line_spacing
= XFASTINT (new_value
);
3426 else if (FLOATP (new_value
))
3428 int new_spacing
= XFLOAT_DATA (new_value
) * FRAME_LINE_HEIGHT (f
) + 0.5;
3430 if (new_spacing
>= 0)
3431 f
->extra_line_spacing
= new_spacing
;
3433 signal_error ("Invalid line-spacing", new_value
);
3436 signal_error ("Invalid line-spacing", new_value
);
3437 if (FRAME_VISIBLE_P (f
))
3442 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3443 the previous value of that parameter, NEW_VALUE is the new value. */
3446 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3448 Lisp_Object bgcolor
;
3450 if (NILP (new_value
))
3452 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3453 /* The value 0.4545 is the normal viewing gamma. */
3454 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3456 signal_error ("Invalid screen-gamma", new_value
);
3458 /* Apply the new gamma value to the frame background. */
3459 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3460 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3462 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3463 if (NATNUMP (parm_index
)
3464 && XFASTINT (parm_index
) < ARRAYELTS (frame_parms
)
3465 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3466 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3470 Fclear_face_cache (Qnil
);
3475 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3477 Lisp_Object font_object
;
3479 #ifdef HAVE_X_WINDOWS
3480 Lisp_Object font_param
= arg
;
3483 /* Set the frame parameter back to the old value because we may
3484 fail to use ARG as the new parameter value. */
3485 store_frame_param (f
, Qfont
, oldval
);
3487 /* ARG is a fontset name, a font name, a cons of fontset name and a
3488 font object, or a font object. In the last case, this function
3492 fontset
= fs_query_fontset (arg
, 0);
3495 font_object
= font_open_by_name (f
, arg
);
3496 if (NILP (font_object
))
3497 error ("Font `%s' is not defined", SSDATA (arg
));
3498 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3500 else if (fontset
> 0)
3502 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
3503 if (NILP (font_object
))
3504 error ("Font `%s' is not defined", SDATA (arg
));
3505 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3508 error ("The default fontset can't be used for a frame font");
3510 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3512 /* This is the case that the ASCII font of F's fontset XCAR
3513 (arg) is changed to the font XCDR (arg) by
3514 `set-fontset-font'. */
3515 fontset
= fs_query_fontset (XCAR (arg
), 0);
3517 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3518 font_object
= XCDR (arg
);
3519 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3520 #ifdef HAVE_X_WINDOWS
3521 font_param
= Ffont_get (font_object
, QCname
);
3524 else if (FONT_OBJECT_P (arg
))
3527 #ifdef HAVE_X_WINDOWS
3528 font_param
= Ffont_get (font_object
, QCname
);
3530 /* This is to store the XLFD font name in the frame parameter for
3531 backward compatibility. We should store the font-object
3532 itself in the future. */
3533 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3534 fontset
= FRAME_FONTSET (f
);
3535 /* Check if we can use the current fontset. If not, set FONTSET
3536 to -1 to generate a new fontset from FONT-OBJECT. */
3539 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3540 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3543 signal_error ("Invalid font name", ascii_font
);
3545 if (! font_match_p (spec
, font_object
))
3550 signal_error ("Invalid font", arg
);
3552 if (! NILP (Fequal (font_object
, oldval
)))
3555 x_new_font (f
, font_object
, fontset
);
3556 store_frame_param (f
, Qfont
, arg
);
3557 #ifdef HAVE_X_WINDOWS
3558 store_frame_param (f
, Qfont_param
, font_param
);
3560 /* Recalculate toolbar height. */
3561 f
->n_tool_bar_rows
= 0;
3563 /* Ensure we redraw it. */
3564 clear_current_matrices (f
);
3566 /* Attempt to hunt down bug#16028. */
3567 SET_FRAME_GARBAGED (f
);
3569 recompute_basic_faces (f
);
3571 do_pending_window_change (0);
3573 /* We used to call face-set-after-frame-default here, but it leads to
3574 recursive calls (since that function can set the `default' face's
3575 font which in turns changes the frame's `font' parameter).
3576 Also I don't know what this call is meant to do, but it seems the
3577 wrong way to do it anyway (it does a lot more work than what seems
3578 reasonable in response to a change to `font'). */
3583 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3585 if (! NILP (new_value
)
3586 && !CONSP (new_value
))
3590 CHECK_STRING (new_value
);
3591 p0
= p1
= SSDATA (new_value
);
3595 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
3597 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3603 while ((c
= *++p1
) && c_isspace (c
));
3607 new_value
= Fnreverse (new_value
);
3610 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3614 free_all_realized_faces (Qnil
);
3616 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3617 if (NILP (new_value
))
3619 if (NILP (old_value
))
3620 error ("No font backend available");
3621 font_update_drivers (f
, old_value
);
3622 error ("None of specified font backends are available");
3624 store_frame_param (f
, Qfont_backend
, new_value
);
3630 XSETFRAME (frame
, f
);
3631 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3632 ++face_change_count
;
3633 windows_or_buffers_changed
= 18;
3638 x_set_left_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3640 int unit
= FRAME_COLUMN_WIDTH (f
);
3641 int old_width
= FRAME_LEFT_FRINGE_WIDTH (f
);
3644 new_width
= (RANGED_INTEGERP (-INT_MAX
, new_value
, INT_MAX
)
3645 ? eabs (XINT (new_value
)) : 8);
3647 if (new_width
!= old_width
)
3649 FRAME_LEFT_FRINGE_WIDTH (f
) = new_width
;
3650 FRAME_FRINGE_COLS (f
) /* Round up. */
3651 = (new_width
+ FRAME_RIGHT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
3653 if (FRAME_X_WINDOW (f
) != 0)
3654 adjust_frame_size (f
, -1, -1, 3, 0);
3656 SET_FRAME_GARBAGED (f
);
3662 x_set_right_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3664 int unit
= FRAME_COLUMN_WIDTH (f
);
3665 int old_width
= FRAME_RIGHT_FRINGE_WIDTH (f
);
3668 new_width
= (RANGED_INTEGERP (-INT_MAX
, new_value
, INT_MAX
)
3669 ? eabs (XINT (new_value
)) : 8);
3671 if (new_width
!= old_width
)
3673 FRAME_RIGHT_FRINGE_WIDTH (f
) = new_width
;
3674 FRAME_FRINGE_COLS (f
) /* Round up. */
3675 = (new_width
+ FRAME_LEFT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
3677 if (FRAME_X_WINDOW (f
) != 0)
3678 adjust_frame_size (f
, -1, -1, 3, 0);
3680 SET_FRAME_GARBAGED (f
);
3686 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3688 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3690 if (XINT (arg
) == f
->border_width
)
3693 if (FRAME_X_WINDOW (f
) != 0)
3694 error ("Cannot change the border width of a frame");
3696 f
->border_width
= XINT (arg
);
3700 x_set_right_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3702 int old
= FRAME_RIGHT_DIVIDER_WIDTH (f
);
3704 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3705 FRAME_RIGHT_DIVIDER_WIDTH (f
) = XINT (arg
);
3706 if (FRAME_RIGHT_DIVIDER_WIDTH (f
) < 0)
3707 FRAME_RIGHT_DIVIDER_WIDTH (f
) = 0;
3708 if (FRAME_RIGHT_DIVIDER_WIDTH (f
) != old
)
3710 adjust_frame_size (f
, -1, -1, 4, 0);
3711 adjust_frame_glyphs (f
);
3712 SET_FRAME_GARBAGED (f
);
3718 x_set_bottom_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3720 int old
= FRAME_BOTTOM_DIVIDER_WIDTH (f
);
3722 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3723 FRAME_BOTTOM_DIVIDER_WIDTH (f
) = XINT (arg
);
3724 if (FRAME_BOTTOM_DIVIDER_WIDTH (f
) < 0)
3725 FRAME_BOTTOM_DIVIDER_WIDTH (f
) = 0;
3726 if (FRAME_BOTTOM_DIVIDER_WIDTH (f
) != old
)
3728 adjust_frame_size (f
, -1, -1, 4, 0);
3729 adjust_frame_glyphs (f
);
3730 SET_FRAME_GARBAGED (f
);
3735 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3738 XSETFRAME (frame
, f
);
3741 Fmake_frame_invisible (frame
, Qt
);
3742 else if (EQ (value
, Qicon
))
3743 Ficonify_frame (frame
);
3745 Fmake_frame_visible (frame
);
3749 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3751 f
->auto_raise
= !EQ (Qnil
, arg
);
3755 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3757 f
->auto_lower
= !EQ (Qnil
, arg
);
3761 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3763 f
->no_split
= !NILP (arg
);
3767 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3769 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3770 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3771 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3772 || (!NILP (arg
) && !FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3774 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3776 ? vertical_scroll_bar_none
3778 ? vertical_scroll_bar_left
3780 ? vertical_scroll_bar_right
3781 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3782 ? vertical_scroll_bar_left
3783 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3784 ? vertical_scroll_bar_right
3785 : vertical_scroll_bar_none
);
3787 /* We set this parameter before creating the X window for the
3788 frame, so we can get the geometry right from the start.
3789 However, if the window hasn't been created yet, we shouldn't
3790 call x_set_window_size. */
3791 if (FRAME_X_WINDOW (f
))
3792 adjust_frame_size (f
, -1, -1, 3, 0);
3794 SET_FRAME_GARBAGED (f
);
3799 x_set_horizontal_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3801 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI)
3802 if ((NILP (arg
) && FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
))
3803 || (!NILP (arg
) && !FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)))
3805 FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)
3806 = NILP (arg
) ? false : true;
3808 /* We set this parameter before creating the X window for the
3809 frame, so we can get the geometry right from the start.
3810 However, if the window hasn't been created yet, we shouldn't
3811 call x_set_window_size. */
3812 if (FRAME_X_WINDOW (f
))
3813 adjust_frame_size (f
, -1, -1, 3, 0);
3815 SET_FRAME_GARBAGED (f
);
3821 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3823 int unit
= FRAME_COLUMN_WIDTH (f
);
3827 x_set_scroll_bar_default_width (f
);
3829 if (FRAME_X_WINDOW (f
))
3830 adjust_frame_size (f
, -1, -1, 3, 0);
3832 SET_FRAME_GARBAGED (f
);
3834 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3835 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3837 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3838 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + unit
- 1) / unit
;
3839 if (FRAME_X_WINDOW (f
))
3840 adjust_frame_size (f
, -1, -1, 3, 0);
3842 SET_FRAME_GARBAGED (f
);
3845 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3846 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3850 x_set_scroll_bar_height (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3852 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI)
3853 int unit
= FRAME_LINE_HEIGHT (f
);
3857 x_set_scroll_bar_default_height (f
);
3859 if (FRAME_X_WINDOW (f
))
3860 adjust_frame_size (f
, -1, -1, 3, 0);
3862 SET_FRAME_GARBAGED (f
);
3864 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3865 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
3867 FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) = XFASTINT (arg
);
3868 FRAME_CONFIG_SCROLL_BAR_LINES (f
) = (XFASTINT (arg
) + unit
- 1) / unit
;
3869 if (FRAME_X_WINDOW (f
))
3870 adjust_frame_size (f
, -1, -1, 3, 0);
3872 SET_FRAME_GARBAGED (f
);
3875 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.vpos
= 0;
3876 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.y
= 0;
3881 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3888 for (i
= 0; i
< 2; i
++)
3901 else if (FLOATP (item
))
3903 alpha
= XFLOAT_DATA (item
);
3904 if (! (0 <= alpha
&& alpha
<= 1.0))
3905 args_out_of_range (make_float (0.0), make_float (1.0));
3907 else if (INTEGERP (item
))
3909 EMACS_INT ialpha
= XINT (item
);
3910 if (! (0 <= ialpha
&& alpha
<= 100))
3911 args_out_of_range (make_number (0), make_number (100));
3912 alpha
= ialpha
/ 100.0;
3915 wrong_type_argument (Qnumberp
, item
);
3919 for (i
= 0; i
< 2; i
++)
3920 f
->alpha
[i
] = newval
[i
];
3922 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3924 x_set_frame_alpha (f
);
3933 /* Non-zero if mouse is grabbed on DPYINFO
3934 and we know the frame where it is. */
3936 bool x_mouse_grabbed (Display_Info
*dpyinfo
)
3938 return (dpyinfo
->grabbed
3939 && dpyinfo
->last_mouse_frame
3940 && FRAME_LIVE_P (dpyinfo
->last_mouse_frame
));
3943 /* Re-highlight something with mouse-face properties
3944 on DPYINFO using saved frame and mouse position. */
3947 x_redo_mouse_highlight (Display_Info
*dpyinfo
)
3949 if (dpyinfo
->last_mouse_motion_frame
3950 && FRAME_LIVE_P (dpyinfo
->last_mouse_motion_frame
))
3951 note_mouse_highlight (dpyinfo
->last_mouse_motion_frame
,
3952 dpyinfo
->last_mouse_motion_x
,
3953 dpyinfo
->last_mouse_motion_y
);
3956 #endif /* HAVE_NS */
3958 /* Subroutines of creating an X frame. */
3960 /* Make sure that Vx_resource_name is set to a reasonable value.
3961 Fix it up, or set it to `emacs' if it is too hopeless. */
3964 validate_x_resource_name (void)
3967 /* Number of valid characters in the resource name. */
3968 ptrdiff_t good_count
= 0;
3969 /* Number of invalid characters in the resource name. */
3970 ptrdiff_t bad_count
= 0;
3974 if (!STRINGP (Vx_resource_class
))
3975 Vx_resource_class
= build_string (EMACS_CLASS
);
3977 if (STRINGP (Vx_resource_name
))
3979 unsigned char *p
= SDATA (Vx_resource_name
);
3981 len
= SBYTES (Vx_resource_name
);
3983 /* Only letters, digits, - and _ are valid in resource names.
3984 Count the valid characters and count the invalid ones. */
3985 for (i
= 0; i
< len
; i
++)
3988 if (! ((c
>= 'a' && c
<= 'z')
3989 || (c
>= 'A' && c
<= 'Z')
3990 || (c
>= '0' && c
<= '9')
3991 || c
== '-' || c
== '_'))
3998 /* Not a string => completely invalid. */
3999 bad_count
= 5, good_count
= 0;
4001 /* If name is valid already, return. */
4005 /* If name is entirely invalid, or nearly so, or is so implausibly
4006 large that alloca might not work, use `emacs'. */
4007 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
4009 Vx_resource_name
= build_string ("emacs");
4013 /* Name is partly valid. Copy it and replace the invalid characters
4014 with underscores. */
4016 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
4018 for (i
= 0; i
< len
; i
++)
4020 int c
= SREF (new, i
);
4021 if (! ((c
>= 'a' && c
<= 'z')
4022 || (c
>= 'A' && c
<= 'Z')
4023 || (c
>= '0' && c
<= '9')
4024 || c
== '-' || c
== '_'))
4029 /* Get specified attribute from resource database RDB.
4030 See Fx_get_resource below for other parameters. */
4033 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
4035 register char *value
;
4039 CHECK_STRING (attribute
);
4040 CHECK_STRING (class);
4042 if (!NILP (component
))
4043 CHECK_STRING (component
);
4044 if (!NILP (subclass
))
4045 CHECK_STRING (subclass
);
4046 if (NILP (component
) != NILP (subclass
))
4047 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
4049 validate_x_resource_name ();
4051 /* Allocate space for the components, the dots which separate them,
4052 and the final '\0'. Make them big enough for the worst case. */
4053 name_key
= alloca (SBYTES (Vx_resource_name
)
4054 + (STRINGP (component
)
4055 ? SBYTES (component
) : 0)
4056 + SBYTES (attribute
)
4059 class_key
= alloca (SBYTES (Vx_resource_class
)
4061 + (STRINGP (subclass
)
4062 ? SBYTES (subclass
) : 0)
4065 /* Start with emacs.FRAMENAME for the name (the specific one)
4066 and with `Emacs' for the class key (the general one). */
4067 strcpy (name_key
, SSDATA (Vx_resource_name
));
4068 strcpy (class_key
, SSDATA (Vx_resource_class
));
4070 strcat (class_key
, ".");
4071 strcat (class_key
, SSDATA (class));
4073 if (!NILP (component
))
4075 strcat (class_key
, ".");
4076 strcat (class_key
, SSDATA (subclass
));
4078 strcat (name_key
, ".");
4079 strcat (name_key
, SSDATA (component
));
4082 strcat (name_key
, ".");
4083 strcat (name_key
, SSDATA (attribute
));
4085 value
= x_get_string_resource (rdb
, name_key
, class_key
);
4087 if (value
&& *value
)
4088 return build_string (value
);
4094 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
4095 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
4096 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
4097 class, where INSTANCE is the name under which Emacs was invoked, or
4098 the name specified by the `-name' or `-rn' command-line arguments.
4100 The optional arguments COMPONENT and SUBCLASS add to the key and the
4101 class, respectively. You must specify both of them or neither.
4102 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
4103 and the class is `Emacs.CLASS.SUBCLASS'. */)
4104 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
,
4105 Lisp_Object subclass
)
4107 check_window_system (NULL
);
4109 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
4110 attribute
, class, component
, subclass
);
4113 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
4116 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
,
4117 Lisp_Object
class, Lisp_Object component
,
4118 Lisp_Object subclass
)
4120 return xrdb_get_resource (dpyinfo
->xrdb
,
4121 attribute
, class, component
, subclass
);
4124 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
4125 /* Used when C code wants a resource value. */
4126 /* Called from oldXMenu/Create.c. */
4128 x_get_resource_string (const char *attribute
, const char *class)
4131 struct frame
*sf
= SELECTED_FRAME ();
4132 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
4135 /* Allocate space for the components, the dots which separate them,
4136 and the final '\0'. */
4137 char *name_key
= SAFE_ALLOCA (invocation_namelen
+ strlen (attribute
) + 2);
4138 char *class_key
= alloca ((sizeof (EMACS_CLASS
) - 1) + strlen (class) + 2);
4140 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
4141 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
4143 result
= x_get_string_resource (FRAME_DISPLAY_INFO (sf
)->xrdb
,
4144 name_key
, class_key
);
4150 /* Return the value of parameter PARAM.
4152 First search ALIST, then Vdefault_frame_alist, then the X defaults
4153 database, using ATTRIBUTE as the attribute name and CLASS as its class.
4155 Convert the resource to the type specified by desired_type.
4157 If no default is specified, return Qunbound. If you call
4158 x_get_arg, make sure you deal with Qunbound in a reasonable way,
4159 and don't let it get stored in any Lisp-visible variables! */
4162 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
4163 const char *attribute
, const char *class, enum resource_types type
)
4165 register Lisp_Object tem
;
4167 tem
= Fassq (param
, alist
);
4171 /* If we find this parm in ALIST, clear it out
4172 so that it won't be "left over" at the end. */
4174 XSETCAR (tem
, Qnil
);
4175 /* In case the parameter appears more than once in the alist,
4177 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
4178 if (CONSP (XCAR (tail
))
4179 && EQ (XCAR (XCAR (tail
)), param
))
4180 XSETCAR (XCAR (tail
), Qnil
);
4183 tem
= Fassq (param
, Vdefault_frame_alist
);
4185 /* If it wasn't specified in ALIST or the Lisp-level defaults,
4186 look in the X resources. */
4189 if (attribute
&& dpyinfo
)
4191 tem
= display_x_get_resource (dpyinfo
,
4192 build_string (attribute
),
4193 build_string (class),
4201 case RES_TYPE_NUMBER
:
4202 return make_number (atoi (SSDATA (tem
)));
4204 case RES_TYPE_BOOLEAN_NUMBER
:
4205 if (!strcmp (SSDATA (tem
), "on")
4206 || !strcmp (SSDATA (tem
), "true"))
4207 return make_number (1);
4208 return make_number (atoi (SSDATA (tem
)));
4211 case RES_TYPE_FLOAT
:
4212 return make_float (atof (SSDATA (tem
)));
4214 case RES_TYPE_BOOLEAN
:
4215 tem
= Fdowncase (tem
);
4216 if (!strcmp (SSDATA (tem
), "on")
4218 || !strcmp (SSDATA (tem
), "yes")
4220 || !strcmp (SSDATA (tem
), "true"))
4225 case RES_TYPE_STRING
:
4228 case RES_TYPE_SYMBOL
:
4229 /* As a special case, we map the values `true' and `on'
4230 to Qt, and `false' and `off' to Qnil. */
4233 lower
= Fdowncase (tem
);
4234 if (!strcmp (SSDATA (lower
), "on")
4236 || !strcmp (SSDATA (lower
), "yes")
4238 || !strcmp (SSDATA (lower
), "true"))
4240 else if (!strcmp (SSDATA (lower
), "off")
4242 || !strcmp (SSDATA (lower
), "no")
4244 || !strcmp (SSDATA (lower
), "false"))
4247 return Fintern (tem
, Qnil
);
4261 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
4262 const char *attribute
, const char *class,
4263 enum resource_types type
)
4265 return x_get_arg (FRAME_DISPLAY_INFO (f
),
4266 alist
, param
, attribute
, class, type
);
4269 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
4272 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
4274 const char *attribute
, const char *class,
4275 enum resource_types type
)
4279 value
= x_get_arg (FRAME_DISPLAY_INFO (f
), alist
, param
,
4280 attribute
, class, type
);
4281 if (! NILP (value
) && ! EQ (value
, Qunbound
))
4282 store_frame_param (f
, param
, value
);
4288 /* Record in frame F the specified or default value according to ALIST
4289 of the parameter named PROP (a Lisp symbol).
4290 If no value is specified for PROP, look for an X default for XPROP
4291 on the frame named NAME.
4292 If that is not found either, use the value DEFLT. */
4295 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
4296 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
4297 enum resource_types type
)
4301 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
4302 if (EQ (tem
, Qunbound
))
4304 x_set_frame_parameters (f
, list1 (Fcons (prop
, tem
)));
4309 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
4312 * XParseGeometry parses strings of the form
4313 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
4314 * width, height, xoffset, and yoffset are unsigned integers.
4315 * Example: "=80x24+300-49"
4316 * The equal sign is optional.
4317 * It returns a bitmask that indicates which of the four values
4318 * were actually found in the string. For each value found,
4319 * the corresponding argument is updated; for each value
4320 * not found, the corresponding argument is left unchanged.
4324 XParseGeometry (char *string
,
4326 unsigned int *width
, unsigned int *height
)
4330 unsigned long tempWidth
, tempHeight
;
4331 long int tempX
, tempY
;
4332 char *nextCharacter
;
4334 if (string
== NULL
|| *string
== '\0')
4337 string
++; /* ignore possible '=' at beg of geometry spec */
4340 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
4342 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
4343 if (strind
== nextCharacter
)
4345 strind
= nextCharacter
;
4349 if (*strind
== 'x' || *strind
== 'X')
4352 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
4353 if (strind
== nextCharacter
)
4355 strind
= nextCharacter
;
4356 mask
|= HeightValue
;
4359 if (*strind
== '+' || *strind
== '-')
4363 tempX
= strtol (strind
, &nextCharacter
, 10);
4364 if (strind
== nextCharacter
)
4366 strind
= nextCharacter
;
4368 if (*strind
== '+' || *strind
== '-')
4372 tempY
= strtol (strind
, &nextCharacter
, 10);
4373 if (strind
== nextCharacter
)
4375 strind
= nextCharacter
;
4380 /* If strind isn't at the end of the string then it's an invalid
4381 geometry specification. */
4383 if (*strind
!= '\0')
4387 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
4389 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
4390 if (mask
& WidthValue
)
4391 *width
= min (tempWidth
, UINT_MAX
);
4392 if (mask
& HeightValue
)
4393 *height
= min (tempHeight
, UINT_MAX
);
4397 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
4400 /* NS used to define x-parse-geometry in ns-win.el, but that confused
4401 make-docfile: the documentation string in ns-win.el was used for
4402 x-parse-geometry even in non-NS builds.
4404 With two definitions of x-parse-geometry in this file, various
4405 things still get confused (eg M-x apropos documentation), so that
4406 it is best if the two definitions just share the same doc-string.
4408 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4409 doc
: /* Parse a display geometry string STRING.
4410 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4411 The properties returned may include `top', `left', `height', and `width'.
4412 For X, the value of `left' or `top' may be an integer,
4413 or a list (+ N) meaning N pixels relative to top/left corner,
4414 or a list (- N) meaning -N pixels relative to bottom/right corner.
4415 On Nextstep, this just calls `ns-parse-geometry'. */)
4416 (Lisp_Object string
)
4419 unsigned int width
, height
;
4422 CHECK_STRING (string
);
4425 if (strchr (SSDATA (string
), ' ') != NULL
)
4426 return call1 (Qns_parse_geometry
, string
);
4428 geometry
= XParseGeometry (SSDATA (string
),
4429 &x
, &y
, &width
, &height
);
4431 if (geometry
& XValue
)
4433 Lisp_Object element
;
4435 if (x
>= 0 && (geometry
& XNegative
))
4436 element
= list3 (Qleft
, Qminus
, make_number (-x
));
4437 else if (x
< 0 && ! (geometry
& XNegative
))
4438 element
= list3 (Qleft
, Qplus
, make_number (x
));
4440 element
= Fcons (Qleft
, make_number (x
));
4441 result
= Fcons (element
, result
);
4444 if (geometry
& YValue
)
4446 Lisp_Object element
;
4448 if (y
>= 0 && (geometry
& YNegative
))
4449 element
= list3 (Qtop
, Qminus
, make_number (-y
));
4450 else if (y
< 0 && ! (geometry
& YNegative
))
4451 element
= list3 (Qtop
, Qplus
, make_number (y
));
4453 element
= Fcons (Qtop
, make_number (y
));
4454 result
= Fcons (element
, result
);
4457 if (geometry
& WidthValue
)
4458 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
4459 if (geometry
& HeightValue
)
4460 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
4466 /* Calculate the desired size and position of frame F.
4467 Return the flags saying which aspects were specified.
4469 Also set the win_gravity and size_hint_flags of F.
4471 Adjust height for toolbar if TOOLBAR_P is 1.
4473 This function does not make the coordinates positive. */
4475 #define DEFAULT_ROWS 35
4476 #define DEFAULT_COLS 80
4479 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, bool toolbar_p
)
4481 Lisp_Object height
, width
, user_size
, top
, left
, user_position
;
4482 long window_prompting
= 0;
4483 Display_Info
*dpyinfo
= FRAME_DISPLAY_INFO (f
);
4485 /* Default values if we fall through.
4486 Actually, if that happens we should get
4487 window manager prompting. */
4488 SET_FRAME_WIDTH (f
, DEFAULT_COLS
* FRAME_COLUMN_WIDTH (f
));
4489 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4490 SET_FRAME_HEIGHT (f
, DEFAULT_ROWS
* FRAME_LINE_HEIGHT (f
));
4491 SET_FRAME_LINES (f
, DEFAULT_ROWS
);
4493 /* Window managers expect that if program-specified
4494 positions are not (0,0), they're intentional, not defaults. */
4498 /* Ensure that earlier new_width and new_height settings won't
4499 override what we specify below. */
4500 f
->new_width
= f
->new_height
= 0;
4502 height
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4503 width
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4504 if (!EQ (width
, Qunbound
) || !EQ (height
, Qunbound
))
4506 if (!EQ (width
, Qunbound
))
4508 CHECK_NUMBER (width
);
4509 if (! (0 <= XINT (width
) && XINT (width
) <= INT_MAX
))
4510 xsignal1 (Qargs_out_of_range
, width
);
4512 SET_FRAME_WIDTH (f
, XINT (width
) * FRAME_COLUMN_WIDTH (f
));
4515 if (!EQ (height
, Qunbound
))
4517 CHECK_NUMBER (height
);
4518 if (! (0 <= XINT (height
) && XINT (height
) <= INT_MAX
))
4519 xsignal1 (Qargs_out_of_range
, height
);
4521 SET_FRAME_HEIGHT (f
, XINT (height
) * FRAME_LINE_HEIGHT (f
));
4524 user_size
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4525 if (!NILP (user_size
) && !EQ (user_size
, Qunbound
))
4526 window_prompting
|= USSize
;
4528 window_prompting
|= PSize
;
4531 /* Add a tool bar height to the initial frame height so that the user
4532 gets a text display area of the size he specified with -g or via
4533 .Xdefaults. Later changes of the tool bar height don't change the
4534 frame size. This is done so that users can create tall Emacs
4535 frames without having to guess how tall the tool bar will get. */
4536 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4540 relief
= (tool_bar_button_relief
>= 0
4541 ? tool_bar_button_relief
4542 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4544 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
4545 margin
= XFASTINT (Vtool_bar_button_margin
);
4546 else if (CONSP (Vtool_bar_button_margin
)
4547 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
4548 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4552 FRAME_TOOL_BAR_HEIGHT (f
)
4553 = DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4554 Vframe_initial_frame_tool_bar_height
= make_number (FRAME_TOOL_BAR_HEIGHT (f
));
4557 top
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4558 left
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4559 user_position
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4560 if (! EQ (top
, Qunbound
) || ! EQ (left
, Qunbound
))
4562 if (EQ (top
, Qminus
))
4565 window_prompting
|= YNegative
;
4567 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
4568 && CONSP (XCDR (top
))
4569 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
4571 f
->top_pos
= - XINT (XCAR (XCDR (top
)));
4572 window_prompting
|= YNegative
;
4574 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
4575 && CONSP (XCDR (top
))
4576 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
4578 f
->top_pos
= XINT (XCAR (XCDR (top
)));
4580 else if (EQ (top
, Qunbound
))
4584 CHECK_TYPE_RANGED_INTEGER (int, top
);
4585 f
->top_pos
= XINT (top
);
4587 window_prompting
|= YNegative
;
4590 if (EQ (left
, Qminus
))
4593 window_prompting
|= XNegative
;
4595 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
4596 && CONSP (XCDR (left
))
4597 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
4599 f
->left_pos
= - XINT (XCAR (XCDR (left
)));
4600 window_prompting
|= XNegative
;
4602 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
4603 && CONSP (XCDR (left
))
4604 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
4606 f
->left_pos
= XINT (XCAR (XCDR (left
)));
4608 else if (EQ (left
, Qunbound
))
4612 CHECK_TYPE_RANGED_INTEGER (int, left
);
4613 f
->left_pos
= XINT (left
);
4614 if (f
->left_pos
< 0)
4615 window_prompting
|= XNegative
;
4618 if (!NILP (user_position
) && ! EQ (user_position
, Qunbound
))
4619 window_prompting
|= USPosition
;
4621 window_prompting
|= PPosition
;
4624 if (window_prompting
& XNegative
)
4626 if (window_prompting
& YNegative
)
4627 f
->win_gravity
= SouthEastGravity
;
4629 f
->win_gravity
= NorthEastGravity
;
4633 if (window_prompting
& YNegative
)
4634 f
->win_gravity
= SouthWestGravity
;
4636 f
->win_gravity
= NorthWestGravity
;
4639 f
->size_hint_flags
= window_prompting
;
4641 return window_prompting
;
4646 #endif /* HAVE_WINDOW_SYSTEM */
4649 frame_make_pointer_invisible (struct frame
*f
)
4651 if (! NILP (Vmake_pointer_invisible
))
4653 if (f
&& FRAME_LIVE_P (f
) && !f
->pointer_invisible
4654 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4657 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4658 f
->pointer_invisible
= 1;
4664 frame_make_pointer_visible (struct frame
*f
)
4666 /* We don't check Vmake_pointer_invisible here in case the
4667 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4668 if (f
&& FRAME_LIVE_P (f
) && f
->pointer_invisible
&& f
->mouse_moved
4669 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4671 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4672 f
->pointer_invisible
= 0;
4676 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4677 Sframe_pointer_visible_p
, 0, 1, 0,
4678 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4679 Otherwise it returns nil. FRAME omitted or nil means the
4680 selected frame. This is useful when `make-pointer-invisible' is set. */)
4683 return decode_any_frame (frame
)->pointer_invisible
? Qnil
: Qt
;
4688 /***********************************************************************
4690 ***********************************************************************/
4692 #ifdef HAVE_WINDOW_SYSTEM
4694 # if (defined HAVE_NS \
4695 || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR)))
4697 free_monitors (struct MonitorInfo
*monitors
, int n_monitors
)
4700 for (i
= 0; i
< n_monitors
; ++i
)
4701 xfree (monitors
[i
].name
);
4707 make_monitor_attribute_list (struct MonitorInfo
*monitors
,
4709 int primary_monitor
,
4710 Lisp_Object monitor_frames
,
4713 Lisp_Object attributes_list
= Qnil
;
4714 Lisp_Object primary_monitor_attributes
= Qnil
;
4717 for (i
= 0; i
< n_monitors
; ++i
)
4719 Lisp_Object geometry
, workarea
, attributes
= Qnil
;
4720 struct MonitorInfo
*mi
= &monitors
[i
];
4722 if (mi
->geom
.width
== 0) continue;
4724 workarea
= list4i (mi
->work
.x
, mi
->work
.y
,
4725 mi
->work
.width
, mi
->work
.height
);
4726 geometry
= list4i (mi
->geom
.x
, mi
->geom
.y
,
4727 mi
->geom
.width
, mi
->geom
.height
);
4728 attributes
= Fcons (Fcons (Qsource
, build_string (source
)),
4730 attributes
= Fcons (Fcons (Qframes
, AREF (monitor_frames
, i
)),
4732 attributes
= Fcons (Fcons (Qmm_size
,
4733 list2i (mi
->mm_width
, mi
->mm_height
)),
4735 attributes
= Fcons (Fcons (Qworkarea
, workarea
), attributes
);
4736 attributes
= Fcons (Fcons (Qgeometry
, geometry
), attributes
);
4738 attributes
= Fcons (Fcons (Qname
, make_string (mi
->name
,
4739 strlen (mi
->name
))),
4742 if (i
== primary_monitor
)
4743 primary_monitor_attributes
= attributes
;
4745 attributes_list
= Fcons (attributes
, attributes_list
);
4748 if (!NILP (primary_monitor_attributes
))
4749 attributes_list
= Fcons (primary_monitor_attributes
, attributes_list
);
4750 return attributes_list
;
4753 #endif /* HAVE_WINDOW_SYSTEM */
4756 /***********************************************************************
4758 ***********************************************************************/
4761 syms_of_frame (void)
4763 DEFSYM (Qframep
, "framep");
4764 DEFSYM (Qframe_live_p
, "frame-live-p");
4765 DEFSYM (Qframe_windows_min_size
, "frame-windows-min-size");
4766 DEFSYM (Qexplicit_name
, "explicit-name");
4767 DEFSYM (Qheight
, "height");
4768 DEFSYM (Qicon
, "icon");
4769 DEFSYM (Qminibuffer
, "minibuffer");
4770 DEFSYM (Qmodeline
, "modeline");
4771 DEFSYM (Qonly
, "only");
4772 DEFSYM (Qnone
, "none");
4773 DEFSYM (Qwidth
, "width");
4774 DEFSYM (Qgeometry
, "geometry");
4775 DEFSYM (Qicon_left
, "icon-left");
4776 DEFSYM (Qicon_top
, "icon-top");
4777 DEFSYM (Qtooltip
, "tooltip");
4778 DEFSYM (Quser_position
, "user-position");
4779 DEFSYM (Quser_size
, "user-size");
4780 DEFSYM (Qwindow_id
, "window-id");
4781 #ifdef HAVE_X_WINDOWS
4782 DEFSYM (Qouter_window_id
, "outer-window-id");
4784 DEFSYM (Qparent_id
, "parent-id");
4786 DEFSYM (Qw32
, "w32");
4789 DEFSYM (Qvisible
, "visible");
4790 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4791 DEFSYM (Qbuffer_list
, "buffer-list");
4792 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4793 DEFSYM (Qdisplay_type
, "display-type");
4794 DEFSYM (Qbackground_mode
, "background-mode");
4795 DEFSYM (Qnoelisp
, "noelisp");
4796 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4797 DEFSYM (Qtty
, "tty");
4798 DEFSYM (Qtty_type
, "tty-type");
4800 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4802 DEFSYM (Qfullwidth
, "fullwidth");
4803 DEFSYM (Qfullheight
, "fullheight");
4804 DEFSYM (Qfullboth
, "fullboth");
4805 DEFSYM (Qmaximized
, "maximized");
4806 DEFSYM (Qx_resource_name
, "x-resource-name");
4807 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4809 DEFSYM (Qterminal
, "terminal");
4811 DEFSYM (Qgeometry
, "geometry");
4812 DEFSYM (Qworkarea
, "workarea");
4813 DEFSYM (Qmm_size
, "mm-size");
4814 DEFSYM (Qframes
, "frames");
4815 DEFSYM (Qsource
, "source");
4818 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4824 for (i
= 0; i
< ARRAYELTS (frame_parms
); i
++)
4826 Lisp_Object v
= intern_c_string (frame_parms
[i
].name
);
4827 if (frame_parms
[i
].variable
)
4829 *frame_parms
[i
].variable
= v
;
4830 staticpro (frame_parms
[i
].variable
);
4832 Fput (v
, Qx_frame_parameter
, make_number (i
));
4836 #ifdef HAVE_WINDOW_SYSTEM
4837 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4838 doc
: /* The name Emacs uses to look up X resources.
4839 `x-get-resource' uses this as the first component of the instance name
4840 when requesting resource values.
4841 Emacs initially sets `x-resource-name' to the name under which Emacs
4842 was invoked, or to the value specified with the `-name' or `-rn'
4843 switches, if present.
4845 It may be useful to bind this variable locally around a call
4846 to `x-get-resource'. See also the variable `x-resource-class'. */);
4847 Vx_resource_name
= Qnil
;
4849 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4850 doc
: /* The class Emacs uses to look up X resources.
4851 `x-get-resource' uses this as the first component of the instance class
4852 when requesting resource values.
4854 Emacs initially sets `x-resource-class' to "Emacs".
4856 Setting this variable permanently is not a reasonable thing to do,
4857 but binding this variable locally around a call to `x-get-resource'
4858 is a reasonable practice. See also the variable `x-resource-name'. */);
4859 Vx_resource_class
= build_string (EMACS_CLASS
);
4861 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4862 doc
: /* The lower limit of the frame opacity (alpha transparency).
4863 The value should range from 0 (invisible) to 100 (completely opaque).
4864 You can also use a floating number between 0.0 and 1.0. */);
4865 Vframe_alpha_lower_limit
= make_number (20);
4868 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4869 doc
: /* Alist of default values for frame creation.
4870 These may be set in your init file, like this:
4871 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4872 These override values given in window system configuration data,
4873 including X Windows' defaults database.
4874 For values specific to the first Emacs frame, see `initial-frame-alist'.
4875 For window-system specific values, see `window-system-default-frame-alist'.
4876 For values specific to the separate minibuffer frame, see
4877 `minibuffer-frame-alist'.
4878 The `menu-bar-lines' element of the list controls whether new frames
4879 have menu bars; `menu-bar-mode' works by altering this element.
4880 Setting this variable does not affect existing frames, only new ones. */);
4881 Vdefault_frame_alist
= Qnil
;
4883 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
4884 doc
: /* Default position of vertical scroll bars on this window-system. */);
4885 #ifdef HAVE_WINDOW_SYSTEM
4886 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
4887 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
4889 Vdefault_frame_scroll_bars
= Qright
;
4891 Vdefault_frame_scroll_bars
= Qleft
;
4894 Vdefault_frame_scroll_bars
= Qnil
;
4897 DEFVAR_LISP ("default-frame-horizontal-scroll-bars", Vdefault_frame_horizontal_scroll_bars
,
4898 doc
: /* Default value for horizontal scroll bars on this window-system. */);
4899 #ifdef HAVE_WINDOW_SYSTEM
4900 Vdefault_frame_horizontal_scroll_bars
= Qt
;
4902 Vdefault_frame_horizontal_scroll_bars
= Qnil
;
4905 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
4906 scroll_bar_adjust_thumb_portion_p
,
4907 doc
: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
4908 Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
4909 even if the end of the buffer is shown (i.e. overscrolling).
4910 Set to nil if you want the thumb to be at the bottom when the end of the buffer
4911 is shown. Also, the thumb fills the whole scroll bar when the entire buffer
4912 is visible. In this case you can not overscroll. */);
4913 scroll_bar_adjust_thumb_portion_p
= 1;
4915 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
4916 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4918 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
4919 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4920 `mouse-position' calls this function, passing its usual return value as
4921 argument, and returns whatever this function returns.
4922 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4923 which need to do mouse handling at the Lisp level. */);
4924 Vmouse_position_function
= Qnil
;
4926 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
4927 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4928 If the value is an integer, highlighting is only shown after moving the
4929 mouse, while keyboard input turns off the highlight even when the mouse
4930 is over the clickable text. However, the mouse shape still indicates
4931 when the mouse is over clickable text. */);
4932 Vmouse_highlight
= Qt
;
4934 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
4935 doc
: /* If non-nil, make pointer invisible while typing.
4936 The pointer becomes visible again when the mouse is moved. */);
4937 Vmake_pointer_invisible
= Qt
;
4939 DEFVAR_LISP ("focus-in-hook", Vfocus_in_hook
,
4940 doc
: /* Normal hook run when a frame gains input focus. */);
4941 Vfocus_in_hook
= Qnil
;
4942 DEFSYM (Qfocus_in_hook
, "focus-in-hook");
4944 DEFVAR_LISP ("focus-out-hook", Vfocus_out_hook
,
4945 doc
: /* Normal hook run when a frame loses input focus. */);
4946 Vfocus_out_hook
= Qnil
;
4947 DEFSYM (Qfocus_out_hook
, "focus-out-hook");
4949 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
4950 doc
: /* Functions run before deleting a frame.
4951 The functions are run with one arg, the frame to be deleted.
4954 Note that functions in this list may be called just before the frame is
4955 actually deleted, or some time later (or even both when an earlier function
4956 in `delete-frame-functions' (indirectly) calls `delete-frame'
4958 Vdelete_frame_functions
= Qnil
;
4959 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
4961 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
4962 doc
: /* Non-nil if Menu-Bar mode is enabled.
4963 See the command `menu-bar-mode' for a description of this minor mode.
4964 Setting this variable directly does not take effect;
4965 either customize it (see the info node `Easy Customization')
4966 or call the function `menu-bar-mode'. */);
4967 Vmenu_bar_mode
= Qt
;
4969 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
4970 doc
: /* Non-nil if Tool-Bar mode is enabled.
4971 See the command `tool-bar-mode' for a description of this minor mode.
4972 Setting this variable directly does not take effect;
4973 either customize it (see the info node `Easy Customization')
4974 or call the function `tool-bar-mode'. */);
4975 #ifdef HAVE_WINDOW_SYSTEM
4976 Vtool_bar_mode
= Qt
;
4978 Vtool_bar_mode
= Qnil
;
4981 DEFVAR_LISP ("frame-initial-frame-tool-bar-height", Vframe_initial_frame_tool_bar_height
,
4982 doc
: /* Height of tool bar of initial frame. */);
4983 Vframe_initial_frame_tool_bar_height
= make_number (0);
4985 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4986 doc
: /* Minibufferless frames use this frame's minibuffer.
4987 Emacs cannot create minibufferless frames unless this is set to an
4988 appropriate surrogate.
4990 Emacs consults this variable only when creating minibufferless
4991 frames; once the frame is created, it sticks with its assigned
4992 minibuffer, no matter what this variable is set to. This means that
4993 this variable doesn't necessarily say anything meaningful about the
4994 current set of frames, or where the minibuffer is currently being
4997 This variable is local to the current terminal and cannot be buffer-local. */);
4999 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
5000 doc
: /* Non-nil if window system changes focus when you move the mouse.
5001 You should set this variable to tell Emacs how your window manager
5002 handles focus, since there is no way in general for Emacs to find out
5003 automatically. See also `mouse-autoselect-window'. */);
5004 focus_follows_mouse
= 0;
5006 DEFVAR_BOOL ("frame-resize-pixelwise", frame_resize_pixelwise
,
5007 doc
: /* Non-nil means resize frames pixelwise.
5008 If this option is nil, resizing a frame rounds its sizes to the frame's
5009 current values of `frame-char-height' and `frame-char-width'. If this
5010 is non-nil, no rounding occurs, hence frame sizes can increase/decrease
5013 With some window managers you may have to set this to non-nil in order
5014 to fully maximize frames. To resize your initial frame pixelwise, set
5015 this option to a non-nil value in your init file. */);
5016 frame_resize_pixelwise
= 0;
5018 DEFVAR_BOOL ("frame-inhibit-implied-resize", frame_inhibit_implied_resize
,
5019 doc
: /* Non-nil means do not resize frame implicitly.
5020 If this option is nil, setting default font, menubar mode, fringe width,
5021 or scroll bar mode of a specific frame may resize the frame in order to
5022 preserve the number of columns or lines it displays. If this option is
5023 non-nil, no such resizing is done. */);
5024 frame_inhibit_implied_resize
= 0;
5026 staticpro (&Vframe_list
);
5029 defsubr (&Sframe_live_p
);
5030 defsubr (&Swindow_system
);
5031 defsubr (&Smake_terminal_frame
);
5032 defsubr (&Shandle_switch_frame
);
5033 defsubr (&Sselect_frame
);
5034 defsubr (&Sselected_frame
);
5035 defsubr (&Sframe_list
);
5036 defsubr (&Snext_frame
);
5037 defsubr (&Sprevious_frame
);
5038 defsubr (&Slast_nonminibuf_frame
);
5039 defsubr (&Sdelete_frame
);
5040 defsubr (&Smouse_position
);
5041 defsubr (&Smouse_pixel_position
);
5042 defsubr (&Sset_mouse_position
);
5043 defsubr (&Sset_mouse_pixel_position
);
5045 defsubr (&Sframe_configuration
);
5046 defsubr (&Srestore_frame_configuration
);
5048 defsubr (&Smake_frame_visible
);
5049 defsubr (&Smake_frame_invisible
);
5050 defsubr (&Siconify_frame
);
5051 defsubr (&Sframe_visible_p
);
5052 defsubr (&Svisible_frame_list
);
5053 defsubr (&Sraise_frame
);
5054 defsubr (&Slower_frame
);
5055 defsubr (&Sx_focus_frame
);
5056 defsubr (&Sredirect_frame_focus
);
5057 defsubr (&Sframe_focus
);
5058 defsubr (&Sframe_parameters
);
5059 defsubr (&Sframe_parameter
);
5060 defsubr (&Smodify_frame_parameters
);
5061 defsubr (&Sframe_char_height
);
5062 defsubr (&Sframe_char_width
);
5063 defsubr (&Sframe_pixel_height
);
5064 defsubr (&Sframe_pixel_width
);
5065 defsubr (&Sframe_text_cols
);
5066 defsubr (&Sframe_text_lines
);
5067 defsubr (&Sframe_total_cols
);
5068 defsubr (&Sframe_total_lines
);
5069 defsubr (&Sframe_text_width
);
5070 defsubr (&Sframe_text_height
);
5071 defsubr (&Sscroll_bar_width
);
5072 defsubr (&Sscroll_bar_height
);
5073 defsubr (&Sfringe_width
);
5074 defsubr (&Sborder_width
);
5075 defsubr (&Sright_divider_width
);
5076 defsubr (&Sbottom_divider_width
);
5077 defsubr (&Stool_bar_pixel_width
);
5078 defsubr (&Sset_frame_height
);
5079 defsubr (&Sset_frame_width
);
5080 defsubr (&Sset_frame_size
);
5081 defsubr (&Sset_frame_position
);
5082 defsubr (&Sframe_pointer_visible_p
);
5084 #ifdef HAVE_WINDOW_SYSTEM
5085 defsubr (&Sx_get_resource
);
5086 defsubr (&Sx_parse_geometry
);