1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
37 /* These help us bind and responding to switch-frame events. */
41 #ifdef HAVE_WINDOW_SYSTEM
44 #include "blockinput.h"
45 #include "termhooks.h"
46 #include "dispextern.h"
54 #ifdef HAVE_WINDOW_SYSTEM
56 /* The name we're using in resource queries. Most often "emacs". */
58 Lisp_Object Vx_resource_name
;
60 /* The application class we're using in resource queries.
63 Lisp_Object Vx_resource_class
;
67 Lisp_Object Qframep
, Qframe_live_p
;
68 Lisp_Object Qicon
, Qmodeline
;
70 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
;
72 Lisp_Object Qdisplay_type
;
73 Lisp_Object Qbackground_mode
;
75 Lisp_Object Qx_frame_parameter
;
76 Lisp_Object Qx_resource_name
;
78 /* Frame parameters (set or reported). */
80 Lisp_Object Qauto_raise
, Qauto_lower
;
81 Lisp_Object Qborder_color
, Qborder_width
;
82 Lisp_Object Qcursor_color
, Qcursor_type
;
83 Lisp_Object Qgeometry
; /* Not used */
84 Lisp_Object Qheight
, Qwidth
;
85 Lisp_Object Qleft
, Qright
;
86 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
87 Lisp_Object Qinternal_border_width
;
88 Lisp_Object Qmouse_color
;
89 Lisp_Object Qminibuffer
;
90 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
91 Lisp_Object Qvisibility
;
92 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
93 Lisp_Object Qscreen_gamma
;
94 Lisp_Object Qline_spacing
;
95 Lisp_Object Quser_position
, Quser_size
;
96 Lisp_Object Qwait_for_wm
;
97 Lisp_Object Qwindow_id
;
99 Lisp_Object Qouter_window_id
;
101 Lisp_Object Qparent_id
;
102 Lisp_Object Qtitle
, Qname
;
103 Lisp_Object Qexplicit_name
;
104 Lisp_Object Qunsplittable
;
105 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
106 Lisp_Object Qleft_fringe
, Qright_fringe
;
107 Lisp_Object Qbuffer_predicate
, Qbuffer_list
;
108 Lisp_Object Qtty_color_mode
;
110 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
;
112 Lisp_Object Qinhibit_face_set_after_frame_default
;
113 Lisp_Object Qface_set_after_frame_default
;
116 Lisp_Object Vterminal_frame
;
117 Lisp_Object Vdefault_frame_alist
;
118 Lisp_Object Vdefault_frame_scroll_bars
;
119 Lisp_Object Vmouse_position_function
;
120 Lisp_Object Vmouse_highlight
;
121 Lisp_Object Vdelete_frame_functions
;
123 int focus_follows_mouse
;
126 set_menu_bar_lines_1 (window
, n
)
130 struct window
*w
= XWINDOW (window
);
132 XSETFASTINT (w
->last_modified
, 0);
133 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
134 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
136 if (INTEGERP (w
->orig_top_line
))
137 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
138 if (INTEGERP (w
->orig_total_lines
))
139 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
141 /* Handle just the top child in a vertical split. */
142 if (!NILP (w
->vchild
))
143 set_menu_bar_lines_1 (w
->vchild
, n
);
145 /* Adjust all children in a horizontal split. */
146 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
148 w
= XWINDOW (window
);
149 set_menu_bar_lines_1 (window
, n
);
154 set_menu_bar_lines (f
, value
, oldval
)
156 Lisp_Object value
, oldval
;
159 int olines
= FRAME_MENU_BAR_LINES (f
);
161 /* Right now, menu bars don't work properly in minibuf-only frames;
162 most of the commands try to apply themselves to the minibuffer
163 frame itself, and get an error because you can't switch buffers
164 in or split the minibuffer window. */
165 if (FRAME_MINIBUF_ONLY_P (f
))
168 if (INTEGERP (value
))
169 nlines
= XINT (value
);
173 if (nlines
!= olines
)
175 windows_or_buffers_changed
++;
176 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
177 FRAME_MENU_BAR_LINES (f
) = nlines
;
178 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
183 Lisp_Object Vemacs_iconified
;
184 Lisp_Object Vframe_list
;
186 struct x_output tty_display
;
188 extern Lisp_Object Vminibuffer_list
;
189 extern Lisp_Object
get_minibuffer ();
190 extern Lisp_Object
Fhandle_switch_frame ();
191 extern Lisp_Object
Fredirect_frame_focus ();
192 extern Lisp_Object
x_get_focus_frame ();
194 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
195 doc
: /* Return non-nil if OBJECT is a frame.
196 Value is t for a termcap frame (a character-only terminal),
197 `x' for an Emacs frame that is really an X window,
198 `w32' for an Emacs frame that is a window on MS-Windows display,
199 `mac' for an Emacs frame on a Macintosh display,
200 `pc' for a direct-write MS-DOS frame.
201 See also `frame-live-p'. */)
205 if (!FRAMEP (object
))
207 switch (XFRAME (object
)->output_method
)
211 case output_x_window
:
215 case output_msdos_raw
:
224 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
225 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
226 Value is nil if OBJECT is not a live frame. If object is a live
227 frame, the return value indicates what sort of output device it is
228 displayed on. See the documentation of `framep' for possible
233 return ((FRAMEP (object
)
234 && FRAME_LIVE_P (XFRAME (object
)))
244 register struct frame
*f
;
245 register Lisp_Object root_window
;
246 register Lisp_Object mini_window
;
248 f
= allocate_frame ();
249 XSETFRAME (frame
, f
);
251 f
->desired_matrix
= 0;
252 f
->current_matrix
= 0;
255 f
->glyphs_initialized_p
= 0;
256 f
->decode_mode_spec_buffer
= 0;
258 f
->async_visible
= 0;
259 f
->output_data
.nothing
= 0;
261 f
->async_iconified
= 0;
262 f
->wants_modeline
= 1;
267 f
->has_minibuffer
= mini_p
;
268 f
->focus_frame
= Qnil
;
269 f
->explicit_name
= 0;
270 f
->can_have_scroll_bars
= 0;
271 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
272 f
->param_alist
= Qnil
;
273 f
->scroll_bars
= Qnil
;
274 f
->condemned_scroll_bars
= Qnil
;
275 f
->face_alist
= Qnil
;
276 f
->face_cache
= NULL
;
277 f
->menu_bar_items
= Qnil
;
278 f
->menu_bar_vector
= Qnil
;
279 f
->menu_bar_items_used
= 0;
280 f
->buffer_predicate
= Qnil
;
281 f
->buffer_list
= Qnil
;
283 f
->kboard
= initial_kboard
;
287 f
->menu_bar_window
= Qnil
;
288 f
->tool_bar_window
= Qnil
;
289 f
->tool_bar_items
= Qnil
;
290 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
291 f
->n_tool_bar_items
= 0;
292 f
->left_fringe_width
= f
->right_fringe_width
= 0;
294 f
->scroll_bar_actual_width
= 0;
296 f
->internal_border_width
= 0;
297 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
298 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
299 f
->x_pixels_diff
= f
->y_pixels_diff
= 0;
300 #ifdef HAVE_WINDOW_SYSTEM
301 f
->want_fullscreen
= FULLSCREEN_NONE
;
303 f
->size_hint_flags
= 0;
306 root_window
= make_window ();
309 mini_window
= make_window ();
310 XWINDOW (root_window
)->next
= mini_window
;
311 XWINDOW (mini_window
)->prev
= root_window
;
312 XWINDOW (mini_window
)->mini_p
= Qt
;
313 XWINDOW (mini_window
)->frame
= frame
;
314 f
->minibuffer_window
= mini_window
;
319 XWINDOW (root_window
)->next
= Qnil
;
320 f
->minibuffer_window
= Qnil
;
323 XWINDOW (root_window
)->frame
= frame
;
326 just so that there is "something there."
327 Correct size will be set up later with change_frame_size. */
329 SET_FRAME_COLS (f
, 10);
330 FRAME_LINES (f
) = 10;
332 XSETFASTINT (XWINDOW (root_window
)->total_cols
, 10);
333 XSETFASTINT (XWINDOW (root_window
)->total_lines
, (mini_p
? 9 : 10));
337 XSETFASTINT (XWINDOW (mini_window
)->total_cols
, 10);
338 XSETFASTINT (XWINDOW (mini_window
)->top_line
, 9);
339 XSETFASTINT (XWINDOW (mini_window
)->total_lines
, 1);
342 /* Choose a buffer for the frame's root window. */
346 XWINDOW (root_window
)->buffer
= Qt
;
347 buf
= Fcurrent_buffer ();
348 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
349 a space), try to find another one. */
350 if (SREF (Fbuffer_name (buf
), 0) == ' ')
351 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
353 /* Use set_window_buffer, not Fset_window_buffer, and don't let
354 hooks be run by it. The reason is that the whole frame/window
355 arrangement is not yet fully intialized at this point. Windows
356 don't have the right size, glyph matrices aren't initialized
357 etc. Running Lisp functions at this point surely ends in a
359 set_window_buffer (root_window
, buf
, 0, 0);
360 f
->buffer_list
= Fcons (buf
, Qnil
);
365 XWINDOW (mini_window
)->buffer
= Qt
;
366 set_window_buffer (mini_window
,
367 (NILP (Vminibuffer_list
)
369 : Fcar (Vminibuffer_list
)),
373 f
->root_window
= root_window
;
374 f
->selected_window
= root_window
;
375 /* Make sure this window seems more recently used than
376 a newly-created, never-selected window. */
377 ++window_select_count
;
378 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, window_select_count
);
380 f
->default_face_done_p
= 0;
385 #ifdef HAVE_WINDOW_SYSTEM
386 /* Make a frame using a separate minibuffer window on another frame.
387 MINI_WINDOW is the minibuffer window to use. nil means use the
388 default (the global minibuffer). */
391 make_frame_without_minibuffer (mini_window
, kb
, display
)
392 register Lisp_Object mini_window
;
396 register struct frame
*f
;
399 if (!NILP (mini_window
))
400 CHECK_LIVE_WINDOW (mini_window
);
403 if (!NILP (mini_window
)
404 && XFRAME (XWINDOW (mini_window
)->frame
)->kboard
!= kb
)
405 error ("Frame and minibuffer must be on the same display");
408 /* Make a frame containing just a root window. */
411 if (NILP (mini_window
))
413 /* Use default-minibuffer-frame if possible. */
414 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
415 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
417 Lisp_Object frame_dummy
;
419 XSETFRAME (frame_dummy
, f
);
420 GCPRO1 (frame_dummy
);
421 /* If there's no minibuffer frame to use, create one. */
422 kb
->Vdefault_minibuffer_frame
=
423 call1 (intern ("make-initial-minibuffer-frame"), display
);
427 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
430 f
->minibuffer_window
= mini_window
;
432 /* Make the chosen minibuffer window display the proper minibuffer,
433 unless it is already showing a minibuffer. */
434 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
435 Fset_window_buffer (mini_window
,
436 (NILP (Vminibuffer_list
)
438 : Fcar (Vminibuffer_list
)), Qnil
);
442 /* Make a frame containing only a minibuffer window. */
445 make_minibuffer_frame ()
447 /* First make a frame containing just a root window, no minibuffer. */
449 register struct frame
*f
= make_frame (0);
450 register Lisp_Object mini_window
;
451 register Lisp_Object frame
;
453 XSETFRAME (frame
, f
);
458 f
->wants_modeline
= 0;
459 f
->has_minibuffer
= 1;
461 /* Now label the root window as also being the minibuffer.
462 Avoid infinite looping on the window chain by marking next pointer
465 mini_window
= f
->minibuffer_window
= f
->root_window
;
466 XWINDOW (mini_window
)->mini_p
= Qt
;
467 XWINDOW (mini_window
)->next
= Qnil
;
468 XWINDOW (mini_window
)->prev
= Qnil
;
469 XWINDOW (mini_window
)->frame
= frame
;
471 /* Put the proper buffer in that window. */
473 Fset_window_buffer (mini_window
,
474 (NILP (Vminibuffer_list
)
476 : Fcar (Vminibuffer_list
)), Qnil
);
479 #endif /* HAVE_WINDOW_SYSTEM */
481 /* Construct a frame that refers to the terminal (stdin and stdout). */
483 static int terminal_frame_count
;
486 make_terminal_frame ()
488 register struct frame
*f
;
495 initial_kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
496 init_kboard (initial_kboard
);
497 initial_kboard
->next_kboard
= all_kboards
;
498 all_kboards
= initial_kboard
;
502 /* The first call must initialize Vframe_list. */
503 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
508 XSETFRAME (frame
, f
);
509 Vframe_list
= Fcons (frame
, Vframe_list
);
511 terminal_frame_count
++;
512 sprintf (name
, "F%d", terminal_frame_count
);
513 f
->name
= build_string (name
);
515 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
516 f
->async_visible
= 1; /* Don't let visible be cleared later. */
518 f
->output_data
.x
= &the_only_x_display
;
519 if (!inhibit_window_system
520 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
521 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
523 f
->output_method
= output_msdos_raw
;
524 /* This initialization of foreground and background pixels is
525 only important for the initial frame created in temacs. If
526 we don't do that, we get black background and foreground in
527 the dumped Emacs because the_only_x_display is a static
528 variable, hence it is born all-zeroes, and zero is the code
529 for the black color. Other frames all inherit their pixels
530 from what's already in the_only_x_display. */
531 if ((!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
532 && f
->output_data
.x
->background_pixel
== 0
533 && f
->output_data
.x
->foreground_pixel
== 0)
535 f
->output_data
.x
->background_pixel
= FACE_TTY_DEFAULT_BG_COLOR
;
536 f
->output_data
.x
->foreground_pixel
= FACE_TTY_DEFAULT_FG_COLOR
;
540 f
->output_method
= output_termcap
;
543 f
->output_method
= output_termcap
;
544 f
->output_data
.x
= &tty_display
;
547 make_mac_terminal_frame (f
);
549 f
->output_data
.x
= &tty_display
;
551 FRAME_FOREGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_FG_COLOR
;
552 FRAME_BACKGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_BG_COLOR
;
555 #endif /* WINDOWSNT */
559 init_frame_faces (f
);
564 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
566 doc
: /* Create an additional terminal frame.
567 You can create multiple frames on a text-only terminal in this way.
568 Only the selected terminal frame is actually displayed.
569 This function takes one argument, an alist specifying frame parameters.
570 In practice, generally you don't need to specify any parameters.
571 Note that changing the size of one terminal frame automatically affects all. */)
576 Lisp_Object frame
, tem
;
577 struct frame
*sf
= SELECTED_FRAME ();
580 if (sf
->output_method
!= output_msdos_raw
581 && sf
->output_method
!= output_termcap
)
583 #else /* not MSDOS */
586 if (sf
->output_method
!= output_mac
)
587 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
589 if (sf
->output_method
!= output_termcap
)
590 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
592 #endif /* not MSDOS */
594 f
= make_terminal_frame ();
596 change_frame_size (f
, FRAME_LINES (sf
),
597 FRAME_COLS (sf
), 0, 0, 0);
600 XSETFRAME (frame
, f
);
601 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
602 Fmodify_frame_parameters (frame
, parms
);
604 /* Make the frame face alist be frame-specific, so that each
605 frame could change its face definitions independently. */
606 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
607 /* Simple Fcopy_alist isn't enough, because we need the contents of
608 the vectors which are the CDRs of associations in face_alist to
609 be copied as well. */
610 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
611 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
616 /* Perform the switch to frame FRAME.
618 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
621 If TRACK is non-zero and the frame that currently has the focus
622 redirects its focus to the selected frame, redirect that focused
623 frame's focus to FRAME instead.
625 FOR_DELETION non-zero means that the selected frame is being
626 deleted, which includes the possibility that the frame's display
630 do_switch_frame (frame
, track
, for_deletion
)
632 int track
, for_deletion
;
634 struct frame
*sf
= SELECTED_FRAME ();
636 /* If FRAME is a switch-frame event, extract the frame we should
639 && EQ (XCAR (frame
), Qswitch_frame
)
640 && CONSP (XCDR (frame
)))
641 frame
= XCAR (XCDR (frame
));
643 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
644 a switch-frame event to arrive after a frame is no longer live,
645 especially when deleting the initial frame during startup. */
647 if (! FRAME_LIVE_P (XFRAME (frame
)))
650 if (sf
== XFRAME (frame
))
653 /* This is too greedy; it causes inappropriate focus redirection
654 that's hard to get rid of. */
656 /* If a frame's focus has been redirected toward the currently
657 selected frame, we should change the redirection to point to the
658 newly selected frame. This means that if the focus is redirected
659 from a minibufferless frame to a surrogate minibuffer frame, we
660 can use `other-window' to switch between all the frames using
661 that minibuffer frame, and the focus redirection will follow us
667 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
671 if (!FRAMEP (XCAR (tail
)))
674 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
676 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
677 Fredirect_frame_focus (XCAR (tail
), frame
);
681 /* Instead, apply it only to the frame we're pointing to. */
682 #ifdef HAVE_WINDOW_SYSTEM
683 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
685 Lisp_Object focus
, xfocus
;
687 xfocus
= x_get_focus_frame (XFRAME (frame
));
690 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
691 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
692 Fredirect_frame_focus (xfocus
, frame
);
695 #endif /* HAVE_X_WINDOWS */
698 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
699 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
701 selected_frame
= frame
;
702 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
703 last_nonminibuf_frame
= XFRAME (selected_frame
);
705 Fselect_window (XFRAME (frame
)->selected_window
, Qnil
);
708 /* Make sure to switch the tty color mode to that of the newly
710 sf
= SELECTED_FRAME ();
711 if (FRAME_TERMCAP_P (sf
))
713 Lisp_Object color_mode_spec
, color_mode
;
715 color_mode_spec
= assq_no_quit (Qtty_color_mode
, sf
->param_alist
);
716 if (CONSP (color_mode_spec
))
717 color_mode
= XCDR (color_mode_spec
);
719 color_mode
= make_number (0);
720 set_tty_color_mode (sf
, color_mode
);
722 #endif /* !WINDOWSNT */
724 /* We want to make sure that the next event generates a frame-switch
725 event to the appropriate frame. This seems kludgy to me, but
726 before you take it out, make sure that evaluating something like
727 (select-window (frame-root-window (new-frame))) doesn't end up
728 with your typing being interpreted in the new frame instead of
729 the one you're actually typing in. */
730 internal_last_event_frame
= Qnil
;
735 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 1, "e",
736 doc
: /* Select the frame FRAME.
737 Subsequent editing commands apply to its selected window.
738 The selection of FRAME lasts until the next time the user does
739 something to select a different frame, or until the next time this
740 function is called. If you are using a window system, the previously
741 selected frame may be restored as the selected frame after return to
742 the command loop, because it still may have the window system's input
743 focus. On a text-only terminal, the next redisplay will display FRAME.
745 This function returns FRAME, or nil if FRAME has been deleted. */)
749 return do_switch_frame (frame
, 1, 0);
753 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
754 doc
: /* Handle a switch-frame event EVENT.
755 Switch-frame events are usually bound to this function.
756 A switch-frame event tells Emacs that the window manager has requested
757 that the user's events be directed to the frame mentioned in the event.
758 This function selects the selected window of the frame of EVENT.
760 If EVENT is frame object, handle it as if it were a switch-frame event
765 /* Preserve prefix arg that the command loop just cleared. */
766 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
767 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
768 return do_switch_frame (event
, 0, 0);
771 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
772 doc
: /* Return the frame that is now selected. */)
775 return selected_frame
;
778 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
779 doc
: /* Return the frame object that window WINDOW is on. */)
783 CHECK_LIVE_WINDOW (window
);
784 return XWINDOW (window
)->frame
;
787 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
788 doc
: /* Returns the topmost, leftmost window of FRAME.
789 If omitted, FRAME defaults to the currently selected frame. */)
796 w
= SELECTED_FRAME ()->root_window
;
799 CHECK_LIVE_FRAME (frame
);
800 w
= XFRAME (frame
)->root_window
;
802 while (NILP (XWINDOW (w
)->buffer
))
804 if (! NILP (XWINDOW (w
)->hchild
))
805 w
= XWINDOW (w
)->hchild
;
806 else if (! NILP (XWINDOW (w
)->vchild
))
807 w
= XWINDOW (w
)->vchild
;
814 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
815 Sactive_minibuffer_window
, 0, 0, 0,
816 doc
: /* Return the currently active minibuffer window, or nil if none. */)
819 return minibuf_level
? minibuf_window
: Qnil
;
822 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
823 doc
: /* Returns the root-window of FRAME.
824 If omitted, FRAME defaults to the currently selected frame. */)
831 window
= SELECTED_FRAME ()->root_window
;
834 CHECK_LIVE_FRAME (frame
);
835 window
= XFRAME (frame
)->root_window
;
841 DEFUN ("frame-selected-window", Fframe_selected_window
,
842 Sframe_selected_window
, 0, 1, 0,
843 doc
: /* Return the selected window of frame object FRAME.
844 If omitted, FRAME defaults to the currently selected frame. */)
851 window
= SELECTED_FRAME ()->selected_window
;
854 CHECK_LIVE_FRAME (frame
);
855 window
= XFRAME (frame
)->selected_window
;
861 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
862 Sset_frame_selected_window
, 2, 2, 0,
863 doc
: /* Set the selected window of frame object FRAME to WINDOW.
865 If FRAME is nil, the selected frame is used.
866 If FRAME is the selected frame, this makes WINDOW the selected window. */)
868 Lisp_Object frame
, window
;
871 frame
= selected_frame
;
873 CHECK_LIVE_FRAME (frame
);
874 CHECK_LIVE_WINDOW (window
);
876 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
877 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
879 if (EQ (frame
, selected_frame
))
880 return Fselect_window (window
, Qnil
);
882 return XFRAME (frame
)->selected_window
= window
;
885 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
887 doc
: /* Return a list of all frames. */)
891 frames
= Fcopy_sequence (Vframe_list
);
892 #ifdef HAVE_WINDOW_SYSTEM
893 if (FRAMEP (tip_frame
))
894 frames
= Fdelq (tip_frame
, frames
);
899 /* Return the next frame in the frame list after FRAME.
900 If MINIBUF is nil, exclude minibuffer-only frames.
901 If MINIBUF is a window, include only its own frame
902 and any frame now using that window as the minibuffer.
903 If MINIBUF is `visible', include all visible frames.
904 If MINIBUF is 0, include all visible and iconified frames.
905 Otherwise, include all frames. */
908 next_frame (frame
, minibuf
)
915 /* There must always be at least one frame in Vframe_list. */
916 if (! CONSP (Vframe_list
))
919 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
920 forever. Forestall that. */
921 CHECK_LIVE_FRAME (frame
);
924 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
931 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
933 /* Decide whether this frame is eligible to be returned. */
935 /* If we've looped all the way around without finding any
936 eligible frames, return the original frame. */
940 /* Let minibuf decide if this frame is acceptable. */
943 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
946 else if (EQ (minibuf
, Qvisible
))
948 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
949 if (FRAME_VISIBLE_P (XFRAME (f
)))
952 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
954 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
955 if (FRAME_VISIBLE_P (XFRAME (f
))
956 || FRAME_ICONIFIED_P (XFRAME (f
)))
959 else if (WINDOWP (minibuf
))
961 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
962 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
963 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
964 FRAME_FOCUS_FRAME (XFRAME (f
))))
976 /* Return the previous frame in the frame list before FRAME.
977 If MINIBUF is nil, exclude minibuffer-only frames.
978 If MINIBUF is a window, include only its own frame
979 and any frame now using that window as the minibuffer.
980 If MINIBUF is `visible', include all visible frames.
981 If MINIBUF is 0, include all visible and iconified frames.
982 Otherwise, include all frames. */
985 prev_frame (frame
, minibuf
)
992 /* There must always be at least one frame in Vframe_list. */
993 if (! CONSP (Vframe_list
))
997 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1005 if (EQ (frame
, f
) && !NILP (prev
))
1008 if (FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1010 /* Decide whether this frame is eligible to be returned,
1011 according to minibuf. */
1014 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1017 else if (WINDOWP (minibuf
))
1019 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1020 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1021 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1022 FRAME_FOCUS_FRAME (XFRAME (f
))))
1025 else if (EQ (minibuf
, Qvisible
))
1027 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1028 if (FRAME_VISIBLE_P (XFRAME (f
)))
1031 else if (XFASTINT (minibuf
) == 0)
1033 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1034 if (FRAME_VISIBLE_P (XFRAME (f
))
1035 || FRAME_ICONIFIED_P (XFRAME (f
)))
1043 /* We've scanned the entire list. */
1045 /* We went through the whole frame list without finding a single
1046 acceptable frame. Return the original frame. */
1049 /* There were no acceptable frames in the list before FRAME; otherwise,
1050 we would have returned directly from the loop. Since PREV is the last
1051 acceptable frame in the list, return it. */
1056 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1057 doc
: /* Return the next frame in the frame list after FRAME.
1058 It considers only frames on the same terminal as FRAME.
1059 By default, skip minibuffer-only frames.
1060 If omitted, FRAME defaults to the selected frame.
1061 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1062 If MINIFRAME is a window, include only its own frame
1063 and any frame now using that window as the minibuffer.
1064 If MINIFRAME is `visible', include all visible frames.
1065 If MINIFRAME is 0, include all visible and iconified frames.
1066 Otherwise, include all frames. */)
1068 Lisp_Object frame
, miniframe
;
1071 frame
= selected_frame
;
1073 CHECK_LIVE_FRAME (frame
);
1074 return next_frame (frame
, miniframe
);
1077 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1078 doc
: /* Return the previous frame in the frame list before FRAME.
1079 It considers only frames on the same terminal as FRAME.
1080 By default, skip minibuffer-only frames.
1081 If omitted, FRAME defaults to the selected frame.
1082 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1083 If MINIFRAME is a window, include only its own frame
1084 and any frame now using that window as the minibuffer.
1085 If MINIFRAME is `visible', include all visible frames.
1086 If MINIFRAME is 0, include all visible and iconified frames.
1087 Otherwise, include all frames. */)
1089 Lisp_Object frame
, miniframe
;
1092 frame
= selected_frame
;
1093 CHECK_LIVE_FRAME (frame
);
1094 return prev_frame (frame
, miniframe
);
1097 /* Return 1 if it is ok to delete frame F;
1098 0 if all frames aside from F are invisible.
1099 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1102 other_visible_frames (f
)
1105 /* We know the selected frame is visible,
1106 so if F is some other frame, it can't be the sole visible one. */
1107 if (f
== SELECTED_FRAME ())
1112 for (frames
= Vframe_list
;
1114 frames
= XCDR (frames
))
1118 this = XCAR (frames
);
1119 /* Verify that the frame's window still exists
1120 and we can still talk to it. And note any recent change
1122 #ifdef HAVE_WINDOW_SYSTEM
1123 if (FRAME_WINDOW_P (XFRAME (this)))
1125 x_sync (XFRAME (this));
1126 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1130 if (FRAME_VISIBLE_P (XFRAME (this))
1131 || FRAME_ICONIFIED_P (XFRAME (this))
1132 /* Allow deleting the terminal frame when at least
1133 one X frame exists! */
1134 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1142 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1143 doc
: /* Delete FRAME, permanently eliminating it from use.
1144 If omitted, FRAME defaults to the selected frame.
1145 A frame may not be deleted if its minibuffer is used by other frames.
1146 Normally, you may not delete a frame if all other frames are invisible,
1147 but if the second optional argument FORCE is non-nil, you may do so.
1149 This function runs `delete-frame-functions' before actually deleting the
1150 frame, unless the frame is a tooltip.
1151 The functions are run with one arg, the frame to be deleted. */)
1153 Lisp_Object frame
, force
;
1156 struct frame
*sf
= SELECTED_FRAME ();
1157 int minibuffer_selected
;
1159 if (EQ (frame
, Qnil
))
1162 XSETFRAME (frame
, f
);
1166 CHECK_FRAME (frame
);
1170 if (! FRAME_LIVE_P (f
))
1173 if (NILP (force
) && !other_visible_frames (f
)
1175 /* Terminal frame deleted before any other visible frames are
1177 && strcmp (SDATA (f
->name
), "F1") != 0
1180 error ("Attempt to delete the sole visible or iconified frame");
1183 /* This is a nice idea, but x_connection_closed needs to be able
1184 to delete the last frame, if it is gone. */
1185 if (NILP (XCDR (Vframe_list
)))
1186 error ("Attempt to delete the only frame");
1189 /* Does this frame have a minibuffer, and is it the surrogate
1190 minibuffer for any other frame? */
1191 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1195 for (frames
= Vframe_list
;
1197 frames
= XCDR (frames
))
1200 this = XCAR (frames
);
1202 if (! EQ (this, frame
)
1204 WINDOW_FRAME (XWINDOW
1205 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1206 error ("Attempt to delete a surrogate minibuffer frame");
1210 /* Run `delete-frame-functions' unless frame is a tooltip. */
1211 if (!NILP (Vrun_hooks
)
1212 && NILP (Fframe_parameter (frame
, intern ("tooltip"))))
1214 Lisp_Object args
[2];
1215 args
[0] = intern ("delete-frame-functions");
1217 Frun_hook_with_args (2, args
);
1220 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1222 /* Don't let the frame remain selected. */
1225 Lisp_Object tail
, frame1
;
1227 /* Look for another visible frame on the same terminal. */
1228 frame1
= next_frame (frame
, Qvisible
);
1230 /* If there is none, find *some* other frame. */
1231 if (NILP (frame1
) || EQ (frame1
, frame
))
1233 FOR_EACH_FRAME (tail
, frame1
)
1235 if (! EQ (frame
, frame1
))
1240 do_switch_frame (frame1
, 0, 1);
1241 sf
= SELECTED_FRAME ();
1244 /* Don't allow minibuf_window to remain on a deleted frame. */
1245 if (EQ (f
->minibuffer_window
, minibuf_window
))
1247 Fset_window_buffer (sf
->minibuffer_window
,
1248 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1249 minibuf_window
= sf
->minibuffer_window
;
1251 /* If the dying minibuffer window was selected,
1252 select the new one. */
1253 if (minibuffer_selected
)
1254 Fselect_window (minibuf_window
, Qnil
);
1257 /* Don't let echo_area_window to remain on a deleted frame. */
1258 if (EQ (f
->minibuffer_window
, echo_area_window
))
1259 echo_area_window
= sf
->minibuffer_window
;
1261 /* Clear any X selections for this frame. */
1262 #ifdef HAVE_X_WINDOWS
1264 x_clear_frame_selections (f
);
1267 if (FRAME_MAC_P (f
))
1268 x_clear_frame_selections (f
);
1272 This function must be called before the window tree of the
1273 frame is deleted because windows contain dynamically allocated
1277 /* Mark all the windows that used to be on FRAME as deleted, and then
1278 remove the reference to them. */
1279 delete_all_subwindows (XWINDOW (f
->root_window
));
1280 f
->root_window
= Qnil
;
1282 Vframe_list
= Fdelq (frame
, Vframe_list
);
1283 FRAME_SET_VISIBLE (f
, 0);
1287 if (f
->decode_mode_spec_buffer
)
1288 xfree (f
->decode_mode_spec_buffer
);
1289 if (FRAME_INSERT_COST (f
))
1290 xfree (FRAME_INSERT_COST (f
));
1291 if (FRAME_DELETEN_COST (f
))
1292 xfree (FRAME_DELETEN_COST (f
));
1293 if (FRAME_INSERTN_COST (f
))
1294 xfree (FRAME_INSERTN_COST (f
));
1295 if (FRAME_DELETE_COST (f
))
1296 xfree (FRAME_DELETE_COST (f
));
1297 if (FRAME_MESSAGE_BUF (f
))
1298 xfree (FRAME_MESSAGE_BUF (f
));
1300 /* Since some events are handled at the interrupt level, we may get
1301 an event for f at any time; if we zero out the frame's display
1302 now, then we may trip up the event-handling code. Instead, we'll
1303 promise that the display of the frame must be valid until we have
1304 called the window-system-dependent frame destruction routine. */
1306 /* I think this should be done with a hook. */
1307 #ifdef HAVE_WINDOW_SYSTEM
1308 if (FRAME_WINDOW_P (f
))
1309 x_destroy_window (f
);
1312 f
->output_data
.nothing
= 0;
1314 /* If we've deleted the last_nonminibuf_frame, then try to find
1316 if (f
== last_nonminibuf_frame
)
1320 last_nonminibuf_frame
= 0;
1322 for (frames
= Vframe_list
;
1324 frames
= XCDR (frames
))
1326 f
= XFRAME (XCAR (frames
));
1327 if (!FRAME_MINIBUF_ONLY_P (f
))
1329 last_nonminibuf_frame
= f
;
1335 /* If there's no other frame on the same kboard, get out of
1336 single-kboard state if we're in it for this kboard. */
1339 /* Some frame we found on the same kboard, or nil if there are none. */
1340 Lisp_Object frame_on_same_kboard
;
1342 frame_on_same_kboard
= Qnil
;
1344 for (frames
= Vframe_list
;
1346 frames
= XCDR (frames
))
1351 this = XCAR (frames
);
1356 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1357 frame_on_same_kboard
= this;
1360 if (NILP (frame_on_same_kboard
))
1361 not_single_kboard_state (FRAME_KBOARD (f
));
1365 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1366 find another one. Prefer minibuffer-only frames, but also notice
1367 frames with other windows. */
1368 if (EQ (frame
, FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
))
1372 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1373 Lisp_Object frame_with_minibuf
;
1374 /* Some frame we found on the same kboard, or nil if there are none. */
1375 Lisp_Object frame_on_same_kboard
;
1377 frame_on_same_kboard
= Qnil
;
1378 frame_with_minibuf
= Qnil
;
1380 for (frames
= Vframe_list
;
1382 frames
= XCDR (frames
))
1387 this = XCAR (frames
);
1392 /* Consider only frames on the same kboard
1393 and only those with minibuffers. */
1394 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
)
1395 && FRAME_HAS_MINIBUF_P (f1
))
1397 frame_with_minibuf
= this;
1398 if (FRAME_MINIBUF_ONLY_P (f1
))
1402 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1403 frame_on_same_kboard
= this;
1406 if (!NILP (frame_on_same_kboard
))
1408 /* We know that there must be some frame with a minibuffer out
1409 there. If this were not true, all of the frames present
1410 would have to be minibufferless, which implies that at some
1411 point their minibuffer frames must have been deleted, but
1412 that is prohibited at the top; you can't delete surrogate
1413 minibuffer frames. */
1414 if (NILP (frame_with_minibuf
))
1417 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1420 /* No frames left on this kboard--say no minibuffer either. */
1421 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= Qnil
;
1424 /* Cause frame titles to update--necessary if we now have just one frame. */
1425 update_mode_lines
= 1;
1430 /* Return mouse position in character cell units. */
1432 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1433 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1434 The position is given in character cells, where (0, 0) is the
1435 upper-left corner of the frame, X is the horizontal offset, and Y is
1436 the vertical offset.
1437 If Emacs is running on a mouseless terminal or hasn't been programmed
1438 to read the mouse position, it returns the selected frame for FRAME
1439 and nil for X and Y.
1440 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1441 passing the normal return value to that function as an argument,
1442 and returns whatever that function returns. */)
1446 Lisp_Object lispy_dummy
;
1447 enum scroll_bar_part party_dummy
;
1448 Lisp_Object x
, y
, retval
;
1450 unsigned long long_dummy
;
1451 struct gcpro gcpro1
;
1453 f
= SELECTED_FRAME ();
1457 /* It's okay for the hook to refrain from storing anything. */
1458 if (mouse_position_hook
)
1459 (*mouse_position_hook
) (&f
, -1,
1460 &lispy_dummy
, &party_dummy
,
1467 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1472 XSETFRAME (lispy_dummy
, f
);
1473 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1475 if (!NILP (Vmouse_position_function
))
1476 retval
= call1 (Vmouse_position_function
, retval
);
1477 RETURN_UNGCPRO (retval
);
1480 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1481 Smouse_pixel_position
, 0, 0, 0,
1482 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1483 The position is given in pixel units, where (0, 0) is the
1484 upper-left corner of the frame, X is the horizontal offset, and Y is
1485 the vertical offset.
1486 If Emacs is running on a mouseless terminal or hasn't been programmed
1487 to read the mouse position, it returns the selected frame for FRAME
1488 and nil for X and Y. */)
1492 Lisp_Object lispy_dummy
;
1493 enum scroll_bar_part party_dummy
;
1495 unsigned long long_dummy
;
1497 f
= SELECTED_FRAME ();
1501 /* It's okay for the hook to refrain from storing anything. */
1502 if (mouse_position_hook
)
1503 (*mouse_position_hook
) (&f
, -1,
1504 &lispy_dummy
, &party_dummy
,
1508 XSETFRAME (lispy_dummy
, f
);
1509 return Fcons (lispy_dummy
, Fcons (x
, y
));
1512 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1513 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1514 Coordinates are relative to the frame, not a window,
1515 so the coordinates of the top left character in the frame
1516 may be nonzero due to left-hand scroll bars or the menu bar.
1518 The position is given in character cells, where (0, 0) is the
1519 upper-left corner of the frame, X is the horizontal offset, and Y is
1520 the vertical offset.
1522 This function is a no-op for an X frame that is not visible.
1523 If you have just created a frame, you must wait for it to become visible
1524 before calling this function on it, like this.
1525 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1527 Lisp_Object frame
, x
, y
;
1529 CHECK_LIVE_FRAME (frame
);
1533 /* I think this should be done with a hook. */
1534 #ifdef HAVE_WINDOW_SYSTEM
1535 if (FRAME_WINDOW_P (XFRAME (frame
)))
1536 /* Warping the mouse will cause enternotify and focus events. */
1537 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1539 #if defined (MSDOS) && defined (HAVE_MOUSE)
1540 if (FRAME_MSDOS_P (XFRAME (frame
)))
1542 Fselect_frame (frame
);
1543 mouse_moveto (XINT (x
), XINT (y
));
1551 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1552 Sset_mouse_pixel_position
, 3, 3, 0,
1553 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1554 The position is given in pixels, where (0, 0) is the upper-left corner
1555 of the frame, X is the horizontal offset, and Y is the vertical offset.
1557 Note, this is a no-op for an X frame that is not visible.
1558 If you have just created a frame, you must wait for it to become visible
1559 before calling this function on it, like this.
1560 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1562 Lisp_Object frame
, x
, y
;
1564 CHECK_LIVE_FRAME (frame
);
1568 /* I think this should be done with a hook. */
1569 #ifdef HAVE_WINDOW_SYSTEM
1570 if (FRAME_WINDOW_P (XFRAME (frame
)))
1571 /* Warping the mouse will cause enternotify and focus events. */
1572 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1574 #if defined (MSDOS) && defined (HAVE_MOUSE)
1575 if (FRAME_MSDOS_P (XFRAME (frame
)))
1577 Fselect_frame (frame
);
1578 mouse_moveto (XINT (x
), XINT (y
));
1586 static void make_frame_visible_1
P_ ((Lisp_Object
));
1588 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1590 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1591 If omitted, FRAME defaults to the currently selected frame. */)
1596 frame
= selected_frame
;
1598 CHECK_LIVE_FRAME (frame
);
1600 /* I think this should be done with a hook. */
1601 #ifdef HAVE_WINDOW_SYSTEM
1602 if (FRAME_WINDOW_P (XFRAME (frame
)))
1604 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1605 x_make_frame_visible (XFRAME (frame
));
1609 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1611 /* Make menu bar update for the Buffers and Frames menus. */
1612 windows_or_buffers_changed
++;
1617 /* Update the display_time slot of the buffers shown in WINDOW
1618 and all its descendents. */
1621 make_frame_visible_1 (window
)
1626 for (;!NILP (window
); window
= w
->next
)
1628 w
= XWINDOW (window
);
1630 if (!NILP (w
->buffer
))
1631 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1633 if (!NILP (w
->vchild
))
1634 make_frame_visible_1 (w
->vchild
);
1635 if (!NILP (w
->hchild
))
1636 make_frame_visible_1 (w
->hchild
);
1640 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1642 doc
: /* Make the frame FRAME invisible (assuming it is an X window).
1643 If omitted, FRAME defaults to the currently selected frame.
1644 Normally you may not make FRAME invisible if all other frames are invisible,
1645 but if the second optional argument FORCE is non-nil, you may do so. */)
1647 Lisp_Object frame
, force
;
1650 frame
= selected_frame
;
1652 CHECK_LIVE_FRAME (frame
);
1654 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1655 error ("Attempt to make invisible the sole visible or iconified frame");
1657 #if 0 /* This isn't logically necessary, and it can do GC. */
1658 /* Don't let the frame remain selected. */
1659 if (EQ (frame
, selected_frame
))
1660 do_switch_frame (next_frame (frame
, Qt
), 0, 0)
1663 /* Don't allow minibuf_window to remain on a deleted frame. */
1664 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1666 struct frame
*sf
= XFRAME (selected_frame
);
1667 Fset_window_buffer (sf
->minibuffer_window
,
1668 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1669 minibuf_window
= sf
->minibuffer_window
;
1672 /* I think this should be done with a hook. */
1673 #ifdef HAVE_WINDOW_SYSTEM
1674 if (FRAME_WINDOW_P (XFRAME (frame
)))
1675 x_make_frame_invisible (XFRAME (frame
));
1678 /* Make menu bar update for the Buffers and Frames menus. */
1679 windows_or_buffers_changed
++;
1684 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1686 doc
: /* Make the frame FRAME into an icon.
1687 If omitted, FRAME defaults to the currently selected frame. */)
1692 frame
= selected_frame
;
1694 CHECK_LIVE_FRAME (frame
);
1696 #if 0 /* This isn't logically necessary, and it can do GC. */
1697 /* Don't let the frame remain selected. */
1698 if (EQ (frame
, selected_frame
))
1699 Fhandle_switch_frame (next_frame (frame
, Qt
));
1702 /* Don't allow minibuf_window to remain on a deleted frame. */
1703 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1705 struct frame
*sf
= XFRAME (selected_frame
);
1706 Fset_window_buffer (sf
->minibuffer_window
,
1707 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1708 minibuf_window
= sf
->minibuffer_window
;
1711 /* I think this should be done with a hook. */
1712 #ifdef HAVE_WINDOW_SYSTEM
1713 if (FRAME_WINDOW_P (XFRAME (frame
)))
1714 x_iconify_frame (XFRAME (frame
));
1717 /* Make menu bar update for the Buffers and Frames menus. */
1718 windows_or_buffers_changed
++;
1723 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1725 doc
: /* Return t if FRAME is now \"visible\" (actually in use for display).
1726 A frame that is not \"visible\" is not updated and, if it works through
1727 a window system, it may not show at all.
1728 Return the symbol `icon' if frame is visible only as an icon.
1730 On a text-only terminal, all frames are considered visible, whether
1731 they are currently being displayed or not, and this function returns t
1736 CHECK_LIVE_FRAME (frame
);
1738 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1740 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1742 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1747 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1749 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1752 Lisp_Object tail
, frame
;
1757 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1759 frame
= XCAR (tail
);
1760 if (!FRAMEP (frame
))
1763 if (FRAME_VISIBLE_P (f
))
1764 value
= Fcons (frame
, value
);
1770 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1771 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1772 If FRAME is invisible or iconified, make it visible.
1773 If you don't specify a frame, the selected frame is used.
1774 If Emacs is displaying on an ordinary terminal or some other device which
1775 doesn't support multiple overlapping frames, this function does nothing. */)
1780 frame
= selected_frame
;
1782 CHECK_LIVE_FRAME (frame
);
1784 /* Do like the documentation says. */
1785 Fmake_frame_visible (frame
);
1787 if (frame_raise_lower_hook
)
1788 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1793 /* Should we have a corresponding function called Flower_Power? */
1794 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1795 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1796 If you don't specify a frame, the selected frame is used.
1797 If Emacs is displaying on an ordinary terminal or some other device which
1798 doesn't support multiple overlapping frames, this function does nothing. */)
1803 frame
= selected_frame
;
1805 CHECK_LIVE_FRAME (frame
);
1807 if (frame_raise_lower_hook
)
1808 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1814 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1816 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1817 In other words, switch-frame events caused by events in FRAME will
1818 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1819 FOCUS-FRAME after reading an event typed at FRAME.
1821 If FOCUS-FRAME is omitted or nil, any existing redirection is
1822 cancelled, and the frame again receives its own keystrokes.
1824 Focus redirection is useful for temporarily redirecting keystrokes to
1825 a surrogate minibuffer frame when a frame doesn't have its own
1828 A frame's focus redirection can be changed by `select-frame'. If frame
1829 FOO is selected, and then a different frame BAR is selected, any
1830 frames redirecting their focus to FOO are shifted to redirect their
1831 focus to BAR. This allows focus redirection to work properly when the
1832 user switches from one frame to another using `select-window'.
1834 This means that a frame whose focus is redirected to itself is treated
1835 differently from a frame whose focus is redirected to nil; the former
1836 is affected by `select-frame', while the latter is not.
1838 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1839 (frame
, focus_frame
)
1840 Lisp_Object frame
, focus_frame
;
1842 /* Note that we don't check for a live frame here. It's reasonable
1843 to redirect the focus of a frame you're about to delete, if you
1844 know what other frame should receive those keystrokes. */
1845 CHECK_FRAME (frame
);
1847 if (! NILP (focus_frame
))
1848 CHECK_LIVE_FRAME (focus_frame
);
1850 XFRAME (frame
)->focus_frame
= focus_frame
;
1852 if (frame_rehighlight_hook
)
1853 (*frame_rehighlight_hook
) (XFRAME (frame
));
1859 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1860 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1861 This returns nil if FRAME's focus is not redirected.
1862 See `redirect-frame-focus'. */)
1866 CHECK_LIVE_FRAME (frame
);
1868 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1873 /* Return the value of frame parameter PROP in frame FRAME. */
1876 get_frame_param (frame
, prop
)
1877 register struct frame
*frame
;
1880 register Lisp_Object tem
;
1882 tem
= Fassq (prop
, frame
->param_alist
);
1888 /* Return the buffer-predicate of the selected frame. */
1891 frame_buffer_predicate (frame
)
1894 return XFRAME (frame
)->buffer_predicate
;
1897 /* Return the buffer-list of the selected frame. */
1900 frame_buffer_list (frame
)
1903 return XFRAME (frame
)->buffer_list
;
1906 /* Set the buffer-list of the selected frame. */
1909 set_frame_buffer_list (frame
, list
)
1910 Lisp_Object frame
, list
;
1912 XFRAME (frame
)->buffer_list
= list
;
1915 /* Discard BUFFER from the buffer-list of each frame. */
1918 frames_discard_buffer (buffer
)
1921 Lisp_Object frame
, tail
;
1923 FOR_EACH_FRAME (tail
, frame
)
1925 XFRAME (frame
)->buffer_list
1926 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1930 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1931 If the alist already has an element for PROP, we change it. */
1934 store_in_alist (alistptr
, prop
, val
)
1935 Lisp_Object
*alistptr
, val
;
1938 register Lisp_Object tem
;
1940 tem
= Fassq (prop
, *alistptr
);
1942 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1948 frame_name_fnn_p (str
, len
)
1952 if (len
> 1 && str
[0] == 'F')
1956 strtol (str
+ 1, &end_ptr
, 10);
1958 if (end_ptr
== str
+ len
)
1964 /* Set the name of the terminal frame. Also used by MSDOS frames.
1965 Modeled after x_set_name which is used for WINDOW frames. */
1968 set_term_frame_name (f
, name
)
1972 f
->explicit_name
= ! NILP (name
);
1974 /* If NAME is nil, set the name to F<num>. */
1979 /* Check for no change needed in this very common case
1980 before we do any consing. */
1981 if (frame_name_fnn_p (SDATA (f
->name
),
1985 terminal_frame_count
++;
1986 sprintf (namebuf
, "F%d", terminal_frame_count
);
1987 name
= build_string (namebuf
);
1991 CHECK_STRING (name
);
1993 /* Don't change the name if it's already NAME. */
1994 if (! NILP (Fstring_equal (name
, f
->name
)))
1997 /* Don't allow the user to set the frame name to F<num>, so it
1998 doesn't clash with the names we generate for terminal frames. */
1999 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
2000 error ("Frame names of the form F<num> are usurped by Emacs");
2004 update_mode_lines
= 1;
2008 store_frame_param (f
, prop
, val
)
2010 Lisp_Object prop
, val
;
2012 register Lisp_Object old_alist_elt
;
2014 /* The buffer-alist parameter is stored in a special place and is
2015 not in the alist. */
2016 if (EQ (prop
, Qbuffer_list
))
2018 f
->buffer_list
= val
;
2022 /* If PROP is a symbol which is supposed to have frame-local values,
2023 and it is set up based on this frame, switch to the global
2024 binding. That way, we can create or alter the frame-local binding
2025 without messing up the symbol's status. */
2028 Lisp_Object valcontents
;
2029 valcontents
= SYMBOL_VALUE (prop
);
2030 if ((BUFFER_LOCAL_VALUEP (valcontents
)
2031 || SOME_BUFFER_LOCAL_VALUEP (valcontents
))
2032 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
2033 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
2034 swap_in_global_binding (prop
);
2038 /* The tty color mode needs to be set before the frame's parameter
2039 alist is updated with the new value, because set_tty_color_mode
2040 wants to look at the old mode. */
2041 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
))
2042 set_tty_color_mode (f
, val
);
2045 /* Update the frame parameter alist. */
2046 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2047 if (EQ (old_alist_elt
, Qnil
))
2048 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2050 Fsetcdr (old_alist_elt
, val
);
2052 /* Update some other special parameters in their special places
2053 in addition to the alist. */
2055 if (EQ (prop
, Qbuffer_predicate
))
2056 f
->buffer_predicate
= val
;
2058 if (! FRAME_WINDOW_P (f
))
2060 if (EQ (prop
, Qmenu_bar_lines
))
2061 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2062 else if (EQ (prop
, Qname
))
2063 set_term_frame_name (f
, val
);
2066 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2068 if (! MINI_WINDOW_P (XWINDOW (val
)))
2069 error ("Surrogate minibuffer windows must be minibuffer windows");
2071 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2072 && !EQ (val
, f
->minibuffer_window
))
2073 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2075 /* Install the chosen minibuffer window, with proper buffer. */
2076 f
->minibuffer_window
= val
;
2080 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2081 doc
: /* Return the parameters-alist of frame FRAME.
2082 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2083 The meaningful PARMs depend on the kind of frame.
2084 If FRAME is omitted, return information on the currently selected frame. */)
2091 struct gcpro gcpro1
;
2094 frame
= selected_frame
;
2096 CHECK_FRAME (frame
);
2099 if (!FRAME_LIVE_P (f
))
2102 alist
= Fcopy_alist (f
->param_alist
);
2105 if (!FRAME_WINDOW_P (f
))
2107 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2108 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2111 /* If the frame's parameter alist says the colors are
2112 unspecified and reversed, take the frame's background pixel
2113 for foreground and vice versa. */
2114 elt
= Fassq (Qforeground_color
, alist
);
2115 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2117 if (strncmp (SDATA (XCDR (elt
)),
2119 SCHARS (XCDR (elt
))) == 0)
2120 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2121 else if (strncmp (SDATA (XCDR (elt
)),
2123 SCHARS (XCDR (elt
))) == 0)
2124 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2127 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2128 elt
= Fassq (Qbackground_color
, alist
);
2129 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2131 if (strncmp (SDATA (XCDR (elt
)),
2133 SCHARS (XCDR (elt
))) == 0)
2134 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2135 else if (strncmp (SDATA (XCDR (elt
)),
2137 SCHARS (XCDR (elt
))) == 0)
2138 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2141 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2142 store_in_alist (&alist
, intern ("font"),
2143 build_string (FRAME_MSDOS_P (f
)
2145 : FRAME_W32_P (f
) ? "w32term"
2148 store_in_alist (&alist
, Qname
, f
->name
);
2149 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2150 store_in_alist (&alist
, Qheight
, make_number (height
));
2151 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2152 store_in_alist (&alist
, Qwidth
, make_number (width
));
2153 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2154 store_in_alist (&alist
, Qminibuffer
,
2155 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2156 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2157 : FRAME_MINIBUF_WINDOW (f
)));
2158 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2159 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2161 /* I think this should be done with a hook. */
2162 #ifdef HAVE_WINDOW_SYSTEM
2163 if (FRAME_WINDOW_P (f
))
2164 x_report_frame_params (f
, &alist
);
2168 /* This ought to be correct in f->param_alist for an X frame. */
2170 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2171 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2179 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2180 doc
: /* Return FRAME's value for parameter PARAMETER.
2181 If FRAME is nil, describe the currently selected frame. */)
2183 Lisp_Object frame
, parameter
;
2189 frame
= selected_frame
;
2191 CHECK_FRAME (frame
);
2192 CHECK_SYMBOL (parameter
);
2197 if (FRAME_LIVE_P (f
))
2199 /* Avoid consing in frequent cases. */
2200 if (EQ (parameter
, Qname
))
2202 #ifdef HAVE_X_WINDOWS
2203 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2204 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2205 #endif /* HAVE_X_WINDOWS */
2206 else if (EQ (parameter
, Qbackground_color
)
2207 || EQ (parameter
, Qforeground_color
))
2209 value
= Fassq (parameter
, f
->param_alist
);
2212 value
= XCDR (value
);
2213 /* Fframe_parameters puts the actual fg/bg color names,
2214 even if f->param_alist says otherwise. This is
2215 important when param_alist's notion of colors is
2216 "unspecified". We need to do the same here. */
2217 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2219 const char *color_name
;
2222 if (EQ (parameter
, Qbackground_color
))
2224 color_name
= SDATA (value
);
2225 csz
= SCHARS (value
);
2226 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2227 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2228 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2229 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2231 else if (EQ (parameter
, Qforeground_color
))
2233 color_name
= SDATA (value
);
2234 csz
= SCHARS (value
);
2235 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2236 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2237 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2238 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2243 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2245 else if (EQ (parameter
, Qdisplay_type
)
2246 || EQ (parameter
, Qbackground_mode
))
2247 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2249 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2256 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2257 Smodify_frame_parameters
, 2, 2, 0,
2258 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2259 If FRAME is nil, it defaults to the selected frame.
2260 ALIST is an alist of parameters to change and their new values.
2261 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2262 The meaningful PARMs depend on the kind of frame.
2263 Undefined PARMs are ignored, but stored in the frame's parameter list
2264 so that `frame-parameters' will return them.
2266 The value of frame parameter FOO can also be accessed
2267 as a frame-local binding for the variable FOO, if you have
2268 enabled such bindings for that variable with `make-variable-frame-local'. */)
2270 Lisp_Object frame
, alist
;
2273 register Lisp_Object tail
, prop
, val
;
2275 if (EQ (frame
, Qnil
))
2276 frame
= selected_frame
;
2277 CHECK_LIVE_FRAME (frame
);
2280 /* I think this should be done with a hook. */
2281 #ifdef HAVE_WINDOW_SYSTEM
2282 if (FRAME_WINDOW_P (f
))
2283 x_set_frame_parameters (f
, alist
);
2287 if (FRAME_MSDOS_P (f
))
2288 IT_set_frame_parameters (f
, alist
);
2293 int length
= XINT (Flength (alist
));
2296 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2298 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2300 /* Extract parm names and values into those vectors. */
2303 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2308 parms
[i
] = Fcar (elt
);
2309 values
[i
] = Fcdr (elt
);
2313 /* Now process them in reverse of specified order. */
2314 for (i
--; i
>= 0; i
--)
2318 store_frame_param (f
, prop
, val
);
2320 /* Changing the background color might change the background
2321 mode, so that we have to load new defface specs.
2322 Call frame-set-background-mode to do that. */
2323 if (EQ (prop
, Qbackground_color
))
2324 call1 (Qframe_set_background_mode
, frame
);
2331 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2333 doc
: /* Height in pixels of a line in the font in frame FRAME.
2334 If FRAME is omitted, the selected frame is used.
2335 For a terminal frame, the value is always 1. */)
2342 frame
= selected_frame
;
2343 CHECK_FRAME (frame
);
2346 #ifdef HAVE_WINDOW_SYSTEM
2347 if (FRAME_WINDOW_P (f
))
2348 return make_number (x_char_height (f
));
2351 return make_number (1);
2355 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2357 doc
: /* Width in pixels of characters in the font in frame FRAME.
2358 If FRAME is omitted, the selected frame is used.
2359 On a graphical screen, the width is the standard width of the default font.
2360 For a terminal screen, the value is always 1. */)
2367 frame
= selected_frame
;
2368 CHECK_FRAME (frame
);
2371 #ifdef HAVE_WINDOW_SYSTEM
2372 if (FRAME_WINDOW_P (f
))
2373 return make_number (x_char_width (f
));
2376 return make_number (1);
2379 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2380 Sframe_pixel_height
, 0, 1, 0,
2381 doc
: /* Return a FRAME's height in pixels.
2382 This counts only the height available for text lines,
2383 not menu bars on window-system Emacs frames.
2384 For a terminal frame, the result really gives the height in characters.
2385 If FRAME is omitted, the selected frame is used. */)
2392 frame
= selected_frame
;
2393 CHECK_FRAME (frame
);
2396 #ifdef HAVE_WINDOW_SYSTEM
2397 if (FRAME_WINDOW_P (f
))
2398 return make_number (x_pixel_height (f
));
2401 return make_number (FRAME_LINES (f
));
2404 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2405 Sframe_pixel_width
, 0, 1, 0,
2406 doc
: /* Return FRAME's width in pixels.
2407 For a terminal frame, the result really gives the width in characters.
2408 If FRAME is omitted, the selected frame is used. */)
2415 frame
= selected_frame
;
2416 CHECK_FRAME (frame
);
2419 #ifdef HAVE_WINDOW_SYSTEM
2420 if (FRAME_WINDOW_P (f
))
2421 return make_number (x_pixel_width (f
));
2424 return make_number (FRAME_COLS (f
));
2427 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2428 doc
: /* Specify that the frame FRAME has LINES lines.
2429 Optional third arg non-nil means that redisplay should use LINES lines
2430 but that the idea of the actual height of the frame should not be changed. */)
2431 (frame
, lines
, pretend
)
2432 Lisp_Object frame
, lines
, pretend
;
2434 register struct frame
*f
;
2436 CHECK_NUMBER (lines
);
2438 frame
= selected_frame
;
2439 CHECK_LIVE_FRAME (frame
);
2442 /* I think this should be done with a hook. */
2443 #ifdef HAVE_WINDOW_SYSTEM
2444 if (FRAME_WINDOW_P (f
))
2446 if (XINT (lines
) != FRAME_LINES (f
))
2447 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2448 do_pending_window_change (0);
2452 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2456 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2457 doc
: /* Specify that the frame FRAME has COLS columns.
2458 Optional third arg non-nil means that redisplay should use COLS columns
2459 but that the idea of the actual width of the frame should not be changed. */)
2460 (frame
, cols
, pretend
)
2461 Lisp_Object frame
, cols
, pretend
;
2463 register struct frame
*f
;
2464 CHECK_NUMBER (cols
);
2466 frame
= selected_frame
;
2467 CHECK_LIVE_FRAME (frame
);
2470 /* I think this should be done with a hook. */
2471 #ifdef HAVE_WINDOW_SYSTEM
2472 if (FRAME_WINDOW_P (f
))
2474 if (XINT (cols
) != FRAME_COLS (f
))
2475 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2476 do_pending_window_change (0);
2480 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2484 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2485 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2487 Lisp_Object frame
, cols
, rows
;
2489 register struct frame
*f
;
2491 CHECK_LIVE_FRAME (frame
);
2492 CHECK_NUMBER (cols
);
2493 CHECK_NUMBER (rows
);
2496 /* I think this should be done with a hook. */
2497 #ifdef HAVE_WINDOW_SYSTEM
2498 if (FRAME_WINDOW_P (f
))
2500 if (XINT (rows
) != FRAME_LINES (f
)
2501 || XINT (cols
) != FRAME_COLS (f
)
2502 || f
->new_text_lines
|| f
->new_text_cols
)
2503 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2504 do_pending_window_change (0);
2508 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2513 DEFUN ("set-frame-position", Fset_frame_position
,
2514 Sset_frame_position
, 3, 3, 0,
2515 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2516 This is actually the position of the upper left corner of the frame.
2517 Negative values for XOFFSET or YOFFSET are interpreted relative to
2518 the rightmost or bottommost possible position (that stays within the screen). */)
2519 (frame
, xoffset
, yoffset
)
2520 Lisp_Object frame
, xoffset
, yoffset
;
2522 register struct frame
*f
;
2524 CHECK_LIVE_FRAME (frame
);
2525 CHECK_NUMBER (xoffset
);
2526 CHECK_NUMBER (yoffset
);
2529 /* I think this should be done with a hook. */
2530 #ifdef HAVE_WINDOW_SYSTEM
2531 if (FRAME_WINDOW_P (f
))
2532 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2539 /***********************************************************************
2541 ***********************************************************************/
2543 /* Connect the frame-parameter names for X frames
2544 to the ways of passing the parameter values to the window system.
2546 The name of a parameter, as a Lisp symbol,
2547 has an `x-frame-parameter' property which is an integer in Lisp
2548 that is an index in this table. */
2550 struct frame_parm_table
{
2552 Lisp_Object
*variable
;
2555 static struct frame_parm_table frame_parms
[] =
2557 {"auto-raise", &Qauto_raise
},
2558 {"auto-lower", &Qauto_lower
},
2559 {"background-color", 0},
2560 {"border-color", &Qborder_color
},
2561 {"border-width", &Qborder_width
},
2562 {"cursor-color", &Qcursor_color
},
2563 {"cursor-type", &Qcursor_type
},
2565 {"foreground-color", 0},
2566 {"icon-name", &Qicon_name
},
2567 {"icon-type", &Qicon_type
},
2568 {"internal-border-width", &Qinternal_border_width
},
2569 {"menu-bar-lines", &Qmenu_bar_lines
},
2570 {"mouse-color", &Qmouse_color
},
2572 {"scroll-bar-width", &Qscroll_bar_width
},
2574 {"unsplittable", &Qunsplittable
},
2575 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2576 {"visibility", &Qvisibility
},
2577 {"tool-bar-lines", &Qtool_bar_lines
},
2578 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2579 {"scroll-bar-background", &Qscroll_bar_background
},
2580 {"screen-gamma", &Qscreen_gamma
},
2581 {"line-spacing", &Qline_spacing
},
2582 {"left-fringe", &Qleft_fringe
},
2583 {"right-fringe", &Qright_fringe
},
2584 {"wait-for-wm", &Qwait_for_wm
},
2585 {"fullscreen", &Qfullscreen
},
2588 #ifdef HAVE_WINDOW_SYSTEM
2590 extern Lisp_Object Qbox
;
2591 extern Lisp_Object Qtop
;
2593 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2594 wanted positions of the WM window (not Emacs window).
2595 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2596 window (FRAME_X_WINDOW).
2600 x_fullscreen_adjust (f
, width
, height
, top_pos
, left_pos
)
2607 int newwidth
= FRAME_COLS (f
);
2608 int newheight
= FRAME_LINES (f
);
2610 *top_pos
= f
->top_pos
;
2611 *left_pos
= f
->left_pos
;
2613 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2617 ph
= FRAME_X_DISPLAY_INFO (f
)->height
;
2618 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2619 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2620 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2624 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2628 pw
= FRAME_X_DISPLAY_INFO (f
)->width
;
2629 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2630 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2631 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2636 *height
= newheight
;
2640 /* Change the parameters of frame F as specified by ALIST.
2641 If a parameter is not specially recognized, do nothing special;
2642 otherwise call the `x_set_...' function for that parameter.
2643 Except for certain geometry properties, always call store_frame_param
2644 to store the new value in the parameter alist. */
2647 x_set_frame_parameters (f
, alist
)
2653 /* If both of these parameters are present, it's more efficient to
2654 set them both at once. So we wait until we've looked at the
2655 entire list before we set them. */
2659 Lisp_Object left
, top
;
2661 /* Same with these. */
2662 Lisp_Object icon_left
, icon_top
;
2664 /* Record in these vectors all the parms specified. */
2666 Lisp_Object
*values
;
2668 int left_no_change
= 0, top_no_change
= 0;
2669 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2670 int fullscreen_is_being_set
= 0;
2672 struct gcpro gcpro1
, gcpro2
;
2675 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2678 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2679 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2681 /* Extract parm names and values into those vectors. */
2684 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2689 parms
[i
] = Fcar (elt
);
2690 values
[i
] = Fcdr (elt
);
2693 /* TAIL and ALIST are not used again below here. */
2694 alist
= tail
= Qnil
;
2696 GCPRO2 (*parms
, *values
);
2700 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2701 because their values appear in VALUES and strings are not valid. */
2702 top
= left
= Qunbound
;
2703 icon_left
= icon_top
= Qunbound
;
2705 /* Provide default values for HEIGHT and WIDTH. */
2706 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2707 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2709 /* Process foreground_color and background_color before anything else.
2710 They are independent of other properties, but other properties (e.g.,
2711 cursor_color) are dependent upon them. */
2712 /* Process default font as well, since fringe widths depends on it. */
2713 /* Also, process fullscreen, width and height depend upon that */
2714 for (p
= 0; p
< i
; p
++)
2716 Lisp_Object prop
, val
;
2720 if (EQ (prop
, Qforeground_color
)
2721 || EQ (prop
, Qbackground_color
)
2723 || EQ (prop
, Qfullscreen
))
2725 register Lisp_Object param_index
, old_value
;
2726 int count
= SPECPDL_INDEX ();
2728 old_value
= get_frame_param (f
, prop
);
2729 fullscreen_is_being_set
|= EQ (prop
, Qfullscreen
);
2731 if (NILP (Fequal (val
, old_value
)))
2733 /* For :font attributes, the frame_parm_handler
2734 x_set_font calls `face-set-after-frame-default'.
2735 Unless we bind inhibit-face-set-after-frame-default
2736 here, this would reset the :font attribute that we
2737 just applied to the default value for new faces. */
2738 specbind (Qinhibit_face_set_after_frame_default
, Qt
);
2740 store_frame_param (f
, prop
, val
);
2742 param_index
= Fget (prop
, Qx_frame_parameter
);
2743 if (NATNUMP (param_index
)
2744 && (XFASTINT (param_index
)
2745 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2746 && rif
->frame_parm_handlers
[XINT (param_index
)])
2747 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2749 unbind_to (count
, Qnil
);
2754 /* Now process them in reverse of specified order. */
2755 for (i
--; i
>= 0; i
--)
2757 Lisp_Object prop
, val
;
2762 if (EQ (prop
, Qwidth
) && NUMBERP (val
))
2763 width
= XFASTINT (val
);
2764 else if (EQ (prop
, Qheight
) && NUMBERP (val
))
2765 height
= XFASTINT (val
);
2766 else if (EQ (prop
, Qtop
))
2768 else if (EQ (prop
, Qleft
))
2770 else if (EQ (prop
, Qicon_top
))
2772 else if (EQ (prop
, Qicon_left
))
2774 else if (EQ (prop
, Qforeground_color
)
2775 || EQ (prop
, Qbackground_color
)
2777 || EQ (prop
, Qfullscreen
))
2778 /* Processed above. */
2782 register Lisp_Object param_index
, old_value
;
2784 old_value
= get_frame_param (f
, prop
);
2786 store_frame_param (f
, prop
, val
);
2788 param_index
= Fget (prop
, Qx_frame_parameter
);
2789 if (NATNUMP (param_index
)
2790 && (XFASTINT (param_index
)
2791 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2792 && rif
->frame_parm_handlers
[XINT (param_index
)])
2793 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2797 /* Don't die if just one of these was set. */
2798 if (EQ (left
, Qunbound
))
2801 if (f
->left_pos
< 0)
2802 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2804 XSETINT (left
, f
->left_pos
);
2806 if (EQ (top
, Qunbound
))
2810 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2812 XSETINT (top
, f
->top_pos
);
2815 /* If one of the icon positions was not set, preserve or default it. */
2816 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
2818 icon_left_no_change
= 1;
2819 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2820 if (NILP (icon_left
))
2821 XSETINT (icon_left
, 0);
2823 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
2825 icon_top_no_change
= 1;
2826 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2827 if (NILP (icon_top
))
2828 XSETINT (icon_top
, 0);
2831 if (FRAME_VISIBLE_P (f
) && fullscreen_is_being_set
)
2833 /* If the frame is visible already and the fullscreen parameter is
2834 being set, it is too late to set WM manager hints to specify
2836 Here we first get the width, height and position that applies to
2837 fullscreen. We then move the frame to the appropriate
2838 position. Resize of the frame is taken care of in the code after
2839 this if-statement. */
2840 int new_left
, new_top
;
2842 x_fullscreen_adjust (f
, &width
, &height
, &new_top
, &new_left
);
2843 if (new_top
!= f
->top_pos
|| new_left
!= f
->left_pos
)
2844 x_set_offset (f
, new_left
, new_top
, 1);
2847 /* Don't set these parameters unless they've been explicitly
2848 specified. The window might be mapped or resized while we're in
2849 this function, and we don't want to override that unless the lisp
2850 code has asked for it.
2852 Don't set these parameters unless they actually differ from the
2853 window's current parameters; the window may not actually exist
2858 check_frame_size (f
, &height
, &width
);
2860 XSETFRAME (frame
, f
);
2862 if (width
!= FRAME_COLS (f
)
2863 || height
!= FRAME_LINES (f
)
2864 || f
->new_text_lines
|| f
->new_text_cols
)
2865 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2867 if ((!NILP (left
) || !NILP (top
))
2868 && ! (left_no_change
&& top_no_change
)
2869 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2870 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2875 /* Record the signs. */
2876 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2877 if (EQ (left
, Qminus
))
2878 f
->size_hint_flags
|= XNegative
;
2879 else if (INTEGERP (left
))
2881 leftpos
= XINT (left
);
2883 f
->size_hint_flags
|= XNegative
;
2885 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2886 && CONSP (XCDR (left
))
2887 && INTEGERP (XCAR (XCDR (left
))))
2889 leftpos
= - XINT (XCAR (XCDR (left
)));
2890 f
->size_hint_flags
|= XNegative
;
2892 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2893 && CONSP (XCDR (left
))
2894 && INTEGERP (XCAR (XCDR (left
))))
2896 leftpos
= XINT (XCAR (XCDR (left
)));
2899 if (EQ (top
, Qminus
))
2900 f
->size_hint_flags
|= YNegative
;
2901 else if (INTEGERP (top
))
2903 toppos
= XINT (top
);
2905 f
->size_hint_flags
|= YNegative
;
2907 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2908 && CONSP (XCDR (top
))
2909 && INTEGERP (XCAR (XCDR (top
))))
2911 toppos
= - XINT (XCAR (XCDR (top
)));
2912 f
->size_hint_flags
|= YNegative
;
2914 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2915 && CONSP (XCDR (top
))
2916 && INTEGERP (XCAR (XCDR (top
))))
2918 toppos
= XINT (XCAR (XCDR (top
)));
2922 /* Store the numeric value of the position. */
2923 f
->top_pos
= toppos
;
2924 f
->left_pos
= leftpos
;
2926 f
->win_gravity
= NorthWestGravity
;
2928 /* Actually set that position, and convert to absolute. */
2929 x_set_offset (f
, leftpos
, toppos
, -1);
2932 if ((!NILP (icon_left
) || !NILP (icon_top
))
2933 && ! (icon_left_no_change
&& icon_top_no_change
))
2934 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2941 /* Insert a description of internally-recorded parameters of frame X
2942 into the parameter alist *ALISTPTR that is to be given to the user.
2943 Only parameters that are specific to the X window system
2944 and whose values are not correctly recorded in the frame's
2945 param_alist need to be considered here. */
2948 x_report_frame_params (f
, alistptr
)
2950 Lisp_Object
*alistptr
;
2955 /* Represent negative positions (off the top or left screen edge)
2956 in a way that Fmodify_frame_parameters will understand correctly. */
2957 XSETINT (tem
, f
->left_pos
);
2958 if (f
->left_pos
>= 0)
2959 store_in_alist (alistptr
, Qleft
, tem
);
2961 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2963 XSETINT (tem
, f
->top_pos
);
2964 if (f
->top_pos
>= 0)
2965 store_in_alist (alistptr
, Qtop
, tem
);
2967 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2969 store_in_alist (alistptr
, Qborder_width
,
2970 make_number (f
->border_width
));
2971 store_in_alist (alistptr
, Qinternal_border_width
,
2972 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
2973 store_in_alist (alistptr
, Qleft_fringe
,
2974 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
2975 store_in_alist (alistptr
, Qright_fringe
,
2976 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
2977 store_in_alist (alistptr
, Qscroll_bar_width
,
2978 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2980 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
2981 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
2982 /* nil means "use default width"
2983 for non-toolkit scroll bar.
2984 ruler-mode.el depends on this. */
2986 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
2987 store_in_alist (alistptr
, Qwindow_id
,
2988 build_string (buf
));
2989 #ifdef HAVE_X_WINDOWS
2990 #ifdef USE_X_TOOLKIT
2991 /* Tooltip frame may not have this widget. */
2992 if (FRAME_X_OUTPUT (f
)->widget
)
2994 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
2995 store_in_alist (alistptr
, Qouter_window_id
,
2996 build_string (buf
));
2998 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
2999 FRAME_SAMPLE_VISIBILITY (f
);
3000 store_in_alist (alistptr
, Qvisibility
,
3001 (FRAME_VISIBLE_P (f
) ? Qt
3002 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3003 store_in_alist (alistptr
, Qdisplay
,
3004 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3006 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3009 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3010 store_in_alist (alistptr
, Qexplicit_name
, (f
->explicit_name
? Qt
: Qnil
));
3011 store_in_alist (alistptr
, Qparent_id
, tem
);
3015 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3016 the previous value of that parameter, NEW_VALUE is the new value. */
3019 x_set_fullscreen (f
, new_value
, old_value
)
3021 Lisp_Object new_value
, old_value
;
3023 if (NILP (new_value
))
3024 f
->want_fullscreen
= FULLSCREEN_NONE
;
3025 else if (EQ (new_value
, Qfullboth
))
3026 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3027 else if (EQ (new_value
, Qfullwidth
))
3028 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3029 else if (EQ (new_value
, Qfullheight
))
3030 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3032 if (fullscreen_hook
!= NULL
)
3033 fullscreen_hook (f
);
3037 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3038 the previous value of that parameter, NEW_VALUE is the new value. */
3041 x_set_line_spacing (f
, new_value
, old_value
)
3043 Lisp_Object new_value
, old_value
;
3045 if (NILP (new_value
))
3046 f
->extra_line_spacing
= 0;
3047 else if (NATNUMP (new_value
))
3048 f
->extra_line_spacing
= XFASTINT (new_value
);
3050 signal_error ("Invalid line-spacing", new_value
);
3051 if (FRAME_VISIBLE_P (f
))
3056 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3057 the previous value of that parameter, NEW_VALUE is the new value. */
3060 x_set_screen_gamma (f
, new_value
, old_value
)
3062 Lisp_Object new_value
, old_value
;
3064 Lisp_Object bgcolor
;
3066 if (NILP (new_value
))
3068 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3069 /* The value 0.4545 is the normal viewing gamma. */
3070 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3072 signal_error ("Invalid screen-gamma", new_value
);
3074 /* Apply the new gamma value to the frame background. */
3075 bgcolor
= Fassq (Qbackground_color
, f
->param_alist
);
3076 if (CONSP (bgcolor
) && (bgcolor
= XCDR (bgcolor
), STRINGP (bgcolor
)))
3078 Lisp_Object index
= Fget (Qbackground_color
, Qx_frame_parameter
);
3080 && (XFASTINT (index
)
3081 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
3082 && rif
->frame_parm_handlers
[XFASTINT (index
)])
3083 (*(rif
->frame_parm_handlers
[XFASTINT (index
)]))
3087 Fclear_face_cache (Qnil
);
3092 x_set_font (f
, arg
, oldval
)
3094 Lisp_Object arg
, oldval
;
3097 Lisp_Object fontset_name
;
3099 int old_fontset
= FRAME_FONTSET(f
);
3103 fontset_name
= Fquery_fontset (arg
, Qnil
);
3106 result
= (STRINGP (fontset_name
)
3107 ? x_new_fontset (f
, SDATA (fontset_name
))
3108 : x_new_font (f
, SDATA (arg
)));
3111 if (EQ (result
, Qnil
))
3112 error ("Font `%s' is not defined", SDATA (arg
));
3113 else if (EQ (result
, Qt
))
3114 error ("The characters of the given font have varying widths");
3115 else if (STRINGP (result
))
3117 set_default_ascii_font (result
);
3118 if (STRINGP (fontset_name
))
3120 /* Fontset names are built from ASCII font names, so the
3121 names may be equal despite there was a change. */
3122 if (old_fontset
== FRAME_FONTSET (f
))
3125 else if (!NILP (Fequal (result
, oldval
)))
3128 /* Recalculate toolbar height. */
3129 f
->n_tool_bar_rows
= 0;
3130 /* Ensure we redraw it. */
3131 clear_current_matrices (f
);
3133 store_frame_param (f
, Qfont
, result
);
3134 recompute_basic_faces (f
);
3139 do_pending_window_change (0);
3141 /* Don't call `face-set-after-frame-default' when faces haven't been
3142 initialized yet. This is the case when called from
3143 Fx_create_frame. In that case, the X widget or window doesn't
3144 exist either, and we can end up in x_report_frame_params with a
3145 null widget which gives a segfault. */
3146 if (FRAME_FACE_CACHE (f
))
3148 XSETFRAME (frame
, f
);
3149 call1 (Qface_set_after_frame_default
, frame
);
3155 x_set_fringe_width (f
, new_value
, old_value
)
3157 Lisp_Object new_value
, old_value
;
3159 compute_fringe_widths (f
, 1);
3163 x_set_border_width (f
, arg
, oldval
)
3165 Lisp_Object arg
, oldval
;
3169 if (XINT (arg
) == f
->border_width
)
3172 if (FRAME_X_WINDOW (f
) != 0)
3173 error ("Cannot change the border width of a frame");
3175 f
->border_width
= XINT (arg
);
3179 x_set_internal_border_width (f
, arg
, oldval
)
3181 Lisp_Object arg
, oldval
;
3183 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3186 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3187 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3188 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3190 #ifdef USE_X_TOOLKIT
3191 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3192 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3195 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3198 if (FRAME_X_WINDOW (f
) != 0)
3200 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3201 SET_FRAME_GARBAGED (f
);
3202 do_pending_window_change (0);
3205 SET_FRAME_GARBAGED (f
);
3209 x_set_visibility (f
, value
, oldval
)
3211 Lisp_Object value
, oldval
;
3214 XSETFRAME (frame
, f
);
3217 Fmake_frame_invisible (frame
, Qt
);
3218 else if (EQ (value
, Qicon
))
3219 Ficonify_frame (frame
);
3221 Fmake_frame_visible (frame
);
3225 x_set_autoraise (f
, arg
, oldval
)
3227 Lisp_Object arg
, oldval
;
3229 f
->auto_raise
= !EQ (Qnil
, arg
);
3233 x_set_autolower (f
, arg
, oldval
)
3235 Lisp_Object arg
, oldval
;
3237 f
->auto_lower
= !EQ (Qnil
, arg
);
3241 x_set_unsplittable (f
, arg
, oldval
)
3243 Lisp_Object arg
, oldval
;
3245 f
->no_split
= !NILP (arg
);
3249 x_set_vertical_scroll_bars (f
, arg
, oldval
)
3251 Lisp_Object arg
, oldval
;
3253 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3254 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3255 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3256 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3258 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3260 ? vertical_scroll_bar_none
3262 ? vertical_scroll_bar_left
3264 ? vertical_scroll_bar_right
3265 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3266 ? vertical_scroll_bar_left
3267 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3268 ? vertical_scroll_bar_right
3269 : vertical_scroll_bar_none
);
3271 /* We set this parameter before creating the X window for the
3272 frame, so we can get the geometry right from the start.
3273 However, if the window hasn't been created yet, we shouldn't
3274 call x_set_window_size. */
3275 if (FRAME_X_WINDOW (f
))
3276 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3277 do_pending_window_change (0);
3282 x_set_scroll_bar_width (f
, arg
, oldval
)
3284 Lisp_Object arg
, oldval
;
3286 int wid
= FRAME_COLUMN_WIDTH (f
);
3290 x_set_scroll_bar_default_width (f
);
3292 if (FRAME_X_WINDOW (f
))
3293 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3294 do_pending_window_change (0);
3296 else if (INTEGERP (arg
) && XINT (arg
) > 0
3297 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3299 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3300 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3302 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3303 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3304 if (FRAME_X_WINDOW (f
))
3305 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3306 do_pending_window_change (0);
3309 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3310 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3311 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3316 /* Return non-nil if frame F wants a bitmap icon. */
3324 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3332 /* Subroutines of creating an X frame. */
3334 /* Make sure that Vx_resource_name is set to a reasonable value.
3335 Fix it up, or set it to `emacs' if it is too hopeless. */
3338 validate_x_resource_name ()
3341 /* Number of valid characters in the resource name. */
3343 /* Number of invalid characters in the resource name. */
3348 if (!STRINGP (Vx_resource_class
))
3349 Vx_resource_class
= build_string (EMACS_CLASS
);
3351 if (STRINGP (Vx_resource_name
))
3353 unsigned char *p
= SDATA (Vx_resource_name
);
3356 len
= SBYTES (Vx_resource_name
);
3358 /* Only letters, digits, - and _ are valid in resource names.
3359 Count the valid characters and count the invalid ones. */
3360 for (i
= 0; i
< len
; i
++)
3363 if (! ((c
>= 'a' && c
<= 'z')
3364 || (c
>= 'A' && c
<= 'Z')
3365 || (c
>= '0' && c
<= '9')
3366 || c
== '-' || c
== '_'))
3373 /* Not a string => completely invalid. */
3374 bad_count
= 5, good_count
= 0;
3376 /* If name is valid already, return. */
3380 /* If name is entirely invalid, or nearly so, use `emacs'. */
3382 || (good_count
== 1 && bad_count
> 0))
3384 Vx_resource_name
= build_string ("emacs");
3388 /* Name is partly valid. Copy it and replace the invalid characters
3389 with underscores. */
3391 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3393 for (i
= 0; i
< len
; i
++)
3395 int c
= SREF (new, i
);
3396 if (! ((c
>= 'a' && c
<= 'z')
3397 || (c
>= 'A' && c
<= 'Z')
3398 || (c
>= '0' && c
<= '9')
3399 || c
== '-' || c
== '_'))
3405 extern char *x_get_string_resource
P_ ((XrmDatabase
, char *, char *));
3406 extern Display_Info
*check_x_display_info
P_ ((Lisp_Object
));
3409 /* Get specified attribute from resource database RDB.
3410 See Fx_get_resource below for other parameters. */
3413 xrdb_get_resource (rdb
, attribute
, class, component
, subclass
)
3415 Lisp_Object attribute
, class, component
, subclass
;
3417 register char *value
;
3421 CHECK_STRING (attribute
);
3422 CHECK_STRING (class);
3424 if (!NILP (component
))
3425 CHECK_STRING (component
);
3426 if (!NILP (subclass
))
3427 CHECK_STRING (subclass
);
3428 if (NILP (component
) != NILP (subclass
))
3429 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3431 validate_x_resource_name ();
3433 /* Allocate space for the components, the dots which separate them,
3434 and the final '\0'. Make them big enough for the worst case. */
3435 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3436 + (STRINGP (component
)
3437 ? SBYTES (component
) : 0)
3438 + SBYTES (attribute
)
3441 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3443 + (STRINGP (subclass
)
3444 ? SBYTES (subclass
) : 0)
3447 /* Start with emacs.FRAMENAME for the name (the specific one)
3448 and with `Emacs' for the class key (the general one). */
3449 strcpy (name_key
, SDATA (Vx_resource_name
));
3450 strcpy (class_key
, SDATA (Vx_resource_class
));
3452 strcat (class_key
, ".");
3453 strcat (class_key
, SDATA (class));
3455 if (!NILP (component
))
3457 strcat (class_key
, ".");
3458 strcat (class_key
, SDATA (subclass
));
3460 strcat (name_key
, ".");
3461 strcat (name_key
, SDATA (component
));
3464 strcat (name_key
, ".");
3465 strcat (name_key
, SDATA (attribute
));
3467 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3469 if (value
!= (char *) 0)
3470 return build_string (value
);
3476 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3477 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3478 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3479 class, where INSTANCE is the name under which Emacs was invoked, or
3480 the name specified by the `-name' or `-rn' command-line arguments.
3482 The optional arguments COMPONENT and SUBCLASS add to the key and the
3483 class, respectively. You must specify both of them or neither.
3484 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3485 and the class is `Emacs.CLASS.SUBCLASS'. */)
3486 (attribute
, class, component
, subclass
)
3487 Lisp_Object attribute
, class, component
, subclass
;
3489 #ifdef HAVE_X_WINDOWS
3493 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3494 attribute
, class, component
, subclass
);
3497 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3500 display_x_get_resource (dpyinfo
, attribute
, class, component
, subclass
)
3501 Display_Info
*dpyinfo
;
3502 Lisp_Object attribute
, class, component
, subclass
;
3504 return xrdb_get_resource (dpyinfo
->xrdb
,
3505 attribute
, class, component
, subclass
);
3508 /* Used when C code wants a resource value. */
3511 x_get_resource_string (attribute
, class)
3512 char *attribute
, *class;
3516 struct frame
*sf
= SELECTED_FRAME ();
3518 /* Allocate space for the components, the dots which separate them,
3519 and the final '\0'. */
3520 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3521 + strlen (attribute
) + 2);
3522 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3523 + strlen (class) + 2);
3525 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3526 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3528 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3529 name_key
, class_key
);
3533 /* Return the value of parameter PARAM.
3535 First search ALIST, then Vdefault_frame_alist, then the X defaults
3536 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3538 Convert the resource to the type specified by desired_type.
3540 If no default is specified, return Qunbound. If you call
3541 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3542 and don't let it get stored in any Lisp-visible variables! */
3545 x_get_arg (dpyinfo
, alist
, param
, attribute
, class, type
)
3546 Display_Info
*dpyinfo
;
3547 Lisp_Object alist
, param
;
3550 enum resource_types type
;
3552 register Lisp_Object tem
;
3554 tem
= Fassq (param
, alist
);
3558 /* If we find this parm in ALIST, clear it out
3559 so that it won't be "left over" at the end. */
3560 #ifndef WINDOWSNT /* w32fns.c has not yet been changed to cope with this. */
3562 XSETCAR (tem
, Qnil
);
3563 /* In case the parameter appears more than once in the alist,
3565 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3566 if (CONSP (XCAR (tail
))
3567 && EQ (XCAR (XCAR (tail
)), param
))
3568 XSETCAR (XCAR (tail
), Qnil
);
3572 tem
= Fassq (param
, Vdefault_frame_alist
);
3574 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3575 look in the X resources. */
3580 tem
= display_x_get_resource (dpyinfo
,
3581 build_string (attribute
),
3582 build_string (class),
3590 case RES_TYPE_NUMBER
:
3591 return make_number (atoi (SDATA (tem
)));
3593 case RES_TYPE_FLOAT
:
3594 return make_float (atof (SDATA (tem
)));
3596 case RES_TYPE_BOOLEAN
:
3597 tem
= Fdowncase (tem
);
3598 if (!strcmp (SDATA (tem
), "on")
3599 || !strcmp (SDATA (tem
), "true"))
3604 case RES_TYPE_STRING
:
3607 case RES_TYPE_SYMBOL
:
3608 /* As a special case, we map the values `true' and `on'
3609 to Qt, and `false' and `off' to Qnil. */
3612 lower
= Fdowncase (tem
);
3613 if (!strcmp (SDATA (lower
), "on")
3614 || !strcmp (SDATA (lower
), "true"))
3616 else if (!strcmp (SDATA (lower
), "off")
3617 || !strcmp (SDATA (lower
), "false"))
3620 return Fintern (tem
, Qnil
);
3634 x_frame_get_arg (f
, alist
, param
, attribute
, class, type
)
3636 Lisp_Object alist
, param
;
3639 enum resource_types type
;
3641 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3642 alist
, param
, attribute
, class, type
);
3645 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3648 x_frame_get_and_record_arg (f
, alist
, param
, attribute
, class, type
)
3650 Lisp_Object alist
, param
;
3653 enum resource_types type
;
3657 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3658 attribute
, class, type
);
3659 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3660 store_frame_param (f
, param
, value
);
3666 /* Record in frame F the specified or default value according to ALIST
3667 of the parameter named PROP (a Lisp symbol).
3668 If no value is specified for PROP, look for an X default for XPROP
3669 on the frame named NAME.
3670 If that is not found either, use the value DEFLT. */
3673 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
3680 enum resource_types type
;
3684 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3685 if (EQ (tem
, Qunbound
))
3687 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3694 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3695 doc
: /* Parse an X-style geometry string STRING.
3696 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3697 The properties returned may include `top', `left', `height', and `width'.
3698 The value of `left' or `top' may be an integer,
3699 or a list (+ N) meaning N pixels relative to top/left corner,
3700 or a list (- N) meaning -N pixels relative to bottom/right corner. */)
3705 unsigned int width
, height
;
3708 CHECK_STRING (string
);
3710 geometry
= XParseGeometry ((char *) SDATA (string
),
3711 &x
, &y
, &width
, &height
);
3714 if (!!(geometry
& XValue
) != !!(geometry
& YValue
))
3715 error ("Must specify both x and y position, or neither");
3719 if (geometry
& XValue
)
3721 Lisp_Object element
;
3723 if (x
>= 0 && (geometry
& XNegative
))
3724 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3725 else if (x
< 0 && ! (geometry
& XNegative
))
3726 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3728 element
= Fcons (Qleft
, make_number (x
));
3729 result
= Fcons (element
, result
);
3732 if (geometry
& YValue
)
3734 Lisp_Object element
;
3736 if (y
>= 0 && (geometry
& YNegative
))
3737 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3738 else if (y
< 0 && ! (geometry
& YNegative
))
3739 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3741 element
= Fcons (Qtop
, make_number (y
));
3742 result
= Fcons (element
, result
);
3745 if (geometry
& WidthValue
)
3746 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3747 if (geometry
& HeightValue
)
3748 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3753 /* Calculate the desired size and position of frame F.
3754 Return the flags saying which aspects were specified.
3756 Also set the win_gravity and size_hint_flags of F.
3758 Adjust height for toolbar if TOOLBAR_P is 1.
3760 This function does not make the coordinates positive. */
3762 #define DEFAULT_ROWS 40
3763 #define DEFAULT_COLS 80
3766 x_figure_window_size (f
, parms
, toolbar_p
)
3771 register Lisp_Object tem0
, tem1
, tem2
;
3772 long window_prompting
= 0;
3773 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3775 /* Default values if we fall through.
3776 Actually, if that happens we should get
3777 window manager prompting. */
3778 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3779 FRAME_LINES (f
) = DEFAULT_ROWS
;
3780 /* Window managers expect that if program-specified
3781 positions are not (0,0), they're intentional, not defaults. */
3785 /* Ensure that old new_text_cols and new_text_lines will not override the
3787 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3788 f
->new_text_cols
= f
->new_text_lines
= 0;
3790 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3791 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3792 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3793 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3795 if (!EQ (tem0
, Qunbound
))
3797 CHECK_NUMBER (tem0
);
3798 FRAME_LINES (f
) = XINT (tem0
);
3800 if (!EQ (tem1
, Qunbound
))
3802 CHECK_NUMBER (tem1
);
3803 SET_FRAME_COLS (f
, XINT (tem1
));
3805 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
3806 window_prompting
|= USSize
;
3808 window_prompting
|= PSize
;
3811 f
->scroll_bar_actual_width
3812 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
3814 /* This used to be done _before_ calling x_figure_window_size, but
3815 since the height is reset here, this was really a no-op. I
3816 assume that moving it here does what Gerd intended (although he
3817 no longer can remember what that was... ++KFS, 2003-03-25. */
3819 /* Add the tool-bar height to the initial frame height so that the
3820 user gets a text display area of the size he specified with -g or
3821 via .Xdefaults. Later changes of the tool-bar height don't
3822 change the frame size. This is done so that users can create
3823 tall Emacs frames without having to guess how tall the tool-bar
3825 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
3827 int margin
, relief
, bar_height
;
3829 relief
= (tool_bar_button_relief
>= 0
3830 ? tool_bar_button_relief
3831 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
3833 if (INTEGERP (Vtool_bar_button_margin
)
3834 && XINT (Vtool_bar_button_margin
) > 0)
3835 margin
= XFASTINT (Vtool_bar_button_margin
);
3836 else if (CONSP (Vtool_bar_button_margin
)
3837 && INTEGERP (XCDR (Vtool_bar_button_margin
))
3838 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
3839 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
3843 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
3844 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
3847 compute_fringe_widths (f
, 0);
3849 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
3850 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
3852 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
3853 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
3854 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
3855 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3857 if (EQ (tem0
, Qminus
))
3860 window_prompting
|= YNegative
;
3862 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
3863 && CONSP (XCDR (tem0
))
3864 && INTEGERP (XCAR (XCDR (tem0
))))
3866 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
3867 window_prompting
|= YNegative
;
3869 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
3870 && CONSP (XCDR (tem0
))
3871 && INTEGERP (XCAR (XCDR (tem0
))))
3873 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
3875 else if (EQ (tem0
, Qunbound
))
3879 CHECK_NUMBER (tem0
);
3880 f
->top_pos
= XINT (tem0
);
3882 window_prompting
|= YNegative
;
3885 if (EQ (tem1
, Qminus
))
3888 window_prompting
|= XNegative
;
3890 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
3891 && CONSP (XCDR (tem1
))
3892 && INTEGERP (XCAR (XCDR (tem1
))))
3894 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
3895 window_prompting
|= XNegative
;
3897 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
3898 && CONSP (XCDR (tem1
))
3899 && INTEGERP (XCAR (XCDR (tem1
))))
3901 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
3903 else if (EQ (tem1
, Qunbound
))
3907 CHECK_NUMBER (tem1
);
3908 f
->left_pos
= XINT (tem1
);
3909 if (f
->left_pos
< 0)
3910 window_prompting
|= XNegative
;
3913 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
3914 window_prompting
|= USPosition
;
3916 window_prompting
|= PPosition
;
3919 if (f
->want_fullscreen
!= FULLSCREEN_NONE
)
3924 /* It takes both for some WM:s to place it where we want */
3925 window_prompting
|= USPosition
| PPosition
;
3926 x_fullscreen_adjust (f
, &width
, &height
, &top
, &left
);
3927 FRAME_COLS (f
) = width
;
3928 FRAME_LINES (f
) = height
;
3929 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, width
);
3930 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, height
);
3935 if (window_prompting
& XNegative
)
3937 if (window_prompting
& YNegative
)
3938 f
->win_gravity
= SouthEastGravity
;
3940 f
->win_gravity
= NorthEastGravity
;
3944 if (window_prompting
& YNegative
)
3945 f
->win_gravity
= SouthWestGravity
;
3947 f
->win_gravity
= NorthWestGravity
;
3950 f
->size_hint_flags
= window_prompting
;
3952 return window_prompting
;
3957 #endif /* HAVE_WINDOW_SYSTEM */
3961 /***********************************************************************
3963 ***********************************************************************/
3968 Qframep
= intern ("framep");
3969 staticpro (&Qframep
);
3970 Qframe_live_p
= intern ("frame-live-p");
3971 staticpro (&Qframe_live_p
);
3972 Qexplicit_name
= intern ("explicit-name");
3973 staticpro (&Qexplicit_name
);
3974 Qheight
= intern ("height");
3975 staticpro (&Qheight
);
3976 Qicon
= intern ("icon");
3978 Qminibuffer
= intern ("minibuffer");
3979 staticpro (&Qminibuffer
);
3980 Qmodeline
= intern ("modeline");
3981 staticpro (&Qmodeline
);
3982 Qonly
= intern ("only");
3984 Qwidth
= intern ("width");
3985 staticpro (&Qwidth
);
3986 Qgeometry
= intern ("geometry");
3987 staticpro (&Qgeometry
);
3988 Qicon_left
= intern ("icon-left");
3989 staticpro (&Qicon_left
);
3990 Qicon_top
= intern ("icon-top");
3991 staticpro (&Qicon_top
);
3992 Qleft
= intern ("left");
3994 Qright
= intern ("right");
3995 staticpro (&Qright
);
3996 Quser_position
= intern ("user-position");
3997 staticpro (&Quser_position
);
3998 Quser_size
= intern ("user-size");
3999 staticpro (&Quser_size
);
4000 Qwindow_id
= intern ("window-id");
4001 staticpro (&Qwindow_id
);
4002 #ifdef HAVE_X_WINDOWS
4003 Qouter_window_id
= intern ("outer-window-id");
4004 staticpro (&Qouter_window_id
);
4006 Qparent_id
= intern ("parent-id");
4007 staticpro (&Qparent_id
);
4010 Qw32
= intern ("w32");
4012 Qpc
= intern ("pc");
4014 Qmac
= intern ("mac");
4016 Qvisible
= intern ("visible");
4017 staticpro (&Qvisible
);
4018 Qbuffer_predicate
= intern ("buffer-predicate");
4019 staticpro (&Qbuffer_predicate
);
4020 Qbuffer_list
= intern ("buffer-list");
4021 staticpro (&Qbuffer_list
);
4022 Qdisplay_type
= intern ("display-type");
4023 staticpro (&Qdisplay_type
);
4024 Qbackground_mode
= intern ("background-mode");
4025 staticpro (&Qbackground_mode
);
4026 Qtty_color_mode
= intern ("tty-color-mode");
4027 staticpro (&Qtty_color_mode
);
4029 Qface_set_after_frame_default
= intern ("face-set-after-frame-default");
4030 staticpro (&Qface_set_after_frame_default
);
4032 Qinhibit_face_set_after_frame_default
4033 = intern ("inhibit-face-set-after-frame-default");
4034 staticpro (&Qinhibit_face_set_after_frame_default
);
4036 Qfullwidth
= intern ("fullwidth");
4037 staticpro (&Qfullwidth
);
4038 Qfullheight
= intern ("fullheight");
4039 staticpro (&Qfullheight
);
4040 Qfullboth
= intern ("fullboth");
4041 staticpro (&Qfullboth
);
4042 Qx_resource_name
= intern ("x-resource-name");
4043 staticpro (&Qx_resource_name
);
4045 Qx_frame_parameter
= intern ("x-frame-parameter");
4046 staticpro (&Qx_frame_parameter
);
4051 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4053 Lisp_Object v
= intern (frame_parms
[i
].name
);
4054 if (frame_parms
[i
].variable
)
4056 *frame_parms
[i
].variable
= v
;
4057 staticpro (frame_parms
[i
].variable
);
4059 Fput (v
, Qx_frame_parameter
, make_number (i
));
4063 #ifdef HAVE_WINDOW_SYSTEM
4064 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4065 doc
: /* The name Emacs uses to look up X resources.
4066 `x-get-resource' uses this as the first component of the instance name
4067 when requesting resource values.
4068 Emacs initially sets `x-resource-name' to the name under which Emacs
4069 was invoked, or to the value specified with the `-name' or `-rn'
4070 switches, if present.
4072 It may be useful to bind this variable locally around a call
4073 to `x-get-resource'. See also the variable `x-resource-class'. */);
4074 Vx_resource_name
= Qnil
;
4076 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4077 doc
: /* The class Emacs uses to look up X resources.
4078 `x-get-resource' uses this as the first component of the instance class
4079 when requesting resource values.
4081 Emacs initially sets `x-resource-class' to "Emacs".
4083 Setting this variable permanently is not a reasonable thing to do,
4084 but binding this variable locally around a call to `x-get-resource'
4085 is a reasonable practice. See also the variable `x-resource-name'. */);
4086 Vx_resource_class
= build_string (EMACS_CLASS
);
4089 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4090 doc
: /* Alist of default values for frame creation.
4091 These may be set in your init file, like this:
4092 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4093 These override values given in window system configuration data,
4094 including X Windows' defaults database.
4095 For values specific to the first Emacs frame, see `initial-frame-alist'.
4096 For values specific to the separate minibuffer frame, see
4097 `minibuffer-frame-alist'.
4098 The `menu-bar-lines' element of the list controls whether new frames
4099 have menu bars; `menu-bar-mode' works by altering this element.
4100 Setting this variable does not affect existing frames, only new ones. */);
4101 Vdefault_frame_alist
= Qnil
;
4103 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars
,
4104 doc
: /* Default position of scroll bars on this window-system. */);
4105 #ifdef HAVE_WINDOW_SYSTEM
4106 #if defined(HAVE_NTGUI) || defined(MAC_OS)
4107 /* MS-Windows has scroll bars on the right by default. */
4108 Vdefault_frame_scroll_bars
= Qright
;
4110 Vdefault_frame_scroll_bars
= Qleft
;
4113 Vdefault_frame_scroll_bars
= Qnil
;
4116 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4117 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4119 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
4120 doc
: /* Non-nil if all of Emacs is iconified and frame updates are not needed. */);
4121 Vemacs_iconified
= Qnil
;
4123 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4124 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4125 `mouse-position' calls this function, passing its usual return value as
4126 argument, and returns whatever this function returns.
4127 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4128 which need to do mouse handling at the Lisp level. */);
4129 Vmouse_position_function
= Qnil
;
4131 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4132 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4133 If the value is an integer, highlighting is only shown after moving the
4134 mouse, while keyboard input turns off the highlight even when the mouse
4135 is over the clickable text. However, the mouse shape still indicates
4136 when the mouse is over clickable text. */);
4137 Vmouse_highlight
= Qt
;
4139 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4140 doc
: /* Functions to be run before deleting a frame.
4141 The functions are run with one arg, the frame to be deleted.
4142 See `delete-frame'. */);
4143 Vdelete_frame_functions
= Qnil
;
4145 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4146 doc
: /* Minibufferless frames use this frame's minibuffer.
4148 Emacs cannot create minibufferless frames unless this is set to an
4149 appropriate surrogate.
4151 Emacs consults this variable only when creating minibufferless
4152 frames; once the frame is created, it sticks with its assigned
4153 minibuffer, no matter what this variable is set to. This means that
4154 this variable doesn't necessarily say anything meaningful about the
4155 current set of frames, or where the minibuffer is currently being
4158 This variable is local to the current terminal and cannot be buffer-local. */);
4160 DEFVAR_BOOL ("focus-follows-mouse", &focus_follows_mouse
,
4161 doc
: /* Non-nil if window system changes focus when you move the mouse.
4162 You should set this variable to tell Emacs how your window manager
4163 handles focus, since there is no way in general for Emacs to find out
4165 #ifdef HAVE_WINDOW_SYSTEM
4166 #if defined(HAVE_NTGUI) || defined(MAC_OS)
4167 focus_follows_mouse
= 0;
4169 focus_follows_mouse
= 1;
4172 focus_follows_mouse
= 0;
4175 staticpro (&Vframe_list
);
4177 defsubr (&Sactive_minibuffer_window
);
4179 defsubr (&Sframe_live_p
);
4180 defsubr (&Smake_terminal_frame
);
4181 defsubr (&Shandle_switch_frame
);
4182 defsubr (&Sselect_frame
);
4183 defsubr (&Sselected_frame
);
4184 defsubr (&Swindow_frame
);
4185 defsubr (&Sframe_root_window
);
4186 defsubr (&Sframe_first_window
);
4187 defsubr (&Sframe_selected_window
);
4188 defsubr (&Sset_frame_selected_window
);
4189 defsubr (&Sframe_list
);
4190 defsubr (&Snext_frame
);
4191 defsubr (&Sprevious_frame
);
4192 defsubr (&Sdelete_frame
);
4193 defsubr (&Smouse_position
);
4194 defsubr (&Smouse_pixel_position
);
4195 defsubr (&Sset_mouse_position
);
4196 defsubr (&Sset_mouse_pixel_position
);
4198 defsubr (&Sframe_configuration
);
4199 defsubr (&Srestore_frame_configuration
);
4201 defsubr (&Smake_frame_visible
);
4202 defsubr (&Smake_frame_invisible
);
4203 defsubr (&Siconify_frame
);
4204 defsubr (&Sframe_visible_p
);
4205 defsubr (&Svisible_frame_list
);
4206 defsubr (&Sraise_frame
);
4207 defsubr (&Slower_frame
);
4208 defsubr (&Sredirect_frame_focus
);
4209 defsubr (&Sframe_focus
);
4210 defsubr (&Sframe_parameters
);
4211 defsubr (&Sframe_parameter
);
4212 defsubr (&Smodify_frame_parameters
);
4213 defsubr (&Sframe_char_height
);
4214 defsubr (&Sframe_char_width
);
4215 defsubr (&Sframe_pixel_height
);
4216 defsubr (&Sframe_pixel_width
);
4217 defsubr (&Sset_frame_height
);
4218 defsubr (&Sset_frame_width
);
4219 defsubr (&Sset_frame_size
);
4220 defsubr (&Sset_frame_position
);
4222 #ifdef HAVE_WINDOW_SYSTEM
4223 defsubr (&Sx_get_resource
);
4224 defsubr (&Sx_parse_geometry
);
4229 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4230 (do not change this comment) */