(Fdelete_frame): Only get kboard when MULTI_KBOARD defined.
[bpt/emacs.git] / src / frame.c
1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
4
5 This file is part of GNU Emacs.
6
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.
11
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.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
21
22 #include <config.h>
23
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 "termchar.h"
46 #include "termhooks.h"
47 #include "dispextern.h"
48 #include "window.h"
49 #ifdef MSDOS
50 #include "msdos.h"
51 #include "dosfns.h"
52 #endif
53
54
55 #ifdef HAVE_WINDOW_SYSTEM
56
57 /* The name we're using in resource queries. Most often "emacs". */
58
59 Lisp_Object Vx_resource_name;
60
61 /* The application class we're using in resource queries.
62 Normally "Emacs". */
63
64 Lisp_Object Vx_resource_class;
65
66 #endif
67
68 Lisp_Object Qframep, Qframe_live_p;
69 Lisp_Object Qicon, Qmodeline;
70 Lisp_Object Qonly;
71 Lisp_Object Qx, Qw32, Qmac, Qpc;
72 Lisp_Object Qvisible;
73 Lisp_Object Qdisplay_type;
74 Lisp_Object Qbackground_mode;
75
76 Lisp_Object Qx_frame_parameter;
77 Lisp_Object Qx_resource_name;
78 Lisp_Object Qterminal;
79 Lisp_Object Qterminal_live_p;
80
81 /* Frame parameters (set or reported). */
82
83 Lisp_Object Qauto_raise, Qauto_lower;
84 Lisp_Object Qborder_color, Qborder_width;
85 Lisp_Object Qcursor_color, Qcursor_type;
86 Lisp_Object Qgeometry; /* Not used */
87 Lisp_Object Qheight, Qwidth;
88 Lisp_Object Qleft, Qright;
89 Lisp_Object Qicon_left, Qicon_top, Qicon_type, Qicon_name;
90 Lisp_Object Qinternal_border_width;
91 Lisp_Object Qmouse_color;
92 Lisp_Object Qminibuffer;
93 Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
94 Lisp_Object Qvisibility;
95 Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
96 Lisp_Object Qscreen_gamma;
97 Lisp_Object Qline_spacing;
98 Lisp_Object Quser_position, Quser_size;
99 Lisp_Object Qwait_for_wm;
100 Lisp_Object Qwindow_id;
101 #ifdef HAVE_X_WINDOWS
102 Lisp_Object Qouter_window_id;
103 #endif
104 Lisp_Object Qparent_id;
105 Lisp_Object Qtitle, Qname;
106 Lisp_Object Qunsplittable;
107 Lisp_Object Qmenu_bar_lines, Qtool_bar_lines;
108 Lisp_Object Qleft_fringe, Qright_fringe;
109 Lisp_Object Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list;
110 Lisp_Object Qtty_color_mode;
111 Lisp_Object Qtty, Qtty_type;
112 Lisp_Object Qwindow_system;
113 Lisp_Object Qenvironment;
114
115 Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
116
117 Lisp_Object Qinhibit_face_set_after_frame_default;
118 Lisp_Object Qface_set_after_frame_default;
119
120 Lisp_Object Vterminal_frame;
121 Lisp_Object Vdefault_frame_alist;
122 Lisp_Object Vdefault_frame_scroll_bars;
123 Lisp_Object Vmouse_position_function;
124 Lisp_Object Vmouse_highlight;
125 Lisp_Object Vdelete_frame_functions;
126 \f
127 static void
128 set_menu_bar_lines_1 (window, n)
129 Lisp_Object window;
130 int n;
131 {
132 struct window *w = XWINDOW (window);
133
134 XSETFASTINT (w->last_modified, 0);
135 XSETFASTINT (w->top_line, XFASTINT (w->top_line) + n);
136 XSETFASTINT (w->total_lines, XFASTINT (w->total_lines) - n);
137
138 if (INTEGERP (w->orig_top_line))
139 XSETFASTINT (w->orig_top_line, XFASTINT (w->orig_top_line) + n);
140 if (INTEGERP (w->orig_total_lines))
141 XSETFASTINT (w->orig_total_lines, XFASTINT (w->orig_total_lines) - n);
142
143 /* Handle just the top child in a vertical split. */
144 if (!NILP (w->vchild))
145 set_menu_bar_lines_1 (w->vchild, n);
146
147 /* Adjust all children in a horizontal split. */
148 for (window = w->hchild; !NILP (window); window = w->next)
149 {
150 w = XWINDOW (window);
151 set_menu_bar_lines_1 (window, n);
152 }
153 }
154
155 void
156 set_menu_bar_lines (f, value, oldval)
157 struct frame *f;
158 Lisp_Object value, oldval;
159 {
160 int nlines;
161 int olines = FRAME_MENU_BAR_LINES (f);
162
163 /* Right now, menu bars don't work properly in minibuf-only frames;
164 most of the commands try to apply themselves to the minibuffer
165 frame itself, and get an error because you can't switch buffers
166 in or split the minibuffer window. */
167 if (FRAME_MINIBUF_ONLY_P (f))
168 return;
169
170 if (INTEGERP (value))
171 nlines = XINT (value);
172 else
173 nlines = 0;
174
175 if (nlines != olines)
176 {
177 windows_or_buffers_changed++;
178 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
179 FRAME_MENU_BAR_LINES (f) = nlines;
180 set_menu_bar_lines_1 (f->root_window, nlines - olines);
181 adjust_glyphs (f);
182 }
183 }
184 \f
185 Lisp_Object Vemacs_iconified;
186 Lisp_Object Vframe_list;
187
188 extern Lisp_Object Vminibuffer_list;
189 extern Lisp_Object get_minibuffer ();
190 extern Lisp_Object Fhandle_switch_frame ();
191 extern Lisp_Object Fredirect_frame_focus ();
192 extern Lisp_Object x_get_focus_frame ();
193 \f
194 DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
195 doc: /* Return non-nil if OBJECT is a frame.
196 Value is t for a termcap frame (a character-only terminal),
197 `x' for an Emacs frame that is really an X window,
198 `w32' for an Emacs frame that is a window on MS-Windows display,
199 `mac' for an Emacs frame on a Macintosh display,
200 `pc' for a direct-write MS-DOS frame.
201 See also `frame-live-p'. */)
202 (object)
203 Lisp_Object object;
204 {
205 if (!FRAMEP (object))
206 return Qnil;
207 switch (XFRAME (object)->output_method)
208 {
209 case output_initial: /* The initial frame is like a termcap frame. */
210 case output_termcap:
211 return Qt;
212 case output_x_window:
213 return Qx;
214 case output_w32:
215 return Qw32;
216 case output_msdos_raw:
217 return Qpc;
218 case output_mac:
219 return Qmac;
220 default:
221 abort ();
222 }
223 }
224
225 DEFUN ("frame-live-p", Fframe_live_p, Sframe_live_p, 1, 1, 0,
226 doc: /* Return non-nil if OBJECT is a frame which has not been deleted.
227 Value is nil if OBJECT is not a live frame. If object is a live
228 frame, the return value indicates what sort of terminal device it is
229 displayed on. See the documentation of `framep' for possible
230 return values. */)
231 (object)
232 Lisp_Object object;
233 {
234 return ((FRAMEP (object)
235 && FRAME_LIVE_P (XFRAME (object)))
236 ? Fframep (object)
237 : Qnil);
238 }
239
240 DEFUN ("window-system", Fwindow_system, Swindow_system, 0, 1, 0,
241 doc: /* The name of the window system that FRAME is displaying through.
242 The value is a symbol---for instance, 'x' for X windows.
243 The value is nil if Emacs is using a text-only terminal.
244
245 FRAME defaults to the currently selected frame. */)
246 (frame)
247 Lisp_Object frame;
248 {
249 Lisp_Object type;
250 if (NILP (frame))
251 frame = selected_frame;
252
253 type = Fframep (frame);
254
255 if (NILP (type))
256 wrong_type_argument (Qframep, frame);
257
258 if (EQ (type, Qt))
259 return Qnil;
260 else
261 return type;
262 }
263
264 struct frame *
265 make_frame (mini_p)
266 int mini_p;
267 {
268 Lisp_Object frame;
269 register struct frame *f;
270 register Lisp_Object root_window;
271 register Lisp_Object mini_window;
272
273 f = allocate_frame ();
274 XSETFRAME (frame, f);
275
276 f->desired_matrix = 0;
277 f->current_matrix = 0;
278 f->desired_pool = 0;
279 f->current_pool = 0;
280 f->glyphs_initialized_p = 0;
281 f->decode_mode_spec_buffer = 0;
282 f->visible = 0;
283 f->async_visible = 0;
284 f->output_data.nothing = 0;
285 f->iconified = 0;
286 f->async_iconified = 0;
287 f->wants_modeline = 1;
288 f->auto_raise = 0;
289 f->auto_lower = 0;
290 f->no_split = 0;
291 f->garbaged = 1;
292 f->has_minibuffer = mini_p;
293 f->focus_frame = Qnil;
294 f->explicit_name = 0;
295 f->can_have_scroll_bars = 0;
296 f->vertical_scroll_bar_type = vertical_scroll_bar_none;
297 f->param_alist = Qnil;
298 f->scroll_bars = Qnil;
299 f->condemned_scroll_bars = Qnil;
300 f->face_alist = Qnil;
301 f->face_cache = NULL;
302 f->menu_bar_items = Qnil;
303 f->menu_bar_vector = Qnil;
304 f->menu_bar_items_used = 0;
305 f->buffer_predicate = Qnil;
306 f->buffer_list = Qnil;
307 f->buried_buffer_list = Qnil;
308 f->namebuf = 0;
309 f->title = Qnil;
310 f->menu_bar_window = Qnil;
311 f->tool_bar_window = Qnil;
312 f->tool_bar_items = Qnil;
313 f->desired_tool_bar_string = f->current_tool_bar_string = Qnil;
314 f->n_tool_bar_items = 0;
315 f->left_fringe_width = f->right_fringe_width = 0;
316 f->fringe_cols = 0;
317 f->scroll_bar_actual_width = 0;
318 f->border_width = 0;
319 f->internal_border_width = 0;
320 f->column_width = 1; /* !FRAME_WINDOW_P value */
321 f->line_height = 1; /* !FRAME_WINDOW_P value */
322 f->x_pixels_diff = f->y_pixels_diff = 0;
323 #ifdef HAVE_WINDOW_SYSTEM
324 f->want_fullscreen = FULLSCREEN_NONE;
325 #endif
326 f->size_hint_flags = 0;
327 f->win_gravity = 0;
328
329 root_window = make_window ();
330 if (mini_p)
331 {
332 mini_window = make_window ();
333 XWINDOW (root_window)->next = mini_window;
334 XWINDOW (mini_window)->prev = root_window;
335 XWINDOW (mini_window)->mini_p = Qt;
336 XWINDOW (mini_window)->frame = frame;
337 f->minibuffer_window = mini_window;
338 }
339 else
340 {
341 mini_window = Qnil;
342 XWINDOW (root_window)->next = Qnil;
343 f->minibuffer_window = Qnil;
344 }
345
346 XWINDOW (root_window)->frame = frame;
347
348 /* 10 is arbitrary,
349 just so that there is "something there."
350 Correct size will be set up later with change_frame_size. */
351
352 SET_FRAME_COLS (f, 10);
353 FRAME_LINES (f) = 10;
354
355 XSETFASTINT (XWINDOW (root_window)->total_cols, 10);
356 XSETFASTINT (XWINDOW (root_window)->total_lines, (mini_p ? 9 : 10));
357
358 if (mini_p)
359 {
360 XSETFASTINT (XWINDOW (mini_window)->total_cols, 10);
361 XSETFASTINT (XWINDOW (mini_window)->top_line, 9);
362 XSETFASTINT (XWINDOW (mini_window)->total_lines, 1);
363 }
364
365 /* Choose a buffer for the frame's root window. */
366 {
367 Lisp_Object buf;
368
369 XWINDOW (root_window)->buffer = Qt;
370 buf = Fcurrent_buffer ();
371 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
372 a space), try to find another one. */
373 if (SREF (Fbuffer_name (buf), 0) == ' ')
374 buf = Fother_buffer (buf, Qnil, Qnil);
375
376 /* Use set_window_buffer, not Fset_window_buffer, and don't let
377 hooks be run by it. The reason is that the whole frame/window
378 arrangement is not yet fully intialized at this point. Windows
379 don't have the right size, glyph matrices aren't initialized
380 etc. Running Lisp functions at this point surely ends in a
381 SEGV. */
382 set_window_buffer (root_window, buf, 0, 0);
383 f->buffer_list = Fcons (buf, Qnil);
384 }
385
386 if (mini_p)
387 {
388 XWINDOW (mini_window)->buffer = Qt;
389 set_window_buffer (mini_window,
390 (NILP (Vminibuffer_list)
391 ? get_minibuffer (0)
392 : Fcar (Vminibuffer_list)),
393 0, 0);
394 }
395
396 f->root_window = root_window;
397 f->selected_window = root_window;
398 /* Make sure this window seems more recently used than
399 a newly-created, never-selected window. */
400 ++window_select_count;
401 XSETFASTINT (XWINDOW (f->selected_window)->use_time, window_select_count);
402
403 f->default_face_done_p = 0;
404
405 return f;
406 }
407 \f
408 #ifdef HAVE_WINDOW_SYSTEM
409 /* Make a frame using a separate minibuffer window on another frame.
410 MINI_WINDOW is the minibuffer window to use. nil means use the
411 default (the global minibuffer). */
412
413 struct frame *
414 make_frame_without_minibuffer (mini_window, kb, display)
415 register Lisp_Object mini_window;
416 KBOARD *kb;
417 Lisp_Object display;
418 {
419 register struct frame *f;
420 struct gcpro gcpro1;
421
422 if (!NILP (mini_window))
423 CHECK_LIVE_WINDOW (mini_window);
424
425 #ifdef MULTI_KBOARD
426 if (!NILP (mini_window)
427 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window)->frame)) != kb)
428 error ("Frame and minibuffer must be on the same terminal");
429 #endif
430
431 /* Make a frame containing just a root window. */
432 f = make_frame (0);
433
434 if (NILP (mini_window))
435 {
436 /* Use default-minibuffer-frame if possible. */
437 if (!FRAMEP (kb->Vdefault_minibuffer_frame)
438 || ! FRAME_LIVE_P (XFRAME (kb->Vdefault_minibuffer_frame)))
439 {
440 Lisp_Object frame_dummy;
441
442 XSETFRAME (frame_dummy, f);
443 GCPRO1 (frame_dummy);
444 /* If there's no minibuffer frame to use, create one. */
445 kb->Vdefault_minibuffer_frame =
446 call1 (intern ("make-initial-minibuffer-frame"), display);
447 UNGCPRO;
448 }
449
450 mini_window = XFRAME (kb->Vdefault_minibuffer_frame)->minibuffer_window;
451 }
452
453 f->minibuffer_window = mini_window;
454
455 /* Make the chosen minibuffer window display the proper minibuffer,
456 unless it is already showing a minibuffer. */
457 if (NILP (Fmemq (XWINDOW (mini_window)->buffer, Vminibuffer_list)))
458 Fset_window_buffer (mini_window,
459 (NILP (Vminibuffer_list)
460 ? get_minibuffer (0)
461 : Fcar (Vminibuffer_list)), Qnil);
462 return f;
463 }
464
465 /* Make a frame containing only a minibuffer window. */
466
467 struct frame *
468 make_minibuffer_frame ()
469 {
470 /* First make a frame containing just a root window, no minibuffer. */
471
472 register struct frame *f = make_frame (0);
473 register Lisp_Object mini_window;
474 register Lisp_Object frame;
475
476 XSETFRAME (frame, f);
477
478 f->auto_raise = 0;
479 f->auto_lower = 0;
480 f->no_split = 1;
481 f->wants_modeline = 0;
482 f->has_minibuffer = 1;
483
484 /* Now label the root window as also being the minibuffer.
485 Avoid infinite looping on the window chain by marking next pointer
486 as nil. */
487
488 mini_window = f->minibuffer_window = f->root_window;
489 XWINDOW (mini_window)->mini_p = Qt;
490 XWINDOW (mini_window)->next = Qnil;
491 XWINDOW (mini_window)->prev = Qnil;
492 XWINDOW (mini_window)->frame = frame;
493
494 /* Put the proper buffer in that window. */
495
496 Fset_window_buffer (mini_window,
497 (NILP (Vminibuffer_list)
498 ? get_minibuffer (0)
499 : Fcar (Vminibuffer_list)), Qnil);
500 return f;
501 }
502 #endif /* HAVE_WINDOW_SYSTEM */
503 \f
504 /* Construct a frame that refers to a terminal. */
505
506 static int tty_frame_count;
507
508 struct frame *
509 make_initial_frame (void)
510 {
511 struct frame *f;
512 struct terminal *terminal;
513 Lisp_Object frame;
514
515 #ifdef MULTI_KBOARD
516 /* Create the initial keyboard. */
517 if (!initial_kboard)
518 {
519 initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
520 init_kboard (initial_kboard);
521 initial_kboard->next_kboard = all_kboards;
522 all_kboards = initial_kboard;
523 }
524 #endif
525
526 /* The first call must initialize Vframe_list. */
527 if (! (NILP (Vframe_list) || CONSP (Vframe_list)))
528 Vframe_list = Qnil;
529
530 terminal = init_initial_terminal ();
531
532 f = make_frame (1);
533 XSETFRAME (frame, f);
534
535 Vframe_list = Fcons (frame, Vframe_list);
536
537 tty_frame_count = 1;
538 f->name = build_string ("F1");
539
540 f->visible = 1;
541 f->async_visible = 1;
542
543 f->output_method = terminal->type;
544 f->terminal = terminal;
545 f->terminal->reference_count++;
546 f->output_data.nothing = 0;
547
548 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
549 FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
550
551 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
552 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
553
554 return f;
555 }
556
557
558 struct frame *
559 make_terminal_frame (struct terminal *terminal)
560 {
561 register struct frame *f;
562 Lisp_Object frame;
563 char name[20];
564
565 if (terminal->deleted)
566 error ("Terminal is being deleted, can't create new frames on it");
567
568 f = make_frame (1);
569
570 XSETFRAME (frame, f);
571 Vframe_list = Fcons (frame, Vframe_list);
572
573 tty_frame_count++;
574 sprintf (name, "F%d", tty_frame_count);
575 f->name = build_string (name);
576
577 f->visible = 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
578 f->async_visible = 1; /* Don't let visible be cleared later. */
579 #ifdef MSDOS
580 f->output_data.x = &the_only_x_display;
581 if (!inhibit_window_system
582 && (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame))
583 || XFRAME (selected_frame)->output_method == output_msdos_raw))
584 {
585 f->output_method = output_msdos_raw;
586 /* This initialization of foreground and background pixels is
587 only important for the initial frame created in temacs. If
588 we don't do that, we get black background and foreground in
589 the dumped Emacs because the_only_x_display is a static
590 variable, hence it is born all-zeroes, and zero is the code
591 for the black color. Other frames all inherit their pixels
592 from what's already in the_only_x_display. */
593 if ((!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame)))
594 && FRAME_BACKGROUND_PIXEL (f) == 0
595 && FRAME_FOREGROUND_PIXEL (f) == 0)
596 {
597 FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
598 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
599 }
600 }
601 else
602 f->output_method = output_termcap;
603 #else
604 #ifdef WINDOWSNT
605 f->output_method = output_termcap;
606 f->terminal = terminal;
607 f->terminal->reference_count++;
608 create_w32cons_output (f);
609 #else
610 #ifdef MAC_OS8
611 make_mac_terminal_frame (f);
612 #else
613 {
614 f->output_method = output_termcap;
615 f->terminal = terminal;
616 f->terminal->reference_count++;
617 create_tty_output (f);
618
619 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
620 FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
621
622 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
623 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
624
625 /* Set the top frame to the newly created frame. */
626 if (FRAME_TTY (f)->top_frame
627 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f)->top_frame)))
628 XFRAME (FRAME_TTY (f)->top_frame)->async_visible = 2; /* obscured */
629
630 FRAME_TTY (f)->top_frame = frame;
631 }
632
633 #ifdef CANNOT_DUMP
634 FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR;
635 FRAME_BACKGROUND_PIXEL(f) = FACE_TTY_DEFAULT_BG_COLOR;
636 #endif
637 #endif /* MAC_OS8 */
638 #endif /* WINDOWSNT */
639 #endif /* MSDOS */
640
641 if (!noninteractive)
642 init_frame_faces (f);
643
644 return f;
645 }
646
647 /* Get a suitable value for frame parameter PARAMETER for a newly
648 created frame, based on (1) the user-supplied frame parameter
649 alist SUPPLIED_PARMS, (2) CURRENT_VALUE, and finally, if all else
650 fails, (3) Vdefault_frame_alist. */
651
652 static Lisp_Object
653 get_future_frame_param (Lisp_Object parameter,
654 Lisp_Object supplied_parms,
655 char *current_value)
656 {
657 Lisp_Object result;
658
659 result = Fassq (parameter, supplied_parms);
660 if (NILP (result))
661 result = Fassq (parameter, XFRAME (selected_frame)->param_alist);
662 if (NILP (result) && current_value != NULL)
663 result = build_string (current_value);
664 if (NILP (result))
665 result = Fassq (parameter, Vdefault_frame_alist);
666 if (!NILP (result) && !STRINGP (result))
667 result = XCDR (result);
668 if (NILP (result) || !STRINGP (result))
669 result = Qnil;
670
671 return result;
672 }
673
674 DEFUN ("make-terminal-frame", Fmake_terminal_frame, Smake_terminal_frame,
675 1, 1, 0,
676 doc: /* Create an additional terminal frame, possibly on another terminal.
677 This function takes one argument, an alist specifying frame parameters.
678
679 You can create multiple frames on a single text-only terminal, but
680 only one of them (the selected terminal frame) is actually displayed.
681
682 In practice, generally you don't need to specify any parameters,
683 except when you want to create a new frame on another terminal.
684 In that case, the `tty' parameter specifies the device file to open,
685 and the `tty-type' parameter specifies the terminal type. Example:
686
687 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
688
689 Note that changing the size of one terminal frame automatically
690 affects all frames on the same terminal device. */)
691 (parms)
692 Lisp_Object parms;
693 {
694 struct frame *f;
695 struct terminal *t = NULL;
696 Lisp_Object frame, tem;
697 struct frame *sf = SELECTED_FRAME ();
698
699 #ifdef MSDOS
700 if (sf->output_method != output_msdos_raw
701 && sf->output_method != output_termcap)
702 abort ();
703 #else /* not MSDOS */
704
705 #ifdef MAC_OS
706 if (sf->output_method != output_mac)
707 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
708 #else
709 #if 0 /* This should work now! */
710 if (sf->output_method != output_termcap)
711 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
712 #endif
713 #endif
714 #endif /* not MSDOS */
715
716 {
717 Lisp_Object terminal;
718
719 terminal = Fassq (Qterminal, parms);
720 if (!NILP (terminal))
721 {
722 terminal = XCDR (terminal);
723 t = get_terminal (terminal, 1);
724 }
725 }
726
727 if (!t)
728 {
729 char *name = 0, *type = 0;
730 Lisp_Object tty, tty_type;
731
732 tty = get_future_frame_param
733 (Qtty, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame))
734 ? FRAME_TTY (XFRAME (selected_frame))->name
735 : NULL));
736 if (!NILP (tty))
737 {
738 name = (char *) alloca (SBYTES (tty) + 1);
739 strncpy (name, SDATA (tty), SBYTES (tty));
740 name[SBYTES (tty)] = 0;
741 }
742
743 tty_type = get_future_frame_param
744 (Qtty_type, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame))
745 ? FRAME_TTY (XFRAME (selected_frame))->type
746 : NULL));
747 if (!NILP (tty_type))
748 {
749 type = (char *) alloca (SBYTES (tty_type) + 1);
750 strncpy (type, SDATA (tty_type), SBYTES (tty_type));
751 type[SBYTES (tty_type)] = 0;
752 }
753
754 t = init_tty (name, type, 0); /* Errors are not fatal. */
755 }
756
757 f = make_terminal_frame (t);
758
759 {
760 int width, height;
761 get_tty_size (fileno (FRAME_TTY (f)->input), &width, &height);
762 change_frame_size (f, height, width, 0, 0, 0);
763 }
764
765 adjust_glyphs (f);
766 calculate_costs (f);
767 XSETFRAME (frame, f);
768 Fmodify_frame_parameters (frame, Vdefault_frame_alist);
769 Fmodify_frame_parameters (frame, parms);
770 Fmodify_frame_parameters (frame, Fcons (Fcons (Qwindow_system, Qnil), Qnil));
771 Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty_type,
772 build_string (t->display_info.tty->type)),
773 Qnil));
774 if (t->display_info.tty->name != NULL)
775 Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty,
776 build_string (t->display_info.tty->name)),
777 Qnil));
778 else
779 Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty, Qnil), Qnil));
780
781 /* Make the frame face alist be frame-specific, so that each
782 frame could change its face definitions independently. */
783 f->face_alist = Fcopy_alist (sf->face_alist);
784 /* Simple Fcopy_alist isn't enough, because we need the contents of
785 the vectors which are the CDRs of associations in face_alist to
786 be copied as well. */
787 for (tem = f->face_alist; CONSP (tem); tem = XCDR (tem))
788 XSETCDR (XCAR (tem), Fcopy_sequence (XCDR (XCAR (tem))));
789 return frame;
790 }
791
792 \f
793 /* Perform the switch to frame FRAME.
794
795 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
796 FRAME1 as frame.
797
798 If TRACK is non-zero and the frame that currently has the focus
799 redirects its focus to the selected frame, redirect that focused
800 frame's focus to FRAME instead.
801
802 FOR_DELETION non-zero means that the selected frame is being
803 deleted, which includes the possibility that the frame's terminal
804 is dead. */
805
806 Lisp_Object
807 do_switch_frame (frame, track, for_deletion)
808 Lisp_Object frame;
809 int track, for_deletion;
810 {
811 struct frame *sf = SELECTED_FRAME ();
812
813 /* If FRAME is a switch-frame event, extract the frame we should
814 switch to. */
815 if (CONSP (frame)
816 && EQ (XCAR (frame), Qswitch_frame)
817 && CONSP (XCDR (frame)))
818 frame = XCAR (XCDR (frame));
819
820 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
821 a switch-frame event to arrive after a frame is no longer live,
822 especially when deleting the initial frame during startup. */
823 CHECK_FRAME (frame);
824 if (! FRAME_LIVE_P (XFRAME (frame)))
825 return Qnil;
826
827 if (sf == XFRAME (frame))
828 return frame;
829
830 /* This is too greedy; it causes inappropriate focus redirection
831 that's hard to get rid of. */
832 #if 0
833 /* If a frame's focus has been redirected toward the currently
834 selected frame, we should change the redirection to point to the
835 newly selected frame. This means that if the focus is redirected
836 from a minibufferless frame to a surrogate minibuffer frame, we
837 can use `other-window' to switch between all the frames using
838 that minibuffer frame, and the focus redirection will follow us
839 around. */
840 if (track)
841 {
842 Lisp_Object tail;
843
844 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
845 {
846 Lisp_Object focus;
847
848 if (!FRAMEP (XCAR (tail)))
849 abort ();
850
851 focus = FRAME_FOCUS_FRAME (XFRAME (XCAR (tail)));
852
853 if (FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ())
854 Fredirect_frame_focus (XCAR (tail), frame);
855 }
856 }
857 #else /* ! 0 */
858 /* Instead, apply it only to the frame we're pointing to. */
859 #ifdef HAVE_WINDOW_SYSTEM
860 if (track && FRAME_WINDOW_P (XFRAME (frame)))
861 {
862 Lisp_Object focus, xfocus;
863
864 xfocus = x_get_focus_frame (XFRAME (frame));
865 if (FRAMEP (xfocus))
866 {
867 focus = FRAME_FOCUS_FRAME (XFRAME (xfocus));
868 if (FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ())
869 Fredirect_frame_focus (xfocus, frame);
870 }
871 }
872 #endif /* HAVE_X_WINDOWS */
873 #endif /* ! 0 */
874
875 if (!for_deletion && FRAME_HAS_MINIBUF_P (sf))
876 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf)), 1);
877
878 if (FRAME_TERMCAP_P (XFRAME (selected_frame))
879 && FRAME_TERMCAP_P (XFRAME (frame))
880 && FRAME_TTY (XFRAME (selected_frame)) == FRAME_TTY (XFRAME (frame)))
881 {
882 XFRAME (selected_frame)->async_visible = 2; /* obscured */
883 XFRAME (frame)->async_visible = 1;
884 FRAME_TTY (XFRAME (frame))->top_frame = frame;
885 }
886
887 selected_frame = frame;
888 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame)))
889 last_nonminibuf_frame = XFRAME (selected_frame);
890
891 Fselect_window (XFRAME (frame)->selected_window, Qnil);
892
893 #ifndef WINDOWSNT
894 /* Make sure to switch the tty color mode to that of the newly
895 selected frame. */
896 sf = SELECTED_FRAME ();
897 if (FRAME_TERMCAP_P (sf))
898 {
899 Lisp_Object color_mode_spec, color_mode;
900
901 color_mode_spec = assq_no_quit (Qtty_color_mode, sf->param_alist);
902 if (CONSP (color_mode_spec))
903 color_mode = XCDR (color_mode_spec);
904 else
905 color_mode = make_number (0);
906 set_tty_color_mode (sf, color_mode);
907 }
908 #endif /* !WINDOWSNT */
909
910 /* We want to make sure that the next event generates a frame-switch
911 event to the appropriate frame. This seems kludgy to me, but
912 before you take it out, make sure that evaluating something like
913 (select-window (frame-root-window (new-frame))) doesn't end up
914 with your typing being interpreted in the new frame instead of
915 the one you're actually typing in. */
916 internal_last_event_frame = Qnil;
917
918 return frame;
919 }
920
921 DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 1, "e",
922 doc: /* Select the frame FRAME.
923 Subsequent editing commands apply to its selected window.
924 The selection of FRAME lasts until the next time the user does
925 something to select a different frame, or until the next time this
926 function is called. If you are using a window system, the previously
927 selected frame may be restored as the selected frame after return to
928 the command loop, because it still may have the window system's input
929 focus. On a text-only terminal, the next redisplay will display FRAME.
930
931 This function returns FRAME, or nil if FRAME has been deleted. */)
932 (frame)
933 Lisp_Object frame;
934 {
935 return do_switch_frame (frame, 1, 0);
936 }
937
938
939 DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 1, "e",
940 doc: /* Handle a switch-frame event EVENT.
941 Switch-frame events are usually bound to this function.
942 A switch-frame event tells Emacs that the window manager has requested
943 that the user's events be directed to the frame mentioned in the event.
944 This function selects the selected window of the frame of EVENT.
945
946 If EVENT is frame object, handle it as if it were a switch-frame event
947 to that frame. */)
948 (event)
949 Lisp_Object event;
950 {
951 /* Preserve prefix arg that the command loop just cleared. */
952 current_kboard->Vprefix_arg = Vcurrent_prefix_arg;
953 call1 (Vrun_hooks, Qmouse_leave_buffer_hook);
954 return do_switch_frame (event, 0, 0);
955 }
956
957 DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
958 doc: /* Return the frame that is now selected. */)
959 ()
960 {
961 return selected_frame;
962 }
963 \f
964 DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
965 doc: /* Return the frame object that window WINDOW is on. */)
966 (window)
967 Lisp_Object window;
968 {
969 CHECK_LIVE_WINDOW (window);
970 return XWINDOW (window)->frame;
971 }
972
973 DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0,
974 doc: /* Returns the topmost, leftmost window of FRAME.
975 If omitted, FRAME defaults to the currently selected frame. */)
976 (frame)
977 Lisp_Object frame;
978 {
979 Lisp_Object w;
980
981 if (NILP (frame))
982 w = SELECTED_FRAME ()->root_window;
983 else
984 {
985 CHECK_LIVE_FRAME (frame);
986 w = XFRAME (frame)->root_window;
987 }
988 while (NILP (XWINDOW (w)->buffer))
989 {
990 if (! NILP (XWINDOW (w)->hchild))
991 w = XWINDOW (w)->hchild;
992 else if (! NILP (XWINDOW (w)->vchild))
993 w = XWINDOW (w)->vchild;
994 else
995 abort ();
996 }
997 return w;
998 }
999
1000 DEFUN ("active-minibuffer-window", Factive_minibuffer_window,
1001 Sactive_minibuffer_window, 0, 0, 0,
1002 doc: /* Return the currently active minibuffer window, or nil if none. */)
1003 ()
1004 {
1005 return minibuf_level ? minibuf_window : Qnil;
1006 }
1007
1008 DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0,
1009 doc: /* Returns the root-window of FRAME.
1010 If omitted, FRAME defaults to the currently selected frame. */)
1011 (frame)
1012 Lisp_Object frame;
1013 {
1014 Lisp_Object window;
1015
1016 if (NILP (frame))
1017 window = SELECTED_FRAME ()->root_window;
1018 else
1019 {
1020 CHECK_LIVE_FRAME (frame);
1021 window = XFRAME (frame)->root_window;
1022 }
1023
1024 return window;
1025 }
1026
1027 DEFUN ("frame-selected-window", Fframe_selected_window,
1028 Sframe_selected_window, 0, 1, 0,
1029 doc: /* Return the selected window of frame object FRAME.
1030 If omitted, FRAME defaults to the currently selected frame. */)
1031 (frame)
1032 Lisp_Object frame;
1033 {
1034 Lisp_Object window;
1035
1036 if (NILP (frame))
1037 window = SELECTED_FRAME ()->selected_window;
1038 else
1039 {
1040 CHECK_LIVE_FRAME (frame);
1041 window = XFRAME (frame)->selected_window;
1042 }
1043
1044 return window;
1045 }
1046
1047 DEFUN ("set-frame-selected-window", Fset_frame_selected_window,
1048 Sset_frame_selected_window, 2, 2, 0,
1049 doc: /* Set the selected window of frame object FRAME to WINDOW.
1050 Return WINDOW.
1051 If FRAME is nil, the selected frame is used.
1052 If FRAME is the selected frame, this makes WINDOW the selected window. */)
1053 (frame, window)
1054 Lisp_Object frame, window;
1055 {
1056 if (NILP (frame))
1057 frame = selected_frame;
1058
1059 CHECK_LIVE_FRAME (frame);
1060 CHECK_LIVE_WINDOW (window);
1061
1062 if (! EQ (frame, WINDOW_FRAME (XWINDOW (window))))
1063 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
1064
1065 if (EQ (frame, selected_frame))
1066 return Fselect_window (window, Qnil);
1067
1068 return XFRAME (frame)->selected_window = window;
1069 }
1070
1071 \f
1072 DEFUN ("frame-list", Fframe_list, Sframe_list,
1073 0, 0, 0,
1074 doc: /* Return a list of all frames. */)
1075 ()
1076 {
1077 Lisp_Object frames;
1078 frames = Fcopy_sequence (Vframe_list);
1079 #ifdef HAVE_WINDOW_SYSTEM
1080 if (FRAMEP (tip_frame))
1081 frames = Fdelq (tip_frame, frames);
1082 #endif
1083 return frames;
1084 }
1085
1086 /* Return the next frame in the frame list after FRAME.
1087 If MINIBUF is nil, exclude minibuffer-only frames.
1088 If MINIBUF is a window, include only its own frame
1089 and any frame now using that window as the minibuffer.
1090 If MINIBUF is `visible', include all visible frames.
1091 If MINIBUF is 0, include all visible and iconified frames.
1092 Otherwise, include all frames. */
1093
1094 static Lisp_Object
1095 next_frame (frame, minibuf)
1096 Lisp_Object frame;
1097 Lisp_Object minibuf;
1098 {
1099 Lisp_Object tail;
1100 int passed = 0;
1101
1102 /* There must always be at least one frame in Vframe_list. */
1103 if (! CONSP (Vframe_list))
1104 abort ();
1105
1106 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
1107 forever. Forestall that. */
1108 CHECK_LIVE_FRAME (frame);
1109
1110 while (1)
1111 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
1112 {
1113 Lisp_Object f;
1114
1115 f = XCAR (tail);
1116
1117 if (passed
1118 && ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame))
1119 && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame)))
1120 || (FRAME_TERMCAP_P (XFRAME (f)) && FRAME_TERMCAP_P (XFRAME (frame))
1121 && FRAME_TTY (XFRAME (f)) == FRAME_TTY (XFRAME (frame)))))
1122 {
1123 /* Decide whether this frame is eligible to be returned. */
1124
1125 /* If we've looped all the way around without finding any
1126 eligible frames, return the original frame. */
1127 if (EQ (f, frame))
1128 return f;
1129
1130 /* Let minibuf decide if this frame is acceptable. */
1131 if (NILP (minibuf))
1132 {
1133 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
1134 return f;
1135 }
1136 else if (EQ (minibuf, Qvisible))
1137 {
1138 FRAME_SAMPLE_VISIBILITY (XFRAME (f));
1139 if (FRAME_VISIBLE_P (XFRAME (f)))
1140 return f;
1141 }
1142 else if (INTEGERP (minibuf) && XINT (minibuf) == 0)
1143 {
1144 FRAME_SAMPLE_VISIBILITY (XFRAME (f));
1145 if (FRAME_VISIBLE_P (XFRAME (f))
1146 || FRAME_ICONIFIED_P (XFRAME (f)))
1147 return f;
1148 }
1149 else if (WINDOWP (minibuf))
1150 {
1151 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf)
1152 || EQ (WINDOW_FRAME (XWINDOW (minibuf)), f)
1153 || EQ (WINDOW_FRAME (XWINDOW (minibuf)),
1154 FRAME_FOCUS_FRAME (XFRAME (f))))
1155 return f;
1156 }
1157 else
1158 return f;
1159 }
1160
1161 if (EQ (frame, f))
1162 passed++;
1163 }
1164 }
1165
1166 /* Return the previous frame in the frame list before FRAME.
1167 If MINIBUF is nil, exclude minibuffer-only frames.
1168 If MINIBUF is a window, include only its own frame
1169 and any frame now using that window as the minibuffer.
1170 If MINIBUF is `visible', include all visible frames.
1171 If MINIBUF is 0, include all visible and iconified frames.
1172 Otherwise, include all frames. */
1173
1174 static Lisp_Object
1175 prev_frame (frame, minibuf)
1176 Lisp_Object frame;
1177 Lisp_Object minibuf;
1178 {
1179 Lisp_Object tail;
1180 Lisp_Object prev;
1181
1182 /* There must always be at least one frame in Vframe_list. */
1183 if (! CONSP (Vframe_list))
1184 abort ();
1185
1186 prev = Qnil;
1187 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
1188 {
1189 Lisp_Object f;
1190
1191 f = XCAR (tail);
1192 if (!FRAMEP (f))
1193 abort ();
1194
1195 if (EQ (frame, f) && !NILP (prev))
1196 return prev;
1197
1198 if ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame))
1199 && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame)))
1200 || (FRAME_TERMCAP_P (XFRAME (f)) && FRAME_TERMCAP_P (XFRAME (frame))
1201 && FRAME_TTY (XFRAME (f)) == FRAME_TTY (XFRAME (frame))))
1202 {
1203 /* Decide whether this frame is eligible to be returned,
1204 according to minibuf. */
1205 if (NILP (minibuf))
1206 {
1207 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
1208 prev = f;
1209 }
1210 else if (WINDOWP (minibuf))
1211 {
1212 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf)
1213 || EQ (WINDOW_FRAME (XWINDOW (minibuf)), f)
1214 || EQ (WINDOW_FRAME (XWINDOW (minibuf)),
1215 FRAME_FOCUS_FRAME (XFRAME (f))))
1216 prev = f;
1217 }
1218 else if (EQ (minibuf, Qvisible))
1219 {
1220 FRAME_SAMPLE_VISIBILITY (XFRAME (f));
1221 if (FRAME_VISIBLE_P (XFRAME (f)))
1222 prev = f;
1223 }
1224 else if (XFASTINT (minibuf) == 0)
1225 {
1226 FRAME_SAMPLE_VISIBILITY (XFRAME (f));
1227 if (FRAME_VISIBLE_P (XFRAME (f))
1228 || FRAME_ICONIFIED_P (XFRAME (f)))
1229 prev = f;
1230 }
1231 else
1232 prev = f;
1233 }
1234 }
1235
1236 /* We've scanned the entire list. */
1237 if (NILP (prev))
1238 /* We went through the whole frame list without finding a single
1239 acceptable frame. Return the original frame. */
1240 return frame;
1241 else
1242 /* There were no acceptable frames in the list before FRAME; otherwise,
1243 we would have returned directly from the loop. Since PREV is the last
1244 acceptable frame in the list, return it. */
1245 return prev;
1246 }
1247
1248
1249 DEFUN ("next-frame", Fnext_frame, Snext_frame, 0, 2, 0,
1250 doc: /* Return the next frame in the frame list after FRAME.
1251 It considers only frames on the same terminal as FRAME.
1252 By default, skip minibuffer-only frames.
1253 If omitted, FRAME defaults to the selected frame.
1254 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1255 If MINIFRAME is a window, include only its own frame
1256 and any frame now using that window as the minibuffer.
1257 If MINIFRAME is `visible', include all visible frames.
1258 If MINIFRAME is 0, include all visible and iconified frames.
1259 Otherwise, include all frames. */)
1260 (frame, miniframe)
1261 Lisp_Object frame, miniframe;
1262 {
1263 if (NILP (frame))
1264 frame = selected_frame;
1265
1266 CHECK_LIVE_FRAME (frame);
1267 return next_frame (frame, miniframe);
1268 }
1269
1270 DEFUN ("previous-frame", Fprevious_frame, Sprevious_frame, 0, 2, 0,
1271 doc: /* Return the previous frame in the frame list before FRAME.
1272 It considers only frames on the same terminal as FRAME.
1273 By default, skip minibuffer-only frames.
1274 If omitted, FRAME defaults to the selected frame.
1275 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1276 If MINIFRAME is a window, include only its own frame
1277 and any frame now using that window as the minibuffer.
1278 If MINIFRAME is `visible', include all visible frames.
1279 If MINIFRAME is 0, include all visible and iconified frames.
1280 Otherwise, include all frames. */)
1281 (frame, miniframe)
1282 Lisp_Object frame, miniframe;
1283 {
1284 if (NILP (frame))
1285 frame = selected_frame;
1286 CHECK_LIVE_FRAME (frame);
1287 return prev_frame (frame, miniframe);
1288 }
1289 \f
1290 /* Return 1 if it is ok to delete frame F;
1291 0 if all frames aside from F are invisible.
1292 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1293
1294 int
1295 other_visible_frames (f)
1296 FRAME_PTR f;
1297 {
1298 /* We know the selected frame is visible,
1299 so if F is some other frame, it can't be the sole visible one. */
1300 if (f == SELECTED_FRAME ())
1301 {
1302 Lisp_Object frames;
1303 int count = 0;
1304
1305 for (frames = Vframe_list;
1306 CONSP (frames);
1307 frames = XCDR (frames))
1308 {
1309 Lisp_Object this;
1310
1311 this = XCAR (frames);
1312 /* Verify that the frame's window still exists
1313 and we can still talk to it. And note any recent change
1314 in visibility. */
1315 #ifdef HAVE_WINDOW_SYSTEM
1316 if (FRAME_WINDOW_P (XFRAME (this)))
1317 {
1318 x_sync (XFRAME (this));
1319 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1320 }
1321 #endif
1322
1323 if (FRAME_VISIBLE_P (XFRAME (this))
1324 || FRAME_ICONIFIED_P (XFRAME (this))
1325 /* Allow deleting the terminal frame when at least
1326 one X frame exists! */
1327 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f)))
1328 count++;
1329 }
1330 return count > 1;
1331 }
1332 return 1;
1333 }
1334
1335 /* Error handler for `delete-frame-functions'. */
1336 static Lisp_Object
1337 delete_frame_handler (Lisp_Object arg)
1338 {
1339 add_to_log ("Error during `delete-frame': %s", arg, Qnil);
1340 return Qnil;
1341 }
1342
1343 DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "",
1344 doc: /* Delete FRAME, permanently eliminating it from use.
1345 If omitted, FRAME defaults to the selected frame.
1346 A frame may not be deleted if its minibuffer is used by other frames.
1347 Normally, you may not delete a frame if all other frames are invisible,
1348 but if the second optional argument FORCE is non-nil, you may do so.
1349
1350 This function runs `delete-frame-functions' before actually deleting the
1351 frame, unless the frame is a tooltip.
1352 The functions are run with one arg, the frame to be deleted. */)
1353 (frame, force)
1354 Lisp_Object frame, force;
1355 {
1356 struct frame *f;
1357 struct frame *sf = SELECTED_FRAME ();
1358 struct kboard *kb;
1359
1360 int minibuffer_selected;
1361
1362 if (EQ (frame, Qnil))
1363 {
1364 f = sf;
1365 XSETFRAME (frame, f);
1366 }
1367 else
1368 {
1369 CHECK_FRAME (frame);
1370 f = XFRAME (frame);
1371 }
1372
1373 if (! FRAME_LIVE_P (f))
1374 return Qnil;
1375
1376 if (NILP (force) && !other_visible_frames (f)
1377 #ifdef MAC_OS8
1378 /* Terminal frame deleted before any other visible frames are
1379 created. */
1380 && strcmp (SDATA (f->name), "F1") != 0
1381 #endif
1382 )
1383 error ("Attempt to delete the sole visible or iconified frame");
1384
1385 #if 0
1386 /* This is a nice idea, but x_connection_closed needs to be able
1387 to delete the last frame, if it is gone. */
1388 if (NILP (XCDR (Vframe_list)))
1389 error ("Attempt to delete the only frame");
1390 #endif
1391
1392 /* Does this frame have a minibuffer, and is it the surrogate
1393 minibuffer for any other frame? */
1394 if (FRAME_HAS_MINIBUF_P (XFRAME (frame)))
1395 {
1396 Lisp_Object frames;
1397
1398 for (frames = Vframe_list;
1399 CONSP (frames);
1400 frames = XCDR (frames))
1401 {
1402 Lisp_Object this;
1403 this = XCAR (frames);
1404
1405 if (! EQ (this, frame)
1406 && EQ (frame,
1407 WINDOW_FRAME (XWINDOW
1408 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1409 error ("Attempt to delete a surrogate minibuffer frame");
1410 }
1411 }
1412
1413 /* Run `delete-frame-functions' unless frame is a tooltip. */
1414 if (!NILP (Vrun_hooks)
1415 && NILP (Fframe_parameter (frame, intern ("tooltip"))))
1416 {
1417 Lisp_Object args[2];
1418 struct gcpro gcpro1, gcpro2;
1419
1420 /* Don't let a rogue function in `delete-frame-functions'
1421 prevent the frame deletion. */
1422 GCPRO2 (args[0], args[1]);
1423 args[0] = intern ("delete-frame-functions");
1424 args[1] = frame;
1425 internal_condition_case_2 (Frun_hook_with_args, 2, args,
1426 Qt, delete_frame_handler);
1427 UNGCPRO;
1428 }
1429
1430 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1431 if (! FRAME_LIVE_P (f))
1432 return Qnil;
1433
1434 minibuffer_selected = EQ (minibuf_window, selected_window);
1435
1436 /* Don't let the frame remain selected. */
1437 if (f == sf)
1438 {
1439 Lisp_Object tail, frame1;
1440
1441 /* Look for another visible frame on the same terminal. */
1442 frame1 = next_frame (frame, Qvisible);
1443
1444 /* If there is none, find *some* other frame. */
1445 if (NILP (frame1) || EQ (frame1, frame))
1446 {
1447 FOR_EACH_FRAME (tail, frame1)
1448 {
1449 if (! EQ (frame, frame1) && FRAME_LIVE_P (XFRAME (frame1)))
1450 break;
1451 }
1452 }
1453
1454 do_switch_frame (frame1, 0, 1);
1455 sf = SELECTED_FRAME ();
1456 }
1457
1458 /* Don't allow minibuf_window to remain on a deleted frame. */
1459 if (EQ (f->minibuffer_window, minibuf_window))
1460 {
1461 Fset_window_buffer (sf->minibuffer_window,
1462 XWINDOW (minibuf_window)->buffer, Qnil);
1463 minibuf_window = sf->minibuffer_window;
1464
1465 /* If the dying minibuffer window was selected,
1466 select the new one. */
1467 if (minibuffer_selected)
1468 Fselect_window (minibuf_window, Qnil);
1469 }
1470
1471 /* Don't let echo_area_window to remain on a deleted frame. */
1472 if (EQ (f->minibuffer_window, echo_area_window))
1473 echo_area_window = sf->minibuffer_window;
1474
1475 /* Don't allow other frames to refer to a deleted frame in their
1476 'environment parameter. */
1477 {
1478 Lisp_Object tail, frame1;
1479 Lisp_Object env = get_frame_param (XFRAME (frame), Qenvironment);
1480 FOR_EACH_FRAME (tail, frame1)
1481 {
1482 if (EQ (frame, frame1) || !FRAME_LIVE_P (XFRAME (frame1)))
1483 continue;
1484 if (EQ (frame, get_frame_param (XFRAME (frame1), Qenvironment)))
1485 {
1486 store_frame_param (XFRAME (frame1), Qenvironment, env);
1487 if (!FRAMEP (env))
1488 env = frame1;
1489 }
1490 }
1491 }
1492
1493 /* Clear any X selections for this frame. */
1494 #ifdef HAVE_X_WINDOWS
1495 if (FRAME_X_P (f))
1496 x_clear_frame_selections (f);
1497 #endif
1498 #ifdef MAC_OS
1499 if (FRAME_MAC_P (f))
1500 x_clear_frame_selections (f);
1501 #endif
1502
1503 /* Free glyphs.
1504 This function must be called before the window tree of the
1505 frame is deleted because windows contain dynamically allocated
1506 memory. */
1507 free_glyphs (f);
1508
1509 /* Mark all the windows that used to be on FRAME as deleted, and then
1510 remove the reference to them. */
1511 delete_all_subwindows (XWINDOW (f->root_window));
1512 f->root_window = Qnil;
1513
1514 Vframe_list = Fdelq (frame, Vframe_list);
1515 FRAME_SET_VISIBLE (f, 0);
1516
1517 if (f->namebuf)
1518 xfree (f->namebuf);
1519 if (f->decode_mode_spec_buffer)
1520 xfree (f->decode_mode_spec_buffer);
1521 if (FRAME_INSERT_COST (f))
1522 xfree (FRAME_INSERT_COST (f));
1523 if (FRAME_DELETEN_COST (f))
1524 xfree (FRAME_DELETEN_COST (f));
1525 if (FRAME_INSERTN_COST (f))
1526 xfree (FRAME_INSERTN_COST (f));
1527 if (FRAME_DELETE_COST (f))
1528 xfree (FRAME_DELETE_COST (f));
1529 if (FRAME_MESSAGE_BUF (f))
1530 xfree (FRAME_MESSAGE_BUF (f));
1531
1532 /* Since some events are handled at the interrupt level, we may get
1533 an event for f at any time; if we zero out the frame's terminal
1534 now, then we may trip up the event-handling code. Instead, we'll
1535 promise that the terminal of the frame must be valid until we
1536 have called the window-system-dependent frame destruction
1537 routine. */
1538
1539 if (FRAME_TERMINAL (f)->delete_frame_hook)
1540 (*FRAME_TERMINAL (f)->delete_frame_hook) (f);
1541
1542 {
1543 struct terminal *terminal = FRAME_TERMINAL (f);
1544 f->output_data.nothing = 0;
1545 f->terminal = 0; /* Now the frame is dead. */
1546
1547 /* If needed, delete the terminal that this frame was on.
1548 (This must be done after the frame is killed.) */
1549 terminal->reference_count--;
1550 if (terminal->reference_count == 0)
1551 {
1552 kb = NULL;
1553 if (terminal->delete_terminal_hook)
1554 (*terminal->delete_terminal_hook) (terminal);
1555 else
1556 delete_terminal (terminal);
1557 }
1558 #ifdef MULTI_KBOARD
1559 else
1560 kb = terminal->kboard;
1561 #endif
1562 }
1563
1564 /* If we've deleted the last_nonminibuf_frame, then try to find
1565 another one. */
1566 if (f == last_nonminibuf_frame)
1567 {
1568 Lisp_Object frames;
1569
1570 last_nonminibuf_frame = 0;
1571
1572 for (frames = Vframe_list;
1573 CONSP (frames);
1574 frames = XCDR (frames))
1575 {
1576 f = XFRAME (XCAR (frames));
1577 if (!FRAME_MINIBUF_ONLY_P (f))
1578 {
1579 last_nonminibuf_frame = f;
1580 break;
1581 }
1582 }
1583 }
1584
1585 /* If there's no other frame on the same kboard, get out of
1586 single-kboard state if we're in it for this kboard. */
1587 if (kb != NULL)
1588 {
1589 Lisp_Object frames;
1590 /* Some frame we found on the same kboard, or nil if there are none. */
1591 Lisp_Object frame_on_same_kboard;
1592
1593 frame_on_same_kboard = Qnil;
1594
1595 for (frames = Vframe_list;
1596 CONSP (frames);
1597 frames = XCDR (frames))
1598 {
1599 Lisp_Object this;
1600 struct frame *f1;
1601
1602 this = XCAR (frames);
1603 if (!FRAMEP (this))
1604 abort ();
1605 f1 = XFRAME (this);
1606
1607 if (kb == FRAME_KBOARD (f1))
1608 frame_on_same_kboard = this;
1609 }
1610
1611 if (NILP (frame_on_same_kboard))
1612 not_single_kboard_state (kb);
1613 }
1614
1615
1616 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1617 find another one. Prefer minibuffer-only frames, but also notice
1618 frames with other windows. */
1619 if (kb != NULL && EQ (frame, kb->Vdefault_minibuffer_frame))
1620 {
1621 Lisp_Object frames;
1622
1623 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1624 Lisp_Object frame_with_minibuf;
1625 /* Some frame we found on the same kboard, or nil if there are none. */
1626 Lisp_Object frame_on_same_kboard;
1627
1628 frame_on_same_kboard = Qnil;
1629 frame_with_minibuf = Qnil;
1630
1631 for (frames = Vframe_list;
1632 CONSP (frames);
1633 frames = XCDR (frames))
1634 {
1635 Lisp_Object this;
1636 struct frame *f1;
1637
1638 this = XCAR (frames);
1639 if (!FRAMEP (this))
1640 abort ();
1641 f1 = XFRAME (this);
1642
1643 /* Consider only frames on the same kboard
1644 and only those with minibuffers. */
1645 if (kb == FRAME_KBOARD (f1)
1646 && FRAME_HAS_MINIBUF_P (f1))
1647 {
1648 frame_with_minibuf = this;
1649 if (FRAME_MINIBUF_ONLY_P (f1))
1650 break;
1651 }
1652
1653 if (kb == FRAME_KBOARD (f1))
1654 frame_on_same_kboard = this;
1655 }
1656
1657 if (!NILP (frame_on_same_kboard))
1658 {
1659 /* We know that there must be some frame with a minibuffer out
1660 there. If this were not true, all of the frames present
1661 would have to be minibufferless, which implies that at some
1662 point their minibuffer frames must have been deleted, but
1663 that is prohibited at the top; you can't delete surrogate
1664 minibuffer frames. */
1665 if (NILP (frame_with_minibuf))
1666 abort ();
1667
1668 kb->Vdefault_minibuffer_frame = frame_with_minibuf;
1669 }
1670 else
1671 /* No frames left on this kboard--say no minibuffer either. */
1672 kb->Vdefault_minibuffer_frame = Qnil;
1673 }
1674
1675 /* Cause frame titles to update--necessary if we now have just one frame. */
1676 update_mode_lines = 1;
1677
1678 return Qnil;
1679 }
1680 \f
1681 /* Return mouse position in character cell units. */
1682
1683 DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0,
1684 doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1685 The position is given in character cells, where (0, 0) is the
1686 upper-left corner of the frame, X is the horizontal offset, and Y is
1687 the vertical offset.
1688 If Emacs is running on a mouseless terminal or hasn't been programmed
1689 to read the mouse position, it returns the selected frame for FRAME
1690 and nil for X and Y.
1691 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1692 passing the normal return value to that function as an argument,
1693 and returns whatever that function returns. */)
1694 ()
1695 {
1696 FRAME_PTR f;
1697 Lisp_Object lispy_dummy;
1698 enum scroll_bar_part party_dummy;
1699 Lisp_Object x, y, retval;
1700 int col, row;
1701 unsigned long long_dummy;
1702 struct gcpro gcpro1;
1703
1704 f = SELECTED_FRAME ();
1705 x = y = Qnil;
1706
1707 #ifdef HAVE_MOUSE
1708 /* It's okay for the hook to refrain from storing anything. */
1709 if (FRAME_TERMINAL (f)->mouse_position_hook)
1710 (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, -1,
1711 &lispy_dummy, &party_dummy,
1712 &x, &y,
1713 &long_dummy);
1714 if (! NILP (x))
1715 {
1716 col = XINT (x);
1717 row = XINT (y);
1718 pixel_to_glyph_coords (f, col, row, &col, &row, NULL, 1);
1719 XSETINT (x, col);
1720 XSETINT (y, row);
1721 }
1722 #endif
1723 XSETFRAME (lispy_dummy, f);
1724 retval = Fcons (lispy_dummy, Fcons (x, y));
1725 GCPRO1 (retval);
1726 if (!NILP (Vmouse_position_function))
1727 retval = call1 (Vmouse_position_function, retval);
1728 RETURN_UNGCPRO (retval);
1729 }
1730
1731 DEFUN ("mouse-pixel-position", Fmouse_pixel_position,
1732 Smouse_pixel_position, 0, 0, 0,
1733 doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1734 The position is given in pixel units, where (0, 0) is the
1735 upper-left corner of the frame, X is the horizontal offset, and Y is
1736 the vertical offset.
1737 If Emacs is running on a mouseless terminal or hasn't been programmed
1738 to read the mouse position, it returns the selected frame for FRAME
1739 and nil for X and Y. */)
1740 ()
1741 {
1742 FRAME_PTR f;
1743 Lisp_Object lispy_dummy;
1744 enum scroll_bar_part party_dummy;
1745 Lisp_Object x, y;
1746 unsigned long long_dummy;
1747
1748 f = SELECTED_FRAME ();
1749 x = y = Qnil;
1750
1751 #ifdef HAVE_MOUSE
1752 /* It's okay for the hook to refrain from storing anything. */
1753 if (FRAME_TERMINAL (f)->mouse_position_hook)
1754 (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, -1,
1755 &lispy_dummy, &party_dummy,
1756 &x, &y,
1757 &long_dummy);
1758 #endif
1759 XSETFRAME (lispy_dummy, f);
1760 return Fcons (lispy_dummy, Fcons (x, y));
1761 }
1762
1763 DEFUN ("set-mouse-position", Fset_mouse_position, Sset_mouse_position, 3, 3, 0,
1764 doc: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1765 Coordinates are relative to the frame, not a window,
1766 so the coordinates of the top left character in the frame
1767 may be nonzero due to left-hand scroll bars or the menu bar.
1768
1769 The position is given in character cells, where (0, 0) is the
1770 upper-left corner of the frame, X is the horizontal offset, and Y is
1771 the vertical offset.
1772
1773 This function is a no-op for an X frame that is not visible.
1774 If you have just created a frame, you must wait for it to become visible
1775 before calling this function on it, like this.
1776 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1777 (frame, x, y)
1778 Lisp_Object frame, x, y;
1779 {
1780 CHECK_LIVE_FRAME (frame);
1781 CHECK_NUMBER (x);
1782 CHECK_NUMBER (y);
1783
1784 /* I think this should be done with a hook. */
1785 #ifdef HAVE_WINDOW_SYSTEM
1786 if (FRAME_WINDOW_P (XFRAME (frame)))
1787 /* Warping the mouse will cause enternotify and focus events. */
1788 x_set_mouse_position (XFRAME (frame), XINT (x), XINT (y));
1789 #else
1790 #if defined (MSDOS) && defined (HAVE_MOUSE)
1791 if (FRAME_MSDOS_P (XFRAME (frame)))
1792 {
1793 Fselect_frame (frame);
1794 mouse_moveto (XINT (x), XINT (y));
1795 }
1796 #endif
1797 #endif
1798
1799 return Qnil;
1800 }
1801
1802 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position,
1803 Sset_mouse_pixel_position, 3, 3, 0,
1804 doc: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1805 The position is given in pixels, where (0, 0) is the upper-left corner
1806 of the frame, X is the horizontal offset, and Y is the vertical offset.
1807
1808 Note, this is a no-op for an X frame that is not visible.
1809 If you have just created a frame, you must wait for it to become visible
1810 before calling this function on it, like this.
1811 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1812 (frame, x, y)
1813 Lisp_Object frame, x, y;
1814 {
1815 CHECK_LIVE_FRAME (frame);
1816 CHECK_NUMBER (x);
1817 CHECK_NUMBER (y);
1818
1819 /* I think this should be done with a hook. */
1820 #ifdef HAVE_WINDOW_SYSTEM
1821 if (FRAME_WINDOW_P (XFRAME (frame)))
1822 /* Warping the mouse will cause enternotify and focus events. */
1823 x_set_mouse_pixel_position (XFRAME (frame), XINT (x), XINT (y));
1824 #else
1825 #if defined (MSDOS) && defined (HAVE_MOUSE)
1826 if (FRAME_MSDOS_P (XFRAME (frame)))
1827 {
1828 Fselect_frame (frame);
1829 mouse_moveto (XINT (x), XINT (y));
1830 }
1831 #endif
1832 #endif
1833
1834 return Qnil;
1835 }
1836 \f
1837 static void make_frame_visible_1 P_ ((Lisp_Object));
1838
1839 DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
1840 0, 1, "",
1841 doc: /* Make the frame FRAME visible (assuming it is an X window).
1842 If omitted, FRAME defaults to the currently selected frame. */)
1843 (frame)
1844 Lisp_Object frame;
1845 {
1846 if (NILP (frame))
1847 frame = selected_frame;
1848
1849 CHECK_LIVE_FRAME (frame);
1850
1851 /* I think this should be done with a hook. */
1852 #ifdef HAVE_WINDOW_SYSTEM
1853 if (FRAME_WINDOW_P (XFRAME (frame)))
1854 {
1855 FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
1856 x_make_frame_visible (XFRAME (frame));
1857 }
1858 #endif
1859
1860 make_frame_visible_1 (XFRAME (frame)->root_window);
1861
1862 /* Make menu bar update for the Buffers and Frames menus. */
1863 windows_or_buffers_changed++;
1864
1865 return frame;
1866 }
1867
1868 /* Update the display_time slot of the buffers shown in WINDOW
1869 and all its descendents. */
1870
1871 static void
1872 make_frame_visible_1 (window)
1873 Lisp_Object window;
1874 {
1875 struct window *w;
1876
1877 for (;!NILP (window); window = w->next)
1878 {
1879 w = XWINDOW (window);
1880
1881 if (!NILP (w->buffer))
1882 XBUFFER (w->buffer)->display_time = Fcurrent_time ();
1883
1884 if (!NILP (w->vchild))
1885 make_frame_visible_1 (w->vchild);
1886 if (!NILP (w->hchild))
1887 make_frame_visible_1 (w->hchild);
1888 }
1889 }
1890
1891 DEFUN ("make-frame-invisible", Fmake_frame_invisible, Smake_frame_invisible,
1892 0, 2, "",
1893 doc: /* Make the frame FRAME invisible (assuming it is an X window).
1894 If omitted, FRAME defaults to the currently selected frame.
1895 Normally you may not make FRAME invisible if all other frames are invisible,
1896 but if the second optional argument FORCE is non-nil, you may do so. */)
1897 (frame, force)
1898 Lisp_Object frame, force;
1899 {
1900 if (NILP (frame))
1901 frame = selected_frame;
1902
1903 CHECK_LIVE_FRAME (frame);
1904
1905 if (NILP (force) && !other_visible_frames (XFRAME (frame)))
1906 error ("Attempt to make invisible the sole visible or iconified frame");
1907
1908 #if 0 /* This isn't logically necessary, and it can do GC. */
1909 /* Don't let the frame remain selected. */
1910 if (EQ (frame, selected_frame))
1911 do_switch_frame (next_frame (frame, Qt), 0, 0)
1912 #endif
1913
1914 /* Don't allow minibuf_window to remain on a deleted frame. */
1915 if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window))
1916 {
1917 struct frame *sf = XFRAME (selected_frame);
1918 Fset_window_buffer (sf->minibuffer_window,
1919 XWINDOW (minibuf_window)->buffer, Qnil);
1920 minibuf_window = sf->minibuffer_window;
1921 }
1922
1923 /* I think this should be done with a hook. */
1924 #ifdef HAVE_WINDOW_SYSTEM
1925 if (FRAME_WINDOW_P (XFRAME (frame)))
1926 x_make_frame_invisible (XFRAME (frame));
1927 #endif
1928
1929 /* Make menu bar update for the Buffers and Frames menus. */
1930 windows_or_buffers_changed++;
1931
1932 return Qnil;
1933 }
1934
1935 DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame,
1936 0, 1, "",
1937 doc: /* Make the frame FRAME into an icon.
1938 If omitted, FRAME defaults to the currently selected frame. */)
1939 (frame)
1940 Lisp_Object frame;
1941 {
1942 if (NILP (frame))
1943 frame = selected_frame;
1944
1945 CHECK_LIVE_FRAME (frame);
1946
1947 #if 0 /* This isn't logically necessary, and it can do GC. */
1948 /* Don't let the frame remain selected. */
1949 if (EQ (frame, selected_frame))
1950 Fhandle_switch_frame (next_frame (frame, Qt));
1951 #endif
1952
1953 /* Don't allow minibuf_window to remain on a deleted frame. */
1954 if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window))
1955 {
1956 struct frame *sf = XFRAME (selected_frame);
1957 Fset_window_buffer (sf->minibuffer_window,
1958 XWINDOW (minibuf_window)->buffer, Qnil);
1959 minibuf_window = sf->minibuffer_window;
1960 }
1961
1962 /* I think this should be done with a hook. */
1963 #ifdef HAVE_WINDOW_SYSTEM
1964 if (FRAME_WINDOW_P (XFRAME (frame)))
1965 x_iconify_frame (XFRAME (frame));
1966 #endif
1967
1968 /* Make menu bar update for the Buffers and Frames menus. */
1969 windows_or_buffers_changed++;
1970
1971 return Qnil;
1972 }
1973
1974 DEFUN ("frame-visible-p", Fframe_visible_p, Sframe_visible_p,
1975 1, 1, 0,
1976 doc: /* Return t if FRAME is now \"visible\" (actually in use for display).
1977 A frame that is not \"visible\" is not updated and, if it works through
1978 a window system, it may not show at all.
1979 Return the symbol `icon' if frame is visible only as an icon.
1980
1981 On a text-only terminal, all frames are considered visible, whether
1982 they are currently being displayed or not, and this function returns t
1983 for all frames. */)
1984 (frame)
1985 Lisp_Object frame;
1986 {
1987 CHECK_LIVE_FRAME (frame);
1988
1989 FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
1990
1991 if (FRAME_VISIBLE_P (XFRAME (frame)))
1992 return Qt;
1993 if (FRAME_ICONIFIED_P (XFRAME (frame)))
1994 return Qicon;
1995 return Qnil;
1996 }
1997
1998 DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list,
1999 0, 0, 0,
2000 doc: /* Return a list of all frames now \"visible\" (being updated). */)
2001 ()
2002 {
2003 Lisp_Object tail, frame;
2004 struct frame *f;
2005 Lisp_Object value;
2006
2007 value = Qnil;
2008 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
2009 {
2010 frame = XCAR (tail);
2011 if (!FRAMEP (frame))
2012 continue;
2013 f = XFRAME (frame);
2014 if (FRAME_VISIBLE_P (f))
2015 value = Fcons (frame, value);
2016 }
2017 return value;
2018 }
2019
2020
2021 DEFUN ("raise-frame", Fraise_frame, Sraise_frame, 0, 1, "",
2022 doc: /* Bring FRAME to the front, so it occludes any frames it overlaps.
2023 If FRAME is invisible or iconified, make it visible.
2024 If you don't specify a frame, the selected frame is used.
2025 If Emacs is displaying on an ordinary terminal or some other device which
2026 doesn't support multiple overlapping frames, this function does nothing. */)
2027 (frame)
2028 Lisp_Object frame;
2029 {
2030 struct frame *f;
2031 if (NILP (frame))
2032 frame = selected_frame;
2033
2034 CHECK_LIVE_FRAME (frame);
2035
2036 f = XFRAME (frame);
2037
2038 /* Do like the documentation says. */
2039 Fmake_frame_visible (frame);
2040
2041 if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
2042 (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 1);
2043
2044 return Qnil;
2045 }
2046
2047 /* Should we have a corresponding function called Flower_Power? */
2048 DEFUN ("lower-frame", Flower_frame, Slower_frame, 0, 1, "",
2049 doc: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2050 If you don't specify a frame, the selected frame is used.
2051 If Emacs is displaying on an ordinary terminal or some other device which
2052 doesn't support multiple overlapping frames, this function does nothing. */)
2053 (frame)
2054 Lisp_Object frame;
2055 {
2056 struct frame *f;
2057
2058 if (NILP (frame))
2059 frame = selected_frame;
2060
2061 CHECK_LIVE_FRAME (frame);
2062
2063 f = XFRAME (frame);
2064
2065 if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
2066 (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 0);
2067
2068 return Qnil;
2069 }
2070
2071 \f
2072 DEFUN ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus,
2073 1, 2, 0,
2074 doc: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2075 In other words, switch-frame events caused by events in FRAME will
2076 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2077 FOCUS-FRAME after reading an event typed at FRAME.
2078
2079 If FOCUS-FRAME is omitted or nil, any existing redirection is
2080 cancelled, and the frame again receives its own keystrokes.
2081
2082 Focus redirection is useful for temporarily redirecting keystrokes to
2083 a surrogate minibuffer frame when a frame doesn't have its own
2084 minibuffer window.
2085
2086 A frame's focus redirection can be changed by `select-frame'. If frame
2087 FOO is selected, and then a different frame BAR is selected, any
2088 frames redirecting their focus to FOO are shifted to redirect their
2089 focus to BAR. This allows focus redirection to work properly when the
2090 user switches from one frame to another using `select-window'.
2091
2092 This means that a frame whose focus is redirected to itself is treated
2093 differently from a frame whose focus is redirected to nil; the former
2094 is affected by `select-frame', while the latter is not.
2095
2096 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2097 (frame, focus_frame)
2098 Lisp_Object frame, focus_frame;
2099 {
2100 struct frame *f;
2101
2102 /* Note that we don't check for a live frame here. It's reasonable
2103 to redirect the focus of a frame you're about to delete, if you
2104 know what other frame should receive those keystrokes. */
2105 CHECK_FRAME (frame);
2106
2107 if (! NILP (focus_frame))
2108 CHECK_LIVE_FRAME (focus_frame);
2109
2110 f = XFRAME (frame);
2111
2112 f->focus_frame = focus_frame;
2113
2114 if (FRAME_TERMINAL (f)->frame_rehighlight_hook)
2115 (*FRAME_TERMINAL (f)->frame_rehighlight_hook) (f);
2116
2117 return Qnil;
2118 }
2119
2120
2121 DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0,
2122 doc: /* Return the frame to which FRAME's keystrokes are currently being sent.
2123 This returns nil if FRAME's focus is not redirected.
2124 See `redirect-frame-focus'. */)
2125 (frame)
2126 Lisp_Object frame;
2127 {
2128 CHECK_LIVE_FRAME (frame);
2129
2130 return FRAME_FOCUS_FRAME (XFRAME (frame));
2131 }
2132
2133
2134 \f
2135 /* Return the value of frame parameter PROP in frame FRAME. */
2136
2137 Lisp_Object
2138 get_frame_param (frame, prop)
2139 register struct frame *frame;
2140 Lisp_Object prop;
2141 {
2142 register Lisp_Object tem;
2143
2144 tem = Fassq (prop, frame->param_alist);
2145 if (EQ (tem, Qnil))
2146 return tem;
2147 return Fcdr (tem);
2148 }
2149
2150 /* Return the buffer-predicate of the selected frame. */
2151
2152 Lisp_Object
2153 frame_buffer_predicate (frame)
2154 Lisp_Object frame;
2155 {
2156 return XFRAME (frame)->buffer_predicate;
2157 }
2158
2159 /* Return the buffer-list of the selected frame. */
2160
2161 Lisp_Object
2162 frame_buffer_list (frame)
2163 Lisp_Object frame;
2164 {
2165 return XFRAME (frame)->buffer_list;
2166 }
2167
2168 /* Set the buffer-list of the selected frame. */
2169
2170 void
2171 set_frame_buffer_list (frame, list)
2172 Lisp_Object frame, list;
2173 {
2174 XFRAME (frame)->buffer_list = list;
2175 }
2176
2177 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2178
2179 void
2180 frames_discard_buffer (buffer)
2181 Lisp_Object buffer;
2182 {
2183 Lisp_Object frame, tail;
2184
2185 FOR_EACH_FRAME (tail, frame)
2186 {
2187 XFRAME (frame)->buffer_list
2188 = Fdelq (buffer, XFRAME (frame)->buffer_list);
2189 XFRAME (frame)->buried_buffer_list
2190 = Fdelq (buffer, XFRAME (frame)->buried_buffer_list);
2191 }
2192 }
2193
2194 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2195 If the alist already has an element for PROP, we change it. */
2196
2197 void
2198 store_in_alist (alistptr, prop, val)
2199 Lisp_Object *alistptr, val;
2200 Lisp_Object prop;
2201 {
2202 register Lisp_Object tem;
2203
2204 tem = Fassq (prop, *alistptr);
2205 if (EQ (tem, Qnil))
2206 *alistptr = Fcons (Fcons (prop, val), *alistptr);
2207 else
2208 Fsetcdr (tem, val);
2209 }
2210
2211 static int
2212 frame_name_fnn_p (str, len)
2213 char *str;
2214 int len;
2215 {
2216 if (len > 1 && str[0] == 'F')
2217 {
2218 char *end_ptr;
2219
2220 strtol (str + 1, &end_ptr, 10);
2221
2222 if (end_ptr == str + len)
2223 return 1;
2224 }
2225 return 0;
2226 }
2227
2228 /* Set the name of the terminal frame. Also used by MSDOS frames.
2229 Modeled after x_set_name which is used for WINDOW frames. */
2230
2231 static void
2232 set_term_frame_name (f, name)
2233 struct frame *f;
2234 Lisp_Object name;
2235 {
2236 f->explicit_name = ! NILP (name);
2237
2238 /* If NAME is nil, set the name to F<num>. */
2239 if (NILP (name))
2240 {
2241 char namebuf[20];
2242
2243 /* Check for no change needed in this very common case
2244 before we do any consing. */
2245 if (frame_name_fnn_p (SDATA (f->name),
2246 SBYTES (f->name)))
2247 return;
2248
2249 tty_frame_count++;
2250 sprintf (namebuf, "F%d", tty_frame_count);
2251 name = build_string (namebuf);
2252 }
2253 else
2254 {
2255 CHECK_STRING (name);
2256
2257 /* Don't change the name if it's already NAME. */
2258 if (! NILP (Fstring_equal (name, f->name)))
2259 return;
2260
2261 /* Don't allow the user to set the frame name to F<num>, so it
2262 doesn't clash with the names we generate for terminal frames. */
2263 if (frame_name_fnn_p (SDATA (name), SBYTES (name)))
2264 error ("Frame names of the form F<num> are usurped by Emacs");
2265 }
2266
2267 f->name = name;
2268 update_mode_lines = 1;
2269 }
2270
2271 void
2272 store_frame_param (f, prop, val)
2273 struct frame *f;
2274 Lisp_Object prop, val;
2275 {
2276 register Lisp_Object old_alist_elt;
2277
2278 /* The buffer-list parameters are stored in a special place and not
2279 in the alist. */
2280 if (EQ (prop, Qbuffer_list))
2281 {
2282 f->buffer_list = val;
2283 return;
2284 }
2285 if (EQ (prop, Qburied_buffer_list))
2286 {
2287 f->buried_buffer_list = val;
2288 return;
2289 }
2290
2291 /* If PROP is a symbol which is supposed to have frame-local values,
2292 and it is set up based on this frame, switch to the global
2293 binding. That way, we can create or alter the frame-local binding
2294 without messing up the symbol's status. */
2295 if (SYMBOLP (prop))
2296 {
2297 Lisp_Object valcontents;
2298 valcontents = SYMBOL_VALUE (prop);
2299 if ((BUFFER_LOCAL_VALUEP (valcontents)
2300 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
2301 && XBUFFER_LOCAL_VALUE (valcontents)->check_frame
2302 && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame
2303 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents)->frame) == f)
2304 swap_in_global_binding (prop);
2305 }
2306
2307 #ifndef WINDOWSNT
2308 /* The tty color mode needs to be set before the frame's parameter
2309 alist is updated with the new value, because set_tty_color_mode
2310 wants to look at the old mode. */
2311 if (FRAME_TERMCAP_P (f) && EQ (prop, Qtty_color_mode))
2312 set_tty_color_mode (f, val);
2313 #endif
2314
2315 /* Update the frame parameter alist. */
2316 old_alist_elt = Fassq (prop, f->param_alist);
2317 if (EQ (old_alist_elt, Qnil))
2318 f->param_alist = Fcons (Fcons (prop, val), f->param_alist);
2319 else
2320 Fsetcdr (old_alist_elt, val);
2321
2322 /* Update some other special parameters in their special places
2323 in addition to the alist. */
2324
2325 if (EQ (prop, Qbuffer_predicate))
2326 f->buffer_predicate = val;
2327
2328 if (! FRAME_WINDOW_P (f))
2329 {
2330 if (EQ (prop, Qmenu_bar_lines))
2331 set_menu_bar_lines (f, val, make_number (FRAME_MENU_BAR_LINES (f)));
2332 else if (EQ (prop, Qname))
2333 set_term_frame_name (f, val);
2334 }
2335
2336 if (EQ (prop, Qminibuffer) && WINDOWP (val))
2337 {
2338 if (! MINI_WINDOW_P (XWINDOW (val)))
2339 error ("Surrogate minibuffer windows must be minibuffer windows");
2340
2341 if ((FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f))
2342 && !EQ (val, f->minibuffer_window))
2343 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2344
2345 /* Install the chosen minibuffer window, with proper buffer. */
2346 f->minibuffer_window = val;
2347 }
2348 }
2349
2350 DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0,
2351 doc: /* Return the parameters-alist of frame FRAME.
2352 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2353 The meaningful PARMs depend on the kind of frame.
2354 If FRAME is omitted, return information on the currently selected frame. */)
2355 (frame)
2356 Lisp_Object frame;
2357 {
2358 Lisp_Object alist;
2359 FRAME_PTR f;
2360 int height, width;
2361 struct gcpro gcpro1;
2362
2363 if (NILP (frame))
2364 frame = selected_frame;
2365
2366 CHECK_FRAME (frame);
2367 f = XFRAME (frame);
2368
2369 if (!FRAME_LIVE_P (f))
2370 return Qnil;
2371
2372 alist = Fcopy_alist (f->param_alist);
2373 GCPRO1 (alist);
2374
2375 if (!FRAME_WINDOW_P (f))
2376 {
2377 int fg = FRAME_FOREGROUND_PIXEL (f);
2378 int bg = FRAME_BACKGROUND_PIXEL (f);
2379 Lisp_Object elt;
2380
2381 /* If the frame's parameter alist says the colors are
2382 unspecified and reversed, take the frame's background pixel
2383 for foreground and vice versa. */
2384 elt = Fassq (Qforeground_color, alist);
2385 if (!NILP (elt) && CONSP (elt) && STRINGP (XCDR (elt)))
2386 {
2387 if (strncmp (SDATA (XCDR (elt)),
2388 unspecified_bg,
2389 SCHARS (XCDR (elt))) == 0)
2390 store_in_alist (&alist, Qforeground_color, tty_color_name (f, bg));
2391 else if (strncmp (SDATA (XCDR (elt)),
2392 unspecified_fg,
2393 SCHARS (XCDR (elt))) == 0)
2394 store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg));
2395 }
2396 else
2397 store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg));
2398 elt = Fassq (Qbackground_color, alist);
2399 if (!NILP (elt) && CONSP (elt) && STRINGP (XCDR (elt)))
2400 {
2401 if (strncmp (SDATA (XCDR (elt)),
2402 unspecified_fg,
2403 SCHARS (XCDR (elt))) == 0)
2404 store_in_alist (&alist, Qbackground_color, tty_color_name (f, fg));
2405 else if (strncmp (SDATA (XCDR (elt)),
2406 unspecified_bg,
2407 SCHARS (XCDR (elt))) == 0)
2408 store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg));
2409 }
2410 else
2411 store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg));
2412 store_in_alist (&alist, intern ("font"),
2413 build_string (FRAME_MSDOS_P (f)
2414 ? "ms-dos"
2415 : FRAME_W32_P (f) ? "w32term"
2416 :"tty"));
2417 }
2418 store_in_alist (&alist, Qname, f->name);
2419 height = (f->new_text_lines ? f->new_text_lines : FRAME_LINES (f));
2420 store_in_alist (&alist, Qheight, make_number (height));
2421 width = (f->new_text_cols ? f->new_text_cols : FRAME_COLS (f));
2422 store_in_alist (&alist, Qwidth, make_number (width));
2423 store_in_alist (&alist, Qmodeline, (FRAME_WANTS_MODELINE_P (f) ? Qt : Qnil));
2424 store_in_alist (&alist, Qminibuffer,
2425 (! FRAME_HAS_MINIBUF_P (f) ? Qnil
2426 : FRAME_MINIBUF_ONLY_P (f) ? Qonly
2427 : FRAME_MINIBUF_WINDOW (f)));
2428 store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil));
2429 store_in_alist (&alist, Qbuffer_list, frame_buffer_list (frame));
2430 store_in_alist (&alist, Qburied_buffer_list, XFRAME (frame)->buried_buffer_list);
2431
2432 /* I think this should be done with a hook. */
2433 #ifdef HAVE_WINDOW_SYSTEM
2434 if (FRAME_WINDOW_P (f))
2435 x_report_frame_params (f, &alist);
2436 else
2437 #endif
2438 {
2439 /* This ought to be correct in f->param_alist for an X frame. */
2440 Lisp_Object lines;
2441 XSETFASTINT (lines, FRAME_MENU_BAR_LINES (f));
2442 store_in_alist (&alist, Qmenu_bar_lines, lines);
2443 }
2444
2445 UNGCPRO;
2446 return alist;
2447 }
2448
2449
2450 DEFUN ("frame-parameter", Fframe_parameter, Sframe_parameter, 2, 2, 0,
2451 doc: /* Return FRAME's value for parameter PARAMETER.
2452 If FRAME is nil, describe the currently selected frame. */)
2453 (frame, parameter)
2454 Lisp_Object frame, parameter;
2455 {
2456 struct frame *f;
2457 Lisp_Object value;
2458
2459 if (NILP (frame))
2460 frame = selected_frame;
2461 else
2462 CHECK_FRAME (frame);
2463 CHECK_SYMBOL (parameter);
2464
2465 f = XFRAME (frame);
2466 value = Qnil;
2467
2468 if (FRAME_LIVE_P (f))
2469 {
2470 /* Avoid consing in frequent cases. */
2471 if (EQ (parameter, Qname))
2472 value = f->name;
2473 #ifdef HAVE_X_WINDOWS
2474 else if (EQ (parameter, Qdisplay) && FRAME_X_P (f))
2475 value = XCAR (FRAME_X_DISPLAY_INFO (f)->name_list_element);
2476 #endif /* HAVE_X_WINDOWS */
2477 else if (EQ (parameter, Qbackground_color)
2478 || EQ (parameter, Qforeground_color))
2479 {
2480 value = Fassq (parameter, f->param_alist);
2481 if (CONSP (value))
2482 {
2483 value = XCDR (value);
2484 /* Fframe_parameters puts the actual fg/bg color names,
2485 even if f->param_alist says otherwise. This is
2486 important when param_alist's notion of colors is
2487 "unspecified". We need to do the same here. */
2488 if (STRINGP (value) && !FRAME_WINDOW_P (f))
2489 {
2490 const char *color_name;
2491 EMACS_INT csz;
2492
2493 if (EQ (parameter, Qbackground_color))
2494 {
2495 color_name = SDATA (value);
2496 csz = SCHARS (value);
2497 if (strncmp (color_name, unspecified_bg, csz) == 0)
2498 value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f));
2499 else if (strncmp (color_name, unspecified_fg, csz) == 0)
2500 value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f));
2501 }
2502 else if (EQ (parameter, Qforeground_color))
2503 {
2504 color_name = SDATA (value);
2505 csz = SCHARS (value);
2506 if (strncmp (color_name, unspecified_fg, csz) == 0)
2507 value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f));
2508 else if (strncmp (color_name, unspecified_bg, csz) == 0)
2509 value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f));
2510 }
2511 }
2512 }
2513 else
2514 value = Fcdr (Fassq (parameter, Fframe_parameters (frame)));
2515 }
2516 else if (EQ (parameter, Qdisplay_type)
2517 || EQ (parameter, Qbackground_mode))
2518 value = Fcdr (Fassq (parameter, f->param_alist));
2519 else
2520 value = Fcdr (Fassq (parameter, Fframe_parameters (frame)));
2521 }
2522
2523 return value;
2524 }
2525
2526
2527 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters,
2528 Smodify_frame_parameters, 2, 2, 0,
2529 doc: /* Modify the parameters of frame FRAME according to ALIST.
2530 If FRAME is nil, it defaults to the selected frame.
2531 ALIST is an alist of parameters to change and their new values.
2532 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2533 The meaningful PARMs depend on the kind of frame.
2534 Undefined PARMs are ignored, but stored in the frame's parameter list
2535 so that `frame-parameters' will return them.
2536
2537 The value of frame parameter FOO can also be accessed
2538 as a frame-local binding for the variable FOO, if you have
2539 enabled such bindings for that variable with `make-variable-frame-local'. */)
2540 (frame, alist)
2541 Lisp_Object frame, alist;
2542 {
2543 FRAME_PTR f;
2544 register Lisp_Object tail, prop, val;
2545
2546 if (EQ (frame, Qnil))
2547 frame = selected_frame;
2548 CHECK_LIVE_FRAME (frame);
2549 f = XFRAME (frame);
2550
2551 /* I think this should be done with a hook. */
2552 #ifdef HAVE_WINDOW_SYSTEM
2553 if (FRAME_WINDOW_P (f))
2554 x_set_frame_parameters (f, alist);
2555 else
2556 #endif
2557 #ifdef MSDOS
2558 if (FRAME_MSDOS_P (f))
2559 IT_set_frame_parameters (f, alist);
2560 else
2561 #endif
2562
2563 {
2564 int length = XINT (Flength (alist));
2565 int i;
2566 Lisp_Object *parms
2567 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
2568 Lisp_Object *values
2569 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
2570
2571 /* Extract parm names and values into those vectors. */
2572
2573 i = 0;
2574 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
2575 {
2576 Lisp_Object elt;
2577
2578 elt = Fcar (tail);
2579 parms[i] = Fcar (elt);
2580 values[i] = Fcdr (elt);
2581 i++;
2582 }
2583
2584 /* Now process them in reverse of specified order. */
2585 for (i--; i >= 0; i--)
2586 {
2587 prop = parms[i];
2588 val = values[i];
2589 store_frame_param (f, prop, val);
2590
2591 /* Changing the background color might change the background
2592 mode, so that we have to load new defface specs.
2593 Call frame-set-background-mode to do that. */
2594 if (EQ (prop, Qbackground_color))
2595 call1 (Qframe_set_background_mode, frame);
2596 }
2597 }
2598 }
2599
2600 DEFUN ("frame-with-environment", Fframe_with_environment, Sframe_with_environment, 0, 1, 0,
2601 doc: /* Return the frame that has the environment variable list for FRAME.
2602
2603 The frame-local environment variable list is normally shared between
2604 frames that were created in the same Emacsclient session. The
2605 environment list is stored in a single frame's 'environment parameter;
2606 the other frames' 'environment parameter is set to this frame. This
2607 function follows the chain of 'environment references to reach the
2608 frame that stores the actual local environment list, and returns that
2609 frame. */)
2610 (frame)
2611 Lisp_Object frame;
2612 {
2613 Lisp_Object hare, tortoise;
2614
2615 if (NILP (frame))
2616 frame = selected_frame;
2617 CHECK_FRAME (frame);
2618
2619 hare = tortoise = get_frame_param (XFRAME (frame), Qenvironment);
2620 while (!NILP (hare) && FRAMEP (hare))
2621 {
2622 frame = hare;
2623 hare = get_frame_param (XFRAME (hare), Qenvironment);
2624 if (NILP (hare) || !FRAMEP (hare))
2625 break;
2626 frame = hare;
2627 hare = get_frame_param (XFRAME (hare), Qenvironment);
2628 tortoise = get_frame_param (XFRAME (tortoise), Qenvironment);
2629 if (EQ (hare, tortoise))
2630 error ("Cyclic frame-local environment indirection");
2631 }
2632
2633 return frame;
2634 }
2635
2636 \f
2637 DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
2638 0, 1, 0,
2639 doc: /* Height in pixels of a line in the font in frame FRAME.
2640 If FRAME is omitted, the selected frame is used.
2641 For a terminal frame, the value is always 1. */)
2642 (frame)
2643 Lisp_Object frame;
2644 {
2645 struct frame *f;
2646
2647 if (NILP (frame))
2648 frame = selected_frame;
2649 CHECK_FRAME (frame);
2650 f = XFRAME (frame);
2651
2652 #ifdef HAVE_WINDOW_SYSTEM
2653 if (FRAME_WINDOW_P (f))
2654 return make_number (x_char_height (f));
2655 else
2656 #endif
2657 return make_number (1);
2658 }
2659
2660
2661 DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
2662 0, 1, 0,
2663 doc: /* Width in pixels of characters in the font in frame FRAME.
2664 If FRAME is omitted, the selected frame is used.
2665 On a graphical screen, the width is the standard width of the default font.
2666 For a terminal screen, the value is always 1. */)
2667 (frame)
2668 Lisp_Object frame;
2669 {
2670 struct frame *f;
2671
2672 if (NILP (frame))
2673 frame = selected_frame;
2674 CHECK_FRAME (frame);
2675 f = XFRAME (frame);
2676
2677 #ifdef HAVE_WINDOW_SYSTEM
2678 if (FRAME_WINDOW_P (f))
2679 return make_number (x_char_width (f));
2680 else
2681 #endif
2682 return make_number (1);
2683 }
2684
2685 DEFUN ("frame-pixel-height", Fframe_pixel_height,
2686 Sframe_pixel_height, 0, 1, 0,
2687 doc: /* Return a FRAME's height in pixels.
2688 This counts only the height available for text lines,
2689 not menu bars on window-system Emacs frames.
2690 For a terminal frame, the result really gives the height in characters.
2691 If FRAME is omitted, the selected frame is used. */)
2692 (frame)
2693 Lisp_Object frame;
2694 {
2695 struct frame *f;
2696
2697 if (NILP (frame))
2698 frame = selected_frame;
2699 CHECK_FRAME (frame);
2700 f = XFRAME (frame);
2701
2702 #ifdef HAVE_WINDOW_SYSTEM
2703 if (FRAME_WINDOW_P (f))
2704 return make_number (x_pixel_height (f));
2705 else
2706 #endif
2707 return make_number (FRAME_LINES (f));
2708 }
2709
2710 DEFUN ("frame-pixel-width", Fframe_pixel_width,
2711 Sframe_pixel_width, 0, 1, 0,
2712 doc: /* Return FRAME's width in pixels.
2713 For a terminal frame, the result really gives the width in characters.
2714 If FRAME is omitted, the selected frame is used. */)
2715 (frame)
2716 Lisp_Object frame;
2717 {
2718 struct frame *f;
2719
2720 if (NILP (frame))
2721 frame = selected_frame;
2722 CHECK_FRAME (frame);
2723 f = XFRAME (frame);
2724
2725 #ifdef HAVE_WINDOW_SYSTEM
2726 if (FRAME_WINDOW_P (f))
2727 return make_number (x_pixel_width (f));
2728 else
2729 #endif
2730 return make_number (FRAME_COLS (f));
2731 }
2732 \f
2733 DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
2734 doc: /* Specify that the frame FRAME has LINES lines.
2735 Optional third arg non-nil means that redisplay should use LINES lines
2736 but that the idea of the actual height of the frame should not be changed. */)
2737 (frame, lines, pretend)
2738 Lisp_Object frame, lines, pretend;
2739 {
2740 register struct frame *f;
2741
2742 CHECK_NUMBER (lines);
2743 if (NILP (frame))
2744 frame = selected_frame;
2745 CHECK_LIVE_FRAME (frame);
2746 f = XFRAME (frame);
2747
2748 /* I think this should be done with a hook. */
2749 #ifdef HAVE_WINDOW_SYSTEM
2750 if (FRAME_WINDOW_P (f))
2751 {
2752 if (XINT (lines) != FRAME_LINES (f))
2753 x_set_window_size (f, 1, FRAME_COLS (f), XINT (lines));
2754 do_pending_window_change (0);
2755 }
2756 else
2757 #endif
2758 change_frame_size (f, XINT (lines), 0, !NILP (pretend), 0, 0);
2759 return Qnil;
2760 }
2761
2762 DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 3, 0,
2763 doc: /* Specify that the frame FRAME has COLS columns.
2764 Optional third arg non-nil means that redisplay should use COLS columns
2765 but that the idea of the actual width of the frame should not be changed. */)
2766 (frame, cols, pretend)
2767 Lisp_Object frame, cols, pretend;
2768 {
2769 register struct frame *f;
2770 CHECK_NUMBER (cols);
2771 if (NILP (frame))
2772 frame = selected_frame;
2773 CHECK_LIVE_FRAME (frame);
2774 f = XFRAME (frame);
2775
2776 /* I think this should be done with a hook. */
2777 #ifdef HAVE_WINDOW_SYSTEM
2778 if (FRAME_WINDOW_P (f))
2779 {
2780 if (XINT (cols) != FRAME_COLS (f))
2781 x_set_window_size (f, 1, XINT (cols), FRAME_LINES (f));
2782 do_pending_window_change (0);
2783 }
2784 else
2785 #endif
2786 change_frame_size (f, 0, XINT (cols), !NILP (pretend), 0, 0);
2787 return Qnil;
2788 }
2789
2790 DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0,
2791 doc: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2792 (frame, cols, rows)
2793 Lisp_Object frame, cols, rows;
2794 {
2795 register struct frame *f;
2796
2797 CHECK_LIVE_FRAME (frame);
2798 CHECK_NUMBER (cols);
2799 CHECK_NUMBER (rows);
2800 f = XFRAME (frame);
2801
2802 /* I think this should be done with a hook. */
2803 #ifdef HAVE_WINDOW_SYSTEM
2804 if (FRAME_WINDOW_P (f))
2805 {
2806 if (XINT (rows) != FRAME_LINES (f)
2807 || XINT (cols) != FRAME_COLS (f)
2808 || f->new_text_lines || f->new_text_cols)
2809 x_set_window_size (f, 1, XINT (cols), XINT (rows));
2810 do_pending_window_change (0);
2811 }
2812 else
2813 #endif
2814 change_frame_size (f, XINT (rows), XINT (cols), 0, 0, 0);
2815
2816 return Qnil;
2817 }
2818
2819 DEFUN ("set-frame-position", Fset_frame_position,
2820 Sset_frame_position, 3, 3, 0,
2821 doc: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2822 This is actually the position of the upper left corner of the frame.
2823 Negative values for XOFFSET or YOFFSET are interpreted relative to
2824 the rightmost or bottommost possible position (that stays within the screen). */)
2825 (frame, xoffset, yoffset)
2826 Lisp_Object frame, xoffset, yoffset;
2827 {
2828 register struct frame *f;
2829
2830 CHECK_LIVE_FRAME (frame);
2831 CHECK_NUMBER (xoffset);
2832 CHECK_NUMBER (yoffset);
2833 f = XFRAME (frame);
2834
2835 /* I think this should be done with a hook. */
2836 #ifdef HAVE_WINDOW_SYSTEM
2837 if (FRAME_WINDOW_P (f))
2838 x_set_offset (f, XINT (xoffset), XINT (yoffset), 1);
2839 #endif
2840
2841 return Qt;
2842 }
2843
2844 \f
2845 /***********************************************************************
2846 Frame Parameters
2847 ***********************************************************************/
2848
2849 /* Connect the frame-parameter names for X frames
2850 to the ways of passing the parameter values to the window system.
2851
2852 The name of a parameter, as a Lisp symbol,
2853 has an `x-frame-parameter' property which is an integer in Lisp
2854 that is an index in this table. */
2855
2856 struct frame_parm_table {
2857 char *name;
2858 Lisp_Object *variable;
2859 };
2860
2861 static struct frame_parm_table frame_parms[] =
2862 {
2863 {"auto-raise", &Qauto_raise},
2864 {"auto-lower", &Qauto_lower},
2865 {"background-color", 0},
2866 {"border-color", &Qborder_color},
2867 {"border-width", &Qborder_width},
2868 {"cursor-color", &Qcursor_color},
2869 {"cursor-type", &Qcursor_type},
2870 {"font", 0},
2871 {"foreground-color", 0},
2872 {"icon-name", &Qicon_name},
2873 {"icon-type", &Qicon_type},
2874 {"internal-border-width", &Qinternal_border_width},
2875 {"menu-bar-lines", &Qmenu_bar_lines},
2876 {"mouse-color", &Qmouse_color},
2877 {"name", &Qname},
2878 {"scroll-bar-width", &Qscroll_bar_width},
2879 {"title", &Qtitle},
2880 {"unsplittable", &Qunsplittable},
2881 {"vertical-scroll-bars", &Qvertical_scroll_bars},
2882 {"visibility", &Qvisibility},
2883 {"tool-bar-lines", &Qtool_bar_lines},
2884 {"scroll-bar-foreground", &Qscroll_bar_foreground},
2885 {"scroll-bar-background", &Qscroll_bar_background},
2886 {"screen-gamma", &Qscreen_gamma},
2887 {"line-spacing", &Qline_spacing},
2888 {"left-fringe", &Qleft_fringe},
2889 {"right-fringe", &Qright_fringe},
2890 {"wait-for-wm", &Qwait_for_wm},
2891 {"fullscreen", &Qfullscreen},
2892 };
2893
2894 #ifdef HAVE_WINDOW_SYSTEM
2895
2896 extern Lisp_Object Qbox;
2897 extern Lisp_Object Qtop;
2898
2899 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2900 wanted positions of the WM window (not Emacs window).
2901 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2902 window (FRAME_X_WINDOW).
2903 */
2904
2905 void
2906 x_fullscreen_adjust (f, width, height, top_pos, left_pos)
2907 struct frame *f;
2908 int *width;
2909 int *height;
2910 int *top_pos;
2911 int *left_pos;
2912 {
2913 int newwidth = FRAME_COLS (f);
2914 int newheight = FRAME_LINES (f);
2915
2916 *top_pos = f->top_pos;
2917 *left_pos = f->left_pos;
2918
2919 if (f->want_fullscreen & FULLSCREEN_HEIGHT)
2920 {
2921 int ph;
2922
2923 ph = FRAME_X_DISPLAY_INFO (f)->height;
2924 newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph);
2925 ph = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, newheight) - f->y_pixels_diff;
2926 newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph);
2927 *top_pos = 0;
2928 }
2929
2930 if (f->want_fullscreen & FULLSCREEN_WIDTH)
2931 {
2932 int pw;
2933
2934 pw = FRAME_X_DISPLAY_INFO (f)->width;
2935 newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw);
2936 pw = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, newwidth) - f->x_pixels_diff;
2937 newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw);
2938 *left_pos = 0;
2939 }
2940
2941 *width = newwidth;
2942 *height = newheight;
2943 }
2944
2945
2946 /* Change the parameters of frame F as specified by ALIST.
2947 If a parameter is not specially recognized, do nothing special;
2948 otherwise call the `x_set_...' function for that parameter.
2949 Except for certain geometry properties, always call store_frame_param
2950 to store the new value in the parameter alist. */
2951
2952 void
2953 x_set_frame_parameters (f, alist)
2954 FRAME_PTR f;
2955 Lisp_Object alist;
2956 {
2957 Lisp_Object tail;
2958
2959 /* If both of these parameters are present, it's more efficient to
2960 set them both at once. So we wait until we've looked at the
2961 entire list before we set them. */
2962 int width, height;
2963
2964 /* Same here. */
2965 Lisp_Object left, top;
2966
2967 /* Same with these. */
2968 Lisp_Object icon_left, icon_top;
2969
2970 /* Record in these vectors all the parms specified. */
2971 Lisp_Object *parms;
2972 Lisp_Object *values;
2973 int i, p;
2974 int left_no_change = 0, top_no_change = 0;
2975 int icon_left_no_change = 0, icon_top_no_change = 0;
2976 int fullscreen_is_being_set = 0;
2977
2978 struct gcpro gcpro1, gcpro2;
2979
2980 i = 0;
2981 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
2982 i++;
2983
2984 parms = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
2985 values = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
2986
2987 /* Extract parm names and values into those vectors. */
2988
2989 i = 0;
2990 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
2991 {
2992 Lisp_Object elt;
2993
2994 elt = Fcar (tail);
2995 parms[i] = Fcar (elt);
2996 values[i] = Fcdr (elt);
2997 i++;
2998 }
2999 /* TAIL and ALIST are not used again below here. */
3000 alist = tail = Qnil;
3001
3002 GCPRO2 (*parms, *values);
3003 gcpro1.nvars = i;
3004 gcpro2.nvars = i;
3005
3006 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
3007 because their values appear in VALUES and strings are not valid. */
3008 top = left = Qunbound;
3009 icon_left = icon_top = Qunbound;
3010
3011 /* Provide default values for HEIGHT and WIDTH. */
3012 width = (f->new_text_cols ? f->new_text_cols : FRAME_COLS (f));
3013 height = (f->new_text_lines ? f->new_text_lines : FRAME_LINES (f));
3014
3015 /* Process foreground_color and background_color before anything else.
3016 They are independent of other properties, but other properties (e.g.,
3017 cursor_color) are dependent upon them. */
3018 /* Process default font as well, since fringe widths depends on it. */
3019 /* Also, process fullscreen, width and height depend upon that */
3020 for (p = 0; p < i; p++)
3021 {
3022 Lisp_Object prop, val;
3023
3024 prop = parms[p];
3025 val = values[p];
3026 if (EQ (prop, Qforeground_color)
3027 || EQ (prop, Qbackground_color)
3028 || EQ (prop, Qfont)
3029 || EQ (prop, Qfullscreen))
3030 {
3031 register Lisp_Object param_index, old_value;
3032 int count = SPECPDL_INDEX ();
3033
3034 old_value = get_frame_param (f, prop);
3035 fullscreen_is_being_set |= EQ (prop, Qfullscreen);
3036
3037 if (NILP (Fequal (val, old_value)))
3038 {
3039 /* For :font attributes, the frame_parm_handler
3040 x_set_font calls `face-set-after-frame-default'.
3041 Unless we bind inhibit-face-set-after-frame-default
3042 here, this would reset the :font attribute that we
3043 just applied to the default value for new faces. */
3044 specbind (Qinhibit_face_set_after_frame_default, Qt);
3045
3046 store_frame_param (f, prop, val);
3047
3048 param_index = Fget (prop, Qx_frame_parameter);
3049 if (NATNUMP (param_index)
3050 && (XFASTINT (param_index)
3051 < sizeof (frame_parms)/sizeof (frame_parms[0]))
3052 && FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])
3053 (*(FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])) (f, val, old_value);
3054 unbind_to (count, Qnil);
3055 }
3056 }
3057 }
3058
3059 /* Now process them in reverse of specified order. */
3060 for (i--; i >= 0; i--)
3061 {
3062 Lisp_Object prop, val;
3063
3064 prop = parms[i];
3065 val = values[i];
3066
3067 if (EQ (prop, Qwidth) && NUMBERP (val))
3068 width = XFASTINT (val);
3069 else if (EQ (prop, Qheight) && NUMBERP (val))
3070 height = XFASTINT (val);
3071 else if (EQ (prop, Qtop))
3072 top = val;
3073 else if (EQ (prop, Qleft))
3074 left = val;
3075 else if (EQ (prop, Qicon_top))
3076 icon_top = val;
3077 else if (EQ (prop, Qicon_left))
3078 icon_left = val;
3079 else if (EQ (prop, Qforeground_color)
3080 || EQ (prop, Qbackground_color)
3081 || EQ (prop, Qfont)
3082 || EQ (prop, Qfullscreen))
3083 /* Processed above. */
3084 continue;
3085 else
3086 {
3087 register Lisp_Object param_index, old_value;
3088
3089 old_value = get_frame_param (f, prop);
3090
3091 store_frame_param (f, prop, val);
3092
3093 param_index = Fget (prop, Qx_frame_parameter);
3094 if (NATNUMP (param_index)
3095 && (XFASTINT (param_index)
3096 < sizeof (frame_parms)/sizeof (frame_parms[0]))
3097 && FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])
3098 (*(FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])) (f, val, old_value);
3099 }
3100 }
3101
3102 /* Don't die if just one of these was set. */
3103 if (EQ (left, Qunbound))
3104 {
3105 left_no_change = 1;
3106 if (f->left_pos < 0)
3107 left = Fcons (Qplus, Fcons (make_number (f->left_pos), Qnil));
3108 else
3109 XSETINT (left, f->left_pos);
3110 }
3111 if (EQ (top, Qunbound))
3112 {
3113 top_no_change = 1;
3114 if (f->top_pos < 0)
3115 top = Fcons (Qplus, Fcons (make_number (f->top_pos), Qnil));
3116 else
3117 XSETINT (top, f->top_pos);
3118 }
3119
3120 /* If one of the icon positions was not set, preserve or default it. */
3121 if (EQ (icon_left, Qunbound) || ! INTEGERP (icon_left))
3122 {
3123 icon_left_no_change = 1;
3124 icon_left = Fcdr (Fassq (Qicon_left, f->param_alist));
3125 if (NILP (icon_left))
3126 XSETINT (icon_left, 0);
3127 }
3128 if (EQ (icon_top, Qunbound) || ! INTEGERP (icon_top))
3129 {
3130 icon_top_no_change = 1;
3131 icon_top = Fcdr (Fassq (Qicon_top, f->param_alist));
3132 if (NILP (icon_top))
3133 XSETINT (icon_top, 0);
3134 }
3135
3136 if (FRAME_VISIBLE_P (f) && fullscreen_is_being_set)
3137 {
3138 /* If the frame is visible already and the fullscreen parameter is
3139 being set, it is too late to set WM manager hints to specify
3140 size and position.
3141 Here we first get the width, height and position that applies to
3142 fullscreen. We then move the frame to the appropriate
3143 position. Resize of the frame is taken care of in the code after
3144 this if-statement. */
3145 int new_left, new_top;
3146
3147 x_fullscreen_adjust (f, &width, &height, &new_top, &new_left);
3148 if (new_top != f->top_pos || new_left != f->left_pos)
3149 x_set_offset (f, new_left, new_top, 1);
3150 }
3151
3152 /* Don't set these parameters unless they've been explicitly
3153 specified. The window might be mapped or resized while we're in
3154 this function, and we don't want to override that unless the lisp
3155 code has asked for it.
3156
3157 Don't set these parameters unless they actually differ from the
3158 window's current parameters; the window may not actually exist
3159 yet. */
3160 {
3161 Lisp_Object frame;
3162
3163 check_frame_size (f, &height, &width);
3164
3165 XSETFRAME (frame, f);
3166
3167 if (width != FRAME_COLS (f)
3168 || height != FRAME_LINES (f)
3169 || f->new_text_lines || f->new_text_cols)
3170 Fset_frame_size (frame, make_number (width), make_number (height));
3171
3172 if ((!NILP (left) || !NILP (top))
3173 && ! (left_no_change && top_no_change)
3174 && ! (NUMBERP (left) && XINT (left) == f->left_pos
3175 && NUMBERP (top) && XINT (top) == f->top_pos))
3176 {
3177 int leftpos = 0;
3178 int toppos = 0;
3179
3180 /* Record the signs. */
3181 f->size_hint_flags &= ~ (XNegative | YNegative);
3182 if (EQ (left, Qminus))
3183 f->size_hint_flags |= XNegative;
3184 else if (INTEGERP (left))
3185 {
3186 leftpos = XINT (left);
3187 if (leftpos < 0)
3188 f->size_hint_flags |= XNegative;
3189 }
3190 else if (CONSP (left) && EQ (XCAR (left), Qminus)
3191 && CONSP (XCDR (left))
3192 && INTEGERP (XCAR (XCDR (left))))
3193 {
3194 leftpos = - XINT (XCAR (XCDR (left)));
3195 f->size_hint_flags |= XNegative;
3196 }
3197 else if (CONSP (left) && EQ (XCAR (left), Qplus)
3198 && CONSP (XCDR (left))
3199 && INTEGERP (XCAR (XCDR (left))))
3200 {
3201 leftpos = XINT (XCAR (XCDR (left)));
3202 }
3203
3204 if (EQ (top, Qminus))
3205 f->size_hint_flags |= YNegative;
3206 else if (INTEGERP (top))
3207 {
3208 toppos = XINT (top);
3209 if (toppos < 0)
3210 f->size_hint_flags |= YNegative;
3211 }
3212 else if (CONSP (top) && EQ (XCAR (top), Qminus)
3213 && CONSP (XCDR (top))
3214 && INTEGERP (XCAR (XCDR (top))))
3215 {
3216 toppos = - XINT (XCAR (XCDR (top)));
3217 f->size_hint_flags |= YNegative;
3218 }
3219 else if (CONSP (top) && EQ (XCAR (top), Qplus)
3220 && CONSP (XCDR (top))
3221 && INTEGERP (XCAR (XCDR (top))))
3222 {
3223 toppos = XINT (XCAR (XCDR (top)));
3224 }
3225
3226
3227 /* Store the numeric value of the position. */
3228 f->top_pos = toppos;
3229 f->left_pos = leftpos;
3230
3231 f->win_gravity = NorthWestGravity;
3232
3233 /* Actually set that position, and convert to absolute. */
3234 x_set_offset (f, leftpos, toppos, -1);
3235 }
3236
3237 if ((!NILP (icon_left) || !NILP (icon_top))
3238 && ! (icon_left_no_change && icon_top_no_change))
3239 x_wm_set_icon_position (f, XINT (icon_left), XINT (icon_top));
3240 }
3241
3242 UNGCPRO;
3243 }
3244
3245
3246 /* Insert a description of internally-recorded parameters of frame X
3247 into the parameter alist *ALISTPTR that is to be given to the user.
3248 Only parameters that are specific to the X window system
3249 and whose values are not correctly recorded in the frame's
3250 param_alist need to be considered here. */
3251
3252 void
3253 x_report_frame_params (f, alistptr)
3254 struct frame *f;
3255 Lisp_Object *alistptr;
3256 {
3257 char buf[16];
3258 Lisp_Object tem;
3259
3260 /* Represent negative positions (off the top or left screen edge)
3261 in a way that Fmodify_frame_parameters will understand correctly. */
3262 XSETINT (tem, f->left_pos);
3263 if (f->left_pos >= 0)
3264 store_in_alist (alistptr, Qleft, tem);
3265 else
3266 store_in_alist (alistptr, Qleft, Fcons (Qplus, Fcons (tem, Qnil)));
3267
3268 XSETINT (tem, f->top_pos);
3269 if (f->top_pos >= 0)
3270 store_in_alist (alistptr, Qtop, tem);
3271 else
3272 store_in_alist (alistptr, Qtop, Fcons (Qplus, Fcons (tem, Qnil)));
3273
3274 store_in_alist (alistptr, Qborder_width,
3275 make_number (f->border_width));
3276 store_in_alist (alistptr, Qinternal_border_width,
3277 make_number (FRAME_INTERNAL_BORDER_WIDTH (f)));
3278 store_in_alist (alistptr, Qleft_fringe,
3279 make_number (FRAME_LEFT_FRINGE_WIDTH (f)));
3280 store_in_alist (alistptr, Qright_fringe,
3281 make_number (FRAME_RIGHT_FRINGE_WIDTH (f)));
3282 store_in_alist (alistptr, Qscroll_bar_width,
3283 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f)
3284 ? make_number (0)
3285 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0
3286 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
3287 /* nil means "use default width"
3288 for non-toolkit scroll bar.
3289 ruler-mode.el depends on this. */
3290 : Qnil));
3291 sprintf (buf, "%ld", (long) FRAME_X_WINDOW (f));
3292 store_in_alist (alistptr, Qwindow_id,
3293 build_string (buf));
3294 #ifdef HAVE_X_WINDOWS
3295 #ifdef USE_X_TOOLKIT
3296 /* Tooltip frame may not have this widget. */
3297 if (FRAME_X_OUTPUT (f)->widget)
3298 #endif
3299 sprintf (buf, "%ld", (long) FRAME_OUTER_WINDOW (f));
3300 store_in_alist (alistptr, Qouter_window_id,
3301 build_string (buf));
3302 #endif
3303 store_in_alist (alistptr, Qicon_name, f->icon_name);
3304 FRAME_SAMPLE_VISIBILITY (f);
3305 store_in_alist (alistptr, Qvisibility,
3306 (FRAME_VISIBLE_P (f) ? Qt
3307 : FRAME_ICONIFIED_P (f) ? Qicon : Qnil));
3308 store_in_alist (alistptr, Qdisplay,
3309 XCAR (FRAME_X_DISPLAY_INFO (f)->name_list_element));
3310
3311 if (FRAME_X_OUTPUT (f)->parent_desc == FRAME_X_DISPLAY_INFO (f)->root_window)
3312 tem = Qnil;
3313 else
3314 XSETFASTINT (tem, FRAME_X_OUTPUT (f)->parent_desc);
3315 store_in_alist (alistptr, Qparent_id, tem);
3316 }
3317
3318
3319 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3320 the previous value of that parameter, NEW_VALUE is the new value. */
3321
3322 void
3323 x_set_fullscreen (f, new_value, old_value)
3324 struct frame *f;
3325 Lisp_Object new_value, old_value;
3326 {
3327 if (NILP (new_value))
3328 f->want_fullscreen = FULLSCREEN_NONE;
3329 else if (EQ (new_value, Qfullboth))
3330 f->want_fullscreen = FULLSCREEN_BOTH;
3331 else if (EQ (new_value, Qfullwidth))
3332 f->want_fullscreen = FULLSCREEN_WIDTH;
3333 else if (EQ (new_value, Qfullheight))
3334 f->want_fullscreen = FULLSCREEN_HEIGHT;
3335
3336 if (FRAME_TERMINAL (f)->fullscreen_hook != NULL)
3337 FRAME_TERMINAL (f)->fullscreen_hook (f);
3338 }
3339
3340
3341 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3342 the previous value of that parameter, NEW_VALUE is the new value. */
3343
3344 void
3345 x_set_line_spacing (f, new_value, old_value)
3346 struct frame *f;
3347 Lisp_Object new_value, old_value;
3348 {
3349 if (NILP (new_value))
3350 f->extra_line_spacing = 0;
3351 else if (NATNUMP (new_value))
3352 f->extra_line_spacing = XFASTINT (new_value);
3353 else
3354 signal_error ("Invalid line-spacing", new_value);
3355 if (FRAME_VISIBLE_P (f))
3356 redraw_frame (f);
3357 }
3358
3359
3360 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3361 the previous value of that parameter, NEW_VALUE is the new value. */
3362
3363 void
3364 x_set_screen_gamma (f, new_value, old_value)
3365 struct frame *f;
3366 Lisp_Object new_value, old_value;
3367 {
3368 Lisp_Object bgcolor;
3369
3370 if (NILP (new_value))
3371 f->gamma = 0;
3372 else if (NUMBERP (new_value) && XFLOATINT (new_value) > 0)
3373 /* The value 0.4545 is the normal viewing gamma. */
3374 f->gamma = 1.0 / (0.4545 * XFLOATINT (new_value));
3375 else
3376 signal_error ("Invalid screen-gamma", new_value);
3377
3378 /* Apply the new gamma value to the frame background. */
3379 bgcolor = Fassq (Qbackground_color, f->param_alist);
3380 if (CONSP (bgcolor) && (bgcolor = XCDR (bgcolor), STRINGP (bgcolor)))
3381 {
3382 Lisp_Object index = Fget (Qbackground_color, Qx_frame_parameter);
3383 if (NATNUMP (index)
3384 && (XFASTINT (index)
3385 < sizeof (frame_parms)/sizeof (frame_parms[0]))
3386 && FRAME_RIF (f)->frame_parm_handlers[XFASTINT (index)])
3387 (*FRAME_RIF (f)->frame_parm_handlers[XFASTINT (index)])
3388 (f, bgcolor, Qnil);
3389 }
3390
3391 Fclear_face_cache (Qnil);
3392 }
3393
3394
3395 void
3396 x_set_font (f, arg, oldval)
3397 struct frame *f;
3398 Lisp_Object arg, oldval;
3399 {
3400 Lisp_Object result;
3401 Lisp_Object fontset_name;
3402 Lisp_Object frame;
3403 int old_fontset = FRAME_FONTSET(f);
3404
3405 CHECK_STRING (arg);
3406
3407 fontset_name = Fquery_fontset (arg, Qnil);
3408
3409 BLOCK_INPUT;
3410 result = (STRINGP (fontset_name)
3411 ? x_new_fontset (f, SDATA (fontset_name))
3412 : x_new_font (f, SDATA (arg)));
3413 UNBLOCK_INPUT;
3414
3415 if (EQ (result, Qnil))
3416 error ("Font `%s' is not defined", SDATA (arg));
3417 else if (EQ (result, Qt))
3418 error ("The characters of the given font have varying widths");
3419 else if (STRINGP (result))
3420 {
3421 set_default_ascii_font (result);
3422 if (STRINGP (fontset_name))
3423 {
3424 /* Fontset names are built from ASCII font names, so the
3425 names may be equal despite there was a change. */
3426 if (old_fontset == FRAME_FONTSET (f))
3427 return;
3428 }
3429 else if (!NILP (Fequal (result, oldval)))
3430 return;
3431
3432 /* Recalculate toolbar height. */
3433 f->n_tool_bar_rows = 0;
3434 /* Ensure we redraw it. */
3435 clear_current_matrices (f);
3436
3437 store_frame_param (f, Qfont, result);
3438 recompute_basic_faces (f);
3439 }
3440 else
3441 abort ();
3442
3443 do_pending_window_change (0);
3444
3445 /* Don't call `face-set-after-frame-default' when faces haven't been
3446 initialized yet. This is the case when called from
3447 Fx_create_frame. In that case, the X widget or window doesn't
3448 exist either, and we can end up in x_report_frame_params with a
3449 null widget which gives a segfault. */
3450 if (FRAME_FACE_CACHE (f))
3451 {
3452 XSETFRAME (frame, f);
3453 call1 (Qface_set_after_frame_default, frame);
3454 }
3455 }
3456
3457
3458 void
3459 x_set_fringe_width (f, new_value, old_value)
3460 struct frame *f;
3461 Lisp_Object new_value, old_value;
3462 {
3463 compute_fringe_widths (f, 1);
3464 }
3465
3466 void
3467 x_set_border_width (f, arg, oldval)
3468 struct frame *f;
3469 Lisp_Object arg, oldval;
3470 {
3471 CHECK_NUMBER (arg);
3472
3473 if (XINT (arg) == f->border_width)
3474 return;
3475
3476 if (FRAME_X_WINDOW (f) != 0)
3477 error ("Cannot change the border width of a frame");
3478
3479 f->border_width = XINT (arg);
3480 }
3481
3482 void
3483 x_set_internal_border_width (f, arg, oldval)
3484 struct frame *f;
3485 Lisp_Object arg, oldval;
3486 {
3487 int old = FRAME_INTERNAL_BORDER_WIDTH (f);
3488
3489 CHECK_NUMBER (arg);
3490 FRAME_INTERNAL_BORDER_WIDTH (f) = XINT (arg);
3491 if (FRAME_INTERNAL_BORDER_WIDTH (f) < 0)
3492 FRAME_INTERNAL_BORDER_WIDTH (f) = 0;
3493
3494 #ifdef USE_X_TOOLKIT
3495 if (FRAME_X_OUTPUT (f)->edit_widget)
3496 widget_store_internal_border (FRAME_X_OUTPUT (f)->edit_widget);
3497 #endif
3498
3499 if (FRAME_INTERNAL_BORDER_WIDTH (f) == old)
3500 return;
3501
3502 if (FRAME_X_WINDOW (f) != 0)
3503 {
3504 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
3505 SET_FRAME_GARBAGED (f);
3506 do_pending_window_change (0);
3507 }
3508 else
3509 SET_FRAME_GARBAGED (f);
3510 }
3511
3512 void
3513 x_set_visibility (f, value, oldval)
3514 struct frame *f;
3515 Lisp_Object value, oldval;
3516 {
3517 Lisp_Object frame;
3518 XSETFRAME (frame, f);
3519
3520 if (NILP (value))
3521 Fmake_frame_invisible (frame, Qt);
3522 else if (EQ (value, Qicon))
3523 Ficonify_frame (frame);
3524 else
3525 Fmake_frame_visible (frame);
3526 }
3527
3528 void
3529 x_set_autoraise (f, arg, oldval)
3530 struct frame *f;
3531 Lisp_Object arg, oldval;
3532 {
3533 f->auto_raise = !EQ (Qnil, arg);
3534 }
3535
3536 void
3537 x_set_autolower (f, arg, oldval)
3538 struct frame *f;
3539 Lisp_Object arg, oldval;
3540 {
3541 f->auto_lower = !EQ (Qnil, arg);
3542 }
3543
3544 void
3545 x_set_unsplittable (f, arg, oldval)
3546 struct frame *f;
3547 Lisp_Object arg, oldval;
3548 {
3549 f->no_split = !NILP (arg);
3550 }
3551
3552 void
3553 x_set_vertical_scroll_bars (f, arg, oldval)
3554 struct frame *f;
3555 Lisp_Object arg, oldval;
3556 {
3557 if ((EQ (arg, Qleft) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
3558 || (EQ (arg, Qright) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
3559 || (NILP (arg) && FRAME_HAS_VERTICAL_SCROLL_BARS (f))
3560 || (!NILP (arg) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f)))
3561 {
3562 FRAME_VERTICAL_SCROLL_BAR_TYPE (f)
3563 = (NILP (arg)
3564 ? vertical_scroll_bar_none
3565 : EQ (Qleft, arg)
3566 ? vertical_scroll_bar_left
3567 : EQ (Qright, arg)
3568 ? vertical_scroll_bar_right
3569 : EQ (Qleft, Vdefault_frame_scroll_bars)
3570 ? vertical_scroll_bar_left
3571 : EQ (Qright, Vdefault_frame_scroll_bars)
3572 ? vertical_scroll_bar_right
3573 : vertical_scroll_bar_none);
3574
3575 /* We set this parameter before creating the X window for the
3576 frame, so we can get the geometry right from the start.
3577 However, if the window hasn't been created yet, we shouldn't
3578 call x_set_window_size. */
3579 if (FRAME_X_WINDOW (f))
3580 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
3581 do_pending_window_change (0);
3582 }
3583 }
3584
3585 void
3586 x_set_scroll_bar_width (f, arg, oldval)
3587 struct frame *f;
3588 Lisp_Object arg, oldval;
3589 {
3590 int wid = FRAME_COLUMN_WIDTH (f);
3591
3592 if (NILP (arg))
3593 {
3594 x_set_scroll_bar_default_width (f);
3595
3596 if (FRAME_X_WINDOW (f))
3597 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
3598 do_pending_window_change (0);
3599 }
3600 else if (INTEGERP (arg) && XINT (arg) > 0
3601 && XFASTINT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
3602 {
3603 if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM)
3604 XSETINT (arg, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM + 1);
3605
3606 FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFASTINT (arg);
3607 FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + wid-1) / wid;
3608 if (FRAME_X_WINDOW (f))
3609 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
3610 do_pending_window_change (0);
3611 }
3612
3613 change_frame_size (f, 0, FRAME_COLS (f), 0, 0, 0);
3614 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;
3615 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;
3616 }
3617
3618
3619
3620 /* Return non-nil if frame F wants a bitmap icon. */
3621
3622 Lisp_Object
3623 x_icon_type (f)
3624 FRAME_PTR f;
3625 {
3626 Lisp_Object tem;
3627
3628 tem = assq_no_quit (Qicon_type, f->param_alist);
3629 if (CONSP (tem))
3630 return XCDR (tem);
3631 else
3632 return Qnil;
3633 }
3634
3635 \f
3636 /* Subroutines of creating an X frame. */
3637
3638 /* Make sure that Vx_resource_name is set to a reasonable value.
3639 Fix it up, or set it to `emacs' if it is too hopeless. */
3640
3641 void
3642 validate_x_resource_name ()
3643 {
3644 int len = 0;
3645 /* Number of valid characters in the resource name. */
3646 int good_count = 0;
3647 /* Number of invalid characters in the resource name. */
3648 int bad_count = 0;
3649 Lisp_Object new;
3650 int i;
3651
3652 if (!STRINGP (Vx_resource_class))
3653 Vx_resource_class = build_string (EMACS_CLASS);
3654
3655 if (STRINGP (Vx_resource_name))
3656 {
3657 unsigned char *p = SDATA (Vx_resource_name);
3658 int i;
3659
3660 len = SBYTES (Vx_resource_name);
3661
3662 /* Only letters, digits, - and _ are valid in resource names.
3663 Count the valid characters and count the invalid ones. */
3664 for (i = 0; i < len; i++)
3665 {
3666 int c = p[i];
3667 if (! ((c >= 'a' && c <= 'z')
3668 || (c >= 'A' && c <= 'Z')
3669 || (c >= '0' && c <= '9')
3670 || c == '-' || c == '_'))
3671 bad_count++;
3672 else
3673 good_count++;
3674 }
3675 }
3676 else
3677 /* Not a string => completely invalid. */
3678 bad_count = 5, good_count = 0;
3679
3680 /* If name is valid already, return. */
3681 if (bad_count == 0)
3682 return;
3683
3684 /* If name is entirely invalid, or nearly so, use `emacs'. */
3685 if (good_count == 0
3686 || (good_count == 1 && bad_count > 0))
3687 {
3688 Vx_resource_name = build_string ("emacs");
3689 return;
3690 }
3691
3692 /* Name is partly valid. Copy it and replace the invalid characters
3693 with underscores. */
3694
3695 Vx_resource_name = new = Fcopy_sequence (Vx_resource_name);
3696
3697 for (i = 0; i < len; i++)
3698 {
3699 int c = SREF (new, i);
3700 if (! ((c >= 'a' && c <= 'z')
3701 || (c >= 'A' && c <= 'Z')
3702 || (c >= '0' && c <= '9')
3703 || c == '-' || c == '_'))
3704 SSET (new, i, '_');
3705 }
3706 }
3707
3708
3709 extern char *x_get_string_resource P_ ((XrmDatabase, char *, char *));
3710 extern Display_Info *check_x_display_info P_ ((Lisp_Object));
3711
3712
3713 /* Get specified attribute from resource database RDB.
3714 See Fx_get_resource below for other parameters. */
3715
3716 static Lisp_Object
3717 xrdb_get_resource (rdb, attribute, class, component, subclass)
3718 XrmDatabase rdb;
3719 Lisp_Object attribute, class, component, subclass;
3720 {
3721 register char *value;
3722 char *name_key;
3723 char *class_key;
3724
3725 CHECK_STRING (attribute);
3726 CHECK_STRING (class);
3727
3728 if (!NILP (component))
3729 CHECK_STRING (component);
3730 if (!NILP (subclass))
3731 CHECK_STRING (subclass);
3732 if (NILP (component) != NILP (subclass))
3733 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
3734
3735 validate_x_resource_name ();
3736
3737 /* Allocate space for the components, the dots which separate them,
3738 and the final '\0'. Make them big enough for the worst case. */
3739 name_key = (char *) alloca (SBYTES (Vx_resource_name)
3740 + (STRINGP (component)
3741 ? SBYTES (component) : 0)
3742 + SBYTES (attribute)
3743 + 3);
3744
3745 class_key = (char *) alloca (SBYTES (Vx_resource_class)
3746 + SBYTES (class)
3747 + (STRINGP (subclass)
3748 ? SBYTES (subclass) : 0)
3749 + 3);
3750
3751 /* Start with emacs.FRAMENAME for the name (the specific one)
3752 and with `Emacs' for the class key (the general one). */
3753 strcpy (name_key, SDATA (Vx_resource_name));
3754 strcpy (class_key, SDATA (Vx_resource_class));
3755
3756 strcat (class_key, ".");
3757 strcat (class_key, SDATA (class));
3758
3759 if (!NILP (component))
3760 {
3761 strcat (class_key, ".");
3762 strcat (class_key, SDATA (subclass));
3763
3764 strcat (name_key, ".");
3765 strcat (name_key, SDATA (component));
3766 }
3767
3768 strcat (name_key, ".");
3769 strcat (name_key, SDATA (attribute));
3770
3771 value = x_get_string_resource (rdb, name_key, class_key);
3772
3773 if (value != (char *) 0)
3774 return build_string (value);
3775 else
3776 return Qnil;
3777 }
3778
3779
3780 DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 2, 4, 0,
3781 doc: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.
3782 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the
3783 class, where INSTANCE is the name under which Emacs was invoked, or
3784 the name specified by the `-name' or `-rn' command-line arguments.
3785
3786 The optional arguments COMPONENT and SUBCLASS add to the key and the
3787 class, respectively. You must specify both of them or neither.
3788 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'
3789 and the class is `Emacs.CLASS.SUBCLASS'. */)
3790 (attribute, class, component, subclass)
3791 Lisp_Object attribute, class, component, subclass;
3792 {
3793 #ifdef HAVE_X_WINDOWS
3794 check_x ();
3795 #endif
3796
3797 return xrdb_get_resource (check_x_display_info (Qnil)->xrdb,
3798 attribute, class, component, subclass);
3799 }
3800
3801 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
3802
3803 Lisp_Object
3804 display_x_get_resource (dpyinfo, attribute, class, component, subclass)
3805 Display_Info *dpyinfo;
3806 Lisp_Object attribute, class, component, subclass;
3807 {
3808 return xrdb_get_resource (dpyinfo->xrdb,
3809 attribute, class, component, subclass);
3810 }
3811
3812 /* Used when C code wants a resource value. */
3813
3814 char *
3815 x_get_resource_string (attribute, class)
3816 char *attribute, *class;
3817 {
3818 char *name_key;
3819 char *class_key;
3820 struct frame *sf = SELECTED_FRAME ();
3821
3822 /* Allocate space for the components, the dots which separate them,
3823 and the final '\0'. */
3824 name_key = (char *) alloca (SBYTES (Vinvocation_name)
3825 + strlen (attribute) + 2);
3826 class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
3827 + strlen (class) + 2);
3828
3829 sprintf (name_key, "%s.%s", SDATA (Vinvocation_name), attribute);
3830 sprintf (class_key, "%s.%s", EMACS_CLASS, class);
3831
3832 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb,
3833 name_key, class_key);
3834 }
3835
3836
3837 /* Return the value of parameter PARAM.
3838
3839 First search ALIST, then Vdefault_frame_alist, then the X defaults
3840 database, using ATTRIBUTE as the attribute name and CLASS as its class.
3841
3842 Convert the resource to the type specified by desired_type.
3843
3844 If no default is specified, return Qunbound. If you call
3845 x_get_arg, make sure you deal with Qunbound in a reasonable way,
3846 and don't let it get stored in any Lisp-visible variables! */
3847
3848 Lisp_Object
3849 x_get_arg (dpyinfo, alist, param, attribute, class, type)
3850 Display_Info *dpyinfo;
3851 Lisp_Object alist, param;
3852 char *attribute;
3853 char *class;
3854 enum resource_types type;
3855 {
3856 register Lisp_Object tem;
3857
3858 tem = Fassq (param, alist);
3859
3860 if (!NILP (tem))
3861 {
3862 /* If we find this parm in ALIST, clear it out
3863 so that it won't be "left over" at the end. */
3864 #ifndef WINDOWSNT /* w32fns.c has not yet been changed to cope with this. */
3865 Lisp_Object tail;
3866 XSETCAR (tem, Qnil);
3867 /* In case the parameter appears more than once in the alist,
3868 clear it out. */
3869 for (tail = alist; CONSP (tail); tail = XCDR (tail))
3870 if (CONSP (XCAR (tail))
3871 && EQ (XCAR (XCAR (tail)), param))
3872 XSETCAR (XCAR (tail), Qnil);
3873 #endif
3874 }
3875 else
3876 tem = Fassq (param, Vdefault_frame_alist);
3877
3878 /* If it wasn't specified in ALIST or the Lisp-level defaults,
3879 look in the X resources. */
3880 if (EQ (tem, Qnil))
3881 {
3882 if (attribute)
3883 {
3884 tem = display_x_get_resource (dpyinfo,
3885 build_string (attribute),
3886 build_string (class),
3887 Qnil, Qnil);
3888
3889 if (NILP (tem))
3890 return Qunbound;
3891
3892 switch (type)
3893 {
3894 case RES_TYPE_NUMBER:
3895 return make_number (atoi (SDATA (tem)));
3896
3897 case RES_TYPE_FLOAT:
3898 return make_float (atof (SDATA (tem)));
3899
3900 case RES_TYPE_BOOLEAN:
3901 tem = Fdowncase (tem);
3902 if (!strcmp (SDATA (tem), "on")
3903 || !strcmp (SDATA (tem), "true"))
3904 return Qt;
3905 else
3906 return Qnil;
3907
3908 case RES_TYPE_STRING:
3909 return tem;
3910
3911 case RES_TYPE_SYMBOL:
3912 /* As a special case, we map the values `true' and `on'
3913 to Qt, and `false' and `off' to Qnil. */
3914 {
3915 Lisp_Object lower;
3916 lower = Fdowncase (tem);
3917 if (!strcmp (SDATA (lower), "on")
3918 || !strcmp (SDATA (lower), "true"))
3919 return Qt;
3920 else if (!strcmp (SDATA (lower), "off")
3921 || !strcmp (SDATA (lower), "false"))
3922 return Qnil;
3923 else
3924 return Fintern (tem, Qnil);
3925 }
3926
3927 default:
3928 abort ();
3929 }
3930 }
3931 else
3932 return Qunbound;
3933 }
3934 return Fcdr (tem);
3935 }
3936
3937 Lisp_Object
3938 x_frame_get_arg (f, alist, param, attribute, class, type)
3939 struct frame *f;
3940 Lisp_Object alist, param;
3941 char *attribute;
3942 char *class;
3943 enum resource_types type;
3944 {
3945 return x_get_arg (FRAME_X_DISPLAY_INFO (f),
3946 alist, param, attribute, class, type);
3947 }
3948
3949 /* Like x_frame_get_arg, but also record the value in f->param_alist. */
3950
3951 Lisp_Object
3952 x_frame_get_and_record_arg (f, alist, param, attribute, class, type)
3953 struct frame *f;
3954 Lisp_Object alist, param;
3955 char *attribute;
3956 char *class;
3957 enum resource_types type;
3958 {
3959 Lisp_Object value;
3960
3961 value = x_get_arg (FRAME_X_DISPLAY_INFO (f), alist, param,
3962 attribute, class, type);
3963 if (! NILP (value) && ! EQ (value, Qunbound))
3964 store_frame_param (f, param, value);
3965
3966 return value;
3967 }
3968
3969
3970 /* Record in frame F the specified or default value according to ALIST
3971 of the parameter named PROP (a Lisp symbol).
3972 If no value is specified for PROP, look for an X default for XPROP
3973 on the frame named NAME.
3974 If that is not found either, use the value DEFLT. */
3975
3976 Lisp_Object
3977 x_default_parameter (f, alist, prop, deflt, xprop, xclass, type)
3978 struct frame *f;
3979 Lisp_Object alist;
3980 Lisp_Object prop;
3981 Lisp_Object deflt;
3982 char *xprop;
3983 char *xclass;
3984 enum resource_types type;
3985 {
3986 Lisp_Object tem;
3987
3988 tem = x_frame_get_arg (f, alist, prop, xprop, xclass, type);
3989 if (EQ (tem, Qunbound))
3990 tem = deflt;
3991 x_set_frame_parameters (f, Fcons (Fcons (prop, tem), Qnil));
3992 return tem;
3993 }
3994
3995
3996
3997 \f
3998 DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0,
3999 doc: /* Parse an X-style geometry string STRING.
4000 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
4001 The properties returned may include `top', `left', `height', and `width'.
4002 The value of `left' or `top' may be an integer,
4003 or a list (+ N) meaning N pixels relative to top/left corner,
4004 or a list (- N) meaning -N pixels relative to bottom/right corner. */)
4005 (string)
4006 Lisp_Object string;
4007 {
4008 int geometry, x, y;
4009 unsigned int width, height;
4010 Lisp_Object result;
4011
4012 CHECK_STRING (string);
4013
4014 geometry = XParseGeometry ((char *) SDATA (string),
4015 &x, &y, &width, &height);
4016
4017 #if 0
4018 if (!!(geometry & XValue) != !!(geometry & YValue))
4019 error ("Must specify both x and y position, or neither");
4020 #endif
4021
4022 result = Qnil;
4023 if (geometry & XValue)
4024 {
4025 Lisp_Object element;
4026
4027 if (x >= 0 && (geometry & XNegative))
4028 element = Fcons (Qleft, Fcons (Qminus, Fcons (make_number (-x), Qnil)));
4029 else if (x < 0 && ! (geometry & XNegative))
4030 element = Fcons (Qleft, Fcons (Qplus, Fcons (make_number (x), Qnil)));
4031 else
4032 element = Fcons (Qleft, make_number (x));
4033 result = Fcons (element, result);
4034 }
4035
4036 if (geometry & YValue)
4037 {
4038 Lisp_Object element;
4039
4040 if (y >= 0 && (geometry & YNegative))
4041 element = Fcons (Qtop, Fcons (Qminus, Fcons (make_number (-y), Qnil)));
4042 else if (y < 0 && ! (geometry & YNegative))
4043 element = Fcons (Qtop, Fcons (Qplus, Fcons (make_number (y), Qnil)));
4044 else
4045 element = Fcons (Qtop, make_number (y));
4046 result = Fcons (element, result);
4047 }
4048
4049 if (geometry & WidthValue)
4050 result = Fcons (Fcons (Qwidth, make_number (width)), result);
4051 if (geometry & HeightValue)
4052 result = Fcons (Fcons (Qheight, make_number (height)), result);
4053
4054 return result;
4055 }
4056
4057 /* Calculate the desired size and position of frame F.
4058 Return the flags saying which aspects were specified.
4059
4060 Also set the win_gravity and size_hint_flags of F.
4061
4062 Adjust height for toolbar if TOOLBAR_P is 1.
4063
4064 This function does not make the coordinates positive. */
4065
4066 #define DEFAULT_ROWS 40
4067 #define DEFAULT_COLS 80
4068
4069 int
4070 x_figure_window_size (f, parms, toolbar_p)
4071 struct frame *f;
4072 Lisp_Object parms;
4073 int toolbar_p;
4074 {
4075 register Lisp_Object tem0, tem1, tem2;
4076 long window_prompting = 0;
4077 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
4078
4079 /* Default values if we fall through.
4080 Actually, if that happens we should get
4081 window manager prompting. */
4082 SET_FRAME_COLS (f, DEFAULT_COLS);
4083 FRAME_LINES (f) = DEFAULT_ROWS;
4084 /* Window managers expect that if program-specified
4085 positions are not (0,0), they're intentional, not defaults. */
4086 f->top_pos = 0;
4087 f->left_pos = 0;
4088
4089 /* Ensure that old new_text_cols and new_text_lines will not override the
4090 values set here. */
4091 /* ++KFS: This was specific to W32, but seems ok for all platforms */
4092 f->new_text_cols = f->new_text_lines = 0;
4093
4094 tem0 = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER);
4095 tem1 = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
4096 tem2 = x_get_arg (dpyinfo, parms, Quser_size, 0, 0, RES_TYPE_NUMBER);
4097 if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
4098 {
4099 if (!EQ (tem0, Qunbound))
4100 {
4101 CHECK_NUMBER (tem0);
4102 FRAME_LINES (f) = XINT (tem0);
4103 }
4104 if (!EQ (tem1, Qunbound))
4105 {
4106 CHECK_NUMBER (tem1);
4107 SET_FRAME_COLS (f, XINT (tem1));
4108 }
4109 if (!NILP (tem2) && !EQ (tem2, Qunbound))
4110 window_prompting |= USSize;
4111 else
4112 window_prompting |= PSize;
4113 }
4114
4115 f->scroll_bar_actual_width
4116 = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
4117
4118 /* This used to be done _before_ calling x_figure_window_size, but
4119 since the height is reset here, this was really a no-op. I
4120 assume that moving it here does what Gerd intended (although he
4121 no longer can remember what that was... ++KFS, 2003-03-25. */
4122
4123 /* Add the tool-bar height to the initial frame height so that the
4124 user gets a text display area of the size he specified with -g or
4125 via .Xdefaults. Later changes of the tool-bar height don't
4126 change the frame size. This is done so that users can create
4127 tall Emacs frames without having to guess how tall the tool-bar
4128 will get. */
4129 if (toolbar_p && FRAME_TOOL_BAR_LINES (f))
4130 {
4131 int margin, relief, bar_height;
4132
4133 relief = (tool_bar_button_relief >= 0
4134 ? tool_bar_button_relief
4135 : DEFAULT_TOOL_BAR_BUTTON_RELIEF);
4136
4137 if (INTEGERP (Vtool_bar_button_margin)
4138 && XINT (Vtool_bar_button_margin) > 0)
4139 margin = XFASTINT (Vtool_bar_button_margin);
4140 else if (CONSP (Vtool_bar_button_margin)
4141 && INTEGERP (XCDR (Vtool_bar_button_margin))
4142 && XINT (XCDR (Vtool_bar_button_margin)) > 0)
4143 margin = XFASTINT (XCDR (Vtool_bar_button_margin));
4144 else
4145 margin = 0;
4146
4147 bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;
4148 FRAME_LINES (f) += (bar_height + FRAME_LINE_HEIGHT (f) - 1) / FRAME_LINE_HEIGHT (f);
4149 }
4150
4151 compute_fringe_widths (f, 0);
4152
4153 FRAME_PIXEL_WIDTH (f) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, FRAME_COLS (f));
4154 FRAME_PIXEL_HEIGHT (f) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, FRAME_LINES (f));
4155
4156 tem0 = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER);
4157 tem1 = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER);
4158 tem2 = x_get_arg (dpyinfo, parms, Quser_position, 0, 0, RES_TYPE_NUMBER);
4159 if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
4160 {
4161 if (EQ (tem0, Qminus))
4162 {
4163 f->top_pos = 0;
4164 window_prompting |= YNegative;
4165 }
4166 else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus)
4167 && CONSP (XCDR (tem0))
4168 && INTEGERP (XCAR (XCDR (tem0))))
4169 {
4170 f->top_pos = - XINT (XCAR (XCDR (tem0)));
4171 window_prompting |= YNegative;
4172 }
4173 else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus)
4174 && CONSP (XCDR (tem0))
4175 && INTEGERP (XCAR (XCDR (tem0))))
4176 {
4177 f->top_pos = XINT (XCAR (XCDR (tem0)));
4178 }
4179 else if (EQ (tem0, Qunbound))
4180 f->top_pos = 0;
4181 else
4182 {
4183 CHECK_NUMBER (tem0);
4184 f->top_pos = XINT (tem0);
4185 if (f->top_pos < 0)
4186 window_prompting |= YNegative;
4187 }
4188
4189 if (EQ (tem1, Qminus))
4190 {
4191 f->left_pos = 0;
4192 window_prompting |= XNegative;
4193 }
4194 else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus)
4195 && CONSP (XCDR (tem1))
4196 && INTEGERP (XCAR (XCDR (tem1))))
4197 {
4198 f->left_pos = - XINT (XCAR (XCDR (tem1)));
4199 window_prompting |= XNegative;
4200 }
4201 else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus)
4202 && CONSP (XCDR (tem1))
4203 && INTEGERP (XCAR (XCDR (tem1))))
4204 {
4205 f->left_pos = XINT (XCAR (XCDR (tem1)));
4206 }
4207 else if (EQ (tem1, Qunbound))
4208 f->left_pos = 0;
4209 else
4210 {
4211 CHECK_NUMBER (tem1);
4212 f->left_pos = XINT (tem1);
4213 if (f->left_pos < 0)
4214 window_prompting |= XNegative;
4215 }
4216
4217 if (!NILP (tem2) && ! EQ (tem2, Qunbound))
4218 window_prompting |= USPosition;
4219 else
4220 window_prompting |= PPosition;
4221 }
4222
4223 if (f->want_fullscreen != FULLSCREEN_NONE)
4224 {
4225 int left, top;
4226 int width, height;
4227
4228 /* It takes both for some WM:s to place it where we want */
4229 window_prompting = USPosition | PPosition;
4230 x_fullscreen_adjust (f, &width, &height, &top, &left);
4231 FRAME_COLS (f) = width;
4232 FRAME_LINES (f) = height;
4233 FRAME_PIXEL_WIDTH (f) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, width);
4234 FRAME_PIXEL_HEIGHT (f) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, height);
4235 f->left_pos = left;
4236 f->top_pos = top;
4237 }
4238
4239 if (window_prompting & XNegative)
4240 {
4241 if (window_prompting & YNegative)
4242 f->win_gravity = SouthEastGravity;
4243 else
4244 f->win_gravity = NorthEastGravity;
4245 }
4246 else
4247 {
4248 if (window_prompting & YNegative)
4249 f->win_gravity = SouthWestGravity;
4250 else
4251 f->win_gravity = NorthWestGravity;
4252 }
4253
4254 f->size_hint_flags = window_prompting;
4255
4256 return window_prompting;
4257 }
4258
4259
4260
4261 #endif /* HAVE_WINDOW_SYSTEM */
4262
4263
4264 \f
4265 /***********************************************************************
4266 Initialization
4267 ***********************************************************************/
4268
4269 void
4270 syms_of_frame ()
4271 {
4272 Qframep = intern ("framep");
4273 staticpro (&Qframep);
4274 Qframe_live_p = intern ("frame-live-p");
4275 staticpro (&Qframe_live_p);
4276 Qheight = intern ("height");
4277 staticpro (&Qheight);
4278 Qicon = intern ("icon");
4279 staticpro (&Qicon);
4280 Qminibuffer = intern ("minibuffer");
4281 staticpro (&Qminibuffer);
4282 Qmodeline = intern ("modeline");
4283 staticpro (&Qmodeline);
4284 Qonly = intern ("only");
4285 staticpro (&Qonly);
4286 Qwidth = intern ("width");
4287 staticpro (&Qwidth);
4288 Qgeometry = intern ("geometry");
4289 staticpro (&Qgeometry);
4290 Qicon_left = intern ("icon-left");
4291 staticpro (&Qicon_left);
4292 Qicon_top = intern ("icon-top");
4293 staticpro (&Qicon_top);
4294 Qleft = intern ("left");
4295 staticpro (&Qleft);
4296 Qright = intern ("right");
4297 staticpro (&Qright);
4298 Quser_position = intern ("user-position");
4299 staticpro (&Quser_position);
4300 Quser_size = intern ("user-size");
4301 staticpro (&Quser_size);
4302 Qwindow_id = intern ("window-id");
4303 staticpro (&Qwindow_id);
4304 #ifdef HAVE_X_WINDOWS
4305 Qouter_window_id = intern ("outer-window-id");
4306 staticpro (&Qouter_window_id);
4307 #endif
4308 Qparent_id = intern ("parent-id");
4309 staticpro (&Qparent_id);
4310 Qx = intern ("x");
4311 staticpro (&Qx);
4312 Qw32 = intern ("w32");
4313 staticpro (&Qw32);
4314 Qpc = intern ("pc");
4315 staticpro (&Qpc);
4316 Qmac = intern ("mac");
4317 staticpro (&Qmac);
4318 Qvisible = intern ("visible");
4319 staticpro (&Qvisible);
4320 Qbuffer_predicate = intern ("buffer-predicate");
4321 staticpro (&Qbuffer_predicate);
4322 Qbuffer_list = intern ("buffer-list");
4323 staticpro (&Qbuffer_list);
4324 Qburied_buffer_list = intern ("buried-buffer-list");
4325 staticpro (&Qburied_buffer_list);
4326 Qdisplay_type = intern ("display-type");
4327 staticpro (&Qdisplay_type);
4328 Qbackground_mode = intern ("background-mode");
4329 staticpro (&Qbackground_mode);
4330 Qtty_color_mode = intern ("tty-color-mode");
4331 staticpro (&Qtty_color_mode);
4332 Qtty = intern ("tty");
4333 staticpro (&Qtty);
4334 Qtty_type = intern ("tty-type");
4335 staticpro (&Qtty_type);
4336 Qwindow_system = intern ("window-system");
4337 staticpro (&Qwindow_system);
4338 Qenvironment = intern ("environment");
4339 staticpro (&Qenvironment);
4340
4341 Qface_set_after_frame_default = intern ("face-set-after-frame-default");
4342 staticpro (&Qface_set_after_frame_default);
4343
4344 Qinhibit_face_set_after_frame_default
4345 = intern ("inhibit-face-set-after-frame-default");
4346 staticpro (&Qinhibit_face_set_after_frame_default);
4347
4348 Qfullwidth = intern ("fullwidth");
4349 staticpro (&Qfullwidth);
4350 Qfullheight = intern ("fullheight");
4351 staticpro (&Qfullheight);
4352 Qfullboth = intern ("fullboth");
4353 staticpro (&Qfullboth);
4354 Qx_resource_name = intern ("x-resource-name");
4355 staticpro (&Qx_resource_name);
4356
4357 Qx_frame_parameter = intern ("x-frame-parameter");
4358 staticpro (&Qx_frame_parameter);
4359
4360 Qterminal = intern ("terminal");
4361 staticpro (&Qterminal);
4362 Qterminal_live_p = intern ("terminal-live-p");
4363 staticpro (&Qterminal_live_p);
4364
4365 {
4366 int i;
4367
4368 for (i = 0; i < sizeof (frame_parms) / sizeof (frame_parms[0]); i++)
4369 {
4370 Lisp_Object v = intern (frame_parms[i].name);
4371 if (frame_parms[i].variable)
4372 {
4373 *frame_parms[i].variable = v;
4374 staticpro (frame_parms[i].variable);
4375 }
4376 Fput (v, Qx_frame_parameter, make_number (i));
4377 }
4378 }
4379
4380 #ifdef HAVE_WINDOW_SYSTEM
4381 DEFVAR_LISP ("x-resource-name", &Vx_resource_name,
4382 doc: /* The name Emacs uses to look up X resources.
4383 `x-get-resource' uses this as the first component of the instance name
4384 when requesting resource values.
4385 Emacs initially sets `x-resource-name' to the name under which Emacs
4386 was invoked, or to the value specified with the `-name' or `-rn'
4387 switches, if present.
4388
4389 It may be useful to bind this variable locally around a call
4390 to `x-get-resource'. See also the variable `x-resource-class'. */);
4391 Vx_resource_name = Qnil;
4392
4393 DEFVAR_LISP ("x-resource-class", &Vx_resource_class,
4394 doc: /* The class Emacs uses to look up X resources.
4395 `x-get-resource' uses this as the first component of the instance class
4396 when requesting resource values.
4397
4398 Emacs initially sets `x-resource-class' to "Emacs".
4399
4400 Setting this variable permanently is not a reasonable thing to do,
4401 but binding this variable locally around a call to `x-get-resource'
4402 is a reasonable practice. See also the variable `x-resource-name'. */);
4403 Vx_resource_class = build_string (EMACS_CLASS);
4404 #endif
4405
4406 DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
4407 doc: /* Alist of default values for frame creation.
4408 These may be set in your init file, like this:
4409 (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
4410 These override values given in window system configuration data,
4411 including X Windows' defaults database.
4412 For values specific to the first Emacs frame, see `initial-frame-alist'.
4413 For window-system specific values, see `window-system-default-frame-alist'.
4414 For values specific to the separate minibuffer frame, see
4415 `minibuffer-frame-alist'.
4416 The `menu-bar-lines' element of the list controls whether new frames
4417 have menu bars; `menu-bar-mode' works by altering this element.
4418 Setting this variable does not affect existing frames, only new ones. */);
4419 Vdefault_frame_alist = Qnil;
4420
4421 DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars,
4422 doc: /* Default position of scroll bars on this window-system. */);
4423 #ifdef HAVE_WINDOW_SYSTEM
4424 #if defined(HAVE_NTGUI) || defined(MAC_OS)
4425 /* MS-Windows has scroll bars on the right by default. */
4426 Vdefault_frame_scroll_bars = Qright;
4427 #else
4428 Vdefault_frame_scroll_bars = Qleft;
4429 #endif
4430 #else
4431 Vdefault_frame_scroll_bars = Qnil;
4432 #endif
4433
4434 DEFVAR_LISP ("terminal-frame", &Vterminal_frame,
4435 doc: /* The initial frame-object, which represents Emacs's stdout. */);
4436
4437 DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified,
4438 doc: /* Non-nil if all of Emacs is iconified and frame updates are not needed. */);
4439 Vemacs_iconified = Qnil;
4440
4441 DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function,
4442 doc: /* If non-nil, function to transform normal value of `mouse-position'.
4443 `mouse-position' calls this function, passing its usual return value as
4444 argument, and returns whatever this function returns.
4445 This abnormal hook exists for the benefit of packages like `xt-mouse.el'
4446 which need to do mouse handling at the Lisp level. */);
4447 Vmouse_position_function = Qnil;
4448
4449 DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight,
4450 doc: /* If non-nil, clickable text is highlighted when mouse is over it.
4451 If the value is an integer, highlighting is only shown after moving the
4452 mouse, while keyboard input turns off the highlight even when the mouse
4453 is over the clickable text. However, the mouse shape still indicates
4454 when the mouse is over clickable text. */);
4455 Vmouse_highlight = Qt;
4456
4457 DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions,
4458 doc: /* Functions to be run before deleting a frame.
4459 The functions are run with one arg, the frame to be deleted.
4460 See `delete-frame'.
4461
4462 Note that functions in this list may be called twice on the same
4463 frame. In the second invocation, the frame is already deleted, and
4464 the function should do nothing. (You can use `frame-live-p' to check
4465 for this.) This wrinkle happens when an earlier function in
4466 `delete-frame-functions' (indirectly) calls delete-frame
4467 recursively. */);
4468 Vdelete_frame_functions = Qnil;
4469
4470 DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame,
4471 doc: /* Minibufferless frames use this frame's minibuffer.
4472
4473 Emacs cannot create minibufferless frames unless this is set to an
4474 appropriate surrogate.
4475
4476 Emacs consults this variable only when creating minibufferless
4477 frames; once the frame is created, it sticks with its assigned
4478 minibuffer, no matter what this variable is set to. This means that
4479 this variable doesn't necessarily say anything meaningful about the
4480 current set of frames, or where the minibuffer is currently being
4481 displayed.
4482
4483 This variable is local to the current terminal and cannot be buffer-local. */);
4484
4485 staticpro (&Vframe_list);
4486
4487 defsubr (&Sactive_minibuffer_window);
4488 defsubr (&Sframep);
4489 defsubr (&Sframe_live_p);
4490 defsubr (&Swindow_system);
4491 defsubr (&Smake_terminal_frame);
4492 defsubr (&Shandle_switch_frame);
4493 defsubr (&Sselect_frame);
4494 defsubr (&Sselected_frame);
4495 defsubr (&Swindow_frame);
4496 defsubr (&Sframe_root_window);
4497 defsubr (&Sframe_first_window);
4498 defsubr (&Sframe_selected_window);
4499 defsubr (&Sset_frame_selected_window);
4500 defsubr (&Sframe_list);
4501 defsubr (&Snext_frame);
4502 defsubr (&Sprevious_frame);
4503 defsubr (&Sdelete_frame);
4504 defsubr (&Smouse_position);
4505 defsubr (&Smouse_pixel_position);
4506 defsubr (&Sset_mouse_position);
4507 defsubr (&Sset_mouse_pixel_position);
4508 #if 0
4509 defsubr (&Sframe_configuration);
4510 defsubr (&Srestore_frame_configuration);
4511 #endif
4512 defsubr (&Smake_frame_visible);
4513 defsubr (&Smake_frame_invisible);
4514 defsubr (&Siconify_frame);
4515 defsubr (&Sframe_visible_p);
4516 defsubr (&Svisible_frame_list);
4517 defsubr (&Sraise_frame);
4518 defsubr (&Slower_frame);
4519 defsubr (&Sredirect_frame_focus);
4520 defsubr (&Sframe_focus);
4521 defsubr (&Sframe_parameters);
4522 defsubr (&Sframe_parameter);
4523 defsubr (&Smodify_frame_parameters);
4524 defsubr (&Sframe_with_environment);
4525 defsubr (&Sframe_char_height);
4526 defsubr (&Sframe_char_width);
4527 defsubr (&Sframe_pixel_height);
4528 defsubr (&Sframe_pixel_width);
4529 defsubr (&Sset_frame_height);
4530 defsubr (&Sset_frame_width);
4531 defsubr (&Sset_frame_size);
4532 defsubr (&Sset_frame_position);
4533
4534 #ifdef HAVE_WINDOW_SYSTEM
4535 defsubr (&Sx_get_resource);
4536 defsubr (&Sx_parse_geometry);
4537 #endif
4538
4539 }
4540
4541 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4542 (do not change this comment) */