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 "termhooks.h"
46 #include "dispextern.h"
54 #ifdef HAVE_WINDOW_SYSTEM
56 /* The name we're using in resource queries. Most often "emacs". */
58 Lisp_Object Vx_resource_name
;
60 /* The application class we're using in resource queries.
63 Lisp_Object Vx_resource_class
;
67 Lisp_Object Qframep
, Qframe_live_p
;
68 Lisp_Object Qicon
, Qmodeline
;
70 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
;
72 Lisp_Object Qdisplay_type
;
73 Lisp_Object Qbackground_mode
;
74 Lisp_Object Qinhibit_default_face_x_resources
;
76 Lisp_Object Qx_frame_parameter
;
77 Lisp_Object Qx_resource_name
;
79 /* Frame parameters (set or reported). */
81 Lisp_Object Qauto_raise
, Qauto_lower
;
82 Lisp_Object Qborder_color
, Qborder_width
;
83 Lisp_Object Qcursor_color
, Qcursor_type
;
84 Lisp_Object Qgeometry
; /* Not used */
85 Lisp_Object Qheight
, Qwidth
;
86 Lisp_Object Qleft
, Qright
;
87 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
88 Lisp_Object Qinternal_border_width
;
89 Lisp_Object Qmouse_color
;
90 Lisp_Object Qminibuffer
;
91 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
92 Lisp_Object Qvisibility
;
93 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
94 Lisp_Object Qscreen_gamma
;
95 Lisp_Object Qline_spacing
;
96 Lisp_Object Quser_position
, Quser_size
;
97 Lisp_Object Qwait_for_wm
;
98 Lisp_Object Qwindow_id
;
100 Lisp_Object Qouter_window_id
;
102 Lisp_Object Qparent_id
;
103 Lisp_Object Qtitle
, Qname
;
104 Lisp_Object Qunsplittable
;
105 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
106 Lisp_Object Qleft_fringe
, Qright_fringe
;
107 Lisp_Object Qbuffer_predicate
, Qbuffer_list
;
108 Lisp_Object Qtty_color_mode
;
110 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
;
112 Lisp_Object Qface_set_after_frame_default
;
115 Lisp_Object Vterminal_frame
;
116 Lisp_Object Vdefault_frame_alist
;
117 Lisp_Object Vdefault_frame_scroll_bars
;
118 Lisp_Object Vmouse_position_function
;
119 Lisp_Object Vmouse_highlight
;
120 Lisp_Object Vdelete_frame_functions
;
123 set_menu_bar_lines_1 (window
, n
)
127 struct window
*w
= XWINDOW (window
);
129 XSETFASTINT (w
->last_modified
, 0);
130 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
131 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
133 if (INTEGERP (w
->orig_top_line
))
134 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
135 if (INTEGERP (w
->orig_total_lines
))
136 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
138 /* Handle just the top child in a vertical split. */
139 if (!NILP (w
->vchild
))
140 set_menu_bar_lines_1 (w
->vchild
, n
);
142 /* Adjust all children in a horizontal split. */
143 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
145 w
= XWINDOW (window
);
146 set_menu_bar_lines_1 (window
, n
);
151 set_menu_bar_lines (f
, value
, oldval
)
153 Lisp_Object value
, oldval
;
156 int olines
= FRAME_MENU_BAR_LINES (f
);
158 /* Right now, menu bars don't work properly in minibuf-only frames;
159 most of the commands try to apply themselves to the minibuffer
160 frame itself, and get an error because you can't switch buffers
161 in or split the minibuffer window. */
162 if (FRAME_MINIBUF_ONLY_P (f
))
165 if (INTEGERP (value
))
166 nlines
= XINT (value
);
170 if (nlines
!= olines
)
172 windows_or_buffers_changed
++;
173 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
174 FRAME_MENU_BAR_LINES (f
) = nlines
;
175 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
180 Lisp_Object Vemacs_iconified
;
181 Lisp_Object Vframe_list
;
183 struct x_output tty_display
;
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 the terminal (stdin and stdout). */
479 static int terminal_frame_count
;
482 make_terminal_frame ()
484 register struct frame
*f
;
491 initial_kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
492 init_kboard (initial_kboard
);
493 initial_kboard
->next_kboard
= all_kboards
;
494 all_kboards
= initial_kboard
;
498 /* The first call must initialize Vframe_list. */
499 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
504 XSETFRAME (frame
, f
);
505 Vframe_list
= Fcons (frame
, Vframe_list
);
507 terminal_frame_count
++;
508 sprintf (name
, "F%d", terminal_frame_count
);
509 f
->name
= build_string (name
);
511 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
512 f
->async_visible
= 1; /* Don't let visible be cleared later. */
514 f
->output_data
.x
= &the_only_x_display
;
515 if (!inhibit_window_system
516 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
517 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
519 f
->output_method
= output_msdos_raw
;
520 /* This initialization of foreground and background pixels is
521 only important for the initial frame created in temacs. If
522 we don't do that, we get black background and foreground in
523 the dumped Emacs because the_only_x_display is a static
524 variable, hence it is born all-zeroes, and zero is the code
525 for the black color. Other frames all inherit their pixels
526 from what's already in the_only_x_display. */
527 if ((!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
528 && f
->output_data
.x
->background_pixel
== 0
529 && f
->output_data
.x
->foreground_pixel
== 0)
531 f
->output_data
.x
->background_pixel
= FACE_TTY_DEFAULT_BG_COLOR
;
532 f
->output_data
.x
->foreground_pixel
= FACE_TTY_DEFAULT_FG_COLOR
;
536 f
->output_method
= output_termcap
;
539 f
->output_method
= output_termcap
;
540 f
->output_data
.x
= &tty_display
;
543 make_mac_terminal_frame (f
);
545 f
->output_data
.x
= &tty_display
;
547 FRAME_FOREGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_FG_COLOR
;
548 FRAME_BACKGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_BG_COLOR
;
551 #endif /* WINDOWSNT */
555 init_frame_faces (f
);
560 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
562 doc
: /* Create an additional terminal frame.
563 You can create multiple frames on a text-only terminal in this way.
564 Only the selected terminal frame is actually displayed.
565 This function takes one argument, an alist specifying frame parameters.
566 In practice, generally you don't need to specify any parameters.
567 Note that changing the size of one terminal frame automatically affects all. */)
572 Lisp_Object frame
, tem
;
573 struct frame
*sf
= SELECTED_FRAME ();
576 if (sf
->output_method
!= output_msdos_raw
577 && sf
->output_method
!= output_termcap
)
579 #else /* not MSDOS */
582 if (sf
->output_method
!= output_mac
)
583 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
585 if (sf
->output_method
!= output_termcap
)
586 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
588 #endif /* not MSDOS */
590 f
= make_terminal_frame ();
592 change_frame_size (f
, FRAME_LINES (sf
),
593 FRAME_COLS (sf
), 0, 0, 0);
596 XSETFRAME (frame
, f
);
597 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
598 Fmodify_frame_parameters (frame
, parms
);
600 /* Make the frame face alist be frame-specific, so that each
601 frame could change its face definitions independently. */
602 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
603 /* Simple Fcopy_alist isn't enough, because we need the contents of
604 the vectors which are the CDRs of associations in face_alist to
605 be copied as well. */
606 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
607 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
612 /* Perform the switch to frame FRAME.
614 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
617 If TRACK is non-zero and the frame that currently has the focus
618 redirects its focus to the selected frame, redirect that focused
619 frame's focus to FRAME instead.
621 FOR_DELETION non-zero means that the selected frame is being
622 deleted, which includes the possibility that the frame's display
626 do_switch_frame (frame
, track
, for_deletion
)
628 int track
, for_deletion
;
630 struct frame
*sf
= SELECTED_FRAME ();
632 /* If FRAME is a switch-frame event, extract the frame we should
635 && EQ (XCAR (frame
), Qswitch_frame
)
636 && CONSP (XCDR (frame
)))
637 frame
= XCAR (XCDR (frame
));
639 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
640 a switch-frame event to arrive after a frame is no longer live,
641 especially when deleting the initial frame during startup. */
643 if (! FRAME_LIVE_P (XFRAME (frame
)))
646 if (sf
== XFRAME (frame
))
649 /* This is too greedy; it causes inappropriate focus redirection
650 that's hard to get rid of. */
652 /* If a frame's focus has been redirected toward the currently
653 selected frame, we should change the redirection to point to the
654 newly selected frame. This means that if the focus is redirected
655 from a minibufferless frame to a surrogate minibuffer frame, we
656 can use `other-window' to switch between all the frames using
657 that minibuffer frame, and the focus redirection will follow us
663 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
667 if (!FRAMEP (XCAR (tail
)))
670 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
672 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
673 Fredirect_frame_focus (XCAR (tail
), frame
);
677 /* Instead, apply it only to the frame we're pointing to. */
678 #ifdef HAVE_WINDOW_SYSTEM
679 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
681 Lisp_Object focus
, xfocus
;
683 xfocus
= x_get_focus_frame (XFRAME (frame
));
686 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
687 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
688 Fredirect_frame_focus (xfocus
, frame
);
691 #endif /* HAVE_X_WINDOWS */
694 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
695 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
697 selected_frame
= frame
;
698 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
699 last_nonminibuf_frame
= XFRAME (selected_frame
);
701 Fselect_window (XFRAME (frame
)->selected_window
, Qnil
);
704 /* Make sure to switch the tty color mode to that of the newly
706 sf
= SELECTED_FRAME ();
707 if (FRAME_TERMCAP_P (sf
))
709 Lisp_Object color_mode_spec
, color_mode
;
711 color_mode_spec
= assq_no_quit (Qtty_color_mode
, sf
->param_alist
);
712 if (CONSP (color_mode_spec
))
713 color_mode
= XCDR (color_mode_spec
);
715 color_mode
= make_number (0);
716 set_tty_color_mode (sf
, color_mode
);
718 #endif /* !WINDOWSNT */
720 /* We want to make sure that the next event generates a frame-switch
721 event to the appropriate frame. This seems kludgy to me, but
722 before you take it out, make sure that evaluating something like
723 (select-window (frame-root-window (new-frame))) doesn't end up
724 with your typing being interpreted in the new frame instead of
725 the one you're actually typing in. */
726 internal_last_event_frame
= Qnil
;
731 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
732 doc
: /* Select the frame FRAME.
733 Subsequent editing commands apply to its selected window.
734 The selection of FRAME lasts until the next time the user does
735 something to select a different frame, or until the next time this
736 function is called. */)
738 Lisp_Object frame
, no_enter
;
740 return do_switch_frame (frame
, 1, 0);
744 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 2, "e",
745 doc
: /* Handle a switch-frame event EVENT.
746 Switch-frame events are usually bound to this function.
747 A switch-frame event tells Emacs that the window manager has requested
748 that the user's events be directed to the frame mentioned in the event.
749 This function selects the selected window of the frame of EVENT.
751 If EVENT is frame object, handle it as if it were a switch-frame event
754 Lisp_Object event
, no_enter
;
756 /* Preserve prefix arg that the command loop just cleared. */
757 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
758 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
759 return do_switch_frame (event
, 0, 0);
762 DEFUN ("ignore-event", Fignore_event
, Signore_event
, 0, 0, "",
763 doc
: /* Do nothing, but preserve any prefix argument already specified.
764 This is a suitable binding for `iconify-frame' and `make-frame-visible'. */)
767 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
771 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
772 doc
: /* Return the frame that is now selected. */)
775 return selected_frame
;
778 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
779 doc
: /* Return the frame object that window WINDOW is on. */)
783 CHECK_LIVE_WINDOW (window
);
784 return XWINDOW (window
)->frame
;
787 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
788 doc
: /* Returns the topmost, leftmost window of FRAME.
789 If omitted, FRAME defaults to the currently selected frame. */)
796 w
= SELECTED_FRAME ()->root_window
;
799 CHECK_LIVE_FRAME (frame
);
800 w
= XFRAME (frame
)->root_window
;
802 while (NILP (XWINDOW (w
)->buffer
))
804 if (! NILP (XWINDOW (w
)->hchild
))
805 w
= XWINDOW (w
)->hchild
;
806 else if (! NILP (XWINDOW (w
)->vchild
))
807 w
= XWINDOW (w
)->vchild
;
814 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
815 Sactive_minibuffer_window
, 0, 0, 0,
816 doc
: /* Return the currently active minibuffer window, or nil if none. */)
819 return minibuf_level
? minibuf_window
: Qnil
;
822 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
823 doc
: /* Returns the root-window of FRAME.
824 If omitted, FRAME defaults to the currently selected frame. */)
831 window
= SELECTED_FRAME ()->root_window
;
834 CHECK_LIVE_FRAME (frame
);
835 window
= XFRAME (frame
)->root_window
;
841 DEFUN ("frame-selected-window", Fframe_selected_window
,
842 Sframe_selected_window
, 0, 1, 0,
843 doc
: /* Return the selected window of frame object FRAME.
844 If omitted, FRAME defaults to the currently selected frame. */)
851 window
= SELECTED_FRAME ()->selected_window
;
854 CHECK_LIVE_FRAME (frame
);
855 window
= XFRAME (frame
)->selected_window
;
861 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
862 Sset_frame_selected_window
, 2, 2, 0,
863 doc
: /* Set the selected window of frame object FRAME to WINDOW.
864 If FRAME is nil, the selected frame is used.
865 If FRAME is the selected frame, this makes WINDOW the selected window. */)
867 Lisp_Object frame
, window
;
870 frame
= selected_frame
;
872 CHECK_LIVE_FRAME (frame
);
873 CHECK_LIVE_WINDOW (window
);
875 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
876 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
878 if (EQ (frame
, selected_frame
))
879 return Fselect_window (window
, Qnil
);
881 return XFRAME (frame
)->selected_window
= window
;
884 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
886 doc
: /* Return a list of all frames. */)
890 frames
= Fcopy_sequence (Vframe_list
);
891 #ifdef HAVE_WINDOW_SYSTEM
892 if (FRAMEP (tip_frame
))
893 frames
= Fdelq (tip_frame
, frames
);
898 /* Return the next frame in the frame list after FRAME.
899 If MINIBUF is nil, exclude minibuffer-only frames.
900 If MINIBUF is a window, include only its own frame
901 and any frame now using that window as the minibuffer.
902 If MINIBUF is `visible', include all visible frames.
903 If MINIBUF is 0, include all visible and iconified frames.
904 Otherwise, include all frames. */
907 next_frame (frame
, minibuf
)
914 /* There must always be at least one frame in Vframe_list. */
915 if (! CONSP (Vframe_list
))
918 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
919 forever. Forestall that. */
920 CHECK_LIVE_FRAME (frame
);
923 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
930 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
932 /* Decide whether this frame is eligible to be returned. */
934 /* If we've looped all the way around without finding any
935 eligible frames, return the original frame. */
939 /* Let minibuf decide if this frame is acceptable. */
942 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
945 else if (EQ (minibuf
, Qvisible
))
947 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
948 if (FRAME_VISIBLE_P (XFRAME (f
)))
951 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
953 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
954 if (FRAME_VISIBLE_P (XFRAME (f
))
955 || FRAME_ICONIFIED_P (XFRAME (f
)))
958 else if (WINDOWP (minibuf
))
960 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
961 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
962 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
963 FRAME_FOCUS_FRAME (XFRAME (f
))))
975 /* Return the previous frame in the frame list before FRAME.
976 If MINIBUF is nil, exclude minibuffer-only frames.
977 If MINIBUF is a window, include only its own frame
978 and any frame now using that window as the minibuffer.
979 If MINIBUF is `visible', include all visible frames.
980 If MINIBUF is 0, include all visible and iconified frames.
981 Otherwise, include all frames. */
984 prev_frame (frame
, minibuf
)
991 /* There must always be at least one frame in Vframe_list. */
992 if (! CONSP (Vframe_list
))
996 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1004 if (EQ (frame
, f
) && !NILP (prev
))
1007 if (FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1009 /* Decide whether this frame is eligible to be returned,
1010 according to minibuf. */
1013 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1016 else if (WINDOWP (minibuf
))
1018 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1019 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1020 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1021 FRAME_FOCUS_FRAME (XFRAME (f
))))
1024 else if (EQ (minibuf
, Qvisible
))
1026 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1027 if (FRAME_VISIBLE_P (XFRAME (f
)))
1030 else if (XFASTINT (minibuf
) == 0)
1032 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1033 if (FRAME_VISIBLE_P (XFRAME (f
))
1034 || FRAME_ICONIFIED_P (XFRAME (f
)))
1042 /* We've scanned the entire list. */
1044 /* We went through the whole frame list without finding a single
1045 acceptable frame. Return the original frame. */
1048 /* There were no acceptable frames in the list before FRAME; otherwise,
1049 we would have returned directly from the loop. Since PREV is the last
1050 acceptable frame in the list, return it. */
1055 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1056 doc
: /* Return the next frame in the frame list after FRAME.
1057 It considers only frames on the same terminal as FRAME.
1058 By default, skip minibuffer-only frames.
1059 If omitted, FRAME defaults to the selected frame.
1060 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1061 If MINIFRAME is a window, include only its own frame
1062 and any frame now using that window as the minibuffer.
1063 If MINIFRAME is `visible', include all visible frames.
1064 If MINIFRAME is 0, include all visible and iconified frames.
1065 Otherwise, include all frames. */)
1067 Lisp_Object frame
, miniframe
;
1070 frame
= selected_frame
;
1072 CHECK_LIVE_FRAME (frame
);
1073 return next_frame (frame
, miniframe
);
1076 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1077 doc
: /* Return the previous frame in the frame list before FRAME.
1078 It considers only frames on the same terminal as FRAME.
1079 By default, skip minibuffer-only frames.
1080 If omitted, FRAME defaults to the selected frame.
1081 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1082 If MINIFRAME is a window, include only its own frame
1083 and any frame now using that window as the minibuffer.
1084 If MINIFRAME is `visible', include all visible frames.
1085 If MINIFRAME is 0, include all visible and iconified frames.
1086 Otherwise, include all frames. */)
1088 Lisp_Object frame
, miniframe
;
1091 frame
= selected_frame
;
1092 CHECK_LIVE_FRAME (frame
);
1093 return prev_frame (frame
, miniframe
);
1096 /* Return 1 if it is ok to delete frame F;
1097 0 if all frames aside from F are invisible.
1098 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1101 other_visible_frames (f
)
1104 /* We know the selected frame is visible,
1105 so if F is some other frame, it can't be the sole visible one. */
1106 if (f
== SELECTED_FRAME ())
1111 for (frames
= Vframe_list
;
1113 frames
= XCDR (frames
))
1117 this = XCAR (frames
);
1118 /* Verify that the frame's window still exists
1119 and we can still talk to it. And note any recent change
1121 #ifdef HAVE_WINDOW_SYSTEM
1122 if (FRAME_WINDOW_P (XFRAME (this)))
1124 x_sync (XFRAME (this));
1125 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1129 if (FRAME_VISIBLE_P (XFRAME (this))
1130 || FRAME_ICONIFIED_P (XFRAME (this))
1131 /* Allow deleting the terminal frame when at least
1132 one X frame exists! */
1133 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1141 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1142 doc
: /* Delete FRAME, permanently eliminating it from use.
1143 If omitted, FRAME defaults to the selected frame.
1144 A frame may not be deleted if its minibuffer is used by other frames.
1145 Normally, you may not delete a frame if all other frames are invisible,
1146 but if the second optional argument FORCE is non-nil, you may do so.
1148 This function runs `delete-frame-functions' before actually deleting the
1149 frame, unless the frame is a tooltip.
1150 The functions are run with one arg, the frame to be deleted. */)
1152 Lisp_Object frame
, force
;
1155 struct frame
*sf
= SELECTED_FRAME ();
1156 int minibuffer_selected
;
1158 if (EQ (frame
, Qnil
))
1161 XSETFRAME (frame
, f
);
1165 CHECK_FRAME (frame
);
1169 if (! FRAME_LIVE_P (f
))
1172 if (NILP (force
) && !other_visible_frames (f
)
1174 /* Terminal frame deleted before any other visible frames are
1176 && strcmp (SDATA (f
->name
), "F1") != 0
1179 error ("Attempt to delete the sole visible or iconified frame");
1182 /* This is a nice idea, but x_connection_closed needs to be able
1183 to delete the last frame, if it is gone. */
1184 if (NILP (XCDR (Vframe_list
)))
1185 error ("Attempt to delete the only frame");
1188 /* Does this frame have a minibuffer, and is it the surrogate
1189 minibuffer for any other frame? */
1190 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1194 for (frames
= Vframe_list
;
1196 frames
= XCDR (frames
))
1199 this = XCAR (frames
);
1201 if (! EQ (this, frame
)
1203 WINDOW_FRAME (XWINDOW
1204 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1205 error ("Attempt to delete a surrogate minibuffer frame");
1209 /* Run `delete-frame-functions' unless frame is a tooltip. */
1210 if (!NILP (Vrun_hooks
)
1211 && NILP (Fframe_parameter (frame
, intern ("tooltip"))))
1213 Lisp_Object args
[2];
1214 args
[0] = intern ("delete-frame-functions");
1216 Frun_hook_with_args (2, args
);
1219 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1221 /* Don't let the frame remain selected. */
1224 Lisp_Object tail
, frame1
;
1226 /* Look for another visible frame on the same terminal. */
1227 frame1
= next_frame (frame
, Qvisible
);
1229 /* If there is none, find *some* other frame. */
1230 if (NILP (frame1
) || EQ (frame1
, frame
))
1232 FOR_EACH_FRAME (tail
, frame1
)
1234 if (! EQ (frame
, frame1
))
1239 do_switch_frame (frame1
, 0, 1);
1240 sf
= SELECTED_FRAME ();
1243 /* Don't allow minibuf_window to remain on a deleted frame. */
1244 if (EQ (f
->minibuffer_window
, minibuf_window
))
1246 Fset_window_buffer (sf
->minibuffer_window
,
1247 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1248 minibuf_window
= sf
->minibuffer_window
;
1250 /* If the dying minibuffer window was selected,
1251 select the new one. */
1252 if (minibuffer_selected
)
1253 Fselect_window (minibuf_window
, Qnil
);
1256 /* Don't let echo_area_window to remain on a deleted frame. */
1257 if (EQ (f
->minibuffer_window
, echo_area_window
))
1258 echo_area_window
= sf
->minibuffer_window
;
1260 /* Clear any X selections for this frame. */
1261 #ifdef HAVE_X_WINDOWS
1263 x_clear_frame_selections (f
);
1267 This function must be called before the window tree of the
1268 frame is deleted because windows contain dynamically allocated
1272 /* Mark all the windows that used to be on FRAME as deleted, and then
1273 remove the reference to them. */
1274 delete_all_subwindows (XWINDOW (f
->root_window
));
1275 f
->root_window
= Qnil
;
1277 Vframe_list
= Fdelq (frame
, Vframe_list
);
1278 FRAME_SET_VISIBLE (f
, 0);
1282 if (f
->decode_mode_spec_buffer
)
1283 xfree (f
->decode_mode_spec_buffer
);
1284 if (FRAME_INSERT_COST (f
))
1285 xfree (FRAME_INSERT_COST (f
));
1286 if (FRAME_DELETEN_COST (f
))
1287 xfree (FRAME_DELETEN_COST (f
));
1288 if (FRAME_INSERTN_COST (f
))
1289 xfree (FRAME_INSERTN_COST (f
));
1290 if (FRAME_DELETE_COST (f
))
1291 xfree (FRAME_DELETE_COST (f
));
1292 if (FRAME_MESSAGE_BUF (f
))
1293 xfree (FRAME_MESSAGE_BUF (f
));
1295 /* Since some events are handled at the interrupt level, we may get
1296 an event for f at any time; if we zero out the frame's display
1297 now, then we may trip up the event-handling code. Instead, we'll
1298 promise that the display of the frame must be valid until we have
1299 called the window-system-dependent frame destruction routine. */
1301 /* I think this should be done with a hook. */
1302 #ifdef HAVE_WINDOW_SYSTEM
1303 if (FRAME_WINDOW_P (f
))
1304 x_destroy_window (f
);
1307 f
->output_data
.nothing
= 0;
1309 /* If we've deleted the last_nonminibuf_frame, then try to find
1311 if (f
== last_nonminibuf_frame
)
1315 last_nonminibuf_frame
= 0;
1317 for (frames
= Vframe_list
;
1319 frames
= XCDR (frames
))
1321 f
= XFRAME (XCAR (frames
));
1322 if (!FRAME_MINIBUF_ONLY_P (f
))
1324 last_nonminibuf_frame
= f
;
1330 /* If there's no other frame on the same kboard, get out of
1331 single-kboard state if we're in it for this kboard. */
1334 /* Some frame we found on the same kboard, or nil if there are none. */
1335 Lisp_Object frame_on_same_kboard
;
1337 frame_on_same_kboard
= Qnil
;
1339 for (frames
= Vframe_list
;
1341 frames
= XCDR (frames
))
1346 this = XCAR (frames
);
1351 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1352 frame_on_same_kboard
= this;
1355 if (NILP (frame_on_same_kboard
))
1356 not_single_kboard_state (FRAME_KBOARD (f
));
1360 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1361 find another one. Prefer minibuffer-only frames, but also notice
1362 frames with other windows. */
1363 if (EQ (frame
, FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
))
1367 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1368 Lisp_Object frame_with_minibuf
;
1369 /* Some frame we found on the same kboard, or nil if there are none. */
1370 Lisp_Object frame_on_same_kboard
;
1372 frame_on_same_kboard
= Qnil
;
1373 frame_with_minibuf
= Qnil
;
1375 for (frames
= Vframe_list
;
1377 frames
= XCDR (frames
))
1382 this = XCAR (frames
);
1387 /* Consider only frames on the same kboard
1388 and only those with minibuffers. */
1389 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
)
1390 && FRAME_HAS_MINIBUF_P (f1
))
1392 frame_with_minibuf
= this;
1393 if (FRAME_MINIBUF_ONLY_P (f1
))
1397 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1398 frame_on_same_kboard
= this;
1401 if (!NILP (frame_on_same_kboard
))
1403 /* We know that there must be some frame with a minibuffer out
1404 there. If this were not true, all of the frames present
1405 would have to be minibufferless, which implies that at some
1406 point their minibuffer frames must have been deleted, but
1407 that is prohibited at the top; you can't delete surrogate
1408 minibuffer frames. */
1409 if (NILP (frame_with_minibuf
))
1412 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1415 /* No frames left on this kboard--say no minibuffer either. */
1416 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= Qnil
;
1419 /* Cause frame titles to update--necessary if we now have just one frame. */
1420 update_mode_lines
= 1;
1425 /* Return mouse position in character cell units. */
1427 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1428 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1429 The position is given in character cells, where (0, 0) is the
1431 If Emacs is running on a mouseless terminal or hasn't been programmed
1432 to read the mouse position, it returns the selected frame for FRAME
1433 and nil for X and Y.
1434 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1435 passing the normal return value to that function as an argument,
1436 and returns whatever that function returns. */)
1440 Lisp_Object lispy_dummy
;
1441 enum scroll_bar_part party_dummy
;
1442 Lisp_Object x
, y
, retval
;
1444 unsigned long long_dummy
;
1445 struct gcpro gcpro1
;
1447 f
= SELECTED_FRAME ();
1451 /* It's okay for the hook to refrain from storing anything. */
1452 if (mouse_position_hook
)
1453 (*mouse_position_hook
) (&f
, -1,
1454 &lispy_dummy
, &party_dummy
,
1461 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1466 XSETFRAME (lispy_dummy
, f
);
1467 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1469 if (!NILP (Vmouse_position_function
))
1470 retval
= call1 (Vmouse_position_function
, retval
);
1471 RETURN_UNGCPRO (retval
);
1474 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1475 Smouse_pixel_position
, 0, 0, 0,
1476 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1477 The position is given in pixel units, where (0, 0) is the
1479 If Emacs is running on a mouseless terminal or hasn't been programmed
1480 to read the mouse position, it returns the selected frame for FRAME
1481 and nil for X and Y. */)
1485 Lisp_Object lispy_dummy
;
1486 enum scroll_bar_part party_dummy
;
1488 unsigned long long_dummy
;
1490 f
= SELECTED_FRAME ();
1494 /* It's okay for the hook to refrain from storing anything. */
1495 if (mouse_position_hook
)
1496 (*mouse_position_hook
) (&f
, -1,
1497 &lispy_dummy
, &party_dummy
,
1501 XSETFRAME (lispy_dummy
, f
);
1502 return Fcons (lispy_dummy
, Fcons (x
, y
));
1505 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1506 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1507 Coordinates are relative to the frame, not a window,
1508 so the coordinates of the top left character in the frame
1509 may be nonzero due to left-hand scroll bars or the menu bar.
1511 This function is a no-op for an X frame that is not visible.
1512 If you have just created a frame, you must wait for it to become visible
1513 before calling this function on it, like this.
1514 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1516 Lisp_Object frame
, x
, y
;
1518 CHECK_LIVE_FRAME (frame
);
1522 /* I think this should be done with a hook. */
1523 #ifdef HAVE_WINDOW_SYSTEM
1524 if (FRAME_WINDOW_P (XFRAME (frame
)))
1525 /* Warping the mouse will cause enternotify and focus events. */
1526 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1528 #if defined (MSDOS) && defined (HAVE_MOUSE)
1529 if (FRAME_MSDOS_P (XFRAME (frame
)))
1531 Fselect_frame (frame
, Qnil
);
1532 mouse_moveto (XINT (x
), XINT (y
));
1540 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1541 Sset_mouse_pixel_position
, 3, 3, 0,
1542 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1543 Note, this is a no-op for an X frame that is not visible.
1544 If you have just created a frame, you must wait for it to become visible
1545 before calling this function on it, like this.
1546 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1548 Lisp_Object frame
, x
, y
;
1550 CHECK_LIVE_FRAME (frame
);
1554 /* I think this should be done with a hook. */
1555 #ifdef HAVE_WINDOW_SYSTEM
1556 if (FRAME_WINDOW_P (XFRAME (frame
)))
1557 /* Warping the mouse will cause enternotify and focus events. */
1558 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1560 #if defined (MSDOS) && defined (HAVE_MOUSE)
1561 if (FRAME_MSDOS_P (XFRAME (frame
)))
1563 Fselect_frame (frame
, Qnil
);
1564 mouse_moveto (XINT (x
), XINT (y
));
1572 static void make_frame_visible_1
P_ ((Lisp_Object
));
1574 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1576 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1577 If omitted, FRAME defaults to the currently selected frame. */)
1582 frame
= selected_frame
;
1584 CHECK_LIVE_FRAME (frame
);
1586 /* I think this should be done with a hook. */
1587 #ifdef HAVE_WINDOW_SYSTEM
1588 if (FRAME_WINDOW_P (XFRAME (frame
)))
1590 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1591 x_make_frame_visible (XFRAME (frame
));
1595 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1597 /* Make menu bar update for the Buffers and Frames menus. */
1598 windows_or_buffers_changed
++;
1603 /* Update the display_time slot of the buffers shown in WINDOW
1604 and all its descendents. */
1607 make_frame_visible_1 (window
)
1612 for (;!NILP (window
); window
= w
->next
)
1614 w
= XWINDOW (window
);
1616 if (!NILP (w
->buffer
))
1617 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1619 if (!NILP (w
->vchild
))
1620 make_frame_visible_1 (w
->vchild
);
1621 if (!NILP (w
->hchild
))
1622 make_frame_visible_1 (w
->hchild
);
1626 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1628 doc
: /* Make the frame FRAME invisible (assuming it is an X window).
1629 If omitted, FRAME defaults to the currently selected frame.
1630 Normally you may not make FRAME invisible if all other frames are invisible,
1631 but if the second optional argument FORCE is non-nil, you may do so. */)
1633 Lisp_Object frame
, force
;
1636 frame
= selected_frame
;
1638 CHECK_LIVE_FRAME (frame
);
1640 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1641 error ("Attempt to make invisible the sole visible or iconified frame");
1643 #if 0 /* This isn't logically necessary, and it can do GC. */
1644 /* Don't let the frame remain selected. */
1645 if (EQ (frame
, selected_frame
))
1646 do_switch_frame (next_frame (frame
, Qt
), 0, 0)
1649 /* Don't allow minibuf_window to remain on a deleted frame. */
1650 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1652 struct frame
*sf
= XFRAME (selected_frame
);
1653 Fset_window_buffer (sf
->minibuffer_window
,
1654 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1655 minibuf_window
= sf
->minibuffer_window
;
1658 /* I think this should be done with a hook. */
1659 #ifdef HAVE_WINDOW_SYSTEM
1660 if (FRAME_WINDOW_P (XFRAME (frame
)))
1661 x_make_frame_invisible (XFRAME (frame
));
1664 /* Make menu bar update for the Buffers and Frames menus. */
1665 windows_or_buffers_changed
++;
1670 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1672 doc
: /* Make the frame FRAME into an icon.
1673 If omitted, FRAME defaults to the currently selected frame. */)
1678 frame
= selected_frame
;
1680 CHECK_LIVE_FRAME (frame
);
1682 #if 0 /* This isn't logically necessary, and it can do GC. */
1683 /* Don't let the frame remain selected. */
1684 if (EQ (frame
, selected_frame
))
1685 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1688 /* Don't allow minibuf_window to remain on a deleted frame. */
1689 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1691 struct frame
*sf
= XFRAME (selected_frame
);
1692 Fset_window_buffer (sf
->minibuffer_window
,
1693 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1694 minibuf_window
= sf
->minibuffer_window
;
1697 /* I think this should be done with a hook. */
1698 #ifdef HAVE_WINDOW_SYSTEM
1699 if (FRAME_WINDOW_P (XFRAME (frame
)))
1700 x_iconify_frame (XFRAME (frame
));
1703 /* Make menu bar update for the Buffers and Frames menus. */
1704 windows_or_buffers_changed
++;
1709 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1711 doc
: /* Return t if FRAME is now \"visible\" (actually in use for display).
1712 A frame that is not \"visible\" is not updated and, if it works through
1713 a window system, it may not show at all.
1714 Return the symbol `icon' if frame is visible only as an icon. */)
1718 CHECK_LIVE_FRAME (frame
);
1720 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1722 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1724 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1729 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1731 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1734 Lisp_Object tail
, frame
;
1739 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1741 frame
= XCAR (tail
);
1742 if (!FRAMEP (frame
))
1745 if (FRAME_VISIBLE_P (f
))
1746 value
= Fcons (frame
, value
);
1752 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1753 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1754 If FRAME is invisible, make it visible.
1755 If you don't specify a frame, the selected frame is used.
1756 If Emacs is displaying on an ordinary terminal or some other device which
1757 doesn't support multiple overlapping frames, this function does nothing. */)
1762 frame
= selected_frame
;
1764 CHECK_LIVE_FRAME (frame
);
1766 /* Do like the documentation says. */
1767 Fmake_frame_visible (frame
);
1769 if (frame_raise_lower_hook
)
1770 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1775 /* Should we have a corresponding function called Flower_Power? */
1776 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1777 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1778 If you don't specify a frame, the selected frame is used.
1779 If Emacs is displaying on an ordinary terminal or some other device which
1780 doesn't support multiple overlapping frames, this function does nothing. */)
1785 frame
= selected_frame
;
1787 CHECK_LIVE_FRAME (frame
);
1789 if (frame_raise_lower_hook
)
1790 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1796 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1798 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1799 In other words, switch-frame events caused by events in FRAME will
1800 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1801 FOCUS-FRAME after reading an event typed at FRAME.
1803 If FOCUS-FRAME is omitted or nil, any existing redirection is
1804 cancelled, and the frame again receives its own keystrokes.
1806 Focus redirection is useful for temporarily redirecting keystrokes to
1807 a surrogate minibuffer frame when a frame doesn't have its own
1810 A frame's focus redirection can be changed by select-frame. If frame
1811 FOO is selected, and then a different frame BAR is selected, any
1812 frames redirecting their focus to FOO are shifted to redirect their
1813 focus to BAR. This allows focus redirection to work properly when the
1814 user switches from one frame to another using `select-window'.
1816 This means that a frame whose focus is redirected to itself is treated
1817 differently from a frame whose focus is redirected to nil; the former
1818 is affected by select-frame, while the latter is not.
1820 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1821 (frame
, focus_frame
)
1822 Lisp_Object frame
, focus_frame
;
1824 /* Note that we don't check for a live frame here. It's reasonable
1825 to redirect the focus of a frame you're about to delete, if you
1826 know what other frame should receive those keystrokes. */
1827 CHECK_FRAME (frame
);
1829 if (! NILP (focus_frame
))
1830 CHECK_LIVE_FRAME (focus_frame
);
1832 XFRAME (frame
)->focus_frame
= focus_frame
;
1834 if (frame_rehighlight_hook
)
1835 (*frame_rehighlight_hook
) (XFRAME (frame
));
1841 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1842 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1843 This returns nil if FRAME's focus is not redirected.
1844 See `redirect-frame-focus'. */)
1848 CHECK_LIVE_FRAME (frame
);
1850 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1855 /* Return the value of frame parameter PROP in frame FRAME. */
1858 get_frame_param (frame
, prop
)
1859 register struct frame
*frame
;
1862 register Lisp_Object tem
;
1864 tem
= Fassq (prop
, frame
->param_alist
);
1870 /* Return the buffer-predicate of the selected frame. */
1873 frame_buffer_predicate (frame
)
1876 return XFRAME (frame
)->buffer_predicate
;
1879 /* Return the buffer-list of the selected frame. */
1882 frame_buffer_list (frame
)
1885 return XFRAME (frame
)->buffer_list
;
1888 /* Set the buffer-list of the selected frame. */
1891 set_frame_buffer_list (frame
, list
)
1892 Lisp_Object frame
, list
;
1894 XFRAME (frame
)->buffer_list
= list
;
1897 /* Discard BUFFER from the buffer-list of each frame. */
1900 frames_discard_buffer (buffer
)
1903 Lisp_Object frame
, tail
;
1905 FOR_EACH_FRAME (tail
, frame
)
1907 XFRAME (frame
)->buffer_list
1908 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1912 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1913 If the alist already has an element for PROP, we change it. */
1916 store_in_alist (alistptr
, prop
, val
)
1917 Lisp_Object
*alistptr
, val
;
1920 register Lisp_Object tem
;
1922 tem
= Fassq (prop
, *alistptr
);
1924 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1930 frame_name_fnn_p (str
, len
)
1934 if (len
> 1 && str
[0] == 'F')
1938 strtol (str
+ 1, &end_ptr
, 10);
1940 if (end_ptr
== str
+ len
)
1946 /* Set the name of the terminal frame. Also used by MSDOS frames.
1947 Modeled after x_set_name which is used for WINDOW frames. */
1950 set_term_frame_name (f
, name
)
1954 f
->explicit_name
= ! NILP (name
);
1956 /* If NAME is nil, set the name to F<num>. */
1961 /* Check for no change needed in this very common case
1962 before we do any consing. */
1963 if (frame_name_fnn_p (SDATA (f
->name
),
1967 terminal_frame_count
++;
1968 sprintf (namebuf
, "F%d", terminal_frame_count
);
1969 name
= build_string (namebuf
);
1973 CHECK_STRING (name
);
1975 /* Don't change the name if it's already NAME. */
1976 if (! NILP (Fstring_equal (name
, f
->name
)))
1979 /* Don't allow the user to set the frame name to F<num>, so it
1980 doesn't clash with the names we generate for terminal frames. */
1981 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
1982 error ("Frame names of the form F<num> are usurped by Emacs");
1986 update_mode_lines
= 1;
1990 store_frame_param (f
, prop
, val
)
1992 Lisp_Object prop
, val
;
1994 register Lisp_Object old_alist_elt
;
1996 /* The buffer-alist parameter is stored in a special place and is
1997 not in the alist. */
1998 if (EQ (prop
, Qbuffer_list
))
2000 f
->buffer_list
= val
;
2004 /* If PROP is a symbol which is supposed to have frame-local values,
2005 and it is set up based on this frame, switch to the global
2006 binding. That way, we can create or alter the frame-local binding
2007 without messing up the symbol's status. */
2010 Lisp_Object valcontents
;
2011 valcontents
= SYMBOL_VALUE (prop
);
2012 if ((BUFFER_LOCAL_VALUEP (valcontents
)
2013 || SOME_BUFFER_LOCAL_VALUEP (valcontents
))
2014 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
2015 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
2016 swap_in_global_binding (prop
);
2020 /* The tty color mode needs to be set before the frame's parameter
2021 alist is updated with the new value, because set_tty_color_mode
2022 wants to look at the old mode. */
2023 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
))
2024 set_tty_color_mode (f
, val
);
2027 /* Update the frame parameter alist. */
2028 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2029 if (EQ (old_alist_elt
, Qnil
))
2030 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2032 Fsetcdr (old_alist_elt
, val
);
2034 /* Update some other special parameters in their special places
2035 in addition to the alist. */
2037 if (EQ (prop
, Qbuffer_predicate
))
2038 f
->buffer_predicate
= val
;
2040 if (! FRAME_WINDOW_P (f
))
2042 if (EQ (prop
, Qmenu_bar_lines
))
2043 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2044 else if (EQ (prop
, Qname
))
2045 set_term_frame_name (f
, val
);
2048 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2050 if (! MINI_WINDOW_P (XWINDOW (val
)))
2051 error ("Surrogate minibuffer windows must be minibuffer windows");
2053 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2054 && !EQ (val
, f
->minibuffer_window
))
2055 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2057 /* Install the chosen minibuffer window, with proper buffer. */
2058 f
->minibuffer_window
= val
;
2062 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2063 doc
: /* Return the parameters-alist of frame FRAME.
2064 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2065 The meaningful PARMs depend on the kind of frame.
2066 If FRAME is omitted, return information on the currently selected frame. */)
2073 struct gcpro gcpro1
;
2076 frame
= selected_frame
;
2078 CHECK_FRAME (frame
);
2081 if (!FRAME_LIVE_P (f
))
2084 alist
= Fcopy_alist (f
->param_alist
);
2087 if (!FRAME_WINDOW_P (f
))
2089 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2090 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2093 /* If the frame's parameter alist says the colors are
2094 unspecified and reversed, take the frame's background pixel
2095 for foreground and vice versa. */
2096 elt
= Fassq (Qforeground_color
, alist
);
2097 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2099 if (strncmp (SDATA (XCDR (elt
)),
2101 SCHARS (XCDR (elt
))) == 0)
2102 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2103 else if (strncmp (SDATA (XCDR (elt
)),
2105 SCHARS (XCDR (elt
))) == 0)
2106 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2109 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2110 elt
= Fassq (Qbackground_color
, alist
);
2111 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2113 if (strncmp (SDATA (XCDR (elt
)),
2115 SCHARS (XCDR (elt
))) == 0)
2116 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2117 else if (strncmp (SDATA (XCDR (elt
)),
2119 SCHARS (XCDR (elt
))) == 0)
2120 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2123 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2124 store_in_alist (&alist
, intern ("font"),
2125 build_string (FRAME_MSDOS_P (f
)
2127 : FRAME_W32_P (f
) ? "w32term"
2130 store_in_alist (&alist
, Qname
, f
->name
);
2131 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2132 store_in_alist (&alist
, Qheight
, make_number (height
));
2133 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2134 store_in_alist (&alist
, Qwidth
, make_number (width
));
2135 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2136 store_in_alist (&alist
, Qminibuffer
,
2137 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2138 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2139 : FRAME_MINIBUF_WINDOW (f
)));
2140 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2141 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2143 /* I think this should be done with a hook. */
2144 #ifdef HAVE_WINDOW_SYSTEM
2145 if (FRAME_WINDOW_P (f
))
2146 x_report_frame_params (f
, &alist
);
2150 /* This ought to be correct in f->param_alist for an X frame. */
2152 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2153 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2161 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2162 doc
: /* Return FRAME's value for parameter PARAMETER.
2163 If FRAME is nil, describe the currently selected frame. */)
2165 Lisp_Object frame
, parameter
;
2171 frame
= selected_frame
;
2173 CHECK_FRAME (frame
);
2174 CHECK_SYMBOL (parameter
);
2179 if (FRAME_LIVE_P (f
))
2181 /* Avoid consing in frequent cases. */
2182 if (EQ (parameter
, Qname
))
2184 #ifdef HAVE_X_WINDOWS
2185 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2186 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2187 #endif /* HAVE_X_WINDOWS */
2188 else if (EQ (parameter
, Qbackground_color
)
2189 || EQ (parameter
, Qforeground_color
))
2191 value
= Fassq (parameter
, f
->param_alist
);
2194 value
= XCDR (value
);
2195 /* Fframe_parameters puts the actual fg/bg color names,
2196 even if f->param_alist says otherwise. This is
2197 important when param_alist's notion of colors is
2198 "unspecified". We need to do the same here. */
2199 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2201 const char *color_name
;
2204 if (EQ (parameter
, Qbackground_color
))
2206 color_name
= SDATA (value
);
2207 csz
= SCHARS (value
);
2208 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2209 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2210 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2211 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2213 else if (EQ (parameter
, Qforeground_color
))
2215 color_name
= SDATA (value
);
2216 csz
= SCHARS (value
);
2217 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2218 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2219 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2220 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2225 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2227 else if (EQ (parameter
, Qdisplay_type
)
2228 || EQ (parameter
, Qbackground_mode
))
2229 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2231 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2238 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2239 Smodify_frame_parameters
, 2, 2, 0,
2240 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2241 If FRAME is nil, it defaults to the selected frame.
2242 ALIST is an alist of parameters to change and their new values.
2243 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2244 The meaningful PARMs depend on the kind of frame.
2245 Undefined PARMs are ignored, but stored in the frame's parameter list
2246 so that `frame-parameters' will return them.
2248 The value of frame parameter FOO can also be accessed
2249 as a frame-local binding for the variable FOO, if you have
2250 enabled such bindings for that variable with `make-variable-frame-local'. */)
2252 Lisp_Object frame
, alist
;
2255 register Lisp_Object tail
, prop
, val
;
2256 int count
= SPECPDL_INDEX ();
2258 /* Bind this to t to inhibit initialization of the default face from
2259 X resources in face-set-after-frame-default. If we don't inhibit
2260 this, modifying the `font' frame parameter, for example, while
2261 there is a `default.attributeFont' X resource, won't work,
2262 because `default's font is reset to the value of the X resource
2263 and that resets the `font' frame parameter. */
2264 specbind (Qinhibit_default_face_x_resources
, Qt
);
2266 if (EQ (frame
, Qnil
))
2267 frame
= selected_frame
;
2268 CHECK_LIVE_FRAME (frame
);
2271 /* I think this should be done with a hook. */
2272 #ifdef HAVE_WINDOW_SYSTEM
2273 if (FRAME_WINDOW_P (f
))
2274 x_set_frame_parameters (f
, alist
);
2278 if (FRAME_MSDOS_P (f
))
2279 IT_set_frame_parameters (f
, alist
);
2284 int length
= XINT (Flength (alist
));
2287 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2289 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2291 /* Extract parm names and values into those vectors. */
2294 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2299 parms
[i
] = Fcar (elt
);
2300 values
[i
] = Fcdr (elt
);
2304 /* Now process them in reverse of specified order. */
2305 for (i
--; i
>= 0; i
--)
2309 store_frame_param (f
, prop
, val
);
2313 return unbind_to (count
, Qnil
);
2316 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2318 doc
: /* Height in pixels of a line in the font in frame FRAME.
2319 If FRAME is omitted, the selected frame is used.
2320 For a terminal frame, the value is always 1. */)
2327 frame
= selected_frame
;
2328 CHECK_FRAME (frame
);
2331 #ifdef HAVE_WINDOW_SYSTEM
2332 if (FRAME_WINDOW_P (f
))
2333 return make_number (x_char_height (f
));
2336 return make_number (1);
2340 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2342 doc
: /* Width in pixels of characters in the font in frame FRAME.
2343 If FRAME is omitted, the selected frame is used.
2344 The width is the same for all characters, because
2345 currently Emacs supports only fixed-width fonts.
2346 For a terminal screen, the value is always 1. */)
2353 frame
= selected_frame
;
2354 CHECK_FRAME (frame
);
2357 #ifdef HAVE_WINDOW_SYSTEM
2358 if (FRAME_WINDOW_P (f
))
2359 return make_number (x_char_width (f
));
2362 return make_number (1);
2365 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2366 Sframe_pixel_height
, 0, 1, 0,
2367 doc
: /* Return a FRAME's height in pixels.
2368 This counts only the height available for text lines,
2369 not menu bars on window-system Emacs frames.
2370 For a terminal frame, the result really gives the height in characters.
2371 If FRAME is omitted, the selected frame is used. */)
2378 frame
= selected_frame
;
2379 CHECK_FRAME (frame
);
2382 #ifdef HAVE_WINDOW_SYSTEM
2383 if (FRAME_WINDOW_P (f
))
2384 return make_number (x_pixel_height (f
));
2387 return make_number (FRAME_LINES (f
));
2390 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2391 Sframe_pixel_width
, 0, 1, 0,
2392 doc
: /* Return FRAME's width in pixels.
2393 For a terminal frame, the result really gives the width in characters.
2394 If FRAME is omitted, the selected frame is used. */)
2401 frame
= selected_frame
;
2402 CHECK_FRAME (frame
);
2405 #ifdef HAVE_WINDOW_SYSTEM
2406 if (FRAME_WINDOW_P (f
))
2407 return make_number (x_pixel_width (f
));
2410 return make_number (FRAME_COLS (f
));
2413 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2414 doc
: /* Specify that the frame FRAME has LINES lines.
2415 Optional third arg non-nil means that redisplay should use LINES lines
2416 but that the idea of the actual height of the frame should not be changed. */)
2417 (frame
, lines
, pretend
)
2418 Lisp_Object frame
, lines
, pretend
;
2420 register struct frame
*f
;
2422 CHECK_NUMBER (lines
);
2424 frame
= selected_frame
;
2425 CHECK_LIVE_FRAME (frame
);
2428 /* I think this should be done with a hook. */
2429 #ifdef HAVE_WINDOW_SYSTEM
2430 if (FRAME_WINDOW_P (f
))
2432 if (XINT (lines
) != FRAME_LINES (f
))
2433 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2434 do_pending_window_change (0);
2438 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2442 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2443 doc
: /* Specify that the frame FRAME has COLS columns.
2444 Optional third arg non-nil means that redisplay should use COLS columns
2445 but that the idea of the actual width of the frame should not be changed. */)
2446 (frame
, cols
, pretend
)
2447 Lisp_Object frame
, cols
, pretend
;
2449 register struct frame
*f
;
2450 CHECK_NUMBER (cols
);
2452 frame
= selected_frame
;
2453 CHECK_LIVE_FRAME (frame
);
2456 /* I think this should be done with a hook. */
2457 #ifdef HAVE_WINDOW_SYSTEM
2458 if (FRAME_WINDOW_P (f
))
2460 if (XINT (cols
) != FRAME_COLS (f
))
2461 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2462 do_pending_window_change (0);
2466 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2470 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2471 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2473 Lisp_Object frame
, cols
, rows
;
2475 register struct frame
*f
;
2477 CHECK_LIVE_FRAME (frame
);
2478 CHECK_NUMBER (cols
);
2479 CHECK_NUMBER (rows
);
2482 /* I think this should be done with a hook. */
2483 #ifdef HAVE_WINDOW_SYSTEM
2484 if (FRAME_WINDOW_P (f
))
2486 if (XINT (rows
) != FRAME_LINES (f
)
2487 || XINT (cols
) != FRAME_COLS (f
)
2488 || f
->new_text_lines
|| f
->new_text_cols
)
2489 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2490 do_pending_window_change (0);
2494 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2499 DEFUN ("set-frame-position", Fset_frame_position
,
2500 Sset_frame_position
, 3, 3, 0,
2501 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2502 This is actually the position of the upper left corner of the frame.
2503 Negative values for XOFFSET or YOFFSET are interpreted relative to
2504 the rightmost or bottommost possible position (that stays within the screen). */)
2505 (frame
, xoffset
, yoffset
)
2506 Lisp_Object frame
, xoffset
, yoffset
;
2508 register struct frame
*f
;
2510 CHECK_LIVE_FRAME (frame
);
2511 CHECK_NUMBER (xoffset
);
2512 CHECK_NUMBER (yoffset
);
2515 /* I think this should be done with a hook. */
2516 #ifdef HAVE_WINDOW_SYSTEM
2517 if (FRAME_WINDOW_P (f
))
2518 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2525 /***********************************************************************
2527 ***********************************************************************/
2529 /* Connect the frame-parameter names for X frames
2530 to the ways of passing the parameter values to the window system.
2532 The name of a parameter, as a Lisp symbol,
2533 has an `x-frame-parameter' property which is an integer in Lisp
2534 that is an index in this table. */
2536 struct frame_parm_table
{
2538 Lisp_Object
*variable
;
2541 static struct frame_parm_table frame_parms
[] =
2543 {"auto-raise", &Qauto_raise
},
2544 {"auto-lower", &Qauto_lower
},
2545 {"background-color", 0},
2546 {"border-color", &Qborder_color
},
2547 {"border-width", &Qborder_width
},
2548 {"cursor-color", &Qcursor_color
},
2549 {"cursor-type", &Qcursor_type
},
2551 {"foreground-color", 0},
2552 {"icon-name", &Qicon_name
},
2553 {"icon-type", &Qicon_type
},
2554 {"internal-border-width", &Qinternal_border_width
},
2555 {"menu-bar-lines", &Qmenu_bar_lines
},
2556 {"mouse-color", &Qmouse_color
},
2558 {"scroll-bar-width", &Qscroll_bar_width
},
2560 {"unsplittable", &Qunsplittable
},
2561 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2562 {"visibility", &Qvisibility
},
2563 {"tool-bar-lines", &Qtool_bar_lines
},
2564 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2565 {"scroll-bar-background", &Qscroll_bar_background
},
2566 {"screen-gamma", &Qscreen_gamma
},
2567 {"line-spacing", &Qline_spacing
},
2568 {"left-fringe", &Qleft_fringe
},
2569 {"right-fringe", &Qright_fringe
},
2570 {"wait-for-wm", &Qwait_for_wm
},
2571 {"fullscreen", &Qfullscreen
},
2574 #ifdef HAVE_WINDOW_SYSTEM
2576 extern Lisp_Object Qbox
;
2577 extern Lisp_Object Qtop
;
2579 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2580 wanted positions of the WM window (not emacs window).
2581 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2582 window (FRAME_X_WINDOW).
2586 x_fullscreen_adjust (f
, width
, height
, top_pos
, left_pos
)
2593 int newwidth
= FRAME_COLS (f
);
2594 int newheight
= FRAME_LINES (f
);
2596 *top_pos
= f
->top_pos
;
2597 *left_pos
= f
->left_pos
;
2599 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2603 ph
= FRAME_X_DISPLAY_INFO (f
)->height
;
2604 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2605 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2606 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2610 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2614 pw
= FRAME_X_DISPLAY_INFO (f
)->width
;
2615 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2616 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2617 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2622 *height
= newheight
;
2626 /* Change the parameters of frame F as specified by ALIST.
2627 If a parameter is not specially recognized, do nothing special;
2628 otherwise call the `x_set_...' function for that parameter.
2629 Except for certain geometry properties, always call store_frame_param
2630 to store the new value in the parameter alist. */
2633 x_set_frame_parameters (f
, alist
)
2639 /* If both of these parameters are present, it's more efficient to
2640 set them both at once. So we wait until we've looked at the
2641 entire list before we set them. */
2645 Lisp_Object left
, top
;
2647 /* Same with these. */
2648 Lisp_Object icon_left
, icon_top
;
2650 /* Record in these vectors all the parms specified. */
2652 Lisp_Object
*values
;
2654 int left_no_change
= 0, top_no_change
= 0;
2655 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2656 int fullscreen_is_being_set
= 0;
2658 struct gcpro gcpro1
, gcpro2
;
2661 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2664 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2665 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2667 /* Extract parm names and values into those vectors. */
2670 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2675 parms
[i
] = Fcar (elt
);
2676 values
[i
] = Fcdr (elt
);
2679 /* TAIL and ALIST are not used again below here. */
2680 alist
= tail
= Qnil
;
2682 GCPRO2 (*parms
, *values
);
2686 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2687 because their values appear in VALUES and strings are not valid. */
2688 top
= left
= Qunbound
;
2689 icon_left
= icon_top
= Qunbound
;
2691 /* Provide default values for HEIGHT and WIDTH. */
2692 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2693 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2695 /* Process foreground_color and background_color before anything else.
2696 They are independent of other properties, but other properties (e.g.,
2697 cursor_color) are dependent upon them. */
2698 /* Process default font as well, since fringe widths depends on it. */
2699 /* Also, process fullscreen, width and height depend upon that */
2700 for (p
= 0; p
< i
; p
++)
2702 Lisp_Object prop
, val
;
2706 if (EQ (prop
, Qforeground_color
)
2707 || EQ (prop
, Qbackground_color
)
2709 || EQ (prop
, Qfullscreen
))
2711 register Lisp_Object param_index
, old_value
;
2713 old_value
= get_frame_param (f
, prop
);
2714 fullscreen_is_being_set
|= EQ (prop
, Qfullscreen
);
2716 if (NILP (Fequal (val
, old_value
)))
2718 store_frame_param (f
, prop
, val
);
2720 param_index
= Fget (prop
, Qx_frame_parameter
);
2721 if (NATNUMP (param_index
)
2722 && (XFASTINT (param_index
)
2723 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2724 && rif
->frame_parm_handlers
[XINT (param_index
)])
2725 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2730 /* Now process them in reverse of specified order. */
2731 for (i
--; i
>= 0; i
--)
2733 Lisp_Object prop
, val
;
2738 if (EQ (prop
, Qwidth
) && NUMBERP (val
))
2739 width
= XFASTINT (val
);
2740 else if (EQ (prop
, Qheight
) && NUMBERP (val
))
2741 height
= XFASTINT (val
);
2742 else if (EQ (prop
, Qtop
))
2744 else if (EQ (prop
, Qleft
))
2746 else if (EQ (prop
, Qicon_top
))
2748 else if (EQ (prop
, Qicon_left
))
2750 else if (EQ (prop
, Qforeground_color
)
2751 || EQ (prop
, Qbackground_color
)
2753 || EQ (prop
, Qfullscreen
))
2754 /* Processed above. */
2758 register Lisp_Object param_index
, old_value
;
2760 old_value
= get_frame_param (f
, prop
);
2762 store_frame_param (f
, prop
, val
);
2764 param_index
= Fget (prop
, Qx_frame_parameter
);
2765 if (NATNUMP (param_index
)
2766 && (XFASTINT (param_index
)
2767 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2768 && rif
->frame_parm_handlers
[XINT (param_index
)])
2769 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2773 /* Don't die if just one of these was set. */
2774 if (EQ (left
, Qunbound
))
2777 if (f
->left_pos
< 0)
2778 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2780 XSETINT (left
, f
->left_pos
);
2782 if (EQ (top
, Qunbound
))
2786 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2788 XSETINT (top
, f
->top_pos
);
2791 /* If one of the icon positions was not set, preserve or default it. */
2792 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
2794 icon_left_no_change
= 1;
2795 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2796 if (NILP (icon_left
))
2797 XSETINT (icon_left
, 0);
2799 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
2801 icon_top_no_change
= 1;
2802 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2803 if (NILP (icon_top
))
2804 XSETINT (icon_top
, 0);
2808 /* MAC_TODO: fullscreen */
2809 if (FRAME_VISIBLE_P (f
) && fullscreen_is_being_set
)
2811 /* If the frame is visible already and the fullscreen parameter is
2812 being set, it is too late to set WM manager hints to specify
2814 Here we first get the width, height and position that applies to
2815 fullscreen. We then move the frame to the appropriate
2816 position. Resize of the frame is taken care of in the code after
2817 this if-statement. */
2818 int new_left
, new_top
;
2820 x_fullscreen_adjust (f
, &width
, &height
, &new_top
, &new_left
);
2821 if (new_top
!= f
->top_pos
|| new_left
!= f
->left_pos
)
2822 x_set_offset (f
, new_left
, new_top
, 1);
2826 /* Don't set these parameters unless they've been explicitly
2827 specified. The window might be mapped or resized while we're in
2828 this function, and we don't want to override that unless the lisp
2829 code has asked for it.
2831 Don't set these parameters unless they actually differ from the
2832 window's current parameters; the window may not actually exist
2837 check_frame_size (f
, &height
, &width
);
2839 XSETFRAME (frame
, f
);
2841 if (width
!= FRAME_COLS (f
)
2842 || height
!= FRAME_LINES (f
)
2843 || f
->new_text_lines
|| f
->new_text_cols
)
2844 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2846 if ((!NILP (left
) || !NILP (top
))
2847 && ! (left_no_change
&& top_no_change
)
2848 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2849 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2854 /* Record the signs. */
2855 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2856 if (EQ (left
, Qminus
))
2857 f
->size_hint_flags
|= XNegative
;
2858 else if (INTEGERP (left
))
2860 leftpos
= XINT (left
);
2862 f
->size_hint_flags
|= XNegative
;
2864 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2865 && CONSP (XCDR (left
))
2866 && INTEGERP (XCAR (XCDR (left
))))
2868 leftpos
= - XINT (XCAR (XCDR (left
)));
2869 f
->size_hint_flags
|= XNegative
;
2871 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2872 && CONSP (XCDR (left
))
2873 && INTEGERP (XCAR (XCDR (left
))))
2875 leftpos
= XINT (XCAR (XCDR (left
)));
2878 if (EQ (top
, Qminus
))
2879 f
->size_hint_flags
|= YNegative
;
2880 else if (INTEGERP (top
))
2882 toppos
= XINT (top
);
2884 f
->size_hint_flags
|= YNegative
;
2886 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2887 && CONSP (XCDR (top
))
2888 && INTEGERP (XCAR (XCDR (top
))))
2890 toppos
= - XINT (XCAR (XCDR (top
)));
2891 f
->size_hint_flags
|= YNegative
;
2893 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2894 && CONSP (XCDR (top
))
2895 && INTEGERP (XCAR (XCDR (top
))))
2897 toppos
= XINT (XCAR (XCDR (top
)));
2901 /* Store the numeric value of the position. */
2902 f
->top_pos
= toppos
;
2903 f
->left_pos
= leftpos
;
2905 f
->win_gravity
= NorthWestGravity
;
2907 /* Actually set that position, and convert to absolute. */
2908 x_set_offset (f
, leftpos
, toppos
, -1);
2911 if ((!NILP (icon_left
) || !NILP (icon_top
))
2912 && ! (icon_left_no_change
&& icon_top_no_change
))
2913 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2920 /* Insert a description of internally-recorded parameters of frame X
2921 into the parameter alist *ALISTPTR that is to be given to the user.
2922 Only parameters that are specific to the X window system
2923 and whose values are not correctly recorded in the frame's
2924 param_alist need to be considered here. */
2927 x_report_frame_params (f
, alistptr
)
2929 Lisp_Object
*alistptr
;
2934 /* Represent negative positions (off the top or left screen edge)
2935 in a way that Fmodify_frame_parameters will understand correctly. */
2936 XSETINT (tem
, f
->left_pos
);
2937 if (f
->left_pos
>= 0)
2938 store_in_alist (alistptr
, Qleft
, tem
);
2940 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2942 XSETINT (tem
, f
->top_pos
);
2943 if (f
->top_pos
>= 0)
2944 store_in_alist (alistptr
, Qtop
, tem
);
2946 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2948 store_in_alist (alistptr
, Qborder_width
,
2949 make_number (f
->border_width
));
2950 store_in_alist (alistptr
, Qinternal_border_width
,
2951 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
2952 store_in_alist (alistptr
, Qleft_fringe
,
2953 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
2954 store_in_alist (alistptr
, Qright_fringe
,
2955 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
2956 store_in_alist (alistptr
, Qscroll_bar_width
,
2957 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2959 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
2960 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
2961 /* nil means "use default width"
2962 for non-toolkit scroll bar.
2963 ruler-mode.el depends on this. */
2965 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
2966 store_in_alist (alistptr
, Qwindow_id
,
2967 build_string (buf
));
2968 #ifdef HAVE_X_WINDOWS
2969 #ifdef USE_X_TOOLKIT
2970 /* Tooltip frame may not have this widget. */
2971 if (FRAME_X_OUTPUT (f
)->widget
)
2973 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
2974 store_in_alist (alistptr
, Qouter_window_id
,
2975 build_string (buf
));
2977 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
2978 FRAME_SAMPLE_VISIBILITY (f
);
2979 store_in_alist (alistptr
, Qvisibility
,
2980 (FRAME_VISIBLE_P (f
) ? Qt
2981 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
2982 store_in_alist (alistptr
, Qdisplay
,
2983 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
2986 /* A Mac Window is identified by a struct, not an integer. */
2987 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
2990 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
2991 store_in_alist (alistptr
, Qparent_id
, tem
);
2996 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
2997 the previous value of that parameter, NEW_VALUE is the new value. */
3000 x_set_fullscreen (f
, new_value
, old_value
)
3002 Lisp_Object new_value
, old_value
;
3005 if (NILP (new_value
))
3006 f
->want_fullscreen
= FULLSCREEN_NONE
;
3007 else if (EQ (new_value
, Qfullboth
))
3008 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3009 else if (EQ (new_value
, Qfullwidth
))
3010 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3011 else if (EQ (new_value
, Qfullheight
))
3012 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3017 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3018 the previous value of that parameter, NEW_VALUE is the new value. */
3021 x_set_line_spacing (f
, new_value
, old_value
)
3023 Lisp_Object new_value
, old_value
;
3025 if (NILP (new_value
))
3026 f
->extra_line_spacing
= 0;
3027 else if (NATNUMP (new_value
))
3028 f
->extra_line_spacing
= XFASTINT (new_value
);
3030 Fsignal (Qerror
, Fcons (build_string ("Invalid line-spacing"),
3031 Fcons (new_value
, Qnil
)));
3032 if (FRAME_VISIBLE_P (f
))
3037 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3038 the previous value of that parameter, NEW_VALUE is the new value. */
3041 x_set_screen_gamma (f
, new_value
, old_value
)
3043 Lisp_Object new_value
, old_value
;
3045 if (NILP (new_value
))
3047 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3048 /* The value 0.4545 is the normal viewing gamma. */
3049 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3051 Fsignal (Qerror
, Fcons (build_string ("Invalid screen-gamma"),
3052 Fcons (new_value
, Qnil
)));
3054 clear_face_cache (0);
3059 x_set_font (f
, arg
, oldval
)
3061 Lisp_Object arg
, oldval
;
3064 Lisp_Object fontset_name
;
3066 int old_fontset
= FRAME_FONTSET(f
);
3070 fontset_name
= Fquery_fontset (arg
, Qnil
);
3073 result
= (STRINGP (fontset_name
)
3074 ? x_new_fontset (f
, SDATA (fontset_name
))
3075 : x_new_font (f
, SDATA (arg
)));
3078 if (EQ (result
, Qnil
))
3079 error ("Font `%s' is not defined", SDATA (arg
));
3080 else if (EQ (result
, Qt
))
3081 error ("The characters of the given font have varying widths");
3082 else if (STRINGP (result
))
3084 if (STRINGP (fontset_name
))
3086 /* Fontset names are built from ASCII font names, so the
3087 names may be equal despite there was a change. */
3088 if (old_fontset
== FRAME_FONTSET (f
))
3091 else if (!NILP (Fequal (result
, oldval
)))
3094 store_frame_param (f
, Qfont
, result
);
3095 recompute_basic_faces (f
);
3100 do_pending_window_change (0);
3102 /* Don't call `face-set-after-frame-default' when faces haven't been
3103 initialized yet. This is the case when called from
3104 Fx_create_frame. In that case, the X widget or window doesn't
3105 exist either, and we can end up in x_report_frame_params with a
3106 null widget which gives a segfault. */
3107 if (FRAME_FACE_CACHE (f
))
3109 XSETFRAME (frame
, f
);
3110 call1 (Qface_set_after_frame_default
, frame
);
3116 x_set_fringe_width (f
, new_value
, old_value
)
3118 Lisp_Object new_value
, old_value
;
3120 compute_fringe_widths (f
, 1);
3124 x_set_border_width (f
, arg
, oldval
)
3126 Lisp_Object arg
, oldval
;
3130 if (XINT (arg
) == f
->border_width
)
3134 if (FRAME_X_WINDOW (f
) != 0)
3135 error ("Cannot change the border width of a window");
3136 #endif /* MAC_TODO */
3138 f
->border_width
= XINT (arg
);
3142 x_set_internal_border_width (f
, arg
, oldval
)
3144 Lisp_Object arg
, oldval
;
3146 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3149 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3150 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3151 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3153 #ifdef USE_X_TOOLKIT
3154 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3155 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3158 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3161 if (FRAME_X_WINDOW (f
) != 0)
3163 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3164 SET_FRAME_GARBAGED (f
);
3165 do_pending_window_change (0);
3168 SET_FRAME_GARBAGED (f
);
3172 x_set_visibility (f
, value
, oldval
)
3174 Lisp_Object value
, oldval
;
3177 XSETFRAME (frame
, f
);
3180 Fmake_frame_invisible (frame
, Qt
);
3181 else if (EQ (value
, Qicon
))
3182 Ficonify_frame (frame
);
3184 Fmake_frame_visible (frame
);
3188 x_set_autoraise (f
, arg
, oldval
)
3190 Lisp_Object arg
, oldval
;
3192 f
->auto_raise
= !EQ (Qnil
, arg
);
3196 x_set_autolower (f
, arg
, oldval
)
3198 Lisp_Object arg
, oldval
;
3200 f
->auto_lower
= !EQ (Qnil
, arg
);
3204 x_set_unsplittable (f
, arg
, oldval
)
3206 Lisp_Object arg
, oldval
;
3208 f
->no_split
= !NILP (arg
);
3212 x_set_vertical_scroll_bars (f
, arg
, oldval
)
3214 Lisp_Object arg
, oldval
;
3216 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3217 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3218 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3219 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3221 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3223 ? vertical_scroll_bar_none
3225 ? vertical_scroll_bar_left
3227 ? vertical_scroll_bar_right
3228 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3229 ? vertical_scroll_bar_left
3230 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3231 ? vertical_scroll_bar_right
3232 : vertical_scroll_bar_none
);
3234 /* We set this parameter before creating the X window for the
3235 frame, so we can get the geometry right from the start.
3236 However, if the window hasn't been created yet, we shouldn't
3237 call x_set_window_size. */
3238 if (FRAME_X_WINDOW (f
))
3239 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3240 do_pending_window_change (0);
3245 x_set_scroll_bar_width (f
, arg
, oldval
)
3247 Lisp_Object arg
, oldval
;
3249 int wid
= FRAME_COLUMN_WIDTH (f
);
3253 x_set_scroll_bar_default_width (f
);
3255 if (FRAME_X_WINDOW (f
))
3256 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3257 do_pending_window_change (0);
3259 else if (INTEGERP (arg
) && XINT (arg
) > 0
3260 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3262 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3263 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3265 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3266 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3267 if (FRAME_X_WINDOW (f
))
3268 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3269 do_pending_window_change (0);
3272 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3273 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3274 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3279 /* Return non-nil if frame F wants a bitmap icon. */
3287 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3295 /* Subroutines of creating an X frame. */
3297 /* Make sure that Vx_resource_name is set to a reasonable value.
3298 Fix it up, or set it to `emacs' if it is too hopeless. */
3301 validate_x_resource_name ()
3304 /* Number of valid characters in the resource name. */
3306 /* Number of invalid characters in the resource name. */
3311 if (!STRINGP (Vx_resource_class
))
3312 Vx_resource_class
= build_string (EMACS_CLASS
);
3314 if (STRINGP (Vx_resource_name
))
3316 unsigned char *p
= SDATA (Vx_resource_name
);
3319 len
= SBYTES (Vx_resource_name
);
3321 /* Only letters, digits, - and _ are valid in resource names.
3322 Count the valid characters and count the invalid ones. */
3323 for (i
= 0; i
< len
; i
++)
3326 if (! ((c
>= 'a' && c
<= 'z')
3327 || (c
>= 'A' && c
<= 'Z')
3328 || (c
>= '0' && c
<= '9')
3329 || c
== '-' || c
== '_'))
3336 /* Not a string => completely invalid. */
3337 bad_count
= 5, good_count
= 0;
3339 /* If name is valid already, return. */
3343 /* If name is entirely invalid, or nearly so, use `emacs'. */
3345 || (good_count
== 1 && bad_count
> 0))
3347 Vx_resource_name
= build_string ("emacs");
3351 /* Name is partly valid. Copy it and replace the invalid characters
3352 with underscores. */
3354 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3356 for (i
= 0; i
< len
; i
++)
3358 int c
= SREF (new, i
);
3359 if (! ((c
>= 'a' && c
<= 'z')
3360 || (c
>= 'A' && c
<= 'Z')
3361 || (c
>= '0' && c
<= '9')
3362 || c
== '-' || c
== '_'))
3368 extern char *x_get_string_resource
P_ ((XrmDatabase
, char *, char *));
3369 extern Display_Info
*check_x_display_info
P_ ((Lisp_Object
));
3372 /* Get specified attribute from resource database RDB.
3373 See Fx_get_resource below for other parameters. */
3376 xrdb_get_resource (rdb
, attribute
, class, component
, subclass
)
3378 Lisp_Object attribute
, class, component
, subclass
;
3380 register char *value
;
3384 CHECK_STRING (attribute
);
3385 CHECK_STRING (class);
3387 if (!NILP (component
))
3388 CHECK_STRING (component
);
3389 if (!NILP (subclass
))
3390 CHECK_STRING (subclass
);
3391 if (NILP (component
) != NILP (subclass
))
3392 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3394 validate_x_resource_name ();
3396 /* Allocate space for the components, the dots which separate them,
3397 and the final '\0'. Make them big enough for the worst case. */
3398 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3399 + (STRINGP (component
)
3400 ? SBYTES (component
) : 0)
3401 + SBYTES (attribute
)
3404 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3406 + (STRINGP (subclass
)
3407 ? SBYTES (subclass
) : 0)
3410 /* Start with emacs.FRAMENAME for the name (the specific one)
3411 and with `Emacs' for the class key (the general one). */
3412 strcpy (name_key
, SDATA (Vx_resource_name
));
3413 strcpy (class_key
, SDATA (Vx_resource_class
));
3415 strcat (class_key
, ".");
3416 strcat (class_key
, SDATA (class));
3418 if (!NILP (component
))
3420 strcat (class_key
, ".");
3421 strcat (class_key
, SDATA (subclass
));
3423 strcat (name_key
, ".");
3424 strcat (name_key
, SDATA (component
));
3427 strcat (name_key
, ".");
3428 strcat (name_key
, SDATA (attribute
));
3430 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3432 if (value
!= (char *) 0)
3433 return build_string (value
);
3439 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3440 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3441 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3442 class, where INSTANCE is the name under which Emacs was invoked, or
3443 the name specified by the `-name' or `-rn' command-line arguments.
3445 The optional arguments COMPONENT and SUBCLASS add to the key and the
3446 class, respectively. You must specify both of them or neither.
3447 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3448 and the class is `Emacs.CLASS.SUBCLASS'. */)
3449 (attribute
, class, component
, subclass
)
3450 Lisp_Object attribute
, class, component
, subclass
;
3452 #ifdef HAVE_X_WINDOWS
3456 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3457 attribute
, class, component
, subclass
);
3460 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3463 display_x_get_resource (dpyinfo
, attribute
, class, component
, subclass
)
3464 Display_Info
*dpyinfo
;
3465 Lisp_Object attribute
, class, component
, subclass
;
3467 return xrdb_get_resource (dpyinfo
->xrdb
,
3468 attribute
, class, component
, subclass
);
3471 /* Used when C code wants a resource value. */
3474 x_get_resource_string (attribute
, class)
3475 char *attribute
, *class;
3479 struct frame
*sf
= SELECTED_FRAME ();
3481 /* Allocate space for the components, the dots which separate them,
3482 and the final '\0'. */
3483 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3484 + strlen (attribute
) + 2);
3485 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3486 + strlen (class) + 2);
3488 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3489 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3491 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3492 name_key
, class_key
);
3496 /* Return the value of parameter PARAM.
3498 First search ALIST, then Vdefault_frame_alist, then the X defaults
3499 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3501 Convert the resource to the type specified by desired_type.
3503 If no default is specified, return Qunbound. If you call
3504 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3505 and don't let it get stored in any Lisp-visible variables! */
3508 x_get_arg (dpyinfo
, alist
, param
, attribute
, class, type
)
3509 Display_Info
*dpyinfo
;
3510 Lisp_Object alist
, param
;
3513 enum resource_types type
;
3515 register Lisp_Object tem
;
3517 tem
= Fassq (param
, alist
);
3519 tem
= Fassq (param
, Vdefault_frame_alist
);
3524 tem
= display_x_get_resource (dpyinfo
,
3525 build_string (attribute
),
3526 build_string (class),
3534 case RES_TYPE_NUMBER
:
3535 return make_number (atoi (SDATA (tem
)));
3537 case RES_TYPE_FLOAT
:
3538 return make_float (atof (SDATA (tem
)));
3540 case RES_TYPE_BOOLEAN
:
3541 tem
= Fdowncase (tem
);
3542 if (!strcmp (SDATA (tem
), "on")
3543 || !strcmp (SDATA (tem
), "true"))
3548 case RES_TYPE_STRING
:
3551 case RES_TYPE_SYMBOL
:
3552 /* As a special case, we map the values `true' and `on'
3553 to Qt, and `false' and `off' to Qnil. */
3556 lower
= Fdowncase (tem
);
3557 if (!strcmp (SDATA (lower
), "on")
3558 || !strcmp (SDATA (lower
), "true"))
3560 else if (!strcmp (SDATA (lower
), "off")
3561 || !strcmp (SDATA (lower
), "false"))
3564 return Fintern (tem
, Qnil
);
3578 x_frame_get_arg (f
, alist
, param
, attribute
, class, type
)
3580 Lisp_Object alist
, param
;
3583 enum resource_types type
;
3585 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3586 alist
, param
, attribute
, class, type
);
3589 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3592 x_frame_get_and_record_arg (f
, alist
, param
, attribute
, class, type
)
3594 Lisp_Object alist
, param
;
3597 enum resource_types type
;
3601 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3602 attribute
, class, type
);
3604 store_frame_param (f
, param
, value
);
3610 /* Record in frame F the specified or default value according to ALIST
3611 of the parameter named PROP (a Lisp symbol).
3612 If no value is specified for PROP, look for an X default for XPROP
3613 on the frame named NAME.
3614 If that is not found either, use the value DEFLT. */
3617 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
3624 enum resource_types type
;
3628 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3629 if (EQ (tem
, Qunbound
))
3631 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3638 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3639 doc
: /* Parse an X-style geometry string STRING.
3640 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3641 The properties returned may include `top', `left', `height', and `width'.
3642 The value of `left' or `top' may be an integer,
3643 or a list (+ N) meaning N pixels relative to top/left corner,
3644 or a list (- N) meaning -N pixels relative to bottom/right corner. */)
3649 unsigned int width
, height
;
3652 CHECK_STRING (string
);
3654 geometry
= XParseGeometry ((char *) SDATA (string
),
3655 &x
, &y
, &width
, &height
);
3658 if (!!(geometry
& XValue
) != !!(geometry
& YValue
))
3659 error ("Must specify both x and y position, or neither");
3663 if (geometry
& XValue
)
3665 Lisp_Object element
;
3667 if (x
>= 0 && (geometry
& XNegative
))
3668 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3669 else if (x
< 0 && ! (geometry
& XNegative
))
3670 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3672 element
= Fcons (Qleft
, make_number (x
));
3673 result
= Fcons (element
, result
);
3676 if (geometry
& YValue
)
3678 Lisp_Object element
;
3680 if (y
>= 0 && (geometry
& YNegative
))
3681 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3682 else if (y
< 0 && ! (geometry
& YNegative
))
3683 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3685 element
= Fcons (Qtop
, make_number (y
));
3686 result
= Fcons (element
, result
);
3689 if (geometry
& WidthValue
)
3690 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3691 if (geometry
& HeightValue
)
3692 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3697 /* Calculate the desired size and position of frame F.
3698 Return the flags saying which aspects were specified.
3700 Also set the win_gravity and size_hint_flags of F.
3702 Adjust height for toolbar if TOOLBAR_P is 1.
3704 This function does not make the coordinates positive. */
3706 #define DEFAULT_ROWS 40
3707 #define DEFAULT_COLS 80
3710 x_figure_window_size (f
, parms
, toolbar_p
)
3715 register Lisp_Object tem0
, tem1
, tem2
;
3716 long window_prompting
= 0;
3717 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3719 /* Default values if we fall through.
3720 Actually, if that happens we should get
3721 window manager prompting. */
3722 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3723 FRAME_LINES (f
) = DEFAULT_ROWS
;
3724 /* Window managers expect that if program-specified
3725 positions are not (0,0), they're intentional, not defaults. */
3729 /* Ensure that old new_text_cols and new_text_lines will not override the
3731 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3732 f
->new_text_cols
= f
->new_text_lines
= 0;
3734 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3735 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3736 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3737 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3739 if (!EQ (tem0
, Qunbound
))
3741 CHECK_NUMBER (tem0
);
3742 FRAME_LINES (f
) = XINT (tem0
);
3744 if (!EQ (tem1
, Qunbound
))
3746 CHECK_NUMBER (tem1
);
3747 SET_FRAME_COLS (f
, XINT (tem1
));
3749 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
3750 window_prompting
|= USSize
;
3752 window_prompting
|= PSize
;
3755 f
->scroll_bar_actual_width
3756 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
3758 /* This used to be done _before_ calling x_figure_window_size, but
3759 since the height is reset here, this was really a no-op. I
3760 assume that moving it here does what Gerd intended (although he
3761 no longer can remember what that was... ++KFS, 2003-03-25. */
3763 /* Add the tool-bar height to the initial frame height so that the
3764 user gets a text display area of the size he specified with -g or
3765 via .Xdefaults. Later changes of the tool-bar height don't
3766 change the frame size. This is done so that users can create
3767 tall Emacs frames without having to guess how tall the tool-bar
3769 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
3771 int margin
, relief
, bar_height
;
3773 relief
= (tool_bar_button_relief
>= 0
3774 ? tool_bar_button_relief
3775 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
3777 if (INTEGERP (Vtool_bar_button_margin
)
3778 && XINT (Vtool_bar_button_margin
) > 0)
3779 margin
= XFASTINT (Vtool_bar_button_margin
);
3780 else if (CONSP (Vtool_bar_button_margin
)
3781 && INTEGERP (XCDR (Vtool_bar_button_margin
))
3782 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
3783 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
3787 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
3788 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
3791 compute_fringe_widths (f
, 0);
3793 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
3794 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
3796 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
3797 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
3798 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
3799 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3801 if (EQ (tem0
, Qminus
))
3804 window_prompting
|= YNegative
;
3806 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
3807 && CONSP (XCDR (tem0
))
3808 && INTEGERP (XCAR (XCDR (tem0
))))
3810 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
3811 window_prompting
|= YNegative
;
3813 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
3814 && CONSP (XCDR (tem0
))
3815 && INTEGERP (XCAR (XCDR (tem0
))))
3817 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
3819 else if (EQ (tem0
, Qunbound
))
3823 CHECK_NUMBER (tem0
);
3824 f
->top_pos
= XINT (tem0
);
3826 window_prompting
|= YNegative
;
3829 if (EQ (tem1
, Qminus
))
3832 window_prompting
|= XNegative
;
3834 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
3835 && CONSP (XCDR (tem1
))
3836 && INTEGERP (XCAR (XCDR (tem1
))))
3838 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
3839 window_prompting
|= XNegative
;
3841 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
3842 && CONSP (XCDR (tem1
))
3843 && INTEGERP (XCAR (XCDR (tem1
))))
3845 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
3847 else if (EQ (tem1
, Qunbound
))
3851 CHECK_NUMBER (tem1
);
3852 f
->left_pos
= XINT (tem1
);
3853 if (f
->left_pos
< 0)
3854 window_prompting
|= XNegative
;
3857 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
3858 window_prompting
|= USPosition
;
3860 window_prompting
|= PPosition
;
3863 if (f
->want_fullscreen
!= FULLSCREEN_NONE
)
3868 /* It takes both for some WM:s to place it where we want */
3869 window_prompting
= USPosition
| PPosition
;
3870 x_fullscreen_adjust (f
, &width
, &height
, &top
, &left
);
3871 FRAME_COLS (f
) = width
;
3872 FRAME_LINES (f
) = height
;
3873 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, width
);
3874 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, height
);
3879 if (window_prompting
& XNegative
)
3881 if (window_prompting
& YNegative
)
3882 f
->win_gravity
= SouthEastGravity
;
3884 f
->win_gravity
= NorthEastGravity
;
3888 if (window_prompting
& YNegative
)
3889 f
->win_gravity
= SouthWestGravity
;
3891 f
->win_gravity
= NorthWestGravity
;
3894 f
->size_hint_flags
= window_prompting
;
3896 return window_prompting
;
3901 #endif /* HAVE_WINDOW_SYSTEM */
3905 /***********************************************************************
3907 ***********************************************************************/
3912 Qframep
= intern ("framep");
3913 staticpro (&Qframep
);
3914 Qframe_live_p
= intern ("frame-live-p");
3915 staticpro (&Qframe_live_p
);
3916 Qheight
= intern ("height");
3917 staticpro (&Qheight
);
3918 Qicon
= intern ("icon");
3920 Qminibuffer
= intern ("minibuffer");
3921 staticpro (&Qminibuffer
);
3922 Qmodeline
= intern ("modeline");
3923 staticpro (&Qmodeline
);
3924 Qonly
= intern ("only");
3926 Qwidth
= intern ("width");
3927 staticpro (&Qwidth
);
3928 Qgeometry
= intern ("geometry");
3929 staticpro (&Qgeometry
);
3930 Qicon_left
= intern ("icon-left");
3931 staticpro (&Qicon_left
);
3932 Qicon_top
= intern ("icon-top");
3933 staticpro (&Qicon_top
);
3934 Qleft
= intern ("left");
3936 Qright
= intern ("right");
3937 staticpro (&Qright
);
3938 Quser_position
= intern ("user-position");
3939 staticpro (&Quser_position
);
3940 Quser_size
= intern ("user-size");
3941 staticpro (&Quser_size
);
3942 Qwindow_id
= intern ("window-id");
3943 staticpro (&Qwindow_id
);
3944 #ifdef HAVE_X_WINDOWS
3945 Qouter_window_id
= intern ("outer-window-id");
3946 staticpro (&Qouter_window_id
);
3948 Qparent_id
= intern ("parent-id");
3949 staticpro (&Qparent_id
);
3952 Qw32
= intern ("w32");
3954 Qpc
= intern ("pc");
3956 Qmac
= intern ("mac");
3958 Qvisible
= intern ("visible");
3959 staticpro (&Qvisible
);
3960 Qbuffer_predicate
= intern ("buffer-predicate");
3961 staticpro (&Qbuffer_predicate
);
3962 Qbuffer_list
= intern ("buffer-list");
3963 staticpro (&Qbuffer_list
);
3964 Qdisplay_type
= intern ("display-type");
3965 staticpro (&Qdisplay_type
);
3966 Qbackground_mode
= intern ("background-mode");
3967 staticpro (&Qbackground_mode
);
3968 Qtty_color_mode
= intern ("tty-color-mode");
3969 staticpro (&Qtty_color_mode
);
3971 Qface_set_after_frame_default
= intern ("face-set-after-frame-default");
3972 staticpro (&Qface_set_after_frame_default
);
3974 Qfullwidth
= intern ("fullwidth");
3975 staticpro (&Qfullwidth
);
3976 Qfullheight
= intern ("fullheight");
3977 staticpro (&Qfullheight
);
3978 Qfullboth
= intern ("fullboth");
3979 staticpro (&Qfullboth
);
3980 Qx_resource_name
= intern ("x-resource-name");
3981 staticpro (&Qx_resource_name
);
3983 Qx_frame_parameter
= intern ("x-frame-parameter");
3984 staticpro (&Qx_frame_parameter
);
3989 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
3991 Lisp_Object v
= intern (frame_parms
[i
].name
);
3992 if (frame_parms
[i
].variable
)
3994 *frame_parms
[i
].variable
= v
;
3995 staticpro (frame_parms
[i
].variable
);
3997 Fput (v
, Qx_frame_parameter
, make_number (i
));
4001 #ifdef HAVE_WINDOW_SYSTEM
4002 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4003 doc
: /* The name Emacs uses to look up X resources.
4004 `x-get-resource' uses this as the first component of the instance name
4005 when requesting resource values.
4006 Emacs initially sets `x-resource-name' to the name under which Emacs
4007 was invoked, or to the value specified with the `-name' or `-rn'
4008 switches, if present.
4010 It may be useful to bind this variable locally around a call
4011 to `x-get-resource'. See also the variable `x-resource-class'. */);
4012 Vx_resource_name
= Qnil
;
4014 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4015 doc
: /* The class Emacs uses to look up X resources.
4016 `x-get-resource' uses this as the first component of the instance class
4017 when requesting resource values.
4019 Emacs initially sets `x-resource-class' to "Emacs".
4021 Setting this variable permanently is not a reasonable thing to do,
4022 but binding this variable locally around a call to `x-get-resource'
4023 is a reasonable practice. See also the variable `x-resource-name'. */);
4024 Vx_resource_class
= build_string (EMACS_CLASS
);
4027 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4028 doc
: /* Alist of default values for frame creation.
4029 These may be set in your init file, like this:
4030 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))
4031 These override values given in window system configuration data,
4032 including X Windows' defaults database.
4033 For values specific to the first Emacs frame, see `initial-frame-alist'.
4034 For values specific to the separate minibuffer frame, see
4035 `minibuffer-frame-alist'.
4036 The `menu-bar-lines' element of the list controls whether new frames
4037 have menu bars; `menu-bar-mode' works by altering this element.
4038 Setting this variable does not affect existing frames, only new ones. */);
4039 Vdefault_frame_alist
= Qnil
;
4041 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars
,
4042 doc
: /* Default position of scroll bars on this window-system. */);
4043 #ifdef HAVE_WINDOW_SYSTEM
4044 #if defined(HAVE_NTGUI) || defined(HAVE_CARBON)
4045 /* MS-Windows has scroll bars on the right by default. */
4046 Vdefault_frame_scroll_bars
= Qright
;
4048 Vdefault_frame_scroll_bars
= Qleft
;
4051 Vdefault_frame_scroll_bars
= Qnil
;
4054 Qinhibit_default_face_x_resources
4055 = intern ("inhibit-default-face-x-resources");
4056 staticpro (&Qinhibit_default_face_x_resources
);
4058 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4059 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4061 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
4062 doc
: /* Non-nil if all of emacs is iconified and frame updates are not needed. */);
4063 Vemacs_iconified
= Qnil
;
4065 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4066 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4067 `mouse-position' calls this function, passing its usual return value as
4068 argument, and returns whatever this function returns.
4069 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4070 which need to do mouse handling at the Lisp level. */);
4071 Vmouse_position_function
= Qnil
;
4073 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4074 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4075 If the value is an integer, highlighting is only shown after moving the
4076 mouse, while keyboard input turns off the highlight even when the mouse
4077 is over the clickable text. However, the mouse shape still indicates
4078 when the mouse is over clickable text. */);
4079 Vmouse_highlight
= Qt
;
4081 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4082 doc
: /* Functions to be run before deleting a frame.
4083 The functions are run with one arg, the frame to be deleted.
4084 See `delete-frame'. */);
4085 Vdelete_frame_functions
= Qnil
;
4087 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4088 doc
: /* Minibufferless frames use this frame's minibuffer.
4090 Emacs cannot create minibufferless frames unless this is set to an
4091 appropriate surrogate.
4093 Emacs consults this variable only when creating minibufferless
4094 frames; once the frame is created, it sticks with its assigned
4095 minibuffer, no matter what this variable is set to. This means that
4096 this variable doesn't necessarily say anything meaningful about the
4097 current set of frames, or where the minibuffer is currently being
4100 This variable is local to the current terminal and cannot be buffer-local. */);
4102 staticpro (&Vframe_list
);
4104 defsubr (&Sactive_minibuffer_window
);
4106 defsubr (&Sframe_live_p
);
4107 defsubr (&Smake_terminal_frame
);
4108 defsubr (&Shandle_switch_frame
);
4109 defsubr (&Signore_event
);
4110 defsubr (&Sselect_frame
);
4111 defsubr (&Sselected_frame
);
4112 defsubr (&Swindow_frame
);
4113 defsubr (&Sframe_root_window
);
4114 defsubr (&Sframe_first_window
);
4115 defsubr (&Sframe_selected_window
);
4116 defsubr (&Sset_frame_selected_window
);
4117 defsubr (&Sframe_list
);
4118 defsubr (&Snext_frame
);
4119 defsubr (&Sprevious_frame
);
4120 defsubr (&Sdelete_frame
);
4121 defsubr (&Smouse_position
);
4122 defsubr (&Smouse_pixel_position
);
4123 defsubr (&Sset_mouse_position
);
4124 defsubr (&Sset_mouse_pixel_position
);
4126 defsubr (&Sframe_configuration
);
4127 defsubr (&Srestore_frame_configuration
);
4129 defsubr (&Smake_frame_visible
);
4130 defsubr (&Smake_frame_invisible
);
4131 defsubr (&Siconify_frame
);
4132 defsubr (&Sframe_visible_p
);
4133 defsubr (&Svisible_frame_list
);
4134 defsubr (&Sraise_frame
);
4135 defsubr (&Slower_frame
);
4136 defsubr (&Sredirect_frame_focus
);
4137 defsubr (&Sframe_focus
);
4138 defsubr (&Sframe_parameters
);
4139 defsubr (&Sframe_parameter
);
4140 defsubr (&Smodify_frame_parameters
);
4141 defsubr (&Sframe_char_height
);
4142 defsubr (&Sframe_char_width
);
4143 defsubr (&Sframe_pixel_height
);
4144 defsubr (&Sframe_pixel_width
);
4145 defsubr (&Sset_frame_height
);
4146 defsubr (&Sset_frame_width
);
4147 defsubr (&Sset_frame_size
);
4148 defsubr (&Sset_frame_position
);
4150 #ifdef HAVE_WINDOW_SYSTEM
4151 defsubr (&Sx_get_resource
);
4152 defsubr (&Sx_parse_geometry
);
4157 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4158 (do not change this comment) */