1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003, 2006,
3 2004, 2005, 2006 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
;
78 Lisp_Object Qinhibit_default_face_x_resources
;
80 Lisp_Object Qx_frame_parameter
;
81 Lisp_Object Qx_resource_name
;
83 /* Frame parameters (set or reported). */
85 Lisp_Object Qauto_raise
, Qauto_lower
;
86 Lisp_Object Qborder_color
, Qborder_width
;
87 Lisp_Object Qcursor_color
, Qcursor_type
;
88 Lisp_Object Qgeometry
; /* Not used */
89 Lisp_Object Qheight
, Qwidth
;
90 Lisp_Object Qleft
, Qright
;
91 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
92 Lisp_Object Qinternal_border_width
;
93 Lisp_Object Qmouse_color
;
94 Lisp_Object Qminibuffer
;
95 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
96 Lisp_Object Qvisibility
;
97 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
98 Lisp_Object Qscreen_gamma
;
99 Lisp_Object Qline_spacing
;
100 Lisp_Object Quser_position
, Quser_size
;
101 Lisp_Object Qwait_for_wm
;
102 Lisp_Object Qwindow_id
;
103 #ifdef HAVE_X_WINDOWS
104 Lisp_Object Qouter_window_id
;
106 Lisp_Object Qparent_id
;
107 Lisp_Object Qtitle
, Qname
;
108 Lisp_Object Qunsplittable
;
109 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
110 Lisp_Object Qleft_fringe
, Qright_fringe
;
111 Lisp_Object Qbuffer_predicate
, Qbuffer_list
;
112 Lisp_Object Qtty_color_mode
;
114 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
;
115 #ifdef USE_FONT_BACKEND
116 Lisp_Object Qfont_backend
;
117 #endif /* USE_FONT_BACKEND */
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
1443 If Emacs is running on a mouseless terminal or hasn't been programmed
1444 to read the mouse position, it returns the selected frame for FRAME
1445 and nil for X and Y.
1446 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1447 passing the normal return value to that function as an argument,
1448 and returns whatever that function returns. */)
1452 Lisp_Object lispy_dummy
;
1453 enum scroll_bar_part party_dummy
;
1454 Lisp_Object x
, y
, retval
;
1456 unsigned long long_dummy
;
1457 struct gcpro gcpro1
;
1459 f
= SELECTED_FRAME ();
1463 /* It's okay for the hook to refrain from storing anything. */
1464 if (mouse_position_hook
)
1465 (*mouse_position_hook
) (&f
, -1,
1466 &lispy_dummy
, &party_dummy
,
1473 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1478 XSETFRAME (lispy_dummy
, f
);
1479 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1481 if (!NILP (Vmouse_position_function
))
1482 retval
= call1 (Vmouse_position_function
, retval
);
1483 RETURN_UNGCPRO (retval
);
1486 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1487 Smouse_pixel_position
, 0, 0, 0,
1488 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1489 The position is given in pixel units, where (0, 0) is the
1491 If Emacs is running on a mouseless terminal or hasn't been programmed
1492 to read the mouse position, it returns the selected frame for FRAME
1493 and nil for X and Y. */)
1497 Lisp_Object lispy_dummy
;
1498 enum scroll_bar_part party_dummy
;
1500 unsigned long long_dummy
;
1502 f
= SELECTED_FRAME ();
1506 /* It's okay for the hook to refrain from storing anything. */
1507 if (mouse_position_hook
)
1508 (*mouse_position_hook
) (&f
, -1,
1509 &lispy_dummy
, &party_dummy
,
1513 XSETFRAME (lispy_dummy
, f
);
1514 return Fcons (lispy_dummy
, Fcons (x
, y
));
1517 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1518 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1519 Coordinates are relative to the frame, not a window,
1520 so the coordinates of the top left character in the frame
1521 may be nonzero due to left-hand scroll bars or the menu bar.
1523 This function is a no-op for an X frame that is not visible.
1524 If you have just created a frame, you must wait for it to become visible
1525 before calling this function on it, like this.
1526 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1528 Lisp_Object frame
, x
, y
;
1530 CHECK_LIVE_FRAME (frame
);
1534 /* I think this should be done with a hook. */
1535 #ifdef HAVE_WINDOW_SYSTEM
1536 if (FRAME_WINDOW_P (XFRAME (frame
)))
1537 /* Warping the mouse will cause enternotify and focus events. */
1538 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1540 #if defined (MSDOS) && defined (HAVE_MOUSE)
1541 if (FRAME_MSDOS_P (XFRAME (frame
)))
1543 Fselect_frame (frame
);
1544 mouse_moveto (XINT (x
), XINT (y
));
1552 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1553 Sset_mouse_pixel_position
, 3, 3, 0,
1554 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1555 Note, this is a no-op for an X frame that is not visible.
1556 If you have just created a frame, you must wait for it to become visible
1557 before calling this function on it, like this.
1558 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1560 Lisp_Object frame
, x
, y
;
1562 CHECK_LIVE_FRAME (frame
);
1566 /* I think this should be done with a hook. */
1567 #ifdef HAVE_WINDOW_SYSTEM
1568 if (FRAME_WINDOW_P (XFRAME (frame
)))
1569 /* Warping the mouse will cause enternotify and focus events. */
1570 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1572 #if defined (MSDOS) && defined (HAVE_MOUSE)
1573 if (FRAME_MSDOS_P (XFRAME (frame
)))
1575 Fselect_frame (frame
);
1576 mouse_moveto (XINT (x
), XINT (y
));
1584 static void make_frame_visible_1
P_ ((Lisp_Object
));
1586 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1588 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1589 If omitted, FRAME defaults to the currently selected frame. */)
1594 frame
= selected_frame
;
1596 CHECK_LIVE_FRAME (frame
);
1598 /* I think this should be done with a hook. */
1599 #ifdef HAVE_WINDOW_SYSTEM
1600 if (FRAME_WINDOW_P (XFRAME (frame
)))
1602 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1603 x_make_frame_visible (XFRAME (frame
));
1607 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1609 /* Make menu bar update for the Buffers and Frames menus. */
1610 windows_or_buffers_changed
++;
1615 /* Update the display_time slot of the buffers shown in WINDOW
1616 and all its descendents. */
1619 make_frame_visible_1 (window
)
1624 for (;!NILP (window
); window
= w
->next
)
1626 w
= XWINDOW (window
);
1628 if (!NILP (w
->buffer
))
1629 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1631 if (!NILP (w
->vchild
))
1632 make_frame_visible_1 (w
->vchild
);
1633 if (!NILP (w
->hchild
))
1634 make_frame_visible_1 (w
->hchild
);
1638 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1640 doc
: /* Make the frame FRAME invisible (assuming it is an X window).
1641 If omitted, FRAME defaults to the currently selected frame.
1642 Normally you may not make FRAME invisible if all other frames are invisible,
1643 but if the second optional argument FORCE is non-nil, you may do so. */)
1645 Lisp_Object frame
, force
;
1648 frame
= selected_frame
;
1650 CHECK_LIVE_FRAME (frame
);
1652 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1653 error ("Attempt to make invisible the sole visible or iconified frame");
1655 #if 0 /* This isn't logically necessary, and it can do GC. */
1656 /* Don't let the frame remain selected. */
1657 if (EQ (frame
, selected_frame
))
1658 do_switch_frame (next_frame (frame
, Qt
), 0, 0)
1661 /* Don't allow minibuf_window to remain on a deleted frame. */
1662 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1664 struct frame
*sf
= XFRAME (selected_frame
);
1665 Fset_window_buffer (sf
->minibuffer_window
,
1666 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1667 minibuf_window
= sf
->minibuffer_window
;
1670 /* I think this should be done with a hook. */
1671 #ifdef HAVE_WINDOW_SYSTEM
1672 if (FRAME_WINDOW_P (XFRAME (frame
)))
1673 x_make_frame_invisible (XFRAME (frame
));
1676 /* Make menu bar update for the Buffers and Frames menus. */
1677 windows_or_buffers_changed
++;
1682 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1684 doc
: /* Make the frame FRAME into an icon.
1685 If omitted, FRAME defaults to the currently selected frame. */)
1690 frame
= selected_frame
;
1692 CHECK_LIVE_FRAME (frame
);
1694 #if 0 /* This isn't logically necessary, and it can do GC. */
1695 /* Don't let the frame remain selected. */
1696 if (EQ (frame
, selected_frame
))
1697 Fhandle_switch_frame (next_frame (frame
, Qt
));
1700 /* Don't allow minibuf_window to remain on a deleted frame. */
1701 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1703 struct frame
*sf
= XFRAME (selected_frame
);
1704 Fset_window_buffer (sf
->minibuffer_window
,
1705 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1706 minibuf_window
= sf
->minibuffer_window
;
1709 /* I think this should be done with a hook. */
1710 #ifdef HAVE_WINDOW_SYSTEM
1711 if (FRAME_WINDOW_P (XFRAME (frame
)))
1712 x_iconify_frame (XFRAME (frame
));
1715 /* Make menu bar update for the Buffers and Frames menus. */
1716 windows_or_buffers_changed
++;
1721 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1723 doc
: /* Return t if FRAME is now \"visible\" (actually in use for display).
1724 A frame that is not \"visible\" is not updated and, if it works through
1725 a window system, it may not show at all.
1726 Return the symbol `icon' if frame is visible only as an icon.
1728 On a text-only terminal, all frames are considered visible, whether
1729 they are currently being displayed or not, and this function returns t
1734 CHECK_LIVE_FRAME (frame
);
1736 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1738 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1740 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1745 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1747 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1750 Lisp_Object tail
, frame
;
1755 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1757 frame
= XCAR (tail
);
1758 if (!FRAMEP (frame
))
1761 if (FRAME_VISIBLE_P (f
))
1762 value
= Fcons (frame
, value
);
1768 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1769 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1770 If FRAME is invisible or iconified, make it visible.
1771 If you don't specify a frame, the selected frame is used.
1772 If Emacs is displaying on an ordinary terminal or some other device which
1773 doesn't support multiple overlapping frames, this function does nothing. */)
1778 frame
= selected_frame
;
1780 CHECK_LIVE_FRAME (frame
);
1782 /* Do like the documentation says. */
1783 Fmake_frame_visible (frame
);
1785 if (frame_raise_lower_hook
)
1786 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1791 /* Should we have a corresponding function called Flower_Power? */
1792 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1793 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
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 if (frame_raise_lower_hook
)
1806 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1812 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1814 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1815 In other words, switch-frame events caused by events in FRAME will
1816 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1817 FOCUS-FRAME after reading an event typed at FRAME.
1819 If FOCUS-FRAME is omitted or nil, any existing redirection is
1820 cancelled, and the frame again receives its own keystrokes.
1822 Focus redirection is useful for temporarily redirecting keystrokes to
1823 a surrogate minibuffer frame when a frame doesn't have its own
1826 A frame's focus redirection can be changed by `select-frame'. If frame
1827 FOO is selected, and then a different frame BAR is selected, any
1828 frames redirecting their focus to FOO are shifted to redirect their
1829 focus to BAR. This allows focus redirection to work properly when the
1830 user switches from one frame to another using `select-window'.
1832 This means that a frame whose focus is redirected to itself is treated
1833 differently from a frame whose focus is redirected to nil; the former
1834 is affected by `select-frame', while the latter is not.
1836 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1837 (frame
, focus_frame
)
1838 Lisp_Object frame
, focus_frame
;
1840 /* Note that we don't check for a live frame here. It's reasonable
1841 to redirect the focus of a frame you're about to delete, if you
1842 know what other frame should receive those keystrokes. */
1843 CHECK_FRAME (frame
);
1845 if (! NILP (focus_frame
))
1846 CHECK_LIVE_FRAME (focus_frame
);
1848 XFRAME (frame
)->focus_frame
= focus_frame
;
1850 if (frame_rehighlight_hook
)
1851 (*frame_rehighlight_hook
) (XFRAME (frame
));
1857 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1858 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1859 This returns nil if FRAME's focus is not redirected.
1860 See `redirect-frame-focus'. */)
1864 CHECK_LIVE_FRAME (frame
);
1866 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1871 /* Return the value of frame parameter PROP in frame FRAME. */
1874 get_frame_param (frame
, prop
)
1875 register struct frame
*frame
;
1878 register Lisp_Object tem
;
1880 tem
= Fassq (prop
, frame
->param_alist
);
1886 /* Return the buffer-predicate of the selected frame. */
1889 frame_buffer_predicate (frame
)
1892 return XFRAME (frame
)->buffer_predicate
;
1895 /* Return the buffer-list of the selected frame. */
1898 frame_buffer_list (frame
)
1901 return XFRAME (frame
)->buffer_list
;
1904 /* Set the buffer-list of the selected frame. */
1907 set_frame_buffer_list (frame
, list
)
1908 Lisp_Object frame
, list
;
1910 XFRAME (frame
)->buffer_list
= list
;
1913 /* Discard BUFFER from the buffer-list of each frame. */
1916 frames_discard_buffer (buffer
)
1919 Lisp_Object frame
, tail
;
1921 FOR_EACH_FRAME (tail
, frame
)
1923 XFRAME (frame
)->buffer_list
1924 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1928 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1929 If the alist already has an element for PROP, we change it. */
1932 store_in_alist (alistptr
, prop
, val
)
1933 Lisp_Object
*alistptr
, val
;
1936 register Lisp_Object tem
;
1938 tem
= Fassq (prop
, *alistptr
);
1940 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1946 frame_name_fnn_p (str
, len
)
1950 if (len
> 1 && str
[0] == 'F')
1954 strtol (str
+ 1, &end_ptr
, 10);
1956 if (end_ptr
== str
+ len
)
1962 /* Set the name of the terminal frame. Also used by MSDOS frames.
1963 Modeled after x_set_name which is used for WINDOW frames. */
1966 set_term_frame_name (f
, name
)
1970 f
->explicit_name
= ! NILP (name
);
1972 /* If NAME is nil, set the name to F<num>. */
1977 /* Check for no change needed in this very common case
1978 before we do any consing. */
1979 if (frame_name_fnn_p (SDATA (f
->name
),
1983 terminal_frame_count
++;
1984 sprintf (namebuf
, "F%d", terminal_frame_count
);
1985 name
= build_string (namebuf
);
1989 CHECK_STRING (name
);
1991 /* Don't change the name if it's already NAME. */
1992 if (! NILP (Fstring_equal (name
, f
->name
)))
1995 /* Don't allow the user to set the frame name to F<num>, so it
1996 doesn't clash with the names we generate for terminal frames. */
1997 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
1998 error ("Frame names of the form F<num> are usurped by Emacs");
2002 update_mode_lines
= 1;
2006 store_frame_param (f
, prop
, val
)
2008 Lisp_Object prop
, val
;
2010 register Lisp_Object old_alist_elt
;
2012 /* The buffer-alist parameter is stored in a special place and is
2013 not in the alist. */
2014 if (EQ (prop
, Qbuffer_list
))
2016 f
->buffer_list
= val
;
2020 /* If PROP is a symbol which is supposed to have frame-local values,
2021 and it is set up based on this frame, switch to the global
2022 binding. That way, we can create or alter the frame-local binding
2023 without messing up the symbol's status. */
2026 Lisp_Object valcontents
;
2027 valcontents
= SYMBOL_VALUE (prop
);
2028 if ((BUFFER_LOCAL_VALUEP (valcontents
)
2029 || SOME_BUFFER_LOCAL_VALUEP (valcontents
))
2030 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
2031 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
2032 swap_in_global_binding (prop
);
2036 /* The tty color mode needs to be set before the frame's parameter
2037 alist is updated with the new value, because set_tty_color_mode
2038 wants to look at the old mode. */
2039 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
))
2040 set_tty_color_mode (f
, val
);
2043 /* Update the frame parameter alist. */
2044 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2045 if (EQ (old_alist_elt
, Qnil
))
2046 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2048 Fsetcdr (old_alist_elt
, val
);
2050 /* Update some other special parameters in their special places
2051 in addition to the alist. */
2053 if (EQ (prop
, Qbuffer_predicate
))
2054 f
->buffer_predicate
= val
;
2056 if (! FRAME_WINDOW_P (f
))
2058 if (EQ (prop
, Qmenu_bar_lines
))
2059 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2060 else if (EQ (prop
, Qname
))
2061 set_term_frame_name (f
, val
);
2064 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2066 if (! MINI_WINDOW_P (XWINDOW (val
)))
2067 error ("Surrogate minibuffer windows must be minibuffer windows");
2069 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2070 && !EQ (val
, f
->minibuffer_window
))
2071 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2073 /* Install the chosen minibuffer window, with proper buffer. */
2074 f
->minibuffer_window
= val
;
2078 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2079 doc
: /* Return the parameters-alist of frame FRAME.
2080 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2081 The meaningful PARMs depend on the kind of frame.
2082 If FRAME is omitted, return information on the currently selected frame. */)
2089 struct gcpro gcpro1
;
2092 frame
= selected_frame
;
2094 CHECK_FRAME (frame
);
2097 if (!FRAME_LIVE_P (f
))
2100 alist
= Fcopy_alist (f
->param_alist
);
2103 if (!FRAME_WINDOW_P (f
))
2105 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2106 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2109 /* If the frame's parameter alist says the colors are
2110 unspecified and reversed, take the frame's background pixel
2111 for foreground and vice versa. */
2112 elt
= Fassq (Qforeground_color
, alist
);
2113 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2115 if (strncmp (SDATA (XCDR (elt
)),
2117 SCHARS (XCDR (elt
))) == 0)
2118 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2119 else if (strncmp (SDATA (XCDR (elt
)),
2121 SCHARS (XCDR (elt
))) == 0)
2122 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2125 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2126 elt
= Fassq (Qbackground_color
, alist
);
2127 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2129 if (strncmp (SDATA (XCDR (elt
)),
2131 SCHARS (XCDR (elt
))) == 0)
2132 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2133 else if (strncmp (SDATA (XCDR (elt
)),
2135 SCHARS (XCDR (elt
))) == 0)
2136 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2139 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2140 store_in_alist (&alist
, intern ("font"),
2141 build_string (FRAME_MSDOS_P (f
)
2143 : FRAME_W32_P (f
) ? "w32term"
2146 store_in_alist (&alist
, Qname
, f
->name
);
2147 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2148 store_in_alist (&alist
, Qheight
, make_number (height
));
2149 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2150 store_in_alist (&alist
, Qwidth
, make_number (width
));
2151 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2152 store_in_alist (&alist
, Qminibuffer
,
2153 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2154 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2155 : FRAME_MINIBUF_WINDOW (f
)));
2156 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2157 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2159 /* I think this should be done with a hook. */
2160 #ifdef HAVE_WINDOW_SYSTEM
2161 if (FRAME_WINDOW_P (f
))
2162 x_report_frame_params (f
, &alist
);
2166 /* This ought to be correct in f->param_alist for an X frame. */
2168 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2169 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2177 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2178 doc
: /* Return FRAME's value for parameter PARAMETER.
2179 If FRAME is nil, describe the currently selected frame. */)
2181 Lisp_Object frame
, parameter
;
2187 frame
= selected_frame
;
2189 CHECK_FRAME (frame
);
2190 CHECK_SYMBOL (parameter
);
2195 if (FRAME_LIVE_P (f
))
2197 /* Avoid consing in frequent cases. */
2198 if (EQ (parameter
, Qname
))
2200 #ifdef HAVE_X_WINDOWS
2201 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2202 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2203 #endif /* HAVE_X_WINDOWS */
2204 else if (EQ (parameter
, Qbackground_color
)
2205 || EQ (parameter
, Qforeground_color
))
2207 value
= Fassq (parameter
, f
->param_alist
);
2210 value
= XCDR (value
);
2211 /* Fframe_parameters puts the actual fg/bg color names,
2212 even if f->param_alist says otherwise. This is
2213 important when param_alist's notion of colors is
2214 "unspecified". We need to do the same here. */
2215 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2217 const char *color_name
;
2220 if (EQ (parameter
, Qbackground_color
))
2222 color_name
= SDATA (value
);
2223 csz
= SCHARS (value
);
2224 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2225 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2226 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2227 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2229 else if (EQ (parameter
, Qforeground_color
))
2231 color_name
= SDATA (value
);
2232 csz
= SCHARS (value
);
2233 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2234 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2235 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2236 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2241 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2243 else if (EQ (parameter
, Qdisplay_type
)
2244 || EQ (parameter
, Qbackground_mode
))
2245 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2247 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2254 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2255 Smodify_frame_parameters
, 2, 2, 0,
2256 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2257 If FRAME is nil, it defaults to the selected frame.
2258 ALIST is an alist of parameters to change and their new values.
2259 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2260 The meaningful PARMs depend on the kind of frame.
2261 Undefined PARMs are ignored, but stored in the frame's parameter list
2262 so that `frame-parameters' will return them.
2264 The value of frame parameter FOO can also be accessed
2265 as a frame-local binding for the variable FOO, if you have
2266 enabled such bindings for that variable with `make-variable-frame-local'. */)
2268 Lisp_Object frame
, alist
;
2271 register Lisp_Object tail
, prop
, val
;
2272 int count
= SPECPDL_INDEX ();
2274 /* Bind this to t to inhibit initialization of the default face from
2275 X resources in face-set-after-frame-default. If we don't inhibit
2276 this, modifying the `font' frame parameter, for example, while
2277 there is a `default.attributeFont' X resource, won't work,
2278 because `default's font is reset to the value of the X resource
2279 and that resets the `font' frame parameter. */
2280 specbind (Qinhibit_default_face_x_resources
, Qt
);
2282 if (EQ (frame
, Qnil
))
2283 frame
= selected_frame
;
2284 CHECK_LIVE_FRAME (frame
);
2287 /* I think this should be done with a hook. */
2288 #ifdef HAVE_WINDOW_SYSTEM
2289 if (FRAME_WINDOW_P (f
))
2290 x_set_frame_parameters (f
, alist
);
2294 if (FRAME_MSDOS_P (f
))
2295 IT_set_frame_parameters (f
, alist
);
2300 int length
= XINT (Flength (alist
));
2303 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2305 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2307 /* Extract parm names and values into those vectors. */
2310 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2315 parms
[i
] = Fcar (elt
);
2316 values
[i
] = Fcdr (elt
);
2320 /* Now process them in reverse of specified order. */
2321 for (i
--; i
>= 0; i
--)
2325 store_frame_param (f
, prop
, val
);
2327 /* Changing the background color might change the background
2328 mode, so that we have to load new defface specs.
2329 Call frame-set-background-mode to do that. */
2330 if (EQ (prop
, Qbackground_color
))
2331 call1 (Qframe_set_background_mode
, frame
);
2335 return unbind_to (count
, Qnil
);
2338 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2340 doc
: /* Height in pixels of a line in the font in frame FRAME.
2341 If FRAME is omitted, the selected frame is used.
2342 For a terminal frame, the value is always 1. */)
2349 frame
= selected_frame
;
2350 CHECK_FRAME (frame
);
2353 #ifdef HAVE_WINDOW_SYSTEM
2354 if (FRAME_WINDOW_P (f
))
2355 return make_number (x_char_height (f
));
2358 return make_number (1);
2362 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2364 doc
: /* Width in pixels of characters in the font in frame FRAME.
2365 If FRAME is omitted, the selected frame is used.
2366 On a graphical screen, the width is the standard width of the default font.
2367 For a terminal screen, the value is always 1. */)
2374 frame
= selected_frame
;
2375 CHECK_FRAME (frame
);
2378 #ifdef HAVE_WINDOW_SYSTEM
2379 if (FRAME_WINDOW_P (f
))
2380 return make_number (x_char_width (f
));
2383 return make_number (1);
2386 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2387 Sframe_pixel_height
, 0, 1, 0,
2388 doc
: /* Return a FRAME's height in pixels.
2389 This counts only the height available for text lines,
2390 not menu bars on window-system Emacs frames.
2391 For a terminal frame, the result really gives the height in characters.
2392 If FRAME is omitted, the selected frame is used. */)
2399 frame
= selected_frame
;
2400 CHECK_FRAME (frame
);
2403 #ifdef HAVE_WINDOW_SYSTEM
2404 if (FRAME_WINDOW_P (f
))
2405 return make_number (x_pixel_height (f
));
2408 return make_number (FRAME_LINES (f
));
2411 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2412 Sframe_pixel_width
, 0, 1, 0,
2413 doc
: /* Return FRAME's width in pixels.
2414 For a terminal frame, the result really gives the width in characters.
2415 If FRAME is omitted, the selected frame is used. */)
2422 frame
= selected_frame
;
2423 CHECK_FRAME (frame
);
2426 #ifdef HAVE_WINDOW_SYSTEM
2427 if (FRAME_WINDOW_P (f
))
2428 return make_number (x_pixel_width (f
));
2431 return make_number (FRAME_COLS (f
));
2434 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2435 doc
: /* Specify that the frame FRAME has LINES lines.
2436 Optional third arg non-nil means that redisplay should use LINES lines
2437 but that the idea of the actual height of the frame should not be changed. */)
2438 (frame
, lines
, pretend
)
2439 Lisp_Object frame
, lines
, pretend
;
2441 register struct frame
*f
;
2443 CHECK_NUMBER (lines
);
2445 frame
= selected_frame
;
2446 CHECK_LIVE_FRAME (frame
);
2449 /* I think this should be done with a hook. */
2450 #ifdef HAVE_WINDOW_SYSTEM
2451 if (FRAME_WINDOW_P (f
))
2453 if (XINT (lines
) != FRAME_LINES (f
))
2454 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2455 do_pending_window_change (0);
2459 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2463 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2464 doc
: /* Specify that the frame FRAME has COLS columns.
2465 Optional third arg non-nil means that redisplay should use COLS columns
2466 but that the idea of the actual width of the frame should not be changed. */)
2467 (frame
, cols
, pretend
)
2468 Lisp_Object frame
, cols
, pretend
;
2470 register struct frame
*f
;
2471 CHECK_NUMBER (cols
);
2473 frame
= selected_frame
;
2474 CHECK_LIVE_FRAME (frame
);
2477 /* I think this should be done with a hook. */
2478 #ifdef HAVE_WINDOW_SYSTEM
2479 if (FRAME_WINDOW_P (f
))
2481 if (XINT (cols
) != FRAME_COLS (f
))
2482 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2483 do_pending_window_change (0);
2487 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2491 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2492 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2494 Lisp_Object frame
, cols
, rows
;
2496 register struct frame
*f
;
2498 CHECK_LIVE_FRAME (frame
);
2499 CHECK_NUMBER (cols
);
2500 CHECK_NUMBER (rows
);
2503 /* I think this should be done with a hook. */
2504 #ifdef HAVE_WINDOW_SYSTEM
2505 if (FRAME_WINDOW_P (f
))
2507 if (XINT (rows
) != FRAME_LINES (f
)
2508 || XINT (cols
) != FRAME_COLS (f
)
2509 || f
->new_text_lines
|| f
->new_text_cols
)
2510 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2511 do_pending_window_change (0);
2515 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2520 DEFUN ("set-frame-position", Fset_frame_position
,
2521 Sset_frame_position
, 3, 3, 0,
2522 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2523 This is actually the position of the upper left corner of the frame.
2524 Negative values for XOFFSET or YOFFSET are interpreted relative to
2525 the rightmost or bottommost possible position (that stays within the screen). */)
2526 (frame
, xoffset
, yoffset
)
2527 Lisp_Object frame
, xoffset
, yoffset
;
2529 register struct frame
*f
;
2531 CHECK_LIVE_FRAME (frame
);
2532 CHECK_NUMBER (xoffset
);
2533 CHECK_NUMBER (yoffset
);
2536 /* I think this should be done with a hook. */
2537 #ifdef HAVE_WINDOW_SYSTEM
2538 if (FRAME_WINDOW_P (f
))
2539 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2546 /***********************************************************************
2548 ***********************************************************************/
2550 /* Connect the frame-parameter names for X frames
2551 to the ways of passing the parameter values to the window system.
2553 The name of a parameter, as a Lisp symbol,
2554 has an `x-frame-parameter' property which is an integer in Lisp
2555 that is an index in this table. */
2557 struct frame_parm_table
{
2559 Lisp_Object
*variable
;
2562 static struct frame_parm_table frame_parms
[] =
2564 {"auto-raise", &Qauto_raise
},
2565 {"auto-lower", &Qauto_lower
},
2566 {"background-color", 0},
2567 {"border-color", &Qborder_color
},
2568 {"border-width", &Qborder_width
},
2569 {"cursor-color", &Qcursor_color
},
2570 {"cursor-type", &Qcursor_type
},
2572 {"foreground-color", 0},
2573 {"icon-name", &Qicon_name
},
2574 {"icon-type", &Qicon_type
},
2575 {"internal-border-width", &Qinternal_border_width
},
2576 {"menu-bar-lines", &Qmenu_bar_lines
},
2577 {"mouse-color", &Qmouse_color
},
2579 {"scroll-bar-width", &Qscroll_bar_width
},
2581 {"unsplittable", &Qunsplittable
},
2582 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2583 {"visibility", &Qvisibility
},
2584 {"tool-bar-lines", &Qtool_bar_lines
},
2585 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2586 {"scroll-bar-background", &Qscroll_bar_background
},
2587 {"screen-gamma", &Qscreen_gamma
},
2588 {"line-spacing", &Qline_spacing
},
2589 {"left-fringe", &Qleft_fringe
},
2590 {"right-fringe", &Qright_fringe
},
2591 {"wait-for-wm", &Qwait_for_wm
},
2592 {"fullscreen", &Qfullscreen
},
2593 #ifdef USE_FONT_BACKEND
2594 {"font-backend", &Qfont_backend
}
2595 #endif /* USE_FONT_BACKEND */
2598 #ifdef HAVE_WINDOW_SYSTEM
2600 extern Lisp_Object Qbox
;
2601 extern Lisp_Object Qtop
;
2603 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2604 wanted positions of the WM window (not emacs window).
2605 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2606 window (FRAME_X_WINDOW).
2610 x_fullscreen_adjust (f
, width
, height
, top_pos
, left_pos
)
2617 int newwidth
= FRAME_COLS (f
);
2618 int newheight
= FRAME_LINES (f
);
2620 *top_pos
= f
->top_pos
;
2621 *left_pos
= f
->left_pos
;
2623 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2627 ph
= FRAME_X_DISPLAY_INFO (f
)->height
;
2628 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2629 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2630 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2634 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2638 pw
= FRAME_X_DISPLAY_INFO (f
)->width
;
2639 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2640 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2641 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2646 *height
= newheight
;
2650 /* Change the parameters of frame F as specified by ALIST.
2651 If a parameter is not specially recognized, do nothing special;
2652 otherwise call the `x_set_...' function for that parameter.
2653 Except for certain geometry properties, always call store_frame_param
2654 to store the new value in the parameter alist. */
2657 x_set_frame_parameters (f
, alist
)
2663 /* If both of these parameters are present, it's more efficient to
2664 set them both at once. So we wait until we've looked at the
2665 entire list before we set them. */
2669 Lisp_Object left
, top
;
2671 /* Same with these. */
2672 Lisp_Object icon_left
, icon_top
;
2674 /* Record in these vectors all the parms specified. */
2676 Lisp_Object
*values
;
2678 int left_no_change
= 0, top_no_change
= 0;
2679 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2680 int fullscreen_is_being_set
= 0;
2682 struct gcpro gcpro1
, gcpro2
;
2685 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2688 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2689 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2691 /* Extract parm names and values into those vectors. */
2694 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2699 parms
[i
] = Fcar (elt
);
2700 values
[i
] = Fcdr (elt
);
2703 /* TAIL and ALIST are not used again below here. */
2704 alist
= tail
= Qnil
;
2706 GCPRO2 (*parms
, *values
);
2710 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2711 because their values appear in VALUES and strings are not valid. */
2712 top
= left
= Qunbound
;
2713 icon_left
= icon_top
= Qunbound
;
2715 /* Provide default values for HEIGHT and WIDTH. */
2716 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2717 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2719 /* Process foreground_color and background_color before anything else.
2720 They are independent of other properties, but other properties (e.g.,
2721 cursor_color) are dependent upon them. */
2722 /* Process default font as well, since fringe widths depends on it. */
2723 /* Also, process fullscreen, width and height depend upon that */
2724 for (p
= 0; p
< i
; p
++)
2726 Lisp_Object prop
, val
;
2730 if (EQ (prop
, Qforeground_color
)
2731 || EQ (prop
, Qbackground_color
)
2733 || EQ (prop
, Qfullscreen
))
2735 register Lisp_Object param_index
, old_value
;
2737 old_value
= get_frame_param (f
, prop
);
2738 fullscreen_is_being_set
|= EQ (prop
, Qfullscreen
);
2740 if (NILP (Fequal (val
, old_value
)))
2742 store_frame_param (f
, prop
, val
);
2744 param_index
= Fget (prop
, Qx_frame_parameter
);
2745 if (NATNUMP (param_index
)
2746 && (XFASTINT (param_index
)
2747 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2748 && rif
->frame_parm_handlers
[XINT (param_index
)])
2749 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2754 /* Now process them in reverse of specified order. */
2755 for (i
--; i
>= 0; i
--)
2757 Lisp_Object prop
, val
;
2762 if (EQ (prop
, Qwidth
) && NUMBERP (val
))
2763 width
= XFASTINT (val
);
2764 else if (EQ (prop
, Qheight
) && NUMBERP (val
))
2765 height
= XFASTINT (val
);
2766 else if (EQ (prop
, Qtop
))
2768 else if (EQ (prop
, Qleft
))
2770 else if (EQ (prop
, Qicon_top
))
2772 else if (EQ (prop
, Qicon_left
))
2774 else if (EQ (prop
, Qforeground_color
)
2775 || EQ (prop
, Qbackground_color
)
2777 || EQ (prop
, Qfullscreen
))
2778 /* Processed above. */
2782 register Lisp_Object param_index
, old_value
;
2784 old_value
= get_frame_param (f
, prop
);
2786 store_frame_param (f
, prop
, val
);
2788 param_index
= Fget (prop
, Qx_frame_parameter
);
2789 if (NATNUMP (param_index
)
2790 && (XFASTINT (param_index
)
2791 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2792 && rif
->frame_parm_handlers
[XINT (param_index
)])
2793 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2797 /* Don't die if just one of these was set. */
2798 if (EQ (left
, Qunbound
))
2801 if (f
->left_pos
< 0)
2802 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2804 XSETINT (left
, f
->left_pos
);
2806 if (EQ (top
, Qunbound
))
2810 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2812 XSETINT (top
, f
->top_pos
);
2815 /* If one of the icon positions was not set, preserve or default it. */
2816 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
2818 icon_left_no_change
= 1;
2819 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2820 if (NILP (icon_left
))
2821 XSETINT (icon_left
, 0);
2823 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
2825 icon_top_no_change
= 1;
2826 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2827 if (NILP (icon_top
))
2828 XSETINT (icon_top
, 0);
2831 if (FRAME_VISIBLE_P (f
) && fullscreen_is_being_set
)
2833 /* If the frame is visible already and the fullscreen parameter is
2834 being set, it is too late to set WM manager hints to specify
2836 Here we first get the width, height and position that applies to
2837 fullscreen. We then move the frame to the appropriate
2838 position. Resize of the frame is taken care of in the code after
2839 this if-statement. */
2840 int new_left
, new_top
;
2842 x_fullscreen_adjust (f
, &width
, &height
, &new_top
, &new_left
);
2843 if (new_top
!= f
->top_pos
|| new_left
!= f
->left_pos
)
2844 x_set_offset (f
, new_left
, new_top
, 1);
2847 /* Don't set these parameters unless they've been explicitly
2848 specified. The window might be mapped or resized while we're in
2849 this function, and we don't want to override that unless the lisp
2850 code has asked for it.
2852 Don't set these parameters unless they actually differ from the
2853 window's current parameters; the window may not actually exist
2858 check_frame_size (f
, &height
, &width
);
2860 XSETFRAME (frame
, f
);
2862 if (width
!= FRAME_COLS (f
)
2863 || height
!= FRAME_LINES (f
)
2864 || f
->new_text_lines
|| f
->new_text_cols
)
2865 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2867 if ((!NILP (left
) || !NILP (top
))
2868 && ! (left_no_change
&& top_no_change
)
2869 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2870 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2875 /* Record the signs. */
2876 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2877 if (EQ (left
, Qminus
))
2878 f
->size_hint_flags
|= XNegative
;
2879 else if (INTEGERP (left
))
2881 leftpos
= XINT (left
);
2883 f
->size_hint_flags
|= XNegative
;
2885 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2886 && CONSP (XCDR (left
))
2887 && INTEGERP (XCAR (XCDR (left
))))
2889 leftpos
= - XINT (XCAR (XCDR (left
)));
2890 f
->size_hint_flags
|= XNegative
;
2892 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2893 && CONSP (XCDR (left
))
2894 && INTEGERP (XCAR (XCDR (left
))))
2896 leftpos
= XINT (XCAR (XCDR (left
)));
2899 if (EQ (top
, Qminus
))
2900 f
->size_hint_flags
|= YNegative
;
2901 else if (INTEGERP (top
))
2903 toppos
= XINT (top
);
2905 f
->size_hint_flags
|= YNegative
;
2907 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2908 && CONSP (XCDR (top
))
2909 && INTEGERP (XCAR (XCDR (top
))))
2911 toppos
= - XINT (XCAR (XCDR (top
)));
2912 f
->size_hint_flags
|= YNegative
;
2914 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2915 && CONSP (XCDR (top
))
2916 && INTEGERP (XCAR (XCDR (top
))))
2918 toppos
= XINT (XCAR (XCDR (top
)));
2922 /* Store the numeric value of the position. */
2923 f
->top_pos
= toppos
;
2924 f
->left_pos
= leftpos
;
2926 f
->win_gravity
= NorthWestGravity
;
2928 /* Actually set that position, and convert to absolute. */
2929 x_set_offset (f
, leftpos
, toppos
, -1);
2932 if ((!NILP (icon_left
) || !NILP (icon_top
))
2933 && ! (icon_left_no_change
&& icon_top_no_change
))
2934 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2941 /* Insert a description of internally-recorded parameters of frame X
2942 into the parameter alist *ALISTPTR that is to be given to the user.
2943 Only parameters that are specific to the X window system
2944 and whose values are not correctly recorded in the frame's
2945 param_alist need to be considered here. */
2948 x_report_frame_params (f
, alistptr
)
2950 Lisp_Object
*alistptr
;
2955 /* Represent negative positions (off the top or left screen edge)
2956 in a way that Fmodify_frame_parameters will understand correctly. */
2957 XSETINT (tem
, f
->left_pos
);
2958 if (f
->left_pos
>= 0)
2959 store_in_alist (alistptr
, Qleft
, tem
);
2961 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2963 XSETINT (tem
, f
->top_pos
);
2964 if (f
->top_pos
>= 0)
2965 store_in_alist (alistptr
, Qtop
, tem
);
2967 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2969 store_in_alist (alistptr
, Qborder_width
,
2970 make_number (f
->border_width
));
2971 store_in_alist (alistptr
, Qinternal_border_width
,
2972 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
2973 store_in_alist (alistptr
, Qleft_fringe
,
2974 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
2975 store_in_alist (alistptr
, Qright_fringe
,
2976 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
2977 store_in_alist (alistptr
, Qscroll_bar_width
,
2978 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2980 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
2981 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
2982 /* nil means "use default width"
2983 for non-toolkit scroll bar.
2984 ruler-mode.el depends on this. */
2986 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
2987 store_in_alist (alistptr
, Qwindow_id
,
2988 build_string (buf
));
2989 #ifdef HAVE_X_WINDOWS
2990 #ifdef USE_X_TOOLKIT
2991 /* Tooltip frame may not have this widget. */
2992 if (FRAME_X_OUTPUT (f
)->widget
)
2994 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
2995 store_in_alist (alistptr
, Qouter_window_id
,
2996 build_string (buf
));
2998 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
2999 FRAME_SAMPLE_VISIBILITY (f
);
3000 store_in_alist (alistptr
, Qvisibility
,
3001 (FRAME_VISIBLE_P (f
) ? Qt
3002 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3003 store_in_alist (alistptr
, Qdisplay
,
3004 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3006 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3009 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3010 store_in_alist (alistptr
, Qparent_id
, tem
);
3014 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3015 the previous value of that parameter, NEW_VALUE is the new value. */
3018 x_set_fullscreen (f
, new_value
, old_value
)
3020 Lisp_Object new_value
, old_value
;
3022 if (NILP (new_value
))
3023 f
->want_fullscreen
= FULLSCREEN_NONE
;
3024 else if (EQ (new_value
, Qfullboth
))
3025 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3026 else if (EQ (new_value
, Qfullwidth
))
3027 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3028 else if (EQ (new_value
, Qfullheight
))
3029 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3033 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3034 the previous value of that parameter, NEW_VALUE is the new value. */
3037 x_set_line_spacing (f
, new_value
, old_value
)
3039 Lisp_Object new_value
, old_value
;
3041 if (NILP (new_value
))
3042 f
->extra_line_spacing
= 0;
3043 else if (NATNUMP (new_value
))
3044 f
->extra_line_spacing
= XFASTINT (new_value
);
3046 signal_error ("Invalid line-spacing", new_value
);
3047 if (FRAME_VISIBLE_P (f
))
3052 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3053 the previous value of that parameter, NEW_VALUE is the new value. */
3056 x_set_screen_gamma (f
, new_value
, old_value
)
3058 Lisp_Object new_value
, old_value
;
3060 if (NILP (new_value
))
3062 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3063 /* The value 0.4545 is the normal viewing gamma. */
3064 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3066 signal_error ("Invalid screen-gamma", new_value
);
3068 clear_face_cache (0);
3073 x_set_font (f
, arg
, oldval
)
3075 Lisp_Object arg
, oldval
;
3078 Lisp_Object fontset_name
;
3080 int old_fontset
= FRAME_FONTSET(f
);
3082 #ifdef USE_FONT_BACKEND
3083 if (enable_font_backend
)
3086 Lisp_Object font_object
;
3088 /* ARG is a fontset name, a font name, or a font object.
3089 In the last case, this function never fail. */
3092 fontset
= fs_query_fontset (arg
, Qnil
);
3094 font_object
= font_open_by_name (f
, SDATA (arg
));
3095 else if (fontset
> 0)
3097 Lisp_Object ascii_font
= fontset_ascii (fontset
);
3099 font_object
= font_open_by_name (f
, SDATA (ascii_font
));
3105 if (fontset
< 0 && ! NILP (font_object
))
3106 fontset
= new_fontset_from_font (font_object
);
3109 /* Refuse the default fontset. */
3111 else if (NILP (font_object
))
3114 result
= x_new_fontset2 (f
, fontset
, font_object
);
3118 #endif /* USE_FONT_BACKEND */
3121 fontset_name
= Fquery_fontset (arg
, Qnil
);
3124 result
= (STRINGP (fontset_name
)
3125 ? x_new_fontset (f
, fontset_name
)
3126 : x_new_fontset (f
, arg
));
3128 #ifdef USE_FONT_BACKEND
3132 if (EQ (result
, Qnil
))
3133 error ("Font `%s' is not defined", SDATA (arg
));
3134 else if (EQ (result
, Qt
))
3135 error ("The default fontset can't be used for a frame font");
3136 else if (STRINGP (result
))
3138 set_default_ascii_font (result
);
3139 if (STRINGP (fontset_name
))
3141 /* Fontset names are built from ASCII font names, so the
3142 names may be equal despite there was a change. */
3143 if (old_fontset
== FRAME_FONTSET (f
))
3146 store_frame_param (f
, Qfont
, result
);
3148 if (!NILP (Fequal (result
, oldval
)))
3151 /* Recalculate toolbar height. */
3152 f
->n_tool_bar_rows
= 0;
3153 /* Ensure we redraw it. */
3154 clear_current_matrices (f
);
3156 recompute_basic_faces (f
);
3161 do_pending_window_change (0);
3163 /* Don't call `face-set-after-frame-default' when faces haven't been
3164 initialized yet. This is the case when called from
3165 Fx_create_frame. In that case, the X widget or window doesn't
3166 exist either, and we can end up in x_report_frame_params with a
3167 null widget which gives a segfault. */
3168 if (FRAME_FACE_CACHE (f
))
3170 XSETFRAME (frame
, f
);
3171 call1 (Qface_set_after_frame_default
, frame
);
3176 #ifdef USE_FONT_BACKEND
3178 x_set_font_backend (f
, new_value
, old_value
)
3180 Lisp_Object new_value
, old_value
;
3182 if (! NILP (new_value
)
3183 && !CONSP (new_value
))
3187 CHECK_STRING (new_value
);
3188 p0
= p1
= SDATA (new_value
);
3192 while (*p1
&& *p1
!= ',') p1
++;
3194 new_value
= Fcons (Fintern (make_string (p0
, p1
- p0
), Qnil
),
3200 new_value
= Fnreverse (new_value
);
3203 if (! NILP (old_value
) && ! NILP (Fequal (old_value
, new_value
)))
3206 if (FRAME_FONT_OBJECT (f
))
3208 free_all_realized_faces (Qnil
);
3209 Fclear_font_cache ();
3212 new_value
= font_update_drivers (f
, new_value
);
3213 if (NILP (new_value
))
3214 error ("No font backend available");
3215 store_frame_param (f
, Qfont_backend
, new_value
);
3217 if (FRAME_FONT_OBJECT (f
))
3221 XSETFRAME (frame
, f
);
3222 x_set_font (f
, Fframe_parameter (frame
, Qfont
), Qnil
);
3223 ++face_change_count
;
3224 ++windows_or_buffers_changed
;
3227 #endif /* USE_FONT_BACKEND */
3231 x_set_fringe_width (f
, new_value
, old_value
)
3233 Lisp_Object new_value
, old_value
;
3235 compute_fringe_widths (f
, 1);
3239 x_set_border_width (f
, arg
, oldval
)
3241 Lisp_Object arg
, oldval
;
3245 if (XINT (arg
) == f
->border_width
)
3248 if (FRAME_X_WINDOW (f
) != 0)
3249 error ("Cannot change the border width of a frame");
3251 f
->border_width
= XINT (arg
);
3255 x_set_internal_border_width (f
, arg
, oldval
)
3257 Lisp_Object arg
, oldval
;
3259 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3262 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3263 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3264 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3266 #ifdef USE_X_TOOLKIT
3267 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3268 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3271 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3274 if (FRAME_X_WINDOW (f
) != 0)
3276 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3277 SET_FRAME_GARBAGED (f
);
3278 do_pending_window_change (0);
3281 SET_FRAME_GARBAGED (f
);
3285 x_set_visibility (f
, value
, oldval
)
3287 Lisp_Object value
, oldval
;
3290 XSETFRAME (frame
, f
);
3293 Fmake_frame_invisible (frame
, Qt
);
3294 else if (EQ (value
, Qicon
))
3295 Ficonify_frame (frame
);
3297 Fmake_frame_visible (frame
);
3301 x_set_autoraise (f
, arg
, oldval
)
3303 Lisp_Object arg
, oldval
;
3305 f
->auto_raise
= !EQ (Qnil
, arg
);
3309 x_set_autolower (f
, arg
, oldval
)
3311 Lisp_Object arg
, oldval
;
3313 f
->auto_lower
= !EQ (Qnil
, arg
);
3317 x_set_unsplittable (f
, arg
, oldval
)
3319 Lisp_Object arg
, oldval
;
3321 f
->no_split
= !NILP (arg
);
3325 x_set_vertical_scroll_bars (f
, arg
, oldval
)
3327 Lisp_Object arg
, oldval
;
3329 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3330 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3331 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3332 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3334 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3336 ? vertical_scroll_bar_none
3338 ? vertical_scroll_bar_left
3340 ? vertical_scroll_bar_right
3341 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3342 ? vertical_scroll_bar_left
3343 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3344 ? vertical_scroll_bar_right
3345 : vertical_scroll_bar_none
);
3347 /* We set this parameter before creating the X window for the
3348 frame, so we can get the geometry right from the start.
3349 However, if the window hasn't been created yet, we shouldn't
3350 call x_set_window_size. */
3351 if (FRAME_X_WINDOW (f
))
3352 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3353 do_pending_window_change (0);
3358 x_set_scroll_bar_width (f
, arg
, oldval
)
3360 Lisp_Object arg
, oldval
;
3362 int wid
= FRAME_COLUMN_WIDTH (f
);
3366 x_set_scroll_bar_default_width (f
);
3368 if (FRAME_X_WINDOW (f
))
3369 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3370 do_pending_window_change (0);
3372 else if (INTEGERP (arg
) && XINT (arg
) > 0
3373 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3375 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3376 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3378 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3379 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3380 if (FRAME_X_WINDOW (f
))
3381 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3382 do_pending_window_change (0);
3385 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3386 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3387 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3392 /* Return non-nil if frame F wants a bitmap icon. */
3400 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3408 /* Subroutines of creating an X frame. */
3410 /* Make sure that Vx_resource_name is set to a reasonable value.
3411 Fix it up, or set it to `emacs' if it is too hopeless. */
3414 validate_x_resource_name ()
3417 /* Number of valid characters in the resource name. */
3419 /* Number of invalid characters in the resource name. */
3424 if (!STRINGP (Vx_resource_class
))
3425 Vx_resource_class
= build_string (EMACS_CLASS
);
3427 if (STRINGP (Vx_resource_name
))
3429 unsigned char *p
= SDATA (Vx_resource_name
);
3432 len
= SBYTES (Vx_resource_name
);
3434 /* Only letters, digits, - and _ are valid in resource names.
3435 Count the valid characters and count the invalid ones. */
3436 for (i
= 0; i
< len
; i
++)
3439 if (! ((c
>= 'a' && c
<= 'z')
3440 || (c
>= 'A' && c
<= 'Z')
3441 || (c
>= '0' && c
<= '9')
3442 || c
== '-' || c
== '_'))
3449 /* Not a string => completely invalid. */
3450 bad_count
= 5, good_count
= 0;
3452 /* If name is valid already, return. */
3456 /* If name is entirely invalid, or nearly so, use `emacs'. */
3458 || (good_count
== 1 && bad_count
> 0))
3460 Vx_resource_name
= build_string ("emacs");
3464 /* Name is partly valid. Copy it and replace the invalid characters
3465 with underscores. */
3467 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3469 for (i
= 0; i
< len
; i
++)
3471 int c
= SREF (new, i
);
3472 if (! ((c
>= 'a' && c
<= 'z')
3473 || (c
>= 'A' && c
<= 'Z')
3474 || (c
>= '0' && c
<= '9')
3475 || c
== '-' || c
== '_'))
3481 extern char *x_get_string_resource
P_ ((XrmDatabase
, char *, char *));
3482 extern Display_Info
*check_x_display_info
P_ ((Lisp_Object
));
3485 /* Get specified attribute from resource database RDB.
3486 See Fx_get_resource below for other parameters. */
3489 xrdb_get_resource (rdb
, attribute
, class, component
, subclass
)
3491 Lisp_Object attribute
, class, component
, subclass
;
3493 register char *value
;
3497 CHECK_STRING (attribute
);
3498 CHECK_STRING (class);
3500 if (!NILP (component
))
3501 CHECK_STRING (component
);
3502 if (!NILP (subclass
))
3503 CHECK_STRING (subclass
);
3504 if (NILP (component
) != NILP (subclass
))
3505 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3507 validate_x_resource_name ();
3509 /* Allocate space for the components, the dots which separate them,
3510 and the final '\0'. Make them big enough for the worst case. */
3511 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3512 + (STRINGP (component
)
3513 ? SBYTES (component
) : 0)
3514 + SBYTES (attribute
)
3517 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3519 + (STRINGP (subclass
)
3520 ? SBYTES (subclass
) : 0)
3523 /* Start with emacs.FRAMENAME for the name (the specific one)
3524 and with `Emacs' for the class key (the general one). */
3525 strcpy (name_key
, SDATA (Vx_resource_name
));
3526 strcpy (class_key
, SDATA (Vx_resource_class
));
3528 strcat (class_key
, ".");
3529 strcat (class_key
, SDATA (class));
3531 if (!NILP (component
))
3533 strcat (class_key
, ".");
3534 strcat (class_key
, SDATA (subclass
));
3536 strcat (name_key
, ".");
3537 strcat (name_key
, SDATA (component
));
3540 strcat (name_key
, ".");
3541 strcat (name_key
, SDATA (attribute
));
3543 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3545 if (value
!= (char *) 0)
3546 return build_string (value
);
3552 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3553 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3554 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3555 class, where INSTANCE is the name under which Emacs was invoked, or
3556 the name specified by the `-name' or `-rn' command-line arguments.
3558 The optional arguments COMPONENT and SUBCLASS add to the key and the
3559 class, respectively. You must specify both of them or neither.
3560 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3561 and the class is `Emacs.CLASS.SUBCLASS'. */)
3562 (attribute
, class, component
, subclass
)
3563 Lisp_Object attribute
, class, component
, subclass
;
3565 #ifdef HAVE_X_WINDOWS
3569 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3570 attribute
, class, component
, subclass
);
3573 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3576 display_x_get_resource (dpyinfo
, attribute
, class, component
, subclass
)
3577 Display_Info
*dpyinfo
;
3578 Lisp_Object attribute
, class, component
, subclass
;
3580 return xrdb_get_resource (dpyinfo
->xrdb
,
3581 attribute
, class, component
, subclass
);
3584 /* Used when C code wants a resource value. */
3587 x_get_resource_string (attribute
, class)
3588 char *attribute
, *class;
3592 struct frame
*sf
= SELECTED_FRAME ();
3594 /* Allocate space for the components, the dots which separate them,
3595 and the final '\0'. */
3596 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3597 + strlen (attribute
) + 2);
3598 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3599 + strlen (class) + 2);
3601 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3602 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3604 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3605 name_key
, class_key
);
3609 /* Return the value of parameter PARAM.
3611 First search ALIST, then Vdefault_frame_alist, then the X defaults
3612 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3614 Convert the resource to the type specified by desired_type.
3616 If no default is specified, return Qunbound. If you call
3617 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3618 and don't let it get stored in any Lisp-visible variables! */
3621 x_get_arg (dpyinfo
, alist
, param
, attribute
, class, type
)
3622 Display_Info
*dpyinfo
;
3623 Lisp_Object alist
, param
;
3626 enum resource_types type
;
3628 register Lisp_Object tem
;
3630 tem
= Fassq (param
, alist
);
3634 /* If we find this parm in ALIST, clear it out
3635 so that it won't be "left over" at the end. */
3636 #ifndef WINDOWSNT /* w32fns.c has not yet been changed to cope with this. */
3638 XSETCAR (tem
, Qnil
);
3639 /* In case the parameter appears more than once in the alist,
3641 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3642 if (CONSP (XCAR (tail
))
3643 && EQ (XCAR (XCAR (tail
)), param
))
3644 XSETCAR (XCAR (tail
), Qnil
);
3648 tem
= Fassq (param
, Vdefault_frame_alist
);
3650 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3651 look in the X resources. */
3656 tem
= display_x_get_resource (dpyinfo
,
3657 build_string (attribute
),
3658 build_string (class),
3666 case RES_TYPE_NUMBER
:
3667 return make_number (atoi (SDATA (tem
)));
3669 case RES_TYPE_FLOAT
:
3670 return make_float (atof (SDATA (tem
)));
3672 case RES_TYPE_BOOLEAN
:
3673 tem
= Fdowncase (tem
);
3674 if (!strcmp (SDATA (tem
), "on")
3675 || !strcmp (SDATA (tem
), "true"))
3680 case RES_TYPE_STRING
:
3683 case RES_TYPE_SYMBOL
:
3684 /* As a special case, we map the values `true' and `on'
3685 to Qt, and `false' and `off' to Qnil. */
3688 lower
= Fdowncase (tem
);
3689 if (!strcmp (SDATA (lower
), "on")
3690 || !strcmp (SDATA (lower
), "true"))
3692 else if (!strcmp (SDATA (lower
), "off")
3693 || !strcmp (SDATA (lower
), "false"))
3696 return Fintern (tem
, Qnil
);
3710 x_frame_get_arg (f
, alist
, param
, attribute
, class, type
)
3712 Lisp_Object alist
, param
;
3715 enum resource_types type
;
3717 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3718 alist
, param
, attribute
, class, type
);
3721 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3724 x_frame_get_and_record_arg (f
, alist
, param
, attribute
, class, type
)
3726 Lisp_Object alist
, param
;
3729 enum resource_types type
;
3733 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3734 attribute
, class, type
);
3735 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3736 store_frame_param (f
, param
, value
);
3742 /* Record in frame F the specified or default value according to ALIST
3743 of the parameter named PROP (a Lisp symbol).
3744 If no value is specified for PROP, look for an X default for XPROP
3745 on the frame named NAME.
3746 If that is not found either, use the value DEFLT. */
3749 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
3756 enum resource_types type
;
3760 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3761 if (EQ (tem
, Qunbound
))
3763 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3770 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3771 doc
: /* Parse an X-style geometry string STRING.
3772 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3773 The properties returned may include `top', `left', `height', and `width'.
3774 The value of `left' or `top' may be an integer,
3775 or a list (+ N) meaning N pixels relative to top/left corner,
3776 or a list (- N) meaning -N pixels relative to bottom/right corner. */)
3781 unsigned int width
, height
;
3784 CHECK_STRING (string
);
3786 geometry
= XParseGeometry ((char *) SDATA (string
),
3787 &x
, &y
, &width
, &height
);
3790 if (!!(geometry
& XValue
) != !!(geometry
& YValue
))
3791 error ("Must specify both x and y position, or neither");
3795 if (geometry
& XValue
)
3797 Lisp_Object element
;
3799 if (x
>= 0 && (geometry
& XNegative
))
3800 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3801 else if (x
< 0 && ! (geometry
& XNegative
))
3802 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3804 element
= Fcons (Qleft
, make_number (x
));
3805 result
= Fcons (element
, result
);
3808 if (geometry
& YValue
)
3810 Lisp_Object element
;
3812 if (y
>= 0 && (geometry
& YNegative
))
3813 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3814 else if (y
< 0 && ! (geometry
& YNegative
))
3815 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3817 element
= Fcons (Qtop
, make_number (y
));
3818 result
= Fcons (element
, result
);
3821 if (geometry
& WidthValue
)
3822 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3823 if (geometry
& HeightValue
)
3824 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3829 /* Calculate the desired size and position of frame F.
3830 Return the flags saying which aspects were specified.
3832 Also set the win_gravity and size_hint_flags of F.
3834 Adjust height for toolbar if TOOLBAR_P is 1.
3836 This function does not make the coordinates positive. */
3838 #define DEFAULT_ROWS 40
3839 #define DEFAULT_COLS 80
3842 x_figure_window_size (f
, parms
, toolbar_p
)
3847 register Lisp_Object tem0
, tem1
, tem2
;
3848 long window_prompting
= 0;
3849 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3851 /* Default values if we fall through.
3852 Actually, if that happens we should get
3853 window manager prompting. */
3854 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3855 FRAME_LINES (f
) = DEFAULT_ROWS
;
3856 /* Window managers expect that if program-specified
3857 positions are not (0,0), they're intentional, not defaults. */
3861 /* Ensure that old new_text_cols and new_text_lines will not override the
3863 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3864 f
->new_text_cols
= f
->new_text_lines
= 0;
3866 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3867 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3868 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3869 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3871 if (!EQ (tem0
, Qunbound
))
3873 CHECK_NUMBER (tem0
);
3874 FRAME_LINES (f
) = XINT (tem0
);
3876 if (!EQ (tem1
, Qunbound
))
3878 CHECK_NUMBER (tem1
);
3879 SET_FRAME_COLS (f
, XINT (tem1
));
3881 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
3882 window_prompting
|= USSize
;
3884 window_prompting
|= PSize
;
3887 f
->scroll_bar_actual_width
3888 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
3890 /* This used to be done _before_ calling x_figure_window_size, but
3891 since the height is reset here, this was really a no-op. I
3892 assume that moving it here does what Gerd intended (although he
3893 no longer can remember what that was... ++KFS, 2003-03-25. */
3895 /* Add the tool-bar height to the initial frame height so that the
3896 user gets a text display area of the size he specified with -g or
3897 via .Xdefaults. Later changes of the tool-bar height don't
3898 change the frame size. This is done so that users can create
3899 tall Emacs frames without having to guess how tall the tool-bar
3901 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
3903 int margin
, relief
, bar_height
;
3905 relief
= (tool_bar_button_relief
>= 0
3906 ? tool_bar_button_relief
3907 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
3909 if (INTEGERP (Vtool_bar_button_margin
)
3910 && XINT (Vtool_bar_button_margin
) > 0)
3911 margin
= XFASTINT (Vtool_bar_button_margin
);
3912 else if (CONSP (Vtool_bar_button_margin
)
3913 && INTEGERP (XCDR (Vtool_bar_button_margin
))
3914 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
3915 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
3919 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
3920 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
3923 compute_fringe_widths (f
, 0);
3925 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
3926 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
3928 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
3929 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
3930 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
3931 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3933 if (EQ (tem0
, Qminus
))
3936 window_prompting
|= YNegative
;
3938 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
3939 && CONSP (XCDR (tem0
))
3940 && INTEGERP (XCAR (XCDR (tem0
))))
3942 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
3943 window_prompting
|= YNegative
;
3945 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
3946 && CONSP (XCDR (tem0
))
3947 && INTEGERP (XCAR (XCDR (tem0
))))
3949 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
3951 else if (EQ (tem0
, Qunbound
))
3955 CHECK_NUMBER (tem0
);
3956 f
->top_pos
= XINT (tem0
);
3958 window_prompting
|= YNegative
;
3961 if (EQ (tem1
, Qminus
))
3964 window_prompting
|= XNegative
;
3966 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
3967 && CONSP (XCDR (tem1
))
3968 && INTEGERP (XCAR (XCDR (tem1
))))
3970 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
3971 window_prompting
|= XNegative
;
3973 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
3974 && CONSP (XCDR (tem1
))
3975 && INTEGERP (XCAR (XCDR (tem1
))))
3977 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
3979 else if (EQ (tem1
, Qunbound
))
3983 CHECK_NUMBER (tem1
);
3984 f
->left_pos
= XINT (tem1
);
3985 if (f
->left_pos
< 0)
3986 window_prompting
|= XNegative
;
3989 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
3990 window_prompting
|= USPosition
;
3992 window_prompting
|= PPosition
;
3995 if (f
->want_fullscreen
!= FULLSCREEN_NONE
)
4000 /* It takes both for some WM:s to place it where we want */
4001 window_prompting
= USPosition
| PPosition
;
4002 x_fullscreen_adjust (f
, &width
, &height
, &top
, &left
);
4003 FRAME_COLS (f
) = width
;
4004 FRAME_LINES (f
) = height
;
4005 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, width
);
4006 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, height
);
4011 if (window_prompting
& XNegative
)
4013 if (window_prompting
& YNegative
)
4014 f
->win_gravity
= SouthEastGravity
;
4016 f
->win_gravity
= NorthEastGravity
;
4020 if (window_prompting
& YNegative
)
4021 f
->win_gravity
= SouthWestGravity
;
4023 f
->win_gravity
= NorthWestGravity
;
4026 f
->size_hint_flags
= window_prompting
;
4028 return window_prompting
;
4033 #endif /* HAVE_WINDOW_SYSTEM */
4037 /***********************************************************************
4039 ***********************************************************************/
4044 Qframep
= intern ("framep");
4045 staticpro (&Qframep
);
4046 Qframe_live_p
= intern ("frame-live-p");
4047 staticpro (&Qframe_live_p
);
4048 Qheight
= intern ("height");
4049 staticpro (&Qheight
);
4050 Qicon
= intern ("icon");
4052 Qminibuffer
= intern ("minibuffer");
4053 staticpro (&Qminibuffer
);
4054 Qmodeline
= intern ("modeline");
4055 staticpro (&Qmodeline
);
4056 Qonly
= intern ("only");
4058 Qwidth
= intern ("width");
4059 staticpro (&Qwidth
);
4060 Qgeometry
= intern ("geometry");
4061 staticpro (&Qgeometry
);
4062 Qicon_left
= intern ("icon-left");
4063 staticpro (&Qicon_left
);
4064 Qicon_top
= intern ("icon-top");
4065 staticpro (&Qicon_top
);
4066 Qleft
= intern ("left");
4068 Qright
= intern ("right");
4069 staticpro (&Qright
);
4070 Quser_position
= intern ("user-position");
4071 staticpro (&Quser_position
);
4072 Quser_size
= intern ("user-size");
4073 staticpro (&Quser_size
);
4074 Qwindow_id
= intern ("window-id");
4075 staticpro (&Qwindow_id
);
4076 #ifdef HAVE_X_WINDOWS
4077 Qouter_window_id
= intern ("outer-window-id");
4078 staticpro (&Qouter_window_id
);
4080 Qparent_id
= intern ("parent-id");
4081 staticpro (&Qparent_id
);
4084 Qw32
= intern ("w32");
4086 Qpc
= intern ("pc");
4088 Qmac
= intern ("mac");
4090 Qvisible
= intern ("visible");
4091 staticpro (&Qvisible
);
4092 Qbuffer_predicate
= intern ("buffer-predicate");
4093 staticpro (&Qbuffer_predicate
);
4094 Qbuffer_list
= intern ("buffer-list");
4095 staticpro (&Qbuffer_list
);
4096 Qdisplay_type
= intern ("display-type");
4097 staticpro (&Qdisplay_type
);
4098 Qbackground_mode
= intern ("background-mode");
4099 staticpro (&Qbackground_mode
);
4100 Qtty_color_mode
= intern ("tty-color-mode");
4101 staticpro (&Qtty_color_mode
);
4103 Qface_set_after_frame_default
= intern ("face-set-after-frame-default");
4104 staticpro (&Qface_set_after_frame_default
);
4106 Qfullwidth
= intern ("fullwidth");
4107 staticpro (&Qfullwidth
);
4108 Qfullheight
= intern ("fullheight");
4109 staticpro (&Qfullheight
);
4110 Qfullboth
= intern ("fullboth");
4111 staticpro (&Qfullboth
);
4112 Qx_resource_name
= intern ("x-resource-name");
4113 staticpro (&Qx_resource_name
);
4115 Qx_frame_parameter
= intern ("x-frame-parameter");
4116 staticpro (&Qx_frame_parameter
);
4121 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4123 Lisp_Object v
= intern (frame_parms
[i
].name
);
4124 if (frame_parms
[i
].variable
)
4126 *frame_parms
[i
].variable
= v
;
4127 staticpro (frame_parms
[i
].variable
);
4129 Fput (v
, Qx_frame_parameter
, make_number (i
));
4133 #ifdef HAVE_WINDOW_SYSTEM
4134 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4135 doc
: /* The name Emacs uses to look up X resources.
4136 `x-get-resource' uses this as the first component of the instance name
4137 when requesting resource values.
4138 Emacs initially sets `x-resource-name' to the name under which Emacs
4139 was invoked, or to the value specified with the `-name' or `-rn'
4140 switches, if present.
4142 It may be useful to bind this variable locally around a call
4143 to `x-get-resource'. See also the variable `x-resource-class'. */);
4144 Vx_resource_name
= Qnil
;
4146 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4147 doc
: /* The class Emacs uses to look up X resources.
4148 `x-get-resource' uses this as the first component of the instance class
4149 when requesting resource values.
4151 Emacs initially sets `x-resource-class' to "Emacs".
4153 Setting this variable permanently is not a reasonable thing to do,
4154 but binding this variable locally around a call to `x-get-resource'
4155 is a reasonable practice. See also the variable `x-resource-name'. */);
4156 Vx_resource_class
= build_string (EMACS_CLASS
);
4159 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4160 doc
: /* Alist of default values for frame creation.
4161 These may be set in your init file, like this:
4162 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4163 These override values given in window system configuration data,
4164 including X Windows' defaults database.
4165 For values specific to the first Emacs frame, see `initial-frame-alist'.
4166 For values specific to the separate minibuffer frame, see
4167 `minibuffer-frame-alist'.
4168 The `menu-bar-lines' element of the list controls whether new frames
4169 have menu bars; `menu-bar-mode' works by altering this element.
4170 Setting this variable does not affect existing frames, only new ones. */);
4171 Vdefault_frame_alist
= Qnil
;
4173 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars
,
4174 doc
: /* Default position of scroll bars on this window-system. */);
4175 #ifdef HAVE_WINDOW_SYSTEM
4176 #if defined(HAVE_NTGUI) || defined(MAC_OS)
4177 /* MS-Windows has scroll bars on the right by default. */
4178 Vdefault_frame_scroll_bars
= Qright
;
4180 Vdefault_frame_scroll_bars
= Qleft
;
4183 Vdefault_frame_scroll_bars
= Qnil
;
4186 Qinhibit_default_face_x_resources
4187 = intern ("inhibit-default-face-x-resources");
4188 staticpro (&Qinhibit_default_face_x_resources
);
4190 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4191 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4193 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
4194 doc
: /* Non-nil if all of emacs is iconified and frame updates are not needed. */);
4195 Vemacs_iconified
= Qnil
;
4197 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4198 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4199 `mouse-position' calls this function, passing its usual return value as
4200 argument, and returns whatever this function returns.
4201 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4202 which need to do mouse handling at the Lisp level. */);
4203 Vmouse_position_function
= Qnil
;
4205 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4206 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4207 If the value is an integer, highlighting is only shown after moving the
4208 mouse, while keyboard input turns off the highlight even when the mouse
4209 is over the clickable text. However, the mouse shape still indicates
4210 when the mouse is over clickable text. */);
4211 Vmouse_highlight
= Qt
;
4213 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4214 doc
: /* Functions to be run before deleting a frame.
4215 The functions are run with one arg, the frame to be deleted.
4216 See `delete-frame'. */);
4217 Vdelete_frame_functions
= Qnil
;
4219 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4220 doc
: /* Minibufferless frames use this frame's minibuffer.
4222 Emacs cannot create minibufferless frames unless this is set to an
4223 appropriate surrogate.
4225 Emacs consults this variable only when creating minibufferless
4226 frames; once the frame is created, it sticks with its assigned
4227 minibuffer, no matter what this variable is set to. This means that
4228 this variable doesn't necessarily say anything meaningful about the
4229 current set of frames, or where the minibuffer is currently being
4232 This variable is local to the current terminal and cannot be buffer-local. */);
4234 staticpro (&Vframe_list
);
4236 defsubr (&Sactive_minibuffer_window
);
4238 defsubr (&Sframe_live_p
);
4239 defsubr (&Smake_terminal_frame
);
4240 defsubr (&Shandle_switch_frame
);
4241 defsubr (&Sselect_frame
);
4242 defsubr (&Sselected_frame
);
4243 defsubr (&Swindow_frame
);
4244 defsubr (&Sframe_root_window
);
4245 defsubr (&Sframe_first_window
);
4246 defsubr (&Sframe_selected_window
);
4247 defsubr (&Sset_frame_selected_window
);
4248 defsubr (&Sframe_list
);
4249 defsubr (&Snext_frame
);
4250 defsubr (&Sprevious_frame
);
4251 defsubr (&Sdelete_frame
);
4252 defsubr (&Smouse_position
);
4253 defsubr (&Smouse_pixel_position
);
4254 defsubr (&Sset_mouse_position
);
4255 defsubr (&Sset_mouse_pixel_position
);
4257 defsubr (&Sframe_configuration
);
4258 defsubr (&Srestore_frame_configuration
);
4260 defsubr (&Smake_frame_visible
);
4261 defsubr (&Smake_frame_invisible
);
4262 defsubr (&Siconify_frame
);
4263 defsubr (&Sframe_visible_p
);
4264 defsubr (&Svisible_frame_list
);
4265 defsubr (&Sraise_frame
);
4266 defsubr (&Slower_frame
);
4267 defsubr (&Sredirect_frame_focus
);
4268 defsubr (&Sframe_focus
);
4269 defsubr (&Sframe_parameters
);
4270 defsubr (&Sframe_parameter
);
4271 defsubr (&Smodify_frame_parameters
);
4272 defsubr (&Sframe_char_height
);
4273 defsubr (&Sframe_char_width
);
4274 defsubr (&Sframe_pixel_height
);
4275 defsubr (&Sframe_pixel_width
);
4276 defsubr (&Sset_frame_height
);
4277 defsubr (&Sset_frame_width
);
4278 defsubr (&Sset_frame_size
);
4279 defsubr (&Sset_frame_position
);
4281 #ifdef HAVE_WINDOW_SYSTEM
4282 defsubr (&Sx_get_resource
);
4283 defsubr (&Sx_parse_geometry
);
4288 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4289 (do not change this comment) */