1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
37 /* These help us bind and responding to switch-frame events. */
41 #ifdef HAVE_WINDOW_SYSTEM
44 #include "blockinput.h"
45 #include "termhooks.h"
46 #include "dispextern.h"
54 #ifdef HAVE_WINDOW_SYSTEM
56 /* The name we're using in resource queries. Most often "emacs". */
58 Lisp_Object Vx_resource_name
;
60 /* The application class we're using in resource queries.
63 Lisp_Object Vx_resource_class
;
67 Lisp_Object Qframep
, Qframe_live_p
;
68 Lisp_Object Qicon
, Qmodeline
;
70 Lisp_Object Qx
, Qw32
, Qmac
, Qpc
;
72 Lisp_Object Qdisplay_type
;
73 Lisp_Object Qbackground_mode
;
74 Lisp_Object Qinhibit_default_face_x_resources
;
76 Lisp_Object Qx_frame_parameter
;
77 Lisp_Object Qx_resource_name
;
79 /* Frame parameters (set or reported). */
81 Lisp_Object Qauto_raise
, Qauto_lower
;
82 Lisp_Object Qborder_color
, Qborder_width
;
83 Lisp_Object Qcursor_color
, Qcursor_type
;
84 Lisp_Object Qgeometry
; /* Not used */
85 Lisp_Object Qheight
, Qwidth
;
86 Lisp_Object Qleft
, Qright
;
87 Lisp_Object Qicon_left
, Qicon_top
, Qicon_type
, Qicon_name
;
88 Lisp_Object Qinternal_border_width
;
89 Lisp_Object Qmouse_color
;
90 Lisp_Object Qminibuffer
;
91 Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
92 Lisp_Object Qvisibility
;
93 Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
94 Lisp_Object Qscreen_gamma
;
95 Lisp_Object Qline_spacing
;
96 Lisp_Object Quser_position
, Quser_size
;
97 Lisp_Object Qwait_for_wm
;
98 Lisp_Object Qwindow_id
;
100 Lisp_Object Qouter_window_id
;
102 Lisp_Object Qparent_id
;
103 Lisp_Object Qtitle
, Qname
;
104 Lisp_Object Qunsplittable
;
105 Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
106 Lisp_Object Qleft_fringe
, Qright_fringe
;
107 Lisp_Object Qbuffer_predicate
, Qbuffer_list
;
108 Lisp_Object Qtty_color_mode
;
110 Lisp_Object Qfullscreen
, Qfullwidth
, Qfullheight
, Qfullboth
;
112 Lisp_Object 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
;
124 set_menu_bar_lines_1 (window
, n
)
128 struct window
*w
= XWINDOW (window
);
130 XSETFASTINT (w
->last_modified
, 0);
131 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
132 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
134 if (INTEGERP (w
->orig_top_line
))
135 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
136 if (INTEGERP (w
->orig_total_lines
))
137 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
139 /* Handle just the top child in a vertical split. */
140 if (!NILP (w
->vchild
))
141 set_menu_bar_lines_1 (w
->vchild
, n
);
143 /* Adjust all children in a horizontal split. */
144 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
146 w
= XWINDOW (window
);
147 set_menu_bar_lines_1 (window
, n
);
152 set_menu_bar_lines (f
, value
, oldval
)
154 Lisp_Object value
, oldval
;
157 int olines
= FRAME_MENU_BAR_LINES (f
);
159 /* Right now, menu bars don't work properly in minibuf-only frames;
160 most of the commands try to apply themselves to the minibuffer
161 frame itself, and get an error because you can't switch buffers
162 in or split the minibuffer window. */
163 if (FRAME_MINIBUF_ONLY_P (f
))
166 if (INTEGERP (value
))
167 nlines
= XINT (value
);
171 if (nlines
!= olines
)
173 windows_or_buffers_changed
++;
174 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
175 FRAME_MENU_BAR_LINES (f
) = nlines
;
176 set_menu_bar_lines_1 (f
->root_window
, nlines
- olines
);
181 Lisp_Object Vemacs_iconified
;
182 Lisp_Object Vframe_list
;
184 struct x_output tty_display
;
186 extern Lisp_Object Vminibuffer_list
;
187 extern Lisp_Object
get_minibuffer ();
188 extern Lisp_Object
Fhandle_switch_frame ();
189 extern Lisp_Object
Fredirect_frame_focus ();
190 extern Lisp_Object
x_get_focus_frame ();
192 DEFUN ("framep", Fframep
, Sframep
, 1, 1, 0,
193 doc
: /* Return non-nil if OBJECT is a frame.
194 Value is t for a termcap frame (a character-only terminal),
195 `x' for an Emacs frame that is really an X window,
196 `w32' for an Emacs frame that is a window on MS-Windows display,
197 `mac' for an Emacs frame on a Macintosh display,
198 `pc' for a direct-write MS-DOS frame.
199 See also `frame-live-p'. */)
203 if (!FRAMEP (object
))
205 switch (XFRAME (object
)->output_method
)
209 case output_x_window
:
213 case output_msdos_raw
:
222 DEFUN ("frame-live-p", Fframe_live_p
, Sframe_live_p
, 1, 1, 0,
223 doc
: /* Return non-nil if OBJECT is a frame which has not been deleted.
224 Value is nil if OBJECT is not a live frame. If object is a live
225 frame, the return value indicates what sort of output device it is
226 displayed on. See the documentation of `framep' for possible
231 return ((FRAMEP (object
)
232 && FRAME_LIVE_P (XFRAME (object
)))
242 register struct frame
*f
;
243 register Lisp_Object root_window
;
244 register Lisp_Object mini_window
;
246 f
= allocate_frame ();
247 XSETFRAME (frame
, f
);
249 f
->desired_matrix
= 0;
250 f
->current_matrix
= 0;
253 f
->glyphs_initialized_p
= 0;
254 f
->decode_mode_spec_buffer
= 0;
256 f
->async_visible
= 0;
257 f
->output_data
.nothing
= 0;
259 f
->async_iconified
= 0;
260 f
->wants_modeline
= 1;
265 f
->has_minibuffer
= mini_p
;
266 f
->focus_frame
= Qnil
;
267 f
->explicit_name
= 0;
268 f
->can_have_scroll_bars
= 0;
269 f
->vertical_scroll_bar_type
= vertical_scroll_bar_none
;
270 f
->param_alist
= Qnil
;
271 f
->scroll_bars
= Qnil
;
272 f
->condemned_scroll_bars
= Qnil
;
273 f
->face_alist
= Qnil
;
274 f
->face_cache
= NULL
;
275 f
->menu_bar_items
= Qnil
;
276 f
->menu_bar_vector
= Qnil
;
277 f
->menu_bar_items_used
= 0;
278 f
->buffer_predicate
= Qnil
;
279 f
->buffer_list
= Qnil
;
281 f
->kboard
= initial_kboard
;
285 f
->menu_bar_window
= Qnil
;
286 f
->tool_bar_window
= Qnil
;
287 f
->tool_bar_items
= Qnil
;
288 f
->desired_tool_bar_string
= f
->current_tool_bar_string
= Qnil
;
289 f
->n_tool_bar_items
= 0;
290 f
->left_fringe_width
= f
->right_fringe_width
= 0;
292 f
->scroll_bar_actual_width
= 0;
294 f
->internal_border_width
= 0;
295 f
->column_width
= 1; /* !FRAME_WINDOW_P value */
296 f
->line_height
= 1; /* !FRAME_WINDOW_P value */
297 f
->x_pixels_diff
= f
->y_pixels_diff
= 0;
298 #ifdef HAVE_WINDOW_SYSTEM
299 f
->want_fullscreen
= FULLSCREEN_NONE
;
301 f
->size_hint_flags
= 0;
304 root_window
= make_window ();
307 mini_window
= make_window ();
308 XWINDOW (root_window
)->next
= mini_window
;
309 XWINDOW (mini_window
)->prev
= root_window
;
310 XWINDOW (mini_window
)->mini_p
= Qt
;
311 XWINDOW (mini_window
)->frame
= frame
;
312 f
->minibuffer_window
= mini_window
;
317 XWINDOW (root_window
)->next
= Qnil
;
318 f
->minibuffer_window
= Qnil
;
321 XWINDOW (root_window
)->frame
= frame
;
324 just so that there is "something there."
325 Correct size will be set up later with change_frame_size. */
327 SET_FRAME_COLS (f
, 10);
328 FRAME_LINES (f
) = 10;
330 XSETFASTINT (XWINDOW (root_window
)->total_cols
, 10);
331 XSETFASTINT (XWINDOW (root_window
)->total_lines
, (mini_p
? 9 : 10));
335 XSETFASTINT (XWINDOW (mini_window
)->total_cols
, 10);
336 XSETFASTINT (XWINDOW (mini_window
)->top_line
, 9);
337 XSETFASTINT (XWINDOW (mini_window
)->total_lines
, 1);
340 /* Choose a buffer for the frame's root window. */
344 XWINDOW (root_window
)->buffer
= Qt
;
345 buf
= Fcurrent_buffer ();
346 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
347 a space), try to find another one. */
348 if (SREF (Fbuffer_name (buf
), 0) == ' ')
349 buf
= Fother_buffer (buf
, Qnil
, Qnil
);
351 /* Use set_window_buffer, not Fset_window_buffer, and don't let
352 hooks be run by it. The reason is that the whole frame/window
353 arrangement is not yet fully intialized at this point. Windows
354 don't have the right size, glyph matrices aren't initialized
355 etc. Running Lisp functions at this point surely ends in a
357 set_window_buffer (root_window
, buf
, 0, 0);
358 f
->buffer_list
= Fcons (buf
, Qnil
);
363 XWINDOW (mini_window
)->buffer
= Qt
;
364 set_window_buffer (mini_window
,
365 (NILP (Vminibuffer_list
)
367 : Fcar (Vminibuffer_list
)),
371 f
->root_window
= root_window
;
372 f
->selected_window
= root_window
;
373 /* Make sure this window seems more recently used than
374 a newly-created, never-selected window. */
375 ++window_select_count
;
376 XSETFASTINT (XWINDOW (f
->selected_window
)->use_time
, window_select_count
);
378 f
->default_face_done_p
= 0;
383 #ifdef HAVE_WINDOW_SYSTEM
384 /* Make a frame using a separate minibuffer window on another frame.
385 MINI_WINDOW is the minibuffer window to use. nil means use the
386 default (the global minibuffer). */
389 make_frame_without_minibuffer (mini_window
, kb
, display
)
390 register Lisp_Object mini_window
;
394 register struct frame
*f
;
397 if (!NILP (mini_window
))
398 CHECK_LIVE_WINDOW (mini_window
);
401 if (!NILP (mini_window
)
402 && XFRAME (XWINDOW (mini_window
)->frame
)->kboard
!= kb
)
403 error ("Frame and minibuffer must be on the same display");
406 /* Make a frame containing just a root window. */
409 if (NILP (mini_window
))
411 /* Use default-minibuffer-frame if possible. */
412 if (!FRAMEP (kb
->Vdefault_minibuffer_frame
)
413 || ! FRAME_LIVE_P (XFRAME (kb
->Vdefault_minibuffer_frame
)))
415 Lisp_Object frame_dummy
;
417 XSETFRAME (frame_dummy
, f
);
418 GCPRO1 (frame_dummy
);
419 /* If there's no minibuffer frame to use, create one. */
420 kb
->Vdefault_minibuffer_frame
=
421 call1 (intern ("make-initial-minibuffer-frame"), display
);
425 mini_window
= XFRAME (kb
->Vdefault_minibuffer_frame
)->minibuffer_window
;
428 f
->minibuffer_window
= mini_window
;
430 /* Make the chosen minibuffer window display the proper minibuffer,
431 unless it is already showing a minibuffer. */
432 if (NILP (Fmemq (XWINDOW (mini_window
)->buffer
, Vminibuffer_list
)))
433 Fset_window_buffer (mini_window
,
434 (NILP (Vminibuffer_list
)
436 : Fcar (Vminibuffer_list
)), Qnil
);
440 /* Make a frame containing only a minibuffer window. */
443 make_minibuffer_frame ()
445 /* First make a frame containing just a root window, no minibuffer. */
447 register struct frame
*f
= make_frame (0);
448 register Lisp_Object mini_window
;
449 register Lisp_Object frame
;
451 XSETFRAME (frame
, f
);
456 f
->wants_modeline
= 0;
457 f
->has_minibuffer
= 1;
459 /* Now label the root window as also being the minibuffer.
460 Avoid infinite looping on the window chain by marking next pointer
463 mini_window
= f
->minibuffer_window
= f
->root_window
;
464 XWINDOW (mini_window
)->mini_p
= Qt
;
465 XWINDOW (mini_window
)->next
= Qnil
;
466 XWINDOW (mini_window
)->prev
= Qnil
;
467 XWINDOW (mini_window
)->frame
= frame
;
469 /* Put the proper buffer in that window. */
471 Fset_window_buffer (mini_window
,
472 (NILP (Vminibuffer_list
)
474 : Fcar (Vminibuffer_list
)), Qnil
);
477 #endif /* HAVE_WINDOW_SYSTEM */
479 /* Construct a frame that refers to the terminal (stdin and stdout). */
481 static int terminal_frame_count
;
484 make_terminal_frame ()
486 register struct frame
*f
;
493 initial_kboard
= (KBOARD
*) xmalloc (sizeof (KBOARD
));
494 init_kboard (initial_kboard
);
495 initial_kboard
->next_kboard
= all_kboards
;
496 all_kboards
= initial_kboard
;
500 /* The first call must initialize Vframe_list. */
501 if (! (NILP (Vframe_list
) || CONSP (Vframe_list
)))
506 XSETFRAME (frame
, f
);
507 Vframe_list
= Fcons (frame
, Vframe_list
);
509 terminal_frame_count
++;
510 sprintf (name
, "F%d", terminal_frame_count
);
511 f
->name
= build_string (name
);
513 f
->visible
= 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
514 f
->async_visible
= 1; /* Don't let visible be cleared later. */
516 f
->output_data
.x
= &the_only_x_display
;
517 if (!inhibit_window_system
518 && (!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
))
519 || XFRAME (selected_frame
)->output_method
== output_msdos_raw
))
521 f
->output_method
= output_msdos_raw
;
522 /* This initialization of foreground and background pixels is
523 only important for the initial frame created in temacs. If
524 we don't do that, we get black background and foreground in
525 the dumped Emacs because the_only_x_display is a static
526 variable, hence it is born all-zeroes, and zero is the code
527 for the black color. Other frames all inherit their pixels
528 from what's already in the_only_x_display. */
529 if ((!FRAMEP (selected_frame
) || !FRAME_LIVE_P (XFRAME (selected_frame
)))
530 && f
->output_data
.x
->background_pixel
== 0
531 && f
->output_data
.x
->foreground_pixel
== 0)
533 f
->output_data
.x
->background_pixel
= FACE_TTY_DEFAULT_BG_COLOR
;
534 f
->output_data
.x
->foreground_pixel
= FACE_TTY_DEFAULT_FG_COLOR
;
538 f
->output_method
= output_termcap
;
541 f
->output_method
= output_termcap
;
542 f
->output_data
.x
= &tty_display
;
545 make_mac_terminal_frame (f
);
547 f
->output_data
.x
= &tty_display
;
549 FRAME_FOREGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_FG_COLOR
;
550 FRAME_BACKGROUND_PIXEL(f
) = FACE_TTY_DEFAULT_BG_COLOR
;
553 #endif /* WINDOWSNT */
557 init_frame_faces (f
);
562 DEFUN ("make-terminal-frame", Fmake_terminal_frame
, Smake_terminal_frame
,
564 doc
: /* Create an additional terminal frame.
565 You can create multiple frames on a text-only terminal in this way.
566 Only the selected terminal frame is actually displayed.
567 This function takes one argument, an alist specifying frame parameters.
568 In practice, generally you don't need to specify any parameters.
569 Note that changing the size of one terminal frame automatically affects all. */)
574 Lisp_Object frame
, tem
;
575 struct frame
*sf
= SELECTED_FRAME ();
578 if (sf
->output_method
!= output_msdos_raw
579 && sf
->output_method
!= output_termcap
)
581 #else /* not MSDOS */
584 if (sf
->output_method
!= output_mac
)
585 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
587 if (sf
->output_method
!= output_termcap
)
588 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
590 #endif /* not MSDOS */
592 f
= make_terminal_frame ();
594 change_frame_size (f
, FRAME_LINES (sf
),
595 FRAME_COLS (sf
), 0, 0, 0);
598 XSETFRAME (frame
, f
);
599 Fmodify_frame_parameters (frame
, Vdefault_frame_alist
);
600 Fmodify_frame_parameters (frame
, parms
);
602 /* Make the frame face alist be frame-specific, so that each
603 frame could change its face definitions independently. */
604 f
->face_alist
= Fcopy_alist (sf
->face_alist
);
605 /* Simple Fcopy_alist isn't enough, because we need the contents of
606 the vectors which are the CDRs of associations in face_alist to
607 be copied as well. */
608 for (tem
= f
->face_alist
; CONSP (tem
); tem
= XCDR (tem
))
609 XSETCDR (XCAR (tem
), Fcopy_sequence (XCDR (XCAR (tem
))));
614 /* Perform the switch to frame FRAME.
616 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
619 If TRACK is non-zero and the frame that currently has the focus
620 redirects its focus to the selected frame, redirect that focused
621 frame's focus to FRAME instead.
623 FOR_DELETION non-zero means that the selected frame is being
624 deleted, which includes the possibility that the frame's display
628 do_switch_frame (frame
, track
, for_deletion
)
630 int track
, for_deletion
;
632 struct frame
*sf
= SELECTED_FRAME ();
634 /* If FRAME is a switch-frame event, extract the frame we should
637 && EQ (XCAR (frame
), Qswitch_frame
)
638 && CONSP (XCDR (frame
)))
639 frame
= XCAR (XCDR (frame
));
641 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
642 a switch-frame event to arrive after a frame is no longer live,
643 especially when deleting the initial frame during startup. */
645 if (! FRAME_LIVE_P (XFRAME (frame
)))
648 if (sf
== XFRAME (frame
))
651 /* This is too greedy; it causes inappropriate focus redirection
652 that's hard to get rid of. */
654 /* If a frame's focus has been redirected toward the currently
655 selected frame, we should change the redirection to point to the
656 newly selected frame. This means that if the focus is redirected
657 from a minibufferless frame to a surrogate minibuffer frame, we
658 can use `other-window' to switch between all the frames using
659 that minibuffer frame, and the focus redirection will follow us
665 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
669 if (!FRAMEP (XCAR (tail
)))
672 focus
= FRAME_FOCUS_FRAME (XFRAME (XCAR (tail
)));
674 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
675 Fredirect_frame_focus (XCAR (tail
), frame
);
679 /* Instead, apply it only to the frame we're pointing to. */
680 #ifdef HAVE_WINDOW_SYSTEM
681 if (track
&& FRAME_WINDOW_P (XFRAME (frame
)))
683 Lisp_Object focus
, xfocus
;
685 xfocus
= x_get_focus_frame (XFRAME (frame
));
688 focus
= FRAME_FOCUS_FRAME (XFRAME (xfocus
));
689 if (FRAMEP (focus
) && XFRAME (focus
) == SELECTED_FRAME ())
690 Fredirect_frame_focus (xfocus
, frame
);
693 #endif /* HAVE_X_WINDOWS */
696 if (!for_deletion
&& FRAME_HAS_MINIBUF_P (sf
))
697 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf
)), 1);
699 selected_frame
= frame
;
700 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame
)))
701 last_nonminibuf_frame
= XFRAME (selected_frame
);
703 Fselect_window (XFRAME (frame
)->selected_window
, Qnil
);
706 /* Make sure to switch the tty color mode to that of the newly
708 sf
= SELECTED_FRAME ();
709 if (FRAME_TERMCAP_P (sf
))
711 Lisp_Object color_mode_spec
, color_mode
;
713 color_mode_spec
= assq_no_quit (Qtty_color_mode
, sf
->param_alist
);
714 if (CONSP (color_mode_spec
))
715 color_mode
= XCDR (color_mode_spec
);
717 color_mode
= make_number (0);
718 set_tty_color_mode (sf
, color_mode
);
720 #endif /* !WINDOWSNT */
722 /* We want to make sure that the next event generates a frame-switch
723 event to the appropriate frame. This seems kludgy to me, but
724 before you take it out, make sure that evaluating something like
725 (select-window (frame-root-window (new-frame))) doesn't end up
726 with your typing being interpreted in the new frame instead of
727 the one you're actually typing in. */
728 internal_last_event_frame
= Qnil
;
733 DEFUN ("select-frame", Fselect_frame
, Sselect_frame
, 1, 1, "e",
734 doc
: /* Select the frame FRAME.
735 Subsequent editing commands apply to its selected window.
736 The selection of FRAME lasts until the next time the user does
737 something to select a different frame, or until the next time this
738 function is called. If you are using a window system, the previously
739 selected frame may be restored as the selected frame after return to
740 the command loop, because it still may have the window system's input
741 focus. On a text-only terminal, the next redisplay will display FRAME.
743 This function returns FRAME, or nil if FRAME has been deleted. */)
747 return do_switch_frame (frame
, 1, 0);
751 DEFUN ("handle-switch-frame", Fhandle_switch_frame
, Shandle_switch_frame
, 1, 1, "e",
752 doc
: /* Handle a switch-frame event EVENT.
753 Switch-frame events are usually bound to this function.
754 A switch-frame event tells Emacs that the window manager has requested
755 that the user's events be directed to the frame mentioned in the event.
756 This function selects the selected window of the frame of EVENT.
758 If EVENT is frame object, handle it as if it were a switch-frame event
763 /* Preserve prefix arg that the command loop just cleared. */
764 current_kboard
->Vprefix_arg
= Vcurrent_prefix_arg
;
765 call1 (Vrun_hooks
, Qmouse_leave_buffer_hook
);
766 return do_switch_frame (event
, 0, 0);
769 DEFUN ("selected-frame", Fselected_frame
, Sselected_frame
, 0, 0, 0,
770 doc
: /* Return the frame that is now selected. */)
773 return selected_frame
;
776 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
777 doc
: /* Return the frame object that window WINDOW is on. */)
781 CHECK_LIVE_WINDOW (window
);
782 return XWINDOW (window
)->frame
;
785 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
786 doc
: /* Returns the topmost, leftmost window of FRAME.
787 If omitted, FRAME defaults to the currently selected frame. */)
794 w
= SELECTED_FRAME ()->root_window
;
797 CHECK_LIVE_FRAME (frame
);
798 w
= XFRAME (frame
)->root_window
;
800 while (NILP (XWINDOW (w
)->buffer
))
802 if (! NILP (XWINDOW (w
)->hchild
))
803 w
= XWINDOW (w
)->hchild
;
804 else if (! NILP (XWINDOW (w
)->vchild
))
805 w
= XWINDOW (w
)->vchild
;
812 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
813 Sactive_minibuffer_window
, 0, 0, 0,
814 doc
: /* Return the currently active minibuffer window, or nil if none. */)
817 return minibuf_level
? minibuf_window
: Qnil
;
820 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
821 doc
: /* Returns the root-window of FRAME.
822 If omitted, FRAME defaults to the currently selected frame. */)
829 window
= SELECTED_FRAME ()->root_window
;
832 CHECK_LIVE_FRAME (frame
);
833 window
= XFRAME (frame
)->root_window
;
839 DEFUN ("frame-selected-window", Fframe_selected_window
,
840 Sframe_selected_window
, 0, 1, 0,
841 doc
: /* Return the selected window of frame object FRAME.
842 If omitted, FRAME defaults to the currently selected frame. */)
849 window
= SELECTED_FRAME ()->selected_window
;
852 CHECK_LIVE_FRAME (frame
);
853 window
= XFRAME (frame
)->selected_window
;
859 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
860 Sset_frame_selected_window
, 2, 2, 0,
861 doc
: /* Set the selected window of frame object FRAME to WINDOW.
863 If FRAME is nil, the selected frame is used.
864 If FRAME is the selected frame, this makes WINDOW the selected window. */)
866 Lisp_Object frame
, window
;
869 frame
= selected_frame
;
871 CHECK_LIVE_FRAME (frame
);
872 CHECK_LIVE_WINDOW (window
);
874 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
875 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
877 if (EQ (frame
, selected_frame
))
878 return Fselect_window (window
, Qnil
);
880 return XFRAME (frame
)->selected_window
= window
;
883 DEFUN ("frame-list", Fframe_list
, Sframe_list
,
885 doc
: /* Return a list of all frames. */)
889 frames
= Fcopy_sequence (Vframe_list
);
890 #ifdef HAVE_WINDOW_SYSTEM
891 if (FRAMEP (tip_frame
))
892 frames
= Fdelq (tip_frame
, frames
);
897 /* Return the next frame in the frame list after FRAME.
898 If MINIBUF is nil, exclude minibuffer-only frames.
899 If MINIBUF is a window, include only its own frame
900 and any frame now using that window as the minibuffer.
901 If MINIBUF is `visible', include all visible frames.
902 If MINIBUF is 0, include all visible and iconified frames.
903 Otherwise, include all frames. */
906 next_frame (frame
, minibuf
)
913 /* There must always be at least one frame in Vframe_list. */
914 if (! CONSP (Vframe_list
))
917 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
918 forever. Forestall that. */
919 CHECK_LIVE_FRAME (frame
);
922 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
929 && FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
931 /* Decide whether this frame is eligible to be returned. */
933 /* If we've looped all the way around without finding any
934 eligible frames, return the original frame. */
938 /* Let minibuf decide if this frame is acceptable. */
941 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
944 else if (EQ (minibuf
, Qvisible
))
946 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
947 if (FRAME_VISIBLE_P (XFRAME (f
)))
950 else if (INTEGERP (minibuf
) && XINT (minibuf
) == 0)
952 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
953 if (FRAME_VISIBLE_P (XFRAME (f
))
954 || FRAME_ICONIFIED_P (XFRAME (f
)))
957 else if (WINDOWP (minibuf
))
959 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
960 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
961 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
962 FRAME_FOCUS_FRAME (XFRAME (f
))))
974 /* Return the previous frame in the frame list before FRAME.
975 If MINIBUF is nil, exclude minibuffer-only frames.
976 If MINIBUF is a window, include only its own frame
977 and any frame now using that window as the minibuffer.
978 If MINIBUF is `visible', include all visible frames.
979 If MINIBUF is 0, include all visible and iconified frames.
980 Otherwise, include all frames. */
983 prev_frame (frame
, minibuf
)
990 /* There must always be at least one frame in Vframe_list. */
991 if (! CONSP (Vframe_list
))
995 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1003 if (EQ (frame
, f
) && !NILP (prev
))
1006 if (FRAME_KBOARD (XFRAME (f
)) == FRAME_KBOARD (XFRAME (frame
)))
1008 /* Decide whether this frame is eligible to be returned,
1009 according to minibuf. */
1012 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f
)))
1015 else if (WINDOWP (minibuf
))
1017 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f
)), minibuf
)
1018 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)), f
)
1019 || EQ (WINDOW_FRAME (XWINDOW (minibuf
)),
1020 FRAME_FOCUS_FRAME (XFRAME (f
))))
1023 else if (EQ (minibuf
, Qvisible
))
1025 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1026 if (FRAME_VISIBLE_P (XFRAME (f
)))
1029 else if (XFASTINT (minibuf
) == 0)
1031 FRAME_SAMPLE_VISIBILITY (XFRAME (f
));
1032 if (FRAME_VISIBLE_P (XFRAME (f
))
1033 || FRAME_ICONIFIED_P (XFRAME (f
)))
1041 /* We've scanned the entire list. */
1043 /* We went through the whole frame list without finding a single
1044 acceptable frame. Return the original frame. */
1047 /* There were no acceptable frames in the list before FRAME; otherwise,
1048 we would have returned directly from the loop. Since PREV is the last
1049 acceptable frame in the list, return it. */
1054 DEFUN ("next-frame", Fnext_frame
, Snext_frame
, 0, 2, 0,
1055 doc
: /* Return the next frame in the frame list after FRAME.
1056 It considers only frames on the same terminal as FRAME.
1057 By default, skip minibuffer-only frames.
1058 If omitted, FRAME defaults to the selected frame.
1059 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1060 If MINIFRAME is a window, include only its own frame
1061 and any frame now using that window as the minibuffer.
1062 If MINIFRAME is `visible', include all visible frames.
1063 If MINIFRAME is 0, include all visible and iconified frames.
1064 Otherwise, include all frames. */)
1066 Lisp_Object frame
, miniframe
;
1069 frame
= selected_frame
;
1071 CHECK_LIVE_FRAME (frame
);
1072 return next_frame (frame
, miniframe
);
1075 DEFUN ("previous-frame", Fprevious_frame
, Sprevious_frame
, 0, 2, 0,
1076 doc
: /* Return the previous frame in the frame list before FRAME.
1077 It considers only frames on the same terminal as FRAME.
1078 By default, skip minibuffer-only frames.
1079 If omitted, FRAME defaults to the selected frame.
1080 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1081 If MINIFRAME is a window, include only its own frame
1082 and any frame now using that window as the minibuffer.
1083 If MINIFRAME is `visible', include all visible frames.
1084 If MINIFRAME is 0, include all visible and iconified frames.
1085 Otherwise, include all frames. */)
1087 Lisp_Object frame
, miniframe
;
1090 frame
= selected_frame
;
1091 CHECK_LIVE_FRAME (frame
);
1092 return prev_frame (frame
, miniframe
);
1095 /* Return 1 if it is ok to delete frame F;
1096 0 if all frames aside from F are invisible.
1097 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1100 other_visible_frames (f
)
1103 /* We know the selected frame is visible,
1104 so if F is some other frame, it can't be the sole visible one. */
1105 if (f
== SELECTED_FRAME ())
1110 for (frames
= Vframe_list
;
1112 frames
= XCDR (frames
))
1116 this = XCAR (frames
);
1117 /* Verify that the frame's window still exists
1118 and we can still talk to it. And note any recent change
1120 #ifdef HAVE_WINDOW_SYSTEM
1121 if (FRAME_WINDOW_P (XFRAME (this)))
1123 x_sync (XFRAME (this));
1124 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1128 if (FRAME_VISIBLE_P (XFRAME (this))
1129 || FRAME_ICONIFIED_P (XFRAME (this))
1130 /* Allow deleting the terminal frame when at least
1131 one X frame exists! */
1132 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f
)))
1140 DEFUN ("delete-frame", Fdelete_frame
, Sdelete_frame
, 0, 2, "",
1141 doc
: /* Delete FRAME, permanently eliminating it from use.
1142 If omitted, FRAME defaults to the selected frame.
1143 A frame may not be deleted if its minibuffer is used by other frames.
1144 Normally, you may not delete a frame if all other frames are invisible,
1145 but if the second optional argument FORCE is non-nil, you may do so.
1147 This function runs `delete-frame-functions' before actually deleting the
1148 frame, unless the frame is a tooltip.
1149 The functions are run with one arg, the frame to be deleted. */)
1151 Lisp_Object frame
, force
;
1154 struct frame
*sf
= SELECTED_FRAME ();
1155 int minibuffer_selected
;
1157 if (EQ (frame
, Qnil
))
1160 XSETFRAME (frame
, f
);
1164 CHECK_FRAME (frame
);
1168 if (! FRAME_LIVE_P (f
))
1171 if (NILP (force
) && !other_visible_frames (f
)
1173 /* Terminal frame deleted before any other visible frames are
1175 && strcmp (SDATA (f
->name
), "F1") != 0
1178 error ("Attempt to delete the sole visible or iconified frame");
1181 /* This is a nice idea, but x_connection_closed needs to be able
1182 to delete the last frame, if it is gone. */
1183 if (NILP (XCDR (Vframe_list
)))
1184 error ("Attempt to delete the only frame");
1187 /* Does this frame have a minibuffer, and is it the surrogate
1188 minibuffer for any other frame? */
1189 if (FRAME_HAS_MINIBUF_P (XFRAME (frame
)))
1193 for (frames
= Vframe_list
;
1195 frames
= XCDR (frames
))
1198 this = XCAR (frames
);
1200 if (! EQ (this, frame
)
1202 WINDOW_FRAME (XWINDOW
1203 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1204 error ("Attempt to delete a surrogate minibuffer frame");
1208 /* Run `delete-frame-functions' unless frame is a tooltip. */
1209 if (!NILP (Vrun_hooks
)
1210 && NILP (Fframe_parameter (frame
, intern ("tooltip"))))
1212 Lisp_Object args
[2];
1213 args
[0] = intern ("delete-frame-functions");
1215 Frun_hook_with_args (2, args
);
1218 minibuffer_selected
= EQ (minibuf_window
, selected_window
);
1220 /* Don't let the frame remain selected. */
1223 Lisp_Object tail
, frame1
;
1225 /* Look for another visible frame on the same terminal. */
1226 frame1
= next_frame (frame
, Qvisible
);
1228 /* If there is none, find *some* other frame. */
1229 if (NILP (frame1
) || EQ (frame1
, frame
))
1231 FOR_EACH_FRAME (tail
, frame1
)
1233 if (! EQ (frame
, frame1
))
1238 do_switch_frame (frame1
, 0, 1);
1239 sf
= SELECTED_FRAME ();
1242 /* Don't allow minibuf_window to remain on a deleted frame. */
1243 if (EQ (f
->minibuffer_window
, minibuf_window
))
1245 Fset_window_buffer (sf
->minibuffer_window
,
1246 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1247 minibuf_window
= sf
->minibuffer_window
;
1249 /* If the dying minibuffer window was selected,
1250 select the new one. */
1251 if (minibuffer_selected
)
1252 Fselect_window (minibuf_window
, Qnil
);
1255 /* Don't let echo_area_window to remain on a deleted frame. */
1256 if (EQ (f
->minibuffer_window
, echo_area_window
))
1257 echo_area_window
= sf
->minibuffer_window
;
1259 /* Clear any X selections for this frame. */
1260 #ifdef HAVE_X_WINDOWS
1262 x_clear_frame_selections (f
);
1265 if (FRAME_MAC_P (f
))
1266 x_clear_frame_selections (f
);
1270 This function must be called before the window tree of the
1271 frame is deleted because windows contain dynamically allocated
1275 /* Mark all the windows that used to be on FRAME as deleted, and then
1276 remove the reference to them. */
1277 delete_all_subwindows (XWINDOW (f
->root_window
));
1278 f
->root_window
= Qnil
;
1280 Vframe_list
= Fdelq (frame
, Vframe_list
);
1281 FRAME_SET_VISIBLE (f
, 0);
1285 if (f
->decode_mode_spec_buffer
)
1286 xfree (f
->decode_mode_spec_buffer
);
1287 if (FRAME_INSERT_COST (f
))
1288 xfree (FRAME_INSERT_COST (f
));
1289 if (FRAME_DELETEN_COST (f
))
1290 xfree (FRAME_DELETEN_COST (f
));
1291 if (FRAME_INSERTN_COST (f
))
1292 xfree (FRAME_INSERTN_COST (f
));
1293 if (FRAME_DELETE_COST (f
))
1294 xfree (FRAME_DELETE_COST (f
));
1295 if (FRAME_MESSAGE_BUF (f
))
1296 xfree (FRAME_MESSAGE_BUF (f
));
1298 /* Since some events are handled at the interrupt level, we may get
1299 an event for f at any time; if we zero out the frame's display
1300 now, then we may trip up the event-handling code. Instead, we'll
1301 promise that the display of the frame must be valid until we have
1302 called the window-system-dependent frame destruction routine. */
1304 /* I think this should be done with a hook. */
1305 #ifdef HAVE_WINDOW_SYSTEM
1306 if (FRAME_WINDOW_P (f
))
1307 x_destroy_window (f
);
1310 f
->output_data
.nothing
= 0;
1312 /* If we've deleted the last_nonminibuf_frame, then try to find
1314 if (f
== last_nonminibuf_frame
)
1318 last_nonminibuf_frame
= 0;
1320 for (frames
= Vframe_list
;
1322 frames
= XCDR (frames
))
1324 f
= XFRAME (XCAR (frames
));
1325 if (!FRAME_MINIBUF_ONLY_P (f
))
1327 last_nonminibuf_frame
= f
;
1333 /* If there's no other frame on the same kboard, get out of
1334 single-kboard state if we're in it for this kboard. */
1337 /* Some frame we found on the same kboard, or nil if there are none. */
1338 Lisp_Object frame_on_same_kboard
;
1340 frame_on_same_kboard
= Qnil
;
1342 for (frames
= Vframe_list
;
1344 frames
= XCDR (frames
))
1349 this = XCAR (frames
);
1354 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1355 frame_on_same_kboard
= this;
1358 if (NILP (frame_on_same_kboard
))
1359 not_single_kboard_state (FRAME_KBOARD (f
));
1363 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1364 find another one. Prefer minibuffer-only frames, but also notice
1365 frames with other windows. */
1366 if (EQ (frame
, FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
))
1370 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1371 Lisp_Object frame_with_minibuf
;
1372 /* Some frame we found on the same kboard, or nil if there are none. */
1373 Lisp_Object frame_on_same_kboard
;
1375 frame_on_same_kboard
= Qnil
;
1376 frame_with_minibuf
= Qnil
;
1378 for (frames
= Vframe_list
;
1380 frames
= XCDR (frames
))
1385 this = XCAR (frames
);
1390 /* Consider only frames on the same kboard
1391 and only those with minibuffers. */
1392 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
)
1393 && FRAME_HAS_MINIBUF_P (f1
))
1395 frame_with_minibuf
= this;
1396 if (FRAME_MINIBUF_ONLY_P (f1
))
1400 if (FRAME_KBOARD (f
) == FRAME_KBOARD (f1
))
1401 frame_on_same_kboard
= this;
1404 if (!NILP (frame_on_same_kboard
))
1406 /* We know that there must be some frame with a minibuffer out
1407 there. If this were not true, all of the frames present
1408 would have to be minibufferless, which implies that at some
1409 point their minibuffer frames must have been deleted, but
1410 that is prohibited at the top; you can't delete surrogate
1411 minibuffer frames. */
1412 if (NILP (frame_with_minibuf
))
1415 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= frame_with_minibuf
;
1418 /* No frames left on this kboard--say no minibuffer either. */
1419 FRAME_KBOARD (f
)->Vdefault_minibuffer_frame
= Qnil
;
1422 /* Cause frame titles to update--necessary if we now have just one frame. */
1423 update_mode_lines
= 1;
1428 /* Return mouse position in character cell units. */
1430 DEFUN ("mouse-position", Fmouse_position
, Smouse_position
, 0, 0, 0,
1431 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1432 The position is given in character cells, where (0, 0) is the
1433 upper-left corner of the frame, X is the horizontal offset, and Y is
1434 the vertical offset.
1435 If Emacs is running on a mouseless terminal or hasn't been programmed
1436 to read the mouse position, it returns the selected frame for FRAME
1437 and nil for X and Y.
1438 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1439 passing the normal return value to that function as an argument,
1440 and returns whatever that function returns. */)
1444 Lisp_Object lispy_dummy
;
1445 enum scroll_bar_part party_dummy
;
1446 Lisp_Object x
, y
, retval
;
1448 unsigned long long_dummy
;
1449 struct gcpro gcpro1
;
1451 f
= SELECTED_FRAME ();
1455 /* It's okay for the hook to refrain from storing anything. */
1456 if (mouse_position_hook
)
1457 (*mouse_position_hook
) (&f
, -1,
1458 &lispy_dummy
, &party_dummy
,
1465 pixel_to_glyph_coords (f
, col
, row
, &col
, &row
, NULL
, 1);
1470 XSETFRAME (lispy_dummy
, f
);
1471 retval
= Fcons (lispy_dummy
, Fcons (x
, y
));
1473 if (!NILP (Vmouse_position_function
))
1474 retval
= call1 (Vmouse_position_function
, retval
);
1475 RETURN_UNGCPRO (retval
);
1478 DEFUN ("mouse-pixel-position", Fmouse_pixel_position
,
1479 Smouse_pixel_position
, 0, 0, 0,
1480 doc
: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1481 The position is given in pixel units, where (0, 0) is the
1482 upper-left corner of the frame, X is the horizontal offset, and Y is
1483 the vertical offset.
1484 If Emacs is running on a mouseless terminal or hasn't been programmed
1485 to read the mouse position, it returns the selected frame for FRAME
1486 and nil for X and Y. */)
1490 Lisp_Object lispy_dummy
;
1491 enum scroll_bar_part party_dummy
;
1493 unsigned long long_dummy
;
1495 f
= SELECTED_FRAME ();
1499 /* It's okay for the hook to refrain from storing anything. */
1500 if (mouse_position_hook
)
1501 (*mouse_position_hook
) (&f
, -1,
1502 &lispy_dummy
, &party_dummy
,
1506 XSETFRAME (lispy_dummy
, f
);
1507 return Fcons (lispy_dummy
, Fcons (x
, y
));
1510 DEFUN ("set-mouse-position", Fset_mouse_position
, Sset_mouse_position
, 3, 3, 0,
1511 doc
: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1512 Coordinates are relative to the frame, not a window,
1513 so the coordinates of the top left character in the frame
1514 may be nonzero due to left-hand scroll bars or the menu bar.
1516 The position is given in character cells, where (0, 0) is the
1517 upper-left corner of the frame, X is the horizontal offset, and Y is
1518 the vertical offset.
1520 This function is a no-op for an X frame that is not visible.
1521 If you have just created a frame, you must wait for it to become visible
1522 before calling this function on it, like this.
1523 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1525 Lisp_Object frame
, x
, y
;
1527 CHECK_LIVE_FRAME (frame
);
1531 /* I think this should be done with a hook. */
1532 #ifdef HAVE_WINDOW_SYSTEM
1533 if (FRAME_WINDOW_P (XFRAME (frame
)))
1534 /* Warping the mouse will cause enternotify and focus events. */
1535 x_set_mouse_position (XFRAME (frame
), XINT (x
), XINT (y
));
1537 #if defined (MSDOS) && defined (HAVE_MOUSE)
1538 if (FRAME_MSDOS_P (XFRAME (frame
)))
1540 Fselect_frame (frame
);
1541 mouse_moveto (XINT (x
), XINT (y
));
1549 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position
,
1550 Sset_mouse_pixel_position
, 3, 3, 0,
1551 doc
: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1552 The position is given in pixels, where (0, 0) is the upper-left corner
1553 of the frame, X is the horizontal offset, and Y is the vertical offset.
1555 Note, this is a no-op for an X frame that is not visible.
1556 If you have just created a frame, you must wait for it to become visible
1557 before calling this function on it, like this.
1558 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1560 Lisp_Object frame
, x
, y
;
1562 CHECK_LIVE_FRAME (frame
);
1566 /* I think this should be done with a hook. */
1567 #ifdef HAVE_WINDOW_SYSTEM
1568 if (FRAME_WINDOW_P (XFRAME (frame
)))
1569 /* Warping the mouse will cause enternotify and focus events. */
1570 x_set_mouse_pixel_position (XFRAME (frame
), XINT (x
), XINT (y
));
1572 #if defined (MSDOS) && defined (HAVE_MOUSE)
1573 if (FRAME_MSDOS_P (XFRAME (frame
)))
1575 Fselect_frame (frame
);
1576 mouse_moveto (XINT (x
), XINT (y
));
1584 static void make_frame_visible_1
P_ ((Lisp_Object
));
1586 DEFUN ("make-frame-visible", Fmake_frame_visible
, Smake_frame_visible
,
1588 doc
: /* Make the frame FRAME visible (assuming it is an X window).
1589 If omitted, FRAME defaults to the currently selected frame. */)
1594 frame
= selected_frame
;
1596 CHECK_LIVE_FRAME (frame
);
1598 /* I think this should be done with a hook. */
1599 #ifdef HAVE_WINDOW_SYSTEM
1600 if (FRAME_WINDOW_P (XFRAME (frame
)))
1602 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1603 x_make_frame_visible (XFRAME (frame
));
1607 make_frame_visible_1 (XFRAME (frame
)->root_window
);
1609 /* Make menu bar update for the Buffers and Frames menus. */
1610 windows_or_buffers_changed
++;
1615 /* Update the display_time slot of the buffers shown in WINDOW
1616 and all its descendents. */
1619 make_frame_visible_1 (window
)
1624 for (;!NILP (window
); window
= w
->next
)
1626 w
= XWINDOW (window
);
1628 if (!NILP (w
->buffer
))
1629 XBUFFER (w
->buffer
)->display_time
= Fcurrent_time ();
1631 if (!NILP (w
->vchild
))
1632 make_frame_visible_1 (w
->vchild
);
1633 if (!NILP (w
->hchild
))
1634 make_frame_visible_1 (w
->hchild
);
1638 DEFUN ("make-frame-invisible", Fmake_frame_invisible
, Smake_frame_invisible
,
1640 doc
: /* Make the frame FRAME invisible (assuming it is an X window).
1641 If omitted, FRAME defaults to the currently selected frame.
1642 Normally you may not make FRAME invisible if all other frames are invisible,
1643 but if the second optional argument FORCE is non-nil, you may do so. */)
1645 Lisp_Object frame
, force
;
1648 frame
= selected_frame
;
1650 CHECK_LIVE_FRAME (frame
);
1652 if (NILP (force
) && !other_visible_frames (XFRAME (frame
)))
1653 error ("Attempt to make invisible the sole visible or iconified frame");
1655 #if 0 /* This isn't logically necessary, and it can do GC. */
1656 /* Don't let the frame remain selected. */
1657 if (EQ (frame
, selected_frame
))
1658 do_switch_frame (next_frame (frame
, Qt
), 0, 0)
1661 /* Don't allow minibuf_window to remain on a deleted frame. */
1662 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1664 struct frame
*sf
= XFRAME (selected_frame
);
1665 Fset_window_buffer (sf
->minibuffer_window
,
1666 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1667 minibuf_window
= sf
->minibuffer_window
;
1670 /* I think this should be done with a hook. */
1671 #ifdef HAVE_WINDOW_SYSTEM
1672 if (FRAME_WINDOW_P (XFRAME (frame
)))
1673 x_make_frame_invisible (XFRAME (frame
));
1676 /* Make menu bar update for the Buffers and Frames menus. */
1677 windows_or_buffers_changed
++;
1682 DEFUN ("iconify-frame", Ficonify_frame
, Siconify_frame
,
1684 doc
: /* Make the frame FRAME into an icon.
1685 If omitted, FRAME defaults to the currently selected frame. */)
1690 frame
= selected_frame
;
1692 CHECK_LIVE_FRAME (frame
);
1694 #if 0 /* This isn't logically necessary, and it can do GC. */
1695 /* Don't let the frame remain selected. */
1696 if (EQ (frame
, selected_frame
))
1697 Fhandle_switch_frame (next_frame (frame
, Qt
));
1700 /* Don't allow minibuf_window to remain on a deleted frame. */
1701 if (EQ (XFRAME (frame
)->minibuffer_window
, minibuf_window
))
1703 struct frame
*sf
= XFRAME (selected_frame
);
1704 Fset_window_buffer (sf
->minibuffer_window
,
1705 XWINDOW (minibuf_window
)->buffer
, Qnil
);
1706 minibuf_window
= sf
->minibuffer_window
;
1709 /* I think this should be done with a hook. */
1710 #ifdef HAVE_WINDOW_SYSTEM
1711 if (FRAME_WINDOW_P (XFRAME (frame
)))
1712 x_iconify_frame (XFRAME (frame
));
1715 /* Make menu bar update for the Buffers and Frames menus. */
1716 windows_or_buffers_changed
++;
1721 DEFUN ("frame-visible-p", Fframe_visible_p
, Sframe_visible_p
,
1723 doc
: /* Return t if FRAME is now \"visible\" (actually in use for display).
1724 A frame that is not \"visible\" is not updated and, if it works through
1725 a window system, it may not show at all.
1726 Return the symbol `icon' if frame is visible only as an icon.
1728 On a text-only terminal, all frames are considered visible, whether
1729 they are currently being displayed or not, and this function returns t
1734 CHECK_LIVE_FRAME (frame
);
1736 FRAME_SAMPLE_VISIBILITY (XFRAME (frame
));
1738 if (FRAME_VISIBLE_P (XFRAME (frame
)))
1740 if (FRAME_ICONIFIED_P (XFRAME (frame
)))
1745 DEFUN ("visible-frame-list", Fvisible_frame_list
, Svisible_frame_list
,
1747 doc
: /* Return a list of all frames now \"visible\" (being updated). */)
1750 Lisp_Object tail
, frame
;
1755 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1757 frame
= XCAR (tail
);
1758 if (!FRAMEP (frame
))
1761 if (FRAME_VISIBLE_P (f
))
1762 value
= Fcons (frame
, value
);
1768 DEFUN ("raise-frame", Fraise_frame
, Sraise_frame
, 0, 1, "",
1769 doc
: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1770 If FRAME is invisible or iconified, make it visible.
1771 If you don't specify a frame, the selected frame is used.
1772 If Emacs is displaying on an ordinary terminal or some other device which
1773 doesn't support multiple overlapping frames, this function does nothing. */)
1778 frame
= selected_frame
;
1780 CHECK_LIVE_FRAME (frame
);
1782 /* Do like the documentation says. */
1783 Fmake_frame_visible (frame
);
1785 if (frame_raise_lower_hook
)
1786 (*frame_raise_lower_hook
) (XFRAME (frame
), 1);
1791 /* Should we have a corresponding function called Flower_Power? */
1792 DEFUN ("lower-frame", Flower_frame
, Slower_frame
, 0, 1, "",
1793 doc
: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1794 If you don't specify a frame, the selected frame is used.
1795 If Emacs is displaying on an ordinary terminal or some other device which
1796 doesn't support multiple overlapping frames, this function does nothing. */)
1801 frame
= selected_frame
;
1803 CHECK_LIVE_FRAME (frame
);
1805 if (frame_raise_lower_hook
)
1806 (*frame_raise_lower_hook
) (XFRAME (frame
), 0);
1812 DEFUN ("redirect-frame-focus", Fredirect_frame_focus
, Sredirect_frame_focus
,
1814 doc
: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1815 In other words, switch-frame events caused by events in FRAME will
1816 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1817 FOCUS-FRAME after reading an event typed at FRAME.
1819 If FOCUS-FRAME is omitted or nil, any existing redirection is
1820 cancelled, and the frame again receives its own keystrokes.
1822 Focus redirection is useful for temporarily redirecting keystrokes to
1823 a surrogate minibuffer frame when a frame doesn't have its own
1826 A frame's focus redirection can be changed by `select-frame'. If frame
1827 FOO is selected, and then a different frame BAR is selected, any
1828 frames redirecting their focus to FOO are shifted to redirect their
1829 focus to BAR. This allows focus redirection to work properly when the
1830 user switches from one frame to another using `select-window'.
1832 This means that a frame whose focus is redirected to itself is treated
1833 differently from a frame whose focus is redirected to nil; the former
1834 is affected by `select-frame', while the latter is not.
1836 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1837 (frame
, focus_frame
)
1838 Lisp_Object frame
, focus_frame
;
1840 /* Note that we don't check for a live frame here. It's reasonable
1841 to redirect the focus of a frame you're about to delete, if you
1842 know what other frame should receive those keystrokes. */
1843 CHECK_FRAME (frame
);
1845 if (! NILP (focus_frame
))
1846 CHECK_LIVE_FRAME (focus_frame
);
1848 XFRAME (frame
)->focus_frame
= focus_frame
;
1850 if (frame_rehighlight_hook
)
1851 (*frame_rehighlight_hook
) (XFRAME (frame
));
1857 DEFUN ("frame-focus", Fframe_focus
, Sframe_focus
, 1, 1, 0,
1858 doc
: /* Return the frame to which FRAME's keystrokes are currently being sent.
1859 This returns nil if FRAME's focus is not redirected.
1860 See `redirect-frame-focus'. */)
1864 CHECK_LIVE_FRAME (frame
);
1866 return FRAME_FOCUS_FRAME (XFRAME (frame
));
1871 /* Return the value of frame parameter PROP in frame FRAME. */
1874 get_frame_param (frame
, prop
)
1875 register struct frame
*frame
;
1878 register Lisp_Object tem
;
1880 tem
= Fassq (prop
, frame
->param_alist
);
1886 /* Return the buffer-predicate of the selected frame. */
1889 frame_buffer_predicate (frame
)
1892 return XFRAME (frame
)->buffer_predicate
;
1895 /* Return the buffer-list of the selected frame. */
1898 frame_buffer_list (frame
)
1901 return XFRAME (frame
)->buffer_list
;
1904 /* Set the buffer-list of the selected frame. */
1907 set_frame_buffer_list (frame
, list
)
1908 Lisp_Object frame
, list
;
1910 XFRAME (frame
)->buffer_list
= list
;
1913 /* Discard BUFFER from the buffer-list of each frame. */
1916 frames_discard_buffer (buffer
)
1919 Lisp_Object frame
, tail
;
1921 FOR_EACH_FRAME (tail
, frame
)
1923 XFRAME (frame
)->buffer_list
1924 = Fdelq (buffer
, XFRAME (frame
)->buffer_list
);
1928 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1929 If the alist already has an element for PROP, we change it. */
1932 store_in_alist (alistptr
, prop
, val
)
1933 Lisp_Object
*alistptr
, val
;
1936 register Lisp_Object tem
;
1938 tem
= Fassq (prop
, *alistptr
);
1940 *alistptr
= Fcons (Fcons (prop
, val
), *alistptr
);
1946 frame_name_fnn_p (str
, len
)
1950 if (len
> 1 && str
[0] == 'F')
1954 strtol (str
+ 1, &end_ptr
, 10);
1956 if (end_ptr
== str
+ len
)
1962 /* Set the name of the terminal frame. Also used by MSDOS frames.
1963 Modeled after x_set_name which is used for WINDOW frames. */
1966 set_term_frame_name (f
, name
)
1970 f
->explicit_name
= ! NILP (name
);
1972 /* If NAME is nil, set the name to F<num>. */
1977 /* Check for no change needed in this very common case
1978 before we do any consing. */
1979 if (frame_name_fnn_p (SDATA (f
->name
),
1983 terminal_frame_count
++;
1984 sprintf (namebuf
, "F%d", terminal_frame_count
);
1985 name
= build_string (namebuf
);
1989 CHECK_STRING (name
);
1991 /* Don't change the name if it's already NAME. */
1992 if (! NILP (Fstring_equal (name
, f
->name
)))
1995 /* Don't allow the user to set the frame name to F<num>, so it
1996 doesn't clash with the names we generate for terminal frames. */
1997 if (frame_name_fnn_p (SDATA (name
), SBYTES (name
)))
1998 error ("Frame names of the form F<num> are usurped by Emacs");
2002 update_mode_lines
= 1;
2006 store_frame_param (f
, prop
, val
)
2008 Lisp_Object prop
, val
;
2010 register Lisp_Object old_alist_elt
;
2012 /* The buffer-alist parameter is stored in a special place and is
2013 not in the alist. */
2014 if (EQ (prop
, Qbuffer_list
))
2016 f
->buffer_list
= val
;
2020 /* If PROP is a symbol which is supposed to have frame-local values,
2021 and it is set up based on this frame, switch to the global
2022 binding. That way, we can create or alter the frame-local binding
2023 without messing up the symbol's status. */
2026 Lisp_Object valcontents
;
2027 valcontents
= SYMBOL_VALUE (prop
);
2028 if ((BUFFER_LOCAL_VALUEP (valcontents
)
2029 || SOME_BUFFER_LOCAL_VALUEP (valcontents
))
2030 && XBUFFER_LOCAL_VALUE (valcontents
)->check_frame
2031 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents
)->frame
) == f
)
2032 swap_in_global_binding (prop
);
2036 /* The tty color mode needs to be set before the frame's parameter
2037 alist is updated with the new value, because set_tty_color_mode
2038 wants to look at the old mode. */
2039 if (FRAME_TERMCAP_P (f
) && EQ (prop
, Qtty_color_mode
))
2040 set_tty_color_mode (f
, val
);
2043 /* Update the frame parameter alist. */
2044 old_alist_elt
= Fassq (prop
, f
->param_alist
);
2045 if (EQ (old_alist_elt
, Qnil
))
2046 f
->param_alist
= Fcons (Fcons (prop
, val
), f
->param_alist
);
2048 Fsetcdr (old_alist_elt
, val
);
2050 /* Update some other special parameters in their special places
2051 in addition to the alist. */
2053 if (EQ (prop
, Qbuffer_predicate
))
2054 f
->buffer_predicate
= val
;
2056 if (! FRAME_WINDOW_P (f
))
2058 if (EQ (prop
, Qmenu_bar_lines
))
2059 set_menu_bar_lines (f
, val
, make_number (FRAME_MENU_BAR_LINES (f
)));
2060 else if (EQ (prop
, Qname
))
2061 set_term_frame_name (f
, val
);
2064 if (EQ (prop
, Qminibuffer
) && WINDOWP (val
))
2066 if (! MINI_WINDOW_P (XWINDOW (val
)))
2067 error ("Surrogate minibuffer windows must be minibuffer windows");
2069 if ((FRAME_HAS_MINIBUF_P (f
) || FRAME_MINIBUF_ONLY_P (f
))
2070 && !EQ (val
, f
->minibuffer_window
))
2071 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2073 /* Install the chosen minibuffer window, with proper buffer. */
2074 f
->minibuffer_window
= val
;
2078 DEFUN ("frame-parameters", Fframe_parameters
, Sframe_parameters
, 0, 1, 0,
2079 doc
: /* Return the parameters-alist of frame FRAME.
2080 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2081 The meaningful PARMs depend on the kind of frame.
2082 If FRAME is omitted, return information on the currently selected frame. */)
2089 struct gcpro gcpro1
;
2092 frame
= selected_frame
;
2094 CHECK_FRAME (frame
);
2097 if (!FRAME_LIVE_P (f
))
2100 alist
= Fcopy_alist (f
->param_alist
);
2103 if (!FRAME_WINDOW_P (f
))
2105 int fg
= FRAME_FOREGROUND_PIXEL (f
);
2106 int bg
= FRAME_BACKGROUND_PIXEL (f
);
2109 /* If the frame's parameter alist says the colors are
2110 unspecified and reversed, take the frame's background pixel
2111 for foreground and vice versa. */
2112 elt
= Fassq (Qforeground_color
, alist
);
2113 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2115 if (strncmp (SDATA (XCDR (elt
)),
2117 SCHARS (XCDR (elt
))) == 0)
2118 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, bg
));
2119 else if (strncmp (SDATA (XCDR (elt
)),
2121 SCHARS (XCDR (elt
))) == 0)
2122 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2125 store_in_alist (&alist
, Qforeground_color
, tty_color_name (f
, fg
));
2126 elt
= Fassq (Qbackground_color
, alist
);
2127 if (!NILP (elt
) && CONSP (elt
) && STRINGP (XCDR (elt
)))
2129 if (strncmp (SDATA (XCDR (elt
)),
2131 SCHARS (XCDR (elt
))) == 0)
2132 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, fg
));
2133 else if (strncmp (SDATA (XCDR (elt
)),
2135 SCHARS (XCDR (elt
))) == 0)
2136 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2139 store_in_alist (&alist
, Qbackground_color
, tty_color_name (f
, bg
));
2140 store_in_alist (&alist
, intern ("font"),
2141 build_string (FRAME_MSDOS_P (f
)
2143 : FRAME_W32_P (f
) ? "w32term"
2146 store_in_alist (&alist
, Qname
, f
->name
);
2147 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2148 store_in_alist (&alist
, Qheight
, make_number (height
));
2149 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2150 store_in_alist (&alist
, Qwidth
, make_number (width
));
2151 store_in_alist (&alist
, Qmodeline
, (FRAME_WANTS_MODELINE_P (f
) ? Qt
: Qnil
));
2152 store_in_alist (&alist
, Qminibuffer
,
2153 (! FRAME_HAS_MINIBUF_P (f
) ? Qnil
2154 : FRAME_MINIBUF_ONLY_P (f
) ? Qonly
2155 : FRAME_MINIBUF_WINDOW (f
)));
2156 store_in_alist (&alist
, Qunsplittable
, (FRAME_NO_SPLIT_P (f
) ? Qt
: Qnil
));
2157 store_in_alist (&alist
, Qbuffer_list
, frame_buffer_list (frame
));
2159 /* I think this should be done with a hook. */
2160 #ifdef HAVE_WINDOW_SYSTEM
2161 if (FRAME_WINDOW_P (f
))
2162 x_report_frame_params (f
, &alist
);
2166 /* This ought to be correct in f->param_alist for an X frame. */
2168 XSETFASTINT (lines
, FRAME_MENU_BAR_LINES (f
));
2169 store_in_alist (&alist
, Qmenu_bar_lines
, lines
);
2177 DEFUN ("frame-parameter", Fframe_parameter
, Sframe_parameter
, 2, 2, 0,
2178 doc
: /* Return FRAME's value for parameter PARAMETER.
2179 If FRAME is nil, describe the currently selected frame. */)
2181 Lisp_Object frame
, parameter
;
2187 frame
= selected_frame
;
2189 CHECK_FRAME (frame
);
2190 CHECK_SYMBOL (parameter
);
2195 if (FRAME_LIVE_P (f
))
2197 /* Avoid consing in frequent cases. */
2198 if (EQ (parameter
, Qname
))
2200 #ifdef HAVE_X_WINDOWS
2201 else if (EQ (parameter
, Qdisplay
) && FRAME_X_P (f
))
2202 value
= XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
);
2203 #endif /* HAVE_X_WINDOWS */
2204 else if (EQ (parameter
, Qbackground_color
)
2205 || EQ (parameter
, Qforeground_color
))
2207 value
= Fassq (parameter
, f
->param_alist
);
2210 value
= XCDR (value
);
2211 /* Fframe_parameters puts the actual fg/bg color names,
2212 even if f->param_alist says otherwise. This is
2213 important when param_alist's notion of colors is
2214 "unspecified". We need to do the same here. */
2215 if (STRINGP (value
) && !FRAME_WINDOW_P (f
))
2217 const char *color_name
;
2220 if (EQ (parameter
, Qbackground_color
))
2222 color_name
= SDATA (value
);
2223 csz
= SCHARS (value
);
2224 if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2225 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2226 else if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2227 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2229 else if (EQ (parameter
, Qforeground_color
))
2231 color_name
= SDATA (value
);
2232 csz
= SCHARS (value
);
2233 if (strncmp (color_name
, unspecified_fg
, csz
) == 0)
2234 value
= tty_color_name (f
, FRAME_FOREGROUND_PIXEL (f
));
2235 else if (strncmp (color_name
, unspecified_bg
, csz
) == 0)
2236 value
= tty_color_name (f
, FRAME_BACKGROUND_PIXEL (f
));
2241 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2243 else if (EQ (parameter
, Qdisplay_type
)
2244 || EQ (parameter
, Qbackground_mode
))
2245 value
= Fcdr (Fassq (parameter
, f
->param_alist
));
2247 value
= Fcdr (Fassq (parameter
, Fframe_parameters (frame
)));
2254 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters
,
2255 Smodify_frame_parameters
, 2, 2, 0,
2256 doc
: /* Modify the parameters of frame FRAME according to ALIST.
2257 If FRAME is nil, it defaults to the selected frame.
2258 ALIST is an alist of parameters to change and their new values.
2259 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2260 The meaningful PARMs depend on the kind of frame.
2261 Undefined PARMs are ignored, but stored in the frame's parameter list
2262 so that `frame-parameters' will return them.
2264 The value of frame parameter FOO can also be accessed
2265 as a frame-local binding for the variable FOO, if you have
2266 enabled such bindings for that variable with `make-variable-frame-local'. */)
2268 Lisp_Object frame
, alist
;
2271 register Lisp_Object tail
, prop
, val
;
2272 int count
= SPECPDL_INDEX ();
2274 /* Bind this to t to inhibit initialization of the default face from
2275 X resources in face-set-after-frame-default. If we don't inhibit
2276 this, modifying the `font' frame parameter, for example, while
2277 there is a `default.attributeFont' X resource, won't work,
2278 because `default's font is reset to the value of the X resource
2279 and that resets the `font' frame parameter. */
2280 specbind (Qinhibit_default_face_x_resources
, Qt
);
2282 if (EQ (frame
, Qnil
))
2283 frame
= selected_frame
;
2284 CHECK_LIVE_FRAME (frame
);
2287 /* I think this should be done with a hook. */
2288 #ifdef HAVE_WINDOW_SYSTEM
2289 if (FRAME_WINDOW_P (f
))
2290 x_set_frame_parameters (f
, alist
);
2294 if (FRAME_MSDOS_P (f
))
2295 IT_set_frame_parameters (f
, alist
);
2300 int length
= XINT (Flength (alist
));
2303 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2305 = (Lisp_Object
*) alloca (length
* sizeof (Lisp_Object
));
2307 /* Extract parm names and values into those vectors. */
2310 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2315 parms
[i
] = Fcar (elt
);
2316 values
[i
] = Fcdr (elt
);
2320 /* Now process them in reverse of specified order. */
2321 for (i
--; i
>= 0; i
--)
2325 store_frame_param (f
, prop
, val
);
2327 /* Changing the background color might change the background
2328 mode, so that we have to load new defface specs.
2329 Call frame-set-background-mode to do that. */
2330 if (EQ (prop
, Qbackground_color
))
2331 call1 (Qframe_set_background_mode
, frame
);
2335 return unbind_to (count
, Qnil
);
2338 DEFUN ("frame-char-height", Fframe_char_height
, Sframe_char_height
,
2340 doc
: /* Height in pixels of a line in the font in frame FRAME.
2341 If FRAME is omitted, the selected frame is used.
2342 For a terminal frame, the value is always 1. */)
2349 frame
= selected_frame
;
2350 CHECK_FRAME (frame
);
2353 #ifdef HAVE_WINDOW_SYSTEM
2354 if (FRAME_WINDOW_P (f
))
2355 return make_number (x_char_height (f
));
2358 return make_number (1);
2362 DEFUN ("frame-char-width", Fframe_char_width
, Sframe_char_width
,
2364 doc
: /* Width in pixels of characters in the font in frame FRAME.
2365 If FRAME is omitted, the selected frame is used.
2366 On a graphical screen, the width is the standard width of the default font.
2367 For a terminal screen, the value is always 1. */)
2374 frame
= selected_frame
;
2375 CHECK_FRAME (frame
);
2378 #ifdef HAVE_WINDOW_SYSTEM
2379 if (FRAME_WINDOW_P (f
))
2380 return make_number (x_char_width (f
));
2383 return make_number (1);
2386 DEFUN ("frame-pixel-height", Fframe_pixel_height
,
2387 Sframe_pixel_height
, 0, 1, 0,
2388 doc
: /* Return a FRAME's height in pixels.
2389 This counts only the height available for text lines,
2390 not menu bars on window-system Emacs frames.
2391 For a terminal frame, the result really gives the height in characters.
2392 If FRAME is omitted, the selected frame is used. */)
2399 frame
= selected_frame
;
2400 CHECK_FRAME (frame
);
2403 #ifdef HAVE_WINDOW_SYSTEM
2404 if (FRAME_WINDOW_P (f
))
2405 return make_number (x_pixel_height (f
));
2408 return make_number (FRAME_LINES (f
));
2411 DEFUN ("frame-pixel-width", Fframe_pixel_width
,
2412 Sframe_pixel_width
, 0, 1, 0,
2413 doc
: /* Return FRAME's width in pixels.
2414 For a terminal frame, the result really gives the width in characters.
2415 If FRAME is omitted, the selected frame is used. */)
2422 frame
= selected_frame
;
2423 CHECK_FRAME (frame
);
2426 #ifdef HAVE_WINDOW_SYSTEM
2427 if (FRAME_WINDOW_P (f
))
2428 return make_number (x_pixel_width (f
));
2431 return make_number (FRAME_COLS (f
));
2434 DEFUN ("set-frame-height", Fset_frame_height
, Sset_frame_height
, 2, 3, 0,
2435 doc
: /* Specify that the frame FRAME has LINES lines.
2436 Optional third arg non-nil means that redisplay should use LINES lines
2437 but that the idea of the actual height of the frame should not be changed. */)
2438 (frame
, lines
, pretend
)
2439 Lisp_Object frame
, lines
, pretend
;
2441 register struct frame
*f
;
2443 CHECK_NUMBER (lines
);
2445 frame
= selected_frame
;
2446 CHECK_LIVE_FRAME (frame
);
2449 /* I think this should be done with a hook. */
2450 #ifdef HAVE_WINDOW_SYSTEM
2451 if (FRAME_WINDOW_P (f
))
2453 if (XINT (lines
) != FRAME_LINES (f
))
2454 x_set_window_size (f
, 1, FRAME_COLS (f
), XINT (lines
));
2455 do_pending_window_change (0);
2459 change_frame_size (f
, XINT (lines
), 0, !NILP (pretend
), 0, 0);
2463 DEFUN ("set-frame-width", Fset_frame_width
, Sset_frame_width
, 2, 3, 0,
2464 doc
: /* Specify that the frame FRAME has COLS columns.
2465 Optional third arg non-nil means that redisplay should use COLS columns
2466 but that the idea of the actual width of the frame should not be changed. */)
2467 (frame
, cols
, pretend
)
2468 Lisp_Object frame
, cols
, pretend
;
2470 register struct frame
*f
;
2471 CHECK_NUMBER (cols
);
2473 frame
= selected_frame
;
2474 CHECK_LIVE_FRAME (frame
);
2477 /* I think this should be done with a hook. */
2478 #ifdef HAVE_WINDOW_SYSTEM
2479 if (FRAME_WINDOW_P (f
))
2481 if (XINT (cols
) != FRAME_COLS (f
))
2482 x_set_window_size (f
, 1, XINT (cols
), FRAME_LINES (f
));
2483 do_pending_window_change (0);
2487 change_frame_size (f
, 0, XINT (cols
), !NILP (pretend
), 0, 0);
2491 DEFUN ("set-frame-size", Fset_frame_size
, Sset_frame_size
, 3, 3, 0,
2492 doc
: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2494 Lisp_Object frame
, cols
, rows
;
2496 register struct frame
*f
;
2498 CHECK_LIVE_FRAME (frame
);
2499 CHECK_NUMBER (cols
);
2500 CHECK_NUMBER (rows
);
2503 /* I think this should be done with a hook. */
2504 #ifdef HAVE_WINDOW_SYSTEM
2505 if (FRAME_WINDOW_P (f
))
2507 if (XINT (rows
) != FRAME_LINES (f
)
2508 || XINT (cols
) != FRAME_COLS (f
)
2509 || f
->new_text_lines
|| f
->new_text_cols
)
2510 x_set_window_size (f
, 1, XINT (cols
), XINT (rows
));
2511 do_pending_window_change (0);
2515 change_frame_size (f
, XINT (rows
), XINT (cols
), 0, 0, 0);
2520 DEFUN ("set-frame-position", Fset_frame_position
,
2521 Sset_frame_position
, 3, 3, 0,
2522 doc
: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2523 This is actually the position of the upper left corner of the frame.
2524 Negative values for XOFFSET or YOFFSET are interpreted relative to
2525 the rightmost or bottommost possible position (that stays within the screen). */)
2526 (frame
, xoffset
, yoffset
)
2527 Lisp_Object frame
, xoffset
, yoffset
;
2529 register struct frame
*f
;
2531 CHECK_LIVE_FRAME (frame
);
2532 CHECK_NUMBER (xoffset
);
2533 CHECK_NUMBER (yoffset
);
2536 /* I think this should be done with a hook. */
2537 #ifdef HAVE_WINDOW_SYSTEM
2538 if (FRAME_WINDOW_P (f
))
2539 x_set_offset (f
, XINT (xoffset
), XINT (yoffset
), 1);
2546 /***********************************************************************
2548 ***********************************************************************/
2550 /* Connect the frame-parameter names for X frames
2551 to the ways of passing the parameter values to the window system.
2553 The name of a parameter, as a Lisp symbol,
2554 has an `x-frame-parameter' property which is an integer in Lisp
2555 that is an index in this table. */
2557 struct frame_parm_table
{
2559 Lisp_Object
*variable
;
2562 static struct frame_parm_table frame_parms
[] =
2564 {"auto-raise", &Qauto_raise
},
2565 {"auto-lower", &Qauto_lower
},
2566 {"background-color", 0},
2567 {"border-color", &Qborder_color
},
2568 {"border-width", &Qborder_width
},
2569 {"cursor-color", &Qcursor_color
},
2570 {"cursor-type", &Qcursor_type
},
2572 {"foreground-color", 0},
2573 {"icon-name", &Qicon_name
},
2574 {"icon-type", &Qicon_type
},
2575 {"internal-border-width", &Qinternal_border_width
},
2576 {"menu-bar-lines", &Qmenu_bar_lines
},
2577 {"mouse-color", &Qmouse_color
},
2579 {"scroll-bar-width", &Qscroll_bar_width
},
2581 {"unsplittable", &Qunsplittable
},
2582 {"vertical-scroll-bars", &Qvertical_scroll_bars
},
2583 {"visibility", &Qvisibility
},
2584 {"tool-bar-lines", &Qtool_bar_lines
},
2585 {"scroll-bar-foreground", &Qscroll_bar_foreground
},
2586 {"scroll-bar-background", &Qscroll_bar_background
},
2587 {"screen-gamma", &Qscreen_gamma
},
2588 {"line-spacing", &Qline_spacing
},
2589 {"left-fringe", &Qleft_fringe
},
2590 {"right-fringe", &Qright_fringe
},
2591 {"wait-for-wm", &Qwait_for_wm
},
2592 {"fullscreen", &Qfullscreen
},
2595 #ifdef HAVE_WINDOW_SYSTEM
2597 extern Lisp_Object Qbox
;
2598 extern Lisp_Object Qtop
;
2600 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2601 wanted positions of the WM window (not Emacs window).
2602 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2603 window (FRAME_X_WINDOW).
2607 x_fullscreen_adjust (f
, width
, height
, top_pos
, left_pos
)
2614 int newwidth
= FRAME_COLS (f
);
2615 int newheight
= FRAME_LINES (f
);
2617 *top_pos
= f
->top_pos
;
2618 *left_pos
= f
->left_pos
;
2620 if (f
->want_fullscreen
& FULLSCREEN_HEIGHT
)
2624 ph
= FRAME_X_DISPLAY_INFO (f
)->height
;
2625 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2626 ph
= FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, newheight
) - f
->y_pixels_diff
;
2627 newheight
= FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f
, ph
);
2631 if (f
->want_fullscreen
& FULLSCREEN_WIDTH
)
2635 pw
= FRAME_X_DISPLAY_INFO (f
)->width
;
2636 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2637 pw
= FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, newwidth
) - f
->x_pixels_diff
;
2638 newwidth
= FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f
, pw
);
2643 *height
= newheight
;
2647 /* Change the parameters of frame F as specified by ALIST.
2648 If a parameter is not specially recognized, do nothing special;
2649 otherwise call the `x_set_...' function for that parameter.
2650 Except for certain geometry properties, always call store_frame_param
2651 to store the new value in the parameter alist. */
2654 x_set_frame_parameters (f
, alist
)
2660 /* If both of these parameters are present, it's more efficient to
2661 set them both at once. So we wait until we've looked at the
2662 entire list before we set them. */
2666 Lisp_Object left
, top
;
2668 /* Same with these. */
2669 Lisp_Object icon_left
, icon_top
;
2671 /* Record in these vectors all the parms specified. */
2673 Lisp_Object
*values
;
2675 int left_no_change
= 0, top_no_change
= 0;
2676 int icon_left_no_change
= 0, icon_top_no_change
= 0;
2677 int fullscreen_is_being_set
= 0;
2679 struct gcpro gcpro1
, gcpro2
;
2682 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2685 parms
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2686 values
= (Lisp_Object
*) alloca (i
* sizeof (Lisp_Object
));
2688 /* Extract parm names and values into those vectors. */
2691 for (tail
= alist
; CONSP (tail
); tail
= Fcdr (tail
))
2696 parms
[i
] = Fcar (elt
);
2697 values
[i
] = Fcdr (elt
);
2700 /* TAIL and ALIST are not used again below here. */
2701 alist
= tail
= Qnil
;
2703 GCPRO2 (*parms
, *values
);
2707 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2708 because their values appear in VALUES and strings are not valid. */
2709 top
= left
= Qunbound
;
2710 icon_left
= icon_top
= Qunbound
;
2712 /* Provide default values for HEIGHT and WIDTH. */
2713 width
= (f
->new_text_cols
? f
->new_text_cols
: FRAME_COLS (f
));
2714 height
= (f
->new_text_lines
? f
->new_text_lines
: FRAME_LINES (f
));
2716 /* Process foreground_color and background_color before anything else.
2717 They are independent of other properties, but other properties (e.g.,
2718 cursor_color) are dependent upon them. */
2719 /* Process default font as well, since fringe widths depends on it. */
2720 /* Also, process fullscreen, width and height depend upon that */
2721 for (p
= 0; p
< i
; p
++)
2723 Lisp_Object prop
, val
;
2727 if (EQ (prop
, Qforeground_color
)
2728 || EQ (prop
, Qbackground_color
)
2730 || EQ (prop
, Qfullscreen
))
2732 register Lisp_Object param_index
, old_value
;
2733 int count
= SPECPDL_INDEX ();
2735 old_value
= get_frame_param (f
, prop
);
2736 fullscreen_is_being_set
|= EQ (prop
, Qfullscreen
);
2738 if (NILP (Fequal (val
, old_value
)))
2740 /* For :font attributes, the frame_parm_handler
2741 x_set_font calls `face-set-after-frame-default'.
2742 Unless we bind inhibit-face-set-after-frame-default
2743 here, this would reset the :font attribute that we
2744 just applied to the default value for new faces. */
2745 specbind (Qinhibit_face_set_after_frame_default
, Qt
);
2747 store_frame_param (f
, prop
, val
);
2749 param_index
= Fget (prop
, Qx_frame_parameter
);
2750 if (NATNUMP (param_index
)
2751 && (XFASTINT (param_index
)
2752 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2753 && rif
->frame_parm_handlers
[XINT (param_index
)])
2754 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2756 unbind_to (count
, Qnil
);
2761 /* Now process them in reverse of specified order. */
2762 for (i
--; i
>= 0; i
--)
2764 Lisp_Object prop
, val
;
2769 if (EQ (prop
, Qwidth
) && NUMBERP (val
))
2770 width
= XFASTINT (val
);
2771 else if (EQ (prop
, Qheight
) && NUMBERP (val
))
2772 height
= XFASTINT (val
);
2773 else if (EQ (prop
, Qtop
))
2775 else if (EQ (prop
, Qleft
))
2777 else if (EQ (prop
, Qicon_top
))
2779 else if (EQ (prop
, Qicon_left
))
2781 else if (EQ (prop
, Qforeground_color
)
2782 || EQ (prop
, Qbackground_color
)
2784 || EQ (prop
, Qfullscreen
))
2785 /* Processed above. */
2789 register Lisp_Object param_index
, old_value
;
2791 old_value
= get_frame_param (f
, prop
);
2793 store_frame_param (f
, prop
, val
);
2795 param_index
= Fget (prop
, Qx_frame_parameter
);
2796 if (NATNUMP (param_index
)
2797 && (XFASTINT (param_index
)
2798 < sizeof (frame_parms
)/sizeof (frame_parms
[0]))
2799 && rif
->frame_parm_handlers
[XINT (param_index
)])
2800 (*(rif
->frame_parm_handlers
[XINT (param_index
)])) (f
, val
, old_value
);
2804 /* Don't die if just one of these was set. */
2805 if (EQ (left
, Qunbound
))
2808 if (f
->left_pos
< 0)
2809 left
= Fcons (Qplus
, Fcons (make_number (f
->left_pos
), Qnil
));
2811 XSETINT (left
, f
->left_pos
);
2813 if (EQ (top
, Qunbound
))
2817 top
= Fcons (Qplus
, Fcons (make_number (f
->top_pos
), Qnil
));
2819 XSETINT (top
, f
->top_pos
);
2822 /* If one of the icon positions was not set, preserve or default it. */
2823 if (EQ (icon_left
, Qunbound
) || ! INTEGERP (icon_left
))
2825 icon_left_no_change
= 1;
2826 icon_left
= Fcdr (Fassq (Qicon_left
, f
->param_alist
));
2827 if (NILP (icon_left
))
2828 XSETINT (icon_left
, 0);
2830 if (EQ (icon_top
, Qunbound
) || ! INTEGERP (icon_top
))
2832 icon_top_no_change
= 1;
2833 icon_top
= Fcdr (Fassq (Qicon_top
, f
->param_alist
));
2834 if (NILP (icon_top
))
2835 XSETINT (icon_top
, 0);
2838 if (FRAME_VISIBLE_P (f
) && fullscreen_is_being_set
)
2840 /* If the frame is visible already and the fullscreen parameter is
2841 being set, it is too late to set WM manager hints to specify
2843 Here we first get the width, height and position that applies to
2844 fullscreen. We then move the frame to the appropriate
2845 position. Resize of the frame is taken care of in the code after
2846 this if-statement. */
2847 int new_left
, new_top
;
2849 x_fullscreen_adjust (f
, &width
, &height
, &new_top
, &new_left
);
2850 if (new_top
!= f
->top_pos
|| new_left
!= f
->left_pos
)
2851 x_set_offset (f
, new_left
, new_top
, 1);
2854 /* Don't set these parameters unless they've been explicitly
2855 specified. The window might be mapped or resized while we're in
2856 this function, and we don't want to override that unless the lisp
2857 code has asked for it.
2859 Don't set these parameters unless they actually differ from the
2860 window's current parameters; the window may not actually exist
2865 check_frame_size (f
, &height
, &width
);
2867 XSETFRAME (frame
, f
);
2869 if (width
!= FRAME_COLS (f
)
2870 || height
!= FRAME_LINES (f
)
2871 || f
->new_text_lines
|| f
->new_text_cols
)
2872 Fset_frame_size (frame
, make_number (width
), make_number (height
));
2874 if ((!NILP (left
) || !NILP (top
))
2875 && ! (left_no_change
&& top_no_change
)
2876 && ! (NUMBERP (left
) && XINT (left
) == f
->left_pos
2877 && NUMBERP (top
) && XINT (top
) == f
->top_pos
))
2882 /* Record the signs. */
2883 f
->size_hint_flags
&= ~ (XNegative
| YNegative
);
2884 if (EQ (left
, Qminus
))
2885 f
->size_hint_flags
|= XNegative
;
2886 else if (INTEGERP (left
))
2888 leftpos
= XINT (left
);
2890 f
->size_hint_flags
|= XNegative
;
2892 else if (CONSP (left
) && EQ (XCAR (left
), Qminus
)
2893 && CONSP (XCDR (left
))
2894 && INTEGERP (XCAR (XCDR (left
))))
2896 leftpos
= - XINT (XCAR (XCDR (left
)));
2897 f
->size_hint_flags
|= XNegative
;
2899 else if (CONSP (left
) && EQ (XCAR (left
), Qplus
)
2900 && CONSP (XCDR (left
))
2901 && INTEGERP (XCAR (XCDR (left
))))
2903 leftpos
= XINT (XCAR (XCDR (left
)));
2906 if (EQ (top
, Qminus
))
2907 f
->size_hint_flags
|= YNegative
;
2908 else if (INTEGERP (top
))
2910 toppos
= XINT (top
);
2912 f
->size_hint_flags
|= YNegative
;
2914 else if (CONSP (top
) && EQ (XCAR (top
), Qminus
)
2915 && CONSP (XCDR (top
))
2916 && INTEGERP (XCAR (XCDR (top
))))
2918 toppos
= - XINT (XCAR (XCDR (top
)));
2919 f
->size_hint_flags
|= YNegative
;
2921 else if (CONSP (top
) && EQ (XCAR (top
), Qplus
)
2922 && CONSP (XCDR (top
))
2923 && INTEGERP (XCAR (XCDR (top
))))
2925 toppos
= XINT (XCAR (XCDR (top
)));
2929 /* Store the numeric value of the position. */
2930 f
->top_pos
= toppos
;
2931 f
->left_pos
= leftpos
;
2933 f
->win_gravity
= NorthWestGravity
;
2935 /* Actually set that position, and convert to absolute. */
2936 x_set_offset (f
, leftpos
, toppos
, -1);
2939 if ((!NILP (icon_left
) || !NILP (icon_top
))
2940 && ! (icon_left_no_change
&& icon_top_no_change
))
2941 x_wm_set_icon_position (f
, XINT (icon_left
), XINT (icon_top
));
2948 /* Insert a description of internally-recorded parameters of frame X
2949 into the parameter alist *ALISTPTR that is to be given to the user.
2950 Only parameters that are specific to the X window system
2951 and whose values are not correctly recorded in the frame's
2952 param_alist need to be considered here. */
2955 x_report_frame_params (f
, alistptr
)
2957 Lisp_Object
*alistptr
;
2962 /* Represent negative positions (off the top or left screen edge)
2963 in a way that Fmodify_frame_parameters will understand correctly. */
2964 XSETINT (tem
, f
->left_pos
);
2965 if (f
->left_pos
>= 0)
2966 store_in_alist (alistptr
, Qleft
, tem
);
2968 store_in_alist (alistptr
, Qleft
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2970 XSETINT (tem
, f
->top_pos
);
2971 if (f
->top_pos
>= 0)
2972 store_in_alist (alistptr
, Qtop
, tem
);
2974 store_in_alist (alistptr
, Qtop
, Fcons (Qplus
, Fcons (tem
, Qnil
)));
2976 store_in_alist (alistptr
, Qborder_width
,
2977 make_number (f
->border_width
));
2978 store_in_alist (alistptr
, Qinternal_border_width
,
2979 make_number (FRAME_INTERNAL_BORDER_WIDTH (f
)));
2980 store_in_alist (alistptr
, Qleft_fringe
,
2981 make_number (FRAME_LEFT_FRINGE_WIDTH (f
)));
2982 store_in_alist (alistptr
, Qright_fringe
,
2983 make_number (FRAME_RIGHT_FRINGE_WIDTH (f
)));
2984 store_in_alist (alistptr
, Qscroll_bar_width
,
2985 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
2987 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) > 0
2988 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
2989 /* nil means "use default width"
2990 for non-toolkit scroll bar.
2991 ruler-mode.el depends on this. */
2993 sprintf (buf
, "%ld", (long) FRAME_X_WINDOW (f
));
2994 store_in_alist (alistptr
, Qwindow_id
,
2995 build_string (buf
));
2996 #ifdef HAVE_X_WINDOWS
2997 #ifdef USE_X_TOOLKIT
2998 /* Tooltip frame may not have this widget. */
2999 if (FRAME_X_OUTPUT (f
)->widget
)
3001 sprintf (buf
, "%ld", (long) FRAME_OUTER_WINDOW (f
));
3002 store_in_alist (alistptr
, Qouter_window_id
,
3003 build_string (buf
));
3005 store_in_alist (alistptr
, Qicon_name
, f
->icon_name
);
3006 FRAME_SAMPLE_VISIBILITY (f
);
3007 store_in_alist (alistptr
, Qvisibility
,
3008 (FRAME_VISIBLE_P (f
) ? Qt
3009 : FRAME_ICONIFIED_P (f
) ? Qicon
: Qnil
));
3010 store_in_alist (alistptr
, Qdisplay
,
3011 XCAR (FRAME_X_DISPLAY_INFO (f
)->name_list_element
));
3013 if (FRAME_X_OUTPUT (f
)->parent_desc
== FRAME_X_DISPLAY_INFO (f
)->root_window
)
3016 XSETFASTINT (tem
, FRAME_X_OUTPUT (f
)->parent_desc
);
3017 store_in_alist (alistptr
, Qparent_id
, tem
);
3021 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3022 the previous value of that parameter, NEW_VALUE is the new value. */
3025 x_set_fullscreen (f
, new_value
, old_value
)
3027 Lisp_Object new_value
, old_value
;
3029 if (NILP (new_value
))
3030 f
->want_fullscreen
= FULLSCREEN_NONE
;
3031 else if (EQ (new_value
, Qfullboth
))
3032 f
->want_fullscreen
= FULLSCREEN_BOTH
;
3033 else if (EQ (new_value
, Qfullwidth
))
3034 f
->want_fullscreen
= FULLSCREEN_WIDTH
;
3035 else if (EQ (new_value
, Qfullheight
))
3036 f
->want_fullscreen
= FULLSCREEN_HEIGHT
;
3038 if (fullscreen_hook
!= NULL
)
3039 fullscreen_hook (f
);
3043 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3044 the previous value of that parameter, NEW_VALUE is the new value. */
3047 x_set_line_spacing (f
, new_value
, old_value
)
3049 Lisp_Object new_value
, old_value
;
3051 if (NILP (new_value
))
3052 f
->extra_line_spacing
= 0;
3053 else if (NATNUMP (new_value
))
3054 f
->extra_line_spacing
= XFASTINT (new_value
);
3056 signal_error ("Invalid line-spacing", new_value
);
3057 if (FRAME_VISIBLE_P (f
))
3062 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3063 the previous value of that parameter, NEW_VALUE is the new value. */
3066 x_set_screen_gamma (f
, new_value
, old_value
)
3068 Lisp_Object new_value
, old_value
;
3070 if (NILP (new_value
))
3072 else if (NUMBERP (new_value
) && XFLOATINT (new_value
) > 0)
3073 /* The value 0.4545 is the normal viewing gamma. */
3074 f
->gamma
= 1.0 / (0.4545 * XFLOATINT (new_value
));
3076 signal_error ("Invalid screen-gamma", new_value
);
3078 clear_face_cache (0);
3083 x_set_font (f
, arg
, oldval
)
3085 Lisp_Object arg
, oldval
;
3088 Lisp_Object fontset_name
;
3090 int old_fontset
= FRAME_FONTSET(f
);
3094 fontset_name
= Fquery_fontset (arg
, Qnil
);
3097 result
= (STRINGP (fontset_name
)
3098 ? x_new_fontset (f
, SDATA (fontset_name
))
3099 : x_new_font (f
, SDATA (arg
)));
3102 if (EQ (result
, Qnil
))
3103 error ("Font `%s' is not defined", SDATA (arg
));
3104 else if (EQ (result
, Qt
))
3105 error ("The characters of the given font have varying widths");
3106 else if (STRINGP (result
))
3108 set_default_ascii_font (result
);
3109 if (STRINGP (fontset_name
))
3111 /* Fontset names are built from ASCII font names, so the
3112 names may be equal despite there was a change. */
3113 if (old_fontset
== FRAME_FONTSET (f
))
3116 else if (!NILP (Fequal (result
, oldval
)))
3119 /* Recalculate toolbar height. */
3120 f
->n_tool_bar_rows
= 0;
3121 /* Ensure we redraw it. */
3122 clear_current_matrices (f
);
3124 store_frame_param (f
, Qfont
, result
);
3125 recompute_basic_faces (f
);
3130 do_pending_window_change (0);
3132 /* Don't call `face-set-after-frame-default' when faces haven't been
3133 initialized yet. This is the case when called from
3134 Fx_create_frame. In that case, the X widget or window doesn't
3135 exist either, and we can end up in x_report_frame_params with a
3136 null widget which gives a segfault. */
3137 if (FRAME_FACE_CACHE (f
))
3139 XSETFRAME (frame
, f
);
3140 call1 (Qface_set_after_frame_default
, frame
);
3146 x_set_fringe_width (f
, new_value
, old_value
)
3148 Lisp_Object new_value
, old_value
;
3150 compute_fringe_widths (f
, 1);
3154 x_set_border_width (f
, arg
, oldval
)
3156 Lisp_Object arg
, oldval
;
3160 if (XINT (arg
) == f
->border_width
)
3163 if (FRAME_X_WINDOW (f
) != 0)
3164 error ("Cannot change the border width of a frame");
3166 f
->border_width
= XINT (arg
);
3170 x_set_internal_border_width (f
, arg
, oldval
)
3172 Lisp_Object arg
, oldval
;
3174 int old
= FRAME_INTERNAL_BORDER_WIDTH (f
);
3177 FRAME_INTERNAL_BORDER_WIDTH (f
) = XINT (arg
);
3178 if (FRAME_INTERNAL_BORDER_WIDTH (f
) < 0)
3179 FRAME_INTERNAL_BORDER_WIDTH (f
) = 0;
3181 #ifdef USE_X_TOOLKIT
3182 if (FRAME_X_OUTPUT (f
)->edit_widget
)
3183 widget_store_internal_border (FRAME_X_OUTPUT (f
)->edit_widget
);
3186 if (FRAME_INTERNAL_BORDER_WIDTH (f
) == old
)
3189 if (FRAME_X_WINDOW (f
) != 0)
3191 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3192 SET_FRAME_GARBAGED (f
);
3193 do_pending_window_change (0);
3196 SET_FRAME_GARBAGED (f
);
3200 x_set_visibility (f
, value
, oldval
)
3202 Lisp_Object value
, oldval
;
3205 XSETFRAME (frame
, f
);
3208 Fmake_frame_invisible (frame
, Qt
);
3209 else if (EQ (value
, Qicon
))
3210 Ficonify_frame (frame
);
3212 Fmake_frame_visible (frame
);
3216 x_set_autoraise (f
, arg
, oldval
)
3218 Lisp_Object arg
, oldval
;
3220 f
->auto_raise
= !EQ (Qnil
, arg
);
3224 x_set_autolower (f
, arg
, oldval
)
3226 Lisp_Object arg
, oldval
;
3228 f
->auto_lower
= !EQ (Qnil
, arg
);
3232 x_set_unsplittable (f
, arg
, oldval
)
3234 Lisp_Object arg
, oldval
;
3236 f
->no_split
= !NILP (arg
);
3240 x_set_vertical_scroll_bars (f
, arg
, oldval
)
3242 Lisp_Object arg
, oldval
;
3244 if ((EQ (arg
, Qleft
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
3245 || (EQ (arg
, Qright
) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f
))
3246 || (NILP (arg
) && FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
3247 || (!NILP (arg
) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f
)))
3249 FRAME_VERTICAL_SCROLL_BAR_TYPE (f
)
3251 ? vertical_scroll_bar_none
3253 ? vertical_scroll_bar_left
3255 ? vertical_scroll_bar_right
3256 : EQ (Qleft
, Vdefault_frame_scroll_bars
)
3257 ? vertical_scroll_bar_left
3258 : EQ (Qright
, Vdefault_frame_scroll_bars
)
3259 ? vertical_scroll_bar_right
3260 : vertical_scroll_bar_none
);
3262 /* We set this parameter before creating the X window for the
3263 frame, so we can get the geometry right from the start.
3264 However, if the window hasn't been created yet, we shouldn't
3265 call x_set_window_size. */
3266 if (FRAME_X_WINDOW (f
))
3267 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3268 do_pending_window_change (0);
3273 x_set_scroll_bar_width (f
, arg
, oldval
)
3275 Lisp_Object arg
, oldval
;
3277 int wid
= FRAME_COLUMN_WIDTH (f
);
3281 x_set_scroll_bar_default_width (f
);
3283 if (FRAME_X_WINDOW (f
))
3284 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3285 do_pending_window_change (0);
3287 else if (INTEGERP (arg
) && XINT (arg
) > 0
3288 && XFASTINT (arg
) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f
))
3290 if (XFASTINT (arg
) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
)
3291 XSETINT (arg
, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM
+ 1);
3293 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = XFASTINT (arg
);
3294 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (XFASTINT (arg
) + wid
-1) / wid
;
3295 if (FRAME_X_WINDOW (f
))
3296 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
3297 do_pending_window_change (0);
3300 change_frame_size (f
, 0, FRAME_COLS (f
), 0, 0, 0);
3301 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.hpos
= 0;
3302 XWINDOW (FRAME_SELECTED_WINDOW (f
))->cursor
.x
= 0;
3307 /* Return non-nil if frame F wants a bitmap icon. */
3315 tem
= assq_no_quit (Qicon_type
, f
->param_alist
);
3323 /* Subroutines of creating an X frame. */
3325 /* Make sure that Vx_resource_name is set to a reasonable value.
3326 Fix it up, or set it to `emacs' if it is too hopeless. */
3329 validate_x_resource_name ()
3332 /* Number of valid characters in the resource name. */
3334 /* Number of invalid characters in the resource name. */
3339 if (!STRINGP (Vx_resource_class
))
3340 Vx_resource_class
= build_string (EMACS_CLASS
);
3342 if (STRINGP (Vx_resource_name
))
3344 unsigned char *p
= SDATA (Vx_resource_name
);
3347 len
= SBYTES (Vx_resource_name
);
3349 /* Only letters, digits, - and _ are valid in resource names.
3350 Count the valid characters and count the invalid ones. */
3351 for (i
= 0; i
< len
; i
++)
3354 if (! ((c
>= 'a' && c
<= 'z')
3355 || (c
>= 'A' && c
<= 'Z')
3356 || (c
>= '0' && c
<= '9')
3357 || c
== '-' || c
== '_'))
3364 /* Not a string => completely invalid. */
3365 bad_count
= 5, good_count
= 0;
3367 /* If name is valid already, return. */
3371 /* If name is entirely invalid, or nearly so, use `emacs'. */
3373 || (good_count
== 1 && bad_count
> 0))
3375 Vx_resource_name
= build_string ("emacs");
3379 /* Name is partly valid. Copy it and replace the invalid characters
3380 with underscores. */
3382 Vx_resource_name
= new = Fcopy_sequence (Vx_resource_name
);
3384 for (i
= 0; i
< len
; i
++)
3386 int c
= SREF (new, i
);
3387 if (! ((c
>= 'a' && c
<= 'z')
3388 || (c
>= 'A' && c
<= 'Z')
3389 || (c
>= '0' && c
<= '9')
3390 || c
== '-' || c
== '_'))
3396 extern char *x_get_string_resource
P_ ((XrmDatabase
, char *, char *));
3397 extern Display_Info
*check_x_display_info
P_ ((Lisp_Object
));
3400 /* Get specified attribute from resource database RDB.
3401 See Fx_get_resource below for other parameters. */
3404 xrdb_get_resource (rdb
, attribute
, class, component
, subclass
)
3406 Lisp_Object attribute
, class, component
, subclass
;
3408 register char *value
;
3412 CHECK_STRING (attribute
);
3413 CHECK_STRING (class);
3415 if (!NILP (component
))
3416 CHECK_STRING (component
);
3417 if (!NILP (subclass
))
3418 CHECK_STRING (subclass
);
3419 if (NILP (component
) != NILP (subclass
))
3420 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3422 validate_x_resource_name ();
3424 /* Allocate space for the components, the dots which separate them,
3425 and the final '\0'. Make them big enough for the worst case. */
3426 name_key
= (char *) alloca (SBYTES (Vx_resource_name
)
3427 + (STRINGP (component
)
3428 ? SBYTES (component
) : 0)
3429 + SBYTES (attribute
)
3432 class_key
= (char *) alloca (SBYTES (Vx_resource_class
)
3434 + (STRINGP (subclass
)
3435 ? SBYTES (subclass
) : 0)
3438 /* Start with emacs.FRAMENAME for the name (the specific one)
3439 and with `Emacs' for the class key (the general one). */
3440 strcpy (name_key
, SDATA (Vx_resource_name
));
3441 strcpy (class_key
, SDATA (Vx_resource_class
));
3443 strcat (class_key
, ".");
3444 strcat (class_key
, SDATA (class));
3446 if (!NILP (component
))
3448 strcat (class_key
, ".");
3449 strcat (class_key
, SDATA (subclass
));
3451 strcat (name_key
, ".");
3452 strcat (name_key
, SDATA (component
));
3455 strcat (name_key
, ".");
3456 strcat (name_key
, SDATA (attribute
));
3458 value
= x_get_string_resource (rdb
, name_key
, class_key
);
3460 if (value
!= (char *) 0)
3461 return build_string (value
);
3467 DEFUN ("x-get-resource", Fx_get_resource
, Sx_get_resource
, 2, 4, 0,
3468 doc
: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3469 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3470 class, where INSTANCE is the name under which Emacs was invoked, or
3471 the name specified by the `-name' or `-rn' command-line arguments.
3473 The optional arguments COMPONENT and SUBCLASS add to the key and the
3474 class, respectively. You must specify both of them or neither.
3475 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3476 and the class is `Emacs.CLASS.SUBCLASS'. */)
3477 (attribute
, class, component
, subclass
)
3478 Lisp_Object attribute
, class, component
, subclass
;
3480 #ifdef HAVE_X_WINDOWS
3484 return xrdb_get_resource (check_x_display_info (Qnil
)->xrdb
,
3485 attribute
, class, component
, subclass
);
3488 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3491 display_x_get_resource (dpyinfo
, attribute
, class, component
, subclass
)
3492 Display_Info
*dpyinfo
;
3493 Lisp_Object attribute
, class, component
, subclass
;
3495 return xrdb_get_resource (dpyinfo
->xrdb
,
3496 attribute
, class, component
, subclass
);
3499 /* Used when C code wants a resource value. */
3502 x_get_resource_string (attribute
, class)
3503 char *attribute
, *class;
3507 struct frame
*sf
= SELECTED_FRAME ();
3509 /* Allocate space for the components, the dots which separate them,
3510 and the final '\0'. */
3511 name_key
= (char *) alloca (SBYTES (Vinvocation_name
)
3512 + strlen (attribute
) + 2);
3513 class_key
= (char *) alloca ((sizeof (EMACS_CLASS
) - 1)
3514 + strlen (class) + 2);
3516 sprintf (name_key
, "%s.%s", SDATA (Vinvocation_name
), attribute
);
3517 sprintf (class_key
, "%s.%s", EMACS_CLASS
, class);
3519 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf
)->xrdb
,
3520 name_key
, class_key
);
3524 /* Return the value of parameter PARAM.
3526 First search ALIST, then Vdefault_frame_alist, then the X defaults
3527 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3529 Convert the resource to the type specified by desired_type.
3531 If no default is specified, return Qunbound. If you call
3532 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3533 and don't let it get stored in any Lisp-visible variables! */
3536 x_get_arg (dpyinfo
, alist
, param
, attribute
, class, type
)
3537 Display_Info
*dpyinfo
;
3538 Lisp_Object alist
, param
;
3541 enum resource_types type
;
3543 register Lisp_Object tem
;
3545 tem
= Fassq (param
, alist
);
3549 /* If we find this parm in ALIST, clear it out
3550 so that it won't be "left over" at the end. */
3551 #ifndef WINDOWSNT /* w32fns.c has not yet been changed to cope with this. */
3553 XSETCAR (tem
, Qnil
);
3554 /* In case the parameter appears more than once in the alist,
3556 for (tail
= alist
; CONSP (tail
); tail
= XCDR (tail
))
3557 if (CONSP (XCAR (tail
))
3558 && EQ (XCAR (XCAR (tail
)), param
))
3559 XSETCAR (XCAR (tail
), Qnil
);
3563 tem
= Fassq (param
, Vdefault_frame_alist
);
3565 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3566 look in the X resources. */
3571 tem
= display_x_get_resource (dpyinfo
,
3572 build_string (attribute
),
3573 build_string (class),
3581 case RES_TYPE_NUMBER
:
3582 return make_number (atoi (SDATA (tem
)));
3584 case RES_TYPE_FLOAT
:
3585 return make_float (atof (SDATA (tem
)));
3587 case RES_TYPE_BOOLEAN
:
3588 tem
= Fdowncase (tem
);
3589 if (!strcmp (SDATA (tem
), "on")
3590 || !strcmp (SDATA (tem
), "true"))
3595 case RES_TYPE_STRING
:
3598 case RES_TYPE_SYMBOL
:
3599 /* As a special case, we map the values `true' and `on'
3600 to Qt, and `false' and `off' to Qnil. */
3603 lower
= Fdowncase (tem
);
3604 if (!strcmp (SDATA (lower
), "on")
3605 || !strcmp (SDATA (lower
), "true"))
3607 else if (!strcmp (SDATA (lower
), "off")
3608 || !strcmp (SDATA (lower
), "false"))
3611 return Fintern (tem
, Qnil
);
3625 x_frame_get_arg (f
, alist
, param
, attribute
, class, type
)
3627 Lisp_Object alist
, param
;
3630 enum resource_types type
;
3632 return x_get_arg (FRAME_X_DISPLAY_INFO (f
),
3633 alist
, param
, attribute
, class, type
);
3636 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3639 x_frame_get_and_record_arg (f
, alist
, param
, attribute
, class, type
)
3641 Lisp_Object alist
, param
;
3644 enum resource_types type
;
3648 value
= x_get_arg (FRAME_X_DISPLAY_INFO (f
), alist
, param
,
3649 attribute
, class, type
);
3650 if (! NILP (value
) && ! EQ (value
, Qunbound
))
3651 store_frame_param (f
, param
, value
);
3657 /* Record in frame F the specified or default value according to ALIST
3658 of the parameter named PROP (a Lisp symbol).
3659 If no value is specified for PROP, look for an X default for XPROP
3660 on the frame named NAME.
3661 If that is not found either, use the value DEFLT. */
3664 x_default_parameter (f
, alist
, prop
, deflt
, xprop
, xclass
, type
)
3671 enum resource_types type
;
3675 tem
= x_frame_get_arg (f
, alist
, prop
, xprop
, xclass
, type
);
3676 if (EQ (tem
, Qunbound
))
3678 x_set_frame_parameters (f
, Fcons (Fcons (prop
, tem
), Qnil
));
3685 DEFUN ("x-parse-geometry", Fx_parse_geometry
, Sx_parse_geometry
, 1, 1, 0,
3686 doc
: /* Parse an X-style geometry string STRING.
3687 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3688 The properties returned may include `top', `left', `height', and `width'.
3689 The value of `left' or `top' may be an integer,
3690 or a list (+ N) meaning N pixels relative to top/left corner,
3691 or a list (- N) meaning -N pixels relative to bottom/right corner. */)
3696 unsigned int width
, height
;
3699 CHECK_STRING (string
);
3701 geometry
= XParseGeometry ((char *) SDATA (string
),
3702 &x
, &y
, &width
, &height
);
3705 if (!!(geometry
& XValue
) != !!(geometry
& YValue
))
3706 error ("Must specify both x and y position, or neither");
3710 if (geometry
& XValue
)
3712 Lisp_Object element
;
3714 if (x
>= 0 && (geometry
& XNegative
))
3715 element
= Fcons (Qleft
, Fcons (Qminus
, Fcons (make_number (-x
), Qnil
)));
3716 else if (x
< 0 && ! (geometry
& XNegative
))
3717 element
= Fcons (Qleft
, Fcons (Qplus
, Fcons (make_number (x
), Qnil
)));
3719 element
= Fcons (Qleft
, make_number (x
));
3720 result
= Fcons (element
, result
);
3723 if (geometry
& YValue
)
3725 Lisp_Object element
;
3727 if (y
>= 0 && (geometry
& YNegative
))
3728 element
= Fcons (Qtop
, Fcons (Qminus
, Fcons (make_number (-y
), Qnil
)));
3729 else if (y
< 0 && ! (geometry
& YNegative
))
3730 element
= Fcons (Qtop
, Fcons (Qplus
, Fcons (make_number (y
), Qnil
)));
3732 element
= Fcons (Qtop
, make_number (y
));
3733 result
= Fcons (element
, result
);
3736 if (geometry
& WidthValue
)
3737 result
= Fcons (Fcons (Qwidth
, make_number (width
)), result
);
3738 if (geometry
& HeightValue
)
3739 result
= Fcons (Fcons (Qheight
, make_number (height
)), result
);
3744 /* Calculate the desired size and position of frame F.
3745 Return the flags saying which aspects were specified.
3747 Also set the win_gravity and size_hint_flags of F.
3749 Adjust height for toolbar if TOOLBAR_P is 1.
3751 This function does not make the coordinates positive. */
3753 #define DEFAULT_ROWS 40
3754 #define DEFAULT_COLS 80
3757 x_figure_window_size (f
, parms
, toolbar_p
)
3762 register Lisp_Object tem0
, tem1
, tem2
;
3763 long window_prompting
= 0;
3764 Display_Info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
3766 /* Default values if we fall through.
3767 Actually, if that happens we should get
3768 window manager prompting. */
3769 SET_FRAME_COLS (f
, DEFAULT_COLS
);
3770 FRAME_LINES (f
) = DEFAULT_ROWS
;
3771 /* Window managers expect that if program-specified
3772 positions are not (0,0), they're intentional, not defaults. */
3776 /* Ensure that old new_text_cols and new_text_lines will not override the
3778 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3779 f
->new_text_cols
= f
->new_text_lines
= 0;
3781 tem0
= x_get_arg (dpyinfo
, parms
, Qheight
, 0, 0, RES_TYPE_NUMBER
);
3782 tem1
= x_get_arg (dpyinfo
, parms
, Qwidth
, 0, 0, RES_TYPE_NUMBER
);
3783 tem2
= x_get_arg (dpyinfo
, parms
, Quser_size
, 0, 0, RES_TYPE_NUMBER
);
3784 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3786 if (!EQ (tem0
, Qunbound
))
3788 CHECK_NUMBER (tem0
);
3789 FRAME_LINES (f
) = XINT (tem0
);
3791 if (!EQ (tem1
, Qunbound
))
3793 CHECK_NUMBER (tem1
);
3794 SET_FRAME_COLS (f
, XINT (tem1
));
3796 if (!NILP (tem2
) && !EQ (tem2
, Qunbound
))
3797 window_prompting
|= USSize
;
3799 window_prompting
|= PSize
;
3802 f
->scroll_bar_actual_width
3803 = FRAME_SCROLL_BAR_COLS (f
) * FRAME_COLUMN_WIDTH (f
);
3805 /* This used to be done _before_ calling x_figure_window_size, but
3806 since the height is reset here, this was really a no-op. I
3807 assume that moving it here does what Gerd intended (although he
3808 no longer can remember what that was... ++KFS, 2003-03-25. */
3810 /* Add the tool-bar height to the initial frame height so that the
3811 user gets a text display area of the size he specified with -g or
3812 via .Xdefaults. Later changes of the tool-bar height don't
3813 change the frame size. This is done so that users can create
3814 tall Emacs frames without having to guess how tall the tool-bar
3816 if (toolbar_p
&& FRAME_TOOL_BAR_LINES (f
))
3818 int margin
, relief
, bar_height
;
3820 relief
= (tool_bar_button_relief
>= 0
3821 ? tool_bar_button_relief
3822 : DEFAULT_TOOL_BAR_BUTTON_RELIEF
);
3824 if (INTEGERP (Vtool_bar_button_margin
)
3825 && XINT (Vtool_bar_button_margin
) > 0)
3826 margin
= XFASTINT (Vtool_bar_button_margin
);
3827 else if (CONSP (Vtool_bar_button_margin
)
3828 && INTEGERP (XCDR (Vtool_bar_button_margin
))
3829 && XINT (XCDR (Vtool_bar_button_margin
)) > 0)
3830 margin
= XFASTINT (XCDR (Vtool_bar_button_margin
));
3834 bar_height
= DEFAULT_TOOL_BAR_IMAGE_HEIGHT
+ 2 * margin
+ 2 * relief
;
3835 FRAME_LINES (f
) += (bar_height
+ FRAME_LINE_HEIGHT (f
) - 1) / FRAME_LINE_HEIGHT (f
);
3838 compute_fringe_widths (f
, 0);
3840 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, FRAME_COLS (f
));
3841 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, FRAME_LINES (f
));
3843 tem0
= x_get_arg (dpyinfo
, parms
, Qtop
, 0, 0, RES_TYPE_NUMBER
);
3844 tem1
= x_get_arg (dpyinfo
, parms
, Qleft
, 0, 0, RES_TYPE_NUMBER
);
3845 tem2
= x_get_arg (dpyinfo
, parms
, Quser_position
, 0, 0, RES_TYPE_NUMBER
);
3846 if (! EQ (tem0
, Qunbound
) || ! EQ (tem1
, Qunbound
))
3848 if (EQ (tem0
, Qminus
))
3851 window_prompting
|= YNegative
;
3853 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qminus
)
3854 && CONSP (XCDR (tem0
))
3855 && INTEGERP (XCAR (XCDR (tem0
))))
3857 f
->top_pos
= - XINT (XCAR (XCDR (tem0
)));
3858 window_prompting
|= YNegative
;
3860 else if (CONSP (tem0
) && EQ (XCAR (tem0
), Qplus
)
3861 && CONSP (XCDR (tem0
))
3862 && INTEGERP (XCAR (XCDR (tem0
))))
3864 f
->top_pos
= XINT (XCAR (XCDR (tem0
)));
3866 else if (EQ (tem0
, Qunbound
))
3870 CHECK_NUMBER (tem0
);
3871 f
->top_pos
= XINT (tem0
);
3873 window_prompting
|= YNegative
;
3876 if (EQ (tem1
, Qminus
))
3879 window_prompting
|= XNegative
;
3881 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qminus
)
3882 && CONSP (XCDR (tem1
))
3883 && INTEGERP (XCAR (XCDR (tem1
))))
3885 f
->left_pos
= - XINT (XCAR (XCDR (tem1
)));
3886 window_prompting
|= XNegative
;
3888 else if (CONSP (tem1
) && EQ (XCAR (tem1
), Qplus
)
3889 && CONSP (XCDR (tem1
))
3890 && INTEGERP (XCAR (XCDR (tem1
))))
3892 f
->left_pos
= XINT (XCAR (XCDR (tem1
)));
3894 else if (EQ (tem1
, Qunbound
))
3898 CHECK_NUMBER (tem1
);
3899 f
->left_pos
= XINT (tem1
);
3900 if (f
->left_pos
< 0)
3901 window_prompting
|= XNegative
;
3904 if (!NILP (tem2
) && ! EQ (tem2
, Qunbound
))
3905 window_prompting
|= USPosition
;
3907 window_prompting
|= PPosition
;
3910 if (f
->want_fullscreen
!= FULLSCREEN_NONE
)
3915 /* It takes both for some WM:s to place it where we want */
3916 window_prompting
= USPosition
| PPosition
;
3917 x_fullscreen_adjust (f
, &width
, &height
, &top
, &left
);
3918 FRAME_COLS (f
) = width
;
3919 FRAME_LINES (f
) = height
;
3920 FRAME_PIXEL_WIDTH (f
) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f
, width
);
3921 FRAME_PIXEL_HEIGHT (f
) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f
, height
);
3926 if (window_prompting
& XNegative
)
3928 if (window_prompting
& YNegative
)
3929 f
->win_gravity
= SouthEastGravity
;
3931 f
->win_gravity
= NorthEastGravity
;
3935 if (window_prompting
& YNegative
)
3936 f
->win_gravity
= SouthWestGravity
;
3938 f
->win_gravity
= NorthWestGravity
;
3941 f
->size_hint_flags
= window_prompting
;
3943 return window_prompting
;
3948 #endif /* HAVE_WINDOW_SYSTEM */
3952 /***********************************************************************
3954 ***********************************************************************/
3959 Qframep
= intern ("framep");
3960 staticpro (&Qframep
);
3961 Qframe_live_p
= intern ("frame-live-p");
3962 staticpro (&Qframe_live_p
);
3963 Qheight
= intern ("height");
3964 staticpro (&Qheight
);
3965 Qicon
= intern ("icon");
3967 Qminibuffer
= intern ("minibuffer");
3968 staticpro (&Qminibuffer
);
3969 Qmodeline
= intern ("modeline");
3970 staticpro (&Qmodeline
);
3971 Qonly
= intern ("only");
3973 Qwidth
= intern ("width");
3974 staticpro (&Qwidth
);
3975 Qgeometry
= intern ("geometry");
3976 staticpro (&Qgeometry
);
3977 Qicon_left
= intern ("icon-left");
3978 staticpro (&Qicon_left
);
3979 Qicon_top
= intern ("icon-top");
3980 staticpro (&Qicon_top
);
3981 Qleft
= intern ("left");
3983 Qright
= intern ("right");
3984 staticpro (&Qright
);
3985 Quser_position
= intern ("user-position");
3986 staticpro (&Quser_position
);
3987 Quser_size
= intern ("user-size");
3988 staticpro (&Quser_size
);
3989 Qwindow_id
= intern ("window-id");
3990 staticpro (&Qwindow_id
);
3991 #ifdef HAVE_X_WINDOWS
3992 Qouter_window_id
= intern ("outer-window-id");
3993 staticpro (&Qouter_window_id
);
3995 Qparent_id
= intern ("parent-id");
3996 staticpro (&Qparent_id
);
3999 Qw32
= intern ("w32");
4001 Qpc
= intern ("pc");
4003 Qmac
= intern ("mac");
4005 Qvisible
= intern ("visible");
4006 staticpro (&Qvisible
);
4007 Qbuffer_predicate
= intern ("buffer-predicate");
4008 staticpro (&Qbuffer_predicate
);
4009 Qbuffer_list
= intern ("buffer-list");
4010 staticpro (&Qbuffer_list
);
4011 Qdisplay_type
= intern ("display-type");
4012 staticpro (&Qdisplay_type
);
4013 Qbackground_mode
= intern ("background-mode");
4014 staticpro (&Qbackground_mode
);
4015 Qtty_color_mode
= intern ("tty-color-mode");
4016 staticpro (&Qtty_color_mode
);
4018 Qface_set_after_frame_default
= intern ("face-set-after-frame-default");
4019 staticpro (&Qface_set_after_frame_default
);
4021 Qinhibit_face_set_after_frame_default
4022 = intern ("inhibit-face-set-after-frame-default");
4023 staticpro (&Qinhibit_face_set_after_frame_default
);
4025 Qfullwidth
= intern ("fullwidth");
4026 staticpro (&Qfullwidth
);
4027 Qfullheight
= intern ("fullheight");
4028 staticpro (&Qfullheight
);
4029 Qfullboth
= intern ("fullboth");
4030 staticpro (&Qfullboth
);
4031 Qx_resource_name
= intern ("x-resource-name");
4032 staticpro (&Qx_resource_name
);
4034 Qx_frame_parameter
= intern ("x-frame-parameter");
4035 staticpro (&Qx_frame_parameter
);
4040 for (i
= 0; i
< sizeof (frame_parms
) / sizeof (frame_parms
[0]); i
++)
4042 Lisp_Object v
= intern (frame_parms
[i
].name
);
4043 if (frame_parms
[i
].variable
)
4045 *frame_parms
[i
].variable
= v
;
4046 staticpro (frame_parms
[i
].variable
);
4048 Fput (v
, Qx_frame_parameter
, make_number (i
));
4052 #ifdef HAVE_WINDOW_SYSTEM
4053 DEFVAR_LISP ("x-resource-name", &Vx_resource_name
,
4054 doc
: /* The name Emacs uses to look up X resources.
4055 `x-get-resource' uses this as the first component of the instance name
4056 when requesting resource values.
4057 Emacs initially sets `x-resource-name' to the name under which Emacs
4058 was invoked, or to the value specified with the `-name' or `-rn'
4059 switches, if present.
4061 It may be useful to bind this variable locally around a call
4062 to `x-get-resource'. See also the variable `x-resource-class'. */);
4063 Vx_resource_name
= Qnil
;
4065 DEFVAR_LISP ("x-resource-class", &Vx_resource_class
,
4066 doc
: /* The class Emacs uses to look up X resources.
4067 `x-get-resource' uses this as the first component of the instance class
4068 when requesting resource values.
4070 Emacs initially sets `x-resource-class' to "Emacs".
4072 Setting this variable permanently is not a reasonable thing to do,
4073 but binding this variable locally around a call to `x-get-resource'
4074 is a reasonable practice. See also the variable `x-resource-name'. */);
4075 Vx_resource_class
= build_string (EMACS_CLASS
);
4078 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist
,
4079 doc
: /* Alist of default values for frame creation.
4080 These may be set in your init file, like this:
4081 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4082 These override values given in window system configuration data,
4083 including X Windows' defaults database.
4084 For values specific to the first Emacs frame, see `initial-frame-alist'.
4085 For values specific to the separate minibuffer frame, see
4086 `minibuffer-frame-alist'.
4087 The `menu-bar-lines' element of the list controls whether new frames
4088 have menu bars; `menu-bar-mode' works by altering this element.
4089 Setting this variable does not affect existing frames, only new ones. */);
4090 Vdefault_frame_alist
= Qnil
;
4092 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars
,
4093 doc
: /* Default position of scroll bars on this window-system. */);
4094 #ifdef HAVE_WINDOW_SYSTEM
4095 #if defined(HAVE_NTGUI) || defined(MAC_OS)
4096 /* MS-Windows has scroll bars on the right by default. */
4097 Vdefault_frame_scroll_bars
= Qright
;
4099 Vdefault_frame_scroll_bars
= Qleft
;
4102 Vdefault_frame_scroll_bars
= Qnil
;
4105 Qinhibit_default_face_x_resources
4106 = intern ("inhibit-default-face-x-resources");
4107 staticpro (&Qinhibit_default_face_x_resources
);
4109 DEFVAR_LISP ("terminal-frame", &Vterminal_frame
,
4110 doc
: /* The initial frame-object, which represents Emacs's stdout. */);
4112 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified
,
4113 doc
: /* Non-nil if all of Emacs is iconified and frame updates are not needed. */);
4114 Vemacs_iconified
= Qnil
;
4116 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function
,
4117 doc
: /* If non-nil, function to transform normal value of `mouse-position'.
4118 `mouse-position' calls this function, passing its usual return value as
4119 argument, and returns whatever this function returns.
4120 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4121 which need to do mouse handling at the Lisp level. */);
4122 Vmouse_position_function
= Qnil
;
4124 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight
,
4125 doc
: /* If non-nil, clickable text is highlighted when mouse is over it.
4126 If the value is an integer, highlighting is only shown after moving the
4127 mouse, while keyboard input turns off the highlight even when the mouse
4128 is over the clickable text. However, the mouse shape still indicates
4129 when the mouse is over clickable text. */);
4130 Vmouse_highlight
= Qt
;
4132 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions
,
4133 doc
: /* Functions to be run before deleting a frame.
4134 The functions are run with one arg, the frame to be deleted.
4135 See `delete-frame'. */);
4136 Vdelete_frame_functions
= Qnil
;
4138 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame
,
4139 doc
: /* Minibufferless frames use this frame's minibuffer.
4141 Emacs cannot create minibufferless frames unless this is set to an
4142 appropriate surrogate.
4144 Emacs consults this variable only when creating minibufferless
4145 frames; once the frame is created, it sticks with its assigned
4146 minibuffer, no matter what this variable is set to. This means that
4147 this variable doesn't necessarily say anything meaningful about the
4148 current set of frames, or where the minibuffer is currently being
4151 This variable is local to the current terminal and cannot be buffer-local. */);
4153 staticpro (&Vframe_list
);
4155 defsubr (&Sactive_minibuffer_window
);
4157 defsubr (&Sframe_live_p
);
4158 defsubr (&Smake_terminal_frame
);
4159 defsubr (&Shandle_switch_frame
);
4160 defsubr (&Sselect_frame
);
4161 defsubr (&Sselected_frame
);
4162 defsubr (&Swindow_frame
);
4163 defsubr (&Sframe_root_window
);
4164 defsubr (&Sframe_first_window
);
4165 defsubr (&Sframe_selected_window
);
4166 defsubr (&Sset_frame_selected_window
);
4167 defsubr (&Sframe_list
);
4168 defsubr (&Snext_frame
);
4169 defsubr (&Sprevious_frame
);
4170 defsubr (&Sdelete_frame
);
4171 defsubr (&Smouse_position
);
4172 defsubr (&Smouse_pixel_position
);
4173 defsubr (&Sset_mouse_position
);
4174 defsubr (&Sset_mouse_pixel_position
);
4176 defsubr (&Sframe_configuration
);
4177 defsubr (&Srestore_frame_configuration
);
4179 defsubr (&Smake_frame_visible
);
4180 defsubr (&Smake_frame_invisible
);
4181 defsubr (&Siconify_frame
);
4182 defsubr (&Sframe_visible_p
);
4183 defsubr (&Svisible_frame_list
);
4184 defsubr (&Sraise_frame
);
4185 defsubr (&Slower_frame
);
4186 defsubr (&Sredirect_frame_focus
);
4187 defsubr (&Sframe_focus
);
4188 defsubr (&Sframe_parameters
);
4189 defsubr (&Sframe_parameter
);
4190 defsubr (&Smodify_frame_parameters
);
4191 defsubr (&Sframe_char_height
);
4192 defsubr (&Sframe_char_width
);
4193 defsubr (&Sframe_pixel_height
);
4194 defsubr (&Sframe_pixel_width
);
4195 defsubr (&Sset_frame_height
);
4196 defsubr (&Sset_frame_width
);
4197 defsubr (&Sset_frame_size
);
4198 defsubr (&Sset_frame_position
);
4200 #ifdef HAVE_WINDOW_SYSTEM
4201 defsubr (&Sx_get_resource
);
4202 defsubr (&Sx_parse_geometry
);
4207 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4208 (do not change this comment) */