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 /* The name we're using in resource queries. Most often "emacs". */
56 Lisp_Object Vx_resource_name
;
58 /* The application class we're using in resource queries.
61 Lisp_Object Vx_resource_class
;
64 Lisp_Object Qframep
, Qframe_live_p
;
65 Lisp_Object Qicon
, Qmodeline
;
67 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
;
69 Lisp_Object Qdisplay_type
;
70 Lisp_Object Qbackground_mode
;
71 Lisp_Object Qinhibit_default_face_x_resources
;
73 Lisp_Object Qx_frame_parameter
;
74 Lisp_Object Qx_resource_name
;
76 /* Frame parameters (set or reported). */
78 Lisp_Object Qauto_raise
, Qauto_lower
;
79 Lisp_Object Qborder_color
, Qborder_width
;
80 Lisp_Object Qcursor_color
, Qcursor_type
;
81 Lisp_Object Qgeometry
; /* Not used */
82 Lisp_Object Qheight
, Qwidth
;
83 Lisp_Object Qleft
, Qright
;
84 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
85 Lisp_Object Qinternal_border_width
;
86 Lisp_Object Qmouse_color
;
87 Lisp_Object Qminibuffer
;
88 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
89 Lisp_Object Qvisibility
;
90 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
91 Lisp_Object Qscreen_gamma
;
92 Lisp_Object Qline_spacing
;
93 Lisp_Object Quser_position
, Quser_size
;
94 Lisp_Object Qwait_for_wm
;
95 Lisp_Object Qwindow_id
;
97 Lisp_Object Qouter_window_id
;
99 Lisp_Object Qparent_id
;
100 Lisp_Object Qtitle
, Qname
;
101 Lisp_Object Qunsplittable
;
102 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
103 Lisp_Object Qleft_fringe
, Qright_fringe
;
104 Lisp_Object Qbuffer_predicate
, Qbuffer_list
;
105 Lisp_Object Qtty_color_mode
;
107 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
;
109 Lisp_Object Qface_set_after_frame_default
;
112 Lisp_Object Vterminal_frame
;
113 Lisp_Object Vdefault_frame_alist
;
114 Lisp_Object Vmouse_position_function
;
115 Lisp_Object Vmouse_highlight
;
116 Lisp_Object Vdelete_frame_functions
;
119 set_menu_bar_lines_1 (window
, n
)
123 struct window
*w
= XWINDOW (window
);
125 XSETFASTINT (w
->last_modified
, 0);
126 XSETFASTINT (w
->top
, XFASTINT (w
->top
) + n
);
127 XSETFASTINT (w
->height
, XFASTINT (w
->height
) - n
);
129 if (INTEGERP (w
->orig_top
))
130 XSETFASTINT (w
->orig_top
, XFASTINT (w
->orig_top
) + n
);
131 if (INTEGERP (w
->orig_height
))
132 XSETFASTINT (w
->orig_height
, XFASTINT (w
->orig_height
) - n
);
134 /* Handle just the top child in a vertical split. */
135 if (!NILP (w
->vchild
))
136 set_menu_bar_lines_1 (w
->vchild
, n
);
138 /* Adjust all children in a horizontal split. */
139 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
141 w
= XWINDOW (window
);
142 set_menu_bar_lines_1 (window
, n
);
147 set_menu_bar_lines (f
, value
, oldval
)
149 Lisp_Object value
, oldval
;
152 int olines
= FRAME_MENU_BAR_LINES (f
);
154 /* Right now, menu bars don't work properly in minibuf-only frames;
155 most of the commands try to apply themselves to the minibuffer
156 frame itself, and get an error because you can't switch buffers
157 in or split the minibuffer window. */
158 if (FRAME_MINIBUF_ONLY_P (f
))
161 if (INTEGERP (value
))
162 nlines
= XINT (value
);
166 if (nlines
!= olines
)
168 windows_or_buffers_changed
++;
169 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
170 FRAME_MENU_BAR_LINES (f
) = nlines
;
171 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
176 Lisp_Object Vemacs_iconified
;
177 Lisp_Object Vframe_list
;
179 struct x_output tty_display
;
181 extern Lisp_Object Vminibuffer_list
;
182 extern Lisp_Object
get_minibuffer ();
183 extern Lisp_Object
Fhandle_switch_frame ();
184 extern Lisp_Object
Fredirect_frame_focus ();
185 extern Lisp_Object
x_get_focus_frame ();
187 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
188 doc
: /* Return non-nil if OBJECT is a frame.
189 Value is t for a termcap frame (a character-only terminal),
190 `x' for an Emacs frame that is really an X window,
191 `w32' for an Emacs frame that is a window on MS-Windows display,
192 `mac' for an Emacs frame on a Macintosh display,
193 `pc' for a direct-write MS-DOS frame.
194 See also `frame-live-p'. */)
198 if (!FRAMEP (object
))
200 switch (XFRAME (object
)->output_method
)
204 case output_x_window
:
208 case output_msdos_raw
:
217 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
218 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
219 Value is nil if OBJECT is not a live frame. If object is a live
220 frame, the return value indicates what sort of output device it is
221 displayed on. See the documentation of `framep' for possible
226 return ((FRAMEP (object
)
227 && FRAME_LIVE_P (XFRAME (object
)))
237 register struct frame
*f
;
238 register Lisp_Object root_window
;
239 register Lisp_Object mini_window
;
241 f
= allocate_frame ();
242 XSETFRAME (frame
, f
);
244 f
->desired_matrix
= 0;
245 f
->current_matrix
= 0;
248 f
->glyphs_initialized_p
= 0;
249 f
->decode_mode_spec_buffer
= 0;
251 f
->async_visible
= 0;
252 f
->output_data
.nothing
= 0;
254 f
->async_iconified
= 0;
255 f
->wants_modeline
= 1;
260 f
->has_minibuffer
= mini_p
;
261 f
->focus_frame
= Qnil
;
262 f
->explicit_name
= 0;
263 f
->can_have_scroll_bars
= 0;
264 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
265 f
->param_alist
= Qnil
;
266 f
->scroll_bars
= Qnil
;
267 f
->condemned_scroll_bars
= Qnil
;
268 f
->face_alist
= Qnil
;
269 f
->face_cache
= NULL
;
270 f
->menu_bar_items
= Qnil
;
271 f
->menu_bar_vector
= Qnil
;
272 f
->menu_bar_items_used
= 0;
273 f
->buffer_predicate
= Qnil
;
274 f
->buffer_list
= Qnil
;
276 f
->kboard
= initial_kboard
;
280 f
->menu_bar_window
= Qnil
;
281 f
->tool_bar_window
= Qnil
;
282 f
->tool_bar_items
= Qnil
;
283 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
284 f
->n_tool_bar_items
= 0;
286 root_window
= make_window ();
289 mini_window
= make_window ();
290 XWINDOW (root_window
)->next
= mini_window
;
291 XWINDOW (mini_window
)->prev
= root_window
;
292 XWINDOW (mini_window
)->mini_p
= Qt
;
293 XWINDOW (mini_window
)->frame
= frame
;
294 f
->minibuffer_window
= mini_window
;
299 XWINDOW (root_window
)->next
= Qnil
;
300 f
->minibuffer_window
= Qnil
;
303 XWINDOW (root_window
)->frame
= frame
;
306 just so that there is "something there."
307 Correct size will be set up later with change_frame_size. */
309 SET_FRAME_WIDTH (f
, 10);
312 XSETFASTINT (XWINDOW (root_window
)->width
, 10);
313 XSETFASTINT (XWINDOW (root_window
)->height
, (mini_p
? 9 : 10));
317 XSETFASTINT (XWINDOW (mini_window
)->width
, 10);
318 XSETFASTINT (XWINDOW (mini_window
)->top
, 9);
319 XSETFASTINT (XWINDOW (mini_window
)->height
, 1);
322 /* Choose a buffer for the frame's root window. */
326 XWINDOW (root_window
)->buffer
= Qt
;
327 buf
= Fcurrent_buffer ();
328 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
329 a space), try to find another one. */
330 if (SREF (Fbuffer_name (buf
), 0) == ' ')
331 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
333 /* Use set_window_buffer, not Fset_window_buffer, and don't let
334 hooks be run by it. The reason is that the whole frame/window
335 arrangement is not yet fully intialized at this point. Windows
336 don't have the right size, glyph matrices aren't initialized
337 etc. Running Lisp functions at this point surely ends in a
339 set_window_buffer (root_window
, buf
, 0);
340 f
->buffer_list
= Fcons (buf
, Qnil
);
345 XWINDOW (mini_window
)->buffer
= Qt
;
346 set_window_buffer (mini_window
,
347 (NILP (Vminibuffer_list
)
349 : Fcar (Vminibuffer_list
)),
353 f
->root_window
= root_window
;
354 f
->selected_window
= root_window
;
355 /* Make sure this window seems more recently used than
356 a newly-created, never-selected window. */
357 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, ++window_select_count
);
362 #ifdef HAVE_WINDOW_SYSTEM
363 /* Make a frame using a separate minibuffer window on another frame.
364 MINI_WINDOW is the minibuffer window to use. nil means use the
365 default (the global minibuffer). */
368 make_frame_without_minibuffer (mini_window
, kb
, display
)
369 register Lisp_Object mini_window
;
373 register struct frame
*f
;
376 if (!NILP (mini_window
))
377 CHECK_LIVE_WINDOW (mini_window
);
380 if (!NILP (mini_window
)
381 && XFRAME (XWINDOW (mini_window
)->frame
)->kboard
!= kb
)
382 error ("frame and minibuffer must be on the same display");
385 /* Make a frame containing just a root window. */
388 if (NILP (mini_window
))
390 /* Use default-minibuffer-frame if possible. */
391 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
392 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
394 Lisp_Object frame_dummy
;
396 XSETFRAME (frame_dummy
, f
);
397 GCPRO1 (frame_dummy
);
398 /* If there's no minibuffer frame to use, create one. */
399 kb
->Vdefault_minibuffer_frame
=
400 call1 (intern ("make-initial-minibuffer-frame"), display
);
404 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
407 f
->minibuffer_window
= mini_window
;
409 /* Make the chosen minibuffer window display the proper minibuffer,
410 unless it is already showing a minibuffer. */
411 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
412 Fset_window_buffer (mini_window
,
413 (NILP (Vminibuffer_list
)
415 : Fcar (Vminibuffer_list
)));
419 /* Make a frame containing only a minibuffer window. */
422 make_minibuffer_frame ()
424 /* First make a frame containing just a root window, no minibuffer. */
426 register struct frame
*f
= make_frame (0);
427 register Lisp_Object mini_window
;
428 register Lisp_Object frame
;
430 XSETFRAME (frame
, f
);
435 f
->wants_modeline
= 0;
436 f
->has_minibuffer
= 1;
438 /* Now label the root window as also being the minibuffer.
439 Avoid infinite looping on the window chain by marking next pointer
442 mini_window
= f
->minibuffer_window
= f
->root_window
;
443 XWINDOW (mini_window
)->mini_p
= Qt
;
444 XWINDOW (mini_window
)->next
= Qnil
;
445 XWINDOW (mini_window
)->prev
= Qnil
;
446 XWINDOW (mini_window
)->frame
= frame
;
448 /* Put the proper buffer in that window. */
450 Fset_window_buffer (mini_window
,
451 (NILP (Vminibuffer_list
)
453 : Fcar (Vminibuffer_list
)));
456 #endif /* HAVE_WINDOW_SYSTEM */
458 /* Construct a frame that refers to the terminal (stdin and stdout). */
460 static int terminal_frame_count
;
463 make_terminal_frame ()
465 register struct frame
*f
;
472 initial_kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
473 init_kboard (initial_kboard
);
474 initial_kboard
->next_kboard
= all_kboards
;
475 all_kboards
= initial_kboard
;
479 /* The first call must initialize Vframe_list. */
480 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
485 XSETFRAME (frame
, f
);
486 Vframe_list
= Fcons (frame
, Vframe_list
);
488 terminal_frame_count
++;
489 sprintf (name
, "F%d", terminal_frame_count
);
490 f
->name
= build_string (name
);
492 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
493 f
->async_visible
= 1; /* Don't let visible be cleared later. */
495 f
->output_data
.x
= &the_only_x_display
;
496 if (!inhibit_window_system
497 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
498 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
500 f
->output_method
= output_msdos_raw
;
501 /* This initialization of foreground and background pixels is
502 only important for the initial frame created in temacs. If
503 we don't do that, we get black background and foreground in
504 the dumped Emacs because the_only_x_display is a static
505 variable, hence it is born all-zeroes, and zero is the code
506 for the black color. Other frames all inherit their pixels
507 from what's already in the_only_x_display. */
508 if ((!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
509 && f
->output_data
.x
->background_pixel
== 0
510 && f
->output_data
.x
->foreground_pixel
== 0)
512 f
->output_data
.x
->background_pixel
= FACE_TTY_DEFAULT_BG_COLOR
;
513 f
->output_data
.x
->foreground_pixel
= FACE_TTY_DEFAULT_FG_COLOR
;
517 f
->output_method
= output_termcap
;
520 f
->output_method
= output_termcap
;
521 f
->output_data
.x
= &tty_display
;
524 make_mac_terminal_frame (f
);
526 f
->output_data
.x
= &tty_display
;
528 FRAME_FOREGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_FG_COLOR
;
529 FRAME_BACKGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_BG_COLOR
;
532 #endif /* WINDOWSNT */
536 init_frame_faces (f
);
541 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
543 doc
: /* Create an additional terminal frame.
544 You can create multiple frames on a text-only terminal in this way.
545 Only the selected terminal frame is actually displayed.
546 This function takes one argument, an alist specifying frame parameters.
547 In practice, generally you don't need to specify any parameters.
548 Note that changing the size of one terminal frame automatically affects all. */)
553 Lisp_Object frame
, tem
;
554 struct frame
*sf
= SELECTED_FRAME ();
557 if (sf
->output_method
!= output_msdos_raw
558 && sf
->output_method
!= output_termcap
)
560 #else /* not MSDOS */
563 if (sf
->output_method
!= output_mac
)
564 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
566 if (sf
->output_method
!= output_termcap
)
567 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
569 #endif /* not MSDOS */
571 f
= make_terminal_frame ();
573 change_frame_size (f
, FRAME_HEIGHT (sf
),
574 FRAME_WIDTH (sf
), 0, 0, 0);
577 XSETFRAME (frame
, f
);
578 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
579 Fmodify_frame_parameters (frame
, parms
);
581 /* Make the frame face alist be frame-specific, so that each
582 frame could change its face definitions independently. */
583 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
584 /* Simple Fcopy_alist isn't enough, because we need the contents of
585 the vectors which are the CDRs of associations in face_alist to
586 be copied as well. */
587 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
588 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
593 /* Perform the switch to frame FRAME.
595 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
598 If TRACK is non-zero and the frame that currently has the focus
599 redirects its focus to the selected frame, redirect that focused
600 frame's focus to FRAME instead.
602 FOR_DELETION non-zero means that the selected frame is being
603 deleted, which includes the possibility that the frame's display
607 do_switch_frame (frame
, track
, for_deletion
)
609 int track
, for_deletion
;
611 struct frame
*sf
= SELECTED_FRAME ();
613 /* If FRAME is a switch-frame event, extract the frame we should
616 && EQ (XCAR (frame
), Qswitch_frame
)
617 && CONSP (XCDR (frame
)))
618 frame
= XCAR (XCDR (frame
));
620 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
621 a switch-frame event to arrive after a frame is no longer live,
622 especially when deleting the initial frame during startup. */
624 if (! FRAME_LIVE_P (XFRAME (frame
)))
627 if (sf
== XFRAME (frame
))
630 /* This is too greedy; it causes inappropriate focus redirection
631 that's hard to get rid of. */
633 /* If a frame's focus has been redirected toward the currently
634 selected frame, we should change the redirection to point to the
635 newly selected frame. This means that if the focus is redirected
636 from a minibufferless frame to a surrogate minibuffer frame, we
637 can use `other-window' to switch between all the frames using
638 that minibuffer frame, and the focus redirection will follow us
644 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
648 if (!FRAMEP (XCAR (tail
)))
651 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
653 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
654 Fredirect_frame_focus (XCAR (tail
), frame
);
658 /* Instead, apply it only to the frame we're pointing to. */
659 #ifdef HAVE_WINDOW_SYSTEM
660 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
662 Lisp_Object focus
, xfocus
;
664 xfocus
= x_get_focus_frame (XFRAME (frame
));
667 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
668 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
669 Fredirect_frame_focus (xfocus
, frame
);
672 #endif /* HAVE_X_WINDOWS */
675 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
676 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
678 selected_frame
= frame
;
679 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
680 last_nonminibuf_frame
= XFRAME (selected_frame
);
682 Fselect_window (XFRAME (frame
)->selected_window
);
685 /* Make sure to switch the tty color mode to that of the newly
687 sf
= SELECTED_FRAME ();
688 if (FRAME_TERMCAP_P (sf
))
690 Lisp_Object color_mode_spec
, color_mode
;
692 color_mode_spec
= assq_no_quit (Qtty_color_mode
, sf
->param_alist
);
693 if (CONSP (color_mode_spec
))
694 color_mode
= XCDR (color_mode_spec
);
696 color_mode
= make_number (0);
697 set_tty_color_mode (sf
, color_mode
);
699 #endif /* !WINDOWSNT */
701 /* We want to make sure that the next event generates a frame-switch
702 event to the appropriate frame. This seems kludgy to me, but
703 before you take it out, make sure that evaluating something like
704 (select-window (frame-root-window (new-frame))) doesn't end up
705 with your typing being interpreted in the new frame instead of
706 the one you're actually typing in. */
707 internal_last_event_frame
= Qnil
;
712 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 2, "e",
713 doc
: /* Select the frame FRAME.
714 Subsequent editing commands apply to its selected window.
715 The selection of FRAME lasts until the next time the user does
716 something to select a different frame, or until the next time this
717 function is called. */)
719 Lisp_Object frame
, no_enter
;
721 return do_switch_frame (frame
, 1, 0);
725 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 2, "e",
726 doc
: /* Handle a switch-frame event EVENT.
727 Switch-frame events are usually bound to this function.
728 A switch-frame event tells Emacs that the window manager has requested
729 that the user's events be directed to the frame mentioned in the event.
730 This function selects the selected window of the frame of EVENT.
732 If EVENT is frame object, handle it as if it were a switch-frame event
735 Lisp_Object event
, no_enter
;
737 /* Preserve prefix arg that the command loop just cleared. */
738 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
739 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
740 return do_switch_frame (event
, 0, 0);
743 DEFUN ("ignore-event", Fignore_event
, Signore_event
, 0, 0, "",
744 doc
: /* Do nothing, but preserve any prefix argument already specified.
745 This is a suitable binding for iconify-frame and make-frame-visible. */)
748 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
752 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
753 doc
: /* Return the frame that is now selected. */)
756 return selected_frame
;
759 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
760 doc
: /* Return the frame object that window WINDOW is on. */)
764 CHECK_LIVE_WINDOW (window
);
765 return XWINDOW (window
)->frame
;
768 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
769 doc
: /* Returns the topmost, leftmost window of FRAME.
770 If omitted, FRAME defaults to the currently selected frame. */)
777 w
= SELECTED_FRAME ()->root_window
;
780 CHECK_LIVE_FRAME (frame
);
781 w
= XFRAME (frame
)->root_window
;
783 while (NILP (XWINDOW (w
)->buffer
))
785 if (! NILP (XWINDOW (w
)->hchild
))
786 w
= XWINDOW (w
)->hchild
;
787 else if (! NILP (XWINDOW (w
)->vchild
))
788 w
= XWINDOW (w
)->vchild
;
795 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
796 Sactive_minibuffer_window
, 0, 0, 0,
797 doc
: /* Return the currently active minibuffer window, or nil if none. */)
800 return minibuf_level
? minibuf_window
: Qnil
;
803 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
804 doc
: /* Returns the root-window of FRAME.
805 If omitted, FRAME defaults to the currently selected frame. */)
812 window
= SELECTED_FRAME ()->root_window
;
815 CHECK_LIVE_FRAME (frame
);
816 window
= XFRAME (frame
)->root_window
;
822 DEFUN ("frame-selected-window", Fframe_selected_window
,
823 Sframe_selected_window
, 0, 1, 0,
824 doc
: /* Return the selected window of frame object FRAME.
825 If omitted, FRAME defaults to the currently selected frame. */)
832 window
= SELECTED_FRAME ()->selected_window
;
835 CHECK_LIVE_FRAME (frame
);
836 window
= XFRAME (frame
)->selected_window
;
842 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
843 Sset_frame_selected_window
, 2, 2, 0,
844 doc
: /* Set the selected window of frame object FRAME to WINDOW.
845 If FRAME is nil, the selected frame is used.
846 If FRAME is the selected frame, this makes WINDOW the selected window. */)
848 Lisp_Object frame
, window
;
851 frame
= selected_frame
;
853 CHECK_LIVE_FRAME (frame
);
854 CHECK_LIVE_WINDOW (window
);
856 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
857 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
859 if (EQ (frame
, selected_frame
))
860 return Fselect_window (window
);
862 return XFRAME (frame
)->selected_window
= window
;
865 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
867 doc
: /* Return a list of all frames. */)
871 frames
= Fcopy_sequence (Vframe_list
);
872 #ifdef HAVE_WINDOW_SYSTEM
873 if (FRAMEP (tip_frame
))
874 frames
= Fdelq (tip_frame
, frames
);
879 /* Return the next frame in the frame list after FRAME.
880 If MINIBUF is nil, exclude minibuffer-only frames.
881 If MINIBUF is a window, include only its own frame
882 and any frame now using that window as the minibuffer.
883 If MINIBUF is `visible', include all visible frames.
884 If MINIBUF is 0, include all visible and iconified frames.
885 Otherwise, include all frames. */
888 next_frame (frame
, minibuf
)
895 /* There must always be at least one frame in Vframe_list. */
896 if (! CONSP (Vframe_list
))
899 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
900 forever. Forestall that. */
901 CHECK_LIVE_FRAME (frame
);
904 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
911 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
913 /* Decide whether this frame is eligible to be returned. */
915 /* If we've looped all the way around without finding any
916 eligible frames, return the original frame. */
920 /* Let minibuf decide if this frame is acceptable. */
923 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
926 else if (EQ (minibuf
, Qvisible
))
928 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
929 if (FRAME_VISIBLE_P (XFRAME (f
)))
932 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
934 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
935 if (FRAME_VISIBLE_P (XFRAME (f
))
936 || FRAME_ICONIFIED_P (XFRAME (f
)))
939 else if (WINDOWP (minibuf
))
941 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
942 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
943 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
944 FRAME_FOCUS_FRAME (XFRAME (f
))))
956 /* Return the previous frame in the frame list before FRAME.
957 If MINIBUF is nil, exclude minibuffer-only frames.
958 If MINIBUF is a window, include only its own frame
959 and any frame now using that window as the minibuffer.
960 If MINIBUF is `visible', include all visible frames.
961 If MINIBUF is 0, include all visible and iconified frames.
962 Otherwise, include all frames. */
965 prev_frame (frame
, minibuf
)
972 /* There must always be at least one frame in Vframe_list. */
973 if (! CONSP (Vframe_list
))
977 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
985 if (EQ (frame
, f
) && !NILP (prev
))
988 if (FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
990 /* Decide whether this frame is eligible to be returned,
991 according to minibuf. */
994 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
997 else if (WINDOWP (minibuf
))
999 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1000 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1001 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1002 FRAME_FOCUS_FRAME (XFRAME (f
))))
1005 else if (EQ (minibuf
, Qvisible
))
1007 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1008 if (FRAME_VISIBLE_P (XFRAME (f
)))
1011 else if (XFASTINT (minibuf
) == 0)
1013 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1014 if (FRAME_VISIBLE_P (XFRAME (f
))
1015 || FRAME_ICONIFIED_P (XFRAME (f
)))
1023 /* We've scanned the entire list. */
1025 /* We went through the whole frame list without finding a single
1026 acceptable frame. Return the original frame. */
1029 /* There were no acceptable frames in the list before FRAME; otherwise,
1030 we would have returned directly from the loop. Since PREV is the last
1031 acceptable frame in the list, return it. */
1036 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1037 doc
: /* Return the next frame in the frame list after FRAME.
1038 It considers only frames on the same terminal as FRAME.
1039 By default, skip minibuffer-only frames.
1040 If omitted, FRAME defaults to the selected frame.
1041 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1042 If MINIFRAME is a window, include only its own frame
1043 and any frame now using that window as the minibuffer.
1044 If MINIFRAME is `visible', include all visible frames.
1045 If MINIFRAME is 0, include all visible and iconified frames.
1046 Otherwise, include all frames. */)
1048 Lisp_Object frame
, miniframe
;
1051 frame
= selected_frame
;
1053 CHECK_LIVE_FRAME (frame
);
1054 return next_frame (frame
, miniframe
);
1057 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1058 doc
: /* Return the previous frame in the frame list before FRAME.
1059 It considers only frames on the same terminal as FRAME.
1060 By default, skip minibuffer-only frames.
1061 If omitted, FRAME defaults to the selected frame.
1062 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1063 If MINIFRAME is a window, include only its own frame
1064 and any frame now using that window as the minibuffer.
1065 If MINIFRAME is `visible', include all visible frames.
1066 If MINIFRAME is 0, include all visible and iconified frames.
1067 Otherwise, include all frames. */)
1069 Lisp_Object frame
, miniframe
;
1072 frame
= selected_frame
;
1073 CHECK_LIVE_FRAME (frame
);
1074 return prev_frame (frame
, miniframe
);
1077 /* Return 1 if it is ok to delete frame F;
1078 0 if all frames aside from F are invisible.
1079 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1082 other_visible_frames (f
)
1085 /* We know the selected frame is visible,
1086 so if F is some other frame, it can't be the sole visible one. */
1087 if (f
== SELECTED_FRAME ())
1092 for (frames
= Vframe_list
;
1094 frames
= XCDR (frames
))
1098 this = XCAR (frames
);
1099 /* Verify that the frame's window still exists
1100 and we can still talk to it. And note any recent change
1102 #ifdef HAVE_WINDOW_SYSTEM
1103 if (FRAME_WINDOW_P (XFRAME (this)))
1105 x_sync (XFRAME (this));
1106 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1110 if (FRAME_VISIBLE_P (XFRAME (this))
1111 || FRAME_ICONIFIED_P (XFRAME (this))
1112 /* Allow deleting the terminal frame when at least
1113 one X frame exists! */
1114 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1122 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1123 doc
: /* Delete FRAME, permanently eliminating it from use.
1124 If omitted, FRAME defaults to the selected frame.
1125 A frame may not be deleted if its minibuffer is used by other frames.
1126 Normally, you may not delete a frame if all other frames are invisible,
1127 but if the second optional argument FORCE is non-nil, you may do so.
1129 This function runs `delete-frame-functions' before actually deleting the
1130 frame, unless the frame is a tooltip.
1131 The functions are run with one arg, the frame to be deleted. */)
1133 Lisp_Object frame
, force
;
1136 struct frame
*sf
= SELECTED_FRAME ();
1137 int minibuffer_selected
;
1139 if (EQ (frame
, Qnil
))
1142 XSETFRAME (frame
, f
);
1146 CHECK_FRAME (frame
);
1150 if (! FRAME_LIVE_P (f
))
1153 if (NILP (force
) && !other_visible_frames (f
)
1155 /* Terminal frame deleted before any other visible frames are
1157 && strcmp (SDATA (f
->name
), "F1") != 0
1160 error ("Attempt to delete the sole visible or iconified frame");
1163 /* This is a nice idea, but x_connection_closed needs to be able
1164 to delete the last frame, if it is gone. */
1165 if (NILP (XCDR (Vframe_list
)))
1166 error ("Attempt to delete the only frame");
1169 /* Does this frame have a minibuffer, and is it the surrogate
1170 minibuffer for any other frame? */
1171 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1175 for (frames
= Vframe_list
;
1177 frames
= XCDR (frames
))
1180 this = XCAR (frames
);
1182 if (! EQ (this, frame
)
1184 WINDOW_FRAME (XWINDOW
1185 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1186 error ("Attempt to delete a surrogate minibuffer frame");
1190 /* Run `delete-frame-functions' unless frame is a tooltip. */
1191 if (!NILP (Vrun_hooks
)
1192 && NILP (Fframe_parameter (frame
, intern ("tooltip"))))
1194 Lisp_Object args
[2];
1195 args
[0] = intern ("delete-frame-functions");
1197 Frun_hook_with_args (2, args
);
1200 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1202 /* Don't let the frame remain selected. */
1205 Lisp_Object tail
, frame1
;
1207 /* Look for another visible frame on the same terminal. */
1208 frame1
= next_frame (frame
, Qvisible
);
1210 /* If there is none, find *some* other frame. */
1211 if (NILP (frame1
) || EQ (frame1
, frame
))
1213 FOR_EACH_FRAME (tail
, frame1
)
1215 if (! EQ (frame
, frame1
))
1220 do_switch_frame (frame1
, 0, 1);
1221 sf
= SELECTED_FRAME ();
1224 /* Don't allow minibuf_window to remain on a deleted frame. */
1225 if (EQ (f
->minibuffer_window
, minibuf_window
))
1227 Fset_window_buffer (sf
->minibuffer_window
,
1228 XWINDOW (minibuf_window
)->buffer
);
1229 minibuf_window
= sf
->minibuffer_window
;
1231 /* If the dying minibuffer window was selected,
1232 select the new one. */
1233 if (minibuffer_selected
)
1234 Fselect_window (minibuf_window
);
1237 /* Don't let echo_area_window to remain on a deleted frame. */
1238 if (EQ (f
->minibuffer_window
, echo_area_window
))
1239 echo_area_window
= sf
->minibuffer_window
;
1241 /* Clear any X selections for this frame. */
1242 #ifdef HAVE_X_WINDOWS
1244 x_clear_frame_selections (f
);
1248 This function must be called before the window tree of the
1249 frame is deleted because windows contain dynamically allocated
1253 /* Mark all the windows that used to be on FRAME as deleted, and then
1254 remove the reference to them. */
1255 delete_all_subwindows (XWINDOW (f
->root_window
));
1256 f
->root_window
= Qnil
;
1258 Vframe_list
= Fdelq (frame
, Vframe_list
);
1259 FRAME_SET_VISIBLE (f
, 0);
1263 if (FRAME_INSERT_COST (f
))
1264 xfree (FRAME_INSERT_COST (f
));
1265 if (FRAME_DELETEN_COST (f
))
1266 xfree (FRAME_DELETEN_COST (f
));
1267 if (FRAME_INSERTN_COST (f
))
1268 xfree (FRAME_INSERTN_COST (f
));
1269 if (FRAME_DELETE_COST (f
))
1270 xfree (FRAME_DELETE_COST (f
));
1271 if (FRAME_MESSAGE_BUF (f
))
1272 xfree (FRAME_MESSAGE_BUF (f
));
1274 /* Since some events are handled at the interrupt level, we may get
1275 an event for f at any time; if we zero out the frame's display
1276 now, then we may trip up the event-handling code. Instead, we'll
1277 promise that the display of the frame must be valid until we have
1278 called the window-system-dependent frame destruction routine. */
1280 /* I think this should be done with a hook. */
1281 #ifdef HAVE_WINDOW_SYSTEM
1282 if (FRAME_WINDOW_P (f
))
1283 x_destroy_window (f
);
1286 f
->output_data
.nothing
= 0;
1288 /* If we've deleted the last_nonminibuf_frame, then try to find
1290 if (f
== last_nonminibuf_frame
)
1294 last_nonminibuf_frame
= 0;
1296 for (frames
= Vframe_list
;
1298 frames
= XCDR (frames
))
1300 f
= XFRAME (XCAR (frames
));
1301 if (!FRAME_MINIBUF_ONLY_P (f
))
1303 last_nonminibuf_frame
= f
;
1309 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1310 find another one. Prefer minibuffer-only frames, but also notice
1311 frames with other windows. */
1312 if (EQ (frame
, FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
))
1316 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1317 Lisp_Object frame_with_minibuf
;
1318 /* Some frame we found on the same kboard, or nil if there are none. */
1319 Lisp_Object frame_on_same_kboard
;
1321 frame_on_same_kboard
= Qnil
;
1322 frame_with_minibuf
= Qnil
;
1324 for (frames
= Vframe_list
;
1326 frames
= XCDR (frames
))
1331 this = XCAR (frames
);
1336 /* Consider only frames on the same kboard
1337 and only those with minibuffers. */
1338 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
)
1339 && FRAME_HAS_MINIBUF_P (f1
))
1341 frame_with_minibuf
= this;
1342 if (FRAME_MINIBUF_ONLY_P (f1
))
1346 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1347 frame_on_same_kboard
= this;
1350 if (!NILP (frame_on_same_kboard
))
1352 /* We know that there must be some frame with a minibuffer out
1353 there. If this were not true, all of the frames present
1354 would have to be minibufferless, which implies that at some
1355 point their minibuffer frames must have been deleted, but
1356 that is prohibited at the top; you can't delete surrogate
1357 minibuffer frames. */
1358 if (NILP (frame_with_minibuf
))
1361 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1364 /* No frames left on this kboard--say no minibuffer either. */
1365 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= Qnil
;
1368 /* Cause frame titles to update--necessary if we now have just one frame. */
1369 update_mode_lines
= 1;
1374 /* Return mouse position in character cell units. */
1376 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1377 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1378 The position is given in character cells, where (0, 0) is the
1380 If Emacs is running on a mouseless terminal or hasn't been programmed
1381 to read the mouse position, it returns the selected frame for FRAME
1382 and nil for X and Y.
1383 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1384 passing the normal return value to that function as an argument,
1385 and returns whatever that function returns. */)
1389 Lisp_Object lispy_dummy
;
1390 enum scroll_bar_part party_dummy
;
1391 Lisp_Object x
, y
, retval
;
1393 unsigned long long_dummy
;
1394 struct gcpro gcpro1
;
1396 f
= SELECTED_FRAME ();
1400 /* It's okay for the hook to refrain from storing anything. */
1401 if (mouse_position_hook
)
1402 (*mouse_position_hook
) (&f
, -1,
1403 &lispy_dummy
, &party_dummy
,
1410 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1415 XSETFRAME (lispy_dummy
, f
);
1416 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1418 if (!NILP (Vmouse_position_function
))
1419 retval
= call1 (Vmouse_position_function
, retval
);
1420 RETURN_UNGCPRO (retval
);
1423 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1424 Smouse_pixel_position
, 0, 0, 0,
1425 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1426 The position is given in pixel units, where (0, 0) is the
1428 If Emacs is running on a mouseless terminal or hasn't been programmed
1429 to read the mouse position, it returns the selected frame for FRAME
1430 and nil for X and Y. */)
1434 Lisp_Object lispy_dummy
;
1435 enum scroll_bar_part party_dummy
;
1437 unsigned long long_dummy
;
1439 f
= SELECTED_FRAME ();
1443 /* It's okay for the hook to refrain from storing anything. */
1444 if (mouse_position_hook
)
1445 (*mouse_position_hook
) (&f
, -1,
1446 &lispy_dummy
, &party_dummy
,
1450 XSETFRAME (lispy_dummy
, f
);
1451 return Fcons (lispy_dummy
, Fcons (x
, y
));
1454 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1455 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1456 Coordinates are relative to the frame, not a window,
1457 so the coordinates of the top left character in the frame
1458 may be nonzero due to left-hand scroll bars or the menu bar.
1460 This function is a no-op for an X frame that is not visible.
1461 If you have just created a frame, you must wait for it to become visible
1462 before calling this function on it, like this.
1463 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1465 Lisp_Object frame
, x
, y
;
1467 CHECK_LIVE_FRAME (frame
);
1471 /* I think this should be done with a hook. */
1472 #ifdef HAVE_WINDOW_SYSTEM
1473 if (FRAME_WINDOW_P (XFRAME (frame
)))
1474 /* Warping the mouse will cause enternotify and focus events. */
1475 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1477 #if defined (MSDOS) && defined (HAVE_MOUSE)
1478 if (FRAME_MSDOS_P (XFRAME (frame
)))
1480 Fselect_frame (frame
, Qnil
);
1481 mouse_moveto (XINT (x
), XINT (y
));
1489 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1490 Sset_mouse_pixel_position
, 3, 3, 0,
1491 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1492 Note, this is a no-op for an X frame that is not visible.
1493 If you have just created a frame, you must wait for it to become visible
1494 before calling this function on it, like this.
1495 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1497 Lisp_Object frame
, x
, y
;
1499 CHECK_LIVE_FRAME (frame
);
1503 /* I think this should be done with a hook. */
1504 #ifdef HAVE_WINDOW_SYSTEM
1505 if (FRAME_WINDOW_P (XFRAME (frame
)))
1506 /* Warping the mouse will cause enternotify and focus events. */
1507 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1509 #if defined (MSDOS) && defined (HAVE_MOUSE)
1510 if (FRAME_MSDOS_P (XFRAME (frame
)))
1512 Fselect_frame (frame
, Qnil
);
1513 mouse_moveto (XINT (x
), XINT (y
));
1521 static void make_frame_visible_1
P_ ((Lisp_Object
));
1523 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1525 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1526 If omitted, FRAME defaults to the currently selected frame. */)
1531 frame
= selected_frame
;
1533 CHECK_LIVE_FRAME (frame
);
1535 /* I think this should be done with a hook. */
1536 #ifdef HAVE_WINDOW_SYSTEM
1537 if (FRAME_WINDOW_P (XFRAME (frame
)))
1539 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1540 x_make_frame_visible (XFRAME (frame
));
1544 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1546 /* Make menu bar update for the Buffers and Frames menus. */
1547 windows_or_buffers_changed
++;
1552 /* Update the display_time slot of the buffers shown in WINDOW
1553 and all its descendents. */
1556 make_frame_visible_1 (window
)
1561 for (;!NILP (window
); window
= w
->next
)
1563 w
= XWINDOW (window
);
1565 if (!NILP (w
->buffer
))
1566 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1568 if (!NILP (w
->vchild
))
1569 make_frame_visible_1 (w
->vchild
);
1570 if (!NILP (w
->hchild
))
1571 make_frame_visible_1 (w
->hchild
);
1575 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1577 doc
: /* Make the frame FRAME invisible (assuming it is an X window).
1578 If omitted, FRAME defaults to the currently selected frame.
1579 Normally you may not make FRAME invisible if all other frames are invisible,
1580 but if the second optional argument FORCE is non-nil, you may do so. */)
1582 Lisp_Object frame
, force
;
1585 frame
= selected_frame
;
1587 CHECK_LIVE_FRAME (frame
);
1589 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1590 error ("Attempt to make invisible the sole visible or iconified frame");
1592 #if 0 /* This isn't logically necessary, and it can do GC. */
1593 /* Don't let the frame remain selected. */
1594 if (EQ (frame
, selected_frame
))
1595 do_switch_frame (next_frame (frame
, Qt
), 0, 0)
1598 /* Don't allow minibuf_window to remain on a deleted frame. */
1599 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1601 struct frame
*sf
= XFRAME (selected_frame
);
1602 Fset_window_buffer (sf
->minibuffer_window
,
1603 XWINDOW (minibuf_window
)->buffer
);
1604 minibuf_window
= sf
->minibuffer_window
;
1607 /* I think this should be done with a hook. */
1608 #ifdef HAVE_WINDOW_SYSTEM
1609 if (FRAME_WINDOW_P (XFRAME (frame
)))
1610 x_make_frame_invisible (XFRAME (frame
));
1613 /* Make menu bar update for the Buffers and Frames menus. */
1614 windows_or_buffers_changed
++;
1619 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1621 doc
: /* Make the frame FRAME into an icon.
1622 If omitted, FRAME defaults to the currently selected frame. */)
1627 frame
= selected_frame
;
1629 CHECK_LIVE_FRAME (frame
);
1631 #if 0 /* This isn't logically necessary, and it can do GC. */
1632 /* Don't let the frame remain selected. */
1633 if (EQ (frame
, selected_frame
))
1634 Fhandle_switch_frame (next_frame (frame
, Qt
), Qnil
);
1637 /* Don't allow minibuf_window to remain on a deleted frame. */
1638 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1640 struct frame
*sf
= XFRAME (selected_frame
);
1641 Fset_window_buffer (sf
->minibuffer_window
,
1642 XWINDOW (minibuf_window
)->buffer
);
1643 minibuf_window
= sf
->minibuffer_window
;
1646 /* I think this should be done with a hook. */
1647 #ifdef HAVE_WINDOW_SYSTEM
1648 if (FRAME_WINDOW_P (XFRAME (frame
)))
1649 x_iconify_frame (XFRAME (frame
));
1652 /* Make menu bar update for the Buffers and Frames menus. */
1653 windows_or_buffers_changed
++;
1658 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1660 doc
: /* Return t if FRAME is now \"visible\" (actually in use for display).
1661 A frame that is not \"visible\" is not updated and, if it works through
1662 a window system, it may not show at all.
1663 Return the symbol `icon' if frame is visible only as an icon. */)
1667 CHECK_LIVE_FRAME (frame
);
1669 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1671 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1673 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1678 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1680 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1683 Lisp_Object tail
, frame
;
1688 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1690 frame
= XCAR (tail
);
1691 if (!FRAMEP (frame
))
1694 if (FRAME_VISIBLE_P (f
))
1695 value
= Fcons (frame
, value
);
1701 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1702 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1703 If FRAME is invisible, make it visible.
1704 If you don't specify a frame, the selected frame is used.
1705 If Emacs is displaying on an ordinary terminal or some other device which
1706 doesn't support multiple overlapping frames, this function does nothing. */)
1711 frame
= selected_frame
;
1713 CHECK_LIVE_FRAME (frame
);
1715 /* Do like the documentation says. */
1716 Fmake_frame_visible (frame
);
1718 if (frame_raise_lower_hook
)
1719 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1724 /* Should we have a corresponding function called Flower_Power? */
1725 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1726 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1727 If you don't specify a frame, the selected frame is used.
1728 If Emacs is displaying on an ordinary terminal or some other device which
1729 doesn't support multiple overlapping frames, this function does nothing. */)
1734 frame
= selected_frame
;
1736 CHECK_LIVE_FRAME (frame
);
1738 if (frame_raise_lower_hook
)
1739 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1745 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1747 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1748 In other words, switch-frame events caused by events in FRAME will
1749 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1750 FOCUS-FRAME after reading an event typed at FRAME.
1752 If FOCUS-FRAME is omitted or nil, any existing redirection is
1753 cancelled, and the frame again receives its own keystrokes.
1755 Focus redirection is useful for temporarily redirecting keystrokes to
1756 a surrogate minibuffer frame when a frame doesn't have its own
1759 A frame's focus redirection can be changed by select-frame. If frame
1760 FOO is selected, and then a different frame BAR is selected, any
1761 frames redirecting their focus to FOO are shifted to redirect their
1762 focus to BAR. This allows focus redirection to work properly when the
1763 user switches from one frame to another using `select-window'.
1765 This means that a frame whose focus is redirected to itself is treated
1766 differently from a frame whose focus is redirected to nil; the former
1767 is affected by select-frame, while the latter is not.
1769 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1770 (frame
, focus_frame
)
1771 Lisp_Object frame
, focus_frame
;
1773 /* Note that we don't check for a live frame here. It's reasonable
1774 to redirect the focus of a frame you're about to delete, if you
1775 know what other frame should receive those keystrokes. */
1776 CHECK_FRAME (frame
);
1778 if (! NILP (focus_frame
))
1779 CHECK_LIVE_FRAME (focus_frame
);
1781 XFRAME (frame
)->focus_frame
= focus_frame
;
1783 if (frame_rehighlight_hook
)
1784 (*frame_rehighlight_hook
) (XFRAME (frame
));
1790 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1791 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1792 This returns nil if FRAME's focus is not redirected.
1793 See `redirect-frame-focus'. */)
1797 CHECK_LIVE_FRAME (frame
);
1799 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1804 /* Return the value of frame parameter PROP in frame FRAME. */
1807 get_frame_param (frame
, prop
)
1808 register struct frame
*frame
;
1811 register Lisp_Object tem
;
1813 tem
= Fassq (prop
, frame
->param_alist
);
1819 /* Return the buffer-predicate of the selected frame. */
1822 frame_buffer_predicate (frame
)
1825 return XFRAME (frame
)->buffer_predicate
;
1828 /* Return the buffer-list of the selected frame. */
1831 frame_buffer_list (frame
)
1834 return XFRAME (frame
)->buffer_list
;
1837 /* Set the buffer-list of the selected frame. */
1840 set_frame_buffer_list (frame
, list
)
1841 Lisp_Object frame
, list
;
1843 XFRAME (frame
)->buffer_list
= list
;
1846 /* Discard BUFFER from the buffer-list of each frame. */
1849 frames_discard_buffer (buffer
)
1852 Lisp_Object frame
, tail
;
1854 FOR_EACH_FRAME (tail
, frame
)
1856 XFRAME (frame
)->buffer_list
1857 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1861 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1862 If the alist already has an element for PROP, we change it. */
1865 store_in_alist (alistptr
, prop
, val
)
1866 Lisp_Object
*alistptr
, val
;
1869 register Lisp_Object tem
;
1871 tem
= Fassq (prop
, *alistptr
);
1873 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1879 frame_name_fnn_p (str
, len
)
1883 if (len
> 1 && str
[0] == 'F')
1887 strtol (str
+ 1, &end_ptr
, 10);
1889 if (end_ptr
== str
+ len
)
1895 /* Set the name of the terminal frame. Also used by MSDOS frames.
1896 Modeled after x_set_name which is used for WINDOW frames. */
1899 set_term_frame_name (f
, name
)
1903 f
->explicit_name
= ! NILP (name
);
1905 /* If NAME is nil, set the name to F<num>. */
1910 /* Check for no change needed in this very common case
1911 before we do any consing. */
1912 if (frame_name_fnn_p (SDATA (f
->name
),
1916 terminal_frame_count
++;
1917 sprintf (namebuf
, "F%d", terminal_frame_count
);
1918 name
= build_string (namebuf
);
1922 CHECK_STRING (name
);
1924 /* Don't change the name if it's already NAME. */
1925 if (! NILP (Fstring_equal (name
, f
->name
)))
1928 /* Don't allow the user to set the frame name to F<num>, so it
1929 doesn't clash with the names we generate for terminal frames. */
1930 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
1931 error ("Frame names of the form F<num> are usurped by Emacs");
1935 update_mode_lines
= 1;
1939 store_frame_param (f
, prop
, val
)
1941 Lisp_Object prop
, val
;
1943 register Lisp_Object old_alist_elt
;
1945 /* The buffer-alist parameter is stored in a special place and is
1946 not in the alist. */
1947 if (EQ (prop
, Qbuffer_list
))
1949 f
->buffer_list
= val
;
1953 /* If PROP is a symbol which is supposed to have frame-local values,
1954 and it is set up based on this frame, switch to the global
1955 binding. That way, we can create or alter the frame-local binding
1956 without messing up the symbol's status. */
1959 Lisp_Object valcontents
;
1960 valcontents
= SYMBOL_VALUE (prop
);
1961 if ((BUFFER_LOCAL_VALUEP (valcontents
)
1962 || SOME_BUFFER_LOCAL_VALUEP (valcontents
))
1963 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
1964 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
1965 swap_in_global_binding (prop
);
1969 /* The tty color mode needs to be set before the frame's parameter
1970 alist is updated with the new value, because set_tty_color_mode
1971 wants to look at the old mode. */
1972 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
))
1973 set_tty_color_mode (f
, val
);
1976 /* Update the frame parameter alist. */
1977 old_alist_elt
= Fassq (prop
, f
->param_alist
);
1978 if (EQ (old_alist_elt
, Qnil
))
1979 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
1981 Fsetcdr (old_alist_elt
, val
);
1983 /* Update some other special parameters in their special places
1984 in addition to the alist. */
1986 if (EQ (prop
, Qbuffer_predicate
))
1987 f
->buffer_predicate
= val
;
1989 if (! FRAME_WINDOW_P (f
))
1991 if (EQ (prop
, Qmenu_bar_lines
))
1992 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
1993 else if (EQ (prop
, Qname
))
1994 set_term_frame_name (f
, val
);
1997 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
1999 if (! MINI_WINDOW_P (XWINDOW (val
)))
2000 error ("Surrogate minibuffer windows must be minibuffer windows.");
2002 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2003 && !EQ (val
, f
->minibuffer_window
))
2004 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2006 /* Install the chosen minibuffer window, with proper buffer. */
2007 f
->minibuffer_window
= val
;
2011 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2012 doc
: /* Return the parameters-alist of frame FRAME.
2013 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2014 The meaningful PARMs depend on the kind of frame.
2015 If FRAME is omitted, return information on the currently selected frame. */)
2022 struct gcpro gcpro1
;
2025 frame
= selected_frame
;
2027 CHECK_FRAME (frame
);
2030 if (!FRAME_LIVE_P (f
))
2033 alist
= Fcopy_alist (f
->param_alist
);
2036 if (!FRAME_WINDOW_P (f
))
2038 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2039 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2042 /* If the frame's parameter alist says the colors are
2043 unspecified and reversed, take the frame's background pixel
2044 for foreground and vice versa. */
2045 elt
= Fassq (Qforeground_color
, alist
);
2046 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2048 if (strncmp (SDATA (XCDR (elt
)),
2050 SCHARS (XCDR (elt
))) == 0)
2051 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2052 else if (strncmp (SDATA (XCDR (elt
)),
2054 SCHARS (XCDR (elt
))) == 0)
2055 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2058 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2059 elt
= Fassq (Qbackground_color
, alist
);
2060 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2062 if (strncmp (SDATA (XCDR (elt
)),
2064 SCHARS (XCDR (elt
))) == 0)
2065 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2066 else if (strncmp (SDATA (XCDR (elt
)),
2068 SCHARS (XCDR (elt
))) == 0)
2069 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2072 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2073 store_in_alist (&alist
, intern ("font"),
2074 build_string (FRAME_MSDOS_P (f
)
2076 : FRAME_W32_P (f
) ? "w32term"
2079 store_in_alist (&alist
, Qname
, f
->name
);
2080 height
= (FRAME_NEW_HEIGHT (f
) ? FRAME_NEW_HEIGHT (f
) : FRAME_HEIGHT (f
));
2081 store_in_alist (&alist
, Qheight
, make_number (height
));
2082 width
= (FRAME_NEW_WIDTH (f
) ? FRAME_NEW_WIDTH (f
) : FRAME_WIDTH (f
));
2083 store_in_alist (&alist
, Qwidth
, make_number (width
));
2084 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2085 store_in_alist (&alist
, Qminibuffer
,
2086 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2087 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2088 : FRAME_MINIBUF_WINDOW (f
)));
2089 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2090 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2092 /* I think this should be done with a hook. */
2093 #ifdef HAVE_WINDOW_SYSTEM
2094 if (FRAME_WINDOW_P (f
))
2095 x_report_frame_params (f
, &alist
);
2099 /* This ought to be correct in f->param_alist for an X frame. */
2101 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2102 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2110 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2111 doc
: /* Return FRAME's value for parameter PARAMETER.
2112 If FRAME is nil, describe the currently selected frame. */)
2114 Lisp_Object frame
, parameter
;
2120 frame
= selected_frame
;
2122 CHECK_FRAME (frame
);
2123 CHECK_SYMBOL (parameter
);
2128 if (FRAME_LIVE_P (f
))
2130 /* Avoid consing in frequent cases. */
2131 if (EQ (parameter
, Qname
))
2133 #ifdef HAVE_X_WINDOWS
2134 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2135 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2136 #endif /* HAVE_X_WINDOWS */
2137 else if (EQ (parameter
, Qbackground_color
)
2138 || EQ (parameter
, Qforeground_color
))
2140 value
= Fassq (parameter
, f
->param_alist
);
2143 value
= XCDR (value
);
2144 /* Fframe_parameters puts the actual fg/bg color names,
2145 even if f->param_alist says otherwise. This is
2146 important when param_alist's notion of colors is
2147 "unspecified". We need to do the same here. */
2148 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2150 const char *color_name
;
2153 if (EQ (parameter
, Qbackground_color
))
2155 color_name
= SDATA (value
);
2156 csz
= SCHARS (value
);
2157 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2158 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2159 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2160 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2162 else if (EQ (parameter
, Qforeground_color
))
2164 color_name
= SDATA (value
);
2165 csz
= SCHARS (value
);
2166 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2167 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2168 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2169 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2174 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2176 else if (EQ (parameter
, Qdisplay_type
)
2177 || EQ (parameter
, Qbackground_mode
))
2178 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2180 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2187 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2188 Smodify_frame_parameters
, 2, 2, 0,
2189 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2190 If FRAME is nil, it defaults to the selected frame.
2191 ALIST is an alist of parameters to change and their new values.
2192 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2193 The meaningful PARMs depend on the kind of frame.
2194 Undefined PARMs are ignored, but stored in the frame's parameter list
2195 so that `frame-parameters' will return them.
2197 The value of frame parameter FOO can also be accessed
2198 as a frame-local binding for the variable FOO, if you have
2199 enabled such bindings for that variable with `make-variable-frame-local'. */)
2201 Lisp_Object frame
, alist
;
2204 register Lisp_Object tail
, prop
, val
;
2205 int count
= SPECPDL_INDEX ();
2207 /* Bind this to t to inhibit initialization of the default face from
2208 X resources in face-set-after-frame-default. If we don't inhibit
2209 this, modifying the `font' frame parameter, for example, while
2210 there is a `default.attributeFont' X resource, won't work,
2211 because `default's font is reset to the value of the X resource
2212 and that resets the `font' frame parameter. */
2213 specbind (Qinhibit_default_face_x_resources
, Qt
);
2215 if (EQ (frame
, Qnil
))
2216 frame
= selected_frame
;
2217 CHECK_LIVE_FRAME (frame
);
2220 /* I think this should be done with a hook. */
2221 #ifdef HAVE_WINDOW_SYSTEM
2222 if (FRAME_WINDOW_P (f
))
2223 x_set_frame_parameters (f
, alist
);
2227 if (FRAME_MSDOS_P (f
))
2228 IT_set_frame_parameters (f
, alist
);
2233 int length
= XINT (Flength (alist
));
2236 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2238 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2240 /* Extract parm names and values into those vectors. */
2243 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2248 parms
[i
] = Fcar (elt
);
2249 values
[i
] = Fcdr (elt
);
2253 /* Now process them in reverse of specified order. */
2254 for (i
--; i
>= 0; i
--)
2258 store_frame_param (f
, prop
, val
);
2262 return unbind_to (count
, Qnil
);
2265 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2267 doc
: /* Height in pixels of a line in the font in frame FRAME.
2268 If FRAME is omitted, the selected frame is used.
2269 For a terminal frame, the value is always 1. */)
2276 frame
= selected_frame
;
2277 CHECK_FRAME (frame
);
2280 #ifdef HAVE_WINDOW_SYSTEM
2281 if (FRAME_WINDOW_P (f
))
2282 return make_number (x_char_height (f
));
2285 return make_number (1);
2289 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2291 doc
: /* Width in pixels of characters in the font in frame FRAME.
2292 If FRAME is omitted, the selected frame is used.
2293 The width is the same for all characters, because
2294 currently Emacs supports only fixed-width fonts.
2295 For a terminal screen, the value is always 1. */)
2302 frame
= selected_frame
;
2303 CHECK_FRAME (frame
);
2306 #ifdef HAVE_WINDOW_SYSTEM
2307 if (FRAME_WINDOW_P (f
))
2308 return make_number (x_char_width (f
));
2311 return make_number (1);
2314 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2315 Sframe_pixel_height
, 0, 1, 0,
2316 doc
: /* Return a FRAME's height in pixels.
2317 This counts only the height available for text lines,
2318 not menu bars on window-system Emacs frames.
2319 For a terminal frame, the result really gives the height in characters.
2320 If FRAME is omitted, the selected frame is used. */)
2327 frame
= selected_frame
;
2328 CHECK_FRAME (frame
);
2331 #ifdef HAVE_WINDOW_SYSTEM
2332 if (FRAME_WINDOW_P (f
))
2333 return make_number (x_pixel_height (f
));
2336 return make_number (FRAME_HEIGHT (f
));
2339 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2340 Sframe_pixel_width
, 0, 1, 0,
2341 doc
: /* Return FRAME's width in pixels.
2342 For a terminal frame, the result really gives the width in characters.
2343 If FRAME is omitted, the selected frame is used. */)
2350 frame
= selected_frame
;
2351 CHECK_FRAME (frame
);
2354 #ifdef HAVE_WINDOW_SYSTEM
2355 if (FRAME_WINDOW_P (f
))
2356 return make_number (x_pixel_width (f
));
2359 return make_number (FRAME_WIDTH (f
));
2362 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2363 doc
: /* Specify that the frame FRAME has LINES lines.
2364 Optional third arg non-nil means that redisplay should use LINES lines
2365 but that the idea of the actual height of the frame should not be changed. */)
2366 (frame
, lines
, pretend
)
2367 Lisp_Object frame
, lines
, pretend
;
2369 register struct frame
*f
;
2371 CHECK_NUMBER (lines
);
2373 frame
= selected_frame
;
2374 CHECK_LIVE_FRAME (frame
);
2377 /* I think this should be done with a hook. */
2378 #ifdef HAVE_WINDOW_SYSTEM
2379 if (FRAME_WINDOW_P (f
))
2381 if (XINT (lines
) != f
->height
)
2382 x_set_window_size (f
, 1, f
->width
, XINT (lines
));
2383 do_pending_window_change (0);
2387 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2391 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2392 doc
: /* Specify that the frame FRAME has COLS columns.
2393 Optional third arg non-nil means that redisplay should use COLS columns
2394 but that the idea of the actual width of the frame should not be changed. */)
2395 (frame
, cols
, pretend
)
2396 Lisp_Object frame
, cols
, pretend
;
2398 register struct frame
*f
;
2399 CHECK_NUMBER (cols
);
2401 frame
= selected_frame
;
2402 CHECK_LIVE_FRAME (frame
);
2405 /* I think this should be done with a hook. */
2406 #ifdef HAVE_WINDOW_SYSTEM
2407 if (FRAME_WINDOW_P (f
))
2409 if (XINT (cols
) != f
->width
)
2410 x_set_window_size (f
, 1, XINT (cols
), f
->height
);
2411 do_pending_window_change (0);
2415 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2419 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2420 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2422 Lisp_Object frame
, cols
, rows
;
2424 register struct frame
*f
;
2426 CHECK_LIVE_FRAME (frame
);
2427 CHECK_NUMBER (cols
);
2428 CHECK_NUMBER (rows
);
2431 /* I think this should be done with a hook. */
2432 #ifdef HAVE_WINDOW_SYSTEM
2433 if (FRAME_WINDOW_P (f
))
2435 if (XINT (rows
) != f
->height
|| XINT (cols
) != f
->width
2436 || FRAME_NEW_HEIGHT (f
) || FRAME_NEW_WIDTH (f
))
2437 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2438 do_pending_window_change (0);
2442 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2447 DEFUN ("set-frame-position", Fset_frame_position
,
2448 Sset_frame_position
, 3, 3, 0,
2449 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2450 This is actually the position of the upper left corner of the frame.
2451 Negative values for XOFFSET or YOFFSET are interpreted relative to
2452 the rightmost or bottommost possible position (that stays within the screen). */)
2453 (frame
, xoffset
, yoffset
)
2454 Lisp_Object frame
, xoffset
, yoffset
;
2456 register struct frame
*f
;
2458 CHECK_LIVE_FRAME (frame
);
2459 CHECK_NUMBER (xoffset
);
2460 CHECK_NUMBER (yoffset
);
2463 /* I think this should be done with a hook. */
2464 #ifdef HAVE_WINDOW_SYSTEM
2465 if (FRAME_WINDOW_P (f
))
2466 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2473 /***********************************************************************
2475 ***********************************************************************/
2477 /* Connect the frame-parameter names for X frames
2478 to the ways of passing the parameter values to the window system.
2480 The name of a parameter, as a Lisp symbol,
2481 has an `x-frame-parameter' property which is an integer in Lisp
2482 that is an index in this table. */
2484 struct frame_parm_table
{
2486 Lisp_Object
*variable
;
2489 static struct frame_parm_table frame_parms
[] =
2491 {"auto-raise", &Qauto_raise
},
2492 {"auto-lower", &Qauto_lower
},
2493 {"background-color", 0},
2494 {"border-color", &Qborder_color
},
2495 {"border-width", &Qborder_width
},
2496 {"cursor-color", &Qcursor_color
},
2497 {"cursor-type", &Qcursor_type
},
2499 {"foreground-color", 0},
2500 {"icon-name", &Qicon_name
},
2501 {"icon-type", &Qicon_type
},
2502 {"internal-border-width", &Qinternal_border_width
},
2503 {"menu-bar-lines", &Qmenu_bar_lines
},
2504 {"mouse-color", &Qmouse_color
},
2506 {"scroll-bar-width", &Qscroll_bar_width
},
2508 {"unsplittable", &Qunsplittable
},
2509 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2510 {"visibility", &Qvisibility
},
2511 {"tool-bar-lines", &Qtool_bar_lines
},
2512 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2513 {"scroll-bar-background", &Qscroll_bar_background
},
2514 {"screen-gamma", &Qscreen_gamma
},
2515 {"line-spacing", &Qline_spacing
},
2516 {"left-fringe", &Qleft_fringe
},
2517 {"right-fringe", &Qright_fringe
},
2518 {"wait-for-wm", &Qwait_for_wm
},
2519 {"fullscreen", &Qfullscreen
},
2522 #ifdef HAVE_WINDOW_SYSTEM
2524 extern Lisp_Object Qbox
;
2525 extern Lisp_Object Qtop
;
2527 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2528 wanted positions of the WM window (not emacs window).
2529 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2530 window (FRAME_X_WINDOW).
2534 x_fullscreen_adjust (f
, width
, height
, top_pos
, left_pos
)
2541 int newwidth
= f
->width
, newheight
= f
->height
;
2543 *top_pos
= FRAME_X_OUTPUT (f
)->top_pos
;
2544 *left_pos
= FRAME_X_OUTPUT (f
)->left_pos
;
2546 if (FRAME_X_OUTPUT (f
)->want_fullscreen
& FULLSCREEN_HEIGHT
)
2550 ph
= FRAME_X_DISPLAY_INFO (f
)->height
;
2551 newheight
= PIXEL_TO_CHAR_HEIGHT (f
, ph
);
2552 ph
= CHAR_TO_PIXEL_HEIGHT (f
, newheight
)
2553 - FRAME_X_OUTPUT (f
)->y_pixels_diff
;
2554 newheight
= PIXEL_TO_CHAR_HEIGHT (f
, ph
);
2558 if (FRAME_X_OUTPUT (f
)->want_fullscreen
& FULLSCREEN_WIDTH
)
2562 pw
= FRAME_X_DISPLAY_INFO (f
)->width
;
2563 newwidth
= PIXEL_TO_CHAR_WIDTH (f
, pw
);
2564 pw
= CHAR_TO_PIXEL_WIDTH (f
, newwidth
)
2565 - FRAME_X_OUTPUT (f
)->x_pixels_diff
;
2566 newwidth
= PIXEL_TO_CHAR_WIDTH (f
, pw
);
2571 *height
= newheight
;
2575 /* Really try to move where we want to be in case of fullscreen. Some WMs
2576 moves the window where we tell them. Some (mwm, twm) moves the outer
2577 window manager window there instead.
2578 Try to compensate for those WM here. */
2581 x_fullscreen_move (f
, new_top
, new_left
)
2586 if (new_top
!= FRAME_X_OUTPUT (f
)->top_pos
2587 || new_left
!= FRAME_X_OUTPUT (f
)->left_pos
)
2589 int move_x
= new_left
;
2590 int move_y
= new_top
;
2592 #ifdef HAVE_X_WINDOWS
2593 move_x
+= FRAME_X_OUTPUT (f
)->x_pixels_outer_diff
;
2594 move_y
+= FRAME_X_OUTPUT (f
)->y_pixels_outer_diff
;
2597 FRAME_X_OUTPUT (f
)->want_fullscreen
|= FULLSCREEN_MOVE_WAIT
;
2598 x_set_offset (f
, move_x
, move_y
, 1);
2602 /* Change the parameters of frame F as specified by ALIST.
2603 If a parameter is not specially recognized, do nothing special;
2604 otherwise call the `x_set_...' function for that parameter.
2605 Except for certain geometry properties, always call store_frame_param
2606 to store the new value in the parameter alist. */
2609 x_set_frame_parameters (f
, alist
)
2615 /* If both of these parameters are present, it's more efficient to
2616 set them both at once. So we wait until we've looked at the
2617 entire list before we set them. */
2621 Lisp_Object left
, top
;
2623 /* Same with these. */
2624 Lisp_Object icon_left
, icon_top
;
2626 /* Record in these vectors all the parms specified. */
2628 Lisp_Object
*values
;
2630 int left_no_change
= 0, top_no_change
= 0;
2631 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2632 int fullscreen_is_being_set
= 0;
2634 struct gcpro gcpro1
, gcpro2
;
2637 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2640 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2641 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2643 /* Extract parm names and values into those vectors. */
2646 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2651 parms
[i
] = Fcar (elt
);
2652 values
[i
] = Fcdr (elt
);
2655 /* TAIL and ALIST are not used again below here. */
2656 alist
= tail
= Qnil
;
2658 GCPRO2 (*parms
, *values
);
2662 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2663 because their values appear in VALUES and strings are not valid. */
2664 top
= left
= Qunbound
;
2665 icon_left
= icon_top
= Qunbound
;
2667 /* Provide default values for HEIGHT and WIDTH. */
2668 if (FRAME_NEW_WIDTH (f
))
2669 width
= FRAME_NEW_WIDTH (f
);
2671 width
= FRAME_WIDTH (f
);
2673 if (FRAME_NEW_HEIGHT (f
))
2674 height
= FRAME_NEW_HEIGHT (f
);
2676 height
= FRAME_HEIGHT (f
);
2678 /* Process foreground_color and background_color before anything else.
2679 They are independent of other properties, but other properties (e.g.,
2680 cursor_color) are dependent upon them. */
2681 /* Process default font as well, since fringe widths depends on it. */
2682 /* Also, process fullscreen, width and height depend upon that */
2683 for (p
= 0; p
< i
; p
++)
2685 Lisp_Object prop
, val
;
2689 if (EQ (prop
, Qforeground_color
)
2690 || EQ (prop
, Qbackground_color
)
2692 || EQ (prop
, Qfullscreen
))
2694 register Lisp_Object param_index
, old_value
;
2696 old_value
= get_frame_param (f
, prop
);
2697 fullscreen_is_being_set
|= EQ (prop
, Qfullscreen
);
2699 if (NILP (Fequal (val
, old_value
)))
2701 store_frame_param (f
, prop
, val
);
2703 param_index
= Fget (prop
, Qx_frame_parameter
);
2704 if (NATNUMP (param_index
)
2705 && (XFASTINT (param_index
)
2706 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2707 && rif
->frame_parm_handlers
[XINT (param_index
)])
2708 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2713 /* Now process them in reverse of specified order. */
2714 for (i
--; i
>= 0; i
--)
2716 Lisp_Object prop
, val
;
2721 if (EQ (prop
, Qwidth
) && NUMBERP (val
))
2722 width
= XFASTINT (val
);
2723 else if (EQ (prop
, Qheight
) && NUMBERP (val
))
2724 height
= XFASTINT (val
);
2725 else if (EQ (prop
, Qtop
))
2727 else if (EQ (prop
, Qleft
))
2729 else if (EQ (prop
, Qicon_top
))
2731 else if (EQ (prop
, Qicon_left
))
2733 else if (EQ (prop
, Qforeground_color
)
2734 || EQ (prop
, Qbackground_color
)
2736 || EQ (prop
, Qfullscreen
))
2737 /* Processed above. */
2741 register Lisp_Object param_index
, old_value
;
2743 old_value
= get_frame_param (f
, prop
);
2745 store_frame_param (f
, prop
, val
);
2747 param_index
= Fget (prop
, Qx_frame_parameter
);
2748 if (NATNUMP (param_index
)
2749 && (XFASTINT (param_index
)
2750 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2751 && rif
->frame_parm_handlers
[XINT (param_index
)])
2752 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2756 /* Don't die if just one of these was set. */
2757 if (EQ (left
, Qunbound
))
2760 if (FRAME_X_OUTPUT (f
)->left_pos
< 0)
2761 left
= Fcons (Qplus
, Fcons (make_number (FRAME_X_OUTPUT (f
)->left_pos
), Qnil
));
2763 XSETINT (left
, FRAME_X_OUTPUT (f
)->left_pos
);
2765 if (EQ (top
, Qunbound
))
2768 if (FRAME_X_OUTPUT (f
)->top_pos
< 0)
2769 top
= Fcons (Qplus
, Fcons (make_number (FRAME_X_OUTPUT (f
)->top_pos
), Qnil
));
2771 XSETINT (top
, FRAME_X_OUTPUT (f
)->top_pos
);
2774 /* If one of the icon positions was not set, preserve or default it. */
2775 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
2777 icon_left_no_change
= 1;
2778 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2779 if (NILP (icon_left
))
2780 XSETINT (icon_left
, 0);
2782 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
2784 icon_top_no_change
= 1;
2785 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2786 if (NILP (icon_top
))
2787 XSETINT (icon_top
, 0);
2791 /* MAC_TODO: fullscreen */
2792 if (FRAME_VISIBLE_P (f
) && fullscreen_is_being_set
)
2794 /* If the frame is visible already and the fullscreen parameter is
2795 being set, it is too late to set WM manager hints to specify
2797 Here we first get the width, height and position that applies to
2798 fullscreen. We then move the frame to the appropriate
2799 position. Resize of the frame is taken care of in the code after
2800 this if-statement. */
2801 int new_left
, new_top
;
2803 x_fullscreen_adjust (f
, &width
, &height
, &new_top
, &new_left
);
2804 x_fullscreen_move (f
, new_top
, new_left
);
2808 /* Don't set these parameters unless they've been explicitly
2809 specified. The window might be mapped or resized while we're in
2810 this function, and we don't want to override that unless the lisp
2811 code has asked for it.
2813 Don't set these parameters unless they actually differ from the
2814 window's current parameters; the window may not actually exist
2819 check_frame_size (f
, &height
, &width
);
2821 XSETFRAME (frame
, f
);
2823 if (width
!= FRAME_WIDTH (f
)
2824 || height
!= FRAME_HEIGHT (f
)
2825 || FRAME_NEW_HEIGHT (f
) || FRAME_NEW_WIDTH (f
))
2826 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2828 if ((!NILP (left
) || !NILP (top
))
2829 && ! (left_no_change
&& top_no_change
)
2830 && ! (NUMBERP (left
) && XINT (left
) == FRAME_X_OUTPUT (f
)->left_pos
2831 && NUMBERP (top
) && XINT (top
) == FRAME_X_OUTPUT (f
)->top_pos
))
2836 /* Record the signs. */
2837 FRAME_X_OUTPUT (f
)->size_hint_flags
&= ~ (XNegative
| YNegative
);
2838 if (EQ (left
, Qminus
))
2839 FRAME_X_OUTPUT (f
)->size_hint_flags
|= XNegative
;
2840 else if (INTEGERP (left
))
2842 leftpos
= XINT (left
);
2844 FRAME_X_OUTPUT (f
)->size_hint_flags
|= XNegative
;
2846 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2847 && CONSP (XCDR (left
))
2848 && INTEGERP (XCAR (XCDR (left
))))
2850 leftpos
= - XINT (XCAR (XCDR (left
)));
2851 FRAME_X_OUTPUT (f
)->size_hint_flags
|= XNegative
;
2853 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2854 && CONSP (XCDR (left
))
2855 && INTEGERP (XCAR (XCDR (left
))))
2857 leftpos
= XINT (XCAR (XCDR (left
)));
2860 if (EQ (top
, Qminus
))
2861 FRAME_X_OUTPUT (f
)->size_hint_flags
|= YNegative
;
2862 else if (INTEGERP (top
))
2864 toppos
= XINT (top
);
2866 FRAME_X_OUTPUT (f
)->size_hint_flags
|= YNegative
;
2868 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2869 && CONSP (XCDR (top
))
2870 && INTEGERP (XCAR (XCDR (top
))))
2872 toppos
= - XINT (XCAR (XCDR (top
)));
2873 FRAME_X_OUTPUT (f
)->size_hint_flags
|= YNegative
;
2875 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2876 && CONSP (XCDR (top
))
2877 && INTEGERP (XCAR (XCDR (top
))))
2879 toppos
= XINT (XCAR (XCDR (top
)));
2883 /* Store the numeric value of the position. */
2884 FRAME_X_OUTPUT (f
)->top_pos
= toppos
;
2885 FRAME_X_OUTPUT (f
)->left_pos
= leftpos
;
2887 FRAME_X_OUTPUT (f
)->win_gravity
= NorthWestGravity
;
2889 /* Actually set that position, and convert to absolute. */
2890 x_set_offset (f
, leftpos
, toppos
, -1);
2893 if ((!NILP (icon_left
) || !NILP (icon_top
))
2894 && ! (icon_left_no_change
&& icon_top_no_change
))
2895 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2902 /* Insert a description of internally-recorded parameters of frame X
2903 into the parameter alist *ALISTPTR that is to be given to the user.
2904 Only parameters that are specific to the X window system
2905 and whose values are not correctly recorded in the frame's
2906 param_alist need to be considered here. */
2909 x_report_frame_params (f
, alistptr
)
2911 Lisp_Object
*alistptr
;
2916 /* Represent negative positions (off the top or left screen edge)
2917 in a way that Fmodify_frame_parameters will understand correctly. */
2918 XSETINT (tem
, FRAME_X_OUTPUT (f
)->left_pos
);
2919 if (FRAME_X_OUTPUT (f
)->left_pos
>= 0)
2920 store_in_alist (alistptr
, Qleft
, tem
);
2922 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2924 XSETINT (tem
, FRAME_X_OUTPUT (f
)->top_pos
);
2925 if (FRAME_X_OUTPUT (f
)->top_pos
>= 0)
2926 store_in_alist (alistptr
, Qtop
, tem
);
2928 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2930 store_in_alist (alistptr
, Qborder_width
,
2931 make_number (FRAME_X_OUTPUT (f
)->border_width
));
2932 store_in_alist (alistptr
, Qinternal_border_width
,
2933 make_number (FRAME_X_OUTPUT (f
)->internal_border_width
));
2934 store_in_alist (alistptr
, Qleft_fringe
,
2935 make_number (FRAME_X_OUTPUT (f
)->left_fringe_width
));
2936 store_in_alist (alistptr
, Qright_fringe
,
2937 make_number (FRAME_X_OUTPUT (f
)->right_fringe_width
));
2938 store_in_alist (alistptr
, Qscroll_bar_width
,
2939 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2941 : FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) > 0
2942 ? make_number (FRAME_SCROLL_BAR_PIXEL_WIDTH (f
))
2943 /* nil means "use default width"
2944 for non-toolkit scroll bar.
2945 ruler-mode.el depends on this. */
2947 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
2948 store_in_alist (alistptr
, Qwindow_id
,
2949 build_string (buf
));
2950 #ifdef HAVE_X_WINDOWS
2951 #ifdef USE_X_TOOLKIT
2952 /* Tooltip frame may not have this widget. */
2953 if (FRAME_X_OUTPUT (f
)->widget
)
2955 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
2956 store_in_alist (alistptr
, Qouter_window_id
,
2957 build_string (buf
));
2959 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
2960 FRAME_SAMPLE_VISIBILITY (f
);
2961 store_in_alist (alistptr
, Qvisibility
,
2962 (FRAME_VISIBLE_P (f
) ? Qt
2963 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
2964 store_in_alist (alistptr
, Qdisplay
,
2965 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
2967 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
2970 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
2971 store_in_alist (alistptr
, Qparent_id
, tem
);
2975 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
2976 the previous value of that parameter, NEW_VALUE is the new value. */
2979 x_set_fullscreen (f
, new_value
, old_value
)
2981 Lisp_Object new_value
, old_value
;
2984 if (NILP (new_value
))
2985 FRAME_X_OUTPUT (f
)->want_fullscreen
= FULLSCREEN_NONE
;
2986 else if (EQ (new_value
, Qfullboth
))
2987 FRAME_X_OUTPUT (f
)->want_fullscreen
= FULLSCREEN_BOTH
;
2988 else if (EQ (new_value
, Qfullwidth
))
2989 FRAME_X_OUTPUT (f
)->want_fullscreen
= FULLSCREEN_WIDTH
;
2990 else if (EQ (new_value
, Qfullheight
))
2991 FRAME_X_OUTPUT (f
)->want_fullscreen
= FULLSCREEN_HEIGHT
;
2996 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
2997 the previous value of that parameter, NEW_VALUE is the new value. */
3000 x_set_line_spacing (f
, new_value
, old_value
)
3002 Lisp_Object new_value
, old_value
;
3004 if (NILP (new_value
))
3005 f
->extra_line_spacing
= 0;
3006 else if (NATNUMP (new_value
))
3007 f
->extra_line_spacing
= XFASTINT (new_value
);
3009 Fsignal (Qerror
, Fcons (build_string ("Invalid line-spacing"),
3010 Fcons (new_value
, Qnil
)));
3011 if (FRAME_VISIBLE_P (f
))
3016 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3017 the previous value of that parameter, NEW_VALUE is the new value. */
3020 x_set_screen_gamma (f
, new_value
, old_value
)
3022 Lisp_Object new_value
, old_value
;
3024 if (NILP (new_value
))
3026 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3027 /* The value 0.4545 is the normal viewing gamma. */
3028 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3030 Fsignal (Qerror
, Fcons (build_string ("Invalid screen-gamma"),
3031 Fcons (new_value
, Qnil
)));
3033 clear_face_cache (0);
3038 x_set_font (f
, arg
, oldval
)
3040 Lisp_Object arg
, oldval
;
3043 Lisp_Object fontset_name
;
3045 int old_fontset
= FRAME_FONTSET(f
);
3049 fontset_name
= Fquery_fontset (arg
, Qnil
);
3052 result
= (STRINGP (fontset_name
)
3053 ? x_new_fontset (f
, SDATA (fontset_name
))
3054 : x_new_font (f
, SDATA (arg
)));
3057 if (EQ (result
, Qnil
))
3058 error ("Font `%s' is not defined", SDATA (arg
));
3059 else if (EQ (result
, Qt
))
3060 error ("The characters of the given font have varying widths");
3061 else if (STRINGP (result
))
3063 if (STRINGP (fontset_name
))
3065 /* Fontset names are built from ASCII font names, so the
3066 names may be equal despite there was a change. */
3067 if (old_fontset
== FRAME_FONTSET (f
))
3070 else if (!NILP (Fequal (result
, oldval
)))
3073 store_frame_param (f
, Qfont
, result
);
3074 recompute_basic_faces (f
);
3079 do_pending_window_change (0);
3081 /* Don't call `face-set-after-frame-default' when faces haven't been
3082 initialized yet. This is the case when called from
3083 Fx_create_frame. In that case, the X widget or window doesn't
3084 exist either, and we can end up in x_report_frame_params with a
3085 null widget which gives a segfault. */
3086 if (FRAME_FACE_CACHE (f
))
3088 XSETFRAME (frame
, f
);
3089 call1 (Qface_set_after_frame_default
, frame
);
3095 x_set_fringe_width (f
, new_value
, old_value
)
3097 Lisp_Object new_value
, old_value
;
3099 compute_fringe_widths (f
, 1);
3103 x_set_border_width (f
, arg
, oldval
)
3105 Lisp_Object arg
, oldval
;
3109 if (XINT (arg
) == FRAME_X_OUTPUT (f
)->border_width
)
3113 if (FRAME_X_WINDOW (f
) != 0)
3114 error ("Cannot change the border width of a window");
3115 #endif /* MAC_TODO */
3117 FRAME_X_OUTPUT (f
)->border_width
= XINT (arg
);
3121 x_set_internal_border_width (f
, arg
, oldval
)
3123 Lisp_Object arg
, oldval
;
3125 int old
= FRAME_X_OUTPUT (f
)->internal_border_width
;
3128 FRAME_X_OUTPUT (f
)->internal_border_width
= XINT (arg
);
3129 if (FRAME_X_OUTPUT (f
)->internal_border_width
< 0)
3130 FRAME_X_OUTPUT (f
)->internal_border_width
= 0;
3132 #ifdef USE_X_TOOLKIT
3133 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3134 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3137 if (FRAME_X_OUTPUT (f
)->internal_border_width
== old
)
3140 if (FRAME_X_WINDOW (f
) != 0)
3142 x_set_window_size (f
, 0, f
->width
, f
->height
);
3143 SET_FRAME_GARBAGED (f
);
3144 do_pending_window_change (0);
3147 SET_FRAME_GARBAGED (f
);
3151 x_set_visibility (f
, value
, oldval
)
3153 Lisp_Object value
, oldval
;
3156 XSETFRAME (frame
, f
);
3159 Fmake_frame_invisible (frame
, Qt
);
3160 else if (EQ (value
, Qicon
))
3161 Ficonify_frame (frame
);
3163 Fmake_frame_visible (frame
);
3167 x_set_autoraise (f
, arg
, oldval
)
3169 Lisp_Object arg
, oldval
;
3171 f
->auto_raise
= !EQ (Qnil
, arg
);
3175 x_set_autolower (f
, arg
, oldval
)
3177 Lisp_Object arg
, oldval
;
3179 f
->auto_lower
= !EQ (Qnil
, arg
);
3183 x_set_unsplittable (f
, arg
, oldval
)
3185 Lisp_Object arg
, oldval
;
3187 f
->no_split
= !NILP (arg
);
3191 x_set_vertical_scroll_bars (f
, arg
, oldval
)
3193 Lisp_Object arg
, oldval
;
3195 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3196 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3197 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3198 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3200 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3202 ? vertical_scroll_bar_none
3204 ? vertical_scroll_bar_left
3206 ? vertical_scroll_bar_right
3208 /* MS-Windows has scroll bars on the right by default. */
3209 : vertical_scroll_bar_right
3211 : vertical_scroll_bar_left
3215 /* We set this parameter before creating the X window for the
3216 frame, so we can get the geometry right from the start.
3217 However, if the window hasn't been created yet, we shouldn't
3218 call x_set_window_size. */
3219 if (FRAME_X_WINDOW (f
))
3220 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
3221 do_pending_window_change (0);
3226 x_set_scroll_bar_width (f
, arg
, oldval
)
3228 Lisp_Object arg
, oldval
;
3230 int wid
= FONT_WIDTH (FRAME_FONT (f
));
3234 x_set_scroll_bar_default_width (f
);
3236 if (FRAME_X_WINDOW (f
))
3237 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
3238 do_pending_window_change (0);
3240 else if (INTEGERP (arg
) && XINT (arg
) > 0
3241 && XFASTINT (arg
) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f
))
3243 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3244 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3246 FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) = XFASTINT (arg
);
3247 FRAME_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3248 if (FRAME_X_WINDOW (f
))
3249 x_set_window_size (f
, 0, FRAME_WIDTH (f
), FRAME_HEIGHT (f
));
3250 do_pending_window_change (0);
3253 change_frame_size (f
, 0, FRAME_WIDTH (f
), 0, 0, 0);
3254 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3255 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3260 /* Return non-nil if frame F wants a bitmap icon. */
3268 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3276 /* Subroutines of creating an X frame. */
3278 /* Make sure that Vx_resource_name is set to a reasonable value.
3279 Fix it up, or set it to `emacs' if it is too hopeless. */
3282 validate_x_resource_name ()
3285 /* Number of valid characters in the resource name. */
3287 /* Number of invalid characters in the resource name. */
3292 if (!STRINGP (Vx_resource_class
))
3293 Vx_resource_class
= build_string (EMACS_CLASS
);
3295 if (STRINGP (Vx_resource_name
))
3297 unsigned char *p
= SDATA (Vx_resource_name
);
3300 len
= SBYTES (Vx_resource_name
);
3302 /* Only letters, digits, - and _ are valid in resource names.
3303 Count the valid characters and count the invalid ones. */
3304 for (i
= 0; i
< len
; i
++)
3307 if (! ((c
>= 'a' && c
<= 'z')
3308 || (c
>= 'A' && c
<= 'Z')
3309 || (c
>= '0' && c
<= '9')
3310 || c
== '-' || c
== '_'))
3317 /* Not a string => completely invalid. */
3318 bad_count
= 5, good_count
= 0;
3320 /* If name is valid already, return. */
3324 /* If name is entirely invalid, or nearly so, use `emacs'. */
3326 || (good_count
== 1 && bad_count
> 0))
3328 Vx_resource_name
= build_string ("emacs");
3332 /* Name is partly valid. Copy it and replace the invalid characters
3333 with underscores. */
3335 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3337 for (i
= 0; i
< len
; i
++)
3339 int c
= SREF (new, i
);
3340 if (! ((c
>= 'a' && c
<= 'z')
3341 || (c
>= 'A' && c
<= 'Z')
3342 || (c
>= '0' && c
<= '9')
3343 || c
== '-' || c
== '_'))
3349 extern char *x_get_string_resource
P_ ((XrmDatabase
, char *, char *));
3350 extern Display_Info
*check_x_display_info
P_ ((Lisp_Object
));
3353 /* Get specified attribute from resource database RDB.
3354 See Fx_get_resource below for other parameters. */
3357 xrdb_get_resource (rdb
, attribute
, class, component
, subclass
)
3359 Lisp_Object attribute
, class, component
, subclass
;
3361 register char *value
;
3365 CHECK_STRING (attribute
);
3366 CHECK_STRING (class);
3368 if (!NILP (component
))
3369 CHECK_STRING (component
);
3370 if (!NILP (subclass
))
3371 CHECK_STRING (subclass
);
3372 if (NILP (component
) != NILP (subclass
))
3373 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3375 validate_x_resource_name ();
3377 /* Allocate space for the components, the dots which separate them,
3378 and the final '\0'. Make them big enough for the worst case. */
3379 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3380 + (STRINGP (component
)
3381 ? SBYTES (component
) : 0)
3382 + SBYTES (attribute
)
3385 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3387 + (STRINGP (subclass
)
3388 ? SBYTES (subclass
) : 0)
3391 /* Start with emacs.FRAMENAME for the name (the specific one)
3392 and with `Emacs' for the class key (the general one). */
3393 strcpy (name_key
, SDATA (Vx_resource_name
));
3394 strcpy (class_key
, SDATA (Vx_resource_class
));
3396 strcat (class_key
, ".");
3397 strcat (class_key
, SDATA (class));
3399 if (!NILP (component
))
3401 strcat (class_key
, ".");
3402 strcat (class_key
, SDATA (subclass
));
3404 strcat (name_key
, ".");
3405 strcat (name_key
, SDATA (component
));
3408 strcat (name_key
, ".");
3409 strcat (name_key
, SDATA (attribute
));
3411 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3413 if (value
!= (char *) 0)
3414 return build_string (value
);
3420 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3421 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3422 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3423 class, where INSTANCE is the name under which Emacs was invoked, or
3424 the name specified by the `-name' or `-rn' command-line arguments.
3426 The optional arguments COMPONENT and SUBCLASS add to the key and the
3427 class, respectively. You must specify both of them or neither.
3428 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3429 and the class is `Emacs.CLASS.SUBCLASS'. */)
3430 (attribute
, class, component
, subclass
)
3431 Lisp_Object attribute
, class, component
, subclass
;
3433 #ifdef HAVE_X_WINDOWS
3437 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3438 attribute
, class, component
, subclass
);
3441 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3444 display_x_get_resource (dpyinfo
, attribute
, class, component
, subclass
)
3445 struct x_display_info
*dpyinfo
;
3446 Lisp_Object attribute
, class, component
, subclass
;
3448 return xrdb_get_resource (dpyinfo
->xrdb
,
3449 attribute
, class, component
, subclass
);
3452 /* Used when C code wants a resource value. */
3455 x_get_resource_string (attribute
, class)
3456 char *attribute
, *class;
3460 struct frame
*sf
= SELECTED_FRAME ();
3462 /* Allocate space for the components, the dots which separate them,
3463 and the final '\0'. */
3464 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3465 + strlen (attribute
) + 2);
3466 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3467 + strlen (class) + 2);
3469 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3470 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3472 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3473 name_key
, class_key
);
3477 /* Return the value of parameter PARAM.
3479 First search ALIST, then Vdefault_frame_alist, then the X defaults
3480 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3482 Convert the resource to the type specified by desired_type.
3484 If no default is specified, return Qunbound. If you call
3485 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3486 and don't let it get stored in any Lisp-visible variables! */
3489 x_get_arg (dpyinfo
, alist
, param
, attribute
, class, type
)
3490 Display_Info
*dpyinfo
;
3491 Lisp_Object alist
, param
;
3494 enum resource_types type
;
3496 register Lisp_Object tem
;
3498 tem
= Fassq (param
, alist
);
3500 tem
= Fassq (param
, Vdefault_frame_alist
);
3505 tem
= display_x_get_resource (dpyinfo
,
3506 build_string (attribute
),
3507 build_string (class),
3515 case RES_TYPE_NUMBER
:
3516 return make_number (atoi (SDATA (tem
)));
3518 case RES_TYPE_FLOAT
:
3519 return make_float (atof (SDATA (tem
)));
3521 case RES_TYPE_BOOLEAN
:
3522 tem
= Fdowncase (tem
);
3523 if (!strcmp (SDATA (tem
), "on")
3524 || !strcmp (SDATA (tem
), "true"))
3529 case RES_TYPE_STRING
:
3532 case RES_TYPE_SYMBOL
:
3533 /* As a special case, we map the values `true' and `on'
3534 to Qt, and `false' and `off' to Qnil. */
3537 lower
= Fdowncase (tem
);
3538 if (!strcmp (SDATA (lower
), "on")
3539 || !strcmp (SDATA (lower
), "true"))
3541 else if (!strcmp (SDATA (lower
), "off")
3542 || !strcmp (SDATA (lower
), "false"))
3545 return Fintern (tem
, Qnil
);
3559 x_frame_get_arg (f
, alist
, param
, attribute
, class, type
)
3561 Lisp_Object alist
, param
;
3564 enum resource_types type
;
3566 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3567 alist
, param
, attribute
, class, type
);
3570 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3573 x_frame_get_and_record_arg (f
, alist
, param
, attribute
, class, type
)
3575 Lisp_Object alist
, param
;
3578 enum resource_types type
;
3582 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3583 attribute
, class, type
);
3585 store_frame_param (f
, param
, value
);
3591 /* Record in frame F the specified or default value according to ALIST
3592 of the parameter named PROP (a Lisp symbol).
3593 If no value is specified for PROP, look for an X default for XPROP
3594 on the frame named NAME.
3595 If that is not found either, use the value DEFLT. */
3598 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
3605 enum resource_types type
;
3609 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3610 if (EQ (tem
, Qunbound
))
3612 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3619 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3620 doc
: /* Parse an X-style geometry string STRING.
3621 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3622 The properties returned may include `top', `left', `height', and `width'.
3623 The value of `left' or `top' may be an integer,
3624 or a list (+ N) meaning N pixels relative to top/left corner,
3625 or a list (- N) meaning -N pixels relative to bottom/right corner. */)
3630 unsigned int width
, height
;
3633 CHECK_STRING (string
);
3635 geometry
= XParseGeometry ((char *) SDATA (string
),
3636 &x
, &y
, &width
, &height
);
3639 if (!!(geometry
& XValue
) != !!(geometry
& YValue
))
3640 error ("Must specify both x and y position, or neither");
3644 if (geometry
& XValue
)
3646 Lisp_Object element
;
3648 if (x
>= 0 && (geometry
& XNegative
))
3649 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3650 else if (x
< 0 && ! (geometry
& XNegative
))
3651 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3653 element
= Fcons (Qleft
, make_number (x
));
3654 result
= Fcons (element
, result
);
3657 if (geometry
& YValue
)
3659 Lisp_Object element
;
3661 if (y
>= 0 && (geometry
& YNegative
))
3662 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3663 else if (y
< 0 && ! (geometry
& YNegative
))
3664 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3666 element
= Fcons (Qtop
, make_number (y
));
3667 result
= Fcons (element
, result
);
3670 if (geometry
& WidthValue
)
3671 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3672 if (geometry
& HeightValue
)
3673 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3678 /* Calculate the desired size and position of frame F.
3679 Return the flags saying which aspects were specified.
3681 Also set the win_gravity and size_hint_flags of F.
3683 Adjust height for toolbar if TOOLBAR_P is 1.
3685 This function does not make the coordinates positive. */
3687 #define DEFAULT_ROWS 40
3688 #define DEFAULT_COLS 80
3691 x_figure_window_size (f
, parms
, toolbar_p
)
3696 register Lisp_Object tem0
, tem1
, tem2
;
3697 long window_prompting
= 0;
3698 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3700 /* Default values if we fall through.
3701 Actually, if that happens we should get
3702 window manager prompting. */
3703 SET_FRAME_WIDTH (f
, DEFAULT_COLS
);
3704 f
->height
= DEFAULT_ROWS
;
3705 /* Window managers expect that if program-specified
3706 positions are not (0,0), they're intentional, not defaults. */
3707 FRAME_X_OUTPUT (f
)->top_pos
= 0;
3708 FRAME_X_OUTPUT (f
)->left_pos
= 0;
3710 /* Ensure that old new_width and new_height will not override the
3712 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3713 FRAME_NEW_WIDTH (f
) = 0;
3714 FRAME_NEW_HEIGHT (f
) = 0;
3716 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3717 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3718 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3719 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3721 if (!EQ (tem0
, Qunbound
))
3723 CHECK_NUMBER (tem0
);
3724 f
->height
= XINT (tem0
);
3726 if (!EQ (tem1
, Qunbound
))
3728 CHECK_NUMBER (tem1
);
3729 SET_FRAME_WIDTH (f
, XINT (tem1
));
3731 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
3732 window_prompting
|= USSize
;
3734 window_prompting
|= PSize
;
3737 FRAME_X_OUTPUT (f
)->vertical_scroll_bar_extra
3738 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
3740 #ifndef HAVE_X_WINDOWS
3741 /* +KFS: This was specific for W32 and MAC.. why? */
3742 : FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) > 0
3743 ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f
)
3745 : (FRAME_SCROLL_BAR_COLS (f
) * FONT_WIDTH (FRAME_X_OUTPUT (f
)->font
)));
3747 /* This used to be done _before_ calling x_figure_window_size, but
3748 since the height is reset here, this was really a no-op. I
3749 assume that moving it here does what Gerd intended (although he
3750 no longer can remember what that was... ++KFS, 2003-03-25. */
3752 /* Add the tool-bar height to the initial frame height so that the
3753 user gets a text display area of the size he specified with -g or
3754 via .Xdefaults. Later changes of the tool-bar height don't
3755 change the frame size. This is done so that users can create
3756 tall Emacs frames without having to guess how tall the tool-bar
3758 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
3760 int margin
, relief
, bar_height
;
3762 relief
= (tool_bar_button_relief
>= 0
3763 ? tool_bar_button_relief
3764 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
3766 if (INTEGERP (Vtool_bar_button_margin
)
3767 && XINT (Vtool_bar_button_margin
) > 0)
3768 margin
= XFASTINT (Vtool_bar_button_margin
);
3769 else if (CONSP (Vtool_bar_button_margin
)
3770 && INTEGERP (XCDR (Vtool_bar_button_margin
))
3771 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
3772 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
3776 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
3777 f
->height
+= (bar_height
+ CANON_Y_UNIT (f
) - 1) / CANON_Y_UNIT (f
);
3780 compute_fringe_widths (f
, 0);
3782 FRAME_X_OUTPUT (f
)->pixel_width
= CHAR_TO_PIXEL_WIDTH (f
, f
->width
);
3783 FRAME_X_OUTPUT (f
)->pixel_height
= CHAR_TO_PIXEL_HEIGHT (f
, f
->height
);
3785 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
3786 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
3787 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
3788 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3790 if (EQ (tem0
, Qminus
))
3792 FRAME_X_OUTPUT (f
)->top_pos
= 0;
3793 window_prompting
|= YNegative
;
3795 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
3796 && CONSP (XCDR (tem0
))
3797 && INTEGERP (XCAR (XCDR (tem0
))))
3799 FRAME_X_OUTPUT (f
)->top_pos
= - XINT (XCAR (XCDR (tem0
)));
3800 window_prompting
|= YNegative
;
3802 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
3803 && CONSP (XCDR (tem0
))
3804 && INTEGERP (XCAR (XCDR (tem0
))))
3806 FRAME_X_OUTPUT (f
)->top_pos
= XINT (XCAR (XCDR (tem0
)));
3808 else if (EQ (tem0
, Qunbound
))
3809 FRAME_X_OUTPUT (f
)->top_pos
= 0;
3812 CHECK_NUMBER (tem0
);
3813 FRAME_X_OUTPUT (f
)->top_pos
= XINT (tem0
);
3814 if (FRAME_X_OUTPUT (f
)->top_pos
< 0)
3815 window_prompting
|= YNegative
;
3818 if (EQ (tem1
, Qminus
))
3820 FRAME_X_OUTPUT (f
)->left_pos
= 0;
3821 window_prompting
|= XNegative
;
3823 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
3824 && CONSP (XCDR (tem1
))
3825 && INTEGERP (XCAR (XCDR (tem1
))))
3827 FRAME_X_OUTPUT (f
)->left_pos
= - XINT (XCAR (XCDR (tem1
)));
3828 window_prompting
|= XNegative
;
3830 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
3831 && CONSP (XCDR (tem1
))
3832 && INTEGERP (XCAR (XCDR (tem1
))))
3834 FRAME_X_OUTPUT (f
)->left_pos
= XINT (XCAR (XCDR (tem1
)));
3836 else if (EQ (tem1
, Qunbound
))
3837 FRAME_X_OUTPUT (f
)->left_pos
= 0;
3840 CHECK_NUMBER (tem1
);
3841 FRAME_X_OUTPUT (f
)->left_pos
= XINT (tem1
);
3842 if (FRAME_X_OUTPUT (f
)->left_pos
< 0)
3843 window_prompting
|= XNegative
;
3846 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
3847 window_prompting
|= USPosition
;
3849 window_prompting
|= PPosition
;
3852 if (FRAME_X_OUTPUT (f
)->want_fullscreen
!= FULLSCREEN_NONE
)
3857 /* It takes both for some WM:s to place it where we want */
3858 window_prompting
= USPosition
| PPosition
;
3859 x_fullscreen_adjust (f
, &width
, &height
, &top
, &left
);
3862 FRAME_X_OUTPUT (f
)->pixel_width
= CHAR_TO_PIXEL_WIDTH (f
, f
->width
);
3863 FRAME_X_OUTPUT (f
)->pixel_height
= CHAR_TO_PIXEL_HEIGHT (f
, f
->height
);
3864 FRAME_X_OUTPUT (f
)->left_pos
= left
;
3865 FRAME_X_OUTPUT (f
)->top_pos
= top
;
3868 if (window_prompting
& XNegative
)
3870 if (window_prompting
& YNegative
)
3871 FRAME_X_OUTPUT (f
)->win_gravity
= SouthEastGravity
;
3873 FRAME_X_OUTPUT (f
)->win_gravity
= NorthEastGravity
;
3877 if (window_prompting
& YNegative
)
3878 FRAME_X_OUTPUT (f
)->win_gravity
= SouthWestGravity
;
3880 FRAME_X_OUTPUT (f
)->win_gravity
= NorthWestGravity
;
3883 FRAME_X_OUTPUT (f
)->size_hint_flags
= window_prompting
;
3885 return window_prompting
;
3890 #endif /* HAVE_WINDOW_SYSTEM */
3894 /***********************************************************************
3896 ***********************************************************************/
3901 Qframep
= intern ("framep");
3902 staticpro (&Qframep
);
3903 Qframe_live_p
= intern ("frame-live-p");
3904 staticpro (&Qframe_live_p
);
3905 Qheight
= intern ("height");
3906 staticpro (&Qheight
);
3907 Qicon
= intern ("icon");
3909 Qminibuffer
= intern ("minibuffer");
3910 staticpro (&Qminibuffer
);
3911 Qmodeline
= intern ("modeline");
3912 staticpro (&Qmodeline
);
3913 Qonly
= intern ("only");
3915 Qwidth
= intern ("width");
3916 staticpro (&Qwidth
);
3917 Qgeometry
= intern ("geometry");
3918 staticpro (&Qgeometry
);
3919 Qicon_left
= intern ("icon-left");
3920 staticpro (&Qicon_left
);
3921 Qicon_top
= intern ("icon-top");
3922 staticpro (&Qicon_top
);
3923 Qleft
= intern ("left");
3925 Qright
= intern ("right");
3926 staticpro (&Qright
);
3927 Quser_position
= intern ("user-position");
3928 staticpro (&Quser_position
);
3929 Quser_size
= intern ("user-size");
3930 staticpro (&Quser_size
);
3931 Qwindow_id
= intern ("window-id");
3932 staticpro (&Qwindow_id
);
3933 #ifdef HAVE_X_WINDOWS
3934 Qouter_window_id
= intern ("outer-window-id");
3935 staticpro (&Qouter_window_id
);
3937 Qparent_id
= intern ("parent-id");
3938 staticpro (&Qparent_id
);
3941 Qw32
= intern ("w32");
3943 Qpc
= intern ("pc");
3945 Qmac
= intern ("mac");
3947 Qvisible
= intern ("visible");
3948 staticpro (&Qvisible
);
3949 Qbuffer_predicate
= intern ("buffer-predicate");
3950 staticpro (&Qbuffer_predicate
);
3951 Qbuffer_list
= intern ("buffer-list");
3952 staticpro (&Qbuffer_list
);
3953 Qdisplay_type
= intern ("display-type");
3954 staticpro (&Qdisplay_type
);
3955 Qbackground_mode
= intern ("background-mode");
3956 staticpro (&Qbackground_mode
);
3957 Qtty_color_mode
= intern ("tty-color-mode");
3958 staticpro (&Qtty_color_mode
);
3960 Qface_set_after_frame_default
= intern ("face-set-after-frame-default");
3961 staticpro (&Qface_set_after_frame_default
);
3963 Qfullwidth
= intern ("fullwidth");
3964 staticpro (&Qfullwidth
);
3965 Qfullheight
= intern ("fullheight");
3966 staticpro (&Qfullheight
);
3967 Qfullboth
= intern ("fullboth");
3968 staticpro (&Qfullboth
);
3969 Qx_resource_name
= intern ("x-resource-name");
3970 staticpro (&Qx_resource_name
);
3972 Qx_frame_parameter
= intern ("x-frame-parameter");
3973 staticpro (&Qx_frame_parameter
);
3978 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
3980 Lisp_Object v
= intern (frame_parms
[i
].name
);
3981 if (frame_parms
[i
].variable
)
3983 *frame_parms
[i
].variable
= v
;
3984 staticpro (frame_parms
[i
].variable
);
3986 Fput (v
, Qx_frame_parameter
, make_number (i
));
3990 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
3991 doc
: /* The name Emacs uses to look up X resources.
3992 `x-get-resource' uses this as the first component of the instance name
3993 when requesting resource values.
3994 Emacs initially sets `x-resource-name' to the name under which Emacs
3995 was invoked, or to the value specified with the `-name' or `-rn'
3996 switches, if present.
3998 It may be useful to bind this variable locally around a call
3999 to `x-get-resource'. See also the variable `x-resource-class'. */);
4000 Vx_resource_name
= Qnil
;
4002 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4003 doc
: /* The class Emacs uses to look up X resources.
4004 `x-get-resource' uses this as the first component of the instance class
4005 when requesting resource values.
4007 Emacs initially sets `x-resource-class' to "Emacs".
4009 Setting this variable permanently is not a reasonable thing to do,
4010 but binding this variable locally around a call to `x-get-resource'
4011 is a reasonable practice. See also the variable `x-resource-name'. */);
4012 Vx_resource_class
= build_string (EMACS_CLASS
);
4014 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4015 doc
: /* Alist of default values for frame creation.
4016 These may be set in your init file, like this:
4017 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))
4018 These override values given in window system configuration data,
4019 including X Windows' defaults database.
4020 For values specific to the first Emacs frame, see `initial-frame-alist'.
4021 For values specific to the separate minibuffer frame, see
4022 `minibuffer-frame-alist'.
4023 The `menu-bar-lines' element of the list controls whether new frames
4024 have menu bars; `menu-bar-mode' works by altering this element.
4025 Setting this variable does not affect existing frames, only new ones. */);
4026 Vdefault_frame_alist
= Qnil
;
4028 Qinhibit_default_face_x_resources
4029 = intern ("inhibit-default-face-x-resources");
4030 staticpro (&Qinhibit_default_face_x_resources
);
4032 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4033 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4035 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
4036 doc
: /* Non-nil if all of emacs is iconified and frame updates are not needed. */);
4037 Vemacs_iconified
= Qnil
;
4039 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4040 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4041 `mouse-position' calls this function, passing its usual return value as
4042 argument, and returns whatever this function returns.
4043 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4044 which need to do mouse handling at the Lisp level. */);
4045 Vmouse_position_function
= Qnil
;
4047 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4048 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4049 If the value is an integer, highlighting is only shown after moving the
4050 mouse, while keyboard input turns off the highlight even when the mouse
4051 is over the clickable text. However, the mouse shape still indicates
4052 when the mouse is over clickable text. */);
4053 Vmouse_highlight
= Qt
;
4055 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4056 doc
: /* Functions to be run before deleting a frame.
4057 The functions are run with one arg, the frame to be deleted.
4058 See `delete-frame'. */);
4059 Vdelete_frame_functions
= Qnil
;
4061 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4062 doc
: /* Minibufferless frames use this frame's minibuffer.
4064 Emacs cannot create minibufferless frames unless this is set to an
4065 appropriate surrogate.
4067 Emacs consults this variable only when creating minibufferless
4068 frames; once the frame is created, it sticks with its assigned
4069 minibuffer, no matter what this variable is set to. This means that
4070 this variable doesn't necessarily say anything meaningful about the
4071 current set of frames, or where the minibuffer is currently being
4074 This variable is local to the current terminal and cannot be buffer-local. */);
4076 staticpro (&Vframe_list
);
4078 defsubr (&Sactive_minibuffer_window
);
4080 defsubr (&Sframe_live_p
);
4081 defsubr (&Smake_terminal_frame
);
4082 defsubr (&Shandle_switch_frame
);
4083 defsubr (&Signore_event
);
4084 defsubr (&Sselect_frame
);
4085 defsubr (&Sselected_frame
);
4086 defsubr (&Swindow_frame
);
4087 defsubr (&Sframe_root_window
);
4088 defsubr (&Sframe_first_window
);
4089 defsubr (&Sframe_selected_window
);
4090 defsubr (&Sset_frame_selected_window
);
4091 defsubr (&Sframe_list
);
4092 defsubr (&Snext_frame
);
4093 defsubr (&Sprevious_frame
);
4094 defsubr (&Sdelete_frame
);
4095 defsubr (&Smouse_position
);
4096 defsubr (&Smouse_pixel_position
);
4097 defsubr (&Sset_mouse_position
);
4098 defsubr (&Sset_mouse_pixel_position
);
4100 defsubr (&Sframe_configuration
);
4101 defsubr (&Srestore_frame_configuration
);
4103 defsubr (&Smake_frame_visible
);
4104 defsubr (&Smake_frame_invisible
);
4105 defsubr (&Siconify_frame
);
4106 defsubr (&Sframe_visible_p
);
4107 defsubr (&Svisible_frame_list
);
4108 defsubr (&Sraise_frame
);
4109 defsubr (&Slower_frame
);
4110 defsubr (&Sredirect_frame_focus
);
4111 defsubr (&Sframe_focus
);
4112 defsubr (&Sframe_parameters
);
4113 defsubr (&Sframe_parameter
);
4114 defsubr (&Smodify_frame_parameters
);
4115 defsubr (&Sframe_char_height
);
4116 defsubr (&Sframe_char_width
);
4117 defsubr (&Sframe_pixel_height
);
4118 defsubr (&Sframe_pixel_width
);
4119 defsubr (&Sset_frame_height
);
4120 defsubr (&Sset_frame_width
);
4121 defsubr (&Sset_frame_size
);
4122 defsubr (&Sset_frame_position
);
4124 #ifdef HAVE_WINDOW_SYSTEM
4125 defsubr (&Sx_get_resource
);
4126 defsubr (&Sx_parse_geometry
);