1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007, 2008, 2009 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/>. */
25 #include "character.h"
36 /* These help us bind and responding to switch-frame events. */
40 #include "blockinput.h"
42 #include "termhooks.h"
43 #include "dispextern.h"
45 #ifdef HAVE_WINDOW_SYSTEM
55 #ifdef HAVE_WINDOW_SYSTEM
57 /* The name we're using in resource queries. Most often "emacs". */
59 Lisp_Object Vx_resource_name
;
61 /* The application class we're using in resource queries.
64 Lisp_Object Vx_resource_class
;
66 /* Lower limit value of the frame opacity (alpha transparency). */
68 Lisp_Object Vframe_alpha_lower_limit
;
73 Lisp_Object Qns_parse_geometry
;
76 Lisp_Object Qframep
, Qframe_live_p
;
77 Lisp_Object Qicon
, Qmodeline
;
79 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
, Qns
;
81 Lisp_Object Qdisplay_type
;
82 Lisp_Object Qbackground_mode
;
85 Lisp_Object Qx_frame_parameter
;
86 Lisp_Object Qx_resource_name
;
87 Lisp_Object Qterminal
;
88 Lisp_Object Qterminal_live_p
;
90 /* Frame parameters (set or reported). */
92 Lisp_Object Qauto_raise
, Qauto_lower
;
93 Lisp_Object Qborder_color
, Qborder_width
;
94 Lisp_Object Qcursor_color
, Qcursor_type
;
95 Lisp_Object Qgeometry
; /* Not used */
96 Lisp_Object Qheight
, Qwidth
;
97 Lisp_Object Qleft
, Qright
;
98 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
99 Lisp_Object Qinternal_border_width
;
100 Lisp_Object Qmouse_color
;
101 Lisp_Object Qminibuffer
;
102 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
103 Lisp_Object Qvisibility
;
104 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
105 Lisp_Object Qscreen_gamma
;
106 Lisp_Object Qline_spacing
;
107 Lisp_Object Quser_position
, Quser_size
;
108 Lisp_Object Qwait_for_wm
;
109 Lisp_Object Qwindow_id
;
110 #ifdef HAVE_X_WINDOWS
111 Lisp_Object Qouter_window_id
;
113 Lisp_Object Qparent_id
;
114 Lisp_Object Qtitle
, Qname
;
115 Lisp_Object Qexplicit_name
;
116 Lisp_Object Qunsplittable
;
117 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
118 Lisp_Object Qleft_fringe
, Qright_fringe
;
119 Lisp_Object Qbuffer_predicate
, Qbuffer_list
, Qburied_buffer_list
;
120 Lisp_Object Qtty_color_mode
;
121 Lisp_Object Qtty
, Qtty_type
;
123 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
, Qmaximized
;
125 Lisp_Object Qfont_backend
;
128 Lisp_Object Qface_set_after_frame_default
;
130 Lisp_Object Vterminal_frame
;
131 Lisp_Object Vdefault_frame_alist
;
132 Lisp_Object Vdefault_frame_scroll_bars
;
133 Lisp_Object Vmouse_position_function
;
134 Lisp_Object Vmouse_highlight
;
135 static Lisp_Object Vdelete_frame_functions
, Qdelete_frame_functions
;
137 int focus_follows_mouse
;
140 set_menu_bar_lines_1 (window
, n
)
144 struct window
*w
= XWINDOW (window
);
146 XSETFASTINT (w
->last_modified
, 0);
147 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
148 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
150 if (INTEGERP (w
->orig_top_line
))
151 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
152 if (INTEGERP (w
->orig_total_lines
))
153 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
155 /* Handle just the top child in a vertical split. */
156 if (!NILP (w
->vchild
))
157 set_menu_bar_lines_1 (w
->vchild
, n
);
159 /* Adjust all children in a horizontal split. */
160 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
162 w
= XWINDOW (window
);
163 set_menu_bar_lines_1 (window
, n
);
168 set_menu_bar_lines (f
, value
, oldval
)
170 Lisp_Object value
, oldval
;
173 int olines
= FRAME_MENU_BAR_LINES (f
);
175 /* Right now, menu bars don't work properly in minibuf-only frames;
176 most of the commands try to apply themselves to the minibuffer
177 frame itself, and get an error because you can't switch buffers
178 in or split the minibuffer window. */
179 if (FRAME_MINIBUF_ONLY_P (f
))
182 if (INTEGERP (value
))
183 nlines
= XINT (value
);
187 if (nlines
!= olines
)
189 windows_or_buffers_changed
++;
190 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
191 FRAME_MENU_BAR_LINES (f
) = nlines
;
192 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
197 Lisp_Object Vframe_list
;
199 extern Lisp_Object Vminibuffer_list
;
200 extern Lisp_Object
get_minibuffer ();
201 extern Lisp_Object
Fhandle_switch_frame ();
202 extern Lisp_Object
Fredirect_frame_focus ();
203 extern Lisp_Object
x_get_focus_frame ();
205 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
206 doc
: /* Return non-nil if OBJECT is a frame.
207 Value is t for a termcap frame (a character-only terminal),
208 `x' for an Emacs frame that is really an X window,
209 `w32' for an Emacs frame that is a window on MS-Windows display,
210 `ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
211 `pc' for a direct-write MS-DOS frame.
212 See also `frame-live-p'. */)
216 if (!FRAMEP (object
))
218 switch (XFRAME (object
)->output_method
)
220 case output_initial
: /* The initial frame is like a termcap frame. */
223 case output_x_window
:
227 case output_msdos_raw
:
238 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
239 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
240 Value is nil if OBJECT is not a live frame. If object is a live
241 frame, the return value indicates what sort of terminal device it is
242 displayed on. See the documentation of `framep' for possible
247 return ((FRAMEP (object
)
248 && FRAME_LIVE_P (XFRAME (object
)))
253 DEFUN ("window-system", Fwindow_system
, Swindow_system
, 0, 1, 0,
254 doc
: /* The name of the window system that FRAME is displaying through.
255 The value is a symbol---for instance, 'x' for X windows.
256 The value is nil if Emacs is using a text-only terminal.
258 FRAME defaults to the currently selected frame. */)
264 frame
= selected_frame
;
266 type
= Fframep (frame
);
269 wrong_type_argument (Qframep
, frame
);
282 register struct frame
*f
;
283 register Lisp_Object root_window
;
284 register Lisp_Object mini_window
;
286 f
= allocate_frame ();
287 XSETFRAME (frame
, f
);
289 f
->desired_matrix
= 0;
290 f
->current_matrix
= 0;
293 f
->glyphs_initialized_p
= 0;
294 f
->decode_mode_spec_buffer
= 0;
296 f
->async_visible
= 0;
297 f
->output_data
.nothing
= 0;
299 f
->async_iconified
= 0;
300 f
->wants_modeline
= 1;
305 f
->has_minibuffer
= mini_p
;
306 f
->focus_frame
= Qnil
;
307 f
->explicit_name
= 0;
308 f
->can_have_scroll_bars
= 0;
309 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
310 f
->param_alist
= Qnil
;
311 f
->scroll_bars
= Qnil
;
312 f
->condemned_scroll_bars
= Qnil
;
313 f
->face_alist
= Qnil
;
314 f
->face_cache
= NULL
;
315 f
->menu_bar_items
= Qnil
;
316 f
->menu_bar_vector
= Qnil
;
317 f
->menu_bar_items_used
= 0;
318 f
->buffer_predicate
= Qnil
;
319 f
->buffer_list
= Qnil
;
320 f
->buried_buffer_list
= Qnil
;
323 f
->menu_bar_window
= Qnil
;
324 f
->tool_bar_window
= Qnil
;
325 f
->tool_bar_items
= Qnil
;
326 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
327 f
->n_tool_bar_items
= 0;
328 f
->left_fringe_width
= f
->right_fringe_width
= 0;
330 f
->scroll_bar_actual_width
= 0;
332 f
->internal_border_width
= 0;
333 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
334 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
335 f
->x_pixels_diff
= f
->y_pixels_diff
= 0;
336 #ifdef HAVE_WINDOW_SYSTEM
337 f
->want_fullscreen
= FULLSCREEN_NONE
;
339 f
->size_hint_flags
= 0;
341 f
->font_driver_list
= NULL
;
342 f
->font_data_list
= NULL
;
344 root_window
= make_window ();
347 mini_window
= make_window ();
348 XWINDOW (root_window
)->next
= mini_window
;
349 XWINDOW (mini_window
)->prev
= root_window
;
350 XWINDOW (mini_window
)->mini_p
= Qt
;
351 XWINDOW (mini_window
)->frame
= frame
;
352 f
->minibuffer_window
= mini_window
;
357 XWINDOW (root_window
)->next
= Qnil
;
358 f
->minibuffer_window
= Qnil
;
361 XWINDOW (root_window
)->frame
= frame
;
364 just so that there is "something there."
365 Correct size will be set up later with change_frame_size. */
367 SET_FRAME_COLS (f
, 10);
368 FRAME_LINES (f
) = 10;
370 XSETFASTINT (XWINDOW (root_window
)->total_cols
, 10);
371 XSETFASTINT (XWINDOW (root_window
)->total_lines
, (mini_p
? 9 : 10));
375 XSETFASTINT (XWINDOW (mini_window
)->total_cols
, 10);
376 XSETFASTINT (XWINDOW (mini_window
)->top_line
, 9);
377 XSETFASTINT (XWINDOW (mini_window
)->total_lines
, 1);
380 /* Choose a buffer for the frame's root window. */
384 XWINDOW (root_window
)->buffer
= Qt
;
385 buf
= Fcurrent_buffer ();
386 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
387 a space), try to find another one. */
388 if (SREF (Fbuffer_name (buf
), 0) == ' ')
389 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
391 /* Use set_window_buffer, not Fset_window_buffer, and don't let
392 hooks be run by it. The reason is that the whole frame/window
393 arrangement is not yet fully intialized at this point. Windows
394 don't have the right size, glyph matrices aren't initialized
395 etc. Running Lisp functions at this point surely ends in a
397 set_window_buffer (root_window
, buf
, 0, 0);
398 f
->buffer_list
= Fcons (buf
, Qnil
);
403 XWINDOW (mini_window
)->buffer
= Qt
;
404 set_window_buffer (mini_window
,
405 (NILP (Vminibuffer_list
)
407 : Fcar (Vminibuffer_list
)),
411 f
->root_window
= root_window
;
412 f
->selected_window
= root_window
;
413 /* Make sure this window seems more recently used than
414 a newly-created, never-selected window. */
415 ++window_select_count
;
416 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, window_select_count
);
418 f
->default_face_done_p
= 0;
423 #ifdef HAVE_WINDOW_SYSTEM
424 /* Make a frame using a separate minibuffer window on another frame.
425 MINI_WINDOW is the minibuffer window to use. nil means use the
426 default (the global minibuffer). */
429 make_frame_without_minibuffer (mini_window
, kb
, display
)
430 register Lisp_Object mini_window
;
434 register struct frame
*f
;
437 if (!NILP (mini_window
))
438 CHECK_LIVE_WINDOW (mini_window
);
440 if (!NILP (mini_window
)
441 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window
)->frame
)) != kb
)
442 error ("Frame and minibuffer must be on the same terminal");
444 /* Make a frame containing just a root window. */
447 if (NILP (mini_window
))
449 /* Use default-minibuffer-frame if possible. */
450 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
451 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
453 Lisp_Object frame_dummy
;
455 XSETFRAME (frame_dummy
, f
);
456 GCPRO1 (frame_dummy
);
457 /* If there's no minibuffer frame to use, create one. */
458 kb
->Vdefault_minibuffer_frame
=
459 call1 (intern ("make-initial-minibuffer-frame"), display
);
463 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
466 f
->minibuffer_window
= mini_window
;
468 /* Make the chosen minibuffer window display the proper minibuffer,
469 unless it is already showing a minibuffer. */
470 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
471 Fset_window_buffer (mini_window
,
472 (NILP (Vminibuffer_list
)
474 : Fcar (Vminibuffer_list
)), Qnil
);
478 /* Make a frame containing only a minibuffer window. */
481 make_minibuffer_frame ()
483 /* First make a frame containing just a root window, no minibuffer. */
485 register struct frame
*f
= make_frame (0);
486 register Lisp_Object mini_window
;
487 register Lisp_Object frame
;
489 XSETFRAME (frame
, f
);
494 f
->wants_modeline
= 0;
495 f
->has_minibuffer
= 1;
497 /* Now label the root window as also being the minibuffer.
498 Avoid infinite looping on the window chain by marking next pointer
501 mini_window
= f
->minibuffer_window
= f
->root_window
;
502 XWINDOW (mini_window
)->mini_p
= Qt
;
503 XWINDOW (mini_window
)->next
= Qnil
;
504 XWINDOW (mini_window
)->prev
= Qnil
;
505 XWINDOW (mini_window
)->frame
= frame
;
507 /* Put the proper buffer in that window. */
509 Fset_window_buffer (mini_window
,
510 (NILP (Vminibuffer_list
)
512 : Fcar (Vminibuffer_list
)), Qnil
);
515 #endif /* HAVE_WINDOW_SYSTEM */
517 /* Construct a frame that refers to a terminal. */
519 static int tty_frame_count
;
522 make_initial_frame (void)
525 struct terminal
*terminal
;
528 eassert (initial_kboard
);
530 /* The first call must initialize Vframe_list. */
531 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
534 terminal
= init_initial_terminal ();
537 XSETFRAME (frame
, f
);
539 Vframe_list
= Fcons (frame
, Vframe_list
);
542 f
->name
= build_string ("F1");
545 f
->async_visible
= 1;
547 f
->output_method
= terminal
->type
;
548 f
->terminal
= terminal
;
549 f
->terminal
->reference_count
++;
550 f
->output_data
.nothing
= 0;
552 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
553 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
555 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
556 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
560 init_frame_faces (f
);
568 make_terminal_frame (struct terminal
*terminal
)
570 register struct frame
*f
;
575 error ("Terminal is not live, can't create new frames on it");
579 XSETFRAME (frame
, f
);
580 Vframe_list
= Fcons (frame
, Vframe_list
);
583 sprintf (name
, "F%d", tty_frame_count
);
584 f
->name
= build_string (name
);
586 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
587 f
->async_visible
= 1; /* Don't let visible be cleared later. */
588 f
->terminal
= terminal
;
589 f
->terminal
->reference_count
++;
591 f
->output_data
.tty
->display_info
= &the_only_display_info
;
592 if (!inhibit_window_system
593 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
594 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
595 f
->output_method
= output_msdos_raw
;
597 f
->output_method
= output_termcap
;
598 #else /* not MSDOS */
599 f
->output_method
= output_termcap
;
600 create_tty_output (f
);
601 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
602 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
603 #endif /* not MSDOS */
605 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
606 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
) = vertical_scroll_bar_none
;
608 /* Set the top frame to the newly created frame. */
609 if (FRAMEP (FRAME_TTY (f
)->top_frame
)
610 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f
)->top_frame
)))
611 XFRAME (FRAME_TTY (f
)->top_frame
)->async_visible
= 2; /* obscured */
613 FRAME_TTY (f
)->top_frame
= frame
;
616 init_frame_faces (f
);
621 /* Get a suitable value for frame parameter PARAMETER for a newly
622 created frame, based on (1) the user-supplied frame parameter
623 alist SUPPLIED_PARMS, (2) CURRENT_VALUE, and finally, if all else
624 fails, (3) Vdefault_frame_alist. */
627 get_future_frame_param (Lisp_Object parameter
,
628 Lisp_Object supplied_parms
,
633 result
= Fassq (parameter
, supplied_parms
);
635 result
= Fassq (parameter
, XFRAME (selected_frame
)->param_alist
);
636 if (NILP (result
) && current_value
!= NULL
)
637 result
= build_string (current_value
);
639 result
= Fassq (parameter
, Vdefault_frame_alist
);
640 if (!NILP (result
) && !STRINGP (result
))
641 result
= XCDR (result
);
642 if (NILP (result
) || !STRINGP (result
))
648 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
650 doc
: /* Create an additional terminal frame, possibly on another terminal.
651 This function takes one argument, an alist specifying frame parameters.
653 You can create multiple frames on a single text-only terminal, but
654 only one of them (the selected terminal frame) is actually displayed.
656 In practice, generally you don't need to specify any parameters,
657 except when you want to create a new frame on another terminal.
658 In that case, the `tty' parameter specifies the device file to open,
659 and the `tty-type' parameter specifies the terminal type. Example:
661 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
663 Note that changing the size of one terminal frame automatically
664 affects all frames on the same terminal device. */)
669 struct terminal
*t
= NULL
;
670 Lisp_Object frame
, tem
;
671 struct frame
*sf
= SELECTED_FRAME ();
674 if (sf
->output_method
!= output_msdos_raw
675 && sf
->output_method
!= output_termcap
)
677 #else /* not MSDOS */
679 #ifdef WINDOWSNT /* This should work now! */
680 if (sf
->output_method
!= output_termcap
)
681 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
683 #endif /* not MSDOS */
686 Lisp_Object terminal
;
688 terminal
= Fassq (Qterminal
, parms
);
689 if (!NILP (terminal
))
691 terminal
= XCDR (terminal
);
692 t
= get_terminal (terminal
, 1);
695 if (t
&& t
!= the_only_display_info
.terminal
)
696 /* msdos.c assumes a single tty_display_info object. */
697 error ("Multiple terminals are not supported on this platform");
699 t
= the_only_display_info
.terminal
;
705 char *name
= 0, *type
= 0;
706 Lisp_Object tty
, tty_type
;
708 tty
= get_future_frame_param
709 (Qtty
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
710 ? FRAME_TTY (XFRAME (selected_frame
))->name
714 name
= (char *) alloca (SBYTES (tty
) + 1);
715 strncpy (name
, SDATA (tty
), SBYTES (tty
));
716 name
[SBYTES (tty
)] = 0;
719 tty_type
= get_future_frame_param
720 (Qtty_type
, parms
, (FRAME_TERMCAP_P (XFRAME (selected_frame
))
721 ? FRAME_TTY (XFRAME (selected_frame
))->type
723 if (!NILP (tty_type
))
725 type
= (char *) alloca (SBYTES (tty_type
) + 1);
726 strncpy (type
, SDATA (tty_type
), SBYTES (tty_type
));
727 type
[SBYTES (tty_type
)] = 0;
730 t
= init_tty (name
, type
, 0); /* Errors are not fatal. */
733 f
= make_terminal_frame (t
);
737 get_tty_size (fileno (FRAME_TTY (f
)->input
), &width
, &height
);
738 change_frame_size (f
, height
, width
, 0, 0, 0);
743 XSETFRAME (frame
, f
);
744 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
745 Fmodify_frame_parameters (frame
, parms
);
746 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty_type
,
747 build_string (t
->display_info
.tty
->type
)),
749 if (t
->display_info
.tty
->name
!= NULL
)
750 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
,
751 build_string (t
->display_info
.tty
->name
)),
754 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qtty
, Qnil
), Qnil
));
756 /* Make the frame face alist be frame-specific, so that each
757 frame could change its face definitions independently. */
758 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
759 /* Simple Fcopy_alist isn't enough, because we need the contents of
760 the vectors which are the CDRs of associations in face_alist to
761 be copied as well. */
762 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
763 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
768 /* Perform the switch to frame FRAME.
770 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
773 If TRACK is non-zero and the frame that currently has the focus
774 redirects its focus to the selected frame, redirect that focused
775 frame's focus to FRAME instead.
777 FOR_DELETION non-zero means that the selected frame is being
778 deleted, which includes the possibility that the frame's terminal
781 The value of NORECORD is passed as argument to Fselect_window. */
784 do_switch_frame (frame
, track
, for_deletion
, norecord
)
785 Lisp_Object frame
, norecord
;
786 int track
, for_deletion
;
788 struct frame
*sf
= SELECTED_FRAME ();
790 /* If FRAME is a switch-frame event, extract the frame we should
793 && EQ (XCAR (frame
), Qswitch_frame
)
794 && CONSP (XCDR (frame
)))
795 frame
= XCAR (XCDR (frame
));
797 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
798 a switch-frame event to arrive after a frame is no longer live,
799 especially when deleting the initial frame during startup. */
801 if (! FRAME_LIVE_P (XFRAME (frame
)))
804 if (sf
== XFRAME (frame
))
807 /* This is too greedy; it causes inappropriate focus redirection
808 that's hard to get rid of. */
810 /* If a frame's focus has been redirected toward the currently
811 selected frame, we should change the redirection to point to the
812 newly selected frame. This means that if the focus is redirected
813 from a minibufferless frame to a surrogate minibuffer frame, we
814 can use `other-window' to switch between all the frames using
815 that minibuffer frame, and the focus redirection will follow us
821 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
825 if (!FRAMEP (XCAR (tail
)))
828 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
830 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
831 Fredirect_frame_focus (XCAR (tail
), frame
);
835 /* Instead, apply it only to the frame we're pointing to. */
836 #ifdef HAVE_WINDOW_SYSTEM
837 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
839 Lisp_Object focus
, xfocus
;
841 xfocus
= x_get_focus_frame (XFRAME (frame
));
844 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
845 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
846 Fredirect_frame_focus (xfocus
, frame
);
849 #endif /* HAVE_X_WINDOWS */
852 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
853 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
855 if (FRAME_TERMCAP_P (XFRAME (frame
)) || FRAME_MSDOS_P (XFRAME (frame
)))
857 if (FRAMEP (FRAME_TTY (XFRAME (frame
))->top_frame
))
858 /* Mark previously displayed frame as now obscured. */
859 XFRAME (FRAME_TTY (XFRAME (frame
))->top_frame
)->async_visible
= 2;
860 XFRAME (frame
)->async_visible
= 1;
861 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
864 selected_frame
= frame
;
865 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
866 last_nonminibuf_frame
= XFRAME (selected_frame
);
868 Fselect_window (XFRAME (frame
)->selected_window
, norecord
);
870 /* We want to make sure that the next event generates a frame-switch
871 event to the appropriate frame. This seems kludgy to me, but
872 before you take it out, make sure that evaluating something like
873 (select-window (frame-root-window (new-frame))) doesn't end up
874 with your typing being interpreted in the new frame instead of
875 the one you're actually typing in. */
876 internal_last_event_frame
= Qnil
;
881 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
882 doc
: /* Select FRAME.
883 Subsequent editing commands apply to its selected window.
884 Optional argument NORECORD means to neither change the order of
885 recently selected windows nor the buffer list.
887 The selection of FRAME lasts until the next time the user does
888 something to select a different frame, or until the next time
889 this function is called. If you are using a window system, the
890 previously selected frame may be restored as the selected frame
891 after return to the command loop, because it still may have the
892 window system's input focus. On a text-only terminal, the next
893 redisplay will display FRAME.
895 This function returns FRAME, or nil if FRAME has been deleted. */)
897 Lisp_Object frame
, norecord
;
899 return do_switch_frame (frame
, 1, 0, norecord
);
903 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
904 doc
: /* Handle a switch-frame event EVENT.
905 Switch-frame events are usually bound to this function.
906 A switch-frame event tells Emacs that the window manager has requested
907 that the user's events be directed to the frame mentioned in the event.
908 This function selects the selected window of the frame of EVENT.
910 If EVENT is frame object, handle it as if it were a switch-frame event
915 /* Preserve prefix arg that the command loop just cleared. */
916 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
917 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
918 return do_switch_frame (event
, 0, 0, Qnil
);
921 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
922 doc
: /* Return the frame that is now selected. */)
925 return selected_frame
;
928 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
929 doc
: /* Return the frame object that window WINDOW is on. */)
933 CHECK_LIVE_WINDOW (window
);
934 return XWINDOW (window
)->frame
;
937 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
938 doc
: /* Returns the topmost, leftmost window of FRAME.
939 If omitted, FRAME defaults to the currently selected frame. */)
946 w
= SELECTED_FRAME ()->root_window
;
949 CHECK_LIVE_FRAME (frame
);
950 w
= XFRAME (frame
)->root_window
;
952 while (NILP (XWINDOW (w
)->buffer
))
954 if (! NILP (XWINDOW (w
)->hchild
))
955 w
= XWINDOW (w
)->hchild
;
956 else if (! NILP (XWINDOW (w
)->vchild
))
957 w
= XWINDOW (w
)->vchild
;
964 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
965 Sactive_minibuffer_window
, 0, 0, 0,
966 doc
: /* Return the currently active minibuffer window, or nil if none. */)
969 return minibuf_level
? minibuf_window
: Qnil
;
972 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
973 doc
: /* Returns the root-window of FRAME.
974 If omitted, FRAME defaults to the currently selected frame. */)
981 window
= SELECTED_FRAME ()->root_window
;
984 CHECK_LIVE_FRAME (frame
);
985 window
= XFRAME (frame
)->root_window
;
991 DEFUN ("frame-selected-window", Fframe_selected_window
,
992 Sframe_selected_window
, 0, 1, 0,
993 doc
: /* Return the selected window of FRAME.
994 FRAME defaults to the currently selected frame. */)
1001 window
= SELECTED_FRAME ()->selected_window
;
1004 CHECK_LIVE_FRAME (frame
);
1005 window
= XFRAME (frame
)->selected_window
;
1011 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
1012 Sset_frame_selected_window
, 2, 3, 0,
1013 doc
: /* Set selected window of FRAME to WINDOW.
1014 If FRAME is nil, use the selected frame. If FRAME is the
1015 selected frame, this makes WINDOW the selected window.
1016 Optional argument NORECORD non-nil means to neither change the
1017 order of recently selected windows nor the buffer list.
1019 (frame
, window
, norecord
)
1020 Lisp_Object frame
, window
, norecord
;
1023 frame
= selected_frame
;
1025 CHECK_LIVE_FRAME (frame
);
1026 CHECK_LIVE_WINDOW (window
);
1028 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
1029 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
1031 if (EQ (frame
, selected_frame
))
1032 return Fselect_window (window
, norecord
);
1034 return XFRAME (frame
)->selected_window
= window
;
1038 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
1040 doc
: /* Return a list of all live frames. */)
1044 frames
= Fcopy_sequence (Vframe_list
);
1045 #ifdef HAVE_WINDOW_SYSTEM
1046 if (FRAMEP (tip_frame
))
1047 frames
= Fdelq (tip_frame
, frames
);
1052 /* Return the next frame in the frame list after FRAME.
1053 If MINIBUF is nil, exclude minibuffer-only frames.
1054 If MINIBUF is a window, include only its own frame
1055 and any frame now using that window as the minibuffer.
1056 If MINIBUF is `visible', include all visible frames.
1057 If MINIBUF is 0, include all visible and iconified frames.
1058 Otherwise, include all frames. */
1061 next_frame (frame
, minibuf
)
1063 Lisp_Object minibuf
;
1068 /* There must always be at least one frame in Vframe_list. */
1069 if (! CONSP (Vframe_list
))
1072 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
1073 forever. Forestall that. */
1074 CHECK_LIVE_FRAME (frame
);
1077 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1084 && ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1085 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1086 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1087 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
)))))
1089 /* Decide whether this frame is eligible to be returned. */
1091 /* If we've looped all the way around without finding any
1092 eligible frames, return the original frame. */
1096 /* Let minibuf decide if this frame is acceptable. */
1099 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1102 else if (EQ (minibuf
, Qvisible
))
1104 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1105 if (FRAME_VISIBLE_P (XFRAME (f
)))
1108 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
1110 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1111 if (FRAME_VISIBLE_P (XFRAME (f
))
1112 || FRAME_ICONIFIED_P (XFRAME (f
)))
1115 else if (WINDOWP (minibuf
))
1117 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1118 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1119 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1120 FRAME_FOCUS_FRAME (XFRAME (f
))))
1132 /* Return the previous frame in the frame list before FRAME.
1133 If MINIBUF is nil, exclude minibuffer-only frames.
1134 If MINIBUF is a window, include only its own frame
1135 and any frame now using that window as the minibuffer.
1136 If MINIBUF is `visible', include all visible frames.
1137 If MINIBUF is 0, include all visible and iconified frames.
1138 Otherwise, include all frames. */
1141 prev_frame (frame
, minibuf
)
1143 Lisp_Object minibuf
;
1148 /* There must always be at least one frame in Vframe_list. */
1149 if (! CONSP (Vframe_list
))
1153 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1161 if (EQ (frame
, f
) && !NILP (prev
))
1164 if ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1165 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1166 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1167 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
))))
1169 /* Decide whether this frame is eligible to be returned,
1170 according to minibuf. */
1173 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1176 else if (WINDOWP (minibuf
))
1178 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1179 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1180 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1181 FRAME_FOCUS_FRAME (XFRAME (f
))))
1184 else if (EQ (minibuf
, Qvisible
))
1186 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1187 if (FRAME_VISIBLE_P (XFRAME (f
)))
1190 else if (XFASTINT (minibuf
) == 0)
1192 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1193 if (FRAME_VISIBLE_P (XFRAME (f
))
1194 || FRAME_ICONIFIED_P (XFRAME (f
)))
1202 /* We've scanned the entire list. */
1204 /* We went through the whole frame list without finding a single
1205 acceptable frame. Return the original frame. */
1208 /* There were no acceptable frames in the list before FRAME; otherwise,
1209 we would have returned directly from the loop. Since PREV is the last
1210 acceptable frame in the list, return it. */
1215 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1216 doc
: /* Return the next frame in the frame list after FRAME.
1217 It considers only frames on the same terminal as FRAME.
1218 By default, skip minibuffer-only frames.
1219 If omitted, FRAME defaults to the selected frame.
1220 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1221 If MINIFRAME is a window, include only its own frame
1222 and any frame now using that window as the minibuffer.
1223 If MINIFRAME is `visible', include all visible frames.
1224 If MINIFRAME is 0, include all visible and iconified frames.
1225 Otherwise, include all frames. */)
1227 Lisp_Object frame
, miniframe
;
1230 frame
= selected_frame
;
1232 CHECK_LIVE_FRAME (frame
);
1233 return next_frame (frame
, miniframe
);
1236 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1237 doc
: /* Return the previous frame in the frame list before FRAME.
1238 It considers only frames on the same terminal as FRAME.
1239 By default, skip minibuffer-only frames.
1240 If omitted, FRAME defaults to the selected frame.
1241 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1242 If MINIFRAME is a window, include only its own frame
1243 and any frame now using that window as the minibuffer.
1244 If MINIFRAME is `visible', include all visible frames.
1245 If MINIFRAME is 0, include all visible and iconified frames.
1246 Otherwise, include all frames. */)
1248 Lisp_Object frame
, miniframe
;
1251 frame
= selected_frame
;
1252 CHECK_LIVE_FRAME (frame
);
1253 return prev_frame (frame
, miniframe
);
1256 /* Return 1 if it is ok to delete frame F;
1257 0 if all frames aside from F are invisible.
1258 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1261 other_visible_frames (f
)
1264 /* We know the selected frame is visible,
1265 so if F is some other frame, it can't be the sole visible one. */
1266 if (f
== SELECTED_FRAME ())
1271 for (frames
= Vframe_list
;
1273 frames
= XCDR (frames
))
1277 this = XCAR (frames
);
1278 /* Verify that the frame's window still exists
1279 and we can still talk to it. And note any recent change
1281 #ifdef HAVE_WINDOW_SYSTEM
1282 if (FRAME_WINDOW_P (XFRAME (this)))
1284 x_sync (XFRAME (this));
1285 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1289 if (FRAME_VISIBLE_P (XFRAME (this))
1290 || FRAME_ICONIFIED_P (XFRAME (this))
1291 /* Allow deleting the terminal frame when at least
1292 one X frame exists! */
1293 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1301 /* Error handler for `delete-frame-functions'. */
1303 delete_frame_handler (Lisp_Object arg
)
1305 add_to_log ("Error during `delete-frame': %s", arg
, Qnil
);
1309 extern Lisp_Object Qrun_hook_with_args
;
1311 /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1312 unconditionally. x_connection_closed and delete_terminal use
1313 this. Any other value of FORCE implements the semantics
1314 described for Fdelete_frame. */
1316 delete_frame (frame
, force
)
1317 /* If we use `register' here, gcc-4.0.2 on amd64 using
1318 -DUSE_LISP_UNION_TYPE complains further down that we're getting the
1319 address of `force'. Go figure. */
1320 Lisp_Object frame
, force
;
1323 struct frame
*sf
= SELECTED_FRAME ();
1326 int minibuffer_selected
;
1328 if (EQ (frame
, Qnil
))
1331 XSETFRAME (frame
, f
);
1335 CHECK_FRAME (frame
);
1339 if (! FRAME_LIVE_P (f
))
1342 if (NILP (force
) && !other_visible_frames (f
))
1343 error ("Attempt to delete the sole visible or iconified frame");
1345 /* x_connection_closed must have set FORCE to `noelisp' in order
1346 to delete the last frame, if it is gone. */
1347 if (NILP (XCDR (Vframe_list
)) && !EQ (force
, Qnoelisp
))
1348 error ("Attempt to delete the only frame");
1350 /* Does this frame have a minibuffer, and is it the surrogate
1351 minibuffer for any other frame? */
1352 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1356 for (frames
= Vframe_list
;
1358 frames
= XCDR (frames
))
1361 this = XCAR (frames
);
1363 if (! EQ (this, frame
)
1365 WINDOW_FRAME (XWINDOW
1366 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1368 /* If we MUST delete this frame, delete the other first.
1369 But do this only if FORCE equals `noelisp'. */
1370 if (EQ (force
, Qnoelisp
))
1371 delete_frame (this, Qnoelisp
);
1373 error ("Attempt to delete a surrogate minibuffer frame");
1378 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1379 frame is a tooltip. FORCE is set to `noelisp' when handling
1380 a disconnect from the terminal, so we don't dare call Lisp
1382 if (NILP (Vrun_hooks
) || !NILP (Fframe_parameter (frame
, intern ("tooltip"))))
1384 if (EQ (force
, Qnoelisp
))
1386 = Fcons (list3 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
),
1389 safe_call2 (Qrun_hook_with_args
, Qdelete_frame_functions
, frame
);
1391 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1392 if (! FRAME_LIVE_P (f
))
1395 /* At this point, we are committed to deleting the frame.
1396 There is no more chance for errors to prevent it. */
1398 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1400 /* Don't let the frame remain selected. */
1403 Lisp_Object tail
, frame1
;
1405 /* Look for another visible frame on the same terminal. */
1406 frame1
= next_frame (frame
, Qvisible
);
1408 /* If there is none, find *some* other frame. */
1409 if (NILP (frame1
) || EQ (frame1
, frame
))
1411 FOR_EACH_FRAME (tail
, frame1
)
1413 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1417 #ifdef NS_IMPL_COCOA
1419 /* Under NS, there is no system mechanism for choosing a new
1420 window to get focus -- it is left to application code.
1421 So the portion of THIS application interfacing with NS
1422 needs to know about it. We call Fraise_frame, but the
1423 purpose is really to transfer focus. */
1424 Fraise_frame (frame1
);
1427 do_switch_frame (frame1
, 0, 1, Qnil
);
1428 sf
= SELECTED_FRAME ();
1431 /* Don't allow minibuf_window to remain on a deleted frame. */
1432 if (EQ (f
->minibuffer_window
, minibuf_window
))
1434 Fset_window_buffer (sf
->minibuffer_window
,
1435 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1436 minibuf_window
= sf
->minibuffer_window
;
1438 /* If the dying minibuffer window was selected,
1439 select the new one. */
1440 if (minibuffer_selected
)
1441 Fselect_window (minibuf_window
, Qnil
);
1444 /* Don't let echo_area_window to remain on a deleted frame. */
1445 if (EQ (f
->minibuffer_window
, echo_area_window
))
1446 echo_area_window
= sf
->minibuffer_window
;
1448 /* Clear any X selections for this frame. */
1449 #ifdef HAVE_X_WINDOWS
1451 x_clear_frame_selections (f
);
1455 This function must be called before the window tree of the
1456 frame is deleted because windows contain dynamically allocated
1460 #ifdef HAVE_WINDOW_SYSTEM
1461 /* Give chance to each font driver to free a frame specific data. */
1462 font_update_drivers (f
, Qnil
);
1465 /* Mark all the windows that used to be on FRAME as deleted, and then
1466 remove the reference to them. */
1467 delete_all_subwindows (XWINDOW (f
->root_window
));
1468 f
->root_window
= Qnil
;
1470 Vframe_list
= Fdelq (frame
, Vframe_list
);
1471 FRAME_SET_VISIBLE (f
, 0);
1473 /* Allow the vector of menu bar contents to be freed in the next
1474 garbage collection. The frame object itself may not be garbage
1475 collected until much later, because recent_keys and other data
1476 structures can still refer to it. */
1477 f
->menu_bar_vector
= Qnil
;
1479 free_font_driver_list (f
);
1481 xfree (f
->decode_mode_spec_buffer
);
1482 xfree (FRAME_INSERT_COST (f
));
1483 xfree (FRAME_DELETEN_COST (f
));
1484 xfree (FRAME_INSERTN_COST (f
));
1485 xfree (FRAME_DELETE_COST (f
));
1486 xfree (FRAME_MESSAGE_BUF (f
));
1488 /* Since some events are handled at the interrupt level, we may get
1489 an event for f at any time; if we zero out the frame's terminal
1490 now, then we may trip up the event-handling code. Instead, we'll
1491 promise that the terminal of the frame must be valid until we
1492 have called the window-system-dependent frame destruction
1495 if (FRAME_TERMINAL (f
)->delete_frame_hook
)
1496 (*FRAME_TERMINAL (f
)->delete_frame_hook
) (f
);
1499 struct terminal
*terminal
= FRAME_TERMINAL (f
);
1500 f
->output_data
.nothing
= 0;
1501 f
->terminal
= 0; /* Now the frame is dead. */
1503 /* If needed, delete the terminal that this frame was on.
1504 (This must be done after the frame is killed.) */
1505 terminal
->reference_count
--;
1506 if (terminal
->reference_count
== 0)
1509 XSETTERMINAL (tmp
, terminal
);
1512 Fdelete_terminal (tmp
, NILP (force
) ? Qt
: force
);
1515 kb
= terminal
->kboard
;
1518 /* If we've deleted the last_nonminibuf_frame, then try to find
1520 if (f
== last_nonminibuf_frame
)
1524 last_nonminibuf_frame
= 0;
1526 for (frames
= Vframe_list
;
1528 frames
= XCDR (frames
))
1530 f
= XFRAME (XCAR (frames
));
1531 if (!FRAME_MINIBUF_ONLY_P (f
))
1533 last_nonminibuf_frame
= f
;
1539 /* If there's no other frame on the same kboard, get out of
1540 single-kboard state if we're in it for this kboard. */
1544 /* Some frame we found on the same kboard, or nil if there are none. */
1545 Lisp_Object frame_on_same_kboard
;
1547 frame_on_same_kboard
= Qnil
;
1549 for (frames
= Vframe_list
;
1551 frames
= XCDR (frames
))
1556 this = XCAR (frames
);
1561 if (kb
== FRAME_KBOARD (f1
))
1562 frame_on_same_kboard
= this;
1565 if (NILP (frame_on_same_kboard
))
1566 not_single_kboard_state (kb
);
1570 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1571 find another one. Prefer minibuffer-only frames, but also notice
1572 frames with other windows. */
1573 if (kb
!= NULL
&& EQ (frame
, kb
->Vdefault_minibuffer_frame
))
1577 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1578 Lisp_Object frame_with_minibuf
;
1579 /* Some frame we found on the same kboard, or nil if there are none. */
1580 Lisp_Object frame_on_same_kboard
;
1582 frame_on_same_kboard
= Qnil
;
1583 frame_with_minibuf
= Qnil
;
1585 for (frames
= Vframe_list
;
1587 frames
= XCDR (frames
))
1592 this = XCAR (frames
);
1597 /* Consider only frames on the same kboard
1598 and only those with minibuffers. */
1599 if (kb
== FRAME_KBOARD (f1
)
1600 && FRAME_HAS_MINIBUF_P (f1
))
1602 frame_with_minibuf
= this;
1603 if (FRAME_MINIBUF_ONLY_P (f1
))
1607 if (kb
== FRAME_KBOARD (f1
))
1608 frame_on_same_kboard
= this;
1611 if (!NILP (frame_on_same_kboard
))
1613 /* We know that there must be some frame with a minibuffer out
1614 there. If this were not true, all of the frames present
1615 would have to be minibufferless, which implies that at some
1616 point their minibuffer frames must have been deleted, but
1617 that is prohibited at the top; you can't delete surrogate
1618 minibuffer frames. */
1619 if (NILP (frame_with_minibuf
))
1622 kb
->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1625 /* No frames left on this kboard--say no minibuffer either. */
1626 kb
->Vdefault_minibuffer_frame
= Qnil
;
1629 /* Cause frame titles to update--necessary if we now have just one frame. */
1630 update_mode_lines
= 1;
1635 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1636 doc
: /* Delete FRAME, permanently eliminating it from use.
1637 FRAME defaults to the selected frame.
1639 A frame may not be deleted if its minibuffer is used by other frames.
1640 Normally, you may not delete a frame if all other frames are invisible,
1641 but if the second optional argument FORCE is non-nil, you may do so.
1643 This function runs `delete-frame-functions' before actually
1644 deleting the frame, unless the frame is a tooltip.
1645 The functions are run with one argument, the frame to be deleted. */)
1647 Lisp_Object frame
, force
;
1649 return delete_frame (frame
, !NILP (force
) ? Qt
: Qnil
);
1653 /* Return mouse position in character cell units. */
1655 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1656 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1657 The position is given in character cells, where (0, 0) is the
1658 upper-left corner of the frame, X is the horizontal offset, and Y is
1659 the vertical offset.
1660 If Emacs is running on a mouseless terminal or hasn't been programmed
1661 to read the mouse position, it returns the selected frame for FRAME
1662 and nil for X and Y.
1663 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1664 passing the normal return value to that function as an argument,
1665 and returns whatever that function returns. */)
1669 Lisp_Object lispy_dummy
;
1670 enum scroll_bar_part party_dummy
;
1671 Lisp_Object x
, y
, retval
;
1673 unsigned long long_dummy
;
1674 struct gcpro gcpro1
;
1676 f
= SELECTED_FRAME ();
1679 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1680 /* It's okay for the hook to refrain from storing anything. */
1681 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1682 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1683 &lispy_dummy
, &party_dummy
,
1690 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1695 XSETFRAME (lispy_dummy
, f
);
1696 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1698 if (!NILP (Vmouse_position_function
))
1699 retval
= call1 (Vmouse_position_function
, retval
);
1700 RETURN_UNGCPRO (retval
);
1703 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1704 Smouse_pixel_position
, 0, 0, 0,
1705 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1706 The position is given in pixel units, where (0, 0) is the
1707 upper-left corner of the frame, X is the horizontal offset, and Y is
1708 the vertical offset.
1709 If Emacs is running on a mouseless terminal or hasn't been programmed
1710 to read the mouse position, it returns the selected frame for FRAME
1711 and nil for X and Y. */)
1715 Lisp_Object lispy_dummy
;
1716 enum scroll_bar_part party_dummy
;
1718 unsigned long long_dummy
;
1720 f
= SELECTED_FRAME ();
1723 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1724 /* It's okay for the hook to refrain from storing anything. */
1725 if (FRAME_TERMINAL (f
)->mouse_position_hook
)
1726 (*FRAME_TERMINAL (f
)->mouse_position_hook
) (&f
, -1,
1727 &lispy_dummy
, &party_dummy
,
1731 XSETFRAME (lispy_dummy
, f
);
1732 return Fcons (lispy_dummy
, Fcons (x
, y
));
1735 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1736 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1737 Coordinates are relative to the frame, not a window,
1738 so the coordinates of the top left character in the frame
1739 may be nonzero due to left-hand scroll bars or the menu bar.
1741 The position is given in character cells, where (0, 0) is the
1742 upper-left corner of the frame, X is the horizontal offset, and Y is
1743 the vertical offset.
1745 This function is a no-op for an X frame that is not visible.
1746 If you have just created a frame, you must wait for it to become visible
1747 before calling this function on it, like this.
1748 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1750 Lisp_Object frame
, x
, y
;
1752 CHECK_LIVE_FRAME (frame
);
1756 /* I think this should be done with a hook. */
1757 #ifdef HAVE_WINDOW_SYSTEM
1758 if (FRAME_WINDOW_P (XFRAME (frame
)))
1759 /* Warping the mouse will cause enternotify and focus events. */
1760 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1762 #if defined (MSDOS) && defined (HAVE_MOUSE)
1763 if (FRAME_MSDOS_P (XFRAME (frame
)))
1765 Fselect_frame (frame
, Qnil
);
1766 mouse_moveto (XINT (x
), XINT (y
));
1771 Fselect_frame (frame
, Qnil
);
1772 term_mouse_moveto (XINT (x
), XINT (y
));
1781 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1782 Sset_mouse_pixel_position
, 3, 3, 0,
1783 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1784 The position is given in pixels, where (0, 0) is the upper-left corner
1785 of the frame, X is the horizontal offset, and Y is the vertical offset.
1787 Note, this is a no-op for an X frame that is not visible.
1788 If you have just created a frame, you must wait for it to become visible
1789 before calling this function on it, like this.
1790 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1792 Lisp_Object frame
, x
, y
;
1794 CHECK_LIVE_FRAME (frame
);
1798 /* I think this should be done with a hook. */
1799 #ifdef HAVE_WINDOW_SYSTEM
1800 if (FRAME_WINDOW_P (XFRAME (frame
)))
1801 /* Warping the mouse will cause enternotify and focus events. */
1802 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1804 #if defined (MSDOS) && defined (HAVE_MOUSE)
1805 if (FRAME_MSDOS_P (XFRAME (frame
)))
1807 Fselect_frame (frame
, Qnil
);
1808 mouse_moveto (XINT (x
), XINT (y
));
1813 Fselect_frame (frame
, Qnil
);
1814 term_mouse_moveto (XINT (x
), XINT (y
));
1823 static void make_frame_visible_1
P_ ((Lisp_Object
));
1825 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1827 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1828 If omitted, FRAME defaults to the currently selected frame. */)
1833 frame
= selected_frame
;
1835 CHECK_LIVE_FRAME (frame
);
1837 /* I think this should be done with a hook. */
1838 #ifdef HAVE_WINDOW_SYSTEM
1839 if (FRAME_WINDOW_P (XFRAME (frame
)))
1841 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1842 x_make_frame_visible (XFRAME (frame
));
1846 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1848 /* Make menu bar update for the Buffers and Frames menus. */
1849 windows_or_buffers_changed
++;
1854 /* Update the display_time slot of the buffers shown in WINDOW
1855 and all its descendents. */
1858 make_frame_visible_1 (window
)
1863 for (;!NILP (window
); window
= w
->next
)
1865 w
= XWINDOW (window
);
1867 if (!NILP (w
->buffer
))
1868 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1870 if (!NILP (w
->vchild
))
1871 make_frame_visible_1 (w
->vchild
);
1872 if (!NILP (w
->hchild
))
1873 make_frame_visible_1 (w
->hchild
);
1877 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1879 doc
: /* Make the frame FRAME invisible (assuming it is an X window).
1880 If omitted, FRAME defaults to the currently selected frame.
1881 Normally you may not make FRAME invisible if all other frames are invisible,
1882 but if the second optional argument FORCE is non-nil, you may do so. */)
1884 Lisp_Object frame
, force
;
1887 frame
= selected_frame
;
1889 CHECK_LIVE_FRAME (frame
);
1891 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1892 error ("Attempt to make invisible the sole visible or iconified frame");
1894 #if 0 /* This isn't logically necessary, and it can do GC. */
1895 /* Don't let the frame remain selected. */
1896 if (EQ (frame
, selected_frame
))
1897 do_switch_frame (next_frame (frame
, Qt
), 0, 0, Qnil
)
1900 /* Don't allow minibuf_window to remain on a deleted frame. */
1901 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1903 struct frame
*sf
= XFRAME (selected_frame
);
1904 Fset_window_buffer (sf
->minibuffer_window
,
1905 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1906 minibuf_window
= sf
->minibuffer_window
;
1909 /* I think this should be done with a hook. */
1910 #ifdef HAVE_WINDOW_SYSTEM
1911 if (FRAME_WINDOW_P (XFRAME (frame
)))
1912 x_make_frame_invisible (XFRAME (frame
));
1915 /* Make menu bar update for the Buffers and Frames menus. */
1916 windows_or_buffers_changed
++;
1921 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1923 doc
: /* Make the frame FRAME into an icon.
1924 If omitted, FRAME defaults to the currently selected frame. */)
1929 frame
= selected_frame
;
1931 CHECK_LIVE_FRAME (frame
);
1933 #if 0 /* This isn't logically necessary, and it can do GC. */
1934 /* Don't let the frame remain selected. */
1935 if (EQ (frame
, selected_frame
))
1936 Fhandle_switch_frame (next_frame (frame
, Qt
));
1939 /* Don't allow minibuf_window to remain on a deleted frame. */
1940 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1942 struct frame
*sf
= XFRAME (selected_frame
);
1943 Fset_window_buffer (sf
->minibuffer_window
,
1944 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1945 minibuf_window
= sf
->minibuffer_window
;
1948 /* I think this should be done with a hook. */
1949 #ifdef HAVE_WINDOW_SYSTEM
1950 if (FRAME_WINDOW_P (XFRAME (frame
)))
1951 x_iconify_frame (XFRAME (frame
));
1954 /* Make menu bar update for the Buffers and Frames menus. */
1955 windows_or_buffers_changed
++;
1960 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1962 doc
: /* Return t if FRAME is now \"visible\" (actually in use for display).
1963 A frame that is not \"visible\" is not updated and, if it works through
1964 a window system, it may not show at all.
1965 Return the symbol `icon' if frame is visible only as an icon.
1967 On a text-only terminal, all frames are considered visible, whether
1968 they are currently being displayed or not, and this function returns t
1973 CHECK_LIVE_FRAME (frame
);
1975 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1977 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1979 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1984 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1986 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1989 Lisp_Object tail
, frame
;
1994 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1996 frame
= XCAR (tail
);
1997 if (!FRAMEP (frame
))
2000 if (FRAME_VISIBLE_P (f
))
2001 value
= Fcons (frame
, value
);
2007 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
2008 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
2009 If FRAME is invisible or iconified, make it visible.
2010 If you don't specify a frame, the selected frame is used.
2011 If Emacs is displaying on an ordinary terminal or some other device which
2012 doesn't support multiple overlapping frames, this function selects FRAME. */)
2018 frame
= selected_frame
;
2020 CHECK_LIVE_FRAME (frame
);
2024 if (FRAME_TERMCAP_P (f
))
2025 /* On a text-only terminal select FRAME. */
2026 Fselect_frame (frame
, Qnil
);
2028 /* Do like the documentation says. */
2029 Fmake_frame_visible (frame
);
2031 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2032 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 1);
2037 /* Should we have a corresponding function called Flower_Power? */
2038 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
2039 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2040 If you don't specify a frame, the selected frame is used.
2041 If Emacs is displaying on an ordinary terminal or some other device which
2042 doesn't support multiple overlapping frames, this function does nothing. */)
2049 frame
= selected_frame
;
2051 CHECK_LIVE_FRAME (frame
);
2055 if (FRAME_TERMINAL (f
)->frame_raise_lower_hook
)
2056 (*FRAME_TERMINAL (f
)->frame_raise_lower_hook
) (f
, 0);
2062 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
2064 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2065 In other words, switch-frame events caused by events in FRAME will
2066 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2067 FOCUS-FRAME after reading an event typed at FRAME.
2069 If FOCUS-FRAME is omitted or nil, any existing redirection is
2070 cancelled, and the frame again receives its own keystrokes.
2072 Focus redirection is useful for temporarily redirecting keystrokes to
2073 a surrogate minibuffer frame when a frame doesn't have its own
2076 A frame's focus redirection can be changed by `select-frame'. If frame
2077 FOO is selected, and then a different frame BAR is selected, any
2078 frames redirecting their focus to FOO are shifted to redirect their
2079 focus to BAR. This allows focus redirection to work properly when the
2080 user switches from one frame to another using `select-window'.
2082 This means that a frame whose focus is redirected to itself is treated
2083 differently from a frame whose focus is redirected to nil; the former
2084 is affected by `select-frame', while the latter is not.
2086 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2087 (frame
, focus_frame
)
2088 Lisp_Object frame
, focus_frame
;
2092 /* Note that we don't check for a live frame here. It's reasonable
2093 to redirect the focus of a frame you're about to delete, if you
2094 know what other frame should receive those keystrokes. */
2095 CHECK_FRAME (frame
);
2097 if (! NILP (focus_frame
))
2098 CHECK_LIVE_FRAME (focus_frame
);
2102 f
->focus_frame
= focus_frame
;
2104 if (FRAME_TERMINAL (f
)->frame_rehighlight_hook
)
2105 (*FRAME_TERMINAL (f
)->frame_rehighlight_hook
) (f
);
2111 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
2112 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
2113 This returns nil if FRAME's focus is not redirected.
2114 See `redirect-frame-focus'. */)
2118 CHECK_LIVE_FRAME (frame
);
2120 return FRAME_FOCUS_FRAME (XFRAME (frame
));
2125 /* Return the value of frame parameter PROP in frame FRAME. */
2128 get_frame_param (frame
, prop
)
2129 register struct frame
*frame
;
2132 register Lisp_Object tem
;
2134 tem
= Fassq (prop
, frame
->param_alist
);
2140 /* Return the buffer-predicate of the selected frame. */
2143 frame_buffer_predicate (frame
)
2146 return XFRAME (frame
)->buffer_predicate
;
2149 /* Return the buffer-list of the selected frame. */
2152 frame_buffer_list (frame
)
2155 return XFRAME (frame
)->buffer_list
;
2158 /* Set the buffer-list of the selected frame. */
2161 set_frame_buffer_list (frame
, list
)
2162 Lisp_Object frame
, list
;
2164 XFRAME (frame
)->buffer_list
= list
;
2167 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2170 frames_discard_buffer (buffer
)
2173 Lisp_Object frame
, tail
;
2175 FOR_EACH_FRAME (tail
, frame
)
2177 XFRAME (frame
)->buffer_list
2178 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
2179 XFRAME (frame
)->buried_buffer_list
2180 = Fdelq (buffer
, XFRAME (frame
)->buried_buffer_list
);
2184 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2185 If the alist already has an element for PROP, we change it. */
2188 store_in_alist (alistptr
, prop
, val
)
2189 Lisp_Object
*alistptr
, val
;
2192 register Lisp_Object tem
;
2194 tem
= Fassq (prop
, *alistptr
);
2196 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2202 frame_name_fnn_p (str
, len
)
2206 if (len
> 1 && str
[0] == 'F')
2210 strtol (str
+ 1, &end_ptr
, 10);
2212 if (end_ptr
== str
+ len
)
2218 /* Set the name of the terminal frame. Also used by MSDOS frames.
2219 Modeled after x_set_name which is used for WINDOW frames. */
2222 set_term_frame_name (f
, name
)
2226 f
->explicit_name
= ! NILP (name
);
2228 /* If NAME is nil, set the name to F<num>. */
2233 /* Check for no change needed in this very common case
2234 before we do any consing. */
2235 if (frame_name_fnn_p (SDATA (f
->name
),
2240 sprintf (namebuf
, "F%d", tty_frame_count
);
2241 name
= build_string (namebuf
);
2245 CHECK_STRING (name
);
2247 /* Don't change the name if it's already NAME. */
2248 if (! NILP (Fstring_equal (name
, f
->name
)))
2251 /* Don't allow the user to set the frame name to F<num>, so it
2252 doesn't clash with the names we generate for terminal frames. */
2253 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
2254 error ("Frame names of the form F<num> are usurped by Emacs");
2258 update_mode_lines
= 1;
2262 store_frame_param (f
, prop
, val
)
2264 Lisp_Object prop
, val
;
2266 register Lisp_Object old_alist_elt
;
2268 /* The buffer-list parameters are stored in a special place and not
2270 if (EQ (prop
, Qbuffer_list
))
2272 f
->buffer_list
= val
;
2275 if (EQ (prop
, Qburied_buffer_list
))
2277 f
->buried_buffer_list
= val
;
2281 /* If PROP is a symbol which is supposed to have frame-local values,
2282 and it is set up based on this frame, switch to the global
2283 binding. That way, we can create or alter the frame-local binding
2284 without messing up the symbol's status. */
2287 Lisp_Object valcontents
;
2288 valcontents
= SYMBOL_VALUE (prop
);
2289 if ((BUFFER_LOCAL_VALUEP (valcontents
))
2290 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
2291 && XBUFFER_LOCAL_VALUE (valcontents
)->found_for_frame
2292 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
2293 swap_in_global_binding (prop
);
2296 /* The tty color needed to be set before the frame's parameter
2297 alist was updated with the new value. This is not true any more,
2298 but we still do this test early on. */
2299 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
)
2300 && f
== FRAME_TTY (f
)->previous_frame
)
2301 /* Force redisplay of this tty. */
2302 FRAME_TTY (f
)->previous_frame
= NULL
;
2304 /* Update the frame parameter alist. */
2305 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2306 if (EQ (old_alist_elt
, Qnil
))
2307 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2309 Fsetcdr (old_alist_elt
, val
);
2311 /* Update some other special parameters in their special places
2312 in addition to the alist. */
2314 if (EQ (prop
, Qbuffer_predicate
))
2315 f
->buffer_predicate
= val
;
2317 if (! FRAME_WINDOW_P (f
))
2319 if (EQ (prop
, Qmenu_bar_lines
))
2320 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2321 else if (EQ (prop
, Qname
))
2322 set_term_frame_name (f
, val
);
2325 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2327 if (! MINI_WINDOW_P (XWINDOW (val
)))
2328 error ("Surrogate minibuffer windows must be minibuffer windows");
2330 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2331 && !EQ (val
, f
->minibuffer_window
))
2332 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2334 /* Install the chosen minibuffer window, with proper buffer. */
2335 f
->minibuffer_window
= val
;
2339 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2340 doc
: /* Return the parameters-alist of frame FRAME.
2341 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2342 The meaningful PARMs depend on the kind of frame.
2343 If FRAME is omitted, return information on the currently selected frame. */)
2350 struct gcpro gcpro1
;
2353 frame
= selected_frame
;
2355 CHECK_FRAME (frame
);
2358 if (!FRAME_LIVE_P (f
))
2361 alist
= Fcopy_alist (f
->param_alist
);
2364 if (!FRAME_WINDOW_P (f
))
2366 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2367 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2370 /* If the frame's parameter alist says the colors are
2371 unspecified and reversed, take the frame's background pixel
2372 for foreground and vice versa. */
2373 elt
= Fassq (Qforeground_color
, alist
);
2374 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2376 if (strncmp (SDATA (XCDR (elt
)),
2378 SCHARS (XCDR (elt
))) == 0)
2379 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2380 else if (strncmp (SDATA (XCDR (elt
)),
2382 SCHARS (XCDR (elt
))) == 0)
2383 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2386 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2387 elt
= Fassq (Qbackground_color
, alist
);
2388 if (CONSP (elt
) && STRINGP (XCDR (elt
)))
2390 if (strncmp (SDATA (XCDR (elt
)),
2392 SCHARS (XCDR (elt
))) == 0)
2393 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2394 else if (strncmp (SDATA (XCDR (elt
)),
2396 SCHARS (XCDR (elt
))) == 0)
2397 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2400 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2401 store_in_alist (&alist
, intern ("font"),
2402 build_string (FRAME_MSDOS_P (f
)
2404 : FRAME_W32_P (f
) ? "w32term"
2407 store_in_alist (&alist
, Qname
, f
->name
);
2408 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2409 store_in_alist (&alist
, Qheight
, make_number (height
));
2410 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2411 store_in_alist (&alist
, Qwidth
, make_number (width
));
2412 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2413 store_in_alist (&alist
, Qminibuffer
,
2414 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2415 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2416 : FRAME_MINIBUF_WINDOW (f
)));
2417 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2418 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2419 store_in_alist (&alist
, Qburied_buffer_list
, XFRAME (frame
)->buried_buffer_list
);
2421 /* I think this should be done with a hook. */
2422 #ifdef HAVE_WINDOW_SYSTEM
2423 if (FRAME_WINDOW_P (f
))
2424 x_report_frame_params (f
, &alist
);
2428 /* This ought to be correct in f->param_alist for an X frame. */
2430 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2431 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2439 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2440 doc
: /* Return FRAME's value for parameter PARAMETER.
2441 If FRAME is nil, describe the currently selected frame. */)
2443 Lisp_Object frame
, parameter
;
2449 frame
= selected_frame
;
2451 CHECK_FRAME (frame
);
2452 CHECK_SYMBOL (parameter
);
2457 if (FRAME_LIVE_P (f
))
2459 /* Avoid consing in frequent cases. */
2460 if (EQ (parameter
, Qname
))
2462 #ifdef HAVE_X_WINDOWS
2463 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2464 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2465 #endif /* HAVE_X_WINDOWS */
2466 else if (EQ (parameter
, Qbackground_color
)
2467 || EQ (parameter
, Qforeground_color
))
2469 value
= Fassq (parameter
, f
->param_alist
);
2472 value
= XCDR (value
);
2473 /* Fframe_parameters puts the actual fg/bg color names,
2474 even if f->param_alist says otherwise. This is
2475 important when param_alist's notion of colors is
2476 "unspecified". We need to do the same here. */
2477 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2479 const char *color_name
;
2482 if (EQ (parameter
, Qbackground_color
))
2484 color_name
= SDATA (value
);
2485 csz
= SCHARS (value
);
2486 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2487 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2488 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2489 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2491 else if (EQ (parameter
, Qforeground_color
))
2493 color_name
= SDATA (value
);
2494 csz
= SCHARS (value
);
2495 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2496 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2497 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2498 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2503 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2505 else if (EQ (parameter
, Qdisplay_type
)
2506 || EQ (parameter
, Qbackground_mode
))
2507 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2509 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2516 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2517 Smodify_frame_parameters
, 2, 2, 0,
2518 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2519 If FRAME is nil, it defaults to the selected frame.
2520 ALIST is an alist of parameters to change and their new values.
2521 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2522 The meaningful PARMs depend on the kind of frame.
2523 Undefined PARMs are ignored, but stored in the frame's parameter list
2524 so that `frame-parameters' will return them.
2526 The value of frame parameter FOO can also be accessed
2527 as a frame-local binding for the variable FOO, if you have
2528 enabled such bindings for that variable with `make-variable-frame-local'.
2529 Note that this functionality is obsolete as of Emacs 22.2, and its
2530 use is not recommended. Explicitly check for a frame-parameter instead. */)
2532 Lisp_Object frame
, alist
;
2535 register Lisp_Object tail
, prop
, val
;
2537 if (EQ (frame
, Qnil
))
2538 frame
= selected_frame
;
2539 CHECK_LIVE_FRAME (frame
);
2542 /* I think this should be done with a hook. */
2543 #ifdef HAVE_WINDOW_SYSTEM
2544 if (FRAME_WINDOW_P (f
))
2545 x_set_frame_parameters (f
, alist
);
2549 if (FRAME_MSDOS_P (f
))
2550 IT_set_frame_parameters (f
, alist
);
2555 int length
= XINT (Flength (alist
));
2558 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2560 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2562 /* Extract parm names and values into those vectors. */
2565 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2570 parms
[i
] = Fcar (elt
);
2571 values
[i
] = Fcdr (elt
);
2575 /* Now process them in reverse of specified order. */
2576 for (i
--; i
>= 0; i
--)
2580 store_frame_param (f
, prop
, val
);
2582 /* Changing the background color might change the background
2583 mode, so that we have to load new defface specs.
2584 Call frame-set-background-mode to do that. */
2585 if (EQ (prop
, Qbackground_color
))
2586 call1 (Qframe_set_background_mode
, frame
);
2592 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2594 doc
: /* Height in pixels of a line in the font in frame FRAME.
2595 If FRAME is omitted, the selected frame is used.
2596 For a terminal frame, the value is always 1. */)
2603 frame
= selected_frame
;
2604 CHECK_FRAME (frame
);
2607 #ifdef HAVE_WINDOW_SYSTEM
2608 if (FRAME_WINDOW_P (f
))
2609 return make_number (x_char_height (f
));
2612 return make_number (1);
2616 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2618 doc
: /* Width in pixels of characters in the font in frame FRAME.
2619 If FRAME is omitted, the selected frame is used.
2620 On a graphical screen, the width is the standard width of the default font.
2621 For a terminal screen, the value is always 1. */)
2628 frame
= selected_frame
;
2629 CHECK_FRAME (frame
);
2632 #ifdef HAVE_WINDOW_SYSTEM
2633 if (FRAME_WINDOW_P (f
))
2634 return make_number (x_char_width (f
));
2637 return make_number (1);
2640 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2641 Sframe_pixel_height
, 0, 1, 0,
2642 doc
: /* Return a FRAME's height in pixels.
2643 This counts only the height available for text lines,
2644 not menu bars on window-system Emacs frames.
2645 For a terminal frame, the result really gives the height in characters.
2646 If FRAME is omitted, the selected frame is used. */)
2653 frame
= selected_frame
;
2654 CHECK_FRAME (frame
);
2657 #ifdef HAVE_WINDOW_SYSTEM
2658 if (FRAME_WINDOW_P (f
))
2659 return make_number (x_pixel_height (f
));
2662 return make_number (FRAME_LINES (f
));
2665 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2666 Sframe_pixel_width
, 0, 1, 0,
2667 doc
: /* Return FRAME's width in pixels.
2668 For a terminal frame, the result really gives the width in characters.
2669 If FRAME is omitted, the selected frame is used. */)
2676 frame
= selected_frame
;
2677 CHECK_FRAME (frame
);
2680 #ifdef HAVE_WINDOW_SYSTEM
2681 if (FRAME_WINDOW_P (f
))
2682 return make_number (x_pixel_width (f
));
2685 return make_number (FRAME_COLS (f
));
2688 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2689 doc
: /* Specify that the frame FRAME has LINES lines.
2690 Optional third arg non-nil means that redisplay should use LINES lines
2691 but that the idea of the actual height of the frame should not be changed. */)
2692 (frame
, lines
, pretend
)
2693 Lisp_Object frame
, lines
, pretend
;
2695 register struct frame
*f
;
2697 CHECK_NUMBER (lines
);
2699 frame
= selected_frame
;
2700 CHECK_LIVE_FRAME (frame
);
2703 /* I think this should be done with a hook. */
2704 #ifdef HAVE_WINDOW_SYSTEM
2705 if (FRAME_WINDOW_P (f
))
2707 if (XINT (lines
) != FRAME_LINES (f
))
2708 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2709 do_pending_window_change (0);
2713 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2717 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2718 doc
: /* Specify that the frame FRAME has COLS columns.
2719 Optional third arg non-nil means that redisplay should use COLS columns
2720 but that the idea of the actual width of the frame should not be changed. */)
2721 (frame
, cols
, pretend
)
2722 Lisp_Object frame
, cols
, pretend
;
2724 register struct frame
*f
;
2725 CHECK_NUMBER (cols
);
2727 frame
= selected_frame
;
2728 CHECK_LIVE_FRAME (frame
);
2731 /* I think this should be done with a hook. */
2732 #ifdef HAVE_WINDOW_SYSTEM
2733 if (FRAME_WINDOW_P (f
))
2735 if (XINT (cols
) != FRAME_COLS (f
))
2736 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2737 do_pending_window_change (0);
2741 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2745 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2746 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2748 Lisp_Object frame
, cols
, rows
;
2750 register struct frame
*f
;
2752 CHECK_LIVE_FRAME (frame
);
2753 CHECK_NUMBER (cols
);
2754 CHECK_NUMBER (rows
);
2757 /* I think this should be done with a hook. */
2758 #ifdef HAVE_WINDOW_SYSTEM
2759 if (FRAME_WINDOW_P (f
))
2761 if (XINT (rows
) != FRAME_LINES (f
)
2762 || XINT (cols
) != FRAME_COLS (f
)
2763 || f
->new_text_lines
|| f
->new_text_cols
)
2764 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2765 do_pending_window_change (0);
2769 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2774 DEFUN ("set-frame-position", Fset_frame_position
,
2775 Sset_frame_position
, 3, 3, 0,
2776 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2777 This is actually the position of the upper left corner of the frame.
2778 Negative values for XOFFSET or YOFFSET are interpreted relative to
2779 the rightmost or bottommost possible position (that stays within the screen). */)
2780 (frame
, xoffset
, yoffset
)
2781 Lisp_Object frame
, xoffset
, yoffset
;
2783 register struct frame
*f
;
2785 CHECK_LIVE_FRAME (frame
);
2786 CHECK_NUMBER (xoffset
);
2787 CHECK_NUMBER (yoffset
);
2790 /* I think this should be done with a hook. */
2791 #ifdef HAVE_WINDOW_SYSTEM
2792 if (FRAME_WINDOW_P (f
))
2793 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2800 /***********************************************************************
2802 ***********************************************************************/
2804 /* Connect the frame-parameter names for X frames
2805 to the ways of passing the parameter values to the window system.
2807 The name of a parameter, as a Lisp symbol,
2808 has an `x-frame-parameter' property which is an integer in Lisp
2809 that is an index in this table. */
2811 struct frame_parm_table
{
2813 Lisp_Object
*variable
;
2816 static struct frame_parm_table frame_parms
[] =
2818 {"auto-raise", &Qauto_raise
},
2819 {"auto-lower", &Qauto_lower
},
2820 {"background-color", 0},
2821 {"border-color", &Qborder_color
},
2822 {"border-width", &Qborder_width
},
2823 {"cursor-color", &Qcursor_color
},
2824 {"cursor-type", &Qcursor_type
},
2826 {"foreground-color", 0},
2827 {"icon-name", &Qicon_name
},
2828 {"icon-type", &Qicon_type
},
2829 {"internal-border-width", &Qinternal_border_width
},
2830 {"menu-bar-lines", &Qmenu_bar_lines
},
2831 {"mouse-color", &Qmouse_color
},
2833 {"scroll-bar-width", &Qscroll_bar_width
},
2835 {"unsplittable", &Qunsplittable
},
2836 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2837 {"visibility", &Qvisibility
},
2838 {"tool-bar-lines", &Qtool_bar_lines
},
2839 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2840 {"scroll-bar-background", &Qscroll_bar_background
},
2841 {"screen-gamma", &Qscreen_gamma
},
2842 {"line-spacing", &Qline_spacing
},
2843 {"left-fringe", &Qleft_fringe
},
2844 {"right-fringe", &Qright_fringe
},
2845 {"wait-for-wm", &Qwait_for_wm
},
2846 {"fullscreen", &Qfullscreen
},
2847 {"font-backend", &Qfont_backend
},
2849 {"sticky", &Qsticky
},
2852 #ifdef HAVE_WINDOW_SYSTEM
2854 extern Lisp_Object Qbox
;
2855 extern Lisp_Object Qtop
;
2857 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2858 wanted positions of the WM window (not Emacs window).
2859 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2860 window (FRAME_X_WINDOW).
2864 x_fullscreen_adjust (f
, width
, height
, top_pos
, left_pos
)
2871 int newwidth
= FRAME_COLS (f
);
2872 int newheight
= FRAME_LINES (f
);
2873 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2875 *top_pos
= f
->top_pos
;
2876 *left_pos
= f
->left_pos
;
2878 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2882 ph
= x_display_pixel_height (dpyinfo
);
2883 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2884 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2885 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2889 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2893 pw
= x_display_pixel_width (dpyinfo
);
2894 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2895 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2896 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2901 *height
= newheight
;
2905 /* Change the parameters of frame F as specified by ALIST.
2906 If a parameter is not specially recognized, do nothing special;
2907 otherwise call the `x_set_...' function for that parameter.
2908 Except for certain geometry properties, always call store_frame_param
2909 to store the new value in the parameter alist. */
2912 x_set_frame_parameters (f
, alist
)
2918 /* If both of these parameters are present, it's more efficient to
2919 set them both at once. So we wait until we've looked at the
2920 entire list before we set them. */
2924 Lisp_Object left
, top
;
2926 /* Same with these. */
2927 Lisp_Object icon_left
, icon_top
;
2929 /* Record in these vectors all the parms specified. */
2931 Lisp_Object
*values
;
2933 int left_no_change
= 0, top_no_change
= 0;
2934 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2935 int size_changed
= 0;
2936 struct gcpro gcpro1
, gcpro2
;
2939 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2942 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2943 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2945 /* Extract parm names and values into those vectors. */
2948 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
2953 parms
[i
] = Fcar (elt
);
2954 values
[i
] = Fcdr (elt
);
2957 /* TAIL and ALIST are not used again below here. */
2958 alist
= tail
= Qnil
;
2960 GCPRO2 (*parms
, *values
);
2964 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2965 because their values appear in VALUES and strings are not valid. */
2966 top
= left
= Qunbound
;
2967 icon_left
= icon_top
= Qunbound
;
2969 /* Provide default values for HEIGHT and WIDTH. */
2970 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2971 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2973 /* Process foreground_color and background_color before anything else.
2974 They are independent of other properties, but other properties (e.g.,
2975 cursor_color) are dependent upon them. */
2976 /* Process default font as well, since fringe widths depends on it. */
2977 for (p
= 0; p
< i
; p
++)
2979 Lisp_Object prop
, val
;
2983 if (EQ (prop
, Qforeground_color
)
2984 || EQ (prop
, Qbackground_color
)
2985 || EQ (prop
, Qfont
))
2987 register Lisp_Object param_index
, old_value
;
2989 old_value
= get_frame_param (f
, prop
);
2990 if (NILP (Fequal (val
, old_value
)))
2992 store_frame_param (f
, prop
, val
);
2994 param_index
= Fget (prop
, Qx_frame_parameter
);
2995 if (NATNUMP (param_index
)
2996 && (XFASTINT (param_index
)
2997 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2998 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2999 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3004 /* Now process them in reverse of specified order. */
3005 for (i
--; i
>= 0; i
--)
3007 Lisp_Object prop
, val
;
3012 if (EQ (prop
, Qwidth
) && NATNUMP (val
))
3015 width
= XFASTINT (val
);
3017 else if (EQ (prop
, Qheight
) && NATNUMP (val
))
3020 height
= XFASTINT (val
);
3022 else if (EQ (prop
, Qtop
))
3024 else if (EQ (prop
, Qleft
))
3026 else if (EQ (prop
, Qicon_top
))
3028 else if (EQ (prop
, Qicon_left
))
3030 else if (EQ (prop
, Qforeground_color
)
3031 || EQ (prop
, Qbackground_color
)
3032 || EQ (prop
, Qfont
))
3033 /* Processed above. */
3037 register Lisp_Object param_index
, old_value
;
3039 old_value
= get_frame_param (f
, prop
);
3041 store_frame_param (f
, prop
, val
);
3043 param_index
= Fget (prop
, Qx_frame_parameter
);
3044 if (NATNUMP (param_index
)
3045 && (XFASTINT (param_index
)
3046 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3047 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
3048 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
3052 /* Don't die if just one of these was set. */
3053 if (EQ (left
, Qunbound
))
3056 if (f
->left_pos
< 0)
3057 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
3059 XSETINT (left
, f
->left_pos
);
3061 if (EQ (top
, Qunbound
))
3065 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
3067 XSETINT (top
, f
->top_pos
);
3070 /* If one of the icon positions was not set, preserve or default it. */
3071 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
3073 icon_left_no_change
= 1;
3074 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
3075 if (NILP (icon_left
))
3076 XSETINT (icon_left
, 0);
3078 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
3080 icon_top_no_change
= 1;
3081 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
3082 if (NILP (icon_top
))
3083 XSETINT (icon_top
, 0);
3086 /* Don't set these parameters unless they've been explicitly
3087 specified. The window might be mapped or resized while we're in
3088 this function, and we don't want to override that unless the lisp
3089 code has asked for it.
3091 Don't set these parameters unless they actually differ from the
3092 window's current parameters; the window may not actually exist
3097 check_frame_size (f
, &height
, &width
);
3099 XSETFRAME (frame
, f
);
3102 && (width
!= FRAME_COLS (f
)
3103 || height
!= FRAME_LINES (f
)
3104 || f
->new_text_lines
|| f
->new_text_cols
))
3105 Fset_frame_size (frame
, make_number (width
), make_number (height
));
3107 if ((!NILP (left
) || !NILP (top
))
3108 && ! (left_no_change
&& top_no_change
)
3109 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
3110 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
3115 /* Record the signs. */
3116 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
3117 if (EQ (left
, Qminus
))
3118 f
->size_hint_flags
|= XNegative
;
3119 else if (INTEGERP (left
))
3121 leftpos
= XINT (left
);
3123 f
->size_hint_flags
|= XNegative
;
3125 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
3126 && CONSP (XCDR (left
))
3127 && INTEGERP (XCAR (XCDR (left
))))
3129 leftpos
= - XINT (XCAR (XCDR (left
)));
3130 f
->size_hint_flags
|= XNegative
;
3132 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
3133 && CONSP (XCDR (left
))
3134 && INTEGERP (XCAR (XCDR (left
))))
3136 leftpos
= XINT (XCAR (XCDR (left
)));
3139 if (EQ (top
, Qminus
))
3140 f
->size_hint_flags
|= YNegative
;
3141 else if (INTEGERP (top
))
3143 toppos
= XINT (top
);
3145 f
->size_hint_flags
|= YNegative
;
3147 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
3148 && CONSP (XCDR (top
))
3149 && INTEGERP (XCAR (XCDR (top
))))
3151 toppos
= - XINT (XCAR (XCDR (top
)));
3152 f
->size_hint_flags
|= YNegative
;
3154 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
3155 && CONSP (XCDR (top
))
3156 && INTEGERP (XCAR (XCDR (top
))))
3158 toppos
= XINT (XCAR (XCDR (top
)));
3162 /* Store the numeric value of the position. */
3163 f
->top_pos
= toppos
;
3164 f
->left_pos
= leftpos
;
3166 f
->win_gravity
= NorthWestGravity
;
3168 /* Actually set that position, and convert to absolute. */
3169 x_set_offset (f
, leftpos
, toppos
, -1);
3172 if ((!NILP (icon_left
) || !NILP (icon_top
))
3173 && ! (icon_left_no_change
&& icon_top_no_change
))
3174 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3181 /* Insert a description of internally-recorded parameters of frame X
3182 into the parameter alist *ALISTPTR that is to be given to the user.
3183 Only parameters that are specific to the X window system
3184 and whose values are not correctly recorded in the frame's
3185 param_alist need to be considered here. */
3188 x_report_frame_params (f
, alistptr
)
3190 Lisp_Object
*alistptr
;
3195 /* Represent negative positions (off the top or left screen edge)
3196 in a way that Fmodify_frame_parameters will understand correctly. */
3197 XSETINT (tem
, f
->left_pos
);
3198 if (f
->left_pos
>= 0)
3199 store_in_alist (alistptr
, Qleft
, tem
);
3201 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3203 XSETINT (tem
, f
->top_pos
);
3204 if (f
->top_pos
>= 0)
3205 store_in_alist (alistptr
, Qtop
, tem
);
3207 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3209 store_in_alist (alistptr
, Qborder_width
,
3210 make_number (f
->border_width
));
3211 store_in_alist (alistptr
, Qinternal_border_width
,
3212 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3213 store_in_alist (alistptr
, Qleft_fringe
,
3214 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3215 store_in_alist (alistptr
, Qright_fringe
,
3216 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3217 store_in_alist (alistptr
, Qscroll_bar_width
,
3218 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3220 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3221 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3222 /* nil means "use default width"
3223 for non-toolkit scroll bar.
3224 ruler-mode.el depends on this. */
3226 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
3227 store_in_alist (alistptr
, Qwindow_id
,
3228 build_string (buf
));
3229 #ifdef HAVE_X_WINDOWS
3230 #ifdef USE_X_TOOLKIT
3231 /* Tooltip frame may not have this widget. */
3232 if (FRAME_X_OUTPUT (f
)->widget
)
3234 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
3235 store_in_alist (alistptr
, Qouter_window_id
,
3236 build_string (buf
));
3238 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3239 FRAME_SAMPLE_VISIBILITY (f
);
3240 store_in_alist (alistptr
, Qvisibility
,
3241 (FRAME_VISIBLE_P (f
) ? Qt
3242 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3243 store_in_alist (alistptr
, Qdisplay
,
3244 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3246 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3249 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3250 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3251 store_in_alist (alistptr
, Qparent_id
, tem
);
3255 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3256 the previous value of that parameter, NEW_VALUE is the new value. */
3259 x_set_fullscreen (f
, new_value
, old_value
)
3261 Lisp_Object new_value
, old_value
;
3263 if (NILP (new_value
))
3264 f
->want_fullscreen
= FULLSCREEN_NONE
;
3265 else if (EQ (new_value
, Qfullboth
) || EQ (new_value
, Qfullscreen
))
3266 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3267 else if (EQ (new_value
, Qfullwidth
))
3268 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3269 else if (EQ (new_value
, Qfullheight
))
3270 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3271 else if (EQ (new_value
, Qmaximized
))
3272 f
->want_fullscreen
= FULLSCREEN_MAXIMIZED
;
3274 if (FRAME_TERMINAL (f
)->fullscreen_hook
!= NULL
)
3275 FRAME_TERMINAL (f
)->fullscreen_hook (f
);
3279 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3280 the previous value of that parameter, NEW_VALUE is the new value. */
3283 x_set_line_spacing (f
, new_value
, old_value
)
3285 Lisp_Object new_value
, old_value
;
3287 if (NILP (new_value
))
3288 f
->extra_line_spacing
= 0;
3289 else if (NATNUMP (new_value
))
3290 f
->extra_line_spacing
= XFASTINT (new_value
);
3292 signal_error ("Invalid line-spacing", new_value
);
3293 if (FRAME_VISIBLE_P (f
))
3298 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3299 the previous value of that parameter, NEW_VALUE is the new value. */
3302 x_set_screen_gamma (f
, new_value
, old_value
)
3304 Lisp_Object new_value
, old_value
;
3306 Lisp_Object bgcolor
;
3308 if (NILP (new_value
))
3310 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3311 /* The value 0.4545 is the normal viewing gamma. */
3312 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3314 signal_error ("Invalid screen-gamma", new_value
);
3316 /* Apply the new gamma value to the frame background. */
3317 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3318 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3320 Lisp_Object index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3322 && (XFASTINT (index
)
3323 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3324 && FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3325 (*FRAME_RIF (f
)->frame_parm_handlers
[XFASTINT (index
)])
3329 Fclear_face_cache (Qnil
);
3334 x_set_font (f
, arg
, oldval
)
3336 Lisp_Object arg
, oldval
;
3338 Lisp_Object frame
, font_object
, lval
;
3341 /* Set the frame parameter back to the old value because we may
3342 fail to use ARG as the new parameter value. */
3343 store_frame_param (f
, Qfont
, oldval
);
3345 /* ARG is a fontset name, a font name, a cons of fontset name and a
3346 font object, or a font object. In the last case, this function
3350 fontset
= fs_query_fontset (arg
, 0);
3353 font_object
= font_open_by_name (f
, SDATA (arg
));
3354 if (NILP (font_object
))
3355 error ("Font `%s' is not defined", SDATA (arg
));
3356 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3358 else if (fontset
> 0)
3360 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3362 font_object
= font_open_by_name (f
, SDATA (ascii_font
));
3363 if (NILP (font_object
))
3364 error ("Font `%s' is not defined", SDATA (arg
));
3365 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3368 error ("The default fontset can't be used for a frame font");
3370 else if (CONSP (arg
) && STRINGP (XCAR (arg
)) && FONT_OBJECT_P (XCDR (arg
)))
3372 /* This is the case that the ASCII font of F's fontset XCAR
3373 (arg) is changed to the font XCDR (arg) by
3374 `set-fontset-font'. */
3375 fontset
= fs_query_fontset (XCAR (arg
), 0);
3377 error ("Unknown fontset: %s", SDATA (XCAR (arg
)));
3378 font_object
= XCDR (arg
);
3379 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3381 else if (FONT_OBJECT_P (arg
))
3384 /* This is to store the XLFD font name in the frame parameter for
3385 backward compatiblity. We should store the font-object
3386 itself in the future. */
3387 arg
= AREF (font_object
, FONT_NAME_INDEX
);
3388 fontset
= FRAME_FONTSET (f
);
3389 /* Check if we can use the current fontset. If not, set FONTSET
3390 to -1 to generate a new fontset from FONT-OBJECT. */
3393 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3394 Lisp_Object spec
= font_spec_from_name (ascii_font
);
3396 if (! font_match_p (spec
, font_object
))
3401 signal_error ("Invalid font", arg
);
3403 if (! NILP (Fequal (font_object
, oldval
)))
3407 lval
= Fassq (Qfullscreen
, f
->param_alist
);
3408 if (CONSP (lval
)) lval
= CDR (lval
);
3410 x_new_font (f
, font_object
, fontset
);
3411 store_frame_param (f
, Qfont
, arg
);
3412 /* Recalculate toolbar height. */
3413 f
->n_tool_bar_rows
= 0;
3414 /* Ensure we redraw it. */
3415 clear_current_matrices (f
);
3417 recompute_basic_faces (f
);
3419 do_pending_window_change (0);
3421 /* We used to call face-set-after-frame-default here, but it leads to
3422 recursive calls (since that function can set the `default' face's
3423 font which in turns changes the frame's `font' parameter).
3424 Also I don't know what this call is meant to do, but it seems the
3425 wrong way to do it anyway (it does a lot more work than what seems
3426 reasonable in response to a change to `font'). */
3431 x_set_font_backend (f
, new_value
, old_value
)
3433 Lisp_Object new_value
, old_value
;
3435 if (! NILP (new_value
)
3436 && !CONSP (new_value
))
3440 CHECK_STRING (new_value
);
3441 p0
= p1
= SDATA (new_value
);
3445 while (*p1
&& ! isspace (*p1
) && *p1
!= ',') p1
++;
3447 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3453 while ((c
= *++p1
) && isspace (c
));
3457 new_value
= Fnreverse (new_value
);
3460 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3464 free_all_realized_faces (Qnil
);
3466 new_value
= font_update_drivers (f
, NILP (new_value
) ? Qt
: new_value
);
3467 if (NILP (new_value
))
3469 if (NILP (old_value
))
3470 error ("No font backend available");
3471 font_update_drivers (f
, old_value
);
3472 error ("None of specified font backends are available");
3474 store_frame_param (f
, Qfont_backend
, new_value
);
3480 XSETFRAME (frame
, f
);
3481 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3482 ++face_change_count
;
3483 ++windows_or_buffers_changed
;
3489 x_set_fringe_width (f
, new_value
, old_value
)
3491 Lisp_Object new_value
, old_value
;
3493 compute_fringe_widths (f
, 1);
3497 x_set_border_width (f
, arg
, oldval
)
3499 Lisp_Object arg
, oldval
;
3503 if (XINT (arg
) == f
->border_width
)
3506 if (FRAME_X_WINDOW (f
) != 0)
3507 error ("Cannot change the border width of a frame");
3509 f
->border_width
= XINT (arg
);
3513 x_set_internal_border_width (f
, arg
, oldval
)
3515 Lisp_Object arg
, oldval
;
3517 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3520 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3521 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3522 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3524 #ifdef USE_X_TOOLKIT
3525 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3526 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3529 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3532 if (FRAME_X_WINDOW (f
) != 0)
3534 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3535 SET_FRAME_GARBAGED (f
);
3536 do_pending_window_change (0);
3539 SET_FRAME_GARBAGED (f
);
3543 x_set_visibility (f
, value
, oldval
)
3545 Lisp_Object value
, oldval
;
3548 XSETFRAME (frame
, f
);
3551 Fmake_frame_invisible (frame
, Qt
);
3552 else if (EQ (value
, Qicon
))
3553 Ficonify_frame (frame
);
3555 Fmake_frame_visible (frame
);
3559 x_set_autoraise (f
, arg
, oldval
)
3561 Lisp_Object arg
, oldval
;
3563 f
->auto_raise
= !EQ (Qnil
, arg
);
3567 x_set_autolower (f
, arg
, oldval
)
3569 Lisp_Object arg
, oldval
;
3571 f
->auto_lower
= !EQ (Qnil
, arg
);
3575 x_set_unsplittable (f
, arg
, oldval
)
3577 Lisp_Object arg
, oldval
;
3579 f
->no_split
= !NILP (arg
);
3583 x_set_vertical_scroll_bars (f
, arg
, oldval
)
3585 Lisp_Object arg
, oldval
;
3587 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3588 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3589 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3590 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3592 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3594 ? vertical_scroll_bar_none
3596 ? vertical_scroll_bar_left
3598 ? vertical_scroll_bar_right
3599 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3600 ? vertical_scroll_bar_left
3601 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3602 ? vertical_scroll_bar_right
3603 : vertical_scroll_bar_none
);
3605 /* We set this parameter before creating the X window for the
3606 frame, so we can get the geometry right from the start.
3607 However, if the window hasn't been created yet, we shouldn't
3608 call x_set_window_size. */
3609 if (FRAME_X_WINDOW (f
))
3610 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3611 do_pending_window_change (0);
3616 x_set_scroll_bar_width (f
, arg
, oldval
)
3618 Lisp_Object arg
, oldval
;
3620 int wid
= FRAME_COLUMN_WIDTH (f
);
3624 x_set_scroll_bar_default_width (f
);
3626 if (FRAME_X_WINDOW (f
))
3627 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3628 do_pending_window_change (0);
3630 else if (INTEGERP (arg
) && XINT (arg
) > 0
3631 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3633 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3634 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3636 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3637 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3638 if (FRAME_X_WINDOW (f
))
3639 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3640 do_pending_window_change (0);
3643 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3644 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3645 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3650 /* Return non-nil if frame F wants a bitmap icon. */
3658 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3666 x_set_alpha (f
, arg
, oldval
)
3668 Lisp_Object arg
, oldval
;
3675 for (i
= 0; i
< 2; i
++)
3688 else if (FLOATP (item
))
3690 alpha
= XFLOAT_DATA (item
);
3691 if (alpha
< 0.0 || 1.0 < alpha
)
3692 args_out_of_range (make_float (0.0), make_float (1.0));
3694 else if (INTEGERP (item
))
3696 ialpha
= XINT (item
);
3697 if (ialpha
< 0 || 100 < ialpha
)
3698 args_out_of_range (make_number (0), make_number (100));
3700 alpha
= ialpha
/ 100.0;
3703 wrong_type_argument (Qnumberp
, item
);
3707 for (i
= 0; i
< 2; i
++)
3708 f
->alpha
[i
] = newval
[i
];
3710 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
3712 x_set_frame_alpha (f
);
3720 /* Subroutines of creating an X frame. */
3722 /* Make sure that Vx_resource_name is set to a reasonable value.
3723 Fix it up, or set it to `emacs' if it is too hopeless. */
3726 validate_x_resource_name ()
3729 /* Number of valid characters in the resource name. */
3731 /* Number of invalid characters in the resource name. */
3736 if (!STRINGP (Vx_resource_class
))
3737 Vx_resource_class
= build_string (EMACS_CLASS
);
3739 if (STRINGP (Vx_resource_name
))
3741 unsigned char *p
= SDATA (Vx_resource_name
);
3744 len
= SBYTES (Vx_resource_name
);
3746 /* Only letters, digits, - and _ are valid in resource names.
3747 Count the valid characters and count the invalid ones. */
3748 for (i
= 0; i
< len
; i
++)
3751 if (! ((c
>= 'a' && c
<= 'z')
3752 || (c
>= 'A' && c
<= 'Z')
3753 || (c
>= '0' && c
<= '9')
3754 || c
== '-' || c
== '_'))
3761 /* Not a string => completely invalid. */
3762 bad_count
= 5, good_count
= 0;
3764 /* If name is valid already, return. */
3768 /* If name is entirely invalid, or nearly so, use `emacs'. */
3770 || (good_count
== 1 && bad_count
> 0))
3772 Vx_resource_name
= build_string ("emacs");
3776 /* Name is partly valid. Copy it and replace the invalid characters
3777 with underscores. */
3779 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3781 for (i
= 0; i
< len
; i
++)
3783 int c
= SREF (new, i
);
3784 if (! ((c
>= 'a' && c
<= 'z')
3785 || (c
>= 'A' && c
<= 'Z')
3786 || (c
>= '0' && c
<= '9')
3787 || c
== '-' || c
== '_'))
3793 extern char *x_get_string_resource
P_ ((XrmDatabase
, char *, char *));
3794 extern Display_Info
*check_x_display_info
P_ ((Lisp_Object
));
3797 /* Get specified attribute from resource database RDB.
3798 See Fx_get_resource below for other parameters. */
3801 xrdb_get_resource (rdb
, attribute
, class, component
, subclass
)
3803 Lisp_Object attribute
, class, component
, subclass
;
3805 register char *value
;
3809 CHECK_STRING (attribute
);
3810 CHECK_STRING (class);
3812 if (!NILP (component
))
3813 CHECK_STRING (component
);
3814 if (!NILP (subclass
))
3815 CHECK_STRING (subclass
);
3816 if (NILP (component
) != NILP (subclass
))
3817 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3819 validate_x_resource_name ();
3821 /* Allocate space for the components, the dots which separate them,
3822 and the final '\0'. Make them big enough for the worst case. */
3823 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3824 + (STRINGP (component
)
3825 ? SBYTES (component
) : 0)
3826 + SBYTES (attribute
)
3829 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3831 + (STRINGP (subclass
)
3832 ? SBYTES (subclass
) : 0)
3835 /* Start with emacs.FRAMENAME for the name (the specific one)
3836 and with `Emacs' for the class key (the general one). */
3837 strcpy (name_key
, SDATA (Vx_resource_name
));
3838 strcpy (class_key
, SDATA (Vx_resource_class
));
3840 strcat (class_key
, ".");
3841 strcat (class_key
, SDATA (class));
3843 if (!NILP (component
))
3845 strcat (class_key
, ".");
3846 strcat (class_key
, SDATA (subclass
));
3848 strcat (name_key
, ".");
3849 strcat (name_key
, SDATA (component
));
3852 strcat (name_key
, ".");
3853 strcat (name_key
, SDATA (attribute
));
3855 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3857 if (value
!= (char *) 0)
3858 return build_string (value
);
3864 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3865 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3866 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3867 class, where INSTANCE is the name under which Emacs was invoked, or
3868 the name specified by the `-name' or `-rn' command-line arguments.
3870 The optional arguments COMPONENT and SUBCLASS add to the key and the
3871 class, respectively. You must specify both of them or neither.
3872 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3873 and the class is `Emacs.CLASS.SUBCLASS'. */)
3874 (attribute
, class, component
, subclass
)
3875 Lisp_Object attribute
, class, component
, subclass
;
3877 #ifdef HAVE_X_WINDOWS
3881 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3882 attribute
, class, component
, subclass
);
3885 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3888 display_x_get_resource (dpyinfo
, attribute
, class, component
, subclass
)
3889 Display_Info
*dpyinfo
;
3890 Lisp_Object attribute
, class, component
, subclass
;
3892 return xrdb_get_resource (dpyinfo
->xrdb
,
3893 attribute
, class, component
, subclass
);
3896 /* Used when C code wants a resource value. */
3899 x_get_resource_string (attribute
, class)
3900 char *attribute
, *class;
3904 struct frame
*sf
= SELECTED_FRAME ();
3906 /* Allocate space for the components, the dots which separate them,
3907 and the final '\0'. */
3908 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3909 + strlen (attribute
) + 2);
3910 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3911 + strlen (class) + 2);
3913 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3914 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3916 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3917 name_key
, class_key
);
3921 /* Return the value of parameter PARAM.
3923 First search ALIST, then Vdefault_frame_alist, then the X defaults
3924 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3926 Convert the resource to the type specified by desired_type.
3928 If no default is specified, return Qunbound. If you call
3929 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3930 and don't let it get stored in any Lisp-visible variables! */
3933 x_get_arg (dpyinfo
, alist
, param
, attribute
, class, type
)
3934 Display_Info
*dpyinfo
;
3935 Lisp_Object alist
, param
;
3938 enum resource_types type
;
3940 register Lisp_Object tem
;
3942 tem
= Fassq (param
, alist
);
3946 /* If we find this parm in ALIST, clear it out
3947 so that it won't be "left over" at the end. */
3949 XSETCAR (tem
, Qnil
);
3950 /* In case the parameter appears more than once in the alist,
3952 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3953 if (CONSP (XCAR (tail
))
3954 && EQ (XCAR (XCAR (tail
)), param
))
3955 XSETCAR (XCAR (tail
), Qnil
);
3958 tem
= Fassq (param
, Vdefault_frame_alist
);
3960 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3961 look in the X resources. */
3964 if (attribute
&& dpyinfo
)
3966 tem
= display_x_get_resource (dpyinfo
,
3967 build_string (attribute
),
3968 build_string (class),
3976 case RES_TYPE_NUMBER
:
3977 return make_number (atoi (SDATA (tem
)));
3979 case RES_TYPE_FLOAT
:
3980 return make_float (atof (SDATA (tem
)));
3982 case RES_TYPE_BOOLEAN
:
3983 tem
= Fdowncase (tem
);
3984 if (!strcmp (SDATA (tem
), "on")
3986 || !strcmp(SDATA(tem
), "yes")
3988 || !strcmp (SDATA (tem
), "true"))
3993 case RES_TYPE_STRING
:
3996 case RES_TYPE_SYMBOL
:
3997 /* As a special case, we map the values `true' and `on'
3998 to Qt, and `false' and `off' to Qnil. */
4001 lower
= Fdowncase (tem
);
4002 if (!strcmp (SDATA (lower
), "on")
4004 || !strcmp(SDATA(lower
), "yes")
4006 || !strcmp (SDATA (lower
), "true"))
4008 else if (!strcmp (SDATA (lower
), "off")
4010 || !strcmp(SDATA(lower
), "no")
4012 || !strcmp (SDATA (lower
), "false"))
4015 return Fintern (tem
, Qnil
);
4029 x_frame_get_arg (f
, alist
, param
, attribute
, class, type
)
4031 Lisp_Object alist
, param
;
4034 enum resource_types type
;
4036 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
4037 alist
, param
, attribute
, class, type
);
4040 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
4043 x_frame_get_and_record_arg (f
, alist
, param
, attribute
, class, type
)
4045 Lisp_Object alist
, param
;
4048 enum resource_types type
;
4052 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
4053 attribute
, class, type
);
4054 if (! NILP (value
) && ! EQ (value
, Qunbound
))
4055 store_frame_param (f
, param
, value
);
4061 /* Record in frame F the specified or default value according to ALIST
4062 of the parameter named PROP (a Lisp symbol).
4063 If no value is specified for PROP, look for an X default for XPROP
4064 on the frame named NAME.
4065 If that is not found either, use the value DEFLT. */
4068 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
4075 enum resource_types type
;
4079 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
4080 if (EQ (tem
, Qunbound
))
4082 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
4091 /* We used to define x-parse-geometry directly in ns-win.el, but that
4092 confused make-docfile: the documentation string in ns-win.el was
4093 used for x-parse-geometry even in non-NS builds.. */
4095 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4096 doc
: /* Parse a Nextstep-style geometry string STRING.
4097 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4098 The properties returned may include `top', `left', `height', and `width'.
4099 This works by calling `ns-parse-geometry'. */)
4103 call1 (Qns_parse_geometry
, string
);
4106 #else /* !HAVE_NS */
4108 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
4109 doc
: /* Parse an X-style geometry string STRING.
4110 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4111 The properties returned may include `top', `left', `height', and `width'.
4112 The value of `left' or `top' may be an integer,
4113 or a list (+ N) meaning N pixels relative to top/left corner,
4114 or a list (- N) meaning -N pixels relative to bottom/right corner. */)
4119 unsigned int width
, height
;
4122 CHECK_STRING (string
);
4124 geometry
= XParseGeometry ((char *) SDATA (string
),
4125 &x
, &y
, &width
, &height
);
4127 if (geometry
& XValue
)
4129 Lisp_Object element
;
4131 if (x
>= 0 && (geometry
& XNegative
))
4132 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
4133 else if (x
< 0 && ! (geometry
& XNegative
))
4134 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
4136 element
= Fcons (Qleft
, make_number (x
));
4137 result
= Fcons (element
, result
);
4140 if (geometry
& YValue
)
4142 Lisp_Object element
;
4144 if (y
>= 0 && (geometry
& YNegative
))
4145 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
4146 else if (y
< 0 && ! (geometry
& YNegative
))
4147 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
4149 element
= Fcons (Qtop
, make_number (y
));
4150 result
= Fcons (element
, result
);
4153 if (geometry
& WidthValue
)
4154 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
4155 if (geometry
& HeightValue
)
4156 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
4160 #endif /* HAVE_NS */
4163 /* Calculate the desired size and position of frame F.
4164 Return the flags saying which aspects were specified.
4166 Also set the win_gravity and size_hint_flags of F.
4168 Adjust height for toolbar if TOOLBAR_P is 1.
4170 This function does not make the coordinates positive. */
4172 #define DEFAULT_ROWS 40
4173 #define DEFAULT_COLS 80
4176 x_figure_window_size (f
, parms
, toolbar_p
)
4181 register Lisp_Object tem0
, tem1
, tem2
;
4182 long window_prompting
= 0;
4183 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
4185 /* Default values if we fall through.
4186 Actually, if that happens we should get
4187 window manager prompting. */
4188 SET_FRAME_COLS (f
, DEFAULT_COLS
);
4189 FRAME_LINES (f
) = DEFAULT_ROWS
;
4190 /* Window managers expect that if program-specified
4191 positions are not (0,0), they're intentional, not defaults. */
4195 /* Ensure that old new_text_cols and new_text_lines will not override the
4197 /* ++KFS: This was specific to W32, but seems ok for all platforms */
4198 f
->new_text_cols
= f
->new_text_lines
= 0;
4200 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
4201 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
4202 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
4203 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4205 if (!EQ (tem0
, Qunbound
))
4207 CHECK_NUMBER (tem0
);
4208 FRAME_LINES (f
) = XINT (tem0
);
4210 if (!EQ (tem1
, Qunbound
))
4212 CHECK_NUMBER (tem1
);
4213 SET_FRAME_COLS (f
, XINT (tem1
));
4215 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
4216 window_prompting
|= USSize
;
4218 window_prompting
|= PSize
;
4221 f
->scroll_bar_actual_width
4222 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
4224 /* This used to be done _before_ calling x_figure_window_size, but
4225 since the height is reset here, this was really a no-op. I
4226 assume that moving it here does what Gerd intended (although he
4227 no longer can remember what that was... ++KFS, 2003-03-25. */
4229 /* Add the tool-bar height to the initial frame height so that the
4230 user gets a text display area of the size he specified with -g or
4231 via .Xdefaults. Later changes of the tool-bar height don't
4232 change the frame size. This is done so that users can create
4233 tall Emacs frames without having to guess how tall the tool-bar
4235 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
4237 int margin
, relief
, bar_height
;
4239 relief
= (tool_bar_button_relief
>= 0
4240 ? tool_bar_button_relief
4241 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
4243 if (INTEGERP (Vtool_bar_button_margin
)
4244 && XINT (Vtool_bar_button_margin
) > 0)
4245 margin
= XFASTINT (Vtool_bar_button_margin
);
4246 else if (CONSP (Vtool_bar_button_margin
)
4247 && INTEGERP (XCDR (Vtool_bar_button_margin
))
4248 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
4249 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
4253 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
4254 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
4257 compute_fringe_widths (f
, 0);
4259 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
4260 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
4262 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
4263 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
4264 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
4265 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
4267 if (EQ (tem0
, Qminus
))
4270 window_prompting
|= YNegative
;
4272 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
4273 && CONSP (XCDR (tem0
))
4274 && INTEGERP (XCAR (XCDR (tem0
))))
4276 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
4277 window_prompting
|= YNegative
;
4279 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
4280 && CONSP (XCDR (tem0
))
4281 && INTEGERP (XCAR (XCDR (tem0
))))
4283 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
4285 else if (EQ (tem0
, Qunbound
))
4289 CHECK_NUMBER (tem0
);
4290 f
->top_pos
= XINT (tem0
);
4292 window_prompting
|= YNegative
;
4295 if (EQ (tem1
, Qminus
))
4298 window_prompting
|= XNegative
;
4300 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4301 && CONSP (XCDR (tem1
))
4302 && INTEGERP (XCAR (XCDR (tem1
))))
4304 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4305 window_prompting
|= XNegative
;
4307 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4308 && CONSP (XCDR (tem1
))
4309 && INTEGERP (XCAR (XCDR (tem1
))))
4311 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4313 else if (EQ (tem1
, Qunbound
))
4317 CHECK_NUMBER (tem1
);
4318 f
->left_pos
= XINT (tem1
);
4319 if (f
->left_pos
< 0)
4320 window_prompting
|= XNegative
;
4323 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4324 window_prompting
|= USPosition
;
4326 window_prompting
|= PPosition
;
4329 if (window_prompting
& XNegative
)
4331 if (window_prompting
& YNegative
)
4332 f
->win_gravity
= SouthEastGravity
;
4334 f
->win_gravity
= NorthEastGravity
;
4338 if (window_prompting
& YNegative
)
4339 f
->win_gravity
= SouthWestGravity
;
4341 f
->win_gravity
= NorthWestGravity
;
4344 f
->size_hint_flags
= window_prompting
;
4346 return window_prompting
;
4351 #endif /* HAVE_WINDOW_SYSTEM */
4355 /***********************************************************************
4357 ***********************************************************************/
4362 Qframep
= intern ("framep");
4363 staticpro (&Qframep
);
4364 Qframe_live_p
= intern ("frame-live-p");
4365 staticpro (&Qframe_live_p
);
4366 Qexplicit_name
= intern ("explicit-name");
4367 staticpro (&Qexplicit_name
);
4368 Qheight
= intern ("height");
4369 staticpro (&Qheight
);
4370 Qicon
= intern ("icon");
4372 Qminibuffer
= intern ("minibuffer");
4373 staticpro (&Qminibuffer
);
4374 Qmodeline
= intern ("modeline");
4375 staticpro (&Qmodeline
);
4376 Qonly
= intern ("only");
4378 Qwidth
= intern ("width");
4379 staticpro (&Qwidth
);
4380 Qgeometry
= intern ("geometry");
4381 staticpro (&Qgeometry
);
4382 Qicon_left
= intern ("icon-left");
4383 staticpro (&Qicon_left
);
4384 Qicon_top
= intern ("icon-top");
4385 staticpro (&Qicon_top
);
4386 Qleft
= intern ("left");
4388 Qright
= intern ("right");
4389 staticpro (&Qright
);
4390 Quser_position
= intern ("user-position");
4391 staticpro (&Quser_position
);
4392 Quser_size
= intern ("user-size");
4393 staticpro (&Quser_size
);
4394 Qwindow_id
= intern ("window-id");
4395 staticpro (&Qwindow_id
);
4396 #ifdef HAVE_X_WINDOWS
4397 Qouter_window_id
= intern ("outer-window-id");
4398 staticpro (&Qouter_window_id
);
4400 Qparent_id
= intern ("parent-id");
4401 staticpro (&Qparent_id
);
4404 Qw32
= intern ("w32");
4406 Qpc
= intern ("pc");
4408 Qmac
= intern ("mac");
4410 Qns
= intern ("ns");
4412 Qvisible
= intern ("visible");
4413 staticpro (&Qvisible
);
4414 Qbuffer_predicate
= intern ("buffer-predicate");
4415 staticpro (&Qbuffer_predicate
);
4416 Qbuffer_list
= intern ("buffer-list");
4417 staticpro (&Qbuffer_list
);
4418 Qburied_buffer_list
= intern ("buried-buffer-list");
4419 staticpro (&Qburied_buffer_list
);
4420 Qdisplay_type
= intern ("display-type");
4421 staticpro (&Qdisplay_type
);
4422 Qbackground_mode
= intern ("background-mode");
4423 staticpro (&Qbackground_mode
);
4424 Qnoelisp
= intern ("noelisp");
4425 staticpro (&Qnoelisp
);
4426 Qtty_color_mode
= intern ("tty-color-mode");
4427 staticpro (&Qtty_color_mode
);
4428 Qtty
= intern ("tty");
4430 Qtty_type
= intern ("tty-type");
4431 staticpro (&Qtty_type
);
4433 Qface_set_after_frame_default
= intern ("face-set-after-frame-default");
4434 staticpro (&Qface_set_after_frame_default
);
4436 Qfullwidth
= intern ("fullwidth");
4437 staticpro (&Qfullwidth
);
4438 Qfullheight
= intern ("fullheight");
4439 staticpro (&Qfullheight
);
4440 Qfullboth
= intern ("fullboth");
4441 staticpro (&Qfullboth
);
4442 Qmaximized
= intern ("maximized");
4443 staticpro (&Qmaximized
);
4444 Qx_resource_name
= intern ("x-resource-name");
4445 staticpro (&Qx_resource_name
);
4447 Qx_frame_parameter
= intern ("x-frame-parameter");
4448 staticpro (&Qx_frame_parameter
);
4450 Qterminal
= intern ("terminal");
4451 staticpro (&Qterminal
);
4452 Qterminal_live_p
= intern ("terminal-live-p");
4453 staticpro (&Qterminal_live_p
);
4456 Qns_parse_geometry
= intern ("ns-parse-geometry");
4457 staticpro (&Qns_parse_geometry
);
4463 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4465 Lisp_Object v
= intern (frame_parms
[i
].name
);
4466 if (frame_parms
[i
].variable
)
4468 *frame_parms
[i
].variable
= v
;
4469 staticpro (frame_parms
[i
].variable
);
4471 Fput (v
, Qx_frame_parameter
, make_number (i
));
4475 #ifdef HAVE_WINDOW_SYSTEM
4476 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4477 doc
: /* The name Emacs uses to look up X resources.
4478 `x-get-resource' uses this as the first component of the instance name
4479 when requesting resource values.
4480 Emacs initially sets `x-resource-name' to the name under which Emacs
4481 was invoked, or to the value specified with the `-name' or `-rn'
4482 switches, if present.
4484 It may be useful to bind this variable locally around a call
4485 to `x-get-resource'. See also the variable `x-resource-class'. */);
4486 Vx_resource_name
= Qnil
;
4488 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4489 doc
: /* The class Emacs uses to look up X resources.
4490 `x-get-resource' uses this as the first component of the instance class
4491 when requesting resource values.
4493 Emacs initially sets `x-resource-class' to "Emacs".
4495 Setting this variable permanently is not a reasonable thing to do,
4496 but binding this variable locally around a call to `x-get-resource'
4497 is a reasonable practice. See also the variable `x-resource-name'. */);
4498 Vx_resource_class
= build_string (EMACS_CLASS
);
4500 DEFVAR_LISP ("frame-alpha-lower-limit", &Vframe_alpha_lower_limit
,
4501 doc
: /* The lower limit of the frame opacity (alpha transparency).
4502 The value should range from 0 (invisible) to 100 (completely opaque).
4503 You can also use a floating number between 0.0 and 1.0.
4504 The default is 20. */);
4505 Vframe_alpha_lower_limit
= make_number (20);
4508 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4509 doc
: /* Alist of default values for frame creation.
4510 These may be set in your init file, like this:
4511 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4512 These override values given in window system configuration data,
4513 including X Windows' defaults database.
4514 For values specific to the first Emacs frame, see `initial-frame-alist'.
4515 For window-system specific values, see `window-system-default-frame-alist'.
4516 For values specific to the separate minibuffer frame, see
4517 `minibuffer-frame-alist'.
4518 The `menu-bar-lines' element of the list controls whether new frames
4519 have menu bars; `menu-bar-mode' works by altering this element.
4520 Setting this variable does not affect existing frames, only new ones. */);
4521 Vdefault_frame_alist
= Qnil
;
4523 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars
,
4524 doc
: /* Default position of scroll bars on this window-system. */);
4525 #ifdef HAVE_WINDOW_SYSTEM
4526 #if defined(HAVE_NTGUI) || defined(NS_IMPL_COCOA)
4527 /* MS-Windows and Mac OS X have scroll bars on the right by default. */
4528 Vdefault_frame_scroll_bars
= Qright
;
4530 Vdefault_frame_scroll_bars
= Qleft
;
4533 Vdefault_frame_scroll_bars
= Qnil
;
4536 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4537 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4539 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4540 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4541 `mouse-position' calls this function, passing its usual return value as
4542 argument, and returns whatever this function returns.
4543 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4544 which need to do mouse handling at the Lisp level. */);
4545 Vmouse_position_function
= Qnil
;
4547 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4548 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4549 If the value is an integer, highlighting is only shown after moving the
4550 mouse, while keyboard input turns off the highlight even when the mouse
4551 is over the clickable text. However, the mouse shape still indicates
4552 when the mouse is over clickable text. */);
4553 Vmouse_highlight
= Qt
;
4555 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4556 doc
: /* Functions to be run before deleting a frame.
4557 The functions are run with one arg, the frame to be deleted.
4560 Note that functions in this list may be called just before the frame is
4561 actually deleted, or some time later (or even both when an earlier function
4562 in `delete-frame-functions' (indirectly) calls `delete-frame'
4564 Vdelete_frame_functions
= Qnil
;
4565 Qdelete_frame_functions
= intern ("delete-frame-functions");
4566 staticpro (&Qdelete_frame_functions
);
4568 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4569 doc
: /* Minibufferless frames use this frame's minibuffer.
4571 Emacs cannot create minibufferless frames unless this is set to an
4572 appropriate surrogate.
4574 Emacs consults this variable only when creating minibufferless
4575 frames; once the frame is created, it sticks with its assigned
4576 minibuffer, no matter what this variable is set to. This means that
4577 this variable doesn't necessarily say anything meaningful about the
4578 current set of frames, or where the minibuffer is currently being
4581 This variable is local to the current terminal and cannot be buffer-local. */);
4583 DEFVAR_BOOL ("focus-follows-mouse", &focus_follows_mouse
,
4584 doc
: /* Non-nil if window system changes focus when you move the mouse.
4585 You should set this variable to tell Emacs how your window manager
4586 handles focus, since there is no way in general for Emacs to find out
4588 #ifdef HAVE_WINDOW_SYSTEM
4589 #if defined(HAVE_NTGUI) || defined(HAVE_NS)
4590 focus_follows_mouse
= 0;
4592 focus_follows_mouse
= 1;
4595 focus_follows_mouse
= 0;
4598 staticpro (&Vframe_list
);
4600 defsubr (&Sactive_minibuffer_window
);
4602 defsubr (&Sframe_live_p
);
4603 defsubr (&Swindow_system
);
4604 defsubr (&Smake_terminal_frame
);
4605 defsubr (&Shandle_switch_frame
);
4606 defsubr (&Sselect_frame
);
4607 defsubr (&Sselected_frame
);
4608 defsubr (&Swindow_frame
);
4609 defsubr (&Sframe_root_window
);
4610 defsubr (&Sframe_first_window
);
4611 defsubr (&Sframe_selected_window
);
4612 defsubr (&Sset_frame_selected_window
);
4613 defsubr (&Sframe_list
);
4614 defsubr (&Snext_frame
);
4615 defsubr (&Sprevious_frame
);
4616 defsubr (&Sdelete_frame
);
4617 defsubr (&Smouse_position
);
4618 defsubr (&Smouse_pixel_position
);
4619 defsubr (&Sset_mouse_position
);
4620 defsubr (&Sset_mouse_pixel_position
);
4622 defsubr (&Sframe_configuration
);
4623 defsubr (&Srestore_frame_configuration
);
4625 defsubr (&Smake_frame_visible
);
4626 defsubr (&Smake_frame_invisible
);
4627 defsubr (&Siconify_frame
);
4628 defsubr (&Sframe_visible_p
);
4629 defsubr (&Svisible_frame_list
);
4630 defsubr (&Sraise_frame
);
4631 defsubr (&Slower_frame
);
4632 defsubr (&Sredirect_frame_focus
);
4633 defsubr (&Sframe_focus
);
4634 defsubr (&Sframe_parameters
);
4635 defsubr (&Sframe_parameter
);
4636 defsubr (&Smodify_frame_parameters
);
4637 defsubr (&Sframe_char_height
);
4638 defsubr (&Sframe_char_width
);
4639 defsubr (&Sframe_pixel_height
);
4640 defsubr (&Sframe_pixel_width
);
4641 defsubr (&Sset_frame_height
);
4642 defsubr (&Sset_frame_width
);
4643 defsubr (&Sset_frame_size
);
4644 defsubr (&Sset_frame_position
);
4646 #ifdef HAVE_WINDOW_SYSTEM
4647 defsubr (&Sx_get_resource
);
4648 defsubr (&Sx_parse_geometry
);
4653 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4654 (do not change this comment) */