1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2003
3 Free Software Foundation.
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 2, or (at your option)
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; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
37 /* These help us bind and responding to switch-frame events. */
41 #ifdef HAVE_WINDOW_SYSTEM
44 #include "blockinput.h"
45 #include "systty.h" /* For emacs_tty in termchar.h */
47 #include "termhooks.h"
48 #include "dispextern.h"
56 #ifdef HAVE_WINDOW_SYSTEM
58 /* The name we're using in resource queries. Most often "emacs". */
60 Lisp_Object Vx_resource_name
;
62 /* The application class we're using in resource queries.
65 Lisp_Object Vx_resource_class
;
69 Lisp_Object Qframep
, Qframe_live_p
;
70 Lisp_Object Qicon
, Qmodeline
;
72 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
;
74 Lisp_Object Qdisplay_type
;
75 Lisp_Object Qbackground_mode
;
76 Lisp_Object Qinhibit_default_face_x_resources
;
78 Lisp_Object Qx_frame_parameter
;
79 Lisp_Object Qx_resource_name
;
81 /* Frame parameters (set or reported). */
83 Lisp_Object Qauto_raise
, Qauto_lower
;
84 Lisp_Object Qborder_color
, Qborder_width
;
85 Lisp_Object Qcursor_color
, Qcursor_type
;
86 Lisp_Object Qgeometry
; /* Not used */
87 Lisp_Object Qheight
, Qwidth
;
88 Lisp_Object Qleft
, Qright
;
89 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
90 Lisp_Object Qinternal_border_width
;
91 Lisp_Object Qmouse_color
;
92 Lisp_Object Qminibuffer
;
93 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
94 Lisp_Object Qvisibility
;
95 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
96 Lisp_Object Qscreen_gamma
;
97 Lisp_Object Qline_spacing
;
98 Lisp_Object Quser_position
, Quser_size
;
99 Lisp_Object Qwait_for_wm
;
100 Lisp_Object Qwindow_id
;
101 #ifdef HAVE_X_WINDOWS
102 Lisp_Object Qouter_window_id
;
104 Lisp_Object Qparent_id
;
105 Lisp_Object Qtitle
, Qname
;
106 Lisp_Object Qunsplittable
;
107 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
108 Lisp_Object Qleft_fringe
, Qright_fringe
;
109 Lisp_Object Qbuffer_predicate
, Qbuffer_list
;
110 Lisp_Object Qtty_color_mode
;
111 Lisp_Object Qtty
, Qtty_type
;
113 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
;
115 Lisp_Object Qface_set_after_frame_default
;
117 Lisp_Object Vterminal_frame
;
118 Lisp_Object Vdefault_frame_alist
;
119 Lisp_Object Vdefault_frame_scroll_bars
;
120 Lisp_Object Vmouse_position_function
;
121 Lisp_Object Vmouse_highlight
;
122 Lisp_Object Vdelete_frame_functions
;
125 set_menu_bar_lines_1 (window
, n
)
129 struct window
*w
= XWINDOW (window
);
131 XSETFASTINT (w
->last_modified
, 0);
132 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
133 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
135 if (INTEGERP (w
->orig_top_line
))
136 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
137 if (INTEGERP (w
->orig_total_lines
))
138 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
140 /* Handle just the top child in a vertical split. */
141 if (!NILP (w
->vchild
))
142 set_menu_bar_lines_1 (w
->vchild
, n
);
144 /* Adjust all children in a horizontal split. */
145 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
147 w
= XWINDOW (window
);
148 set_menu_bar_lines_1 (window
, n
);
153 set_menu_bar_lines (f
, value
, oldval
)
155 Lisp_Object value
, oldval
;
158 int olines
= FRAME_MENU_BAR_LINES (f
);
160 /* Right now, menu bars don't work properly in minibuf-only frames;
161 most of the commands try to apply themselves to the minibuffer
162 frame itself, and get an error because you can't switch buffers
163 in or split the minibuffer window. */
164 if (FRAME_MINIBUF_ONLY_P (f
))
167 if (INTEGERP (value
))
168 nlines
= XINT (value
);
172 if (nlines
!= olines
)
174 windows_or_buffers_changed
++;
175 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
176 FRAME_MENU_BAR_LINES (f
) = nlines
;
177 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
182 Lisp_Object Vemacs_iconified
;
183 Lisp_Object Vframe_list
;
185 extern Lisp_Object Vminibuffer_list
;
186 extern Lisp_Object
get_minibuffer ();
187 extern Lisp_Object
Fhandle_switch_frame ();
188 extern Lisp_Object
Fredirect_frame_focus ();
189 extern Lisp_Object
x_get_focus_frame ();
191 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
192 doc
: /* Return non-nil if OBJECT is a frame.
193 Value is t for a termcap frame (a character-only terminal),
194 `x' for an Emacs frame that is really an X window,
195 `w32' for an Emacs frame that is a window on MS-Windows display,
196 `mac' for an Emacs frame on a Macintosh display,
197 `pc' for a direct-write MS-DOS frame.
198 See also `frame-live-p'. */)
202 if (!FRAMEP (object
))
204 switch (XFRAME (object
)->output_method
)
208 case output_x_window
:
212 case output_msdos_raw
:
221 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
222 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
223 Value is nil if OBJECT is not a live frame. If object is a live
224 frame, the return value indicates what sort of output device it is
225 displayed on. See the documentation of `framep' for possible
230 return ((FRAMEP (object
)
231 && FRAME_LIVE_P (XFRAME (object
)))
241 register struct frame
*f
;
242 register Lisp_Object root_window
;
243 register Lisp_Object mini_window
;
245 f
= allocate_frame ();
246 XSETFRAME (frame
, f
);
248 f
->desired_matrix
= 0;
249 f
->current_matrix
= 0;
252 f
->glyphs_initialized_p
= 0;
253 f
->decode_mode_spec_buffer
= 0;
255 f
->async_visible
= 0;
256 f
->output_data
.nothing
= 0;
258 f
->async_iconified
= 0;
259 f
->wants_modeline
= 1;
264 f
->has_minibuffer
= mini_p
;
265 f
->focus_frame
= Qnil
;
266 f
->explicit_name
= 0;
267 f
->can_have_scroll_bars
= 0;
268 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
269 f
->param_alist
= Qnil
;
270 f
->scroll_bars
= Qnil
;
271 f
->condemned_scroll_bars
= Qnil
;
272 f
->face_alist
= Qnil
;
273 f
->face_cache
= NULL
;
274 f
->menu_bar_items
= Qnil
;
275 f
->menu_bar_vector
= Qnil
;
276 f
->menu_bar_items_used
= 0;
277 f
->buffer_predicate
= Qnil
;
278 f
->buffer_list
= Qnil
;
280 f
->kboard
= initial_kboard
;
284 f
->menu_bar_window
= Qnil
;
285 f
->tool_bar_window
= Qnil
;
286 f
->tool_bar_items
= Qnil
;
287 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
288 f
->n_tool_bar_items
= 0;
289 f
->left_fringe_width
= f
->right_fringe_width
= 0;
291 f
->scroll_bar_actual_width
= 0;
293 f
->internal_border_width
= 0;
294 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
295 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
296 f
->x_pixels_diff
= f
->y_pixels_diff
= 0;
297 #ifdef HAVE_WINDOW_SYSTEM
298 f
->want_fullscreen
= FULLSCREEN_NONE
;
300 f
->size_hint_flags
= 0;
303 root_window
= make_window ();
306 mini_window
= make_window ();
307 XWINDOW (root_window
)->next
= mini_window
;
308 XWINDOW (mini_window
)->prev
= root_window
;
309 XWINDOW (mini_window
)->mini_p
= Qt
;
310 XWINDOW (mini_window
)->frame
= frame
;
311 f
->minibuffer_window
= mini_window
;
316 XWINDOW (root_window
)->next
= Qnil
;
317 f
->minibuffer_window
= Qnil
;
320 XWINDOW (root_window
)->frame
= frame
;
323 just so that there is "something there."
324 Correct size will be set up later with change_frame_size. */
326 SET_FRAME_COLS (f
, 10);
327 FRAME_LINES (f
) = 10;
329 XSETFASTINT (XWINDOW (root_window
)->total_cols
, 10);
330 XSETFASTINT (XWINDOW (root_window
)->total_lines
, (mini_p
? 9 : 10));
334 XSETFASTINT (XWINDOW (mini_window
)->total_cols
, 10);
335 XSETFASTINT (XWINDOW (mini_window
)->top_line
, 9);
336 XSETFASTINT (XWINDOW (mini_window
)->total_lines
, 1);
339 /* Choose a buffer for the frame's root window. */
343 XWINDOW (root_window
)->buffer
= Qt
;
344 buf
= Fcurrent_buffer ();
345 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
346 a space), try to find another one. */
347 if (SREF (Fbuffer_name (buf
), 0) == ' ')
348 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
350 /* Use set_window_buffer, not Fset_window_buffer, and don't let
351 hooks be run by it. The reason is that the whole frame/window
352 arrangement is not yet fully intialized at this point. Windows
353 don't have the right size, glyph matrices aren't initialized
354 etc. Running Lisp functions at this point surely ends in a
356 set_window_buffer (root_window
, buf
, 0, 0);
357 f
->buffer_list
= Fcons (buf
, Qnil
);
362 XWINDOW (mini_window
)->buffer
= Qt
;
363 set_window_buffer (mini_window
,
364 (NILP (Vminibuffer_list
)
366 : Fcar (Vminibuffer_list
)),
370 f
->root_window
= root_window
;
371 f
->selected_window
= root_window
;
372 /* Make sure this window seems more recently used than
373 a newly-created, never-selected window. */
374 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, ++window_select_count
);
376 f
->default_face_done_p
= 0;
381 #ifdef HAVE_WINDOW_SYSTEM
382 /* Make a frame using a separate minibuffer window on another frame.
383 MINI_WINDOW is the minibuffer window to use. nil means use the
384 default (the global minibuffer). */
387 make_frame_without_minibuffer (mini_window
, kb
, display
)
388 register Lisp_Object mini_window
;
392 register struct frame
*f
;
395 if (!NILP (mini_window
))
396 CHECK_LIVE_WINDOW (mini_window
);
399 if (!NILP (mini_window
)
400 && XFRAME (XWINDOW (mini_window
)->frame
)->kboard
!= kb
)
401 error ("frame and minibuffer must be on the same display");
404 /* Make a frame containing just a root window. */
407 if (NILP (mini_window
))
409 /* Use default-minibuffer-frame if possible. */
410 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
411 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
413 Lisp_Object frame_dummy
;
415 XSETFRAME (frame_dummy
, f
);
416 GCPRO1 (frame_dummy
);
417 /* If there's no minibuffer frame to use, create one. */
418 kb
->Vdefault_minibuffer_frame
=
419 call1 (intern ("make-initial-minibuffer-frame"), display
);
423 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
426 f
->minibuffer_window
= mini_window
;
428 /* Make the chosen minibuffer window display the proper minibuffer,
429 unless it is already showing a minibuffer. */
430 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
431 Fset_window_buffer (mini_window
,
432 (NILP (Vminibuffer_list
)
434 : Fcar (Vminibuffer_list
)), Qnil
);
438 /* Make a frame containing only a minibuffer window. */
441 make_minibuffer_frame ()
443 /* First make a frame containing just a root window, no minibuffer. */
445 register struct frame
*f
= make_frame (0);
446 register Lisp_Object mini_window
;
447 register Lisp_Object frame
;
449 XSETFRAME (frame
, f
);
454 f
->wants_modeline
= 0;
455 f
->has_minibuffer
= 1;
457 /* Now label the root window as also being the minibuffer.
458 Avoid infinite looping on the window chain by marking next pointer
461 mini_window
= f
->minibuffer_window
= f
->root_window
;
462 XWINDOW (mini_window
)->mini_p
= Qt
;
463 XWINDOW (mini_window
)->next
= Qnil
;
464 XWINDOW (mini_window
)->prev
= Qnil
;
465 XWINDOW (mini_window
)->frame
= frame
;
467 /* Put the proper buffer in that window. */
469 Fset_window_buffer (mini_window
,
470 (NILP (Vminibuffer_list
)
472 : Fcar (Vminibuffer_list
)), Qnil
);
475 #endif /* HAVE_WINDOW_SYSTEM */
477 /* Construct a frame that refers to a terminal. */
479 static int terminal_frame_count
;
482 make_terminal_frame (tty_name
, tty_type
)
486 register struct frame
*f
;
491 /* Create the initial keyboard. */
494 initial_kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
495 init_kboard (initial_kboard
);
496 initial_kboard
->next_kboard
= all_kboards
;
497 all_kboards
= initial_kboard
;
501 /* The first call must initialize Vframe_list. */
502 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
507 XSETFRAME (frame
, f
);
508 Vframe_list
= Fcons (frame
, Vframe_list
);
510 terminal_frame_count
++;
511 sprintf (name
, "F%d", terminal_frame_count
);
512 f
->name
= build_string (name
);
514 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
515 f
->async_visible
= 1; /* Don't let visible be cleared later. */
517 f
->output_data
.x
= &the_only_x_display
;
518 if (!inhibit_window_system
519 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
520 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
522 f
->output_method
= output_msdos_raw
;
523 /* This initialization of foreground and background pixels is
524 only important for the initial frame created in temacs. If
525 we don't do that, we get black background and foreground in
526 the dumped Emacs because the_only_x_display is a static
527 variable, hence it is born all-zeroes, and zero is the code
528 for the black color. Other frames all inherit their pixels
529 from what's already in the_only_x_display. */
530 if ((!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
531 && f
->output_data
.x
->background_pixel
== 0
532 && f
->output_data
.x
->foreground_pixel
== 0)
534 f
->output_data
.x
->background_pixel
= FACE_TTY_DEFAULT_BG_COLOR
;
535 f
->output_data
.x
->foreground_pixel
= FACE_TTY_DEFAULT_FG_COLOR
;
539 f
->output_method
= output_termcap
;
542 f
->output_method
= output_termcap
;
543 f
->output_data
.x
= &tty_display
; /* XXX */
546 make_mac_terminal_frame (f
);
549 struct tty_display_info
*tty
;
550 f
->output_method
= output_termcap
;
552 f
->output_data
.tty
= (struct tty_output
*) xmalloc (sizeof (struct tty_output
));
553 bzero (f
->output_data
.tty
, sizeof (struct tty_output
));
555 FRAME_FOREGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_FG_COLOR
;
556 FRAME_BACKGROUND_PIXEL (f
) = FACE_TTY_DEFAULT_BG_COLOR
;
560 /* Note that term_init may signal an error, but then it is its
561 responsibility to make sure this frame is deleted. */
562 f
->output_data
.tty
->display_info
= term_init (frame
, tty_name
, tty_type
);
566 /* init_display() will reinitialize the terminal with correct values after dump. */
567 f
->output_data
.tty
->display_info
= term_dummy_init ();
569 FRAME_TTY (f
)->reference_count
++;
570 f
->display_method
= FRAME_TTY (f
)->display_method
;
572 f
->kboard
= FRAME_TTY (f
)->kboard
;
577 FRAME_FOREGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_FG_COLOR
;
578 FRAME_BACKGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_BG_COLOR
;
581 #endif /* WINDOWSNT */
585 init_frame_faces (f
);
590 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
592 doc
: /* Create an additional terminal frame, possibly on another terminal.
593 This function takes one argument, an alist specifying frame parameters.
595 You can create multiple frames on a single text-only terminal, but
596 only one of them (the selected terminal frame) is actually displayed.
598 In practice, generally you don't need to specify any parameters,
599 except when you want to create a new frame on another terminal.
600 In that case, the `tty' parameter specifies the device file to open,
601 and the `tty-type' parameter specifies the terminal type. Example:
603 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
605 Note that changing the size of one terminal frame automatically affects all. */)
610 Lisp_Object frame
, tem
;
611 struct frame
*sf
= SELECTED_FRAME ();
614 if (sf
->output_method
!= output_msdos_raw
615 && sf
->output_method
!= output_termcap
)
617 #else /* not MSDOS */
620 if (sf
->output_method
!= output_mac
)
621 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
623 #if 0 /* This should work now! */
624 if (sf
->output_method
!= output_termcap
)
625 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
628 #endif /* not MSDOS */
631 Lisp_Object tty
, tty_type
;
632 char *name
= 0, *type
= 0;
634 /* XXX Ugh, there must be a better way to do this. */
635 tty
= Fassq (Qtty
, parms
);
637 tty
= Fassq (Qtty
, XFRAME (selected_frame
)->param_alist
);
639 tty
= Fassq (Qtty
, Vdefault_frame_alist
);
640 if (! EQ (tty
, Qnil
))
642 if (EQ (tty
, Qnil
) || !STRINGP (tty
))
645 tty_type
= Fassq (Qtty_type
, parms
);
646 if (EQ (tty_type
, Qnil
))
647 tty_type
= Fassq (Qtty_type
, Vdefault_frame_alist
);
648 if (EQ (tty_type
, Qnil
))
649 tty_type
= Fassq (Qtty
, XFRAME (selected_frame
)->param_alist
);
650 if (! EQ (tty_type
, Qnil
))
651 tty_type
= XCDR (tty_type
);
652 if (EQ (tty_type
, Qnil
) || !STRINGP (tty_type
))
655 if (! EQ (tty
, Qnil
))
657 name
= (char *) alloca (SBYTES (tty
) + 1);
658 strncpy (name
, SDATA (tty
), SBYTES (tty
));
659 name
[SBYTES (tty
)] = 0;
662 if (! EQ (tty_type
, Qnil
))
664 type
= (char *) alloca (SBYTES (tty_type
) + 1);
665 strncpy (type
, SDATA (tty_type
), SBYTES (tty_type
));
666 type
[SBYTES (tty_type
)] = 0;
669 f
= make_terminal_frame (name
, type
);
674 get_tty_size (fileno (TTY_INPUT (FRAME_TTY (f
))), &width
, &height
);
675 change_frame_size (f
, height
, width
, 0, 0, 0);
680 XSETFRAME (frame
, f
);
681 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
682 Fmodify_frame_parameters (frame
, parms
);
684 /* Make the frame face alist be frame-specific, so that each
685 frame could change its face definitions independently. */
686 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
687 /* Simple Fcopy_alist isn't enough, because we need the contents of
688 the vectors which are the CDRs of associations in face_alist to
689 be copied as well. */
690 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
691 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
696 /* Perform the switch to frame FRAME.
698 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
701 If TRACK is non-zero and the frame that currently has the focus
702 redirects its focus to the selected frame, redirect that focused
703 frame's focus to FRAME instead.
705 FOR_DELETION non-zero means that the selected frame is being
706 deleted, which includes the possibility that the frame's display
710 do_switch_frame (frame
, track
, for_deletion
)
712 int track
, for_deletion
;
714 struct frame
*sf
= SELECTED_FRAME ();
716 /* If FRAME is a switch-frame event, extract the frame we should
719 && EQ (XCAR (frame
), Qswitch_frame
)
720 && CONSP (XCDR (frame
)))
721 frame
= XCAR (XCDR (frame
));
723 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
724 a switch-frame event to arrive after a frame is no longer live,
725 especially when deleting the initial frame during startup. */
727 if (! FRAME_LIVE_P (XFRAME (frame
)))
730 if (sf
== XFRAME (frame
))
733 /* This is too greedy; it causes inappropriate focus redirection
734 that's hard to get rid of. */
736 /* If a frame's focus has been redirected toward the currently
737 selected frame, we should change the redirection to point to the
738 newly selected frame. This means that if the focus is redirected
739 from a minibufferless frame to a surrogate minibuffer frame, we
740 can use `other-window' to switch between all the frames using
741 that minibuffer frame, and the focus redirection will follow us
747 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
751 if (!FRAMEP (XCAR (tail
)))
754 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
756 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
757 Fredirect_frame_focus (XCAR (tail
), frame
);
761 /* Instead, apply it only to the frame we're pointing to. */
762 #ifdef HAVE_WINDOW_SYSTEM
763 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
765 Lisp_Object focus
, xfocus
;
767 xfocus
= x_get_focus_frame (XFRAME (frame
));
770 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
771 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
772 Fredirect_frame_focus (xfocus
, frame
);
775 #endif /* HAVE_X_WINDOWS */
778 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
779 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
781 if (FRAME_TERMCAP_P (XFRAME (selected_frame
))
782 && FRAME_TERMCAP_P (XFRAME (frame
))
783 && FRAME_TTY (XFRAME (selected_frame
)) == FRAME_TTY (XFRAME (frame
)))
785 XFRAME (selected_frame
)->async_visible
= 2; /* obscured */
786 XFRAME (frame
)->async_visible
= 1;
787 FRAME_TTY (XFRAME (frame
))->top_frame
= frame
;
790 selected_frame
= frame
;
791 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
792 last_nonminibuf_frame
= XFRAME (selected_frame
);
794 Fselect_window (XFRAME (frame
)->selected_window
, Qnil
);
797 /* Make sure to switch the tty color mode to that of the newly
799 sf
= SELECTED_FRAME ();
800 if (FRAME_TERMCAP_P (sf
))
802 Lisp_Object color_mode_spec
, color_mode
;
804 color_mode_spec
= assq_no_quit (Qtty_color_mode
, sf
->param_alist
);
805 if (CONSP (color_mode_spec
))
806 color_mode
= XCDR (color_mode_spec
);
808 color_mode
= make_number (0);
809 set_tty_color_mode (sf
, color_mode
);
811 #endif /* !WINDOWSNT */
813 /* We want to make sure that the next event generates a frame-switch
814 event to the appropriate frame. This seems kludgy to me, but
815 before you take it out, make sure that evaluating something like
816 (select-window (frame-root-window (new-frame))) doesn't end up
817 with your typing being interpreted in the new frame instead of
818 the one you're actually typing in. */
819 internal_last_event_frame
= Qnil
;
824 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
825 doc
: /* Select the frame FRAME.
826 Subsequent editing commands apply to its selected window.
827 The selection of FRAME lasts until the next time the user does
828 something to select a different frame, or until the next time this
829 function is called. */)
831 Lisp_Object frame
, no_enter
;
833 return do_switch_frame (frame
, 1, 0);
837 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 2, "e",
838 doc
: /* Handle a switch-frame event EVENT.
839 Switch-frame events are usually bound to this function.
840 A switch-frame event tells Emacs that the window manager has requested
841 that the user's events be directed to the frame mentioned in the event.
842 This function selects the selected window of the frame of EVENT.
844 If EVENT is frame object, handle it as if it were a switch-frame event
847 Lisp_Object event
, no_enter
;
849 /* Preserve prefix arg that the command loop just cleared. */
850 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
851 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
852 return do_switch_frame (event
, 0, 0);
855 DEFUN ("ignore-event", Fignore_event
, Signore_event
, 0, 0, "",
856 doc
: /* Do nothing, but preserve any prefix argument already specified.
857 This is a suitable binding for `iconify-frame' and `make-frame-visible'. */)
860 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
864 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
865 doc
: /* Return the frame that is now selected. */)
868 return selected_frame
;
871 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
872 doc
: /* Return the frame object that window WINDOW is on. */)
876 CHECK_LIVE_WINDOW (window
);
877 return XWINDOW (window
)->frame
;
880 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
881 doc
: /* Returns the topmost, leftmost window of FRAME.
882 If omitted, FRAME defaults to the currently selected frame. */)
889 w
= SELECTED_FRAME ()->root_window
;
892 CHECK_LIVE_FRAME (frame
);
893 w
= XFRAME (frame
)->root_window
;
895 while (NILP (XWINDOW (w
)->buffer
))
897 if (! NILP (XWINDOW (w
)->hchild
))
898 w
= XWINDOW (w
)->hchild
;
899 else if (! NILP (XWINDOW (w
)->vchild
))
900 w
= XWINDOW (w
)->vchild
;
907 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
908 Sactive_minibuffer_window
, 0, 0, 0,
909 doc
: /* Return the currently active minibuffer window, or nil if none. */)
912 return minibuf_level
? minibuf_window
: Qnil
;
915 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
916 doc
: /* Returns the root-window of FRAME.
917 If omitted, FRAME defaults to the currently selected frame. */)
924 window
= SELECTED_FRAME ()->root_window
;
927 CHECK_LIVE_FRAME (frame
);
928 window
= XFRAME (frame
)->root_window
;
934 DEFUN ("frame-selected-window", Fframe_selected_window
,
935 Sframe_selected_window
, 0, 1, 0,
936 doc
: /* Return the selected window of frame object FRAME.
937 If omitted, FRAME defaults to the currently selected frame. */)
944 window
= SELECTED_FRAME ()->selected_window
;
947 CHECK_LIVE_FRAME (frame
);
948 window
= XFRAME (frame
)->selected_window
;
954 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
955 Sset_frame_selected_window
, 2, 2, 0,
956 doc
: /* Set the selected window of frame object FRAME to WINDOW.
957 If FRAME is nil, the selected frame is used.
958 If FRAME is the selected frame, this makes WINDOW the selected window. */)
960 Lisp_Object frame
, window
;
963 frame
= selected_frame
;
965 CHECK_LIVE_FRAME (frame
);
966 CHECK_LIVE_WINDOW (window
);
968 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
969 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
971 if (EQ (frame
, selected_frame
))
972 return Fselect_window (window
, Qnil
);
974 return XFRAME (frame
)->selected_window
= window
;
977 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
979 doc
: /* Return a list of all frames. */)
983 frames
= Fcopy_sequence (Vframe_list
);
984 #ifdef HAVE_WINDOW_SYSTEM
985 if (FRAMEP (tip_frame
))
986 frames
= Fdelq (tip_frame
, frames
);
991 /* Return the next frame in the frame list after FRAME.
992 If MINIBUF is nil, exclude minibuffer-only frames.
993 If MINIBUF is a window, include only its own frame
994 and any frame now using that window as the minibuffer.
995 If MINIBUF is `visible', include all visible frames.
996 If MINIBUF is 0, include all visible and iconified frames.
997 Otherwise, include all frames. */
1000 next_frame (frame
, minibuf
)
1002 Lisp_Object minibuf
;
1007 /* There must always be at least one frame in Vframe_list. */
1008 if (! CONSP (Vframe_list
))
1011 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
1012 forever. Forestall that. */
1013 CHECK_LIVE_FRAME (frame
);
1016 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1023 && ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1024 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1025 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1026 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
)))))
1028 /* Decide whether this frame is eligible to be returned. */
1030 /* If we've looped all the way around without finding any
1031 eligible frames, return the original frame. */
1035 /* Let minibuf decide if this frame is acceptable. */
1038 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1041 else if (EQ (minibuf
, Qvisible
))
1043 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1044 if (FRAME_VISIBLE_P (XFRAME (f
)))
1047 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
1049 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1050 if (FRAME_VISIBLE_P (XFRAME (f
))
1051 || FRAME_ICONIFIED_P (XFRAME (f
)))
1054 else if (WINDOWP (minibuf
))
1056 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1057 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1058 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1059 FRAME_FOCUS_FRAME (XFRAME (f
))))
1071 /* Return the previous frame in the frame list before FRAME.
1072 If MINIBUF is nil, exclude minibuffer-only frames.
1073 If MINIBUF is a window, include only its own frame
1074 and any frame now using that window as the minibuffer.
1075 If MINIBUF is `visible', include all visible frames.
1076 If MINIBUF is 0, include all visible and iconified frames.
1077 Otherwise, include all frames. */
1080 prev_frame (frame
, minibuf
)
1082 Lisp_Object minibuf
;
1087 /* There must always be at least one frame in Vframe_list. */
1088 if (! CONSP (Vframe_list
))
1092 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1100 if (EQ (frame
, f
) && !NILP (prev
))
1103 if ((!FRAME_TERMCAP_P (XFRAME (f
)) && !FRAME_TERMCAP_P (XFRAME (frame
))
1104 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1105 || (FRAME_TERMCAP_P (XFRAME (f
)) && FRAME_TERMCAP_P (XFRAME (frame
))
1106 && FRAME_TTY (XFRAME (f
)) == FRAME_TTY (XFRAME (frame
))))
1108 /* Decide whether this frame is eligible to be returned,
1109 according to minibuf. */
1112 if (! FRAME_MINIBUF_ONLY_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
))))
1123 else if (EQ (minibuf
, Qvisible
))
1125 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1126 if (FRAME_VISIBLE_P (XFRAME (f
)))
1129 else if (XFASTINT (minibuf
) == 0)
1131 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1132 if (FRAME_VISIBLE_P (XFRAME (f
))
1133 || FRAME_ICONIFIED_P (XFRAME (f
)))
1141 /* We've scanned the entire list. */
1143 /* We went through the whole frame list without finding a single
1144 acceptable frame. Return the original frame. */
1147 /* There were no acceptable frames in the list before FRAME; otherwise,
1148 we would have returned directly from the loop. Since PREV is the last
1149 acceptable frame in the list, return it. */
1154 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1155 doc
: /* Return the next frame in the frame list after FRAME.
1156 It considers only frames on the same terminal as FRAME.
1157 By default, skip minibuffer-only frames.
1158 If omitted, FRAME defaults to the selected frame.
1159 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1160 If MINIFRAME is a window, include only its own frame
1161 and any frame now using that window as the minibuffer.
1162 If MINIFRAME is `visible', include all visible frames.
1163 If MINIFRAME is 0, include all visible and iconified frames.
1164 Otherwise, include all frames. */)
1166 Lisp_Object frame
, miniframe
;
1169 frame
= selected_frame
;
1171 CHECK_LIVE_FRAME (frame
);
1172 return next_frame (frame
, miniframe
);
1175 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1176 doc
: /* Return the previous frame in the frame list before FRAME.
1177 It considers only frames on the same terminal as FRAME.
1178 By default, skip minibuffer-only frames.
1179 If omitted, FRAME defaults to the selected frame.
1180 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1181 If MINIFRAME is a window, include only its own frame
1182 and any frame now using that window as the minibuffer.
1183 If MINIFRAME is `visible', include all visible frames.
1184 If MINIFRAME is 0, include all visible and iconified frames.
1185 Otherwise, include all frames. */)
1187 Lisp_Object frame
, miniframe
;
1190 frame
= selected_frame
;
1191 CHECK_LIVE_FRAME (frame
);
1192 return prev_frame (frame
, miniframe
);
1195 /* Return 1 if it is ok to delete frame F;
1196 0 if all frames aside from F are invisible.
1197 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1200 other_visible_frames (f
)
1203 /* We know the selected frame is visible,
1204 so if F is some other frame, it can't be the sole visible one. */
1205 if (f
== SELECTED_FRAME ())
1210 for (frames
= Vframe_list
;
1212 frames
= XCDR (frames
))
1216 this = XCAR (frames
);
1217 /* Verify that the frame's window still exists
1218 and we can still talk to it. And note any recent change
1220 #ifdef HAVE_WINDOW_SYSTEM
1221 if (FRAME_WINDOW_P (XFRAME (this)))
1223 x_sync (XFRAME (this));
1224 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1228 if (FRAME_VISIBLE_P (XFRAME (this))
1229 || FRAME_ICONIFIED_P (XFRAME (this))
1230 /* Allow deleting the terminal frame when at least
1231 one X frame exists! */
1232 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1240 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1241 doc
: /* Delete FRAME, permanently eliminating it from use.
1242 If omitted, FRAME defaults to the selected frame.
1243 A frame may not be deleted if its minibuffer is used by other frames.
1244 Normally, you may not delete a frame if all other frames are invisible,
1245 but if the second optional argument FORCE is non-nil, you may do so.
1247 This function runs `delete-frame-functions' before actually deleting the
1248 frame, unless the frame is a tooltip.
1249 The functions are run with one arg, the frame to be deleted. */)
1251 Lisp_Object frame
, force
;
1254 struct frame
*sf
= SELECTED_FRAME ();
1255 int minibuffer_selected
;
1257 if (EQ (frame
, Qnil
))
1260 XSETFRAME (frame
, f
);
1264 CHECK_FRAME (frame
);
1268 if (! FRAME_LIVE_P (f
))
1271 if (NILP (force
) && !other_visible_frames (f
)
1273 /* Terminal frame deleted before any other visible frames are
1275 && strcmp (SDATA (f
->name
), "F1") != 0
1278 error ("Attempt to delete the sole visible or iconified frame");
1281 /* This is a nice idea, but x_connection_closed needs to be able
1282 to delete the last frame, if it is gone. */
1283 if (NILP (XCDR (Vframe_list
)))
1284 error ("Attempt to delete the only frame");
1287 /* Does this frame have a minibuffer, and is it the surrogate
1288 minibuffer for any other frame? */
1289 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1293 for (frames
= Vframe_list
;
1295 frames
= XCDR (frames
))
1298 this = XCAR (frames
);
1300 if (! EQ (this, frame
)
1302 WINDOW_FRAME (XWINDOW
1303 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1304 error ("Attempt to delete a surrogate minibuffer frame");
1308 /* Run `delete-frame-functions' unless frame is a tooltip. */
1309 if (!NILP (Vrun_hooks
)
1310 && NILP (Fframe_parameter (frame
, intern ("tooltip"))))
1312 Lisp_Object args
[2];
1313 args
[0] = intern ("delete-frame-functions");
1315 Frun_hook_with_args (2, args
);
1318 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1320 /* Don't let the frame remain selected. */
1323 Lisp_Object tail
, frame1
;
1325 /* Look for another visible frame on the same terminal. */
1326 frame1
= next_frame (frame
, Qvisible
);
1328 /* If there is none, find *some* other frame. */
1329 if (NILP (frame1
) || EQ (frame1
, frame
))
1331 FOR_EACH_FRAME (tail
, frame1
)
1333 if (! EQ (frame
, frame1
) && FRAME_LIVE_P (XFRAME (frame1
)))
1338 do_switch_frame (frame1
, 0, 1);
1339 sf
= SELECTED_FRAME ();
1342 /* Don't allow minibuf_window to remain on a deleted frame. */
1343 if (EQ (f
->minibuffer_window
, minibuf_window
))
1345 Fset_window_buffer (sf
->minibuffer_window
,
1346 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1347 minibuf_window
= sf
->minibuffer_window
;
1349 /* If the dying minibuffer window was selected,
1350 select the new one. */
1351 if (minibuffer_selected
)
1352 Fselect_window (minibuf_window
, Qnil
);
1355 /* Don't let echo_area_window to remain on a deleted frame. */
1356 if (EQ (f
->minibuffer_window
, echo_area_window
))
1357 echo_area_window
= sf
->minibuffer_window
;
1359 /* Clear any X selections for this frame. */
1360 #ifdef HAVE_X_WINDOWS
1362 x_clear_frame_selections (f
);
1366 This function must be called before the window tree of the
1367 frame is deleted because windows contain dynamically allocated
1371 /* Mark all the windows that used to be on FRAME as deleted, and then
1372 remove the reference to them. */
1373 delete_all_subwindows (XWINDOW (f
->root_window
));
1374 f
->root_window
= Qnil
;
1376 Vframe_list
= Fdelq (frame
, Vframe_list
);
1377 FRAME_SET_VISIBLE (f
, 0);
1381 if (f
->decode_mode_spec_buffer
)
1382 xfree (f
->decode_mode_spec_buffer
);
1383 if (FRAME_INSERT_COST (f
))
1384 xfree (FRAME_INSERT_COST (f
));
1385 if (FRAME_DELETEN_COST (f
))
1386 xfree (FRAME_DELETEN_COST (f
));
1387 if (FRAME_INSERTN_COST (f
))
1388 xfree (FRAME_INSERTN_COST (f
));
1389 if (FRAME_DELETE_COST (f
))
1390 xfree (FRAME_DELETE_COST (f
));
1391 if (FRAME_MESSAGE_BUF (f
))
1392 xfree (FRAME_MESSAGE_BUF (f
));
1394 /* Since some events are handled at the interrupt level, we may get
1395 an event for f at any time; if we zero out the frame's display
1396 now, then we may trip up the event-handling code. Instead, we'll
1397 promise that the display of the frame must be valid until we have
1398 called the window-system-dependent frame destruction routine. */
1400 /* I think this should be done with a hook. */
1401 #ifdef HAVE_WINDOW_SYSTEM
1402 if (FRAME_WINDOW_P (f
))
1403 x_destroy_window (f
);
1406 if (FRAME_TERMCAP_P (f
))
1409 struct tty_display_info
*tty
= FRAME_TTY (f
);
1411 if (! --tty
->reference_count
)
1413 /* delete_tty would call us recursively if we don't kill the
1415 xfree (f
->output_data
.tty
);
1416 f
->output_data
.nothing
= 0;
1422 f
->output_data
.nothing
= 0;
1425 /* If we've deleted the last_nonminibuf_frame, then try to find
1427 if (f
== last_nonminibuf_frame
)
1431 last_nonminibuf_frame
= 0;
1433 for (frames
= Vframe_list
;
1435 frames
= XCDR (frames
))
1437 f
= XFRAME (XCAR (frames
));
1438 if (!FRAME_MINIBUF_ONLY_P (f
))
1440 last_nonminibuf_frame
= f
;
1446 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1447 find another one. Prefer minibuffer-only frames, but also notice
1448 frames with other windows. */
1449 if (EQ (frame
, FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
))
1453 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1454 Lisp_Object frame_with_minibuf
;
1455 /* Some frame we found on the same kboard, or nil if there are none. */
1456 Lisp_Object frame_on_same_kboard
;
1458 frame_on_same_kboard
= Qnil
;
1459 frame_with_minibuf
= Qnil
;
1461 for (frames
= Vframe_list
;
1463 frames
= XCDR (frames
))
1468 this = XCAR (frames
);
1473 /* Consider only frames on the same kboard
1474 and only those with minibuffers. */
1475 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
)
1476 && FRAME_HAS_MINIBUF_P (f1
))
1478 frame_with_minibuf
= this;
1479 if (FRAME_MINIBUF_ONLY_P (f1
))
1483 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1484 frame_on_same_kboard
= this;
1487 if (!NILP (frame_on_same_kboard
))
1489 /* We know that there must be some frame with a minibuffer out
1490 there. If this were not true, all of the frames present
1491 would have to be minibufferless, which implies that at some
1492 point their minibuffer frames must have been deleted, but
1493 that is prohibited at the top; you can't delete surrogate
1494 minibuffer frames. */
1495 if (NILP (frame_with_minibuf
))
1498 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1501 /* No frames left on this kboard--say no minibuffer either. */
1502 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= Qnil
;
1505 /* Cause frame titles to update--necessary if we now have just one frame. */
1506 update_mode_lines
= 1;
1511 /* Return mouse position in character cell units. */
1513 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1514 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1515 The position is given in character cells, where (0, 0) is the
1517 If Emacs is running on a mouseless terminal or hasn't been programmed
1518 to read the mouse position, it returns the selected frame for FRAME
1519 and nil for X and Y.
1520 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1521 passing the normal return value to that function as an argument,
1522 and returns whatever that function returns. */)
1526 Lisp_Object lispy_dummy
;
1527 enum scroll_bar_part party_dummy
;
1528 Lisp_Object x
, y
, retval
;
1530 unsigned long long_dummy
;
1531 struct gcpro gcpro1
;
1533 f
= SELECTED_FRAME ();
1537 /* It's okay for the hook to refrain from storing anything. */
1538 if (mouse_position_hook
)
1539 (*mouse_position_hook
) (&f
, -1,
1540 &lispy_dummy
, &party_dummy
,
1547 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1552 XSETFRAME (lispy_dummy
, f
);
1553 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1555 if (!NILP (Vmouse_position_function
))
1556 retval
= call1 (Vmouse_position_function
, retval
);
1557 RETURN_UNGCPRO (retval
);
1560 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1561 Smouse_pixel_position
, 0, 0, 0,
1562 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1563 The position is given in pixel units, where (0, 0) is the
1565 If Emacs is running on a mouseless terminal or hasn't been programmed
1566 to read the mouse position, it returns the selected frame for FRAME
1567 and nil for X and Y. */)
1571 Lisp_Object lispy_dummy
;
1572 enum scroll_bar_part party_dummy
;
1574 unsigned long long_dummy
;
1576 f
= SELECTED_FRAME ();
1580 /* It's okay for the hook to refrain from storing anything. */
1581 if (mouse_position_hook
)
1582 (*mouse_position_hook
) (&f
, -1,
1583 &lispy_dummy
, &party_dummy
,
1587 XSETFRAME (lispy_dummy
, f
);
1588 return Fcons (lispy_dummy
, Fcons (x
, y
));
1591 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1592 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1593 Coordinates are relative to the frame, not a window,
1594 so the coordinates of the top left character in the frame
1595 may be nonzero due to left-hand scroll bars or the menu bar.
1597 This function is a no-op for an X frame that is not visible.
1598 If you have just created a frame, you must wait for it to become visible
1599 before calling this function on it, like this.
1600 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1602 Lisp_Object frame
, x
, y
;
1604 CHECK_LIVE_FRAME (frame
);
1608 /* I think this should be done with a hook. */
1609 #ifdef HAVE_WINDOW_SYSTEM
1610 if (FRAME_WINDOW_P (XFRAME (frame
)))
1611 /* Warping the mouse will cause enternotify and focus events. */
1612 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1614 #if defined (MSDOS) && defined (HAVE_MOUSE)
1615 if (FRAME_MSDOS_P (XFRAME (frame
)))
1617 Fselect_frame (frame
, Qnil
);
1618 mouse_moveto (XINT (x
), XINT (y
));
1626 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1627 Sset_mouse_pixel_position
, 3, 3, 0,
1628 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1629 Note, this is a no-op for an X frame that is not visible.
1630 If you have just created a frame, you must wait for it to become visible
1631 before calling this function on it, like this.
1632 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1634 Lisp_Object frame
, x
, y
;
1636 CHECK_LIVE_FRAME (frame
);
1640 /* I think this should be done with a hook. */
1641 #ifdef HAVE_WINDOW_SYSTEM
1642 if (FRAME_WINDOW_P (XFRAME (frame
)))
1643 /* Warping the mouse will cause enternotify and focus events. */
1644 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1646 #if defined (MSDOS) && defined (HAVE_MOUSE)
1647 if (FRAME_MSDOS_P (XFRAME (frame
)))
1649 Fselect_frame (frame
, Qnil
);
1650 mouse_moveto (XINT (x
), XINT (y
));
1658 static void make_frame_visible_1
P_ ((Lisp_Object
));
1660 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1662 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1663 If omitted, FRAME defaults to the currently selected frame. */)
1668 frame
= selected_frame
;
1670 CHECK_LIVE_FRAME (frame
);
1672 /* I think this should be done with a hook. */
1673 #ifdef HAVE_WINDOW_SYSTEM
1674 if (FRAME_WINDOW_P (XFRAME (frame
)))
1676 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1677 x_make_frame_visible (XFRAME (frame
));
1681 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1683 /* Make menu bar update for the Buffers and Frames menus. */
1684 windows_or_buffers_changed
++;
1689 /* Update the display_time slot of the buffers shown in WINDOW
1690 and all its descendents. */
1693 make_frame_visible_1 (window
)
1698 for (;!NILP (window
); window
= w
->next
)
1700 w
= XWINDOW (window
);
1702 if (!NILP (w
->buffer
))
1703 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1705 if (!NILP (w
->vchild
))
1706 make_frame_visible_1 (w
->vchild
);
1707 if (!NILP (w
->hchild
))
1708 make_frame_visible_1 (w
->hchild
);
1712 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1714 doc
: /* Make the frame FRAME invisible (assuming it is an X window).
1715 If omitted, FRAME defaults to the currently selected frame.
1716 Normally you may not make FRAME invisible if all other frames are invisible,
1717 but if the second optional argument FORCE is non-nil, you may do so. */)
1719 Lisp_Object frame
, force
;
1722 frame
= selected_frame
;
1724 CHECK_LIVE_FRAME (frame
);
1726 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1727 error ("Attempt to make invisible the sole visible or iconified frame");
1729 #if 0 /* This isn't logically necessary, and it can do GC. */
1730 /* Don't let the frame remain selected. */
1731 if (EQ (frame
, selected_frame
))
1732 do_switch_frame (next_frame (frame
, Qt
), 0, 0)
1735 /* Don't allow minibuf_window to remain on a deleted frame. */
1736 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1738 struct frame
*sf
= XFRAME (selected_frame
);
1739 Fset_window_buffer (sf
->minibuffer_window
,
1740 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1741 minibuf_window
= sf
->minibuffer_window
;
1744 /* I think this should be done with a hook. */
1745 #ifdef HAVE_WINDOW_SYSTEM
1746 if (FRAME_WINDOW_P (XFRAME (frame
)))
1747 x_make_frame_invisible (XFRAME (frame
));
1750 /* Make menu bar update for the Buffers and Frames menus. */
1751 windows_or_buffers_changed
++;
1756 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1758 doc
: /* Make the frame FRAME into an icon.
1759 If omitted, FRAME defaults to the currently selected frame. */)
1764 frame
= selected_frame
;
1766 CHECK_LIVE_FRAME (frame
);
1768 #if 0 /* This isn't logically necessary, and it can do GC. */
1769 /* Don't let the frame remain selected. */
1770 if (EQ (frame
, selected_frame
))
1771 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1774 /* Don't allow minibuf_window to remain on a deleted frame. */
1775 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1777 struct frame
*sf
= XFRAME (selected_frame
);
1778 Fset_window_buffer (sf
->minibuffer_window
,
1779 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1780 minibuf_window
= sf
->minibuffer_window
;
1783 /* I think this should be done with a hook. */
1784 #ifdef HAVE_WINDOW_SYSTEM
1785 if (FRAME_WINDOW_P (XFRAME (frame
)))
1786 x_iconify_frame (XFRAME (frame
));
1789 /* Make menu bar update for the Buffers and Frames menus. */
1790 windows_or_buffers_changed
++;
1795 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1797 doc
: /* Return t if FRAME is now \"visible\" (actually in use for display).
1798 A frame that is not \"visible\" is not updated and, if it works through
1799 a window system, it may not show at all.
1800 Return the symbol `icon' if frame is visible only as an icon. */)
1804 CHECK_LIVE_FRAME (frame
);
1806 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1808 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1810 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1815 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1817 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1820 Lisp_Object tail
, frame
;
1825 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1827 frame
= XCAR (tail
);
1828 if (!FRAMEP (frame
))
1831 if (FRAME_VISIBLE_P (f
))
1832 value
= Fcons (frame
, value
);
1838 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1839 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1840 If FRAME is invisible, make it visible.
1841 If you don't specify a frame, the selected frame is used.
1842 If Emacs is displaying on an ordinary terminal or some other device which
1843 doesn't support multiple overlapping frames, this function does nothing. */)
1848 frame
= selected_frame
;
1850 CHECK_LIVE_FRAME (frame
);
1852 /* Do like the documentation says. */
1853 Fmake_frame_visible (frame
);
1855 if (frame_raise_lower_hook
)
1856 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1861 /* Should we have a corresponding function called Flower_Power? */
1862 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1863 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1864 If you don't specify a frame, the selected frame is used.
1865 If Emacs is displaying on an ordinary terminal or some other device which
1866 doesn't support multiple overlapping frames, this function does nothing. */)
1871 frame
= selected_frame
;
1873 CHECK_LIVE_FRAME (frame
);
1875 if (frame_raise_lower_hook
)
1876 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1882 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1884 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1885 In other words, switch-frame events caused by events in FRAME will
1886 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1887 FOCUS-FRAME after reading an event typed at FRAME.
1889 If FOCUS-FRAME is omitted or nil, any existing redirection is
1890 cancelled, and the frame again receives its own keystrokes.
1892 Focus redirection is useful for temporarily redirecting keystrokes to
1893 a surrogate minibuffer frame when a frame doesn't have its own
1896 A frame's focus redirection can be changed by select-frame. If frame
1897 FOO is selected, and then a different frame BAR is selected, any
1898 frames redirecting their focus to FOO are shifted to redirect their
1899 focus to BAR. This allows focus redirection to work properly when the
1900 user switches from one frame to another using `select-window'.
1902 This means that a frame whose focus is redirected to itself is treated
1903 differently from a frame whose focus is redirected to nil; the former
1904 is affected by select-frame, while the latter is not.
1906 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1907 (frame
, focus_frame
)
1908 Lisp_Object frame
, focus_frame
;
1910 /* Note that we don't check for a live frame here. It's reasonable
1911 to redirect the focus of a frame you're about to delete, if you
1912 know what other frame should receive those keystrokes. */
1913 CHECK_FRAME (frame
);
1915 if (! NILP (focus_frame
))
1916 CHECK_LIVE_FRAME (focus_frame
);
1918 XFRAME (frame
)->focus_frame
= focus_frame
;
1920 if (!FRAME_TERMCAP_P (XFRAME (frame
)) && frame_rehighlight_hook
)
1921 (*frame_rehighlight_hook
) (XFRAME (frame
));
1927 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1928 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1929 This returns nil if FRAME's focus is not redirected.
1930 See `redirect-frame-focus'. */)
1934 CHECK_LIVE_FRAME (frame
);
1936 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1941 /* Return the value of frame parameter PROP in frame FRAME. */
1944 get_frame_param (frame
, prop
)
1945 register struct frame
*frame
;
1948 register Lisp_Object tem
;
1950 tem
= Fassq (prop
, frame
->param_alist
);
1956 /* Return the buffer-predicate of the selected frame. */
1959 frame_buffer_predicate (frame
)
1962 return XFRAME (frame
)->buffer_predicate
;
1965 /* Return the buffer-list of the selected frame. */
1968 frame_buffer_list (frame
)
1971 return XFRAME (frame
)->buffer_list
;
1974 /* Set the buffer-list of the selected frame. */
1977 set_frame_buffer_list (frame
, list
)
1978 Lisp_Object frame
, list
;
1980 XFRAME (frame
)->buffer_list
= list
;
1983 /* Discard BUFFER from the buffer-list of each frame. */
1986 frames_discard_buffer (buffer
)
1989 Lisp_Object frame
, tail
;
1991 FOR_EACH_FRAME (tail
, frame
)
1993 XFRAME (frame
)->buffer_list
1994 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1998 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1999 If the alist already has an element for PROP, we change it. */
2002 store_in_alist (alistptr
, prop
, val
)
2003 Lisp_Object
*alistptr
, val
;
2006 register Lisp_Object tem
;
2008 tem
= Fassq (prop
, *alistptr
);
2010 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
2016 frame_name_fnn_p (str
, len
)
2020 if (len
> 1 && str
[0] == 'F')
2024 strtol (str
+ 1, &end_ptr
, 10);
2026 if (end_ptr
== str
+ len
)
2032 /* Set the name of the terminal frame. Also used by MSDOS frames.
2033 Modeled after x_set_name which is used for WINDOW frames. */
2036 set_term_frame_name (f
, name
)
2040 f
->explicit_name
= ! NILP (name
);
2042 /* If NAME is nil, set the name to F<num>. */
2047 /* Check for no change needed in this very common case
2048 before we do any consing. */
2049 if (frame_name_fnn_p (SDATA (f
->name
),
2053 terminal_frame_count
++;
2054 sprintf (namebuf
, "F%d", terminal_frame_count
);
2055 name
= build_string (namebuf
);
2059 CHECK_STRING (name
);
2061 /* Don't change the name if it's already NAME. */
2062 if (! NILP (Fstring_equal (name
, f
->name
)))
2065 /* Don't allow the user to set the frame name to F<num>, so it
2066 doesn't clash with the names we generate for terminal frames. */
2067 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
2068 error ("Frame names of the form F<num> are usurped by Emacs");
2072 update_mode_lines
= 1;
2076 store_frame_param (f
, prop
, val
)
2078 Lisp_Object prop
, val
;
2080 register Lisp_Object old_alist_elt
;
2082 /* The buffer-alist parameter is stored in a special place and is
2083 not in the alist. */
2084 if (EQ (prop
, Qbuffer_list
))
2086 f
->buffer_list
= val
;
2090 /* If PROP is a symbol which is supposed to have frame-local values,
2091 and it is set up based on this frame, switch to the global
2092 binding. That way, we can create or alter the frame-local binding
2093 without messing up the symbol's status. */
2096 Lisp_Object valcontents
;
2097 valcontents
= SYMBOL_VALUE (prop
);
2098 if ((BUFFER_LOCAL_VALUEP (valcontents
)
2099 || SOME_BUFFER_LOCAL_VALUEP (valcontents
))
2100 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
2101 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
2102 swap_in_global_binding (prop
);
2106 /* The tty color mode needs to be set before the frame's parameter
2107 alist is updated with the new value, because set_tty_color_mode
2108 wants to look at the old mode. */
2109 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
))
2110 set_tty_color_mode (f
, val
);
2113 /* Update the frame parameter alist. */
2114 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2115 if (EQ (old_alist_elt
, Qnil
))
2116 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2118 Fsetcdr (old_alist_elt
, val
);
2120 /* Update some other special parameters in their special places
2121 in addition to the alist. */
2123 if (EQ (prop
, Qbuffer_predicate
))
2124 f
->buffer_predicate
= val
;
2126 if (! FRAME_WINDOW_P (f
))
2128 if (EQ (prop
, Qmenu_bar_lines
))
2129 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2130 else if (EQ (prop
, Qname
))
2131 set_term_frame_name (f
, val
);
2134 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2136 if (! MINI_WINDOW_P (XWINDOW (val
)))
2137 error ("Surrogate minibuffer windows must be minibuffer windows");
2139 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2140 && !EQ (val
, f
->minibuffer_window
))
2141 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2143 /* Install the chosen minibuffer window, with proper buffer. */
2144 f
->minibuffer_window
= val
;
2148 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2149 doc
: /* Return the parameters-alist of frame FRAME.
2150 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2151 The meaningful PARMs depend on the kind of frame.
2152 If FRAME is omitted, return information on the currently selected frame. */)
2159 struct gcpro gcpro1
;
2162 frame
= selected_frame
;
2164 CHECK_FRAME (frame
);
2167 if (!FRAME_LIVE_P (f
))
2170 alist
= Fcopy_alist (f
->param_alist
);
2173 if (!FRAME_WINDOW_P (f
))
2175 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2176 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2179 /* If the frame's parameter alist says the colors are
2180 unspecified and reversed, take the frame's background pixel
2181 for foreground and vice versa. */
2182 elt
= Fassq (Qforeground_color
, alist
);
2183 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2185 if (strncmp (SDATA (XCDR (elt
)),
2187 SCHARS (XCDR (elt
))) == 0)
2188 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2189 else if (strncmp (SDATA (XCDR (elt
)),
2191 SCHARS (XCDR (elt
))) == 0)
2192 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2195 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2196 elt
= Fassq (Qbackground_color
, alist
);
2197 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2199 if (strncmp (SDATA (XCDR (elt
)),
2201 SCHARS (XCDR (elt
))) == 0)
2202 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2203 else if (strncmp (SDATA (XCDR (elt
)),
2205 SCHARS (XCDR (elt
))) == 0)
2206 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2209 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2210 store_in_alist (&alist
, intern ("font"),
2211 build_string (FRAME_MSDOS_P (f
)
2213 : FRAME_W32_P (f
) ? "w32term"
2216 store_in_alist (&alist
, Qname
, f
->name
);
2217 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2218 store_in_alist (&alist
, Qheight
, make_number (height
));
2219 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2220 store_in_alist (&alist
, Qwidth
, make_number (width
));
2221 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2222 store_in_alist (&alist
, Qminibuffer
,
2223 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2224 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2225 : FRAME_MINIBUF_WINDOW (f
)));
2226 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2227 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2229 /* I think this should be done with a hook. */
2230 #ifdef HAVE_WINDOW_SYSTEM
2231 if (FRAME_WINDOW_P (f
))
2232 x_report_frame_params (f
, &alist
);
2236 /* This ought to be correct in f->param_alist for an X frame. */
2238 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2239 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2247 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2248 doc
: /* Return FRAME's value for parameter PARAMETER.
2249 If FRAME is nil, describe the currently selected frame. */)
2251 Lisp_Object frame
, parameter
;
2257 frame
= selected_frame
;
2259 CHECK_FRAME (frame
);
2260 CHECK_SYMBOL (parameter
);
2265 if (FRAME_LIVE_P (f
))
2267 /* Avoid consing in frequent cases. */
2268 if (EQ (parameter
, Qname
))
2270 #ifdef HAVE_X_WINDOWS
2271 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2272 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2273 #endif /* HAVE_X_WINDOWS */
2274 else if (EQ (parameter
, Qbackground_color
)
2275 || EQ (parameter
, Qforeground_color
))
2277 value
= Fassq (parameter
, f
->param_alist
);
2280 value
= XCDR (value
);
2281 /* Fframe_parameters puts the actual fg/bg color names,
2282 even if f->param_alist says otherwise. This is
2283 important when param_alist's notion of colors is
2284 "unspecified". We need to do the same here. */
2285 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2287 const char *color_name
;
2290 if (EQ (parameter
, Qbackground_color
))
2292 color_name
= SDATA (value
);
2293 csz
= SCHARS (value
);
2294 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2295 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2296 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2297 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2299 else if (EQ (parameter
, Qforeground_color
))
2301 color_name
= SDATA (value
);
2302 csz
= SCHARS (value
);
2303 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2304 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2305 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2306 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2311 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2313 else if (EQ (parameter
, Qdisplay_type
)
2314 || EQ (parameter
, Qbackground_mode
))
2315 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2317 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2324 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2325 Smodify_frame_parameters
, 2, 2, 0,
2326 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2327 If FRAME is nil, it defaults to the selected frame.
2328 ALIST is an alist of parameters to change and their new values.
2329 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2330 The meaningful PARMs depend on the kind of frame.
2331 Undefined PARMs are ignored, but stored in the frame's parameter list
2332 so that `frame-parameters' will return them.
2334 The value of frame parameter FOO can also be accessed
2335 as a frame-local binding for the variable FOO, if you have
2336 enabled such bindings for that variable with `make-variable-frame-local'. */)
2338 Lisp_Object frame
, alist
;
2341 register Lisp_Object tail
, prop
, val
;
2342 int count
= SPECPDL_INDEX ();
2344 /* Bind this to t to inhibit initialization of the default face from
2345 X resources in face-set-after-frame-default. If we don't inhibit
2346 this, modifying the `font' frame parameter, for example, while
2347 there is a `default.attributeFont' X resource, won't work,
2348 because `default's font is reset to the value of the X resource
2349 and that resets the `font' frame parameter. */
2350 specbind (Qinhibit_default_face_x_resources
, Qt
);
2352 if (EQ (frame
, Qnil
))
2353 frame
= selected_frame
;
2354 CHECK_LIVE_FRAME (frame
);
2357 /* I think this should be done with a hook. */
2358 #ifdef HAVE_WINDOW_SYSTEM
2359 if (FRAME_WINDOW_P (f
))
2360 x_set_frame_parameters (f
, alist
);
2364 if (FRAME_MSDOS_P (f
))
2365 IT_set_frame_parameters (f
, alist
);
2370 int length
= XINT (Flength (alist
));
2373 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2375 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2377 /* Extract parm names and values into those vectors. */
2380 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2385 parms
[i
] = Fcar (elt
);
2386 values
[i
] = Fcdr (elt
);
2390 /* Now process them in reverse of specified order. */
2391 for (i
--; i
>= 0; i
--)
2395 store_frame_param (f
, prop
, val
);
2399 return unbind_to (count
, Qnil
);
2402 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2404 doc
: /* Height in pixels of a line in the font in frame FRAME.
2405 If FRAME is omitted, the selected frame is used.
2406 For a terminal frame, the value is always 1. */)
2413 frame
= selected_frame
;
2414 CHECK_FRAME (frame
);
2417 #ifdef HAVE_WINDOW_SYSTEM
2418 if (FRAME_WINDOW_P (f
))
2419 return make_number (x_char_height (f
));
2422 return make_number (1);
2426 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2428 doc
: /* Width in pixels of characters in the font in frame FRAME.
2429 If FRAME is omitted, the selected frame is used.
2430 The width is the same for all characters, because
2431 currently Emacs supports only fixed-width fonts.
2432 For a terminal screen, the value is always 1. */)
2439 frame
= selected_frame
;
2440 CHECK_FRAME (frame
);
2443 #ifdef HAVE_WINDOW_SYSTEM
2444 if (FRAME_WINDOW_P (f
))
2445 return make_number (x_char_width (f
));
2448 return make_number (1);
2451 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2452 Sframe_pixel_height
, 0, 1, 0,
2453 doc
: /* Return a FRAME's height in pixels.
2454 This counts only the height available for text lines,
2455 not menu bars on window-system Emacs frames.
2456 For a terminal frame, the result really gives the height in characters.
2457 If FRAME is omitted, the selected frame is used. */)
2464 frame
= selected_frame
;
2465 CHECK_FRAME (frame
);
2468 #ifdef HAVE_WINDOW_SYSTEM
2469 if (FRAME_WINDOW_P (f
))
2470 return make_number (x_pixel_height (f
));
2473 return make_number (FRAME_LINES (f
));
2476 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2477 Sframe_pixel_width
, 0, 1, 0,
2478 doc
: /* Return FRAME's width in pixels.
2479 For a terminal frame, the result really gives the width in characters.
2480 If FRAME is omitted, the selected frame is used. */)
2487 frame
= selected_frame
;
2488 CHECK_FRAME (frame
);
2491 #ifdef HAVE_WINDOW_SYSTEM
2492 if (FRAME_WINDOW_P (f
))
2493 return make_number (x_pixel_width (f
));
2496 return make_number (FRAME_COLS (f
));
2499 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2500 doc
: /* Specify that the frame FRAME has LINES lines.
2501 Optional third arg non-nil means that redisplay should use LINES lines
2502 but that the idea of the actual height of the frame should not be changed. */)
2503 (frame
, lines
, pretend
)
2504 Lisp_Object frame
, lines
, pretend
;
2506 register struct frame
*f
;
2508 CHECK_NUMBER (lines
);
2510 frame
= selected_frame
;
2511 CHECK_LIVE_FRAME (frame
);
2514 /* I think this should be done with a hook. */
2515 #ifdef HAVE_WINDOW_SYSTEM
2516 if (FRAME_WINDOW_P (f
))
2518 if (XINT (lines
) != FRAME_LINES (f
))
2519 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2520 do_pending_window_change (0);
2524 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2528 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2529 doc
: /* Specify that the frame FRAME has COLS columns.
2530 Optional third arg non-nil means that redisplay should use COLS columns
2531 but that the idea of the actual width of the frame should not be changed. */)
2532 (frame
, cols
, pretend
)
2533 Lisp_Object frame
, cols
, pretend
;
2535 register struct frame
*f
;
2536 CHECK_NUMBER (cols
);
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
))
2546 if (XINT (cols
) != FRAME_COLS (f
))
2547 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2548 do_pending_window_change (0);
2552 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2556 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2557 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2559 Lisp_Object frame
, cols
, rows
;
2561 register struct frame
*f
;
2563 CHECK_LIVE_FRAME (frame
);
2564 CHECK_NUMBER (cols
);
2565 CHECK_NUMBER (rows
);
2568 /* I think this should be done with a hook. */
2569 #ifdef HAVE_WINDOW_SYSTEM
2570 if (FRAME_WINDOW_P (f
))
2572 if (XINT (rows
) != FRAME_LINES (f
)
2573 || XINT (cols
) != FRAME_COLS (f
)
2574 || f
->new_text_lines
|| f
->new_text_cols
)
2575 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2576 do_pending_window_change (0);
2580 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2585 DEFUN ("set-frame-position", Fset_frame_position
,
2586 Sset_frame_position
, 3, 3, 0,
2587 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2588 This is actually the position of the upper left corner of the frame.
2589 Negative values for XOFFSET or YOFFSET are interpreted relative to
2590 the rightmost or bottommost possible position (that stays within the screen). */)
2591 (frame
, xoffset
, yoffset
)
2592 Lisp_Object frame
, xoffset
, yoffset
;
2594 register struct frame
*f
;
2596 CHECK_LIVE_FRAME (frame
);
2597 CHECK_NUMBER (xoffset
);
2598 CHECK_NUMBER (yoffset
);
2601 /* I think this should be done with a hook. */
2602 #ifdef HAVE_WINDOW_SYSTEM
2603 if (FRAME_WINDOW_P (f
))
2604 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2611 /***********************************************************************
2613 ***********************************************************************/
2615 /* Connect the frame-parameter names for X frames
2616 to the ways of passing the parameter values to the window system.
2618 The name of a parameter, as a Lisp symbol,
2619 has an `x-frame-parameter' property which is an integer in Lisp
2620 that is an index in this table. */
2622 struct frame_parm_table
{
2624 Lisp_Object
*variable
;
2627 static struct frame_parm_table frame_parms
[] =
2629 {"auto-raise", &Qauto_raise
},
2630 {"auto-lower", &Qauto_lower
},
2631 {"background-color", 0},
2632 {"border-color", &Qborder_color
},
2633 {"border-width", &Qborder_width
},
2634 {"cursor-color", &Qcursor_color
},
2635 {"cursor-type", &Qcursor_type
},
2637 {"foreground-color", 0},
2638 {"icon-name", &Qicon_name
},
2639 {"icon-type", &Qicon_type
},
2640 {"internal-border-width", &Qinternal_border_width
},
2641 {"menu-bar-lines", &Qmenu_bar_lines
},
2642 {"mouse-color", &Qmouse_color
},
2644 {"scroll-bar-width", &Qscroll_bar_width
},
2646 {"unsplittable", &Qunsplittable
},
2647 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2648 {"visibility", &Qvisibility
},
2649 {"tool-bar-lines", &Qtool_bar_lines
},
2650 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2651 {"scroll-bar-background", &Qscroll_bar_background
},
2652 {"screen-gamma", &Qscreen_gamma
},
2653 {"line-spacing", &Qline_spacing
},
2654 {"left-fringe", &Qleft_fringe
},
2655 {"right-fringe", &Qright_fringe
},
2656 {"wait-for-wm", &Qwait_for_wm
},
2657 {"fullscreen", &Qfullscreen
},
2660 #ifdef HAVE_WINDOW_SYSTEM
2662 extern Lisp_Object Qbox
;
2663 extern Lisp_Object Qtop
;
2665 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2666 wanted positions of the WM window (not emacs window).
2667 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2668 window (FRAME_X_WINDOW).
2672 x_fullscreen_adjust (f
, width
, height
, top_pos
, left_pos
)
2679 int newwidth
= FRAME_COLS (f
);
2680 int newheight
= FRAME_LINES (f
);
2682 *top_pos
= f
->top_pos
;
2683 *left_pos
= f
->left_pos
;
2685 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2689 ph
= FRAME_X_DISPLAY_INFO (f
)->height
;
2690 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2691 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2692 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2696 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2700 pw
= FRAME_X_DISPLAY_INFO (f
)->width
;
2701 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2702 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2703 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2708 *height
= newheight
;
2712 /* Change the parameters of frame F as specified by ALIST.
2713 If a parameter is not specially recognized, do nothing special;
2714 otherwise call the `x_set_...' function for that parameter.
2715 Except for certain geometry properties, always call store_frame_param
2716 to store the new value in the parameter alist. */
2719 x_set_frame_parameters (f
, alist
)
2725 /* If both of these parameters are present, it's more efficient to
2726 set them both at once. So we wait until we've looked at the
2727 entire list before we set them. */
2731 Lisp_Object left
, top
;
2733 /* Same with these. */
2734 Lisp_Object icon_left
, icon_top
;
2736 /* Record in these vectors all the parms specified. */
2738 Lisp_Object
*values
;
2740 int left_no_change
= 0, top_no_change
= 0;
2741 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2742 int fullscreen_is_being_set
= 0;
2744 struct gcpro gcpro1
, gcpro2
;
2747 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2750 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2751 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2753 /* Extract parm names and values into those vectors. */
2756 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2761 parms
[i
] = Fcar (elt
);
2762 values
[i
] = Fcdr (elt
);
2765 /* TAIL and ALIST are not used again below here. */
2766 alist
= tail
= Qnil
;
2768 GCPRO2 (*parms
, *values
);
2772 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2773 because their values appear in VALUES and strings are not valid. */
2774 top
= left
= Qunbound
;
2775 icon_left
= icon_top
= Qunbound
;
2777 /* Provide default values for HEIGHT and WIDTH. */
2778 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2779 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2781 /* Process foreground_color and background_color before anything else.
2782 They are independent of other properties, but other properties (e.g.,
2783 cursor_color) are dependent upon them. */
2784 /* Process default font as well, since fringe widths depends on it. */
2785 /* Also, process fullscreen, width and height depend upon that */
2786 for (p
= 0; p
< i
; p
++)
2788 Lisp_Object prop
, val
;
2792 if (EQ (prop
, Qforeground_color
)
2793 || EQ (prop
, Qbackground_color
)
2795 || EQ (prop
, Qfullscreen
))
2797 register Lisp_Object param_index
, old_value
;
2799 old_value
= get_frame_param (f
, prop
);
2800 fullscreen_is_being_set
|= EQ (prop
, Qfullscreen
);
2802 if (NILP (Fequal (val
, old_value
)))
2804 store_frame_param (f
, prop
, val
);
2806 param_index
= Fget (prop
, Qx_frame_parameter
);
2807 if (NATNUMP (param_index
)
2808 && (XFASTINT (param_index
)
2809 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2810 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2811 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2816 /* Now process them in reverse of specified order. */
2817 for (i
--; i
>= 0; i
--)
2819 Lisp_Object prop
, val
;
2824 if (EQ (prop
, Qwidth
) && NUMBERP (val
))
2825 width
= XFASTINT (val
);
2826 else if (EQ (prop
, Qheight
) && NUMBERP (val
))
2827 height
= XFASTINT (val
);
2828 else if (EQ (prop
, Qtop
))
2830 else if (EQ (prop
, Qleft
))
2832 else if (EQ (prop
, Qicon_top
))
2834 else if (EQ (prop
, Qicon_left
))
2836 else if (EQ (prop
, Qforeground_color
)
2837 || EQ (prop
, Qbackground_color
)
2839 || EQ (prop
, Qfullscreen
))
2840 /* Processed above. */
2844 register Lisp_Object param_index
, old_value
;
2846 old_value
= get_frame_param (f
, prop
);
2848 store_frame_param (f
, prop
, val
);
2850 param_index
= Fget (prop
, Qx_frame_parameter
);
2851 if (NATNUMP (param_index
)
2852 && (XFASTINT (param_index
)
2853 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2854 && FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])
2855 (*(FRAME_RIF (f
)->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2859 /* Don't die if just one of these was set. */
2860 if (EQ (left
, Qunbound
))
2863 if (f
->left_pos
< 0)
2864 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2866 XSETINT (left
, f
->left_pos
);
2868 if (EQ (top
, Qunbound
))
2872 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2874 XSETINT (top
, f
->top_pos
);
2877 /* If one of the icon positions was not set, preserve or default it. */
2878 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
2880 icon_left_no_change
= 1;
2881 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2882 if (NILP (icon_left
))
2883 XSETINT (icon_left
, 0);
2885 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
2887 icon_top_no_change
= 1;
2888 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2889 if (NILP (icon_top
))
2890 XSETINT (icon_top
, 0);
2894 /* MAC_TODO: fullscreen */
2895 if (FRAME_VISIBLE_P (f
) && fullscreen_is_being_set
)
2897 /* If the frame is visible already and the fullscreen parameter is
2898 being set, it is too late to set WM manager hints to specify
2900 Here we first get the width, height and position that applies to
2901 fullscreen. We then move the frame to the appropriate
2902 position. Resize of the frame is taken care of in the code after
2903 this if-statement. */
2904 int new_left
, new_top
;
2906 x_fullscreen_adjust (f
, &width
, &height
, &new_top
, &new_left
);
2907 if (new_top
!= f
->top_pos
|| new_left
!= f
->left_pos
)
2908 x_set_offset (f
, new_left
, new_top
, 1);
2912 /* Don't set these parameters unless they've been explicitly
2913 specified. The window might be mapped or resized while we're in
2914 this function, and we don't want to override that unless the lisp
2915 code has asked for it.
2917 Don't set these parameters unless they actually differ from the
2918 window's current parameters; the window may not actually exist
2923 check_frame_size (f
, &height
, &width
);
2925 XSETFRAME (frame
, f
);
2927 if (width
!= FRAME_COLS (f
)
2928 || height
!= FRAME_LINES (f
)
2929 || f
->new_text_lines
|| f
->new_text_cols
)
2930 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2932 if ((!NILP (left
) || !NILP (top
))
2933 && ! (left_no_change
&& top_no_change
)
2934 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2935 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2940 /* Record the signs. */
2941 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2942 if (EQ (left
, Qminus
))
2943 f
->size_hint_flags
|= XNegative
;
2944 else if (INTEGERP (left
))
2946 leftpos
= XINT (left
);
2948 f
->size_hint_flags
|= XNegative
;
2950 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2951 && CONSP (XCDR (left
))
2952 && INTEGERP (XCAR (XCDR (left
))))
2954 leftpos
= - XINT (XCAR (XCDR (left
)));
2955 f
->size_hint_flags
|= XNegative
;
2957 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2958 && CONSP (XCDR (left
))
2959 && INTEGERP (XCAR (XCDR (left
))))
2961 leftpos
= XINT (XCAR (XCDR (left
)));
2964 if (EQ (top
, Qminus
))
2965 f
->size_hint_flags
|= YNegative
;
2966 else if (INTEGERP (top
))
2968 toppos
= XINT (top
);
2970 f
->size_hint_flags
|= YNegative
;
2972 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2973 && CONSP (XCDR (top
))
2974 && INTEGERP (XCAR (XCDR (top
))))
2976 toppos
= - XINT (XCAR (XCDR (top
)));
2977 f
->size_hint_flags
|= YNegative
;
2979 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2980 && CONSP (XCDR (top
))
2981 && INTEGERP (XCAR (XCDR (top
))))
2983 toppos
= XINT (XCAR (XCDR (top
)));
2987 /* Store the numeric value of the position. */
2988 f
->top_pos
= toppos
;
2989 f
->left_pos
= leftpos
;
2991 f
->win_gravity
= NorthWestGravity
;
2993 /* Actually set that position, and convert to absolute. */
2994 x_set_offset (f
, leftpos
, toppos
, -1);
2997 if ((!NILP (icon_left
) || !NILP (icon_top
))
2998 && ! (icon_left_no_change
&& icon_top_no_change
))
2999 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
3006 /* Insert a description of internally-recorded parameters of frame X
3007 into the parameter alist *ALISTPTR that is to be given to the user.
3008 Only parameters that are specific to the X window system
3009 and whose values are not correctly recorded in the frame's
3010 param_alist need to be considered here. */
3013 x_report_frame_params (f
, alistptr
)
3015 Lisp_Object
*alistptr
;
3020 /* Represent negative positions (off the top or left screen edge)
3021 in a way that Fmodify_frame_parameters will understand correctly. */
3022 XSETINT (tem
, f
->left_pos
);
3023 if (f
->left_pos
>= 0)
3024 store_in_alist (alistptr
, Qleft
, tem
);
3026 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3028 XSETINT (tem
, f
->top_pos
);
3029 if (f
->top_pos
>= 0)
3030 store_in_alist (alistptr
, Qtop
, tem
);
3032 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
3034 store_in_alist (alistptr
, Qborder_width
,
3035 make_number (f
->border_width
));
3036 store_in_alist (alistptr
, Qinternal_border_width
,
3037 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
3038 store_in_alist (alistptr
, Qleft_fringe
,
3039 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
3040 store_in_alist (alistptr
, Qright_fringe
,
3041 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3042 store_in_alist (alistptr
, Qscroll_bar_width
,
3043 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3045 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3046 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3047 /* nil means "use default width"
3048 for non-toolkit scroll bar.
3049 ruler-mode.el depends on this. */
3051 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
3052 store_in_alist (alistptr
, Qwindow_id
,
3053 build_string (buf
));
3054 #ifdef HAVE_X_WINDOWS
3055 #ifdef USE_X_TOOLKIT
3056 /* Tooltip frame may not have this widget. */
3057 if (FRAME_X_OUTPUT (f
)->widget
)
3059 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
3060 store_in_alist (alistptr
, Qouter_window_id
,
3061 build_string (buf
));
3063 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3064 FRAME_SAMPLE_VISIBILITY (f
);
3065 store_in_alist (alistptr
, Qvisibility
,
3066 (FRAME_VISIBLE_P (f
) ? Qt
3067 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3068 store_in_alist (alistptr
, Qdisplay
,
3069 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3072 /* A Mac Window is identified by a struct, not an integer. */
3073 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3076 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3077 store_in_alist (alistptr
, Qparent_id
, tem
);
3082 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3083 the previous value of that parameter, NEW_VALUE is the new value. */
3086 x_set_fullscreen (f
, new_value
, old_value
)
3088 Lisp_Object new_value
, old_value
;
3091 if (NILP (new_value
))
3092 f
->want_fullscreen
= FULLSCREEN_NONE
;
3093 else if (EQ (new_value
, Qfullboth
))
3094 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3095 else if (EQ (new_value
, Qfullwidth
))
3096 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3097 else if (EQ (new_value
, Qfullheight
))
3098 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3103 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3104 the previous value of that parameter, NEW_VALUE is the new value. */
3107 x_set_line_spacing (f
, new_value
, old_value
)
3109 Lisp_Object new_value
, old_value
;
3111 if (NILP (new_value
))
3112 f
->extra_line_spacing
= 0;
3113 else if (NATNUMP (new_value
))
3114 f
->extra_line_spacing
= XFASTINT (new_value
);
3116 Fsignal (Qerror
, Fcons (build_string ("Invalid line-spacing"),
3117 Fcons (new_value
, Qnil
)));
3118 if (FRAME_VISIBLE_P (f
))
3123 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3124 the previous value of that parameter, NEW_VALUE is the new value. */
3127 x_set_screen_gamma (f
, new_value
, old_value
)
3129 Lisp_Object new_value
, old_value
;
3131 if (NILP (new_value
))
3133 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3134 /* The value 0.4545 is the normal viewing gamma. */
3135 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3137 Fsignal (Qerror
, Fcons (build_string ("Invalid screen-gamma"),
3138 Fcons (new_value
, Qnil
)));
3140 clear_face_cache (0);
3145 x_set_font (f
, arg
, oldval
)
3147 Lisp_Object arg
, oldval
;
3150 Lisp_Object fontset_name
;
3152 int old_fontset
= FRAME_FONTSET(f
);
3156 fontset_name
= Fquery_fontset (arg
, Qnil
);
3159 result
= (STRINGP (fontset_name
)
3160 ? x_new_fontset (f
, SDATA (fontset_name
))
3161 : x_new_font (f
, SDATA (arg
)));
3164 if (EQ (result
, Qnil
))
3165 error ("Font `%s' is not defined", SDATA (arg
));
3166 else if (EQ (result
, Qt
))
3167 error ("The characters of the given font have varying widths");
3168 else if (STRINGP (result
))
3170 if (STRINGP (fontset_name
))
3172 /* Fontset names are built from ASCII font names, so the
3173 names may be equal despite there was a change. */
3174 if (old_fontset
== FRAME_FONTSET (f
))
3177 else if (!NILP (Fequal (result
, oldval
)))
3180 store_frame_param (f
, Qfont
, result
);
3181 recompute_basic_faces (f
);
3186 do_pending_window_change (0);
3188 /* Don't call `face-set-after-frame-default' when faces haven't been
3189 initialized yet. This is the case when called from
3190 Fx_create_frame. In that case, the X widget or window doesn't
3191 exist either, and we can end up in x_report_frame_params with a
3192 null widget which gives a segfault. */
3193 if (FRAME_FACE_CACHE (f
))
3195 XSETFRAME (frame
, f
);
3196 call1 (Qface_set_after_frame_default
, frame
);
3202 x_set_fringe_width (f
, new_value
, old_value
)
3204 Lisp_Object new_value
, old_value
;
3206 compute_fringe_widths (f
, 1);
3210 x_set_border_width (f
, arg
, oldval
)
3212 Lisp_Object arg
, oldval
;
3216 if (XINT (arg
) == f
->border_width
)
3220 if (FRAME_X_WINDOW (f
) != 0)
3221 error ("Cannot change the border width of a window");
3222 #endif /* MAC_TODO */
3224 f
->border_width
= XINT (arg
);
3228 x_set_internal_border_width (f
, arg
, oldval
)
3230 Lisp_Object arg
, oldval
;
3232 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3235 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3236 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3237 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3239 #ifdef USE_X_TOOLKIT
3240 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3241 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3244 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3247 if (FRAME_X_WINDOW (f
) != 0)
3249 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3250 SET_FRAME_GARBAGED (f
);
3251 do_pending_window_change (0);
3254 SET_FRAME_GARBAGED (f
);
3258 x_set_visibility (f
, value
, oldval
)
3260 Lisp_Object value
, oldval
;
3263 XSETFRAME (frame
, f
);
3266 Fmake_frame_invisible (frame
, Qt
);
3267 else if (EQ (value
, Qicon
))
3268 Ficonify_frame (frame
);
3270 Fmake_frame_visible (frame
);
3274 x_set_autoraise (f
, arg
, oldval
)
3276 Lisp_Object arg
, oldval
;
3278 f
->auto_raise
= !EQ (Qnil
, arg
);
3282 x_set_autolower (f
, arg
, oldval
)
3284 Lisp_Object arg
, oldval
;
3286 f
->auto_lower
= !EQ (Qnil
, arg
);
3290 x_set_unsplittable (f
, arg
, oldval
)
3292 Lisp_Object arg
, oldval
;
3294 f
->no_split
= !NILP (arg
);
3298 x_set_vertical_scroll_bars (f
, arg
, oldval
)
3300 Lisp_Object arg
, oldval
;
3302 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3303 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3304 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3305 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3307 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3309 ? vertical_scroll_bar_none
3311 ? vertical_scroll_bar_left
3313 ? vertical_scroll_bar_right
3314 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3315 ? vertical_scroll_bar_left
3316 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3317 ? vertical_scroll_bar_right
3318 : vertical_scroll_bar_none
);
3320 /* We set this parameter before creating the X window for the
3321 frame, so we can get the geometry right from the start.
3322 However, if the window hasn't been created yet, we shouldn't
3323 call x_set_window_size. */
3324 if (FRAME_X_WINDOW (f
))
3325 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3326 do_pending_window_change (0);
3331 x_set_scroll_bar_width (f
, arg
, oldval
)
3333 Lisp_Object arg
, oldval
;
3335 int wid
= FRAME_COLUMN_WIDTH (f
);
3339 x_set_scroll_bar_default_width (f
);
3341 if (FRAME_X_WINDOW (f
))
3342 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3343 do_pending_window_change (0);
3345 else if (INTEGERP (arg
) && XINT (arg
) > 0
3346 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3348 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3349 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3351 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3352 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3353 if (FRAME_X_WINDOW (f
))
3354 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3355 do_pending_window_change (0);
3358 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3359 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3360 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3365 /* Return non-nil if frame F wants a bitmap icon. */
3373 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3381 /* Subroutines of creating an X frame. */
3383 /* Make sure that Vx_resource_name is set to a reasonable value.
3384 Fix it up, or set it to `emacs' if it is too hopeless. */
3387 validate_x_resource_name ()
3390 /* Number of valid characters in the resource name. */
3392 /* Number of invalid characters in the resource name. */
3397 if (!STRINGP (Vx_resource_class
))
3398 Vx_resource_class
= build_string (EMACS_CLASS
);
3400 if (STRINGP (Vx_resource_name
))
3402 unsigned char *p
= SDATA (Vx_resource_name
);
3405 len
= SBYTES (Vx_resource_name
);
3407 /* Only letters, digits, - and _ are valid in resource names.
3408 Count the valid characters and count the invalid ones. */
3409 for (i
= 0; i
< len
; i
++)
3412 if (! ((c
>= 'a' && c
<= 'z')
3413 || (c
>= 'A' && c
<= 'Z')
3414 || (c
>= '0' && c
<= '9')
3415 || c
== '-' || c
== '_'))
3422 /* Not a string => completely invalid. */
3423 bad_count
= 5, good_count
= 0;
3425 /* If name is valid already, return. */
3429 /* If name is entirely invalid, or nearly so, use `emacs'. */
3431 || (good_count
== 1 && bad_count
> 0))
3433 Vx_resource_name
= build_string ("emacs");
3437 /* Name is partly valid. Copy it and replace the invalid characters
3438 with underscores. */
3440 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3442 for (i
= 0; i
< len
; i
++)
3444 int c
= SREF (new, i
);
3445 if (! ((c
>= 'a' && c
<= 'z')
3446 || (c
>= 'A' && c
<= 'Z')
3447 || (c
>= '0' && c
<= '9')
3448 || c
== '-' || c
== '_'))
3454 extern char *x_get_string_resource
P_ ((XrmDatabase
, char *, char *));
3455 extern Display_Info
*check_x_display_info
P_ ((Lisp_Object
));
3458 /* Get specified attribute from resource database RDB.
3459 See Fx_get_resource below for other parameters. */
3462 xrdb_get_resource (rdb
, attribute
, class, component
, subclass
)
3464 Lisp_Object attribute
, class, component
, subclass
;
3466 register char *value
;
3470 CHECK_STRING (attribute
);
3471 CHECK_STRING (class);
3473 if (!NILP (component
))
3474 CHECK_STRING (component
);
3475 if (!NILP (subclass
))
3476 CHECK_STRING (subclass
);
3477 if (NILP (component
) != NILP (subclass
))
3478 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3480 validate_x_resource_name ();
3482 /* Allocate space for the components, the dots which separate them,
3483 and the final '\0'. Make them big enough for the worst case. */
3484 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3485 + (STRINGP (component
)
3486 ? SBYTES (component
) : 0)
3487 + SBYTES (attribute
)
3490 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3492 + (STRINGP (subclass
)
3493 ? SBYTES (subclass
) : 0)
3496 /* Start with emacs.FRAMENAME for the name (the specific one)
3497 and with `Emacs' for the class key (the general one). */
3498 strcpy (name_key
, SDATA (Vx_resource_name
));
3499 strcpy (class_key
, SDATA (Vx_resource_class
));
3501 strcat (class_key
, ".");
3502 strcat (class_key
, SDATA (class));
3504 if (!NILP (component
))
3506 strcat (class_key
, ".");
3507 strcat (class_key
, SDATA (subclass
));
3509 strcat (name_key
, ".");
3510 strcat (name_key
, SDATA (component
));
3513 strcat (name_key
, ".");
3514 strcat (name_key
, SDATA (attribute
));
3516 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3518 if (value
!= (char *) 0)
3519 return build_string (value
);
3525 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3526 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3527 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3528 class, where INSTANCE is the name under which Emacs was invoked, or
3529 the name specified by the `-name' or `-rn' command-line arguments.
3531 The optional arguments COMPONENT and SUBCLASS add to the key and the
3532 class, respectively. You must specify both of them or neither.
3533 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3534 and the class is `Emacs.CLASS.SUBCLASS'. */)
3535 (attribute
, class, component
, subclass
)
3536 Lisp_Object attribute
, class, component
, subclass
;
3538 #ifdef HAVE_X_WINDOWS
3542 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3543 attribute
, class, component
, subclass
);
3546 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3549 display_x_get_resource (dpyinfo
, attribute
, class, component
, subclass
)
3550 Display_Info
*dpyinfo
;
3551 Lisp_Object attribute
, class, component
, subclass
;
3553 return xrdb_get_resource (dpyinfo
->xrdb
,
3554 attribute
, class, component
, subclass
);
3557 /* Used when C code wants a resource value. */
3560 x_get_resource_string (attribute
, class)
3561 char *attribute
, *class;
3565 struct frame
*sf
= SELECTED_FRAME ();
3567 /* Allocate space for the components, the dots which separate them,
3568 and the final '\0'. */
3569 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3570 + strlen (attribute
) + 2);
3571 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3572 + strlen (class) + 2);
3574 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3575 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3577 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3578 name_key
, class_key
);
3582 /* Return the value of parameter PARAM.
3584 First search ALIST, then Vdefault_frame_alist, then the X defaults
3585 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3587 Convert the resource to the type specified by desired_type.
3589 If no default is specified, return Qunbound. If you call
3590 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3591 and don't let it get stored in any Lisp-visible variables! */
3594 x_get_arg (dpyinfo
, alist
, param
, attribute
, class, type
)
3595 Display_Info
*dpyinfo
;
3596 Lisp_Object alist
, param
;
3599 enum resource_types type
;
3601 register Lisp_Object tem
;
3603 tem
= Fassq (param
, alist
);
3605 tem
= Fassq (param
, Vdefault_frame_alist
);
3610 tem
= display_x_get_resource (dpyinfo
,
3611 build_string (attribute
),
3612 build_string (class),
3620 case RES_TYPE_NUMBER
:
3621 return make_number (atoi (SDATA (tem
)));
3623 case RES_TYPE_FLOAT
:
3624 return make_float (atof (SDATA (tem
)));
3626 case RES_TYPE_BOOLEAN
:
3627 tem
= Fdowncase (tem
);
3628 if (!strcmp (SDATA (tem
), "on")
3629 || !strcmp (SDATA (tem
), "true"))
3634 case RES_TYPE_STRING
:
3637 case RES_TYPE_SYMBOL
:
3638 /* As a special case, we map the values `true' and `on'
3639 to Qt, and `false' and `off' to Qnil. */
3642 lower
= Fdowncase (tem
);
3643 if (!strcmp (SDATA (lower
), "on")
3644 || !strcmp (SDATA (lower
), "true"))
3646 else if (!strcmp (SDATA (lower
), "off")
3647 || !strcmp (SDATA (lower
), "false"))
3650 return Fintern (tem
, Qnil
);
3664 x_frame_get_arg (f
, alist
, param
, attribute
, class, type
)
3666 Lisp_Object alist
, param
;
3669 enum resource_types type
;
3671 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3672 alist
, param
, attribute
, class, type
);
3675 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3678 x_frame_get_and_record_arg (f
, alist
, param
, attribute
, class, type
)
3680 Lisp_Object alist
, param
;
3683 enum resource_types type
;
3687 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3688 attribute
, class, type
);
3690 store_frame_param (f
, param
, value
);
3696 /* Record in frame F the specified or default value according to ALIST
3697 of the parameter named PROP (a Lisp symbol).
3698 If no value is specified for PROP, look for an X default for XPROP
3699 on the frame named NAME.
3700 If that is not found either, use the value DEFLT. */
3703 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
3710 enum resource_types type
;
3714 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3715 if (EQ (tem
, Qunbound
))
3717 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3724 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3725 doc
: /* Parse an X-style geometry string STRING.
3726 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3727 The properties returned may include `top', `left', `height', and `width'.
3728 The value of `left' or `top' may be an integer,
3729 or a list (+ N) meaning N pixels relative to top/left corner,
3730 or a list (- N) meaning -N pixels relative to bottom/right corner. */)
3735 unsigned int width
, height
;
3738 CHECK_STRING (string
);
3740 geometry
= XParseGeometry ((char *) SDATA (string
),
3741 &x
, &y
, &width
, &height
);
3744 if (!!(geometry
& XValue
) != !!(geometry
& YValue
))
3745 error ("Must specify both x and y position, or neither");
3749 if (geometry
& XValue
)
3751 Lisp_Object element
;
3753 if (x
>= 0 && (geometry
& XNegative
))
3754 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3755 else if (x
< 0 && ! (geometry
& XNegative
))
3756 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3758 element
= Fcons (Qleft
, make_number (x
));
3759 result
= Fcons (element
, result
);
3762 if (geometry
& YValue
)
3764 Lisp_Object element
;
3766 if (y
>= 0 && (geometry
& YNegative
))
3767 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3768 else if (y
< 0 && ! (geometry
& YNegative
))
3769 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3771 element
= Fcons (Qtop
, make_number (y
));
3772 result
= Fcons (element
, result
);
3775 if (geometry
& WidthValue
)
3776 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3777 if (geometry
& HeightValue
)
3778 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3783 /* Calculate the desired size and position of frame F.
3784 Return the flags saying which aspects were specified.
3786 Also set the win_gravity and size_hint_flags of F.
3788 Adjust height for toolbar if TOOLBAR_P is 1.
3790 This function does not make the coordinates positive. */
3792 #define DEFAULT_ROWS 40
3793 #define DEFAULT_COLS 80
3796 x_figure_window_size (f
, parms
, toolbar_p
)
3801 register Lisp_Object tem0
, tem1
, tem2
;
3802 long window_prompting
= 0;
3803 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3805 /* Default values if we fall through.
3806 Actually, if that happens we should get
3807 window manager prompting. */
3808 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3809 FRAME_LINES (f
) = DEFAULT_ROWS
;
3810 /* Window managers expect that if program-specified
3811 positions are not (0,0), they're intentional, not defaults. */
3815 /* Ensure that old new_text_cols and new_text_lines will not override the
3817 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3818 f
->new_text_cols
= f
->new_text_lines
= 0;
3820 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3821 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3822 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3823 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3825 if (!EQ (tem0
, Qunbound
))
3827 CHECK_NUMBER (tem0
);
3828 FRAME_LINES (f
) = XINT (tem0
);
3830 if (!EQ (tem1
, Qunbound
))
3832 CHECK_NUMBER (tem1
);
3833 SET_FRAME_COLS (f
, XINT (tem1
));
3835 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
3836 window_prompting
|= USSize
;
3838 window_prompting
|= PSize
;
3841 f
->scroll_bar_actual_width
3842 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
3844 /* This used to be done _before_ calling x_figure_window_size, but
3845 since the height is reset here, this was really a no-op. I
3846 assume that moving it here does what Gerd intended (although he
3847 no longer can remember what that was... ++KFS, 2003-03-25. */
3849 /* Add the tool-bar height to the initial frame height so that the
3850 user gets a text display area of the size he specified with -g or
3851 via .Xdefaults. Later changes of the tool-bar height don't
3852 change the frame size. This is done so that users can create
3853 tall Emacs frames without having to guess how tall the tool-bar
3855 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
3857 int margin
, relief
, bar_height
;
3859 relief
= (tool_bar_button_relief
>= 0
3860 ? tool_bar_button_relief
3861 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
3863 if (INTEGERP (Vtool_bar_button_margin
)
3864 && XINT (Vtool_bar_button_margin
) > 0)
3865 margin
= XFASTINT (Vtool_bar_button_margin
);
3866 else if (CONSP (Vtool_bar_button_margin
)
3867 && INTEGERP (XCDR (Vtool_bar_button_margin
))
3868 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
3869 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
3873 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
3874 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
3877 compute_fringe_widths (f
, 0);
3879 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
3880 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
3882 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
3883 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
3884 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
3885 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3887 if (EQ (tem0
, Qminus
))
3890 window_prompting
|= YNegative
;
3892 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
3893 && CONSP (XCDR (tem0
))
3894 && INTEGERP (XCAR (XCDR (tem0
))))
3896 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
3897 window_prompting
|= YNegative
;
3899 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
3900 && CONSP (XCDR (tem0
))
3901 && INTEGERP (XCAR (XCDR (tem0
))))
3903 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
3905 else if (EQ (tem0
, Qunbound
))
3909 CHECK_NUMBER (tem0
);
3910 f
->top_pos
= XINT (tem0
);
3912 window_prompting
|= YNegative
;
3915 if (EQ (tem1
, Qminus
))
3918 window_prompting
|= XNegative
;
3920 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
3921 && CONSP (XCDR (tem1
))
3922 && INTEGERP (XCAR (XCDR (tem1
))))
3924 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
3925 window_prompting
|= XNegative
;
3927 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
3928 && CONSP (XCDR (tem1
))
3929 && INTEGERP (XCAR (XCDR (tem1
))))
3931 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
3933 else if (EQ (tem1
, Qunbound
))
3937 CHECK_NUMBER (tem1
);
3938 f
->left_pos
= XINT (tem1
);
3939 if (f
->left_pos
< 0)
3940 window_prompting
|= XNegative
;
3943 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
3944 window_prompting
|= USPosition
;
3946 window_prompting
|= PPosition
;
3949 if (f
->want_fullscreen
!= FULLSCREEN_NONE
)
3954 /* It takes both for some WM:s to place it where we want */
3955 window_prompting
= USPosition
| PPosition
;
3956 x_fullscreen_adjust (f
, &width
, &height
, &top
, &left
);
3957 FRAME_COLS (f
) = width
;
3958 FRAME_LINES (f
) = height
;
3959 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, width
);
3960 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, height
);
3965 if (window_prompting
& XNegative
)
3967 if (window_prompting
& YNegative
)
3968 f
->win_gravity
= SouthEastGravity
;
3970 f
->win_gravity
= NorthEastGravity
;
3974 if (window_prompting
& YNegative
)
3975 f
->win_gravity
= SouthWestGravity
;
3977 f
->win_gravity
= NorthWestGravity
;
3980 f
->size_hint_flags
= window_prompting
;
3982 return window_prompting
;
3987 #endif /* HAVE_WINDOW_SYSTEM */
3991 /***********************************************************************
3993 ***********************************************************************/
3998 Qframep
= intern ("framep");
3999 staticpro (&Qframep
);
4000 Qframe_live_p
= intern ("frame-live-p");
4001 staticpro (&Qframe_live_p
);
4002 Qheight
= intern ("height");
4003 staticpro (&Qheight
);
4004 Qicon
= intern ("icon");
4006 Qminibuffer
= intern ("minibuffer");
4007 staticpro (&Qminibuffer
);
4008 Qmodeline
= intern ("modeline");
4009 staticpro (&Qmodeline
);
4010 Qonly
= intern ("only");
4012 Qwidth
= intern ("width");
4013 staticpro (&Qwidth
);
4014 Qgeometry
= intern ("geometry");
4015 staticpro (&Qgeometry
);
4016 Qicon_left
= intern ("icon-left");
4017 staticpro (&Qicon_left
);
4018 Qicon_top
= intern ("icon-top");
4019 staticpro (&Qicon_top
);
4020 Qleft
= intern ("left");
4022 Qright
= intern ("right");
4023 staticpro (&Qright
);
4024 Quser_position
= intern ("user-position");
4025 staticpro (&Quser_position
);
4026 Quser_size
= intern ("user-size");
4027 staticpro (&Quser_size
);
4028 Qwindow_id
= intern ("window-id");
4029 staticpro (&Qwindow_id
);
4030 #ifdef HAVE_X_WINDOWS
4031 Qouter_window_id
= intern ("outer-window-id");
4032 staticpro (&Qouter_window_id
);
4034 Qparent_id
= intern ("parent-id");
4035 staticpro (&Qparent_id
);
4038 Qw32
= intern ("w32");
4040 Qpc
= intern ("pc");
4042 Qmac
= intern ("mac");
4044 Qvisible
= intern ("visible");
4045 staticpro (&Qvisible
);
4046 Qbuffer_predicate
= intern ("buffer-predicate");
4047 staticpro (&Qbuffer_predicate
);
4048 Qbuffer_list
= intern ("buffer-list");
4049 staticpro (&Qbuffer_list
);
4050 Qdisplay_type
= intern ("display-type");
4051 staticpro (&Qdisplay_type
);
4052 Qbackground_mode
= intern ("background-mode");
4053 staticpro (&Qbackground_mode
);
4054 Qtty_color_mode
= intern ("tty-color-mode");
4055 staticpro (&Qtty_color_mode
);
4056 Qtty
= intern ("tty");
4058 Qtty_type
= intern ("tty-type");
4059 staticpro (&Qtty_type
);
4061 Qface_set_after_frame_default
= intern ("face-set-after-frame-default");
4062 staticpro (&Qface_set_after_frame_default
);
4064 Qfullwidth
= intern ("fullwidth");
4065 staticpro (&Qfullwidth
);
4066 Qfullheight
= intern ("fullheight");
4067 staticpro (&Qfullheight
);
4068 Qfullboth
= intern ("fullboth");
4069 staticpro (&Qfullboth
);
4070 Qx_resource_name
= intern ("x-resource-name");
4071 staticpro (&Qx_resource_name
);
4073 Qx_frame_parameter
= intern ("x-frame-parameter");
4074 staticpro (&Qx_frame_parameter
);
4079 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4081 Lisp_Object v
= intern (frame_parms
[i
].name
);
4082 if (frame_parms
[i
].variable
)
4084 *frame_parms
[i
].variable
= v
;
4085 staticpro (frame_parms
[i
].variable
);
4087 Fput (v
, Qx_frame_parameter
, make_number (i
));
4091 #ifdef HAVE_WINDOW_SYSTEM
4092 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4093 doc
: /* The name Emacs uses to look up X resources.
4094 `x-get-resource' uses this as the first component of the instance name
4095 when requesting resource values.
4096 Emacs initially sets `x-resource-name' to the name under which Emacs
4097 was invoked, or to the value specified with the `-name' or `-rn'
4098 switches, if present.
4100 It may be useful to bind this variable locally around a call
4101 to `x-get-resource'. See also the variable `x-resource-class'. */);
4102 Vx_resource_name
= Qnil
;
4104 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4105 doc
: /* The class Emacs uses to look up X resources.
4106 `x-get-resource' uses this as the first component of the instance class
4107 when requesting resource values.
4109 Emacs initially sets `x-resource-class' to "Emacs".
4111 Setting this variable permanently is not a reasonable thing to do,
4112 but binding this variable locally around a call to `x-get-resource'
4113 is a reasonable practice. See also the variable `x-resource-name'. */);
4114 Vx_resource_class
= build_string (EMACS_CLASS
);
4117 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4118 doc
: /* Alist of default values for frame creation.
4119 These may be set in your init file, like this:
4120 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))
4121 These override values given in window system configuration data,
4122 including X Windows' defaults database.
4123 For values specific to the first Emacs frame, see `initial-frame-alist'.
4124 For values specific to the separate minibuffer frame, see
4125 `minibuffer-frame-alist'.
4126 The `menu-bar-lines' element of the list controls whether new frames
4127 have menu bars; `menu-bar-mode' works by altering this element.
4128 Setting this variable does not affect existing frames, only new ones. */);
4129 Vdefault_frame_alist
= Qnil
;
4131 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars
,
4132 doc
: /* Default position of scroll bars on this window-system. */);
4133 #ifdef HAVE_WINDOW_SYSTEM
4134 #if defined(HAVE_NTGUI) || defined(HAVE_CARBON)
4135 /* MS-Windows has scroll bars on the right by default. */
4136 Vdefault_frame_scroll_bars
= Qright
;
4138 Vdefault_frame_scroll_bars
= Qleft
;
4141 Vdefault_frame_scroll_bars
= Qnil
;
4144 Qinhibit_default_face_x_resources
4145 = intern ("inhibit-default-face-x-resources");
4146 staticpro (&Qinhibit_default_face_x_resources
);
4148 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4149 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4151 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
4152 doc
: /* Non-nil if all of emacs is iconified and frame updates are not needed. */);
4153 Vemacs_iconified
= Qnil
;
4155 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4156 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4157 `mouse-position' calls this function, passing its usual return value as
4158 argument, and returns whatever this function returns.
4159 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4160 which need to do mouse handling at the Lisp level. */);
4161 Vmouse_position_function
= Qnil
;
4163 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4164 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4165 If the value is an integer, highlighting is only shown after moving the
4166 mouse, while keyboard input turns off the highlight even when the mouse
4167 is over the clickable text. However, the mouse shape still indicates
4168 when the mouse is over clickable text. */);
4169 Vmouse_highlight
= Qt
;
4171 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4172 doc
: /* Functions to be run before deleting a frame.
4173 The functions are run with one arg, the frame to be deleted.
4174 See `delete-frame'. */);
4175 Vdelete_frame_functions
= Qnil
;
4177 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4178 doc
: /* Minibufferless frames use this frame's minibuffer.
4180 Emacs cannot create minibufferless frames unless this is set to an
4181 appropriate surrogate.
4183 Emacs consults this variable only when creating minibufferless
4184 frames; once the frame is created, it sticks with its assigned
4185 minibuffer, no matter what this variable is set to. This means that
4186 this variable doesn't necessarily say anything meaningful about the
4187 current set of frames, or where the minibuffer is currently being
4190 This variable is local to the current terminal and cannot be buffer-local. */);
4192 staticpro (&Vframe_list
);
4194 defsubr (&Sactive_minibuffer_window
);
4196 defsubr (&Sframe_live_p
);
4197 defsubr (&Smake_terminal_frame
);
4198 defsubr (&Shandle_switch_frame
);
4199 defsubr (&Signore_event
);
4200 defsubr (&Sselect_frame
);
4201 defsubr (&Sselected_frame
);
4202 defsubr (&Swindow_frame
);
4203 defsubr (&Sframe_root_window
);
4204 defsubr (&Sframe_first_window
);
4205 defsubr (&Sframe_selected_window
);
4206 defsubr (&Sset_frame_selected_window
);
4207 defsubr (&Sframe_list
);
4208 defsubr (&Snext_frame
);
4209 defsubr (&Sprevious_frame
);
4210 defsubr (&Sdelete_frame
);
4211 defsubr (&Smouse_position
);
4212 defsubr (&Smouse_pixel_position
);
4213 defsubr (&Sset_mouse_position
);
4214 defsubr (&Sset_mouse_pixel_position
);
4216 defsubr (&Sframe_configuration
);
4217 defsubr (&Srestore_frame_configuration
);
4219 defsubr (&Smake_frame_visible
);
4220 defsubr (&Smake_frame_invisible
);
4221 defsubr (&Siconify_frame
);
4222 defsubr (&Sframe_visible_p
);
4223 defsubr (&Svisible_frame_list
);
4224 defsubr (&Sraise_frame
);
4225 defsubr (&Slower_frame
);
4226 defsubr (&Sredirect_frame_focus
);
4227 defsubr (&Sframe_focus
);
4228 defsubr (&Sframe_parameters
);
4229 defsubr (&Sframe_parameter
);
4230 defsubr (&Smodify_frame_parameters
);
4231 defsubr (&Sframe_char_height
);
4232 defsubr (&Sframe_char_width
);
4233 defsubr (&Sframe_pixel_height
);
4234 defsubr (&Sframe_pixel_width
);
4235 defsubr (&Sset_frame_height
);
4236 defsubr (&Sset_frame_width
);
4237 defsubr (&Sset_frame_size
);
4238 defsubr (&Sset_frame_position
);
4240 #ifdef HAVE_WINDOW_SYSTEM
4241 defsubr (&Sx_get_resource
);
4242 defsubr (&Sx_parse_geometry
);
4247 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4248 (do not change this comment) */