1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2003
3 Free Software Foundation.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
37 /* These help us bind and responding to switch-frame events. */
41 #ifdef HAVE_WINDOW_SYSTEM
44 #include "blockinput.h"
45 #include "termhooks.h"
46 #include "dispextern.h"
54 #ifdef HAVE_WINDOW_SYSTEM
56 /* The name we're using in resource queries. Most often "emacs". */
58 Lisp_Object Vx_resource_name
;
60 /* The application class we're using in resource queries.
63 Lisp_Object Vx_resource_class
;
67 Lisp_Object Qframep
, Qframe_live_p
;
68 Lisp_Object Qicon
, Qmodeline
;
70 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
;
72 Lisp_Object Qdisplay_type
;
73 Lisp_Object Qbackground_mode
;
74 Lisp_Object Qinhibit_default_face_x_resources
;
76 Lisp_Object Qx_frame_parameter
;
77 Lisp_Object Qx_resource_name
;
79 /* Frame parameters (set or reported). */
81 Lisp_Object Qauto_raise
, Qauto_lower
;
82 Lisp_Object Qborder_color
, Qborder_width
;
83 Lisp_Object Qcursor_color
, Qcursor_type
;
84 Lisp_Object Qgeometry
; /* Not used */
85 Lisp_Object Qheight
, Qwidth
;
86 Lisp_Object Qleft
, Qright
;
87 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
88 Lisp_Object Qinternal_border_width
;
89 Lisp_Object Qmouse_color
;
90 Lisp_Object Qminibuffer
;
91 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
92 Lisp_Object Qvisibility
;
93 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
94 Lisp_Object Qscreen_gamma
;
95 Lisp_Object Qline_spacing
;
96 Lisp_Object Quser_position
, Quser_size
;
97 Lisp_Object Qwait_for_wm
;
98 Lisp_Object Qwindow_id
;
100 Lisp_Object Qouter_window_id
;
102 Lisp_Object Qparent_id
;
103 Lisp_Object Qtitle
, Qname
;
104 Lisp_Object Qunsplittable
;
105 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
106 Lisp_Object Qleft_fringe
, Qright_fringe
;
107 Lisp_Object Qbuffer_predicate
, Qbuffer_list
;
108 Lisp_Object Qtty_color_mode
;
110 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
;
112 Lisp_Object Qface_set_after_frame_default
;
115 Lisp_Object Vterminal_frame
;
116 Lisp_Object Vdefault_frame_alist
;
117 Lisp_Object Vmouse_position_function
;
118 Lisp_Object Vmouse_highlight
;
119 Lisp_Object Vdelete_frame_functions
;
122 set_menu_bar_lines_1 (window
, n
)
126 struct window
*w
= XWINDOW (window
);
128 XSETFASTINT (w
->last_modified
, 0);
129 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
130 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
132 if (INTEGERP (w
->orig_top_line
))
133 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
134 if (INTEGERP (w
->orig_total_lines
))
135 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
137 /* Handle just the top child in a vertical split. */
138 if (!NILP (w
->vchild
))
139 set_menu_bar_lines_1 (w
->vchild
, n
);
141 /* Adjust all children in a horizontal split. */
142 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
144 w
= XWINDOW (window
);
145 set_menu_bar_lines_1 (window
, n
);
150 set_menu_bar_lines (f
, value
, oldval
)
152 Lisp_Object value
, oldval
;
155 int olines
= FRAME_MENU_BAR_LINES (f
);
157 /* Right now, menu bars don't work properly in minibuf-only frames;
158 most of the commands try to apply themselves to the minibuffer
159 frame itself, and get an error because you can't switch buffers
160 in or split the minibuffer window. */
161 if (FRAME_MINIBUF_ONLY_P (f
))
164 if (INTEGERP (value
))
165 nlines
= XINT (value
);
169 if (nlines
!= olines
)
171 windows_or_buffers_changed
++;
172 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
173 FRAME_MENU_BAR_LINES (f
) = nlines
;
174 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
179 Lisp_Object Vemacs_iconified
;
180 Lisp_Object Vframe_list
;
182 struct x_output tty_display
;
184 extern Lisp_Object Vminibuffer_list
;
185 extern Lisp_Object
get_minibuffer ();
186 extern Lisp_Object
Fhandle_switch_frame ();
187 extern Lisp_Object
Fredirect_frame_focus ();
188 extern Lisp_Object
x_get_focus_frame ();
190 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
191 doc
: /* Return non-nil if OBJECT is a frame.
192 Value is t for a termcap frame (a character-only terminal),
193 `x' for an Emacs frame that is really an X window,
194 `w32' for an Emacs frame that is a window on MS-Windows display,
195 `mac' for an Emacs frame on a Macintosh display,
196 `pc' for a direct-write MS-DOS frame.
197 See also `frame-live-p'. */)
201 if (!FRAMEP (object
))
203 switch (XFRAME (object
)->output_method
)
207 case output_x_window
:
211 case output_msdos_raw
:
220 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
221 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
222 Value is nil if OBJECT is not a live frame. If object is a live
223 frame, the return value indicates what sort of output device it is
224 displayed on. See the documentation of `framep' for possible
229 return ((FRAMEP (object
)
230 && FRAME_LIVE_P (XFRAME (object
)))
240 register struct frame
*f
;
241 register Lisp_Object root_window
;
242 register Lisp_Object mini_window
;
244 f
= allocate_frame ();
245 XSETFRAME (frame
, f
);
247 f
->desired_matrix
= 0;
248 f
->current_matrix
= 0;
251 f
->glyphs_initialized_p
= 0;
252 f
->decode_mode_spec_buffer
= 0;
254 f
->async_visible
= 0;
255 f
->output_data
.nothing
= 0;
257 f
->async_iconified
= 0;
258 f
->wants_modeline
= 1;
263 f
->has_minibuffer
= mini_p
;
264 f
->focus_frame
= Qnil
;
265 f
->explicit_name
= 0;
266 f
->can_have_scroll_bars
= 0;
267 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
268 f
->param_alist
= Qnil
;
269 f
->scroll_bars
= Qnil
;
270 f
->condemned_scroll_bars
= Qnil
;
271 f
->face_alist
= Qnil
;
272 f
->face_cache
= NULL
;
273 f
->menu_bar_items
= Qnil
;
274 f
->menu_bar_vector
= Qnil
;
275 f
->menu_bar_items_used
= 0;
276 f
->buffer_predicate
= Qnil
;
277 f
->buffer_list
= Qnil
;
279 f
->kboard
= initial_kboard
;
283 f
->menu_bar_window
= Qnil
;
284 f
->tool_bar_window
= Qnil
;
285 f
->tool_bar_items
= Qnil
;
286 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
287 f
->n_tool_bar_items
= 0;
288 f
->left_fringe_width
= f
->right_fringe_width
= 0;
290 f
->scroll_bar_actual_width
= 0;
292 f
->internal_border_width
= 0;
293 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
294 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
295 f
->x_pixels_diff
= f
->y_pixels_diff
= 0;
296 #ifdef HAVE_WINDOW_SYSTEM
297 f
->want_fullscreen
= FULLSCREEN_NONE
;
299 f
->size_hint_flags
= 0;
302 root_window
= make_window ();
305 mini_window
= make_window ();
306 XWINDOW (root_window
)->next
= mini_window
;
307 XWINDOW (mini_window
)->prev
= root_window
;
308 XWINDOW (mini_window
)->mini_p
= Qt
;
309 XWINDOW (mini_window
)->frame
= frame
;
310 f
->minibuffer_window
= mini_window
;
315 XWINDOW (root_window
)->next
= Qnil
;
316 f
->minibuffer_window
= Qnil
;
319 XWINDOW (root_window
)->frame
= frame
;
322 just so that there is "something there."
323 Correct size will be set up later with change_frame_size. */
325 SET_FRAME_COLS (f
, 10);
326 FRAME_LINES (f
) = 10;
328 XSETFASTINT (XWINDOW (root_window
)->total_cols
, 10);
329 XSETFASTINT (XWINDOW (root_window
)->total_lines
, (mini_p
? 9 : 10));
333 XSETFASTINT (XWINDOW (mini_window
)->total_cols
, 10);
334 XSETFASTINT (XWINDOW (mini_window
)->top_line
, 9);
335 XSETFASTINT (XWINDOW (mini_window
)->total_lines
, 1);
338 /* Choose a buffer for the frame's root window. */
342 XWINDOW (root_window
)->buffer
= Qt
;
343 buf
= Fcurrent_buffer ();
344 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
345 a space), try to find another one. */
346 if (SREF (Fbuffer_name (buf
), 0) == ' ')
347 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
349 /* Use set_window_buffer, not Fset_window_buffer, and don't let
350 hooks be run by it. The reason is that the whole frame/window
351 arrangement is not yet fully intialized at this point. Windows
352 don't have the right size, glyph matrices aren't initialized
353 etc. Running Lisp functions at this point surely ends in a
355 set_window_buffer (root_window
, buf
, 0, 0);
356 f
->buffer_list
= Fcons (buf
, Qnil
);
361 XWINDOW (mini_window
)->buffer
= Qt
;
362 set_window_buffer (mini_window
,
363 (NILP (Vminibuffer_list
)
365 : Fcar (Vminibuffer_list
)),
369 f
->root_window
= root_window
;
370 f
->selected_window
= root_window
;
371 /* Make sure this window seems more recently used than
372 a newly-created, never-selected window. */
373 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, ++window_select_count
);
375 f
->default_face_done_p
= 0;
380 #ifdef HAVE_WINDOW_SYSTEM
381 /* Make a frame using a separate minibuffer window on another frame.
382 MINI_WINDOW is the minibuffer window to use. nil means use the
383 default (the global minibuffer). */
386 make_frame_without_minibuffer (mini_window
, kb
, display
)
387 register Lisp_Object mini_window
;
391 register struct frame
*f
;
394 if (!NILP (mini_window
))
395 CHECK_LIVE_WINDOW (mini_window
);
398 if (!NILP (mini_window
)
399 && XFRAME (XWINDOW (mini_window
)->frame
)->kboard
!= kb
)
400 error ("frame and minibuffer must be on the same display");
403 /* Make a frame containing just a root window. */
406 if (NILP (mini_window
))
408 /* Use default-minibuffer-frame if possible. */
409 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
410 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
412 Lisp_Object frame_dummy
;
414 XSETFRAME (frame_dummy
, f
);
415 GCPRO1 (frame_dummy
);
416 /* If there's no minibuffer frame to use, create one. */
417 kb
->Vdefault_minibuffer_frame
=
418 call1 (intern ("make-initial-minibuffer-frame"), display
);
422 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
425 f
->minibuffer_window
= mini_window
;
427 /* Make the chosen minibuffer window display the proper minibuffer,
428 unless it is already showing a minibuffer. */
429 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
430 Fset_window_buffer (mini_window
,
431 (NILP (Vminibuffer_list
)
433 : Fcar (Vminibuffer_list
)), Qnil
);
437 /* Make a frame containing only a minibuffer window. */
440 make_minibuffer_frame ()
442 /* First make a frame containing just a root window, no minibuffer. */
444 register struct frame
*f
= make_frame (0);
445 register Lisp_Object mini_window
;
446 register Lisp_Object frame
;
448 XSETFRAME (frame
, f
);
453 f
->wants_modeline
= 0;
454 f
->has_minibuffer
= 1;
456 /* Now label the root window as also being the minibuffer.
457 Avoid infinite looping on the window chain by marking next pointer
460 mini_window
= f
->minibuffer_window
= f
->root_window
;
461 XWINDOW (mini_window
)->mini_p
= Qt
;
462 XWINDOW (mini_window
)->next
= Qnil
;
463 XWINDOW (mini_window
)->prev
= Qnil
;
464 XWINDOW (mini_window
)->frame
= frame
;
466 /* Put the proper buffer in that window. */
468 Fset_window_buffer (mini_window
,
469 (NILP (Vminibuffer_list
)
471 : Fcar (Vminibuffer_list
)), Qnil
);
474 #endif /* HAVE_WINDOW_SYSTEM */
476 /* Construct a frame that refers to the terminal (stdin and stdout). */
478 static int terminal_frame_count
;
481 make_terminal_frame ()
483 register struct frame
*f
;
490 initial_kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
491 init_kboard (initial_kboard
);
492 initial_kboard
->next_kboard
= all_kboards
;
493 all_kboards
= initial_kboard
;
497 /* The first call must initialize Vframe_list. */
498 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
503 XSETFRAME (frame
, f
);
504 Vframe_list
= Fcons (frame
, Vframe_list
);
506 terminal_frame_count
++;
507 sprintf (name
, "F%d", terminal_frame_count
);
508 f
->name
= build_string (name
);
510 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
511 f
->async_visible
= 1; /* Don't let visible be cleared later. */
513 f
->output_data
.x
= &the_only_x_display
;
514 if (!inhibit_window_system
515 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
516 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
518 f
->output_method
= output_msdos_raw
;
519 /* This initialization of foreground and background pixels is
520 only important for the initial frame created in temacs. If
521 we don't do that, we get black background and foreground in
522 the dumped Emacs because the_only_x_display is a static
523 variable, hence it is born all-zeroes, and zero is the code
524 for the black color. Other frames all inherit their pixels
525 from what's already in the_only_x_display. */
526 if ((!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
527 && f
->output_data
.x
->background_pixel
== 0
528 && f
->output_data
.x
->foreground_pixel
== 0)
530 f
->output_data
.x
->background_pixel
= FACE_TTY_DEFAULT_BG_COLOR
;
531 f
->output_data
.x
->foreground_pixel
= FACE_TTY_DEFAULT_FG_COLOR
;
535 f
->output_method
= output_termcap
;
538 f
->output_method
= output_termcap
;
539 f
->output_data
.x
= &tty_display
;
542 make_mac_terminal_frame (f
);
544 f
->output_data
.x
= &tty_display
;
546 FRAME_FOREGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_FG_COLOR
;
547 FRAME_BACKGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_BG_COLOR
;
550 #endif /* WINDOWSNT */
554 init_frame_faces (f
);
559 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
561 doc
: /* Create an additional terminal frame.
562 You can create multiple frames on a text-only terminal in this way.
563 Only the selected terminal frame is actually displayed.
564 This function takes one argument, an alist specifying frame parameters.
565 In practice, generally you don't need to specify any parameters.
566 Note that changing the size of one terminal frame automatically affects all. */)
571 Lisp_Object frame
, tem
;
572 struct frame
*sf
= SELECTED_FRAME ();
575 if (sf
->output_method
!= output_msdos_raw
576 && sf
->output_method
!= output_termcap
)
578 #else /* not MSDOS */
581 if (sf
->output_method
!= output_mac
)
582 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
584 if (sf
->output_method
!= output_termcap
)
585 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
587 #endif /* not MSDOS */
589 f
= make_terminal_frame ();
591 change_frame_size (f
, FRAME_LINES (sf
),
592 FRAME_COLS (sf
), 0, 0, 0);
595 XSETFRAME (frame
, f
);
596 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
597 Fmodify_frame_parameters (frame
, parms
);
599 /* Make the frame face alist be frame-specific, so that each
600 frame could change its face definitions independently. */
601 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
602 /* Simple Fcopy_alist isn't enough, because we need the contents of
603 the vectors which are the CDRs of associations in face_alist to
604 be copied as well. */
605 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
606 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
611 /* Perform the switch to frame FRAME.
613 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
616 If TRACK is non-zero and the frame that currently has the focus
617 redirects its focus to the selected frame, redirect that focused
618 frame's focus to FRAME instead.
620 FOR_DELETION non-zero means that the selected frame is being
621 deleted, which includes the possibility that the frame's display
625 do_switch_frame (frame
, track
, for_deletion
)
627 int track
, for_deletion
;
629 struct frame
*sf
= SELECTED_FRAME ();
631 /* If FRAME is a switch-frame event, extract the frame we should
634 && EQ (XCAR (frame
), Qswitch_frame
)
635 && CONSP (XCDR (frame
)))
636 frame
= XCAR (XCDR (frame
));
638 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
639 a switch-frame event to arrive after a frame is no longer live,
640 especially when deleting the initial frame during startup. */
642 if (! FRAME_LIVE_P (XFRAME (frame
)))
645 if (sf
== XFRAME (frame
))
648 /* This is too greedy; it causes inappropriate focus redirection
649 that's hard to get rid of. */
651 /* If a frame's focus has been redirected toward the currently
652 selected frame, we should change the redirection to point to the
653 newly selected frame. This means that if the focus is redirected
654 from a minibufferless frame to a surrogate minibuffer frame, we
655 can use `other-window' to switch between all the frames using
656 that minibuffer frame, and the focus redirection will follow us
662 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
666 if (!FRAMEP (XCAR (tail
)))
669 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
671 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
672 Fredirect_frame_focus (XCAR (tail
), frame
);
676 /* Instead, apply it only to the frame we're pointing to. */
677 #ifdef HAVE_WINDOW_SYSTEM
678 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
680 Lisp_Object focus
, xfocus
;
682 xfocus
= x_get_focus_frame (XFRAME (frame
));
685 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
686 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
687 Fredirect_frame_focus (xfocus
, frame
);
690 #endif /* HAVE_X_WINDOWS */
693 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
694 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
696 selected_frame
= frame
;
697 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
698 last_nonminibuf_frame
= XFRAME (selected_frame
);
700 Fselect_window (XFRAME (frame
)->selected_window
, Qnil
);
703 /* Make sure to switch the tty color mode to that of the newly
705 sf
= SELECTED_FRAME ();
706 if (FRAME_TERMCAP_P (sf
))
708 Lisp_Object color_mode_spec
, color_mode
;
710 color_mode_spec
= assq_no_quit (Qtty_color_mode
, sf
->param_alist
);
711 if (CONSP (color_mode_spec
))
712 color_mode
= XCDR (color_mode_spec
);
714 color_mode
= make_number (0);
715 set_tty_color_mode (sf
, color_mode
);
717 #endif /* !WINDOWSNT */
719 /* We want to make sure that the next event generates a frame-switch
720 event to the appropriate frame. This seems kludgy to me, but
721 before you take it out, make sure that evaluating something like
722 (select-window (frame-root-window (new-frame))) doesn't end up
723 with your typing being interpreted in the new frame instead of
724 the one you're actually typing in. */
725 internal_last_event_frame
= Qnil
;
730 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
731 doc
: /* Select the frame FRAME.
732 Subsequent editing commands apply to its selected window.
733 The selection of FRAME lasts until the next time the user does
734 something to select a different frame, or until the next time this
735 function is called. */)
737 Lisp_Object frame
, no_enter
;
739 return do_switch_frame (frame
, 1, 0);
743 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 2, "e",
744 doc
: /* Handle a switch-frame event EVENT.
745 Switch-frame events are usually bound to this function.
746 A switch-frame event tells Emacs that the window manager has requested
747 that the user's events be directed to the frame mentioned in the event.
748 This function selects the selected window of the frame of EVENT.
750 If EVENT is frame object, handle it as if it were a switch-frame event
753 Lisp_Object event
, no_enter
;
755 /* Preserve prefix arg that the command loop just cleared. */
756 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
757 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
758 return do_switch_frame (event
, 0, 0);
761 DEFUN ("ignore-event", Fignore_event
, Signore_event
, 0, 0, "",
762 doc
: /* Do nothing, but preserve any prefix argument already specified.
763 This is a suitable binding for `iconify-frame' and `make-frame-visible'. */)
766 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
770 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
771 doc
: /* Return the frame that is now selected. */)
774 return selected_frame
;
777 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
778 doc
: /* Return the frame object that window WINDOW is on. */)
782 CHECK_LIVE_WINDOW (window
);
783 return XWINDOW (window
)->frame
;
786 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
787 doc
: /* Returns the topmost, leftmost window of FRAME.
788 If omitted, FRAME defaults to the currently selected frame. */)
795 w
= SELECTED_FRAME ()->root_window
;
798 CHECK_LIVE_FRAME (frame
);
799 w
= XFRAME (frame
)->root_window
;
801 while (NILP (XWINDOW (w
)->buffer
))
803 if (! NILP (XWINDOW (w
)->hchild
))
804 w
= XWINDOW (w
)->hchild
;
805 else if (! NILP (XWINDOW (w
)->vchild
))
806 w
= XWINDOW (w
)->vchild
;
813 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
814 Sactive_minibuffer_window
, 0, 0, 0,
815 doc
: /* Return the currently active minibuffer window, or nil if none. */)
818 return minibuf_level
? minibuf_window
: Qnil
;
821 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
822 doc
: /* Returns the root-window of FRAME.
823 If omitted, FRAME defaults to the currently selected frame. */)
830 window
= SELECTED_FRAME ()->root_window
;
833 CHECK_LIVE_FRAME (frame
);
834 window
= XFRAME (frame
)->root_window
;
840 DEFUN ("frame-selected-window", Fframe_selected_window
,
841 Sframe_selected_window
, 0, 1, 0,
842 doc
: /* Return the selected window of frame object FRAME.
843 If omitted, FRAME defaults to the currently selected frame. */)
850 window
= SELECTED_FRAME ()->selected_window
;
853 CHECK_LIVE_FRAME (frame
);
854 window
= XFRAME (frame
)->selected_window
;
860 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
861 Sset_frame_selected_window
, 2, 2, 0,
862 doc
: /* Set the selected window of frame object FRAME to WINDOW.
863 If FRAME is nil, the selected frame is used.
864 If FRAME is the selected frame, this makes WINDOW the selected window. */)
866 Lisp_Object frame
, window
;
869 frame
= selected_frame
;
871 CHECK_LIVE_FRAME (frame
);
872 CHECK_LIVE_WINDOW (window
);
874 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
875 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
877 if (EQ (frame
, selected_frame
))
878 return Fselect_window (window
, Qnil
);
880 return XFRAME (frame
)->selected_window
= window
;
883 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
885 doc
: /* Return a list of all frames. */)
889 frames
= Fcopy_sequence (Vframe_list
);
890 #ifdef HAVE_WINDOW_SYSTEM
891 if (FRAMEP (tip_frame
))
892 frames
= Fdelq (tip_frame
, frames
);
897 /* Return the next frame in the frame list after FRAME.
898 If MINIBUF is nil, exclude minibuffer-only frames.
899 If MINIBUF is a window, include only its own frame
900 and any frame now using that window as the minibuffer.
901 If MINIBUF is `visible', include all visible frames.
902 If MINIBUF is 0, include all visible and iconified frames.
903 Otherwise, include all frames. */
906 next_frame (frame
, minibuf
)
913 /* There must always be at least one frame in Vframe_list. */
914 if (! CONSP (Vframe_list
))
917 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
918 forever. Forestall that. */
919 CHECK_LIVE_FRAME (frame
);
922 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
929 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
931 /* Decide whether this frame is eligible to be returned. */
933 /* If we've looped all the way around without finding any
934 eligible frames, return the original frame. */
938 /* Let minibuf decide if this frame is acceptable. */
941 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
944 else if (EQ (minibuf
, Qvisible
))
946 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
947 if (FRAME_VISIBLE_P (XFRAME (f
)))
950 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
952 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
953 if (FRAME_VISIBLE_P (XFRAME (f
))
954 || FRAME_ICONIFIED_P (XFRAME (f
)))
957 else if (WINDOWP (minibuf
))
959 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
960 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
961 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
962 FRAME_FOCUS_FRAME (XFRAME (f
))))
974 /* Return the previous frame in the frame list before FRAME.
975 If MINIBUF is nil, exclude minibuffer-only frames.
976 If MINIBUF is a window, include only its own frame
977 and any frame now using that window as the minibuffer.
978 If MINIBUF is `visible', include all visible frames.
979 If MINIBUF is 0, include all visible and iconified frames.
980 Otherwise, include all frames. */
983 prev_frame (frame
, minibuf
)
990 /* There must always be at least one frame in Vframe_list. */
991 if (! CONSP (Vframe_list
))
995 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1003 if (EQ (frame
, f
) && !NILP (prev
))
1006 if (FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1008 /* Decide whether this frame is eligible to be returned,
1009 according to minibuf. */
1012 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1015 else if (WINDOWP (minibuf
))
1017 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1018 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1019 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1020 FRAME_FOCUS_FRAME (XFRAME (f
))))
1023 else if (EQ (minibuf
, Qvisible
))
1025 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1026 if (FRAME_VISIBLE_P (XFRAME (f
)))
1029 else if (XFASTINT (minibuf
) == 0)
1031 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1032 if (FRAME_VISIBLE_P (XFRAME (f
))
1033 || FRAME_ICONIFIED_P (XFRAME (f
)))
1041 /* We've scanned the entire list. */
1043 /* We went through the whole frame list without finding a single
1044 acceptable frame. Return the original frame. */
1047 /* There were no acceptable frames in the list before FRAME; otherwise,
1048 we would have returned directly from the loop. Since PREV is the last
1049 acceptable frame in the list, return it. */
1054 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1055 doc
: /* Return the next frame in the frame list after FRAME.
1056 It considers only frames on the same terminal as FRAME.
1057 By default, skip minibuffer-only frames.
1058 If omitted, FRAME defaults to the selected frame.
1059 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1060 If MINIFRAME is a window, include only its own frame
1061 and any frame now using that window as the minibuffer.
1062 If MINIFRAME is `visible', include all visible frames.
1063 If MINIFRAME is 0, include all visible and iconified frames.
1064 Otherwise, include all frames. */)
1066 Lisp_Object frame
, miniframe
;
1069 frame
= selected_frame
;
1071 CHECK_LIVE_FRAME (frame
);
1072 return next_frame (frame
, miniframe
);
1075 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1076 doc
: /* Return the previous frame in the frame list before FRAME.
1077 It considers only frames on the same terminal as FRAME.
1078 By default, skip minibuffer-only frames.
1079 If omitted, FRAME defaults to the selected frame.
1080 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1081 If MINIFRAME is a window, include only its own frame
1082 and any frame now using that window as the minibuffer.
1083 If MINIFRAME is `visible', include all visible frames.
1084 If MINIFRAME is 0, include all visible and iconified frames.
1085 Otherwise, include all frames. */)
1087 Lisp_Object frame
, miniframe
;
1090 frame
= selected_frame
;
1091 CHECK_LIVE_FRAME (frame
);
1092 return prev_frame (frame
, miniframe
);
1095 /* Return 1 if it is ok to delete frame F;
1096 0 if all frames aside from F are invisible.
1097 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1100 other_visible_frames (f
)
1103 /* We know the selected frame is visible,
1104 so if F is some other frame, it can't be the sole visible one. */
1105 if (f
== SELECTED_FRAME ())
1110 for (frames
= Vframe_list
;
1112 frames
= XCDR (frames
))
1116 this = XCAR (frames
);
1117 /* Verify that the frame's window still exists
1118 and we can still talk to it. And note any recent change
1120 #ifdef HAVE_WINDOW_SYSTEM
1121 if (FRAME_WINDOW_P (XFRAME (this)))
1123 x_sync (XFRAME (this));
1124 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1128 if (FRAME_VISIBLE_P (XFRAME (this))
1129 || FRAME_ICONIFIED_P (XFRAME (this))
1130 /* Allow deleting the terminal frame when at least
1131 one X frame exists! */
1132 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1140 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1141 doc
: /* Delete FRAME, permanently eliminating it from use.
1142 If omitted, FRAME defaults to the selected frame.
1143 A frame may not be deleted if its minibuffer is used by other frames.
1144 Normally, you may not delete a frame if all other frames are invisible,
1145 but if the second optional argument FORCE is non-nil, you may do so.
1147 This function runs `delete-frame-functions' before actually deleting the
1148 frame, unless the frame is a tooltip.
1149 The functions are run with one arg, the frame to be deleted. */)
1151 Lisp_Object frame
, force
;
1154 struct frame
*sf
= SELECTED_FRAME ();
1155 int minibuffer_selected
;
1157 if (EQ (frame
, Qnil
))
1160 XSETFRAME (frame
, f
);
1164 CHECK_FRAME (frame
);
1168 if (! FRAME_LIVE_P (f
))
1171 if (NILP (force
) && !other_visible_frames (f
)
1173 /* Terminal frame deleted before any other visible frames are
1175 && strcmp (SDATA (f
->name
), "F1") != 0
1178 error ("Attempt to delete the sole visible or iconified frame");
1181 /* This is a nice idea, but x_connection_closed needs to be able
1182 to delete the last frame, if it is gone. */
1183 if (NILP (XCDR (Vframe_list
)))
1184 error ("Attempt to delete the only frame");
1187 /* Does this frame have a minibuffer, and is it the surrogate
1188 minibuffer for any other frame? */
1189 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1193 for (frames
= Vframe_list
;
1195 frames
= XCDR (frames
))
1198 this = XCAR (frames
);
1200 if (! EQ (this, frame
)
1202 WINDOW_FRAME (XWINDOW
1203 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1204 error ("Attempt to delete a surrogate minibuffer frame");
1208 /* Run `delete-frame-functions' unless frame is a tooltip. */
1209 if (!NILP (Vrun_hooks
)
1210 && NILP (Fframe_parameter (frame
, intern ("tooltip"))))
1212 Lisp_Object args
[2];
1213 args
[0] = intern ("delete-frame-functions");
1215 Frun_hook_with_args (2, args
);
1218 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1220 /* Don't let the frame remain selected. */
1223 Lisp_Object tail
, frame1
;
1225 /* Look for another visible frame on the same terminal. */
1226 frame1
= next_frame (frame
, Qvisible
);
1228 /* If there is none, find *some* other frame. */
1229 if (NILP (frame1
) || EQ (frame1
, frame
))
1231 FOR_EACH_FRAME (tail
, frame1
)
1233 if (! EQ (frame
, frame1
))
1238 do_switch_frame (frame1
, 0, 1);
1239 sf
= SELECTED_FRAME ();
1242 /* Don't allow minibuf_window to remain on a deleted frame. */
1243 if (EQ (f
->minibuffer_window
, minibuf_window
))
1245 Fset_window_buffer (sf
->minibuffer_window
,
1246 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1247 minibuf_window
= sf
->minibuffer_window
;
1249 /* If the dying minibuffer window was selected,
1250 select the new one. */
1251 if (minibuffer_selected
)
1252 Fselect_window (minibuf_window
, Qnil
);
1255 /* Don't let echo_area_window to remain on a deleted frame. */
1256 if (EQ (f
->minibuffer_window
, echo_area_window
))
1257 echo_area_window
= sf
->minibuffer_window
;
1259 /* Clear any X selections for this frame. */
1260 #ifdef HAVE_X_WINDOWS
1262 x_clear_frame_selections (f
);
1266 This function must be called before the window tree of the
1267 frame is deleted because windows contain dynamically allocated
1271 /* Mark all the windows that used to be on FRAME as deleted, and then
1272 remove the reference to them. */
1273 delete_all_subwindows (XWINDOW (f
->root_window
));
1274 f
->root_window
= Qnil
;
1276 Vframe_list
= Fdelq (frame
, Vframe_list
);
1277 FRAME_SET_VISIBLE (f
, 0);
1281 if (FRAME_INSERT_COST (f
))
1282 xfree (FRAME_INSERT_COST (f
));
1283 if (FRAME_DELETEN_COST (f
))
1284 xfree (FRAME_DELETEN_COST (f
));
1285 if (FRAME_INSERTN_COST (f
))
1286 xfree (FRAME_INSERTN_COST (f
));
1287 if (FRAME_DELETE_COST (f
))
1288 xfree (FRAME_DELETE_COST (f
));
1289 if (FRAME_MESSAGE_BUF (f
))
1290 xfree (FRAME_MESSAGE_BUF (f
));
1292 /* Since some events are handled at the interrupt level, we may get
1293 an event for f at any time; if we zero out the frame's display
1294 now, then we may trip up the event-handling code. Instead, we'll
1295 promise that the display of the frame must be valid until we have
1296 called the window-system-dependent frame destruction routine. */
1298 /* I think this should be done with a hook. */
1299 #ifdef HAVE_WINDOW_SYSTEM
1300 if (FRAME_WINDOW_P (f
))
1301 x_destroy_window (f
);
1304 f
->output_data
.nothing
= 0;
1306 /* If we've deleted the last_nonminibuf_frame, then try to find
1308 if (f
== last_nonminibuf_frame
)
1312 last_nonminibuf_frame
= 0;
1314 for (frames
= Vframe_list
;
1316 frames
= XCDR (frames
))
1318 f
= XFRAME (XCAR (frames
));
1319 if (!FRAME_MINIBUF_ONLY_P (f
))
1321 last_nonminibuf_frame
= f
;
1327 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1328 find another one. Prefer minibuffer-only frames, but also notice
1329 frames with other windows. */
1330 if (EQ (frame
, FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
))
1334 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1335 Lisp_Object frame_with_minibuf
;
1336 /* Some frame we found on the same kboard, or nil if there are none. */
1337 Lisp_Object frame_on_same_kboard
;
1339 frame_on_same_kboard
= Qnil
;
1340 frame_with_minibuf
= Qnil
;
1342 for (frames
= Vframe_list
;
1344 frames
= XCDR (frames
))
1349 this = XCAR (frames
);
1354 /* Consider only frames on the same kboard
1355 and only those with minibuffers. */
1356 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
)
1357 && FRAME_HAS_MINIBUF_P (f1
))
1359 frame_with_minibuf
= this;
1360 if (FRAME_MINIBUF_ONLY_P (f1
))
1364 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1365 frame_on_same_kboard
= this;
1368 if (!NILP (frame_on_same_kboard
))
1370 /* We know that there must be some frame with a minibuffer out
1371 there. If this were not true, all of the frames present
1372 would have to be minibufferless, which implies that at some
1373 point their minibuffer frames must have been deleted, but
1374 that is prohibited at the top; you can't delete surrogate
1375 minibuffer frames. */
1376 if (NILP (frame_with_minibuf
))
1379 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1382 /* No frames left on this kboard--say no minibuffer either. */
1383 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= Qnil
;
1386 /* Cause frame titles to update--necessary if we now have just one frame. */
1387 update_mode_lines
= 1;
1392 /* Return mouse position in character cell units. */
1394 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1395 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1396 The position is given in character cells, where (0, 0) is the
1398 If Emacs is running on a mouseless terminal or hasn't been programmed
1399 to read the mouse position, it returns the selected frame for FRAME
1400 and nil for X and Y.
1401 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1402 passing the normal return value to that function as an argument,
1403 and returns whatever that function returns. */)
1407 Lisp_Object lispy_dummy
;
1408 enum scroll_bar_part party_dummy
;
1409 Lisp_Object x
, y
, retval
;
1411 unsigned long long_dummy
;
1412 struct gcpro gcpro1
;
1414 f
= SELECTED_FRAME ();
1418 /* It's okay for the hook to refrain from storing anything. */
1419 if (mouse_position_hook
)
1420 (*mouse_position_hook
) (&f
, -1,
1421 &lispy_dummy
, &party_dummy
,
1428 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1433 XSETFRAME (lispy_dummy
, f
);
1434 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1436 if (!NILP (Vmouse_position_function
))
1437 retval
= call1 (Vmouse_position_function
, retval
);
1438 RETURN_UNGCPRO (retval
);
1441 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1442 Smouse_pixel_position
, 0, 0, 0,
1443 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1444 The position is given in pixel units, where (0, 0) is the
1446 If Emacs is running on a mouseless terminal or hasn't been programmed
1447 to read the mouse position, it returns the selected frame for FRAME
1448 and nil for X and Y. */)
1452 Lisp_Object lispy_dummy
;
1453 enum scroll_bar_part party_dummy
;
1455 unsigned long long_dummy
;
1457 f
= SELECTED_FRAME ();
1461 /* It's okay for the hook to refrain from storing anything. */
1462 if (mouse_position_hook
)
1463 (*mouse_position_hook
) (&f
, -1,
1464 &lispy_dummy
, &party_dummy
,
1468 XSETFRAME (lispy_dummy
, f
);
1469 return Fcons (lispy_dummy
, Fcons (x
, y
));
1472 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1473 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1474 Coordinates are relative to the frame, not a window,
1475 so the coordinates of the top left character in the frame
1476 may be nonzero due to left-hand scroll bars or the menu bar.
1478 This function is a no-op for an X frame that is not visible.
1479 If you have just created a frame, you must wait for it to become visible
1480 before calling this function on it, like this.
1481 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1483 Lisp_Object frame
, x
, y
;
1485 CHECK_LIVE_FRAME (frame
);
1489 /* I think this should be done with a hook. */
1490 #ifdef HAVE_WINDOW_SYSTEM
1491 if (FRAME_WINDOW_P (XFRAME (frame
)))
1492 /* Warping the mouse will cause enternotify and focus events. */
1493 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1495 #if defined (MSDOS) && defined (HAVE_MOUSE)
1496 if (FRAME_MSDOS_P (XFRAME (frame
)))
1498 Fselect_frame (frame
, Qnil
);
1499 mouse_moveto (XINT (x
), XINT (y
));
1507 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1508 Sset_mouse_pixel_position
, 3, 3, 0,
1509 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1510 Note, this is a no-op for an X frame that is not visible.
1511 If you have just created a frame, you must wait for it to become visible
1512 before calling this function on it, like this.
1513 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1515 Lisp_Object frame
, x
, y
;
1517 CHECK_LIVE_FRAME (frame
);
1521 /* I think this should be done with a hook. */
1522 #ifdef HAVE_WINDOW_SYSTEM
1523 if (FRAME_WINDOW_P (XFRAME (frame
)))
1524 /* Warping the mouse will cause enternotify and focus events. */
1525 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1527 #if defined (MSDOS) && defined (HAVE_MOUSE)
1528 if (FRAME_MSDOS_P (XFRAME (frame
)))
1530 Fselect_frame (frame
, Qnil
);
1531 mouse_moveto (XINT (x
), XINT (y
));
1539 static void make_frame_visible_1
P_ ((Lisp_Object
));
1541 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1543 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1544 If omitted, FRAME defaults to the currently selected frame. */)
1549 frame
= selected_frame
;
1551 CHECK_LIVE_FRAME (frame
);
1553 /* I think this should be done with a hook. */
1554 #ifdef HAVE_WINDOW_SYSTEM
1555 if (FRAME_WINDOW_P (XFRAME (frame
)))
1557 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1558 x_make_frame_visible (XFRAME (frame
));
1562 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1564 /* Make menu bar update for the Buffers and Frames menus. */
1565 windows_or_buffers_changed
++;
1570 /* Update the display_time slot of the buffers shown in WINDOW
1571 and all its descendents. */
1574 make_frame_visible_1 (window
)
1579 for (;!NILP (window
); window
= w
->next
)
1581 w
= XWINDOW (window
);
1583 if (!NILP (w
->buffer
))
1584 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1586 if (!NILP (w
->vchild
))
1587 make_frame_visible_1 (w
->vchild
);
1588 if (!NILP (w
->hchild
))
1589 make_frame_visible_1 (w
->hchild
);
1593 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1595 doc
: /* Make the frame FRAME invisible (assuming it is an X window).
1596 If omitted, FRAME defaults to the currently selected frame.
1597 Normally you may not make FRAME invisible if all other frames are invisible,
1598 but if the second optional argument FORCE is non-nil, you may do so. */)
1600 Lisp_Object frame
, force
;
1603 frame
= selected_frame
;
1605 CHECK_LIVE_FRAME (frame
);
1607 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1608 error ("Attempt to make invisible the sole visible or iconified frame");
1610 #if 0 /* This isn't logically necessary, and it can do GC. */
1611 /* Don't let the frame remain selected. */
1612 if (EQ (frame
, selected_frame
))
1613 do_switch_frame (next_frame (frame
, Qt
), 0, 0)
1616 /* Don't allow minibuf_window to remain on a deleted frame. */
1617 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1619 struct frame
*sf
= XFRAME (selected_frame
);
1620 Fset_window_buffer (sf
->minibuffer_window
,
1621 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1622 minibuf_window
= sf
->minibuffer_window
;
1625 /* I think this should be done with a hook. */
1626 #ifdef HAVE_WINDOW_SYSTEM
1627 if (FRAME_WINDOW_P (XFRAME (frame
)))
1628 x_make_frame_invisible (XFRAME (frame
));
1631 /* Make menu bar update for the Buffers and Frames menus. */
1632 windows_or_buffers_changed
++;
1637 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1639 doc
: /* Make the frame FRAME into an icon.
1640 If omitted, FRAME defaults to the currently selected frame. */)
1645 frame
= selected_frame
;
1647 CHECK_LIVE_FRAME (frame
);
1649 #if 0 /* This isn't logically necessary, and it can do GC. */
1650 /* Don't let the frame remain selected. */
1651 if (EQ (frame
, selected_frame
))
1652 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1655 /* Don't allow minibuf_window to remain on a deleted frame. */
1656 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1658 struct frame
*sf
= XFRAME (selected_frame
);
1659 Fset_window_buffer (sf
->minibuffer_window
,
1660 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1661 minibuf_window
= sf
->minibuffer_window
;
1664 /* I think this should be done with a hook. */
1665 #ifdef HAVE_WINDOW_SYSTEM
1666 if (FRAME_WINDOW_P (XFRAME (frame
)))
1667 x_iconify_frame (XFRAME (frame
));
1670 /* Make menu bar update for the Buffers and Frames menus. */
1671 windows_or_buffers_changed
++;
1676 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1678 doc
: /* Return t if FRAME is now \"visible\" (actually in use for display).
1679 A frame that is not \"visible\" is not updated and, if it works through
1680 a window system, it may not show at all.
1681 Return the symbol `icon' if frame is visible only as an icon. */)
1685 CHECK_LIVE_FRAME (frame
);
1687 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1689 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1691 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1696 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1698 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1701 Lisp_Object tail
, frame
;
1706 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1708 frame
= XCAR (tail
);
1709 if (!FRAMEP (frame
))
1712 if (FRAME_VISIBLE_P (f
))
1713 value
= Fcons (frame
, value
);
1719 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1720 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1721 If FRAME is invisible, make it visible.
1722 If you don't specify a frame, the selected frame is used.
1723 If Emacs is displaying on an ordinary terminal or some other device which
1724 doesn't support multiple overlapping frames, this function does nothing. */)
1729 frame
= selected_frame
;
1731 CHECK_LIVE_FRAME (frame
);
1733 /* Do like the documentation says. */
1734 Fmake_frame_visible (frame
);
1736 if (frame_raise_lower_hook
)
1737 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1742 /* Should we have a corresponding function called Flower_Power? */
1743 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1744 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1745 If you don't specify a frame, the selected frame is used.
1746 If Emacs is displaying on an ordinary terminal or some other device which
1747 doesn't support multiple overlapping frames, this function does nothing. */)
1752 frame
= selected_frame
;
1754 CHECK_LIVE_FRAME (frame
);
1756 if (frame_raise_lower_hook
)
1757 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1763 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1765 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1766 In other words, switch-frame events caused by events in FRAME will
1767 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1768 FOCUS-FRAME after reading an event typed at FRAME.
1770 If FOCUS-FRAME is omitted or nil, any existing redirection is
1771 cancelled, and the frame again receives its own keystrokes.
1773 Focus redirection is useful for temporarily redirecting keystrokes to
1774 a surrogate minibuffer frame when a frame doesn't have its own
1777 A frame's focus redirection can be changed by select-frame. If frame
1778 FOO is selected, and then a different frame BAR is selected, any
1779 frames redirecting their focus to FOO are shifted to redirect their
1780 focus to BAR. This allows focus redirection to work properly when the
1781 user switches from one frame to another using `select-window'.
1783 This means that a frame whose focus is redirected to itself is treated
1784 differently from a frame whose focus is redirected to nil; the former
1785 is affected by select-frame, while the latter is not.
1787 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1788 (frame
, focus_frame
)
1789 Lisp_Object frame
, focus_frame
;
1791 /* Note that we don't check for a live frame here. It's reasonable
1792 to redirect the focus of a frame you're about to delete, if you
1793 know what other frame should receive those keystrokes. */
1794 CHECK_FRAME (frame
);
1796 if (! NILP (focus_frame
))
1797 CHECK_LIVE_FRAME (focus_frame
);
1799 XFRAME (frame
)->focus_frame
= focus_frame
;
1801 if (frame_rehighlight_hook
)
1802 (*frame_rehighlight_hook
) (XFRAME (frame
));
1808 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1809 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1810 This returns nil if FRAME's focus is not redirected.
1811 See `redirect-frame-focus'. */)
1815 CHECK_LIVE_FRAME (frame
);
1817 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1822 /* Return the value of frame parameter PROP in frame FRAME. */
1825 get_frame_param (frame
, prop
)
1826 register struct frame
*frame
;
1829 register Lisp_Object tem
;
1831 tem
= Fassq (prop
, frame
->param_alist
);
1837 /* Return the buffer-predicate of the selected frame. */
1840 frame_buffer_predicate (frame
)
1843 return XFRAME (frame
)->buffer_predicate
;
1846 /* Return the buffer-list of the selected frame. */
1849 frame_buffer_list (frame
)
1852 return XFRAME (frame
)->buffer_list
;
1855 /* Set the buffer-list of the selected frame. */
1858 set_frame_buffer_list (frame
, list
)
1859 Lisp_Object frame
, list
;
1861 XFRAME (frame
)->buffer_list
= list
;
1864 /* Discard BUFFER from the buffer-list of each frame. */
1867 frames_discard_buffer (buffer
)
1870 Lisp_Object frame
, tail
;
1872 FOR_EACH_FRAME (tail
, frame
)
1874 XFRAME (frame
)->buffer_list
1875 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1879 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1880 If the alist already has an element for PROP, we change it. */
1883 store_in_alist (alistptr
, prop
, val
)
1884 Lisp_Object
*alistptr
, val
;
1887 register Lisp_Object tem
;
1889 tem
= Fassq (prop
, *alistptr
);
1891 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1897 frame_name_fnn_p (str
, len
)
1901 if (len
> 1 && str
[0] == 'F')
1905 strtol (str
+ 1, &end_ptr
, 10);
1907 if (end_ptr
== str
+ len
)
1913 /* Set the name of the terminal frame. Also used by MSDOS frames.
1914 Modeled after x_set_name which is used for WINDOW frames. */
1917 set_term_frame_name (f
, name
)
1921 f
->explicit_name
= ! NILP (name
);
1923 /* If NAME is nil, set the name to F<num>. */
1928 /* Check for no change needed in this very common case
1929 before we do any consing. */
1930 if (frame_name_fnn_p (SDATA (f
->name
),
1934 terminal_frame_count
++;
1935 sprintf (namebuf
, "F%d", terminal_frame_count
);
1936 name
= build_string (namebuf
);
1940 CHECK_STRING (name
);
1942 /* Don't change the name if it's already NAME. */
1943 if (! NILP (Fstring_equal (name
, f
->name
)))
1946 /* Don't allow the user to set the frame name to F<num>, so it
1947 doesn't clash with the names we generate for terminal frames. */
1948 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
1949 error ("Frame names of the form F<num> are usurped by Emacs");
1953 update_mode_lines
= 1;
1957 store_frame_param (f
, prop
, val
)
1959 Lisp_Object prop
, val
;
1961 register Lisp_Object old_alist_elt
;
1963 /* The buffer-alist parameter is stored in a special place and is
1964 not in the alist. */
1965 if (EQ (prop
, Qbuffer_list
))
1967 f
->buffer_list
= val
;
1971 /* If PROP is a symbol which is supposed to have frame-local values,
1972 and it is set up based on this frame, switch to the global
1973 binding. That way, we can create or alter the frame-local binding
1974 without messing up the symbol's status. */
1977 Lisp_Object valcontents
;
1978 valcontents
= SYMBOL_VALUE (prop
);
1979 if ((BUFFER_LOCAL_VALUEP (valcontents
)
1980 || SOME_BUFFER_LOCAL_VALUEP (valcontents
))
1981 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
1982 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
1983 swap_in_global_binding (prop
);
1987 /* The tty color mode needs to be set before the frame's parameter
1988 alist is updated with the new value, because set_tty_color_mode
1989 wants to look at the old mode. */
1990 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
))
1991 set_tty_color_mode (f
, val
);
1994 /* Update the frame parameter alist. */
1995 old_alist_elt
= Fassq (prop
, f
->param_alist
);
1996 if (EQ (old_alist_elt
, Qnil
))
1997 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
1999 Fsetcdr (old_alist_elt
, val
);
2001 /* Update some other special parameters in their special places
2002 in addition to the alist. */
2004 if (EQ (prop
, Qbuffer_predicate
))
2005 f
->buffer_predicate
= val
;
2007 if (! FRAME_WINDOW_P (f
))
2009 if (EQ (prop
, Qmenu_bar_lines
))
2010 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2011 else if (EQ (prop
, Qname
))
2012 set_term_frame_name (f
, val
);
2015 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2017 if (! MINI_WINDOW_P (XWINDOW (val
)))
2018 error ("Surrogate minibuffer windows must be minibuffer windows.");
2020 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2021 && !EQ (val
, f
->minibuffer_window
))
2022 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2024 /* Install the chosen minibuffer window, with proper buffer. */
2025 f
->minibuffer_window
= val
;
2029 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2030 doc
: /* Return the parameters-alist of frame FRAME.
2031 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2032 The meaningful PARMs depend on the kind of frame.
2033 If FRAME is omitted, return information on the currently selected frame. */)
2040 struct gcpro gcpro1
;
2043 frame
= selected_frame
;
2045 CHECK_FRAME (frame
);
2048 if (!FRAME_LIVE_P (f
))
2051 alist
= Fcopy_alist (f
->param_alist
);
2054 if (!FRAME_WINDOW_P (f
))
2056 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2057 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2060 /* If the frame's parameter alist says the colors are
2061 unspecified and reversed, take the frame's background pixel
2062 for foreground and vice versa. */
2063 elt
= Fassq (Qforeground_color
, alist
);
2064 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2066 if (strncmp (SDATA (XCDR (elt
)),
2068 SCHARS (XCDR (elt
))) == 0)
2069 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2070 else if (strncmp (SDATA (XCDR (elt
)),
2072 SCHARS (XCDR (elt
))) == 0)
2073 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2076 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2077 elt
= Fassq (Qbackground_color
, alist
);
2078 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2080 if (strncmp (SDATA (XCDR (elt
)),
2082 SCHARS (XCDR (elt
))) == 0)
2083 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2084 else if (strncmp (SDATA (XCDR (elt
)),
2086 SCHARS (XCDR (elt
))) == 0)
2087 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2090 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2091 store_in_alist (&alist
, intern ("font"),
2092 build_string (FRAME_MSDOS_P (f
)
2094 : FRAME_W32_P (f
) ? "w32term"
2097 store_in_alist (&alist
, Qname
, f
->name
);
2098 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2099 store_in_alist (&alist
, Qheight
, make_number (height
));
2100 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2101 store_in_alist (&alist
, Qwidth
, make_number (width
));
2102 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2103 store_in_alist (&alist
, Qminibuffer
,
2104 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2105 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2106 : FRAME_MINIBUF_WINDOW (f
)));
2107 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2108 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2110 /* I think this should be done with a hook. */
2111 #ifdef HAVE_WINDOW_SYSTEM
2112 if (FRAME_WINDOW_P (f
))
2113 x_report_frame_params (f
, &alist
);
2117 /* This ought to be correct in f->param_alist for an X frame. */
2119 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2120 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2128 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2129 doc
: /* Return FRAME's value for parameter PARAMETER.
2130 If FRAME is nil, describe the currently selected frame. */)
2132 Lisp_Object frame
, parameter
;
2138 frame
= selected_frame
;
2140 CHECK_FRAME (frame
);
2141 CHECK_SYMBOL (parameter
);
2146 if (FRAME_LIVE_P (f
))
2148 /* Avoid consing in frequent cases. */
2149 if (EQ (parameter
, Qname
))
2151 #ifdef HAVE_X_WINDOWS
2152 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2153 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2154 #endif /* HAVE_X_WINDOWS */
2155 else if (EQ (parameter
, Qbackground_color
)
2156 || EQ (parameter
, Qforeground_color
))
2158 value
= Fassq (parameter
, f
->param_alist
);
2161 value
= XCDR (value
);
2162 /* Fframe_parameters puts the actual fg/bg color names,
2163 even if f->param_alist says otherwise. This is
2164 important when param_alist's notion of colors is
2165 "unspecified". We need to do the same here. */
2166 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2168 const char *color_name
;
2171 if (EQ (parameter
, Qbackground_color
))
2173 color_name
= SDATA (value
);
2174 csz
= SCHARS (value
);
2175 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2176 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2177 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2178 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2180 else if (EQ (parameter
, Qforeground_color
))
2182 color_name
= SDATA (value
);
2183 csz
= SCHARS (value
);
2184 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2185 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2186 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2187 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2192 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2194 else if (EQ (parameter
, Qdisplay_type
)
2195 || EQ (parameter
, Qbackground_mode
))
2196 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2198 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2205 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2206 Smodify_frame_parameters
, 2, 2, 0,
2207 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2208 If FRAME is nil, it defaults to the selected frame.
2209 ALIST is an alist of parameters to change and their new values.
2210 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2211 The meaningful PARMs depend on the kind of frame.
2212 Undefined PARMs are ignored, but stored in the frame's parameter list
2213 so that `frame-parameters' will return them.
2215 The value of frame parameter FOO can also be accessed
2216 as a frame-local binding for the variable FOO, if you have
2217 enabled such bindings for that variable with `make-variable-frame-local'. */)
2219 Lisp_Object frame
, alist
;
2222 register Lisp_Object tail
, prop
, val
;
2223 int count
= SPECPDL_INDEX ();
2225 /* Bind this to t to inhibit initialization of the default face from
2226 X resources in face-set-after-frame-default. If we don't inhibit
2227 this, modifying the `font' frame parameter, for example, while
2228 there is a `default.attributeFont' X resource, won't work,
2229 because `default's font is reset to the value of the X resource
2230 and that resets the `font' frame parameter. */
2231 specbind (Qinhibit_default_face_x_resources
, Qt
);
2233 if (EQ (frame
, Qnil
))
2234 frame
= selected_frame
;
2235 CHECK_LIVE_FRAME (frame
);
2238 /* I think this should be done with a hook. */
2239 #ifdef HAVE_WINDOW_SYSTEM
2240 if (FRAME_WINDOW_P (f
))
2241 x_set_frame_parameters (f
, alist
);
2245 if (FRAME_MSDOS_P (f
))
2246 IT_set_frame_parameters (f
, alist
);
2251 int length
= XINT (Flength (alist
));
2254 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2256 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2258 /* Extract parm names and values into those vectors. */
2261 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2266 parms
[i
] = Fcar (elt
);
2267 values
[i
] = Fcdr (elt
);
2271 /* Now process them in reverse of specified order. */
2272 for (i
--; i
>= 0; i
--)
2276 store_frame_param (f
, prop
, val
);
2280 return unbind_to (count
, Qnil
);
2283 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2285 doc
: /* Height in pixels of a line in the font in frame FRAME.
2286 If FRAME is omitted, the selected frame is used.
2287 For a terminal frame, the value is always 1. */)
2294 frame
= selected_frame
;
2295 CHECK_FRAME (frame
);
2298 #ifdef HAVE_WINDOW_SYSTEM
2299 if (FRAME_WINDOW_P (f
))
2300 return make_number (x_char_height (f
));
2303 return make_number (1);
2307 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2309 doc
: /* Width in pixels of characters in the font in frame FRAME.
2310 If FRAME is omitted, the selected frame is used.
2311 The width is the same for all characters, because
2312 currently Emacs supports only fixed-width fonts.
2313 For a terminal screen, the value is always 1. */)
2320 frame
= selected_frame
;
2321 CHECK_FRAME (frame
);
2324 #ifdef HAVE_WINDOW_SYSTEM
2325 if (FRAME_WINDOW_P (f
))
2326 return make_number (x_char_width (f
));
2329 return make_number (1);
2332 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2333 Sframe_pixel_height
, 0, 1, 0,
2334 doc
: /* Return a FRAME's height in pixels.
2335 This counts only the height available for text lines,
2336 not menu bars on window-system Emacs frames.
2337 For a terminal frame, the result really gives the height in characters.
2338 If FRAME is omitted, the selected frame is used. */)
2345 frame
= selected_frame
;
2346 CHECK_FRAME (frame
);
2349 #ifdef HAVE_WINDOW_SYSTEM
2350 if (FRAME_WINDOW_P (f
))
2351 return make_number (x_pixel_height (f
));
2354 return make_number (FRAME_LINES (f
));
2357 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2358 Sframe_pixel_width
, 0, 1, 0,
2359 doc
: /* Return FRAME's width in pixels.
2360 For a terminal frame, the result really gives the width in characters.
2361 If FRAME is omitted, the selected frame is used. */)
2368 frame
= selected_frame
;
2369 CHECK_FRAME (frame
);
2372 #ifdef HAVE_WINDOW_SYSTEM
2373 if (FRAME_WINDOW_P (f
))
2374 return make_number (x_pixel_width (f
));
2377 return make_number (FRAME_COLS (f
));
2380 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2381 doc
: /* Specify that the frame FRAME has LINES lines.
2382 Optional third arg non-nil means that redisplay should use LINES lines
2383 but that the idea of the actual height of the frame should not be changed. */)
2384 (frame
, lines
, pretend
)
2385 Lisp_Object frame
, lines
, pretend
;
2387 register struct frame
*f
;
2389 CHECK_NUMBER (lines
);
2391 frame
= selected_frame
;
2392 CHECK_LIVE_FRAME (frame
);
2395 /* I think this should be done with a hook. */
2396 #ifdef HAVE_WINDOW_SYSTEM
2397 if (FRAME_WINDOW_P (f
))
2399 if (XINT (lines
) != FRAME_LINES (f
))
2400 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2401 do_pending_window_change (0);
2405 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2409 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2410 doc
: /* Specify that the frame FRAME has COLS columns.
2411 Optional third arg non-nil means that redisplay should use COLS columns
2412 but that the idea of the actual width of the frame should not be changed. */)
2413 (frame
, cols
, pretend
)
2414 Lisp_Object frame
, cols
, pretend
;
2416 register struct frame
*f
;
2417 CHECK_NUMBER (cols
);
2419 frame
= selected_frame
;
2420 CHECK_LIVE_FRAME (frame
);
2423 /* I think this should be done with a hook. */
2424 #ifdef HAVE_WINDOW_SYSTEM
2425 if (FRAME_WINDOW_P (f
))
2427 if (XINT (cols
) != FRAME_COLS (f
))
2428 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2429 do_pending_window_change (0);
2433 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2437 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2438 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2440 Lisp_Object frame
, cols
, rows
;
2442 register struct frame
*f
;
2444 CHECK_LIVE_FRAME (frame
);
2445 CHECK_NUMBER (cols
);
2446 CHECK_NUMBER (rows
);
2449 /* I think this should be done with a hook. */
2450 #ifdef HAVE_WINDOW_SYSTEM
2451 if (FRAME_WINDOW_P (f
))
2453 if (XINT (rows
) != FRAME_LINES (f
)
2454 || XINT (cols
) != FRAME_COLS (f
)
2455 || f
->new_text_lines
|| f
->new_text_cols
)
2456 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2457 do_pending_window_change (0);
2461 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2466 DEFUN ("set-frame-position", Fset_frame_position
,
2467 Sset_frame_position
, 3, 3, 0,
2468 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2469 This is actually the position of the upper left corner of the frame.
2470 Negative values for XOFFSET or YOFFSET are interpreted relative to
2471 the rightmost or bottommost possible position (that stays within the screen). */)
2472 (frame
, xoffset
, yoffset
)
2473 Lisp_Object frame
, xoffset
, yoffset
;
2475 register struct frame
*f
;
2477 CHECK_LIVE_FRAME (frame
);
2478 CHECK_NUMBER (xoffset
);
2479 CHECK_NUMBER (yoffset
);
2482 /* I think this should be done with a hook. */
2483 #ifdef HAVE_WINDOW_SYSTEM
2484 if (FRAME_WINDOW_P (f
))
2485 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2492 /***********************************************************************
2494 ***********************************************************************/
2496 /* Connect the frame-parameter names for X frames
2497 to the ways of passing the parameter values to the window system.
2499 The name of a parameter, as a Lisp symbol,
2500 has an `x-frame-parameter' property which is an integer in Lisp
2501 that is an index in this table. */
2503 struct frame_parm_table
{
2505 Lisp_Object
*variable
;
2508 static struct frame_parm_table frame_parms
[] =
2510 {"auto-raise", &Qauto_raise
},
2511 {"auto-lower", &Qauto_lower
},
2512 {"background-color", 0},
2513 {"border-color", &Qborder_color
},
2514 {"border-width", &Qborder_width
},
2515 {"cursor-color", &Qcursor_color
},
2516 {"cursor-type", &Qcursor_type
},
2518 {"foreground-color", 0},
2519 {"icon-name", &Qicon_name
},
2520 {"icon-type", &Qicon_type
},
2521 {"internal-border-width", &Qinternal_border_width
},
2522 {"menu-bar-lines", &Qmenu_bar_lines
},
2523 {"mouse-color", &Qmouse_color
},
2525 {"scroll-bar-width", &Qscroll_bar_width
},
2527 {"unsplittable", &Qunsplittable
},
2528 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2529 {"visibility", &Qvisibility
},
2530 {"tool-bar-lines", &Qtool_bar_lines
},
2531 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2532 {"scroll-bar-background", &Qscroll_bar_background
},
2533 {"screen-gamma", &Qscreen_gamma
},
2534 {"line-spacing", &Qline_spacing
},
2535 {"left-fringe", &Qleft_fringe
},
2536 {"right-fringe", &Qright_fringe
},
2537 {"wait-for-wm", &Qwait_for_wm
},
2538 {"fullscreen", &Qfullscreen
},
2541 #ifdef HAVE_WINDOW_SYSTEM
2543 extern Lisp_Object Qbox
;
2544 extern Lisp_Object Qtop
;
2546 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2547 wanted positions of the WM window (not emacs window).
2548 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2549 window (FRAME_X_WINDOW).
2553 x_fullscreen_adjust (f
, width
, height
, top_pos
, left_pos
)
2560 int newwidth
= FRAME_COLS (f
);
2561 int newheight
= FRAME_LINES (f
);
2563 *top_pos
= f
->top_pos
;
2564 *left_pos
= f
->left_pos
;
2566 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2570 ph
= FRAME_X_DISPLAY_INFO (f
)->height
;
2571 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2572 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2573 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2577 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2581 pw
= FRAME_X_DISPLAY_INFO (f
)->width
;
2582 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2583 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2584 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2589 *height
= newheight
;
2593 /* Really try to move where we want to be in case of fullscreen. Some WMs
2594 moves the window where we tell them. Some (mwm, twm) moves the outer
2595 window manager window there instead.
2596 Try to compensate for those WM here. */
2599 x_fullscreen_move (f
, new_top
, new_left
)
2604 if (new_top
!= f
->top_pos
|| new_left
!= f
->left_pos
)
2606 int move_x
= new_left
;
2607 int move_y
= new_top
;
2609 #ifdef HAVE_X_WINDOWS
2610 move_x
+= FRAME_X_OUTPUT (f
)->x_pixels_outer_diff
;
2611 move_y
+= FRAME_X_OUTPUT (f
)->y_pixels_outer_diff
;
2614 f
->want_fullscreen
|= FULLSCREEN_MOVE_WAIT
;
2615 x_set_offset (f
, move_x
, move_y
, 1);
2619 /* Change the parameters of frame F as specified by ALIST.
2620 If a parameter is not specially recognized, do nothing special;
2621 otherwise call the `x_set_...' function for that parameter.
2622 Except for certain geometry properties, always call store_frame_param
2623 to store the new value in the parameter alist. */
2626 x_set_frame_parameters (f
, alist
)
2632 /* If both of these parameters are present, it's more efficient to
2633 set them both at once. So we wait until we've looked at the
2634 entire list before we set them. */
2638 Lisp_Object left
, top
;
2640 /* Same with these. */
2641 Lisp_Object icon_left
, icon_top
;
2643 /* Record in these vectors all the parms specified. */
2645 Lisp_Object
*values
;
2647 int left_no_change
= 0, top_no_change
= 0;
2648 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2649 int fullscreen_is_being_set
= 0;
2651 struct gcpro gcpro1
, gcpro2
;
2654 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2657 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2658 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2660 /* Extract parm names and values into those vectors. */
2663 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2668 parms
[i
] = Fcar (elt
);
2669 values
[i
] = Fcdr (elt
);
2672 /* TAIL and ALIST are not used again below here. */
2673 alist
= tail
= Qnil
;
2675 GCPRO2 (*parms
, *values
);
2679 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2680 because their values appear in VALUES and strings are not valid. */
2681 top
= left
= Qunbound
;
2682 icon_left
= icon_top
= Qunbound
;
2684 /* Provide default values for HEIGHT and WIDTH. */
2685 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2686 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2688 /* Process foreground_color and background_color before anything else.
2689 They are independent of other properties, but other properties (e.g.,
2690 cursor_color) are dependent upon them. */
2691 /* Process default font as well, since fringe widths depends on it. */
2692 /* Also, process fullscreen, width and height depend upon that */
2693 for (p
= 0; p
< i
; p
++)
2695 Lisp_Object prop
, val
;
2699 if (EQ (prop
, Qforeground_color
)
2700 || EQ (prop
, Qbackground_color
)
2702 || EQ (prop
, Qfullscreen
))
2704 register Lisp_Object param_index
, old_value
;
2706 old_value
= get_frame_param (f
, prop
);
2707 fullscreen_is_being_set
|= EQ (prop
, Qfullscreen
);
2709 if (NILP (Fequal (val
, old_value
)))
2711 store_frame_param (f
, prop
, val
);
2713 param_index
= Fget (prop
, Qx_frame_parameter
);
2714 if (NATNUMP (param_index
)
2715 && (XFASTINT (param_index
)
2716 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2717 && rif
->frame_parm_handlers
[XINT (param_index
)])
2718 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2723 /* Now process them in reverse of specified order. */
2724 for (i
--; i
>= 0; i
--)
2726 Lisp_Object prop
, val
;
2731 if (EQ (prop
, Qwidth
) && NUMBERP (val
))
2732 width
= XFASTINT (val
);
2733 else if (EQ (prop
, Qheight
) && NUMBERP (val
))
2734 height
= XFASTINT (val
);
2735 else if (EQ (prop
, Qtop
))
2737 else if (EQ (prop
, Qleft
))
2739 else if (EQ (prop
, Qicon_top
))
2741 else if (EQ (prop
, Qicon_left
))
2743 else if (EQ (prop
, Qforeground_color
)
2744 || EQ (prop
, Qbackground_color
)
2746 || EQ (prop
, Qfullscreen
))
2747 /* Processed above. */
2751 register Lisp_Object param_index
, old_value
;
2753 old_value
= get_frame_param (f
, prop
);
2755 store_frame_param (f
, prop
, val
);
2757 param_index
= Fget (prop
, Qx_frame_parameter
);
2758 if (NATNUMP (param_index
)
2759 && (XFASTINT (param_index
)
2760 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2761 && rif
->frame_parm_handlers
[XINT (param_index
)])
2762 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2766 /* Don't die if just one of these was set. */
2767 if (EQ (left
, Qunbound
))
2770 if (f
->left_pos
< 0)
2771 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2773 XSETINT (left
, f
->left_pos
);
2775 if (EQ (top
, Qunbound
))
2779 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2781 XSETINT (top
, f
->top_pos
);
2784 /* If one of the icon positions was not set, preserve or default it. */
2785 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
2787 icon_left_no_change
= 1;
2788 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2789 if (NILP (icon_left
))
2790 XSETINT (icon_left
, 0);
2792 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
2794 icon_top_no_change
= 1;
2795 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2796 if (NILP (icon_top
))
2797 XSETINT (icon_top
, 0);
2801 /* MAC_TODO: fullscreen */
2802 if (FRAME_VISIBLE_P (f
) && fullscreen_is_being_set
)
2804 /* If the frame is visible already and the fullscreen parameter is
2805 being set, it is too late to set WM manager hints to specify
2807 Here we first get the width, height and position that applies to
2808 fullscreen. We then move the frame to the appropriate
2809 position. Resize of the frame is taken care of in the code after
2810 this if-statement. */
2811 int new_left
, new_top
;
2813 x_fullscreen_adjust (f
, &width
, &height
, &new_top
, &new_left
);
2814 x_fullscreen_move (f
, new_top
, new_left
);
2818 /* Don't set these parameters unless they've been explicitly
2819 specified. The window might be mapped or resized while we're in
2820 this function, and we don't want to override that unless the lisp
2821 code has asked for it.
2823 Don't set these parameters unless they actually differ from the
2824 window's current parameters; the window may not actually exist
2829 check_frame_size (f
, &height
, &width
);
2831 XSETFRAME (frame
, f
);
2833 if (width
!= FRAME_COLS (f
)
2834 || height
!= FRAME_LINES (f
)
2835 || f
->new_text_lines
|| f
->new_text_cols
)
2836 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2838 if ((!NILP (left
) || !NILP (top
))
2839 && ! (left_no_change
&& top_no_change
)
2840 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2841 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2846 /* Record the signs. */
2847 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2848 if (EQ (left
, Qminus
))
2849 f
->size_hint_flags
|= XNegative
;
2850 else if (INTEGERP (left
))
2852 leftpos
= XINT (left
);
2854 f
->size_hint_flags
|= XNegative
;
2856 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2857 && CONSP (XCDR (left
))
2858 && INTEGERP (XCAR (XCDR (left
))))
2860 leftpos
= - XINT (XCAR (XCDR (left
)));
2861 f
->size_hint_flags
|= XNegative
;
2863 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2864 && CONSP (XCDR (left
))
2865 && INTEGERP (XCAR (XCDR (left
))))
2867 leftpos
= XINT (XCAR (XCDR (left
)));
2870 if (EQ (top
, Qminus
))
2871 f
->size_hint_flags
|= YNegative
;
2872 else if (INTEGERP (top
))
2874 toppos
= XINT (top
);
2876 f
->size_hint_flags
|= YNegative
;
2878 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2879 && CONSP (XCDR (top
))
2880 && INTEGERP (XCAR (XCDR (top
))))
2882 toppos
= - XINT (XCAR (XCDR (top
)));
2883 f
->size_hint_flags
|= YNegative
;
2885 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2886 && CONSP (XCDR (top
))
2887 && INTEGERP (XCAR (XCDR (top
))))
2889 toppos
= XINT (XCAR (XCDR (top
)));
2893 /* Store the numeric value of the position. */
2894 f
->top_pos
= toppos
;
2895 f
->left_pos
= leftpos
;
2897 f
->win_gravity
= NorthWestGravity
;
2899 /* Actually set that position, and convert to absolute. */
2900 x_set_offset (f
, leftpos
, toppos
, -1);
2903 if ((!NILP (icon_left
) || !NILP (icon_top
))
2904 && ! (icon_left_no_change
&& icon_top_no_change
))
2905 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2912 /* Insert a description of internally-recorded parameters of frame X
2913 into the parameter alist *ALISTPTR that is to be given to the user.
2914 Only parameters that are specific to the X window system
2915 and whose values are not correctly recorded in the frame's
2916 param_alist need to be considered here. */
2919 x_report_frame_params (f
, alistptr
)
2921 Lisp_Object
*alistptr
;
2926 /* Represent negative positions (off the top or left screen edge)
2927 in a way that Fmodify_frame_parameters will understand correctly. */
2928 XSETINT (tem
, f
->left_pos
);
2929 if (f
->left_pos
>= 0)
2930 store_in_alist (alistptr
, Qleft
, tem
);
2932 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2934 XSETINT (tem
, f
->top_pos
);
2935 if (f
->top_pos
>= 0)
2936 store_in_alist (alistptr
, Qtop
, tem
);
2938 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2940 store_in_alist (alistptr
, Qborder_width
,
2941 make_number (f
->border_width
));
2942 store_in_alist (alistptr
, Qinternal_border_width
,
2943 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
2944 store_in_alist (alistptr
, Qleft_fringe
,
2945 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
2946 store_in_alist (alistptr
, Qright_fringe
,
2947 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
2948 store_in_alist (alistptr
, Qscroll_bar_width
,
2949 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2951 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
2952 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
2953 /* nil means "use default width"
2954 for non-toolkit scroll bar.
2955 ruler-mode.el depends on this. */
2957 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
2958 store_in_alist (alistptr
, Qwindow_id
,
2959 build_string (buf
));
2960 #ifdef HAVE_X_WINDOWS
2961 #ifdef USE_X_TOOLKIT
2962 /* Tooltip frame may not have this widget. */
2963 if (FRAME_X_OUTPUT (f
)->widget
)
2965 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
2966 store_in_alist (alistptr
, Qouter_window_id
,
2967 build_string (buf
));
2969 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
2970 FRAME_SAMPLE_VISIBILITY (f
);
2971 store_in_alist (alistptr
, Qvisibility
,
2972 (FRAME_VISIBLE_P (f
) ? Qt
2973 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
2974 store_in_alist (alistptr
, Qdisplay
,
2975 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
2978 /* A Mac Window is identified by a struct, not an integer. */
2979 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
2982 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
2983 store_in_alist (alistptr
, Qparent_id
, tem
);
2988 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
2989 the previous value of that parameter, NEW_VALUE is the new value. */
2992 x_set_fullscreen (f
, new_value
, old_value
)
2994 Lisp_Object new_value
, old_value
;
2997 if (NILP (new_value
))
2998 f
->want_fullscreen
= FULLSCREEN_NONE
;
2999 else if (EQ (new_value
, Qfullboth
))
3000 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3001 else if (EQ (new_value
, Qfullwidth
))
3002 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3003 else if (EQ (new_value
, Qfullheight
))
3004 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3009 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3010 the previous value of that parameter, NEW_VALUE is the new value. */
3013 x_set_line_spacing (f
, new_value
, old_value
)
3015 Lisp_Object new_value
, old_value
;
3017 if (NILP (new_value
))
3018 f
->extra_line_spacing
= 0;
3019 else if (NATNUMP (new_value
))
3020 f
->extra_line_spacing
= XFASTINT (new_value
);
3022 Fsignal (Qerror
, Fcons (build_string ("Invalid line-spacing"),
3023 Fcons (new_value
, Qnil
)));
3024 if (FRAME_VISIBLE_P (f
))
3029 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3030 the previous value of that parameter, NEW_VALUE is the new value. */
3033 x_set_screen_gamma (f
, new_value
, old_value
)
3035 Lisp_Object new_value
, old_value
;
3037 if (NILP (new_value
))
3039 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3040 /* The value 0.4545 is the normal viewing gamma. */
3041 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3043 Fsignal (Qerror
, Fcons (build_string ("Invalid screen-gamma"),
3044 Fcons (new_value
, Qnil
)));
3046 clear_face_cache (0);
3051 x_set_font (f
, arg
, oldval
)
3053 Lisp_Object arg
, oldval
;
3056 Lisp_Object fontset_name
;
3058 int old_fontset
= FRAME_FONTSET(f
);
3062 fontset_name
= Fquery_fontset (arg
, Qnil
);
3065 result
= (STRINGP (fontset_name
)
3066 ? x_new_fontset (f
, SDATA (fontset_name
))
3067 : x_new_font (f
, SDATA (arg
)));
3070 if (EQ (result
, Qnil
))
3071 error ("Font `%s' is not defined", SDATA (arg
));
3072 else if (EQ (result
, Qt
))
3073 error ("The characters of the given font have varying widths");
3074 else if (STRINGP (result
))
3076 if (STRINGP (fontset_name
))
3078 /* Fontset names are built from ASCII font names, so the
3079 names may be equal despite there was a change. */
3080 if (old_fontset
== FRAME_FONTSET (f
))
3083 else if (!NILP (Fequal (result
, oldval
)))
3086 store_frame_param (f
, Qfont
, result
);
3087 recompute_basic_faces (f
);
3092 do_pending_window_change (0);
3094 /* Don't call `face-set-after-frame-default' when faces haven't been
3095 initialized yet. This is the case when called from
3096 Fx_create_frame. In that case, the X widget or window doesn't
3097 exist either, and we can end up in x_report_frame_params with a
3098 null widget which gives a segfault. */
3099 if (FRAME_FACE_CACHE (f
))
3101 XSETFRAME (frame
, f
);
3102 call1 (Qface_set_after_frame_default
, frame
);
3108 x_set_fringe_width (f
, new_value
, old_value
)
3110 Lisp_Object new_value
, old_value
;
3112 compute_fringe_widths (f
, 1);
3116 x_set_border_width (f
, arg
, oldval
)
3118 Lisp_Object arg
, oldval
;
3122 if (XINT (arg
) == f
->border_width
)
3126 if (FRAME_X_WINDOW (f
) != 0)
3127 error ("Cannot change the border width of a window");
3128 #endif /* MAC_TODO */
3130 f
->border_width
= XINT (arg
);
3134 x_set_internal_border_width (f
, arg
, oldval
)
3136 Lisp_Object arg
, oldval
;
3138 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3141 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3142 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3143 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3145 #ifdef USE_X_TOOLKIT
3146 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3147 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3150 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3153 if (FRAME_X_WINDOW (f
) != 0)
3155 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3156 SET_FRAME_GARBAGED (f
);
3157 do_pending_window_change (0);
3160 SET_FRAME_GARBAGED (f
);
3164 x_set_visibility (f
, value
, oldval
)
3166 Lisp_Object value
, oldval
;
3169 XSETFRAME (frame
, f
);
3172 Fmake_frame_invisible (frame
, Qt
);
3173 else if (EQ (value
, Qicon
))
3174 Ficonify_frame (frame
);
3176 Fmake_frame_visible (frame
);
3180 x_set_autoraise (f
, arg
, oldval
)
3182 Lisp_Object arg
, oldval
;
3184 f
->auto_raise
= !EQ (Qnil
, arg
);
3188 x_set_autolower (f
, arg
, oldval
)
3190 Lisp_Object arg
, oldval
;
3192 f
->auto_lower
= !EQ (Qnil
, arg
);
3196 x_set_unsplittable (f
, arg
, oldval
)
3198 Lisp_Object arg
, oldval
;
3200 f
->no_split
= !NILP (arg
);
3204 x_set_vertical_scroll_bars (f
, arg
, oldval
)
3206 Lisp_Object arg
, oldval
;
3208 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3209 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3210 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3211 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3213 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3215 ? vertical_scroll_bar_none
3217 ? vertical_scroll_bar_left
3219 ? vertical_scroll_bar_right
3221 /* MS-Windows has scroll bars on the right by default. */
3222 : vertical_scroll_bar_right
3224 : vertical_scroll_bar_left
3228 /* We set this parameter before creating the X window for the
3229 frame, so we can get the geometry right from the start.
3230 However, if the window hasn't been created yet, we shouldn't
3231 call x_set_window_size. */
3232 if (FRAME_X_WINDOW (f
))
3233 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3234 do_pending_window_change (0);
3239 x_set_scroll_bar_width (f
, arg
, oldval
)
3241 Lisp_Object arg
, oldval
;
3243 int wid
= FRAME_COLUMN_WIDTH (f
);
3247 x_set_scroll_bar_default_width (f
);
3249 if (FRAME_X_WINDOW (f
))
3250 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3251 do_pending_window_change (0);
3253 else if (INTEGERP (arg
) && XINT (arg
) > 0
3254 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3256 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3257 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3259 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3260 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3261 if (FRAME_X_WINDOW (f
))
3262 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3263 do_pending_window_change (0);
3266 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3267 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3268 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3273 /* Return non-nil if frame F wants a bitmap icon. */
3281 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3289 /* Subroutines of creating an X frame. */
3291 /* Make sure that Vx_resource_name is set to a reasonable value.
3292 Fix it up, or set it to `emacs' if it is too hopeless. */
3295 validate_x_resource_name ()
3298 /* Number of valid characters in the resource name. */
3300 /* Number of invalid characters in the resource name. */
3305 if (!STRINGP (Vx_resource_class
))
3306 Vx_resource_class
= build_string (EMACS_CLASS
);
3308 if (STRINGP (Vx_resource_name
))
3310 unsigned char *p
= SDATA (Vx_resource_name
);
3313 len
= SBYTES (Vx_resource_name
);
3315 /* Only letters, digits, - and _ are valid in resource names.
3316 Count the valid characters and count the invalid ones. */
3317 for (i
= 0; i
< len
; i
++)
3320 if (! ((c
>= 'a' && c
<= 'z')
3321 || (c
>= 'A' && c
<= 'Z')
3322 || (c
>= '0' && c
<= '9')
3323 || c
== '-' || c
== '_'))
3330 /* Not a string => completely invalid. */
3331 bad_count
= 5, good_count
= 0;
3333 /* If name is valid already, return. */
3337 /* If name is entirely invalid, or nearly so, use `emacs'. */
3339 || (good_count
== 1 && bad_count
> 0))
3341 Vx_resource_name
= build_string ("emacs");
3345 /* Name is partly valid. Copy it and replace the invalid characters
3346 with underscores. */
3348 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3350 for (i
= 0; i
< len
; i
++)
3352 int c
= SREF (new, i
);
3353 if (! ((c
>= 'a' && c
<= 'z')
3354 || (c
>= 'A' && c
<= 'Z')
3355 || (c
>= '0' && c
<= '9')
3356 || c
== '-' || c
== '_'))
3362 extern char *x_get_string_resource
P_ ((XrmDatabase
, char *, char *));
3363 extern Display_Info
*check_x_display_info
P_ ((Lisp_Object
));
3366 /* Get specified attribute from resource database RDB.
3367 See Fx_get_resource below for other parameters. */
3370 xrdb_get_resource (rdb
, attribute
, class, component
, subclass
)
3372 Lisp_Object attribute
, class, component
, subclass
;
3374 register char *value
;
3378 CHECK_STRING (attribute
);
3379 CHECK_STRING (class);
3381 if (!NILP (component
))
3382 CHECK_STRING (component
);
3383 if (!NILP (subclass
))
3384 CHECK_STRING (subclass
);
3385 if (NILP (component
) != NILP (subclass
))
3386 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3388 validate_x_resource_name ();
3390 /* Allocate space for the components, the dots which separate them,
3391 and the final '\0'. Make them big enough for the worst case. */
3392 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3393 + (STRINGP (component
)
3394 ? SBYTES (component
) : 0)
3395 + SBYTES (attribute
)
3398 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3400 + (STRINGP (subclass
)
3401 ? SBYTES (subclass
) : 0)
3404 /* Start with emacs.FRAMENAME for the name (the specific one)
3405 and with `Emacs' for the class key (the general one). */
3406 strcpy (name_key
, SDATA (Vx_resource_name
));
3407 strcpy (class_key
, SDATA (Vx_resource_class
));
3409 strcat (class_key
, ".");
3410 strcat (class_key
, SDATA (class));
3412 if (!NILP (component
))
3414 strcat (class_key
, ".");
3415 strcat (class_key
, SDATA (subclass
));
3417 strcat (name_key
, ".");
3418 strcat (name_key
, SDATA (component
));
3421 strcat (name_key
, ".");
3422 strcat (name_key
, SDATA (attribute
));
3424 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3426 if (value
!= (char *) 0)
3427 return build_string (value
);
3433 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3434 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3435 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3436 class, where INSTANCE is the name under which Emacs was invoked, or
3437 the name specified by the `-name' or `-rn' command-line arguments.
3439 The optional arguments COMPONENT and SUBCLASS add to the key and the
3440 class, respectively. You must specify both of them or neither.
3441 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3442 and the class is `Emacs.CLASS.SUBCLASS'. */)
3443 (attribute
, class, component
, subclass
)
3444 Lisp_Object attribute
, class, component
, subclass
;
3446 #ifdef HAVE_X_WINDOWS
3450 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3451 attribute
, class, component
, subclass
);
3454 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3457 display_x_get_resource (dpyinfo
, attribute
, class, component
, subclass
)
3458 Display_Info
*dpyinfo
;
3459 Lisp_Object attribute
, class, component
, subclass
;
3461 return xrdb_get_resource (dpyinfo
->xrdb
,
3462 attribute
, class, component
, subclass
);
3465 /* Used when C code wants a resource value. */
3468 x_get_resource_string (attribute
, class)
3469 char *attribute
, *class;
3473 struct frame
*sf
= SELECTED_FRAME ();
3475 /* Allocate space for the components, the dots which separate them,
3476 and the final '\0'. */
3477 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3478 + strlen (attribute
) + 2);
3479 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3480 + strlen (class) + 2);
3482 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3483 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3485 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3486 name_key
, class_key
);
3490 /* Return the value of parameter PARAM.
3492 First search ALIST, then Vdefault_frame_alist, then the X defaults
3493 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3495 Convert the resource to the type specified by desired_type.
3497 If no default is specified, return Qunbound. If you call
3498 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3499 and don't let it get stored in any Lisp-visible variables! */
3502 x_get_arg (dpyinfo
, alist
, param
, attribute
, class, type
)
3503 Display_Info
*dpyinfo
;
3504 Lisp_Object alist
, param
;
3507 enum resource_types type
;
3509 register Lisp_Object tem
;
3511 tem
= Fassq (param
, alist
);
3513 tem
= Fassq (param
, Vdefault_frame_alist
);
3518 tem
= display_x_get_resource (dpyinfo
,
3519 build_string (attribute
),
3520 build_string (class),
3528 case RES_TYPE_NUMBER
:
3529 return make_number (atoi (SDATA (tem
)));
3531 case RES_TYPE_FLOAT
:
3532 return make_float (atof (SDATA (tem
)));
3534 case RES_TYPE_BOOLEAN
:
3535 tem
= Fdowncase (tem
);
3536 if (!strcmp (SDATA (tem
), "on")
3537 || !strcmp (SDATA (tem
), "true"))
3542 case RES_TYPE_STRING
:
3545 case RES_TYPE_SYMBOL
:
3546 /* As a special case, we map the values `true' and `on'
3547 to Qt, and `false' and `off' to Qnil. */
3550 lower
= Fdowncase (tem
);
3551 if (!strcmp (SDATA (lower
), "on")
3552 || !strcmp (SDATA (lower
), "true"))
3554 else if (!strcmp (SDATA (lower
), "off")
3555 || !strcmp (SDATA (lower
), "false"))
3558 return Fintern (tem
, Qnil
);
3572 x_frame_get_arg (f
, alist
, param
, attribute
, class, type
)
3574 Lisp_Object alist
, param
;
3577 enum resource_types type
;
3579 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3580 alist
, param
, attribute
, class, type
);
3583 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3586 x_frame_get_and_record_arg (f
, alist
, param
, attribute
, class, type
)
3588 Lisp_Object alist
, param
;
3591 enum resource_types type
;
3595 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3596 attribute
, class, type
);
3598 store_frame_param (f
, param
, value
);
3604 /* Record in frame F the specified or default value according to ALIST
3605 of the parameter named PROP (a Lisp symbol).
3606 If no value is specified for PROP, look for an X default for XPROP
3607 on the frame named NAME.
3608 If that is not found either, use the value DEFLT. */
3611 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
3618 enum resource_types type
;
3622 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3623 if (EQ (tem
, Qunbound
))
3625 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3632 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3633 doc
: /* Parse an X-style geometry string STRING.
3634 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3635 The properties returned may include `top', `left', `height', and `width'.
3636 The value of `left' or `top' may be an integer,
3637 or a list (+ N) meaning N pixels relative to top/left corner,
3638 or a list (- N) meaning -N pixels relative to bottom/right corner. */)
3643 unsigned int width
, height
;
3646 CHECK_STRING (string
);
3648 geometry
= XParseGeometry ((char *) SDATA (string
),
3649 &x
, &y
, &width
, &height
);
3652 if (!!(geometry
& XValue
) != !!(geometry
& YValue
))
3653 error ("Must specify both x and y position, or neither");
3657 if (geometry
& XValue
)
3659 Lisp_Object element
;
3661 if (x
>= 0 && (geometry
& XNegative
))
3662 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3663 else if (x
< 0 && ! (geometry
& XNegative
))
3664 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3666 element
= Fcons (Qleft
, make_number (x
));
3667 result
= Fcons (element
, result
);
3670 if (geometry
& YValue
)
3672 Lisp_Object element
;
3674 if (y
>= 0 && (geometry
& YNegative
))
3675 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3676 else if (y
< 0 && ! (geometry
& YNegative
))
3677 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3679 element
= Fcons (Qtop
, make_number (y
));
3680 result
= Fcons (element
, result
);
3683 if (geometry
& WidthValue
)
3684 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3685 if (geometry
& HeightValue
)
3686 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3691 /* Calculate the desired size and position of frame F.
3692 Return the flags saying which aspects were specified.
3694 Also set the win_gravity and size_hint_flags of F.
3696 Adjust height for toolbar if TOOLBAR_P is 1.
3698 This function does not make the coordinates positive. */
3700 #define DEFAULT_ROWS 40
3701 #define DEFAULT_COLS 80
3704 x_figure_window_size (f
, parms
, toolbar_p
)
3709 register Lisp_Object tem0
, tem1
, tem2
;
3710 long window_prompting
= 0;
3711 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3713 /* Default values if we fall through.
3714 Actually, if that happens we should get
3715 window manager prompting. */
3716 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3717 FRAME_LINES (f
) = DEFAULT_ROWS
;
3718 /* Window managers expect that if program-specified
3719 positions are not (0,0), they're intentional, not defaults. */
3723 /* Ensure that old new_text_cols and new_text_lines will not override the
3725 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3726 f
->new_text_cols
= f
->new_text_lines
= 0;
3728 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3729 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3730 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3731 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3733 if (!EQ (tem0
, Qunbound
))
3735 CHECK_NUMBER (tem0
);
3736 FRAME_LINES (f
) = XINT (tem0
);
3738 if (!EQ (tem1
, Qunbound
))
3740 CHECK_NUMBER (tem1
);
3741 SET_FRAME_COLS (f
, XINT (tem1
));
3743 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
3744 window_prompting
|= USSize
;
3746 window_prompting
|= PSize
;
3749 f
->scroll_bar_actual_width
3750 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
3752 /* This used to be done _before_ calling x_figure_window_size, but
3753 since the height is reset here, this was really a no-op. I
3754 assume that moving it here does what Gerd intended (although he
3755 no longer can remember what that was... ++KFS, 2003-03-25. */
3757 /* Add the tool-bar height to the initial frame height so that the
3758 user gets a text display area of the size he specified with -g or
3759 via .Xdefaults. Later changes of the tool-bar height don't
3760 change the frame size. This is done so that users can create
3761 tall Emacs frames without having to guess how tall the tool-bar
3763 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
3765 int margin
, relief
, bar_height
;
3767 relief
= (tool_bar_button_relief
>= 0
3768 ? tool_bar_button_relief
3769 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
3771 if (INTEGERP (Vtool_bar_button_margin
)
3772 && XINT (Vtool_bar_button_margin
) > 0)
3773 margin
= XFASTINT (Vtool_bar_button_margin
);
3774 else if (CONSP (Vtool_bar_button_margin
)
3775 && INTEGERP (XCDR (Vtool_bar_button_margin
))
3776 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
3777 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
3781 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
3782 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
3785 compute_fringe_widths (f
, 0);
3787 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
3788 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
3790 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
3791 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
3792 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
3793 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3795 if (EQ (tem0
, Qminus
))
3798 window_prompting
|= YNegative
;
3800 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
3801 && CONSP (XCDR (tem0
))
3802 && INTEGERP (XCAR (XCDR (tem0
))))
3804 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
3805 window_prompting
|= YNegative
;
3807 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
3808 && CONSP (XCDR (tem0
))
3809 && INTEGERP (XCAR (XCDR (tem0
))))
3811 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
3813 else if (EQ (tem0
, Qunbound
))
3817 CHECK_NUMBER (tem0
);
3818 f
->top_pos
= XINT (tem0
);
3820 window_prompting
|= YNegative
;
3823 if (EQ (tem1
, Qminus
))
3826 window_prompting
|= XNegative
;
3828 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
3829 && CONSP (XCDR (tem1
))
3830 && INTEGERP (XCAR (XCDR (tem1
))))
3832 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
3833 window_prompting
|= XNegative
;
3835 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
3836 && CONSP (XCDR (tem1
))
3837 && INTEGERP (XCAR (XCDR (tem1
))))
3839 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
3841 else if (EQ (tem1
, Qunbound
))
3845 CHECK_NUMBER (tem1
);
3846 f
->left_pos
= XINT (tem1
);
3847 if (f
->left_pos
< 0)
3848 window_prompting
|= XNegative
;
3851 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
3852 window_prompting
|= USPosition
;
3854 window_prompting
|= PPosition
;
3857 if (f
->want_fullscreen
!= FULLSCREEN_NONE
)
3862 /* It takes both for some WM:s to place it where we want */
3863 window_prompting
= USPosition
| PPosition
;
3864 x_fullscreen_adjust (f
, &width
, &height
, &top
, &left
);
3865 FRAME_COLS (f
) = width
;
3866 FRAME_LINES (f
) = height
;
3867 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, width
);
3868 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, height
);
3873 if (window_prompting
& XNegative
)
3875 if (window_prompting
& YNegative
)
3876 f
->win_gravity
= SouthEastGravity
;
3878 f
->win_gravity
= NorthEastGravity
;
3882 if (window_prompting
& YNegative
)
3883 f
->win_gravity
= SouthWestGravity
;
3885 f
->win_gravity
= NorthWestGravity
;
3888 f
->size_hint_flags
= window_prompting
;
3890 return window_prompting
;
3895 #endif /* HAVE_WINDOW_SYSTEM */
3899 /***********************************************************************
3901 ***********************************************************************/
3906 Qframep
= intern ("framep");
3907 staticpro (&Qframep
);
3908 Qframe_live_p
= intern ("frame-live-p");
3909 staticpro (&Qframe_live_p
);
3910 Qheight
= intern ("height");
3911 staticpro (&Qheight
);
3912 Qicon
= intern ("icon");
3914 Qminibuffer
= intern ("minibuffer");
3915 staticpro (&Qminibuffer
);
3916 Qmodeline
= intern ("modeline");
3917 staticpro (&Qmodeline
);
3918 Qonly
= intern ("only");
3920 Qwidth
= intern ("width");
3921 staticpro (&Qwidth
);
3922 Qgeometry
= intern ("geometry");
3923 staticpro (&Qgeometry
);
3924 Qicon_left
= intern ("icon-left");
3925 staticpro (&Qicon_left
);
3926 Qicon_top
= intern ("icon-top");
3927 staticpro (&Qicon_top
);
3928 Qleft
= intern ("left");
3930 Qright
= intern ("right");
3931 staticpro (&Qright
);
3932 Quser_position
= intern ("user-position");
3933 staticpro (&Quser_position
);
3934 Quser_size
= intern ("user-size");
3935 staticpro (&Quser_size
);
3936 Qwindow_id
= intern ("window-id");
3937 staticpro (&Qwindow_id
);
3938 #ifdef HAVE_X_WINDOWS
3939 Qouter_window_id
= intern ("outer-window-id");
3940 staticpro (&Qouter_window_id
);
3942 Qparent_id
= intern ("parent-id");
3943 staticpro (&Qparent_id
);
3946 Qw32
= intern ("w32");
3948 Qpc
= intern ("pc");
3950 Qmac
= intern ("mac");
3952 Qvisible
= intern ("visible");
3953 staticpro (&Qvisible
);
3954 Qbuffer_predicate
= intern ("buffer-predicate");
3955 staticpro (&Qbuffer_predicate
);
3956 Qbuffer_list
= intern ("buffer-list");
3957 staticpro (&Qbuffer_list
);
3958 Qdisplay_type
= intern ("display-type");
3959 staticpro (&Qdisplay_type
);
3960 Qbackground_mode
= intern ("background-mode");
3961 staticpro (&Qbackground_mode
);
3962 Qtty_color_mode
= intern ("tty-color-mode");
3963 staticpro (&Qtty_color_mode
);
3965 Qface_set_after_frame_default
= intern ("face-set-after-frame-default");
3966 staticpro (&Qface_set_after_frame_default
);
3968 Qfullwidth
= intern ("fullwidth");
3969 staticpro (&Qfullwidth
);
3970 Qfullheight
= intern ("fullheight");
3971 staticpro (&Qfullheight
);
3972 Qfullboth
= intern ("fullboth");
3973 staticpro (&Qfullboth
);
3974 Qx_resource_name
= intern ("x-resource-name");
3975 staticpro (&Qx_resource_name
);
3977 Qx_frame_parameter
= intern ("x-frame-parameter");
3978 staticpro (&Qx_frame_parameter
);
3983 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
3985 Lisp_Object v
= intern (frame_parms
[i
].name
);
3986 if (frame_parms
[i
].variable
)
3988 *frame_parms
[i
].variable
= v
;
3989 staticpro (frame_parms
[i
].variable
);
3991 Fput (v
, Qx_frame_parameter
, make_number (i
));
3995 #ifdef HAVE_WINDOW_SYSTEM
3996 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
3997 doc
: /* The name Emacs uses to look up X resources.
3998 `x-get-resource' uses this as the first component of the instance name
3999 when requesting resource values.
4000 Emacs initially sets `x-resource-name' to the name under which Emacs
4001 was invoked, or to the value specified with the `-name' or `-rn'
4002 switches, if present.
4004 It may be useful to bind this variable locally around a call
4005 to `x-get-resource'. See also the variable `x-resource-class'. */);
4006 Vx_resource_name
= Qnil
;
4008 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4009 doc
: /* The class Emacs uses to look up X resources.
4010 `x-get-resource' uses this as the first component of the instance class
4011 when requesting resource values.
4013 Emacs initially sets `x-resource-class' to "Emacs".
4015 Setting this variable permanently is not a reasonable thing to do,
4016 but binding this variable locally around a call to `x-get-resource'
4017 is a reasonable practice. See also the variable `x-resource-name'. */);
4018 Vx_resource_class
= build_string (EMACS_CLASS
);
4021 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4022 doc
: /* Alist of default values for frame creation.
4023 These may be set in your init file, like this:
4024 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))
4025 These override values given in window system configuration data,
4026 including X Windows' defaults database.
4027 For values specific to the first Emacs frame, see `initial-frame-alist'.
4028 For values specific to the separate minibuffer frame, see
4029 `minibuffer-frame-alist'.
4030 The `menu-bar-lines' element of the list controls whether new frames
4031 have menu bars; `menu-bar-mode' works by altering this element.
4032 Setting this variable does not affect existing frames, only new ones. */);
4033 Vdefault_frame_alist
= Qnil
;
4035 Qinhibit_default_face_x_resources
4036 = intern ("inhibit-default-face-x-resources");
4037 staticpro (&Qinhibit_default_face_x_resources
);
4039 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4040 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4042 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
4043 doc
: /* Non-nil if all of emacs is iconified and frame updates are not needed. */);
4044 Vemacs_iconified
= Qnil
;
4046 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4047 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4048 `mouse-position' calls this function, passing its usual return value as
4049 argument, and returns whatever this function returns.
4050 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4051 which need to do mouse handling at the Lisp level. */);
4052 Vmouse_position_function
= Qnil
;
4054 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4055 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4056 If the value is an integer, highlighting is only shown after moving the
4057 mouse, while keyboard input turns off the highlight even when the mouse
4058 is over the clickable text. However, the mouse shape still indicates
4059 when the mouse is over clickable text. */);
4060 Vmouse_highlight
= Qt
;
4062 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4063 doc
: /* Functions to be run before deleting a frame.
4064 The functions are run with one arg, the frame to be deleted.
4065 See `delete-frame'. */);
4066 Vdelete_frame_functions
= Qnil
;
4068 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4069 doc
: /* Minibufferless frames use this frame's minibuffer.
4071 Emacs cannot create minibufferless frames unless this is set to an
4072 appropriate surrogate.
4074 Emacs consults this variable only when creating minibufferless
4075 frames; once the frame is created, it sticks with its assigned
4076 minibuffer, no matter what this variable is set to. This means that
4077 this variable doesn't necessarily say anything meaningful about the
4078 current set of frames, or where the minibuffer is currently being
4081 This variable is local to the current terminal and cannot be buffer-local. */);
4083 staticpro (&Vframe_list
);
4085 defsubr (&Sactive_minibuffer_window
);
4087 defsubr (&Sframe_live_p
);
4088 defsubr (&Smake_terminal_frame
);
4089 defsubr (&Shandle_switch_frame
);
4090 defsubr (&Signore_event
);
4091 defsubr (&Sselect_frame
);
4092 defsubr (&Sselected_frame
);
4093 defsubr (&Swindow_frame
);
4094 defsubr (&Sframe_root_window
);
4095 defsubr (&Sframe_first_window
);
4096 defsubr (&Sframe_selected_window
);
4097 defsubr (&Sset_frame_selected_window
);
4098 defsubr (&Sframe_list
);
4099 defsubr (&Snext_frame
);
4100 defsubr (&Sprevious_frame
);
4101 defsubr (&Sdelete_frame
);
4102 defsubr (&Smouse_position
);
4103 defsubr (&Smouse_pixel_position
);
4104 defsubr (&Sset_mouse_position
);
4105 defsubr (&Sset_mouse_pixel_position
);
4107 defsubr (&Sframe_configuration
);
4108 defsubr (&Srestore_frame_configuration
);
4110 defsubr (&Smake_frame_visible
);
4111 defsubr (&Smake_frame_invisible
);
4112 defsubr (&Siconify_frame
);
4113 defsubr (&Sframe_visible_p
);
4114 defsubr (&Svisible_frame_list
);
4115 defsubr (&Sraise_frame
);
4116 defsubr (&Slower_frame
);
4117 defsubr (&Sredirect_frame_focus
);
4118 defsubr (&Sframe_focus
);
4119 defsubr (&Sframe_parameters
);
4120 defsubr (&Sframe_parameter
);
4121 defsubr (&Smodify_frame_parameters
);
4122 defsubr (&Sframe_char_height
);
4123 defsubr (&Sframe_char_width
);
4124 defsubr (&Sframe_pixel_height
);
4125 defsubr (&Sframe_pixel_width
);
4126 defsubr (&Sset_frame_height
);
4127 defsubr (&Sset_frame_width
);
4128 defsubr (&Sset_frame_size
);
4129 defsubr (&Sset_frame_position
);
4131 #ifdef HAVE_WINDOW_SYSTEM
4132 defsubr (&Sx_get_resource
);
4133 defsubr (&Sx_parse_geometry
);