1 /* Generic frame functions.
3 Copyright (C) 1993-1995, 1997, 1999-2015 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29 #include "character.h"
31 #ifdef HAVE_WINDOW_SYSTEM
33 #endif /* HAVE_WINDOW_SYSTEM */
36 /* These help us bind and responding to switch-frame events. */
40 #include "blockinput.h"
42 #include "termhooks.h"
43 #include "dispextern.h"
46 #ifdef HAVE_WINDOW_SYSTEM
58 /* The currently selected frame. */
60 Lisp_Object selected_frame
;
62 /* A frame which is not just a mini-buffer, or NULL if there are no such
63 frames. This is usually the most recent such frame that was selected. */
65 static struct frame
*last_nonminibuf_frame
;
67 /* False means there are no visible garbaged frames. */
70 /* The default tool bar height for future frames. */
71 #if defined USE_GTK || defined HAVE_NS
72 enum { frame_default_tool_bar_height
= 0 };
74 int frame_default_tool_bar_height
;
77 #ifdef HAVE_WINDOW_SYSTEM
78 static void x_report_frame_params (struct frame
*, Lisp_Object
*);
81 /* These setters are used only in this file, so they can be private. */
83 fset_buffer_predicate (struct frame
*f
, Lisp_Object val
)
85 f
->buffer_predicate
= val
;
88 fset_minibuffer_window (struct frame
*f
, Lisp_Object val
)
90 f
->minibuffer_window
= val
;
94 decode_live_frame (register Lisp_Object frame
)
97 frame
= selected_frame
;
98 CHECK_LIVE_FRAME (frame
);
99 return XFRAME (frame
);
103 decode_any_frame (register Lisp_Object frame
)
106 frame
= selected_frame
;
108 return XFRAME (frame
);
111 #ifdef HAVE_WINDOW_SYSTEM
114 window_system_available (struct frame
*f
)
116 return f
? FRAME_WINDOW_P (f
) || FRAME_MSDOS_P (f
) : x_display_list
!= NULL
;
119 #endif /* HAVE_WINDOW_SYSTEM */
122 decode_window_system_frame (Lisp_Object frame
)
124 struct frame
*f
= decode_live_frame (frame
);
126 if (!window_system_available (f
))
127 error ("Window system frame should be used");
132 check_window_system (struct frame
*f
)
134 if (!window_system_available (f
))
135 error (f
? "Window system frame should be used"
136 : "Window system is not in use or not initialized");
139 /* Return the value of frame parameter PROP in frame FRAME. */
142 get_frame_param (register struct frame
*frame
, Lisp_Object prop
)
144 register Lisp_Object tem
;
146 tem
= Fassq (prop
, frame
->param_alist
);
154 frame_size_history_add (struct frame
*f
, Lisp_Object fun_symbol
,
155 int width
, int height
, Lisp_Object rest
)
160 XSETFRAME (frame
, f
);
161 if (CONSP (frame_size_history
)
162 && NUMBERP (Fcar (frame_size_history
))
163 && ((number
= XINT (Fcar (frame_size_history
))) > 0))
165 Fcons (make_number (number
- 1),
169 ? list4 (make_number (FRAME_TEXT_WIDTH (f
)),
170 make_number (FRAME_TEXT_HEIGHT (f
)),
172 make_number (height
))
175 Fcdr (frame_size_history
)));
179 /* Return 1 if `frame-inhibit-implied-resize' is non-nil or fullscreen
180 state of frame F would be affected by a vertical (horizontal if
181 HORIZONTAL is true) resize. PARAMETER is the symbol of the frame
182 parameter that is changed. */
184 frame_inhibit_resize (struct frame
*f
, bool horizontal
, Lisp_Object parameter
)
186 Lisp_Object fullscreen
= get_frame_param (f
, Qfullscreen
);
188 = ((f
->after_make_frame
189 && (EQ (frame_inhibit_implied_resize
, Qt
)
190 || (CONSP (frame_inhibit_implied_resize
)
191 && !NILP (Fmemq (parameter
, frame_inhibit_implied_resize
)))))
193 && !EQ (fullscreen
, Qnil
) && !EQ (fullscreen
, Qfullheight
))
195 && !EQ (fullscreen
, Qnil
) && !EQ (fullscreen
, Qfullwidth
))
196 || FRAME_TERMCAP_P (f
) || FRAME_MSDOS_P (f
));
198 if (inhibit
&& !FRAME_TERMCAP_P (f
) && !FRAME_MSDOS_P (f
))
199 frame_size_history_add
200 (f
, Qframe_inhibit_resize
, 0, 0,
201 list5 (horizontal
? Qt
: Qnil
, parameter
,
202 f
->after_make_frame
? Qt
: Qnil
,
203 frame_inhibit_implied_resize
,
210 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
213 int olines
= FRAME_MENU_BAR_LINES (f
);
215 /* Right now, menu bars don't work properly in minibuf-only frames;
216 most of the commands try to apply themselves to the minibuffer
217 frame itself, and get an error because you can't switch buffers
218 in or split the minibuffer window. */
219 if (FRAME_MINIBUF_ONLY_P (f
))
222 if (TYPE_RANGED_INTEGERP (int, value
))
223 nlines
= XINT (value
);
227 if (nlines
!= olines
)
229 windows_or_buffers_changed
= 14;
230 FRAME_MENU_BAR_LINES (f
) = nlines
;
231 FRAME_MENU_BAR_HEIGHT (f
) = nlines
* FRAME_LINE_HEIGHT (f
);
232 change_frame_size (f
, FRAME_COLS (f
),
233 FRAME_LINES (f
) + olines
- nlines
,
238 Lisp_Object Vframe_list
;
241 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
242 doc
: /* Return non-nil if OBJECT is a frame.
244 t for a termcap frame (a character-only terminal),
245 'x' for an Emacs frame that is really an X window,
246 'w32' for an Emacs frame that is a window on MS-Windows display,
247 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
248 'pc' for a direct-write MS-DOS frame.
249 See also `frame-live-p'. */)
252 if (!FRAMEP (object
))
254 switch (XFRAME (object
)->output_method
)
256 case output_initial
: /* The initial frame is like a termcap frame. */
259 case output_x_window
:
263 case output_msdos_raw
:
272 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
273 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
274 Value is nil if OBJECT is not a live frame. If object is a live
275 frame, the return value indicates what sort of terminal device it is
276 displayed on. See the documentation of `framep' for possible
280 return ((FRAMEP (object
)
281 && FRAME_LIVE_P (XFRAME (object
)))
286 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
287 doc
: /* The name of the window system that FRAME is displaying through.
288 The value is a symbol:
289 nil for a termcap frame (a character-only terminal),
290 'x' for an Emacs frame that is really an X window,
291 'w32' for an Emacs frame that is a window on MS-Windows display,
292 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
293 'pc' for a direct-write MS-DOS frame.
295 FRAME defaults to the currently selected frame.
297 Use of this function as a predicate is deprecated. Instead,
298 use `display-graphic-p' or any of the other `display-*-p'
299 predicates which report frame's specific UI-related capabilities. */)
304 frame
= selected_frame
;
306 type
= Fframep (frame
);
309 wrong_type_argument (Qframep
, frame
);
317 /* Placeholder used by temacs -nw before window.el is loaded. */
318 DEFUN ("frame-windows-min-size", Fframe_windows_min_size
,
319 Sframe_windows_min_size
, 4, 4, 0,
322 (Lisp_Object frame
, Lisp_Object horizontal
,
323 Lisp_Object ignore
, Lisp_Object pixelwise
)
325 return make_number (0);
329 frame_windows_min_size (Lisp_Object frame
, Lisp_Object horizontal
,
330 Lisp_Object ignore
, Lisp_Object pixelwise
)
332 return XINT (call4 (Qframe_windows_min_size
, frame
, horizontal
,
337 /* Make sure windows sizes of frame F are OK. new_width and new_height
338 are in pixels. A value of -1 means no change is requested for that
339 size (but the frame may still have to be resized to accommodate
340 windows with their minimum sizes). This can either issue a request
341 to resize the frame externally (via x_set_window_size), to resize the
342 frame internally (via resize_frame_windows) or do nothing at all.
344 The argument INHIBIT can assume the following values:
346 0 means to unconditionally call x_set_window_size even if sizes
347 apparently do not change. Fx_create_frame uses this to pass the
348 initial size to the window manager.
350 1 means to call x_set_window_size if the outer frame size really
351 changes. Fset_frame_size, Fset_frame_height, ... use this.
353 2 means to call x_set_window_size provided frame_inhibit_resize
354 allows it. The menu and tool bar code use this ("3" won't work
355 here in general because menu and tool bar are often not counted in
356 the frame's text height).
358 3 means call x_set_window_size if window minimum sizes must be
359 preserved or frame_inhibit_resize allows it. x_set_left_fringe,
360 x_set_scroll_bar_width, x_new_font ... use (or should use) this.
362 4 means call x_set_window_size only if window minimum sizes must be
363 preserved. x_set_right_divider_width, x_set_border_width and the
364 code responsible for wrapping the tool bar use this.
366 5 means to never call x_set_window_size. change_frame_size uses
369 Note that even when x_set_window_size is not called, individual
370 windows may have to be resized (via `window--sanitize-window-sizes')
371 in order to support minimum size constraints.
373 PRETEND is as for change_frame_size. PARAMETER, if non-nil, is the
374 symbol of the parameter changed (like `menu-bar-lines', `font', ...).
375 This is passed on to frame_inhibit_resize to let the latter decide on
376 a case-by-case basis whether the frame may be resized externally. */
378 adjust_frame_size (struct frame
*f
, int new_width
, int new_height
, int inhibit
,
379 bool pretend
, Lisp_Object parameter
)
381 int unit_width
= FRAME_COLUMN_WIDTH (f
);
382 int unit_height
= FRAME_LINE_HEIGHT (f
);
383 int old_pixel_width
= FRAME_PIXEL_WIDTH (f
);
384 int old_pixel_height
= FRAME_PIXEL_HEIGHT (f
);
385 int old_cols
= FRAME_COLS (f
);
386 int old_lines
= FRAME_LINES (f
);
387 int new_pixel_width
, new_pixel_height
;
388 /* The following two values are calculated from the old frame pixel
389 sizes and any "new" settings for tool bar, menu bar and internal
390 borders. We do it this way to detect whether we have to call
391 x_set_window_size as consequence of the new settings. */
392 int windows_width
= FRAME_WINDOWS_WIDTH (f
);
393 int windows_height
= FRAME_WINDOWS_HEIGHT (f
);
394 int min_windows_width
, min_windows_height
;
395 /* These are a bit tedious, maybe we should use a macro. */
396 struct window
*r
= XWINDOW (FRAME_ROOT_WINDOW (f
));
397 int old_windows_width
= WINDOW_PIXEL_WIDTH (r
);
398 int old_windows_height
399 = (WINDOW_PIXEL_HEIGHT (r
)
400 + (FRAME_HAS_MINIBUF_P (f
)
401 ? WINDOW_PIXEL_HEIGHT (XWINDOW (FRAME_MINIBUF_WINDOW (f
)))
403 int new_windows_width
, new_windows_height
;
404 int old_text_width
= FRAME_TEXT_WIDTH (f
);
405 int old_text_height
= FRAME_TEXT_HEIGHT (f
);
406 /* If a size is < 0 use the old value. */
407 int new_text_width
= (new_width
>= 0) ? new_width
: old_text_width
;
408 int new_text_height
= (new_height
>= 0) ? new_height
: old_text_height
;
409 int new_cols
, new_lines
;
410 bool inhibit_horizontal
, inhibit_vertical
;
413 XSETFRAME (frame
, f
);
415 frame_size_history_add
416 (f
, Qadjust_frame_size_1
, new_text_width
, new_text_height
,
417 list2 (parameter
, make_number (inhibit
)));
419 /* The following two values are calculated from the old window body
420 sizes and any "new" settings for scroll bars, dividers, fringes and
421 margins (though the latter should have been processed already). */
423 = frame_windows_min_size (frame
, Qt
, (inhibit
== 5) ? Qt
: Qnil
, Qt
);
425 = frame_windows_min_size (frame
, Qnil
, (inhibit
== 5) ? Qt
: Qnil
, Qt
);
427 if (inhibit
>= 2 && inhibit
<= 4)
428 /* When INHIBIT is in [2..4] inhibit if the "old" window sizes stay
429 within the limits and either frame_inhibit_resize tells us to do
430 so or INHIBIT equals 4. */
432 inhibit_horizontal
= ((windows_width
>= min_windows_width
434 || frame_inhibit_resize (f
, true, parameter
)))
436 inhibit_vertical
= ((windows_height
>= min_windows_height
438 || frame_inhibit_resize (f
, false, parameter
)))
442 /* Otherwise inhibit if INHIBIT equals 5. */
443 inhibit_horizontal
= inhibit_vertical
= inhibit
== 5;
445 new_pixel_width
= ((inhibit_horizontal
&& (inhibit
< 5))
447 : max (FRAME_TEXT_TO_PIXEL_WIDTH (f
, new_text_width
),
449 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
450 new_windows_width
= new_pixel_width
- 2 * FRAME_INTERNAL_BORDER_WIDTH (f
);
451 new_text_width
= FRAME_PIXEL_TO_TEXT_WIDTH (f
, new_pixel_width
);
452 new_cols
= new_text_width
/ unit_width
;
454 new_pixel_height
= ((inhibit_vertical
&& (inhibit
< 5))
456 : max (FRAME_TEXT_TO_PIXEL_HEIGHT (f
, new_text_height
),
458 + FRAME_TOP_MARGIN_HEIGHT (f
)
459 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
460 new_windows_height
= (new_pixel_height
461 - FRAME_TOP_MARGIN_HEIGHT (f
)
462 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f
));
463 new_text_height
= FRAME_PIXEL_TO_TEXT_HEIGHT (f
, new_pixel_height
);
464 new_lines
= new_text_height
/ unit_height
;
466 #ifdef HAVE_WINDOW_SYSTEM
467 if (FRAME_WINDOW_P (f
)
468 && f
->can_x_set_window_size
469 && ((!inhibit_horizontal
470 && (new_pixel_width
!= old_pixel_width
471 || inhibit
== 0 || inhibit
== 2))
472 || (!inhibit_vertical
473 && (new_pixel_height
!= old_pixel_height
474 || inhibit
== 0 || inhibit
== 2))))
475 /* We are either allowed to change the frame size or the minimum
476 sizes request such a change. Do not care for fixing minimum
477 sizes here, we do that eventually when we're called from
478 change_frame_size. */
480 /* Make sure we respect fullheight and fullwidth. */
481 if (inhibit_horizontal
)
482 new_text_width
= old_text_width
;
483 else if (inhibit_vertical
)
484 new_text_height
= old_text_height
;
486 frame_size_history_add
487 (f
, Qadjust_frame_size_2
, new_text_width
, new_text_height
,
488 list2 (inhibit_horizontal
? Qt
: Qnil
,
489 inhibit_vertical
? Qt
: Qnil
));
491 x_set_window_size (f
, 0, new_text_width
, new_text_height
, 1);
498 if (new_text_width
== old_text_width
499 && new_text_height
== old_text_height
500 && new_windows_width
== old_windows_width
501 && new_windows_height
== old_windows_height
502 && new_pixel_width
== old_pixel_width
503 && new_pixel_height
== old_pixel_height
504 && new_cols
== old_cols
505 && new_lines
== old_lines
)
506 /* No change. Sanitize window sizes and return. */
508 sanitize_window_sizes (frame
, Qt
);
509 sanitize_window_sizes (frame
, Qnil
);
517 /* We only can set screen dimensions to certain values supported
518 by our video hardware. Try to find the smallest size greater
519 or equal to the requested dimensions. */
520 dos_set_window_size (&new_lines
, &new_cols
);
523 if (new_windows_width
!= old_windows_width
)
525 resize_frame_windows (f
, new_windows_width
, 1, 1);
527 /* MSDOS frames cannot PRETEND, as they change frame size by
528 manipulating video hardware. */
529 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
530 FrameCols (FRAME_TTY (f
)) = new_cols
;
532 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
533 if (WINDOWP (f
->tool_bar_window
))
535 XWINDOW (f
->tool_bar_window
)->pixel_width
= new_windows_width
;
536 XWINDOW (f
->tool_bar_window
)->total_cols
537 = new_windows_width
/ unit_width
;
542 if (new_windows_height
!= old_windows_height
543 /* When the top margin has changed we have to recalculate the top
544 edges of all windows. No such calculation is necessary for the
546 || WINDOW_TOP_PIXEL_EDGE (r
) != FRAME_TOP_MARGIN_HEIGHT (f
))
548 resize_frame_windows (f
, new_windows_height
, 0, 1);
550 /* MSDOS frames cannot PRETEND, as they change frame size by
551 manipulating video hardware. */
552 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
553 FrameRows (FRAME_TTY (f
)) = new_lines
+ FRAME_TOP_MARGIN (f
);
556 frame_size_history_add
557 (f
, Qadjust_frame_size_3
, new_text_width
, new_text_height
,
558 list4 (make_number (old_pixel_width
), make_number (old_pixel_height
),
559 make_number (new_pixel_width
), make_number (new_pixel_height
)));
561 /* Assign new sizes. */
562 FRAME_TEXT_WIDTH (f
) = new_text_width
;
563 FRAME_TEXT_HEIGHT (f
) = new_text_height
;
564 FRAME_PIXEL_WIDTH (f
) = new_pixel_width
;
565 FRAME_PIXEL_HEIGHT (f
) = new_pixel_height
;
566 SET_FRAME_COLS (f
, new_cols
);
567 SET_FRAME_LINES (f
, new_lines
);
570 struct window
*w
= XWINDOW (FRAME_SELECTED_WINDOW (f
));
571 int text_area_x
, text_area_y
, text_area_width
, text_area_height
;
573 window_box (w
, TEXT_AREA
, &text_area_x
, &text_area_y
, &text_area_width
,
575 if (w
->cursor
.x
>= text_area_x
+ text_area_width
)
576 w
->cursor
.hpos
= w
->cursor
.x
= 0;
577 if (w
->cursor
.y
>= text_area_y
+ text_area_height
)
578 w
->cursor
.vpos
= w
->cursor
.y
= 0;
581 /* Sanitize window sizes. */
582 sanitize_window_sizes (frame
, Qt
);
583 sanitize_window_sizes (frame
, Qnil
);
585 adjust_frame_glyphs (f
);
587 SET_FRAME_GARBAGED (f
);
589 /* A frame was "resized" if one of its pixelsizes changed, even if its
590 X window wasn't resized at all. */
591 f
->resized_p
= (new_pixel_width
!= old_pixel_width
592 || new_pixel_height
!= old_pixel_height
);
596 run_window_configuration_change_hook (f
);
599 /* Allocate basically initialized frame. */
601 static struct frame
*
602 allocate_frame (void)
604 return ALLOCATE_ZEROED_PSEUDOVECTOR (struct frame
, face_cache
, PVEC_FRAME
);
608 make_frame (bool mini_p
)
611 register struct frame
*f
;
612 register struct window
*rw
, *mw
;
613 register Lisp_Object root_window
;
614 register Lisp_Object mini_window
;
616 f
= allocate_frame ();
617 XSETFRAME (frame
, f
);
620 /* Initialize Lisp data. Note that allocate_frame initializes all
621 Lisp data to nil, so do it only for slots which should not be nil. */
622 fset_tool_bar_position (f
, Qtop
);
625 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
626 non-Lisp data, so do it only for slots which should not be zero.
627 To avoid subtle bugs and for the sake of readability, it's better to
628 initialize enum members explicitly even if their values are zero. */
629 f
->wants_modeline
= true;
632 f
->can_x_set_window_size
= false;
633 f
->after_make_frame
= false;
634 f
->tool_bar_redisplayed_once
= false;
635 f
->column_width
= 1; /* !FRAME_WINDOW_P value. */
636 f
->line_height
= 1; /* !FRAME_WINDOW_P value. */
637 #ifdef HAVE_WINDOW_SYSTEM
638 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
639 f
->horizontal_scroll_bars
= false;
640 f
->want_fullscreen
= FULLSCREEN_NONE
;
641 #if ! defined (USE_GTK) && ! defined (HAVE_NS)
642 f
->last_tool_bar_item
= -1;
646 root_window
= make_window ();
647 rw
= XWINDOW (root_window
);
650 mini_window
= make_window ();
651 mw
= XWINDOW (mini_window
);
652 wset_next (rw
, mini_window
);
653 wset_prev (mw
, root_window
);
655 wset_frame (mw
, frame
);
656 fset_minibuffer_window (f
, mini_window
);
661 wset_next (rw
, Qnil
);
662 fset_minibuffer_window (f
, Qnil
);
665 wset_frame (rw
, frame
);
668 just so that there is "something there."
669 Correct size will be set up later with adjust_frame_size. */
671 SET_FRAME_COLS (f
, 10);
672 SET_FRAME_LINES (f
, 10);
673 SET_FRAME_WIDTH (f
, FRAME_COLS (f
) * FRAME_COLUMN_WIDTH (f
));
674 SET_FRAME_HEIGHT (f
, FRAME_LINES (f
) * FRAME_LINE_HEIGHT (f
));
677 rw
->pixel_width
= rw
->total_cols
* FRAME_COLUMN_WIDTH (f
);
678 rw
->total_lines
= mini_p
? 9 : 10;
679 rw
->pixel_height
= rw
->total_lines
* FRAME_LINE_HEIGHT (f
);
683 mw
->top_line
= rw
->total_lines
;
684 mw
->pixel_top
= rw
->pixel_height
;
685 mw
->total_cols
= rw
->total_cols
;
686 mw
->pixel_width
= rw
->pixel_width
;
688 mw
->pixel_height
= FRAME_LINE_HEIGHT (f
);
691 /* Choose a buffer for the frame's root window. */
693 Lisp_Object buf
= Fcurrent_buffer ();
695 /* If current buffer is hidden, try to find another one. */
696 if (BUFFER_HIDDEN_P (XBUFFER (buf
)))
697 buf
= other_buffer_safely (buf
);
699 /* Use set_window_buffer, not Fset_window_buffer, and don't let
700 hooks be run by it. The reason is that the whole frame/window
701 arrangement is not yet fully initialized at this point. Windows
702 don't have the right size, glyph matrices aren't initialized
703 etc. Running Lisp functions at this point surely ends in a
705 set_window_buffer (root_window
, buf
, 0, 0);
706 fset_buffer_list (f
, list1 (buf
));
711 set_window_buffer (mini_window
,
712 (NILP (Vminibuffer_list
)
714 : Fcar (Vminibuffer_list
)),
716 /* No horizontal scroll bars in minibuffers. */
717 wset_horizontal_scroll_bar (mw
, Qnil
);
720 fset_root_window (f
, root_window
);
721 fset_selected_window (f
, root_window
);
722 /* Make sure this window seems more recently used than
723 a newly-created, never-selected window. */
724 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
729 #ifdef HAVE_WINDOW_SYSTEM
730 /* Make a frame using a separate minibuffer window on another frame.
731 MINI_WINDOW is the minibuffer window to use. nil means use the
732 default (the global minibuffer). */
735 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
737 register struct frame
*f
;
740 if (!NILP (mini_window
))
741 CHECK_LIVE_WINDOW (mini_window
);
743 if (!NILP (mini_window
)
744 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
745 error ("Frame and minibuffer must be on the same terminal");
747 /* Make a frame containing just a root window. */
750 if (NILP (mini_window
))
752 /* Use default-minibuffer-frame if possible. */
753 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
754 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
756 Lisp_Object frame_dummy
;
758 XSETFRAME (frame_dummy
, f
);
759 GCPRO1 (frame_dummy
);
760 /* If there's no minibuffer frame to use, create one. */
761 kset_default_minibuffer_frame
762 (kb
, call1 (intern ("make-initial-minibuffer-frame"), display
));
767 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
770 fset_minibuffer_window (f
, mini_window
);
772 /* Make the chosen minibuffer window display the proper minibuffer,
773 unless it is already showing a minibuffer. */
774 if (NILP (Fmemq (XWINDOW (mini_window
)->contents
, Vminibuffer_list
)))
775 /* Use set_window_buffer instead of Fset_window_buffer (see
776 discussion of bug#11984, bug#12025, bug#12026). */
777 set_window_buffer (mini_window
,
778 (NILP (Vminibuffer_list
)
780 : Fcar (Vminibuffer_list
)), 0, 0);
784 /* Make a frame containing only a minibuffer window. */
787 make_minibuffer_frame (void)
789 /* First make a frame containing just a root window, no minibuffer. */
791 register struct frame
*f
= make_frame (0);
792 register Lisp_Object mini_window
;
793 register Lisp_Object frame
;
795 XSETFRAME (frame
, f
);
800 f
->wants_modeline
= 0;
802 /* Now label the root window as also being the minibuffer.
803 Avoid infinite looping on the window chain by marking next pointer
806 mini_window
= f
->root_window
;
807 fset_minibuffer_window (f
, mini_window
);
808 XWINDOW (mini_window
)->mini
= 1;
809 wset_next (XWINDOW (mini_window
), Qnil
);
810 wset_prev (XWINDOW (mini_window
), Qnil
);
811 wset_frame (XWINDOW (mini_window
), frame
);
813 /* Put the proper buffer in that window. */
815 /* Use set_window_buffer instead of Fset_window_buffer (see
816 discussion of bug#11984, bug#12025, bug#12026). */
817 set_window_buffer (mini_window
,
818 (NILP (Vminibuffer_list
)
820 : Fcar (Vminibuffer_list
)), 0, 0);
823 #endif /* HAVE_WINDOW_SYSTEM */
825 /* Construct a frame that refers to a terminal. */
827 static printmax_t tty_frame_count
;
830 make_initial_frame (void)
833 struct terminal
*terminal
;
836 eassert (initial_kboard
);
838 /* The first call must initialize Vframe_list. */
839 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
842 terminal
= init_initial_terminal ();
845 XSETFRAME (frame
, f
);
847 Vframe_list
= Fcons (frame
, Vframe_list
);
850 fset_name (f
, build_pure_c_string ("F1"));
852 SET_FRAME_VISIBLE (f
, 1);
854 f
->output_method
= terminal
->type
;
855 f
->terminal
= terminal
;
856 f
->terminal
->reference_count
++;
857 f
->output_data
.nothing
= 0;
859 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
860 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
862 #ifdef HAVE_WINDOW_SYSTEM
863 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
864 f
->horizontal_scroll_bars
= false;
867 /* The default value of menu-bar-mode is t. */
868 set_menu_bar_lines (f
, make_number (1), Qnil
);
871 init_frame_faces (f
);
873 last_nonminibuf_frame
= f
;
879 static struct frame
*
880 make_terminal_frame (struct terminal
*terminal
)
882 register struct frame
*f
;
884 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
887 error ("Terminal is not live, can't create new frames on it");
891 XSETFRAME (frame
, f
);
892 Vframe_list
= Fcons (frame
, Vframe_list
);
894 fset_name (f
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
896 SET_FRAME_VISIBLE (f
, 1);
898 f
->terminal
= terminal
;
899 f
->terminal
->reference_count
++;
901 f
->output_data
.tty
->display_info
= &the_only_display_info
;
902 if (!inhibit_window_system
903 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
904 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
905 f
->output_method
= output_msdos_raw
;
907 f
->output_method
= output_termcap
;
908 #else /* not MSDOS */
909 f
->output_method
= output_termcap
;
910 create_tty_output (f
);
911 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
912 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
913 #endif /* not MSDOS */
915 #ifdef HAVE_WINDOW_SYSTEM
916 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
917 f
->horizontal_scroll_bars
= false;
920 FRAME_MENU_BAR_LINES (f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
921 FRAME_LINES (f
) = FRAME_LINES (f
) - FRAME_MENU_BAR_LINES (f
);
922 FRAME_MENU_BAR_HEIGHT (f
) = FRAME_MENU_BAR_LINES (f
) * FRAME_LINE_HEIGHT (f
);
923 FRAME_TEXT_HEIGHT (f
) = FRAME_TEXT_HEIGHT (f
) - FRAME_MENU_BAR_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
= decode_live_terminal (terminal
);
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
;
1022 tty
= get_future_frame_param
1023 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1024 ? FRAME_TTY (XFRAME (selected_frame
))->name
1027 SAFE_ALLOCA_STRING (name
, tty
);
1029 tty_type
= get_future_frame_param
1030 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1031 ? FRAME_TTY (XFRAME (selected_frame
))->type
1033 if (!NILP (tty_type
))
1034 SAFE_ALLOCA_STRING (type
, tty_type
);
1036 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
1040 f
= make_terminal_frame (t
);
1044 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
1045 adjust_frame_size (f
, width
, height
- FRAME_MENU_BAR_LINES (f
),
1046 5, 0, Qterminal_frame
);
1049 adjust_frame_glyphs (f
);
1050 calculate_costs (f
);
1051 XSETFRAME (frame
, f
);
1053 store_in_alist (&parms
, Qtty_type
, build_string (t
->display_info
.tty
->type
));
1054 store_in_alist (&parms
, Qtty
,
1055 (t
->display_info
.tty
->name
1056 ? build_string (t
->display_info
.tty
->name
)
1058 Fmodify_frame_parameters (frame
, parms
);
1060 /* Make the frame face alist be frame-specific, so that each
1061 frame could change its face definitions independently. */
1062 fset_face_alist (f
, Fcopy_alist (sf
->face_alist
));
1063 /* Simple Fcopy_alist isn't enough, because we need the contents of
1064 the vectors which are the CDRs of associations in face_alist to
1065 be copied as well. */
1066 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
1067 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
1072 /* Perform the switch to frame FRAME.
1074 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
1077 If TRACK is non-zero and the frame that currently has the focus
1078 redirects its focus to the selected frame, redirect that focused
1079 frame's focus to FRAME instead.
1081 FOR_DELETION non-zero means that the selected frame is being
1082 deleted, which includes the possibility that the frame's terminal
1085 The value of NORECORD is passed as argument to Fselect_window. */
1088 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
1090 struct frame
*sf
= SELECTED_FRAME ();
1092 /* If FRAME is a switch-frame event, extract the frame we should
1095 && EQ (XCAR (frame
), Qswitch_frame
)
1096 && CONSP (XCDR (frame
)))
1097 frame
= XCAR (XCDR (frame
));
1099 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
1100 a switch-frame event to arrive after a frame is no longer live,
1101 especially when deleting the initial frame during startup. */
1102 CHECK_FRAME (frame
);
1103 if (! FRAME_LIVE_P (XFRAME (frame
)))
1106 if (sf
== XFRAME (frame
))
1109 /* If a frame's focus has been redirected toward the currently
1110 selected frame, we should change the redirection to point to the
1111 newly selected frame. This means that if the focus is redirected
1112 from a minibufferless frame to a surrogate minibuffer frame, we
1113 can use `other-window' to switch between all the frames using
1114 that minibuffer frame, and the focus redirection will follow us
1117 /* This is too greedy; it causes inappropriate focus redirection
1118 that's hard to get rid of. */
1123 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1127 if (!FRAMEP (XCAR (tail
)))
1130 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
1132 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1133 Fredirect_frame_focus (XCAR (tail
), frame
);
1137 /* Instead, apply it only to the frame we're pointing to. */
1138 #ifdef HAVE_WINDOW_SYSTEM
1139 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
1141 Lisp_Object focus
, xfocus
;
1143 xfocus
= x_get_focus_frame (XFRAME (frame
));
1144 if (FRAMEP (xfocus
))
1146 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
1147 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1148 Fredirect_frame_focus (xfocus
, frame
);
1151 #endif /* HAVE_X_WINDOWS */
1154 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
1155 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
1157 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
1159 struct frame
*f
= XFRAME (frame
);
1160 struct tty_display_info
*tty
= FRAME_TTY (f
);
1161 Lisp_Object top_frame
= tty
->top_frame
;
1163 /* Don't mark the frame garbaged and/or obscured if we are
1164 switching to the frame that is already the top frame of that
1166 if (!EQ (frame
, top_frame
))
1168 if (FRAMEP (top_frame
))
1169 /* Mark previously displayed frame as now obscured. */
1170 SET_FRAME_VISIBLE (XFRAME (top_frame
), 2);
1171 SET_FRAME_VISIBLE (f
, 1);
1172 /* If the new TTY frame changed dimensions, we need to
1173 resync term.c's idea of the frame size with the new
1175 if (FRAME_COLS (f
) != FrameCols (tty
))
1176 FrameCols (tty
) = FRAME_COLS (f
);
1177 if (FRAME_TOTAL_LINES (f
) != FrameRows (tty
))
1178 FrameRows (tty
) = FRAME_TOTAL_LINES (f
);
1180 tty
->top_frame
= frame
;
1183 selected_frame
= frame
;
1184 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
1185 last_nonminibuf_frame
= XFRAME (selected_frame
);
1187 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
1189 /* We want to make sure that the next event generates a frame-switch
1190 event to the appropriate frame. This seems kludgy to me, but
1191 before you take it out, make sure that evaluating something like
1192 (select-window (frame-root-window (new-frame))) doesn't end up
1193 with your typing being interpreted in the new frame instead of
1194 the one you're actually typing in. */
1195 internal_last_event_frame
= Qnil
;
1200 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
1201 doc
: /* Select FRAME.
1202 Subsequent editing commands apply to its selected window.
1203 Optional argument NORECORD means to neither change the order of
1204 recently selected windows nor the buffer list.
1206 The selection of FRAME lasts until the next time the user does
1207 something to select a different frame, or until the next time
1208 this function is called. If you are using a window system, the
1209 previously selected frame may be restored as the selected frame
1210 when returning to the command loop, because it still may have
1211 the window system's input focus. On a text terminal, the next
1212 redisplay will display FRAME.
1214 This function returns FRAME, or nil if FRAME has been deleted. */)
1215 (Lisp_Object frame
, Lisp_Object norecord
)
1217 return do_switch_frame (frame
, 1, 0, norecord
);
1220 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "^e",
1221 doc
: /* Handle a switch-frame event EVENT.
1222 Switch-frame events are usually bound to this function.
1223 A switch-frame event tells Emacs that the window manager has requested
1224 that the user's events be directed to the frame mentioned in the event.
1225 This function selects the selected window of the frame of EVENT.
1227 If EVENT is frame object, handle it as if it were a switch-frame event
1231 /* Preserve prefix arg that the command loop just cleared. */
1232 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
1233 run_hook (Qmouse_leave_buffer_hook
);
1234 /* `switch-frame' implies a focus in. */
1235 call1 (intern ("handle-focus-in"), event
);
1236 return do_switch_frame (event
, 0, 0, Qnil
);
1239 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1240 doc
: /* Return the frame that is now selected. */)
1243 return selected_frame
;
1246 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1248 doc
: /* Return a list of all live frames. */)
1252 frames
= Fcopy_sequence (Vframe_list
);
1253 #ifdef HAVE_WINDOW_SYSTEM
1254 if (FRAMEP (tip_frame
))
1255 frames
= Fdelq (tip_frame
, frames
);
1260 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
1261 same tty (for tty frames) or among frames which uses FRAME's keyboard.
1262 If MINIBUF is nil, do not consider minibuffer-only candidate.
1263 If MINIBUF is `visible', do not consider an invisible candidate.
1264 If MINIBUF is a window, consider only its own frame and candidate now
1265 using that window as the minibuffer.
1266 If MINIBUF is 0, consider candidate if it is visible or iconified.
1267 Otherwise consider any candidate and return nil if CANDIDATE is not
1271 candidate_frame (Lisp_Object candidate
, Lisp_Object frame
, Lisp_Object minibuf
)
1273 struct frame
*c
= XFRAME (candidate
), *f
= XFRAME (frame
);
1275 if ((!FRAME_TERMCAP_P (c
) && !FRAME_TERMCAP_P (f
)
1276 && FRAME_KBOARD (c
) == FRAME_KBOARD (f
))
1277 || (FRAME_TERMCAP_P (c
) && FRAME_TERMCAP_P (f
)
1278 && FRAME_TTY (c
) == FRAME_TTY (f
)))
1282 if (!FRAME_MINIBUF_ONLY_P (c
))
1285 else if (EQ (minibuf
, Qvisible
))
1287 if (FRAME_VISIBLE_P (c
))
1290 else if (WINDOWP (minibuf
))
1292 if (EQ (FRAME_MINIBUF_WINDOW (c
), minibuf
)
1293 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), candidate
)
1294 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1295 FRAME_FOCUS_FRAME (c
)))
1298 else if (XFASTINT (minibuf
) == 0)
1300 if (FRAME_VISIBLE_P (c
) || FRAME_ICONIFIED_P (c
))
1309 /* Return the next frame in the frame list after FRAME. */
1312 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1314 Lisp_Object f
, tail
;
1317 /* There must always be at least one frame in Vframe_list. */
1318 eassert (CONSP (Vframe_list
));
1321 FOR_EACH_FRAME (tail
, f
)
1325 f
= candidate_frame (f
, frame
, minibuf
);
1335 /* Return the previous frame in the frame list before FRAME. */
1338 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1340 Lisp_Object f
, tail
, prev
= Qnil
;
1342 /* There must always be at least one frame in Vframe_list. */
1343 eassert (CONSP (Vframe_list
));
1345 FOR_EACH_FRAME (tail
, f
)
1347 if (EQ (frame
, f
) && !NILP (prev
))
1349 f
= candidate_frame (f
, frame
, minibuf
);
1354 /* We've scanned the entire list. */
1356 /* We went through the whole frame list without finding a single
1357 acceptable frame. Return the original frame. */
1360 /* There were no acceptable frames in the list before FRAME; otherwise,
1361 we would have returned directly from the loop. Since PREV is the last
1362 acceptable frame in the list, return it. */
1367 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1368 doc
: /* Return the next frame in the frame list after FRAME.
1369 It considers only frames on the same terminal as FRAME.
1370 By default, skip minibuffer-only frames.
1371 If omitted, FRAME defaults to the selected frame.
1372 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1373 If MINIFRAME is a window, include only its own frame
1374 and any frame now using that window as the minibuffer.
1375 If MINIFRAME is `visible', include all visible frames.
1376 If MINIFRAME is 0, include all visible and iconified frames.
1377 Otherwise, include all frames. */)
1378 (Lisp_Object frame
, Lisp_Object miniframe
)
1381 frame
= selected_frame
;
1382 CHECK_LIVE_FRAME (frame
);
1383 return next_frame (frame
, miniframe
);
1386 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1387 doc
: /* Return the previous frame in the frame list before FRAME.
1388 It considers only frames on the same terminal as FRAME.
1389 By default, skip minibuffer-only frames.
1390 If omitted, FRAME defaults to the selected frame.
1391 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1392 If MINIFRAME is a window, include only its own frame
1393 and any frame now using that window as the minibuffer.
1394 If MINIFRAME is `visible', include all visible frames.
1395 If MINIFRAME is 0, include all visible and iconified frames.
1396 Otherwise, include all frames. */)
1397 (Lisp_Object frame
, Lisp_Object miniframe
)
1400 frame
= selected_frame
;
1401 CHECK_LIVE_FRAME (frame
);
1402 return prev_frame (frame
, miniframe
);
1405 DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame
,
1406 Slast_nonminibuf_frame
, 0, 0, 0,
1407 doc
: /* Return last non-minibuffer frame selected. */)
1410 Lisp_Object frame
= Qnil
;
1412 if (last_nonminibuf_frame
)
1413 XSETFRAME (frame
, last_nonminibuf_frame
);
1418 /* Return 1 if it is ok to delete frame F;
1419 0 if all frames aside from F are invisible.
1420 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1423 other_visible_frames (struct frame
*f
)
1425 Lisp_Object frames
, this;
1427 FOR_EACH_FRAME (frames
, this)
1429 if (f
== XFRAME (this))
1432 /* Verify that we can still talk to the frame's X window,
1433 and note any recent change in visibility. */
1434 #ifdef HAVE_X_WINDOWS
1435 if (FRAME_WINDOW_P (XFRAME (this)))
1436 x_sync (XFRAME (this));
1439 if (FRAME_VISIBLE_P (XFRAME (this))
1440 || FRAME_ICONIFIED_P (XFRAME (this))
1441 /* Allow deleting the terminal frame when at least one X
1443 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1449 /* Make sure that minibuf_window doesn't refer to FRAME's minibuffer
1450 window. Preferably use the selected frame's minibuffer window
1451 instead. If the selected frame doesn't have one, get some other
1452 frame's minibuffer window. SELECT non-zero means select the new
1453 minibuffer window. */
1455 check_minibuf_window (Lisp_Object frame
, int select
)
1457 struct frame
*f
= decode_live_frame (frame
);
1459 XSETFRAME (frame
, f
);
1461 if (WINDOWP (minibuf_window
) && EQ (f
->minibuffer_window
, minibuf_window
))
1463 Lisp_Object frames
, this, window
= make_number (0);
1465 if (!EQ (frame
, selected_frame
)
1466 && FRAME_HAS_MINIBUF_P (XFRAME (selected_frame
)))
1467 window
= FRAME_MINIBUF_WINDOW (XFRAME (selected_frame
));
1469 FOR_EACH_FRAME (frames
, this)
1471 if (!EQ (this, frame
) && FRAME_HAS_MINIBUF_P (XFRAME (this)))
1473 window
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1478 /* Don't abort if no window was found (Bug#15247). */
1479 if (WINDOWP (window
))
1481 /* Use set_window_buffer instead of Fset_window_buffer (see
1482 discussion of bug#11984, bug#12025, bug#12026). */
1483 set_window_buffer (window
, XWINDOW (minibuf_window
)->contents
, 0, 0);
1484 minibuf_window
= window
;
1486 /* SELECT non-zero usually means that FRAME's minibuffer
1487 window was selected; select the new one. */
1489 Fselect_window (minibuf_window
, Qnil
);
1495 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1496 unconditionally. x_connection_closed and delete_terminal use
1497 this. Any other value of FORCE implements the semantics
1498 described for Fdelete_frame. */
1500 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1502 struct frame
*f
= decode_any_frame (frame
);
1506 int minibuffer_selected
, is_tooltip_frame
;
1508 if (! FRAME_LIVE_P (f
))
1511 if (NILP (force
) && !other_visible_frames (f
))
1512 error ("Attempt to delete the sole visible or iconified frame");
1514 /* x_connection_closed must have set FORCE to `noelisp' in order
1515 to delete the last frame, if it is gone. */
1516 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1517 error ("Attempt to delete the only frame");
1519 XSETFRAME (frame
, f
);
1521 /* Does this frame have a minibuffer, and is it the surrogate
1522 minibuffer for any other frame? */
1523 if (FRAME_HAS_MINIBUF_P (f
))
1525 Lisp_Object frames
, this;
1527 FOR_EACH_FRAME (frames
, this)
1531 if (EQ (this, frame
))
1534 fminiw
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1536 if (WINDOWP (fminiw
) && EQ (frame
, WINDOW_FRAME (XWINDOW (fminiw
))))
1538 /* If we MUST delete this frame, delete the other first.
1539 But do this only if FORCE equals `noelisp'. */
1540 if (EQ (force
, Qnoelisp
))
1541 delete_frame (this, Qnoelisp
);
1543 error ("Attempt to delete a surrogate minibuffer frame");
1548 is_tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1550 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1551 frame is a tooltip. FORCE is set to `noelisp' when handling
1552 a disconnect from the terminal, so we don't dare call Lisp
1554 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1556 else if (EQ (force
, Qnoelisp
))
1558 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1562 #ifdef HAVE_X_WINDOWS
1563 /* Also, save clipboard to the clipboard manager. */
1564 x_clipboard_manager_save_frame (frame
);
1567 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1570 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1571 if (! FRAME_LIVE_P (f
))
1574 /* At this point, we are committed to deleting the frame.
1575 There is no more chance for errors to prevent it. */
1577 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1578 sf
= SELECTED_FRAME ();
1579 /* Don't let the frame remain selected. */
1583 Lisp_Object frame1
= Qnil
;
1585 /* Look for another visible frame on the same terminal.
1586 Do not call next_frame here because it may loop forever.
1587 See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15025. */
1588 FOR_EACH_FRAME (tail
, frame1
)
1589 if (!EQ (frame
, frame1
)
1590 && (FRAME_TERMINAL (XFRAME (frame
))
1591 == FRAME_TERMINAL (XFRAME (frame1
)))
1592 && FRAME_VISIBLE_P (XFRAME (frame1
)))
1595 /* If there is none, find *some* other frame. */
1596 if (NILP (frame1
) || EQ (frame1
, frame
))
1598 FOR_EACH_FRAME (tail
, frame1
)
1600 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1602 /* Do not change a text terminal's top-frame. */
1603 struct frame
*f1
= XFRAME (frame1
);
1604 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1606 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1607 if (!EQ (top_frame
, frame
))
1614 #ifdef NS_IMPL_COCOA
1616 /* Under NS, there is no system mechanism for choosing a new
1617 window to get focus -- it is left to application code.
1618 So the portion of THIS application interfacing with NS
1619 needs to know about it. We call Fraise_frame, but the
1620 purpose is really to transfer focus. */
1621 Fraise_frame (frame1
);
1624 do_switch_frame (frame1
, 0, 1, Qnil
);
1625 sf
= SELECTED_FRAME ();
1628 /* Don't allow minibuf_window to remain on a deleted frame. */
1629 check_minibuf_window (frame
, minibuffer_selected
);
1631 /* Don't let echo_area_window to remain on a deleted frame. */
1632 if (EQ (f
->minibuffer_window
, echo_area_window
))
1633 echo_area_window
= sf
->minibuffer_window
;
1635 /* Clear any X selections for this frame. */
1636 #ifdef HAVE_X_WINDOWS
1638 x_clear_frame_selections (f
);
1642 This function must be called before the window tree of the
1643 frame is deleted because windows contain dynamically allocated
1647 #ifdef HAVE_WINDOW_SYSTEM
1648 /* Give chance to each font driver to free a frame specific data. */
1649 font_update_drivers (f
, Qnil
);
1652 /* Mark all the windows that used to be on FRAME as deleted, and then
1653 remove the reference to them. */
1654 delete_all_child_windows (f
->root_window
);
1655 fset_root_window (f
, Qnil
);
1657 Vframe_list
= Fdelq (frame
, Vframe_list
);
1658 SET_FRAME_VISIBLE (f
, 0);
1660 /* Allow the vector of menu bar contents to be freed in the next
1661 garbage collection. The frame object itself may not be garbage
1662 collected until much later, because recent_keys and other data
1663 structures can still refer to it. */
1664 fset_menu_bar_vector (f
, Qnil
);
1666 /* If FRAME's buffer lists contains killed
1667 buffers, this helps GC to reclaim them. */
1668 fset_buffer_list (f
, Qnil
);
1669 fset_buried_buffer_list (f
, Qnil
);
1671 free_font_driver_list (f
);
1672 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1675 xfree (f
->decode_mode_spec_buffer
);
1676 xfree (FRAME_INSERT_COST (f
));
1677 xfree (FRAME_DELETEN_COST (f
));
1678 xfree (FRAME_INSERTN_COST (f
));
1679 xfree (FRAME_DELETE_COST (f
));
1681 /* Since some events are handled at the interrupt level, we may get
1682 an event for f at any time; if we zero out the frame's terminal
1683 now, then we may trip up the event-handling code. Instead, we'll
1684 promise that the terminal of the frame must be valid until we
1685 have called the window-system-dependent frame destruction
1690 struct terminal
*terminal
;
1692 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1693 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1694 terminal
= FRAME_TERMINAL (f
);
1695 f
->output_data
.nothing
= 0;
1696 f
->terminal
= 0; /* Now the frame is dead. */
1699 /* If needed, delete the terminal that this frame was on.
1700 (This must be done after the frame is killed.) */
1701 terminal
->reference_count
--;
1703 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1705 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1706 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1707 terminal
->reference_count
= 1;
1708 #endif /* USE_GTK */
1709 if (terminal
->reference_count
== 0)
1712 XSETTERMINAL (tmp
, terminal
);
1715 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1718 kb
= terminal
->kboard
;
1721 /* If we've deleted the last_nonminibuf_frame, then try to find
1723 if (f
== last_nonminibuf_frame
)
1725 Lisp_Object frames
, this;
1727 last_nonminibuf_frame
= 0;
1729 FOR_EACH_FRAME (frames
, this)
1732 if (!FRAME_MINIBUF_ONLY_P (f
))
1734 last_nonminibuf_frame
= f
;
1740 /* If there's no other frame on the same kboard, get out of
1741 single-kboard state if we're in it for this kboard. */
1744 Lisp_Object frames
, this;
1745 /* Some frame we found on the same kboard, or nil if there are none. */
1746 Lisp_Object frame_on_same_kboard
= Qnil
;
1748 FOR_EACH_FRAME (frames
, this)
1749 if (kb
== FRAME_KBOARD (XFRAME (this)))
1750 frame_on_same_kboard
= this;
1752 if (NILP (frame_on_same_kboard
))
1753 not_single_kboard_state (kb
);
1757 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1758 find another one. Prefer minibuffer-only frames, but also notice
1759 frames with other windows. */
1760 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1762 Lisp_Object frames
, this;
1764 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1765 Lisp_Object frame_with_minibuf
= Qnil
;
1766 /* Some frame we found on the same kboard, or nil if there are none. */
1767 Lisp_Object frame_on_same_kboard
= Qnil
;
1769 FOR_EACH_FRAME (frames
, this)
1771 struct frame
*f1
= XFRAME (this);
1773 /* Consider only frames on the same kboard
1774 and only those with minibuffers. */
1775 if (kb
== FRAME_KBOARD (f1
)
1776 && FRAME_HAS_MINIBUF_P (f1
))
1778 frame_with_minibuf
= this;
1779 if (FRAME_MINIBUF_ONLY_P (f1
))
1783 if (kb
== FRAME_KBOARD (f1
))
1784 frame_on_same_kboard
= this;
1787 if (!NILP (frame_on_same_kboard
))
1789 /* We know that there must be some frame with a minibuffer out
1790 there. If this were not true, all of the frames present
1791 would have to be minibufferless, which implies that at some
1792 point their minibuffer frames must have been deleted, but
1793 that is prohibited at the top; you can't delete surrogate
1794 minibuffer frames. */
1795 if (NILP (frame_with_minibuf
))
1798 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
1801 /* No frames left on this kboard--say no minibuffer either. */
1802 kset_default_minibuffer_frame (kb
, Qnil
);
1805 /* Cause frame titles to update--necessary if we now have just one frame. */
1806 if (!is_tooltip_frame
)
1807 update_mode_lines
= 15;
1812 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1813 doc
: /* Delete FRAME, permanently eliminating it from use.
1814 FRAME defaults to the selected frame.
1816 A frame may not be deleted if its minibuffer is used by other frames.
1817 Normally, you may not delete a frame if all other frames are invisible,
1818 but if the second optional argument FORCE is non-nil, you may do so.
1820 This function runs `delete-frame-functions' before actually
1821 deleting the frame, unless the frame is a tooltip.
1822 The functions are run with one argument, the frame to be deleted. */)
1823 (Lisp_Object frame
, Lisp_Object force
)
1825 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1829 /* Return mouse position in character cell units. */
1831 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1832 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1833 The position is given in canonical character cells, where (0, 0) is the
1834 upper-left corner of the frame, X is the horizontal offset, and Y is the
1835 vertical offset, measured in units of the frame's default character size.
1836 If Emacs is running on a mouseless terminal or hasn't been programmed
1837 to read the mouse position, it returns the selected frame for FRAME
1838 and nil for X and Y.
1839 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1840 passing the normal return value to that function as an argument,
1841 and returns whatever that function returns. */)
1845 Lisp_Object lispy_dummy
;
1846 Lisp_Object x
, y
, retval
;
1847 struct gcpro gcpro1
;
1849 f
= SELECTED_FRAME ();
1852 /* It's okay for the hook to refrain from storing anything. */
1853 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1855 enum scroll_bar_part party_dummy
;
1857 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1858 &lispy_dummy
, &party_dummy
,
1867 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1871 XSETFRAME (lispy_dummy
, f
);
1872 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1874 if (!NILP (Vmouse_position_function
))
1875 retval
= call1 (Vmouse_position_function
, retval
);
1876 RETURN_UNGCPRO (retval
);
1879 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1880 Smouse_pixel_position
, 0, 0, 0,
1881 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1882 The position is given in pixel units, where (0, 0) is the
1883 upper-left corner of the frame, X is the horizontal offset, and Y is
1884 the vertical offset.
1885 If Emacs is running on a mouseless terminal or hasn't been programmed
1886 to read the mouse position, it returns the selected frame for FRAME
1887 and nil for X and Y. */)
1891 Lisp_Object lispy_dummy
;
1892 Lisp_Object x
, y
, retval
;
1893 struct gcpro gcpro1
;
1895 f
= SELECTED_FRAME ();
1898 /* It's okay for the hook to refrain from storing anything. */
1899 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1901 enum scroll_bar_part party_dummy
;
1903 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1904 &lispy_dummy
, &party_dummy
,
1909 XSETFRAME (lispy_dummy
, f
);
1910 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1912 if (!NILP (Vmouse_position_function
))
1913 retval
= call1 (Vmouse_position_function
, retval
);
1914 RETURN_UNGCPRO (retval
);
1917 #ifdef HAVE_WINDOW_SYSTEM
1919 /* On frame F, convert character coordinates X and Y to pixel
1920 coordinates *PIX_X and *PIX_Y. */
1923 frame_char_to_pixel_position (struct frame
*f
, int x
, int y
,
1924 int *pix_x
, int *pix_y
)
1926 *pix_x
= FRAME_COL_TO_PIXEL_X (f
, x
) + FRAME_COLUMN_WIDTH (f
) / 2;
1927 *pix_y
= FRAME_LINE_TO_PIXEL_Y (f
, y
) + FRAME_LINE_HEIGHT (f
) / 2;
1931 if (*pix_x
> FRAME_PIXEL_WIDTH (f
))
1932 *pix_x
= FRAME_PIXEL_WIDTH (f
);
1936 if (*pix_y
> FRAME_PIXEL_HEIGHT (f
))
1937 *pix_y
= FRAME_PIXEL_HEIGHT (f
);
1940 /* On frame F, reposition mouse pointer to character coordinates X and Y. */
1943 frame_set_mouse_position (struct frame
*f
, int x
, int y
)
1947 frame_char_to_pixel_position (f
, x
, y
, &pix_x
, &pix_y
);
1948 frame_set_mouse_pixel_position (f
, pix_x
, pix_y
);
1951 #endif /* HAVE_WINDOW_SYSTEM */
1953 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1954 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1955 Coordinates are relative to the frame, not a window,
1956 so the coordinates of the top left character in the frame
1957 may be nonzero due to left-hand scroll bars or the menu bar.
1959 The position is given in canonical character cells, where (0, 0) is
1960 the upper-left corner of the frame, X is the horizontal offset, and
1961 Y is the vertical offset, measured in units of the frame's default
1964 This function is a no-op for an X frame that is not visible.
1965 If you have just created a frame, you must wait for it to become visible
1966 before calling this function on it, like this.
1967 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1968 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1970 CHECK_LIVE_FRAME (frame
);
1971 CHECK_TYPE_RANGED_INTEGER (int, x
);
1972 CHECK_TYPE_RANGED_INTEGER (int, y
);
1974 /* I think this should be done with a hook. */
1975 #ifdef HAVE_WINDOW_SYSTEM
1976 if (FRAME_WINDOW_P (XFRAME (frame
)))
1977 /* Warping the mouse will cause enternotify and focus events. */
1978 frame_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1981 if (FRAME_MSDOS_P (XFRAME (frame
)))
1983 Fselect_frame (frame
, Qnil
);
1984 mouse_moveto (XINT (x
), XINT (y
));
1989 Fselect_frame (frame
, Qnil
);
1990 term_mouse_moveto (XINT (x
), XINT (y
));
1999 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
2000 Sset_mouse_pixel_position
, 3, 3, 0,
2001 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
2002 The position is given in pixels, where (0, 0) is the upper-left corner
2003 of the frame, X is the horizontal offset, and Y is the vertical offset.
2005 Note, this is a no-op for an X frame that is not visible.
2006 If you have just created a frame, you must wait for it to become visible
2007 before calling this function on it, like this.
2008 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
2009 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
2011 CHECK_LIVE_FRAME (frame
);
2012 CHECK_TYPE_RANGED_INTEGER (int, x
);
2013 CHECK_TYPE_RANGED_INTEGER (int, y
);
2015 /* I think this should be done with a hook. */
2016 #ifdef HAVE_WINDOW_SYSTEM
2017 if (FRAME_WINDOW_P (XFRAME (frame
)))
2018 /* Warping the mouse will cause enternotify and focus events. */
2019 frame_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
2022 if (FRAME_MSDOS_P (XFRAME (frame
)))
2024 Fselect_frame (frame
, Qnil
);
2025 mouse_moveto (XINT (x
), XINT (y
));
2030 Fselect_frame (frame
, Qnil
);
2031 term_mouse_moveto (XINT (x
), XINT (y
));
2040 static void make_frame_visible_1 (Lisp_Object
);
2042 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
2044 doc
: /* Make the frame FRAME visible (assuming it is an X window).
2045 If omitted, FRAME defaults to the currently selected frame. */)
2048 struct frame
*f
= decode_live_frame (frame
);
2050 /* I think this should be done with a hook. */
2051 #ifdef HAVE_WINDOW_SYSTEM
2052 if (FRAME_WINDOW_P (f
))
2053 x_make_frame_visible (f
);
2056 make_frame_visible_1 (f
->root_window
);
2058 /* Make menu bar update for the Buffers and Frames menus. */
2059 /* windows_or_buffers_changed = 15; FIXME: Why? */
2061 XSETFRAME (frame
, f
);
2065 /* Update the display_time slot of the buffers shown in WINDOW
2066 and all its descendants. */
2069 make_frame_visible_1 (Lisp_Object window
)
2073 for (; !NILP (window
); window
= w
->next
)
2075 w
= XWINDOW (window
);
2076 if (WINDOWP (w
->contents
))
2077 make_frame_visible_1 (w
->contents
);
2079 bset_display_time (XBUFFER (w
->contents
), Fcurrent_time ());
2083 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
2085 doc
: /* Make the frame FRAME invisible.
2086 If omitted, FRAME defaults to the currently selected frame.
2087 On graphical displays, invisible frames are not updated and are
2088 usually not displayed at all, even in a window system's \"taskbar\".
2090 Normally you may not make FRAME invisible if all other frames are invisible,
2091 but if the second optional argument FORCE is non-nil, you may do so.
2093 This function has no effect on text terminal frames. Such frames are
2094 always considered visible, whether or not they are currently being
2095 displayed in the terminal. */)
2096 (Lisp_Object frame
, Lisp_Object force
)
2098 struct frame
*f
= decode_live_frame (frame
);
2100 if (NILP (force
) && !other_visible_frames (f
))
2101 error ("Attempt to make invisible the sole visible or iconified frame");
2103 /* Don't allow minibuf_window to remain on an invisible frame. */
2104 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2106 /* I think this should be done with a hook. */
2107 #ifdef HAVE_WINDOW_SYSTEM
2108 if (FRAME_WINDOW_P (f
))
2109 x_make_frame_invisible (f
);
2112 /* Make menu bar update for the Buffers and Frames menus. */
2113 windows_or_buffers_changed
= 16;
2118 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
2120 doc
: /* Make the frame FRAME into an icon.
2121 If omitted, FRAME defaults to the currently selected frame. */)
2124 struct frame
*f
= decode_live_frame (frame
);
2126 /* Don't allow minibuf_window to remain on an iconified frame. */
2127 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2129 /* I think this should be done with a hook. */
2130 #ifdef HAVE_WINDOW_SYSTEM
2131 if (FRAME_WINDOW_P (f
))
2132 x_iconify_frame (f
);
2135 /* Make menu bar update for the Buffers and Frames menus. */
2136 windows_or_buffers_changed
= 17;
2141 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
2143 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
2144 Return the symbol `icon' if FRAME is iconified or \"minimized\".
2145 Return nil if FRAME was made invisible, via `make-frame-invisible'.
2146 On graphical displays, invisible frames are not updated and are
2147 usually not displayed at all, even in a window system's \"taskbar\".
2149 If FRAME is a text terminal frame, this always returns t.
2150 Such frames are always considered visible, whether or not they are
2151 currently being displayed on the terminal. */)
2154 CHECK_LIVE_FRAME (frame
);
2156 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2158 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
2163 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
2165 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
2168 Lisp_Object tail
, frame
, value
= Qnil
;
2170 FOR_EACH_FRAME (tail
, frame
)
2171 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2172 value
= Fcons (frame
, value
);
2178 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
2179 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
2180 If FRAME is invisible or iconified, make it visible.
2181 If you don't specify a frame, the selected frame is used.
2182 If Emacs is displaying on an ordinary terminal or some other device which
2183 doesn't support multiple overlapping frames, this function selects FRAME. */)
2186 struct frame
*f
= decode_live_frame (frame
);
2188 XSETFRAME (frame
, f
);
2190 if (FRAME_TERMCAP_P (f
))
2191 /* On a text terminal select FRAME. */
2192 Fselect_frame (frame
, Qnil
);
2194 /* Do like the documentation says. */
2195 Fmake_frame_visible (frame
);
2197 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2198 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
2203 /* Should we have a corresponding function called Flower_Power? */
2204 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
2205 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2206 If you don't specify a frame, the selected frame is used.
2207 If Emacs is displaying on an ordinary terminal or some other device which
2208 doesn't support multiple overlapping frames, this function does nothing. */)
2211 struct frame
*f
= decode_live_frame (frame
);
2213 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2214 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2220 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2222 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2223 In other words, switch-frame events caused by events in FRAME will
2224 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2225 FOCUS-FRAME after reading an event typed at FRAME.
2227 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
2228 frame again receives its own keystrokes.
2230 Focus redirection is useful for temporarily redirecting keystrokes to
2231 a surrogate minibuffer frame when a frame doesn't have its own
2234 A frame's focus redirection can be changed by `select-frame'. If frame
2235 FOO is selected, and then a different frame BAR is selected, any
2236 frames redirecting their focus to FOO are shifted to redirect their
2237 focus to BAR. This allows focus redirection to work properly when the
2238 user switches from one frame to another using `select-window'.
2240 This means that a frame whose focus is redirected to itself is treated
2241 differently from a frame whose focus is redirected to nil; the former
2242 is affected by `select-frame', while the latter is not.
2244 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2245 (Lisp_Object frame
, Lisp_Object focus_frame
)
2247 /* Note that we don't check for a live frame here. It's reasonable
2248 to redirect the focus of a frame you're about to delete, if you
2249 know what other frame should receive those keystrokes. */
2250 struct frame
*f
= decode_any_frame (frame
);
2252 if (! NILP (focus_frame
))
2253 CHECK_LIVE_FRAME (focus_frame
);
2255 fset_focus_frame (f
, focus_frame
);
2257 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2258 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2264 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 0, 1, 0,
2265 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2266 If FRAME is omitted or nil, the selected frame is used.
2267 Return nil if FRAME's focus is not redirected.
2268 See `redirect-frame-focus'. */)
2271 return FRAME_FOCUS_FRAME (decode_live_frame (frame
));
2274 DEFUN ("x-focus-frame", Fx_focus_frame
, Sx_focus_frame
, 1, 1, 0,
2275 doc
: /* Set the input focus to FRAME.
2276 FRAME nil means use the selected frame.
2277 If there is no window system support, this function does nothing. */)
2280 #ifdef HAVE_WINDOW_SYSTEM
2281 x_focus_frame (decode_window_system_frame (frame
));
2286 DEFUN ("frame-after-make-frame",
2287 Fframe_after_make_frame
,
2288 Sframe_after_make_frame
, 2, 2, 0,
2289 doc
: /* Mark FRAME as made.
2290 FRAME nil means use the selected frame. Second argument MADE non-nil
2291 means functions on `window-configuration-change-hook' are called
2292 whenever the window configuration of FRAME changes. MADE nil means
2293 these functions are not called.
2295 This function is currently called by `make-frame' only and should be
2296 otherwise used with utter care to avoid that running functions on
2297 `window-configuration-change-hook' is impeded forever. */)
2298 (Lisp_Object frame
, Lisp_Object made
)
2300 struct frame
*f
= decode_live_frame (frame
);
2302 f
->after_make_frame
= NILP (made
) ? false : true;
2308 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2311 frames_discard_buffer (Lisp_Object buffer
)
2313 Lisp_Object frame
, tail
;
2315 FOR_EACH_FRAME (tail
, frame
)
2318 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
2319 fset_buried_buffer_list
2320 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
2324 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2325 If the alist already has an element for PROP, we change it. */
2328 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2330 register Lisp_Object tem
;
2332 tem
= Fassq (prop
, *alistptr
);
2334 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2340 frame_name_fnn_p (char *str
, ptrdiff_t len
)
2342 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
2345 while ('0' <= *p
&& *p
<= '9')
2353 /* Set the name of the terminal frame. Also used by MSDOS frames.
2354 Modeled after x_set_name which is used for WINDOW frames. */
2357 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2359 f
->explicit_name
= ! NILP (name
);
2361 /* If NAME is nil, set the name to F<num>. */
2364 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
2366 /* Check for no change needed in this very common case
2367 before we do any consing. */
2368 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
2371 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
2375 CHECK_STRING (name
);
2377 /* Don't change the name if it's already NAME. */
2378 if (! NILP (Fstring_equal (name
, f
->name
)))
2381 /* Don't allow the user to set the frame name to F<num>, so it
2382 doesn't clash with the names we generate for terminal frames. */
2383 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2384 error ("Frame names of the form F<num> are usurped by Emacs");
2387 fset_name (f
, name
);
2388 update_mode_lines
= 16;
2392 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2394 register Lisp_Object old_alist_elt
;
2396 /* The buffer-list parameters are stored in a special place and not
2397 in the alist. All buffers must be live. */
2398 if (EQ (prop
, Qbuffer_list
))
2400 Lisp_Object list
= Qnil
;
2401 for (; CONSP (val
); val
= XCDR (val
))
2402 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2403 list
= Fcons (XCAR (val
), list
);
2404 fset_buffer_list (f
, Fnreverse (list
));
2407 if (EQ (prop
, Qburied_buffer_list
))
2409 Lisp_Object list
= Qnil
;
2410 for (; CONSP (val
); val
= XCDR (val
))
2411 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2412 list
= Fcons (XCAR (val
), list
);
2413 fset_buried_buffer_list (f
, Fnreverse (list
));
2417 /* If PROP is a symbol which is supposed to have frame-local values,
2418 and it is set up based on this frame, switch to the global
2419 binding. That way, we can create or alter the frame-local binding
2420 without messing up the symbol's status. */
2423 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2425 switch (sym
->redirect
)
2427 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2428 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2429 case SYMBOL_LOCALIZED
:
2430 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2431 if (blv
->frame_local
&& blv_found (blv
) && XFRAME (blv
->where
) == f
)
2432 swap_in_global_binding (sym
);
2435 default: emacs_abort ();
2439 /* The tty color needed to be set before the frame's parameter
2440 alist was updated with the new value. This is not true any more,
2441 but we still do this test early on. */
2442 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2443 && f
== FRAME_TTY (f
)->previous_frame
)
2444 /* Force redisplay of this tty. */
2445 FRAME_TTY (f
)->previous_frame
= NULL
;
2447 /* Update the frame parameter alist. */
2448 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2449 if (EQ (old_alist_elt
, Qnil
))
2450 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2452 Fsetcdr (old_alist_elt
, val
);
2454 /* Update some other special parameters in their special places
2455 in addition to the alist. */
2457 if (EQ (prop
, Qbuffer_predicate
))
2458 fset_buffer_predicate (f
, val
);
2460 if (! FRAME_WINDOW_P (f
))
2462 if (EQ (prop
, Qmenu_bar_lines
))
2463 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2464 else if (EQ (prop
, Qname
))
2465 set_term_frame_name (f
, val
);
2468 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2470 if (! MINI_WINDOW_P (XWINDOW (val
)))
2471 error ("Surrogate minibuffer windows must be minibuffer windows");
2473 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2474 && !EQ (val
, f
->minibuffer_window
))
2475 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2477 /* Install the chosen minibuffer window, with proper buffer. */
2478 fset_minibuffer_window (f
, val
);
2482 /* Return color matches UNSPEC on frame F or nil if UNSPEC
2483 is not an unspecified foreground or background color. */
2486 frame_unspecified_color (struct frame
*f
, Lisp_Object unspec
)
2488 return (!strncmp (SSDATA (unspec
), unspecified_bg
, SBYTES (unspec
))
2489 ? tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
))
2490 : (!strncmp (SSDATA (unspec
), unspecified_fg
, SBYTES (unspec
))
2491 ? tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)) : Qnil
));
2494 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2495 doc
: /* Return the parameters-alist of frame FRAME.
2496 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2497 The meaningful PARMs depend on the kind of frame.
2498 If FRAME is omitted or nil, return information on the currently selected frame. */)
2502 struct frame
*f
= decode_any_frame (frame
);
2504 struct gcpro gcpro1
;
2506 if (!FRAME_LIVE_P (f
))
2509 alist
= Fcopy_alist (f
->param_alist
);
2512 if (!FRAME_WINDOW_P (f
))
2516 /* If the frame's parameter alist says the colors are
2517 unspecified and reversed, take the frame's background pixel
2518 for foreground and vice versa. */
2519 elt
= Fassq (Qforeground_color
, alist
);
2520 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2522 elt
= frame_unspecified_color (f
, XCDR (elt
));
2524 store_in_alist (&alist
, Qforeground_color
, elt
);
2527 store_in_alist (&alist
, Qforeground_color
,
2528 tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)));
2529 elt
= Fassq (Qbackground_color
, alist
);
2530 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2532 elt
= frame_unspecified_color (f
, XCDR (elt
));
2534 store_in_alist (&alist
, Qbackground_color
, elt
);
2537 store_in_alist (&alist
, Qbackground_color
,
2538 tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
)));
2539 store_in_alist (&alist
, intern ("font"),
2540 build_string (FRAME_MSDOS_P (f
)
2542 : FRAME_W32_P (f
) ? "w32term"
2545 store_in_alist (&alist
, Qname
, f
->name
);
2546 height
= (f
->new_height
2548 ? (f
->new_height
/ FRAME_LINE_HEIGHT (f
))
2551 store_in_alist (&alist
, Qheight
, make_number (height
));
2552 width
= (f
->new_width
2554 ? (f
->new_width
/ FRAME_COLUMN_WIDTH (f
))
2557 store_in_alist (&alist
, Qwidth
, make_number (width
));
2558 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2559 store_in_alist (&alist
, Qminibuffer
,
2560 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2561 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2562 : FRAME_MINIBUF_WINDOW (f
)));
2563 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2564 store_in_alist (&alist
, Qbuffer_list
, f
->buffer_list
);
2565 store_in_alist (&alist
, Qburied_buffer_list
, f
->buried_buffer_list
);
2567 /* I think this should be done with a hook. */
2568 #ifdef HAVE_WINDOW_SYSTEM
2569 if (FRAME_WINDOW_P (f
))
2570 x_report_frame_params (f
, &alist
);
2574 /* This ought to be correct in f->param_alist for an X frame. */
2576 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2577 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2585 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2586 doc
: /* Return FRAME's value for parameter PARAMETER.
2587 If FRAME is nil, describe the currently selected frame. */)
2588 (Lisp_Object frame
, Lisp_Object parameter
)
2590 struct frame
*f
= decode_any_frame (frame
);
2591 Lisp_Object value
= Qnil
;
2593 CHECK_SYMBOL (parameter
);
2595 XSETFRAME (frame
, f
);
2597 if (FRAME_LIVE_P (f
))
2599 /* Avoid consing in frequent cases. */
2600 if (EQ (parameter
, Qname
))
2602 #ifdef HAVE_X_WINDOWS
2603 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2604 value
= XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
);
2605 #endif /* HAVE_X_WINDOWS */
2606 else if (EQ (parameter
, Qbackground_color
)
2607 || EQ (parameter
, Qforeground_color
))
2609 value
= Fassq (parameter
, f
->param_alist
);
2612 value
= XCDR (value
);
2613 /* Fframe_parameters puts the actual fg/bg color names,
2614 even if f->param_alist says otherwise. This is
2615 important when param_alist's notion of colors is
2616 "unspecified". We need to do the same here. */
2617 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2619 Lisp_Object tem
= frame_unspecified_color (f
, value
);
2626 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2628 else if (EQ (parameter
, Qdisplay_type
)
2629 || EQ (parameter
, Qbackground_mode
))
2630 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2632 /* FIXME: Avoid this code path at all (as well as code duplication)
2633 by sharing more code with Fframe_parameters. */
2634 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2641 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2642 Smodify_frame_parameters
, 2, 2, 0,
2643 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2644 If FRAME is nil, it defaults to the selected frame.
2645 ALIST is an alist of parameters to change and their new values.
2646 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2647 The meaningful PARMs depend on the kind of frame.
2648 Undefined PARMs are ignored, but stored in the frame's parameter list
2649 so that `frame-parameters' will return them.
2651 The value of frame parameter FOO can also be accessed
2652 as a frame-local binding for the variable FOO, if you have
2653 enabled such bindings for that variable with `make-variable-frame-local'.
2654 Note that this functionality is obsolete as of Emacs 22.2, and its
2655 use is not recommended. Explicitly check for a frame-parameter instead. */)
2656 (Lisp_Object frame
, Lisp_Object alist
)
2658 struct frame
*f
= decode_live_frame (frame
);
2659 register Lisp_Object prop
, val
;
2663 /* I think this should be done with a hook. */
2664 #ifdef HAVE_WINDOW_SYSTEM
2665 if (FRAME_WINDOW_P (f
))
2666 x_set_frame_parameters (f
, alist
);
2670 if (FRAME_MSDOS_P (f
))
2671 IT_set_frame_parameters (f
, alist
);
2676 EMACS_INT length
= XFASTINT (Flength (alist
));
2679 Lisp_Object
*values
;
2681 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2682 values
= parms
+ length
;
2684 /* Extract parm names and values into those vectors. */
2686 for (i
= 0; CONSP (alist
); alist
= XCDR (alist
))
2691 parms
[i
] = Fcar (elt
);
2692 values
[i
] = Fcdr (elt
);
2696 /* Now process them in reverse of specified order. */
2701 store_frame_param (f
, prop
, val
);
2703 if (EQ (prop
, Qforeground_color
)
2704 || EQ (prop
, Qbackground_color
))
2705 update_face_from_frame_parameter (f
, prop
, val
);
2713 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2715 doc
: /* Height in pixels of a line in the font in frame FRAME.
2716 If FRAME is omitted or nil, the selected frame is used.
2717 For a terminal frame, the value is always 1. */)
2720 #ifdef HAVE_WINDOW_SYSTEM
2721 struct frame
*f
= decode_any_frame (frame
);
2723 if (FRAME_WINDOW_P (f
))
2724 return make_number (FRAME_LINE_HEIGHT (f
));
2727 return make_number (1);
2731 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2733 doc
: /* Width in pixels of characters in the font in frame FRAME.
2734 If FRAME is omitted or nil, the selected frame is used.
2735 On a graphical screen, the width is the standard width of the default font.
2736 For a terminal screen, the value is always 1. */)
2739 #ifdef HAVE_WINDOW_SYSTEM
2740 struct frame
*f
= decode_any_frame (frame
);
2742 if (FRAME_WINDOW_P (f
))
2743 return make_number (FRAME_COLUMN_WIDTH (f
));
2746 return make_number (1);
2749 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2750 Sframe_pixel_height
, 0, 1, 0,
2751 doc
: /* Return a FRAME's height in pixels.
2752 If FRAME is omitted or nil, the selected frame is used. The exact value
2753 of the result depends on the window-system and toolkit in use:
2755 In the Gtk+ version of Emacs, it includes only any window (including
2756 the minibuffer or echo area), mode line, and header line. It does not
2757 include the tool bar or menu bar.
2759 With other graphical versions, it also includes the tool bar and the
2762 For a text terminal, it includes the menu bar. In this case, the
2763 result is really in characters rather than pixels (i.e., is identical
2764 to `frame-height'). */)
2767 struct frame
*f
= decode_any_frame (frame
);
2769 #ifdef HAVE_WINDOW_SYSTEM
2770 if (FRAME_WINDOW_P (f
))
2771 return make_number (FRAME_PIXEL_HEIGHT (f
));
2774 return make_number (FRAME_TOTAL_LINES (f
));
2777 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2778 Sframe_pixel_width
, 0, 1, 0,
2779 doc
: /* Return FRAME's width in pixels.
2780 For a terminal frame, the result really gives the width in characters.
2781 If FRAME is omitted or nil, the selected frame is used. */)
2784 struct frame
*f
= decode_any_frame (frame
);
2786 #ifdef HAVE_WINDOW_SYSTEM
2787 if (FRAME_WINDOW_P (f
))
2788 return make_number (FRAME_PIXEL_WIDTH (f
));
2791 return make_number (FRAME_TOTAL_COLS (f
));
2794 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2795 Stool_bar_pixel_width
, 0, 1, 0,
2796 doc
: /* Return width in pixels of FRAME's tool bar.
2797 The result is greater than zero only when the tool bar is on the left
2798 or right side of FRAME. If FRAME is omitted or nil, the selected frame
2802 #ifdef FRAME_TOOLBAR_WIDTH
2803 struct frame
*f
= decode_any_frame (frame
);
2805 if (FRAME_WINDOW_P (f
))
2806 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2808 return make_number (0);
2811 DEFUN ("frame-text-cols", Fframe_text_cols
, Sframe_text_cols
, 0, 1, 0,
2812 doc
: /* Return width in columns of FRAME's text area. */)
2815 return make_number (FRAME_COLS (decode_any_frame (frame
)));
2818 DEFUN ("frame-text-lines", Fframe_text_lines
, Sframe_text_lines
, 0, 1, 0,
2819 doc
: /* Return height in lines of FRAME's text area. */)
2822 return make_number (FRAME_LINES (decode_any_frame (frame
)));
2825 DEFUN ("frame-total-cols", Fframe_total_cols
, Sframe_total_cols
, 0, 1, 0,
2826 doc
: /* Return number of total columns of FRAME. */)
2829 return make_number (FRAME_TOTAL_COLS (decode_any_frame (frame
)));
2832 DEFUN ("frame-total-lines", Fframe_total_lines
, Sframe_total_lines
, 0, 1, 0,
2833 doc
: /* Return number of total lines of FRAME. */)
2836 return make_number (FRAME_TOTAL_LINES (decode_any_frame (frame
)));
2839 DEFUN ("frame-text-width", Fframe_text_width
, Sframe_text_width
, 0, 1, 0,
2840 doc
: /* Return text area width of FRAME in pixels. */)
2843 return make_number (FRAME_TEXT_WIDTH (decode_any_frame (frame
)));
2846 DEFUN ("frame-text-height", Fframe_text_height
, Sframe_text_height
, 0, 1, 0,
2847 doc
: /* Return text area height of FRAME in pixels. */)
2850 return make_number (FRAME_TEXT_HEIGHT (decode_any_frame (frame
)));
2853 DEFUN ("frame-scroll-bar-width", Fscroll_bar_width
, Sscroll_bar_width
, 0, 1, 0,
2854 doc
: /* Return scroll bar width of FRAME in pixels. */)
2857 return make_number (FRAME_SCROLL_BAR_AREA_WIDTH (decode_any_frame (frame
)));
2860 DEFUN ("frame-scroll-bar-height", Fscroll_bar_height
, Sscroll_bar_height
, 0, 1, 0,
2861 doc
: /* Return scroll bar height of FRAME in pixels. */)
2864 return make_number (FRAME_SCROLL_BAR_AREA_HEIGHT (decode_any_frame (frame
)));
2867 DEFUN ("frame-fringe-width", Ffringe_width
, Sfringe_width
, 0, 1, 0,
2868 doc
: /* Return fringe width of FRAME in pixels. */)
2871 return make_number (FRAME_TOTAL_FRINGE_WIDTH (decode_any_frame (frame
)));
2874 DEFUN ("frame-border-width", Fborder_width
, Sborder_width
, 0, 1, 0,
2875 doc
: /* Return border width of FRAME in pixels. */)
2878 return make_number (FRAME_INTERNAL_BORDER_WIDTH (decode_any_frame (frame
)));
2881 DEFUN ("frame-right-divider-width", Fright_divider_width
, Sright_divider_width
, 0, 1, 0,
2882 doc
: /* Return width (in pixels) of vertical window dividers on FRAME. */)
2885 return make_number (FRAME_RIGHT_DIVIDER_WIDTH (decode_any_frame (frame
)));
2888 DEFUN ("frame-bottom-divider-width", Fbottom_divider_width
, Sbottom_divider_width
, 0, 1, 0,
2889 doc
: /* Return width (in pixels) of horizontal window dividers on FRAME. */)
2892 return make_number (FRAME_BOTTOM_DIVIDER_WIDTH (decode_any_frame (frame
)));
2895 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 4, 0,
2896 doc
: /* Set text height of frame FRAME to HEIGHT lines.
2897 Optional third arg PRETEND non-nil means that redisplay should use
2898 HEIGHT lines but that the idea of the actual height of the frame should
2901 Optional fourth argument PIXELWISE non-nil means that FRAME should be
2902 HEIGHT pixels high. Note: When `frame-resize-pixelwise' is nil, some
2903 window managers may refuse to honor a HEIGHT that is not an integer
2904 multiple of the default frame font height. */)
2905 (Lisp_Object frame
, Lisp_Object height
, Lisp_Object pretend
, Lisp_Object pixelwise
)
2907 struct frame
*f
= decode_live_frame (frame
);
2910 CHECK_TYPE_RANGED_INTEGER (int, height
);
2912 pixel_height
= (!NILP (pixelwise
)
2914 : XINT (height
) * FRAME_LINE_HEIGHT (f
));
2915 adjust_frame_size (f
, -1, pixel_height
, 1, !NILP (pretend
), Qheight
);
2920 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 4, 0,
2921 doc
: /* Set text width of frame FRAME to WIDTH columns.
2922 Optional third arg PRETEND non-nil means that redisplay should use WIDTH
2923 columns but that the idea of the actual width of the frame should not
2926 Optional fourth argument PIXELWISE non-nil means that FRAME should be
2927 WIDTH pixels wide. Note: When `frame-resize-pixelwise' is nil, some
2928 window managers may refuse to honor a WIDTH that is not an integer
2929 multiple of the default frame font width. */)
2930 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object pretend
, Lisp_Object pixelwise
)
2932 struct frame
*f
= decode_live_frame (frame
);
2935 CHECK_TYPE_RANGED_INTEGER (int, width
);
2937 pixel_width
= (!NILP (pixelwise
)
2939 : XINT (width
) * FRAME_COLUMN_WIDTH (f
));
2940 adjust_frame_size (f
, pixel_width
, -1, 1, !NILP (pretend
), Qwidth
);
2945 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 4, 0,
2946 doc
: /* Set text size of FRAME to WIDTH by HEIGHT, measured in characters.
2947 Optional argument PIXELWISE non-nil means to measure in pixels. Note:
2948 When `frame-resize-pixelwise' is nil, some window managers may refuse to
2949 honor a WIDTH that is not an integer multiple of the default frame font
2950 width or a HEIGHT that is not an integer multiple of the default frame
2952 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object height
, Lisp_Object pixelwise
)
2954 struct frame
*f
= decode_live_frame (frame
);
2955 int pixel_width
, pixel_height
;
2957 CHECK_TYPE_RANGED_INTEGER (int, width
);
2958 CHECK_TYPE_RANGED_INTEGER (int, height
);
2960 pixel_width
= (!NILP (pixelwise
)
2962 : XINT (width
) * FRAME_COLUMN_WIDTH (f
));
2963 pixel_height
= (!NILP (pixelwise
)
2965 : XINT (height
) * FRAME_LINE_HEIGHT (f
));
2966 adjust_frame_size (f
, pixel_width
, pixel_height
, 1, 0, Qsize
);
2971 DEFUN ("set-frame-position", Fset_frame_position
,
2972 Sset_frame_position
, 3, 3, 0,
2973 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2974 If FRAME is nil, the selected frame is used. XOFFSET and YOFFSET are
2975 actually the position of the upper left corner of the frame. Negative
2976 values for XOFFSET or YOFFSET are interpreted relative to the rightmost
2977 or bottommost possible position (that stays within the screen). */)
2978 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2980 register struct frame
*f
= decode_live_frame (frame
);
2982 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2983 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2985 /* I think this should be done with a hook. */
2986 #ifdef HAVE_WINDOW_SYSTEM
2987 if (FRAME_WINDOW_P (f
))
2988 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2995 /***********************************************************************
2997 ***********************************************************************/
2999 /* Connect the frame-parameter names for X frames
3000 to the ways of passing the parameter values to the window system.
3002 The name of a parameter, as a Lisp symbol,
3003 has an `x-frame-parameter' property which is an integer in Lisp
3004 that is an index in this table. */
3006 struct frame_parm_table
{
3011 static const struct frame_parm_table frame_parms
[] =
3013 {"auto-raise", SYMBOL_INDEX (Qauto_raise
)},
3014 {"auto-lower", SYMBOL_INDEX (Qauto_lower
)},
3015 {"background-color", -1},
3016 {"border-color", SYMBOL_INDEX (Qborder_color
)},
3017 {"border-width", SYMBOL_INDEX (Qborder_width
)},
3018 {"cursor-color", SYMBOL_INDEX (Qcursor_color
)},
3019 {"cursor-type", SYMBOL_INDEX (Qcursor_type
)},
3021 {"foreground-color", -1},
3022 {"icon-name", SYMBOL_INDEX (Qicon_name
)},
3023 {"icon-type", SYMBOL_INDEX (Qicon_type
)},
3024 {"internal-border-width", SYMBOL_INDEX (Qinternal_border_width
)},
3025 {"right-divider-width", SYMBOL_INDEX (Qright_divider_width
)},
3026 {"bottom-divider-width", SYMBOL_INDEX (Qbottom_divider_width
)},
3027 {"menu-bar-lines", SYMBOL_INDEX (Qmenu_bar_lines
)},
3028 {"mouse-color", SYMBOL_INDEX (Qmouse_color
)},
3029 {"name", SYMBOL_INDEX (Qname
)},
3030 {"scroll-bar-width", SYMBOL_INDEX (Qscroll_bar_width
)},
3031 {"scroll-bar-height", SYMBOL_INDEX (Qscroll_bar_height
)},
3032 {"title", SYMBOL_INDEX (Qtitle
)},
3033 {"unsplittable", SYMBOL_INDEX (Qunsplittable
)},
3034 {"vertical-scroll-bars", SYMBOL_INDEX (Qvertical_scroll_bars
)},
3035 {"horizontal-scroll-bars", SYMBOL_INDEX (Qhorizontal_scroll_bars
)},
3036 {"visibility", SYMBOL_INDEX (Qvisibility
)},
3037 {"tool-bar-lines", SYMBOL_INDEX (Qtool_bar_lines
)},
3038 {"scroll-bar-foreground", SYMBOL_INDEX (Qscroll_bar_foreground
)},
3039 {"scroll-bar-background", SYMBOL_INDEX (Qscroll_bar_background
)},
3040 {"screen-gamma", SYMBOL_INDEX (Qscreen_gamma
)},
3041 {"line-spacing", SYMBOL_INDEX (Qline_spacing
)},
3042 {"left-fringe", SYMBOL_INDEX (Qleft_fringe
)},
3043 {"right-fringe", SYMBOL_INDEX (Qright_fringe
)},
3044 {"wait-for-wm", SYMBOL_INDEX (Qwait_for_wm
)},
3045 {"fullscreen", SYMBOL_INDEX (Qfullscreen
)},
3046 {"font-backend", SYMBOL_INDEX (Qfont_backend
)},
3047 {"alpha", SYMBOL_INDEX (Qalpha
)},
3048 {"sticky", SYMBOL_INDEX (Qsticky
)},
3049 {"tool-bar-position", SYMBOL_INDEX (Qtool_bar_position
)},
3052 #ifdef HAVE_WINDOW_SYSTEM
3054 /* Change the parameters of frame F as specified by ALIST.
3055 If a parameter is not specially recognized, do nothing special;
3056 otherwise call the `x_set_...' function for that parameter.
3057 Except for certain geometry properties, always call store_frame_param
3058 to store the new value in the parameter alist. */
3061 x_set_frame_parameters (struct frame
*f
, Lisp_Object alist
)
3065 /* If both of these parameters are present, it's more efficient to
3066 set them both at once. So we wait until we've looked at the
3067 entire list before we set them. */
3068 int width
IF_LINT (= 0), height
IF_LINT (= 0);
3069 bool width_change
= false, height_change
= false;
3072 Lisp_Object left
, top
;
3074 /* Same with these. */
3075 Lisp_Object icon_left
, icon_top
;
3077 /* And with this. */
3078 Lisp_Object fullscreen
;
3079 bool fullscreen_change
= false;
3081 /* Record in these vectors all the parms specified. */
3083 Lisp_Object
*values
;
3085 bool left_no_change
= 0, top_no_change
= 0;
3086 #ifdef HAVE_X_WINDOWS
3087 bool icon_left_no_change
= 0, icon_top_no_change
= 0;
3091 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3095 SAFE_ALLOCA_LISP (parms
, 2 * i
);
3098 /* Extract parm names and values into those vectors. */
3101 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3106 parms
[i
] = Fcar (elt
);
3107 values
[i
] = Fcdr (elt
);
3110 /* TAIL and ALIST are not used again below here. */
3111 alist
= tail
= Qnil
;
3113 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
3114 because their values appear in VALUES and strings are not valid. */
3115 top
= left
= Qunbound
;
3116 icon_left
= icon_top
= Qunbound
;
3118 /* Process foreground_color and background_color before anything else.
3119 They are independent of other properties, but other properties (e.g.,
3120 cursor_color) are dependent upon them. */
3121 /* Process default font as well, since fringe widths depends on it. */
3122 for (p
= 0; p
< i
; p
++)
3124 Lisp_Object prop
, val
;
3128 if (EQ (prop
, Qforeground_color
)
3129 || EQ (prop
, Qbackground_color
)
3130 || EQ (prop
, Qfont
))
3132 register Lisp_Object param_index
, old_value
;
3134 old_value
= get_frame_param (f
, prop
);
3135 if (NILP (Fequal (val
, old_value
)))
3137 store_frame_param (f
, prop
, val
);
3139 param_index
= Fget (prop
, Qx_frame_parameter
);
3140 if (NATNUMP (param_index
)
3141 && XFASTINT (param_index
) < ARRAYELTS (frame_parms
)
3142 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3143 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3148 /* Now process them in reverse of specified order. */
3151 Lisp_Object prop
, val
;
3156 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
3159 width
= XFASTINT (val
) * FRAME_COLUMN_WIDTH (f
) ;
3161 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
3164 height
= XFASTINT (val
) * FRAME_LINE_HEIGHT (f
);
3166 else if (EQ (prop
, Qtop
))
3168 else if (EQ (prop
, Qleft
))
3170 else if (EQ (prop
, Qicon_top
))
3172 else if (EQ (prop
, Qicon_left
))
3174 else if (EQ (prop
, Qfullscreen
))
3177 fullscreen_change
= true;
3179 else if (EQ (prop
, Qforeground_color
)
3180 || EQ (prop
, Qbackground_color
)
3181 || EQ (prop
, Qfont
))
3182 /* Processed above. */
3186 register Lisp_Object param_index
, old_value
;
3188 old_value
= get_frame_param (f
, prop
);
3190 store_frame_param (f
, prop
, val
);
3192 param_index
= Fget (prop
, Qx_frame_parameter
);
3193 if (NATNUMP (param_index
)
3194 && XFASTINT (param_index
) < ARRAYELTS (frame_parms
)
3195 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3196 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3200 /* Don't die if just one of these was set. */
3201 if (EQ (left
, Qunbound
))
3204 if (f
->left_pos
< 0)
3205 left
= list2 (Qplus
, make_number (f
->left_pos
));
3207 XSETINT (left
, f
->left_pos
);
3209 if (EQ (top
, Qunbound
))
3213 top
= list2 (Qplus
, make_number (f
->top_pos
));
3215 XSETINT (top
, f
->top_pos
);
3218 /* If one of the icon positions was not set, preserve or default it. */
3219 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
3221 #ifdef HAVE_X_WINDOWS
3222 icon_left_no_change
= 1;
3224 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3225 if (NILP (icon_left
))
3226 XSETINT (icon_left
, 0);
3228 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
3230 #ifdef HAVE_X_WINDOWS
3231 icon_top_no_change
= 1;
3233 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3234 if (NILP (icon_top
))
3235 XSETINT (icon_top
, 0);
3238 /* Don't set these parameters unless they've been explicitly
3239 specified. The window might be mapped or resized while we're in
3240 this function, and we don't want to override that unless the lisp
3241 code has asked for it.
3243 Don't set these parameters unless they actually differ from the
3244 window's current parameters; the window may not actually exist
3249 XSETFRAME (frame
, f
);
3251 if ((width_change
&& width
!= FRAME_TEXT_WIDTH (f
))
3252 || (height_change
&& height
!= FRAME_TEXT_HEIGHT (f
))
3253 || (f
->can_x_set_window_size
&& (f
->new_height
|| f
->new_width
)))
3255 /* If necessary provide default values for HEIGHT and WIDTH. Do
3256 that here since otherwise a size change implied by an
3257 intermittent font change may get lost as in Bug#17142. */
3259 width
= ((f
->can_x_set_window_size
&& f
->new_width
)
3262 : (f
->new_width
* FRAME_COLUMN_WIDTH (f
)))
3263 : FRAME_TEXT_WIDTH (f
));
3266 height
= ((f
->can_x_set_window_size
&& f
->new_height
)
3269 : (f
->new_height
* FRAME_LINE_HEIGHT (f
)))
3270 : FRAME_TEXT_HEIGHT (f
));
3272 Fset_frame_size (frame
, make_number (width
), make_number (height
), Qt
);
3275 if ((!NILP (left
) || !NILP (top
))
3276 && ! (left_no_change
&& top_no_change
)
3277 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3278 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3283 /* Record the signs. */
3284 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3285 if (EQ (left
, Qminus
))
3286 f
->size_hint_flags
|= XNegative
;
3287 else if (TYPE_RANGED_INTEGERP (int, left
))
3289 leftpos
= XINT (left
);
3291 f
->size_hint_flags
|= XNegative
;
3293 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3294 && CONSP (XCDR (left
))
3295 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
3297 leftpos
= - XINT (XCAR (XCDR (left
)));
3298 f
->size_hint_flags
|= XNegative
;
3300 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3301 && CONSP (XCDR (left
))
3302 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
3304 leftpos
= XINT (XCAR (XCDR (left
)));
3307 if (EQ (top
, Qminus
))
3308 f
->size_hint_flags
|= YNegative
;
3309 else if (TYPE_RANGED_INTEGERP (int, top
))
3311 toppos
= XINT (top
);
3313 f
->size_hint_flags
|= YNegative
;
3315 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3316 && CONSP (XCDR (top
))
3317 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
3319 toppos
= - XINT (XCAR (XCDR (top
)));
3320 f
->size_hint_flags
|= YNegative
;
3322 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
3323 && CONSP (XCDR (top
))
3324 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
3326 toppos
= XINT (XCAR (XCDR (top
)));
3330 /* Store the numeric value of the position. */
3331 f
->top_pos
= toppos
;
3332 f
->left_pos
= leftpos
;
3334 f
->win_gravity
= NorthWestGravity
;
3336 /* Actually set that position, and convert to absolute. */
3337 x_set_offset (f
, leftpos
, toppos
, -1);
3340 if (fullscreen_change
)
3342 Lisp_Object old_value
= get_frame_param (f
, Qfullscreen
);
3344 frame_size_history_add
3345 (f
, Qx_set_fullscreen
, 0, 0, list2 (old_value
, fullscreen
));
3347 store_frame_param (f
, Qfullscreen
, fullscreen
);
3348 if (!EQ (fullscreen
, old_value
))
3349 x_set_fullscreen (f
, fullscreen
, old_value
);
3353 #ifdef HAVE_X_WINDOWS
3354 if ((!NILP (icon_left
) || !NILP (icon_top
))
3355 && ! (icon_left_no_change
&& icon_top_no_change
))
3356 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3357 #endif /* HAVE_X_WINDOWS */
3364 /* Insert a description of internally-recorded parameters of frame X
3365 into the parameter alist *ALISTPTR that is to be given to the user.
3366 Only parameters that are specific to the X window system
3367 and whose values are not correctly recorded in the frame's
3368 param_alist need to be considered here. */
3371 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3375 char buf
[INT_BUFSIZE_BOUND (w
)];
3377 /* Represent negative positions (off the top or left screen edge)
3378 in a way that Fmodify_frame_parameters will understand correctly. */
3379 XSETINT (tem
, f
->left_pos
);
3380 if (f
->left_pos
>= 0)
3381 store_in_alist (alistptr
, Qleft
, tem
);
3383 store_in_alist (alistptr
, Qleft
, list2 (Qplus
, tem
));
3385 XSETINT (tem
, f
->top_pos
);
3386 if (f
->top_pos
>= 0)
3387 store_in_alist (alistptr
, Qtop
, tem
);
3389 store_in_alist (alistptr
, Qtop
, list2 (Qplus
, tem
));
3391 store_in_alist (alistptr
, Qborder_width
,
3392 make_number (f
->border_width
));
3393 store_in_alist (alistptr
, Qinternal_border_width
,
3394 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3395 store_in_alist (alistptr
, Qright_divider_width
,
3396 make_number (FRAME_RIGHT_DIVIDER_WIDTH (f
)));
3397 store_in_alist (alistptr
, Qbottom_divider_width
,
3398 make_number (FRAME_BOTTOM_DIVIDER_WIDTH (f
)));
3399 store_in_alist (alistptr
, Qleft_fringe
,
3400 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3401 store_in_alist (alistptr
, Qright_fringe
,
3402 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3403 store_in_alist (alistptr
, Qscroll_bar_width
,
3404 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3406 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3407 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3408 /* nil means "use default width"
3409 for non-toolkit scroll bar.
3410 ruler-mode.el depends on this. */
3412 store_in_alist (alistptr
, Qscroll_bar_height
,
3413 (! FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)
3415 : FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) > 0
3416 ? make_number (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
3417 /* nil means "use default height"
3418 for non-toolkit scroll bar. */
3420 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
3421 MS-Windows it returns a value whose type is HANDLE, which is
3422 actually a pointer. Explicit casting avoids compiler
3424 w
= (uintptr_t) FRAME_X_WINDOW (f
);
3425 store_in_alist (alistptr
, Qwindow_id
,
3426 make_formatted_string (buf
, "%"pMu
, w
));
3427 #ifdef HAVE_X_WINDOWS
3428 #ifdef USE_X_TOOLKIT
3429 /* Tooltip frame may not have this widget. */
3430 if (FRAME_X_OUTPUT (f
)->widget
)
3432 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
3433 store_in_alist (alistptr
, Qouter_window_id
,
3434 make_formatted_string (buf
, "%"pMu
, w
));
3436 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3437 store_in_alist (alistptr
, Qvisibility
,
3438 (FRAME_VISIBLE_P (f
) ? Qt
3439 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3440 store_in_alist (alistptr
, Qdisplay
,
3441 XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
));
3443 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_DISPLAY_INFO (f
)->root_window
)
3446 tem
= make_natnum ((uintptr_t) FRAME_X_OUTPUT (f
)->parent_desc
);
3447 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3448 store_in_alist (alistptr
, Qparent_id
, tem
);
3449 store_in_alist (alistptr
, Qtool_bar_position
, FRAME_TOOL_BAR_POSITION (f
));
3453 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3454 the previous value of that parameter, NEW_VALUE is the new value. */
3457 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3459 if (NILP (new_value
))
3460 f
->want_fullscreen
= FULLSCREEN_NONE
;
3461 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3462 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3463 else if (EQ (new_value
, Qfullwidth
))
3464 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3465 else if (EQ (new_value
, Qfullheight
))
3466 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3467 else if (EQ (new_value
, Qmaximized
))
3468 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3470 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3471 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3475 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3476 the previous value of that parameter, NEW_VALUE is the new value. */
3479 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3481 if (NILP (new_value
))
3482 f
->extra_line_spacing
= 0;
3483 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
3484 f
->extra_line_spacing
= XFASTINT (new_value
);
3485 else if (FLOATP (new_value
))
3487 int new_spacing
= XFLOAT_DATA (new_value
) * FRAME_LINE_HEIGHT (f
) + 0.5;
3489 if (new_spacing
>= 0)
3490 f
->extra_line_spacing
= new_spacing
;
3492 signal_error ("Invalid line-spacing", new_value
);
3495 signal_error ("Invalid line-spacing", new_value
);
3496 if (FRAME_VISIBLE_P (f
))
3501 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3502 the previous value of that parameter, NEW_VALUE is the new value. */
3505 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3507 Lisp_Object bgcolor
;
3509 if (NILP (new_value
))
3511 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3512 /* The value 0.4545 is the normal viewing gamma. */
3513 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3515 signal_error ("Invalid screen-gamma", new_value
);
3517 /* Apply the new gamma value to the frame background. */
3518 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3519 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3521 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3522 if (NATNUMP (parm_index
)
3523 && XFASTINT (parm_index
) < ARRAYELTS (frame_parms
)
3524 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3525 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3529 Fclear_face_cache (Qnil
);
3534 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3536 Lisp_Object font_object
;
3538 #ifdef HAVE_X_WINDOWS
3539 Lisp_Object font_param
= arg
;
3542 /* Set the frame parameter back to the old value because we may
3543 fail to use ARG as the new parameter value. */
3544 store_frame_param (f
, Qfont
, oldval
);
3546 /* ARG is a fontset name, a font name, a cons of fontset name and a
3547 font object, or a font object. In the last case, this function
3551 fontset
= fs_query_fontset (arg
, 0);
3554 font_object
= font_open_by_name (f
, arg
);
3555 if (NILP (font_object
))
3556 error ("Font `%s' is not defined", SSDATA (arg
));
3557 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3559 else if (fontset
> 0)
3561 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
3562 if (NILP (font_object
))
3563 error ("Font `%s' is not defined", SDATA (arg
));
3564 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3567 error ("The default fontset can't be used for a frame font");
3569 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3571 /* This is the case that the ASCII font of F's fontset XCAR
3572 (arg) is changed to the font XCDR (arg) by
3573 `set-fontset-font'. */
3574 fontset
= fs_query_fontset (XCAR (arg
), 0);
3576 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3577 font_object
= XCDR (arg
);
3578 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3579 #ifdef HAVE_X_WINDOWS
3580 font_param
= Ffont_get (font_object
, QCname
);
3583 else if (FONT_OBJECT_P (arg
))
3586 #ifdef HAVE_X_WINDOWS
3587 font_param
= Ffont_get (font_object
, QCname
);
3589 /* This is to store the XLFD font name in the frame parameter for
3590 backward compatibility. We should store the font-object
3591 itself in the future. */
3592 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3593 fontset
= FRAME_FONTSET (f
);
3594 /* Check if we can use the current fontset. If not, set FONTSET
3595 to -1 to generate a new fontset from FONT-OBJECT. */
3598 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3599 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3602 signal_error ("Invalid font name", ascii_font
);
3604 if (! font_match_p (spec
, font_object
))
3609 signal_error ("Invalid font", arg
);
3611 if (! NILP (Fequal (font_object
, oldval
)))
3614 x_new_font (f
, font_object
, fontset
);
3615 store_frame_param (f
, Qfont
, arg
);
3616 #ifdef HAVE_X_WINDOWS
3617 store_frame_param (f
, Qfont_param
, font_param
);
3619 /* Recalculate toolbar height. */
3620 f
->n_tool_bar_rows
= 0;
3622 /* Ensure we redraw it. */
3623 clear_current_matrices (f
);
3625 /* Attempt to hunt down bug#16028. */
3626 SET_FRAME_GARBAGED (f
);
3628 recompute_basic_faces (f
);
3630 do_pending_window_change (0);
3632 /* We used to call face-set-after-frame-default here, but it leads to
3633 recursive calls (since that function can set the `default' face's
3634 font which in turns changes the frame's `font' parameter).
3635 Also I don't know what this call is meant to do, but it seems the
3636 wrong way to do it anyway (it does a lot more work than what seems
3637 reasonable in response to a change to `font'). */
3642 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3644 if (! NILP (new_value
)
3645 && !CONSP (new_value
))
3649 CHECK_STRING (new_value
);
3650 p0
= p1
= SSDATA (new_value
);
3654 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
3656 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3662 while ((c
= *++p1
) && c_isspace (c
));
3666 new_value
= Fnreverse (new_value
);
3669 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3673 free_all_realized_faces (Qnil
);
3675 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3676 if (NILP (new_value
))
3678 if (NILP (old_value
))
3679 error ("No font backend available");
3680 font_update_drivers (f
, old_value
);
3681 error ("None of specified font backends are available");
3683 store_frame_param (f
, Qfont_backend
, new_value
);
3689 XSETFRAME (frame
, f
);
3690 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3692 windows_or_buffers_changed
= 18;
3697 x_set_left_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3699 int unit
= FRAME_COLUMN_WIDTH (f
);
3700 int old_width
= FRAME_LEFT_FRINGE_WIDTH (f
);
3703 new_width
= (RANGED_INTEGERP (-INT_MAX
, new_value
, INT_MAX
)
3704 ? eabs (XINT (new_value
)) : 8);
3706 if (new_width
!= old_width
)
3708 FRAME_LEFT_FRINGE_WIDTH (f
) = new_width
;
3709 FRAME_FRINGE_COLS (f
) /* Round up. */
3710 = (new_width
+ FRAME_RIGHT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
3712 if (FRAME_X_WINDOW (f
) != 0)
3713 adjust_frame_size (f
, -1, -1, 3, 0, Qleft_fringe
);
3715 SET_FRAME_GARBAGED (f
);
3721 x_set_right_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3723 int unit
= FRAME_COLUMN_WIDTH (f
);
3724 int old_width
= FRAME_RIGHT_FRINGE_WIDTH (f
);
3727 new_width
= (RANGED_INTEGERP (-INT_MAX
, new_value
, INT_MAX
)
3728 ? eabs (XINT (new_value
)) : 8);
3730 if (new_width
!= old_width
)
3732 FRAME_RIGHT_FRINGE_WIDTH (f
) = new_width
;
3733 FRAME_FRINGE_COLS (f
) /* Round up. */
3734 = (new_width
+ FRAME_LEFT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
3736 if (FRAME_X_WINDOW (f
) != 0)
3737 adjust_frame_size (f
, -1, -1, 3, 0, Qright_fringe
);
3739 SET_FRAME_GARBAGED (f
);
3745 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3747 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3749 if (XINT (arg
) == f
->border_width
)
3752 if (FRAME_X_WINDOW (f
) != 0)
3753 error ("Cannot change the border width of a frame");
3755 f
->border_width
= XINT (arg
);
3759 x_set_right_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3761 int old
= FRAME_RIGHT_DIVIDER_WIDTH (f
);
3763 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3764 FRAME_RIGHT_DIVIDER_WIDTH (f
) = XINT (arg
);
3765 if (FRAME_RIGHT_DIVIDER_WIDTH (f
) < 0)
3766 FRAME_RIGHT_DIVIDER_WIDTH (f
) = 0;
3767 if (FRAME_RIGHT_DIVIDER_WIDTH (f
) != old
)
3769 adjust_frame_size (f
, -1, -1, 4, 0, Qright_divider_width
);
3770 adjust_frame_glyphs (f
);
3771 SET_FRAME_GARBAGED (f
);
3777 x_set_bottom_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3779 int old
= FRAME_BOTTOM_DIVIDER_WIDTH (f
);
3781 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3782 FRAME_BOTTOM_DIVIDER_WIDTH (f
) = XINT (arg
);
3783 if (FRAME_BOTTOM_DIVIDER_WIDTH (f
) < 0)
3784 FRAME_BOTTOM_DIVIDER_WIDTH (f
) = 0;
3785 if (FRAME_BOTTOM_DIVIDER_WIDTH (f
) != old
)
3787 adjust_frame_size (f
, -1, -1, 4, 0, Qbottom_divider_width
);
3788 adjust_frame_glyphs (f
);
3789 SET_FRAME_GARBAGED (f
);
3794 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3797 XSETFRAME (frame
, f
);
3800 Fmake_frame_invisible (frame
, Qt
);
3801 else if (EQ (value
, Qicon
))
3802 Ficonify_frame (frame
);
3804 Fmake_frame_visible (frame
);
3808 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3810 f
->auto_raise
= !EQ (Qnil
, arg
);
3814 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3816 f
->auto_lower
= !EQ (Qnil
, arg
);
3820 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3822 f
->no_split
= !NILP (arg
);
3826 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3828 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3829 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3830 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3831 || (!NILP (arg
) && !FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3833 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3835 ? vertical_scroll_bar_none
3837 ? vertical_scroll_bar_left
3839 ? vertical_scroll_bar_right
3840 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3841 ? vertical_scroll_bar_left
3842 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3843 ? vertical_scroll_bar_right
3844 : vertical_scroll_bar_none
);
3846 /* We set this parameter before creating the X window for the
3847 frame, so we can get the geometry right from the start.
3848 However, if the window hasn't been created yet, we shouldn't
3849 call x_set_window_size. */
3850 if (FRAME_X_WINDOW (f
))
3851 adjust_frame_size (f
, -1, -1, 3, 0, Qvertical_scroll_bars
);
3853 SET_FRAME_GARBAGED (f
);
3858 x_set_horizontal_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3860 #if USE_HORIZONTAL_SCROLL_BARS
3861 if ((NILP (arg
) && FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
))
3862 || (!NILP (arg
) && !FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)))
3864 f
->horizontal_scroll_bars
= NILP (arg
) ? false : true;
3866 /* We set this parameter before creating the X window for the
3867 frame, so we can get the geometry right from the start.
3868 However, if the window hasn't been created yet, we shouldn't
3869 call x_set_window_size. */
3870 if (FRAME_X_WINDOW (f
))
3871 adjust_frame_size (f
, -1, -1, 3, 0, Qhorizontal_scroll_bars
);
3873 SET_FRAME_GARBAGED (f
);
3879 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3881 int unit
= FRAME_COLUMN_WIDTH (f
);
3885 x_set_scroll_bar_default_width (f
);
3887 if (FRAME_X_WINDOW (f
))
3888 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_width
);
3890 SET_FRAME_GARBAGED (f
);
3892 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3893 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3895 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3896 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + unit
- 1) / unit
;
3897 if (FRAME_X_WINDOW (f
))
3898 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_width
);
3900 SET_FRAME_GARBAGED (f
);
3903 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3904 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3908 x_set_scroll_bar_height (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3910 #if USE_HORIZONTAL_SCROLL_BARS
3911 int unit
= FRAME_LINE_HEIGHT (f
);
3915 x_set_scroll_bar_default_height (f
);
3917 if (FRAME_X_WINDOW (f
))
3918 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_height
);
3920 SET_FRAME_GARBAGED (f
);
3922 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3923 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
3925 FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) = XFASTINT (arg
);
3926 FRAME_CONFIG_SCROLL_BAR_LINES (f
) = (XFASTINT (arg
) + unit
- 1) / unit
;
3927 if (FRAME_X_WINDOW (f
))
3928 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_height
);
3930 SET_FRAME_GARBAGED (f
);
3933 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.vpos
= 0;
3934 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.y
= 0;
3939 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3946 for (i
= 0; i
< 2; i
++)
3959 else if (FLOATP (item
))
3961 alpha
= XFLOAT_DATA (item
);
3962 if (! (0 <= alpha
&& alpha
<= 1.0))
3963 args_out_of_range (make_float (0.0), make_float (1.0));
3965 else if (INTEGERP (item
))
3967 EMACS_INT ialpha
= XINT (item
);
3968 if (! (0 <= ialpha
&& alpha
<= 100))
3969 args_out_of_range (make_number (0), make_number (100));
3970 alpha
= ialpha
/ 100.0;
3973 wrong_type_argument (Qnumberp
, item
);
3977 for (i
= 0; i
< 2; i
++)
3978 f
->alpha
[i
] = newval
[i
];
3980 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3982 x_set_frame_alpha (f
);
3991 /* Non-zero if mouse is grabbed on DPYINFO
3992 and we know the frame where it is. */
3994 bool x_mouse_grabbed (Display_Info
*dpyinfo
)
3996 return (dpyinfo
->grabbed
3997 && dpyinfo
->last_mouse_frame
3998 && FRAME_LIVE_P (dpyinfo
->last_mouse_frame
));
4001 /* Re-highlight something with mouse-face properties
4002 on DPYINFO using saved frame and mouse position. */
4005 x_redo_mouse_highlight (Display_Info
*dpyinfo
)
4007 if (dpyinfo
->last_mouse_motion_frame
4008 && FRAME_LIVE_P (dpyinfo
->last_mouse_motion_frame
))
4009 note_mouse_highlight (dpyinfo
->last_mouse_motion_frame
,
4010 dpyinfo
->last_mouse_motion_x
,
4011 dpyinfo
->last_mouse_motion_y
);
4014 #endif /* HAVE_NS */
4016 /* Subroutines of creating an X frame. */
4018 /* Make sure that Vx_resource_name is set to a reasonable value.
4019 Fix it up, or set it to `emacs' if it is too hopeless. */
4022 validate_x_resource_name (void)
4025 /* Number of valid characters in the resource name. */
4026 ptrdiff_t good_count
= 0;
4027 /* Number of invalid characters in the resource name. */
4028 ptrdiff_t bad_count
= 0;
4032 if (!STRINGP (Vx_resource_class
))
4033 Vx_resource_class
= build_string (EMACS_CLASS
);
4035 if (STRINGP (Vx_resource_name
))
4037 unsigned char *p
= SDATA (Vx_resource_name
);
4039 len
= SBYTES (Vx_resource_name
);
4041 /* Only letters, digits, - and _ are valid in resource names.
4042 Count the valid characters and count the invalid ones. */
4043 for (i
= 0; i
< len
; i
++)
4046 if (! ((c
>= 'a' && c
<= 'z')
4047 || (c
>= 'A' && c
<= 'Z')
4048 || (c
>= '0' && c
<= '9')
4049 || c
== '-' || c
== '_'))
4056 /* Not a string => completely invalid. */
4057 bad_count
= 5, good_count
= 0;
4059 /* If name is valid already, return. */
4063 /* If name is entirely invalid, or nearly so, or is so implausibly
4064 large that alloca might not work, use `emacs'. */
4065 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
4067 Vx_resource_name
= build_string ("emacs");
4071 /* Name is partly valid. Copy it and replace the invalid characters
4072 with underscores. */
4074 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
4076 for (i
= 0; i
< len
; i
++)
4078 int c
= SREF (new, i
);
4079 if (! ((c
>= 'a' && c
<= 'z')
4080 || (c
>= 'A' && c
<= 'Z')
4081 || (c
>= '0' && c
<= '9')
4082 || c
== '-' || c
== '_'))
4087 /* Get specified attribute from resource database RDB.
4088 See Fx_get_resource below for other parameters. */
4091 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
4093 CHECK_STRING (attribute
);
4094 CHECK_STRING (class);
4096 if (!NILP (component
))
4097 CHECK_STRING (component
);
4098 if (!NILP (subclass
))
4099 CHECK_STRING (subclass
);
4100 if (NILP (component
) != NILP (subclass
))
4101 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
4103 validate_x_resource_name ();
4105 /* Allocate space for the components, the dots which separate them,
4106 and the final '\0'. Make them big enough for the worst case. */
4107 ptrdiff_t name_keysize
= (SBYTES (Vx_resource_name
)
4108 + (STRINGP (component
)
4109 ? SBYTES (component
) : 0)
4110 + SBYTES (attribute
)
4113 ptrdiff_t class_keysize
= (SBYTES (Vx_resource_class
)
4115 + (STRINGP (subclass
)
4116 ? SBYTES (subclass
) : 0)
4119 char *name_key
= SAFE_ALLOCA (name_keysize
+ class_keysize
);
4120 char *class_key
= name_key
+ name_keysize
;
4122 /* Start with emacs.FRAMENAME for the name (the specific one)
4123 and with `Emacs' for the class key (the general one). */
4124 char *nz
= lispstpcpy (name_key
, Vx_resource_name
);
4125 char *cz
= lispstpcpy (class_key
, Vx_resource_class
);
4128 cz
= lispstpcpy (cz
, class);
4130 if (!NILP (component
))
4133 lispstpcpy (cz
, subclass
);
4136 nz
= lispstpcpy (nz
, component
);
4140 lispstpcpy (nz
, attribute
);
4142 char *value
= x_get_string_resource (rdb
, name_key
, class_key
);
4145 if (value
&& *value
)
4146 return build_string (value
);
4152 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
4153 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
4154 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
4155 class, where INSTANCE is the name under which Emacs was invoked, or
4156 the name specified by the `-name' or `-rn' command-line arguments.
4158 The optional arguments COMPONENT and SUBCLASS add to the key and the
4159 class, respectively. You must specify both of them or neither.
4160 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
4161 and the class is `Emacs.CLASS.SUBCLASS'. */)
4162 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
,
4163 Lisp_Object subclass
)
4165 check_window_system (NULL
);
4167 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
4168 attribute
, class, component
, subclass
);
4171 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
4174 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
,
4175 Lisp_Object
class, Lisp_Object component
,
4176 Lisp_Object subclass
)
4178 return xrdb_get_resource (dpyinfo
->xrdb
,
4179 attribute
, class, component
, subclass
);
4182 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
4183 /* Used when C code wants a resource value. */
4184 /* Called from oldXMenu/Create.c. */
4186 x_get_resource_string (const char *attribute
, const char *class)
4189 struct frame
*sf
= SELECTED_FRAME ();
4190 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
4193 /* Allocate space for the components, the dots which separate them,
4194 and the final '\0'. */
4195 ptrdiff_t name_keysize
= invocation_namelen
+ strlen (attribute
) + 2;
4196 ptrdiff_t class_keysize
= sizeof (EMACS_CLASS
) - 1 + strlen (class) + 2;
4197 char *name_key
= SAFE_ALLOCA (name_keysize
+ class_keysize
);
4198 char *class_key
= name_key
+ name_keysize
;
4200 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
4201 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
4203 result
= x_get_string_resource (FRAME_DISPLAY_INFO (sf
)->xrdb
,
4204 name_key
, class_key
);
4210 /* Return the value of parameter PARAM.
4212 First search ALIST, then Vdefault_frame_alist, then the X defaults
4213 database, using ATTRIBUTE as the attribute name and CLASS as its class.
4215 Convert the resource to the type specified by desired_type.
4217 If no default is specified, return Qunbound. If you call
4218 x_get_arg, make sure you deal with Qunbound in a reasonable way,
4219 and don't let it get stored in any Lisp-visible variables! */
4222 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
4223 const char *attribute
, const char *class, enum resource_types type
)
4227 tem
= Fassq (param
, alist
);
4231 /* If we find this parm in ALIST, clear it out
4232 so that it won't be "left over" at the end. */
4234 XSETCAR (tem
, Qnil
);
4235 /* In case the parameter appears more than once in the alist,
4237 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
4238 if (CONSP (XCAR (tail
))
4239 && EQ (XCAR (XCAR (tail
)), param
))
4240 XSETCAR (XCAR (tail
), Qnil
);
4243 tem
= Fassq (param
, Vdefault_frame_alist
);
4245 /* If it wasn't specified in ALIST or the Lisp-level defaults,
4246 look in the X resources. */
4249 if (attribute
&& dpyinfo
)
4251 AUTO_STRING (at
, attribute
);
4252 AUTO_STRING (cl
, class);
4253 tem
= display_x_get_resource (dpyinfo
, at
, cl
, Qnil
, Qnil
);
4260 case RES_TYPE_NUMBER
:
4261 return make_number (atoi (SSDATA (tem
)));
4263 case RES_TYPE_BOOLEAN_NUMBER
:
4264 if (!strcmp (SSDATA (tem
), "on")
4265 || !strcmp (SSDATA (tem
), "true"))
4266 return make_number (1);
4267 return make_number (atoi (SSDATA (tem
)));
4270 case RES_TYPE_FLOAT
:
4271 return make_float (atof (SSDATA (tem
)));
4273 case RES_TYPE_BOOLEAN
:
4274 tem
= Fdowncase (tem
);
4275 if (!strcmp (SSDATA (tem
), "on")
4277 || !strcmp (SSDATA (tem
), "yes")
4279 || !strcmp (SSDATA (tem
), "true"))
4284 case RES_TYPE_STRING
:
4287 case RES_TYPE_SYMBOL
:
4288 /* As a special case, we map the values `true' and `on'
4289 to Qt, and `false' and `off' to Qnil. */
4292 lower
= Fdowncase (tem
);
4293 if (!strcmp (SSDATA (lower
), "on")
4295 || !strcmp (SSDATA (lower
), "yes")
4297 || !strcmp (SSDATA (lower
), "true"))
4299 else if (!strcmp (SSDATA (lower
), "off")
4301 || !strcmp (SSDATA (lower
), "no")
4303 || !strcmp (SSDATA (lower
), "false"))
4306 return Fintern (tem
, Qnil
);
4320 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
4321 const char *attribute
, const char *class,
4322 enum resource_types type
)
4324 return x_get_arg (FRAME_DISPLAY_INFO (f
),
4325 alist
, param
, attribute
, class, type
);
4328 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
4331 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
4333 const char *attribute
, const char *class,
4334 enum resource_types type
)
4338 value
= x_get_arg (FRAME_DISPLAY_INFO (f
), alist
, param
,
4339 attribute
, class, type
);
4340 if (! NILP (value
) && ! EQ (value
, Qunbound
))
4341 store_frame_param (f
, param
, value
);
4347 /* Record in frame F the specified or default value according to ALIST
4348 of the parameter named PROP (a Lisp symbol).
4349 If no value is specified for PROP, look for an X default for XPROP
4350 on the frame named NAME.
4351 If that is not found either, use the value DEFLT. */
4354 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
4355 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
4356 enum resource_types type
)
4360 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
4361 if (EQ (tem
, Qunbound
))
4363 AUTO_FRAME_ARG (arg
, prop
, tem
);
4364 x_set_frame_parameters (f
, arg
);
4369 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
4372 * XParseGeometry parses strings of the form
4373 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
4374 * width, height, xoffset, and yoffset are unsigned integers.
4375 * Example: "=80x24+300-49"
4376 * The equal sign is optional.
4377 * It returns a bitmask that indicates which of the four values
4378 * were actually found in the string. For each value found,
4379 * the corresponding argument is updated; for each value
4380 * not found, the corresponding argument is left unchanged.
4384 XParseGeometry (char *string
,
4386 unsigned int *width
, unsigned int *height
)
4390 unsigned long tempWidth
, tempHeight
;
4391 long int tempX
, tempY
;
4392 char *nextCharacter
;
4394 if (string
== NULL
|| *string
== '\0')
4397 string
++; /* ignore possible '=' at beg of geometry spec */
4400 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
4402 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
4403 if (strind
== nextCharacter
)
4405 strind
= nextCharacter
;
4409 if (*strind
== 'x' || *strind
== 'X')
4412 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
4413 if (strind
== nextCharacter
)
4415 strind
= nextCharacter
;
4416 mask
|= HeightValue
;
4419 if (*strind
== '+' || *strind
== '-')
4423 tempX
= strtol (strind
, &nextCharacter
, 10);
4424 if (strind
== nextCharacter
)
4426 strind
= nextCharacter
;
4428 if (*strind
== '+' || *strind
== '-')
4432 tempY
= strtol (strind
, &nextCharacter
, 10);
4433 if (strind
== nextCharacter
)
4435 strind
= nextCharacter
;
4440 /* If strind isn't at the end of the string then it's an invalid
4441 geometry specification. */
4443 if (*strind
!= '\0')
4447 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
4449 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
4450 if (mask
& WidthValue
)
4451 *width
= min (tempWidth
, UINT_MAX
);
4452 if (mask
& HeightValue
)
4453 *height
= min (tempHeight
, UINT_MAX
);
4457 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
4460 /* NS used to define x-parse-geometry in ns-win.el, but that confused
4461 make-docfile: the documentation string in ns-win.el was used for
4462 x-parse-geometry even in non-NS builds.
4464 With two definitions of x-parse-geometry in this file, various
4465 things still get confused (eg M-x apropos documentation), so that
4466 it is best if the two definitions just share the same doc-string.
4468 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4469 doc
: /* Parse a display geometry string STRING.
4470 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4471 The properties returned may include `top', `left', `height', and `width'.
4472 For X, the value of `left' or `top' may be an integer,
4473 or a list (+ N) meaning N pixels relative to top/left corner,
4474 or a list (- N) meaning -N pixels relative to bottom/right corner.
4475 On Nextstep, this just calls `ns-parse-geometry'. */)
4476 (Lisp_Object string
)
4479 unsigned int width
, height
;
4482 CHECK_STRING (string
);
4485 if (strchr (SSDATA (string
), ' ') != NULL
)
4486 return call1 (Qns_parse_geometry
, string
);
4488 geometry
= XParseGeometry (SSDATA (string
),
4489 &x
, &y
, &width
, &height
);
4491 if (geometry
& XValue
)
4493 Lisp_Object element
;
4495 if (x
>= 0 && (geometry
& XNegative
))
4496 element
= list3 (Qleft
, Qminus
, make_number (-x
));
4497 else if (x
< 0 && ! (geometry
& XNegative
))
4498 element
= list3 (Qleft
, Qplus
, make_number (x
));
4500 element
= Fcons (Qleft
, make_number (x
));
4501 result
= Fcons (element
, result
);
4504 if (geometry
& YValue
)
4506 Lisp_Object element
;
4508 if (y
>= 0 && (geometry
& YNegative
))
4509 element
= list3 (Qtop
, Qminus
, make_number (-y
));
4510 else if (y
< 0 && ! (geometry
& YNegative
))
4511 element
= list3 (Qtop
, Qplus
, make_number (y
));
4513 element
= Fcons (Qtop
, make_number (y
));
4514 result
= Fcons (element
, result
);
4517 if (geometry
& WidthValue
)
4518 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
4519 if (geometry
& HeightValue
)
4520 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
4526 /* Calculate the desired size and position of frame F.
4527 Return the flags saying which aspects were specified.
4529 Also set the win_gravity and size_hint_flags of F.
4531 Adjust height for toolbar if TOOLBAR_P is 1.
4533 This function does not make the coordinates positive. */
4535 #define DEFAULT_ROWS 35
4536 #define DEFAULT_COLS 80
4539 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, bool toolbar_p
)
4541 Lisp_Object height
, width
, user_size
, top
, left
, user_position
;
4542 long window_prompting
= 0;
4543 Display_Info
*dpyinfo
= FRAME_DISPLAY_INFO (f
);
4545 /* Default values if we fall through.
4546 Actually, if that happens we should get
4547 window manager prompting. */
4548 SET_FRAME_WIDTH (f
, DEFAULT_COLS
* FRAME_COLUMN_WIDTH (f
));
4549 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4550 SET_FRAME_HEIGHT (f
, DEFAULT_ROWS
* FRAME_LINE_HEIGHT (f
));
4551 SET_FRAME_LINES (f
, DEFAULT_ROWS
);
4553 /* Window managers expect that if program-specified
4554 positions are not (0,0), they're intentional, not defaults. */
4558 /* Ensure that earlier new_width and new_height settings won't
4559 override what we specify below. */
4560 f
->new_width
= f
->new_height
= 0;
4562 height
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4563 width
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4564 if (!EQ (width
, Qunbound
) || !EQ (height
, Qunbound
))
4566 if (!EQ (width
, Qunbound
))
4568 CHECK_NUMBER (width
);
4569 if (! (0 <= XINT (width
) && XINT (width
) <= INT_MAX
))
4570 xsignal1 (Qargs_out_of_range
, width
);
4572 SET_FRAME_WIDTH (f
, XINT (width
) * FRAME_COLUMN_WIDTH (f
));
4575 if (!EQ (height
, Qunbound
))
4577 CHECK_NUMBER (height
);
4578 if (! (0 <= XINT (height
) && XINT (height
) <= INT_MAX
))
4579 xsignal1 (Qargs_out_of_range
, height
);
4581 SET_FRAME_HEIGHT (f
, XINT (height
) * FRAME_LINE_HEIGHT (f
));
4584 user_size
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4585 if (!NILP (user_size
) && !EQ (user_size
, Qunbound
))
4586 window_prompting
|= USSize
;
4588 window_prompting
|= PSize
;
4591 /* Add a tool bar height to the initial frame height so that the user
4592 gets a text display area of the size he specified with -g or via
4593 .Xdefaults. Later changes of the tool bar height don't change the
4594 frame size. This is done so that users can create tall Emacs
4595 frames without having to guess how tall the tool bar will get. */
4596 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4598 if (frame_default_tool_bar_height
)
4599 FRAME_TOOL_BAR_HEIGHT (f
) = frame_default_tool_bar_height
;
4604 relief
= (tool_bar_button_relief
>= 0
4605 ? tool_bar_button_relief
4606 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4608 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
4609 margin
= XFASTINT (Vtool_bar_button_margin
);
4610 else if (CONSP (Vtool_bar_button_margin
)
4611 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
4612 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4616 FRAME_TOOL_BAR_HEIGHT (f
)
4617 = DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4621 top
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4622 left
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4623 user_position
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4624 if (! EQ (top
, Qunbound
) || ! EQ (left
, Qunbound
))
4626 if (EQ (top
, Qminus
))
4629 window_prompting
|= YNegative
;
4631 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
4632 && CONSP (XCDR (top
))
4633 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
4635 f
->top_pos
= - XINT (XCAR (XCDR (top
)));
4636 window_prompting
|= YNegative
;
4638 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
4639 && CONSP (XCDR (top
))
4640 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
4642 f
->top_pos
= XINT (XCAR (XCDR (top
)));
4644 else if (EQ (top
, Qunbound
))
4648 CHECK_TYPE_RANGED_INTEGER (int, top
);
4649 f
->top_pos
= XINT (top
);
4651 window_prompting
|= YNegative
;
4654 if (EQ (left
, Qminus
))
4657 window_prompting
|= XNegative
;
4659 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
4660 && CONSP (XCDR (left
))
4661 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
4663 f
->left_pos
= - XINT (XCAR (XCDR (left
)));
4664 window_prompting
|= XNegative
;
4666 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
4667 && CONSP (XCDR (left
))
4668 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
4670 f
->left_pos
= XINT (XCAR (XCDR (left
)));
4672 else if (EQ (left
, Qunbound
))
4676 CHECK_TYPE_RANGED_INTEGER (int, left
);
4677 f
->left_pos
= XINT (left
);
4678 if (f
->left_pos
< 0)
4679 window_prompting
|= XNegative
;
4682 if (!NILP (user_position
) && ! EQ (user_position
, Qunbound
))
4683 window_prompting
|= USPosition
;
4685 window_prompting
|= PPosition
;
4688 if (window_prompting
& XNegative
)
4690 if (window_prompting
& YNegative
)
4691 f
->win_gravity
= SouthEastGravity
;
4693 f
->win_gravity
= NorthEastGravity
;
4697 if (window_prompting
& YNegative
)
4698 f
->win_gravity
= SouthWestGravity
;
4700 f
->win_gravity
= NorthWestGravity
;
4703 f
->size_hint_flags
= window_prompting
;
4705 return window_prompting
;
4710 #endif /* HAVE_WINDOW_SYSTEM */
4713 frame_make_pointer_invisible (struct frame
*f
)
4715 if (! NILP (Vmake_pointer_invisible
))
4717 if (f
&& FRAME_LIVE_P (f
) && !f
->pointer_invisible
4718 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4721 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4722 f
->pointer_invisible
= 1;
4728 frame_make_pointer_visible (struct frame
*f
)
4730 /* We don't check Vmake_pointer_invisible here in case the
4731 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4732 if (f
&& FRAME_LIVE_P (f
) && f
->pointer_invisible
&& f
->mouse_moved
4733 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4735 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4736 f
->pointer_invisible
= 0;
4740 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4741 Sframe_pointer_visible_p
, 0, 1, 0,
4742 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4743 Otherwise it returns nil. FRAME omitted or nil means the
4744 selected frame. This is useful when `make-pointer-invisible' is set. */)
4747 return decode_any_frame (frame
)->pointer_invisible
? Qnil
: Qt
;
4752 /***********************************************************************
4754 ***********************************************************************/
4756 #ifdef HAVE_WINDOW_SYSTEM
4758 # if (defined HAVE_NS \
4759 || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR)))
4761 free_monitors (struct MonitorInfo
*monitors
, int n_monitors
)
4764 for (i
= 0; i
< n_monitors
; ++i
)
4765 xfree (monitors
[i
].name
);
4771 make_monitor_attribute_list (struct MonitorInfo
*monitors
,
4773 int primary_monitor
,
4774 Lisp_Object monitor_frames
,
4777 Lisp_Object attributes_list
= Qnil
;
4778 Lisp_Object primary_monitor_attributes
= Qnil
;
4781 for (i
= 0; i
< n_monitors
; ++i
)
4783 Lisp_Object geometry
, workarea
, attributes
= Qnil
;
4784 struct MonitorInfo
*mi
= &monitors
[i
];
4786 if (mi
->geom
.width
== 0) continue;
4788 workarea
= list4i (mi
->work
.x
, mi
->work
.y
,
4789 mi
->work
.width
, mi
->work
.height
);
4790 geometry
= list4i (mi
->geom
.x
, mi
->geom
.y
,
4791 mi
->geom
.width
, mi
->geom
.height
);
4792 attributes
= Fcons (Fcons (Qsource
, build_string (source
)),
4794 attributes
= Fcons (Fcons (Qframes
, AREF (monitor_frames
, i
)),
4796 attributes
= Fcons (Fcons (Qmm_size
,
4797 list2i (mi
->mm_width
, mi
->mm_height
)),
4799 attributes
= Fcons (Fcons (Qworkarea
, workarea
), attributes
);
4800 attributes
= Fcons (Fcons (Qgeometry
, geometry
), attributes
);
4802 attributes
= Fcons (Fcons (Qname
, make_string (mi
->name
,
4803 strlen (mi
->name
))),
4806 if (i
== primary_monitor
)
4807 primary_monitor_attributes
= attributes
;
4809 attributes_list
= Fcons (attributes
, attributes_list
);
4812 if (!NILP (primary_monitor_attributes
))
4813 attributes_list
= Fcons (primary_monitor_attributes
, attributes_list
);
4814 return attributes_list
;
4817 #endif /* HAVE_WINDOW_SYSTEM */
4820 /***********************************************************************
4822 ***********************************************************************/
4825 syms_of_frame (void)
4827 DEFSYM (Qframep
, "framep");
4828 DEFSYM (Qframe_live_p
, "frame-live-p");
4829 DEFSYM (Qframe_windows_min_size
, "frame-windows-min-size");
4830 DEFSYM (Qexplicit_name
, "explicit-name");
4831 DEFSYM (Qheight
, "height");
4832 DEFSYM (Qicon
, "icon");
4833 DEFSYM (Qminibuffer
, "minibuffer");
4834 DEFSYM (Qmodeline
, "modeline");
4835 DEFSYM (Qonly
, "only");
4836 DEFSYM (Qnone
, "none");
4837 DEFSYM (Qwidth
, "width");
4838 DEFSYM (Qgeometry
, "geometry");
4839 DEFSYM (Qicon_left
, "icon-left");
4840 DEFSYM (Qicon_top
, "icon-top");
4841 DEFSYM (Qtooltip
, "tooltip");
4842 DEFSYM (Quser_position
, "user-position");
4843 DEFSYM (Quser_size
, "user-size");
4844 DEFSYM (Qwindow_id
, "window-id");
4845 #ifdef HAVE_X_WINDOWS
4846 DEFSYM (Qouter_window_id
, "outer-window-id");
4848 DEFSYM (Qparent_id
, "parent-id");
4850 DEFSYM (Qw32
, "w32");
4853 DEFSYM (Qvisible
, "visible");
4854 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4855 DEFSYM (Qbuffer_list
, "buffer-list");
4856 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4857 DEFSYM (Qdisplay_type
, "display-type");
4858 DEFSYM (Qbackground_mode
, "background-mode");
4859 DEFSYM (Qnoelisp
, "noelisp");
4860 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4861 DEFSYM (Qtty
, "tty");
4862 DEFSYM (Qtty_type
, "tty-type");
4864 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4866 DEFSYM (Qfullwidth
, "fullwidth");
4867 DEFSYM (Qfullheight
, "fullheight");
4868 DEFSYM (Qfullboth
, "fullboth");
4869 DEFSYM (Qmaximized
, "maximized");
4870 DEFSYM (Qx_resource_name
, "x-resource-name");
4871 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4873 DEFSYM (Qterminal
, "terminal");
4875 DEFSYM (Qworkarea
, "workarea");
4876 DEFSYM (Qmm_size
, "mm-size");
4877 DEFSYM (Qframes
, "frames");
4878 DEFSYM (Qsource
, "source");
4880 DEFSYM (Qframe_position
, "frame-position");
4881 DEFSYM (Qframe_outer_size
, "frame-outer-size");
4882 DEFSYM (Qexternal_border_size
, "external-border-size");
4883 DEFSYM (Qtitle_height
, "title-height");
4884 DEFSYM (Qmenu_bar_external
, "menu-bar-external");
4885 DEFSYM (Qmenu_bar_size
, "menu-bar-size");
4886 DEFSYM (Qtool_bar_external
, "tool-bar-external");
4887 DEFSYM (Qtool_bar_size
, "tool-bar-size");
4888 DEFSYM (Qframe_inner_size
, "frame-inner-size");
4889 /* The following are used for frame_size_history. */
4890 DEFSYM (Qadjust_frame_size_1
, "adjust-frame-size-1");
4891 DEFSYM (Qadjust_frame_size_2
, "adjust-frame-size-2");
4892 DEFSYM (Qadjust_frame_size_3
, "adjust-frame-size-3");
4893 DEFSYM (QEmacsFrameResize
, "EmacsFrameResize");
4894 DEFSYM (Qframe_inhibit_resize
, "frame-inhibit-resize");
4895 DEFSYM (Qx_set_fullscreen
, "x-set-fullscreen");
4896 DEFSYM (Qx_check_fullscreen
, "x-check-fullscreen");
4897 DEFSYM (Qx_set_window_size_1
, "x-set-window-size-1");
4898 DEFSYM (Qxg_frame_resized
, "xg-frame-resized");
4899 DEFSYM (Qxg_frame_set_char_size_1
, "xg-frame-set-char-size-1");
4900 DEFSYM (Qxg_frame_set_char_size_2
, "xg-frame-set-char-size-2");
4901 DEFSYM (Qxg_frame_set_char_size_3
, "xg-frame-set-char-size-3");
4902 DEFSYM (Qxg_change_toolbar_position
, "xg-change-toolbar-position");
4903 DEFSYM (Qx_net_wm_state
, "x-net-wm-state");
4904 DEFSYM (Qx_handle_net_wm_state
, "x-handle-net-wm-state");
4905 DEFSYM (Qtb_size_cb
, "tb-size-cb");
4906 DEFSYM (Qupdate_frame_tool_bar
, "update-frame-tool-bar");
4907 DEFSYM (Qfree_frame_tool_bar
, "free-frame-tool-bar");
4909 DEFSYM (Qchange_frame_size
, "change-frame-size");
4910 DEFSYM (Qxg_frame_set_char_size
, "xg-frame-set-char-size");
4911 DEFSYM (Qset_window_configuration
, "set-window-configuration");
4912 DEFSYM (Qx_create_frame_1
, "x-create-frame-1");
4913 DEFSYM (Qx_create_frame_2
, "x-create-frame-2");
4914 DEFSYM (Qtip_frame
, "tip-frame");
4915 DEFSYM (Qterminal_frame
, "terminal-frame");
4918 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4921 DEFSYM (Qalpha
, "alpha");
4922 DEFSYM (Qauto_lower
, "auto-lower");
4923 DEFSYM (Qauto_raise
, "auto-raise");
4924 DEFSYM (Qborder_color
, "border-color");
4925 DEFSYM (Qborder_width
, "border-width");
4926 DEFSYM (Qbottom_divider_width
, "bottom-divider-width");
4927 DEFSYM (Qcursor_color
, "cursor-color");
4928 DEFSYM (Qcursor_type
, "cursor-type");
4929 DEFSYM (Qfont_backend
, "font-backend");
4930 DEFSYM (Qfullscreen
, "fullscreen");
4931 DEFSYM (Qhorizontal_scroll_bars
, "horizontal-scroll-bars");
4932 DEFSYM (Qicon_name
, "icon-name");
4933 DEFSYM (Qicon_type
, "icon-type");
4934 DEFSYM (Qinternal_border_width
, "internal-border-width");
4935 DEFSYM (Qleft_fringe
, "left-fringe");
4936 DEFSYM (Qline_spacing
, "line-spacing");
4937 DEFSYM (Qmenu_bar_lines
, "menu-bar-lines");
4938 DEFSYM (Qmouse_color
, "mouse-color");
4939 DEFSYM (Qname
, "name");
4940 DEFSYM (Qright_divider_width
, "right-divider-width");
4941 DEFSYM (Qright_fringe
, "right-fringe");
4942 DEFSYM (Qscreen_gamma
, "screen-gamma");
4943 DEFSYM (Qscroll_bar_background
, "scroll-bar-background");
4944 DEFSYM (Qscroll_bar_foreground
, "scroll-bar-foreground");
4945 DEFSYM (Qscroll_bar_height
, "scroll-bar-height");
4946 DEFSYM (Qscroll_bar_width
, "scroll-bar-width");
4947 DEFSYM (Qsticky
, "sticky");
4948 DEFSYM (Qtitle
, "title");
4949 DEFSYM (Qtool_bar_lines
, "tool-bar-lines");
4950 DEFSYM (Qtool_bar_position
, "tool-bar-position");
4951 DEFSYM (Qunsplittable
, "unsplittable");
4952 DEFSYM (Qvertical_scroll_bars
, "vertical-scroll-bars");
4953 DEFSYM (Qvisibility
, "visibility");
4954 DEFSYM (Qwait_for_wm
, "wait-for-wm");
4959 for (i
= 0; i
< ARRAYELTS (frame_parms
); i
++)
4961 Lisp_Object v
= (frame_parms
[i
].sym
< 0
4962 ? intern_c_string (frame_parms
[i
].name
)
4963 : builtin_lisp_symbol (frame_parms
[i
].sym
));
4964 Fput (v
, Qx_frame_parameter
, make_number (i
));
4968 #ifdef HAVE_WINDOW_SYSTEM
4969 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4970 doc
: /* The name Emacs uses to look up X resources.
4971 `x-get-resource' uses this as the first component of the instance name
4972 when requesting resource values.
4973 Emacs initially sets `x-resource-name' to the name under which Emacs
4974 was invoked, or to the value specified with the `-name' or `-rn'
4975 switches, if present.
4977 It may be useful to bind this variable locally around a call
4978 to `x-get-resource'. See also the variable `x-resource-class'. */);
4979 Vx_resource_name
= Qnil
;
4981 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4982 doc
: /* The class Emacs uses to look up X resources.
4983 `x-get-resource' uses this as the first component of the instance class
4984 when requesting resource values.
4986 Emacs initially sets `x-resource-class' to "Emacs".
4988 Setting this variable permanently is not a reasonable thing to do,
4989 but binding this variable locally around a call to `x-get-resource'
4990 is a reasonable practice. See also the variable `x-resource-name'. */);
4991 Vx_resource_class
= build_string (EMACS_CLASS
);
4993 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4994 doc
: /* The lower limit of the frame opacity (alpha transparency).
4995 The value should range from 0 (invisible) to 100 (completely opaque).
4996 You can also use a floating number between 0.0 and 1.0. */);
4997 Vframe_alpha_lower_limit
= make_number (20);
5000 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
5001 doc
: /* Alist of default values for frame creation.
5002 These may be set in your init file, like this:
5003 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
5004 These override values given in window system configuration data,
5005 including X Windows' defaults database.
5006 For values specific to the first Emacs frame, see `initial-frame-alist'.
5007 For window-system specific values, see `window-system-default-frame-alist'.
5008 For values specific to the separate minibuffer frame, see
5009 `minibuffer-frame-alist'.
5010 The `menu-bar-lines' element of the list controls whether new frames
5011 have menu bars; `menu-bar-mode' works by altering this element.
5012 Setting this variable does not affect existing frames, only new ones. */);
5013 Vdefault_frame_alist
= Qnil
;
5015 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
5016 doc
: /* Default position of vertical scroll bars on this window-system. */);
5017 #ifdef HAVE_WINDOW_SYSTEM
5018 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
5019 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
5021 Vdefault_frame_scroll_bars
= Qright
;
5023 Vdefault_frame_scroll_bars
= Qleft
;
5026 Vdefault_frame_scroll_bars
= Qnil
;
5029 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
5030 scroll_bar_adjust_thumb_portion_p
,
5031 doc
: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
5032 Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
5033 even if the end of the buffer is shown (i.e. overscrolling).
5034 Set to nil if you want the thumb to be at the bottom when the end of the buffer
5035 is shown. Also, the thumb fills the whole scroll bar when the entire buffer
5036 is visible. In this case you can not overscroll. */);
5037 scroll_bar_adjust_thumb_portion_p
= 1;
5039 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
5040 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
5042 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
5043 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
5044 `mouse-position' and `mouse-pixel-position' call this function, passing their
5045 usual return value as argument, and return whatever this function returns.
5046 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
5047 which need to do mouse handling at the Lisp level. */);
5048 Vmouse_position_function
= Qnil
;
5050 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
5051 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
5052 If the value is an integer, highlighting is only shown after moving the
5053 mouse, while keyboard input turns off the highlight even when the mouse
5054 is over the clickable text. However, the mouse shape still indicates
5055 when the mouse is over clickable text. */);
5056 Vmouse_highlight
= Qt
;
5058 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
5059 doc
: /* If non-nil, make pointer invisible while typing.
5060 The pointer becomes visible again when the mouse is moved. */);
5061 Vmake_pointer_invisible
= Qt
;
5063 DEFVAR_LISP ("focus-in-hook", Vfocus_in_hook
,
5064 doc
: /* Normal hook run when a frame gains input focus. */);
5065 Vfocus_in_hook
= Qnil
;
5066 DEFSYM (Qfocus_in_hook
, "focus-in-hook");
5068 DEFVAR_LISP ("focus-out-hook", Vfocus_out_hook
,
5069 doc
: /* Normal hook run when a frame loses input focus. */);
5070 Vfocus_out_hook
= Qnil
;
5071 DEFSYM (Qfocus_out_hook
, "focus-out-hook");
5073 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
5074 doc
: /* Functions run before deleting a frame.
5075 The functions are run with one arg, the frame to be deleted.
5078 Note that functions in this list may be called just before the frame is
5079 actually deleted, or some time later (or even both when an earlier function
5080 in `delete-frame-functions' (indirectly) calls `delete-frame'
5082 Vdelete_frame_functions
= Qnil
;
5083 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
5085 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
5086 doc
: /* Non-nil if Menu-Bar mode is enabled.
5087 See the command `menu-bar-mode' for a description of this minor mode.
5088 Setting this variable directly does not take effect;
5089 either customize it (see the info node `Easy Customization')
5090 or call the function `menu-bar-mode'. */);
5091 Vmenu_bar_mode
= Qt
;
5093 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
5094 doc
: /* Non-nil if Tool-Bar mode is enabled.
5095 See the command `tool-bar-mode' for a description of this minor mode.
5096 Setting this variable directly does not take effect;
5097 either customize it (see the info node `Easy Customization')
5098 or call the function `tool-bar-mode'. */);
5099 #ifdef HAVE_WINDOW_SYSTEM
5100 Vtool_bar_mode
= Qt
;
5102 Vtool_bar_mode
= Qnil
;
5105 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
5106 doc
: /* Minibufferless frames use this frame's minibuffer.
5107 Emacs cannot create minibufferless frames unless this is set to an
5108 appropriate surrogate.
5110 Emacs consults this variable only when creating minibufferless
5111 frames; once the frame is created, it sticks with its assigned
5112 minibuffer, no matter what this variable is set to. This means that
5113 this variable doesn't necessarily say anything meaningful about the
5114 current set of frames, or where the minibuffer is currently being
5117 This variable is local to the current terminal and cannot be buffer-local. */);
5119 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
5120 doc
: /* Non-nil if window system changes focus when you move the mouse.
5121 You should set this variable to tell Emacs how your window manager
5122 handles focus, since there is no way in general for Emacs to find out
5123 automatically. See also `mouse-autoselect-window'. */);
5124 focus_follows_mouse
= 0;
5126 DEFVAR_BOOL ("frame-resize-pixelwise", frame_resize_pixelwise
,
5127 doc
: /* Non-nil means resize frames pixelwise.
5128 If this option is nil, resizing a frame rounds its sizes to the frame's
5129 current values of `frame-char-height' and `frame-char-width'. If this
5130 is non-nil, no rounding occurs, hence frame sizes can increase/decrease
5133 With some window managers you may have to set this to non-nil in order
5134 to set the size of a frame in pixels, to maximize frames or to make them
5135 fullscreen. To resize your initial frame pixelwise, set this option to
5136 a non-nil value in your init file. */);
5137 frame_resize_pixelwise
= 0;
5139 DEFVAR_LISP ("frame-inhibit-implied-resize", frame_inhibit_implied_resize
,
5140 doc
: /* Whether frames should be resized implicitly.
5141 If this option is nil, setting font, menu bar, tool bar, internal
5142 borders, fringes or scroll bars of a specific frame may resize the frame
5143 in order to preserve the number of columns or lines it displays. If
5144 this option is `t', no such resizing is done. Note that the size of
5145 fullscreen and maximized frames, the height of fullheight frames and the
5146 width of fullwidth frames never change implicitly.
5148 The value of this option can be also be a list of frame parameters. In
5149 this case, resizing is inhibited when changing a parameter that appears
5150 in that list. The parameters currently handled by this option include
5151 `font', `font-backend', `internal-border-width', `menu-bar-lines' and
5154 Changing any of the parameters `scroll-bar-width', `scroll-bar-height',
5155 `vertical-scroll-bars', `horizontal-scroll-bars', `left-fringe' and
5156 `right-fringe' is handled as if the frame contained just one live
5157 window. This means, for example, that removing vertical scroll bars on
5158 a frame containing several side by side windows will shrink the frame
5159 width by the width of one scroll bar provided this option is nil and
5160 keep it unchanged if this option is either `t' or a list containing
5161 `vertical-scroll-bars'.
5163 The default value is '(tool-bar-lines) on Lucid, Motif and Windows
5164 \(which means that adding/removing a tool bar does not change the frame
5165 height), nil on all other window systems including GTK+ (which means
5166 that changing any of the parameters listed above may change the size of
5167 the frame), and `t' otherwise (which means the frame size never changes
5168 implicitly when there's no window system support).
5170 Note that when a frame is not large enough to accommodate a change of
5171 any of the parameters listed above, Emacs may try to enlarge the frame
5172 even if this option is non-nil. */);
5173 #if defined (HAVE_WINDOW_SYSTEM)
5174 #if defined (USE_LUCID) || defined (USE_MOTIF) || defined (HAVE_NTGUI)
5175 frame_inhibit_implied_resize
= list1 (Qtool_bar_lines
);
5177 frame_inhibit_implied_resize
= Qnil
;
5180 frame_inhibit_implied_resize
= Qt
;
5183 DEFVAR_LISP ("frame-size-history", frame_size_history
,
5184 doc
: /* History of frame size adjustments.
5185 If non-nil, list recording frame size adjustment. Adjustments are
5186 recorded only if the first element of this list is a positive number.
5187 Adding an adjustment decrements that number by one.
5189 The remaining elements are the adjustments. Each adjustment is a list
5190 of four elements `frame', `function', `sizes' and `more'. `frame' is
5191 the affected frame and `function' the invoking function. `sizes' is
5192 usually a list of four elements `old-width', `old-height', `new-width'
5193 and `new-height' representing the old and new sizes recorded/requested
5194 by `function'. `more' is a list with additional information.
5196 The function `frame--size-history' displays the value of this variable
5197 in a more readable form. */);
5198 frame_size_history
= Qnil
;
5200 staticpro (&Vframe_list
);
5203 defsubr (&Sframe_live_p
);
5204 defsubr (&Swindow_system
);
5205 defsubr (&Sframe_windows_min_size
);
5206 defsubr (&Smake_terminal_frame
);
5207 defsubr (&Shandle_switch_frame
);
5208 defsubr (&Sselect_frame
);
5209 defsubr (&Sselected_frame
);
5210 defsubr (&Sframe_list
);
5211 defsubr (&Snext_frame
);
5212 defsubr (&Sprevious_frame
);
5213 defsubr (&Slast_nonminibuf_frame
);
5214 defsubr (&Sdelete_frame
);
5215 defsubr (&Smouse_position
);
5216 defsubr (&Smouse_pixel_position
);
5217 defsubr (&Sset_mouse_position
);
5218 defsubr (&Sset_mouse_pixel_position
);
5220 defsubr (&Sframe_configuration
);
5221 defsubr (&Srestore_frame_configuration
);
5223 defsubr (&Smake_frame_visible
);
5224 defsubr (&Smake_frame_invisible
);
5225 defsubr (&Siconify_frame
);
5226 defsubr (&Sframe_visible_p
);
5227 defsubr (&Svisible_frame_list
);
5228 defsubr (&Sraise_frame
);
5229 defsubr (&Slower_frame
);
5230 defsubr (&Sx_focus_frame
);
5231 defsubr (&Sframe_after_make_frame
);
5232 defsubr (&Sredirect_frame_focus
);
5233 defsubr (&Sframe_focus
);
5234 defsubr (&Sframe_parameters
);
5235 defsubr (&Sframe_parameter
);
5236 defsubr (&Smodify_frame_parameters
);
5237 defsubr (&Sframe_char_height
);
5238 defsubr (&Sframe_char_width
);
5239 defsubr (&Sframe_pixel_height
);
5240 defsubr (&Sframe_pixel_width
);
5241 defsubr (&Sframe_text_cols
);
5242 defsubr (&Sframe_text_lines
);
5243 defsubr (&Sframe_total_cols
);
5244 defsubr (&Sframe_total_lines
);
5245 defsubr (&Sframe_text_width
);
5246 defsubr (&Sframe_text_height
);
5247 defsubr (&Sscroll_bar_width
);
5248 defsubr (&Sscroll_bar_height
);
5249 defsubr (&Sfringe_width
);
5250 defsubr (&Sborder_width
);
5251 defsubr (&Sright_divider_width
);
5252 defsubr (&Sbottom_divider_width
);
5253 defsubr (&Stool_bar_pixel_width
);
5254 defsubr (&Sset_frame_height
);
5255 defsubr (&Sset_frame_width
);
5256 defsubr (&Sset_frame_size
);
5257 defsubr (&Sset_frame_position
);
5258 defsubr (&Sframe_pointer_visible_p
);
5260 #ifdef HAVE_WINDOW_SYSTEM
5261 defsubr (&Sx_get_resource
);
5262 defsubr (&Sx_parse_geometry
);