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