(fill-paragraph-function): Doc fix.
[emacs.git] / src / frame.c
blobc4ba9af176b6fdb8587a8265cee6be11a02399ea
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)
10 any later version.
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. */
22 #include <config.h>
24 #include <stdio.h>
25 #include "lisp.h"
26 #include "charset.h"
27 #ifdef HAVE_X_WINDOWS
28 #include "xterm.h"
29 #endif
30 #ifdef WINDOWSNT
31 #include "w32term.h"
32 #endif
33 #ifdef MAC_OS
34 #include "macterm.h"
35 #endif
36 #include "buffer.h"
37 /* These help us bind and responding to switch-frame events. */
38 #include "commands.h"
39 #include "keyboard.h"
40 #include "frame.h"
41 #ifdef HAVE_WINDOW_SYSTEM
42 #include "fontset.h"
43 #endif
44 #include "blockinput.h"
45 #include "termhooks.h"
46 #include "dispextern.h"
47 #include "window.h"
48 #ifdef MSDOS
49 #include "msdos.h"
50 #include "dosfns.h"
51 #endif
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.
61 Normally "Emacs". */
63 Lisp_Object Vx_resource_class;
65 #endif
67 Lisp_Object Qframep, Qframe_live_p;
68 Lisp_Object Qicon, Qmodeline;
69 Lisp_Object Qonly;
70 Lisp_Object Qx, Qw32, Qmac, Qpc;
71 Lisp_Object Qvisible;
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;
99 #ifdef HAVE_X_WINDOWS
100 Lisp_Object Qouter_window_id;
101 #endif
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;
123 static void
124 set_menu_bar_lines_1 (window, n)
125 Lisp_Object window;
126 int 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);
151 void
152 set_menu_bar_lines (f, value, oldval)
153 struct frame *f;
154 Lisp_Object value, oldval;
156 int nlines;
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))
164 return;
166 if (INTEGERP (value))
167 nlines = XINT (value);
168 else
169 nlines = 0;
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);
177 adjust_glyphs (f);
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'. */)
200 (object)
201 Lisp_Object object;
203 if (!FRAMEP (object))
204 return Qnil;
205 switch (XFRAME (object)->output_method)
207 case output_termcap:
208 return Qt;
209 case output_x_window:
210 return Qx;
211 case output_w32:
212 return Qw32;
213 case output_msdos_raw:
214 return Qpc;
215 case output_mac:
216 return Qmac;
217 default:
218 abort ();
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
227 return values. */)
228 (object)
229 Lisp_Object object;
231 return ((FRAMEP (object)
232 && FRAME_LIVE_P (XFRAME (object)))
233 ? Fframep (object)
234 : Qnil);
237 struct frame *
238 make_frame (mini_p)
239 int mini_p;
241 Lisp_Object frame;
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;
251 f->desired_pool = 0;
252 f->current_pool = 0;
253 f->glyphs_initialized_p = 0;
254 f->decode_mode_spec_buffer = 0;
255 f->visible = 0;
256 f->async_visible = 0;
257 f->output_data.nothing = 0;
258 f->iconified = 0;
259 f->async_iconified = 0;
260 f->wants_modeline = 1;
261 f->auto_raise = 0;
262 f->auto_lower = 0;
263 f->no_split = 0;
264 f->garbaged = 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;
280 #ifdef MULTI_KBOARD
281 f->kboard = initial_kboard;
282 #endif
283 f->namebuf = 0;
284 f->title = Qnil;
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;
291 f->fringe_cols = 0;
292 f->scroll_bar_actual_width = 0;
293 f->border_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;
300 #endif
301 f->size_hint_flags = 0;
302 f->win_gravity = 0;
304 root_window = make_window ();
305 if (mini_p)
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;
314 else
316 mini_window = Qnil;
317 XWINDOW (root_window)->next = Qnil;
318 f->minibuffer_window = Qnil;
321 XWINDOW (root_window)->frame = frame;
323 /* 10 is arbitrary,
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));
333 if (mini_p)
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. */
342 Lisp_Object buf;
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
356 SEGV. */
357 set_window_buffer (root_window, buf, 0, 0);
358 f->buffer_list = Fcons (buf, Qnil);
361 if (mini_p)
363 XWINDOW (mini_window)->buffer = Qt;
364 set_window_buffer (mini_window,
365 (NILP (Vminibuffer_list)
366 ? get_minibuffer (0)
367 : Fcar (Vminibuffer_list)),
368 0, 0);
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;
380 return f;
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). */
388 struct frame *
389 make_frame_without_minibuffer (mini_window, kb, display)
390 register Lisp_Object mini_window;
391 KBOARD *kb;
392 Lisp_Object display;
394 register struct frame *f;
395 struct gcpro gcpro1;
397 if (!NILP (mini_window))
398 CHECK_LIVE_WINDOW (mini_window);
400 #ifdef MULTI_KBOARD
401 if (!NILP (mini_window)
402 && XFRAME (XWINDOW (mini_window)->frame)->kboard != kb)
403 error ("Frame and minibuffer must be on the same display");
404 #endif
406 /* Make a frame containing just a root window. */
407 f = make_frame (0);
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);
422 UNGCPRO;
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)
435 ? get_minibuffer (0)
436 : Fcar (Vminibuffer_list)), Qnil);
437 return f;
440 /* Make a frame containing only a minibuffer window. */
442 struct frame *
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);
453 f->auto_raise = 0;
454 f->auto_lower = 0;
455 f->no_split = 1;
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
461 as nil. */
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)
473 ? get_minibuffer (0)
474 : Fcar (Vminibuffer_list)), Qnil);
475 return f;
477 #endif /* HAVE_WINDOW_SYSTEM */
479 /* Construct a frame that refers to the terminal (stdin and stdout). */
481 static int terminal_frame_count;
483 struct frame *
484 make_terminal_frame ()
486 register struct frame *f;
487 Lisp_Object frame;
488 char name[20];
490 #ifdef MULTI_KBOARD
491 if (!initial_kboard)
493 initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
494 init_kboard (initial_kboard);
495 initial_kboard->next_kboard = all_kboards;
496 all_kboards = initial_kboard;
498 #endif
500 /* The first call must initialize Vframe_list. */
501 if (! (NILP (Vframe_list) || CONSP (Vframe_list)))
502 Vframe_list = Qnil;
504 f = make_frame (1);
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. */
515 #ifdef MSDOS
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;
537 else
538 f->output_method = output_termcap;
539 #else
540 #ifdef WINDOWSNT
541 f->output_method = output_termcap;
542 f->output_data.x = &tty_display;
543 #else
544 #ifdef MAC_OS8
545 make_mac_terminal_frame (f);
546 #else
547 f->output_data.x = &tty_display;
548 #ifdef CANNOT_DUMP
549 FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR;
550 FRAME_BACKGROUND_PIXEL(f) = FACE_TTY_DEFAULT_BG_COLOR;
551 #endif
552 #endif /* MAC_OS8 */
553 #endif /* WINDOWSNT */
554 #endif /* MSDOS */
556 if (!noninteractive)
557 init_frame_faces (f);
559 return f;
562 DEFUN ("make-terminal-frame", Fmake_terminal_frame, Smake_terminal_frame,
563 1, 1, 0,
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. */)
570 (parms)
571 Lisp_Object parms;
573 struct frame *f;
574 Lisp_Object frame, tem;
575 struct frame *sf = SELECTED_FRAME ();
577 #ifdef MSDOS
578 if (sf->output_method != output_msdos_raw
579 && sf->output_method != output_termcap)
580 abort ();
581 #else /* not MSDOS */
583 #ifdef MAC_OS
584 if (sf->output_method != output_mac)
585 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
586 #else
587 if (sf->output_method != output_termcap)
588 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
589 #endif
590 #endif /* not MSDOS */
592 f = make_terminal_frame ();
594 change_frame_size (f, FRAME_LINES (sf),
595 FRAME_COLS (sf), 0, 0, 0);
596 adjust_glyphs (f);
597 calculate_costs (f);
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))));
610 return frame;
614 /* Perform the switch to frame FRAME.
616 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
617 FRAME1 as frame.
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
625 is dead. */
627 Lisp_Object
628 do_switch_frame (frame, track, for_deletion)
629 Lisp_Object frame;
630 int track, for_deletion;
632 struct frame *sf = SELECTED_FRAME ();
634 /* If FRAME is a switch-frame event, extract the frame we should
635 switch to. */
636 if (CONSP (frame)
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. */
644 CHECK_FRAME (frame);
645 if (! FRAME_LIVE_P (XFRAME (frame)))
646 return Qnil;
648 if (sf == XFRAME (frame))
649 return frame;
651 /* This is too greedy; it causes inappropriate focus redirection
652 that's hard to get rid of. */
653 #if 0
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
660 around. */
661 if (track)
663 Lisp_Object tail;
665 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
667 Lisp_Object focus;
669 if (!FRAMEP (XCAR (tail)))
670 abort ();
672 focus = FRAME_FOCUS_FRAME (XFRAME (XCAR (tail)));
674 if (FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ())
675 Fredirect_frame_focus (XCAR (tail), frame);
678 #else /* ! 0 */
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));
686 if (FRAMEP (xfocus))
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 */
694 #endif /* ! 0 */
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);
705 #ifndef WINDOWSNT
706 /* Make sure to switch the tty color mode to that of the newly
707 selected frame. */
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);
716 else
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;
730 return frame;
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. */)
744 (frame)
745 Lisp_Object frame;
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
759 to that frame. */)
760 (event)
761 Lisp_Object 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. */)
778 (window)
779 Lisp_Object window;
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. */)
788 (frame)
789 Lisp_Object frame;
791 Lisp_Object w;
793 if (NILP (frame))
794 w = SELECTED_FRAME ()->root_window;
795 else
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;
806 else
807 abort ();
809 return w;
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. */)
823 (frame)
824 Lisp_Object frame;
826 Lisp_Object window;
828 if (NILP (frame))
829 window = SELECTED_FRAME ()->root_window;
830 else
832 CHECK_LIVE_FRAME (frame);
833 window = XFRAME (frame)->root_window;
836 return 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. */)
843 (frame)
844 Lisp_Object frame;
846 Lisp_Object window;
848 if (NILP (frame))
849 window = SELECTED_FRAME ()->selected_window;
850 else
852 CHECK_LIVE_FRAME (frame);
853 window = XFRAME (frame)->selected_window;
856 return 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.
862 Return WINDOW.
863 If FRAME is nil, the selected frame is used.
864 If FRAME is the selected frame, this makes WINDOW the selected window. */)
865 (frame, window)
866 Lisp_Object frame, window;
868 if (NILP (frame))
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,
884 0, 0, 0,
885 doc: /* Return a list of all frames. */)
888 Lisp_Object frames;
889 frames = Fcopy_sequence (Vframe_list);
890 #ifdef HAVE_WINDOW_SYSTEM
891 if (FRAMEP (tip_frame))
892 frames = Fdelq (tip_frame, frames);
893 #endif
894 return 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. */
905 static Lisp_Object
906 next_frame (frame, minibuf)
907 Lisp_Object frame;
908 Lisp_Object minibuf;
910 Lisp_Object tail;
911 int passed = 0;
913 /* There must always be at least one frame in Vframe_list. */
914 if (! CONSP (Vframe_list))
915 abort ();
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);
921 while (1)
922 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
924 Lisp_Object f;
926 f = XCAR (tail);
928 if (passed
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. */
935 if (EQ (f, frame))
936 return f;
938 /* Let minibuf decide if this frame is acceptable. */
939 if (NILP (minibuf))
941 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
942 return f;
944 else if (EQ (minibuf, Qvisible))
946 FRAME_SAMPLE_VISIBILITY (XFRAME (f));
947 if (FRAME_VISIBLE_P (XFRAME (f)))
948 return 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)))
955 return 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))))
963 return f;
965 else
966 return f;
969 if (EQ (frame, f))
970 passed++;
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. */
982 static Lisp_Object
983 prev_frame (frame, minibuf)
984 Lisp_Object frame;
985 Lisp_Object minibuf;
987 Lisp_Object tail;
988 Lisp_Object prev;
990 /* There must always be at least one frame in Vframe_list. */
991 if (! CONSP (Vframe_list))
992 abort ();
994 prev = Qnil;
995 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
997 Lisp_Object f;
999 f = XCAR (tail);
1000 if (!FRAMEP (f))
1001 abort ();
1003 if (EQ (frame, f) && !NILP (prev))
1004 return 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. */
1010 if (NILP (minibuf))
1012 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
1013 prev = 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))))
1021 prev = f;
1023 else if (EQ (minibuf, Qvisible))
1025 FRAME_SAMPLE_VISIBILITY (XFRAME (f));
1026 if (FRAME_VISIBLE_P (XFRAME (f)))
1027 prev = 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)))
1034 prev = f;
1036 else
1037 prev = f;
1041 /* We've scanned the entire list. */
1042 if (NILP (prev))
1043 /* We went through the whole frame list without finding a single
1044 acceptable frame. Return the original frame. */
1045 return frame;
1046 else
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. */
1050 return prev;
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. */)
1065 (frame, miniframe)
1066 Lisp_Object frame, miniframe;
1068 if (NILP (frame))
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. */)
1086 (frame, miniframe)
1087 Lisp_Object frame, miniframe;
1089 if (NILP (frame))
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)
1101 FRAME_PTR 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 ())
1107 Lisp_Object frames;
1108 int count = 0;
1110 for (frames = Vframe_list;
1111 CONSP (frames);
1112 frames = XCDR (frames))
1114 Lisp_Object this;
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
1119 in visibility. */
1120 #ifdef HAVE_WINDOW_SYSTEM
1121 if (FRAME_WINDOW_P (XFRAME (this)))
1123 x_sync (XFRAME (this));
1124 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1126 #endif
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)))
1133 count++;
1135 return count > 1;
1137 return 1;
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. */)
1150 (frame, force)
1151 Lisp_Object frame, force;
1153 struct frame *f;
1154 struct frame *sf = SELECTED_FRAME ();
1155 int minibuffer_selected;
1157 if (EQ (frame, Qnil))
1159 f = sf;
1160 XSETFRAME (frame, f);
1162 else
1164 CHECK_FRAME (frame);
1165 f = XFRAME (frame);
1168 if (! FRAME_LIVE_P (f))
1169 return Qnil;
1171 if (NILP (force) && !other_visible_frames (f)
1172 #ifdef MAC_OS8
1173 /* Terminal frame deleted before any other visible frames are
1174 created. */
1175 && strcmp (SDATA (f->name), "F1") != 0
1176 #endif
1178 error ("Attempt to delete the sole visible or iconified frame");
1180 #if 0
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");
1185 #endif
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)))
1191 Lisp_Object frames;
1193 for (frames = Vframe_list;
1194 CONSP (frames);
1195 frames = XCDR (frames))
1197 Lisp_Object this;
1198 this = XCAR (frames);
1200 if (! EQ (this, frame)
1201 && EQ (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");
1214 args[1] = frame;
1215 Frun_hook_with_args (2, args);
1218 minibuffer_selected = EQ (minibuf_window, selected_window);
1220 /* Don't let the frame remain selected. */
1221 if (f == sf)
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))
1234 break;
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
1261 if (FRAME_X_P (f))
1262 x_clear_frame_selections (f);
1263 #endif
1264 #ifdef MAC_OS
1265 if (FRAME_MAC_P (f))
1266 x_clear_frame_selections (f);
1267 #endif
1269 /* Free glyphs.
1270 This function must be called before the window tree of the
1271 frame is deleted because windows contain dynamically allocated
1272 memory. */
1273 free_glyphs (f);
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);
1283 if (f->namebuf)
1284 xfree (f->namebuf);
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);
1308 #endif
1310 f->output_data.nothing = 0;
1312 /* If we've deleted the last_nonminibuf_frame, then try to find
1313 another one. */
1314 if (f == last_nonminibuf_frame)
1316 Lisp_Object frames;
1318 last_nonminibuf_frame = 0;
1320 for (frames = Vframe_list;
1321 CONSP (frames);
1322 frames = XCDR (frames))
1324 f = XFRAME (XCAR (frames));
1325 if (!FRAME_MINIBUF_ONLY_P (f))
1327 last_nonminibuf_frame = f;
1328 break;
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. */
1336 Lisp_Object frames;
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;
1343 CONSP (frames);
1344 frames = XCDR (frames))
1346 Lisp_Object this;
1347 struct frame *f1;
1349 this = XCAR (frames);
1350 if (!FRAMEP (this))
1351 abort ();
1352 f1 = XFRAME (this);
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))
1368 Lisp_Object frames;
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;
1379 CONSP (frames);
1380 frames = XCDR (frames))
1382 Lisp_Object this;
1383 struct frame *f1;
1385 this = XCAR (frames);
1386 if (!FRAMEP (this))
1387 abort ();
1388 f1 = XFRAME (this);
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))
1397 break;
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))
1413 abort ();
1415 FRAME_KBOARD (f)->Vdefault_minibuffer_frame = frame_with_minibuf;
1417 else
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;
1425 return Qnil;
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. */)
1443 FRAME_PTR f;
1444 Lisp_Object lispy_dummy;
1445 enum scroll_bar_part party_dummy;
1446 Lisp_Object x, y, retval;
1447 int col, row;
1448 unsigned long long_dummy;
1449 struct gcpro gcpro1;
1451 f = SELECTED_FRAME ();
1452 x = y = Qnil;
1454 #ifdef HAVE_MOUSE
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,
1459 &x, &y,
1460 &long_dummy);
1461 if (! NILP (x))
1463 col = XINT (x);
1464 row = XINT (y);
1465 pixel_to_glyph_coords (f, col, row, &col, &row, NULL, 1);
1466 XSETINT (x, col);
1467 XSETINT (y, row);
1469 #endif
1470 XSETFRAME (lispy_dummy, f);
1471 retval = Fcons (lispy_dummy, Fcons (x, y));
1472 GCPRO1 (retval);
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. */)
1489 FRAME_PTR f;
1490 Lisp_Object lispy_dummy;
1491 enum scroll_bar_part party_dummy;
1492 Lisp_Object x, y;
1493 unsigned long long_dummy;
1495 f = SELECTED_FRAME ();
1496 x = y = Qnil;
1498 #ifdef HAVE_MOUSE
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,
1503 &x, &y,
1504 &long_dummy);
1505 #endif
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)) */)
1524 (frame, x, y)
1525 Lisp_Object frame, x, y;
1527 CHECK_LIVE_FRAME (frame);
1528 CHECK_NUMBER (x);
1529 CHECK_NUMBER (y);
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));
1536 #else
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));
1543 #endif
1544 #endif
1546 return Qnil;
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)) */)
1559 (frame, x, y)
1560 Lisp_Object frame, x, y;
1562 CHECK_LIVE_FRAME (frame);
1563 CHECK_NUMBER (x);
1564 CHECK_NUMBER (y);
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));
1571 #else
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));
1578 #endif
1579 #endif
1581 return Qnil;
1584 static void make_frame_visible_1 P_ ((Lisp_Object));
1586 DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
1587 0, 1, "",
1588 doc: /* Make the frame FRAME visible (assuming it is an X window).
1589 If omitted, FRAME defaults to the currently selected frame. */)
1590 (frame)
1591 Lisp_Object frame;
1593 if (NILP (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));
1605 #endif
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++;
1612 return frame;
1615 /* Update the display_time slot of the buffers shown in WINDOW
1616 and all its descendents. */
1618 static void
1619 make_frame_visible_1 (window)
1620 Lisp_Object window;
1622 struct window *w;
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,
1639 0, 2, "",
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. */)
1644 (frame, force)
1645 Lisp_Object frame, force;
1647 if (NILP (frame))
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)
1659 #endif
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));
1674 #endif
1676 /* Make menu bar update for the Buffers and Frames menus. */
1677 windows_or_buffers_changed++;
1679 return Qnil;
1682 DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame,
1683 0, 1, "",
1684 doc: /* Make the frame FRAME into an icon.
1685 If omitted, FRAME defaults to the currently selected frame. */)
1686 (frame)
1687 Lisp_Object frame;
1689 if (NILP (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));
1698 #endif
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));
1713 #endif
1715 /* Make menu bar update for the Buffers and Frames menus. */
1716 windows_or_buffers_changed++;
1718 return Qnil;
1721 DEFUN ("frame-visible-p", Fframe_visible_p, Sframe_visible_p,
1722 1, 1, 0,
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
1730 for all frames. */)
1731 (frame)
1732 Lisp_Object frame;
1734 CHECK_LIVE_FRAME (frame);
1736 FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
1738 if (FRAME_VISIBLE_P (XFRAME (frame)))
1739 return Qt;
1740 if (FRAME_ICONIFIED_P (XFRAME (frame)))
1741 return Qicon;
1742 return Qnil;
1745 DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list,
1746 0, 0, 0,
1747 doc: /* Return a list of all frames now \"visible\" (being updated). */)
1750 Lisp_Object tail, frame;
1751 struct frame *f;
1752 Lisp_Object value;
1754 value = Qnil;
1755 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
1757 frame = XCAR (tail);
1758 if (!FRAMEP (frame))
1759 continue;
1760 f = XFRAME (frame);
1761 if (FRAME_VISIBLE_P (f))
1762 value = Fcons (frame, value);
1764 return 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. */)
1774 (frame)
1775 Lisp_Object frame;
1777 if (NILP (frame))
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);
1788 return Qnil;
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. */)
1797 (frame)
1798 Lisp_Object frame;
1800 if (NILP (frame))
1801 frame = selected_frame;
1803 CHECK_LIVE_FRAME (frame);
1805 if (frame_raise_lower_hook)
1806 (*frame_raise_lower_hook) (XFRAME (frame), 0);
1808 return Qnil;
1812 DEFUN ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus,
1813 1, 2, 0,
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
1824 minibuffer window.
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));
1853 return Qnil;
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'. */)
1861 (frame)
1862 Lisp_Object frame;
1864 CHECK_LIVE_FRAME (frame);
1866 return FRAME_FOCUS_FRAME (XFRAME (frame));
1871 /* Return the value of frame parameter PROP in frame FRAME. */
1873 Lisp_Object
1874 get_frame_param (frame, prop)
1875 register struct frame *frame;
1876 Lisp_Object prop;
1878 register Lisp_Object tem;
1880 tem = Fassq (prop, frame->param_alist);
1881 if (EQ (tem, Qnil))
1882 return tem;
1883 return Fcdr (tem);
1886 /* Return the buffer-predicate of the selected frame. */
1888 Lisp_Object
1889 frame_buffer_predicate (frame)
1890 Lisp_Object frame;
1892 return XFRAME (frame)->buffer_predicate;
1895 /* Return the buffer-list of the selected frame. */
1897 Lisp_Object
1898 frame_buffer_list (frame)
1899 Lisp_Object frame;
1901 return XFRAME (frame)->buffer_list;
1904 /* Set the buffer-list of the selected frame. */
1906 void
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. */
1915 void
1916 frames_discard_buffer (buffer)
1917 Lisp_Object 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. */
1931 void
1932 store_in_alist (alistptr, prop, val)
1933 Lisp_Object *alistptr, val;
1934 Lisp_Object prop;
1936 register Lisp_Object tem;
1938 tem = Fassq (prop, *alistptr);
1939 if (EQ (tem, Qnil))
1940 *alistptr = Fcons (Fcons (prop, val), *alistptr);
1941 else
1942 Fsetcdr (tem, val);
1945 static int
1946 frame_name_fnn_p (str, len)
1947 char *str;
1948 int len;
1950 if (len > 1 && str[0] == 'F')
1952 char *end_ptr;
1954 strtol (str + 1, &end_ptr, 10);
1956 if (end_ptr == str + len)
1957 return 1;
1959 return 0;
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. */
1965 static void
1966 set_term_frame_name (f, name)
1967 struct frame *f;
1968 Lisp_Object name;
1970 f->explicit_name = ! NILP (name);
1972 /* If NAME is nil, set the name to F<num>. */
1973 if (NILP (name))
1975 char namebuf[20];
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),
1980 SBYTES (f->name)))
1981 return;
1983 terminal_frame_count++;
1984 sprintf (namebuf, "F%d", terminal_frame_count);
1985 name = build_string (namebuf);
1987 else
1989 CHECK_STRING (name);
1991 /* Don't change the name if it's already NAME. */
1992 if (! NILP (Fstring_equal (name, f->name)))
1993 return;
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");
2001 f->name = name;
2002 update_mode_lines = 1;
2005 void
2006 store_frame_param (f, prop, val)
2007 struct frame *f;
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;
2017 return;
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. */
2024 if (SYMBOLP (prop))
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);
2035 #ifndef WINDOWSNT
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);
2041 #endif
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);
2047 else
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. */)
2083 (frame)
2084 Lisp_Object frame;
2086 Lisp_Object alist;
2087 FRAME_PTR f;
2088 int height, width;
2089 struct gcpro gcpro1;
2091 if (NILP (frame))
2092 frame = selected_frame;
2094 CHECK_FRAME (frame);
2095 f = XFRAME (frame);
2097 if (!FRAME_LIVE_P (f))
2098 return Qnil;
2100 alist = Fcopy_alist (f->param_alist);
2101 GCPRO1 (alist);
2103 if (!FRAME_WINDOW_P (f))
2105 int fg = FRAME_FOREGROUND_PIXEL (f);
2106 int bg = FRAME_BACKGROUND_PIXEL (f);
2107 Lisp_Object elt;
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)),
2116 unspecified_bg,
2117 SCHARS (XCDR (elt))) == 0)
2118 store_in_alist (&alist, Qforeground_color, tty_color_name (f, bg));
2119 else if (strncmp (SDATA (XCDR (elt)),
2120 unspecified_fg,
2121 SCHARS (XCDR (elt))) == 0)
2122 store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg));
2124 else
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)),
2130 unspecified_fg,
2131 SCHARS (XCDR (elt))) == 0)
2132 store_in_alist (&alist, Qbackground_color, tty_color_name (f, fg));
2133 else if (strncmp (SDATA (XCDR (elt)),
2134 unspecified_bg,
2135 SCHARS (XCDR (elt))) == 0)
2136 store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg));
2138 else
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)
2142 ? "ms-dos"
2143 : FRAME_W32_P (f) ? "w32term"
2144 :"tty"));
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);
2163 else
2164 #endif
2166 /* This ought to be correct in f->param_alist for an X frame. */
2167 Lisp_Object lines;
2168 XSETFASTINT (lines, FRAME_MENU_BAR_LINES (f));
2169 store_in_alist (&alist, Qmenu_bar_lines, lines);
2172 UNGCPRO;
2173 return alist;
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. */)
2180 (frame, parameter)
2181 Lisp_Object frame, parameter;
2183 struct frame *f;
2184 Lisp_Object value;
2186 if (NILP (frame))
2187 frame = selected_frame;
2188 else
2189 CHECK_FRAME (frame);
2190 CHECK_SYMBOL (parameter);
2192 f = XFRAME (frame);
2193 value = Qnil;
2195 if (FRAME_LIVE_P (f))
2197 /* Avoid consing in frequent cases. */
2198 if (EQ (parameter, Qname))
2199 value = f->name;
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);
2208 if (CONSP (value))
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;
2218 EMACS_INT csz;
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));
2240 else
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));
2246 else
2247 value = Fcdr (Fassq (parameter, Fframe_parameters (frame)));
2250 return value;
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'. */)
2267 (frame, alist)
2268 Lisp_Object frame, alist;
2270 FRAME_PTR f;
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);
2285 f = XFRAME (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);
2291 else
2292 #endif
2293 #ifdef MSDOS
2294 if (FRAME_MSDOS_P (f))
2295 IT_set_frame_parameters (f, alist);
2296 else
2297 #endif
2300 int length = XINT (Flength (alist));
2301 int i;
2302 Lisp_Object *parms
2303 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
2304 Lisp_Object *values
2305 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
2307 /* Extract parm names and values into those vectors. */
2309 i = 0;
2310 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
2312 Lisp_Object elt;
2314 elt = Fcar (tail);
2315 parms[i] = Fcar (elt);
2316 values[i] = Fcdr (elt);
2317 i++;
2320 /* Now process them in reverse of specified order. */
2321 for (i--; i >= 0; i--)
2323 prop = parms[i];
2324 val = values[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,
2339 0, 1, 0,
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. */)
2343 (frame)
2344 Lisp_Object frame;
2346 struct frame *f;
2348 if (NILP (frame))
2349 frame = selected_frame;
2350 CHECK_FRAME (frame);
2351 f = XFRAME (frame);
2353 #ifdef HAVE_WINDOW_SYSTEM
2354 if (FRAME_WINDOW_P (f))
2355 return make_number (x_char_height (f));
2356 else
2357 #endif
2358 return make_number (1);
2362 DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
2363 0, 1, 0,
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. */)
2368 (frame)
2369 Lisp_Object frame;
2371 struct frame *f;
2373 if (NILP (frame))
2374 frame = selected_frame;
2375 CHECK_FRAME (frame);
2376 f = XFRAME (frame);
2378 #ifdef HAVE_WINDOW_SYSTEM
2379 if (FRAME_WINDOW_P (f))
2380 return make_number (x_char_width (f));
2381 else
2382 #endif
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. */)
2393 (frame)
2394 Lisp_Object frame;
2396 struct frame *f;
2398 if (NILP (frame))
2399 frame = selected_frame;
2400 CHECK_FRAME (frame);
2401 f = XFRAME (frame);
2403 #ifdef HAVE_WINDOW_SYSTEM
2404 if (FRAME_WINDOW_P (f))
2405 return make_number (x_pixel_height (f));
2406 else
2407 #endif
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. */)
2416 (frame)
2417 Lisp_Object frame;
2419 struct frame *f;
2421 if (NILP (frame))
2422 frame = selected_frame;
2423 CHECK_FRAME (frame);
2424 f = XFRAME (frame);
2426 #ifdef HAVE_WINDOW_SYSTEM
2427 if (FRAME_WINDOW_P (f))
2428 return make_number (x_pixel_width (f));
2429 else
2430 #endif
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);
2444 if (NILP (frame))
2445 frame = selected_frame;
2446 CHECK_LIVE_FRAME (frame);
2447 f = XFRAME (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);
2457 else
2458 #endif
2459 change_frame_size (f, XINT (lines), 0, !NILP (pretend), 0, 0);
2460 return Qnil;
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);
2472 if (NILP (frame))
2473 frame = selected_frame;
2474 CHECK_LIVE_FRAME (frame);
2475 f = XFRAME (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);
2485 else
2486 #endif
2487 change_frame_size (f, 0, XINT (cols), !NILP (pretend), 0, 0);
2488 return Qnil;
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. */)
2493 (frame, cols, rows)
2494 Lisp_Object frame, cols, rows;
2496 register struct frame *f;
2498 CHECK_LIVE_FRAME (frame);
2499 CHECK_NUMBER (cols);
2500 CHECK_NUMBER (rows);
2501 f = XFRAME (frame);
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);
2513 else
2514 #endif
2515 change_frame_size (f, XINT (rows), XINT (cols), 0, 0, 0);
2517 return Qnil;
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);
2534 f = XFRAME (frame);
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);
2540 #endif
2542 return Qt;
2546 /***********************************************************************
2547 Frame Parameters
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 {
2558 char *name;
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},
2571 {"font", 0},
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},
2578 {"name", &Qname},
2579 {"scroll-bar-width", &Qscroll_bar_width},
2580 {"title", &Qtitle},
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).
2606 void
2607 x_fullscreen_adjust (f, width, height, top_pos, left_pos)
2608 struct frame *f;
2609 int *width;
2610 int *height;
2611 int *top_pos;
2612 int *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)
2622 int ph;
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);
2628 *top_pos = 0;
2631 if (f->want_fullscreen & FULLSCREEN_WIDTH)
2633 int pw;
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);
2639 *left_pos = 0;
2642 *width = newwidth;
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. */
2653 void
2654 x_set_frame_parameters (f, alist)
2655 FRAME_PTR f;
2656 Lisp_Object alist;
2658 Lisp_Object tail;
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. */
2663 int width, height;
2665 /* Same here. */
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. */
2672 Lisp_Object *parms;
2673 Lisp_Object *values;
2674 int i, p;
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;
2681 i = 0;
2682 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
2683 i++;
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. */
2690 i = 0;
2691 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
2693 Lisp_Object elt;
2695 elt = Fcar (tail);
2696 parms[i] = Fcar (elt);
2697 values[i] = Fcdr (elt);
2698 i++;
2700 /* TAIL and ALIST are not used again below here. */
2701 alist = tail = Qnil;
2703 GCPRO2 (*parms, *values);
2704 gcpro1.nvars = i;
2705 gcpro2.nvars = i;
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;
2725 prop = parms[p];
2726 val = values[p];
2727 if (EQ (prop, Qforeground_color)
2728 || EQ (prop, Qbackground_color)
2729 || EQ (prop, Qfont)
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;
2766 prop = parms[i];
2767 val = values[i];
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))
2774 top = val;
2775 else if (EQ (prop, Qleft))
2776 left = val;
2777 else if (EQ (prop, Qicon_top))
2778 icon_top = val;
2779 else if (EQ (prop, Qicon_left))
2780 icon_left = val;
2781 else if (EQ (prop, Qforeground_color)
2782 || EQ (prop, Qbackground_color)
2783 || EQ (prop, Qfont)
2784 || EQ (prop, Qfullscreen))
2785 /* Processed above. */
2786 continue;
2787 else
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))
2807 left_no_change = 1;
2808 if (f->left_pos < 0)
2809 left = Fcons (Qplus, Fcons (make_number (f->left_pos), Qnil));
2810 else
2811 XSETINT (left, f->left_pos);
2813 if (EQ (top, Qunbound))
2815 top_no_change = 1;
2816 if (f->top_pos < 0)
2817 top = Fcons (Qplus, Fcons (make_number (f->top_pos), Qnil));
2818 else
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
2842 size and position.
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
2861 yet. */
2863 Lisp_Object frame;
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))
2879 int leftpos = 0;
2880 int toppos = 0;
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);
2889 if (leftpos < 0)
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);
2911 if (toppos < 0)
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));
2944 UNGCPRO;
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. */
2954 void
2955 x_report_frame_params (f, alistptr)
2956 struct frame *f;
2957 Lisp_Object *alistptr;
2959 char buf[16];
2960 Lisp_Object tem;
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);
2967 else
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);
2973 else
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)
2986 ? make_number (0)
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. */
2992 : Qnil));
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)
3000 #endif
3001 sprintf (buf, "%ld", (long) FRAME_OUTER_WINDOW (f));
3002 store_in_alist (alistptr, Qouter_window_id,
3003 build_string (buf));
3004 #endif
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)
3014 tem = Qnil;
3015 else
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. */
3024 void
3025 x_set_fullscreen (f, new_value, old_value)
3026 struct frame *f;
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. */
3046 void
3047 x_set_line_spacing (f, new_value, old_value)
3048 struct frame *f;
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);
3055 else
3056 signal_error ("Invalid line-spacing", new_value);
3057 if (FRAME_VISIBLE_P (f))
3058 redraw_frame (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. */
3065 void
3066 x_set_screen_gamma (f, new_value, old_value)
3067 struct frame *f;
3068 Lisp_Object new_value, old_value;
3070 if (NILP (new_value))
3071 f->gamma = 0;
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));
3075 else
3076 signal_error ("Invalid screen-gamma", new_value);
3078 clear_face_cache (0);
3082 void
3083 x_set_font (f, arg, oldval)
3084 struct frame *f;
3085 Lisp_Object arg, oldval;
3087 Lisp_Object result;
3088 Lisp_Object fontset_name;
3089 Lisp_Object frame;
3090 int old_fontset = FRAME_FONTSET(f);
3092 CHECK_STRING (arg);
3094 fontset_name = Fquery_fontset (arg, Qnil);
3096 BLOCK_INPUT;
3097 result = (STRINGP (fontset_name)
3098 ? x_new_fontset (f, SDATA (fontset_name))
3099 : x_new_font (f, SDATA (arg)));
3100 UNBLOCK_INPUT;
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))
3114 return;
3116 else if (!NILP (Fequal (result, oldval)))
3117 return;
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);
3127 else
3128 abort ();
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);
3145 void
3146 x_set_fringe_width (f, new_value, old_value)
3147 struct frame *f;
3148 Lisp_Object new_value, old_value;
3150 compute_fringe_widths (f, 1);
3153 void
3154 x_set_border_width (f, arg, oldval)
3155 struct frame *f;
3156 Lisp_Object arg, oldval;
3158 CHECK_NUMBER (arg);
3160 if (XINT (arg) == f->border_width)
3161 return;
3163 if (FRAME_X_WINDOW (f) != 0)
3164 error ("Cannot change the border width of a frame");
3166 f->border_width = XINT (arg);
3169 void
3170 x_set_internal_border_width (f, arg, oldval)
3171 struct frame *f;
3172 Lisp_Object arg, oldval;
3174 int old = FRAME_INTERNAL_BORDER_WIDTH (f);
3176 CHECK_NUMBER (arg);
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);
3184 #endif
3186 if (FRAME_INTERNAL_BORDER_WIDTH (f) == old)
3187 return;
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);
3195 else
3196 SET_FRAME_GARBAGED (f);
3199 void
3200 x_set_visibility (f, value, oldval)
3201 struct frame *f;
3202 Lisp_Object value, oldval;
3204 Lisp_Object frame;
3205 XSETFRAME (frame, f);
3207 if (NILP (value))
3208 Fmake_frame_invisible (frame, Qt);
3209 else if (EQ (value, Qicon))
3210 Ficonify_frame (frame);
3211 else
3212 Fmake_frame_visible (frame);
3215 void
3216 x_set_autoraise (f, arg, oldval)
3217 struct frame *f;
3218 Lisp_Object arg, oldval;
3220 f->auto_raise = !EQ (Qnil, arg);
3223 void
3224 x_set_autolower (f, arg, oldval)
3225 struct frame *f;
3226 Lisp_Object arg, oldval;
3228 f->auto_lower = !EQ (Qnil, arg);
3231 void
3232 x_set_unsplittable (f, arg, oldval)
3233 struct frame *f;
3234 Lisp_Object arg, oldval;
3236 f->no_split = !NILP (arg);
3239 void
3240 x_set_vertical_scroll_bars (f, arg, oldval)
3241 struct frame *f;
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)
3250 = (NILP (arg)
3251 ? vertical_scroll_bar_none
3252 : EQ (Qleft, arg)
3253 ? vertical_scroll_bar_left
3254 : EQ (Qright, arg)
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);
3272 void
3273 x_set_scroll_bar_width (f, arg, oldval)
3274 struct frame *f;
3275 Lisp_Object arg, oldval;
3277 int wid = FRAME_COLUMN_WIDTH (f);
3279 if (NILP (arg))
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. */
3309 Lisp_Object
3310 x_icon_type (f)
3311 FRAME_PTR f;
3313 Lisp_Object tem;
3315 tem = assq_no_quit (Qicon_type, f->param_alist);
3316 if (CONSP (tem))
3317 return XCDR (tem);
3318 else
3319 return Qnil;
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. */
3328 void
3329 validate_x_resource_name ()
3331 int len = 0;
3332 /* Number of valid characters in the resource name. */
3333 int good_count = 0;
3334 /* Number of invalid characters in the resource name. */
3335 int bad_count = 0;
3336 Lisp_Object new;
3337 int i;
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);
3345 int i;
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++)
3353 int c = p[i];
3354 if (! ((c >= 'a' && c <= 'z')
3355 || (c >= 'A' && c <= 'Z')
3356 || (c >= '0' && c <= '9')
3357 || c == '-' || c == '_'))
3358 bad_count++;
3359 else
3360 good_count++;
3363 else
3364 /* Not a string => completely invalid. */
3365 bad_count = 5, good_count = 0;
3367 /* If name is valid already, return. */
3368 if (bad_count == 0)
3369 return;
3371 /* If name is entirely invalid, or nearly so, use `emacs'. */
3372 if (good_count == 0
3373 || (good_count == 1 && bad_count > 0))
3375 Vx_resource_name = build_string ("emacs");
3376 return;
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 == '_'))
3391 SSET (new, i, '_');
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. */
3403 static Lisp_Object
3404 xrdb_get_resource (rdb, attribute, class, component, subclass)
3405 XrmDatabase rdb;
3406 Lisp_Object attribute, class, component, subclass;
3408 register char *value;
3409 char *name_key;
3410 char *class_key;
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)
3430 + 3);
3432 class_key = (char *) alloca (SBYTES (Vx_resource_class)
3433 + SBYTES (class)
3434 + (STRINGP (subclass)
3435 ? SBYTES (subclass) : 0)
3436 + 3);
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);
3462 else
3463 return Qnil;
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
3481 check_x ();
3482 #endif
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. */
3490 Lisp_Object
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. */
3501 char *
3502 x_get_resource_string (attribute, class)
3503 char *attribute, *class;
3505 char *name_key;
3506 char *class_key;
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! */
3535 Lisp_Object
3536 x_get_arg (dpyinfo, alist, param, attribute, class, type)
3537 Display_Info *dpyinfo;
3538 Lisp_Object alist, param;
3539 char *attribute;
3540 char *class;
3541 enum resource_types type;
3543 register Lisp_Object tem;
3545 tem = Fassq (param, alist);
3547 if (!NILP (tem))
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. */
3552 Lisp_Object tail;
3553 XSETCAR (tem, Qnil);
3554 /* In case the parameter appears more than once in the alist,
3555 clear it out. */
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);
3560 #endif
3562 else
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. */
3567 if (EQ (tem, Qnil))
3569 if (attribute)
3571 tem = display_x_get_resource (dpyinfo,
3572 build_string (attribute),
3573 build_string (class),
3574 Qnil, Qnil);
3576 if (NILP (tem))
3577 return Qunbound;
3579 switch (type)
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"))
3591 return Qt;
3592 else
3593 return Qnil;
3595 case RES_TYPE_STRING:
3596 return tem;
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. */
3602 Lisp_Object lower;
3603 lower = Fdowncase (tem);
3604 if (!strcmp (SDATA (lower), "on")
3605 || !strcmp (SDATA (lower), "true"))
3606 return Qt;
3607 else if (!strcmp (SDATA (lower), "off")
3608 || !strcmp (SDATA (lower), "false"))
3609 return Qnil;
3610 else
3611 return Fintern (tem, Qnil);
3614 default:
3615 abort ();
3618 else
3619 return Qunbound;
3621 return Fcdr (tem);
3624 Lisp_Object
3625 x_frame_get_arg (f, alist, param, attribute, class, type)
3626 struct frame *f;
3627 Lisp_Object alist, param;
3628 char *attribute;
3629 char *class;
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. */
3638 Lisp_Object
3639 x_frame_get_and_record_arg (f, alist, param, attribute, class, type)
3640 struct frame *f;
3641 Lisp_Object alist, param;
3642 char *attribute;
3643 char *class;
3644 enum resource_types type;
3646 Lisp_Object value;
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);
3653 return 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. */
3663 Lisp_Object
3664 x_default_parameter (f, alist, prop, deflt, xprop, xclass, type)
3665 struct frame *f;
3666 Lisp_Object alist;
3667 Lisp_Object prop;
3668 Lisp_Object deflt;
3669 char *xprop;
3670 char *xclass;
3671 enum resource_types type;
3673 Lisp_Object tem;
3675 tem = x_frame_get_arg (f, alist, prop, xprop, xclass, type);
3676 if (EQ (tem, Qunbound))
3677 tem = deflt;
3678 x_set_frame_parameters (f, Fcons (Fcons (prop, tem), Qnil));
3679 return tem;
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. */)
3692 (string)
3693 Lisp_Object string;
3695 int geometry, x, y;
3696 unsigned int width, height;
3697 Lisp_Object result;
3699 CHECK_STRING (string);
3701 geometry = XParseGeometry ((char *) SDATA (string),
3702 &x, &y, &width, &height);
3704 #if 0
3705 if (!!(geometry & XValue) != !!(geometry & YValue))
3706 error ("Must specify both x and y position, or neither");
3707 #endif
3709 result = Qnil;
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)));
3718 else
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)));
3731 else
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);
3741 return 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)
3758 struct frame *f;
3759 Lisp_Object parms;
3760 int 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. */
3773 f->top_pos = 0;
3774 f->left_pos = 0;
3776 /* Ensure that old new_text_cols and new_text_lines will not override the
3777 values set here. */
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;
3798 else
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
3815 will get. */
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));
3831 else
3832 margin = 0;
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))
3850 f->top_pos = 0;
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))
3867 f->top_pos = 0;
3868 else
3870 CHECK_NUMBER (tem0);
3871 f->top_pos = XINT (tem0);
3872 if (f->top_pos < 0)
3873 window_prompting |= YNegative;
3876 if (EQ (tem1, Qminus))
3878 f->left_pos = 0;
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))
3895 f->left_pos = 0;
3896 else
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;
3906 else
3907 window_prompting |= PPosition;
3910 if (f->want_fullscreen != FULLSCREEN_NONE)
3912 int left, top;
3913 int width, height;
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);
3922 f->left_pos = left;
3923 f->top_pos = top;
3926 if (window_prompting & XNegative)
3928 if (window_prompting & YNegative)
3929 f->win_gravity = SouthEastGravity;
3930 else
3931 f->win_gravity = NorthEastGravity;
3933 else
3935 if (window_prompting & YNegative)
3936 f->win_gravity = SouthWestGravity;
3937 else
3938 f->win_gravity = NorthWestGravity;
3941 f->size_hint_flags = window_prompting;
3943 return window_prompting;
3948 #endif /* HAVE_WINDOW_SYSTEM */
3952 /***********************************************************************
3953 Initialization
3954 ***********************************************************************/
3956 void
3957 syms_of_frame ()
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");
3966 staticpro (&Qicon);
3967 Qminibuffer = intern ("minibuffer");
3968 staticpro (&Qminibuffer);
3969 Qmodeline = intern ("modeline");
3970 staticpro (&Qmodeline);
3971 Qonly = intern ("only");
3972 staticpro (&Qonly);
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");
3982 staticpro (&Qleft);
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);
3994 #endif
3995 Qparent_id = intern ("parent-id");
3996 staticpro (&Qparent_id);
3997 Qx = intern ("x");
3998 staticpro (&Qx);
3999 Qw32 = intern ("w32");
4000 staticpro (&Qw32);
4001 Qpc = intern ("pc");
4002 staticpro (&Qpc);
4003 Qmac = intern ("mac");
4004 staticpro (&Qmac);
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);
4038 int i;
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);
4076 #endif
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;
4098 #else
4099 Vdefault_frame_scroll_bars = Qleft;
4100 #endif
4101 #else
4102 Vdefault_frame_scroll_bars = Qnil;
4103 #endif
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
4149 displayed.
4151 This variable is local to the current terminal and cannot be buffer-local. */);
4153 staticpro (&Vframe_list);
4155 defsubr (&Sactive_minibuffer_window);
4156 defsubr (&Sframep);
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);
4175 #if 0
4176 defsubr (&Sframe_configuration);
4177 defsubr (&Srestore_frame_configuration);
4178 #endif
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);
4203 #endif
4207 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4208 (do not change this comment) */