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
)
159 XSETFRAME (frame
, f
);
160 if (CONSP (frame_size_history
)
161 && INTEGERP (XCAR (frame_size_history
))
162 && 0 < XINT (XCAR (frame_size_history
)))
164 Fcons (make_number (XINT (XCAR (frame_size_history
)) - 1),
168 ? list4 (make_number (FRAME_TEXT_WIDTH (f
)),
169 make_number (FRAME_TEXT_HEIGHT (f
)),
171 make_number (height
))
174 XCDR (frame_size_history
)));
178 /* Return 1 if `frame-inhibit-implied-resize' is non-nil or fullscreen
179 state of frame F would be affected by a vertical (horizontal if
180 HORIZONTAL is true) resize. PARAMETER is the symbol of the frame
181 parameter that is changed. */
183 frame_inhibit_resize (struct frame
*f
, bool horizontal
, Lisp_Object parameter
)
185 Lisp_Object fullscreen
= get_frame_param (f
, Qfullscreen
);
187 = ((f
->after_make_frame
188 && (EQ (frame_inhibit_implied_resize
, Qt
)
189 || (CONSP (frame_inhibit_implied_resize
)
190 && !NILP (Fmemq (parameter
, frame_inhibit_implied_resize
)))))
192 && !EQ (fullscreen
, Qnil
) && !EQ (fullscreen
, Qfullheight
))
194 && !EQ (fullscreen
, Qnil
) && !EQ (fullscreen
, Qfullwidth
))
195 || FRAME_TERMCAP_P (f
) || FRAME_MSDOS_P (f
));
197 if (inhibit
&& !FRAME_TERMCAP_P (f
) && !FRAME_MSDOS_P (f
))
198 frame_size_history_add
199 (f
, Qframe_inhibit_resize
, 0, 0,
200 list5 (horizontal
? Qt
: Qnil
, parameter
,
201 f
->after_make_frame
? Qt
: Qnil
,
202 frame_inhibit_implied_resize
,
209 set_menu_bar_lines (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
212 int olines
= FRAME_MENU_BAR_LINES (f
);
214 /* Right now, menu bars don't work properly in minibuf-only frames;
215 most of the commands try to apply themselves to the minibuffer
216 frame itself, and get an error because you can't switch buffers
217 in or split the minibuffer window. */
218 if (FRAME_MINIBUF_ONLY_P (f
))
221 if (TYPE_RANGED_INTEGERP (int, value
))
222 nlines
= XINT (value
);
226 if (nlines
!= olines
)
228 windows_or_buffers_changed
= 14;
229 FRAME_MENU_BAR_LINES (f
) = nlines
;
230 FRAME_MENU_BAR_HEIGHT (f
) = nlines
* FRAME_LINE_HEIGHT (f
);
231 change_frame_size (f
, FRAME_COLS (f
),
232 FRAME_LINES (f
) + olines
- nlines
,
237 Lisp_Object Vframe_list
;
240 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
241 doc
: /* Return non-nil if OBJECT is a frame.
243 t for a termcap frame (a character-only terminal),
244 'x' for an Emacs frame that is really an X window,
245 'w32' for an Emacs frame that is a window on MS-Windows display,
246 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
247 'pc' for a direct-write MS-DOS frame.
248 See also `frame-live-p'. */)
251 if (!FRAMEP (object
))
253 switch (XFRAME (object
)->output_method
)
255 case output_initial
: /* The initial frame is like a termcap frame. */
258 case output_x_window
:
262 case output_msdos_raw
:
271 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
272 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
273 Value is nil if OBJECT is not a live frame. If object is a live
274 frame, the return value indicates what sort of terminal device it is
275 displayed on. See the documentation of `framep' for possible
279 return ((FRAMEP (object
)
280 && FRAME_LIVE_P (XFRAME (object
)))
285 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
286 doc
: /* The name of the window system that FRAME is displaying through.
287 The value is a symbol:
288 nil for a termcap frame (a character-only terminal),
289 'x' for an Emacs frame that is really an X window,
290 'w32' for an Emacs frame that is a window on MS-Windows display,
291 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
292 'pc' for a direct-write MS-DOS frame.
294 FRAME defaults to the currently selected frame.
296 Use of this function as a predicate is deprecated. Instead,
297 use `display-graphic-p' or any of the other `display-*-p'
298 predicates which report frame's specific UI-related capabilities. */)
303 frame
= selected_frame
;
305 type
= Fframep (frame
);
308 wrong_type_argument (Qframep
, frame
);
316 /* Placeholder used by temacs -nw before window.el is loaded. */
317 DEFUN ("frame-windows-min-size", Fframe_windows_min_size
,
318 Sframe_windows_min_size
, 4, 4, 0,
321 (Lisp_Object frame
, Lisp_Object horizontal
,
322 Lisp_Object ignore
, Lisp_Object pixelwise
)
324 return make_number (0);
328 frame_windows_min_size (Lisp_Object frame
, Lisp_Object horizontal
,
329 Lisp_Object ignore
, Lisp_Object pixelwise
)
331 return XINT (call4 (Qframe_windows_min_size
, frame
, horizontal
,
336 /* Make sure windows sizes of frame F are OK. new_width and new_height
337 are in pixels. A value of -1 means no change is requested for that
338 size (but the frame may still have to be resized to accommodate
339 windows with their minimum sizes). This can either issue a request
340 to resize the frame externally (via x_set_window_size), to resize the
341 frame internally (via resize_frame_windows) or do nothing at all.
343 The argument INHIBIT can assume the following values:
345 0 means to unconditionally call x_set_window_size even if sizes
346 apparently do not change. Fx_create_frame uses this to pass the
347 initial size to the window manager.
349 1 means to call x_set_window_size if the outer frame size really
350 changes. Fset_frame_size, Fset_frame_height, ... use this.
352 2 means to call x_set_window_size provided frame_inhibit_resize
353 allows it. The menu and tool bar code use this ("3" won't work
354 here in general because menu and tool bar are often not counted in
355 the frame's text height).
357 3 means call x_set_window_size if window minimum sizes must be
358 preserved or frame_inhibit_resize allows it. x_set_left_fringe,
359 x_set_scroll_bar_width, x_new_font ... use (or should use) this.
361 4 means call x_set_window_size only if window minimum sizes must be
362 preserved. x_set_right_divider_width, x_set_border_width and the
363 code responsible for wrapping the tool bar use this.
365 5 means to never call x_set_window_size. change_frame_size uses
368 Note that even when x_set_window_size is not called, individual
369 windows may have to be resized (via `window--sanitize-window-sizes')
370 in order to support minimum size constraints.
372 PRETEND is as for change_frame_size. PARAMETER, if non-nil, is the
373 symbol of the parameter changed (like `menu-bar-lines', `font', ...).
374 This is passed on to frame_inhibit_resize to let the latter decide on
375 a case-by-case basis whether the frame may be resized externally. */
377 adjust_frame_size (struct frame
*f
, int new_width
, int new_height
, int inhibit
,
378 bool pretend
, Lisp_Object parameter
)
380 int unit_width
= FRAME_COLUMN_WIDTH (f
);
381 int unit_height
= FRAME_LINE_HEIGHT (f
);
382 int old_pixel_width
= FRAME_PIXEL_WIDTH (f
);
383 int old_pixel_height
= FRAME_PIXEL_HEIGHT (f
);
384 int old_cols
= FRAME_COLS (f
);
385 int old_lines
= FRAME_LINES (f
);
386 int new_pixel_width
, new_pixel_height
;
387 /* The following two values are calculated from the old frame pixel
388 sizes and any "new" settings for tool bar, menu bar and internal
389 borders. We do it this way to detect whether we have to call
390 x_set_window_size as consequence of the new settings. */
391 int windows_width
= FRAME_WINDOWS_WIDTH (f
);
392 int windows_height
= FRAME_WINDOWS_HEIGHT (f
);
393 int min_windows_width
, min_windows_height
;
394 /* These are a bit tedious, maybe we should use a macro. */
395 struct window
*r
= XWINDOW (FRAME_ROOT_WINDOW (f
));
396 int old_windows_width
= WINDOW_PIXEL_WIDTH (r
);
397 int old_windows_height
398 = (WINDOW_PIXEL_HEIGHT (r
)
399 + (FRAME_HAS_MINIBUF_P (f
)
400 ? WINDOW_PIXEL_HEIGHT (XWINDOW (FRAME_MINIBUF_WINDOW (f
)))
402 int new_windows_width
, new_windows_height
;
403 int old_text_width
= FRAME_TEXT_WIDTH (f
);
404 int old_text_height
= FRAME_TEXT_HEIGHT (f
);
405 /* If a size is < 0 use the old value. */
406 int new_text_width
= (new_width
>= 0) ? new_width
: old_text_width
;
407 int new_text_height
= (new_height
>= 0) ? new_height
: old_text_height
;
408 int new_cols
, new_lines
;
409 bool inhibit_horizontal
, inhibit_vertical
;
412 XSETFRAME (frame
, f
);
414 frame_size_history_add
415 (f
, Qadjust_frame_size_1
, new_text_width
, new_text_height
,
416 list2 (parameter
, make_number (inhibit
)));
418 /* The following two values are calculated from the old window body
419 sizes and any "new" settings for scroll bars, dividers, fringes and
420 margins (though the latter should have been processed already). */
422 = frame_windows_min_size (frame
, Qt
, (inhibit
== 5) ? Qt
: Qnil
, Qt
);
424 = frame_windows_min_size (frame
, Qnil
, (inhibit
== 5) ? Qt
: Qnil
, Qt
);
426 if (inhibit
>= 2 && inhibit
<= 4)
427 /* When INHIBIT is in [2..4] inhibit if the "old" window sizes stay
428 within the limits and either frame_inhibit_resize tells us to do
429 so or INHIBIT equals 4. */
431 inhibit_horizontal
= ((windows_width
>= min_windows_width
433 || frame_inhibit_resize (f
, true, parameter
)))
435 inhibit_vertical
= ((windows_height
>= min_windows_height
437 || frame_inhibit_resize (f
, false, parameter
)))
441 /* Otherwise inhibit if INHIBIT equals 5. */
442 inhibit_horizontal
= inhibit_vertical
= inhibit
== 5;
444 new_pixel_width
= ((inhibit_horizontal
&& (inhibit
< 5))
446 : max (FRAME_TEXT_TO_PIXEL_WIDTH (f
, new_text_width
),
448 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
449 new_windows_width
= new_pixel_width
- 2 * FRAME_INTERNAL_BORDER_WIDTH (f
);
450 new_text_width
= FRAME_PIXEL_TO_TEXT_WIDTH (f
, new_pixel_width
);
451 new_cols
= new_text_width
/ unit_width
;
453 new_pixel_height
= ((inhibit_vertical
&& (inhibit
< 5))
455 : max (FRAME_TEXT_TO_PIXEL_HEIGHT (f
, new_text_height
),
457 + FRAME_TOP_MARGIN_HEIGHT (f
)
458 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f
)));
459 new_windows_height
= (new_pixel_height
460 - FRAME_TOP_MARGIN_HEIGHT (f
)
461 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f
));
462 new_text_height
= FRAME_PIXEL_TO_TEXT_HEIGHT (f
, new_pixel_height
);
463 new_lines
= new_text_height
/ unit_height
;
465 #ifdef HAVE_WINDOW_SYSTEM
466 if (FRAME_WINDOW_P (f
)
467 && f
->can_x_set_window_size
468 && ((!inhibit_horizontal
469 && (new_pixel_width
!= old_pixel_width
470 || inhibit
== 0 || inhibit
== 2))
471 || (!inhibit_vertical
472 && (new_pixel_height
!= old_pixel_height
473 || inhibit
== 0 || inhibit
== 2))))
474 /* We are either allowed to change the frame size or the minimum
475 sizes request such a change. Do not care for fixing minimum
476 sizes here, we do that eventually when we're called from
477 change_frame_size. */
479 /* Make sure we respect fullheight and fullwidth. */
480 if (inhibit_horizontal
)
481 new_text_width
= old_text_width
;
482 else if (inhibit_vertical
)
483 new_text_height
= old_text_height
;
485 frame_size_history_add
486 (f
, Qadjust_frame_size_2
, new_text_width
, new_text_height
,
487 list2 (inhibit_horizontal
? Qt
: Qnil
,
488 inhibit_vertical
? Qt
: Qnil
));
490 x_set_window_size (f
, 0, new_text_width
, new_text_height
, 1);
497 if (new_text_width
== old_text_width
498 && new_text_height
== old_text_height
499 && new_windows_width
== old_windows_width
500 && new_windows_height
== old_windows_height
501 && new_pixel_width
== old_pixel_width
502 && new_pixel_height
== old_pixel_height
503 && new_cols
== old_cols
504 && new_lines
== old_lines
)
505 /* No change. Sanitize window sizes and return. */
507 sanitize_window_sizes (frame
, Qt
);
508 sanitize_window_sizes (frame
, Qnil
);
516 /* We only can set screen dimensions to certain values supported
517 by our video hardware. Try to find the smallest size greater
518 or equal to the requested dimensions. */
519 dos_set_window_size (&new_lines
, &new_cols
);
522 if (new_windows_width
!= old_windows_width
)
524 resize_frame_windows (f
, new_windows_width
, 1, 1);
526 /* MSDOS frames cannot PRETEND, as they change frame size by
527 manipulating video hardware. */
528 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
529 FrameCols (FRAME_TTY (f
)) = new_cols
;
531 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
532 if (WINDOWP (f
->tool_bar_window
))
534 XWINDOW (f
->tool_bar_window
)->pixel_width
= new_windows_width
;
535 XWINDOW (f
->tool_bar_window
)->total_cols
536 = new_windows_width
/ unit_width
;
541 if (new_windows_height
!= old_windows_height
542 /* When the top margin has changed we have to recalculate the top
543 edges of all windows. No such calculation is necessary for the
545 || WINDOW_TOP_PIXEL_EDGE (r
) != FRAME_TOP_MARGIN_HEIGHT (f
))
547 resize_frame_windows (f
, new_windows_height
, 0, 1);
549 /* MSDOS frames cannot PRETEND, as they change frame size by
550 manipulating video hardware. */
551 if ((FRAME_TERMCAP_P (f
) && !pretend
) || FRAME_MSDOS_P (f
))
552 FrameRows (FRAME_TTY (f
)) = new_lines
+ FRAME_TOP_MARGIN (f
);
555 frame_size_history_add
556 (f
, Qadjust_frame_size_3
, new_text_width
, new_text_height
,
557 list4 (make_number (old_pixel_width
), make_number (old_pixel_height
),
558 make_number (new_pixel_width
), make_number (new_pixel_height
)));
560 /* Assign new sizes. */
561 FRAME_TEXT_WIDTH (f
) = new_text_width
;
562 FRAME_TEXT_HEIGHT (f
) = new_text_height
;
563 FRAME_PIXEL_WIDTH (f
) = new_pixel_width
;
564 FRAME_PIXEL_HEIGHT (f
) = new_pixel_height
;
565 SET_FRAME_COLS (f
, new_cols
);
566 SET_FRAME_LINES (f
, new_lines
);
569 struct window
*w
= XWINDOW (FRAME_SELECTED_WINDOW (f
));
570 int text_area_x
, text_area_y
, text_area_width
, text_area_height
;
572 window_box (w
, TEXT_AREA
, &text_area_x
, &text_area_y
, &text_area_width
,
574 if (w
->cursor
.x
>= text_area_x
+ text_area_width
)
575 w
->cursor
.hpos
= w
->cursor
.x
= 0;
576 if (w
->cursor
.y
>= text_area_y
+ text_area_height
)
577 w
->cursor
.vpos
= w
->cursor
.y
= 0;
580 /* Sanitize window sizes. */
581 sanitize_window_sizes (frame
, Qt
);
582 sanitize_window_sizes (frame
, Qnil
);
584 adjust_frame_glyphs (f
);
586 SET_FRAME_GARBAGED (f
);
588 /* A frame was "resized" if one of its pixelsizes changed, even if its
589 X window wasn't resized at all. */
590 f
->resized_p
= (new_pixel_width
!= old_pixel_width
591 || new_pixel_height
!= old_pixel_height
);
595 run_window_configuration_change_hook (f
);
598 /* Allocate basically initialized frame. */
600 static struct frame
*
601 allocate_frame (void)
603 return ALLOCATE_ZEROED_PSEUDOVECTOR (struct frame
, face_cache
, PVEC_FRAME
);
607 make_frame (bool mini_p
)
610 register struct frame
*f
;
611 register struct window
*rw
, *mw
;
612 register Lisp_Object root_window
;
613 register Lisp_Object mini_window
;
615 f
= allocate_frame ();
616 XSETFRAME (frame
, f
);
619 /* Initialize Lisp data. Note that allocate_frame initializes all
620 Lisp data to nil, so do it only for slots which should not be nil. */
621 fset_tool_bar_position (f
, Qtop
);
624 /* Initialize non-Lisp data. Note that allocate_frame zeroes out all
625 non-Lisp data, so do it only for slots which should not be zero.
626 To avoid subtle bugs and for the sake of readability, it's better to
627 initialize enum members explicitly even if their values are zero. */
628 f
->wants_modeline
= true;
631 f
->can_x_set_window_size
= false;
632 f
->after_make_frame
= false;
633 f
->tool_bar_redisplayed_once
= false;
634 f
->column_width
= 1; /* !FRAME_WINDOW_P value. */
635 f
->line_height
= 1; /* !FRAME_WINDOW_P value. */
636 #ifdef HAVE_WINDOW_SYSTEM
637 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
638 f
->horizontal_scroll_bars
= false;
639 f
->want_fullscreen
= FULLSCREEN_NONE
;
640 #if ! defined (USE_GTK) && ! defined (HAVE_NS)
641 f
->last_tool_bar_item
= -1;
645 root_window
= make_window ();
646 rw
= XWINDOW (root_window
);
649 mini_window
= make_window ();
650 mw
= XWINDOW (mini_window
);
651 wset_next (rw
, mini_window
);
652 wset_prev (mw
, root_window
);
654 wset_frame (mw
, frame
);
655 fset_minibuffer_window (f
, mini_window
);
660 wset_next (rw
, Qnil
);
661 fset_minibuffer_window (f
, Qnil
);
664 wset_frame (rw
, frame
);
667 just so that there is "something there."
668 Correct size will be set up later with adjust_frame_size. */
670 SET_FRAME_COLS (f
, 10);
671 SET_FRAME_LINES (f
, 10);
672 SET_FRAME_WIDTH (f
, FRAME_COLS (f
) * FRAME_COLUMN_WIDTH (f
));
673 SET_FRAME_HEIGHT (f
, FRAME_LINES (f
) * FRAME_LINE_HEIGHT (f
));
676 rw
->pixel_width
= rw
->total_cols
* FRAME_COLUMN_WIDTH (f
);
677 rw
->total_lines
= mini_p
? 9 : 10;
678 rw
->pixel_height
= rw
->total_lines
* FRAME_LINE_HEIGHT (f
);
682 mw
->top_line
= rw
->total_lines
;
683 mw
->pixel_top
= rw
->pixel_height
;
684 mw
->total_cols
= rw
->total_cols
;
685 mw
->pixel_width
= rw
->pixel_width
;
687 mw
->pixel_height
= FRAME_LINE_HEIGHT (f
);
690 /* Choose a buffer for the frame's root window. */
692 Lisp_Object buf
= Fcurrent_buffer ();
694 /* If current buffer is hidden, try to find another one. */
695 if (BUFFER_HIDDEN_P (XBUFFER (buf
)))
696 buf
= other_buffer_safely (buf
);
698 /* Use set_window_buffer, not Fset_window_buffer, and don't let
699 hooks be run by it. The reason is that the whole frame/window
700 arrangement is not yet fully initialized at this point. Windows
701 don't have the right size, glyph matrices aren't initialized
702 etc. Running Lisp functions at this point surely ends in a
704 set_window_buffer (root_window
, buf
, 0, 0);
705 fset_buffer_list (f
, list1 (buf
));
710 set_window_buffer (mini_window
,
711 (NILP (Vminibuffer_list
)
713 : Fcar (Vminibuffer_list
)),
715 /* No horizontal scroll bars in minibuffers. */
716 wset_horizontal_scroll_bar (mw
, Qnil
);
719 fset_root_window (f
, root_window
);
720 fset_selected_window (f
, root_window
);
721 /* Make sure this window seems more recently used than
722 a newly-created, never-selected window. */
723 XWINDOW (f
->selected_window
)->use_time
= ++window_select_count
;
728 #ifdef HAVE_WINDOW_SYSTEM
729 /* Make a frame using a separate minibuffer window on another frame.
730 MINI_WINDOW is the minibuffer window to use. nil means use the
731 default (the global minibuffer). */
734 make_frame_without_minibuffer (register Lisp_Object mini_window
, KBOARD
*kb
, Lisp_Object display
)
736 register struct frame
*f
;
739 if (!NILP (mini_window
))
740 CHECK_LIVE_WINDOW (mini_window
);
742 if (!NILP (mini_window
)
743 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
744 error ("Frame and minibuffer must be on the same terminal");
746 /* Make a frame containing just a root window. */
749 if (NILP (mini_window
))
751 /* Use default-minibuffer-frame if possible. */
752 if (!FRAMEP (KVAR (kb
, Vdefault_minibuffer_frame
))
753 || ! FRAME_LIVE_P (XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))))
755 Lisp_Object frame_dummy
;
757 XSETFRAME (frame_dummy
, f
);
758 GCPRO1 (frame_dummy
);
759 /* If there's no minibuffer frame to use, create one. */
760 kset_default_minibuffer_frame
761 (kb
, call1 (intern ("make-initial-minibuffer-frame"), display
));
766 = XFRAME (KVAR (kb
, Vdefault_minibuffer_frame
))->minibuffer_window
;
769 fset_minibuffer_window (f
, mini_window
);
771 /* Make the chosen minibuffer window display the proper minibuffer,
772 unless it is already showing a minibuffer. */
773 if (NILP (Fmemq (XWINDOW (mini_window
)->contents
, Vminibuffer_list
)))
774 /* Use set_window_buffer instead of Fset_window_buffer (see
775 discussion of bug#11984, bug#12025, bug#12026). */
776 set_window_buffer (mini_window
,
777 (NILP (Vminibuffer_list
)
779 : Fcar (Vminibuffer_list
)), 0, 0);
783 /* Make a frame containing only a minibuffer window. */
786 make_minibuffer_frame (void)
788 /* First make a frame containing just a root window, no minibuffer. */
790 register struct frame
*f
= make_frame (0);
791 register Lisp_Object mini_window
;
792 register Lisp_Object frame
;
794 XSETFRAME (frame
, f
);
799 f
->wants_modeline
= 0;
801 /* Now label the root window as also being the minibuffer.
802 Avoid infinite looping on the window chain by marking next pointer
805 mini_window
= f
->root_window
;
806 fset_minibuffer_window (f
, mini_window
);
807 XWINDOW (mini_window
)->mini
= 1;
808 wset_next (XWINDOW (mini_window
), Qnil
);
809 wset_prev (XWINDOW (mini_window
), Qnil
);
810 wset_frame (XWINDOW (mini_window
), frame
);
812 /* Put the proper buffer in that window. */
814 /* Use set_window_buffer instead of Fset_window_buffer (see
815 discussion of bug#11984, bug#12025, bug#12026). */
816 set_window_buffer (mini_window
,
817 (NILP (Vminibuffer_list
)
819 : Fcar (Vminibuffer_list
)), 0, 0);
822 #endif /* HAVE_WINDOW_SYSTEM */
824 /* Construct a frame that refers to a terminal. */
826 static printmax_t tty_frame_count
;
829 make_initial_frame (void)
832 struct terminal
*terminal
;
835 eassert (initial_kboard
);
837 /* The first call must initialize Vframe_list. */
838 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
841 terminal
= init_initial_terminal ();
844 XSETFRAME (frame
, f
);
846 Vframe_list
= Fcons (frame
, Vframe_list
);
849 fset_name (f
, build_pure_c_string ("F1"));
851 SET_FRAME_VISIBLE (f
, 1);
853 f
->output_method
= terminal
->type
;
854 f
->terminal
= terminal
;
855 f
->terminal
->reference_count
++;
856 f
->output_data
.nothing
= 0;
858 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
859 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
861 #ifdef HAVE_WINDOW_SYSTEM
862 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
863 f
->horizontal_scroll_bars
= false;
866 /* The default value of menu-bar-mode is t. */
867 set_menu_bar_lines (f
, make_number (1), Qnil
);
870 init_frame_faces (f
);
872 last_nonminibuf_frame
= f
;
878 static struct frame
*
879 make_terminal_frame (struct terminal
*terminal
)
881 register struct frame
*f
;
883 char name
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
886 error ("Terminal is not live, can't create new frames on it");
890 XSETFRAME (frame
, f
);
891 Vframe_list
= Fcons (frame
, Vframe_list
);
893 fset_name (f
, make_formatted_string (name
, "F%"pMd
, ++tty_frame_count
));
895 SET_FRAME_VISIBLE (f
, 1);
897 f
->terminal
= terminal
;
898 f
->terminal
->reference_count
++;
900 f
->output_data
.tty
->display_info
= &the_only_display_info
;
901 if (!inhibit_window_system
902 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
903 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
904 f
->output_method
= output_msdos_raw
;
906 f
->output_method
= output_termcap
;
907 #else /* not MSDOS */
908 f
->output_method
= output_termcap
;
909 create_tty_output (f
);
910 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
911 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
912 #endif /* not MSDOS */
914 #ifdef HAVE_WINDOW_SYSTEM
915 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
916 f
->horizontal_scroll_bars
= false;
919 FRAME_MENU_BAR_LINES (f
) = NILP (Vmenu_bar_mode
) ? 0 : 1;
920 FRAME_LINES (f
) = FRAME_LINES (f
) - FRAME_MENU_BAR_LINES (f
);
921 FRAME_MENU_BAR_HEIGHT (f
) = FRAME_MENU_BAR_LINES (f
) * FRAME_LINE_HEIGHT (f
);
922 FRAME_TEXT_HEIGHT (f
) = FRAME_TEXT_HEIGHT (f
) - FRAME_MENU_BAR_HEIGHT (f
);
924 /* Set the top frame to the newly created frame. */
925 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
926 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
927 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f
)->top_frame
), 2); /* obscured */
929 FRAME_TTY (f
)->top_frame
= frame
;
932 init_frame_faces (f
);
937 /* Get a suitable value for frame parameter PARAMETER for a newly
938 created frame, based on (1) the user-supplied frame parameter
939 alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */
942 get_future_frame_param (Lisp_Object parameter
,
943 Lisp_Object supplied_parms
,
948 result
= Fassq (parameter
, supplied_parms
);
950 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
951 if (NILP (result
) && current_value
!= NULL
)
952 result
= build_string (current_value
);
953 if (!NILP (result
) && !STRINGP (result
))
954 result
= XCDR (result
);
955 if (NILP (result
) || !STRINGP (result
))
961 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
963 doc
: /* Create an additional terminal frame, possibly on another terminal.
964 This function takes one argument, an alist specifying frame parameters.
966 You can create multiple frames on a single text terminal, but only one
967 of them (the selected terminal frame) is actually displayed.
969 In practice, generally you don't need to specify any parameters,
970 except when you want to create a new frame on another terminal.
971 In that case, the `tty' parameter specifies the device file to open,
972 and the `tty-type' parameter specifies the terminal type. Example:
974 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
976 Note that changing the size of one terminal frame automatically
977 affects all frames on the same terminal device. */)
981 struct terminal
*t
= NULL
;
982 Lisp_Object frame
, tem
;
983 struct frame
*sf
= SELECTED_FRAME ();
986 if (sf
->output_method
!= output_msdos_raw
987 && sf
->output_method
!= output_termcap
)
989 #else /* not MSDOS */
991 #ifdef WINDOWSNT /* This should work now! */
992 if (sf
->output_method
!= output_termcap
)
993 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
995 #endif /* not MSDOS */
998 Lisp_Object terminal
;
1000 terminal
= Fassq (Qterminal
, parms
);
1001 if (CONSP (terminal
))
1003 terminal
= XCDR (terminal
);
1004 t
= decode_live_terminal (terminal
);
1007 if (t
&& t
!= the_only_display_info
.terminal
)
1008 /* msdos.c assumes a single tty_display_info object. */
1009 error ("Multiple terminals are not supported on this platform");
1011 t
= the_only_display_info
.terminal
;
1017 char *name
= 0, *type
= 0;
1018 Lisp_Object tty
, tty_type
;
1021 tty
= get_future_frame_param
1022 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1023 ? FRAME_TTY (XFRAME (selected_frame
))->name
1026 SAFE_ALLOCA_STRING (name
, tty
);
1028 tty_type
= get_future_frame_param
1029 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
1030 ? FRAME_TTY (XFRAME (selected_frame
))->type
1032 if (!NILP (tty_type
))
1033 SAFE_ALLOCA_STRING (type
, tty_type
);
1035 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
1039 f
= make_terminal_frame (t
);
1043 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
1044 adjust_frame_size (f
, width
, height
- FRAME_MENU_BAR_LINES (f
),
1045 5, 0, Qterminal_frame
);
1048 adjust_frame_glyphs (f
);
1049 calculate_costs (f
);
1050 XSETFRAME (frame
, f
);
1052 store_in_alist (&parms
, Qtty_type
, build_string (t
->display_info
.tty
->type
));
1053 store_in_alist (&parms
, Qtty
,
1054 (t
->display_info
.tty
->name
1055 ? build_string (t
->display_info
.tty
->name
)
1057 Fmodify_frame_parameters (frame
, parms
);
1059 /* Make the frame face alist be frame-specific, so that each
1060 frame could change its face definitions independently. */
1061 fset_face_alist (f
, Fcopy_alist (sf
->face_alist
));
1062 /* Simple Fcopy_alist isn't enough, because we need the contents of
1063 the vectors which are the CDRs of associations in face_alist to
1064 be copied as well. */
1065 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
1066 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
1071 /* Perform the switch to frame FRAME.
1073 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
1076 If TRACK is non-zero and the frame that currently has the focus
1077 redirects its focus to the selected frame, redirect that focused
1078 frame's focus to FRAME instead.
1080 FOR_DELETION non-zero means that the selected frame is being
1081 deleted, which includes the possibility that the frame's terminal
1084 The value of NORECORD is passed as argument to Fselect_window. */
1087 do_switch_frame (Lisp_Object frame
, int track
, int for_deletion
, Lisp_Object norecord
)
1089 struct frame
*sf
= SELECTED_FRAME ();
1091 /* If FRAME is a switch-frame event, extract the frame we should
1094 && EQ (XCAR (frame
), Qswitch_frame
)
1095 && CONSP (XCDR (frame
)))
1096 frame
= XCAR (XCDR (frame
));
1098 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
1099 a switch-frame event to arrive after a frame is no longer live,
1100 especially when deleting the initial frame during startup. */
1101 CHECK_FRAME (frame
);
1102 if (! FRAME_LIVE_P (XFRAME (frame
)))
1105 if (sf
== XFRAME (frame
))
1108 /* If a frame's focus has been redirected toward the currently
1109 selected frame, we should change the redirection to point to the
1110 newly selected frame. This means that if the focus is redirected
1111 from a minibufferless frame to a surrogate minibuffer frame, we
1112 can use `other-window' to switch between all the frames using
1113 that minibuffer frame, and the focus redirection will follow us
1116 /* This is too greedy; it causes inappropriate focus redirection
1117 that's hard to get rid of. */
1122 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1126 if (!FRAMEP (XCAR (tail
)))
1129 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
1131 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1132 Fredirect_frame_focus (XCAR (tail
), frame
);
1136 /* Instead, apply it only to the frame we're pointing to. */
1137 #ifdef HAVE_WINDOW_SYSTEM
1138 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
1140 Lisp_Object focus
, xfocus
;
1142 xfocus
= x_get_focus_frame (XFRAME (frame
));
1143 if (FRAMEP (xfocus
))
1145 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
1146 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
1147 Fredirect_frame_focus (xfocus
, frame
);
1150 #endif /* HAVE_X_WINDOWS */
1153 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
1154 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
1156 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
1158 struct frame
*f
= XFRAME (frame
);
1159 struct tty_display_info
*tty
= FRAME_TTY (f
);
1160 Lisp_Object top_frame
= tty
->top_frame
;
1162 /* Don't mark the frame garbaged and/or obscured if we are
1163 switching to the frame that is already the top frame of that
1165 if (!EQ (frame
, top_frame
))
1167 if (FRAMEP (top_frame
))
1168 /* Mark previously displayed frame as now obscured. */
1169 SET_FRAME_VISIBLE (XFRAME (top_frame
), 2);
1170 SET_FRAME_VISIBLE (f
, 1);
1171 /* If the new TTY frame changed dimensions, we need to
1172 resync term.c's idea of the frame size with the new
1174 if (FRAME_COLS (f
) != FrameCols (tty
))
1175 FrameCols (tty
) = FRAME_COLS (f
);
1176 if (FRAME_TOTAL_LINES (f
) != FrameRows (tty
))
1177 FrameRows (tty
) = FRAME_TOTAL_LINES (f
);
1179 tty
->top_frame
= frame
;
1182 selected_frame
= frame
;
1183 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
1184 last_nonminibuf_frame
= XFRAME (selected_frame
);
1186 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
1188 /* We want to make sure that the next event generates a frame-switch
1189 event to the appropriate frame. This seems kludgy to me, but
1190 before you take it out, make sure that evaluating something like
1191 (select-window (frame-root-window (new-frame))) doesn't end up
1192 with your typing being interpreted in the new frame instead of
1193 the one you're actually typing in. */
1194 internal_last_event_frame
= Qnil
;
1199 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
1200 doc
: /* Select FRAME.
1201 Subsequent editing commands apply to its selected window.
1202 Optional argument NORECORD means to neither change the order of
1203 recently selected windows nor the buffer list.
1205 The selection of FRAME lasts until the next time the user does
1206 something to select a different frame, or until the next time
1207 this function is called. If you are using a window system, the
1208 previously selected frame may be restored as the selected frame
1209 when returning to the command loop, because it still may have
1210 the window system's input focus. On a text terminal, the next
1211 redisplay will display FRAME.
1213 This function returns FRAME, or nil if FRAME has been deleted. */)
1214 (Lisp_Object frame
, Lisp_Object norecord
)
1216 return do_switch_frame (frame
, 1, 0, norecord
);
1219 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "^e",
1220 doc
: /* Handle a switch-frame event EVENT.
1221 Switch-frame events are usually bound to this function.
1222 A switch-frame event tells Emacs that the window manager has requested
1223 that the user's events be directed to the frame mentioned in the event.
1224 This function selects the selected window of the frame of EVENT.
1226 If EVENT is frame object, handle it as if it were a switch-frame event
1230 /* Preserve prefix arg that the command loop just cleared. */
1231 kset_prefix_arg (current_kboard
, Vcurrent_prefix_arg
);
1232 run_hook (Qmouse_leave_buffer_hook
);
1233 /* `switch-frame' implies a focus in. */
1234 call1 (intern ("handle-focus-in"), event
);
1235 return do_switch_frame (event
, 0, 0, Qnil
);
1238 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
1239 doc
: /* Return the frame that is now selected. */)
1242 return selected_frame
;
1245 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1247 doc
: /* Return a list of all live frames. */)
1251 frames
= Fcopy_sequence (Vframe_list
);
1252 #ifdef HAVE_WINDOW_SYSTEM
1253 if (FRAMEP (tip_frame
))
1254 frames
= Fdelq (tip_frame
, frames
);
1259 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
1260 same tty (for tty frames) or among frames which uses FRAME's keyboard.
1261 If MINIBUF is nil, do not consider minibuffer-only candidate.
1262 If MINIBUF is `visible', do not consider an invisible candidate.
1263 If MINIBUF is a window, consider only its own frame and candidate now
1264 using that window as the minibuffer.
1265 If MINIBUF is 0, consider candidate if it is visible or iconified.
1266 Otherwise consider any candidate and return nil if CANDIDATE is not
1270 candidate_frame (Lisp_Object candidate
, Lisp_Object frame
, Lisp_Object minibuf
)
1272 struct frame
*c
= XFRAME (candidate
), *f
= XFRAME (frame
);
1274 if ((!FRAME_TERMCAP_P (c
) && !FRAME_TERMCAP_P (f
)
1275 && FRAME_KBOARD (c
) == FRAME_KBOARD (f
))
1276 || (FRAME_TERMCAP_P (c
) && FRAME_TERMCAP_P (f
)
1277 && FRAME_TTY (c
) == FRAME_TTY (f
)))
1281 if (!FRAME_MINIBUF_ONLY_P (c
))
1284 else if (EQ (minibuf
, Qvisible
))
1286 if (FRAME_VISIBLE_P (c
))
1289 else if (WINDOWP (minibuf
))
1291 if (EQ (FRAME_MINIBUF_WINDOW (c
), minibuf
)
1292 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), candidate
)
1293 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1294 FRAME_FOCUS_FRAME (c
)))
1297 else if (XFASTINT (minibuf
) == 0)
1299 if (FRAME_VISIBLE_P (c
) || FRAME_ICONIFIED_P (c
))
1308 /* Return the next frame in the frame list after FRAME. */
1311 next_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1313 Lisp_Object f
, tail
;
1316 /* There must always be at least one frame in Vframe_list. */
1317 eassert (CONSP (Vframe_list
));
1320 FOR_EACH_FRAME (tail
, f
)
1324 f
= candidate_frame (f
, frame
, minibuf
);
1334 /* Return the previous frame in the frame list before FRAME. */
1337 prev_frame (Lisp_Object frame
, Lisp_Object minibuf
)
1339 Lisp_Object f
, tail
, prev
= Qnil
;
1341 /* There must always be at least one frame in Vframe_list. */
1342 eassert (CONSP (Vframe_list
));
1344 FOR_EACH_FRAME (tail
, f
)
1346 if (EQ (frame
, f
) && !NILP (prev
))
1348 f
= candidate_frame (f
, frame
, minibuf
);
1353 /* We've scanned the entire list. */
1355 /* We went through the whole frame list without finding a single
1356 acceptable frame. Return the original frame. */
1359 /* There were no acceptable frames in the list before FRAME; otherwise,
1360 we would have returned directly from the loop. Since PREV is the last
1361 acceptable frame in the list, return it. */
1366 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1367 doc
: /* Return the next frame in the frame list after FRAME.
1368 It considers only frames on the same terminal as FRAME.
1369 By default, skip minibuffer-only frames.
1370 If omitted, FRAME defaults to the selected frame.
1371 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1372 If MINIFRAME is a window, include only its own frame
1373 and any frame now using that window as the minibuffer.
1374 If MINIFRAME is `visible', include all visible frames.
1375 If MINIFRAME is 0, include all visible and iconified frames.
1376 Otherwise, include all frames. */)
1377 (Lisp_Object frame
, Lisp_Object miniframe
)
1380 frame
= selected_frame
;
1381 CHECK_LIVE_FRAME (frame
);
1382 return next_frame (frame
, miniframe
);
1385 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1386 doc
: /* Return the previous frame in the frame list before FRAME.
1387 It considers only frames on the same terminal as FRAME.
1388 By default, skip minibuffer-only frames.
1389 If omitted, FRAME defaults to the selected frame.
1390 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1391 If MINIFRAME is a window, include only its own frame
1392 and any frame now using that window as the minibuffer.
1393 If MINIFRAME is `visible', include all visible frames.
1394 If MINIFRAME is 0, include all visible and iconified frames.
1395 Otherwise, include all frames. */)
1396 (Lisp_Object frame
, Lisp_Object miniframe
)
1399 frame
= selected_frame
;
1400 CHECK_LIVE_FRAME (frame
);
1401 return prev_frame (frame
, miniframe
);
1404 DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame
,
1405 Slast_nonminibuf_frame
, 0, 0, 0,
1406 doc
: /* Return last non-minibuffer frame selected. */)
1409 Lisp_Object frame
= Qnil
;
1411 if (last_nonminibuf_frame
)
1412 XSETFRAME (frame
, last_nonminibuf_frame
);
1417 /* Return 1 if it is ok to delete frame F;
1418 0 if all frames aside from F are invisible.
1419 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1422 other_visible_frames (struct frame
*f
)
1424 Lisp_Object frames
, this;
1426 FOR_EACH_FRAME (frames
, this)
1428 if (f
== XFRAME (this))
1431 /* Verify that we can still talk to the frame's X window,
1432 and note any recent change in visibility. */
1433 #ifdef HAVE_X_WINDOWS
1434 if (FRAME_WINDOW_P (XFRAME (this)))
1435 x_sync (XFRAME (this));
1438 if (FRAME_VISIBLE_P (XFRAME (this))
1439 || FRAME_ICONIFIED_P (XFRAME (this))
1440 /* Allow deleting the terminal frame when at least one X
1442 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1448 /* Make sure that minibuf_window doesn't refer to FRAME's minibuffer
1449 window. Preferably use the selected frame's minibuffer window
1450 instead. If the selected frame doesn't have one, get some other
1451 frame's minibuffer window. SELECT non-zero means select the new
1452 minibuffer window. */
1454 check_minibuf_window (Lisp_Object frame
, int select
)
1456 struct frame
*f
= decode_live_frame (frame
);
1458 XSETFRAME (frame
, f
);
1460 if (WINDOWP (minibuf_window
) && EQ (f
->minibuffer_window
, minibuf_window
))
1462 Lisp_Object frames
, this, window
= make_number (0);
1464 if (!EQ (frame
, selected_frame
)
1465 && FRAME_HAS_MINIBUF_P (XFRAME (selected_frame
)))
1466 window
= FRAME_MINIBUF_WINDOW (XFRAME (selected_frame
));
1468 FOR_EACH_FRAME (frames
, this)
1470 if (!EQ (this, frame
) && FRAME_HAS_MINIBUF_P (XFRAME (this)))
1472 window
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1477 /* Don't abort if no window was found (Bug#15247). */
1478 if (WINDOWP (window
))
1480 /* Use set_window_buffer instead of Fset_window_buffer (see
1481 discussion of bug#11984, bug#12025, bug#12026). */
1482 set_window_buffer (window
, XWINDOW (minibuf_window
)->contents
, 0, 0);
1483 minibuf_window
= window
;
1485 /* SELECT non-zero usually means that FRAME's minibuffer
1486 window was selected; select the new one. */
1488 Fselect_window (minibuf_window
, Qnil
);
1494 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1495 unconditionally. x_connection_closed and delete_terminal use
1496 this. Any other value of FORCE implements the semantics
1497 described for Fdelete_frame. */
1499 delete_frame (Lisp_Object frame
, Lisp_Object force
)
1501 struct frame
*f
= decode_any_frame (frame
);
1505 int minibuffer_selected
, is_tooltip_frame
;
1507 if (! FRAME_LIVE_P (f
))
1510 if (NILP (force
) && !other_visible_frames (f
))
1511 error ("Attempt to delete the sole visible or iconified frame");
1513 /* x_connection_closed must have set FORCE to `noelisp' in order
1514 to delete the last frame, if it is gone. */
1515 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1516 error ("Attempt to delete the only frame");
1518 XSETFRAME (frame
, f
);
1520 /* Does this frame have a minibuffer, and is it the surrogate
1521 minibuffer for any other frame? */
1522 if (FRAME_HAS_MINIBUF_P (f
))
1524 Lisp_Object frames
, this;
1526 FOR_EACH_FRAME (frames
, this)
1530 if (EQ (this, frame
))
1533 fminiw
= FRAME_MINIBUF_WINDOW (XFRAME (this));
1535 if (WINDOWP (fminiw
) && EQ (frame
, WINDOW_FRAME (XWINDOW (fminiw
))))
1537 /* If we MUST delete this frame, delete the other first.
1538 But do this only if FORCE equals `noelisp'. */
1539 if (EQ (force
, Qnoelisp
))
1540 delete_frame (this, Qnoelisp
);
1542 error ("Attempt to delete a surrogate minibuffer frame");
1547 is_tooltip_frame
= !NILP (Fframe_parameter (frame
, intern ("tooltip")));
1549 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1550 frame is a tooltip. FORCE is set to `noelisp' when handling
1551 a disconnect from the terminal, so we don't dare call Lisp
1553 if (NILP (Vrun_hooks
) || is_tooltip_frame
)
1555 else if (EQ (force
, Qnoelisp
))
1557 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1561 #ifdef HAVE_X_WINDOWS
1562 /* Also, save clipboard to the clipboard manager. */
1563 x_clipboard_manager_save_frame (frame
);
1566 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1569 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1570 if (! FRAME_LIVE_P (f
))
1573 /* At this point, we are committed to deleting the frame.
1574 There is no more chance for errors to prevent it. */
1576 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1577 sf
= SELECTED_FRAME ();
1578 /* Don't let the frame remain selected. */
1582 Lisp_Object frame1
= Qnil
;
1584 /* Look for another visible frame on the same terminal.
1585 Do not call next_frame here because it may loop forever.
1586 See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15025. */
1587 FOR_EACH_FRAME (tail
, frame1
)
1588 if (!EQ (frame
, frame1
)
1589 && (FRAME_TERMINAL (XFRAME (frame
))
1590 == FRAME_TERMINAL (XFRAME (frame1
)))
1591 && FRAME_VISIBLE_P (XFRAME (frame1
)))
1594 /* If there is none, find *some* other frame. */
1595 if (NILP (frame1
) || EQ (frame1
, frame
))
1597 FOR_EACH_FRAME (tail
, frame1
)
1599 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1601 /* Do not change a text terminal's top-frame. */
1602 struct frame
*f1
= XFRAME (frame1
);
1603 if (FRAME_TERMCAP_P (f1
) || FRAME_MSDOS_P (f1
))
1605 Lisp_Object top_frame
= FRAME_TTY (f1
)->top_frame
;
1606 if (!EQ (top_frame
, frame
))
1613 #ifdef NS_IMPL_COCOA
1615 /* Under NS, there is no system mechanism for choosing a new
1616 window to get focus -- it is left to application code.
1617 So the portion of THIS application interfacing with NS
1618 needs to know about it. We call Fraise_frame, but the
1619 purpose is really to transfer focus. */
1620 Fraise_frame (frame1
);
1623 do_switch_frame (frame1
, 0, 1, Qnil
);
1624 sf
= SELECTED_FRAME ();
1627 /* Don't allow minibuf_window to remain on a deleted frame. */
1628 check_minibuf_window (frame
, minibuffer_selected
);
1630 /* Don't let echo_area_window to remain on a deleted frame. */
1631 if (EQ (f
->minibuffer_window
, echo_area_window
))
1632 echo_area_window
= sf
->minibuffer_window
;
1634 /* Clear any X selections for this frame. */
1635 #ifdef HAVE_X_WINDOWS
1637 x_clear_frame_selections (f
);
1641 This function must be called before the window tree of the
1642 frame is deleted because windows contain dynamically allocated
1646 #ifdef HAVE_WINDOW_SYSTEM
1647 /* Give chance to each font driver to free a frame specific data. */
1648 font_update_drivers (f
, Qnil
);
1651 /* Mark all the windows that used to be on FRAME as deleted, and then
1652 remove the reference to them. */
1653 delete_all_child_windows (f
->root_window
);
1654 fset_root_window (f
, Qnil
);
1656 Vframe_list
= Fdelq (frame
, Vframe_list
);
1657 SET_FRAME_VISIBLE (f
, 0);
1659 /* Allow the vector of menu bar contents to be freed in the next
1660 garbage collection. The frame object itself may not be garbage
1661 collected until much later, because recent_keys and other data
1662 structures can still refer to it. */
1663 fset_menu_bar_vector (f
, Qnil
);
1665 /* If FRAME's buffer lists contains killed
1666 buffers, this helps GC to reclaim them. */
1667 fset_buffer_list (f
, Qnil
);
1668 fset_buried_buffer_list (f
, Qnil
);
1670 free_font_driver_list (f
);
1671 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
1674 xfree (f
->decode_mode_spec_buffer
);
1675 xfree (FRAME_INSERT_COST (f
));
1676 xfree (FRAME_DELETEN_COST (f
));
1677 xfree (FRAME_INSERTN_COST (f
));
1678 xfree (FRAME_DELETE_COST (f
));
1680 /* Since some events are handled at the interrupt level, we may get
1681 an event for f at any time; if we zero out the frame's terminal
1682 now, then we may trip up the event-handling code. Instead, we'll
1683 promise that the terminal of the frame must be valid until we
1684 have called the window-system-dependent frame destruction
1689 struct terminal
*terminal
;
1691 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1692 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1693 terminal
= FRAME_TERMINAL (f
);
1694 f
->output_data
.nothing
= 0;
1695 f
->terminal
= 0; /* Now the frame is dead. */
1698 /* If needed, delete the terminal that this frame was on.
1699 (This must be done after the frame is killed.) */
1700 terminal
->reference_count
--;
1702 /* FIXME: Deleting the terminal crashes emacs because of a GTK
1704 http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */
1705 if (terminal
->reference_count
== 0 && terminal
->type
== output_x_window
)
1706 terminal
->reference_count
= 1;
1707 #endif /* USE_GTK */
1708 if (terminal
->reference_count
== 0)
1711 XSETTERMINAL (tmp
, terminal
);
1714 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1717 kb
= terminal
->kboard
;
1720 /* If we've deleted the last_nonminibuf_frame, then try to find
1722 if (f
== last_nonminibuf_frame
)
1724 Lisp_Object frames
, this;
1726 last_nonminibuf_frame
= 0;
1728 FOR_EACH_FRAME (frames
, this)
1731 if (!FRAME_MINIBUF_ONLY_P (f
))
1733 last_nonminibuf_frame
= f
;
1739 /* If there's no other frame on the same kboard, get out of
1740 single-kboard state if we're in it for this kboard. */
1743 Lisp_Object frames
, this;
1744 /* Some frame we found on the same kboard, or nil if there are none. */
1745 Lisp_Object frame_on_same_kboard
= Qnil
;
1747 FOR_EACH_FRAME (frames
, this)
1748 if (kb
== FRAME_KBOARD (XFRAME (this)))
1749 frame_on_same_kboard
= this;
1751 if (NILP (frame_on_same_kboard
))
1752 not_single_kboard_state (kb
);
1756 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1757 find another one. Prefer minibuffer-only frames, but also notice
1758 frames with other windows. */
1759 if (kb
!= NULL
&& EQ (frame
, KVAR (kb
, Vdefault_minibuffer_frame
)))
1761 Lisp_Object frames
, this;
1763 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1764 Lisp_Object frame_with_minibuf
= Qnil
;
1765 /* Some frame we found on the same kboard, or nil if there are none. */
1766 Lisp_Object frame_on_same_kboard
= Qnil
;
1768 FOR_EACH_FRAME (frames
, this)
1770 struct frame
*f1
= XFRAME (this);
1772 /* Consider only frames on the same kboard
1773 and only those with minibuffers. */
1774 if (kb
== FRAME_KBOARD (f1
)
1775 && FRAME_HAS_MINIBUF_P (f1
))
1777 frame_with_minibuf
= this;
1778 if (FRAME_MINIBUF_ONLY_P (f1
))
1782 if (kb
== FRAME_KBOARD (f1
))
1783 frame_on_same_kboard
= this;
1786 if (!NILP (frame_on_same_kboard
))
1788 /* We know that there must be some frame with a minibuffer out
1789 there. If this were not true, all of the frames present
1790 would have to be minibufferless, which implies that at some
1791 point their minibuffer frames must have been deleted, but
1792 that is prohibited at the top; you can't delete surrogate
1793 minibuffer frames. */
1794 if (NILP (frame_with_minibuf
))
1797 kset_default_minibuffer_frame (kb
, frame_with_minibuf
);
1800 /* No frames left on this kboard--say no minibuffer either. */
1801 kset_default_minibuffer_frame (kb
, Qnil
);
1804 /* Cause frame titles to update--necessary if we now have just one frame. */
1805 if (!is_tooltip_frame
)
1806 update_mode_lines
= 15;
1811 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1812 doc
: /* Delete FRAME, permanently eliminating it from use.
1813 FRAME defaults to the selected frame.
1815 A frame may not be deleted if its minibuffer is used by other frames.
1816 Normally, you may not delete a frame if all other frames are invisible,
1817 but if the second optional argument FORCE is non-nil, you may do so.
1819 This function runs `delete-frame-functions' before actually
1820 deleting the frame, unless the frame is a tooltip.
1821 The functions are run with one argument, the frame to be deleted. */)
1822 (Lisp_Object frame
, Lisp_Object force
)
1824 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1828 /* Return mouse position in character cell units. */
1830 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1831 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1832 The position is given in canonical character cells, where (0, 0) is the
1833 upper-left corner of the frame, X is the horizontal offset, and Y is the
1834 vertical offset, measured in units of the frame's default character size.
1835 If Emacs is running on a mouseless terminal or hasn't been programmed
1836 to read the mouse position, it returns the selected frame for FRAME
1837 and nil for X and Y.
1838 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1839 passing the normal return value to that function as an argument,
1840 and returns whatever that function returns. */)
1844 Lisp_Object lispy_dummy
;
1845 Lisp_Object x
, y
, retval
;
1846 struct gcpro gcpro1
;
1848 f
= SELECTED_FRAME ();
1851 /* It's okay for the hook to refrain from storing anything. */
1852 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1854 enum scroll_bar_part party_dummy
;
1856 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1857 &lispy_dummy
, &party_dummy
,
1866 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1870 XSETFRAME (lispy_dummy
, f
);
1871 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1873 if (!NILP (Vmouse_position_function
))
1874 retval
= call1 (Vmouse_position_function
, retval
);
1875 RETURN_UNGCPRO (retval
);
1878 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1879 Smouse_pixel_position
, 0, 0, 0,
1880 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1881 The position is given in pixel units, where (0, 0) is the
1882 upper-left corner of the frame, X is the horizontal offset, and Y is
1883 the vertical offset.
1884 If Emacs is running on a mouseless terminal or hasn't been programmed
1885 to read the mouse position, it returns the selected frame for FRAME
1886 and nil for X and Y. */)
1890 Lisp_Object lispy_dummy
;
1891 Lisp_Object x
, y
, retval
;
1892 struct gcpro gcpro1
;
1894 f
= SELECTED_FRAME ();
1897 /* It's okay for the hook to refrain from storing anything. */
1898 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1900 enum scroll_bar_part party_dummy
;
1902 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1903 &lispy_dummy
, &party_dummy
,
1908 XSETFRAME (lispy_dummy
, f
);
1909 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1911 if (!NILP (Vmouse_position_function
))
1912 retval
= call1 (Vmouse_position_function
, retval
);
1913 RETURN_UNGCPRO (retval
);
1916 #ifdef HAVE_WINDOW_SYSTEM
1918 /* On frame F, convert character coordinates X and Y to pixel
1919 coordinates *PIX_X and *PIX_Y. */
1922 frame_char_to_pixel_position (struct frame
*f
, int x
, int y
,
1923 int *pix_x
, int *pix_y
)
1925 *pix_x
= FRAME_COL_TO_PIXEL_X (f
, x
) + FRAME_COLUMN_WIDTH (f
) / 2;
1926 *pix_y
= FRAME_LINE_TO_PIXEL_Y (f
, y
) + FRAME_LINE_HEIGHT (f
) / 2;
1930 if (*pix_x
> FRAME_PIXEL_WIDTH (f
))
1931 *pix_x
= FRAME_PIXEL_WIDTH (f
);
1935 if (*pix_y
> FRAME_PIXEL_HEIGHT (f
))
1936 *pix_y
= FRAME_PIXEL_HEIGHT (f
);
1939 /* On frame F, reposition mouse pointer to character coordinates X and Y. */
1942 frame_set_mouse_position (struct frame
*f
, int x
, int y
)
1946 frame_char_to_pixel_position (f
, x
, y
, &pix_x
, &pix_y
);
1947 frame_set_mouse_pixel_position (f
, pix_x
, pix_y
);
1950 #endif /* HAVE_WINDOW_SYSTEM */
1952 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1953 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1954 Coordinates are relative to the frame, not a window,
1955 so the coordinates of the top left character in the frame
1956 may be nonzero due to left-hand scroll bars or the menu bar.
1958 The position is given in canonical character cells, where (0, 0) is
1959 the upper-left corner of the frame, X is the horizontal offset, and
1960 Y is the vertical offset, measured in units of the frame's default
1963 This function is a no-op for an X frame that is not visible.
1964 If you have just created a frame, you must wait for it to become visible
1965 before calling this function on it, like this.
1966 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1967 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
1969 CHECK_LIVE_FRAME (frame
);
1970 CHECK_TYPE_RANGED_INTEGER (int, x
);
1971 CHECK_TYPE_RANGED_INTEGER (int, y
);
1973 /* I think this should be done with a hook. */
1974 #ifdef HAVE_WINDOW_SYSTEM
1975 if (FRAME_WINDOW_P (XFRAME (frame
)))
1976 /* Warping the mouse will cause enternotify and focus events. */
1977 frame_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1980 if (FRAME_MSDOS_P (XFRAME (frame
)))
1982 Fselect_frame (frame
, Qnil
);
1983 mouse_moveto (XINT (x
), XINT (y
));
1988 Fselect_frame (frame
, Qnil
);
1989 term_mouse_moveto (XINT (x
), XINT (y
));
1998 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1999 Sset_mouse_pixel_position
, 3, 3, 0,
2000 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
2001 The position is given in pixels, where (0, 0) is the upper-left corner
2002 of the frame, X is the horizontal offset, and Y is the vertical offset.
2004 Note, this is a no-op for an X frame that is not visible.
2005 If you have just created a frame, you must wait for it to become visible
2006 before calling this function on it, like this.
2007 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
2008 (Lisp_Object frame
, Lisp_Object x
, Lisp_Object y
)
2010 CHECK_LIVE_FRAME (frame
);
2011 CHECK_TYPE_RANGED_INTEGER (int, x
);
2012 CHECK_TYPE_RANGED_INTEGER (int, y
);
2014 /* I think this should be done with a hook. */
2015 #ifdef HAVE_WINDOW_SYSTEM
2016 if (FRAME_WINDOW_P (XFRAME (frame
)))
2017 /* Warping the mouse will cause enternotify and focus events. */
2018 frame_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
2021 if (FRAME_MSDOS_P (XFRAME (frame
)))
2023 Fselect_frame (frame
, Qnil
);
2024 mouse_moveto (XINT (x
), XINT (y
));
2029 Fselect_frame (frame
, Qnil
);
2030 term_mouse_moveto (XINT (x
), XINT (y
));
2039 static void make_frame_visible_1 (Lisp_Object
);
2041 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
2043 doc
: /* Make the frame FRAME visible (assuming it is an X window).
2044 If omitted, FRAME defaults to the currently selected frame. */)
2047 struct frame
*f
= decode_live_frame (frame
);
2049 /* I think this should be done with a hook. */
2050 #ifdef HAVE_WINDOW_SYSTEM
2051 if (FRAME_WINDOW_P (f
))
2052 x_make_frame_visible (f
);
2055 make_frame_visible_1 (f
->root_window
);
2057 /* Make menu bar update for the Buffers and Frames menus. */
2058 /* windows_or_buffers_changed = 15; FIXME: Why? */
2060 XSETFRAME (frame
, f
);
2064 /* Update the display_time slot of the buffers shown in WINDOW
2065 and all its descendants. */
2068 make_frame_visible_1 (Lisp_Object window
)
2072 for (; !NILP (window
); window
= w
->next
)
2074 w
= XWINDOW (window
);
2075 if (WINDOWP (w
->contents
))
2076 make_frame_visible_1 (w
->contents
);
2078 bset_display_time (XBUFFER (w
->contents
), Fcurrent_time ());
2082 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
2084 doc
: /* Make the frame FRAME invisible.
2085 If omitted, FRAME defaults to the currently selected frame.
2086 On graphical displays, invisible frames are not updated and are
2087 usually not displayed at all, even in a window system's \"taskbar\".
2089 Normally you may not make FRAME invisible if all other frames are invisible,
2090 but if the second optional argument FORCE is non-nil, you may do so.
2092 This function has no effect on text terminal frames. Such frames are
2093 always considered visible, whether or not they are currently being
2094 displayed in the terminal. */)
2095 (Lisp_Object frame
, Lisp_Object force
)
2097 struct frame
*f
= decode_live_frame (frame
);
2099 if (NILP (force
) && !other_visible_frames (f
))
2100 error ("Attempt to make invisible the sole visible or iconified frame");
2102 /* Don't allow minibuf_window to remain on an invisible frame. */
2103 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2105 /* I think this should be done with a hook. */
2106 #ifdef HAVE_WINDOW_SYSTEM
2107 if (FRAME_WINDOW_P (f
))
2108 x_make_frame_invisible (f
);
2111 /* Make menu bar update for the Buffers and Frames menus. */
2112 windows_or_buffers_changed
= 16;
2117 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
2119 doc
: /* Make the frame FRAME into an icon.
2120 If omitted, FRAME defaults to the currently selected frame. */)
2123 struct frame
*f
= decode_live_frame (frame
);
2125 /* Don't allow minibuf_window to remain on an iconified frame. */
2126 check_minibuf_window (frame
, EQ (minibuf_window
, selected_window
));
2128 /* I think this should be done with a hook. */
2129 #ifdef HAVE_WINDOW_SYSTEM
2130 if (FRAME_WINDOW_P (f
))
2131 x_iconify_frame (f
);
2134 /* Make menu bar update for the Buffers and Frames menus. */
2135 windows_or_buffers_changed
= 17;
2140 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
2142 doc
: /* Return t if FRAME is \"visible\" (actually in use for display).
2143 Return the symbol `icon' if FRAME is iconified or \"minimized\".
2144 Return nil if FRAME was made invisible, via `make-frame-invisible'.
2145 On graphical displays, invisible frames are not updated and are
2146 usually not displayed at all, even in a window system's \"taskbar\".
2148 If FRAME is a text terminal frame, this always returns t.
2149 Such frames are always considered visible, whether or not they are
2150 currently being displayed on the terminal. */)
2153 CHECK_LIVE_FRAME (frame
);
2155 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2157 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
2162 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
2164 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
2167 Lisp_Object tail
, frame
, value
= Qnil
;
2169 FOR_EACH_FRAME (tail
, frame
)
2170 if (FRAME_VISIBLE_P (XFRAME (frame
)))
2171 value
= Fcons (frame
, value
);
2177 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
2178 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
2179 If FRAME is invisible or iconified, make it visible.
2180 If you don't specify a frame, the selected frame is used.
2181 If Emacs is displaying on an ordinary terminal or some other device which
2182 doesn't support multiple overlapping frames, this function selects FRAME. */)
2185 struct frame
*f
= decode_live_frame (frame
);
2187 XSETFRAME (frame
, f
);
2189 if (FRAME_TERMCAP_P (f
))
2190 /* On a text terminal select FRAME. */
2191 Fselect_frame (frame
, Qnil
);
2193 /* Do like the documentation says. */
2194 Fmake_frame_visible (frame
);
2196 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2197 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
2202 /* Should we have a corresponding function called Flower_Power? */
2203 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
2204 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2205 If you don't specify a frame, the selected frame is used.
2206 If Emacs is displaying on an ordinary terminal or some other device which
2207 doesn't support multiple overlapping frames, this function does nothing. */)
2210 struct frame
*f
= decode_live_frame (frame
);
2212 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2213 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2219 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2221 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2222 In other words, switch-frame events caused by events in FRAME will
2223 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2224 FOCUS-FRAME after reading an event typed at FRAME.
2226 If FOCUS-FRAME is nil, any existing redirection is canceled, and the
2227 frame again receives its own keystrokes.
2229 Focus redirection is useful for temporarily redirecting keystrokes to
2230 a surrogate minibuffer frame when a frame doesn't have its own
2233 A frame's focus redirection can be changed by `select-frame'. If frame
2234 FOO is selected, and then a different frame BAR is selected, any
2235 frames redirecting their focus to FOO are shifted to redirect their
2236 focus to BAR. This allows focus redirection to work properly when the
2237 user switches from one frame to another using `select-window'.
2239 This means that a frame whose focus is redirected to itself is treated
2240 differently from a frame whose focus is redirected to nil; the former
2241 is affected by `select-frame', while the latter is not.
2243 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2244 (Lisp_Object frame
, Lisp_Object focus_frame
)
2246 /* Note that we don't check for a live frame here. It's reasonable
2247 to redirect the focus of a frame you're about to delete, if you
2248 know what other frame should receive those keystrokes. */
2249 struct frame
*f
= decode_any_frame (frame
);
2251 if (! NILP (focus_frame
))
2252 CHECK_LIVE_FRAME (focus_frame
);
2254 fset_focus_frame (f
, focus_frame
);
2256 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2257 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2263 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 0, 1, 0,
2264 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2265 If FRAME is omitted or nil, the selected frame is used.
2266 Return nil if FRAME's focus is not redirected.
2267 See `redirect-frame-focus'. */)
2270 return FRAME_FOCUS_FRAME (decode_live_frame (frame
));
2273 DEFUN ("x-focus-frame", Fx_focus_frame
, Sx_focus_frame
, 1, 1, 0,
2274 doc
: /* Set the input focus to FRAME.
2275 FRAME nil means use the selected frame.
2276 If there is no window system support, this function does nothing. */)
2279 #ifdef HAVE_WINDOW_SYSTEM
2280 x_focus_frame (decode_window_system_frame (frame
));
2285 DEFUN ("frame-after-make-frame",
2286 Fframe_after_make_frame
,
2287 Sframe_after_make_frame
, 2, 2, 0,
2288 doc
: /* Mark FRAME as made.
2289 FRAME nil means use the selected frame. Second argument MADE non-nil
2290 means functions on `window-configuration-change-hook' are called
2291 whenever the window configuration of FRAME changes. MADE nil means
2292 these functions are not called.
2294 This function is currently called by `make-frame' only and should be
2295 otherwise used with utter care to avoid that running functions on
2296 `window-configuration-change-hook' is impeded forever. */)
2297 (Lisp_Object frame
, Lisp_Object made
)
2299 struct frame
*f
= decode_live_frame (frame
);
2300 f
->after_make_frame
= !NILP (made
);
2305 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2308 frames_discard_buffer (Lisp_Object buffer
)
2310 Lisp_Object frame
, tail
;
2312 FOR_EACH_FRAME (tail
, frame
)
2315 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buffer_list
));
2316 fset_buried_buffer_list
2317 (XFRAME (frame
), Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
));
2321 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2322 If the alist already has an element for PROP, we change it. */
2325 store_in_alist (Lisp_Object
*alistptr
, Lisp_Object prop
, Lisp_Object val
)
2327 register Lisp_Object tem
;
2329 tem
= Fassq (prop
, *alistptr
);
2331 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2337 frame_name_fnn_p (char *str
, ptrdiff_t len
)
2339 if (len
> 1 && str
[0] == 'F' && '0' <= str
[1] && str
[1] <= '9')
2342 while ('0' <= *p
&& *p
<= '9')
2350 /* Set the name of the terminal frame. Also used by MSDOS frames.
2351 Modeled after x_set_name which is used for WINDOW frames. */
2354 set_term_frame_name (struct frame
*f
, Lisp_Object name
)
2356 f
->explicit_name
= ! NILP (name
);
2358 /* If NAME is nil, set the name to F<num>. */
2361 char namebuf
[sizeof "F" + INT_STRLEN_BOUND (printmax_t
)];
2363 /* Check for no change needed in this very common case
2364 before we do any consing. */
2365 if (frame_name_fnn_p (SSDATA (f
->name
), SBYTES (f
->name
)))
2368 name
= make_formatted_string (namebuf
, "F%"pMd
, ++tty_frame_count
);
2372 CHECK_STRING (name
);
2374 /* Don't change the name if it's already NAME. */
2375 if (! NILP (Fstring_equal (name
, f
->name
)))
2378 /* Don't allow the user to set the frame name to F<num>, so it
2379 doesn't clash with the names we generate for terminal frames. */
2380 if (frame_name_fnn_p (SSDATA (name
), SBYTES (name
)))
2381 error ("Frame names of the form F<num> are usurped by Emacs");
2384 fset_name (f
, name
);
2385 update_mode_lines
= 16;
2389 store_frame_param (struct frame
*f
, Lisp_Object prop
, Lisp_Object val
)
2391 register Lisp_Object old_alist_elt
;
2393 /* The buffer-list parameters are stored in a special place and not
2394 in the alist. All buffers must be live. */
2395 if (EQ (prop
, Qbuffer_list
))
2397 Lisp_Object list
= Qnil
;
2398 for (; CONSP (val
); val
= XCDR (val
))
2399 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2400 list
= Fcons (XCAR (val
), list
);
2401 fset_buffer_list (f
, Fnreverse (list
));
2404 if (EQ (prop
, Qburied_buffer_list
))
2406 Lisp_Object list
= Qnil
;
2407 for (; CONSP (val
); val
= XCDR (val
))
2408 if (!NILP (Fbuffer_live_p (XCAR (val
))))
2409 list
= Fcons (XCAR (val
), list
);
2410 fset_buried_buffer_list (f
, Fnreverse (list
));
2414 /* If PROP is a symbol which is supposed to have frame-local values,
2415 and it is set up based on this frame, switch to the global
2416 binding. That way, we can create or alter the frame-local binding
2417 without messing up the symbol's status. */
2420 struct Lisp_Symbol
*sym
= XSYMBOL (prop
);
2422 switch (sym
->redirect
)
2424 case SYMBOL_VARALIAS
: sym
= indirect_variable (sym
); goto start
;
2425 case SYMBOL_PLAINVAL
: case SYMBOL_FORWARDED
: break;
2426 case SYMBOL_LOCALIZED
:
2427 { struct Lisp_Buffer_Local_Value
*blv
= sym
->val
.blv
;
2428 if (blv
->frame_local
&& blv_found (blv
) && XFRAME (blv
->where
) == f
)
2429 swap_in_global_binding (sym
);
2432 default: emacs_abort ();
2436 /* The tty color needed to be set before the frame's parameter
2437 alist was updated with the new value. This is not true any more,
2438 but we still do this test early on. */
2439 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2440 && f
== FRAME_TTY (f
)->previous_frame
)
2441 /* Force redisplay of this tty. */
2442 FRAME_TTY (f
)->previous_frame
= NULL
;
2444 /* Update the frame parameter alist. */
2445 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2446 if (EQ (old_alist_elt
, Qnil
))
2447 fset_param_alist (f
, Fcons (Fcons (prop
, val
), f
->param_alist
));
2449 Fsetcdr (old_alist_elt
, val
);
2451 /* Update some other special parameters in their special places
2452 in addition to the alist. */
2454 if (EQ (prop
, Qbuffer_predicate
))
2455 fset_buffer_predicate (f
, val
);
2457 if (! FRAME_WINDOW_P (f
))
2459 if (EQ (prop
, Qmenu_bar_lines
))
2460 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2461 else if (EQ (prop
, Qname
))
2462 set_term_frame_name (f
, val
);
2465 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2467 if (! MINI_WINDOW_P (XWINDOW (val
)))
2468 error ("Surrogate minibuffer windows must be minibuffer windows");
2470 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2471 && !EQ (val
, f
->minibuffer_window
))
2472 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2474 /* Install the chosen minibuffer window, with proper buffer. */
2475 fset_minibuffer_window (f
, val
);
2479 /* Return color matches UNSPEC on frame F or nil if UNSPEC
2480 is not an unspecified foreground or background color. */
2483 frame_unspecified_color (struct frame
*f
, Lisp_Object unspec
)
2485 return (!strncmp (SSDATA (unspec
), unspecified_bg
, SBYTES (unspec
))
2486 ? tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
))
2487 : (!strncmp (SSDATA (unspec
), unspecified_fg
, SBYTES (unspec
))
2488 ? tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)) : Qnil
));
2491 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2492 doc
: /* Return the parameters-alist of frame FRAME.
2493 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2494 The meaningful PARMs depend on the kind of frame.
2495 If FRAME is omitted or nil, return information on the currently selected frame. */)
2499 struct frame
*f
= decode_any_frame (frame
);
2501 struct gcpro gcpro1
;
2503 if (!FRAME_LIVE_P (f
))
2506 alist
= Fcopy_alist (f
->param_alist
);
2509 if (!FRAME_WINDOW_P (f
))
2513 /* If the frame's parameter alist says the colors are
2514 unspecified and reversed, take the frame's background pixel
2515 for foreground and vice versa. */
2516 elt
= Fassq (Qforeground_color
, alist
);
2517 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2519 elt
= frame_unspecified_color (f
, XCDR (elt
));
2521 store_in_alist (&alist
, Qforeground_color
, elt
);
2524 store_in_alist (&alist
, Qforeground_color
,
2525 tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
)));
2526 elt
= Fassq (Qbackground_color
, alist
);
2527 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2529 elt
= frame_unspecified_color (f
, XCDR (elt
));
2531 store_in_alist (&alist
, Qbackground_color
, elt
);
2534 store_in_alist (&alist
, Qbackground_color
,
2535 tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
)));
2536 store_in_alist (&alist
, intern ("font"),
2537 build_string (FRAME_MSDOS_P (f
)
2539 : FRAME_W32_P (f
) ? "w32term"
2542 store_in_alist (&alist
, Qname
, f
->name
);
2543 height
= (f
->new_height
2545 ? (f
->new_height
/ FRAME_LINE_HEIGHT (f
))
2548 store_in_alist (&alist
, Qheight
, make_number (height
));
2549 width
= (f
->new_width
2551 ? (f
->new_width
/ FRAME_COLUMN_WIDTH (f
))
2554 store_in_alist (&alist
, Qwidth
, make_number (width
));
2555 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2556 store_in_alist (&alist
, Qminibuffer
,
2557 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2558 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2559 : FRAME_MINIBUF_WINDOW (f
)));
2560 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2561 store_in_alist (&alist
, Qbuffer_list
, f
->buffer_list
);
2562 store_in_alist (&alist
, Qburied_buffer_list
, f
->buried_buffer_list
);
2564 /* I think this should be done with a hook. */
2565 #ifdef HAVE_WINDOW_SYSTEM
2566 if (FRAME_WINDOW_P (f
))
2567 x_report_frame_params (f
, &alist
);
2571 /* This ought to be correct in f->param_alist for an X frame. */
2573 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2574 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2582 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2583 doc
: /* Return FRAME's value for parameter PARAMETER.
2584 If FRAME is nil, describe the currently selected frame. */)
2585 (Lisp_Object frame
, Lisp_Object parameter
)
2587 struct frame
*f
= decode_any_frame (frame
);
2588 Lisp_Object value
= Qnil
;
2590 CHECK_SYMBOL (parameter
);
2592 XSETFRAME (frame
, f
);
2594 if (FRAME_LIVE_P (f
))
2596 /* Avoid consing in frequent cases. */
2597 if (EQ (parameter
, Qname
))
2599 #ifdef HAVE_X_WINDOWS
2600 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2601 value
= XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
);
2602 #endif /* HAVE_X_WINDOWS */
2603 else if (EQ (parameter
, Qbackground_color
)
2604 || EQ (parameter
, Qforeground_color
))
2606 value
= Fassq (parameter
, f
->param_alist
);
2609 value
= XCDR (value
);
2610 /* Fframe_parameters puts the actual fg/bg color names,
2611 even if f->param_alist says otherwise. This is
2612 important when param_alist's notion of colors is
2613 "unspecified". We need to do the same here. */
2614 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2616 Lisp_Object tem
= frame_unspecified_color (f
, value
);
2623 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2625 else if (EQ (parameter
, Qdisplay_type
)
2626 || EQ (parameter
, Qbackground_mode
))
2627 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2629 /* FIXME: Avoid this code path at all (as well as code duplication)
2630 by sharing more code with Fframe_parameters. */
2631 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2638 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2639 Smodify_frame_parameters
, 2, 2, 0,
2640 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2641 If FRAME is nil, it defaults to the selected frame.
2642 ALIST is an alist of parameters to change and their new values.
2643 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2644 The meaningful PARMs depend on the kind of frame.
2645 Undefined PARMs are ignored, but stored in the frame's parameter list
2646 so that `frame-parameters' will return them.
2648 The value of frame parameter FOO can also be accessed
2649 as a frame-local binding for the variable FOO, if you have
2650 enabled such bindings for that variable with `make-variable-frame-local'.
2651 Note that this functionality is obsolete as of Emacs 22.2, and its
2652 use is not recommended. Explicitly check for a frame-parameter instead. */)
2653 (Lisp_Object frame
, Lisp_Object alist
)
2655 struct frame
*f
= decode_live_frame (frame
);
2656 register Lisp_Object prop
, val
;
2660 /* I think this should be done with a hook. */
2661 #ifdef HAVE_WINDOW_SYSTEM
2662 if (FRAME_WINDOW_P (f
))
2663 x_set_frame_parameters (f
, alist
);
2667 if (FRAME_MSDOS_P (f
))
2668 IT_set_frame_parameters (f
, alist
);
2673 EMACS_INT length
= XFASTINT (Flength (alist
));
2676 Lisp_Object
*values
;
2678 SAFE_ALLOCA_LISP (parms
, 2 * length
);
2679 values
= parms
+ length
;
2681 /* Extract parm names and values into those vectors. */
2683 for (i
= 0; CONSP (alist
); alist
= XCDR (alist
))
2688 parms
[i
] = Fcar (elt
);
2689 values
[i
] = Fcdr (elt
);
2693 /* Now process them in reverse of specified order. */
2698 store_frame_param (f
, prop
, val
);
2700 if (EQ (prop
, Qforeground_color
)
2701 || EQ (prop
, Qbackground_color
))
2702 update_face_from_frame_parameter (f
, prop
, val
);
2710 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2712 doc
: /* Height in pixels of a line in the font in frame FRAME.
2713 If FRAME is omitted or nil, the selected frame is used.
2714 For a terminal frame, the value is always 1. */)
2717 #ifdef HAVE_WINDOW_SYSTEM
2718 struct frame
*f
= decode_any_frame (frame
);
2720 if (FRAME_WINDOW_P (f
))
2721 return make_number (FRAME_LINE_HEIGHT (f
));
2724 return make_number (1);
2728 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2730 doc
: /* Width in pixels of characters in the font in frame FRAME.
2731 If FRAME is omitted or nil, the selected frame is used.
2732 On a graphical screen, the width is the standard width of the default font.
2733 For a terminal screen, the value is always 1. */)
2736 #ifdef HAVE_WINDOW_SYSTEM
2737 struct frame
*f
= decode_any_frame (frame
);
2739 if (FRAME_WINDOW_P (f
))
2740 return make_number (FRAME_COLUMN_WIDTH (f
));
2743 return make_number (1);
2746 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2747 Sframe_pixel_height
, 0, 1, 0,
2748 doc
: /* Return a FRAME's height in pixels.
2749 If FRAME is omitted or nil, the selected frame is used. The exact value
2750 of the result depends on the window-system and toolkit in use:
2752 In the Gtk+ version of Emacs, it includes only any window (including
2753 the minibuffer or echo area), mode line, and header line. It does not
2754 include the tool bar or menu bar.
2756 With other graphical versions, it also includes the tool bar and the
2759 For a text terminal, it includes the menu bar. In this case, the
2760 result is really in characters rather than pixels (i.e., is identical
2761 to `frame-height'). */)
2764 struct frame
*f
= decode_any_frame (frame
);
2766 #ifdef HAVE_WINDOW_SYSTEM
2767 if (FRAME_WINDOW_P (f
))
2768 return make_number (FRAME_PIXEL_HEIGHT (f
));
2771 return make_number (FRAME_TOTAL_LINES (f
));
2774 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2775 Sframe_pixel_width
, 0, 1, 0,
2776 doc
: /* Return FRAME's width in pixels.
2777 For a terminal frame, the result really gives the width in characters.
2778 If FRAME is omitted or nil, the selected frame is used. */)
2781 struct frame
*f
= decode_any_frame (frame
);
2783 #ifdef HAVE_WINDOW_SYSTEM
2784 if (FRAME_WINDOW_P (f
))
2785 return make_number (FRAME_PIXEL_WIDTH (f
));
2788 return make_number (FRAME_TOTAL_COLS (f
));
2791 DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width
,
2792 Stool_bar_pixel_width
, 0, 1, 0,
2793 doc
: /* Return width in pixels of FRAME's tool bar.
2794 The result is greater than zero only when the tool bar is on the left
2795 or right side of FRAME. If FRAME is omitted or nil, the selected frame
2799 #ifdef FRAME_TOOLBAR_WIDTH
2800 struct frame
*f
= decode_any_frame (frame
);
2802 if (FRAME_WINDOW_P (f
))
2803 return make_number (FRAME_TOOLBAR_WIDTH (f
));
2805 return make_number (0);
2808 DEFUN ("frame-text-cols", Fframe_text_cols
, Sframe_text_cols
, 0, 1, 0,
2809 doc
: /* Return width in columns of FRAME's text area. */)
2812 return make_number (FRAME_COLS (decode_any_frame (frame
)));
2815 DEFUN ("frame-text-lines", Fframe_text_lines
, Sframe_text_lines
, 0, 1, 0,
2816 doc
: /* Return height in lines of FRAME's text area. */)
2819 return make_number (FRAME_LINES (decode_any_frame (frame
)));
2822 DEFUN ("frame-total-cols", Fframe_total_cols
, Sframe_total_cols
, 0, 1, 0,
2823 doc
: /* Return number of total columns of FRAME. */)
2826 return make_number (FRAME_TOTAL_COLS (decode_any_frame (frame
)));
2829 DEFUN ("frame-total-lines", Fframe_total_lines
, Sframe_total_lines
, 0, 1, 0,
2830 doc
: /* Return number of total lines of FRAME. */)
2833 return make_number (FRAME_TOTAL_LINES (decode_any_frame (frame
)));
2836 DEFUN ("frame-text-width", Fframe_text_width
, Sframe_text_width
, 0, 1, 0,
2837 doc
: /* Return text area width of FRAME in pixels. */)
2840 return make_number (FRAME_TEXT_WIDTH (decode_any_frame (frame
)));
2843 DEFUN ("frame-text-height", Fframe_text_height
, Sframe_text_height
, 0, 1, 0,
2844 doc
: /* Return text area height of FRAME in pixels. */)
2847 return make_number (FRAME_TEXT_HEIGHT (decode_any_frame (frame
)));
2850 DEFUN ("frame-scroll-bar-width", Fscroll_bar_width
, Sscroll_bar_width
, 0, 1, 0,
2851 doc
: /* Return scroll bar width of FRAME in pixels. */)
2854 return make_number (FRAME_SCROLL_BAR_AREA_WIDTH (decode_any_frame (frame
)));
2857 DEFUN ("frame-scroll-bar-height", Fscroll_bar_height
, Sscroll_bar_height
, 0, 1, 0,
2858 doc
: /* Return scroll bar height of FRAME in pixels. */)
2861 return make_number (FRAME_SCROLL_BAR_AREA_HEIGHT (decode_any_frame (frame
)));
2864 DEFUN ("frame-fringe-width", Ffringe_width
, Sfringe_width
, 0, 1, 0,
2865 doc
: /* Return fringe width of FRAME in pixels. */)
2868 return make_number (FRAME_TOTAL_FRINGE_WIDTH (decode_any_frame (frame
)));
2871 DEFUN ("frame-border-width", Fborder_width
, Sborder_width
, 0, 1, 0,
2872 doc
: /* Return border width of FRAME in pixels. */)
2875 return make_number (FRAME_INTERNAL_BORDER_WIDTH (decode_any_frame (frame
)));
2878 DEFUN ("frame-right-divider-width", Fright_divider_width
, Sright_divider_width
, 0, 1, 0,
2879 doc
: /* Return width (in pixels) of vertical window dividers on FRAME. */)
2882 return make_number (FRAME_RIGHT_DIVIDER_WIDTH (decode_any_frame (frame
)));
2885 DEFUN ("frame-bottom-divider-width", Fbottom_divider_width
, Sbottom_divider_width
, 0, 1, 0,
2886 doc
: /* Return width (in pixels) of horizontal window dividers on FRAME. */)
2889 return make_number (FRAME_BOTTOM_DIVIDER_WIDTH (decode_any_frame (frame
)));
2892 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 4, 0,
2893 doc
: /* Set text height of frame FRAME to HEIGHT lines.
2894 Optional third arg PRETEND non-nil means that redisplay should use
2895 HEIGHT lines but that the idea of the actual height of the frame should
2898 Optional fourth argument PIXELWISE non-nil means that FRAME should be
2899 HEIGHT pixels high. Note: When `frame-resize-pixelwise' is nil, some
2900 window managers may refuse to honor a HEIGHT that is not an integer
2901 multiple of the default frame font height. */)
2902 (Lisp_Object frame
, Lisp_Object height
, Lisp_Object pretend
, Lisp_Object pixelwise
)
2904 struct frame
*f
= decode_live_frame (frame
);
2907 CHECK_TYPE_RANGED_INTEGER (int, height
);
2909 pixel_height
= (!NILP (pixelwise
)
2911 : XINT (height
) * FRAME_LINE_HEIGHT (f
));
2912 adjust_frame_size (f
, -1, pixel_height
, 1, !NILP (pretend
), Qheight
);
2917 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 4, 0,
2918 doc
: /* Set text width of frame FRAME to WIDTH columns.
2919 Optional third arg PRETEND non-nil means that redisplay should use WIDTH
2920 columns but that the idea of the actual width of the frame should not
2923 Optional fourth argument PIXELWISE non-nil means that FRAME should be
2924 WIDTH pixels wide. Note: When `frame-resize-pixelwise' is nil, some
2925 window managers may refuse to honor a WIDTH that is not an integer
2926 multiple of the default frame font width. */)
2927 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object pretend
, Lisp_Object pixelwise
)
2929 struct frame
*f
= decode_live_frame (frame
);
2932 CHECK_TYPE_RANGED_INTEGER (int, width
);
2934 pixel_width
= (!NILP (pixelwise
)
2936 : XINT (width
) * FRAME_COLUMN_WIDTH (f
));
2937 adjust_frame_size (f
, pixel_width
, -1, 1, !NILP (pretend
), Qwidth
);
2942 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 4, 0,
2943 doc
: /* Set text size of FRAME to WIDTH by HEIGHT, measured in characters.
2944 Optional argument PIXELWISE non-nil means to measure in pixels. Note:
2945 When `frame-resize-pixelwise' is nil, some window managers may refuse to
2946 honor a WIDTH that is not an integer multiple of the default frame font
2947 width or a HEIGHT that is not an integer multiple of the default frame
2949 (Lisp_Object frame
, Lisp_Object width
, Lisp_Object height
, Lisp_Object pixelwise
)
2951 struct frame
*f
= decode_live_frame (frame
);
2952 int pixel_width
, pixel_height
;
2954 CHECK_TYPE_RANGED_INTEGER (int, width
);
2955 CHECK_TYPE_RANGED_INTEGER (int, height
);
2957 pixel_width
= (!NILP (pixelwise
)
2959 : XINT (width
) * FRAME_COLUMN_WIDTH (f
));
2960 pixel_height
= (!NILP (pixelwise
)
2962 : XINT (height
) * FRAME_LINE_HEIGHT (f
));
2963 adjust_frame_size (f
, pixel_width
, pixel_height
, 1, 0, Qsize
);
2968 DEFUN ("set-frame-position", Fset_frame_position
,
2969 Sset_frame_position
, 3, 3, 0,
2970 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2971 If FRAME is nil, the selected frame is used. XOFFSET and YOFFSET are
2972 actually the position of the upper left corner of the frame. Negative
2973 values for XOFFSET or YOFFSET are interpreted relative to the rightmost
2974 or bottommost possible position (that stays within the screen). */)
2975 (Lisp_Object frame
, Lisp_Object xoffset
, Lisp_Object yoffset
)
2977 register struct frame
*f
= decode_live_frame (frame
);
2979 CHECK_TYPE_RANGED_INTEGER (int, xoffset
);
2980 CHECK_TYPE_RANGED_INTEGER (int, yoffset
);
2982 /* I think this should be done with a hook. */
2983 #ifdef HAVE_WINDOW_SYSTEM
2984 if (FRAME_WINDOW_P (f
))
2985 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2992 /***********************************************************************
2994 ***********************************************************************/
2996 /* Connect the frame-parameter names for X frames
2997 to the ways of passing the parameter values to the window system.
2999 The name of a parameter, as a Lisp symbol,
3000 has an `x-frame-parameter' property which is an integer in Lisp
3001 that is an index in this table. */
3003 struct frame_parm_table
{
3008 static const struct frame_parm_table frame_parms
[] =
3010 {"auto-raise", SYMBOL_INDEX (Qauto_raise
)},
3011 {"auto-lower", SYMBOL_INDEX (Qauto_lower
)},
3012 {"background-color", -1},
3013 {"border-color", SYMBOL_INDEX (Qborder_color
)},
3014 {"border-width", SYMBOL_INDEX (Qborder_width
)},
3015 {"cursor-color", SYMBOL_INDEX (Qcursor_color
)},
3016 {"cursor-type", SYMBOL_INDEX (Qcursor_type
)},
3018 {"foreground-color", -1},
3019 {"icon-name", SYMBOL_INDEX (Qicon_name
)},
3020 {"icon-type", SYMBOL_INDEX (Qicon_type
)},
3021 {"internal-border-width", SYMBOL_INDEX (Qinternal_border_width
)},
3022 {"right-divider-width", SYMBOL_INDEX (Qright_divider_width
)},
3023 {"bottom-divider-width", SYMBOL_INDEX (Qbottom_divider_width
)},
3024 {"menu-bar-lines", SYMBOL_INDEX (Qmenu_bar_lines
)},
3025 {"mouse-color", SYMBOL_INDEX (Qmouse_color
)},
3026 {"name", SYMBOL_INDEX (Qname
)},
3027 {"scroll-bar-width", SYMBOL_INDEX (Qscroll_bar_width
)},
3028 {"scroll-bar-height", SYMBOL_INDEX (Qscroll_bar_height
)},
3029 {"title", SYMBOL_INDEX (Qtitle
)},
3030 {"unsplittable", SYMBOL_INDEX (Qunsplittable
)},
3031 {"vertical-scroll-bars", SYMBOL_INDEX (Qvertical_scroll_bars
)},
3032 {"horizontal-scroll-bars", SYMBOL_INDEX (Qhorizontal_scroll_bars
)},
3033 {"visibility", SYMBOL_INDEX (Qvisibility
)},
3034 {"tool-bar-lines", SYMBOL_INDEX (Qtool_bar_lines
)},
3035 {"scroll-bar-foreground", SYMBOL_INDEX (Qscroll_bar_foreground
)},
3036 {"scroll-bar-background", SYMBOL_INDEX (Qscroll_bar_background
)},
3037 {"screen-gamma", SYMBOL_INDEX (Qscreen_gamma
)},
3038 {"line-spacing", SYMBOL_INDEX (Qline_spacing
)},
3039 {"left-fringe", SYMBOL_INDEX (Qleft_fringe
)},
3040 {"right-fringe", SYMBOL_INDEX (Qright_fringe
)},
3041 {"wait-for-wm", SYMBOL_INDEX (Qwait_for_wm
)},
3042 {"fullscreen", SYMBOL_INDEX (Qfullscreen
)},
3043 {"font-backend", SYMBOL_INDEX (Qfont_backend
)},
3044 {"alpha", SYMBOL_INDEX (Qalpha
)},
3045 {"sticky", SYMBOL_INDEX (Qsticky
)},
3046 {"tool-bar-position", SYMBOL_INDEX (Qtool_bar_position
)},
3049 #ifdef HAVE_WINDOW_SYSTEM
3051 /* Change the parameters of frame F as specified by ALIST.
3052 If a parameter is not specially recognized, do nothing special;
3053 otherwise call the `x_set_...' function for that parameter.
3054 Except for certain geometry properties, always call store_frame_param
3055 to store the new value in the parameter alist. */
3058 x_set_frame_parameters (struct frame
*f
, Lisp_Object alist
)
3062 /* If both of these parameters are present, it's more efficient to
3063 set them both at once. So we wait until we've looked at the
3064 entire list before we set them. */
3065 int width
IF_LINT (= 0), height
IF_LINT (= 0);
3066 bool width_change
= false, height_change
= false;
3069 Lisp_Object left
, top
;
3071 /* Same with these. */
3072 Lisp_Object icon_left
, icon_top
;
3074 /* And with this. */
3075 Lisp_Object fullscreen
;
3076 bool fullscreen_change
= false;
3078 /* Record in these vectors all the parms specified. */
3080 Lisp_Object
*values
;
3082 bool left_no_change
= 0, top_no_change
= 0;
3083 #ifdef HAVE_X_WINDOWS
3084 bool icon_left_no_change
= 0, icon_top_no_change
= 0;
3088 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3092 SAFE_ALLOCA_LISP (parms
, 2 * i
);
3095 /* Extract parm names and values into those vectors. */
3098 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3103 parms
[i
] = Fcar (elt
);
3104 values
[i
] = Fcdr (elt
);
3107 /* TAIL and ALIST are not used again below here. */
3108 alist
= tail
= Qnil
;
3110 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
3111 because their values appear in VALUES and strings are not valid. */
3112 top
= left
= Qunbound
;
3113 icon_left
= icon_top
= Qunbound
;
3115 /* Process foreground_color and background_color before anything else.
3116 They are independent of other properties, but other properties (e.g.,
3117 cursor_color) are dependent upon them. */
3118 /* Process default font as well, since fringe widths depends on it. */
3119 for (p
= 0; p
< i
; p
++)
3121 Lisp_Object prop
, val
;
3125 if (EQ (prop
, Qforeground_color
)
3126 || EQ (prop
, Qbackground_color
)
3127 || EQ (prop
, Qfont
))
3129 register Lisp_Object param_index
, old_value
;
3131 old_value
= get_frame_param (f
, prop
);
3132 if (NILP (Fequal (val
, old_value
)))
3134 store_frame_param (f
, prop
, val
);
3136 param_index
= Fget (prop
, Qx_frame_parameter
);
3137 if (NATNUMP (param_index
)
3138 && XFASTINT (param_index
) < ARRAYELTS (frame_parms
)
3139 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3140 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3145 /* Now process them in reverse of specified order. */
3148 Lisp_Object prop
, val
;
3153 if (EQ (prop
, Qwidth
) && RANGED_INTEGERP (0, val
, INT_MAX
))
3156 width
= XFASTINT (val
) * FRAME_COLUMN_WIDTH (f
) ;
3158 else if (EQ (prop
, Qheight
) && RANGED_INTEGERP (0, val
, INT_MAX
))
3161 height
= XFASTINT (val
) * FRAME_LINE_HEIGHT (f
);
3163 else if (EQ (prop
, Qtop
))
3165 else if (EQ (prop
, Qleft
))
3167 else if (EQ (prop
, Qicon_top
))
3169 else if (EQ (prop
, Qicon_left
))
3171 else if (EQ (prop
, Qfullscreen
))
3174 fullscreen_change
= true;
3176 else if (EQ (prop
, Qforeground_color
)
3177 || EQ (prop
, Qbackground_color
)
3178 || EQ (prop
, Qfont
))
3179 /* Processed above. */
3183 register Lisp_Object param_index
, old_value
;
3185 old_value
= get_frame_param (f
, prop
);
3187 store_frame_param (f
, prop
, val
);
3189 param_index
= Fget (prop
, Qx_frame_parameter
);
3190 if (NATNUMP (param_index
)
3191 && XFASTINT (param_index
) < ARRAYELTS (frame_parms
)
3192 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3193 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3197 /* Don't die if just one of these was set. */
3198 if (EQ (left
, Qunbound
))
3201 if (f
->left_pos
< 0)
3202 left
= list2 (Qplus
, make_number (f
->left_pos
));
3204 XSETINT (left
, f
->left_pos
);
3206 if (EQ (top
, Qunbound
))
3210 top
= list2 (Qplus
, make_number (f
->top_pos
));
3212 XSETINT (top
, f
->top_pos
);
3215 /* If one of the icon positions was not set, preserve or default it. */
3216 if (! TYPE_RANGED_INTEGERP (int, icon_left
))
3218 #ifdef HAVE_X_WINDOWS
3219 icon_left_no_change
= 1;
3221 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3222 if (NILP (icon_left
))
3223 XSETINT (icon_left
, 0);
3225 if (! TYPE_RANGED_INTEGERP (int, icon_top
))
3227 #ifdef HAVE_X_WINDOWS
3228 icon_top_no_change
= 1;
3230 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3231 if (NILP (icon_top
))
3232 XSETINT (icon_top
, 0);
3235 /* Don't set these parameters unless they've been explicitly
3236 specified. The window might be mapped or resized while we're in
3237 this function, and we don't want to override that unless the lisp
3238 code has asked for it.
3240 Don't set these parameters unless they actually differ from the
3241 window's current parameters; the window may not actually exist
3246 XSETFRAME (frame
, f
);
3248 if ((width_change
&& width
!= FRAME_TEXT_WIDTH (f
))
3249 || (height_change
&& height
!= FRAME_TEXT_HEIGHT (f
))
3250 || (f
->can_x_set_window_size
&& (f
->new_height
|| f
->new_width
)))
3252 /* If necessary provide default values for HEIGHT and WIDTH. Do
3253 that here since otherwise a size change implied by an
3254 intermittent font change may get lost as in Bug#17142. */
3256 width
= ((f
->can_x_set_window_size
&& f
->new_width
)
3259 : (f
->new_width
* FRAME_COLUMN_WIDTH (f
)))
3260 : FRAME_TEXT_WIDTH (f
));
3263 height
= ((f
->can_x_set_window_size
&& f
->new_height
)
3266 : (f
->new_height
* FRAME_LINE_HEIGHT (f
)))
3267 : FRAME_TEXT_HEIGHT (f
));
3269 Fset_frame_size (frame
, make_number (width
), make_number (height
), Qt
);
3272 if ((!NILP (left
) || !NILP (top
))
3273 && ! (left_no_change
&& top_no_change
)
3274 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3275 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3280 /* Record the signs. */
3281 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3282 if (EQ (left
, Qminus
))
3283 f
->size_hint_flags
|= XNegative
;
3284 else if (TYPE_RANGED_INTEGERP (int, left
))
3286 leftpos
= XINT (left
);
3288 f
->size_hint_flags
|= XNegative
;
3290 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3291 && CONSP (XCDR (left
))
3292 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
3294 leftpos
= - XINT (XCAR (XCDR (left
)));
3295 f
->size_hint_flags
|= XNegative
;
3297 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3298 && CONSP (XCDR (left
))
3299 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
3301 leftpos
= XINT (XCAR (XCDR (left
)));
3304 if (EQ (top
, Qminus
))
3305 f
->size_hint_flags
|= YNegative
;
3306 else if (TYPE_RANGED_INTEGERP (int, top
))
3308 toppos
= XINT (top
);
3310 f
->size_hint_flags
|= YNegative
;
3312 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3313 && CONSP (XCDR (top
))
3314 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
3316 toppos
= - XINT (XCAR (XCDR (top
)));
3317 f
->size_hint_flags
|= YNegative
;
3319 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
3320 && CONSP (XCDR (top
))
3321 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
3323 toppos
= XINT (XCAR (XCDR (top
)));
3327 /* Store the numeric value of the position. */
3328 f
->top_pos
= toppos
;
3329 f
->left_pos
= leftpos
;
3331 f
->win_gravity
= NorthWestGravity
;
3333 /* Actually set that position, and convert to absolute. */
3334 x_set_offset (f
, leftpos
, toppos
, -1);
3337 if (fullscreen_change
)
3339 Lisp_Object old_value
= get_frame_param (f
, Qfullscreen
);
3341 frame_size_history_add
3342 (f
, Qx_set_fullscreen
, 0, 0, list2 (old_value
, fullscreen
));
3344 store_frame_param (f
, Qfullscreen
, fullscreen
);
3345 if (!EQ (fullscreen
, old_value
))
3346 x_set_fullscreen (f
, fullscreen
, old_value
);
3350 #ifdef HAVE_X_WINDOWS
3351 if ((!NILP (icon_left
) || !NILP (icon_top
))
3352 && ! (icon_left_no_change
&& icon_top_no_change
))
3353 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3354 #endif /* HAVE_X_WINDOWS */
3361 /* Insert a description of internally-recorded parameters of frame X
3362 into the parameter alist *ALISTPTR that is to be given to the user.
3363 Only parameters that are specific to the X window system
3364 and whose values are not correctly recorded in the frame's
3365 param_alist need to be considered here. */
3368 x_report_frame_params (struct frame
*f
, Lisp_Object
*alistptr
)
3372 char buf
[INT_BUFSIZE_BOUND (w
)];
3374 /* Represent negative positions (off the top or left screen edge)
3375 in a way that Fmodify_frame_parameters will understand correctly. */
3376 XSETINT (tem
, f
->left_pos
);
3377 if (f
->left_pos
>= 0)
3378 store_in_alist (alistptr
, Qleft
, tem
);
3380 store_in_alist (alistptr
, Qleft
, list2 (Qplus
, tem
));
3382 XSETINT (tem
, f
->top_pos
);
3383 if (f
->top_pos
>= 0)
3384 store_in_alist (alistptr
, Qtop
, tem
);
3386 store_in_alist (alistptr
, Qtop
, list2 (Qplus
, tem
));
3388 store_in_alist (alistptr
, Qborder_width
,
3389 make_number (f
->border_width
));
3390 store_in_alist (alistptr
, Qinternal_border_width
,
3391 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3392 store_in_alist (alistptr
, Qright_divider_width
,
3393 make_number (FRAME_RIGHT_DIVIDER_WIDTH (f
)));
3394 store_in_alist (alistptr
, Qbottom_divider_width
,
3395 make_number (FRAME_BOTTOM_DIVIDER_WIDTH (f
)));
3396 store_in_alist (alistptr
, Qleft_fringe
,
3397 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3398 store_in_alist (alistptr
, Qright_fringe
,
3399 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3400 store_in_alist (alistptr
, Qscroll_bar_width
,
3401 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3403 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3404 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3405 /* nil means "use default width"
3406 for non-toolkit scroll bar.
3407 ruler-mode.el depends on this. */
3409 store_in_alist (alistptr
, Qscroll_bar_height
,
3410 (! FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)
3412 : FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) > 0
3413 ? make_number (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
3414 /* nil means "use default height"
3415 for non-toolkit scroll bar. */
3417 /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on
3418 MS-Windows it returns a value whose type is HANDLE, which is
3419 actually a pointer. Explicit casting avoids compiler
3421 w
= (uintptr_t) FRAME_X_WINDOW (f
);
3422 store_in_alist (alistptr
, Qwindow_id
,
3423 make_formatted_string (buf
, "%"pMu
, w
));
3424 #ifdef HAVE_X_WINDOWS
3425 #ifdef USE_X_TOOLKIT
3426 /* Tooltip frame may not have this widget. */
3427 if (FRAME_X_OUTPUT (f
)->widget
)
3429 w
= (uintptr_t) FRAME_OUTER_WINDOW (f
);
3430 store_in_alist (alistptr
, Qouter_window_id
,
3431 make_formatted_string (buf
, "%"pMu
, w
));
3433 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3434 store_in_alist (alistptr
, Qvisibility
,
3435 (FRAME_VISIBLE_P (f
) ? Qt
3436 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3437 store_in_alist (alistptr
, Qdisplay
,
3438 XCAR (FRAME_DISPLAY_INFO (f
)->name_list_element
));
3440 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_DISPLAY_INFO (f
)->root_window
)
3443 tem
= make_natnum ((uintptr_t) FRAME_X_OUTPUT (f
)->parent_desc
);
3444 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3445 store_in_alist (alistptr
, Qparent_id
, tem
);
3446 store_in_alist (alistptr
, Qtool_bar_position
, FRAME_TOOL_BAR_POSITION (f
));
3450 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3451 the previous value of that parameter, NEW_VALUE is the new value. */
3454 x_set_fullscreen (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3456 if (NILP (new_value
))
3457 f
->want_fullscreen
= FULLSCREEN_NONE
;
3458 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3459 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3460 else if (EQ (new_value
, Qfullwidth
))
3461 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3462 else if (EQ (new_value
, Qfullheight
))
3463 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3464 else if (EQ (new_value
, Qmaximized
))
3465 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3467 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3468 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3472 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3473 the previous value of that parameter, NEW_VALUE is the new value. */
3476 x_set_line_spacing (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3478 if (NILP (new_value
))
3479 f
->extra_line_spacing
= 0;
3480 else if (RANGED_INTEGERP (0, new_value
, INT_MAX
))
3481 f
->extra_line_spacing
= XFASTINT (new_value
);
3482 else if (FLOATP (new_value
))
3484 int new_spacing
= XFLOAT_DATA (new_value
) * FRAME_LINE_HEIGHT (f
) + 0.5;
3486 if (new_spacing
>= 0)
3487 f
->extra_line_spacing
= new_spacing
;
3489 signal_error ("Invalid line-spacing", new_value
);
3492 signal_error ("Invalid line-spacing", new_value
);
3493 if (FRAME_VISIBLE_P (f
))
3498 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3499 the previous value of that parameter, NEW_VALUE is the new value. */
3502 x_set_screen_gamma (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3504 Lisp_Object bgcolor
;
3506 if (NILP (new_value
))
3508 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3509 /* The value 0.4545 is the normal viewing gamma. */
3510 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3512 signal_error ("Invalid screen-gamma", new_value
);
3514 /* Apply the new gamma value to the frame background. */
3515 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3516 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3518 Lisp_Object parm_index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3519 if (NATNUMP (parm_index
)
3520 && XFASTINT (parm_index
) < ARRAYELTS (frame_parms
)
3521 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3522 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (parm_index
)])
3526 Fclear_face_cache (Qnil
);
3531 x_set_font (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3533 Lisp_Object font_object
;
3535 #ifdef HAVE_X_WINDOWS
3536 Lisp_Object font_param
= arg
;
3539 /* Set the frame parameter back to the old value because we may
3540 fail to use ARG as the new parameter value. */
3541 store_frame_param (f
, Qfont
, oldval
);
3543 /* ARG is a fontset name, a font name, a cons of fontset name and a
3544 font object, or a font object. In the last case, this function
3548 fontset
= fs_query_fontset (arg
, 0);
3551 font_object
= font_open_by_name (f
, arg
);
3552 if (NILP (font_object
))
3553 error ("Font `%s' is not defined", SSDATA (arg
));
3554 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3556 else if (fontset
> 0)
3558 font_object
= font_open_by_name (f
, fontset_ascii (fontset
));
3559 if (NILP (font_object
))
3560 error ("Font `%s' is not defined", SDATA (arg
));
3561 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3564 error ("The default fontset can't be used for a frame font");
3566 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3568 /* This is the case that the ASCII font of F's fontset XCAR
3569 (arg) is changed to the font XCDR (arg) by
3570 `set-fontset-font'. */
3571 fontset
= fs_query_fontset (XCAR (arg
), 0);
3573 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3574 font_object
= XCDR (arg
);
3575 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3576 #ifdef HAVE_X_WINDOWS
3577 font_param
= Ffont_get (font_object
, QCname
);
3580 else if (FONT_OBJECT_P (arg
))
3583 #ifdef HAVE_X_WINDOWS
3584 font_param
= Ffont_get (font_object
, QCname
);
3586 /* This is to store the XLFD font name in the frame parameter for
3587 backward compatibility. We should store the font-object
3588 itself in the future. */
3589 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3590 fontset
= FRAME_FONTSET (f
);
3591 /* Check if we can use the current fontset. If not, set FONTSET
3592 to -1 to generate a new fontset from FONT-OBJECT. */
3595 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3596 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3599 signal_error ("Invalid font name", ascii_font
);
3601 if (! font_match_p (spec
, font_object
))
3606 signal_error ("Invalid font", arg
);
3608 if (! NILP (Fequal (font_object
, oldval
)))
3611 x_new_font (f
, font_object
, fontset
);
3612 store_frame_param (f
, Qfont
, arg
);
3613 #ifdef HAVE_X_WINDOWS
3614 store_frame_param (f
, Qfont_param
, font_param
);
3616 /* Recalculate toolbar height. */
3617 f
->n_tool_bar_rows
= 0;
3619 /* Ensure we redraw it. */
3620 clear_current_matrices (f
);
3622 /* Attempt to hunt down bug#16028. */
3623 SET_FRAME_GARBAGED (f
);
3625 recompute_basic_faces (f
);
3627 do_pending_window_change (0);
3629 /* We used to call face-set-after-frame-default here, but it leads to
3630 recursive calls (since that function can set the `default' face's
3631 font which in turns changes the frame's `font' parameter).
3632 Also I don't know what this call is meant to do, but it seems the
3633 wrong way to do it anyway (it does a lot more work than what seems
3634 reasonable in response to a change to `font'). */
3639 x_set_font_backend (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3641 if (! NILP (new_value
)
3642 && !CONSP (new_value
))
3646 CHECK_STRING (new_value
);
3647 p0
= p1
= SSDATA (new_value
);
3651 while (*p1
&& ! c_isspace (*p1
) && *p1
!= ',') p1
++;
3653 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3659 while ((c
= *++p1
) && c_isspace (c
));
3663 new_value
= Fnreverse (new_value
);
3666 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3670 free_all_realized_faces (Qnil
);
3672 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3673 if (NILP (new_value
))
3675 if (NILP (old_value
))
3676 error ("No font backend available");
3677 font_update_drivers (f
, old_value
);
3678 error ("None of specified font backends are available");
3680 store_frame_param (f
, Qfont_backend
, new_value
);
3686 XSETFRAME (frame
, f
);
3687 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3689 windows_or_buffers_changed
= 18;
3694 x_set_left_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3696 int unit
= FRAME_COLUMN_WIDTH (f
);
3697 int old_width
= FRAME_LEFT_FRINGE_WIDTH (f
);
3700 new_width
= (RANGED_INTEGERP (-INT_MAX
, new_value
, INT_MAX
)
3701 ? eabs (XINT (new_value
)) : 8);
3703 if (new_width
!= old_width
)
3705 FRAME_LEFT_FRINGE_WIDTH (f
) = new_width
;
3706 FRAME_FRINGE_COLS (f
) /* Round up. */
3707 = (new_width
+ FRAME_RIGHT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
3709 if (FRAME_X_WINDOW (f
) != 0)
3710 adjust_frame_size (f
, -1, -1, 3, 0, Qleft_fringe
);
3712 SET_FRAME_GARBAGED (f
);
3718 x_set_right_fringe (struct frame
*f
, Lisp_Object new_value
, Lisp_Object old_value
)
3720 int unit
= FRAME_COLUMN_WIDTH (f
);
3721 int old_width
= FRAME_RIGHT_FRINGE_WIDTH (f
);
3724 new_width
= (RANGED_INTEGERP (-INT_MAX
, new_value
, INT_MAX
)
3725 ? eabs (XINT (new_value
)) : 8);
3727 if (new_width
!= old_width
)
3729 FRAME_RIGHT_FRINGE_WIDTH (f
) = new_width
;
3730 FRAME_FRINGE_COLS (f
) /* Round up. */
3731 = (new_width
+ FRAME_LEFT_FRINGE_WIDTH (f
) + unit
- 1) / unit
;
3733 if (FRAME_X_WINDOW (f
) != 0)
3734 adjust_frame_size (f
, -1, -1, 3, 0, Qright_fringe
);
3736 SET_FRAME_GARBAGED (f
);
3742 x_set_border_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3744 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3746 if (XINT (arg
) == f
->border_width
)
3749 if (FRAME_X_WINDOW (f
) != 0)
3750 error ("Cannot change the border width of a frame");
3752 f
->border_width
= XINT (arg
);
3756 x_set_right_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3758 int old
= FRAME_RIGHT_DIVIDER_WIDTH (f
);
3760 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3761 FRAME_RIGHT_DIVIDER_WIDTH (f
) = XINT (arg
);
3762 if (FRAME_RIGHT_DIVIDER_WIDTH (f
) < 0)
3763 FRAME_RIGHT_DIVIDER_WIDTH (f
) = 0;
3764 if (FRAME_RIGHT_DIVIDER_WIDTH (f
) != old
)
3766 adjust_frame_size (f
, -1, -1, 4, 0, Qright_divider_width
);
3767 adjust_frame_glyphs (f
);
3768 SET_FRAME_GARBAGED (f
);
3774 x_set_bottom_divider_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3776 int old
= FRAME_BOTTOM_DIVIDER_WIDTH (f
);
3778 CHECK_TYPE_RANGED_INTEGER (int, arg
);
3779 FRAME_BOTTOM_DIVIDER_WIDTH (f
) = XINT (arg
);
3780 if (FRAME_BOTTOM_DIVIDER_WIDTH (f
) < 0)
3781 FRAME_BOTTOM_DIVIDER_WIDTH (f
) = 0;
3782 if (FRAME_BOTTOM_DIVIDER_WIDTH (f
) != old
)
3784 adjust_frame_size (f
, -1, -1, 4, 0, Qbottom_divider_width
);
3785 adjust_frame_glyphs (f
);
3786 SET_FRAME_GARBAGED (f
);
3791 x_set_visibility (struct frame
*f
, Lisp_Object value
, Lisp_Object oldval
)
3794 XSETFRAME (frame
, f
);
3797 Fmake_frame_invisible (frame
, Qt
);
3798 else if (EQ (value
, Qicon
))
3799 Ficonify_frame (frame
);
3801 Fmake_frame_visible (frame
);
3805 x_set_autoraise (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3807 f
->auto_raise
= !EQ (Qnil
, arg
);
3811 x_set_autolower (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3813 f
->auto_lower
= !EQ (Qnil
, arg
);
3817 x_set_unsplittable (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3819 f
->no_split
= !NILP (arg
);
3823 x_set_vertical_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3825 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3826 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3827 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3828 || (!NILP (arg
) && !FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3830 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3832 ? vertical_scroll_bar_none
3834 ? vertical_scroll_bar_left
3836 ? vertical_scroll_bar_right
3837 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3838 ? vertical_scroll_bar_left
3839 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3840 ? vertical_scroll_bar_right
3841 : vertical_scroll_bar_none
);
3843 /* We set this parameter before creating the X window for the
3844 frame, so we can get the geometry right from the start.
3845 However, if the window hasn't been created yet, we shouldn't
3846 call x_set_window_size. */
3847 if (FRAME_X_WINDOW (f
))
3848 adjust_frame_size (f
, -1, -1, 3, 0, Qvertical_scroll_bars
);
3850 SET_FRAME_GARBAGED (f
);
3855 x_set_horizontal_scroll_bars (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3857 #if USE_HORIZONTAL_SCROLL_BARS
3858 if ((NILP (arg
) && FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
))
3859 || (!NILP (arg
) && !FRAME_HAS_HORIZONTAL_SCROLL_BARS (f
)))
3861 f
->horizontal_scroll_bars
= NILP (arg
) ? false : true;
3863 /* We set this parameter before creating the X window for the
3864 frame, so we can get the geometry right from the start.
3865 However, if the window hasn't been created yet, we shouldn't
3866 call x_set_window_size. */
3867 if (FRAME_X_WINDOW (f
))
3868 adjust_frame_size (f
, -1, -1, 3, 0, Qhorizontal_scroll_bars
);
3870 SET_FRAME_GARBAGED (f
);
3876 x_set_scroll_bar_width (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3878 int unit
= FRAME_COLUMN_WIDTH (f
);
3882 x_set_scroll_bar_default_width (f
);
3884 if (FRAME_X_WINDOW (f
))
3885 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_width
);
3887 SET_FRAME_GARBAGED (f
);
3889 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3890 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3892 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3893 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + unit
- 1) / unit
;
3894 if (FRAME_X_WINDOW (f
))
3895 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_width
);
3897 SET_FRAME_GARBAGED (f
);
3900 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3901 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3905 x_set_scroll_bar_height (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3907 #if USE_HORIZONTAL_SCROLL_BARS
3908 int unit
= FRAME_LINE_HEIGHT (f
);
3912 x_set_scroll_bar_default_height (f
);
3914 if (FRAME_X_WINDOW (f
))
3915 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_height
);
3917 SET_FRAME_GARBAGED (f
);
3919 else if (RANGED_INTEGERP (1, arg
, INT_MAX
)
3920 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
))
3922 FRAME_CONFIG_SCROLL_BAR_HEIGHT (f
) = XFASTINT (arg
);
3923 FRAME_CONFIG_SCROLL_BAR_LINES (f
) = (XFASTINT (arg
) + unit
- 1) / unit
;
3924 if (FRAME_X_WINDOW (f
))
3925 adjust_frame_size (f
, -1, -1, 3, 0, Qscroll_bar_height
);
3927 SET_FRAME_GARBAGED (f
);
3930 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.vpos
= 0;
3931 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.y
= 0;
3936 x_set_alpha (struct frame
*f
, Lisp_Object arg
, Lisp_Object oldval
)
3943 for (i
= 0; i
< 2; i
++)
3956 else if (FLOATP (item
))
3958 alpha
= XFLOAT_DATA (item
);
3959 if (! (0 <= alpha
&& alpha
<= 1.0))
3960 args_out_of_range (make_float (0.0), make_float (1.0));
3962 else if (INTEGERP (item
))
3964 EMACS_INT ialpha
= XINT (item
);
3965 if (! (0 <= ialpha
&& alpha
<= 100))
3966 args_out_of_range (make_number (0), make_number (100));
3967 alpha
= ialpha
/ 100.0;
3970 wrong_type_argument (Qnumberp
, item
);
3974 for (i
= 0; i
< 2; i
++)
3975 f
->alpha
[i
] = newval
[i
];
3977 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3979 x_set_frame_alpha (f
);
3988 /* Non-zero if mouse is grabbed on DPYINFO
3989 and we know the frame where it is. */
3991 bool x_mouse_grabbed (Display_Info
*dpyinfo
)
3993 return (dpyinfo
->grabbed
3994 && dpyinfo
->last_mouse_frame
3995 && FRAME_LIVE_P (dpyinfo
->last_mouse_frame
));
3998 /* Re-highlight something with mouse-face properties
3999 on DPYINFO using saved frame and mouse position. */
4002 x_redo_mouse_highlight (Display_Info
*dpyinfo
)
4004 if (dpyinfo
->last_mouse_motion_frame
4005 && FRAME_LIVE_P (dpyinfo
->last_mouse_motion_frame
))
4006 note_mouse_highlight (dpyinfo
->last_mouse_motion_frame
,
4007 dpyinfo
->last_mouse_motion_x
,
4008 dpyinfo
->last_mouse_motion_y
);
4011 #endif /* HAVE_NS */
4013 /* Subroutines of creating an X frame. */
4015 /* Make sure that Vx_resource_name is set to a reasonable value.
4016 Fix it up, or set it to `emacs' if it is too hopeless. */
4019 validate_x_resource_name (void)
4022 /* Number of valid characters in the resource name. */
4023 ptrdiff_t good_count
= 0;
4024 /* Number of invalid characters in the resource name. */
4025 ptrdiff_t bad_count
= 0;
4029 if (!STRINGP (Vx_resource_class
))
4030 Vx_resource_class
= build_string (EMACS_CLASS
);
4032 if (STRINGP (Vx_resource_name
))
4034 unsigned char *p
= SDATA (Vx_resource_name
);
4036 len
= SBYTES (Vx_resource_name
);
4038 /* Only letters, digits, - and _ are valid in resource names.
4039 Count the valid characters and count the invalid ones. */
4040 for (i
= 0; i
< len
; i
++)
4043 if (! ((c
>= 'a' && c
<= 'z')
4044 || (c
>= 'A' && c
<= 'Z')
4045 || (c
>= '0' && c
<= '9')
4046 || c
== '-' || c
== '_'))
4053 /* Not a string => completely invalid. */
4054 bad_count
= 5, good_count
= 0;
4056 /* If name is valid already, return. */
4060 /* If name is entirely invalid, or nearly so, or is so implausibly
4061 large that alloca might not work, use `emacs'. */
4062 if (good_count
< 2 || MAX_ALLOCA
- sizeof ".customization" < len
)
4064 Vx_resource_name
= build_string ("emacs");
4068 /* Name is partly valid. Copy it and replace the invalid characters
4069 with underscores. */
4071 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
4073 for (i
= 0; i
< len
; i
++)
4075 int c
= SREF (new, i
);
4076 if (! ((c
>= 'a' && c
<= 'z')
4077 || (c
>= 'A' && c
<= 'Z')
4078 || (c
>= '0' && c
<= '9')
4079 || c
== '-' || c
== '_'))
4084 /* Get specified attribute from resource database RDB.
4085 See Fx_get_resource below for other parameters. */
4088 xrdb_get_resource (XrmDatabase rdb
, Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
, Lisp_Object subclass
)
4090 CHECK_STRING (attribute
);
4091 CHECK_STRING (class);
4093 if (!NILP (component
))
4094 CHECK_STRING (component
);
4095 if (!NILP (subclass
))
4096 CHECK_STRING (subclass
);
4097 if (NILP (component
) != NILP (subclass
))
4098 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
4100 validate_x_resource_name ();
4102 /* Allocate space for the components, the dots which separate them,
4103 and the final '\0'. Make them big enough for the worst case. */
4104 ptrdiff_t name_keysize
= (SBYTES (Vx_resource_name
)
4105 + (STRINGP (component
)
4106 ? SBYTES (component
) : 0)
4107 + SBYTES (attribute
)
4110 ptrdiff_t class_keysize
= (SBYTES (Vx_resource_class
)
4112 + (STRINGP (subclass
)
4113 ? SBYTES (subclass
) : 0)
4116 char *name_key
= SAFE_ALLOCA (name_keysize
+ class_keysize
);
4117 char *class_key
= name_key
+ name_keysize
;
4119 /* Start with emacs.FRAMENAME for the name (the specific one)
4120 and with `Emacs' for the class key (the general one). */
4121 char *nz
= lispstpcpy (name_key
, Vx_resource_name
);
4122 char *cz
= lispstpcpy (class_key
, Vx_resource_class
);
4125 cz
= lispstpcpy (cz
, class);
4127 if (!NILP (component
))
4130 lispstpcpy (cz
, subclass
);
4133 nz
= lispstpcpy (nz
, component
);
4137 lispstpcpy (nz
, attribute
);
4139 char *value
= x_get_string_resource (rdb
, name_key
, class_key
);
4142 if (value
&& *value
)
4143 return build_string (value
);
4149 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
4150 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
4151 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
4152 class, where INSTANCE is the name under which Emacs was invoked, or
4153 the name specified by the `-name' or `-rn' command-line arguments.
4155 The optional arguments COMPONENT and SUBCLASS add to the key and the
4156 class, respectively. You must specify both of them or neither.
4157 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
4158 and the class is `Emacs.CLASS.SUBCLASS'. */)
4159 (Lisp_Object attribute
, Lisp_Object
class, Lisp_Object component
,
4160 Lisp_Object subclass
)
4162 check_window_system (NULL
);
4164 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
4165 attribute
, class, component
, subclass
);
4168 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
4171 display_x_get_resource (Display_Info
*dpyinfo
, Lisp_Object attribute
,
4172 Lisp_Object
class, Lisp_Object component
,
4173 Lisp_Object subclass
)
4175 return xrdb_get_resource (dpyinfo
->xrdb
,
4176 attribute
, class, component
, subclass
);
4179 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
4180 /* Used when C code wants a resource value. */
4181 /* Called from oldXMenu/Create.c. */
4183 x_get_resource_string (const char *attribute
, const char *class)
4186 struct frame
*sf
= SELECTED_FRAME ();
4187 ptrdiff_t invocation_namelen
= SBYTES (Vinvocation_name
);
4190 /* Allocate space for the components, the dots which separate them,
4191 and the final '\0'. */
4192 ptrdiff_t name_keysize
= invocation_namelen
+ strlen (attribute
) + 2;
4193 ptrdiff_t class_keysize
= sizeof (EMACS_CLASS
) - 1 + strlen (class) + 2;
4194 char *name_key
= SAFE_ALLOCA (name_keysize
+ class_keysize
);
4195 char *class_key
= name_key
+ name_keysize
;
4197 esprintf (name_key
, "%s.%s", SSDATA (Vinvocation_name
), attribute
);
4198 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
4200 result
= x_get_string_resource (FRAME_DISPLAY_INFO (sf
)->xrdb
,
4201 name_key
, class_key
);
4207 /* Return the value of parameter PARAM.
4209 First search ALIST, then Vdefault_frame_alist, then the X defaults
4210 database, using ATTRIBUTE as the attribute name and CLASS as its class.
4212 Convert the resource to the type specified by desired_type.
4214 If no default is specified, return Qunbound. If you call
4215 x_get_arg, make sure you deal with Qunbound in a reasonable way,
4216 and don't let it get stored in any Lisp-visible variables! */
4219 x_get_arg (Display_Info
*dpyinfo
, Lisp_Object alist
, Lisp_Object param
,
4220 const char *attribute
, const char *class, enum resource_types type
)
4224 tem
= Fassq (param
, alist
);
4228 /* If we find this parm in ALIST, clear it out
4229 so that it won't be "left over" at the end. */
4231 XSETCAR (tem
, Qnil
);
4232 /* In case the parameter appears more than once in the alist,
4234 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
4235 if (CONSP (XCAR (tail
))
4236 && EQ (XCAR (XCAR (tail
)), param
))
4237 XSETCAR (XCAR (tail
), Qnil
);
4240 tem
= Fassq (param
, Vdefault_frame_alist
);
4242 /* If it wasn't specified in ALIST or the Lisp-level defaults,
4243 look in the X resources. */
4246 if (attribute
&& dpyinfo
)
4248 AUTO_STRING (at
, attribute
);
4249 AUTO_STRING (cl
, class);
4250 tem
= display_x_get_resource (dpyinfo
, at
, cl
, Qnil
, Qnil
);
4257 case RES_TYPE_NUMBER
:
4258 return make_number (atoi (SSDATA (tem
)));
4260 case RES_TYPE_BOOLEAN_NUMBER
:
4261 if (!strcmp (SSDATA (tem
), "on")
4262 || !strcmp (SSDATA (tem
), "true"))
4263 return make_number (1);
4264 return make_number (atoi (SSDATA (tem
)));
4267 case RES_TYPE_FLOAT
:
4268 return make_float (atof (SSDATA (tem
)));
4270 case RES_TYPE_BOOLEAN
:
4271 tem
= Fdowncase (tem
);
4272 if (!strcmp (SSDATA (tem
), "on")
4274 || !strcmp (SSDATA (tem
), "yes")
4276 || !strcmp (SSDATA (tem
), "true"))
4281 case RES_TYPE_STRING
:
4284 case RES_TYPE_SYMBOL
:
4285 /* As a special case, we map the values `true' and `on'
4286 to Qt, and `false' and `off' to Qnil. */
4289 lower
= Fdowncase (tem
);
4290 if (!strcmp (SSDATA (lower
), "on")
4292 || !strcmp (SSDATA (lower
), "yes")
4294 || !strcmp (SSDATA (lower
), "true"))
4296 else if (!strcmp (SSDATA (lower
), "off")
4298 || !strcmp (SSDATA (lower
), "no")
4300 || !strcmp (SSDATA (lower
), "false"))
4303 return Fintern (tem
, Qnil
);
4317 x_frame_get_arg (struct frame
*f
, Lisp_Object alist
, Lisp_Object param
,
4318 const char *attribute
, const char *class,
4319 enum resource_types type
)
4321 return x_get_arg (FRAME_DISPLAY_INFO (f
),
4322 alist
, param
, attribute
, class, type
);
4325 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
4328 x_frame_get_and_record_arg (struct frame
*f
, Lisp_Object alist
,
4330 const char *attribute
, const char *class,
4331 enum resource_types type
)
4335 value
= x_get_arg (FRAME_DISPLAY_INFO (f
), alist
, param
,
4336 attribute
, class, type
);
4337 if (! NILP (value
) && ! EQ (value
, Qunbound
))
4338 store_frame_param (f
, param
, value
);
4344 /* Record in frame F the specified or default value according to ALIST
4345 of the parameter named PROP (a Lisp symbol).
4346 If no value is specified for PROP, look for an X default for XPROP
4347 on the frame named NAME.
4348 If that is not found either, use the value DEFLT. */
4351 x_default_parameter (struct frame
*f
, Lisp_Object alist
, Lisp_Object prop
,
4352 Lisp_Object deflt
, const char *xprop
, const char *xclass
,
4353 enum resource_types type
)
4357 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
4358 if (EQ (tem
, Qunbound
))
4360 AUTO_FRAME_ARG (arg
, prop
, tem
);
4361 x_set_frame_parameters (f
, arg
);
4366 #if !defined (HAVE_X_WINDOWS) && defined (NoValue)
4369 * XParseGeometry parses strings of the form
4370 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
4371 * width, height, xoffset, and yoffset are unsigned integers.
4372 * Example: "=80x24+300-49"
4373 * The equal sign is optional.
4374 * It returns a bitmask that indicates which of the four values
4375 * were actually found in the string. For each value found,
4376 * the corresponding argument is updated; for each value
4377 * not found, the corresponding argument is left unchanged.
4381 XParseGeometry (char *string
,
4383 unsigned int *width
, unsigned int *height
)
4387 unsigned long tempWidth
, tempHeight
;
4388 long int tempX
, tempY
;
4389 char *nextCharacter
;
4391 if (string
== NULL
|| *string
== '\0')
4394 string
++; /* ignore possible '=' at beg of geometry spec */
4397 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
4399 tempWidth
= strtoul (strind
, &nextCharacter
, 10);
4400 if (strind
== nextCharacter
)
4402 strind
= nextCharacter
;
4406 if (*strind
== 'x' || *strind
== 'X')
4409 tempHeight
= strtoul (strind
, &nextCharacter
, 10);
4410 if (strind
== nextCharacter
)
4412 strind
= nextCharacter
;
4413 mask
|= HeightValue
;
4416 if (*strind
== '+' || *strind
== '-')
4420 tempX
= strtol (strind
, &nextCharacter
, 10);
4421 if (strind
== nextCharacter
)
4423 strind
= nextCharacter
;
4425 if (*strind
== '+' || *strind
== '-')
4429 tempY
= strtol (strind
, &nextCharacter
, 10);
4430 if (strind
== nextCharacter
)
4432 strind
= nextCharacter
;
4437 /* If strind isn't at the end of the string then it's an invalid
4438 geometry specification. */
4440 if (*strind
!= '\0')
4444 *x
= clip_to_bounds (INT_MIN
, tempX
, INT_MAX
);
4446 *y
= clip_to_bounds (INT_MIN
, tempY
, INT_MAX
);
4447 if (mask
& WidthValue
)
4448 *width
= min (tempWidth
, UINT_MAX
);
4449 if (mask
& HeightValue
)
4450 *height
= min (tempHeight
, UINT_MAX
);
4454 #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */
4457 /* NS used to define x-parse-geometry in ns-win.el, but that confused
4458 make-docfile: the documentation string in ns-win.el was used for
4459 x-parse-geometry even in non-NS builds.
4461 With two definitions of x-parse-geometry in this file, various
4462 things still get confused (eg M-x apropos documentation), so that
4463 it is best if the two definitions just share the same doc-string.
4465 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4466 doc
: /* Parse a display geometry string STRING.
4467 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4468 The properties returned may include `top', `left', `height', and `width'.
4469 For X, the value of `left' or `top' may be an integer,
4470 or a list (+ N) meaning N pixels relative to top/left corner,
4471 or a list (- N) meaning -N pixels relative to bottom/right corner.
4472 On Nextstep, this just calls `ns-parse-geometry'. */)
4473 (Lisp_Object string
)
4476 unsigned int width
, height
;
4479 CHECK_STRING (string
);
4482 if (strchr (SSDATA (string
), ' ') != NULL
)
4483 return call1 (Qns_parse_geometry
, string
);
4485 geometry
= XParseGeometry (SSDATA (string
),
4486 &x
, &y
, &width
, &height
);
4488 if (geometry
& XValue
)
4490 Lisp_Object element
;
4492 if (x
>= 0 && (geometry
& XNegative
))
4493 element
= list3 (Qleft
, Qminus
, make_number (-x
));
4494 else if (x
< 0 && ! (geometry
& XNegative
))
4495 element
= list3 (Qleft
, Qplus
, make_number (x
));
4497 element
= Fcons (Qleft
, make_number (x
));
4498 result
= Fcons (element
, result
);
4501 if (geometry
& YValue
)
4503 Lisp_Object element
;
4505 if (y
>= 0 && (geometry
& YNegative
))
4506 element
= list3 (Qtop
, Qminus
, make_number (-y
));
4507 else if (y
< 0 && ! (geometry
& YNegative
))
4508 element
= list3 (Qtop
, Qplus
, make_number (y
));
4510 element
= Fcons (Qtop
, make_number (y
));
4511 result
= Fcons (element
, result
);
4514 if (geometry
& WidthValue
)
4515 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
4516 if (geometry
& HeightValue
)
4517 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
4523 /* Calculate the desired size and position of frame F.
4524 Return the flags saying which aspects were specified.
4526 Also set the win_gravity and size_hint_flags of F.
4528 Adjust height for toolbar if TOOLBAR_P is 1.
4530 This function does not make the coordinates positive. */
4532 #define DEFAULT_ROWS 35
4533 #define DEFAULT_COLS 80
4536 x_figure_window_size (struct frame
*f
, Lisp_Object parms
, bool toolbar_p
)
4538 Lisp_Object height
, width
, user_size
, top
, left
, user_position
;
4539 long window_prompting
= 0;
4540 Display_Info
*dpyinfo
= FRAME_DISPLAY_INFO (f
);
4542 /* Default values if we fall through.
4543 Actually, if that happens we should get
4544 window manager prompting. */
4545 SET_FRAME_WIDTH (f
, DEFAULT_COLS
* FRAME_COLUMN_WIDTH (f
));
4546 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4547 SET_FRAME_HEIGHT (f
, DEFAULT_ROWS
* FRAME_LINE_HEIGHT (f
));
4548 SET_FRAME_LINES (f
, DEFAULT_ROWS
);
4550 /* Window managers expect that if program-specified
4551 positions are not (0,0), they're intentional, not defaults. */
4555 /* Ensure that earlier new_width and new_height settings won't
4556 override what we specify below. */
4557 f
->new_width
= f
->new_height
= 0;
4559 height
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4560 width
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4561 if (!EQ (width
, Qunbound
) || !EQ (height
, Qunbound
))
4563 if (!EQ (width
, Qunbound
))
4565 CHECK_NUMBER (width
);
4566 if (! (0 <= XINT (width
) && XINT (width
) <= INT_MAX
))
4567 xsignal1 (Qargs_out_of_range
, width
);
4569 SET_FRAME_WIDTH (f
, XINT (width
) * FRAME_COLUMN_WIDTH (f
));
4572 if (!EQ (height
, Qunbound
))
4574 CHECK_NUMBER (height
);
4575 if (! (0 <= XINT (height
) && XINT (height
) <= INT_MAX
))
4576 xsignal1 (Qargs_out_of_range
, height
);
4578 SET_FRAME_HEIGHT (f
, XINT (height
) * FRAME_LINE_HEIGHT (f
));
4581 user_size
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4582 if (!NILP (user_size
) && !EQ (user_size
, Qunbound
))
4583 window_prompting
|= USSize
;
4585 window_prompting
|= PSize
;
4588 /* Add a tool bar height to the initial frame height so that the user
4589 gets a text display area of the size he specified with -g or via
4590 .Xdefaults. Later changes of the tool bar height don't change the
4591 frame size. This is done so that users can create tall Emacs
4592 frames without having to guess how tall the tool bar will get. */
4593 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4595 if (frame_default_tool_bar_height
)
4596 FRAME_TOOL_BAR_HEIGHT (f
) = frame_default_tool_bar_height
;
4601 relief
= (tool_bar_button_relief
>= 0
4602 ? tool_bar_button_relief
4603 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4605 if (RANGED_INTEGERP (1, Vtool_bar_button_margin
, INT_MAX
))
4606 margin
= XFASTINT (Vtool_bar_button_margin
);
4607 else if (CONSP (Vtool_bar_button_margin
)
4608 && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin
), INT_MAX
))
4609 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4613 FRAME_TOOL_BAR_HEIGHT (f
)
4614 = DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4618 top
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4619 left
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4620 user_position
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4621 if (! EQ (top
, Qunbound
) || ! EQ (left
, Qunbound
))
4623 if (EQ (top
, Qminus
))
4626 window_prompting
|= YNegative
;
4628 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
4629 && CONSP (XCDR (top
))
4630 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (top
)), INT_MAX
))
4632 f
->top_pos
= - XINT (XCAR (XCDR (top
)));
4633 window_prompting
|= YNegative
;
4635 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
4636 && CONSP (XCDR (top
))
4637 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top
))))
4639 f
->top_pos
= XINT (XCAR (XCDR (top
)));
4641 else if (EQ (top
, Qunbound
))
4645 CHECK_TYPE_RANGED_INTEGER (int, top
);
4646 f
->top_pos
= XINT (top
);
4648 window_prompting
|= YNegative
;
4651 if (EQ (left
, Qminus
))
4654 window_prompting
|= XNegative
;
4656 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
4657 && CONSP (XCDR (left
))
4658 && RANGED_INTEGERP (-INT_MAX
, XCAR (XCDR (left
)), INT_MAX
))
4660 f
->left_pos
= - XINT (XCAR (XCDR (left
)));
4661 window_prompting
|= XNegative
;
4663 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
4664 && CONSP (XCDR (left
))
4665 && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left
))))
4667 f
->left_pos
= XINT (XCAR (XCDR (left
)));
4669 else if (EQ (left
, Qunbound
))
4673 CHECK_TYPE_RANGED_INTEGER (int, left
);
4674 f
->left_pos
= XINT (left
);
4675 if (f
->left_pos
< 0)
4676 window_prompting
|= XNegative
;
4679 if (!NILP (user_position
) && ! EQ (user_position
, Qunbound
))
4680 window_prompting
|= USPosition
;
4682 window_prompting
|= PPosition
;
4685 if (window_prompting
& XNegative
)
4687 if (window_prompting
& YNegative
)
4688 f
->win_gravity
= SouthEastGravity
;
4690 f
->win_gravity
= NorthEastGravity
;
4694 if (window_prompting
& YNegative
)
4695 f
->win_gravity
= SouthWestGravity
;
4697 f
->win_gravity
= NorthWestGravity
;
4700 f
->size_hint_flags
= window_prompting
;
4702 return window_prompting
;
4707 #endif /* HAVE_WINDOW_SYSTEM */
4710 frame_make_pointer_invisible (struct frame
*f
)
4712 if (! NILP (Vmake_pointer_invisible
))
4714 if (f
&& FRAME_LIVE_P (f
) && !f
->pointer_invisible
4715 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4718 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 1);
4719 f
->pointer_invisible
= 1;
4725 frame_make_pointer_visible (struct frame
*f
)
4727 /* We don't check Vmake_pointer_invisible here in case the
4728 pointer was invisible when Vmake_pointer_invisible was set to nil. */
4729 if (f
&& FRAME_LIVE_P (f
) && f
->pointer_invisible
&& f
->mouse_moved
4730 && FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook
)
4732 FRAME_TERMINAL (f
)->toggle_invisible_pointer_hook (f
, 0);
4733 f
->pointer_invisible
= 0;
4737 DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p
,
4738 Sframe_pointer_visible_p
, 0, 1, 0,
4739 doc
: /* Return t if the mouse pointer displayed on FRAME is visible.
4740 Otherwise it returns nil. FRAME omitted or nil means the
4741 selected frame. This is useful when `make-pointer-invisible' is set. */)
4744 return decode_any_frame (frame
)->pointer_invisible
? Qnil
: Qt
;
4749 /***********************************************************************
4751 ***********************************************************************/
4753 #ifdef HAVE_WINDOW_SYSTEM
4755 # if (defined HAVE_NS \
4756 || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR)))
4758 free_monitors (struct MonitorInfo
*monitors
, int n_monitors
)
4761 for (i
= 0; i
< n_monitors
; ++i
)
4762 xfree (monitors
[i
].name
);
4768 make_monitor_attribute_list (struct MonitorInfo
*monitors
,
4770 int primary_monitor
,
4771 Lisp_Object monitor_frames
,
4774 Lisp_Object attributes_list
= Qnil
;
4775 Lisp_Object primary_monitor_attributes
= Qnil
;
4778 for (i
= 0; i
< n_monitors
; ++i
)
4780 Lisp_Object geometry
, workarea
, attributes
= Qnil
;
4781 struct MonitorInfo
*mi
= &monitors
[i
];
4783 if (mi
->geom
.width
== 0) continue;
4785 workarea
= list4i (mi
->work
.x
, mi
->work
.y
,
4786 mi
->work
.width
, mi
->work
.height
);
4787 geometry
= list4i (mi
->geom
.x
, mi
->geom
.y
,
4788 mi
->geom
.width
, mi
->geom
.height
);
4789 attributes
= Fcons (Fcons (Qsource
, build_string (source
)),
4791 attributes
= Fcons (Fcons (Qframes
, AREF (monitor_frames
, i
)),
4793 attributes
= Fcons (Fcons (Qmm_size
,
4794 list2i (mi
->mm_width
, mi
->mm_height
)),
4796 attributes
= Fcons (Fcons (Qworkarea
, workarea
), attributes
);
4797 attributes
= Fcons (Fcons (Qgeometry
, geometry
), attributes
);
4799 attributes
= Fcons (Fcons (Qname
, make_string (mi
->name
,
4800 strlen (mi
->name
))),
4803 if (i
== primary_monitor
)
4804 primary_monitor_attributes
= attributes
;
4806 attributes_list
= Fcons (attributes
, attributes_list
);
4809 if (!NILP (primary_monitor_attributes
))
4810 attributes_list
= Fcons (primary_monitor_attributes
, attributes_list
);
4811 return attributes_list
;
4814 #endif /* HAVE_WINDOW_SYSTEM */
4817 /***********************************************************************
4819 ***********************************************************************/
4822 syms_of_frame (void)
4824 DEFSYM (Qframep
, "framep");
4825 DEFSYM (Qframe_live_p
, "frame-live-p");
4826 DEFSYM (Qframe_windows_min_size
, "frame-windows-min-size");
4827 DEFSYM (Qexplicit_name
, "explicit-name");
4828 DEFSYM (Qheight
, "height");
4829 DEFSYM (Qicon
, "icon");
4830 DEFSYM (Qminibuffer
, "minibuffer");
4831 DEFSYM (Qmodeline
, "modeline");
4832 DEFSYM (Qonly
, "only");
4833 DEFSYM (Qnone
, "none");
4834 DEFSYM (Qwidth
, "width");
4835 DEFSYM (Qgeometry
, "geometry");
4836 DEFSYM (Qicon_left
, "icon-left");
4837 DEFSYM (Qicon_top
, "icon-top");
4838 DEFSYM (Qtooltip
, "tooltip");
4839 DEFSYM (Quser_position
, "user-position");
4840 DEFSYM (Quser_size
, "user-size");
4841 DEFSYM (Qwindow_id
, "window-id");
4842 #ifdef HAVE_X_WINDOWS
4843 DEFSYM (Qouter_window_id
, "outer-window-id");
4845 DEFSYM (Qparent_id
, "parent-id");
4847 DEFSYM (Qw32
, "w32");
4850 DEFSYM (Qvisible
, "visible");
4851 DEFSYM (Qbuffer_predicate
, "buffer-predicate");
4852 DEFSYM (Qbuffer_list
, "buffer-list");
4853 DEFSYM (Qburied_buffer_list
, "buried-buffer-list");
4854 DEFSYM (Qdisplay_type
, "display-type");
4855 DEFSYM (Qbackground_mode
, "background-mode");
4856 DEFSYM (Qnoelisp
, "noelisp");
4857 DEFSYM (Qtty_color_mode
, "tty-color-mode");
4858 DEFSYM (Qtty
, "tty");
4859 DEFSYM (Qtty_type
, "tty-type");
4861 DEFSYM (Qface_set_after_frame_default
, "face-set-after-frame-default");
4863 DEFSYM (Qfullwidth
, "fullwidth");
4864 DEFSYM (Qfullheight
, "fullheight");
4865 DEFSYM (Qfullboth
, "fullboth");
4866 DEFSYM (Qmaximized
, "maximized");
4867 DEFSYM (Qx_resource_name
, "x-resource-name");
4868 DEFSYM (Qx_frame_parameter
, "x-frame-parameter");
4870 DEFSYM (Qterminal
, "terminal");
4872 DEFSYM (Qworkarea
, "workarea");
4873 DEFSYM (Qmm_size
, "mm-size");
4874 DEFSYM (Qframes
, "frames");
4875 DEFSYM (Qsource
, "source");
4877 DEFSYM (Qframe_position
, "frame-position");
4878 DEFSYM (Qframe_outer_size
, "frame-outer-size");
4879 DEFSYM (Qexternal_border_size
, "external-border-size");
4880 DEFSYM (Qtitle_height
, "title-height");
4881 DEFSYM (Qmenu_bar_external
, "menu-bar-external");
4882 DEFSYM (Qmenu_bar_size
, "menu-bar-size");
4883 DEFSYM (Qtool_bar_external
, "tool-bar-external");
4884 DEFSYM (Qtool_bar_size
, "tool-bar-size");
4885 DEFSYM (Qframe_inner_size
, "frame-inner-size");
4886 /* The following are used for frame_size_history. */
4887 DEFSYM (Qadjust_frame_size_1
, "adjust-frame-size-1");
4888 DEFSYM (Qadjust_frame_size_2
, "adjust-frame-size-2");
4889 DEFSYM (Qadjust_frame_size_3
, "adjust-frame-size-3");
4890 DEFSYM (QEmacsFrameResize
, "EmacsFrameResize");
4891 DEFSYM (Qframe_inhibit_resize
, "frame-inhibit-resize");
4892 DEFSYM (Qx_set_fullscreen
, "x-set-fullscreen");
4893 DEFSYM (Qx_check_fullscreen
, "x-check-fullscreen");
4894 DEFSYM (Qx_set_window_size_1
, "x-set-window-size-1");
4895 DEFSYM (Qxg_frame_resized
, "xg-frame-resized");
4896 DEFSYM (Qxg_frame_set_char_size_1
, "xg-frame-set-char-size-1");
4897 DEFSYM (Qxg_frame_set_char_size_2
, "xg-frame-set-char-size-2");
4898 DEFSYM (Qxg_frame_set_char_size_3
, "xg-frame-set-char-size-3");
4899 DEFSYM (Qxg_change_toolbar_position
, "xg-change-toolbar-position");
4900 DEFSYM (Qx_net_wm_state
, "x-net-wm-state");
4901 DEFSYM (Qx_handle_net_wm_state
, "x-handle-net-wm-state");
4902 DEFSYM (Qtb_size_cb
, "tb-size-cb");
4903 DEFSYM (Qupdate_frame_tool_bar
, "update-frame-tool-bar");
4904 DEFSYM (Qfree_frame_tool_bar
, "free-frame-tool-bar");
4906 DEFSYM (Qchange_frame_size
, "change-frame-size");
4907 DEFSYM (Qxg_frame_set_char_size
, "xg-frame-set-char-size");
4908 DEFSYM (Qset_window_configuration
, "set-window-configuration");
4909 DEFSYM (Qx_create_frame_1
, "x-create-frame-1");
4910 DEFSYM (Qx_create_frame_2
, "x-create-frame-2");
4911 DEFSYM (Qtip_frame
, "tip-frame");
4912 DEFSYM (Qterminal_frame
, "terminal-frame");
4915 DEFSYM (Qns_parse_geometry
, "ns-parse-geometry");
4918 DEFSYM (Qalpha
, "alpha");
4919 DEFSYM (Qauto_lower
, "auto-lower");
4920 DEFSYM (Qauto_raise
, "auto-raise");
4921 DEFSYM (Qborder_color
, "border-color");
4922 DEFSYM (Qborder_width
, "border-width");
4923 DEFSYM (Qbottom_divider_width
, "bottom-divider-width");
4924 DEFSYM (Qcursor_color
, "cursor-color");
4925 DEFSYM (Qcursor_type
, "cursor-type");
4926 DEFSYM (Qfont_backend
, "font-backend");
4927 DEFSYM (Qfullscreen
, "fullscreen");
4928 DEFSYM (Qhorizontal_scroll_bars
, "horizontal-scroll-bars");
4929 DEFSYM (Qicon_name
, "icon-name");
4930 DEFSYM (Qicon_type
, "icon-type");
4931 DEFSYM (Qinternal_border_width
, "internal-border-width");
4932 DEFSYM (Qleft_fringe
, "left-fringe");
4933 DEFSYM (Qline_spacing
, "line-spacing");
4934 DEFSYM (Qmenu_bar_lines
, "menu-bar-lines");
4935 DEFSYM (Qmouse_color
, "mouse-color");
4936 DEFSYM (Qname
, "name");
4937 DEFSYM (Qright_divider_width
, "right-divider-width");
4938 DEFSYM (Qright_fringe
, "right-fringe");
4939 DEFSYM (Qscreen_gamma
, "screen-gamma");
4940 DEFSYM (Qscroll_bar_background
, "scroll-bar-background");
4941 DEFSYM (Qscroll_bar_foreground
, "scroll-bar-foreground");
4942 DEFSYM (Qscroll_bar_height
, "scroll-bar-height");
4943 DEFSYM (Qscroll_bar_width
, "scroll-bar-width");
4944 DEFSYM (Qsticky
, "sticky");
4945 DEFSYM (Qtitle
, "title");
4946 DEFSYM (Qtool_bar_lines
, "tool-bar-lines");
4947 DEFSYM (Qtool_bar_position
, "tool-bar-position");
4948 DEFSYM (Qunsplittable
, "unsplittable");
4949 DEFSYM (Qvertical_scroll_bars
, "vertical-scroll-bars");
4950 DEFSYM (Qvisibility
, "visibility");
4951 DEFSYM (Qwait_for_wm
, "wait-for-wm");
4956 for (i
= 0; i
< ARRAYELTS (frame_parms
); i
++)
4958 Lisp_Object v
= (frame_parms
[i
].sym
< 0
4959 ? intern_c_string (frame_parms
[i
].name
)
4960 : builtin_lisp_symbol (frame_parms
[i
].sym
));
4961 Fput (v
, Qx_frame_parameter
, make_number (i
));
4965 #ifdef HAVE_WINDOW_SYSTEM
4966 DEFVAR_LISP ("x-resource-name", Vx_resource_name
,
4967 doc
: /* The name Emacs uses to look up X resources.
4968 `x-get-resource' uses this as the first component of the instance name
4969 when requesting resource values.
4970 Emacs initially sets `x-resource-name' to the name under which Emacs
4971 was invoked, or to the value specified with the `-name' or `-rn'
4972 switches, if present.
4974 It may be useful to bind this variable locally around a call
4975 to `x-get-resource'. See also the variable `x-resource-class'. */);
4976 Vx_resource_name
= Qnil
;
4978 DEFVAR_LISP ("x-resource-class", Vx_resource_class
,
4979 doc
: /* The class Emacs uses to look up X resources.
4980 `x-get-resource' uses this as the first component of the instance class
4981 when requesting resource values.
4983 Emacs initially sets `x-resource-class' to "Emacs".
4985 Setting this variable permanently is not a reasonable thing to do,
4986 but binding this variable locally around a call to `x-get-resource'
4987 is a reasonable practice. See also the variable `x-resource-name'. */);
4988 Vx_resource_class
= build_string (EMACS_CLASS
);
4990 DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit
,
4991 doc
: /* The lower limit of the frame opacity (alpha transparency).
4992 The value should range from 0 (invisible) to 100 (completely opaque).
4993 You can also use a floating number between 0.0 and 1.0. */);
4994 Vframe_alpha_lower_limit
= make_number (20);
4997 DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist
,
4998 doc
: /* Alist of default values for frame creation.
4999 These may be set in your init file, like this:
5000 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
5001 These override values given in window system configuration data,
5002 including X Windows' defaults database.
5003 For values specific to the first Emacs frame, see `initial-frame-alist'.
5004 For window-system specific values, see `window-system-default-frame-alist'.
5005 For values specific to the separate minibuffer frame, see
5006 `minibuffer-frame-alist'.
5007 The `menu-bar-lines' element of the list controls whether new frames
5008 have menu bars; `menu-bar-mode' works by altering this element.
5009 Setting this variable does not affect existing frames, only new ones. */);
5010 Vdefault_frame_alist
= Qnil
;
5012 DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars
,
5013 doc
: /* Default position of vertical scroll bars on this window-system. */);
5014 #ifdef HAVE_WINDOW_SYSTEM
5015 #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
5016 /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
5018 Vdefault_frame_scroll_bars
= Qright
;
5020 Vdefault_frame_scroll_bars
= Qleft
;
5023 Vdefault_frame_scroll_bars
= Qnil
;
5026 DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion",
5027 scroll_bar_adjust_thumb_portion_p
,
5028 doc
: /* Adjust thumb for overscrolling for Gtk+ and MOTIF.
5029 Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
5030 even if the end of the buffer is shown (i.e. overscrolling).
5031 Set to nil if you want the thumb to be at the bottom when the end of the buffer
5032 is shown. Also, the thumb fills the whole scroll bar when the entire buffer
5033 is visible. In this case you can not overscroll. */);
5034 scroll_bar_adjust_thumb_portion_p
= 1;
5036 DEFVAR_LISP ("terminal-frame", Vterminal_frame
,
5037 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
5039 DEFVAR_LISP ("mouse-position-function", Vmouse_position_function
,
5040 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
5041 `mouse-position' and `mouse-pixel-position' call this function, passing their
5042 usual return value as argument, and return whatever this function returns.
5043 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
5044 which need to do mouse handling at the Lisp level. */);
5045 Vmouse_position_function
= Qnil
;
5047 DEFVAR_LISP ("mouse-highlight", Vmouse_highlight
,
5048 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
5049 If the value is an integer, highlighting is only shown after moving the
5050 mouse, while keyboard input turns off the highlight even when the mouse
5051 is over the clickable text. However, the mouse shape still indicates
5052 when the mouse is over clickable text. */);
5053 Vmouse_highlight
= Qt
;
5055 DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible
,
5056 doc
: /* If non-nil, make pointer invisible while typing.
5057 The pointer becomes visible again when the mouse is moved. */);
5058 Vmake_pointer_invisible
= Qt
;
5060 DEFVAR_LISP ("focus-in-hook", Vfocus_in_hook
,
5061 doc
: /* Normal hook run when a frame gains input focus. */);
5062 Vfocus_in_hook
= Qnil
;
5063 DEFSYM (Qfocus_in_hook
, "focus-in-hook");
5065 DEFVAR_LISP ("focus-out-hook", Vfocus_out_hook
,
5066 doc
: /* Normal hook run when a frame loses input focus. */);
5067 Vfocus_out_hook
= Qnil
;
5068 DEFSYM (Qfocus_out_hook
, "focus-out-hook");
5070 DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions
,
5071 doc
: /* Functions run before deleting a frame.
5072 The functions are run with one arg, the frame to be deleted.
5075 Note that functions in this list may be called just before the frame is
5076 actually deleted, or some time later (or even both when an earlier function
5077 in `delete-frame-functions' (indirectly) calls `delete-frame'
5079 Vdelete_frame_functions
= Qnil
;
5080 DEFSYM (Qdelete_frame_functions
, "delete-frame-functions");
5082 DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode
,
5083 doc
: /* Non-nil if Menu-Bar mode is enabled.
5084 See the command `menu-bar-mode' for a description of this minor mode.
5085 Setting this variable directly does not take effect;
5086 either customize it (see the info node `Easy Customization')
5087 or call the function `menu-bar-mode'. */);
5088 Vmenu_bar_mode
= Qt
;
5090 DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode
,
5091 doc
: /* Non-nil if Tool-Bar mode is enabled.
5092 See the command `tool-bar-mode' for a description of this minor mode.
5093 Setting this variable directly does not take effect;
5094 either customize it (see the info node `Easy Customization')
5095 or call the function `tool-bar-mode'. */);
5096 #ifdef HAVE_WINDOW_SYSTEM
5097 Vtool_bar_mode
= Qt
;
5099 Vtool_bar_mode
= Qnil
;
5102 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
5103 doc
: /* Minibufferless frames use this frame's minibuffer.
5104 Emacs cannot create minibufferless frames unless this is set to an
5105 appropriate surrogate.
5107 Emacs consults this variable only when creating minibufferless
5108 frames; once the frame is created, it sticks with its assigned
5109 minibuffer, no matter what this variable is set to. This means that
5110 this variable doesn't necessarily say anything meaningful about the
5111 current set of frames, or where the minibuffer is currently being
5114 This variable is local to the current terminal and cannot be buffer-local. */);
5116 DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse
,
5117 doc
: /* Non-nil if window system changes focus when you move the mouse.
5118 You should set this variable to tell Emacs how your window manager
5119 handles focus, since there is no way in general for Emacs to find out
5120 automatically. See also `mouse-autoselect-window'. */);
5121 focus_follows_mouse
= 0;
5123 DEFVAR_BOOL ("frame-resize-pixelwise", frame_resize_pixelwise
,
5124 doc
: /* Non-nil means resize frames pixelwise.
5125 If this option is nil, resizing a frame rounds its sizes to the frame's
5126 current values of `frame-char-height' and `frame-char-width'. If this
5127 is non-nil, no rounding occurs, hence frame sizes can increase/decrease
5130 With some window managers you may have to set this to non-nil in order
5131 to set the size of a frame in pixels, to maximize frames or to make them
5132 fullscreen. To resize your initial frame pixelwise, set this option to
5133 a non-nil value in your init file. */);
5134 frame_resize_pixelwise
= 0;
5136 DEFVAR_LISP ("frame-inhibit-implied-resize", frame_inhibit_implied_resize
,
5137 doc
: /* Whether frames should be resized implicitly.
5138 If this option is nil, setting font, menu bar, tool bar, internal
5139 borders, fringes or scroll bars of a specific frame may resize the frame
5140 in order to preserve the number of columns or lines it displays. If
5141 this option is `t', no such resizing is done. Note that the size of
5142 fullscreen and maximized frames, the height of fullheight frames and the
5143 width of fullwidth frames never change implicitly.
5145 The value of this option can be also be a list of frame parameters. In
5146 this case, resizing is inhibited when changing a parameter that appears
5147 in that list. The parameters currently handled by this option include
5148 `font', `font-backend', `internal-border-width', `menu-bar-lines' and
5151 Changing any of the parameters `scroll-bar-width', `scroll-bar-height',
5152 `vertical-scroll-bars', `horizontal-scroll-bars', `left-fringe' and
5153 `right-fringe' is handled as if the frame contained just one live
5154 window. This means, for example, that removing vertical scroll bars on
5155 a frame containing several side by side windows will shrink the frame
5156 width by the width of one scroll bar provided this option is nil and
5157 keep it unchanged if this option is either `t' or a list containing
5158 `vertical-scroll-bars'.
5160 The default value is '(tool-bar-lines) on Lucid, Motif and Windows
5161 \(which means that adding/removing a tool bar does not change the frame
5162 height), nil on all other window systems including GTK+ (which means
5163 that changing any of the parameters listed above may change the size of
5164 the frame), and `t' otherwise (which means the frame size never changes
5165 implicitly when there's no window system support).
5167 Note that when a frame is not large enough to accommodate a change of
5168 any of the parameters listed above, Emacs may try to enlarge the frame
5169 even if this option is non-nil. */);
5170 #if defined (HAVE_WINDOW_SYSTEM)
5171 #if defined (USE_LUCID) || defined (USE_MOTIF) || defined (HAVE_NTGUI)
5172 frame_inhibit_implied_resize
= list1 (Qtool_bar_lines
);
5174 frame_inhibit_implied_resize
= Qnil
;
5177 frame_inhibit_implied_resize
= Qt
;
5180 DEFVAR_LISP ("frame-size-history", frame_size_history
,
5181 doc
: /* History of frame size adjustments.
5182 If non-nil, list recording frame size adjustment. Adjustments are
5183 recorded only if the first element of this list is a positive number.
5184 Adding an adjustment decrements that number by one.
5186 The remaining elements are the adjustments. Each adjustment is a list
5187 of four elements `frame', `function', `sizes' and `more'. `frame' is
5188 the affected frame and `function' the invoking function. `sizes' is
5189 usually a list of four elements `old-width', `old-height', `new-width'
5190 and `new-height' representing the old and new sizes recorded/requested
5191 by `function'. `more' is a list with additional information.
5193 The function `frame--size-history' displays the value of this variable
5194 in a more readable form. */);
5195 frame_size_history
= Qnil
;
5197 staticpro (&Vframe_list
);
5200 defsubr (&Sframe_live_p
);
5201 defsubr (&Swindow_system
);
5202 defsubr (&Sframe_windows_min_size
);
5203 defsubr (&Smake_terminal_frame
);
5204 defsubr (&Shandle_switch_frame
);
5205 defsubr (&Sselect_frame
);
5206 defsubr (&Sselected_frame
);
5207 defsubr (&Sframe_list
);
5208 defsubr (&Snext_frame
);
5209 defsubr (&Sprevious_frame
);
5210 defsubr (&Slast_nonminibuf_frame
);
5211 defsubr (&Sdelete_frame
);
5212 defsubr (&Smouse_position
);
5213 defsubr (&Smouse_pixel_position
);
5214 defsubr (&Sset_mouse_position
);
5215 defsubr (&Sset_mouse_pixel_position
);
5217 defsubr (&Sframe_configuration
);
5218 defsubr (&Srestore_frame_configuration
);
5220 defsubr (&Smake_frame_visible
);
5221 defsubr (&Smake_frame_invisible
);
5222 defsubr (&Siconify_frame
);
5223 defsubr (&Sframe_visible_p
);
5224 defsubr (&Svisible_frame_list
);
5225 defsubr (&Sraise_frame
);
5226 defsubr (&Slower_frame
);
5227 defsubr (&Sx_focus_frame
);
5228 defsubr (&Sframe_after_make_frame
);
5229 defsubr (&Sredirect_frame_focus
);
5230 defsubr (&Sframe_focus
);
5231 defsubr (&Sframe_parameters
);
5232 defsubr (&Sframe_parameter
);
5233 defsubr (&Smodify_frame_parameters
);
5234 defsubr (&Sframe_char_height
);
5235 defsubr (&Sframe_char_width
);
5236 defsubr (&Sframe_pixel_height
);
5237 defsubr (&Sframe_pixel_width
);
5238 defsubr (&Sframe_text_cols
);
5239 defsubr (&Sframe_text_lines
);
5240 defsubr (&Sframe_total_cols
);
5241 defsubr (&Sframe_total_lines
);
5242 defsubr (&Sframe_text_width
);
5243 defsubr (&Sframe_text_height
);
5244 defsubr (&Sscroll_bar_width
);
5245 defsubr (&Sscroll_bar_height
);
5246 defsubr (&Sfringe_width
);
5247 defsubr (&Sborder_width
);
5248 defsubr (&Sright_divider_width
);
5249 defsubr (&Sbottom_divider_width
);
5250 defsubr (&Stool_bar_pixel_width
);
5251 defsubr (&Sset_frame_height
);
5252 defsubr (&Sset_frame_width
);
5253 defsubr (&Sset_frame_size
);
5254 defsubr (&Sset_frame_position
);
5255 defsubr (&Sframe_pointer_visible_p
);
5257 #ifdef HAVE_WINDOW_SYSTEM
5258 defsubr (&Sx_get_resource
);
5259 defsubr (&Sx_parse_geometry
);