1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001
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
, XFASTINT (w
->top
) + n
);
130 XSETFASTINT (w
->height
, XFASTINT (w
->height
) - n
);
132 if (INTEGERP (w
->orig_top
))
133 XSETFASTINT (w
->orig_top
, XFASTINT (w
->orig_top
) + n
);
134 if (INTEGERP (w
->orig_height
))
135 XSETFASTINT (w
->orig_height
, XFASTINT (w
->orig_height
) - 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;
289 root_window
= make_window ();
292 mini_window
= make_window ();
293 XWINDOW (root_window
)->next
= mini_window
;
294 XWINDOW (mini_window
)->prev
= root_window
;
295 XWINDOW (mini_window
)->mini_p
= Qt
;
296 XWINDOW (mini_window
)->frame
= frame
;
297 f
->minibuffer_window
= mini_window
;
302 XWINDOW (root_window
)->next
= Qnil
;
303 f
->minibuffer_window
= Qnil
;
306 XWINDOW (root_window
)->frame
= frame
;
309 just so that there is "something there."
310 Correct size will be set up later with change_frame_size. */
312 SET_FRAME_WIDTH (f
, 10);
315 XSETFASTINT (XWINDOW (root_window
)->width
, 10);
316 XSETFASTINT (XWINDOW (root_window
)->height
, (mini_p
? 9 : 10));
320 XSETFASTINT (XWINDOW (mini_window
)->width
, 10);
321 XSETFASTINT (XWINDOW (mini_window
)->top
, 9);
322 XSETFASTINT (XWINDOW (mini_window
)->height
, 1);
325 /* Choose a buffer for the frame's root window. */
329 XWINDOW (root_window
)->buffer
= Qt
;
330 buf
= Fcurrent_buffer ();
331 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
332 a space), try to find another one. */
333 if (SREF (Fbuffer_name (buf
), 0) == ' ')
334 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
336 /* Use set_window_buffer, not Fset_window_buffer, and don't let
337 hooks be run by it. The reason is that the whole frame/window
338 arrangement is not yet fully intialized at this point. Windows
339 don't have the right size, glyph matrices aren't initialized
340 etc. Running Lisp functions at this point surely ends in a
342 set_window_buffer (root_window
, buf
, 0);
343 f
->buffer_list
= Fcons (buf
, Qnil
);
348 XWINDOW (mini_window
)->buffer
= Qt
;
349 set_window_buffer (mini_window
,
350 (NILP (Vminibuffer_list
)
352 : Fcar (Vminibuffer_list
)),
356 f
->root_window
= root_window
;
357 f
->selected_window
= root_window
;
358 /* Make sure this window seems more recently used than
359 a newly-created, never-selected window. */
360 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, ++window_select_count
);
365 #ifdef HAVE_WINDOW_SYSTEM
366 /* Make a frame using a separate minibuffer window on another frame.
367 MINI_WINDOW is the minibuffer window to use. nil means use the
368 default (the global minibuffer). */
371 make_frame_without_minibuffer (mini_window
, kb
, display
)
372 register Lisp_Object mini_window
;
376 register struct frame
*f
;
379 if (!NILP (mini_window
))
380 CHECK_LIVE_WINDOW (mini_window
);
383 if (!NILP (mini_window
)
384 && XFRAME (XWINDOW (mini_window
)->frame
)->kboard
!= kb
)
385 error ("frame and minibuffer must be on the same display");
388 /* Make a frame containing just a root window. */
391 if (NILP (mini_window
))
393 /* Use default-minibuffer-frame if possible. */
394 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
395 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
397 Lisp_Object frame_dummy
;
399 XSETFRAME (frame_dummy
, f
);
400 GCPRO1 (frame_dummy
);
401 /* If there's no minibuffer frame to use, create one. */
402 kb
->Vdefault_minibuffer_frame
=
403 call1 (intern ("make-initial-minibuffer-frame"), display
);
407 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
410 f
->minibuffer_window
= mini_window
;
412 /* Make the chosen minibuffer window display the proper minibuffer,
413 unless it is already showing a minibuffer. */
414 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
415 Fset_window_buffer (mini_window
,
416 (NILP (Vminibuffer_list
)
418 : Fcar (Vminibuffer_list
)));
422 /* Make a frame containing only a minibuffer window. */
425 make_minibuffer_frame ()
427 /* First make a frame containing just a root window, no minibuffer. */
429 register struct frame
*f
= make_frame (0);
430 register Lisp_Object mini_window
;
431 register Lisp_Object frame
;
433 XSETFRAME (frame
, f
);
438 f
->wants_modeline
= 0;
439 f
->has_minibuffer
= 1;
441 /* Now label the root window as also being the minibuffer.
442 Avoid infinite looping on the window chain by marking next pointer
445 mini_window
= f
->minibuffer_window
= f
->root_window
;
446 XWINDOW (mini_window
)->mini_p
= Qt
;
447 XWINDOW (mini_window
)->next
= Qnil
;
448 XWINDOW (mini_window
)->prev
= Qnil
;
449 XWINDOW (mini_window
)->frame
= frame
;
451 /* Put the proper buffer in that window. */
453 Fset_window_buffer (mini_window
,
454 (NILP (Vminibuffer_list
)
456 : Fcar (Vminibuffer_list
)));
459 #endif /* HAVE_WINDOW_SYSTEM */
461 /* Construct a frame that refers to the terminal (stdin and stdout). */
463 static int terminal_frame_count
;
466 make_terminal_frame ()
468 register struct frame
*f
;
475 initial_kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
476 init_kboard (initial_kboard
);
477 initial_kboard
->next_kboard
= all_kboards
;
478 all_kboards
= initial_kboard
;
482 /* The first call must initialize Vframe_list. */
483 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
488 XSETFRAME (frame
, f
);
489 Vframe_list
= Fcons (frame
, Vframe_list
);
491 terminal_frame_count
++;
492 sprintf (name
, "F%d", terminal_frame_count
);
493 f
->name
= build_string (name
);
495 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
496 f
->async_visible
= 1; /* Don't let visible be cleared later. */
498 f
->output_data
.x
= &the_only_x_display
;
499 if (!inhibit_window_system
500 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
501 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
503 f
->output_method
= output_msdos_raw
;
504 /* This initialization of foreground and background pixels is
505 only important for the initial frame created in temacs. If
506 we don't do that, we get black background and foreground in
507 the dumped Emacs because the_only_x_display is a static
508 variable, hence it is born all-zeroes, and zero is the code
509 for the black color. Other frames all inherit their pixels
510 from what's already in the_only_x_display. */
511 if ((!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
512 && f
->output_data
.x
->background_pixel
== 0
513 && f
->output_data
.x
->foreground_pixel
== 0)
515 f
->output_data
.x
->background_pixel
= FACE_TTY_DEFAULT_BG_COLOR
;
516 f
->output_data
.x
->foreground_pixel
= FACE_TTY_DEFAULT_FG_COLOR
;
520 f
->output_method
= output_termcap
;
523 f
->output_method
= output_termcap
;
524 f
->output_data
.x
= &tty_display
;
527 make_mac_terminal_frame (f
);
529 f
->output_data
.x
= &tty_display
;
531 FRAME_FOREGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_FG_COLOR
;
532 FRAME_BACKGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_BG_COLOR
;
535 #endif /* WINDOWSNT */
539 init_frame_faces (f
);
544 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
546 doc
: /* Create an additional terminal frame.
547 You can create multiple frames on a text-only terminal in this way.
548 Only the selected terminal frame is actually displayed.
549 This function takes one argument, an alist specifying frame parameters.
550 In practice, generally you don't need to specify any parameters.
551 Note that changing the size of one terminal frame automatically affects all. */)
556 Lisp_Object frame
, tem
;
557 struct frame
*sf
= SELECTED_FRAME ();
560 if (sf
->output_method
!= output_msdos_raw
561 && sf
->output_method
!= output_termcap
)
563 #else /* not MSDOS */
566 if (sf
->output_method
!= output_mac
)
567 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
569 if (sf
->output_method
!= output_termcap
)
570 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
572 #endif /* not MSDOS */
574 f
= make_terminal_frame ();
576 change_frame_size (f
, FRAME_HEIGHT (sf
),
577 FRAME_WIDTH (sf
), 0, 0, 0);
580 XSETFRAME (frame
, f
);
581 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
582 Fmodify_frame_parameters (frame
, parms
);
584 /* Make the frame face alist be frame-specific, so that each
585 frame could change its face definitions independently. */
586 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
587 /* Simple Fcopy_alist isn't enough, because we need the contents of
588 the vectors which are the CDRs of associations in face_alist to
589 be copied as well. */
590 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
591 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
596 /* Perform the switch to frame FRAME.
598 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
601 If TRACK is non-zero and the frame that currently has the focus
602 redirects its focus to the selected frame, redirect that focused
603 frame's focus to FRAME instead.
605 FOR_DELETION non-zero means that the selected frame is being
606 deleted, which includes the possibility that the frame's display
610 do_switch_frame (frame
, track
, for_deletion
)
612 int track
, for_deletion
;
614 struct frame
*sf
= SELECTED_FRAME ();
616 /* If FRAME is a switch-frame event, extract the frame we should
619 && EQ (XCAR (frame
), Qswitch_frame
)
620 && CONSP (XCDR (frame
)))
621 frame
= XCAR (XCDR (frame
));
623 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
624 a switch-frame event to arrive after a frame is no longer live,
625 especially when deleting the initial frame during startup. */
627 if (! FRAME_LIVE_P (XFRAME (frame
)))
630 if (sf
== XFRAME (frame
))
633 /* This is too greedy; it causes inappropriate focus redirection
634 that's hard to get rid of. */
636 /* If a frame's focus has been redirected toward the currently
637 selected frame, we should change the redirection to point to the
638 newly selected frame. This means that if the focus is redirected
639 from a minibufferless frame to a surrogate minibuffer frame, we
640 can use `other-window' to switch between all the frames using
641 that minibuffer frame, and the focus redirection will follow us
647 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
651 if (!FRAMEP (XCAR (tail
)))
654 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
656 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
657 Fredirect_frame_focus (XCAR (tail
), frame
);
661 /* Instead, apply it only to the frame we're pointing to. */
662 #ifdef HAVE_WINDOW_SYSTEM
663 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
665 Lisp_Object focus
, xfocus
;
667 xfocus
= x_get_focus_frame (XFRAME (frame
));
670 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
671 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
672 Fredirect_frame_focus (xfocus
, frame
);
675 #endif /* HAVE_X_WINDOWS */
678 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
679 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
681 selected_frame
= frame
;
682 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
683 last_nonminibuf_frame
= XFRAME (selected_frame
);
685 Fselect_window (XFRAME (frame
)->selected_window
);
688 /* Make sure to switch the tty color mode to that of the newly
690 sf
= SELECTED_FRAME ();
691 if (FRAME_TERMCAP_P (sf
))
693 Lisp_Object color_mode_spec
, color_mode
;
695 color_mode_spec
= assq_no_quit (Qtty_color_mode
, sf
->param_alist
);
696 if (CONSP (color_mode_spec
))
697 color_mode
= XCDR (color_mode_spec
);
699 color_mode
= make_number (0);
700 set_tty_color_mode (sf
, color_mode
);
702 #endif /* !WINDOWSNT */
704 /* We want to make sure that the next event generates a frame-switch
705 event to the appropriate frame. This seems kludgy to me, but
706 before you take it out, make sure that evaluating something like
707 (select-window (frame-root-window (new-frame))) doesn't end up
708 with your typing being interpreted in the new frame instead of
709 the one you're actually typing in. */
710 internal_last_event_frame
= Qnil
;
715 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
716 doc
: /* Select the frame FRAME.
717 Subsequent editing commands apply to its selected window.
718 The selection of FRAME lasts until the next time the user does
719 something to select a different frame, or until the next time this
720 function is called. */)
722 Lisp_Object frame
, no_enter
;
724 return do_switch_frame (frame
, 1, 0);
728 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 2, "e",
729 doc
: /* Handle a switch-frame event EVENT.
730 Switch-frame events are usually bound to this function.
731 A switch-frame event tells Emacs that the window manager has requested
732 that the user's events be directed to the frame mentioned in the event.
733 This function selects the selected window of the frame of EVENT.
735 If EVENT is frame object, handle it as if it were a switch-frame event
738 Lisp_Object event
, no_enter
;
740 /* Preserve prefix arg that the command loop just cleared. */
741 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
742 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
743 return do_switch_frame (event
, 0, 0);
746 DEFUN ("ignore-event", Fignore_event
, Signore_event
, 0, 0, "",
747 doc
: /* Do nothing, but preserve any prefix argument already specified.
748 This is a suitable binding for iconify-frame and make-frame-visible. */)
751 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
755 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
756 doc
: /* Return the frame that is now selected. */)
759 return selected_frame
;
762 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
763 doc
: /* Return the frame object that window WINDOW is on. */)
767 CHECK_LIVE_WINDOW (window
);
768 return XWINDOW (window
)->frame
;
771 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
772 doc
: /* Returns the topmost, leftmost window of FRAME.
773 If omitted, FRAME defaults to the currently selected frame. */)
780 w
= SELECTED_FRAME ()->root_window
;
783 CHECK_LIVE_FRAME (frame
);
784 w
= XFRAME (frame
)->root_window
;
786 while (NILP (XWINDOW (w
)->buffer
))
788 if (! NILP (XWINDOW (w
)->hchild
))
789 w
= XWINDOW (w
)->hchild
;
790 else if (! NILP (XWINDOW (w
)->vchild
))
791 w
= XWINDOW (w
)->vchild
;
798 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
799 Sactive_minibuffer_window
, 0, 0, 0,
800 doc
: /* Return the currently active minibuffer window, or nil if none. */)
803 return minibuf_level
? minibuf_window
: Qnil
;
806 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
807 doc
: /* Returns the root-window of FRAME.
808 If omitted, FRAME defaults to the currently selected frame. */)
815 window
= SELECTED_FRAME ()->root_window
;
818 CHECK_LIVE_FRAME (frame
);
819 window
= XFRAME (frame
)->root_window
;
825 DEFUN ("frame-selected-window", Fframe_selected_window
,
826 Sframe_selected_window
, 0, 1, 0,
827 doc
: /* Return the selected window of frame object FRAME.
828 If omitted, FRAME defaults to the currently selected frame. */)
835 window
= SELECTED_FRAME ()->selected_window
;
838 CHECK_LIVE_FRAME (frame
);
839 window
= XFRAME (frame
)->selected_window
;
845 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
846 Sset_frame_selected_window
, 2, 2, 0,
847 doc
: /* Set the selected window of frame object FRAME to WINDOW.
848 If FRAME is nil, the selected frame is used.
849 If FRAME is the selected frame, this makes WINDOW the selected window. */)
851 Lisp_Object frame
, window
;
854 frame
= selected_frame
;
856 CHECK_LIVE_FRAME (frame
);
857 CHECK_LIVE_WINDOW (window
);
859 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
860 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
862 if (EQ (frame
, selected_frame
))
863 return Fselect_window (window
);
865 return XFRAME (frame
)->selected_window
= window
;
868 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
870 doc
: /* Return a list of all frames. */)
874 frames
= Fcopy_sequence (Vframe_list
);
875 #ifdef HAVE_WINDOW_SYSTEM
876 if (FRAMEP (tip_frame
))
877 frames
= Fdelq (tip_frame
, frames
);
882 /* Return the next frame in the frame list after FRAME.
883 If MINIBUF is nil, exclude minibuffer-only frames.
884 If MINIBUF is a window, include only its own frame
885 and any frame now using that window as the minibuffer.
886 If MINIBUF is `visible', include all visible frames.
887 If MINIBUF is 0, include all visible and iconified frames.
888 Otherwise, include all frames. */
891 next_frame (frame
, minibuf
)
898 /* There must always be at least one frame in Vframe_list. */
899 if (! CONSP (Vframe_list
))
902 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
903 forever. Forestall that. */
904 CHECK_LIVE_FRAME (frame
);
907 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
914 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
916 /* Decide whether this frame is eligible to be returned. */
918 /* If we've looped all the way around without finding any
919 eligible frames, return the original frame. */
923 /* Let minibuf decide if this frame is acceptable. */
926 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
929 else if (EQ (minibuf
, Qvisible
))
931 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
932 if (FRAME_VISIBLE_P (XFRAME (f
)))
935 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
937 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
938 if (FRAME_VISIBLE_P (XFRAME (f
))
939 || FRAME_ICONIFIED_P (XFRAME (f
)))
942 else if (WINDOWP (minibuf
))
944 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
945 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
946 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
947 FRAME_FOCUS_FRAME (XFRAME (f
))))
959 /* Return the previous frame in the frame list before FRAME.
960 If MINIBUF is nil, exclude minibuffer-only frames.
961 If MINIBUF is a window, include only its own frame
962 and any frame now using that window as the minibuffer.
963 If MINIBUF is `visible', include all visible frames.
964 If MINIBUF is 0, include all visible and iconified frames.
965 Otherwise, include all frames. */
968 prev_frame (frame
, minibuf
)
975 /* There must always be at least one frame in Vframe_list. */
976 if (! CONSP (Vframe_list
))
980 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
988 if (EQ (frame
, f
) && !NILP (prev
))
991 if (FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
993 /* Decide whether this frame is eligible to be returned,
994 according to minibuf. */
997 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1000 else if (WINDOWP (minibuf
))
1002 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1003 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1004 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1005 FRAME_FOCUS_FRAME (XFRAME (f
))))
1008 else if (EQ (minibuf
, Qvisible
))
1010 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1011 if (FRAME_VISIBLE_P (XFRAME (f
)))
1014 else if (XFASTINT (minibuf
) == 0)
1016 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1017 if (FRAME_VISIBLE_P (XFRAME (f
))
1018 || FRAME_ICONIFIED_P (XFRAME (f
)))
1026 /* We've scanned the entire list. */
1028 /* We went through the whole frame list without finding a single
1029 acceptable frame. Return the original frame. */
1032 /* There were no acceptable frames in the list before FRAME; otherwise,
1033 we would have returned directly from the loop. Since PREV is the last
1034 acceptable frame in the list, return it. */
1039 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1040 doc
: /* Return the next frame in the frame list after FRAME.
1041 It considers only frames on the same terminal as FRAME.
1042 By default, skip minibuffer-only frames.
1043 If omitted, FRAME defaults to the selected frame.
1044 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1045 If MINIFRAME is a window, include only its own frame
1046 and any frame now using that window as the minibuffer.
1047 If MINIFRAME is `visible', include all visible frames.
1048 If MINIFRAME is 0, include all visible and iconified frames.
1049 Otherwise, include all frames. */)
1051 Lisp_Object frame
, miniframe
;
1054 frame
= selected_frame
;
1056 CHECK_LIVE_FRAME (frame
);
1057 return next_frame (frame
, miniframe
);
1060 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1061 doc
: /* Return the previous frame in the frame list before FRAME.
1062 It considers only frames on the same terminal as FRAME.
1063 By default, skip minibuffer-only frames.
1064 If omitted, FRAME defaults to the selected frame.
1065 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1066 If MINIFRAME is a window, include only its own frame
1067 and any frame now using that window as the minibuffer.
1068 If MINIFRAME is `visible', include all visible frames.
1069 If MINIFRAME is 0, include all visible and iconified frames.
1070 Otherwise, include all frames. */)
1072 Lisp_Object frame
, miniframe
;
1075 frame
= selected_frame
;
1076 CHECK_LIVE_FRAME (frame
);
1077 return prev_frame (frame
, miniframe
);
1080 /* Return 1 if it is ok to delete frame F;
1081 0 if all frames aside from F are invisible.
1082 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1085 other_visible_frames (f
)
1088 /* We know the selected frame is visible,
1089 so if F is some other frame, it can't be the sole visible one. */
1090 if (f
== SELECTED_FRAME ())
1095 for (frames
= Vframe_list
;
1097 frames
= XCDR (frames
))
1101 this = XCAR (frames
);
1102 /* Verify that the frame's window still exists
1103 and we can still talk to it. And note any recent change
1105 #ifdef HAVE_WINDOW_SYSTEM
1106 if (FRAME_WINDOW_P (XFRAME (this)))
1108 x_sync (XFRAME (this));
1109 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1113 if (FRAME_VISIBLE_P (XFRAME (this))
1114 || FRAME_ICONIFIED_P (XFRAME (this))
1115 /* Allow deleting the terminal frame when at least
1116 one X frame exists! */
1117 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1125 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1126 doc
: /* Delete FRAME, permanently eliminating it from use.
1127 If omitted, FRAME defaults to the selected frame.
1128 A frame may not be deleted if its minibuffer is used by other frames.
1129 Normally, you may not delete a frame if all other frames are invisible,
1130 but if the second optional argument FORCE is non-nil, you may do so.
1132 This function runs `delete-frame-functions' before actually deleting the
1133 frame, unless the frame is a tooltip.
1134 The functions are run with one arg, the frame to be deleted. */)
1136 Lisp_Object frame
, force
;
1139 struct frame
*sf
= SELECTED_FRAME ();
1140 int minibuffer_selected
;
1142 if (EQ (frame
, Qnil
))
1145 XSETFRAME (frame
, f
);
1149 CHECK_FRAME (frame
);
1153 if (! FRAME_LIVE_P (f
))
1156 if (NILP (force
) && !other_visible_frames (f
)
1158 /* Terminal frame deleted before any other visible frames are
1160 && strcmp (SDATA (f
->name
), "F1") != 0
1163 error ("Attempt to delete the sole visible or iconified frame");
1166 /* This is a nice idea, but x_connection_closed needs to be able
1167 to delete the last frame, if it is gone. */
1168 if (NILP (XCDR (Vframe_list
)))
1169 error ("Attempt to delete the only frame");
1172 /* Does this frame have a minibuffer, and is it the surrogate
1173 minibuffer for any other frame? */
1174 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1178 for (frames
= Vframe_list
;
1180 frames
= XCDR (frames
))
1183 this = XCAR (frames
);
1185 if (! EQ (this, frame
)
1187 WINDOW_FRAME (XWINDOW
1188 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1189 error ("Attempt to delete a surrogate minibuffer frame");
1193 /* Run `delete-frame-functions' unless frame is a tooltip. */
1194 if (!NILP (Vrun_hooks
)
1195 && NILP (Fframe_parameter (frame
, intern ("tooltip"))))
1197 Lisp_Object args
[2];
1198 args
[0] = intern ("delete-frame-functions");
1200 Frun_hook_with_args (2, args
);
1203 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1205 /* Don't let the frame remain selected. */
1208 Lisp_Object tail
, frame1
;
1210 /* Look for another visible frame on the same terminal. */
1211 frame1
= next_frame (frame
, Qvisible
);
1213 /* If there is none, find *some* other frame. */
1214 if (NILP (frame1
) || EQ (frame1
, frame
))
1216 FOR_EACH_FRAME (tail
, frame1
)
1218 if (! EQ (frame
, frame1
))
1223 do_switch_frame (frame1
, 0, 1);
1224 sf
= SELECTED_FRAME ();
1227 /* Don't allow minibuf_window to remain on a deleted frame. */
1228 if (EQ (f
->minibuffer_window
, minibuf_window
))
1230 Fset_window_buffer (sf
->minibuffer_window
,
1231 XWINDOW (minibuf_window
)->buffer
);
1232 minibuf_window
= sf
->minibuffer_window
;
1234 /* If the dying minibuffer window was selected,
1235 select the new one. */
1236 if (minibuffer_selected
)
1237 Fselect_window (minibuf_window
);
1240 /* Don't let echo_area_window to remain on a deleted frame. */
1241 if (EQ (f
->minibuffer_window
, echo_area_window
))
1242 echo_area_window
= sf
->minibuffer_window
;
1244 /* Clear any X selections for this frame. */
1245 #ifdef HAVE_X_WINDOWS
1247 x_clear_frame_selections (f
);
1251 This function must be called before the window tree of the
1252 frame is deleted because windows contain dynamically allocated
1256 /* Mark all the windows that used to be on FRAME as deleted, and then
1257 remove the reference to them. */
1258 delete_all_subwindows (XWINDOW (f
->root_window
));
1259 f
->root_window
= Qnil
;
1261 Vframe_list
= Fdelq (frame
, Vframe_list
);
1262 FRAME_SET_VISIBLE (f
, 0);
1266 if (FRAME_INSERT_COST (f
))
1267 xfree (FRAME_INSERT_COST (f
));
1268 if (FRAME_DELETEN_COST (f
))
1269 xfree (FRAME_DELETEN_COST (f
));
1270 if (FRAME_INSERTN_COST (f
))
1271 xfree (FRAME_INSERTN_COST (f
));
1272 if (FRAME_DELETE_COST (f
))
1273 xfree (FRAME_DELETE_COST (f
));
1274 if (FRAME_MESSAGE_BUF (f
))
1275 xfree (FRAME_MESSAGE_BUF (f
));
1277 /* Since some events are handled at the interrupt level, we may get
1278 an event for f at any time; if we zero out the frame's display
1279 now, then we may trip up the event-handling code. Instead, we'll
1280 promise that the display of the frame must be valid until we have
1281 called the window-system-dependent frame destruction routine. */
1283 /* I think this should be done with a hook. */
1284 #ifdef HAVE_WINDOW_SYSTEM
1285 if (FRAME_WINDOW_P (f
))
1286 x_destroy_window (f
);
1289 f
->output_data
.nothing
= 0;
1291 /* If we've deleted the last_nonminibuf_frame, then try to find
1293 if (f
== last_nonminibuf_frame
)
1297 last_nonminibuf_frame
= 0;
1299 for (frames
= Vframe_list
;
1301 frames
= XCDR (frames
))
1303 f
= XFRAME (XCAR (frames
));
1304 if (!FRAME_MINIBUF_ONLY_P (f
))
1306 last_nonminibuf_frame
= f
;
1312 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1313 find another one. Prefer minibuffer-only frames, but also notice
1314 frames with other windows. */
1315 if (EQ (frame
, FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
))
1319 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1320 Lisp_Object frame_with_minibuf
;
1321 /* Some frame we found on the same kboard, or nil if there are none. */
1322 Lisp_Object frame_on_same_kboard
;
1324 frame_on_same_kboard
= Qnil
;
1325 frame_with_minibuf
= Qnil
;
1327 for (frames
= Vframe_list
;
1329 frames
= XCDR (frames
))
1334 this = XCAR (frames
);
1339 /* Consider only frames on the same kboard
1340 and only those with minibuffers. */
1341 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
)
1342 && FRAME_HAS_MINIBUF_P (f1
))
1344 frame_with_minibuf
= this;
1345 if (FRAME_MINIBUF_ONLY_P (f1
))
1349 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1350 frame_on_same_kboard
= this;
1353 if (!NILP (frame_on_same_kboard
))
1355 /* We know that there must be some frame with a minibuffer out
1356 there. If this were not true, all of the frames present
1357 would have to be minibufferless, which implies that at some
1358 point their minibuffer frames must have been deleted, but
1359 that is prohibited at the top; you can't delete surrogate
1360 minibuffer frames. */
1361 if (NILP (frame_with_minibuf
))
1364 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1367 /* No frames left on this kboard--say no minibuffer either. */
1368 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= Qnil
;
1371 /* Cause frame titles to update--necessary if we now have just one frame. */
1372 update_mode_lines
= 1;
1377 /* Return mouse position in character cell units. */
1379 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1380 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1381 The position is given in character cells, where (0, 0) is the
1383 If Emacs is running on a mouseless terminal or hasn't been programmed
1384 to read the mouse position, it returns the selected frame for FRAME
1385 and nil for X and Y.
1386 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1387 passing the normal return value to that function as an argument,
1388 and returns whatever that function returns. */)
1392 Lisp_Object lispy_dummy
;
1393 enum scroll_bar_part party_dummy
;
1394 Lisp_Object x
, y
, retval
;
1396 unsigned long long_dummy
;
1397 struct gcpro gcpro1
;
1399 f
= SELECTED_FRAME ();
1403 /* It's okay for the hook to refrain from storing anything. */
1404 if (mouse_position_hook
)
1405 (*mouse_position_hook
) (&f
, -1,
1406 &lispy_dummy
, &party_dummy
,
1413 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1418 XSETFRAME (lispy_dummy
, f
);
1419 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1421 if (!NILP (Vmouse_position_function
))
1422 retval
= call1 (Vmouse_position_function
, retval
);
1423 RETURN_UNGCPRO (retval
);
1426 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1427 Smouse_pixel_position
, 0, 0, 0,
1428 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1429 The position is given in pixel units, where (0, 0) is the
1431 If Emacs is running on a mouseless terminal or hasn't been programmed
1432 to read the mouse position, it returns the selected frame for FRAME
1433 and nil for X and Y. */)
1437 Lisp_Object lispy_dummy
;
1438 enum scroll_bar_part party_dummy
;
1440 unsigned long long_dummy
;
1442 f
= SELECTED_FRAME ();
1446 /* It's okay for the hook to refrain from storing anything. */
1447 if (mouse_position_hook
)
1448 (*mouse_position_hook
) (&f
, -1,
1449 &lispy_dummy
, &party_dummy
,
1453 XSETFRAME (lispy_dummy
, f
);
1454 return Fcons (lispy_dummy
, Fcons (x
, y
));
1457 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1458 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1459 Coordinates are relative to the frame, not a window,
1460 so the coordinates of the top left character in the frame
1461 may be nonzero due to left-hand scroll bars or the menu bar.
1463 This function is a no-op for an X frame that is not visible.
1464 If you have just created a frame, you must wait for it to become visible
1465 before calling this function on it, like this.
1466 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1468 Lisp_Object frame
, x
, y
;
1470 CHECK_LIVE_FRAME (frame
);
1474 /* I think this should be done with a hook. */
1475 #ifdef HAVE_WINDOW_SYSTEM
1476 if (FRAME_WINDOW_P (XFRAME (frame
)))
1477 /* Warping the mouse will cause enternotify and focus events. */
1478 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1480 #if defined (MSDOS) && defined (HAVE_MOUSE)
1481 if (FRAME_MSDOS_P (XFRAME (frame
)))
1483 Fselect_frame (frame
, Qnil
);
1484 mouse_moveto (XINT (x
), XINT (y
));
1492 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1493 Sset_mouse_pixel_position
, 3, 3, 0,
1494 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1495 Note, this is a no-op for an X frame that is not visible.
1496 If you have just created a frame, you must wait for it to become visible
1497 before calling this function on it, like this.
1498 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1500 Lisp_Object frame
, x
, y
;
1502 CHECK_LIVE_FRAME (frame
);
1506 /* I think this should be done with a hook. */
1507 #ifdef HAVE_WINDOW_SYSTEM
1508 if (FRAME_WINDOW_P (XFRAME (frame
)))
1509 /* Warping the mouse will cause enternotify and focus events. */
1510 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1512 #if defined (MSDOS) && defined (HAVE_MOUSE)
1513 if (FRAME_MSDOS_P (XFRAME (frame
)))
1515 Fselect_frame (frame
, Qnil
);
1516 mouse_moveto (XINT (x
), XINT (y
));
1524 static void make_frame_visible_1
P_ ((Lisp_Object
));
1526 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1528 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1529 If omitted, FRAME defaults to the currently selected frame. */)
1534 frame
= selected_frame
;
1536 CHECK_LIVE_FRAME (frame
);
1538 /* I think this should be done with a hook. */
1539 #ifdef HAVE_WINDOW_SYSTEM
1540 if (FRAME_WINDOW_P (XFRAME (frame
)))
1542 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1543 x_make_frame_visible (XFRAME (frame
));
1547 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1549 /* Make menu bar update for the Buffers and Frames menus. */
1550 windows_or_buffers_changed
++;
1555 /* Update the display_time slot of the buffers shown in WINDOW
1556 and all its descendents. */
1559 make_frame_visible_1 (window
)
1564 for (;!NILP (window
); window
= w
->next
)
1566 w
= XWINDOW (window
);
1568 if (!NILP (w
->buffer
))
1569 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1571 if (!NILP (w
->vchild
))
1572 make_frame_visible_1 (w
->vchild
);
1573 if (!NILP (w
->hchild
))
1574 make_frame_visible_1 (w
->hchild
);
1578 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1580 doc
: /* Make the frame FRAME invisible (assuming it is an X window).
1581 If omitted, FRAME defaults to the currently selected frame.
1582 Normally you may not make FRAME invisible if all other frames are invisible,
1583 but if the second optional argument FORCE is non-nil, you may do so. */)
1585 Lisp_Object frame
, force
;
1588 frame
= selected_frame
;
1590 CHECK_LIVE_FRAME (frame
);
1592 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1593 error ("Attempt to make invisible the sole visible or iconified frame");
1595 #if 0 /* This isn't logically necessary, and it can do GC. */
1596 /* Don't let the frame remain selected. */
1597 if (EQ (frame
, selected_frame
))
1598 do_switch_frame (next_frame (frame
, Qt
), 0, 0)
1601 /* Don't allow minibuf_window to remain on a deleted frame. */
1602 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1604 struct frame
*sf
= XFRAME (selected_frame
);
1605 Fset_window_buffer (sf
->minibuffer_window
,
1606 XWINDOW (minibuf_window
)->buffer
);
1607 minibuf_window
= sf
->minibuffer_window
;
1610 /* I think this should be done with a hook. */
1611 #ifdef HAVE_WINDOW_SYSTEM
1612 if (FRAME_WINDOW_P (XFRAME (frame
)))
1613 x_make_frame_invisible (XFRAME (frame
));
1616 /* Make menu bar update for the Buffers and Frames menus. */
1617 windows_or_buffers_changed
++;
1622 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1624 doc
: /* Make the frame FRAME into an icon.
1625 If omitted, FRAME defaults to the currently selected frame. */)
1630 frame
= selected_frame
;
1632 CHECK_LIVE_FRAME (frame
);
1634 #if 0 /* This isn't logically necessary, and it can do GC. */
1635 /* Don't let the frame remain selected. */
1636 if (EQ (frame
, selected_frame
))
1637 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1640 /* Don't allow minibuf_window to remain on a deleted frame. */
1641 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1643 struct frame
*sf
= XFRAME (selected_frame
);
1644 Fset_window_buffer (sf
->minibuffer_window
,
1645 XWINDOW (minibuf_window
)->buffer
);
1646 minibuf_window
= sf
->minibuffer_window
;
1649 /* I think this should be done with a hook. */
1650 #ifdef HAVE_WINDOW_SYSTEM
1651 if (FRAME_WINDOW_P (XFRAME (frame
)))
1652 x_iconify_frame (XFRAME (frame
));
1655 /* Make menu bar update for the Buffers and Frames menus. */
1656 windows_or_buffers_changed
++;
1661 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1663 doc
: /* Return t if FRAME is now \"visible\" (actually in use for display).
1664 A frame that is not \"visible\" is not updated and, if it works through
1665 a window system, it may not show at all.
1666 Return the symbol `icon' if frame is visible only as an icon. */)
1670 CHECK_LIVE_FRAME (frame
);
1672 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1674 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1676 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1681 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1683 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1686 Lisp_Object tail
, frame
;
1691 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1693 frame
= XCAR (tail
);
1694 if (!FRAMEP (frame
))
1697 if (FRAME_VISIBLE_P (f
))
1698 value
= Fcons (frame
, value
);
1704 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1705 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1706 If FRAME is invisible, make it visible.
1707 If you don't specify a frame, the selected frame is used.
1708 If Emacs is displaying on an ordinary terminal or some other device which
1709 doesn't support multiple overlapping frames, this function does nothing. */)
1714 frame
= selected_frame
;
1716 CHECK_LIVE_FRAME (frame
);
1718 /* Do like the documentation says. */
1719 Fmake_frame_visible (frame
);
1721 if (frame_raise_lower_hook
)
1722 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1727 /* Should we have a corresponding function called Flower_Power? */
1728 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1729 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1730 If you don't specify a frame, the selected frame is used.
1731 If Emacs is displaying on an ordinary terminal or some other device which
1732 doesn't support multiple overlapping frames, this function does nothing. */)
1737 frame
= selected_frame
;
1739 CHECK_LIVE_FRAME (frame
);
1741 if (frame_raise_lower_hook
)
1742 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1748 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1750 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1751 In other words, switch-frame events caused by events in FRAME will
1752 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1753 FOCUS-FRAME after reading an event typed at FRAME.
1755 If FOCUS-FRAME is omitted or nil, any existing redirection is
1756 cancelled, and the frame again receives its own keystrokes.
1758 Focus redirection is useful for temporarily redirecting keystrokes to
1759 a surrogate minibuffer frame when a frame doesn't have its own
1762 A frame's focus redirection can be changed by select-frame. If frame
1763 FOO is selected, and then a different frame BAR is selected, any
1764 frames redirecting their focus to FOO are shifted to redirect their
1765 focus to BAR. This allows focus redirection to work properly when the
1766 user switches from one frame to another using `select-window'.
1768 This means that a frame whose focus is redirected to itself is treated
1769 differently from a frame whose focus is redirected to nil; the former
1770 is affected by select-frame, while the latter is not.
1772 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1773 (frame
, focus_frame
)
1774 Lisp_Object frame
, focus_frame
;
1776 /* Note that we don't check for a live frame here. It's reasonable
1777 to redirect the focus of a frame you're about to delete, if you
1778 know what other frame should receive those keystrokes. */
1779 CHECK_FRAME (frame
);
1781 if (! NILP (focus_frame
))
1782 CHECK_LIVE_FRAME (focus_frame
);
1784 XFRAME (frame
)->focus_frame
= focus_frame
;
1786 if (frame_rehighlight_hook
)
1787 (*frame_rehighlight_hook
) (XFRAME (frame
));
1793 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1794 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1795 This returns nil if FRAME's focus is not redirected.
1796 See `redirect-frame-focus'. */)
1800 CHECK_LIVE_FRAME (frame
);
1802 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1807 /* Return the value of frame parameter PROP in frame FRAME. */
1810 get_frame_param (frame
, prop
)
1811 register struct frame
*frame
;
1814 register Lisp_Object tem
;
1816 tem
= Fassq (prop
, frame
->param_alist
);
1822 /* Return the buffer-predicate of the selected frame. */
1825 frame_buffer_predicate (frame
)
1828 return XFRAME (frame
)->buffer_predicate
;
1831 /* Return the buffer-list of the selected frame. */
1834 frame_buffer_list (frame
)
1837 return XFRAME (frame
)->buffer_list
;
1840 /* Set the buffer-list of the selected frame. */
1843 set_frame_buffer_list (frame
, list
)
1844 Lisp_Object frame
, list
;
1846 XFRAME (frame
)->buffer_list
= list
;
1849 /* Discard BUFFER from the buffer-list of each frame. */
1852 frames_discard_buffer (buffer
)
1855 Lisp_Object frame
, tail
;
1857 FOR_EACH_FRAME (tail
, frame
)
1859 XFRAME (frame
)->buffer_list
1860 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1864 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1865 If the alist already has an element for PROP, we change it. */
1868 store_in_alist (alistptr
, prop
, val
)
1869 Lisp_Object
*alistptr
, val
;
1872 register Lisp_Object tem
;
1874 tem
= Fassq (prop
, *alistptr
);
1876 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1882 frame_name_fnn_p (str
, len
)
1886 if (len
> 1 && str
[0] == 'F')
1890 strtol (str
+ 1, &end_ptr
, 10);
1892 if (end_ptr
== str
+ len
)
1898 /* Set the name of the terminal frame. Also used by MSDOS frames.
1899 Modeled after x_set_name which is used for WINDOW frames. */
1902 set_term_frame_name (f
, name
)
1906 f
->explicit_name
= ! NILP (name
);
1908 /* If NAME is nil, set the name to F<num>. */
1913 /* Check for no change needed in this very common case
1914 before we do any consing. */
1915 if (frame_name_fnn_p (SDATA (f
->name
),
1919 terminal_frame_count
++;
1920 sprintf (namebuf
, "F%d", terminal_frame_count
);
1921 name
= build_string (namebuf
);
1925 CHECK_STRING (name
);
1927 /* Don't change the name if it's already NAME. */
1928 if (! NILP (Fstring_equal (name
, f
->name
)))
1931 /* Don't allow the user to set the frame name to F<num>, so it
1932 doesn't clash with the names we generate for terminal frames. */
1933 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
1934 error ("Frame names of the form F<num> are usurped by Emacs");
1938 update_mode_lines
= 1;
1942 store_frame_param (f
, prop
, val
)
1944 Lisp_Object prop
, val
;
1946 register Lisp_Object old_alist_elt
;
1948 /* The buffer-alist parameter is stored in a special place and is
1949 not in the alist. */
1950 if (EQ (prop
, Qbuffer_list
))
1952 f
->buffer_list
= val
;
1956 /* If PROP is a symbol which is supposed to have frame-local values,
1957 and it is set up based on this frame, switch to the global
1958 binding. That way, we can create or alter the frame-local binding
1959 without messing up the symbol's status. */
1962 Lisp_Object valcontents
;
1963 valcontents
= SYMBOL_VALUE (prop
);
1964 if ((BUFFER_LOCAL_VALUEP (valcontents
)
1965 || SOME_BUFFER_LOCAL_VALUEP (valcontents
))
1966 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
1967 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
1968 swap_in_global_binding (prop
);
1972 /* The tty color mode needs to be set before the frame's parameter
1973 alist is updated with the new value, because set_tty_color_mode
1974 wants to look at the old mode. */
1975 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
))
1976 set_tty_color_mode (f
, val
);
1979 /* Update the frame parameter alist. */
1980 old_alist_elt
= Fassq (prop
, f
->param_alist
);
1981 if (EQ (old_alist_elt
, Qnil
))
1982 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
1984 Fsetcdr (old_alist_elt
, val
);
1986 /* Update some other special parameters in their special places
1987 in addition to the alist. */
1989 if (EQ (prop
, Qbuffer_predicate
))
1990 f
->buffer_predicate
= val
;
1992 if (! FRAME_WINDOW_P (f
))
1994 if (EQ (prop
, Qmenu_bar_lines
))
1995 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
1996 else if (EQ (prop
, Qname
))
1997 set_term_frame_name (f
, val
);
2000 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2002 if (! MINI_WINDOW_P (XWINDOW (val
)))
2003 error ("Surrogate minibuffer windows must be minibuffer windows.");
2005 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2006 && !EQ (val
, f
->minibuffer_window
))
2007 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2009 /* Install the chosen minibuffer window, with proper buffer. */
2010 f
->minibuffer_window
= val
;
2014 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2015 doc
: /* Return the parameters-alist of frame FRAME.
2016 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2017 The meaningful PARMs depend on the kind of frame.
2018 If FRAME is omitted, return information on the currently selected frame. */)
2025 struct gcpro gcpro1
;
2028 frame
= selected_frame
;
2030 CHECK_FRAME (frame
);
2033 if (!FRAME_LIVE_P (f
))
2036 alist
= Fcopy_alist (f
->param_alist
);
2039 if (!FRAME_WINDOW_P (f
))
2041 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2042 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2045 /* If the frame's parameter alist says the colors are
2046 unspecified and reversed, take the frame's background pixel
2047 for foreground and vice versa. */
2048 elt
= Fassq (Qforeground_color
, alist
);
2049 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2051 if (strncmp (SDATA (XCDR (elt
)),
2053 SCHARS (XCDR (elt
))) == 0)
2054 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2055 else if (strncmp (SDATA (XCDR (elt
)),
2057 SCHARS (XCDR (elt
))) == 0)
2058 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2061 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2062 elt
= Fassq (Qbackground_color
, alist
);
2063 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2065 if (strncmp (SDATA (XCDR (elt
)),
2067 SCHARS (XCDR (elt
))) == 0)
2068 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2069 else if (strncmp (SDATA (XCDR (elt
)),
2071 SCHARS (XCDR (elt
))) == 0)
2072 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2075 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2076 store_in_alist (&alist
, intern ("font"),
2077 build_string (FRAME_MSDOS_P (f
)
2079 : FRAME_W32_P (f
) ? "w32term"
2082 store_in_alist (&alist
, Qname
, f
->name
);
2083 height
= (FRAME_NEW_HEIGHT (f
) ? FRAME_NEW_HEIGHT (f
) : FRAME_HEIGHT (f
));
2084 store_in_alist (&alist
, Qheight
, make_number (height
));
2085 width
= (FRAME_NEW_WIDTH (f
) ? FRAME_NEW_WIDTH (f
) : FRAME_WIDTH (f
));
2086 store_in_alist (&alist
, Qwidth
, make_number (width
));
2087 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2088 store_in_alist (&alist
, Qminibuffer
,
2089 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2090 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2091 : FRAME_MINIBUF_WINDOW (f
)));
2092 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2093 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2095 /* I think this should be done with a hook. */
2096 #ifdef HAVE_WINDOW_SYSTEM
2097 if (FRAME_WINDOW_P (f
))
2098 x_report_frame_params (f
, &alist
);
2102 /* This ought to be correct in f->param_alist for an X frame. */
2104 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2105 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2113 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2114 doc
: /* Return FRAME's value for parameter PARAMETER.
2115 If FRAME is nil, describe the currently selected frame. */)
2117 Lisp_Object frame
, parameter
;
2123 frame
= selected_frame
;
2125 CHECK_FRAME (frame
);
2126 CHECK_SYMBOL (parameter
);
2131 if (FRAME_LIVE_P (f
))
2133 /* Avoid consing in frequent cases. */
2134 if (EQ (parameter
, Qname
))
2136 #ifdef HAVE_X_WINDOWS
2137 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2138 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2139 #endif /* HAVE_X_WINDOWS */
2140 else if (EQ (parameter
, Qbackground_color
)
2141 || EQ (parameter
, Qforeground_color
))
2143 value
= Fassq (parameter
, f
->param_alist
);
2146 value
= XCDR (value
);
2147 /* Fframe_parameters puts the actual fg/bg color names,
2148 even if f->param_alist says otherwise. This is
2149 important when param_alist's notion of colors is
2150 "unspecified". We need to do the same here. */
2151 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2153 const char *color_name
;
2156 if (EQ (parameter
, Qbackground_color
))
2158 color_name
= SDATA (value
);
2159 csz
= SCHARS (value
);
2160 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2161 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2162 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2163 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2165 else if (EQ (parameter
, Qforeground_color
))
2167 color_name
= SDATA (value
);
2168 csz
= SCHARS (value
);
2169 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2170 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2171 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2172 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2177 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2179 else if (EQ (parameter
, Qdisplay_type
)
2180 || EQ (parameter
, Qbackground_mode
))
2181 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2183 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2190 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2191 Smodify_frame_parameters
, 2, 2, 0,
2192 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2193 If FRAME is nil, it defaults to the selected frame.
2194 ALIST is an alist of parameters to change and their new values.
2195 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2196 The meaningful PARMs depend on the kind of frame.
2197 Undefined PARMs are ignored, but stored in the frame's parameter list
2198 so that `frame-parameters' will return them.
2200 The value of frame parameter FOO can also be accessed
2201 as a frame-local binding for the variable FOO, if you have
2202 enabled such bindings for that variable with `make-variable-frame-local'. */)
2204 Lisp_Object frame
, alist
;
2207 register Lisp_Object tail
, prop
, val
;
2208 int count
= SPECPDL_INDEX ();
2210 /* Bind this to t to inhibit initialization of the default face from
2211 X resources in face-set-after-frame-default. If we don't inhibit
2212 this, modifying the `font' frame parameter, for example, while
2213 there is a `default.attributeFont' X resource, won't work,
2214 because `default's font is reset to the value of the X resource
2215 and that resets the `font' frame parameter. */
2216 specbind (Qinhibit_default_face_x_resources
, Qt
);
2218 if (EQ (frame
, Qnil
))
2219 frame
= selected_frame
;
2220 CHECK_LIVE_FRAME (frame
);
2223 /* I think this should be done with a hook. */
2224 #ifdef HAVE_WINDOW_SYSTEM
2225 if (FRAME_WINDOW_P (f
))
2226 x_set_frame_parameters (f
, alist
);
2230 if (FRAME_MSDOS_P (f
))
2231 IT_set_frame_parameters (f
, alist
);
2236 int length
= XINT (Flength (alist
));
2239 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2241 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2243 /* Extract parm names and values into those vectors. */
2246 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2251 parms
[i
] = Fcar (elt
);
2252 values
[i
] = Fcdr (elt
);
2256 /* Now process them in reverse of specified order. */
2257 for (i
--; i
>= 0; i
--)
2261 store_frame_param (f
, prop
, val
);
2265 return unbind_to (count
, Qnil
);
2268 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2270 doc
: /* Height in pixels of a line in the font in frame FRAME.
2271 If FRAME is omitted, the selected frame is used.
2272 For a terminal frame, the value is always 1. */)
2279 frame
= selected_frame
;
2280 CHECK_FRAME (frame
);
2283 #ifdef HAVE_WINDOW_SYSTEM
2284 if (FRAME_WINDOW_P (f
))
2285 return make_number (x_char_height (f
));
2288 return make_number (1);
2292 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2294 doc
: /* Width in pixels of characters in the font in frame FRAME.
2295 If FRAME is omitted, the selected frame is used.
2296 The width is the same for all characters, because
2297 currently Emacs supports only fixed-width fonts.
2298 For a terminal screen, the value is always 1. */)
2305 frame
= selected_frame
;
2306 CHECK_FRAME (frame
);
2309 #ifdef HAVE_WINDOW_SYSTEM
2310 if (FRAME_WINDOW_P (f
))
2311 return make_number (x_char_width (f
));
2314 return make_number (1);
2317 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2318 Sframe_pixel_height
, 0, 1, 0,
2319 doc
: /* Return a FRAME's height in pixels.
2320 This counts only the height available for text lines,
2321 not menu bars on window-system Emacs frames.
2322 For a terminal frame, the result really gives the height in characters.
2323 If FRAME is omitted, the selected frame is used. */)
2330 frame
= selected_frame
;
2331 CHECK_FRAME (frame
);
2334 #ifdef HAVE_WINDOW_SYSTEM
2335 if (FRAME_WINDOW_P (f
))
2336 return make_number (x_pixel_height (f
));
2339 return make_number (FRAME_HEIGHT (f
));
2342 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2343 Sframe_pixel_width
, 0, 1, 0,
2344 doc
: /* Return FRAME's width in pixels.
2345 For a terminal frame, the result really gives the width in characters.
2346 If FRAME is omitted, the selected frame is used. */)
2353 frame
= selected_frame
;
2354 CHECK_FRAME (frame
);
2357 #ifdef HAVE_WINDOW_SYSTEM
2358 if (FRAME_WINDOW_P (f
))
2359 return make_number (x_pixel_width (f
));
2362 return make_number (FRAME_WIDTH (f
));
2365 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2366 doc
: /* Specify that the frame FRAME has LINES lines.
2367 Optional third arg non-nil means that redisplay should use LINES lines
2368 but that the idea of the actual height of the frame should not be changed. */)
2369 (frame
, lines
, pretend
)
2370 Lisp_Object frame
, lines
, pretend
;
2372 register struct frame
*f
;
2374 CHECK_NUMBER (lines
);
2376 frame
= selected_frame
;
2377 CHECK_LIVE_FRAME (frame
);
2380 /* I think this should be done with a hook. */
2381 #ifdef HAVE_WINDOW_SYSTEM
2382 if (FRAME_WINDOW_P (f
))
2384 if (XINT (lines
) != f
->height
)
2385 x_set_window_size (f
, 1, f
->width
, XINT (lines
));
2386 do_pending_window_change (0);
2390 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2394 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2395 doc
: /* Specify that the frame FRAME has COLS columns.
2396 Optional third arg non-nil means that redisplay should use COLS columns
2397 but that the idea of the actual width of the frame should not be changed. */)
2398 (frame
, cols
, pretend
)
2399 Lisp_Object frame
, cols
, pretend
;
2401 register struct frame
*f
;
2402 CHECK_NUMBER (cols
);
2404 frame
= selected_frame
;
2405 CHECK_LIVE_FRAME (frame
);
2408 /* I think this should be done with a hook. */
2409 #ifdef HAVE_WINDOW_SYSTEM
2410 if (FRAME_WINDOW_P (f
))
2412 if (XINT (cols
) != f
->width
)
2413 x_set_window_size (f
, 1, XINT (cols
), f
->height
);
2414 do_pending_window_change (0);
2418 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2422 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2423 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2425 Lisp_Object frame
, cols
, rows
;
2427 register struct frame
*f
;
2429 CHECK_LIVE_FRAME (frame
);
2430 CHECK_NUMBER (cols
);
2431 CHECK_NUMBER (rows
);
2434 /* I think this should be done with a hook. */
2435 #ifdef HAVE_WINDOW_SYSTEM
2436 if (FRAME_WINDOW_P (f
))
2438 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
2439 || FRAME_NEW_HEIGHT (f
) || FRAME_NEW_WIDTH (f
))
2440 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2441 do_pending_window_change (0);
2445 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2450 DEFUN ("set-frame-position", Fset_frame_position
,
2451 Sset_frame_position
, 3, 3, 0,
2452 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2453 This is actually the position of the upper left corner of the frame.
2454 Negative values for XOFFSET or YOFFSET are interpreted relative to
2455 the rightmost or bottommost possible position (that stays within the screen). */)
2456 (frame
, xoffset
, yoffset
)
2457 Lisp_Object frame
, xoffset
, yoffset
;
2459 register struct frame
*f
;
2461 CHECK_LIVE_FRAME (frame
);
2462 CHECK_NUMBER (xoffset
);
2463 CHECK_NUMBER (yoffset
);
2466 /* I think this should be done with a hook. */
2467 #ifdef HAVE_WINDOW_SYSTEM
2468 if (FRAME_WINDOW_P (f
))
2469 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2476 /***********************************************************************
2478 ***********************************************************************/
2480 /* Connect the frame-parameter names for X frames
2481 to the ways of passing the parameter values to the window system.
2483 The name of a parameter, as a Lisp symbol,
2484 has an `x-frame-parameter' property which is an integer in Lisp
2485 that is an index in this table. */
2487 struct frame_parm_table
{
2489 Lisp_Object
*variable
;
2492 static struct frame_parm_table frame_parms
[] =
2494 {"auto-raise", &Qauto_raise
},
2495 {"auto-lower", &Qauto_lower
},
2496 {"background-color", 0},
2497 {"border-color", &Qborder_color
},
2498 {"border-width", &Qborder_width
},
2499 {"cursor-color", &Qcursor_color
},
2500 {"cursor-type", &Qcursor_type
},
2502 {"foreground-color", 0},
2503 {"icon-name", &Qicon_name
},
2504 {"icon-type", &Qicon_type
},
2505 {"internal-border-width", &Qinternal_border_width
},
2506 {"menu-bar-lines", &Qmenu_bar_lines
},
2507 {"mouse-color", &Qmouse_color
},
2509 {"scroll-bar-width", &Qscroll_bar_width
},
2511 {"unsplittable", &Qunsplittable
},
2512 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2513 {"visibility", &Qvisibility
},
2514 {"tool-bar-lines", &Qtool_bar_lines
},
2515 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2516 {"scroll-bar-background", &Qscroll_bar_background
},
2517 {"screen-gamma", &Qscreen_gamma
},
2518 {"line-spacing", &Qline_spacing
},
2519 {"left-fringe", &Qleft_fringe
},
2520 {"right-fringe", &Qright_fringe
},
2521 {"wait-for-wm", &Qwait_for_wm
},
2522 {"fullscreen", &Qfullscreen
},
2525 #ifdef HAVE_WINDOW_SYSTEM
2527 extern Lisp_Object Qbox
;
2528 extern Lisp_Object Qtop
;
2530 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2531 wanted positions of the WM window (not emacs window).
2532 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2533 window (FRAME_X_WINDOW).
2537 x_fullscreen_adjust (f
, width
, height
, top_pos
, left_pos
)
2544 int newwidth
= f
->width
, newheight
= f
->height
;
2546 *top_pos
= FRAME_X_OUTPUT (f
)->top_pos
;
2547 *left_pos
= FRAME_X_OUTPUT (f
)->left_pos
;
2549 if (FRAME_X_OUTPUT (f
)->want_fullscreen
& FULLSCREEN_HEIGHT
)
2553 ph
= FRAME_X_DISPLAY_INFO (f
)->height
;
2554 newheight
= PIXEL_TO_CHAR_HEIGHT (f
, ph
);
2555 ph
= CHAR_TO_PIXEL_HEIGHT (f
, newheight
)
2556 - FRAME_X_OUTPUT (f
)->y_pixels_diff
;
2557 newheight
= PIXEL_TO_CHAR_HEIGHT (f
, ph
);
2561 if (FRAME_X_OUTPUT (f
)->want_fullscreen
& FULLSCREEN_WIDTH
)
2565 pw
= FRAME_X_DISPLAY_INFO (f
)->width
;
2566 newwidth
= PIXEL_TO_CHAR_WIDTH (f
, pw
);
2567 pw
= CHAR_TO_PIXEL_WIDTH (f
, newwidth
)
2568 - FRAME_X_OUTPUT (f
)->x_pixels_diff
;
2569 newwidth
= PIXEL_TO_CHAR_WIDTH (f
, pw
);
2574 *height
= newheight
;
2578 /* Really try to move where we want to be in case of fullscreen. Some WMs
2579 moves the window where we tell them. Some (mwm, twm) moves the outer
2580 window manager window there instead.
2581 Try to compensate for those WM here. */
2584 x_fullscreen_move (f
, new_top
, new_left
)
2589 if (new_top
!= FRAME_X_OUTPUT (f
)->top_pos
2590 || new_left
!= FRAME_X_OUTPUT (f
)->left_pos
)
2592 int move_x
= new_left
;
2593 int move_y
= new_top
;
2595 #ifdef HAVE_X_WINDOWS
2596 move_x
+= FRAME_X_OUTPUT (f
)->x_pixels_outer_diff
;
2597 move_y
+= FRAME_X_OUTPUT (f
)->y_pixels_outer_diff
;
2600 FRAME_X_OUTPUT (f
)->want_fullscreen
|= FULLSCREEN_MOVE_WAIT
;
2601 x_set_offset (f
, move_x
, move_y
, 1);
2605 /* Change the parameters of frame F as specified by ALIST.
2606 If a parameter is not specially recognized, do nothing special;
2607 otherwise call the `x_set_...' function for that parameter.
2608 Except for certain geometry properties, always call store_frame_param
2609 to store the new value in the parameter alist. */
2612 x_set_frame_parameters (f
, alist
)
2618 /* If both of these parameters are present, it's more efficient to
2619 set them both at once. So we wait until we've looked at the
2620 entire list before we set them. */
2624 Lisp_Object left
, top
;
2626 /* Same with these. */
2627 Lisp_Object icon_left
, icon_top
;
2629 /* Record in these vectors all the parms specified. */
2631 Lisp_Object
*values
;
2633 int left_no_change
= 0, top_no_change
= 0;
2634 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2635 int fullscreen_is_being_set
= 0;
2637 struct gcpro gcpro1
, gcpro2
;
2640 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2643 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2644 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2646 /* Extract parm names and values into those vectors. */
2649 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2654 parms
[i
] = Fcar (elt
);
2655 values
[i
] = Fcdr (elt
);
2658 /* TAIL and ALIST are not used again below here. */
2659 alist
= tail
= Qnil
;
2661 GCPRO2 (*parms
, *values
);
2665 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2666 because their values appear in VALUES and strings are not valid. */
2667 top
= left
= Qunbound
;
2668 icon_left
= icon_top
= Qunbound
;
2670 /* Provide default values for HEIGHT and WIDTH. */
2671 if (FRAME_NEW_WIDTH (f
))
2672 width
= FRAME_NEW_WIDTH (f
);
2674 width
= FRAME_WIDTH (f
);
2676 if (FRAME_NEW_HEIGHT (f
))
2677 height
= FRAME_NEW_HEIGHT (f
);
2679 height
= FRAME_HEIGHT (f
);
2681 /* Process foreground_color and background_color before anything else.
2682 They are independent of other properties, but other properties (e.g.,
2683 cursor_color) are dependent upon them. */
2684 /* Process default font as well, since fringe widths depends on it. */
2685 /* Also, process fullscreen, width and height depend upon that */
2686 for (p
= 0; p
< i
; p
++)
2688 Lisp_Object prop
, val
;
2692 if (EQ (prop
, Qforeground_color
)
2693 || EQ (prop
, Qbackground_color
)
2695 || EQ (prop
, Qfullscreen
))
2697 register Lisp_Object param_index
, old_value
;
2699 old_value
= get_frame_param (f
, prop
);
2700 fullscreen_is_being_set
|= EQ (prop
, Qfullscreen
);
2702 if (NILP (Fequal (val
, old_value
)))
2704 store_frame_param (f
, prop
, val
);
2706 param_index
= Fget (prop
, Qx_frame_parameter
);
2707 if (NATNUMP (param_index
)
2708 && (XFASTINT (param_index
)
2709 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2710 && rif
->frame_parm_handlers
[XINT (param_index
)])
2711 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2716 /* Now process them in reverse of specified order. */
2717 for (i
--; i
>= 0; i
--)
2719 Lisp_Object prop
, val
;
2724 if (EQ (prop
, Qwidth
) && NUMBERP (val
))
2725 width
= XFASTINT (val
);
2726 else if (EQ (prop
, Qheight
) && NUMBERP (val
))
2727 height
= XFASTINT (val
);
2728 else if (EQ (prop
, Qtop
))
2730 else if (EQ (prop
, Qleft
))
2732 else if (EQ (prop
, Qicon_top
))
2734 else if (EQ (prop
, Qicon_left
))
2736 else if (EQ (prop
, Qforeground_color
)
2737 || EQ (prop
, Qbackground_color
)
2739 || EQ (prop
, Qfullscreen
))
2740 /* Processed above. */
2744 register Lisp_Object param_index
, old_value
;
2746 old_value
= get_frame_param (f
, prop
);
2748 store_frame_param (f
, prop
, val
);
2750 param_index
= Fget (prop
, Qx_frame_parameter
);
2751 if (NATNUMP (param_index
)
2752 && (XFASTINT (param_index
)
2753 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2754 && rif
->frame_parm_handlers
[XINT (param_index
)])
2755 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2759 /* Don't die if just one of these was set. */
2760 if (EQ (left
, Qunbound
))
2763 if (FRAME_X_OUTPUT (f
)->left_pos
< 0)
2764 left
= Fcons (Qplus
, Fcons (make_number (FRAME_X_OUTPUT (f
)->left_pos
), Qnil
));
2766 XSETINT (left
, FRAME_X_OUTPUT (f
)->left_pos
);
2768 if (EQ (top
, Qunbound
))
2771 if (FRAME_X_OUTPUT (f
)->top_pos
< 0)
2772 top
= Fcons (Qplus
, Fcons (make_number (FRAME_X_OUTPUT (f
)->top_pos
), Qnil
));
2774 XSETINT (top
, FRAME_X_OUTPUT (f
)->top_pos
);
2777 /* If one of the icon positions was not set, preserve or default it. */
2778 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
2780 icon_left_no_change
= 1;
2781 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2782 if (NILP (icon_left
))
2783 XSETINT (icon_left
, 0);
2785 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
2787 icon_top_no_change
= 1;
2788 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2789 if (NILP (icon_top
))
2790 XSETINT (icon_top
, 0);
2794 /* MAC_TODO: fullscreen */
2795 if (FRAME_VISIBLE_P (f
) && fullscreen_is_being_set
)
2797 /* If the frame is visible already and the fullscreen parameter is
2798 being set, it is too late to set WM manager hints to specify
2800 Here we first get the width, height and position that applies to
2801 fullscreen. We then move the frame to the appropriate
2802 position. Resize of the frame is taken care of in the code after
2803 this if-statement. */
2804 int new_left
, new_top
;
2806 x_fullscreen_adjust (f
, &width
, &height
, &new_top
, &new_left
);
2807 x_fullscreen_move (f
, new_top
, new_left
);
2811 /* Don't set these parameters unless they've been explicitly
2812 specified. The window might be mapped or resized while we're in
2813 this function, and we don't want to override that unless the lisp
2814 code has asked for it.
2816 Don't set these parameters unless they actually differ from the
2817 window's current parameters; the window may not actually exist
2822 check_frame_size (f
, &height
, &width
);
2824 XSETFRAME (frame
, f
);
2826 if (width
!= FRAME_WIDTH (f
)
2827 || height
!= FRAME_HEIGHT (f
)
2828 || FRAME_NEW_HEIGHT (f
) || FRAME_NEW_WIDTH (f
))
2829 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2831 if ((!NILP (left
) || !NILP (top
))
2832 && ! (left_no_change
&& top_no_change
)
2833 && ! (NUMBERP (left
) && XINT (left
) == FRAME_X_OUTPUT (f
)->left_pos
2834 && NUMBERP (top
) && XINT (top
) == FRAME_X_OUTPUT (f
)->top_pos
))
2839 /* Record the signs. */
2840 FRAME_X_OUTPUT (f
)->size_hint_flags
&= ~ (XNegative
| YNegative
);
2841 if (EQ (left
, Qminus
))
2842 FRAME_X_OUTPUT (f
)->size_hint_flags
|= XNegative
;
2843 else if (INTEGERP (left
))
2845 leftpos
= XINT (left
);
2847 FRAME_X_OUTPUT (f
)->size_hint_flags
|= XNegative
;
2849 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2850 && CONSP (XCDR (left
))
2851 && INTEGERP (XCAR (XCDR (left
))))
2853 leftpos
= - XINT (XCAR (XCDR (left
)));
2854 FRAME_X_OUTPUT (f
)->size_hint_flags
|= XNegative
;
2856 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2857 && CONSP (XCDR (left
))
2858 && INTEGERP (XCAR (XCDR (left
))))
2860 leftpos
= XINT (XCAR (XCDR (left
)));
2863 if (EQ (top
, Qminus
))
2864 FRAME_X_OUTPUT (f
)->size_hint_flags
|= YNegative
;
2865 else if (INTEGERP (top
))
2867 toppos
= XINT (top
);
2869 FRAME_X_OUTPUT (f
)->size_hint_flags
|= YNegative
;
2871 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2872 && CONSP (XCDR (top
))
2873 && INTEGERP (XCAR (XCDR (top
))))
2875 toppos
= - XINT (XCAR (XCDR (top
)));
2876 FRAME_X_OUTPUT (f
)->size_hint_flags
|= YNegative
;
2878 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2879 && CONSP (XCDR (top
))
2880 && INTEGERP (XCAR (XCDR (top
))))
2882 toppos
= XINT (XCAR (XCDR (top
)));
2886 /* Store the numeric value of the position. */
2887 FRAME_X_OUTPUT (f
)->top_pos
= toppos
;
2888 FRAME_X_OUTPUT (f
)->left_pos
= leftpos
;
2890 FRAME_X_OUTPUT (f
)->win_gravity
= NorthWestGravity
;
2892 /* Actually set that position, and convert to absolute. */
2893 x_set_offset (f
, leftpos
, toppos
, -1);
2896 if ((!NILP (icon_left
) || !NILP (icon_top
))
2897 && ! (icon_left_no_change
&& icon_top_no_change
))
2898 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2905 /* Insert a description of internally-recorded parameters of frame X
2906 into the parameter alist *ALISTPTR that is to be given to the user.
2907 Only parameters that are specific to the X window system
2908 and whose values are not correctly recorded in the frame's
2909 param_alist need to be considered here. */
2912 x_report_frame_params (f
, alistptr
)
2914 Lisp_Object
*alistptr
;
2919 /* Represent negative positions (off the top or left screen edge)
2920 in a way that Fmodify_frame_parameters will understand correctly. */
2921 XSETINT (tem
, FRAME_X_OUTPUT (f
)->left_pos
);
2922 if (FRAME_X_OUTPUT (f
)->left_pos
>= 0)
2923 store_in_alist (alistptr
, Qleft
, tem
);
2925 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2927 XSETINT (tem
, FRAME_X_OUTPUT (f
)->top_pos
);
2928 if (FRAME_X_OUTPUT (f
)->top_pos
>= 0)
2929 store_in_alist (alistptr
, Qtop
, tem
);
2931 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2933 store_in_alist (alistptr
, Qborder_width
,
2934 make_number (FRAME_X_OUTPUT (f
)->border_width
));
2935 store_in_alist (alistptr
, Qinternal_border_width
,
2936 make_number (FRAME_X_OUTPUT (f
)->internal_border_width
));
2937 store_in_alist (alistptr
, Qleft_fringe
,
2938 make_number (FRAME_X_OUTPUT (f
)->left_fringe_width
));
2939 store_in_alist (alistptr
, Qright_fringe
,
2940 make_number (FRAME_X_OUTPUT (f
)->right_fringe_width
));
2941 store_in_alist (alistptr
, Qscroll_bar_width
,
2942 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2944 : FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) > 0
2945 ? make_number (FRAME_SCROLL_BAR_PIXEL_WIDTH (f
))
2946 /* nil means "use default width"
2947 for non-toolkit scroll bar.
2948 ruler-mode.el depends on this. */
2950 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
2951 store_in_alist (alistptr
, Qwindow_id
,
2952 build_string (buf
));
2953 #ifdef HAVE_X_WINDOWS
2954 #ifdef USE_X_TOOLKIT
2955 /* Tooltip frame may not have this widget. */
2956 if (FRAME_X_OUTPUT (f
)->widget
)
2958 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
2959 store_in_alist (alistptr
, Qouter_window_id
,
2960 build_string (buf
));
2962 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
2963 FRAME_SAMPLE_VISIBILITY (f
);
2964 store_in_alist (alistptr
, Qvisibility
,
2965 (FRAME_VISIBLE_P (f
) ? Qt
2966 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
2967 store_in_alist (alistptr
, Qdisplay
,
2968 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
2970 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
2973 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
2974 store_in_alist (alistptr
, Qparent_id
, tem
);
2978 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
2979 the previous value of that parameter, NEW_VALUE is the new value. */
2982 x_set_fullscreen (f
, new_value
, old_value
)
2984 Lisp_Object new_value
, old_value
;
2987 if (NILP (new_value
))
2988 FRAME_X_OUTPUT (f
)->want_fullscreen
= FULLSCREEN_NONE
;
2989 else if (EQ (new_value
, Qfullboth
))
2990 FRAME_X_OUTPUT (f
)->want_fullscreen
= FULLSCREEN_BOTH
;
2991 else if (EQ (new_value
, Qfullwidth
))
2992 FRAME_X_OUTPUT (f
)->want_fullscreen
= FULLSCREEN_WIDTH
;
2993 else if (EQ (new_value
, Qfullheight
))
2994 FRAME_X_OUTPUT (f
)->want_fullscreen
= FULLSCREEN_HEIGHT
;
2999 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3000 the previous value of that parameter, NEW_VALUE is the new value. */
3003 x_set_line_spacing (f
, new_value
, old_value
)
3005 Lisp_Object new_value
, old_value
;
3007 if (NILP (new_value
))
3008 f
->extra_line_spacing
= 0;
3009 else if (NATNUMP (new_value
))
3010 f
->extra_line_spacing
= XFASTINT (new_value
);
3012 Fsignal (Qerror
, Fcons (build_string ("Invalid line-spacing"),
3013 Fcons (new_value
, Qnil
)));
3014 if (FRAME_VISIBLE_P (f
))
3019 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3020 the previous value of that parameter, NEW_VALUE is the new value. */
3023 x_set_screen_gamma (f
, new_value
, old_value
)
3025 Lisp_Object new_value
, old_value
;
3027 if (NILP (new_value
))
3029 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3030 /* The value 0.4545 is the normal viewing gamma. */
3031 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3033 Fsignal (Qerror
, Fcons (build_string ("Invalid screen-gamma"),
3034 Fcons (new_value
, Qnil
)));
3036 clear_face_cache (0);
3041 x_set_font (f
, arg
, oldval
)
3043 Lisp_Object arg
, oldval
;
3046 Lisp_Object fontset_name
;
3048 int old_fontset
= FRAME_FONTSET(f
);
3052 fontset_name
= Fquery_fontset (arg
, Qnil
);
3055 result
= (STRINGP (fontset_name
)
3056 ? x_new_fontset (f
, SDATA (fontset_name
))
3057 : x_new_font (f
, SDATA (arg
)));
3060 if (EQ (result
, Qnil
))
3061 error ("Font `%s' is not defined", SDATA (arg
));
3062 else if (EQ (result
, Qt
))
3063 error ("The characters of the given font have varying widths");
3064 else if (STRINGP (result
))
3066 if (STRINGP (fontset_name
))
3068 /* Fontset names are built from ASCII font names, so the
3069 names may be equal despite there was a change. */
3070 if (old_fontset
== FRAME_FONTSET (f
))
3073 else if (!NILP (Fequal (result
, oldval
)))
3076 store_frame_param (f
, Qfont
, result
);
3077 recompute_basic_faces (f
);
3082 do_pending_window_change (0);
3084 /* Don't call `face-set-after-frame-default' when faces haven't been
3085 initialized yet. This is the case when called from
3086 Fx_create_frame. In that case, the X widget or window doesn't
3087 exist either, and we can end up in x_report_frame_params with a
3088 null widget which gives a segfault. */
3089 if (FRAME_FACE_CACHE (f
))
3091 XSETFRAME (frame
, f
);
3092 call1 (Qface_set_after_frame_default
, frame
);
3098 x_set_fringe_width (f
, new_value
, old_value
)
3100 Lisp_Object new_value
, old_value
;
3102 compute_fringe_widths (f
, 1);
3106 x_set_border_width (f
, arg
, oldval
)
3108 Lisp_Object arg
, oldval
;
3112 if (XINT (arg
) == FRAME_X_OUTPUT (f
)->border_width
)
3116 if (FRAME_X_WINDOW (f
) != 0)
3117 error ("Cannot change the border width of a window");
3118 #endif /* MAC_TODO */
3120 FRAME_X_OUTPUT (f
)->border_width
= XINT (arg
);
3124 x_set_internal_border_width (f
, arg
, oldval
)
3126 Lisp_Object arg
, oldval
;
3128 int old
= FRAME_X_OUTPUT (f
)->internal_border_width
;
3131 FRAME_X_OUTPUT (f
)->internal_border_width
= XINT (arg
);
3132 if (FRAME_X_OUTPUT (f
)->internal_border_width
< 0)
3133 FRAME_X_OUTPUT (f
)->internal_border_width
= 0;
3135 #ifdef USE_X_TOOLKIT
3136 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3137 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3140 if (FRAME_X_OUTPUT (f
)->internal_border_width
== old
)
3143 if (FRAME_X_WINDOW (f
) != 0)
3145 x_set_window_size (f
, 0, f
->width
, f
->height
);
3146 SET_FRAME_GARBAGED (f
);
3147 do_pending_window_change (0);
3150 SET_FRAME_GARBAGED (f
);
3154 x_set_visibility (f
, value
, oldval
)
3156 Lisp_Object value
, oldval
;
3159 XSETFRAME (frame
, f
);
3162 Fmake_frame_invisible (frame
, Qt
);
3163 else if (EQ (value
, Qicon
))
3164 Ficonify_frame (frame
);
3166 Fmake_frame_visible (frame
);
3170 x_set_autoraise (f
, arg
, oldval
)
3172 Lisp_Object arg
, oldval
;
3174 f
->auto_raise
= !EQ (Qnil
, arg
);
3178 x_set_autolower (f
, arg
, oldval
)
3180 Lisp_Object arg
, oldval
;
3182 f
->auto_lower
= !EQ (Qnil
, arg
);
3186 x_set_unsplittable (f
, arg
, oldval
)
3188 Lisp_Object arg
, oldval
;
3190 f
->no_split
= !NILP (arg
);
3194 x_set_vertical_scroll_bars (f
, arg
, oldval
)
3196 Lisp_Object arg
, oldval
;
3198 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3199 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3200 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3201 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3203 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3205 ? vertical_scroll_bar_none
3207 ? vertical_scroll_bar_left
3209 ? vertical_scroll_bar_right
3211 /* MS-Windows has scroll bars on the right by default. */
3212 : vertical_scroll_bar_right
3214 : vertical_scroll_bar_left
3218 /* We set this parameter before creating the X window for the
3219 frame, so we can get the geometry right from the start.
3220 However, if the window hasn't been created yet, we shouldn't
3221 call x_set_window_size. */
3222 if (FRAME_X_WINDOW (f
))
3223 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
3224 do_pending_window_change (0);
3229 x_set_scroll_bar_width (f
, arg
, oldval
)
3231 Lisp_Object arg
, oldval
;
3233 int wid
= FONT_WIDTH (FRAME_FONT (f
));
3237 x_set_scroll_bar_default_width (f
);
3239 if (FRAME_X_WINDOW (f
))
3240 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
3241 do_pending_window_change (0);
3243 else if (INTEGERP (arg
) && XINT (arg
) > 0
3244 && XFASTINT (arg
) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f
))
3246 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3247 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3249 FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) = XFASTINT (arg
);
3250 FRAME_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3251 if (FRAME_X_WINDOW (f
))
3252 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
3253 do_pending_window_change (0);
3256 change_frame_size (f
, 0, FRAME_WIDTH (f
), 0, 0, 0);
3257 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3258 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3263 /* Return non-nil if frame F wants a bitmap icon. */
3271 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3279 /* Subroutines of creating an X frame. */
3281 /* Make sure that Vx_resource_name is set to a reasonable value.
3282 Fix it up, or set it to `emacs' if it is too hopeless. */
3285 validate_x_resource_name ()
3288 /* Number of valid characters in the resource name. */
3290 /* Number of invalid characters in the resource name. */
3295 if (!STRINGP (Vx_resource_class
))
3296 Vx_resource_class
= build_string (EMACS_CLASS
);
3298 if (STRINGP (Vx_resource_name
))
3300 unsigned char *p
= SDATA (Vx_resource_name
);
3303 len
= SBYTES (Vx_resource_name
);
3305 /* Only letters, digits, - and _ are valid in resource names.
3306 Count the valid characters and count the invalid ones. */
3307 for (i
= 0; i
< len
; i
++)
3310 if (! ((c
>= 'a' && c
<= 'z')
3311 || (c
>= 'A' && c
<= 'Z')
3312 || (c
>= '0' && c
<= '9')
3313 || c
== '-' || c
== '_'))
3320 /* Not a string => completely invalid. */
3321 bad_count
= 5, good_count
= 0;
3323 /* If name is valid already, return. */
3327 /* If name is entirely invalid, or nearly so, use `emacs'. */
3329 || (good_count
== 1 && bad_count
> 0))
3331 Vx_resource_name
= build_string ("emacs");
3335 /* Name is partly valid. Copy it and replace the invalid characters
3336 with underscores. */
3338 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3340 for (i
= 0; i
< len
; i
++)
3342 int c
= SREF (new, i
);
3343 if (! ((c
>= 'a' && c
<= 'z')
3344 || (c
>= 'A' && c
<= 'Z')
3345 || (c
>= '0' && c
<= '9')
3346 || c
== '-' || c
== '_'))
3352 extern char *x_get_string_resource
P_ ((XrmDatabase
, char *, char *));
3353 extern Display_Info
*check_x_display_info
P_ ((Lisp_Object
));
3356 /* Get specified attribute from resource database RDB.
3357 See Fx_get_resource below for other parameters. */
3360 xrdb_get_resource (rdb
, attribute
, class, component
, subclass
)
3362 Lisp_Object attribute
, class, component
, subclass
;
3364 register char *value
;
3368 CHECK_STRING (attribute
);
3369 CHECK_STRING (class);
3371 if (!NILP (component
))
3372 CHECK_STRING (component
);
3373 if (!NILP (subclass
))
3374 CHECK_STRING (subclass
);
3375 if (NILP (component
) != NILP (subclass
))
3376 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3378 validate_x_resource_name ();
3380 /* Allocate space for the components, the dots which separate them,
3381 and the final '\0'. Make them big enough for the worst case. */
3382 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3383 + (STRINGP (component
)
3384 ? SBYTES (component
) : 0)
3385 + SBYTES (attribute
)
3388 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3390 + (STRINGP (subclass
)
3391 ? SBYTES (subclass
) : 0)
3394 /* Start with emacs.FRAMENAME for the name (the specific one)
3395 and with `Emacs' for the class key (the general one). */
3396 strcpy (name_key
, SDATA (Vx_resource_name
));
3397 strcpy (class_key
, SDATA (Vx_resource_class
));
3399 strcat (class_key
, ".");
3400 strcat (class_key
, SDATA (class));
3402 if (!NILP (component
))
3404 strcat (class_key
, ".");
3405 strcat (class_key
, SDATA (subclass
));
3407 strcat (name_key
, ".");
3408 strcat (name_key
, SDATA (component
));
3411 strcat (name_key
, ".");
3412 strcat (name_key
, SDATA (attribute
));
3414 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3416 if (value
!= (char *) 0)
3417 return build_string (value
);
3423 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3424 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3425 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3426 class, where INSTANCE is the name under which Emacs was invoked, or
3427 the name specified by the `-name' or `-rn' command-line arguments.
3429 The optional arguments COMPONENT and SUBCLASS add to the key and the
3430 class, respectively. You must specify both of them or neither.
3431 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3432 and the class is `Emacs.CLASS.SUBCLASS'. */)
3433 (attribute
, class, component
, subclass
)
3434 Lisp_Object attribute
, class, component
, subclass
;
3436 #ifdef HAVE_X_WINDOWS
3440 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3441 attribute
, class, component
, subclass
);
3444 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3447 display_x_get_resource (dpyinfo
, attribute
, class, component
, subclass
)
3448 Display_Info
*dpyinfo
;
3449 Lisp_Object attribute
, class, component
, subclass
;
3451 return xrdb_get_resource (dpyinfo
->xrdb
,
3452 attribute
, class, component
, subclass
);
3455 /* Used when C code wants a resource value. */
3458 x_get_resource_string (attribute
, class)
3459 char *attribute
, *class;
3463 struct frame
*sf
= SELECTED_FRAME ();
3465 /* Allocate space for the components, the dots which separate them,
3466 and the final '\0'. */
3467 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3468 + strlen (attribute
) + 2);
3469 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3470 + strlen (class) + 2);
3472 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3473 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3475 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3476 name_key
, class_key
);
3480 /* Return the value of parameter PARAM.
3482 First search ALIST, then Vdefault_frame_alist, then the X defaults
3483 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3485 Convert the resource to the type specified by desired_type.
3487 If no default is specified, return Qunbound. If you call
3488 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3489 and don't let it get stored in any Lisp-visible variables! */
3492 x_get_arg (dpyinfo
, alist
, param
, attribute
, class, type
)
3493 Display_Info
*dpyinfo
;
3494 Lisp_Object alist
, param
;
3497 enum resource_types type
;
3499 register Lisp_Object tem
;
3501 tem
= Fassq (param
, alist
);
3503 tem
= Fassq (param
, Vdefault_frame_alist
);
3508 tem
= display_x_get_resource (dpyinfo
,
3509 build_string (attribute
),
3510 build_string (class),
3518 case RES_TYPE_NUMBER
:
3519 return make_number (atoi (SDATA (tem
)));
3521 case RES_TYPE_FLOAT
:
3522 return make_float (atof (SDATA (tem
)));
3524 case RES_TYPE_BOOLEAN
:
3525 tem
= Fdowncase (tem
);
3526 if (!strcmp (SDATA (tem
), "on")
3527 || !strcmp (SDATA (tem
), "true"))
3532 case RES_TYPE_STRING
:
3535 case RES_TYPE_SYMBOL
:
3536 /* As a special case, we map the values `true' and `on'
3537 to Qt, and `false' and `off' to Qnil. */
3540 lower
= Fdowncase (tem
);
3541 if (!strcmp (SDATA (lower
), "on")
3542 || !strcmp (SDATA (lower
), "true"))
3544 else if (!strcmp (SDATA (lower
), "off")
3545 || !strcmp (SDATA (lower
), "false"))
3548 return Fintern (tem
, Qnil
);
3562 x_frame_get_arg (f
, alist
, param
, attribute
, class, type
)
3564 Lisp_Object alist
, param
;
3567 enum resource_types type
;
3569 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3570 alist
, param
, attribute
, class, type
);
3573 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3576 x_frame_get_and_record_arg (f
, alist
, param
, attribute
, class, type
)
3578 Lisp_Object alist
, param
;
3581 enum resource_types type
;
3585 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3586 attribute
, class, type
);
3588 store_frame_param (f
, param
, value
);
3594 /* Record in frame F the specified or default value according to ALIST
3595 of the parameter named PROP (a Lisp symbol).
3596 If no value is specified for PROP, look for an X default for XPROP
3597 on the frame named NAME.
3598 If that is not found either, use the value DEFLT. */
3601 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
3608 enum resource_types type
;
3612 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3613 if (EQ (tem
, Qunbound
))
3615 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3622 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3623 doc
: /* Parse an X-style geometry string STRING.
3624 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3625 The properties returned may include `top', `left', `height', and `width'.
3626 The value of `left' or `top' may be an integer,
3627 or a list (+ N) meaning N pixels relative to top/left corner,
3628 or a list (- N) meaning -N pixels relative to bottom/right corner. */)
3633 unsigned int width
, height
;
3636 CHECK_STRING (string
);
3638 geometry
= XParseGeometry ((char *) SDATA (string
),
3639 &x
, &y
, &width
, &height
);
3642 if (!!(geometry
& XValue
) != !!(geometry
& YValue
))
3643 error ("Must specify both x and y position, or neither");
3647 if (geometry
& XValue
)
3649 Lisp_Object element
;
3651 if (x
>= 0 && (geometry
& XNegative
))
3652 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3653 else if (x
< 0 && ! (geometry
& XNegative
))
3654 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3656 element
= Fcons (Qleft
, make_number (x
));
3657 result
= Fcons (element
, result
);
3660 if (geometry
& YValue
)
3662 Lisp_Object element
;
3664 if (y
>= 0 && (geometry
& YNegative
))
3665 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3666 else if (y
< 0 && ! (geometry
& YNegative
))
3667 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3669 element
= Fcons (Qtop
, make_number (y
));
3670 result
= Fcons (element
, result
);
3673 if (geometry
& WidthValue
)
3674 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3675 if (geometry
& HeightValue
)
3676 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3681 /* Calculate the desired size and position of frame F.
3682 Return the flags saying which aspects were specified.
3684 Also set the win_gravity and size_hint_flags of F.
3686 Adjust height for toolbar if TOOLBAR_P is 1.
3688 This function does not make the coordinates positive. */
3690 #define DEFAULT_ROWS 40
3691 #define DEFAULT_COLS 80
3694 x_figure_window_size (f
, parms
, toolbar_p
)
3699 register Lisp_Object tem0
, tem1
, tem2
;
3700 long window_prompting
= 0;
3701 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3703 /* Default values if we fall through.
3704 Actually, if that happens we should get
3705 window manager prompting. */
3706 SET_FRAME_WIDTH (f
, DEFAULT_COLS
);
3707 f
->height
= DEFAULT_ROWS
;
3708 /* Window managers expect that if program-specified
3709 positions are not (0,0), they're intentional, not defaults. */
3710 FRAME_X_OUTPUT (f
)->top_pos
= 0;
3711 FRAME_X_OUTPUT (f
)->left_pos
= 0;
3713 /* Ensure that old new_width and new_height will not override the
3715 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3716 FRAME_NEW_WIDTH (f
) = 0;
3717 FRAME_NEW_HEIGHT (f
) = 0;
3719 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3720 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3721 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3722 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3724 if (!EQ (tem0
, Qunbound
))
3726 CHECK_NUMBER (tem0
);
3727 f
->height
= XINT (tem0
);
3729 if (!EQ (tem1
, Qunbound
))
3731 CHECK_NUMBER (tem1
);
3732 SET_FRAME_WIDTH (f
, XINT (tem1
));
3734 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
3735 window_prompting
|= USSize
;
3737 window_prompting
|= PSize
;
3740 FRAME_X_OUTPUT (f
)->vertical_scroll_bar_extra
3741 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3743 #ifndef HAVE_X_WINDOWS
3744 /* +KFS: This was specific for W32 and MAC.. why? */
3745 : FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) > 0
3746 ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f
)
3748 : (FRAME_SCROLL_BAR_COLS (f
) * FONT_WIDTH (FRAME_X_OUTPUT (f
)->font
)));
3750 /* This used to be done _before_ calling x_figure_window_size, but
3751 since the height is reset here, this was really a no-op. I
3752 assume that moving it here does what Gerd intended (although he
3753 no longer can remember what that was... ++KFS, 2003-03-25. */
3755 /* Add the tool-bar height to the initial frame height so that the
3756 user gets a text display area of the size he specified with -g or
3757 via .Xdefaults. Later changes of the tool-bar height don't
3758 change the frame size. This is done so that users can create
3759 tall Emacs frames without having to guess how tall the tool-bar
3761 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
3763 int margin
, relief
, bar_height
;
3765 relief
= (tool_bar_button_relief
>= 0
3766 ? tool_bar_button_relief
3767 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
3769 if (INTEGERP (Vtool_bar_button_margin
)
3770 && XINT (Vtool_bar_button_margin
) > 0)
3771 margin
= XFASTINT (Vtool_bar_button_margin
);
3772 else if (CONSP (Vtool_bar_button_margin
)
3773 && INTEGERP (XCDR (Vtool_bar_button_margin
))
3774 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
3775 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
3779 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
3780 f
->height
+= (bar_height
+ CANON_Y_UNIT (f
) - 1) / CANON_Y_UNIT (f
);
3783 compute_fringe_widths (f
, 0);
3785 FRAME_X_OUTPUT (f
)->pixel_width
= CHAR_TO_PIXEL_WIDTH (f
, f
->width
);
3786 FRAME_X_OUTPUT (f
)->pixel_height
= CHAR_TO_PIXEL_HEIGHT (f
, f
->height
);
3788 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
3789 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
3790 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
3791 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3793 if (EQ (tem0
, Qminus
))
3795 FRAME_X_OUTPUT (f
)->top_pos
= 0;
3796 window_prompting
|= YNegative
;
3798 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
3799 && CONSP (XCDR (tem0
))
3800 && INTEGERP (XCAR (XCDR (tem0
))))
3802 FRAME_X_OUTPUT (f
)->top_pos
= - XINT (XCAR (XCDR (tem0
)));
3803 window_prompting
|= YNegative
;
3805 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
3806 && CONSP (XCDR (tem0
))
3807 && INTEGERP (XCAR (XCDR (tem0
))))
3809 FRAME_X_OUTPUT (f
)->top_pos
= XINT (XCAR (XCDR (tem0
)));
3811 else if (EQ (tem0
, Qunbound
))
3812 FRAME_X_OUTPUT (f
)->top_pos
= 0;
3815 CHECK_NUMBER (tem0
);
3816 FRAME_X_OUTPUT (f
)->top_pos
= XINT (tem0
);
3817 if (FRAME_X_OUTPUT (f
)->top_pos
< 0)
3818 window_prompting
|= YNegative
;
3821 if (EQ (tem1
, Qminus
))
3823 FRAME_X_OUTPUT (f
)->left_pos
= 0;
3824 window_prompting
|= XNegative
;
3826 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
3827 && CONSP (XCDR (tem1
))
3828 && INTEGERP (XCAR (XCDR (tem1
))))
3830 FRAME_X_OUTPUT (f
)->left_pos
= - XINT (XCAR (XCDR (tem1
)));
3831 window_prompting
|= XNegative
;
3833 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
3834 && CONSP (XCDR (tem1
))
3835 && INTEGERP (XCAR (XCDR (tem1
))))
3837 FRAME_X_OUTPUT (f
)->left_pos
= XINT (XCAR (XCDR (tem1
)));
3839 else if (EQ (tem1
, Qunbound
))
3840 FRAME_X_OUTPUT (f
)->left_pos
= 0;
3843 CHECK_NUMBER (tem1
);
3844 FRAME_X_OUTPUT (f
)->left_pos
= XINT (tem1
);
3845 if (FRAME_X_OUTPUT (f
)->left_pos
< 0)
3846 window_prompting
|= XNegative
;
3849 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
3850 window_prompting
|= USPosition
;
3852 window_prompting
|= PPosition
;
3855 if (FRAME_X_OUTPUT (f
)->want_fullscreen
!= FULLSCREEN_NONE
)
3860 /* It takes both for some WM:s to place it where we want */
3861 window_prompting
= USPosition
| PPosition
;
3862 x_fullscreen_adjust (f
, &width
, &height
, &top
, &left
);
3865 FRAME_X_OUTPUT (f
)->pixel_width
= CHAR_TO_PIXEL_WIDTH (f
, f
->width
);
3866 FRAME_X_OUTPUT (f
)->pixel_height
= CHAR_TO_PIXEL_HEIGHT (f
, f
->height
);
3867 FRAME_X_OUTPUT (f
)->left_pos
= left
;
3868 FRAME_X_OUTPUT (f
)->top_pos
= top
;
3871 if (window_prompting
& XNegative
)
3873 if (window_prompting
& YNegative
)
3874 FRAME_X_OUTPUT (f
)->win_gravity
= SouthEastGravity
;
3876 FRAME_X_OUTPUT (f
)->win_gravity
= NorthEastGravity
;
3880 if (window_prompting
& YNegative
)
3881 FRAME_X_OUTPUT (f
)->win_gravity
= SouthWestGravity
;
3883 FRAME_X_OUTPUT (f
)->win_gravity
= NorthWestGravity
;
3886 FRAME_X_OUTPUT (f
)->size_hint_flags
= window_prompting
;
3888 return window_prompting
;
3893 #endif /* HAVE_WINDOW_SYSTEM */
3897 /***********************************************************************
3899 ***********************************************************************/
3904 Qframep
= intern ("framep");
3905 staticpro (&Qframep
);
3906 Qframe_live_p
= intern ("frame-live-p");
3907 staticpro (&Qframe_live_p
);
3908 Qheight
= intern ("height");
3909 staticpro (&Qheight
);
3910 Qicon
= intern ("icon");
3912 Qminibuffer
= intern ("minibuffer");
3913 staticpro (&Qminibuffer
);
3914 Qmodeline
= intern ("modeline");
3915 staticpro (&Qmodeline
);
3916 Qonly
= intern ("only");
3918 Qwidth
= intern ("width");
3919 staticpro (&Qwidth
);
3920 Qgeometry
= intern ("geometry");
3921 staticpro (&Qgeometry
);
3922 Qicon_left
= intern ("icon-left");
3923 staticpro (&Qicon_left
);
3924 Qicon_top
= intern ("icon-top");
3925 staticpro (&Qicon_top
);
3926 Qleft
= intern ("left");
3928 Qright
= intern ("right");
3929 staticpro (&Qright
);
3930 Quser_position
= intern ("user-position");
3931 staticpro (&Quser_position
);
3932 Quser_size
= intern ("user-size");
3933 staticpro (&Quser_size
);
3934 Qwindow_id
= intern ("window-id");
3935 staticpro (&Qwindow_id
);
3936 #ifdef HAVE_X_WINDOWS
3937 Qouter_window_id
= intern ("outer-window-id");
3938 staticpro (&Qouter_window_id
);
3940 Qparent_id
= intern ("parent-id");
3941 staticpro (&Qparent_id
);
3944 Qw32
= intern ("w32");
3946 Qpc
= intern ("pc");
3948 Qmac
= intern ("mac");
3950 Qvisible
= intern ("visible");
3951 staticpro (&Qvisible
);
3952 Qbuffer_predicate
= intern ("buffer-predicate");
3953 staticpro (&Qbuffer_predicate
);
3954 Qbuffer_list
= intern ("buffer-list");
3955 staticpro (&Qbuffer_list
);
3956 Qdisplay_type
= intern ("display-type");
3957 staticpro (&Qdisplay_type
);
3958 Qbackground_mode
= intern ("background-mode");
3959 staticpro (&Qbackground_mode
);
3960 Qtty_color_mode
= intern ("tty-color-mode");
3961 staticpro (&Qtty_color_mode
);
3963 Qface_set_after_frame_default
= intern ("face-set-after-frame-default");
3964 staticpro (&Qface_set_after_frame_default
);
3966 Qfullwidth
= intern ("fullwidth");
3967 staticpro (&Qfullwidth
);
3968 Qfullheight
= intern ("fullheight");
3969 staticpro (&Qfullheight
);
3970 Qfullboth
= intern ("fullboth");
3971 staticpro (&Qfullboth
);
3972 Qx_resource_name
= intern ("x-resource-name");
3973 staticpro (&Qx_resource_name
);
3975 Qx_frame_parameter
= intern ("x-frame-parameter");
3976 staticpro (&Qx_frame_parameter
);
3981 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
3983 Lisp_Object v
= intern (frame_parms
[i
].name
);
3984 if (frame_parms
[i
].variable
)
3986 *frame_parms
[i
].variable
= v
;
3987 staticpro (frame_parms
[i
].variable
);
3989 Fput (v
, Qx_frame_parameter
, make_number (i
));
3993 #ifdef HAVE_WINDOW_SYSTEM
3994 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
3995 doc
: /* The name Emacs uses to look up X resources.
3996 `x-get-resource' uses this as the first component of the instance name
3997 when requesting resource values.
3998 Emacs initially sets `x-resource-name' to the name under which Emacs
3999 was invoked, or to the value specified with the `-name' or `-rn'
4000 switches, if present.
4002 It may be useful to bind this variable locally around a call
4003 to `x-get-resource'. See also the variable `x-resource-class'. */);
4004 Vx_resource_name
= Qnil
;
4006 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4007 doc
: /* The class Emacs uses to look up X resources.
4008 `x-get-resource' uses this as the first component of the instance class
4009 when requesting resource values.
4011 Emacs initially sets `x-resource-class' to "Emacs".
4013 Setting this variable permanently is not a reasonable thing to do,
4014 but binding this variable locally around a call to `x-get-resource'
4015 is a reasonable practice. See also the variable `x-resource-name'. */);
4016 Vx_resource_class
= build_string (EMACS_CLASS
);
4019 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4020 doc
: /* Alist of default values for frame creation.
4021 These may be set in your init file, like this:
4022 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))
4023 These override values given in window system configuration data,
4024 including X Windows' defaults database.
4025 For values specific to the first Emacs frame, see `initial-frame-alist'.
4026 For values specific to the separate minibuffer frame, see
4027 `minibuffer-frame-alist'.
4028 The `menu-bar-lines' element of the list controls whether new frames
4029 have menu bars; `menu-bar-mode' works by altering this element.
4030 Setting this variable does not affect existing frames, only new ones. */);
4031 Vdefault_frame_alist
= Qnil
;
4033 Qinhibit_default_face_x_resources
4034 = intern ("inhibit-default-face-x-resources");
4035 staticpro (&Qinhibit_default_face_x_resources
);
4037 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4038 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4040 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
4041 doc
: /* Non-nil if all of emacs is iconified and frame updates are not needed. */);
4042 Vemacs_iconified
= Qnil
;
4044 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4045 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4046 `mouse-position' calls this function, passing its usual return value as
4047 argument, and returns whatever this function returns.
4048 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4049 which need to do mouse handling at the Lisp level. */);
4050 Vmouse_position_function
= Qnil
;
4052 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4053 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4054 If the value is an integer, highlighting is only shown after moving the
4055 mouse, while keyboard input turns off the highlight even when the mouse
4056 is over the clickable text. However, the mouse shape still indicates
4057 when the mouse is over clickable text. */);
4058 Vmouse_highlight
= Qt
;
4060 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4061 doc
: /* Functions to be run before deleting a frame.
4062 The functions are run with one arg, the frame to be deleted.
4063 See `delete-frame'. */);
4064 Vdelete_frame_functions
= Qnil
;
4066 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4067 doc
: /* Minibufferless frames use this frame's minibuffer.
4069 Emacs cannot create minibufferless frames unless this is set to an
4070 appropriate surrogate.
4072 Emacs consults this variable only when creating minibufferless
4073 frames; once the frame is created, it sticks with its assigned
4074 minibuffer, no matter what this variable is set to. This means that
4075 this variable doesn't necessarily say anything meaningful about the
4076 current set of frames, or where the minibuffer is currently being
4079 This variable is local to the current terminal and cannot be buffer-local. */);
4081 staticpro (&Vframe_list
);
4083 defsubr (&Sactive_minibuffer_window
);
4085 defsubr (&Sframe_live_p
);
4086 defsubr (&Smake_terminal_frame
);
4087 defsubr (&Shandle_switch_frame
);
4088 defsubr (&Signore_event
);
4089 defsubr (&Sselect_frame
);
4090 defsubr (&Sselected_frame
);
4091 defsubr (&Swindow_frame
);
4092 defsubr (&Sframe_root_window
);
4093 defsubr (&Sframe_first_window
);
4094 defsubr (&Sframe_selected_window
);
4095 defsubr (&Sset_frame_selected_window
);
4096 defsubr (&Sframe_list
);
4097 defsubr (&Snext_frame
);
4098 defsubr (&Sprevious_frame
);
4099 defsubr (&Sdelete_frame
);
4100 defsubr (&Smouse_position
);
4101 defsubr (&Smouse_pixel_position
);
4102 defsubr (&Sset_mouse_position
);
4103 defsubr (&Sset_mouse_pixel_position
);
4105 defsubr (&Sframe_configuration
);
4106 defsubr (&Srestore_frame_configuration
);
4108 defsubr (&Smake_frame_visible
);
4109 defsubr (&Smake_frame_invisible
);
4110 defsubr (&Siconify_frame
);
4111 defsubr (&Sframe_visible_p
);
4112 defsubr (&Svisible_frame_list
);
4113 defsubr (&Sraise_frame
);
4114 defsubr (&Slower_frame
);
4115 defsubr (&Sredirect_frame_focus
);
4116 defsubr (&Sframe_focus
);
4117 defsubr (&Sframe_parameters
);
4118 defsubr (&Sframe_parameter
);
4119 defsubr (&Smodify_frame_parameters
);
4120 defsubr (&Sframe_char_height
);
4121 defsubr (&Sframe_char_width
);
4122 defsubr (&Sframe_pixel_height
);
4123 defsubr (&Sframe_pixel_width
);
4124 defsubr (&Sset_frame_height
);
4125 defsubr (&Sset_frame_width
);
4126 defsubr (&Sset_frame_size
);
4127 defsubr (&Sset_frame_position
);
4129 #ifdef HAVE_WINDOW_SYSTEM
4130 defsubr (&Sx_get_resource
);
4131 defsubr (&Sx_parse_geometry
);