Version 2.0.34 (of Tramp) released.
[emacs.git] / src / frame.c
blob580dae02d5e77f70a827133c9d55cdec46b793cf
1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2003
3 Free Software Foundation.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
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., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, 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 Qface_set_after_frame_default;
115 Lisp_Object Vterminal_frame;
116 Lisp_Object Vdefault_frame_alist;
117 Lisp_Object Vmouse_position_function;
118 Lisp_Object Vmouse_highlight;
119 Lisp_Object Vdelete_frame_functions;
121 static void
122 set_menu_bar_lines_1 (window, n)
123 Lisp_Object window;
124 int n;
126 struct window *w = XWINDOW (window);
128 XSETFASTINT (w->last_modified, 0);
129 XSETFASTINT (w->top, XFASTINT (w->top) + n);
130 XSETFASTINT (w->height, XFASTINT (w->height) - n);
132 if (INTEGERP (w->orig_top))
133 XSETFASTINT (w->orig_top, XFASTINT (w->orig_top) + n);
134 if (INTEGERP (w->orig_height))
135 XSETFASTINT (w->orig_height, XFASTINT (w->orig_height) - n);
137 /* Handle just the top child in a vertical split. */
138 if (!NILP (w->vchild))
139 set_menu_bar_lines_1 (w->vchild, n);
141 /* Adjust all children in a horizontal split. */
142 for (window = w->hchild; !NILP (window); window = w->next)
144 w = XWINDOW (window);
145 set_menu_bar_lines_1 (window, n);
149 void
150 set_menu_bar_lines (f, value, oldval)
151 struct frame *f;
152 Lisp_Object value, oldval;
154 int nlines;
155 int olines = FRAME_MENU_BAR_LINES (f);
157 /* Right now, menu bars don't work properly in minibuf-only frames;
158 most of the commands try to apply themselves to the minibuffer
159 frame itself, and get an error because you can't switch buffers
160 in or split the minibuffer window. */
161 if (FRAME_MINIBUF_ONLY_P (f))
162 return;
164 if (INTEGERP (value))
165 nlines = XINT (value);
166 else
167 nlines = 0;
169 if (nlines != olines)
171 windows_or_buffers_changed++;
172 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
173 FRAME_MENU_BAR_LINES (f) = nlines;
174 set_menu_bar_lines_1 (f->root_window, nlines - olines);
175 adjust_glyphs (f);
179 Lisp_Object Vemacs_iconified;
180 Lisp_Object Vframe_list;
182 struct x_output tty_display;
184 extern Lisp_Object Vminibuffer_list;
185 extern Lisp_Object get_minibuffer ();
186 extern Lisp_Object Fhandle_switch_frame ();
187 extern Lisp_Object Fredirect_frame_focus ();
188 extern Lisp_Object x_get_focus_frame ();
190 DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
191 doc: /* Return non-nil if OBJECT is a frame.
192 Value is t for a termcap frame (a character-only terminal),
193 `x' for an Emacs frame that is really an X window,
194 `w32' for an Emacs frame that is a window on MS-Windows display,
195 `mac' for an Emacs frame on a Macintosh display,
196 `pc' for a direct-write MS-DOS frame.
197 See also `frame-live-p'. */)
198 (object)
199 Lisp_Object object;
201 if (!FRAMEP (object))
202 return Qnil;
203 switch (XFRAME (object)->output_method)
205 case output_termcap:
206 return Qt;
207 case output_x_window:
208 return Qx;
209 case output_w32:
210 return Qw32;
211 case output_msdos_raw:
212 return Qpc;
213 case output_mac:
214 return Qmac;
215 default:
216 abort ();
220 DEFUN ("frame-live-p", Fframe_live_p, Sframe_live_p, 1, 1, 0,
221 doc: /* Return non-nil if OBJECT is a frame which has not been deleted.
222 Value is nil if OBJECT is not a live frame. If object is a live
223 frame, the return value indicates what sort of output device it is
224 displayed on. See the documentation of `framep' for possible
225 return values. */)
226 (object)
227 Lisp_Object object;
229 return ((FRAMEP (object)
230 && FRAME_LIVE_P (XFRAME (object)))
231 ? Fframep (object)
232 : Qnil);
235 struct frame *
236 make_frame (mini_p)
237 int mini_p;
239 Lisp_Object frame;
240 register struct frame *f;
241 register Lisp_Object root_window;
242 register Lisp_Object mini_window;
244 f = allocate_frame ();
245 XSETFRAME (frame, f);
247 f->desired_matrix = 0;
248 f->current_matrix = 0;
249 f->desired_pool = 0;
250 f->current_pool = 0;
251 f->glyphs_initialized_p = 0;
252 f->decode_mode_spec_buffer = 0;
253 f->visible = 0;
254 f->async_visible = 0;
255 f->output_data.nothing = 0;
256 f->iconified = 0;
257 f->async_iconified = 0;
258 f->wants_modeline = 1;
259 f->auto_raise = 0;
260 f->auto_lower = 0;
261 f->no_split = 0;
262 f->garbaged = 1;
263 f->has_minibuffer = mini_p;
264 f->focus_frame = Qnil;
265 f->explicit_name = 0;
266 f->can_have_scroll_bars = 0;
267 f->vertical_scroll_bar_type = vertical_scroll_bar_none;
268 f->param_alist = Qnil;
269 f->scroll_bars = Qnil;
270 f->condemned_scroll_bars = Qnil;
271 f->face_alist = Qnil;
272 f->face_cache = NULL;
273 f->menu_bar_items = Qnil;
274 f->menu_bar_vector = Qnil;
275 f->menu_bar_items_used = 0;
276 f->buffer_predicate = Qnil;
277 f->buffer_list = Qnil;
278 #ifdef MULTI_KBOARD
279 f->kboard = initial_kboard;
280 #endif
281 f->namebuf = 0;
282 f->title = Qnil;
283 f->menu_bar_window = Qnil;
284 f->tool_bar_window = Qnil;
285 f->tool_bar_items = Qnil;
286 f->desired_tool_bar_string = f->current_tool_bar_string = Qnil;
287 f->n_tool_bar_items = 0;
289 root_window = make_window ();
290 if (mini_p)
292 mini_window = make_window ();
293 XWINDOW (root_window)->next = mini_window;
294 XWINDOW (mini_window)->prev = root_window;
295 XWINDOW (mini_window)->mini_p = Qt;
296 XWINDOW (mini_window)->frame = frame;
297 f->minibuffer_window = mini_window;
299 else
301 mini_window = Qnil;
302 XWINDOW (root_window)->next = Qnil;
303 f->minibuffer_window = Qnil;
306 XWINDOW (root_window)->frame = frame;
308 /* 10 is arbitrary,
309 just so that there is "something there."
310 Correct size will be set up later with change_frame_size. */
312 SET_FRAME_WIDTH (f, 10);
313 f->height = 10;
315 XSETFASTINT (XWINDOW (root_window)->width, 10);
316 XSETFASTINT (XWINDOW (root_window)->height, (mini_p ? 9 : 10));
318 if (mini_p)
320 XSETFASTINT (XWINDOW (mini_window)->width, 10);
321 XSETFASTINT (XWINDOW (mini_window)->top, 9);
322 XSETFASTINT (XWINDOW (mini_window)->height, 1);
325 /* Choose a buffer for the frame's root window. */
327 Lisp_Object buf;
329 XWINDOW (root_window)->buffer = Qt;
330 buf = Fcurrent_buffer ();
331 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
332 a space), try to find another one. */
333 if (SREF (Fbuffer_name (buf), 0) == ' ')
334 buf = Fother_buffer (buf, Qnil, Qnil);
336 /* Use set_window_buffer, not Fset_window_buffer, and don't let
337 hooks be run by it. The reason is that the whole frame/window
338 arrangement is not yet fully intialized at this point. Windows
339 don't have the right size, glyph matrices aren't initialized
340 etc. Running Lisp functions at this point surely ends in a
341 SEGV. */
342 set_window_buffer (root_window, buf, 0);
343 f->buffer_list = Fcons (buf, Qnil);
346 if (mini_p)
348 XWINDOW (mini_window)->buffer = Qt;
349 set_window_buffer (mini_window,
350 (NILP (Vminibuffer_list)
351 ? get_minibuffer (0)
352 : Fcar (Vminibuffer_list)),
356 f->root_window = root_window;
357 f->selected_window = root_window;
358 /* Make sure this window seems more recently used than
359 a newly-created, never-selected window. */
360 XSETFASTINT (XWINDOW (f->selected_window)->use_time, ++window_select_count);
362 return f;
365 #ifdef HAVE_WINDOW_SYSTEM
366 /* Make a frame using a separate minibuffer window on another frame.
367 MINI_WINDOW is the minibuffer window to use. nil means use the
368 default (the global minibuffer). */
370 struct frame *
371 make_frame_without_minibuffer (mini_window, kb, display)
372 register Lisp_Object mini_window;
373 KBOARD *kb;
374 Lisp_Object display;
376 register struct frame *f;
377 struct gcpro gcpro1;
379 if (!NILP (mini_window))
380 CHECK_LIVE_WINDOW (mini_window);
382 #ifdef MULTI_KBOARD
383 if (!NILP (mini_window)
384 && XFRAME (XWINDOW (mini_window)->frame)->kboard != kb)
385 error ("frame and minibuffer must be on the same display");
386 #endif
388 /* Make a frame containing just a root window. */
389 f = make_frame (0);
391 if (NILP (mini_window))
393 /* Use default-minibuffer-frame if possible. */
394 if (!FRAMEP (kb->Vdefault_minibuffer_frame)
395 || ! FRAME_LIVE_P (XFRAME (kb->Vdefault_minibuffer_frame)))
397 Lisp_Object frame_dummy;
399 XSETFRAME (frame_dummy, f);
400 GCPRO1 (frame_dummy);
401 /* If there's no minibuffer frame to use, create one. */
402 kb->Vdefault_minibuffer_frame =
403 call1 (intern ("make-initial-minibuffer-frame"), display);
404 UNGCPRO;
407 mini_window = XFRAME (kb->Vdefault_minibuffer_frame)->minibuffer_window;
410 f->minibuffer_window = mini_window;
412 /* Make the chosen minibuffer window display the proper minibuffer,
413 unless it is already showing a minibuffer. */
414 if (NILP (Fmemq (XWINDOW (mini_window)->buffer, Vminibuffer_list)))
415 Fset_window_buffer (mini_window,
416 (NILP (Vminibuffer_list)
417 ? get_minibuffer (0)
418 : Fcar (Vminibuffer_list)));
419 return f;
422 /* Make a frame containing only a minibuffer window. */
424 struct frame *
425 make_minibuffer_frame ()
427 /* First make a frame containing just a root window, no minibuffer. */
429 register struct frame *f = make_frame (0);
430 register Lisp_Object mini_window;
431 register Lisp_Object frame;
433 XSETFRAME (frame, f);
435 f->auto_raise = 0;
436 f->auto_lower = 0;
437 f->no_split = 1;
438 f->wants_modeline = 0;
439 f->has_minibuffer = 1;
441 /* Now label the root window as also being the minibuffer.
442 Avoid infinite looping on the window chain by marking next pointer
443 as nil. */
445 mini_window = f->minibuffer_window = f->root_window;
446 XWINDOW (mini_window)->mini_p = Qt;
447 XWINDOW (mini_window)->next = Qnil;
448 XWINDOW (mini_window)->prev = Qnil;
449 XWINDOW (mini_window)->frame = frame;
451 /* Put the proper buffer in that window. */
453 Fset_window_buffer (mini_window,
454 (NILP (Vminibuffer_list)
455 ? get_minibuffer (0)
456 : Fcar (Vminibuffer_list)));
457 return f;
459 #endif /* HAVE_WINDOW_SYSTEM */
461 /* Construct a frame that refers to the terminal (stdin and stdout). */
463 static int terminal_frame_count;
465 struct frame *
466 make_terminal_frame ()
468 register struct frame *f;
469 Lisp_Object frame;
470 char name[20];
472 #ifdef MULTI_KBOARD
473 if (!initial_kboard)
475 initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
476 init_kboard (initial_kboard);
477 initial_kboard->next_kboard = all_kboards;
478 all_kboards = initial_kboard;
480 #endif
482 /* The first call must initialize Vframe_list. */
483 if (! (NILP (Vframe_list) || CONSP (Vframe_list)))
484 Vframe_list = Qnil;
486 f = make_frame (1);
488 XSETFRAME (frame, f);
489 Vframe_list = Fcons (frame, Vframe_list);
491 terminal_frame_count++;
492 sprintf (name, "F%d", terminal_frame_count);
493 f->name = build_string (name);
495 f->visible = 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
496 f->async_visible = 1; /* Don't let visible be cleared later. */
497 #ifdef MSDOS
498 f->output_data.x = &the_only_x_display;
499 if (!inhibit_window_system
500 && (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame))
501 || XFRAME (selected_frame)->output_method == output_msdos_raw))
503 f->output_method = output_msdos_raw;
504 /* This initialization of foreground and background pixels is
505 only important for the initial frame created in temacs. If
506 we don't do that, we get black background and foreground in
507 the dumped Emacs because the_only_x_display is a static
508 variable, hence it is born all-zeroes, and zero is the code
509 for the black color. Other frames all inherit their pixels
510 from what's already in the_only_x_display. */
511 if ((!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame)))
512 && f->output_data.x->background_pixel == 0
513 && f->output_data.x->foreground_pixel == 0)
515 f->output_data.x->background_pixel = FACE_TTY_DEFAULT_BG_COLOR;
516 f->output_data.x->foreground_pixel = FACE_TTY_DEFAULT_FG_COLOR;
519 else
520 f->output_method = output_termcap;
521 #else
522 #ifdef WINDOWSNT
523 f->output_method = output_termcap;
524 f->output_data.x = &tty_display;
525 #else
526 #ifdef MAC_OS8
527 make_mac_terminal_frame (f);
528 #else
529 f->output_data.x = &tty_display;
530 #ifdef CANNOT_DUMP
531 FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR;
532 FRAME_BACKGROUND_PIXEL(f) = FACE_TTY_DEFAULT_BG_COLOR;
533 #endif
534 #endif /* MAC_OS8 */
535 #endif /* WINDOWSNT */
536 #endif /* MSDOS */
538 if (!noninteractive)
539 init_frame_faces (f);
541 return f;
544 DEFUN ("make-terminal-frame", Fmake_terminal_frame, Smake_terminal_frame,
545 1, 1, 0,
546 doc: /* Create an additional terminal frame.
547 You can create multiple frames on a text-only terminal in this way.
548 Only the selected terminal frame is actually displayed.
549 This function takes one argument, an alist specifying frame parameters.
550 In practice, generally you don't need to specify any parameters.
551 Note that changing the size of one terminal frame automatically affects all. */)
552 (parms)
553 Lisp_Object parms;
555 struct frame *f;
556 Lisp_Object frame, tem;
557 struct frame *sf = SELECTED_FRAME ();
559 #ifdef MSDOS
560 if (sf->output_method != output_msdos_raw
561 && sf->output_method != output_termcap)
562 abort ();
563 #else /* not MSDOS */
565 #ifdef MAC_OS
566 if (sf->output_method != output_mac)
567 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
568 #else
569 if (sf->output_method != output_termcap)
570 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
571 #endif
572 #endif /* not MSDOS */
574 f = make_terminal_frame ();
576 change_frame_size (f, FRAME_HEIGHT (sf),
577 FRAME_WIDTH (sf), 0, 0, 0);
578 adjust_glyphs (f);
579 calculate_costs (f);
580 XSETFRAME (frame, f);
581 Fmodify_frame_parameters (frame, Vdefault_frame_alist);
582 Fmodify_frame_parameters (frame, parms);
584 /* Make the frame face alist be frame-specific, so that each
585 frame could change its face definitions independently. */
586 f->face_alist = Fcopy_alist (sf->face_alist);
587 /* Simple Fcopy_alist isn't enough, because we need the contents of
588 the vectors which are the CDRs of associations in face_alist to
589 be copied as well. */
590 for (tem = f->face_alist; CONSP (tem); tem = XCDR (tem))
591 XSETCDR (XCAR (tem), Fcopy_sequence (XCDR (XCAR (tem))));
592 return frame;
596 /* Perform the switch to frame FRAME.
598 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
599 FRAME1 as frame.
601 If TRACK is non-zero and the frame that currently has the focus
602 redirects its focus to the selected frame, redirect that focused
603 frame's focus to FRAME instead.
605 FOR_DELETION non-zero means that the selected frame is being
606 deleted, which includes the possibility that the frame's display
607 is dead. */
609 Lisp_Object
610 do_switch_frame (frame, track, for_deletion)
611 Lisp_Object frame;
612 int track, for_deletion;
614 struct frame *sf = SELECTED_FRAME ();
616 /* If FRAME is a switch-frame event, extract the frame we should
617 switch to. */
618 if (CONSP (frame)
619 && EQ (XCAR (frame), Qswitch_frame)
620 && CONSP (XCDR (frame)))
621 frame = XCAR (XCDR (frame));
623 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
624 a switch-frame event to arrive after a frame is no longer live,
625 especially when deleting the initial frame during startup. */
626 CHECK_FRAME (frame);
627 if (! FRAME_LIVE_P (XFRAME (frame)))
628 return Qnil;
630 if (sf == XFRAME (frame))
631 return frame;
633 /* This is too greedy; it causes inappropriate focus redirection
634 that's hard to get rid of. */
635 #if 0
636 /* If a frame's focus has been redirected toward the currently
637 selected frame, we should change the redirection to point to the
638 newly selected frame. This means that if the focus is redirected
639 from a minibufferless frame to a surrogate minibuffer frame, we
640 can use `other-window' to switch between all the frames using
641 that minibuffer frame, and the focus redirection will follow us
642 around. */
643 if (track)
645 Lisp_Object tail;
647 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
649 Lisp_Object focus;
651 if (!FRAMEP (XCAR (tail)))
652 abort ();
654 focus = FRAME_FOCUS_FRAME (XFRAME (XCAR (tail)));
656 if (FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ())
657 Fredirect_frame_focus (XCAR (tail), frame);
660 #else /* ! 0 */
661 /* Instead, apply it only to the frame we're pointing to. */
662 #ifdef HAVE_WINDOW_SYSTEM
663 if (track && FRAME_WINDOW_P (XFRAME (frame)))
665 Lisp_Object focus, xfocus;
667 xfocus = x_get_focus_frame (XFRAME (frame));
668 if (FRAMEP (xfocus))
670 focus = FRAME_FOCUS_FRAME (XFRAME (xfocus));
671 if (FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ())
672 Fredirect_frame_focus (xfocus, frame);
675 #endif /* HAVE_X_WINDOWS */
676 #endif /* ! 0 */
678 if (!for_deletion && FRAME_HAS_MINIBUF_P (sf))
679 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf)), 1);
681 selected_frame = frame;
682 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame)))
683 last_nonminibuf_frame = XFRAME (selected_frame);
685 Fselect_window (XFRAME (frame)->selected_window, Qnil);
687 #ifndef WINDOWSNT
688 /* Make sure to switch the tty color mode to that of the newly
689 selected frame. */
690 sf = SELECTED_FRAME ();
691 if (FRAME_TERMCAP_P (sf))
693 Lisp_Object color_mode_spec, color_mode;
695 color_mode_spec = assq_no_quit (Qtty_color_mode, sf->param_alist);
696 if (CONSP (color_mode_spec))
697 color_mode = XCDR (color_mode_spec);
698 else
699 color_mode = make_number (0);
700 set_tty_color_mode (sf, color_mode);
702 #endif /* !WINDOWSNT */
704 /* We want to make sure that the next event generates a frame-switch
705 event to the appropriate frame. This seems kludgy to me, but
706 before you take it out, make sure that evaluating something like
707 (select-window (frame-root-window (new-frame))) doesn't end up
708 with your typing being interpreted in the new frame instead of
709 the one you're actually typing in. */
710 internal_last_event_frame = Qnil;
712 return frame;
715 DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e",
716 doc: /* Select the frame FRAME.
717 Subsequent editing commands apply to its selected window.
718 The selection of FRAME lasts until the next time the user does
719 something to select a different frame, or until the next time this
720 function is called. */)
721 (frame, no_enter)
722 Lisp_Object frame, no_enter;
724 return do_switch_frame (frame, 1, 0);
728 DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 2, "e",
729 doc: /* Handle a switch-frame event EVENT.
730 Switch-frame events are usually bound to this function.
731 A switch-frame event tells Emacs that the window manager has requested
732 that the user's events be directed to the frame mentioned in the event.
733 This function selects the selected window of the frame of EVENT.
735 If EVENT is frame object, handle it as if it were a switch-frame event
736 to that frame. */)
737 (event, no_enter)
738 Lisp_Object event, no_enter;
740 /* Preserve prefix arg that the command loop just cleared. */
741 current_kboard->Vprefix_arg = Vcurrent_prefix_arg;
742 call1 (Vrun_hooks, Qmouse_leave_buffer_hook);
743 return do_switch_frame (event, 0, 0);
746 DEFUN ("ignore-event", Fignore_event, Signore_event, 0, 0, "",
747 doc: /* Do nothing, but preserve any prefix argument already specified.
748 This is a suitable binding for `iconify-frame' and `make-frame-visible'. */)
751 current_kboard->Vprefix_arg = Vcurrent_prefix_arg;
752 return Qnil;
755 DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
756 doc: /* Return the frame that is now selected. */)
759 return selected_frame;
762 DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
763 doc: /* Return the frame object that window WINDOW is on. */)
764 (window)
765 Lisp_Object window;
767 CHECK_LIVE_WINDOW (window);
768 return XWINDOW (window)->frame;
771 DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0,
772 doc: /* Returns the topmost, leftmost window of FRAME.
773 If omitted, FRAME defaults to the currently selected frame. */)
774 (frame)
775 Lisp_Object frame;
777 Lisp_Object w;
779 if (NILP (frame))
780 w = SELECTED_FRAME ()->root_window;
781 else
783 CHECK_LIVE_FRAME (frame);
784 w = XFRAME (frame)->root_window;
786 while (NILP (XWINDOW (w)->buffer))
788 if (! NILP (XWINDOW (w)->hchild))
789 w = XWINDOW (w)->hchild;
790 else if (! NILP (XWINDOW (w)->vchild))
791 w = XWINDOW (w)->vchild;
792 else
793 abort ();
795 return w;
798 DEFUN ("active-minibuffer-window", Factive_minibuffer_window,
799 Sactive_minibuffer_window, 0, 0, 0,
800 doc: /* Return the currently active minibuffer window, or nil if none. */)
803 return minibuf_level ? minibuf_window : Qnil;
806 DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0,
807 doc: /* Returns the root-window of FRAME.
808 If omitted, FRAME defaults to the currently selected frame. */)
809 (frame)
810 Lisp_Object frame;
812 Lisp_Object window;
814 if (NILP (frame))
815 window = SELECTED_FRAME ()->root_window;
816 else
818 CHECK_LIVE_FRAME (frame);
819 window = XFRAME (frame)->root_window;
822 return window;
825 DEFUN ("frame-selected-window", Fframe_selected_window,
826 Sframe_selected_window, 0, 1, 0,
827 doc: /* Return the selected window of frame object FRAME.
828 If omitted, FRAME defaults to the currently selected frame. */)
829 (frame)
830 Lisp_Object frame;
832 Lisp_Object window;
834 if (NILP (frame))
835 window = SELECTED_FRAME ()->selected_window;
836 else
838 CHECK_LIVE_FRAME (frame);
839 window = XFRAME (frame)->selected_window;
842 return window;
845 DEFUN ("set-frame-selected-window", Fset_frame_selected_window,
846 Sset_frame_selected_window, 2, 2, 0,
847 doc: /* Set the selected window of frame object FRAME to WINDOW.
848 If FRAME is nil, the selected frame is used.
849 If FRAME is the selected frame, this makes WINDOW the selected window. */)
850 (frame, window)
851 Lisp_Object frame, window;
853 if (NILP (frame))
854 frame = selected_frame;
856 CHECK_LIVE_FRAME (frame);
857 CHECK_LIVE_WINDOW (window);
859 if (! EQ (frame, WINDOW_FRAME (XWINDOW (window))))
860 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
862 if (EQ (frame, selected_frame))
863 return Fselect_window (window, Qnil);
865 return XFRAME (frame)->selected_window = window;
868 DEFUN ("frame-list", Fframe_list, Sframe_list,
869 0, 0, 0,
870 doc: /* Return a list of all frames. */)
873 Lisp_Object frames;
874 frames = Fcopy_sequence (Vframe_list);
875 #ifdef HAVE_WINDOW_SYSTEM
876 if (FRAMEP (tip_frame))
877 frames = Fdelq (tip_frame, frames);
878 #endif
879 return frames;
882 /* Return the next frame in the frame list after FRAME.
883 If MINIBUF is nil, exclude minibuffer-only frames.
884 If MINIBUF is a window, include only its own frame
885 and any frame now using that window as the minibuffer.
886 If MINIBUF is `visible', include all visible frames.
887 If MINIBUF is 0, include all visible and iconified frames.
888 Otherwise, include all frames. */
890 Lisp_Object
891 next_frame (frame, minibuf)
892 Lisp_Object frame;
893 Lisp_Object minibuf;
895 Lisp_Object tail;
896 int passed = 0;
898 /* There must always be at least one frame in Vframe_list. */
899 if (! CONSP (Vframe_list))
900 abort ();
902 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
903 forever. Forestall that. */
904 CHECK_LIVE_FRAME (frame);
906 while (1)
907 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
909 Lisp_Object f;
911 f = XCAR (tail);
913 if (passed
914 && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame)))
916 /* Decide whether this frame is eligible to be returned. */
918 /* If we've looped all the way around without finding any
919 eligible frames, return the original frame. */
920 if (EQ (f, frame))
921 return f;
923 /* Let minibuf decide if this frame is acceptable. */
924 if (NILP (minibuf))
926 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
927 return f;
929 else if (EQ (minibuf, Qvisible))
931 FRAME_SAMPLE_VISIBILITY (XFRAME (f));
932 if (FRAME_VISIBLE_P (XFRAME (f)))
933 return f;
935 else if (INTEGERP (minibuf) && XINT (minibuf) == 0)
937 FRAME_SAMPLE_VISIBILITY (XFRAME (f));
938 if (FRAME_VISIBLE_P (XFRAME (f))
939 || FRAME_ICONIFIED_P (XFRAME (f)))
940 return f;
942 else if (WINDOWP (minibuf))
944 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf)
945 || EQ (WINDOW_FRAME (XWINDOW (minibuf)), f)
946 || EQ (WINDOW_FRAME (XWINDOW (minibuf)),
947 FRAME_FOCUS_FRAME (XFRAME (f))))
948 return f;
950 else
951 return f;
954 if (EQ (frame, f))
955 passed++;
959 /* Return the previous frame in the frame list before FRAME.
960 If MINIBUF is nil, exclude minibuffer-only frames.
961 If MINIBUF is a window, include only its own frame
962 and any frame now using that window as the minibuffer.
963 If MINIBUF is `visible', include all visible frames.
964 If MINIBUF is 0, include all visible and iconified frames.
965 Otherwise, include all frames. */
967 Lisp_Object
968 prev_frame (frame, minibuf)
969 Lisp_Object frame;
970 Lisp_Object minibuf;
972 Lisp_Object tail;
973 Lisp_Object prev;
975 /* There must always be at least one frame in Vframe_list. */
976 if (! CONSP (Vframe_list))
977 abort ();
979 prev = Qnil;
980 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
982 Lisp_Object f;
984 f = XCAR (tail);
985 if (!FRAMEP (f))
986 abort ();
988 if (EQ (frame, f) && !NILP (prev))
989 return prev;
991 if (FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame)))
993 /* Decide whether this frame is eligible to be returned,
994 according to minibuf. */
995 if (NILP (minibuf))
997 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
998 prev = f;
1000 else if (WINDOWP (minibuf))
1002 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf)
1003 || EQ (WINDOW_FRAME (XWINDOW (minibuf)), f)
1004 || EQ (WINDOW_FRAME (XWINDOW (minibuf)),
1005 FRAME_FOCUS_FRAME (XFRAME (f))))
1006 prev = f;
1008 else if (EQ (minibuf, Qvisible))
1010 FRAME_SAMPLE_VISIBILITY (XFRAME (f));
1011 if (FRAME_VISIBLE_P (XFRAME (f)))
1012 prev = f;
1014 else if (XFASTINT (minibuf) == 0)
1016 FRAME_SAMPLE_VISIBILITY (XFRAME (f));
1017 if (FRAME_VISIBLE_P (XFRAME (f))
1018 || FRAME_ICONIFIED_P (XFRAME (f)))
1019 prev = f;
1021 else
1022 prev = f;
1026 /* We've scanned the entire list. */
1027 if (NILP (prev))
1028 /* We went through the whole frame list without finding a single
1029 acceptable frame. Return the original frame. */
1030 return frame;
1031 else
1032 /* There were no acceptable frames in the list before FRAME; otherwise,
1033 we would have returned directly from the loop. Since PREV is the last
1034 acceptable frame in the list, return it. */
1035 return prev;
1039 DEFUN ("next-frame", Fnext_frame, Snext_frame, 0, 2, 0,
1040 doc: /* Return the next frame in the frame list after FRAME.
1041 It considers only frames on the same terminal as FRAME.
1042 By default, skip minibuffer-only frames.
1043 If omitted, FRAME defaults to the selected frame.
1044 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1045 If MINIFRAME is a window, include only its own frame
1046 and any frame now using that window as the minibuffer.
1047 If MINIFRAME is `visible', include all visible frames.
1048 If MINIFRAME is 0, include all visible and iconified frames.
1049 Otherwise, include all frames. */)
1050 (frame, miniframe)
1051 Lisp_Object frame, miniframe;
1053 if (NILP (frame))
1054 frame = selected_frame;
1056 CHECK_LIVE_FRAME (frame);
1057 return next_frame (frame, miniframe);
1060 DEFUN ("previous-frame", Fprevious_frame, Sprevious_frame, 0, 2, 0,
1061 doc: /* Return the previous frame in the frame list before FRAME.
1062 It considers only frames on the same terminal as FRAME.
1063 By default, skip minibuffer-only frames.
1064 If omitted, FRAME defaults to the selected frame.
1065 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1066 If MINIFRAME is a window, include only its own frame
1067 and any frame now using that window as the minibuffer.
1068 If MINIFRAME is `visible', include all visible frames.
1069 If MINIFRAME is 0, include all visible and iconified frames.
1070 Otherwise, include all frames. */)
1071 (frame, miniframe)
1072 Lisp_Object frame, miniframe;
1074 if (NILP (frame))
1075 frame = selected_frame;
1076 CHECK_LIVE_FRAME (frame);
1077 return prev_frame (frame, miniframe);
1080 /* Return 1 if it is ok to delete frame F;
1081 0 if all frames aside from F are invisible.
1082 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1085 other_visible_frames (f)
1086 FRAME_PTR f;
1088 /* We know the selected frame is visible,
1089 so if F is some other frame, it can't be the sole visible one. */
1090 if (f == SELECTED_FRAME ())
1092 Lisp_Object frames;
1093 int count = 0;
1095 for (frames = Vframe_list;
1096 CONSP (frames);
1097 frames = XCDR (frames))
1099 Lisp_Object this;
1101 this = XCAR (frames);
1102 /* Verify that the frame's window still exists
1103 and we can still talk to it. And note any recent change
1104 in visibility. */
1105 #ifdef HAVE_WINDOW_SYSTEM
1106 if (FRAME_WINDOW_P (XFRAME (this)))
1108 x_sync (XFRAME (this));
1109 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1111 #endif
1113 if (FRAME_VISIBLE_P (XFRAME (this))
1114 || FRAME_ICONIFIED_P (XFRAME (this))
1115 /* Allow deleting the terminal frame when at least
1116 one X frame exists! */
1117 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f)))
1118 count++;
1120 return count > 1;
1122 return 1;
1125 DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "",
1126 doc: /* Delete FRAME, permanently eliminating it from use.
1127 If omitted, FRAME defaults to the selected frame.
1128 A frame may not be deleted if its minibuffer is used by other frames.
1129 Normally, you may not delete a frame if all other frames are invisible,
1130 but if the second optional argument FORCE is non-nil, you may do so.
1132 This function runs `delete-frame-functions' before actually deleting the
1133 frame, unless the frame is a tooltip.
1134 The functions are run with one arg, the frame to be deleted. */)
1135 (frame, force)
1136 Lisp_Object frame, force;
1138 struct frame *f;
1139 struct frame *sf = SELECTED_FRAME ();
1140 int minibuffer_selected;
1142 if (EQ (frame, Qnil))
1144 f = sf;
1145 XSETFRAME (frame, f);
1147 else
1149 CHECK_FRAME (frame);
1150 f = XFRAME (frame);
1153 if (! FRAME_LIVE_P (f))
1154 return Qnil;
1156 if (NILP (force) && !other_visible_frames (f)
1157 #ifdef MAC_OS8
1158 /* Terminal frame deleted before any other visible frames are
1159 created. */
1160 && strcmp (SDATA (f->name), "F1") != 0
1161 #endif
1163 error ("Attempt to delete the sole visible or iconified frame");
1165 #if 0
1166 /* This is a nice idea, but x_connection_closed needs to be able
1167 to delete the last frame, if it is gone. */
1168 if (NILP (XCDR (Vframe_list)))
1169 error ("Attempt to delete the only frame");
1170 #endif
1172 /* Does this frame have a minibuffer, and is it the surrogate
1173 minibuffer for any other frame? */
1174 if (FRAME_HAS_MINIBUF_P (XFRAME (frame)))
1176 Lisp_Object frames;
1178 for (frames = Vframe_list;
1179 CONSP (frames);
1180 frames = XCDR (frames))
1182 Lisp_Object this;
1183 this = XCAR (frames);
1185 if (! EQ (this, frame)
1186 && EQ (frame,
1187 WINDOW_FRAME (XWINDOW
1188 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1189 error ("Attempt to delete a surrogate minibuffer frame");
1193 /* Run `delete-frame-functions' unless frame is a tooltip. */
1194 if (!NILP (Vrun_hooks)
1195 && NILP (Fframe_parameter (frame, intern ("tooltip"))))
1197 Lisp_Object args[2];
1198 args[0] = intern ("delete-frame-functions");
1199 args[1] = frame;
1200 Frun_hook_with_args (2, args);
1203 minibuffer_selected = EQ (minibuf_window, selected_window);
1205 /* Don't let the frame remain selected. */
1206 if (f == sf)
1208 Lisp_Object tail, frame1;
1210 /* Look for another visible frame on the same terminal. */
1211 frame1 = next_frame (frame, Qvisible);
1213 /* If there is none, find *some* other frame. */
1214 if (NILP (frame1) || EQ (frame1, frame))
1216 FOR_EACH_FRAME (tail, frame1)
1218 if (! EQ (frame, frame1))
1219 break;
1223 do_switch_frame (frame1, 0, 1);
1224 sf = SELECTED_FRAME ();
1227 /* Don't allow minibuf_window to remain on a deleted frame. */
1228 if (EQ (f->minibuffer_window, minibuf_window))
1230 Fset_window_buffer (sf->minibuffer_window,
1231 XWINDOW (minibuf_window)->buffer);
1232 minibuf_window = sf->minibuffer_window;
1234 /* If the dying minibuffer window was selected,
1235 select the new one. */
1236 if (minibuffer_selected)
1237 Fselect_window (minibuf_window, Qnil);
1240 /* Don't let echo_area_window to remain on a deleted frame. */
1241 if (EQ (f->minibuffer_window, echo_area_window))
1242 echo_area_window = sf->minibuffer_window;
1244 /* Clear any X selections for this frame. */
1245 #ifdef HAVE_X_WINDOWS
1246 if (FRAME_X_P (f))
1247 x_clear_frame_selections (f);
1248 #endif
1250 /* Free glyphs.
1251 This function must be called before the window tree of the
1252 frame is deleted because windows contain dynamically allocated
1253 memory. */
1254 free_glyphs (f);
1256 /* Mark all the windows that used to be on FRAME as deleted, and then
1257 remove the reference to them. */
1258 delete_all_subwindows (XWINDOW (f->root_window));
1259 f->root_window = Qnil;
1261 Vframe_list = Fdelq (frame, Vframe_list);
1262 FRAME_SET_VISIBLE (f, 0);
1264 if (f->namebuf)
1265 xfree (f->namebuf);
1266 if (FRAME_INSERT_COST (f))
1267 xfree (FRAME_INSERT_COST (f));
1268 if (FRAME_DELETEN_COST (f))
1269 xfree (FRAME_DELETEN_COST (f));
1270 if (FRAME_INSERTN_COST (f))
1271 xfree (FRAME_INSERTN_COST (f));
1272 if (FRAME_DELETE_COST (f))
1273 xfree (FRAME_DELETE_COST (f));
1274 if (FRAME_MESSAGE_BUF (f))
1275 xfree (FRAME_MESSAGE_BUF (f));
1277 /* Since some events are handled at the interrupt level, we may get
1278 an event for f at any time; if we zero out the frame's display
1279 now, then we may trip up the event-handling code. Instead, we'll
1280 promise that the display of the frame must be valid until we have
1281 called the window-system-dependent frame destruction routine. */
1283 /* I think this should be done with a hook. */
1284 #ifdef HAVE_WINDOW_SYSTEM
1285 if (FRAME_WINDOW_P (f))
1286 x_destroy_window (f);
1287 #endif
1289 f->output_data.nothing = 0;
1291 /* If we've deleted the last_nonminibuf_frame, then try to find
1292 another one. */
1293 if (f == last_nonminibuf_frame)
1295 Lisp_Object frames;
1297 last_nonminibuf_frame = 0;
1299 for (frames = Vframe_list;
1300 CONSP (frames);
1301 frames = XCDR (frames))
1303 f = XFRAME (XCAR (frames));
1304 if (!FRAME_MINIBUF_ONLY_P (f))
1306 last_nonminibuf_frame = f;
1307 break;
1312 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1313 find another one. Prefer minibuffer-only frames, but also notice
1314 frames with other windows. */
1315 if (EQ (frame, FRAME_KBOARD (f)->Vdefault_minibuffer_frame))
1317 Lisp_Object frames;
1319 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1320 Lisp_Object frame_with_minibuf;
1321 /* Some frame we found on the same kboard, or nil if there are none. */
1322 Lisp_Object frame_on_same_kboard;
1324 frame_on_same_kboard = Qnil;
1325 frame_with_minibuf = Qnil;
1327 for (frames = Vframe_list;
1328 CONSP (frames);
1329 frames = XCDR (frames))
1331 Lisp_Object this;
1332 struct frame *f1;
1334 this = XCAR (frames);
1335 if (!FRAMEP (this))
1336 abort ();
1337 f1 = XFRAME (this);
1339 /* Consider only frames on the same kboard
1340 and only those with minibuffers. */
1341 if (FRAME_KBOARD (f) == FRAME_KBOARD (f1)
1342 && FRAME_HAS_MINIBUF_P (f1))
1344 frame_with_minibuf = this;
1345 if (FRAME_MINIBUF_ONLY_P (f1))
1346 break;
1349 if (FRAME_KBOARD (f) == FRAME_KBOARD (f1))
1350 frame_on_same_kboard = this;
1353 if (!NILP (frame_on_same_kboard))
1355 /* We know that there must be some frame with a minibuffer out
1356 there. If this were not true, all of the frames present
1357 would have to be minibufferless, which implies that at some
1358 point their minibuffer frames must have been deleted, but
1359 that is prohibited at the top; you can't delete surrogate
1360 minibuffer frames. */
1361 if (NILP (frame_with_minibuf))
1362 abort ();
1364 FRAME_KBOARD (f)->Vdefault_minibuffer_frame = frame_with_minibuf;
1366 else
1367 /* No frames left on this kboard--say no minibuffer either. */
1368 FRAME_KBOARD (f)->Vdefault_minibuffer_frame = Qnil;
1371 /* Cause frame titles to update--necessary if we now have just one frame. */
1372 update_mode_lines = 1;
1374 return Qnil;
1377 /* Return mouse position in character cell units. */
1379 DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0,
1380 doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1381 The position is given in character cells, where (0, 0) is the
1382 upper-left corner.
1383 If Emacs is running on a mouseless terminal or hasn't been programmed
1384 to read the mouse position, it returns the selected frame for FRAME
1385 and nil for X and Y.
1386 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1387 passing the normal return value to that function as an argument,
1388 and returns whatever that function returns. */)
1391 FRAME_PTR f;
1392 Lisp_Object lispy_dummy;
1393 enum scroll_bar_part party_dummy;
1394 Lisp_Object x, y, retval;
1395 int col, row;
1396 unsigned long long_dummy;
1397 struct gcpro gcpro1;
1399 f = SELECTED_FRAME ();
1400 x = y = Qnil;
1402 #ifdef HAVE_MOUSE
1403 /* It's okay for the hook to refrain from storing anything. */
1404 if (mouse_position_hook)
1405 (*mouse_position_hook) (&f, -1,
1406 &lispy_dummy, &party_dummy,
1407 &x, &y,
1408 &long_dummy);
1409 if (! NILP (x))
1411 col = XINT (x);
1412 row = XINT (y);
1413 pixel_to_glyph_coords (f, col, row, &col, &row, NULL, 1);
1414 XSETINT (x, col);
1415 XSETINT (y, row);
1417 #endif
1418 XSETFRAME (lispy_dummy, f);
1419 retval = Fcons (lispy_dummy, Fcons (x, y));
1420 GCPRO1 (retval);
1421 if (!NILP (Vmouse_position_function))
1422 retval = call1 (Vmouse_position_function, retval);
1423 RETURN_UNGCPRO (retval);
1426 DEFUN ("mouse-pixel-position", Fmouse_pixel_position,
1427 Smouse_pixel_position, 0, 0, 0,
1428 doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1429 The position is given in pixel units, where (0, 0) is the
1430 upper-left corner.
1431 If Emacs is running on a mouseless terminal or hasn't been programmed
1432 to read the mouse position, it returns the selected frame for FRAME
1433 and nil for X and Y. */)
1436 FRAME_PTR f;
1437 Lisp_Object lispy_dummy;
1438 enum scroll_bar_part party_dummy;
1439 Lisp_Object x, y;
1440 unsigned long long_dummy;
1442 f = SELECTED_FRAME ();
1443 x = y = Qnil;
1445 #ifdef HAVE_MOUSE
1446 /* It's okay for the hook to refrain from storing anything. */
1447 if (mouse_position_hook)
1448 (*mouse_position_hook) (&f, -1,
1449 &lispy_dummy, &party_dummy,
1450 &x, &y,
1451 &long_dummy);
1452 #endif
1453 XSETFRAME (lispy_dummy, f);
1454 return Fcons (lispy_dummy, Fcons (x, y));
1457 DEFUN ("set-mouse-position", Fset_mouse_position, Sset_mouse_position, 3, 3, 0,
1458 doc: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1459 Coordinates are relative to the frame, not a window,
1460 so the coordinates of the top left character in the frame
1461 may be nonzero due to left-hand scroll bars or the menu bar.
1463 This function is a no-op for an X frame that is not visible.
1464 If you have just created a frame, you must wait for it to become visible
1465 before calling this function on it, like this.
1466 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1467 (frame, x, y)
1468 Lisp_Object frame, x, y;
1470 CHECK_LIVE_FRAME (frame);
1471 CHECK_NUMBER (x);
1472 CHECK_NUMBER (y);
1474 /* I think this should be done with a hook. */
1475 #ifdef HAVE_WINDOW_SYSTEM
1476 if (FRAME_WINDOW_P (XFRAME (frame)))
1477 /* Warping the mouse will cause enternotify and focus events. */
1478 x_set_mouse_position (XFRAME (frame), XINT (x), XINT (y));
1479 #else
1480 #if defined (MSDOS) && defined (HAVE_MOUSE)
1481 if (FRAME_MSDOS_P (XFRAME (frame)))
1483 Fselect_frame (frame, Qnil);
1484 mouse_moveto (XINT (x), XINT (y));
1486 #endif
1487 #endif
1489 return Qnil;
1492 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position,
1493 Sset_mouse_pixel_position, 3, 3, 0,
1494 doc: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1495 Note, this is a no-op for an X frame that is not visible.
1496 If you have just created a frame, you must wait for it to become visible
1497 before calling this function on it, like this.
1498 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1499 (frame, x, y)
1500 Lisp_Object frame, x, y;
1502 CHECK_LIVE_FRAME (frame);
1503 CHECK_NUMBER (x);
1504 CHECK_NUMBER (y);
1506 /* I think this should be done with a hook. */
1507 #ifdef HAVE_WINDOW_SYSTEM
1508 if (FRAME_WINDOW_P (XFRAME (frame)))
1509 /* Warping the mouse will cause enternotify and focus events. */
1510 x_set_mouse_pixel_position (XFRAME (frame), XINT (x), XINT (y));
1511 #else
1512 #if defined (MSDOS) && defined (HAVE_MOUSE)
1513 if (FRAME_MSDOS_P (XFRAME (frame)))
1515 Fselect_frame (frame, Qnil);
1516 mouse_moveto (XINT (x), XINT (y));
1518 #endif
1519 #endif
1521 return Qnil;
1524 static void make_frame_visible_1 P_ ((Lisp_Object));
1526 DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
1527 0, 1, "",
1528 doc: /* Make the frame FRAME visible (assuming it is an X window).
1529 If omitted, FRAME defaults to the currently selected frame. */)
1530 (frame)
1531 Lisp_Object frame;
1533 if (NILP (frame))
1534 frame = selected_frame;
1536 CHECK_LIVE_FRAME (frame);
1538 /* I think this should be done with a hook. */
1539 #ifdef HAVE_WINDOW_SYSTEM
1540 if (FRAME_WINDOW_P (XFRAME (frame)))
1542 FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
1543 x_make_frame_visible (XFRAME (frame));
1545 #endif
1547 make_frame_visible_1 (XFRAME (frame)->root_window);
1549 /* Make menu bar update for the Buffers and Frames menus. */
1550 windows_or_buffers_changed++;
1552 return frame;
1555 /* Update the display_time slot of the buffers shown in WINDOW
1556 and all its descendents. */
1558 static void
1559 make_frame_visible_1 (window)
1560 Lisp_Object window;
1562 struct window *w;
1564 for (;!NILP (window); window = w->next)
1566 w = XWINDOW (window);
1568 if (!NILP (w->buffer))
1569 XBUFFER (w->buffer)->display_time = Fcurrent_time ();
1571 if (!NILP (w->vchild))
1572 make_frame_visible_1 (w->vchild);
1573 if (!NILP (w->hchild))
1574 make_frame_visible_1 (w->hchild);
1578 DEFUN ("make-frame-invisible", Fmake_frame_invisible, Smake_frame_invisible,
1579 0, 2, "",
1580 doc: /* Make the frame FRAME invisible (assuming it is an X window).
1581 If omitted, FRAME defaults to the currently selected frame.
1582 Normally you may not make FRAME invisible if all other frames are invisible,
1583 but if the second optional argument FORCE is non-nil, you may do so. */)
1584 (frame, force)
1585 Lisp_Object frame, force;
1587 if (NILP (frame))
1588 frame = selected_frame;
1590 CHECK_LIVE_FRAME (frame);
1592 if (NILP (force) && !other_visible_frames (XFRAME (frame)))
1593 error ("Attempt to make invisible the sole visible or iconified frame");
1595 #if 0 /* This isn't logically necessary, and it can do GC. */
1596 /* Don't let the frame remain selected. */
1597 if (EQ (frame, selected_frame))
1598 do_switch_frame (next_frame (frame, Qt), 0, 0)
1599 #endif
1601 /* Don't allow minibuf_window to remain on a deleted frame. */
1602 if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window))
1604 struct frame *sf = XFRAME (selected_frame);
1605 Fset_window_buffer (sf->minibuffer_window,
1606 XWINDOW (minibuf_window)->buffer);
1607 minibuf_window = sf->minibuffer_window;
1610 /* I think this should be done with a hook. */
1611 #ifdef HAVE_WINDOW_SYSTEM
1612 if (FRAME_WINDOW_P (XFRAME (frame)))
1613 x_make_frame_invisible (XFRAME (frame));
1614 #endif
1616 /* Make menu bar update for the Buffers and Frames menus. */
1617 windows_or_buffers_changed++;
1619 return Qnil;
1622 DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame,
1623 0, 1, "",
1624 doc: /* Make the frame FRAME into an icon.
1625 If omitted, FRAME defaults to the currently selected frame. */)
1626 (frame)
1627 Lisp_Object frame;
1629 if (NILP (frame))
1630 frame = selected_frame;
1632 CHECK_LIVE_FRAME (frame);
1634 #if 0 /* This isn't logically necessary, and it can do GC. */
1635 /* Don't let the frame remain selected. */
1636 if (EQ (frame, selected_frame))
1637 Fhandle_switch_frame (next_frame (frame, Qt), Qnil);
1638 #endif
1640 /* Don't allow minibuf_window to remain on a deleted frame. */
1641 if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window))
1643 struct frame *sf = XFRAME (selected_frame);
1644 Fset_window_buffer (sf->minibuffer_window,
1645 XWINDOW (minibuf_window)->buffer);
1646 minibuf_window = sf->minibuffer_window;
1649 /* I think this should be done with a hook. */
1650 #ifdef HAVE_WINDOW_SYSTEM
1651 if (FRAME_WINDOW_P (XFRAME (frame)))
1652 x_iconify_frame (XFRAME (frame));
1653 #endif
1655 /* Make menu bar update for the Buffers and Frames menus. */
1656 windows_or_buffers_changed++;
1658 return Qnil;
1661 DEFUN ("frame-visible-p", Fframe_visible_p, Sframe_visible_p,
1662 1, 1, 0,
1663 doc: /* Return t if FRAME is now \"visible\" (actually in use for display).
1664 A frame that is not \"visible\" is not updated and, if it works through
1665 a window system, it may not show at all.
1666 Return the symbol `icon' if frame is visible only as an icon. */)
1667 (frame)
1668 Lisp_Object frame;
1670 CHECK_LIVE_FRAME (frame);
1672 FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
1674 if (FRAME_VISIBLE_P (XFRAME (frame)))
1675 return Qt;
1676 if (FRAME_ICONIFIED_P (XFRAME (frame)))
1677 return Qicon;
1678 return Qnil;
1681 DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list,
1682 0, 0, 0,
1683 doc: /* Return a list of all frames now \"visible\" (being updated). */)
1686 Lisp_Object tail, frame;
1687 struct frame *f;
1688 Lisp_Object value;
1690 value = Qnil;
1691 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
1693 frame = XCAR (tail);
1694 if (!FRAMEP (frame))
1695 continue;
1696 f = XFRAME (frame);
1697 if (FRAME_VISIBLE_P (f))
1698 value = Fcons (frame, value);
1700 return value;
1704 DEFUN ("raise-frame", Fraise_frame, Sraise_frame, 0, 1, "",
1705 doc: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1706 If FRAME is invisible, make it visible.
1707 If you don't specify a frame, the selected frame is used.
1708 If Emacs is displaying on an ordinary terminal or some other device which
1709 doesn't support multiple overlapping frames, this function does nothing. */)
1710 (frame)
1711 Lisp_Object frame;
1713 if (NILP (frame))
1714 frame = selected_frame;
1716 CHECK_LIVE_FRAME (frame);
1718 /* Do like the documentation says. */
1719 Fmake_frame_visible (frame);
1721 if (frame_raise_lower_hook)
1722 (*frame_raise_lower_hook) (XFRAME (frame), 1);
1724 return Qnil;
1727 /* Should we have a corresponding function called Flower_Power? */
1728 DEFUN ("lower-frame", Flower_frame, Slower_frame, 0, 1, "",
1729 doc: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
1730 If you don't specify a frame, the selected frame is used.
1731 If Emacs is displaying on an ordinary terminal or some other device which
1732 doesn't support multiple overlapping frames, this function does nothing. */)
1733 (frame)
1734 Lisp_Object frame;
1736 if (NILP (frame))
1737 frame = selected_frame;
1739 CHECK_LIVE_FRAME (frame);
1741 if (frame_raise_lower_hook)
1742 (*frame_raise_lower_hook) (XFRAME (frame), 0);
1744 return Qnil;
1748 DEFUN ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus,
1749 1, 2, 0,
1750 doc: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
1751 In other words, switch-frame events caused by events in FRAME will
1752 request a switch to FOCUS-FRAME, and `last-event-frame' will be
1753 FOCUS-FRAME after reading an event typed at FRAME.
1755 If FOCUS-FRAME is omitted or nil, any existing redirection is
1756 cancelled, and the frame again receives its own keystrokes.
1758 Focus redirection is useful for temporarily redirecting keystrokes to
1759 a surrogate minibuffer frame when a frame doesn't have its own
1760 minibuffer window.
1762 A frame's focus redirection can be changed by select-frame. If frame
1763 FOO is selected, and then a different frame BAR is selected, any
1764 frames redirecting their focus to FOO are shifted to redirect their
1765 focus to BAR. This allows focus redirection to work properly when the
1766 user switches from one frame to another using `select-window'.
1768 This means that a frame whose focus is redirected to itself is treated
1769 differently from a frame whose focus is redirected to nil; the former
1770 is affected by select-frame, while the latter is not.
1772 The redirection lasts until `redirect-frame-focus' is called to change it. */)
1773 (frame, focus_frame)
1774 Lisp_Object frame, focus_frame;
1776 /* Note that we don't check for a live frame here. It's reasonable
1777 to redirect the focus of a frame you're about to delete, if you
1778 know what other frame should receive those keystrokes. */
1779 CHECK_FRAME (frame);
1781 if (! NILP (focus_frame))
1782 CHECK_LIVE_FRAME (focus_frame);
1784 XFRAME (frame)->focus_frame = focus_frame;
1786 if (frame_rehighlight_hook)
1787 (*frame_rehighlight_hook) (XFRAME (frame));
1789 return Qnil;
1793 DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0,
1794 doc: /* Return the frame to which FRAME's keystrokes are currently being sent.
1795 This returns nil if FRAME's focus is not redirected.
1796 See `redirect-frame-focus'. */)
1797 (frame)
1798 Lisp_Object frame;
1800 CHECK_LIVE_FRAME (frame);
1802 return FRAME_FOCUS_FRAME (XFRAME (frame));
1807 /* Return the value of frame parameter PROP in frame FRAME. */
1809 Lisp_Object
1810 get_frame_param (frame, prop)
1811 register struct frame *frame;
1812 Lisp_Object prop;
1814 register Lisp_Object tem;
1816 tem = Fassq (prop, frame->param_alist);
1817 if (EQ (tem, Qnil))
1818 return tem;
1819 return Fcdr (tem);
1822 /* Return the buffer-predicate of the selected frame. */
1824 Lisp_Object
1825 frame_buffer_predicate (frame)
1826 Lisp_Object frame;
1828 return XFRAME (frame)->buffer_predicate;
1831 /* Return the buffer-list of the selected frame. */
1833 Lisp_Object
1834 frame_buffer_list (frame)
1835 Lisp_Object frame;
1837 return XFRAME (frame)->buffer_list;
1840 /* Set the buffer-list of the selected frame. */
1842 void
1843 set_frame_buffer_list (frame, list)
1844 Lisp_Object frame, list;
1846 XFRAME (frame)->buffer_list = list;
1849 /* Discard BUFFER from the buffer-list of each frame. */
1851 void
1852 frames_discard_buffer (buffer)
1853 Lisp_Object buffer;
1855 Lisp_Object frame, tail;
1857 FOR_EACH_FRAME (tail, frame)
1859 XFRAME (frame)->buffer_list
1860 = Fdelq (buffer, XFRAME (frame)->buffer_list);
1864 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
1865 If the alist already has an element for PROP, we change it. */
1867 void
1868 store_in_alist (alistptr, prop, val)
1869 Lisp_Object *alistptr, val;
1870 Lisp_Object prop;
1872 register Lisp_Object tem;
1874 tem = Fassq (prop, *alistptr);
1875 if (EQ (tem, Qnil))
1876 *alistptr = Fcons (Fcons (prop, val), *alistptr);
1877 else
1878 Fsetcdr (tem, val);
1881 static int
1882 frame_name_fnn_p (str, len)
1883 char *str;
1884 int len;
1886 if (len > 1 && str[0] == 'F')
1888 char *end_ptr;
1890 strtol (str + 1, &end_ptr, 10);
1892 if (end_ptr == str + len)
1893 return 1;
1895 return 0;
1898 /* Set the name of the terminal frame. Also used by MSDOS frames.
1899 Modeled after x_set_name which is used for WINDOW frames. */
1901 void
1902 set_term_frame_name (f, name)
1903 struct frame *f;
1904 Lisp_Object name;
1906 f->explicit_name = ! NILP (name);
1908 /* If NAME is nil, set the name to F<num>. */
1909 if (NILP (name))
1911 char namebuf[20];
1913 /* Check for no change needed in this very common case
1914 before we do any consing. */
1915 if (frame_name_fnn_p (SDATA (f->name),
1916 SBYTES (f->name)))
1917 return;
1919 terminal_frame_count++;
1920 sprintf (namebuf, "F%d", terminal_frame_count);
1921 name = build_string (namebuf);
1923 else
1925 CHECK_STRING (name);
1927 /* Don't change the name if it's already NAME. */
1928 if (! NILP (Fstring_equal (name, f->name)))
1929 return;
1931 /* Don't allow the user to set the frame name to F<num>, so it
1932 doesn't clash with the names we generate for terminal frames. */
1933 if (frame_name_fnn_p (SDATA (name), SBYTES (name)))
1934 error ("Frame names of the form F<num> are usurped by Emacs");
1937 f->name = name;
1938 update_mode_lines = 1;
1941 void
1942 store_frame_param (f, prop, val)
1943 struct frame *f;
1944 Lisp_Object prop, val;
1946 register Lisp_Object old_alist_elt;
1948 /* The buffer-alist parameter is stored in a special place and is
1949 not in the alist. */
1950 if (EQ (prop, Qbuffer_list))
1952 f->buffer_list = val;
1953 return;
1956 /* If PROP is a symbol which is supposed to have frame-local values,
1957 and it is set up based on this frame, switch to the global
1958 binding. That way, we can create or alter the frame-local binding
1959 without messing up the symbol's status. */
1960 if (SYMBOLP (prop))
1962 Lisp_Object valcontents;
1963 valcontents = SYMBOL_VALUE (prop);
1964 if ((BUFFER_LOCAL_VALUEP (valcontents)
1965 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
1966 && XBUFFER_LOCAL_VALUE (valcontents)->check_frame
1967 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents)->frame) == f)
1968 swap_in_global_binding (prop);
1971 #ifndef WINDOWSNT
1972 /* The tty color mode needs to be set before the frame's parameter
1973 alist is updated with the new value, because set_tty_color_mode
1974 wants to look at the old mode. */
1975 if (FRAME_TERMCAP_P (f) && EQ (prop, Qtty_color_mode))
1976 set_tty_color_mode (f, val);
1977 #endif
1979 /* Update the frame parameter alist. */
1980 old_alist_elt = Fassq (prop, f->param_alist);
1981 if (EQ (old_alist_elt, Qnil))
1982 f->param_alist = Fcons (Fcons (prop, val), f->param_alist);
1983 else
1984 Fsetcdr (old_alist_elt, val);
1986 /* Update some other special parameters in their special places
1987 in addition to the alist. */
1989 if (EQ (prop, Qbuffer_predicate))
1990 f->buffer_predicate = val;
1992 if (! FRAME_WINDOW_P (f))
1994 if (EQ (prop, Qmenu_bar_lines))
1995 set_menu_bar_lines (f, val, make_number (FRAME_MENU_BAR_LINES (f)));
1996 else if (EQ (prop, Qname))
1997 set_term_frame_name (f, val);
2000 if (EQ (prop, Qminibuffer) && WINDOWP (val))
2002 if (! MINI_WINDOW_P (XWINDOW (val)))
2003 error ("Surrogate minibuffer windows must be minibuffer windows.");
2005 if ((FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f))
2006 && !EQ (val, f->minibuffer_window))
2007 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2009 /* Install the chosen minibuffer window, with proper buffer. */
2010 f->minibuffer_window = val;
2014 DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0,
2015 doc: /* Return the parameters-alist of frame FRAME.
2016 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2017 The meaningful PARMs depend on the kind of frame.
2018 If FRAME is omitted, return information on the currently selected frame. */)
2019 (frame)
2020 Lisp_Object frame;
2022 Lisp_Object alist;
2023 FRAME_PTR f;
2024 int height, width;
2025 struct gcpro gcpro1;
2027 if (NILP (frame))
2028 frame = selected_frame;
2030 CHECK_FRAME (frame);
2031 f = XFRAME (frame);
2033 if (!FRAME_LIVE_P (f))
2034 return Qnil;
2036 alist = Fcopy_alist (f->param_alist);
2037 GCPRO1 (alist);
2039 if (!FRAME_WINDOW_P (f))
2041 int fg = FRAME_FOREGROUND_PIXEL (f);
2042 int bg = FRAME_BACKGROUND_PIXEL (f);
2043 Lisp_Object elt;
2045 /* If the frame's parameter alist says the colors are
2046 unspecified and reversed, take the frame's background pixel
2047 for foreground and vice versa. */
2048 elt = Fassq (Qforeground_color, alist);
2049 if (!NILP (elt) && CONSP (elt) && STRINGP (XCDR (elt)))
2051 if (strncmp (SDATA (XCDR (elt)),
2052 unspecified_bg,
2053 SCHARS (XCDR (elt))) == 0)
2054 store_in_alist (&alist, Qforeground_color, tty_color_name (f, bg));
2055 else if (strncmp (SDATA (XCDR (elt)),
2056 unspecified_fg,
2057 SCHARS (XCDR (elt))) == 0)
2058 store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg));
2060 else
2061 store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg));
2062 elt = Fassq (Qbackground_color, alist);
2063 if (!NILP (elt) && CONSP (elt) && STRINGP (XCDR (elt)))
2065 if (strncmp (SDATA (XCDR (elt)),
2066 unspecified_fg,
2067 SCHARS (XCDR (elt))) == 0)
2068 store_in_alist (&alist, Qbackground_color, tty_color_name (f, fg));
2069 else if (strncmp (SDATA (XCDR (elt)),
2070 unspecified_bg,
2071 SCHARS (XCDR (elt))) == 0)
2072 store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg));
2074 else
2075 store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg));
2076 store_in_alist (&alist, intern ("font"),
2077 build_string (FRAME_MSDOS_P (f)
2078 ? "ms-dos"
2079 : FRAME_W32_P (f) ? "w32term"
2080 :"tty"));
2082 store_in_alist (&alist, Qname, f->name);
2083 height = (FRAME_NEW_HEIGHT (f) ? FRAME_NEW_HEIGHT (f) : FRAME_HEIGHT (f));
2084 store_in_alist (&alist, Qheight, make_number (height));
2085 width = (FRAME_NEW_WIDTH (f) ? FRAME_NEW_WIDTH (f) : FRAME_WIDTH (f));
2086 store_in_alist (&alist, Qwidth, make_number (width));
2087 store_in_alist (&alist, Qmodeline, (FRAME_WANTS_MODELINE_P (f) ? Qt : Qnil));
2088 store_in_alist (&alist, Qminibuffer,
2089 (! FRAME_HAS_MINIBUF_P (f) ? Qnil
2090 : FRAME_MINIBUF_ONLY_P (f) ? Qonly
2091 : FRAME_MINIBUF_WINDOW (f)));
2092 store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil));
2093 store_in_alist (&alist, Qbuffer_list, frame_buffer_list (frame));
2095 /* I think this should be done with a hook. */
2096 #ifdef HAVE_WINDOW_SYSTEM
2097 if (FRAME_WINDOW_P (f))
2098 x_report_frame_params (f, &alist);
2099 else
2100 #endif
2102 /* This ought to be correct in f->param_alist for an X frame. */
2103 Lisp_Object lines;
2104 XSETFASTINT (lines, FRAME_MENU_BAR_LINES (f));
2105 store_in_alist (&alist, Qmenu_bar_lines, lines);
2108 UNGCPRO;
2109 return alist;
2113 DEFUN ("frame-parameter", Fframe_parameter, Sframe_parameter, 2, 2, 0,
2114 doc: /* Return FRAME's value for parameter PARAMETER.
2115 If FRAME is nil, describe the currently selected frame. */)
2116 (frame, parameter)
2117 Lisp_Object frame, parameter;
2119 struct frame *f;
2120 Lisp_Object value;
2122 if (NILP (frame))
2123 frame = selected_frame;
2124 else
2125 CHECK_FRAME (frame);
2126 CHECK_SYMBOL (parameter);
2128 f = XFRAME (frame);
2129 value = Qnil;
2131 if (FRAME_LIVE_P (f))
2133 /* Avoid consing in frequent cases. */
2134 if (EQ (parameter, Qname))
2135 value = f->name;
2136 #ifdef HAVE_X_WINDOWS
2137 else if (EQ (parameter, Qdisplay) && FRAME_X_P (f))
2138 value = XCAR (FRAME_X_DISPLAY_INFO (f)->name_list_element);
2139 #endif /* HAVE_X_WINDOWS */
2140 else if (EQ (parameter, Qbackground_color)
2141 || EQ (parameter, Qforeground_color))
2143 value = Fassq (parameter, f->param_alist);
2144 if (CONSP (value))
2146 value = XCDR (value);
2147 /* Fframe_parameters puts the actual fg/bg color names,
2148 even if f->param_alist says otherwise. This is
2149 important when param_alist's notion of colors is
2150 "unspecified". We need to do the same here. */
2151 if (STRINGP (value) && !FRAME_WINDOW_P (f))
2153 const char *color_name;
2154 EMACS_INT csz;
2156 if (EQ (parameter, Qbackground_color))
2158 color_name = SDATA (value);
2159 csz = SCHARS (value);
2160 if (strncmp (color_name, unspecified_bg, csz) == 0)
2161 value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f));
2162 else if (strncmp (color_name, unspecified_fg, csz) == 0)
2163 value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f));
2165 else if (EQ (parameter, Qforeground_color))
2167 color_name = SDATA (value);
2168 csz = SCHARS (value);
2169 if (strncmp (color_name, unspecified_fg, csz) == 0)
2170 value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f));
2171 else if (strncmp (color_name, unspecified_bg, csz) == 0)
2172 value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f));
2176 else
2177 value = Fcdr (Fassq (parameter, Fframe_parameters (frame)));
2179 else if (EQ (parameter, Qdisplay_type)
2180 || EQ (parameter, Qbackground_mode))
2181 value = Fcdr (Fassq (parameter, f->param_alist));
2182 else
2183 value = Fcdr (Fassq (parameter, Fframe_parameters (frame)));
2186 return value;
2190 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters,
2191 Smodify_frame_parameters, 2, 2, 0,
2192 doc: /* Modify the parameters of frame FRAME according to ALIST.
2193 If FRAME is nil, it defaults to the selected frame.
2194 ALIST is an alist of parameters to change and their new values.
2195 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2196 The meaningful PARMs depend on the kind of frame.
2197 Undefined PARMs are ignored, but stored in the frame's parameter list
2198 so that `frame-parameters' will return them.
2200 The value of frame parameter FOO can also be accessed
2201 as a frame-local binding for the variable FOO, if you have
2202 enabled such bindings for that variable with `make-variable-frame-local'. */)
2203 (frame, alist)
2204 Lisp_Object frame, alist;
2206 FRAME_PTR f;
2207 register Lisp_Object tail, prop, val;
2208 int count = SPECPDL_INDEX ();
2210 /* Bind this to t to inhibit initialization of the default face from
2211 X resources in face-set-after-frame-default. If we don't inhibit
2212 this, modifying the `font' frame parameter, for example, while
2213 there is a `default.attributeFont' X resource, won't work,
2214 because `default's font is reset to the value of the X resource
2215 and that resets the `font' frame parameter. */
2216 specbind (Qinhibit_default_face_x_resources, Qt);
2218 if (EQ (frame, Qnil))
2219 frame = selected_frame;
2220 CHECK_LIVE_FRAME (frame);
2221 f = XFRAME (frame);
2223 /* I think this should be done with a hook. */
2224 #ifdef HAVE_WINDOW_SYSTEM
2225 if (FRAME_WINDOW_P (f))
2226 x_set_frame_parameters (f, alist);
2227 else
2228 #endif
2229 #ifdef MSDOS
2230 if (FRAME_MSDOS_P (f))
2231 IT_set_frame_parameters (f, alist);
2232 else
2233 #endif
2236 int length = XINT (Flength (alist));
2237 int i;
2238 Lisp_Object *parms
2239 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
2240 Lisp_Object *values
2241 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
2243 /* Extract parm names and values into those vectors. */
2245 i = 0;
2246 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
2248 Lisp_Object elt;
2250 elt = Fcar (tail);
2251 parms[i] = Fcar (elt);
2252 values[i] = Fcdr (elt);
2253 i++;
2256 /* Now process them in reverse of specified order. */
2257 for (i--; i >= 0; i--)
2259 prop = parms[i];
2260 val = values[i];
2261 store_frame_param (f, prop, val);
2265 return unbind_to (count, Qnil);
2268 DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
2269 0, 1, 0,
2270 doc: /* Height in pixels of a line in the font in frame FRAME.
2271 If FRAME is omitted, the selected frame is used.
2272 For a terminal frame, the value is always 1. */)
2273 (frame)
2274 Lisp_Object frame;
2276 struct frame *f;
2278 if (NILP (frame))
2279 frame = selected_frame;
2280 CHECK_FRAME (frame);
2281 f = XFRAME (frame);
2283 #ifdef HAVE_WINDOW_SYSTEM
2284 if (FRAME_WINDOW_P (f))
2285 return make_number (x_char_height (f));
2286 else
2287 #endif
2288 return make_number (1);
2292 DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
2293 0, 1, 0,
2294 doc: /* Width in pixels of characters in the font in frame FRAME.
2295 If FRAME is omitted, the selected frame is used.
2296 The width is the same for all characters, because
2297 currently Emacs supports only fixed-width fonts.
2298 For a terminal screen, the value is always 1. */)
2299 (frame)
2300 Lisp_Object frame;
2302 struct frame *f;
2304 if (NILP (frame))
2305 frame = selected_frame;
2306 CHECK_FRAME (frame);
2307 f = XFRAME (frame);
2309 #ifdef HAVE_WINDOW_SYSTEM
2310 if (FRAME_WINDOW_P (f))
2311 return make_number (x_char_width (f));
2312 else
2313 #endif
2314 return make_number (1);
2317 DEFUN ("frame-pixel-height", Fframe_pixel_height,
2318 Sframe_pixel_height, 0, 1, 0,
2319 doc: /* Return a FRAME's height in pixels.
2320 This counts only the height available for text lines,
2321 not menu bars on window-system Emacs frames.
2322 For a terminal frame, the result really gives the height in characters.
2323 If FRAME is omitted, the selected frame is used. */)
2324 (frame)
2325 Lisp_Object frame;
2327 struct frame *f;
2329 if (NILP (frame))
2330 frame = selected_frame;
2331 CHECK_FRAME (frame);
2332 f = XFRAME (frame);
2334 #ifdef HAVE_WINDOW_SYSTEM
2335 if (FRAME_WINDOW_P (f))
2336 return make_number (x_pixel_height (f));
2337 else
2338 #endif
2339 return make_number (FRAME_HEIGHT (f));
2342 DEFUN ("frame-pixel-width", Fframe_pixel_width,
2343 Sframe_pixel_width, 0, 1, 0,
2344 doc: /* Return FRAME's width in pixels.
2345 For a terminal frame, the result really gives the width in characters.
2346 If FRAME is omitted, the selected frame is used. */)
2347 (frame)
2348 Lisp_Object frame;
2350 struct frame *f;
2352 if (NILP (frame))
2353 frame = selected_frame;
2354 CHECK_FRAME (frame);
2355 f = XFRAME (frame);
2357 #ifdef HAVE_WINDOW_SYSTEM
2358 if (FRAME_WINDOW_P (f))
2359 return make_number (x_pixel_width (f));
2360 else
2361 #endif
2362 return make_number (FRAME_WIDTH (f));
2365 DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
2366 doc: /* Specify that the frame FRAME has LINES lines.
2367 Optional third arg non-nil means that redisplay should use LINES lines
2368 but that the idea of the actual height of the frame should not be changed. */)
2369 (frame, lines, pretend)
2370 Lisp_Object frame, lines, pretend;
2372 register struct frame *f;
2374 CHECK_NUMBER (lines);
2375 if (NILP (frame))
2376 frame = selected_frame;
2377 CHECK_LIVE_FRAME (frame);
2378 f = XFRAME (frame);
2380 /* I think this should be done with a hook. */
2381 #ifdef HAVE_WINDOW_SYSTEM
2382 if (FRAME_WINDOW_P (f))
2384 if (XINT (lines) != f->height)
2385 x_set_window_size (f, 1, f->width, XINT (lines));
2386 do_pending_window_change (0);
2388 else
2389 #endif
2390 change_frame_size (f, XINT (lines), 0, !NILP (pretend), 0, 0);
2391 return Qnil;
2394 DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 3, 0,
2395 doc: /* Specify that the frame FRAME has COLS columns.
2396 Optional third arg non-nil means that redisplay should use COLS columns
2397 but that the idea of the actual width of the frame should not be changed. */)
2398 (frame, cols, pretend)
2399 Lisp_Object frame, cols, pretend;
2401 register struct frame *f;
2402 CHECK_NUMBER (cols);
2403 if (NILP (frame))
2404 frame = selected_frame;
2405 CHECK_LIVE_FRAME (frame);
2406 f = XFRAME (frame);
2408 /* I think this should be done with a hook. */
2409 #ifdef HAVE_WINDOW_SYSTEM
2410 if (FRAME_WINDOW_P (f))
2412 if (XINT (cols) != f->width)
2413 x_set_window_size (f, 1, XINT (cols), f->height);
2414 do_pending_window_change (0);
2416 else
2417 #endif
2418 change_frame_size (f, 0, XINT (cols), !NILP (pretend), 0, 0);
2419 return Qnil;
2422 DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0,
2423 doc: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2424 (frame, cols, rows)
2425 Lisp_Object frame, cols, rows;
2427 register struct frame *f;
2429 CHECK_LIVE_FRAME (frame);
2430 CHECK_NUMBER (cols);
2431 CHECK_NUMBER (rows);
2432 f = XFRAME (frame);
2434 /* I think this should be done with a hook. */
2435 #ifdef HAVE_WINDOW_SYSTEM
2436 if (FRAME_WINDOW_P (f))
2438 if (XINT (rows) != f->height || XINT (cols) != f->width
2439 || FRAME_NEW_HEIGHT (f) || FRAME_NEW_WIDTH (f))
2440 x_set_window_size (f, 1, XINT (cols), XINT (rows));
2441 do_pending_window_change (0);
2443 else
2444 #endif
2445 change_frame_size (f, XINT (rows), XINT (cols), 0, 0, 0);
2447 return Qnil;
2450 DEFUN ("set-frame-position", Fset_frame_position,
2451 Sset_frame_position, 3, 3, 0,
2452 doc: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2453 This is actually the position of the upper left corner of the frame.
2454 Negative values for XOFFSET or YOFFSET are interpreted relative to
2455 the rightmost or bottommost possible position (that stays within the screen). */)
2456 (frame, xoffset, yoffset)
2457 Lisp_Object frame, xoffset, yoffset;
2459 register struct frame *f;
2461 CHECK_LIVE_FRAME (frame);
2462 CHECK_NUMBER (xoffset);
2463 CHECK_NUMBER (yoffset);
2464 f = XFRAME (frame);
2466 /* I think this should be done with a hook. */
2467 #ifdef HAVE_WINDOW_SYSTEM
2468 if (FRAME_WINDOW_P (f))
2469 x_set_offset (f, XINT (xoffset), XINT (yoffset), 1);
2470 #endif
2472 return Qt;
2476 /***********************************************************************
2477 Frame Parameters
2478 ***********************************************************************/
2480 /* Connect the frame-parameter names for X frames
2481 to the ways of passing the parameter values to the window system.
2483 The name of a parameter, as a Lisp symbol,
2484 has an `x-frame-parameter' property which is an integer in Lisp
2485 that is an index in this table. */
2487 struct frame_parm_table {
2488 char *name;
2489 Lisp_Object *variable;
2492 static struct frame_parm_table frame_parms[] =
2494 {"auto-raise", &Qauto_raise},
2495 {"auto-lower", &Qauto_lower},
2496 {"background-color", 0},
2497 {"border-color", &Qborder_color},
2498 {"border-width", &Qborder_width},
2499 {"cursor-color", &Qcursor_color},
2500 {"cursor-type", &Qcursor_type},
2501 {"font", 0},
2502 {"foreground-color", 0},
2503 {"icon-name", &Qicon_name},
2504 {"icon-type", &Qicon_type},
2505 {"internal-border-width", &Qinternal_border_width},
2506 {"menu-bar-lines", &Qmenu_bar_lines},
2507 {"mouse-color", &Qmouse_color},
2508 {"name", &Qname},
2509 {"scroll-bar-width", &Qscroll_bar_width},
2510 {"title", &Qtitle},
2511 {"unsplittable", &Qunsplittable},
2512 {"vertical-scroll-bars", &Qvertical_scroll_bars},
2513 {"visibility", &Qvisibility},
2514 {"tool-bar-lines", &Qtool_bar_lines},
2515 {"scroll-bar-foreground", &Qscroll_bar_foreground},
2516 {"scroll-bar-background", &Qscroll_bar_background},
2517 {"screen-gamma", &Qscreen_gamma},
2518 {"line-spacing", &Qline_spacing},
2519 {"left-fringe", &Qleft_fringe},
2520 {"right-fringe", &Qright_fringe},
2521 {"wait-for-wm", &Qwait_for_wm},
2522 {"fullscreen", &Qfullscreen},
2525 #ifdef HAVE_WINDOW_SYSTEM
2527 extern Lisp_Object Qbox;
2528 extern Lisp_Object Qtop;
2530 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2531 wanted positions of the WM window (not emacs window).
2532 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2533 window (FRAME_X_WINDOW).
2536 void
2537 x_fullscreen_adjust (f, width, height, top_pos, left_pos)
2538 struct frame *f;
2539 int *width;
2540 int *height;
2541 int *top_pos;
2542 int *left_pos;
2544 int newwidth = f->width, newheight = f->height;
2546 *top_pos = FRAME_X_OUTPUT (f)->top_pos;
2547 *left_pos = FRAME_X_OUTPUT (f)->left_pos;
2549 if (FRAME_X_OUTPUT (f)->want_fullscreen & FULLSCREEN_HEIGHT)
2551 int ph;
2553 ph = FRAME_X_DISPLAY_INFO (f)->height;
2554 newheight = PIXEL_TO_CHAR_HEIGHT (f, ph);
2555 ph = CHAR_TO_PIXEL_HEIGHT (f, newheight)
2556 - FRAME_X_OUTPUT (f)->y_pixels_diff;
2557 newheight = PIXEL_TO_CHAR_HEIGHT (f, ph);
2558 *top_pos = 0;
2561 if (FRAME_X_OUTPUT (f)->want_fullscreen & FULLSCREEN_WIDTH)
2563 int pw;
2565 pw = FRAME_X_DISPLAY_INFO (f)->width;
2566 newwidth = PIXEL_TO_CHAR_WIDTH (f, pw);
2567 pw = CHAR_TO_PIXEL_WIDTH (f, newwidth)
2568 - FRAME_X_OUTPUT (f)->x_pixels_diff;
2569 newwidth = PIXEL_TO_CHAR_WIDTH (f, pw);
2570 *left_pos = 0;
2573 *width = newwidth;
2574 *height = newheight;
2578 /* Really try to move where we want to be in case of fullscreen. Some WMs
2579 moves the window where we tell them. Some (mwm, twm) moves the outer
2580 window manager window there instead.
2581 Try to compensate for those WM here. */
2583 static void
2584 x_fullscreen_move (f, new_top, new_left)
2585 struct frame *f;
2586 int new_top;
2587 int new_left;
2589 if (new_top != FRAME_X_OUTPUT (f)->top_pos
2590 || new_left != FRAME_X_OUTPUT (f)->left_pos)
2592 int move_x = new_left;
2593 int move_y = new_top;
2595 #ifdef HAVE_X_WINDOWS
2596 move_x += FRAME_X_OUTPUT (f)->x_pixels_outer_diff;
2597 move_y += FRAME_X_OUTPUT (f)->y_pixels_outer_diff;
2598 #endif
2600 FRAME_X_OUTPUT (f)->want_fullscreen |= FULLSCREEN_MOVE_WAIT;
2601 x_set_offset (f, move_x, move_y, 1);
2605 /* Change the parameters of frame F as specified by ALIST.
2606 If a parameter is not specially recognized, do nothing special;
2607 otherwise call the `x_set_...' function for that parameter.
2608 Except for certain geometry properties, always call store_frame_param
2609 to store the new value in the parameter alist. */
2611 void
2612 x_set_frame_parameters (f, alist)
2613 FRAME_PTR f;
2614 Lisp_Object alist;
2616 Lisp_Object tail;
2618 /* If both of these parameters are present, it's more efficient to
2619 set them both at once. So we wait until we've looked at the
2620 entire list before we set them. */
2621 int width, height;
2623 /* Same here. */
2624 Lisp_Object left, top;
2626 /* Same with these. */
2627 Lisp_Object icon_left, icon_top;
2629 /* Record in these vectors all the parms specified. */
2630 Lisp_Object *parms;
2631 Lisp_Object *values;
2632 int i, p;
2633 int left_no_change = 0, top_no_change = 0;
2634 int icon_left_no_change = 0, icon_top_no_change = 0;
2635 int fullscreen_is_being_set = 0;
2637 struct gcpro gcpro1, gcpro2;
2639 i = 0;
2640 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
2641 i++;
2643 parms = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
2644 values = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
2646 /* Extract parm names and values into those vectors. */
2648 i = 0;
2649 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
2651 Lisp_Object elt;
2653 elt = Fcar (tail);
2654 parms[i] = Fcar (elt);
2655 values[i] = Fcdr (elt);
2656 i++;
2658 /* TAIL and ALIST are not used again below here. */
2659 alist = tail = Qnil;
2661 GCPRO2 (*parms, *values);
2662 gcpro1.nvars = i;
2663 gcpro2.nvars = i;
2665 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2666 because their values appear in VALUES and strings are not valid. */
2667 top = left = Qunbound;
2668 icon_left = icon_top = Qunbound;
2670 /* Provide default values for HEIGHT and WIDTH. */
2671 if (FRAME_NEW_WIDTH (f))
2672 width = FRAME_NEW_WIDTH (f);
2673 else
2674 width = FRAME_WIDTH (f);
2676 if (FRAME_NEW_HEIGHT (f))
2677 height = FRAME_NEW_HEIGHT (f);
2678 else
2679 height = FRAME_HEIGHT (f);
2681 /* Process foreground_color and background_color before anything else.
2682 They are independent of other properties, but other properties (e.g.,
2683 cursor_color) are dependent upon them. */
2684 /* Process default font as well, since fringe widths depends on it. */
2685 /* Also, process fullscreen, width and height depend upon that */
2686 for (p = 0; p < i; p++)
2688 Lisp_Object prop, val;
2690 prop = parms[p];
2691 val = values[p];
2692 if (EQ (prop, Qforeground_color)
2693 || EQ (prop, Qbackground_color)
2694 || EQ (prop, Qfont)
2695 || EQ (prop, Qfullscreen))
2697 register Lisp_Object param_index, old_value;
2699 old_value = get_frame_param (f, prop);
2700 fullscreen_is_being_set |= EQ (prop, Qfullscreen);
2702 if (NILP (Fequal (val, old_value)))
2704 store_frame_param (f, prop, val);
2706 param_index = Fget (prop, Qx_frame_parameter);
2707 if (NATNUMP (param_index)
2708 && (XFASTINT (param_index)
2709 < sizeof (frame_parms)/sizeof (frame_parms[0]))
2710 && rif->frame_parm_handlers[XINT (param_index)])
2711 (*(rif->frame_parm_handlers[XINT (param_index)])) (f, val, old_value);
2716 /* Now process them in reverse of specified order. */
2717 for (i--; i >= 0; i--)
2719 Lisp_Object prop, val;
2721 prop = parms[i];
2722 val = values[i];
2724 if (EQ (prop, Qwidth) && NUMBERP (val))
2725 width = XFASTINT (val);
2726 else if (EQ (prop, Qheight) && NUMBERP (val))
2727 height = XFASTINT (val);
2728 else if (EQ (prop, Qtop))
2729 top = val;
2730 else if (EQ (prop, Qleft))
2731 left = val;
2732 else if (EQ (prop, Qicon_top))
2733 icon_top = val;
2734 else if (EQ (prop, Qicon_left))
2735 icon_left = val;
2736 else if (EQ (prop, Qforeground_color)
2737 || EQ (prop, Qbackground_color)
2738 || EQ (prop, Qfont)
2739 || EQ (prop, Qfullscreen))
2740 /* Processed above. */
2741 continue;
2742 else
2744 register Lisp_Object param_index, old_value;
2746 old_value = get_frame_param (f, prop);
2748 store_frame_param (f, prop, val);
2750 param_index = Fget (prop, Qx_frame_parameter);
2751 if (NATNUMP (param_index)
2752 && (XFASTINT (param_index)
2753 < sizeof (frame_parms)/sizeof (frame_parms[0]))
2754 && rif->frame_parm_handlers[XINT (param_index)])
2755 (*(rif->frame_parm_handlers[XINT (param_index)])) (f, val, old_value);
2759 /* Don't die if just one of these was set. */
2760 if (EQ (left, Qunbound))
2762 left_no_change = 1;
2763 if (FRAME_X_OUTPUT (f)->left_pos < 0)
2764 left = Fcons (Qplus, Fcons (make_number (FRAME_X_OUTPUT (f)->left_pos), Qnil));
2765 else
2766 XSETINT (left, FRAME_X_OUTPUT (f)->left_pos);
2768 if (EQ (top, Qunbound))
2770 top_no_change = 1;
2771 if (FRAME_X_OUTPUT (f)->top_pos < 0)
2772 top = Fcons (Qplus, Fcons (make_number (FRAME_X_OUTPUT (f)->top_pos), Qnil));
2773 else
2774 XSETINT (top, FRAME_X_OUTPUT (f)->top_pos);
2777 /* If one of the icon positions was not set, preserve or default it. */
2778 if (EQ (icon_left, Qunbound) || ! INTEGERP (icon_left))
2780 icon_left_no_change = 1;
2781 icon_left = Fcdr (Fassq (Qicon_left, f->param_alist));
2782 if (NILP (icon_left))
2783 XSETINT (icon_left, 0);
2785 if (EQ (icon_top, Qunbound) || ! INTEGERP (icon_top))
2787 icon_top_no_change = 1;
2788 icon_top = Fcdr (Fassq (Qicon_top, f->param_alist));
2789 if (NILP (icon_top))
2790 XSETINT (icon_top, 0);
2793 #ifndef HAVE_CARBON
2794 /* MAC_TODO: fullscreen */
2795 if (FRAME_VISIBLE_P (f) && fullscreen_is_being_set)
2797 /* If the frame is visible already and the fullscreen parameter is
2798 being set, it is too late to set WM manager hints to specify
2799 size and position.
2800 Here we first get the width, height and position that applies to
2801 fullscreen. We then move the frame to the appropriate
2802 position. Resize of the frame is taken care of in the code after
2803 this if-statement. */
2804 int new_left, new_top;
2806 x_fullscreen_adjust (f, &width, &height, &new_top, &new_left);
2807 x_fullscreen_move (f, new_top, new_left);
2809 #endif
2811 /* Don't set these parameters unless they've been explicitly
2812 specified. The window might be mapped or resized while we're in
2813 this function, and we don't want to override that unless the lisp
2814 code has asked for it.
2816 Don't set these parameters unless they actually differ from the
2817 window's current parameters; the window may not actually exist
2818 yet. */
2820 Lisp_Object frame;
2822 check_frame_size (f, &height, &width);
2824 XSETFRAME (frame, f);
2826 if (width != FRAME_WIDTH (f)
2827 || height != FRAME_HEIGHT (f)
2828 || FRAME_NEW_HEIGHT (f) || FRAME_NEW_WIDTH (f))
2829 Fset_frame_size (frame, make_number (width), make_number (height));
2831 if ((!NILP (left) || !NILP (top))
2832 && ! (left_no_change && top_no_change)
2833 && ! (NUMBERP (left) && XINT (left) == FRAME_X_OUTPUT (f)->left_pos
2834 && NUMBERP (top) && XINT (top) == FRAME_X_OUTPUT (f)->top_pos))
2836 int leftpos = 0;
2837 int toppos = 0;
2839 /* Record the signs. */
2840 FRAME_X_OUTPUT (f)->size_hint_flags &= ~ (XNegative | YNegative);
2841 if (EQ (left, Qminus))
2842 FRAME_X_OUTPUT (f)->size_hint_flags |= XNegative;
2843 else if (INTEGERP (left))
2845 leftpos = XINT (left);
2846 if (leftpos < 0)
2847 FRAME_X_OUTPUT (f)->size_hint_flags |= XNegative;
2849 else if (CONSP (left) && EQ (XCAR (left), Qminus)
2850 && CONSP (XCDR (left))
2851 && INTEGERP (XCAR (XCDR (left))))
2853 leftpos = - XINT (XCAR (XCDR (left)));
2854 FRAME_X_OUTPUT (f)->size_hint_flags |= XNegative;
2856 else if (CONSP (left) && EQ (XCAR (left), Qplus)
2857 && CONSP (XCDR (left))
2858 && INTEGERP (XCAR (XCDR (left))))
2860 leftpos = XINT (XCAR (XCDR (left)));
2863 if (EQ (top, Qminus))
2864 FRAME_X_OUTPUT (f)->size_hint_flags |= YNegative;
2865 else if (INTEGERP (top))
2867 toppos = XINT (top);
2868 if (toppos < 0)
2869 FRAME_X_OUTPUT (f)->size_hint_flags |= YNegative;
2871 else if (CONSP (top) && EQ (XCAR (top), Qminus)
2872 && CONSP (XCDR (top))
2873 && INTEGERP (XCAR (XCDR (top))))
2875 toppos = - XINT (XCAR (XCDR (top)));
2876 FRAME_X_OUTPUT (f)->size_hint_flags |= YNegative;
2878 else if (CONSP (top) && EQ (XCAR (top), Qplus)
2879 && CONSP (XCDR (top))
2880 && INTEGERP (XCAR (XCDR (top))))
2882 toppos = XINT (XCAR (XCDR (top)));
2886 /* Store the numeric value of the position. */
2887 FRAME_X_OUTPUT (f)->top_pos = toppos;
2888 FRAME_X_OUTPUT (f)->left_pos = leftpos;
2890 FRAME_X_OUTPUT (f)->win_gravity = NorthWestGravity;
2892 /* Actually set that position, and convert to absolute. */
2893 x_set_offset (f, leftpos, toppos, -1);
2896 if ((!NILP (icon_left) || !NILP (icon_top))
2897 && ! (icon_left_no_change && icon_top_no_change))
2898 x_wm_set_icon_position (f, XINT (icon_left), XINT (icon_top));
2901 UNGCPRO;
2905 /* Insert a description of internally-recorded parameters of frame X
2906 into the parameter alist *ALISTPTR that is to be given to the user.
2907 Only parameters that are specific to the X window system
2908 and whose values are not correctly recorded in the frame's
2909 param_alist need to be considered here. */
2911 void
2912 x_report_frame_params (f, alistptr)
2913 struct frame *f;
2914 Lisp_Object *alistptr;
2916 char buf[16];
2917 Lisp_Object tem;
2919 /* Represent negative positions (off the top or left screen edge)
2920 in a way that Fmodify_frame_parameters will understand correctly. */
2921 XSETINT (tem, FRAME_X_OUTPUT (f)->left_pos);
2922 if (FRAME_X_OUTPUT (f)->left_pos >= 0)
2923 store_in_alist (alistptr, Qleft, tem);
2924 else
2925 store_in_alist (alistptr, Qleft, Fcons (Qplus, Fcons (tem, Qnil)));
2927 XSETINT (tem, FRAME_X_OUTPUT (f)->top_pos);
2928 if (FRAME_X_OUTPUT (f)->top_pos >= 0)
2929 store_in_alist (alistptr, Qtop, tem);
2930 else
2931 store_in_alist (alistptr, Qtop, Fcons (Qplus, Fcons (tem, Qnil)));
2933 store_in_alist (alistptr, Qborder_width,
2934 make_number (FRAME_X_OUTPUT (f)->border_width));
2935 store_in_alist (alistptr, Qinternal_border_width,
2936 make_number (FRAME_X_OUTPUT (f)->internal_border_width));
2937 store_in_alist (alistptr, Qleft_fringe,
2938 make_number (FRAME_X_OUTPUT (f)->left_fringe_width));
2939 store_in_alist (alistptr, Qright_fringe,
2940 make_number (FRAME_X_OUTPUT (f)->right_fringe_width));
2941 store_in_alist (alistptr, Qscroll_bar_width,
2942 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f)
2943 ? make_number (0)
2944 : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0
2945 ? make_number (FRAME_SCROLL_BAR_PIXEL_WIDTH (f))
2946 /* nil means "use default width"
2947 for non-toolkit scroll bar.
2948 ruler-mode.el depends on this. */
2949 : Qnil));
2950 sprintf (buf, "%ld", (long) FRAME_X_WINDOW (f));
2951 store_in_alist (alistptr, Qwindow_id,
2952 build_string (buf));
2953 #ifdef HAVE_X_WINDOWS
2954 #ifdef USE_X_TOOLKIT
2955 /* Tooltip frame may not have this widget. */
2956 if (FRAME_X_OUTPUT (f)->widget)
2957 #endif
2958 sprintf (buf, "%ld", (long) FRAME_OUTER_WINDOW (f));
2959 store_in_alist (alistptr, Qouter_window_id,
2960 build_string (buf));
2961 #endif
2962 store_in_alist (alistptr, Qicon_name, f->icon_name);
2963 FRAME_SAMPLE_VISIBILITY (f);
2964 store_in_alist (alistptr, Qvisibility,
2965 (FRAME_VISIBLE_P (f) ? Qt
2966 : FRAME_ICONIFIED_P (f) ? Qicon : Qnil));
2967 store_in_alist (alistptr, Qdisplay,
2968 XCAR (FRAME_X_DISPLAY_INFO (f)->name_list_element));
2970 #ifndef HAVE_CARBON
2971 /* A Mac Window is identified by a struct, not an integer. */
2972 if (FRAME_X_OUTPUT (f)->parent_desc == FRAME_X_DISPLAY_INFO (f)->root_window)
2973 tem = Qnil;
2974 else
2975 XSETFASTINT (tem, FRAME_X_OUTPUT (f)->parent_desc);
2976 store_in_alist (alistptr, Qparent_id, tem);
2977 #endif
2981 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
2982 the previous value of that parameter, NEW_VALUE is the new value. */
2984 void
2985 x_set_fullscreen (f, new_value, old_value)
2986 struct frame *f;
2987 Lisp_Object new_value, old_value;
2989 #ifndef HAVE_CARBON
2990 if (NILP (new_value))
2991 FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_NONE;
2992 else if (EQ (new_value, Qfullboth))
2993 FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_BOTH;
2994 else if (EQ (new_value, Qfullwidth))
2995 FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_WIDTH;
2996 else if (EQ (new_value, Qfullheight))
2997 FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_HEIGHT;
2998 #endif
3002 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3003 the previous value of that parameter, NEW_VALUE is the new value. */
3005 void
3006 x_set_line_spacing (f, new_value, old_value)
3007 struct frame *f;
3008 Lisp_Object new_value, old_value;
3010 if (NILP (new_value))
3011 f->extra_line_spacing = 0;
3012 else if (NATNUMP (new_value))
3013 f->extra_line_spacing = XFASTINT (new_value);
3014 else
3015 Fsignal (Qerror, Fcons (build_string ("Invalid line-spacing"),
3016 Fcons (new_value, Qnil)));
3017 if (FRAME_VISIBLE_P (f))
3018 redraw_frame (f);
3022 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3023 the previous value of that parameter, NEW_VALUE is the new value. */
3025 void
3026 x_set_screen_gamma (f, new_value, old_value)
3027 struct frame *f;
3028 Lisp_Object new_value, old_value;
3030 if (NILP (new_value))
3031 f->gamma = 0;
3032 else if (NUMBERP (new_value) && XFLOATINT (new_value) > 0)
3033 /* The value 0.4545 is the normal viewing gamma. */
3034 f->gamma = 1.0 / (0.4545 * XFLOATINT (new_value));
3035 else
3036 Fsignal (Qerror, Fcons (build_string ("Invalid screen-gamma"),
3037 Fcons (new_value, Qnil)));
3039 clear_face_cache (0);
3043 void
3044 x_set_font (f, arg, oldval)
3045 struct frame *f;
3046 Lisp_Object arg, oldval;
3048 Lisp_Object result;
3049 Lisp_Object fontset_name;
3050 Lisp_Object frame;
3051 int old_fontset = FRAME_FONTSET(f);
3053 CHECK_STRING (arg);
3055 fontset_name = Fquery_fontset (arg, Qnil);
3057 BLOCK_INPUT;
3058 result = (STRINGP (fontset_name)
3059 ? x_new_fontset (f, SDATA (fontset_name))
3060 : x_new_font (f, SDATA (arg)));
3061 UNBLOCK_INPUT;
3063 if (EQ (result, Qnil))
3064 error ("Font `%s' is not defined", SDATA (arg));
3065 else if (EQ (result, Qt))
3066 error ("The characters of the given font have varying widths");
3067 else if (STRINGP (result))
3069 if (STRINGP (fontset_name))
3071 /* Fontset names are built from ASCII font names, so the
3072 names may be equal despite there was a change. */
3073 if (old_fontset == FRAME_FONTSET (f))
3074 return;
3076 else if (!NILP (Fequal (result, oldval)))
3077 return;
3079 store_frame_param (f, Qfont, result);
3080 recompute_basic_faces (f);
3082 else
3083 abort ();
3085 do_pending_window_change (0);
3087 /* Don't call `face-set-after-frame-default' when faces haven't been
3088 initialized yet. This is the case when called from
3089 Fx_create_frame. In that case, the X widget or window doesn't
3090 exist either, and we can end up in x_report_frame_params with a
3091 null widget which gives a segfault. */
3092 if (FRAME_FACE_CACHE (f))
3094 XSETFRAME (frame, f);
3095 call1 (Qface_set_after_frame_default, frame);
3100 void
3101 x_set_fringe_width (f, new_value, old_value)
3102 struct frame *f;
3103 Lisp_Object new_value, old_value;
3105 compute_fringe_widths (f, 1);
3108 void
3109 x_set_border_width (f, arg, oldval)
3110 struct frame *f;
3111 Lisp_Object arg, oldval;
3113 CHECK_NUMBER (arg);
3115 if (XINT (arg) == FRAME_X_OUTPUT (f)->border_width)
3116 return;
3118 #ifndef HAVE_CARBON
3119 if (FRAME_X_WINDOW (f) != 0)
3120 error ("Cannot change the border width of a window");
3121 #endif /* MAC_TODO */
3123 FRAME_X_OUTPUT (f)->border_width = XINT (arg);
3126 void
3127 x_set_internal_border_width (f, arg, oldval)
3128 struct frame *f;
3129 Lisp_Object arg, oldval;
3131 int old = FRAME_X_OUTPUT (f)->internal_border_width;
3133 CHECK_NUMBER (arg);
3134 FRAME_X_OUTPUT (f)->internal_border_width = XINT (arg);
3135 if (FRAME_X_OUTPUT (f)->internal_border_width < 0)
3136 FRAME_X_OUTPUT (f)->internal_border_width = 0;
3138 #ifdef USE_X_TOOLKIT
3139 if (FRAME_X_OUTPUT (f)->edit_widget)
3140 widget_store_internal_border (FRAME_X_OUTPUT (f)->edit_widget);
3141 #endif
3143 if (FRAME_X_OUTPUT (f)->internal_border_width == old)
3144 return;
3146 if (FRAME_X_WINDOW (f) != 0)
3148 x_set_window_size (f, 0, f->width, f->height);
3149 SET_FRAME_GARBAGED (f);
3150 do_pending_window_change (0);
3152 else
3153 SET_FRAME_GARBAGED (f);
3156 void
3157 x_set_visibility (f, value, oldval)
3158 struct frame *f;
3159 Lisp_Object value, oldval;
3161 Lisp_Object frame;
3162 XSETFRAME (frame, f);
3164 if (NILP (value))
3165 Fmake_frame_invisible (frame, Qt);
3166 else if (EQ (value, Qicon))
3167 Ficonify_frame (frame);
3168 else
3169 Fmake_frame_visible (frame);
3172 void
3173 x_set_autoraise (f, arg, oldval)
3174 struct frame *f;
3175 Lisp_Object arg, oldval;
3177 f->auto_raise = !EQ (Qnil, arg);
3180 void
3181 x_set_autolower (f, arg, oldval)
3182 struct frame *f;
3183 Lisp_Object arg, oldval;
3185 f->auto_lower = !EQ (Qnil, arg);
3188 void
3189 x_set_unsplittable (f, arg, oldval)
3190 struct frame *f;
3191 Lisp_Object arg, oldval;
3193 f->no_split = !NILP (arg);
3196 void
3197 x_set_vertical_scroll_bars (f, arg, oldval)
3198 struct frame *f;
3199 Lisp_Object arg, oldval;
3201 if ((EQ (arg, Qleft) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
3202 || (EQ (arg, Qright) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
3203 || (NILP (arg) && FRAME_HAS_VERTICAL_SCROLL_BARS (f))
3204 || (!NILP (arg) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f)))
3206 FRAME_VERTICAL_SCROLL_BAR_TYPE (f)
3207 = (NILP (arg)
3208 ? vertical_scroll_bar_none
3209 : EQ (Qleft, arg)
3210 ? vertical_scroll_bar_left
3211 : EQ (Qright, arg)
3212 ? vertical_scroll_bar_right
3213 #ifdef HAVE_NTGUI
3214 /* MS-Windows has scroll bars on the right by default. */
3215 : vertical_scroll_bar_right
3216 #else
3217 : vertical_scroll_bar_left
3218 #endif
3221 /* We set this parameter before creating the X window for the
3222 frame, so we can get the geometry right from the start.
3223 However, if the window hasn't been created yet, we shouldn't
3224 call x_set_window_size. */
3225 if (FRAME_X_WINDOW (f))
3226 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
3227 do_pending_window_change (0);
3231 void
3232 x_set_scroll_bar_width (f, arg, oldval)
3233 struct frame *f;
3234 Lisp_Object arg, oldval;
3236 int wid = FONT_WIDTH (FRAME_FONT (f));
3238 if (NILP (arg))
3240 x_set_scroll_bar_default_width (f);
3242 if (FRAME_X_WINDOW (f))
3243 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
3244 do_pending_window_change (0);
3246 else if (INTEGERP (arg) && XINT (arg) > 0
3247 && XFASTINT (arg) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f))
3249 if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM)
3250 XSETINT (arg, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM + 1);
3252 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = XFASTINT (arg);
3253 FRAME_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + wid-1) / wid;
3254 if (FRAME_X_WINDOW (f))
3255 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
3256 do_pending_window_change (0);
3259 change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0);
3260 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;
3261 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;
3266 /* Return non-nil if frame F wants a bitmap icon. */
3268 Lisp_Object
3269 x_icon_type (f)
3270 FRAME_PTR f;
3272 Lisp_Object tem;
3274 tem = assq_no_quit (Qicon_type, f->param_alist);
3275 if (CONSP (tem))
3276 return XCDR (tem);
3277 else
3278 return Qnil;
3282 /* Subroutines of creating an X frame. */
3284 /* Make sure that Vx_resource_name is set to a reasonable value.
3285 Fix it up, or set it to `emacs' if it is too hopeless. */
3287 void
3288 validate_x_resource_name ()
3290 int len = 0;
3291 /* Number of valid characters in the resource name. */
3292 int good_count = 0;
3293 /* Number of invalid characters in the resource name. */
3294 int bad_count = 0;
3295 Lisp_Object new;
3296 int i;
3298 if (!STRINGP (Vx_resource_class))
3299 Vx_resource_class = build_string (EMACS_CLASS);
3301 if (STRINGP (Vx_resource_name))
3303 unsigned char *p = SDATA (Vx_resource_name);
3304 int i;
3306 len = SBYTES (Vx_resource_name);
3308 /* Only letters, digits, - and _ are valid in resource names.
3309 Count the valid characters and count the invalid ones. */
3310 for (i = 0; i < len; i++)
3312 int c = p[i];
3313 if (! ((c >= 'a' && c <= 'z')
3314 || (c >= 'A' && c <= 'Z')
3315 || (c >= '0' && c <= '9')
3316 || c == '-' || c == '_'))
3317 bad_count++;
3318 else
3319 good_count++;
3322 else
3323 /* Not a string => completely invalid. */
3324 bad_count = 5, good_count = 0;
3326 /* If name is valid already, return. */
3327 if (bad_count == 0)
3328 return;
3330 /* If name is entirely invalid, or nearly so, use `emacs'. */
3331 if (good_count == 0
3332 || (good_count == 1 && bad_count > 0))
3334 Vx_resource_name = build_string ("emacs");
3335 return;
3338 /* Name is partly valid. Copy it and replace the invalid characters
3339 with underscores. */
3341 Vx_resource_name = new = Fcopy_sequence (Vx_resource_name);
3343 for (i = 0; i < len; i++)
3345 int c = SREF (new, i);
3346 if (! ((c >= 'a' && c <= 'z')
3347 || (c >= 'A' && c <= 'Z')
3348 || (c >= '0' && c <= '9')
3349 || c == '-' || c == '_'))
3350 SSET (new, i, '_');
3355 extern char *x_get_string_resource P_ ((XrmDatabase, char *, char *));
3356 extern Display_Info *check_x_display_info P_ ((Lisp_Object));
3359 /* Get specified attribute from resource database RDB.
3360 See Fx_get_resource below for other parameters. */
3362 static Lisp_Object
3363 xrdb_get_resource (rdb, attribute, class, component, subclass)
3364 XrmDatabase rdb;
3365 Lisp_Object attribute, class, component, subclass;
3367 register char *value;
3368 char *name_key;
3369 char *class_key;
3371 CHECK_STRING (attribute);
3372 CHECK_STRING (class);
3374 if (!NILP (component))
3375 CHECK_STRING (component);
3376 if (!NILP (subclass))
3377 CHECK_STRING (subclass);
3378 if (NILP (component) != NILP (subclass))
3379 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3381 validate_x_resource_name ();
3383 /* Allocate space for the components, the dots which separate them,
3384 and the final '\0'. Make them big enough for the worst case. */
3385 name_key = (char *) alloca (SBYTES (Vx_resource_name)
3386 + (STRINGP (component)
3387 ? SBYTES (component) : 0)
3388 + SBYTES (attribute)
3389 + 3);
3391 class_key = (char *) alloca (SBYTES (Vx_resource_class)
3392 + SBYTES (class)
3393 + (STRINGP (subclass)
3394 ? SBYTES (subclass) : 0)
3395 + 3);
3397 /* Start with emacs.FRAMENAME for the name (the specific one)
3398 and with `Emacs' for the class key (the general one). */
3399 strcpy (name_key, SDATA (Vx_resource_name));
3400 strcpy (class_key, SDATA (Vx_resource_class));
3402 strcat (class_key, ".");
3403 strcat (class_key, SDATA (class));
3405 if (!NILP (component))
3407 strcat (class_key, ".");
3408 strcat (class_key, SDATA (subclass));
3410 strcat (name_key, ".");
3411 strcat (name_key, SDATA (component));
3414 strcat (name_key, ".");
3415 strcat (name_key, SDATA (attribute));
3417 value = x_get_string_resource (rdb, name_key, class_key);
3419 if (value != (char *) 0)
3420 return build_string (value);
3421 else
3422 return Qnil;
3426 DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 2, 4, 0,
3427 doc: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3428 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3429 class, where INSTANCE is the name under which Emacs was invoked, or
3430 the name specified by the `-name' or `-rn' command-line arguments.
3432 The optional arguments COMPONENT and SUBCLASS add to the key and the
3433 class, respectively. You must specify both of them or neither.
3434 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3435 and the class is `Emacs.CLASS.SUBCLASS'. */)
3436 (attribute, class, component, subclass)
3437 Lisp_Object attribute, class, component, subclass;
3439 #ifdef HAVE_X_WINDOWS
3440 check_x ();
3441 #endif
3443 return xrdb_get_resource (check_x_display_info (Qnil)->xrdb,
3444 attribute, class, component, subclass);
3447 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3449 Lisp_Object
3450 display_x_get_resource (dpyinfo, attribute, class, component, subclass)
3451 Display_Info *dpyinfo;
3452 Lisp_Object attribute, class, component, subclass;
3454 return xrdb_get_resource (dpyinfo->xrdb,
3455 attribute, class, component, subclass);
3458 /* Used when C code wants a resource value. */
3460 char *
3461 x_get_resource_string (attribute, class)
3462 char *attribute, *class;
3464 char *name_key;
3465 char *class_key;
3466 struct frame *sf = SELECTED_FRAME ();
3468 /* Allocate space for the components, the dots which separate them,
3469 and the final '\0'. */
3470 name_key = (char *) alloca (SBYTES (Vinvocation_name)
3471 + strlen (attribute) + 2);
3472 class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
3473 + strlen (class) + 2);
3475 sprintf (name_key, "%s.%s", SDATA (Vinvocation_name), attribute);
3476 sprintf (class_key, "%s.%s", EMACS_CLASS, class);
3478 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb,
3479 name_key, class_key);
3483 /* Return the value of parameter PARAM.
3485 First search ALIST, then Vdefault_frame_alist, then the X defaults
3486 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3488 Convert the resource to the type specified by desired_type.
3490 If no default is specified, return Qunbound. If you call
3491 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3492 and don't let it get stored in any Lisp-visible variables! */
3494 Lisp_Object
3495 x_get_arg (dpyinfo, alist, param, attribute, class, type)
3496 Display_Info *dpyinfo;
3497 Lisp_Object alist, param;
3498 char *attribute;
3499 char *class;
3500 enum resource_types type;
3502 register Lisp_Object tem;
3504 tem = Fassq (param, alist);
3505 if (EQ (tem, Qnil))
3506 tem = Fassq (param, Vdefault_frame_alist);
3507 if (EQ (tem, Qnil))
3509 if (attribute)
3511 tem = display_x_get_resource (dpyinfo,
3512 build_string (attribute),
3513 build_string (class),
3514 Qnil, Qnil);
3516 if (NILP (tem))
3517 return Qunbound;
3519 switch (type)
3521 case RES_TYPE_NUMBER:
3522 return make_number (atoi (SDATA (tem)));
3524 case RES_TYPE_FLOAT:
3525 return make_float (atof (SDATA (tem)));
3527 case RES_TYPE_BOOLEAN:
3528 tem = Fdowncase (tem);
3529 if (!strcmp (SDATA (tem), "on")
3530 || !strcmp (SDATA (tem), "true"))
3531 return Qt;
3532 else
3533 return Qnil;
3535 case RES_TYPE_STRING:
3536 return tem;
3538 case RES_TYPE_SYMBOL:
3539 /* As a special case, we map the values `true' and `on'
3540 to Qt, and `false' and `off' to Qnil. */
3542 Lisp_Object lower;
3543 lower = Fdowncase (tem);
3544 if (!strcmp (SDATA (lower), "on")
3545 || !strcmp (SDATA (lower), "true"))
3546 return Qt;
3547 else if (!strcmp (SDATA (lower), "off")
3548 || !strcmp (SDATA (lower), "false"))
3549 return Qnil;
3550 else
3551 return Fintern (tem, Qnil);
3554 default:
3555 abort ();
3558 else
3559 return Qunbound;
3561 return Fcdr (tem);
3564 Lisp_Object
3565 x_frame_get_arg (f, alist, param, attribute, class, type)
3566 struct frame *f;
3567 Lisp_Object alist, param;
3568 char *attribute;
3569 char *class;
3570 enum resource_types type;
3572 return x_get_arg (FRAME_X_DISPLAY_INFO (f),
3573 alist, param, attribute, class, type);
3576 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3578 Lisp_Object
3579 x_frame_get_and_record_arg (f, alist, param, attribute, class, type)
3580 struct frame *f;
3581 Lisp_Object alist, param;
3582 char *attribute;
3583 char *class;
3584 enum resource_types type;
3586 Lisp_Object value;
3588 value = x_get_arg (FRAME_X_DISPLAY_INFO (f), alist, param,
3589 attribute, class, type);
3590 if (! NILP (value))
3591 store_frame_param (f, param, value);
3593 return value;
3597 /* Record in frame F the specified or default value according to ALIST
3598 of the parameter named PROP (a Lisp symbol).
3599 If no value is specified for PROP, look for an X default for XPROP
3600 on the frame named NAME.
3601 If that is not found either, use the value DEFLT. */
3603 Lisp_Object
3604 x_default_parameter (f, alist, prop, deflt, xprop, xclass, type)
3605 struct frame *f;
3606 Lisp_Object alist;
3607 Lisp_Object prop;
3608 Lisp_Object deflt;
3609 char *xprop;
3610 char *xclass;
3611 enum resource_types type;
3613 Lisp_Object tem;
3615 tem = x_frame_get_arg (f, alist, prop, xprop, xclass, type);
3616 if (EQ (tem, Qunbound))
3617 tem = deflt;
3618 x_set_frame_parameters (f, Fcons (Fcons (prop, tem), Qnil));
3619 return tem;
3625 DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0,
3626 doc: /* Parse an X-style geometry string STRING.
3627 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
3628 The properties returned may include `top', `left', `height', and `width'.
3629 The value of `left' or `top' may be an integer,
3630 or a list (+ N) meaning N pixels relative to top/left corner,
3631 or a list (- N) meaning -N pixels relative to bottom/right corner. */)
3632 (string)
3633 Lisp_Object string;
3635 int geometry, x, y;
3636 unsigned int width, height;
3637 Lisp_Object result;
3639 CHECK_STRING (string);
3641 geometry = XParseGeometry ((char *) SDATA (string),
3642 &x, &y, &width, &height);
3644 #if 0
3645 if (!!(geometry & XValue) != !!(geometry & YValue))
3646 error ("Must specify both x and y position, or neither");
3647 #endif
3649 result = Qnil;
3650 if (geometry & XValue)
3652 Lisp_Object element;
3654 if (x >= 0 && (geometry & XNegative))
3655 element = Fcons (Qleft, Fcons (Qminus, Fcons (make_number (-x), Qnil)));
3656 else if (x < 0 && ! (geometry & XNegative))
3657 element = Fcons (Qleft, Fcons (Qplus, Fcons (make_number (x), Qnil)));
3658 else
3659 element = Fcons (Qleft, make_number (x));
3660 result = Fcons (element, result);
3663 if (geometry & YValue)
3665 Lisp_Object element;
3667 if (y >= 0 && (geometry & YNegative))
3668 element = Fcons (Qtop, Fcons (Qminus, Fcons (make_number (-y), Qnil)));
3669 else if (y < 0 && ! (geometry & YNegative))
3670 element = Fcons (Qtop, Fcons (Qplus, Fcons (make_number (y), Qnil)));
3671 else
3672 element = Fcons (Qtop, make_number (y));
3673 result = Fcons (element, result);
3676 if (geometry & WidthValue)
3677 result = Fcons (Fcons (Qwidth, make_number (width)), result);
3678 if (geometry & HeightValue)
3679 result = Fcons (Fcons (Qheight, make_number (height)), result);
3681 return result;
3684 /* Calculate the desired size and position of frame F.
3685 Return the flags saying which aspects were specified.
3687 Also set the win_gravity and size_hint_flags of F.
3689 Adjust height for toolbar if TOOLBAR_P is 1.
3691 This function does not make the coordinates positive. */
3693 #define DEFAULT_ROWS 40
3694 #define DEFAULT_COLS 80
3697 x_figure_window_size (f, parms, toolbar_p)
3698 struct frame *f;
3699 Lisp_Object parms;
3700 int toolbar_p;
3702 register Lisp_Object tem0, tem1, tem2;
3703 long window_prompting = 0;
3704 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
3706 /* Default values if we fall through.
3707 Actually, if that happens we should get
3708 window manager prompting. */
3709 SET_FRAME_WIDTH (f, DEFAULT_COLS);
3710 f->height = DEFAULT_ROWS;
3711 /* Window managers expect that if program-specified
3712 positions are not (0,0), they're intentional, not defaults. */
3713 FRAME_X_OUTPUT (f)->top_pos = 0;
3714 FRAME_X_OUTPUT (f)->left_pos = 0;
3716 /* Ensure that old new_width and new_height will not override the
3717 values set here. */
3718 /* ++KFS: This was specific to W32, but seems ok for all platforms */
3719 FRAME_NEW_WIDTH (f) = 0;
3720 FRAME_NEW_HEIGHT (f) = 0;
3722 tem0 = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER);
3723 tem1 = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
3724 tem2 = x_get_arg (dpyinfo, parms, Quser_size, 0, 0, RES_TYPE_NUMBER);
3725 if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
3727 if (!EQ (tem0, Qunbound))
3729 CHECK_NUMBER (tem0);
3730 f->height = XINT (tem0);
3732 if (!EQ (tem1, Qunbound))
3734 CHECK_NUMBER (tem1);
3735 SET_FRAME_WIDTH (f, XINT (tem1));
3737 if (!NILP (tem2) && !EQ (tem2, Qunbound))
3738 window_prompting |= USSize;
3739 else
3740 window_prompting |= PSize;
3743 FRAME_X_OUTPUT (f)->vertical_scroll_bar_extra
3744 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
3746 #ifndef HAVE_X_WINDOWS
3747 /* +KFS: This was specific for W32 and MAC.. why? */
3748 : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0
3749 ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f)
3750 #endif
3751 : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (FRAME_X_OUTPUT (f)->font)));
3753 /* This used to be done _before_ calling x_figure_window_size, but
3754 since the height is reset here, this was really a no-op. I
3755 assume that moving it here does what Gerd intended (although he
3756 no longer can remember what that was... ++KFS, 2003-03-25. */
3758 /* Add the tool-bar height to the initial frame height so that the
3759 user gets a text display area of the size he specified with -g or
3760 via .Xdefaults. Later changes of the tool-bar height don't
3761 change the frame size. This is done so that users can create
3762 tall Emacs frames without having to guess how tall the tool-bar
3763 will get. */
3764 if (toolbar_p && FRAME_TOOL_BAR_LINES (f))
3766 int margin, relief, bar_height;
3768 relief = (tool_bar_button_relief >= 0
3769 ? tool_bar_button_relief
3770 : DEFAULT_TOOL_BAR_BUTTON_RELIEF);
3772 if (INTEGERP (Vtool_bar_button_margin)
3773 && XINT (Vtool_bar_button_margin) > 0)
3774 margin = XFASTINT (Vtool_bar_button_margin);
3775 else if (CONSP (Vtool_bar_button_margin)
3776 && INTEGERP (XCDR (Vtool_bar_button_margin))
3777 && XINT (XCDR (Vtool_bar_button_margin)) > 0)
3778 margin = XFASTINT (XCDR (Vtool_bar_button_margin));
3779 else
3780 margin = 0;
3782 bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;
3783 f->height += (bar_height + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f);
3786 compute_fringe_widths (f, 0);
3788 FRAME_X_OUTPUT (f)->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);
3789 FRAME_X_OUTPUT (f)->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);
3791 tem0 = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER);
3792 tem1 = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER);
3793 tem2 = x_get_arg (dpyinfo, parms, Quser_position, 0, 0, RES_TYPE_NUMBER);
3794 if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
3796 if (EQ (tem0, Qminus))
3798 FRAME_X_OUTPUT (f)->top_pos = 0;
3799 window_prompting |= YNegative;
3801 else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus)
3802 && CONSP (XCDR (tem0))
3803 && INTEGERP (XCAR (XCDR (tem0))))
3805 FRAME_X_OUTPUT (f)->top_pos = - XINT (XCAR (XCDR (tem0)));
3806 window_prompting |= YNegative;
3808 else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus)
3809 && CONSP (XCDR (tem0))
3810 && INTEGERP (XCAR (XCDR (tem0))))
3812 FRAME_X_OUTPUT (f)->top_pos = XINT (XCAR (XCDR (tem0)));
3814 else if (EQ (tem0, Qunbound))
3815 FRAME_X_OUTPUT (f)->top_pos = 0;
3816 else
3818 CHECK_NUMBER (tem0);
3819 FRAME_X_OUTPUT (f)->top_pos = XINT (tem0);
3820 if (FRAME_X_OUTPUT (f)->top_pos < 0)
3821 window_prompting |= YNegative;
3824 if (EQ (tem1, Qminus))
3826 FRAME_X_OUTPUT (f)->left_pos = 0;
3827 window_prompting |= XNegative;
3829 else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus)
3830 && CONSP (XCDR (tem1))
3831 && INTEGERP (XCAR (XCDR (tem1))))
3833 FRAME_X_OUTPUT (f)->left_pos = - XINT (XCAR (XCDR (tem1)));
3834 window_prompting |= XNegative;
3836 else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus)
3837 && CONSP (XCDR (tem1))
3838 && INTEGERP (XCAR (XCDR (tem1))))
3840 FRAME_X_OUTPUT (f)->left_pos = XINT (XCAR (XCDR (tem1)));
3842 else if (EQ (tem1, Qunbound))
3843 FRAME_X_OUTPUT (f)->left_pos = 0;
3844 else
3846 CHECK_NUMBER (tem1);
3847 FRAME_X_OUTPUT (f)->left_pos = XINT (tem1);
3848 if (FRAME_X_OUTPUT (f)->left_pos < 0)
3849 window_prompting |= XNegative;
3852 if (!NILP (tem2) && ! EQ (tem2, Qunbound))
3853 window_prompting |= USPosition;
3854 else
3855 window_prompting |= PPosition;
3858 if (FRAME_X_OUTPUT (f)->want_fullscreen != FULLSCREEN_NONE)
3860 int left, top;
3861 int width, height;
3863 /* It takes both for some WM:s to place it where we want */
3864 window_prompting = USPosition | PPosition;
3865 x_fullscreen_adjust (f, &width, &height, &top, &left);
3866 f->width = width;
3867 f->height = height;
3868 FRAME_X_OUTPUT (f)->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);
3869 FRAME_X_OUTPUT (f)->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);
3870 FRAME_X_OUTPUT (f)->left_pos = left;
3871 FRAME_X_OUTPUT (f)->top_pos = top;
3874 if (window_prompting & XNegative)
3876 if (window_prompting & YNegative)
3877 FRAME_X_OUTPUT (f)->win_gravity = SouthEastGravity;
3878 else
3879 FRAME_X_OUTPUT (f)->win_gravity = NorthEastGravity;
3881 else
3883 if (window_prompting & YNegative)
3884 FRAME_X_OUTPUT (f)->win_gravity = SouthWestGravity;
3885 else
3886 FRAME_X_OUTPUT (f)->win_gravity = NorthWestGravity;
3889 FRAME_X_OUTPUT (f)->size_hint_flags = window_prompting;
3891 return window_prompting;
3896 #endif /* HAVE_WINDOW_SYSTEM */
3900 /***********************************************************************
3901 Initialization
3902 ***********************************************************************/
3904 void
3905 syms_of_frame ()
3907 Qframep = intern ("framep");
3908 staticpro (&Qframep);
3909 Qframe_live_p = intern ("frame-live-p");
3910 staticpro (&Qframe_live_p);
3911 Qheight = intern ("height");
3912 staticpro (&Qheight);
3913 Qicon = intern ("icon");
3914 staticpro (&Qicon);
3915 Qminibuffer = intern ("minibuffer");
3916 staticpro (&Qminibuffer);
3917 Qmodeline = intern ("modeline");
3918 staticpro (&Qmodeline);
3919 Qonly = intern ("only");
3920 staticpro (&Qonly);
3921 Qwidth = intern ("width");
3922 staticpro (&Qwidth);
3923 Qgeometry = intern ("geometry");
3924 staticpro (&Qgeometry);
3925 Qicon_left = intern ("icon-left");
3926 staticpro (&Qicon_left);
3927 Qicon_top = intern ("icon-top");
3928 staticpro (&Qicon_top);
3929 Qleft = intern ("left");
3930 staticpro (&Qleft);
3931 Qright = intern ("right");
3932 staticpro (&Qright);
3933 Quser_position = intern ("user-position");
3934 staticpro (&Quser_position);
3935 Quser_size = intern ("user-size");
3936 staticpro (&Quser_size);
3937 Qwindow_id = intern ("window-id");
3938 staticpro (&Qwindow_id);
3939 #ifdef HAVE_X_WINDOWS
3940 Qouter_window_id = intern ("outer-window-id");
3941 staticpro (&Qouter_window_id);
3942 #endif
3943 Qparent_id = intern ("parent-id");
3944 staticpro (&Qparent_id);
3945 Qx = intern ("x");
3946 staticpro (&Qx);
3947 Qw32 = intern ("w32");
3948 staticpro (&Qw32);
3949 Qpc = intern ("pc");
3950 staticpro (&Qpc);
3951 Qmac = intern ("mac");
3952 staticpro (&Qmac);
3953 Qvisible = intern ("visible");
3954 staticpro (&Qvisible);
3955 Qbuffer_predicate = intern ("buffer-predicate");
3956 staticpro (&Qbuffer_predicate);
3957 Qbuffer_list = intern ("buffer-list");
3958 staticpro (&Qbuffer_list);
3959 Qdisplay_type = intern ("display-type");
3960 staticpro (&Qdisplay_type);
3961 Qbackground_mode = intern ("background-mode");
3962 staticpro (&Qbackground_mode);
3963 Qtty_color_mode = intern ("tty-color-mode");
3964 staticpro (&Qtty_color_mode);
3966 Qface_set_after_frame_default = intern ("face-set-after-frame-default");
3967 staticpro (&Qface_set_after_frame_default);
3969 Qfullwidth = intern ("fullwidth");
3970 staticpro (&Qfullwidth);
3971 Qfullheight = intern ("fullheight");
3972 staticpro (&Qfullheight);
3973 Qfullboth = intern ("fullboth");
3974 staticpro (&Qfullboth);
3975 Qx_resource_name = intern ("x-resource-name");
3976 staticpro (&Qx_resource_name);
3978 Qx_frame_parameter = intern ("x-frame-parameter");
3979 staticpro (&Qx_frame_parameter);
3982 int i;
3984 for (i = 0; i < sizeof (frame_parms) / sizeof (frame_parms[0]); i++)
3986 Lisp_Object v = intern (frame_parms[i].name);
3987 if (frame_parms[i].variable)
3989 *frame_parms[i].variable = v;
3990 staticpro (frame_parms[i].variable);
3992 Fput (v, Qx_frame_parameter, make_number (i));
3996 #ifdef HAVE_WINDOW_SYSTEM
3997 DEFVAR_LISP ("x-resource-name", &Vx_resource_name,
3998 doc: /* The name Emacs uses to look up X resources.
3999 `x-get-resource' uses this as the first component of the instance name
4000 when requesting resource values.
4001 Emacs initially sets `x-resource-name' to the name under which Emacs
4002 was invoked, or to the value specified with the `-name' or `-rn'
4003 switches, if present.
4005 It may be useful to bind this variable locally around a call
4006 to `x-get-resource'. See also the variable `x-resource-class'. */);
4007 Vx_resource_name = Qnil;
4009 DEFVAR_LISP ("x-resource-class", &Vx_resource_class,
4010 doc: /* The class Emacs uses to look up X resources.
4011 `x-get-resource' uses this as the first component of the instance class
4012 when requesting resource values.
4014 Emacs initially sets `x-resource-class' to "Emacs".
4016 Setting this variable permanently is not a reasonable thing to do,
4017 but binding this variable locally around a call to `x-get-resource'
4018 is a reasonable practice. See also the variable `x-resource-name'. */);
4019 Vx_resource_class = build_string (EMACS_CLASS);
4020 #endif
4022 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
4023 doc: /* Alist of default values for frame creation.
4024 These may be set in your init file, like this:
4025 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))
4026 These override values given in window system configuration data,
4027 including X Windows' defaults database.
4028 For values specific to the first Emacs frame, see `initial-frame-alist'.
4029 For values specific to the separate minibuffer frame, see
4030 `minibuffer-frame-alist'.
4031 The `menu-bar-lines' element of the list controls whether new frames
4032 have menu bars; `menu-bar-mode' works by altering this element.
4033 Setting this variable does not affect existing frames, only new ones. */);
4034 Vdefault_frame_alist = Qnil;
4036 Qinhibit_default_face_x_resources
4037 = intern ("inhibit-default-face-x-resources");
4038 staticpro (&Qinhibit_default_face_x_resources);
4040 DEFVAR_LISP ("terminal-frame", &Vterminal_frame,
4041 doc: /* The initial frame-object, which represents Emacs's stdout. */);
4043 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified,
4044 doc: /* Non-nil if all of emacs is iconified and frame updates are not needed. */);
4045 Vemacs_iconified = Qnil;
4047 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function,
4048 doc: /* If non-nil, function to transform normal value of `mouse-position'.
4049 `mouse-position' calls this function, passing its usual return value as
4050 argument, and returns whatever this function returns.
4051 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4052 which need to do mouse handling at the Lisp level. */);
4053 Vmouse_position_function = Qnil;
4055 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight,
4056 doc: /* If non-nil, clickable text is highlighted when mouse is over it.
4057 If the value is an integer, highlighting is only shown after moving the
4058 mouse, while keyboard input turns off the highlight even when the mouse
4059 is over the clickable text. However, the mouse shape still indicates
4060 when the mouse is over clickable text. */);
4061 Vmouse_highlight = Qt;
4063 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions,
4064 doc: /* Functions to be run before deleting a frame.
4065 The functions are run with one arg, the frame to be deleted.
4066 See `delete-frame'. */);
4067 Vdelete_frame_functions = Qnil;
4069 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame,
4070 doc: /* Minibufferless frames use this frame's minibuffer.
4072 Emacs cannot create minibufferless frames unless this is set to an
4073 appropriate surrogate.
4075 Emacs consults this variable only when creating minibufferless
4076 frames; once the frame is created, it sticks with its assigned
4077 minibuffer, no matter what this variable is set to. This means that
4078 this variable doesn't necessarily say anything meaningful about the
4079 current set of frames, or where the minibuffer is currently being
4080 displayed.
4082 This variable is local to the current terminal and cannot be buffer-local. */);
4084 staticpro (&Vframe_list);
4086 defsubr (&Sactive_minibuffer_window);
4087 defsubr (&Sframep);
4088 defsubr (&Sframe_live_p);
4089 defsubr (&Smake_terminal_frame);
4090 defsubr (&Shandle_switch_frame);
4091 defsubr (&Signore_event);
4092 defsubr (&Sselect_frame);
4093 defsubr (&Sselected_frame);
4094 defsubr (&Swindow_frame);
4095 defsubr (&Sframe_root_window);
4096 defsubr (&Sframe_first_window);
4097 defsubr (&Sframe_selected_window);
4098 defsubr (&Sset_frame_selected_window);
4099 defsubr (&Sframe_list);
4100 defsubr (&Snext_frame);
4101 defsubr (&Sprevious_frame);
4102 defsubr (&Sdelete_frame);
4103 defsubr (&Smouse_position);
4104 defsubr (&Smouse_pixel_position);
4105 defsubr (&Sset_mouse_position);
4106 defsubr (&Sset_mouse_pixel_position);
4107 #if 0
4108 defsubr (&Sframe_configuration);
4109 defsubr (&Srestore_frame_configuration);
4110 #endif
4111 defsubr (&Smake_frame_visible);
4112 defsubr (&Smake_frame_invisible);
4113 defsubr (&Siconify_frame);
4114 defsubr (&Sframe_visible_p);
4115 defsubr (&Svisible_frame_list);
4116 defsubr (&Sraise_frame);
4117 defsubr (&Slower_frame);
4118 defsubr (&Sredirect_frame_focus);
4119 defsubr (&Sframe_focus);
4120 defsubr (&Sframe_parameters);
4121 defsubr (&Sframe_parameter);
4122 defsubr (&Smodify_frame_parameters);
4123 defsubr (&Sframe_char_height);
4124 defsubr (&Sframe_char_width);
4125 defsubr (&Sframe_pixel_height);
4126 defsubr (&Sframe_pixel_width);
4127 defsubr (&Sset_frame_height);
4128 defsubr (&Sset_frame_width);
4129 defsubr (&Sset_frame_size);
4130 defsubr (&Sset_frame_position);
4132 #ifdef HAVE_WINDOW_SYSTEM
4133 defsubr (&Sx_get_resource);
4134 defsubr (&Sx_parse_geometry);
4135 #endif