1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 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., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
26 #include "character.h"
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 #ifdef USE_FONT_BACKEND
58 #endif /* USE_FONT_BACKEND */
60 /* The name we're using in resource queries. Most often "emacs". */
62 Lisp_Object Vx_resource_name
;
64 /* The application class we're using in resource queries.
67 Lisp_Object Vx_resource_class
;
71 Lisp_Object Qframep
, Qframe_live_p
;
72 Lisp_Object Qicon
, Qmodeline
;
74 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
;
76 Lisp_Object Qdisplay_type
;
77 Lisp_Object Qbackground_mode
;
79 Lisp_Object Qx_frame_parameter
;
80 Lisp_Object Qx_resource_name
;
82 /* Frame parameters (set or reported). */
84 Lisp_Object Qauto_raise
, Qauto_lower
;
85 Lisp_Object Qborder_color
, Qborder_width
;
86 Lisp_Object Qcursor_color
, Qcursor_type
;
87 Lisp_Object Qgeometry
; /* Not used */
88 Lisp_Object Qheight
, Qwidth
;
89 Lisp_Object Qleft
, Qright
;
90 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
91 Lisp_Object Qinternal_border_width
;
92 Lisp_Object Qmouse_color
;
93 Lisp_Object Qminibuffer
;
94 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
95 Lisp_Object Qvisibility
;
96 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
97 Lisp_Object Qscreen_gamma
;
98 Lisp_Object Qline_spacing
;
99 Lisp_Object Quser_position
, Quser_size
;
100 Lisp_Object Qwait_for_wm
;
101 Lisp_Object Qwindow_id
;
102 #ifdef HAVE_X_WINDOWS
103 Lisp_Object Qouter_window_id
;
105 Lisp_Object Qparent_id
;
106 Lisp_Object Qtitle
, Qname
;
107 Lisp_Object Qunsplittable
;
108 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
109 Lisp_Object Qleft_fringe
, Qright_fringe
;
110 Lisp_Object Qbuffer_predicate
, Qbuffer_list
;
111 Lisp_Object Qtty_color_mode
;
113 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
;
114 #ifdef USE_FONT_BACKEND
115 Lisp_Object Qfont_backend
;
116 #endif /* USE_FONT_BACKEND */
118 Lisp_Object Qinhibit_face_set_after_frame_default
;
119 Lisp_Object Qface_set_after_frame_default
;
122 Lisp_Object Vterminal_frame
;
123 Lisp_Object Vdefault_frame_alist
;
124 Lisp_Object Vdefault_frame_scroll_bars
;
125 Lisp_Object Vmouse_position_function
;
126 Lisp_Object Vmouse_highlight
;
127 Lisp_Object Vdelete_frame_functions
;
130 set_menu_bar_lines_1 (window
, n
)
134 struct window
*w
= XWINDOW (window
);
136 XSETFASTINT (w
->last_modified
, 0);
137 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
138 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
140 if (INTEGERP (w
->orig_top_line
))
141 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
142 if (INTEGERP (w
->orig_total_lines
))
143 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
145 /* Handle just the top child in a vertical split. */
146 if (!NILP (w
->vchild
))
147 set_menu_bar_lines_1 (w
->vchild
, n
);
149 /* Adjust all children in a horizontal split. */
150 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
152 w
= XWINDOW (window
);
153 set_menu_bar_lines_1 (window
, n
);
158 set_menu_bar_lines (f
, value
, oldval
)
160 Lisp_Object value
, oldval
;
163 int olines
= FRAME_MENU_BAR_LINES (f
);
165 /* Right now, menu bars don't work properly in minibuf-only frames;
166 most of the commands try to apply themselves to the minibuffer
167 frame itself, and get an error because you can't switch buffers
168 in or split the minibuffer window. */
169 if (FRAME_MINIBUF_ONLY_P (f
))
172 if (INTEGERP (value
))
173 nlines
= XINT (value
);
177 if (nlines
!= olines
)
179 windows_or_buffers_changed
++;
180 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
181 FRAME_MENU_BAR_LINES (f
) = nlines
;
182 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
187 Lisp_Object Vemacs_iconified
;
188 Lisp_Object Vframe_list
;
190 struct x_output tty_display
;
192 extern Lisp_Object Vminibuffer_list
;
193 extern Lisp_Object
get_minibuffer ();
194 extern Lisp_Object
Fhandle_switch_frame ();
195 extern Lisp_Object
Fredirect_frame_focus ();
196 extern Lisp_Object
x_get_focus_frame ();
198 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
199 doc
: /* Return non-nil if OBJECT is a frame.
200 Value is t for a termcap frame (a character-only terminal),
201 `x' for an Emacs frame that is really an X window,
202 `w32' for an Emacs frame that is a window on MS-Windows display,
203 `mac' for an Emacs frame on a Macintosh display,
204 `pc' for a direct-write MS-DOS frame.
205 See also `frame-live-p'. */)
209 if (!FRAMEP (object
))
211 switch (XFRAME (object
)->output_method
)
215 case output_x_window
:
219 case output_msdos_raw
:
228 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
229 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
230 Value is nil if OBJECT is not a live frame. If object is a live
231 frame, the return value indicates what sort of output device it is
232 displayed on. See the documentation of `framep' for possible
237 return ((FRAMEP (object
)
238 && FRAME_LIVE_P (XFRAME (object
)))
248 register struct frame
*f
;
249 register Lisp_Object root_window
;
250 register Lisp_Object mini_window
;
252 f
= allocate_frame ();
253 XSETFRAME (frame
, f
);
255 f
->desired_matrix
= 0;
256 f
->current_matrix
= 0;
259 f
->glyphs_initialized_p
= 0;
260 f
->decode_mode_spec_buffer
= 0;
262 f
->async_visible
= 0;
263 f
->output_data
.nothing
= 0;
265 f
->async_iconified
= 0;
266 f
->wants_modeline
= 1;
271 f
->has_minibuffer
= mini_p
;
272 f
->focus_frame
= Qnil
;
273 f
->explicit_name
= 0;
274 f
->can_have_scroll_bars
= 0;
275 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
276 f
->param_alist
= Qnil
;
277 f
->scroll_bars
= Qnil
;
278 f
->condemned_scroll_bars
= Qnil
;
279 f
->face_alist
= Qnil
;
280 f
->face_cache
= NULL
;
281 f
->menu_bar_items
= Qnil
;
282 f
->menu_bar_vector
= Qnil
;
283 f
->menu_bar_items_used
= 0;
284 f
->buffer_predicate
= Qnil
;
285 f
->buffer_list
= Qnil
;
287 f
->kboard
= initial_kboard
;
291 f
->menu_bar_window
= Qnil
;
292 f
->tool_bar_window
= Qnil
;
293 f
->tool_bar_items
= Qnil
;
294 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
295 f
->n_tool_bar_items
= 0;
296 f
->left_fringe_width
= f
->right_fringe_width
= 0;
298 f
->scroll_bar_actual_width
= 0;
300 f
->internal_border_width
= 0;
301 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
302 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
303 f
->x_pixels_diff
= f
->y_pixels_diff
= 0;
304 #ifdef HAVE_WINDOW_SYSTEM
305 f
->want_fullscreen
= FULLSCREEN_NONE
;
307 f
->size_hint_flags
= 0;
309 #ifdef USE_FONT_BACKEND
310 f
->font_driver_list
= NULL
;
311 #endif /* USE_FONT_BACKEND */
313 root_window
= make_window ();
316 mini_window
= make_window ();
317 XWINDOW (root_window
)->next
= mini_window
;
318 XWINDOW (mini_window
)->prev
= root_window
;
319 XWINDOW (mini_window
)->mini_p
= Qt
;
320 XWINDOW (mini_window
)->frame
= frame
;
321 f
->minibuffer_window
= mini_window
;
326 XWINDOW (root_window
)->next
= Qnil
;
327 f
->minibuffer_window
= Qnil
;
330 XWINDOW (root_window
)->frame
= frame
;
333 just so that there is "something there."
334 Correct size will be set up later with change_frame_size. */
336 SET_FRAME_COLS (f
, 10);
337 FRAME_LINES (f
) = 10;
339 XSETFASTINT (XWINDOW (root_window
)->total_cols
, 10);
340 XSETFASTINT (XWINDOW (root_window
)->total_lines
, (mini_p
? 9 : 10));
344 XSETFASTINT (XWINDOW (mini_window
)->total_cols
, 10);
345 XSETFASTINT (XWINDOW (mini_window
)->top_line
, 9);
346 XSETFASTINT (XWINDOW (mini_window
)->total_lines
, 1);
349 /* Choose a buffer for the frame's root window. */
353 XWINDOW (root_window
)->buffer
= Qt
;
354 buf
= Fcurrent_buffer ();
355 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
356 a space), try to find another one. */
357 if (SREF (Fbuffer_name (buf
), 0) == ' ')
358 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
360 /* Use set_window_buffer, not Fset_window_buffer, and don't let
361 hooks be run by it. The reason is that the whole frame/window
362 arrangement is not yet fully intialized at this point. Windows
363 don't have the right size, glyph matrices aren't initialized
364 etc. Running Lisp functions at this point surely ends in a
366 set_window_buffer (root_window
, buf
, 0, 0);
367 f
->buffer_list
= Fcons (buf
, Qnil
);
372 XWINDOW (mini_window
)->buffer
= Qt
;
373 set_window_buffer (mini_window
,
374 (NILP (Vminibuffer_list
)
376 : Fcar (Vminibuffer_list
)),
380 f
->root_window
= root_window
;
381 f
->selected_window
= root_window
;
382 /* Make sure this window seems more recently used than
383 a newly-created, never-selected window. */
384 ++window_select_count
;
385 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, window_select_count
);
387 f
->default_face_done_p
= 0;
392 #ifdef HAVE_WINDOW_SYSTEM
393 /* Make a frame using a separate minibuffer window on another frame.
394 MINI_WINDOW is the minibuffer window to use. nil means use the
395 default (the global minibuffer). */
398 make_frame_without_minibuffer (mini_window
, kb
, display
)
399 register Lisp_Object mini_window
;
403 register struct frame
*f
;
406 if (!NILP (mini_window
))
407 CHECK_LIVE_WINDOW (mini_window
);
410 if (!NILP (mini_window
)
411 && XFRAME (XWINDOW (mini_window
)->frame
)->kboard
!= kb
)
412 error ("Frame and minibuffer must be on the same display");
415 /* Make a frame containing just a root window. */
418 if (NILP (mini_window
))
420 /* Use default-minibuffer-frame if possible. */
421 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
422 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
424 Lisp_Object frame_dummy
;
426 XSETFRAME (frame_dummy
, f
);
427 GCPRO1 (frame_dummy
);
428 /* If there's no minibuffer frame to use, create one. */
429 kb
->Vdefault_minibuffer_frame
=
430 call1 (intern ("make-initial-minibuffer-frame"), display
);
434 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
437 f
->minibuffer_window
= mini_window
;
439 /* Make the chosen minibuffer window display the proper minibuffer,
440 unless it is already showing a minibuffer. */
441 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
442 Fset_window_buffer (mini_window
,
443 (NILP (Vminibuffer_list
)
445 : Fcar (Vminibuffer_list
)), Qnil
);
449 /* Make a frame containing only a minibuffer window. */
452 make_minibuffer_frame ()
454 /* First make a frame containing just a root window, no minibuffer. */
456 register struct frame
*f
= make_frame (0);
457 register Lisp_Object mini_window
;
458 register Lisp_Object frame
;
460 XSETFRAME (frame
, f
);
465 f
->wants_modeline
= 0;
466 f
->has_minibuffer
= 1;
468 /* Now label the root window as also being the minibuffer.
469 Avoid infinite looping on the window chain by marking next pointer
472 mini_window
= f
->minibuffer_window
= f
->root_window
;
473 XWINDOW (mini_window
)->mini_p
= Qt
;
474 XWINDOW (mini_window
)->next
= Qnil
;
475 XWINDOW (mini_window
)->prev
= Qnil
;
476 XWINDOW (mini_window
)->frame
= frame
;
478 /* Put the proper buffer in that window. */
480 Fset_window_buffer (mini_window
,
481 (NILP (Vminibuffer_list
)
483 : Fcar (Vminibuffer_list
)), Qnil
);
486 #endif /* HAVE_WINDOW_SYSTEM */
488 /* Construct a frame that refers to the terminal (stdin and stdout). */
490 static int terminal_frame_count
;
493 make_terminal_frame ()
495 register struct frame
*f
;
502 initial_kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
503 init_kboard (initial_kboard
);
504 initial_kboard
->next_kboard
= all_kboards
;
505 all_kboards
= initial_kboard
;
509 /* The first call must initialize Vframe_list. */
510 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
515 XSETFRAME (frame
, f
);
516 Vframe_list
= Fcons (frame
, Vframe_list
);
518 terminal_frame_count
++;
519 sprintf (name
, "F%d", terminal_frame_count
);
520 f
->name
= build_string (name
);
522 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
523 f
->async_visible
= 1; /* Don't let visible be cleared later. */
525 f
->output_data
.x
= &the_only_x_display
;
526 if (!inhibit_window_system
527 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
528 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
530 f
->output_method
= output_msdos_raw
;
531 /* This initialization of foreground and background pixels is
532 only important for the initial frame created in temacs. If
533 we don't do that, we get black background and foreground in
534 the dumped Emacs because the_only_x_display is a static
535 variable, hence it is born all-zeroes, and zero is the code
536 for the black color. Other frames all inherit their pixels
537 from what's already in the_only_x_display. */
538 if ((!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
539 && f
->output_data
.x
->background_pixel
== 0
540 && f
->output_data
.x
->foreground_pixel
== 0)
542 f
->output_data
.x
->background_pixel
= FACE_TTY_DEFAULT_BG_COLOR
;
543 f
->output_data
.x
->foreground_pixel
= FACE_TTY_DEFAULT_FG_COLOR
;
547 f
->output_method
= output_termcap
;
550 f
->output_method
= output_termcap
;
551 f
->output_data
.x
= &tty_display
;
554 make_mac_terminal_frame (f
);
556 f
->output_data
.x
= &tty_display
;
558 FRAME_FOREGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_FG_COLOR
;
559 FRAME_BACKGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_BG_COLOR
;
562 #endif /* WINDOWSNT */
566 init_frame_faces (f
);
571 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
573 doc
: /* Create an additional terminal frame.
574 You can create multiple frames on a text-only terminal in this way.
575 Only the selected terminal frame is actually displayed.
576 This function takes one argument, an alist specifying frame parameters.
577 In practice, generally you don't need to specify any parameters.
578 Note that changing the size of one terminal frame automatically affects all. */)
583 Lisp_Object frame
, tem
;
584 struct frame
*sf
= SELECTED_FRAME ();
587 if (sf
->output_method
!= output_msdos_raw
588 && sf
->output_method
!= output_termcap
)
590 #else /* not MSDOS */
593 if (sf
->output_method
!= output_mac
)
594 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
596 if (sf
->output_method
!= output_termcap
)
597 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
599 #endif /* not MSDOS */
601 f
= make_terminal_frame ();
603 change_frame_size (f
, FRAME_LINES (sf
),
604 FRAME_COLS (sf
), 0, 0, 0);
607 XSETFRAME (frame
, f
);
608 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
609 Fmodify_frame_parameters (frame
, parms
);
611 /* Make the frame face alist be frame-specific, so that each
612 frame could change its face definitions independently. */
613 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
614 /* Simple Fcopy_alist isn't enough, because we need the contents of
615 the vectors which are the CDRs of associations in face_alist to
616 be copied as well. */
617 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
618 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
623 /* Perform the switch to frame FRAME.
625 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
628 If TRACK is non-zero and the frame that currently has the focus
629 redirects its focus to the selected frame, redirect that focused
630 frame's focus to FRAME instead.
632 FOR_DELETION non-zero means that the selected frame is being
633 deleted, which includes the possibility that the frame's display
637 do_switch_frame (frame
, track
, for_deletion
)
639 int track
, for_deletion
;
641 struct frame
*sf
= SELECTED_FRAME ();
643 /* If FRAME is a switch-frame event, extract the frame we should
646 && EQ (XCAR (frame
), Qswitch_frame
)
647 && CONSP (XCDR (frame
)))
648 frame
= XCAR (XCDR (frame
));
650 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
651 a switch-frame event to arrive after a frame is no longer live,
652 especially when deleting the initial frame during startup. */
654 if (! FRAME_LIVE_P (XFRAME (frame
)))
657 if (sf
== XFRAME (frame
))
660 /* This is too greedy; it causes inappropriate focus redirection
661 that's hard to get rid of. */
663 /* If a frame's focus has been redirected toward the currently
664 selected frame, we should change the redirection to point to the
665 newly selected frame. This means that if the focus is redirected
666 from a minibufferless frame to a surrogate minibuffer frame, we
667 can use `other-window' to switch between all the frames using
668 that minibuffer frame, and the focus redirection will follow us
674 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
678 if (!FRAMEP (XCAR (tail
)))
681 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
683 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
684 Fredirect_frame_focus (XCAR (tail
), frame
);
688 /* Instead, apply it only to the frame we're pointing to. */
689 #ifdef HAVE_WINDOW_SYSTEM
690 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
692 Lisp_Object focus
, xfocus
;
694 xfocus
= x_get_focus_frame (XFRAME (frame
));
697 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
698 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
699 Fredirect_frame_focus (xfocus
, frame
);
702 #endif /* HAVE_X_WINDOWS */
705 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
706 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
708 selected_frame
= frame
;
709 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
710 last_nonminibuf_frame
= XFRAME (selected_frame
);
712 Fselect_window (XFRAME (frame
)->selected_window
, Qnil
);
715 /* Make sure to switch the tty color mode to that of the newly
717 sf
= SELECTED_FRAME ();
718 if (FRAME_TERMCAP_P (sf
))
720 Lisp_Object color_mode_spec
, color_mode
;
722 color_mode_spec
= assq_no_quit (Qtty_color_mode
, sf
->param_alist
);
723 if (CONSP (color_mode_spec
))
724 color_mode
= XCDR (color_mode_spec
);
726 color_mode
= make_number (0);
727 set_tty_color_mode (sf
, color_mode
);
729 #endif /* !WINDOWSNT */
731 /* We want to make sure that the next event generates a frame-switch
732 event to the appropriate frame. This seems kludgy to me, but
733 before you take it out, make sure that evaluating something like
734 (select-window (frame-root-window (new-frame))) doesn't end up
735 with your typing being interpreted in the new frame instead of
736 the one you're actually typing in. */
737 internal_last_event_frame
= Qnil
;
742 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 1, "e",
743 doc
: /* Select the frame FRAME.
744 Subsequent editing commands apply to its selected window.
745 The selection of FRAME lasts until the next time the user does
746 something to select a different frame, or until the next time this
747 function is called. If you are using a window system, the previously
748 selected frame may be restored as the selected frame after return to
749 the command loop, because it still may have the window system's input
750 focus. On a text-only terminal, the next redisplay will display FRAME.
752 This function returns FRAME, or nil if FRAME has been deleted. */)
756 return do_switch_frame (frame
, 1, 0);
760 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
761 doc
: /* Handle a switch-frame event EVENT.
762 Switch-frame events are usually bound to this function.
763 A switch-frame event tells Emacs that the window manager has requested
764 that the user's events be directed to the frame mentioned in the event.
765 This function selects the selected window of the frame of EVENT.
767 If EVENT is frame object, handle it as if it were a switch-frame event
772 /* Preserve prefix arg that the command loop just cleared. */
773 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
774 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
775 return do_switch_frame (event
, 0, 0);
778 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
779 doc
: /* Return the frame that is now selected. */)
782 return selected_frame
;
785 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
786 doc
: /* Return the frame object that window WINDOW is on. */)
790 CHECK_LIVE_WINDOW (window
);
791 return XWINDOW (window
)->frame
;
794 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
795 doc
: /* Returns the topmost, leftmost window of FRAME.
796 If omitted, FRAME defaults to the currently selected frame. */)
803 w
= SELECTED_FRAME ()->root_window
;
806 CHECK_LIVE_FRAME (frame
);
807 w
= XFRAME (frame
)->root_window
;
809 while (NILP (XWINDOW (w
)->buffer
))
811 if (! NILP (XWINDOW (w
)->hchild
))
812 w
= XWINDOW (w
)->hchild
;
813 else if (! NILP (XWINDOW (w
)->vchild
))
814 w
= XWINDOW (w
)->vchild
;
821 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
822 Sactive_minibuffer_window
, 0, 0, 0,
823 doc
: /* Return the currently active minibuffer window, or nil if none. */)
826 return minibuf_level
? minibuf_window
: Qnil
;
829 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
830 doc
: /* Returns the root-window of FRAME.
831 If omitted, FRAME defaults to the currently selected frame. */)
838 window
= SELECTED_FRAME ()->root_window
;
841 CHECK_LIVE_FRAME (frame
);
842 window
= XFRAME (frame
)->root_window
;
848 DEFUN ("frame-selected-window", Fframe_selected_window
,
849 Sframe_selected_window
, 0, 1, 0,
850 doc
: /* Return the selected window of frame object FRAME.
851 If omitted, FRAME defaults to the currently selected frame. */)
858 window
= SELECTED_FRAME ()->selected_window
;
861 CHECK_LIVE_FRAME (frame
);
862 window
= XFRAME (frame
)->selected_window
;
868 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
869 Sset_frame_selected_window
, 2, 2, 0,
870 doc
: /* Set the selected window of frame object FRAME to WINDOW.
872 If FRAME is nil, the selected frame is used.
873 If FRAME is the selected frame, this makes WINDOW the selected window. */)
875 Lisp_Object frame
, window
;
878 frame
= selected_frame
;
880 CHECK_LIVE_FRAME (frame
);
881 CHECK_LIVE_WINDOW (window
);
883 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
884 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
886 if (EQ (frame
, selected_frame
))
887 return Fselect_window (window
, Qnil
);
889 return XFRAME (frame
)->selected_window
= window
;
892 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
894 doc
: /* Return a list of all frames. */)
898 frames
= Fcopy_sequence (Vframe_list
);
899 #ifdef HAVE_WINDOW_SYSTEM
900 if (FRAMEP (tip_frame
))
901 frames
= Fdelq (tip_frame
, frames
);
906 /* Return the next frame in the frame list after FRAME.
907 If MINIBUF is nil, exclude minibuffer-only frames.
908 If MINIBUF is a window, include only its own frame
909 and any frame now using that window as the minibuffer.
910 If MINIBUF is `visible', include all visible frames.
911 If MINIBUF is 0, include all visible and iconified frames.
912 Otherwise, include all frames. */
915 next_frame (frame
, minibuf
)
922 /* There must always be at least one frame in Vframe_list. */
923 if (! CONSP (Vframe_list
))
926 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
927 forever. Forestall that. */
928 CHECK_LIVE_FRAME (frame
);
931 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
938 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
940 /* Decide whether this frame is eligible to be returned. */
942 /* If we've looped all the way around without finding any
943 eligible frames, return the original frame. */
947 /* Let minibuf decide if this frame is acceptable. */
950 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
953 else if (EQ (minibuf
, Qvisible
))
955 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
956 if (FRAME_VISIBLE_P (XFRAME (f
)))
959 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
961 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
962 if (FRAME_VISIBLE_P (XFRAME (f
))
963 || FRAME_ICONIFIED_P (XFRAME (f
)))
966 else if (WINDOWP (minibuf
))
968 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
969 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
970 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
971 FRAME_FOCUS_FRAME (XFRAME (f
))))
983 /* Return the previous frame in the frame list before FRAME.
984 If MINIBUF is nil, exclude minibuffer-only frames.
985 If MINIBUF is a window, include only its own frame
986 and any frame now using that window as the minibuffer.
987 If MINIBUF is `visible', include all visible frames.
988 If MINIBUF is 0, include all visible and iconified frames.
989 Otherwise, include all frames. */
992 prev_frame (frame
, minibuf
)
999 /* There must always be at least one frame in Vframe_list. */
1000 if (! CONSP (Vframe_list
))
1004 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1012 if (EQ (frame
, f
) && !NILP (prev
))
1015 if (FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1017 /* Decide whether this frame is eligible to be returned,
1018 according to minibuf. */
1021 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1024 else if (WINDOWP (minibuf
))
1026 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1027 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1028 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1029 FRAME_FOCUS_FRAME (XFRAME (f
))))
1032 else if (EQ (minibuf
, Qvisible
))
1034 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1035 if (FRAME_VISIBLE_P (XFRAME (f
)))
1038 else if (XFASTINT (minibuf
) == 0)
1040 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1041 if (FRAME_VISIBLE_P (XFRAME (f
))
1042 || FRAME_ICONIFIED_P (XFRAME (f
)))
1050 /* We've scanned the entire list. */
1052 /* We went through the whole frame list without finding a single
1053 acceptable frame. Return the original frame. */
1056 /* There were no acceptable frames in the list before FRAME; otherwise,
1057 we would have returned directly from the loop. Since PREV is the last
1058 acceptable frame in the list, return it. */
1063 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1064 doc
: /* Return the next frame in the frame list after FRAME.
1065 It considers only frames on the same terminal as FRAME.
1066 By default, skip minibuffer-only frames.
1067 If omitted, FRAME defaults to the selected frame.
1068 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1069 If MINIFRAME is a window, include only its own frame
1070 and any frame now using that window as the minibuffer.
1071 If MINIFRAME is `visible', include all visible frames.
1072 If MINIFRAME is 0, include all visible and iconified frames.
1073 Otherwise, include all frames. */)
1075 Lisp_Object frame
, miniframe
;
1078 frame
= selected_frame
;
1080 CHECK_LIVE_FRAME (frame
);
1081 return next_frame (frame
, miniframe
);
1084 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1085 doc
: /* Return the previous frame in the frame list before FRAME.
1086 It considers only frames on the same terminal as FRAME.
1087 By default, skip minibuffer-only frames.
1088 If omitted, FRAME defaults to the selected frame.
1089 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1090 If MINIFRAME is a window, include only its own frame
1091 and any frame now using that window as the minibuffer.
1092 If MINIFRAME is `visible', include all visible frames.
1093 If MINIFRAME is 0, include all visible and iconified frames.
1094 Otherwise, include all frames. */)
1096 Lisp_Object frame
, miniframe
;
1099 frame
= selected_frame
;
1100 CHECK_LIVE_FRAME (frame
);
1101 return prev_frame (frame
, miniframe
);
1104 /* Return 1 if it is ok to delete frame F;
1105 0 if all frames aside from F are invisible.
1106 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1109 other_visible_frames (f
)
1112 /* We know the selected frame is visible,
1113 so if F is some other frame, it can't be the sole visible one. */
1114 if (f
== SELECTED_FRAME ())
1119 for (frames
= Vframe_list
;
1121 frames
= XCDR (frames
))
1125 this = XCAR (frames
);
1126 /* Verify that the frame's window still exists
1127 and we can still talk to it. And note any recent change
1129 #ifdef HAVE_WINDOW_SYSTEM
1130 if (FRAME_WINDOW_P (XFRAME (this)))
1132 x_sync (XFRAME (this));
1133 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1137 if (FRAME_VISIBLE_P (XFRAME (this))
1138 || FRAME_ICONIFIED_P (XFRAME (this))
1139 /* Allow deleting the terminal frame when at least
1140 one X frame exists! */
1141 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1149 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1150 doc
: /* Delete FRAME, permanently eliminating it from use.
1151 If omitted, FRAME defaults to the selected frame.
1152 A frame may not be deleted if its minibuffer is used by other frames.
1153 Normally, you may not delete a frame if all other frames are invisible,
1154 but if the second optional argument FORCE is non-nil, you may do so.
1156 This function runs `delete-frame-functions' before actually deleting the
1157 frame, unless the frame is a tooltip.
1158 The functions are run with one arg, the frame to be deleted. */)
1160 Lisp_Object frame
, force
;
1163 struct frame
*sf
= SELECTED_FRAME ();
1164 int minibuffer_selected
;
1166 if (EQ (frame
, Qnil
))
1169 XSETFRAME (frame
, f
);
1173 CHECK_FRAME (frame
);
1177 if (! FRAME_LIVE_P (f
))
1180 if (NILP (force
) && !other_visible_frames (f
)
1182 /* Terminal frame deleted before any other visible frames are
1184 && strcmp (SDATA (f
->name
), "F1") != 0
1187 error ("Attempt to delete the sole visible or iconified frame");
1190 /* This is a nice idea, but x_connection_closed needs to be able
1191 to delete the last frame, if it is gone. */
1192 if (NILP (XCDR (Vframe_list
)))
1193 error ("Attempt to delete the only frame");
1196 /* Does this frame have a minibuffer, and is it the surrogate
1197 minibuffer for any other frame? */
1198 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1202 for (frames
= Vframe_list
;
1204 frames
= XCDR (frames
))
1207 this = XCAR (frames
);
1209 if (! EQ (this, frame
)
1211 WINDOW_FRAME (XWINDOW
1212 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1213 error ("Attempt to delete a surrogate minibuffer frame");
1217 /* Run `delete-frame-functions' unless frame is a tooltip. */
1218 if (!NILP (Vrun_hooks
)
1219 && NILP (Fframe_parameter (frame
, intern ("tooltip"))))
1221 Lisp_Object args
[2];
1222 args
[0] = intern ("delete-frame-functions");
1224 Frun_hook_with_args (2, args
);
1227 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1229 /* Don't let the frame remain selected. */
1232 Lisp_Object tail
, frame1
;
1234 /* Look for another visible frame on the same terminal. */
1235 frame1
= next_frame (frame
, Qvisible
);
1237 /* If there is none, find *some* other frame. */
1238 if (NILP (frame1
) || EQ (frame1
, frame
))
1240 FOR_EACH_FRAME (tail
, frame1
)
1242 if (! EQ (frame
, frame1
))
1247 do_switch_frame (frame1
, 0, 1);
1248 sf
= SELECTED_FRAME ();
1251 /* Don't allow minibuf_window to remain on a deleted frame. */
1252 if (EQ (f
->minibuffer_window
, minibuf_window
))
1254 Fset_window_buffer (sf
->minibuffer_window
,
1255 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1256 minibuf_window
= sf
->minibuffer_window
;
1258 /* If the dying minibuffer window was selected,
1259 select the new one. */
1260 if (minibuffer_selected
)
1261 Fselect_window (minibuf_window
, Qnil
);
1264 /* Don't let echo_area_window to remain on a deleted frame. */
1265 if (EQ (f
->minibuffer_window
, echo_area_window
))
1266 echo_area_window
= sf
->minibuffer_window
;
1268 /* Clear any X selections for this frame. */
1269 #ifdef HAVE_X_WINDOWS
1271 x_clear_frame_selections (f
);
1274 if (FRAME_MAC_P (f
))
1275 x_clear_frame_selections (f
);
1279 This function must be called before the window tree of the
1280 frame is deleted because windows contain dynamically allocated
1284 /* Mark all the windows that used to be on FRAME as deleted, and then
1285 remove the reference to them. */
1286 delete_all_subwindows (XWINDOW (f
->root_window
));
1287 f
->root_window
= Qnil
;
1289 Vframe_list
= Fdelq (frame
, Vframe_list
);
1290 FRAME_SET_VISIBLE (f
, 0);
1294 if (f
->decode_mode_spec_buffer
)
1295 xfree (f
->decode_mode_spec_buffer
);
1296 if (FRAME_INSERT_COST (f
))
1297 xfree (FRAME_INSERT_COST (f
));
1298 if (FRAME_DELETEN_COST (f
))
1299 xfree (FRAME_DELETEN_COST (f
));
1300 if (FRAME_INSERTN_COST (f
))
1301 xfree (FRAME_INSERTN_COST (f
));
1302 if (FRAME_DELETE_COST (f
))
1303 xfree (FRAME_DELETE_COST (f
));
1304 if (FRAME_MESSAGE_BUF (f
))
1305 xfree (FRAME_MESSAGE_BUF (f
));
1307 /* Since some events are handled at the interrupt level, we may get
1308 an event for f at any time; if we zero out the frame's display
1309 now, then we may trip up the event-handling code. Instead, we'll
1310 promise that the display of the frame must be valid until we have
1311 called the window-system-dependent frame destruction routine. */
1313 /* I think this should be done with a hook. */
1314 #ifdef HAVE_WINDOW_SYSTEM
1315 if (FRAME_WINDOW_P (f
))
1316 x_destroy_window (f
);
1319 f
->output_data
.nothing
= 0;
1321 /* If we've deleted the last_nonminibuf_frame, then try to find
1323 if (f
== last_nonminibuf_frame
)
1327 last_nonminibuf_frame
= 0;
1329 for (frames
= Vframe_list
;
1331 frames
= XCDR (frames
))
1333 f
= XFRAME (XCAR (frames
));
1334 if (!FRAME_MINIBUF_ONLY_P (f
))
1336 last_nonminibuf_frame
= f
;
1342 /* If there's no other frame on the same kboard, get out of
1343 single-kboard state if we're in it for this kboard. */
1346 /* Some frame we found on the same kboard, or nil if there are none. */
1347 Lisp_Object frame_on_same_kboard
;
1349 frame_on_same_kboard
= Qnil
;
1351 for (frames
= Vframe_list
;
1353 frames
= XCDR (frames
))
1358 this = XCAR (frames
);
1363 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1364 frame_on_same_kboard
= this;
1367 if (NILP (frame_on_same_kboard
))
1368 not_single_kboard_state (FRAME_KBOARD (f
));
1372 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1373 find another one. Prefer minibuffer-only frames, but also notice
1374 frames with other windows. */
1375 if (EQ (frame
, FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
))
1379 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1380 Lisp_Object frame_with_minibuf
;
1381 /* Some frame we found on the same kboard, or nil if there are none. */
1382 Lisp_Object frame_on_same_kboard
;
1384 frame_on_same_kboard
= Qnil
;
1385 frame_with_minibuf
= Qnil
;
1387 for (frames
= Vframe_list
;
1389 frames
= XCDR (frames
))
1394 this = XCAR (frames
);
1399 /* Consider only frames on the same kboard
1400 and only those with minibuffers. */
1401 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
)
1402 && FRAME_HAS_MINIBUF_P (f1
))
1404 frame_with_minibuf
= this;
1405 if (FRAME_MINIBUF_ONLY_P (f1
))
1409 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1410 frame_on_same_kboard
= this;
1413 if (!NILP (frame_on_same_kboard
))
1415 /* We know that there must be some frame with a minibuffer out
1416 there. If this were not true, all of the frames present
1417 would have to be minibufferless, which implies that at some
1418 point their minibuffer frames must have been deleted, but
1419 that is prohibited at the top; you can't delete surrogate
1420 minibuffer frames. */
1421 if (NILP (frame_with_minibuf
))
1424 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1427 /* No frames left on this kboard--say no minibuffer either. */
1428 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= Qnil
;
1431 /* Cause frame titles to update--necessary if we now have just one frame. */
1432 update_mode_lines
= 1;
1437 /* Return mouse position in character cell units. */
1439 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1440 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1441 The position is given in character cells, where (0, 0) is the
1442 upper-left corner of the frame, X is the horizontal offset, and Y is
1443 the vertical offset.
1444 If Emacs is running on a mouseless terminal or hasn't been programmed
1445 to read the mouse position, it returns the selected frame for FRAME
1446 and nil for X and Y.
1447 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1448 passing the normal return value to that function as an argument,
1449 and returns whatever that function returns. */)
1453 Lisp_Object lispy_dummy
;
1454 enum scroll_bar_part party_dummy
;
1455 Lisp_Object x
, y
, retval
;
1457 unsigned long long_dummy
;
1458 struct gcpro gcpro1
;
1460 f
= SELECTED_FRAME ();
1463 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1464 /* It's okay for the hook to refrain from storing anything. */
1465 if (mouse_position_hook
)
1466 (*mouse_position_hook
) (&f
, -1,
1467 &lispy_dummy
, &party_dummy
,
1474 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1479 XSETFRAME (lispy_dummy
, f
);
1480 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1482 if (!NILP (Vmouse_position_function
))
1483 retval
= call1 (Vmouse_position_function
, retval
);
1484 RETURN_UNGCPRO (retval
);
1487 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1488 Smouse_pixel_position
, 0, 0, 0,
1489 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1490 The position is given in pixel units, where (0, 0) is the
1491 upper-left corner of the frame, X is the horizontal offset, and Y is
1492 the vertical offset.
1493 If Emacs is running on a mouseless terminal or hasn't been programmed
1494 to read the mouse position, it returns the selected frame for FRAME
1495 and nil for X and Y. */)
1499 Lisp_Object lispy_dummy
;
1500 enum scroll_bar_part party_dummy
;
1502 unsigned long long_dummy
;
1504 f
= SELECTED_FRAME ();
1507 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1508 /* It's okay for the hook to refrain from storing anything. */
1509 if (mouse_position_hook
)
1510 (*mouse_position_hook
) (&f
, -1,
1511 &lispy_dummy
, &party_dummy
,
1515 XSETFRAME (lispy_dummy
, f
);
1516 return Fcons (lispy_dummy
, Fcons (x
, y
));
1519 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1520 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1521 Coordinates are relative to the frame, not a window,
1522 so the coordinates of the top left character in the frame
1523 may be nonzero due to left-hand scroll bars or the menu bar.
1525 The position is given in character cells, where (0, 0) is the
1526 upper-left corner of the frame, X is the horizontal offset, and Y is
1527 the vertical offset.
1529 This function is a no-op for an X frame that is not visible.
1530 If you have just created a frame, you must wait for it to become visible
1531 before calling this function on it, like this.
1532 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1534 Lisp_Object frame
, x
, y
;
1536 CHECK_LIVE_FRAME (frame
);
1540 /* I think this should be done with a hook. */
1541 #ifdef HAVE_WINDOW_SYSTEM
1542 if (FRAME_WINDOW_P (XFRAME (frame
)))
1543 /* Warping the mouse will cause enternotify and focus events. */
1544 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1546 #if defined (MSDOS) && defined (HAVE_MOUSE)
1547 if (FRAME_MSDOS_P (XFRAME (frame
)))
1549 Fselect_frame (frame
);
1550 mouse_moveto (XINT (x
), XINT (y
));
1555 Fselect_frame (frame
);
1556 term_mouse_moveto (XINT (x
), XINT (y
));
1565 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1566 Sset_mouse_pixel_position
, 3, 3, 0,
1567 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1568 The position is given in pixels, where (0, 0) is the upper-left corner
1569 of the frame, X is the horizontal offset, and Y is the vertical offset.
1571 Note, this is a no-op for an X frame that is not visible.
1572 If you have just created a frame, you must wait for it to become visible
1573 before calling this function on it, like this.
1574 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1576 Lisp_Object frame
, x
, y
;
1578 CHECK_LIVE_FRAME (frame
);
1582 /* I think this should be done with a hook. */
1583 #ifdef HAVE_WINDOW_SYSTEM
1584 if (FRAME_WINDOW_P (XFRAME (frame
)))
1585 /* Warping the mouse will cause enternotify and focus events. */
1586 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1588 #if defined (MSDOS) && defined (HAVE_MOUSE)
1589 if (FRAME_MSDOS_P (XFRAME (frame
)))
1591 Fselect_frame (frame
);
1592 mouse_moveto (XINT (x
), XINT (y
));
1597 Fselect_frame (frame
);
1598 term_mouse_moveto (XINT (x
), XINT (y
));
1607 static void make_frame_visible_1
P_ ((Lisp_Object
));
1609 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1611 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1612 If omitted, FRAME defaults to the currently selected frame. */)
1617 frame
= selected_frame
;
1619 CHECK_LIVE_FRAME (frame
);
1621 /* I think this should be done with a hook. */
1622 #ifdef HAVE_WINDOW_SYSTEM
1623 if (FRAME_WINDOW_P (XFRAME (frame
)))
1625 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1626 x_make_frame_visible (XFRAME (frame
));
1630 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1632 /* Make menu bar update for the Buffers and Frames menus. */
1633 windows_or_buffers_changed
++;
1638 /* Update the display_time slot of the buffers shown in WINDOW
1639 and all its descendents. */
1642 make_frame_visible_1 (window
)
1647 for (;!NILP (window
); window
= w
->next
)
1649 w
= XWINDOW (window
);
1651 if (!NILP (w
->buffer
))
1652 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1654 if (!NILP (w
->vchild
))
1655 make_frame_visible_1 (w
->vchild
);
1656 if (!NILP (w
->hchild
))
1657 make_frame_visible_1 (w
->hchild
);
1661 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1663 doc
: /* Make the frame FRAME invisible (assuming it is an X window).
1664 If omitted, FRAME defaults to the currently selected frame.
1665 Normally you may not make FRAME invisible if all other frames are invisible,
1666 but if the second optional argument FORCE is non-nil, you may do so. */)
1668 Lisp_Object frame
, force
;
1671 frame
= selected_frame
;
1673 CHECK_LIVE_FRAME (frame
);
1675 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1676 error ("Attempt to make invisible the sole visible or iconified frame");
1678 #if 0 /* This isn't logically necessary, and it can do GC. */
1679 /* Don't let the frame remain selected. */
1680 if (EQ (frame
, selected_frame
))
1681 do_switch_frame (next_frame (frame
, Qt
), 0, 0)
1684 /* Don't allow minibuf_window to remain on a deleted frame. */
1685 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1687 struct frame
*sf
= XFRAME (selected_frame
);
1688 Fset_window_buffer (sf
->minibuffer_window
,
1689 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1690 minibuf_window
= sf
->minibuffer_window
;
1693 /* I think this should be done with a hook. */
1694 #ifdef HAVE_WINDOW_SYSTEM
1695 if (FRAME_WINDOW_P (XFRAME (frame
)))
1696 x_make_frame_invisible (XFRAME (frame
));
1699 /* Make menu bar update for the Buffers and Frames menus. */
1700 windows_or_buffers_changed
++;
1705 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1707 doc
: /* Make the frame FRAME into an icon.
1708 If omitted, FRAME defaults to the currently selected frame. */)
1713 frame
= selected_frame
;
1715 CHECK_LIVE_FRAME (frame
);
1717 #if 0 /* This isn't logically necessary, and it can do GC. */
1718 /* Don't let the frame remain selected. */
1719 if (EQ (frame
, selected_frame
))
1720 Fhandle_switch_frame (next_frame (frame
, Qt
));
1723 /* Don't allow minibuf_window to remain on a deleted frame. */
1724 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1726 struct frame
*sf
= XFRAME (selected_frame
);
1727 Fset_window_buffer (sf
->minibuffer_window
,
1728 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1729 minibuf_window
= sf
->minibuffer_window
;
1732 /* I think this should be done with a hook. */
1733 #ifdef HAVE_WINDOW_SYSTEM
1734 if (FRAME_WINDOW_P (XFRAME (frame
)))
1735 x_iconify_frame (XFRAME (frame
));
1738 /* Make menu bar update for the Buffers and Frames menus. */
1739 windows_or_buffers_changed
++;
1744 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1746 doc
: /* Return t if FRAME is now \"visible\" (actually in use for display).
1747 A frame that is not \"visible\" is not updated and, if it works through
1748 a window system, it may not show at all.
1749 Return the symbol `icon' if frame is visible only as an icon.
1751 On a text-only terminal, all frames are considered visible, whether
1752 they are currently being displayed or not, and this function returns t
1757 CHECK_LIVE_FRAME (frame
);
1759 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1761 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1763 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1768 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1770 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1773 Lisp_Object tail
, frame
;
1778 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1780 frame
= XCAR (tail
);
1781 if (!FRAMEP (frame
))
1784 if (FRAME_VISIBLE_P (f
))
1785 value
= Fcons (frame
, value
);
1791 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1792 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1793 If FRAME is invisible or iconified, make it visible.
1794 If you don't specify a frame, the selected frame is used.
1795 If Emacs is displaying on an ordinary terminal or some other device which
1796 doesn't support multiple overlapping frames, this function does nothing. */)
1801 frame
= selected_frame
;
1803 CHECK_LIVE_FRAME (frame
);
1805 /* Do like the documentation says. */
1806 Fmake_frame_visible (frame
);
1808 if (frame_raise_lower_hook
)
1809 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1814 /* Should we have a corresponding function called Flower_Power? */
1815 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1816 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1817 If you don't specify a frame, the selected frame is used.
1818 If Emacs is displaying on an ordinary terminal or some other device which
1819 doesn't support multiple overlapping frames, this function does nothing. */)
1824 frame
= selected_frame
;
1826 CHECK_LIVE_FRAME (frame
);
1828 if (frame_raise_lower_hook
)
1829 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1835 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1837 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1838 In other words, switch-frame events caused by events in FRAME will
1839 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1840 FOCUS-FRAME after reading an event typed at FRAME.
1842 If FOCUS-FRAME is omitted or nil, any existing redirection is
1843 cancelled, and the frame again receives its own keystrokes.
1845 Focus redirection is useful for temporarily redirecting keystrokes to
1846 a surrogate minibuffer frame when a frame doesn't have its own
1849 A frame's focus redirection can be changed by `select-frame'. If frame
1850 FOO is selected, and then a different frame BAR is selected, any
1851 frames redirecting their focus to FOO are shifted to redirect their
1852 focus to BAR. This allows focus redirection to work properly when the
1853 user switches from one frame to another using `select-window'.
1855 This means that a frame whose focus is redirected to itself is treated
1856 differently from a frame whose focus is redirected to nil; the former
1857 is affected by `select-frame', while the latter is not.
1859 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1860 (frame
, focus_frame
)
1861 Lisp_Object frame
, focus_frame
;
1863 /* Note that we don't check for a live frame here. It's reasonable
1864 to redirect the focus of a frame you're about to delete, if you
1865 know what other frame should receive those keystrokes. */
1866 CHECK_FRAME (frame
);
1868 if (! NILP (focus_frame
))
1869 CHECK_LIVE_FRAME (focus_frame
);
1871 XFRAME (frame
)->focus_frame
= focus_frame
;
1873 if (frame_rehighlight_hook
)
1874 (*frame_rehighlight_hook
) (XFRAME (frame
));
1880 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1881 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1882 This returns nil if FRAME's focus is not redirected.
1883 See `redirect-frame-focus'. */)
1887 CHECK_LIVE_FRAME (frame
);
1889 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1894 /* Return the value of frame parameter PROP in frame FRAME. */
1897 get_frame_param (frame
, prop
)
1898 register struct frame
*frame
;
1901 register Lisp_Object tem
;
1903 tem
= Fassq (prop
, frame
->param_alist
);
1909 /* Return the buffer-predicate of the selected frame. */
1912 frame_buffer_predicate (frame
)
1915 return XFRAME (frame
)->buffer_predicate
;
1918 /* Return the buffer-list of the selected frame. */
1921 frame_buffer_list (frame
)
1924 return XFRAME (frame
)->buffer_list
;
1927 /* Set the buffer-list of the selected frame. */
1930 set_frame_buffer_list (frame
, list
)
1931 Lisp_Object frame
, list
;
1933 XFRAME (frame
)->buffer_list
= list
;
1936 /* Discard BUFFER from the buffer-list of each frame. */
1939 frames_discard_buffer (buffer
)
1942 Lisp_Object frame
, tail
;
1944 FOR_EACH_FRAME (tail
, frame
)
1946 XFRAME (frame
)->buffer_list
1947 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1951 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1952 If the alist already has an element for PROP, we change it. */
1955 store_in_alist (alistptr
, prop
, val
)
1956 Lisp_Object
*alistptr
, val
;
1959 register Lisp_Object tem
;
1961 tem
= Fassq (prop
, *alistptr
);
1963 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1969 frame_name_fnn_p (str
, len
)
1973 if (len
> 1 && str
[0] == 'F')
1977 strtol (str
+ 1, &end_ptr
, 10);
1979 if (end_ptr
== str
+ len
)
1985 /* Set the name of the terminal frame. Also used by MSDOS frames.
1986 Modeled after x_set_name which is used for WINDOW frames. */
1989 set_term_frame_name (f
, name
)
1993 f
->explicit_name
= ! NILP (name
);
1995 /* If NAME is nil, set the name to F<num>. */
2000 /* Check for no change needed in this very common case
2001 before we do any consing. */
2002 if (frame_name_fnn_p (SDATA (f
->name
),
2006 terminal_frame_count
++;
2007 sprintf (namebuf
, "F%d", terminal_frame_count
);
2008 name
= build_string (namebuf
);
2012 CHECK_STRING (name
);
2014 /* Don't change the name if it's already NAME. */
2015 if (! NILP (Fstring_equal (name
, f
->name
)))
2018 /* Don't allow the user to set the frame name to F<num>, so it
2019 doesn't clash with the names we generate for terminal frames. */
2020 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
2021 error ("Frame names of the form F<num> are usurped by Emacs");
2025 update_mode_lines
= 1;
2029 store_frame_param (f
, prop
, val
)
2031 Lisp_Object prop
, val
;
2033 register Lisp_Object old_alist_elt
;
2035 /* The buffer-alist parameter is stored in a special place and is
2036 not in the alist. */
2037 if (EQ (prop
, Qbuffer_list
))
2039 f
->buffer_list
= val
;
2043 /* If PROP is a symbol which is supposed to have frame-local values,
2044 and it is set up based on this frame, switch to the global
2045 binding. That way, we can create or alter the frame-local binding
2046 without messing up the symbol's status. */
2049 Lisp_Object valcontents
;
2050 valcontents
= SYMBOL_VALUE (prop
);
2051 if ((BUFFER_LOCAL_VALUEP (valcontents
)
2052 || SOME_BUFFER_LOCAL_VALUEP (valcontents
))
2053 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
2054 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
2055 swap_in_global_binding (prop
);
2059 /* The tty color mode needs to be set before the frame's parameter
2060 alist is updated with the new value, because set_tty_color_mode
2061 wants to look at the old mode. */
2062 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
))
2063 set_tty_color_mode (f
, val
);
2066 /* Update the frame parameter alist. */
2067 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2068 if (EQ (old_alist_elt
, Qnil
))
2069 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2071 Fsetcdr (old_alist_elt
, val
);
2073 /* Update some other special parameters in their special places
2074 in addition to the alist. */
2076 if (EQ (prop
, Qbuffer_predicate
))
2077 f
->buffer_predicate
= val
;
2079 if (! FRAME_WINDOW_P (f
))
2081 if (EQ (prop
, Qmenu_bar_lines
))
2082 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2083 else if (EQ (prop
, Qname
))
2084 set_term_frame_name (f
, val
);
2087 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2089 if (! MINI_WINDOW_P (XWINDOW (val
)))
2090 error ("Surrogate minibuffer windows must be minibuffer windows");
2092 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2093 && !EQ (val
, f
->minibuffer_window
))
2094 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2096 /* Install the chosen minibuffer window, with proper buffer. */
2097 f
->minibuffer_window
= val
;
2101 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2102 doc
: /* Return the parameters-alist of frame FRAME.
2103 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2104 The meaningful PARMs depend on the kind of frame.
2105 If FRAME is omitted, return information on the currently selected frame. */)
2112 struct gcpro gcpro1
;
2115 frame
= selected_frame
;
2117 CHECK_FRAME (frame
);
2120 if (!FRAME_LIVE_P (f
))
2123 alist
= Fcopy_alist (f
->param_alist
);
2126 if (!FRAME_WINDOW_P (f
))
2128 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2129 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2132 /* If the frame's parameter alist says the colors are
2133 unspecified and reversed, take the frame's background pixel
2134 for foreground and vice versa. */
2135 elt
= Fassq (Qforeground_color
, alist
);
2136 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2138 if (strncmp (SDATA (XCDR (elt
)),
2140 SCHARS (XCDR (elt
))) == 0)
2141 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2142 else if (strncmp (SDATA (XCDR (elt
)),
2144 SCHARS (XCDR (elt
))) == 0)
2145 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2148 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2149 elt
= Fassq (Qbackground_color
, alist
);
2150 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2152 if (strncmp (SDATA (XCDR (elt
)),
2154 SCHARS (XCDR (elt
))) == 0)
2155 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2156 else if (strncmp (SDATA (XCDR (elt
)),
2158 SCHARS (XCDR (elt
))) == 0)
2159 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2162 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2163 store_in_alist (&alist
, intern ("font"),
2164 build_string (FRAME_MSDOS_P (f
)
2166 : FRAME_W32_P (f
) ? "w32term"
2169 store_in_alist (&alist
, Qname
, f
->name
);
2170 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2171 store_in_alist (&alist
, Qheight
, make_number (height
));
2172 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2173 store_in_alist (&alist
, Qwidth
, make_number (width
));
2174 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2175 store_in_alist (&alist
, Qminibuffer
,
2176 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2177 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2178 : FRAME_MINIBUF_WINDOW (f
)));
2179 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2180 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2182 /* I think this should be done with a hook. */
2183 #ifdef HAVE_WINDOW_SYSTEM
2184 if (FRAME_WINDOW_P (f
))
2185 x_report_frame_params (f
, &alist
);
2189 /* This ought to be correct in f->param_alist for an X frame. */
2191 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2192 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2200 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2201 doc
: /* Return FRAME's value for parameter PARAMETER.
2202 If FRAME is nil, describe the currently selected frame. */)
2204 Lisp_Object frame
, parameter
;
2210 frame
= selected_frame
;
2212 CHECK_FRAME (frame
);
2213 CHECK_SYMBOL (parameter
);
2218 if (FRAME_LIVE_P (f
))
2220 /* Avoid consing in frequent cases. */
2221 if (EQ (parameter
, Qname
))
2223 #ifdef HAVE_X_WINDOWS
2224 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2225 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2226 #endif /* HAVE_X_WINDOWS */
2227 else if (EQ (parameter
, Qbackground_color
)
2228 || EQ (parameter
, Qforeground_color
))
2230 value
= Fassq (parameter
, f
->param_alist
);
2233 value
= XCDR (value
);
2234 /* Fframe_parameters puts the actual fg/bg color names,
2235 even if f->param_alist says otherwise. This is
2236 important when param_alist's notion of colors is
2237 "unspecified". We need to do the same here. */
2238 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2240 const char *color_name
;
2243 if (EQ (parameter
, Qbackground_color
))
2245 color_name
= SDATA (value
);
2246 csz
= SCHARS (value
);
2247 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2248 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2249 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2250 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2252 else if (EQ (parameter
, Qforeground_color
))
2254 color_name
= SDATA (value
);
2255 csz
= SCHARS (value
);
2256 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2257 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2258 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2259 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2264 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2266 else if (EQ (parameter
, Qdisplay_type
)
2267 || EQ (parameter
, Qbackground_mode
))
2268 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2270 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2277 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2278 Smodify_frame_parameters
, 2, 2, 0,
2279 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2280 If FRAME is nil, it defaults to the selected frame.
2281 ALIST is an alist of parameters to change and their new values.
2282 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2283 The meaningful PARMs depend on the kind of frame.
2284 Undefined PARMs are ignored, but stored in the frame's parameter list
2285 so that `frame-parameters' will return them.
2287 The value of frame parameter FOO can also be accessed
2288 as a frame-local binding for the variable FOO, if you have
2289 enabled such bindings for that variable with `make-variable-frame-local'. */)
2291 Lisp_Object frame
, alist
;
2294 register Lisp_Object tail
, prop
, val
;
2296 if (EQ (frame
, Qnil
))
2297 frame
= selected_frame
;
2298 CHECK_LIVE_FRAME (frame
);
2301 /* I think this should be done with a hook. */
2302 #ifdef HAVE_WINDOW_SYSTEM
2303 if (FRAME_WINDOW_P (f
))
2304 x_set_frame_parameters (f
, alist
);
2308 if (FRAME_MSDOS_P (f
))
2309 IT_set_frame_parameters (f
, alist
);
2314 int length
= XINT (Flength (alist
));
2317 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2319 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2321 /* Extract parm names and values into those vectors. */
2324 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2329 parms
[i
] = Fcar (elt
);
2330 values
[i
] = Fcdr (elt
);
2334 /* Now process them in reverse of specified order. */
2335 for (i
--; i
>= 0; i
--)
2339 store_frame_param (f
, prop
, val
);
2341 /* Changing the background color might change the background
2342 mode, so that we have to load new defface specs.
2343 Call frame-set-background-mode to do that. */
2344 if (EQ (prop
, Qbackground_color
))
2345 call1 (Qframe_set_background_mode
, frame
);
2352 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2354 doc
: /* Height in pixels of a line in the font in frame FRAME.
2355 If FRAME is omitted, the selected frame is used.
2356 For a terminal frame, the value is always 1. */)
2363 frame
= selected_frame
;
2364 CHECK_FRAME (frame
);
2367 #ifdef HAVE_WINDOW_SYSTEM
2368 if (FRAME_WINDOW_P (f
))
2369 return make_number (x_char_height (f
));
2372 return make_number (1);
2376 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2378 doc
: /* Width in pixels of characters in the font in frame FRAME.
2379 If FRAME is omitted, the selected frame is used.
2380 On a graphical screen, the width is the standard width of the default font.
2381 For a terminal screen, the value is always 1. */)
2388 frame
= selected_frame
;
2389 CHECK_FRAME (frame
);
2392 #ifdef HAVE_WINDOW_SYSTEM
2393 if (FRAME_WINDOW_P (f
))
2394 return make_number (x_char_width (f
));
2397 return make_number (1);
2400 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2401 Sframe_pixel_height
, 0, 1, 0,
2402 doc
: /* Return a FRAME's height in pixels.
2403 This counts only the height available for text lines,
2404 not menu bars on window-system Emacs frames.
2405 For a terminal frame, the result really gives the height in characters.
2406 If FRAME is omitted, the selected frame is used. */)
2413 frame
= selected_frame
;
2414 CHECK_FRAME (frame
);
2417 #ifdef HAVE_WINDOW_SYSTEM
2418 if (FRAME_WINDOW_P (f
))
2419 return make_number (x_pixel_height (f
));
2422 return make_number (FRAME_LINES (f
));
2425 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2426 Sframe_pixel_width
, 0, 1, 0,
2427 doc
: /* Return FRAME's width in pixels.
2428 For a terminal frame, the result really gives the width in characters.
2429 If FRAME is omitted, the selected frame is used. */)
2436 frame
= selected_frame
;
2437 CHECK_FRAME (frame
);
2440 #ifdef HAVE_WINDOW_SYSTEM
2441 if (FRAME_WINDOW_P (f
))
2442 return make_number (x_pixel_width (f
));
2445 return make_number (FRAME_COLS (f
));
2448 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2449 doc
: /* Specify that the frame FRAME has LINES lines.
2450 Optional third arg non-nil means that redisplay should use LINES lines
2451 but that the idea of the actual height of the frame should not be changed. */)
2452 (frame
, lines
, pretend
)
2453 Lisp_Object frame
, lines
, pretend
;
2455 register struct frame
*f
;
2457 CHECK_NUMBER (lines
);
2459 frame
= selected_frame
;
2460 CHECK_LIVE_FRAME (frame
);
2463 /* I think this should be done with a hook. */
2464 #ifdef HAVE_WINDOW_SYSTEM
2465 if (FRAME_WINDOW_P (f
))
2467 if (XINT (lines
) != FRAME_LINES (f
))
2468 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2469 do_pending_window_change (0);
2473 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2477 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2478 doc
: /* Specify that the frame FRAME has COLS columns.
2479 Optional third arg non-nil means that redisplay should use COLS columns
2480 but that the idea of the actual width of the frame should not be changed. */)
2481 (frame
, cols
, pretend
)
2482 Lisp_Object frame
, cols
, pretend
;
2484 register struct frame
*f
;
2485 CHECK_NUMBER (cols
);
2487 frame
= selected_frame
;
2488 CHECK_LIVE_FRAME (frame
);
2491 /* I think this should be done with a hook. */
2492 #ifdef HAVE_WINDOW_SYSTEM
2493 if (FRAME_WINDOW_P (f
))
2495 if (XINT (cols
) != FRAME_COLS (f
))
2496 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2497 do_pending_window_change (0);
2501 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2505 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2506 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2508 Lisp_Object frame
, cols
, rows
;
2510 register struct frame
*f
;
2512 CHECK_LIVE_FRAME (frame
);
2513 CHECK_NUMBER (cols
);
2514 CHECK_NUMBER (rows
);
2517 /* I think this should be done with a hook. */
2518 #ifdef HAVE_WINDOW_SYSTEM
2519 if (FRAME_WINDOW_P (f
))
2521 if (XINT (rows
) != FRAME_LINES (f
)
2522 || XINT (cols
) != FRAME_COLS (f
)
2523 || f
->new_text_lines
|| f
->new_text_cols
)
2524 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2525 do_pending_window_change (0);
2529 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2534 DEFUN ("set-frame-position", Fset_frame_position
,
2535 Sset_frame_position
, 3, 3, 0,
2536 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2537 This is actually the position of the upper left corner of the frame.
2538 Negative values for XOFFSET or YOFFSET are interpreted relative to
2539 the rightmost or bottommost possible position (that stays within the screen). */)
2540 (frame
, xoffset
, yoffset
)
2541 Lisp_Object frame
, xoffset
, yoffset
;
2543 register struct frame
*f
;
2545 CHECK_LIVE_FRAME (frame
);
2546 CHECK_NUMBER (xoffset
);
2547 CHECK_NUMBER (yoffset
);
2550 /* I think this should be done with a hook. */
2551 #ifdef HAVE_WINDOW_SYSTEM
2552 if (FRAME_WINDOW_P (f
))
2553 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2560 /***********************************************************************
2562 ***********************************************************************/
2564 /* Connect the frame-parameter names for X frames
2565 to the ways of passing the parameter values to the window system.
2567 The name of a parameter, as a Lisp symbol,
2568 has an `x-frame-parameter' property which is an integer in Lisp
2569 that is an index in this table. */
2571 struct frame_parm_table
{
2573 Lisp_Object
*variable
;
2576 static struct frame_parm_table frame_parms
[] =
2578 {"auto-raise", &Qauto_raise
},
2579 {"auto-lower", &Qauto_lower
},
2580 {"background-color", 0},
2581 {"border-color", &Qborder_color
},
2582 {"border-width", &Qborder_width
},
2583 {"cursor-color", &Qcursor_color
},
2584 {"cursor-type", &Qcursor_type
},
2586 {"foreground-color", 0},
2587 {"icon-name", &Qicon_name
},
2588 {"icon-type", &Qicon_type
},
2589 {"internal-border-width", &Qinternal_border_width
},
2590 {"menu-bar-lines", &Qmenu_bar_lines
},
2591 {"mouse-color", &Qmouse_color
},
2593 {"scroll-bar-width", &Qscroll_bar_width
},
2595 {"unsplittable", &Qunsplittable
},
2596 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2597 {"visibility", &Qvisibility
},
2598 {"tool-bar-lines", &Qtool_bar_lines
},
2599 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2600 {"scroll-bar-background", &Qscroll_bar_background
},
2601 {"screen-gamma", &Qscreen_gamma
},
2602 {"line-spacing", &Qline_spacing
},
2603 {"left-fringe", &Qleft_fringe
},
2604 {"right-fringe", &Qright_fringe
},
2605 {"wait-for-wm", &Qwait_for_wm
},
2606 {"fullscreen", &Qfullscreen
},
2607 #ifdef USE_FONT_BACKEND
2608 {"font-backend", &Qfont_backend
}
2609 #endif /* USE_FONT_BACKEND */
2612 #ifdef HAVE_WINDOW_SYSTEM
2614 extern Lisp_Object Qbox
;
2615 extern Lisp_Object Qtop
;
2617 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2618 wanted positions of the WM window (not Emacs window).
2619 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2620 window (FRAME_X_WINDOW).
2624 x_fullscreen_adjust (f
, width
, height
, top_pos
, left_pos
)
2631 int newwidth
= FRAME_COLS (f
);
2632 int newheight
= FRAME_LINES (f
);
2634 *top_pos
= f
->top_pos
;
2635 *left_pos
= f
->left_pos
;
2637 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2641 ph
= FRAME_X_DISPLAY_INFO (f
)->height
;
2642 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2643 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2644 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2648 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2652 pw
= FRAME_X_DISPLAY_INFO (f
)->width
;
2653 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2654 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2655 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2660 *height
= newheight
;
2664 /* Change the parameters of frame F as specified by ALIST.
2665 If a parameter is not specially recognized, do nothing special;
2666 otherwise call the `x_set_...' function for that parameter.
2667 Except for certain geometry properties, always call store_frame_param
2668 to store the new value in the parameter alist. */
2671 x_set_frame_parameters (f
, alist
)
2677 /* If both of these parameters are present, it's more efficient to
2678 set them both at once. So we wait until we've looked at the
2679 entire list before we set them. */
2683 Lisp_Object left
, top
;
2685 /* Same with these. */
2686 Lisp_Object icon_left
, icon_top
;
2688 /* Record in these vectors all the parms specified. */
2690 Lisp_Object
*values
;
2692 int left_no_change
= 0, top_no_change
= 0;
2693 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2694 int fullscreen_is_being_set
= 0;
2696 struct gcpro gcpro1
, gcpro2
;
2699 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2702 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2703 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2705 /* Extract parm names and values into those vectors. */
2708 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2713 parms
[i
] = Fcar (elt
);
2714 values
[i
] = Fcdr (elt
);
2717 /* TAIL and ALIST are not used again below here. */
2718 alist
= tail
= Qnil
;
2720 GCPRO2 (*parms
, *values
);
2724 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2725 because their values appear in VALUES and strings are not valid. */
2726 top
= left
= Qunbound
;
2727 icon_left
= icon_top
= Qunbound
;
2729 /* Provide default values for HEIGHT and WIDTH. */
2730 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2731 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2733 /* Process foreground_color and background_color before anything else.
2734 They are independent of other properties, but other properties (e.g.,
2735 cursor_color) are dependent upon them. */
2736 /* Process default font as well, since fringe widths depends on it. */
2737 /* Also, process fullscreen, width and height depend upon that */
2738 for (p
= 0; p
< i
; p
++)
2740 Lisp_Object prop
, val
;
2744 if (EQ (prop
, Qforeground_color
)
2745 || EQ (prop
, Qbackground_color
)
2747 || EQ (prop
, Qfullscreen
))
2749 register Lisp_Object param_index
, old_value
;
2750 int count
= SPECPDL_INDEX ();
2752 old_value
= get_frame_param (f
, prop
);
2753 fullscreen_is_being_set
|= EQ (prop
, Qfullscreen
);
2755 if (NILP (Fequal (val
, old_value
)))
2757 /* For :font attributes, the frame_parm_handler
2758 x_set_font calls `face-set-after-frame-default'.
2759 Unless we bind inhibit-face-set-after-frame-default
2760 here, this would reset the :font attribute that we
2761 just applied to the default value for new faces. */
2762 specbind (Qinhibit_face_set_after_frame_default
, Qt
);
2764 store_frame_param (f
, prop
, val
);
2766 param_index
= Fget (prop
, Qx_frame_parameter
);
2767 if (NATNUMP (param_index
)
2768 && (XFASTINT (param_index
)
2769 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2770 && rif
->frame_parm_handlers
[XINT (param_index
)])
2771 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2773 unbind_to (count
, Qnil
);
2778 /* Now process them in reverse of specified order. */
2779 for (i
--; i
>= 0; i
--)
2781 Lisp_Object prop
, val
;
2786 if (EQ (prop
, Qwidth
) && NUMBERP (val
))
2787 width
= XFASTINT (val
);
2788 else if (EQ (prop
, Qheight
) && NUMBERP (val
))
2789 height
= XFASTINT (val
);
2790 else if (EQ (prop
, Qtop
))
2792 else if (EQ (prop
, Qleft
))
2794 else if (EQ (prop
, Qicon_top
))
2796 else if (EQ (prop
, Qicon_left
))
2798 else if (EQ (prop
, Qforeground_color
)
2799 || EQ (prop
, Qbackground_color
)
2801 || EQ (prop
, Qfullscreen
))
2802 /* Processed above. */
2806 register Lisp_Object param_index
, old_value
;
2808 old_value
= get_frame_param (f
, prop
);
2810 store_frame_param (f
, prop
, val
);
2812 param_index
= Fget (prop
, Qx_frame_parameter
);
2813 if (NATNUMP (param_index
)
2814 && (XFASTINT (param_index
)
2815 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2816 && rif
->frame_parm_handlers
[XINT (param_index
)])
2817 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2821 /* Don't die if just one of these was set. */
2822 if (EQ (left
, Qunbound
))
2825 if (f
->left_pos
< 0)
2826 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2828 XSETINT (left
, f
->left_pos
);
2830 if (EQ (top
, Qunbound
))
2834 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2836 XSETINT (top
, f
->top_pos
);
2839 /* If one of the icon positions was not set, preserve or default it. */
2840 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
2842 icon_left_no_change
= 1;
2843 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2844 if (NILP (icon_left
))
2845 XSETINT (icon_left
, 0);
2847 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
2849 icon_top_no_change
= 1;
2850 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2851 if (NILP (icon_top
))
2852 XSETINT (icon_top
, 0);
2855 if (FRAME_VISIBLE_P (f
) && fullscreen_is_being_set
)
2857 /* If the frame is visible already and the fullscreen parameter is
2858 being set, it is too late to set WM manager hints to specify
2860 Here we first get the width, height and position that applies to
2861 fullscreen. We then move the frame to the appropriate
2862 position. Resize of the frame is taken care of in the code after
2863 this if-statement. */
2864 int new_left
, new_top
;
2866 x_fullscreen_adjust (f
, &width
, &height
, &new_top
, &new_left
);
2867 if (new_top
!= f
->top_pos
|| new_left
!= f
->left_pos
)
2868 x_set_offset (f
, new_left
, new_top
, 1);
2871 /* Don't set these parameters unless they've been explicitly
2872 specified. The window might be mapped or resized while we're in
2873 this function, and we don't want to override that unless the lisp
2874 code has asked for it.
2876 Don't set these parameters unless they actually differ from the
2877 window's current parameters; the window may not actually exist
2882 check_frame_size (f
, &height
, &width
);
2884 XSETFRAME (frame
, f
);
2886 if (width
!= FRAME_COLS (f
)
2887 || height
!= FRAME_LINES (f
)
2888 || f
->new_text_lines
|| f
->new_text_cols
)
2889 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2891 if ((!NILP (left
) || !NILP (top
))
2892 && ! (left_no_change
&& top_no_change
)
2893 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2894 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2899 /* Record the signs. */
2900 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2901 if (EQ (left
, Qminus
))
2902 f
->size_hint_flags
|= XNegative
;
2903 else if (INTEGERP (left
))
2905 leftpos
= XINT (left
);
2907 f
->size_hint_flags
|= XNegative
;
2909 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2910 && CONSP (XCDR (left
))
2911 && INTEGERP (XCAR (XCDR (left
))))
2913 leftpos
= - XINT (XCAR (XCDR (left
)));
2914 f
->size_hint_flags
|= XNegative
;
2916 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2917 && CONSP (XCDR (left
))
2918 && INTEGERP (XCAR (XCDR (left
))))
2920 leftpos
= XINT (XCAR (XCDR (left
)));
2923 if (EQ (top
, Qminus
))
2924 f
->size_hint_flags
|= YNegative
;
2925 else if (INTEGERP (top
))
2927 toppos
= XINT (top
);
2929 f
->size_hint_flags
|= YNegative
;
2931 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2932 && CONSP (XCDR (top
))
2933 && INTEGERP (XCAR (XCDR (top
))))
2935 toppos
= - XINT (XCAR (XCDR (top
)));
2936 f
->size_hint_flags
|= YNegative
;
2938 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2939 && CONSP (XCDR (top
))
2940 && INTEGERP (XCAR (XCDR (top
))))
2942 toppos
= XINT (XCAR (XCDR (top
)));
2946 /* Store the numeric value of the position. */
2947 f
->top_pos
= toppos
;
2948 f
->left_pos
= leftpos
;
2950 f
->win_gravity
= NorthWestGravity
;
2952 /* Actually set that position, and convert to absolute. */
2953 x_set_offset (f
, leftpos
, toppos
, -1);
2956 if ((!NILP (icon_left
) || !NILP (icon_top
))
2957 && ! (icon_left_no_change
&& icon_top_no_change
))
2958 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2965 /* Insert a description of internally-recorded parameters of frame X
2966 into the parameter alist *ALISTPTR that is to be given to the user.
2967 Only parameters that are specific to the X window system
2968 and whose values are not correctly recorded in the frame's
2969 param_alist need to be considered here. */
2972 x_report_frame_params (f
, alistptr
)
2974 Lisp_Object
*alistptr
;
2979 /* Represent negative positions (off the top or left screen edge)
2980 in a way that Fmodify_frame_parameters will understand correctly. */
2981 XSETINT (tem
, f
->left_pos
);
2982 if (f
->left_pos
>= 0)
2983 store_in_alist (alistptr
, Qleft
, tem
);
2985 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2987 XSETINT (tem
, f
->top_pos
);
2988 if (f
->top_pos
>= 0)
2989 store_in_alist (alistptr
, Qtop
, tem
);
2991 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2993 store_in_alist (alistptr
, Qborder_width
,
2994 make_number (f
->border_width
));
2995 store_in_alist (alistptr
, Qinternal_border_width
,
2996 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
2997 store_in_alist (alistptr
, Qleft_fringe
,
2998 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
2999 store_in_alist (alistptr
, Qright_fringe
,
3000 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
3001 store_in_alist (alistptr
, Qscroll_bar_width
,
3002 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3004 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
3005 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3006 /* nil means "use default width"
3007 for non-toolkit scroll bar.
3008 ruler-mode.el depends on this. */
3010 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
3011 store_in_alist (alistptr
, Qwindow_id
,
3012 build_string (buf
));
3013 #ifdef HAVE_X_WINDOWS
3014 #ifdef USE_X_TOOLKIT
3015 /* Tooltip frame may not have this widget. */
3016 if (FRAME_X_OUTPUT (f
)->widget
)
3018 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
3019 store_in_alist (alistptr
, Qouter_window_id
,
3020 build_string (buf
));
3022 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3023 FRAME_SAMPLE_VISIBILITY (f
);
3024 store_in_alist (alistptr
, Qvisibility
,
3025 (FRAME_VISIBLE_P (f
) ? Qt
3026 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3027 store_in_alist (alistptr
, Qdisplay
,
3028 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3030 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3033 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3034 store_in_alist (alistptr
, Qparent_id
, tem
);
3038 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3039 the previous value of that parameter, NEW_VALUE is the new value. */
3042 x_set_fullscreen (f
, new_value
, old_value
)
3044 Lisp_Object new_value
, old_value
;
3046 if (NILP (new_value
))
3047 f
->want_fullscreen
= FULLSCREEN_NONE
;
3048 else if (EQ (new_value
, Qfullboth
))
3049 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3050 else if (EQ (new_value
, Qfullwidth
))
3051 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3052 else if (EQ (new_value
, Qfullheight
))
3053 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3055 if (fullscreen_hook
!= NULL
)
3056 fullscreen_hook (f
);
3060 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3061 the previous value of that parameter, NEW_VALUE is the new value. */
3064 x_set_line_spacing (f
, new_value
, old_value
)
3066 Lisp_Object new_value
, old_value
;
3068 if (NILP (new_value
))
3069 f
->extra_line_spacing
= 0;
3070 else if (NATNUMP (new_value
))
3071 f
->extra_line_spacing
= XFASTINT (new_value
);
3073 signal_error ("Invalid line-spacing", new_value
);
3074 if (FRAME_VISIBLE_P (f
))
3079 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3080 the previous value of that parameter, NEW_VALUE is the new value. */
3083 x_set_screen_gamma (f
, new_value
, old_value
)
3085 Lisp_Object new_value
, old_value
;
3087 Lisp_Object bgcolor
;
3089 if (NILP (new_value
))
3091 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3092 /* The value 0.4545 is the normal viewing gamma. */
3093 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3095 signal_error ("Invalid screen-gamma", new_value
);
3097 /* Apply the new gamma value to the frame background. */
3098 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3099 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3101 Lisp_Object index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3103 && (XFASTINT (index
)
3104 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3105 && rif
->frame_parm_handlers
[XFASTINT (index
)])
3106 (*(rif
->frame_parm_handlers
[XFASTINT (index
)]))
3110 Fclear_face_cache (Qnil
);
3115 x_set_font (f
, arg
, oldval
)
3117 Lisp_Object arg
, oldval
;
3120 Lisp_Object fontset_name
;
3122 int old_fontset
= FRAME_FONTSET(f
);
3124 #ifdef USE_FONT_BACKEND
3125 if (enable_font_backend
)
3128 Lisp_Object font_object
;
3130 /* ARG is a fontset name, a font name, or a font object.
3131 In the last case, this function never fail. */
3134 fontset
= fs_query_fontset (arg
, 0);
3136 font_object
= font_open_by_name (f
, SDATA (arg
));
3137 else if (fontset
> 0)
3139 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3141 font_object
= font_open_by_name (f
, SDATA (ascii_font
));
3147 if (fontset
< 0 && ! NILP (font_object
))
3148 fontset
= new_fontset_from_font (font_object
);
3151 /* Refuse the default fontset. */
3153 else if (NILP (font_object
))
3156 result
= x_new_fontset2 (f
, fontset
, font_object
);
3160 #endif /* USE_FONT_BACKEND */
3163 fontset_name
= Fquery_fontset (arg
, Qnil
);
3166 result
= (STRINGP (fontset_name
)
3167 ? x_new_fontset (f
, fontset_name
)
3168 : x_new_fontset (f
, arg
));
3170 #ifdef USE_FONT_BACKEND
3174 if (EQ (result
, Qnil
))
3175 error ("Font `%s' is not defined", SDATA (arg
));
3176 else if (EQ (result
, Qt
))
3177 error ("The default fontset can't be used for a frame font");
3178 else if (STRINGP (result
))
3180 set_default_ascii_font (result
);
3181 if (STRINGP (fontset_name
))
3183 /* Fontset names are built from ASCII font names, so the
3184 names may be equal despite there was a change. */
3185 if (old_fontset
== FRAME_FONTSET (f
))
3188 store_frame_param (f
, Qfont
, result
);
3190 if (!NILP (Fequal (result
, oldval
)))
3193 /* Recalculate toolbar height. */
3194 f
->n_tool_bar_rows
= 0;
3195 /* Ensure we redraw it. */
3196 clear_current_matrices (f
);
3198 recompute_basic_faces (f
);
3203 do_pending_window_change (0);
3205 /* Don't call `face-set-after-frame-default' when faces haven't been
3206 initialized yet. This is the case when called from
3207 Fx_create_frame. In that case, the X widget or window doesn't
3208 exist either, and we can end up in x_report_frame_params with a
3209 null widget which gives a segfault. */
3210 if (FRAME_FACE_CACHE (f
))
3212 XSETFRAME (frame
, f
);
3213 call1 (Qface_set_after_frame_default
, frame
);
3218 #ifdef USE_FONT_BACKEND
3220 x_set_font_backend (f
, new_value
, old_value
)
3222 Lisp_Object new_value
, old_value
;
3224 if (! NILP (new_value
)
3225 && !CONSP (new_value
))
3229 CHECK_STRING (new_value
);
3230 p0
= p1
= SDATA (new_value
);
3234 while (*p1
&& *p1
!= ',') p1
++;
3236 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3242 new_value
= Fnreverse (new_value
);
3245 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3248 if (FRAME_FONT_OBJECT (f
))
3250 free_all_realized_faces (Qnil
);
3251 Fclear_font_cache ();
3254 new_value
= font_update_drivers (f
, new_value
);
3255 if (NILP (new_value
))
3256 error ("No font backend available");
3257 store_frame_param (f
, Qfont_backend
, new_value
);
3259 if (FRAME_FONT_OBJECT (f
))
3263 XSETFRAME (frame
, f
);
3264 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3265 ++face_change_count
;
3266 ++windows_or_buffers_changed
;
3269 #endif /* USE_FONT_BACKEND */
3273 x_set_fringe_width (f
, new_value
, old_value
)
3275 Lisp_Object new_value
, old_value
;
3277 compute_fringe_widths (f
, 1);
3281 x_set_border_width (f
, arg
, oldval
)
3283 Lisp_Object arg
, oldval
;
3287 if (XINT (arg
) == f
->border_width
)
3290 if (FRAME_X_WINDOW (f
) != 0)
3291 error ("Cannot change the border width of a frame");
3293 f
->border_width
= XINT (arg
);
3297 x_set_internal_border_width (f
, arg
, oldval
)
3299 Lisp_Object arg
, oldval
;
3301 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3304 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3305 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3306 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3308 #ifdef USE_X_TOOLKIT
3309 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3310 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3313 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3316 if (FRAME_X_WINDOW (f
) != 0)
3318 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3319 SET_FRAME_GARBAGED (f
);
3320 do_pending_window_change (0);
3323 SET_FRAME_GARBAGED (f
);
3327 x_set_visibility (f
, value
, oldval
)
3329 Lisp_Object value
, oldval
;
3332 XSETFRAME (frame
, f
);
3335 Fmake_frame_invisible (frame
, Qt
);
3336 else if (EQ (value
, Qicon
))
3337 Ficonify_frame (frame
);
3339 Fmake_frame_visible (frame
);
3343 x_set_autoraise (f
, arg
, oldval
)
3345 Lisp_Object arg
, oldval
;
3347 f
->auto_raise
= !EQ (Qnil
, arg
);
3351 x_set_autolower (f
, arg
, oldval
)
3353 Lisp_Object arg
, oldval
;
3355 f
->auto_lower
= !EQ (Qnil
, arg
);
3359 x_set_unsplittable (f
, arg
, oldval
)
3361 Lisp_Object arg
, oldval
;
3363 f
->no_split
= !NILP (arg
);
3367 x_set_vertical_scroll_bars (f
, arg
, oldval
)
3369 Lisp_Object arg
, oldval
;
3371 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3372 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3373 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3374 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3376 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3378 ? vertical_scroll_bar_none
3380 ? vertical_scroll_bar_left
3382 ? vertical_scroll_bar_right
3383 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3384 ? vertical_scroll_bar_left
3385 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3386 ? vertical_scroll_bar_right
3387 : vertical_scroll_bar_none
);
3389 /* We set this parameter before creating the X window for the
3390 frame, so we can get the geometry right from the start.
3391 However, if the window hasn't been created yet, we shouldn't
3392 call x_set_window_size. */
3393 if (FRAME_X_WINDOW (f
))
3394 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3395 do_pending_window_change (0);
3400 x_set_scroll_bar_width (f
, arg
, oldval
)
3402 Lisp_Object arg
, oldval
;
3404 int wid
= FRAME_COLUMN_WIDTH (f
);
3408 x_set_scroll_bar_default_width (f
);
3410 if (FRAME_X_WINDOW (f
))
3411 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3412 do_pending_window_change (0);
3414 else if (INTEGERP (arg
) && XINT (arg
) > 0
3415 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3417 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3418 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3420 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3421 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3422 if (FRAME_X_WINDOW (f
))
3423 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3424 do_pending_window_change (0);
3427 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3428 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3429 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3434 /* Return non-nil if frame F wants a bitmap icon. */
3442 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3450 /* Subroutines of creating an X frame. */
3452 /* Make sure that Vx_resource_name is set to a reasonable value.
3453 Fix it up, or set it to `emacs' if it is too hopeless. */
3456 validate_x_resource_name ()
3459 /* Number of valid characters in the resource name. */
3461 /* Number of invalid characters in the resource name. */
3466 if (!STRINGP (Vx_resource_class
))
3467 Vx_resource_class
= build_string (EMACS_CLASS
);
3469 if (STRINGP (Vx_resource_name
))
3471 unsigned char *p
= SDATA (Vx_resource_name
);
3474 len
= SBYTES (Vx_resource_name
);
3476 /* Only letters, digits, - and _ are valid in resource names.
3477 Count the valid characters and count the invalid ones. */
3478 for (i
= 0; i
< len
; i
++)
3481 if (! ((c
>= 'a' && c
<= 'z')
3482 || (c
>= 'A' && c
<= 'Z')
3483 || (c
>= '0' && c
<= '9')
3484 || c
== '-' || c
== '_'))
3491 /* Not a string => completely invalid. */
3492 bad_count
= 5, good_count
= 0;
3494 /* If name is valid already, return. */
3498 /* If name is entirely invalid, or nearly so, use `emacs'. */
3500 || (good_count
== 1 && bad_count
> 0))
3502 Vx_resource_name
= build_string ("emacs");
3506 /* Name is partly valid. Copy it and replace the invalid characters
3507 with underscores. */
3509 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3511 for (i
= 0; i
< len
; i
++)
3513 int c
= SREF (new, i
);
3514 if (! ((c
>= 'a' && c
<= 'z')
3515 || (c
>= 'A' && c
<= 'Z')
3516 || (c
>= '0' && c
<= '9')
3517 || c
== '-' || c
== '_'))
3523 extern char *x_get_string_resource
P_ ((XrmDatabase
, char *, char *));
3524 extern Display_Info
*check_x_display_info
P_ ((Lisp_Object
));
3527 /* Get specified attribute from resource database RDB.
3528 See Fx_get_resource below for other parameters. */
3531 xrdb_get_resource (rdb
, attribute
, class, component
, subclass
)
3533 Lisp_Object attribute
, class, component
, subclass
;
3535 register char *value
;
3539 CHECK_STRING (attribute
);
3540 CHECK_STRING (class);
3542 if (!NILP (component
))
3543 CHECK_STRING (component
);
3544 if (!NILP (subclass
))
3545 CHECK_STRING (subclass
);
3546 if (NILP (component
) != NILP (subclass
))
3547 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3549 validate_x_resource_name ();
3551 /* Allocate space for the components, the dots which separate them,
3552 and the final '\0'. Make them big enough for the worst case. */
3553 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3554 + (STRINGP (component
)
3555 ? SBYTES (component
) : 0)
3556 + SBYTES (attribute
)
3559 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3561 + (STRINGP (subclass
)
3562 ? SBYTES (subclass
) : 0)
3565 /* Start with emacs.FRAMENAME for the name (the specific one)
3566 and with `Emacs' for the class key (the general one). */
3567 strcpy (name_key
, SDATA (Vx_resource_name
));
3568 strcpy (class_key
, SDATA (Vx_resource_class
));
3570 strcat (class_key
, ".");
3571 strcat (class_key
, SDATA (class));
3573 if (!NILP (component
))
3575 strcat (class_key
, ".");
3576 strcat (class_key
, SDATA (subclass
));
3578 strcat (name_key
, ".");
3579 strcat (name_key
, SDATA (component
));
3582 strcat (name_key
, ".");
3583 strcat (name_key
, SDATA (attribute
));
3585 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3587 if (value
!= (char *) 0)
3588 return build_string (value
);
3594 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3595 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3596 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3597 class, where INSTANCE is the name under which Emacs was invoked, or
3598 the name specified by the `-name' or `-rn' command-line arguments.
3600 The optional arguments COMPONENT and SUBCLASS add to the key and the
3601 class, respectively. You must specify both of them or neither.
3602 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3603 and the class is `Emacs.CLASS.SUBCLASS'. */)
3604 (attribute
, class, component
, subclass
)
3605 Lisp_Object attribute
, class, component
, subclass
;
3607 #ifdef HAVE_X_WINDOWS
3611 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3612 attribute
, class, component
, subclass
);
3615 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3618 display_x_get_resource (dpyinfo
, attribute
, class, component
, subclass
)
3619 Display_Info
*dpyinfo
;
3620 Lisp_Object attribute
, class, component
, subclass
;
3622 return xrdb_get_resource (dpyinfo
->xrdb
,
3623 attribute
, class, component
, subclass
);
3626 /* Used when C code wants a resource value. */
3629 x_get_resource_string (attribute
, class)
3630 char *attribute
, *class;
3634 struct frame
*sf
= SELECTED_FRAME ();
3636 /* Allocate space for the components, the dots which separate them,
3637 and the final '\0'. */
3638 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3639 + strlen (attribute
) + 2);
3640 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3641 + strlen (class) + 2);
3643 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3644 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3646 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3647 name_key
, class_key
);
3651 /* Return the value of parameter PARAM.
3653 First search ALIST, then Vdefault_frame_alist, then the X defaults
3654 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3656 Convert the resource to the type specified by desired_type.
3658 If no default is specified, return Qunbound. If you call
3659 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3660 and don't let it get stored in any Lisp-visible variables! */
3663 x_get_arg (dpyinfo
, alist
, param
, attribute
, class, type
)
3664 Display_Info
*dpyinfo
;
3665 Lisp_Object alist
, param
;
3668 enum resource_types type
;
3670 register Lisp_Object tem
;
3672 tem
= Fassq (param
, alist
);
3676 /* If we find this parm in ALIST, clear it out
3677 so that it won't be "left over" at the end. */
3678 #ifndef WINDOWSNT /* w32fns.c has not yet been changed to cope with this. */
3680 XSETCAR (tem
, Qnil
);
3681 /* In case the parameter appears more than once in the alist,
3683 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3684 if (CONSP (XCAR (tail
))
3685 && EQ (XCAR (XCAR (tail
)), param
))
3686 XSETCAR (XCAR (tail
), Qnil
);
3690 tem
= Fassq (param
, Vdefault_frame_alist
);
3692 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3693 look in the X resources. */
3698 tem
= display_x_get_resource (dpyinfo
,
3699 build_string (attribute
),
3700 build_string (class),
3708 case RES_TYPE_NUMBER
:
3709 return make_number (atoi (SDATA (tem
)));
3711 case RES_TYPE_FLOAT
:
3712 return make_float (atof (SDATA (tem
)));
3714 case RES_TYPE_BOOLEAN
:
3715 tem
= Fdowncase (tem
);
3716 if (!strcmp (SDATA (tem
), "on")
3717 || !strcmp (SDATA (tem
), "true"))
3722 case RES_TYPE_STRING
:
3725 case RES_TYPE_SYMBOL
:
3726 /* As a special case, we map the values `true' and `on'
3727 to Qt, and `false' and `off' to Qnil. */
3730 lower
= Fdowncase (tem
);
3731 if (!strcmp (SDATA (lower
), "on")
3732 || !strcmp (SDATA (lower
), "true"))
3734 else if (!strcmp (SDATA (lower
), "off")
3735 || !strcmp (SDATA (lower
), "false"))
3738 return Fintern (tem
, Qnil
);
3752 x_frame_get_arg (f
, alist
, param
, attribute
, class, type
)
3754 Lisp_Object alist
, param
;
3757 enum resource_types type
;
3759 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3760 alist
, param
, attribute
, class, type
);
3763 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3766 x_frame_get_and_record_arg (f
, alist
, param
, attribute
, class, type
)
3768 Lisp_Object alist
, param
;
3771 enum resource_types type
;
3775 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3776 attribute
, class, type
);
3777 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3778 store_frame_param (f
, param
, value
);
3784 /* Record in frame F the specified or default value according to ALIST
3785 of the parameter named PROP (a Lisp symbol).
3786 If no value is specified for PROP, look for an X default for XPROP
3787 on the frame named NAME.
3788 If that is not found either, use the value DEFLT. */
3791 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
3798 enum resource_types type
;
3802 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3803 if (EQ (tem
, Qunbound
))
3805 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3812 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3813 doc
: /* Parse an X-style geometry string STRING.
3814 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3815 The properties returned may include `top', `left', `height', and `width'.
3816 The value of `left' or `top' may be an integer,
3817 or a list (+ N) meaning N pixels relative to top/left corner,
3818 or a list (- N) meaning -N pixels relative to bottom/right corner. */)
3823 unsigned int width
, height
;
3826 CHECK_STRING (string
);
3828 geometry
= XParseGeometry ((char *) SDATA (string
),
3829 &x
, &y
, &width
, &height
);
3832 if (!!(geometry
& XValue
) != !!(geometry
& YValue
))
3833 error ("Must specify both x and y position, or neither");
3837 if (geometry
& XValue
)
3839 Lisp_Object element
;
3841 if (x
>= 0 && (geometry
& XNegative
))
3842 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3843 else if (x
< 0 && ! (geometry
& XNegative
))
3844 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3846 element
= Fcons (Qleft
, make_number (x
));
3847 result
= Fcons (element
, result
);
3850 if (geometry
& YValue
)
3852 Lisp_Object element
;
3854 if (y
>= 0 && (geometry
& YNegative
))
3855 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3856 else if (y
< 0 && ! (geometry
& YNegative
))
3857 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3859 element
= Fcons (Qtop
, make_number (y
));
3860 result
= Fcons (element
, result
);
3863 if (geometry
& WidthValue
)
3864 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3865 if (geometry
& HeightValue
)
3866 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3871 /* Calculate the desired size and position of frame F.
3872 Return the flags saying which aspects were specified.
3874 Also set the win_gravity and size_hint_flags of F.
3876 Adjust height for toolbar if TOOLBAR_P is 1.
3878 This function does not make the coordinates positive. */
3880 #define DEFAULT_ROWS 40
3881 #define DEFAULT_COLS 80
3884 x_figure_window_size (f
, parms
, toolbar_p
)
3889 register Lisp_Object tem0
, tem1
, tem2
;
3890 long window_prompting
= 0;
3891 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3893 /* Default values if we fall through.
3894 Actually, if that happens we should get
3895 window manager prompting. */
3896 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3897 FRAME_LINES (f
) = DEFAULT_ROWS
;
3898 /* Window managers expect that if program-specified
3899 positions are not (0,0), they're intentional, not defaults. */
3903 /* Ensure that old new_text_cols and new_text_lines will not override the
3905 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3906 f
->new_text_cols
= f
->new_text_lines
= 0;
3908 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3909 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3910 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3911 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3913 if (!EQ (tem0
, Qunbound
))
3915 CHECK_NUMBER (tem0
);
3916 FRAME_LINES (f
) = XINT (tem0
);
3918 if (!EQ (tem1
, Qunbound
))
3920 CHECK_NUMBER (tem1
);
3921 SET_FRAME_COLS (f
, XINT (tem1
));
3923 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
3924 window_prompting
|= USSize
;
3926 window_prompting
|= PSize
;
3929 f
->scroll_bar_actual_width
3930 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
3932 /* This used to be done _before_ calling x_figure_window_size, but
3933 since the height is reset here, this was really a no-op. I
3934 assume that moving it here does what Gerd intended (although he
3935 no longer can remember what that was... ++KFS, 2003-03-25. */
3937 /* Add the tool-bar height to the initial frame height so that the
3938 user gets a text display area of the size he specified with -g or
3939 via .Xdefaults. Later changes of the tool-bar height don't
3940 change the frame size. This is done so that users can create
3941 tall Emacs frames without having to guess how tall the tool-bar
3943 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
3945 int margin
, relief
, bar_height
;
3947 relief
= (tool_bar_button_relief
>= 0
3948 ? tool_bar_button_relief
3949 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
3951 if (INTEGERP (Vtool_bar_button_margin
)
3952 && XINT (Vtool_bar_button_margin
) > 0)
3953 margin
= XFASTINT (Vtool_bar_button_margin
);
3954 else if (CONSP (Vtool_bar_button_margin
)
3955 && INTEGERP (XCDR (Vtool_bar_button_margin
))
3956 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
3957 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
3961 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
3962 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
3965 compute_fringe_widths (f
, 0);
3967 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
3968 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
3970 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
3971 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
3972 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
3973 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3975 if (EQ (tem0
, Qminus
))
3978 window_prompting
|= YNegative
;
3980 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
3981 && CONSP (XCDR (tem0
))
3982 && INTEGERP (XCAR (XCDR (tem0
))))
3984 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
3985 window_prompting
|= YNegative
;
3987 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
3988 && CONSP (XCDR (tem0
))
3989 && INTEGERP (XCAR (XCDR (tem0
))))
3991 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
3993 else if (EQ (tem0
, Qunbound
))
3997 CHECK_NUMBER (tem0
);
3998 f
->top_pos
= XINT (tem0
);
4000 window_prompting
|= YNegative
;
4003 if (EQ (tem1
, Qminus
))
4006 window_prompting
|= XNegative
;
4008 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
4009 && CONSP (XCDR (tem1
))
4010 && INTEGERP (XCAR (XCDR (tem1
))))
4012 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
4013 window_prompting
|= XNegative
;
4015 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
4016 && CONSP (XCDR (tem1
))
4017 && INTEGERP (XCAR (XCDR (tem1
))))
4019 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
4021 else if (EQ (tem1
, Qunbound
))
4025 CHECK_NUMBER (tem1
);
4026 f
->left_pos
= XINT (tem1
);
4027 if (f
->left_pos
< 0)
4028 window_prompting
|= XNegative
;
4031 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
4032 window_prompting
|= USPosition
;
4034 window_prompting
|= PPosition
;
4037 if (f
->want_fullscreen
!= FULLSCREEN_NONE
)
4042 /* It takes both for some WM:s to place it where we want */
4043 window_prompting
= USPosition
| PPosition
;
4044 x_fullscreen_adjust (f
, &width
, &height
, &top
, &left
);
4045 FRAME_COLS (f
) = width
;
4046 FRAME_LINES (f
) = height
;
4047 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, width
);
4048 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, height
);
4053 if (window_prompting
& XNegative
)
4055 if (window_prompting
& YNegative
)
4056 f
->win_gravity
= SouthEastGravity
;
4058 f
->win_gravity
= NorthEastGravity
;
4062 if (window_prompting
& YNegative
)
4063 f
->win_gravity
= SouthWestGravity
;
4065 f
->win_gravity
= NorthWestGravity
;
4068 f
->size_hint_flags
= window_prompting
;
4070 return window_prompting
;
4075 #endif /* HAVE_WINDOW_SYSTEM */
4079 /***********************************************************************
4081 ***********************************************************************/
4086 Qframep
= intern ("framep");
4087 staticpro (&Qframep
);
4088 Qframe_live_p
= intern ("frame-live-p");
4089 staticpro (&Qframe_live_p
);
4090 Qheight
= intern ("height");
4091 staticpro (&Qheight
);
4092 Qicon
= intern ("icon");
4094 Qminibuffer
= intern ("minibuffer");
4095 staticpro (&Qminibuffer
);
4096 Qmodeline
= intern ("modeline");
4097 staticpro (&Qmodeline
);
4098 Qonly
= intern ("only");
4100 Qwidth
= intern ("width");
4101 staticpro (&Qwidth
);
4102 Qgeometry
= intern ("geometry");
4103 staticpro (&Qgeometry
);
4104 Qicon_left
= intern ("icon-left");
4105 staticpro (&Qicon_left
);
4106 Qicon_top
= intern ("icon-top");
4107 staticpro (&Qicon_top
);
4108 Qleft
= intern ("left");
4110 Qright
= intern ("right");
4111 staticpro (&Qright
);
4112 Quser_position
= intern ("user-position");
4113 staticpro (&Quser_position
);
4114 Quser_size
= intern ("user-size");
4115 staticpro (&Quser_size
);
4116 Qwindow_id
= intern ("window-id");
4117 staticpro (&Qwindow_id
);
4118 #ifdef HAVE_X_WINDOWS
4119 Qouter_window_id
= intern ("outer-window-id");
4120 staticpro (&Qouter_window_id
);
4122 Qparent_id
= intern ("parent-id");
4123 staticpro (&Qparent_id
);
4126 Qw32
= intern ("w32");
4128 Qpc
= intern ("pc");
4130 Qmac
= intern ("mac");
4132 Qvisible
= intern ("visible");
4133 staticpro (&Qvisible
);
4134 Qbuffer_predicate
= intern ("buffer-predicate");
4135 staticpro (&Qbuffer_predicate
);
4136 Qbuffer_list
= intern ("buffer-list");
4137 staticpro (&Qbuffer_list
);
4138 Qdisplay_type
= intern ("display-type");
4139 staticpro (&Qdisplay_type
);
4140 Qbackground_mode
= intern ("background-mode");
4141 staticpro (&Qbackground_mode
);
4142 Qtty_color_mode
= intern ("tty-color-mode");
4143 staticpro (&Qtty_color_mode
);
4145 Qface_set_after_frame_default
= intern ("face-set-after-frame-default");
4146 staticpro (&Qface_set_after_frame_default
);
4148 Qinhibit_face_set_after_frame_default
4149 = intern ("inhibit-face-set-after-frame-default");
4150 staticpro (&Qinhibit_face_set_after_frame_default
);
4152 Qfullwidth
= intern ("fullwidth");
4153 staticpro (&Qfullwidth
);
4154 Qfullheight
= intern ("fullheight");
4155 staticpro (&Qfullheight
);
4156 Qfullboth
= intern ("fullboth");
4157 staticpro (&Qfullboth
);
4158 Qx_resource_name
= intern ("x-resource-name");
4159 staticpro (&Qx_resource_name
);
4161 Qx_frame_parameter
= intern ("x-frame-parameter");
4162 staticpro (&Qx_frame_parameter
);
4167 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4169 Lisp_Object v
= intern (frame_parms
[i
].name
);
4170 if (frame_parms
[i
].variable
)
4172 *frame_parms
[i
].variable
= v
;
4173 staticpro (frame_parms
[i
].variable
);
4175 Fput (v
, Qx_frame_parameter
, make_number (i
));
4179 #ifdef HAVE_WINDOW_SYSTEM
4180 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4181 doc
: /* The name Emacs uses to look up X resources.
4182 `x-get-resource' uses this as the first component of the instance name
4183 when requesting resource values.
4184 Emacs initially sets `x-resource-name' to the name under which Emacs
4185 was invoked, or to the value specified with the `-name' or `-rn'
4186 switches, if present.
4188 It may be useful to bind this variable locally around a call
4189 to `x-get-resource'. See also the variable `x-resource-class'. */);
4190 Vx_resource_name
= Qnil
;
4192 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4193 doc
: /* The class Emacs uses to look up X resources.
4194 `x-get-resource' uses this as the first component of the instance class
4195 when requesting resource values.
4197 Emacs initially sets `x-resource-class' to "Emacs".
4199 Setting this variable permanently is not a reasonable thing to do,
4200 but binding this variable locally around a call to `x-get-resource'
4201 is a reasonable practice. See also the variable `x-resource-name'. */);
4202 Vx_resource_class
= build_string (EMACS_CLASS
);
4205 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4206 doc
: /* Alist of default values for frame creation.
4207 These may be set in your init file, like this:
4208 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4209 These override values given in window system configuration data,
4210 including X Windows' defaults database.
4211 For values specific to the first Emacs frame, see `initial-frame-alist'.
4212 For values specific to the separate minibuffer frame, see
4213 `minibuffer-frame-alist'.
4214 The `menu-bar-lines' element of the list controls whether new frames
4215 have menu bars; `menu-bar-mode' works by altering this element.
4216 Setting this variable does not affect existing frames, only new ones. */);
4217 Vdefault_frame_alist
= Qnil
;
4219 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars
,
4220 doc
: /* Default position of scroll bars on this window-system. */);
4221 #ifdef HAVE_WINDOW_SYSTEM
4222 #if defined(HAVE_NTGUI) || defined(MAC_OS)
4223 /* MS-Windows has scroll bars on the right by default. */
4224 Vdefault_frame_scroll_bars
= Qright
;
4226 Vdefault_frame_scroll_bars
= Qleft
;
4229 Vdefault_frame_scroll_bars
= Qnil
;
4232 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4233 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4235 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
4236 doc
: /* Non-nil if all of Emacs is iconified and frame updates are not needed. */);
4237 Vemacs_iconified
= Qnil
;
4239 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4240 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4241 `mouse-position' calls this function, passing its usual return value as
4242 argument, and returns whatever this function returns.
4243 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4244 which need to do mouse handling at the Lisp level. */);
4245 Vmouse_position_function
= Qnil
;
4247 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4248 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4249 If the value is an integer, highlighting is only shown after moving the
4250 mouse, while keyboard input turns off the highlight even when the mouse
4251 is over the clickable text. However, the mouse shape still indicates
4252 when the mouse is over clickable text. */);
4253 Vmouse_highlight
= Qt
;
4255 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4256 doc
: /* Functions to be run before deleting a frame.
4257 The functions are run with one arg, the frame to be deleted.
4258 See `delete-frame'. */);
4259 Vdelete_frame_functions
= Qnil
;
4261 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4262 doc
: /* Minibufferless frames use this frame's minibuffer.
4264 Emacs cannot create minibufferless frames unless this is set to an
4265 appropriate surrogate.
4267 Emacs consults this variable only when creating minibufferless
4268 frames; once the frame is created, it sticks with its assigned
4269 minibuffer, no matter what this variable is set to. This means that
4270 this variable doesn't necessarily say anything meaningful about the
4271 current set of frames, or where the minibuffer is currently being
4274 This variable is local to the current terminal and cannot be buffer-local. */);
4276 staticpro (&Vframe_list
);
4278 defsubr (&Sactive_minibuffer_window
);
4280 defsubr (&Sframe_live_p
);
4281 defsubr (&Smake_terminal_frame
);
4282 defsubr (&Shandle_switch_frame
);
4283 defsubr (&Sselect_frame
);
4284 defsubr (&Sselected_frame
);
4285 defsubr (&Swindow_frame
);
4286 defsubr (&Sframe_root_window
);
4287 defsubr (&Sframe_first_window
);
4288 defsubr (&Sframe_selected_window
);
4289 defsubr (&Sset_frame_selected_window
);
4290 defsubr (&Sframe_list
);
4291 defsubr (&Snext_frame
);
4292 defsubr (&Sprevious_frame
);
4293 defsubr (&Sdelete_frame
);
4294 defsubr (&Smouse_position
);
4295 defsubr (&Smouse_pixel_position
);
4296 defsubr (&Sset_mouse_position
);
4297 defsubr (&Sset_mouse_pixel_position
);
4299 defsubr (&Sframe_configuration
);
4300 defsubr (&Srestore_frame_configuration
);
4302 defsubr (&Smake_frame_visible
);
4303 defsubr (&Smake_frame_invisible
);
4304 defsubr (&Siconify_frame
);
4305 defsubr (&Sframe_visible_p
);
4306 defsubr (&Svisible_frame_list
);
4307 defsubr (&Sraise_frame
);
4308 defsubr (&Slower_frame
);
4309 defsubr (&Sredirect_frame_focus
);
4310 defsubr (&Sframe_focus
);
4311 defsubr (&Sframe_parameters
);
4312 defsubr (&Sframe_parameter
);
4313 defsubr (&Smodify_frame_parameters
);
4314 defsubr (&Sframe_char_height
);
4315 defsubr (&Sframe_char_width
);
4316 defsubr (&Sframe_pixel_height
);
4317 defsubr (&Sframe_pixel_width
);
4318 defsubr (&Sset_frame_height
);
4319 defsubr (&Sset_frame_width
);
4320 defsubr (&Sset_frame_size
);
4321 defsubr (&Sset_frame_position
);
4323 #ifdef HAVE_WINDOW_SYSTEM
4324 defsubr (&Sx_get_resource
);
4325 defsubr (&Sx_parse_geometry
);
4330 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4331 (do not change this comment) */