Merge from emacs--rel--22
[bpt/emacs.git] / src / frame.c
1 /* Generic frame functions.
2 Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2006, 2007, 2008 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 3 of the License, or
10 (at your option) 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. If not, see <http://www.gnu.org/licenses/>. */
19
20 #include <config.h>
21
22 #include <stdio.h>
23 #include "lisp.h"
24 #include "character.h"
25 #ifdef HAVE_X_WINDOWS
26 #include "xterm.h"
27 #endif
28 #ifdef WINDOWSNT
29 #include "w32term.h"
30 #endif
31 #ifdef MAC_OS
32 #include "macterm.h"
33 #endif
34 #include "buffer.h"
35 /* These help us bind and responding to switch-frame events. */
36 #include "commands.h"
37 #include "keyboard.h"
38 #include "frame.h"
39 #include "blockinput.h"
40 #include "termchar.h"
41 #include "termhooks.h"
42 #include "dispextern.h"
43 #include "window.h"
44 #ifdef HAVE_WINDOW_SYSTEM
45 #include "font.h"
46 #include "fontset.h"
47 #endif
48 #ifdef MSDOS
49 #include "msdos.h"
50 #include "dosfns.h"
51 #endif
52
53
54 #ifdef HAVE_WINDOW_SYSTEM
55
56 /* The name we're using in resource queries. Most often "emacs". */
57
58 Lisp_Object Vx_resource_name;
59
60 /* The application class we're using in resource queries.
61 Normally "Emacs". */
62
63 Lisp_Object Vx_resource_class;
64
65 #endif
66
67 Lisp_Object Qframep, Qframe_live_p;
68 Lisp_Object Qicon, Qmodeline;
69 Lisp_Object Qonly;
70 Lisp_Object Qx, Qw32, Qmac, Qpc;
71 Lisp_Object Qvisible;
72 Lisp_Object Qdisplay_type;
73 Lisp_Object Qbackground_mode;
74 Lisp_Object Qnoelisp;
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 Qexplicit_name;
107 Lisp_Object Qunsplittable;
108 Lisp_Object Qmenu_bar_lines, Qtool_bar_lines;
109 Lisp_Object Qleft_fringe, Qright_fringe;
110 Lisp_Object Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list;
111 Lisp_Object Qtty_color_mode;
112 Lisp_Object Qtty, Qtty_type;
113
114 Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
115 Lisp_Object Qfont_backend;
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 static Lisp_Object Vdelete_frame_functions, Qdelete_frame_functions;
126
127 int focus_follows_mouse;
128 \f
129 static void
130 set_menu_bar_lines_1 (window, n)
131 Lisp_Object window;
132 int n;
133 {
134 struct window *w = XWINDOW (window);
135
136 XSETFASTINT (w->last_modified, 0);
137 XSETFASTINT (w->top_line, XFASTINT (w->top_line) + n);
138 XSETFASTINT (w->total_lines, XFASTINT (w->total_lines) - n);
139
140 if (INTEGERP (w->orig_top_line))
141 XSETFASTINT (w->orig_top_line, XFASTINT (w->orig_top_line) + n);
142 if (INTEGERP (w->orig_total_lines))
143 XSETFASTINT (w->orig_total_lines, XFASTINT (w->orig_total_lines) - n);
144
145 /* Handle just the top child in a vertical split. */
146 if (!NILP (w->vchild))
147 set_menu_bar_lines_1 (w->vchild, n);
148
149 /* Adjust all children in a horizontal split. */
150 for (window = w->hchild; !NILP (window); window = w->next)
151 {
152 w = XWINDOW (window);
153 set_menu_bar_lines_1 (window, n);
154 }
155 }
156
157 void
158 set_menu_bar_lines (f, value, oldval)
159 struct frame *f;
160 Lisp_Object value, oldval;
161 {
162 int nlines;
163 int olines = FRAME_MENU_BAR_LINES (f);
164
165 /* Right now, menu bars don't work properly in minibuf-only frames;
166 most of the commands try to apply themselves to the minibuffer
167 frame itself, and get an error because you can't switch buffers
168 in or split the minibuffer window. */
169 if (FRAME_MINIBUF_ONLY_P (f))
170 return;
171
172 if (INTEGERP (value))
173 nlines = XINT (value);
174 else
175 nlines = 0;
176
177 if (nlines != olines)
178 {
179 windows_or_buffers_changed++;
180 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
181 FRAME_MENU_BAR_LINES (f) = nlines;
182 set_menu_bar_lines_1 (f->root_window, nlines - olines);
183 adjust_glyphs (f);
184 }
185 }
186 \f
187 Lisp_Object Vemacs_iconified;
188 Lisp_Object Vframe_list;
189
190 extern Lisp_Object Vminibuffer_list;
191 extern Lisp_Object get_minibuffer ();
192 extern Lisp_Object Fhandle_switch_frame ();
193 extern Lisp_Object Fredirect_frame_focus ();
194 extern Lisp_Object x_get_focus_frame ();
195 \f
196 DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
197 doc: /* Return non-nil if OBJECT is a frame.
198 Value is t for a termcap frame (a character-only terminal),
199 `x' for an Emacs frame that is really an X window,
200 `w32' for an Emacs frame that is a window on MS-Windows display,
201 `mac' for an Emacs frame on a Macintosh display,
202 `pc' for a direct-write MS-DOS frame.
203 See also `frame-live-p'. */)
204 (object)
205 Lisp_Object object;
206 {
207 if (!FRAMEP (object))
208 return Qnil;
209 switch (XFRAME (object)->output_method)
210 {
211 case output_initial: /* The initial frame is like a termcap frame. */
212 case output_termcap:
213 return Qt;
214 case output_x_window:
215 return Qx;
216 case output_w32:
217 return Qw32;
218 case output_msdos_raw:
219 return Qpc;
220 case output_mac:
221 return Qmac;
222 default:
223 abort ();
224 }
225 }
226
227 DEFUN ("frame-live-p", Fframe_live_p, Sframe_live_p, 1, 1, 0,
228 doc: /* Return non-nil if OBJECT is a frame which has not been deleted.
229 Value is nil if OBJECT is not a live frame. If object is a live
230 frame, the return value indicates what sort of terminal device it is
231 displayed on. See the documentation of `framep' for possible
232 return values. */)
233 (object)
234 Lisp_Object object;
235 {
236 return ((FRAMEP (object)
237 && FRAME_LIVE_P (XFRAME (object)))
238 ? Fframep (object)
239 : Qnil);
240 }
241
242 DEFUN ("window-system", Fwindow_system, Swindow_system, 0, 1, 0,
243 doc: /* The name of the window system that FRAME is displaying through.
244 The value is a symbol---for instance, 'x' for X windows.
245 The value is nil if Emacs is using a text-only terminal.
246
247 FRAME defaults to the currently selected frame. */)
248 (frame)
249 Lisp_Object frame;
250 {
251 Lisp_Object type;
252 if (NILP (frame))
253 frame = selected_frame;
254
255 type = Fframep (frame);
256
257 if (NILP (type))
258 wrong_type_argument (Qframep, frame);
259
260 if (EQ (type, Qt))
261 return Qnil;
262 else
263 return type;
264 }
265
266 struct frame *
267 make_frame (mini_p)
268 int mini_p;
269 {
270 Lisp_Object frame;
271 register struct frame *f;
272 register Lisp_Object root_window;
273 register Lisp_Object mini_window;
274
275 f = allocate_frame ();
276 XSETFRAME (frame, f);
277
278 f->desired_matrix = 0;
279 f->current_matrix = 0;
280 f->desired_pool = 0;
281 f->current_pool = 0;
282 f->glyphs_initialized_p = 0;
283 f->decode_mode_spec_buffer = 0;
284 f->visible = 0;
285 f->async_visible = 0;
286 f->output_data.nothing = 0;
287 f->iconified = 0;
288 f->async_iconified = 0;
289 f->wants_modeline = 1;
290 f->auto_raise = 0;
291 f->auto_lower = 0;
292 f->no_split = 0;
293 f->garbaged = 1;
294 f->has_minibuffer = mini_p;
295 f->focus_frame = Qnil;
296 f->explicit_name = 0;
297 f->can_have_scroll_bars = 0;
298 f->vertical_scroll_bar_type = vertical_scroll_bar_none;
299 f->param_alist = Qnil;
300 f->scroll_bars = Qnil;
301 f->condemned_scroll_bars = Qnil;
302 f->face_alist = Qnil;
303 f->face_cache = NULL;
304 f->menu_bar_items = Qnil;
305 f->menu_bar_vector = Qnil;
306 f->menu_bar_items_used = 0;
307 f->buffer_predicate = Qnil;
308 f->buffer_list = Qnil;
309 f->buried_buffer_list = Qnil;
310 f->namebuf = 0;
311 f->title = Qnil;
312 f->menu_bar_window = Qnil;
313 f->tool_bar_window = Qnil;
314 f->tool_bar_items = Qnil;
315 f->desired_tool_bar_string = f->current_tool_bar_string = Qnil;
316 f->n_tool_bar_items = 0;
317 f->left_fringe_width = f->right_fringe_width = 0;
318 f->fringe_cols = 0;
319 f->scroll_bar_actual_width = 0;
320 f->border_width = 0;
321 f->internal_border_width = 0;
322 f->column_width = 1; /* !FRAME_WINDOW_P value */
323 f->line_height = 1; /* !FRAME_WINDOW_P value */
324 f->x_pixels_diff = f->y_pixels_diff = 0;
325 #ifdef HAVE_WINDOW_SYSTEM
326 f->want_fullscreen = FULLSCREEN_NONE;
327 #endif
328 f->size_hint_flags = 0;
329 f->win_gravity = 0;
330 f->font_driver_list = NULL;
331 f->font_data_list = NULL;
332
333 root_window = make_window ();
334 if (mini_p)
335 {
336 mini_window = make_window ();
337 XWINDOW (root_window)->next = mini_window;
338 XWINDOW (mini_window)->prev = root_window;
339 XWINDOW (mini_window)->mini_p = Qt;
340 XWINDOW (mini_window)->frame = frame;
341 f->minibuffer_window = mini_window;
342 }
343 else
344 {
345 mini_window = Qnil;
346 XWINDOW (root_window)->next = Qnil;
347 f->minibuffer_window = Qnil;
348 }
349
350 XWINDOW (root_window)->frame = frame;
351
352 /* 10 is arbitrary,
353 just so that there is "something there."
354 Correct size will be set up later with change_frame_size. */
355
356 SET_FRAME_COLS (f, 10);
357 FRAME_LINES (f) = 10;
358
359 XSETFASTINT (XWINDOW (root_window)->total_cols, 10);
360 XSETFASTINT (XWINDOW (root_window)->total_lines, (mini_p ? 9 : 10));
361
362 if (mini_p)
363 {
364 XSETFASTINT (XWINDOW (mini_window)->total_cols, 10);
365 XSETFASTINT (XWINDOW (mini_window)->top_line, 9);
366 XSETFASTINT (XWINDOW (mini_window)->total_lines, 1);
367 }
368
369 /* Choose a buffer for the frame's root window. */
370 {
371 Lisp_Object buf;
372
373 XWINDOW (root_window)->buffer = Qt;
374 buf = Fcurrent_buffer ();
375 /* If buf is a 'hidden' buffer (i.e. one whose name starts with
376 a space), try to find another one. */
377 if (SREF (Fbuffer_name (buf), 0) == ' ')
378 buf = Fother_buffer (buf, Qnil, Qnil);
379
380 /* Use set_window_buffer, not Fset_window_buffer, and don't let
381 hooks be run by it. The reason is that the whole frame/window
382 arrangement is not yet fully intialized at this point. Windows
383 don't have the right size, glyph matrices aren't initialized
384 etc. Running Lisp functions at this point surely ends in a
385 SEGV. */
386 set_window_buffer (root_window, buf, 0, 0);
387 f->buffer_list = Fcons (buf, Qnil);
388 }
389
390 if (mini_p)
391 {
392 XWINDOW (mini_window)->buffer = Qt;
393 set_window_buffer (mini_window,
394 (NILP (Vminibuffer_list)
395 ? get_minibuffer (0)
396 : Fcar (Vminibuffer_list)),
397 0, 0);
398 }
399
400 f->root_window = root_window;
401 f->selected_window = root_window;
402 /* Make sure this window seems more recently used than
403 a newly-created, never-selected window. */
404 ++window_select_count;
405 XSETFASTINT (XWINDOW (f->selected_window)->use_time, window_select_count);
406
407 f->default_face_done_p = 0;
408
409 return f;
410 }
411 \f
412 #ifdef HAVE_WINDOW_SYSTEM
413 /* Make a frame using a separate minibuffer window on another frame.
414 MINI_WINDOW is the minibuffer window to use. nil means use the
415 default (the global minibuffer). */
416
417 struct frame *
418 make_frame_without_minibuffer (mini_window, kb, display)
419 register Lisp_Object mini_window;
420 KBOARD *kb;
421 Lisp_Object display;
422 {
423 register struct frame *f;
424 struct gcpro gcpro1;
425
426 if (!NILP (mini_window))
427 CHECK_LIVE_WINDOW (mini_window);
428
429 #ifdef MULTI_KBOARD
430 if (!NILP (mini_window)
431 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window)->frame)) != kb)
432 error ("Frame and minibuffer must be on the same terminal");
433 #endif
434
435 /* Make a frame containing just a root window. */
436 f = make_frame (0);
437
438 if (NILP (mini_window))
439 {
440 /* Use default-minibuffer-frame if possible. */
441 if (!FRAMEP (kb->Vdefault_minibuffer_frame)
442 || ! FRAME_LIVE_P (XFRAME (kb->Vdefault_minibuffer_frame)))
443 {
444 Lisp_Object frame_dummy;
445
446 XSETFRAME (frame_dummy, f);
447 GCPRO1 (frame_dummy);
448 /* If there's no minibuffer frame to use, create one. */
449 kb->Vdefault_minibuffer_frame =
450 call1 (intern ("make-initial-minibuffer-frame"), display);
451 UNGCPRO;
452 }
453
454 mini_window = XFRAME (kb->Vdefault_minibuffer_frame)->minibuffer_window;
455 }
456
457 f->minibuffer_window = mini_window;
458
459 /* Make the chosen minibuffer window display the proper minibuffer,
460 unless it is already showing a minibuffer. */
461 if (NILP (Fmemq (XWINDOW (mini_window)->buffer, Vminibuffer_list)))
462 Fset_window_buffer (mini_window,
463 (NILP (Vminibuffer_list)
464 ? get_minibuffer (0)
465 : Fcar (Vminibuffer_list)), Qnil);
466 return f;
467 }
468
469 /* Make a frame containing only a minibuffer window. */
470
471 struct frame *
472 make_minibuffer_frame ()
473 {
474 /* First make a frame containing just a root window, no minibuffer. */
475
476 register struct frame *f = make_frame (0);
477 register Lisp_Object mini_window;
478 register Lisp_Object frame;
479
480 XSETFRAME (frame, f);
481
482 f->auto_raise = 0;
483 f->auto_lower = 0;
484 f->no_split = 1;
485 f->wants_modeline = 0;
486 f->has_minibuffer = 1;
487
488 /* Now label the root window as also being the minibuffer.
489 Avoid infinite looping on the window chain by marking next pointer
490 as nil. */
491
492 mini_window = f->minibuffer_window = f->root_window;
493 XWINDOW (mini_window)->mini_p = Qt;
494 XWINDOW (mini_window)->next = Qnil;
495 XWINDOW (mini_window)->prev = Qnil;
496 XWINDOW (mini_window)->frame = frame;
497
498 /* Put the proper buffer in that window. */
499
500 Fset_window_buffer (mini_window,
501 (NILP (Vminibuffer_list)
502 ? get_minibuffer (0)
503 : Fcar (Vminibuffer_list)), Qnil);
504 return f;
505 }
506 #endif /* HAVE_WINDOW_SYSTEM */
507 \f
508 /* Construct a frame that refers to a terminal. */
509
510 static int tty_frame_count;
511
512 struct frame *
513 make_initial_frame (void)
514 {
515 struct frame *f;
516 struct terminal *terminal;
517 Lisp_Object frame;
518
519 eassert (initial_kboard);
520
521 /* The first call must initialize Vframe_list. */
522 if (! (NILP (Vframe_list) || CONSP (Vframe_list)))
523 Vframe_list = Qnil;
524
525 terminal = init_initial_terminal ();
526
527 f = make_frame (1);
528 XSETFRAME (frame, f);
529
530 Vframe_list = Fcons (frame, Vframe_list);
531
532 tty_frame_count = 1;
533 f->name = build_string ("F1");
534
535 f->visible = 1;
536 f->async_visible = 1;
537
538 f->output_method = terminal->type;
539 f->terminal = terminal;
540 f->terminal->reference_count++;
541 f->output_data.nothing = 0;
542
543 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
544 FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
545
546 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
547 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
548
549 return f;
550 }
551
552
553 struct frame *
554 make_terminal_frame (struct terminal *terminal)
555 {
556 register struct frame *f;
557 Lisp_Object frame;
558 char name[20];
559
560 if (!terminal->name)
561 error ("Terminal is not live, can't create new frames on it");
562
563 f = make_frame (1);
564
565 XSETFRAME (frame, f);
566 Vframe_list = Fcons (frame, Vframe_list);
567
568 tty_frame_count++;
569 sprintf (name, "F%d", tty_frame_count);
570 f->name = build_string (name);
571
572 f->visible = 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
573 f->async_visible = 1; /* Don't let visible be cleared later. */
574 #ifdef MSDOS
575 f->output_data.x = &the_only_x_display;
576 if (!inhibit_window_system
577 && (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame))
578 || XFRAME (selected_frame)->output_method == output_msdos_raw))
579 {
580 f->output_method = output_msdos_raw;
581 /* This initialization of foreground and background pixels is
582 only important for the initial frame created in temacs. If
583 we don't do that, we get black background and foreground in
584 the dumped Emacs because the_only_x_display is a static
585 variable, hence it is born all-zeroes, and zero is the code
586 for the black color. Other frames all inherit their pixels
587 from what's already in the_only_x_display. */
588 if ((!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame)))
589 && FRAME_BACKGROUND_PIXEL (f) == 0
590 && FRAME_FOREGROUND_PIXEL (f) == 0)
591 {
592 FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
593 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
594 }
595 }
596 else
597 f->output_method = output_termcap;
598 #else
599 {
600 f->output_method = output_termcap;
601 f->terminal = terminal;
602 f->terminal->reference_count++;
603 create_tty_output (f);
604
605 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
606 FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
607
608 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
609 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
610
611 /* Set the top frame to the newly created frame. */
612 if (FRAMEP (FRAME_TTY (f)->top_frame)
613 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f)->top_frame)))
614 XFRAME (FRAME_TTY (f)->top_frame)->async_visible = 2; /* obscured */
615
616 FRAME_TTY (f)->top_frame = frame;
617 }
618
619 #ifdef CANNOT_DUMP
620 FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR;
621 FRAME_BACKGROUND_PIXEL(f) = FACE_TTY_DEFAULT_BG_COLOR;
622 #endif
623 #endif /* MSDOS */
624
625 if (!noninteractive)
626 init_frame_faces (f);
627
628 return f;
629 }
630
631 /* Get a suitable value for frame parameter PARAMETER for a newly
632 created frame, based on (1) the user-supplied frame parameter
633 alist SUPPLIED_PARMS, (2) CURRENT_VALUE, and finally, if all else
634 fails, (3) Vdefault_frame_alist. */
635
636 static Lisp_Object
637 get_future_frame_param (Lisp_Object parameter,
638 Lisp_Object supplied_parms,
639 char *current_value)
640 {
641 Lisp_Object result;
642
643 result = Fassq (parameter, supplied_parms);
644 if (NILP (result))
645 result = Fassq (parameter, XFRAME (selected_frame)->param_alist);
646 if (NILP (result) && current_value != NULL)
647 result = build_string (current_value);
648 if (NILP (result))
649 result = Fassq (parameter, Vdefault_frame_alist);
650 if (!NILP (result) && !STRINGP (result))
651 result = XCDR (result);
652 if (NILP (result) || !STRINGP (result))
653 result = Qnil;
654
655 return result;
656 }
657
658 DEFUN ("make-terminal-frame", Fmake_terminal_frame, Smake_terminal_frame,
659 1, 1, 0,
660 doc: /* Create an additional terminal frame, possibly on another terminal.
661 This function takes one argument, an alist specifying frame parameters.
662
663 You can create multiple frames on a single text-only terminal, but
664 only one of them (the selected terminal frame) is actually displayed.
665
666 In practice, generally you don't need to specify any parameters,
667 except when you want to create a new frame on another terminal.
668 In that case, the `tty' parameter specifies the device file to open,
669 and the `tty-type' parameter specifies the terminal type. Example:
670
671 (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
672
673 Note that changing the size of one terminal frame automatically
674 affects all frames on the same terminal device. */)
675 (parms)
676 Lisp_Object parms;
677 {
678 struct frame *f;
679 struct terminal *t = NULL;
680 Lisp_Object frame, tem;
681 struct frame *sf = SELECTED_FRAME ();
682
683 #ifdef MSDOS
684 if (sf->output_method != output_msdos_raw
685 && sf->output_method != output_termcap)
686 abort ();
687 #else /* not MSDOS */
688
689 #if 0
690 /* This can happen for multi-tty when using both terminal frames and
691 Carbon frames. */
692 if (sf->output_method != output_mac)
693 error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
694 #else
695 #if 0 /* This should work now! */
696 if (sf->output_method != output_termcap)
697 error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
698 #endif
699 #endif
700 #endif /* not MSDOS */
701
702 {
703 Lisp_Object terminal;
704
705 terminal = Fassq (Qterminal, parms);
706 if (!NILP (terminal))
707 {
708 terminal = XCDR (terminal);
709 t = get_terminal (terminal, 1);
710 }
711 }
712
713 if (!t)
714 {
715 char *name = 0, *type = 0;
716 Lisp_Object tty, tty_type;
717
718 tty = get_future_frame_param
719 (Qtty, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame))
720 ? FRAME_TTY (XFRAME (selected_frame))->name
721 : NULL));
722 if (!NILP (tty))
723 {
724 name = (char *) alloca (SBYTES (tty) + 1);
725 strncpy (name, SDATA (tty), SBYTES (tty));
726 name[SBYTES (tty)] = 0;
727 }
728
729 tty_type = get_future_frame_param
730 (Qtty_type, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame))
731 ? FRAME_TTY (XFRAME (selected_frame))->type
732 : NULL));
733 if (!NILP (tty_type))
734 {
735 type = (char *) alloca (SBYTES (tty_type) + 1);
736 strncpy (type, SDATA (tty_type), SBYTES (tty_type));
737 type[SBYTES (tty_type)] = 0;
738 }
739
740 t = init_tty (name, type, 0); /* Errors are not fatal. */
741 }
742
743 f = make_terminal_frame (t);
744
745 {
746 int width, height;
747 get_tty_size (fileno (FRAME_TTY (f)->input), &width, &height);
748 change_frame_size (f, height, width, 0, 0, 0);
749 }
750
751 adjust_glyphs (f);
752 calculate_costs (f);
753 XSETFRAME (frame, f);
754 Fmodify_frame_parameters (frame, Vdefault_frame_alist);
755 Fmodify_frame_parameters (frame, parms);
756 Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty_type,
757 build_string (t->display_info.tty->type)),
758 Qnil));
759 if (t->display_info.tty->name != NULL)
760 Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty,
761 build_string (t->display_info.tty->name)),
762 Qnil));
763 else
764 Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty, Qnil), Qnil));
765
766 /* Make the frame face alist be frame-specific, so that each
767 frame could change its face definitions independently. */
768 f->face_alist = Fcopy_alist (sf->face_alist);
769 /* Simple Fcopy_alist isn't enough, because we need the contents of
770 the vectors which are the CDRs of associations in face_alist to
771 be copied as well. */
772 for (tem = f->face_alist; CONSP (tem); tem = XCDR (tem))
773 XSETCDR (XCAR (tem), Fcopy_sequence (XCDR (XCAR (tem))));
774 return frame;
775 }
776
777 \f
778 /* Perform the switch to frame FRAME.
779
780 If FRAME is a switch-frame event `(switch-frame FRAME1)', use
781 FRAME1 as frame.
782
783 If TRACK is non-zero and the frame that currently has the focus
784 redirects its focus to the selected frame, redirect that focused
785 frame's focus to FRAME instead.
786
787 FOR_DELETION non-zero means that the selected frame is being
788 deleted, which includes the possibility that the frame's terminal
789 is dead. */
790
791 Lisp_Object
792 do_switch_frame (frame, track, for_deletion)
793 Lisp_Object frame;
794 int track, for_deletion;
795 {
796 struct frame *sf = SELECTED_FRAME ();
797
798 /* If FRAME is a switch-frame event, extract the frame we should
799 switch to. */
800 if (CONSP (frame)
801 && EQ (XCAR (frame), Qswitch_frame)
802 && CONSP (XCDR (frame)))
803 frame = XCAR (XCDR (frame));
804
805 /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for
806 a switch-frame event to arrive after a frame is no longer live,
807 especially when deleting the initial frame during startup. */
808 CHECK_FRAME (frame);
809 if (! FRAME_LIVE_P (XFRAME (frame)))
810 return Qnil;
811
812 if (sf == XFRAME (frame))
813 return frame;
814
815 /* This is too greedy; it causes inappropriate focus redirection
816 that's hard to get rid of. */
817 #if 0
818 /* If a frame's focus has been redirected toward the currently
819 selected frame, we should change the redirection to point to the
820 newly selected frame. This means that if the focus is redirected
821 from a minibufferless frame to a surrogate minibuffer frame, we
822 can use `other-window' to switch between all the frames using
823 that minibuffer frame, and the focus redirection will follow us
824 around. */
825 if (track)
826 {
827 Lisp_Object tail;
828
829 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
830 {
831 Lisp_Object focus;
832
833 if (!FRAMEP (XCAR (tail)))
834 abort ();
835
836 focus = FRAME_FOCUS_FRAME (XFRAME (XCAR (tail)));
837
838 if (FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ())
839 Fredirect_frame_focus (XCAR (tail), frame);
840 }
841 }
842 #else /* ! 0 */
843 /* Instead, apply it only to the frame we're pointing to. */
844 #ifdef HAVE_WINDOW_SYSTEM
845 if (track && FRAME_WINDOW_P (XFRAME (frame)))
846 {
847 Lisp_Object focus, xfocus;
848
849 xfocus = x_get_focus_frame (XFRAME (frame));
850 if (FRAMEP (xfocus))
851 {
852 focus = FRAME_FOCUS_FRAME (XFRAME (xfocus));
853 if (FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ())
854 Fredirect_frame_focus (xfocus, frame);
855 }
856 }
857 #endif /* HAVE_X_WINDOWS */
858 #endif /* ! 0 */
859
860 if (!for_deletion && FRAME_HAS_MINIBUF_P (sf))
861 resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf)), 1);
862
863 if (FRAME_TERMCAP_P (XFRAME (frame)))
864 {
865 if (FRAMEP (FRAME_TTY (XFRAME (frame))->top_frame))
866 /* Mark previously displayed frame as now obscured. */
867 XFRAME (FRAME_TTY (XFRAME (frame))->top_frame)->async_visible = 2;
868 XFRAME (frame)->async_visible = 1;
869 FRAME_TTY (XFRAME (frame))->top_frame = frame;
870 }
871
872 selected_frame = frame;
873 if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame)))
874 last_nonminibuf_frame = XFRAME (selected_frame);
875
876 Fselect_window (XFRAME (frame)->selected_window, Qnil);
877
878 /* We want to make sure that the next event generates a frame-switch
879 event to the appropriate frame. This seems kludgy to me, but
880 before you take it out, make sure that evaluating something like
881 (select-window (frame-root-window (new-frame))) doesn't end up
882 with your typing being interpreted in the new frame instead of
883 the one you're actually typing in. */
884 internal_last_event_frame = Qnil;
885
886 return frame;
887 }
888
889 DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 1, "e",
890 doc: /* Select the frame FRAME.
891 Subsequent editing commands apply to its selected window.
892 The selection of FRAME lasts until the next time the user does
893 something to select a different frame, or until the next time this
894 function is called. If you are using a window system, the previously
895 selected frame may be restored as the selected frame after return to
896 the command loop, because it still may have the window system's input
897 focus. On a text-only terminal, the next redisplay will display FRAME.
898
899 This function returns FRAME, or nil if FRAME has been deleted. */)
900 (frame)
901 Lisp_Object frame;
902 {
903 return do_switch_frame (frame, 1, 0);
904 }
905
906
907 DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 1, "e",
908 doc: /* Handle a switch-frame event EVENT.
909 Switch-frame events are usually bound to this function.
910 A switch-frame event tells Emacs that the window manager has requested
911 that the user's events be directed to the frame mentioned in the event.
912 This function selects the selected window of the frame of EVENT.
913
914 If EVENT is frame object, handle it as if it were a switch-frame event
915 to that frame. */)
916 (event)
917 Lisp_Object event;
918 {
919 /* Preserve prefix arg that the command loop just cleared. */
920 current_kboard->Vprefix_arg = Vcurrent_prefix_arg;
921 call1 (Vrun_hooks, Qmouse_leave_buffer_hook);
922 return do_switch_frame (event, 0, 0);
923 }
924
925 DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
926 doc: /* Return the frame that is now selected. */)
927 ()
928 {
929 return selected_frame;
930 }
931 \f
932 DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
933 doc: /* Return the frame object that window WINDOW is on. */)
934 (window)
935 Lisp_Object window;
936 {
937 CHECK_LIVE_WINDOW (window);
938 return XWINDOW (window)->frame;
939 }
940
941 DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0,
942 doc: /* Returns the topmost, leftmost window of FRAME.
943 If omitted, FRAME defaults to the currently selected frame. */)
944 (frame)
945 Lisp_Object frame;
946 {
947 Lisp_Object w;
948
949 if (NILP (frame))
950 w = SELECTED_FRAME ()->root_window;
951 else
952 {
953 CHECK_LIVE_FRAME (frame);
954 w = XFRAME (frame)->root_window;
955 }
956 while (NILP (XWINDOW (w)->buffer))
957 {
958 if (! NILP (XWINDOW (w)->hchild))
959 w = XWINDOW (w)->hchild;
960 else if (! NILP (XWINDOW (w)->vchild))
961 w = XWINDOW (w)->vchild;
962 else
963 abort ();
964 }
965 return w;
966 }
967
968 DEFUN ("active-minibuffer-window", Factive_minibuffer_window,
969 Sactive_minibuffer_window, 0, 0, 0,
970 doc: /* Return the currently active minibuffer window, or nil if none. */)
971 ()
972 {
973 return minibuf_level ? minibuf_window : Qnil;
974 }
975
976 DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0,
977 doc: /* Returns the root-window of FRAME.
978 If omitted, FRAME defaults to the currently selected frame. */)
979 (frame)
980 Lisp_Object frame;
981 {
982 Lisp_Object window;
983
984 if (NILP (frame))
985 window = SELECTED_FRAME ()->root_window;
986 else
987 {
988 CHECK_LIVE_FRAME (frame);
989 window = XFRAME (frame)->root_window;
990 }
991
992 return window;
993 }
994
995 DEFUN ("frame-selected-window", Fframe_selected_window,
996 Sframe_selected_window, 0, 1, 0,
997 doc: /* Return the selected window of frame object FRAME.
998 If omitted, FRAME defaults to the currently selected frame. */)
999 (frame)
1000 Lisp_Object frame;
1001 {
1002 Lisp_Object window;
1003
1004 if (NILP (frame))
1005 window = SELECTED_FRAME ()->selected_window;
1006 else
1007 {
1008 CHECK_LIVE_FRAME (frame);
1009 window = XFRAME (frame)->selected_window;
1010 }
1011
1012 return window;
1013 }
1014
1015 DEFUN ("set-frame-selected-window", Fset_frame_selected_window,
1016 Sset_frame_selected_window, 2, 2, 0,
1017 doc: /* Set the selected window of frame object FRAME to WINDOW.
1018 Return WINDOW.
1019 If FRAME is nil, the selected frame is used.
1020 If FRAME is the selected frame, this makes WINDOW the selected window. */)
1021 (frame, window)
1022 Lisp_Object frame, window;
1023 {
1024 if (NILP (frame))
1025 frame = selected_frame;
1026
1027 CHECK_LIVE_FRAME (frame);
1028 CHECK_LIVE_WINDOW (window);
1029
1030 if (! EQ (frame, WINDOW_FRAME (XWINDOW (window))))
1031 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
1032
1033 if (EQ (frame, selected_frame))
1034 return Fselect_window (window, Qnil);
1035
1036 return XFRAME (frame)->selected_window = window;
1037 }
1038
1039 \f
1040 DEFUN ("frame-list", Fframe_list, Sframe_list,
1041 0, 0, 0,
1042 doc: /* Return a list of all frames. */)
1043 ()
1044 {
1045 Lisp_Object frames;
1046 frames = Fcopy_sequence (Vframe_list);
1047 #ifdef HAVE_WINDOW_SYSTEM
1048 if (FRAMEP (tip_frame))
1049 frames = Fdelq (tip_frame, frames);
1050 #endif
1051 return frames;
1052 }
1053
1054 /* Return the next frame in the frame list after FRAME.
1055 If MINIBUF is nil, exclude minibuffer-only frames.
1056 If MINIBUF is a window, include only its own frame
1057 and any frame now using that window as the minibuffer.
1058 If MINIBUF is `visible', include all visible frames.
1059 If MINIBUF is 0, include all visible and iconified frames.
1060 Otherwise, include all frames. */
1061
1062 static Lisp_Object
1063 next_frame (frame, minibuf)
1064 Lisp_Object frame;
1065 Lisp_Object minibuf;
1066 {
1067 Lisp_Object tail;
1068 int passed = 0;
1069
1070 /* There must always be at least one frame in Vframe_list. */
1071 if (! CONSP (Vframe_list))
1072 abort ();
1073
1074 /* If this frame is dead, it won't be in Vframe_list, and we'll loop
1075 forever. Forestall that. */
1076 CHECK_LIVE_FRAME (frame);
1077
1078 while (1)
1079 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
1080 {
1081 Lisp_Object f;
1082
1083 f = XCAR (tail);
1084
1085 if (passed
1086 && ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame))
1087 && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame)))
1088 || (FRAME_TERMCAP_P (XFRAME (f)) && FRAME_TERMCAP_P (XFRAME (frame))
1089 && FRAME_TTY (XFRAME (f)) == FRAME_TTY (XFRAME (frame)))))
1090 {
1091 /* Decide whether this frame is eligible to be returned. */
1092
1093 /* If we've looped all the way around without finding any
1094 eligible frames, return the original frame. */
1095 if (EQ (f, frame))
1096 return f;
1097
1098 /* Let minibuf decide if this frame is acceptable. */
1099 if (NILP (minibuf))
1100 {
1101 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
1102 return f;
1103 }
1104 else if (EQ (minibuf, Qvisible))
1105 {
1106 FRAME_SAMPLE_VISIBILITY (XFRAME (f));
1107 if (FRAME_VISIBLE_P (XFRAME (f)))
1108 return f;
1109 }
1110 else if (INTEGERP (minibuf) && XINT (minibuf) == 0)
1111 {
1112 FRAME_SAMPLE_VISIBILITY (XFRAME (f));
1113 if (FRAME_VISIBLE_P (XFRAME (f))
1114 || FRAME_ICONIFIED_P (XFRAME (f)))
1115 return f;
1116 }
1117 else if (WINDOWP (minibuf))
1118 {
1119 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf)
1120 || EQ (WINDOW_FRAME (XWINDOW (minibuf)), f)
1121 || EQ (WINDOW_FRAME (XWINDOW (minibuf)),
1122 FRAME_FOCUS_FRAME (XFRAME (f))))
1123 return f;
1124 }
1125 else
1126 return f;
1127 }
1128
1129 if (EQ (frame, f))
1130 passed++;
1131 }
1132 }
1133
1134 /* Return the previous frame in the frame list before FRAME.
1135 If MINIBUF is nil, exclude minibuffer-only frames.
1136 If MINIBUF is a window, include only its own frame
1137 and any frame now using that window as the minibuffer.
1138 If MINIBUF is `visible', include all visible frames.
1139 If MINIBUF is 0, include all visible and iconified frames.
1140 Otherwise, include all frames. */
1141
1142 static Lisp_Object
1143 prev_frame (frame, minibuf)
1144 Lisp_Object frame;
1145 Lisp_Object minibuf;
1146 {
1147 Lisp_Object tail;
1148 Lisp_Object prev;
1149
1150 /* There must always be at least one frame in Vframe_list. */
1151 if (! CONSP (Vframe_list))
1152 abort ();
1153
1154 prev = Qnil;
1155 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
1156 {
1157 Lisp_Object f;
1158
1159 f = XCAR (tail);
1160 if (!FRAMEP (f))
1161 abort ();
1162
1163 if (EQ (frame, f) && !NILP (prev))
1164 return prev;
1165
1166 if ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame))
1167 && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame)))
1168 || (FRAME_TERMCAP_P (XFRAME (f)) && FRAME_TERMCAP_P (XFRAME (frame))
1169 && FRAME_TTY (XFRAME (f)) == FRAME_TTY (XFRAME (frame))))
1170 {
1171 /* Decide whether this frame is eligible to be returned,
1172 according to minibuf. */
1173 if (NILP (minibuf))
1174 {
1175 if (! FRAME_MINIBUF_ONLY_P (XFRAME (f)))
1176 prev = f;
1177 }
1178 else if (WINDOWP (minibuf))
1179 {
1180 if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf)
1181 || EQ (WINDOW_FRAME (XWINDOW (minibuf)), f)
1182 || EQ (WINDOW_FRAME (XWINDOW (minibuf)),
1183 FRAME_FOCUS_FRAME (XFRAME (f))))
1184 prev = f;
1185 }
1186 else if (EQ (minibuf, Qvisible))
1187 {
1188 FRAME_SAMPLE_VISIBILITY (XFRAME (f));
1189 if (FRAME_VISIBLE_P (XFRAME (f)))
1190 prev = f;
1191 }
1192 else if (XFASTINT (minibuf) == 0)
1193 {
1194 FRAME_SAMPLE_VISIBILITY (XFRAME (f));
1195 if (FRAME_VISIBLE_P (XFRAME (f))
1196 || FRAME_ICONIFIED_P (XFRAME (f)))
1197 prev = f;
1198 }
1199 else
1200 prev = f;
1201 }
1202 }
1203
1204 /* We've scanned the entire list. */
1205 if (NILP (prev))
1206 /* We went through the whole frame list without finding a single
1207 acceptable frame. Return the original frame. */
1208 return frame;
1209 else
1210 /* There were no acceptable frames in the list before FRAME; otherwise,
1211 we would have returned directly from the loop. Since PREV is the last
1212 acceptable frame in the list, return it. */
1213 return prev;
1214 }
1215
1216
1217 DEFUN ("next-frame", Fnext_frame, Snext_frame, 0, 2, 0,
1218 doc: /* Return the next frame in the frame list after FRAME.
1219 It considers only frames on the same terminal as FRAME.
1220 By default, skip minibuffer-only frames.
1221 If omitted, FRAME defaults to the selected frame.
1222 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1223 If MINIFRAME is a window, include only its own frame
1224 and any frame now using that window as the minibuffer.
1225 If MINIFRAME is `visible', include all visible frames.
1226 If MINIFRAME is 0, include all visible and iconified frames.
1227 Otherwise, include all frames. */)
1228 (frame, miniframe)
1229 Lisp_Object frame, miniframe;
1230 {
1231 if (NILP (frame))
1232 frame = selected_frame;
1233
1234 CHECK_LIVE_FRAME (frame);
1235 return next_frame (frame, miniframe);
1236 }
1237
1238 DEFUN ("previous-frame", Fprevious_frame, Sprevious_frame, 0, 2, 0,
1239 doc: /* Return the previous frame in the frame list before FRAME.
1240 It considers only frames on the same terminal as FRAME.
1241 By default, skip minibuffer-only frames.
1242 If omitted, FRAME defaults to the selected frame.
1243 If optional argument MINIFRAME is nil, exclude minibuffer-only frames.
1244 If MINIFRAME is a window, include only its own frame
1245 and any frame now using that window as the minibuffer.
1246 If MINIFRAME is `visible', include all visible frames.
1247 If MINIFRAME is 0, include all visible and iconified frames.
1248 Otherwise, include all frames. */)
1249 (frame, miniframe)
1250 Lisp_Object frame, miniframe;
1251 {
1252 if (NILP (frame))
1253 frame = selected_frame;
1254 CHECK_LIVE_FRAME (frame);
1255 return prev_frame (frame, miniframe);
1256 }
1257 \f
1258 /* Return 1 if it is ok to delete frame F;
1259 0 if all frames aside from F are invisible.
1260 (Exception: if F is the terminal frame, and we are using X, return 1.) */
1261
1262 int
1263 other_visible_frames (f)
1264 FRAME_PTR f;
1265 {
1266 /* We know the selected frame is visible,
1267 so if F is some other frame, it can't be the sole visible one. */
1268 if (f == SELECTED_FRAME ())
1269 {
1270 Lisp_Object frames;
1271 int count = 0;
1272
1273 for (frames = Vframe_list;
1274 CONSP (frames);
1275 frames = XCDR (frames))
1276 {
1277 Lisp_Object this;
1278
1279 this = XCAR (frames);
1280 /* Verify that the frame's window still exists
1281 and we can still talk to it. And note any recent change
1282 in visibility. */
1283 #ifdef HAVE_WINDOW_SYSTEM
1284 if (FRAME_WINDOW_P (XFRAME (this)))
1285 {
1286 x_sync (XFRAME (this));
1287 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1288 }
1289 #endif
1290
1291 if (FRAME_VISIBLE_P (XFRAME (this))
1292 || FRAME_ICONIFIED_P (XFRAME (this))
1293 /* Allow deleting the terminal frame when at least
1294 one X frame exists! */
1295 || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f)))
1296 count++;
1297 }
1298 return count > 1;
1299 }
1300 return 1;
1301 }
1302
1303 /* Error handler for `delete-frame-functions'. */
1304 static Lisp_Object
1305 delete_frame_handler (Lisp_Object arg)
1306 {
1307 add_to_log ("Error during `delete-frame': %s", arg, Qnil);
1308 return Qnil;
1309 }
1310
1311 extern Lisp_Object Qrun_hook_with_args;
1312
1313 DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "",
1314 doc: /* Delete FRAME, permanently eliminating it from use.
1315 If omitted, FRAME defaults to the selected frame.
1316 A frame may not be deleted if its minibuffer is used by other frames.
1317 Normally, you may not delete a frame if all other frames are invisible,
1318 but if the second optional argument FORCE is non-nil, you may do so.
1319
1320 This function runs `delete-frame-functions' before actually deleting the
1321 frame, unless the frame is a tooltip.
1322 The functions are run with one arg, the frame to be deleted.
1323 But FORCE inhibits this too. */)
1324 /* FORCE is non-nil when handling a disconnected terminal. */
1325 (frame, force)
1326 Lisp_Object frame, force;
1327 {
1328 struct frame *f;
1329 struct frame *sf = SELECTED_FRAME ();
1330 struct kboard *kb;
1331
1332 int minibuffer_selected;
1333
1334 if (EQ (frame, Qnil))
1335 {
1336 f = sf;
1337 XSETFRAME (frame, f);
1338 }
1339 else
1340 {
1341 CHECK_FRAME (frame);
1342 f = XFRAME (frame);
1343 }
1344
1345 if (! FRAME_LIVE_P (f))
1346 return Qnil;
1347
1348 if (NILP (force) && !other_visible_frames (f))
1349 error ("Attempt to delete the sole visible or iconified frame");
1350
1351 #if 0
1352 /* This is a nice idea, but x_connection_closed needs to be able
1353 to delete the last frame, if it is gone. */
1354 if (NILP (XCDR (Vframe_list)))
1355 error ("Attempt to delete the only frame");
1356 #endif
1357
1358 /* Does this frame have a minibuffer, and is it the surrogate
1359 minibuffer for any other frame? */
1360 if (FRAME_HAS_MINIBUF_P (XFRAME (frame)))
1361 {
1362 Lisp_Object frames;
1363
1364 for (frames = Vframe_list;
1365 CONSP (frames);
1366 frames = XCDR (frames))
1367 {
1368 Lisp_Object this;
1369 this = XCAR (frames);
1370
1371 if (! EQ (this, frame)
1372 && EQ (frame,
1373 WINDOW_FRAME (XWINDOW
1374 (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
1375 {
1376 /* If we MUST delete this frame, delete the other first. */
1377 if (!NILP (force))
1378 Fdelete_frame (this, force);
1379 else
1380 error ("Attempt to delete a surrogate minibuffer frame");
1381 }
1382 }
1383 }
1384
1385 /* Run `delete-frame-functions'
1386 unless FORCE is `noelisp' or frame is a tooltip.
1387 FORCE is set to `noelisp' when handling a disconnect from the terminal,
1388 so we don't dare call Lisp code. */
1389 if (NILP (Vrun_hooks) || !NILP (Fframe_parameter (frame, intern ("tooltip"))))
1390 ;
1391 if (EQ (force, Qnoelisp))
1392 pending_funcalls
1393 = Fcons (list3 (Qrun_hook_with_args, Qdelete_frame_functions, frame),
1394 pending_funcalls);
1395 else
1396 safe_call2 (Qrun_hook_with_args, Qdelete_frame_functions, frame);
1397
1398 /* The hook may sometimes (indirectly) cause the frame to be deleted. */
1399 if (! FRAME_LIVE_P (f))
1400 return Qnil;
1401
1402 /* At this point, we are committed to deleting the frame.
1403 There is no more chance for errors to prevent it. */
1404
1405 minibuffer_selected = EQ (minibuf_window, selected_window);
1406
1407 /* Don't let the frame remain selected. */
1408 if (f == sf)
1409 {
1410 Lisp_Object tail, frame1;
1411
1412 /* Look for another visible frame on the same terminal. */
1413 frame1 = next_frame (frame, Qvisible);
1414
1415 /* If there is none, find *some* other frame. */
1416 if (NILP (frame1) || EQ (frame1, frame))
1417 {
1418 FOR_EACH_FRAME (tail, frame1)
1419 {
1420 if (! EQ (frame, frame1) && FRAME_LIVE_P (XFRAME (frame1)))
1421 break;
1422 }
1423 }
1424
1425 do_switch_frame (frame1, 0, 1);
1426 sf = SELECTED_FRAME ();
1427 }
1428
1429 /* Don't allow minibuf_window to remain on a deleted frame. */
1430 if (EQ (f->minibuffer_window, minibuf_window))
1431 {
1432 Fset_window_buffer (sf->minibuffer_window,
1433 XWINDOW (minibuf_window)->buffer, Qnil);
1434 minibuf_window = sf->minibuffer_window;
1435
1436 /* If the dying minibuffer window was selected,
1437 select the new one. */
1438 if (minibuffer_selected)
1439 Fselect_window (minibuf_window, Qnil);
1440 }
1441
1442 /* Don't let echo_area_window to remain on a deleted frame. */
1443 if (EQ (f->minibuffer_window, echo_area_window))
1444 echo_area_window = sf->minibuffer_window;
1445
1446 /* Clear any X selections for this frame. */
1447 #ifdef HAVE_X_WINDOWS
1448 if (FRAME_X_P (f))
1449 x_clear_frame_selections (f);
1450 #endif
1451 #ifdef MAC_OS
1452 if (FRAME_MAC_P (f))
1453 x_clear_frame_selections (f);
1454 #endif
1455
1456 /* Free glyphs.
1457 This function must be called before the window tree of the
1458 frame is deleted because windows contain dynamically allocated
1459 memory. */
1460 free_glyphs (f);
1461
1462 /* Give chance to each font driver to free a frame specific data. */
1463 font_update_drivers (f, Qnil);
1464
1465 /* Mark all the windows that used to be on FRAME as deleted, and then
1466 remove the reference to them. */
1467 delete_all_subwindows (XWINDOW (f->root_window));
1468 f->root_window = Qnil;
1469
1470 Vframe_list = Fdelq (frame, Vframe_list);
1471 FRAME_SET_VISIBLE (f, 0);
1472
1473 if (f->namebuf)
1474 xfree (f->namebuf);
1475 if (f->decode_mode_spec_buffer)
1476 xfree (f->decode_mode_spec_buffer);
1477 if (FRAME_INSERT_COST (f))
1478 xfree (FRAME_INSERT_COST (f));
1479 if (FRAME_DELETEN_COST (f))
1480 xfree (FRAME_DELETEN_COST (f));
1481 if (FRAME_INSERTN_COST (f))
1482 xfree (FRAME_INSERTN_COST (f));
1483 if (FRAME_DELETE_COST (f))
1484 xfree (FRAME_DELETE_COST (f));
1485 if (FRAME_MESSAGE_BUF (f))
1486 xfree (FRAME_MESSAGE_BUF (f));
1487
1488 /* Since some events are handled at the interrupt level, we may get
1489 an event for f at any time; if we zero out the frame's terminal
1490 now, then we may trip up the event-handling code. Instead, we'll
1491 promise that the terminal of the frame must be valid until we
1492 have called the window-system-dependent frame destruction
1493 routine. */
1494
1495 if (FRAME_TERMINAL (f)->delete_frame_hook)
1496 (*FRAME_TERMINAL (f)->delete_frame_hook) (f);
1497
1498 {
1499 struct terminal *terminal = FRAME_TERMINAL (f);
1500 f->output_data.nothing = 0;
1501 f->terminal = 0; /* Now the frame is dead. */
1502
1503 /* If needed, delete the terminal that this frame was on.
1504 (This must be done after the frame is killed.) */
1505 terminal->reference_count--;
1506 if (terminal->reference_count == 0)
1507 {
1508 Lisp_Object tmp;
1509 XSETTERMINAL (tmp, terminal);
1510
1511 kb = NULL;
1512 Fdelete_terminal (tmp, NILP (force) ? Qt : force);
1513 }
1514 #ifdef MULTI_KBOARD
1515 else
1516 kb = terminal->kboard;
1517 #endif
1518 }
1519
1520 /* If we've deleted the last_nonminibuf_frame, then try to find
1521 another one. */
1522 if (f == last_nonminibuf_frame)
1523 {
1524 Lisp_Object frames;
1525
1526 last_nonminibuf_frame = 0;
1527
1528 for (frames = Vframe_list;
1529 CONSP (frames);
1530 frames = XCDR (frames))
1531 {
1532 f = XFRAME (XCAR (frames));
1533 if (!FRAME_MINIBUF_ONLY_P (f))
1534 {
1535 last_nonminibuf_frame = f;
1536 break;
1537 }
1538 }
1539 }
1540
1541 /* If there's no other frame on the same kboard, get out of
1542 single-kboard state if we're in it for this kboard. */
1543 if (kb != NULL)
1544 {
1545 Lisp_Object frames;
1546 /* Some frame we found on the same kboard, or nil if there are none. */
1547 Lisp_Object frame_on_same_kboard;
1548
1549 frame_on_same_kboard = Qnil;
1550
1551 for (frames = Vframe_list;
1552 CONSP (frames);
1553 frames = XCDR (frames))
1554 {
1555 Lisp_Object this;
1556 struct frame *f1;
1557
1558 this = XCAR (frames);
1559 if (!FRAMEP (this))
1560 abort ();
1561 f1 = XFRAME (this);
1562
1563 if (kb == FRAME_KBOARD (f1))
1564 frame_on_same_kboard = this;
1565 }
1566
1567 if (NILP (frame_on_same_kboard))
1568 not_single_kboard_state (kb);
1569 }
1570
1571
1572 /* If we've deleted this keyboard's default_minibuffer_frame, try to
1573 find another one. Prefer minibuffer-only frames, but also notice
1574 frames with other windows. */
1575 if (kb != NULL && EQ (frame, kb->Vdefault_minibuffer_frame))
1576 {
1577 Lisp_Object frames;
1578
1579 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1580 Lisp_Object frame_with_minibuf;
1581 /* Some frame we found on the same kboard, or nil if there are none. */
1582 Lisp_Object frame_on_same_kboard;
1583
1584 frame_on_same_kboard = Qnil;
1585 frame_with_minibuf = Qnil;
1586
1587 for (frames = Vframe_list;
1588 CONSP (frames);
1589 frames = XCDR (frames))
1590 {
1591 Lisp_Object this;
1592 struct frame *f1;
1593
1594 this = XCAR (frames);
1595 if (!FRAMEP (this))
1596 abort ();
1597 f1 = XFRAME (this);
1598
1599 /* Consider only frames on the same kboard
1600 and only those with minibuffers. */
1601 if (kb == FRAME_KBOARD (f1)
1602 && FRAME_HAS_MINIBUF_P (f1))
1603 {
1604 frame_with_minibuf = this;
1605 if (FRAME_MINIBUF_ONLY_P (f1))
1606 break;
1607 }
1608
1609 if (kb == FRAME_KBOARD (f1))
1610 frame_on_same_kboard = this;
1611 }
1612
1613 if (!NILP (frame_on_same_kboard))
1614 {
1615 /* We know that there must be some frame with a minibuffer out
1616 there. If this were not true, all of the frames present
1617 would have to be minibufferless, which implies that at some
1618 point their minibuffer frames must have been deleted, but
1619 that is prohibited at the top; you can't delete surrogate
1620 minibuffer frames. */
1621 if (NILP (frame_with_minibuf))
1622 abort ();
1623
1624 kb->Vdefault_minibuffer_frame = frame_with_minibuf;
1625 }
1626 else
1627 /* No frames left on this kboard--say no minibuffer either. */
1628 kb->Vdefault_minibuffer_frame = Qnil;
1629 }
1630
1631 /* Cause frame titles to update--necessary if we now have just one frame. */
1632 update_mode_lines = 1;
1633
1634 return Qnil;
1635 }
1636 \f
1637 /* Return mouse position in character cell units. */
1638
1639 DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0,
1640 doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1641 The position is given in character cells, where (0, 0) is the
1642 upper-left corner of the frame, X is the horizontal offset, and Y is
1643 the vertical offset.
1644 If Emacs is running on a mouseless terminal or hasn't been programmed
1645 to read the mouse position, it returns the selected frame for FRAME
1646 and nil for X and Y.
1647 If `mouse-position-function' is non-nil, `mouse-position' calls it,
1648 passing the normal return value to that function as an argument,
1649 and returns whatever that function returns. */)
1650 ()
1651 {
1652 FRAME_PTR f;
1653 Lisp_Object lispy_dummy;
1654 enum scroll_bar_part party_dummy;
1655 Lisp_Object x, y, retval;
1656 int col, row;
1657 unsigned long long_dummy;
1658 struct gcpro gcpro1;
1659
1660 f = SELECTED_FRAME ();
1661 x = y = Qnil;
1662
1663 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1664 /* It's okay for the hook to refrain from storing anything. */
1665 if (FRAME_TERMINAL (f)->mouse_position_hook)
1666 (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, -1,
1667 &lispy_dummy, &party_dummy,
1668 &x, &y,
1669 &long_dummy);
1670 if (! NILP (x))
1671 {
1672 col = XINT (x);
1673 row = XINT (y);
1674 pixel_to_glyph_coords (f, col, row, &col, &row, NULL, 1);
1675 XSETINT (x, col);
1676 XSETINT (y, row);
1677 }
1678 #endif
1679 XSETFRAME (lispy_dummy, f);
1680 retval = Fcons (lispy_dummy, Fcons (x, y));
1681 GCPRO1 (retval);
1682 if (!NILP (Vmouse_position_function))
1683 retval = call1 (Vmouse_position_function, retval);
1684 RETURN_UNGCPRO (retval);
1685 }
1686
1687 DEFUN ("mouse-pixel-position", Fmouse_pixel_position,
1688 Smouse_pixel_position, 0, 0, 0,
1689 doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position.
1690 The position is given in pixel units, where (0, 0) is the
1691 upper-left corner of the frame, X is the horizontal offset, and Y is
1692 the vertical offset.
1693 If Emacs is running on a mouseless terminal or hasn't been programmed
1694 to read the mouse position, it returns the selected frame for FRAME
1695 and nil for X and Y. */)
1696 ()
1697 {
1698 FRAME_PTR f;
1699 Lisp_Object lispy_dummy;
1700 enum scroll_bar_part party_dummy;
1701 Lisp_Object x, y;
1702 unsigned long long_dummy;
1703
1704 f = SELECTED_FRAME ();
1705 x = y = Qnil;
1706
1707 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
1708 /* It's okay for the hook to refrain from storing anything. */
1709 if (FRAME_TERMINAL (f)->mouse_position_hook)
1710 (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, -1,
1711 &lispy_dummy, &party_dummy,
1712 &x, &y,
1713 &long_dummy);
1714 #endif
1715 XSETFRAME (lispy_dummy, f);
1716 return Fcons (lispy_dummy, Fcons (x, y));
1717 }
1718
1719 DEFUN ("set-mouse-position", Fset_mouse_position, Sset_mouse_position, 3, 3, 0,
1720 doc: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME.
1721 Coordinates are relative to the frame, not a window,
1722 so the coordinates of the top left character in the frame
1723 may be nonzero due to left-hand scroll bars or the menu bar.
1724
1725 The position is given in character cells, where (0, 0) is the
1726 upper-left corner of the frame, X is the horizontal offset, and Y is
1727 the vertical offset.
1728
1729 This function is a no-op for an X frame that is not visible.
1730 If you have just created a frame, you must wait for it to become visible
1731 before calling this function on it, like this.
1732 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1733 (frame, x, y)
1734 Lisp_Object frame, x, y;
1735 {
1736 CHECK_LIVE_FRAME (frame);
1737 CHECK_NUMBER (x);
1738 CHECK_NUMBER (y);
1739
1740 /* I think this should be done with a hook. */
1741 #ifdef HAVE_WINDOW_SYSTEM
1742 if (FRAME_WINDOW_P (XFRAME (frame)))
1743 /* Warping the mouse will cause enternotify and focus events. */
1744 x_set_mouse_position (XFRAME (frame), XINT (x), XINT (y));
1745 #else
1746 #if defined (MSDOS) && defined (HAVE_MOUSE)
1747 if (FRAME_MSDOS_P (XFRAME (frame)))
1748 {
1749 Fselect_frame (frame);
1750 mouse_moveto (XINT (x), XINT (y));
1751 }
1752 #else
1753 #ifdef HAVE_GPM
1754 {
1755 Fselect_frame (frame);
1756 term_mouse_moveto (XINT (x), XINT (y));
1757 }
1758 #endif
1759 #endif
1760 #endif
1761
1762 return Qnil;
1763 }
1764
1765 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position,
1766 Sset_mouse_pixel_position, 3, 3, 0,
1767 doc: /* Move the mouse pointer to pixel position (X,Y) in FRAME.
1768 The position is given in pixels, where (0, 0) is the upper-left corner
1769 of the frame, X is the horizontal offset, and Y is the vertical offset.
1770
1771 Note, this is a no-op for an X frame that is not visible.
1772 If you have just created a frame, you must wait for it to become visible
1773 before calling this function on it, like this.
1774 (while (not (frame-visible-p frame)) (sleep-for .5)) */)
1775 (frame, x, y)
1776 Lisp_Object frame, x, y;
1777 {
1778 CHECK_LIVE_FRAME (frame);
1779 CHECK_NUMBER (x);
1780 CHECK_NUMBER (y);
1781
1782 /* I think this should be done with a hook. */
1783 #ifdef HAVE_WINDOW_SYSTEM
1784 if (FRAME_WINDOW_P (XFRAME (frame)))
1785 /* Warping the mouse will cause enternotify and focus events. */
1786 x_set_mouse_pixel_position (XFRAME (frame), XINT (x), XINT (y));
1787 #else
1788 #if defined (MSDOS) && defined (HAVE_MOUSE)
1789 if (FRAME_MSDOS_P (XFRAME (frame)))
1790 {
1791 Fselect_frame (frame);
1792 mouse_moveto (XINT (x), XINT (y));
1793 }
1794 #else
1795 #ifdef HAVE_GPM
1796 {
1797 Fselect_frame (frame);
1798 term_mouse_moveto (XINT (x), XINT (y));
1799 }
1800 #endif
1801 #endif
1802 #endif
1803
1804 return Qnil;
1805 }
1806 \f
1807 static void make_frame_visible_1 P_ ((Lisp_Object));
1808
1809 DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
1810 0, 1, "",
1811 doc: /* Make the frame FRAME visible (assuming it is an X window).
1812 If omitted, FRAME defaults to the currently selected frame. */)
1813 (frame)
1814 Lisp_Object frame;
1815 {
1816 if (NILP (frame))
1817 frame = selected_frame;
1818
1819 CHECK_LIVE_FRAME (frame);
1820
1821 /* I think this should be done with a hook. */
1822 #ifdef HAVE_WINDOW_SYSTEM
1823 if (FRAME_WINDOW_P (XFRAME (frame)))
1824 {
1825 FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
1826 x_make_frame_visible (XFRAME (frame));
1827 }
1828 #endif
1829
1830 make_frame_visible_1 (XFRAME (frame)->root_window);
1831
1832 /* Make menu bar update for the Buffers and Frames menus. */
1833 windows_or_buffers_changed++;
1834
1835 return frame;
1836 }
1837
1838 /* Update the display_time slot of the buffers shown in WINDOW
1839 and all its descendents. */
1840
1841 static void
1842 make_frame_visible_1 (window)
1843 Lisp_Object window;
1844 {
1845 struct window *w;
1846
1847 for (;!NILP (window); window = w->next)
1848 {
1849 w = XWINDOW (window);
1850
1851 if (!NILP (w->buffer))
1852 XBUFFER (w->buffer)->display_time = Fcurrent_time ();
1853
1854 if (!NILP (w->vchild))
1855 make_frame_visible_1 (w->vchild);
1856 if (!NILP (w->hchild))
1857 make_frame_visible_1 (w->hchild);
1858 }
1859 }
1860
1861 DEFUN ("make-frame-invisible", Fmake_frame_invisible, Smake_frame_invisible,
1862 0, 2, "",
1863 doc: /* Make the frame FRAME invisible (assuming it is an X window).
1864 If omitted, FRAME defaults to the currently selected frame.
1865 Normally you may not make FRAME invisible if all other frames are invisible,
1866 but if the second optional argument FORCE is non-nil, you may do so. */)
1867 (frame, force)
1868 Lisp_Object frame, force;
1869 {
1870 if (NILP (frame))
1871 frame = selected_frame;
1872
1873 CHECK_LIVE_FRAME (frame);
1874
1875 if (NILP (force) && !other_visible_frames (XFRAME (frame)))
1876 error ("Attempt to make invisible the sole visible or iconified frame");
1877
1878 #if 0 /* This isn't logically necessary, and it can do GC. */
1879 /* Don't let the frame remain selected. */
1880 if (EQ (frame, selected_frame))
1881 do_switch_frame (next_frame (frame, Qt), 0, 0)
1882 #endif
1883
1884 /* Don't allow minibuf_window to remain on a deleted frame. */
1885 if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window))
1886 {
1887 struct frame *sf = XFRAME (selected_frame);
1888 Fset_window_buffer (sf->minibuffer_window,
1889 XWINDOW (minibuf_window)->buffer, Qnil);
1890 minibuf_window = sf->minibuffer_window;
1891 }
1892
1893 /* I think this should be done with a hook. */
1894 #ifdef HAVE_WINDOW_SYSTEM
1895 if (FRAME_WINDOW_P (XFRAME (frame)))
1896 x_make_frame_invisible (XFRAME (frame));
1897 #endif
1898
1899 /* Make menu bar update for the Buffers and Frames menus. */
1900 windows_or_buffers_changed++;
1901
1902 return Qnil;
1903 }
1904
1905 DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame,
1906 0, 1, "",
1907 doc: /* Make the frame FRAME into an icon.
1908 If omitted, FRAME defaults to the currently selected frame. */)
1909 (frame)
1910 Lisp_Object frame;
1911 {
1912 if (NILP (frame))
1913 frame = selected_frame;
1914
1915 CHECK_LIVE_FRAME (frame);
1916
1917 #if 0 /* This isn't logically necessary, and it can do GC. */
1918 /* Don't let the frame remain selected. */
1919 if (EQ (frame, selected_frame))
1920 Fhandle_switch_frame (next_frame (frame, Qt));
1921 #endif
1922
1923 /* Don't allow minibuf_window to remain on a deleted frame. */
1924 if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window))
1925 {
1926 struct frame *sf = XFRAME (selected_frame);
1927 Fset_window_buffer (sf->minibuffer_window,
1928 XWINDOW (minibuf_window)->buffer, Qnil);
1929 minibuf_window = sf->minibuffer_window;
1930 }
1931
1932 /* I think this should be done with a hook. */
1933 #ifdef HAVE_WINDOW_SYSTEM
1934 if (FRAME_WINDOW_P (XFRAME (frame)))
1935 x_iconify_frame (XFRAME (frame));
1936 #endif
1937
1938 /* Make menu bar update for the Buffers and Frames menus. */
1939 windows_or_buffers_changed++;
1940
1941 return Qnil;
1942 }
1943
1944 DEFUN ("frame-visible-p", Fframe_visible_p, Sframe_visible_p,
1945 1, 1, 0,
1946 doc: /* Return t if FRAME is now \"visible\" (actually in use for display).
1947 A frame that is not \"visible\" is not updated and, if it works through
1948 a window system, it may not show at all.
1949 Return the symbol `icon' if frame is visible only as an icon.
1950
1951 On a text-only terminal, all frames are considered visible, whether
1952 they are currently being displayed or not, and this function returns t
1953 for all frames. */)
1954 (frame)
1955 Lisp_Object frame;
1956 {
1957 CHECK_LIVE_FRAME (frame);
1958
1959 FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
1960
1961 if (FRAME_VISIBLE_P (XFRAME (frame)))
1962 return Qt;
1963 if (FRAME_ICONIFIED_P (XFRAME (frame)))
1964 return Qicon;
1965 return Qnil;
1966 }
1967
1968 DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list,
1969 0, 0, 0,
1970 doc: /* Return a list of all frames now \"visible\" (being updated). */)
1971 ()
1972 {
1973 Lisp_Object tail, frame;
1974 struct frame *f;
1975 Lisp_Object value;
1976
1977 value = Qnil;
1978 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
1979 {
1980 frame = XCAR (tail);
1981 if (!FRAMEP (frame))
1982 continue;
1983 f = XFRAME (frame);
1984 if (FRAME_VISIBLE_P (f))
1985 value = Fcons (frame, value);
1986 }
1987 return value;
1988 }
1989
1990
1991 DEFUN ("raise-frame", Fraise_frame, Sraise_frame, 0, 1, "",
1992 doc: /* Bring FRAME to the front, so it occludes any frames it overlaps.
1993 If FRAME is invisible or iconified, make it visible.
1994 If you don't specify a frame, the selected frame is used.
1995 If Emacs is displaying on an ordinary terminal or some other device which
1996 doesn't support multiple overlapping frames, this function does nothing. */)
1997 (frame)
1998 Lisp_Object frame;
1999 {
2000 struct frame *f;
2001 if (NILP (frame))
2002 frame = selected_frame;
2003
2004 CHECK_LIVE_FRAME (frame);
2005
2006 f = XFRAME (frame);
2007
2008 /* Do like the documentation says. */
2009 Fmake_frame_visible (frame);
2010
2011 if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
2012 (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 1);
2013
2014 return Qnil;
2015 }
2016
2017 /* Should we have a corresponding function called Flower_Power? */
2018 DEFUN ("lower-frame", Flower_frame, Slower_frame, 0, 1, "",
2019 doc: /* Send FRAME to the back, so it is occluded by any frames that overlap it.
2020 If you don't specify a frame, the selected frame is used.
2021 If Emacs is displaying on an ordinary terminal or some other device which
2022 doesn't support multiple overlapping frames, this function does nothing. */)
2023 (frame)
2024 Lisp_Object frame;
2025 {
2026 struct frame *f;
2027
2028 if (NILP (frame))
2029 frame = selected_frame;
2030
2031 CHECK_LIVE_FRAME (frame);
2032
2033 f = XFRAME (frame);
2034
2035 if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
2036 (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 0);
2037
2038 return Qnil;
2039 }
2040
2041 \f
2042 DEFUN ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus,
2043 1, 2, 0,
2044 doc: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
2045 In other words, switch-frame events caused by events in FRAME will
2046 request a switch to FOCUS-FRAME, and `last-event-frame' will be
2047 FOCUS-FRAME after reading an event typed at FRAME.
2048
2049 If FOCUS-FRAME is omitted or nil, any existing redirection is
2050 cancelled, and the frame again receives its own keystrokes.
2051
2052 Focus redirection is useful for temporarily redirecting keystrokes to
2053 a surrogate minibuffer frame when a frame doesn't have its own
2054 minibuffer window.
2055
2056 A frame's focus redirection can be changed by `select-frame'. If frame
2057 FOO is selected, and then a different frame BAR is selected, any
2058 frames redirecting their focus to FOO are shifted to redirect their
2059 focus to BAR. This allows focus redirection to work properly when the
2060 user switches from one frame to another using `select-window'.
2061
2062 This means that a frame whose focus is redirected to itself is treated
2063 differently from a frame whose focus is redirected to nil; the former
2064 is affected by `select-frame', while the latter is not.
2065
2066 The redirection lasts until `redirect-frame-focus' is called to change it. */)
2067 (frame, focus_frame)
2068 Lisp_Object frame, focus_frame;
2069 {
2070 struct frame *f;
2071
2072 /* Note that we don't check for a live frame here. It's reasonable
2073 to redirect the focus of a frame you're about to delete, if you
2074 know what other frame should receive those keystrokes. */
2075 CHECK_FRAME (frame);
2076
2077 if (! NILP (focus_frame))
2078 CHECK_LIVE_FRAME (focus_frame);
2079
2080 f = XFRAME (frame);
2081
2082 f->focus_frame = focus_frame;
2083
2084 if (FRAME_TERMINAL (f)->frame_rehighlight_hook)
2085 (*FRAME_TERMINAL (f)->frame_rehighlight_hook) (f);
2086
2087 return Qnil;
2088 }
2089
2090
2091 DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0,
2092 doc: /* Return the frame to which FRAME's keystrokes are currently being sent.
2093 This returns nil if FRAME's focus is not redirected.
2094 See `redirect-frame-focus'. */)
2095 (frame)
2096 Lisp_Object frame;
2097 {
2098 CHECK_LIVE_FRAME (frame);
2099
2100 return FRAME_FOCUS_FRAME (XFRAME (frame));
2101 }
2102
2103
2104 \f
2105 /* Return the value of frame parameter PROP in frame FRAME. */
2106
2107 Lisp_Object
2108 get_frame_param (frame, prop)
2109 register struct frame *frame;
2110 Lisp_Object prop;
2111 {
2112 register Lisp_Object tem;
2113
2114 tem = Fassq (prop, frame->param_alist);
2115 if (EQ (tem, Qnil))
2116 return tem;
2117 return Fcdr (tem);
2118 }
2119
2120 /* Return the buffer-predicate of the selected frame. */
2121
2122 Lisp_Object
2123 frame_buffer_predicate (frame)
2124 Lisp_Object frame;
2125 {
2126 return XFRAME (frame)->buffer_predicate;
2127 }
2128
2129 /* Return the buffer-list of the selected frame. */
2130
2131 Lisp_Object
2132 frame_buffer_list (frame)
2133 Lisp_Object frame;
2134 {
2135 return XFRAME (frame)->buffer_list;
2136 }
2137
2138 /* Set the buffer-list of the selected frame. */
2139
2140 void
2141 set_frame_buffer_list (frame, list)
2142 Lisp_Object frame, list;
2143 {
2144 XFRAME (frame)->buffer_list = list;
2145 }
2146
2147 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
2148
2149 void
2150 frames_discard_buffer (buffer)
2151 Lisp_Object buffer;
2152 {
2153 Lisp_Object frame, tail;
2154
2155 FOR_EACH_FRAME (tail, frame)
2156 {
2157 XFRAME (frame)->buffer_list
2158 = Fdelq (buffer, XFRAME (frame)->buffer_list);
2159 XFRAME (frame)->buried_buffer_list
2160 = Fdelq (buffer, XFRAME (frame)->buried_buffer_list);
2161 }
2162 }
2163
2164 /* Modify the alist in *ALISTPTR to associate PROP with VAL.
2165 If the alist already has an element for PROP, we change it. */
2166
2167 void
2168 store_in_alist (alistptr, prop, val)
2169 Lisp_Object *alistptr, val;
2170 Lisp_Object prop;
2171 {
2172 register Lisp_Object tem;
2173
2174 tem = Fassq (prop, *alistptr);
2175 if (EQ (tem, Qnil))
2176 *alistptr = Fcons (Fcons (prop, val), *alistptr);
2177 else
2178 Fsetcdr (tem, val);
2179 }
2180
2181 static int
2182 frame_name_fnn_p (str, len)
2183 char *str;
2184 EMACS_INT len;
2185 {
2186 if (len > 1 && str[0] == 'F')
2187 {
2188 char *end_ptr;
2189
2190 strtol (str + 1, &end_ptr, 10);
2191
2192 if (end_ptr == str + len)
2193 return 1;
2194 }
2195 return 0;
2196 }
2197
2198 /* Set the name of the terminal frame. Also used by MSDOS frames.
2199 Modeled after x_set_name which is used for WINDOW frames. */
2200
2201 static void
2202 set_term_frame_name (f, name)
2203 struct frame *f;
2204 Lisp_Object name;
2205 {
2206 f->explicit_name = ! NILP (name);
2207
2208 /* If NAME is nil, set the name to F<num>. */
2209 if (NILP (name))
2210 {
2211 char namebuf[20];
2212
2213 /* Check for no change needed in this very common case
2214 before we do any consing. */
2215 if (frame_name_fnn_p (SDATA (f->name),
2216 SBYTES (f->name)))
2217 return;
2218
2219 tty_frame_count++;
2220 sprintf (namebuf, "F%d", tty_frame_count);
2221 name = build_string (namebuf);
2222 }
2223 else
2224 {
2225 CHECK_STRING (name);
2226
2227 /* Don't change the name if it's already NAME. */
2228 if (! NILP (Fstring_equal (name, f->name)))
2229 return;
2230
2231 /* Don't allow the user to set the frame name to F<num>, so it
2232 doesn't clash with the names we generate for terminal frames. */
2233 if (frame_name_fnn_p (SDATA (name), SBYTES (name)))
2234 error ("Frame names of the form F<num> are usurped by Emacs");
2235 }
2236
2237 f->name = name;
2238 update_mode_lines = 1;
2239 }
2240
2241 void
2242 store_frame_param (f, prop, val)
2243 struct frame *f;
2244 Lisp_Object prop, val;
2245 {
2246 register Lisp_Object old_alist_elt;
2247
2248 /* The buffer-list parameters are stored in a special place and not
2249 in the alist. */
2250 if (EQ (prop, Qbuffer_list))
2251 {
2252 f->buffer_list = val;
2253 return;
2254 }
2255 if (EQ (prop, Qburied_buffer_list))
2256 {
2257 f->buried_buffer_list = val;
2258 return;
2259 }
2260
2261 /* If PROP is a symbol which is supposed to have frame-local values,
2262 and it is set up based on this frame, switch to the global
2263 binding. That way, we can create or alter the frame-local binding
2264 without messing up the symbol's status. */
2265 if (SYMBOLP (prop))
2266 {
2267 Lisp_Object valcontents;
2268 valcontents = SYMBOL_VALUE (prop);
2269 if ((BUFFER_LOCAL_VALUEP (valcontents))
2270 && XBUFFER_LOCAL_VALUE (valcontents)->check_frame
2271 && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame
2272 && XFRAME (XBUFFER_LOCAL_VALUE (valcontents)->frame) == f)
2273 swap_in_global_binding (prop);
2274 }
2275
2276 #ifndef WINDOWSNT
2277 /* The tty color needed to be set before the frame's parameter
2278 alist was updated with the new value. This is not true any more,
2279 but we still do this test early on. */
2280 if (FRAME_TERMCAP_P (f) && EQ (prop, Qtty_color_mode)
2281 && f == FRAME_TTY (f)->previous_frame)
2282 /* Force redisplay of this tty. */
2283 FRAME_TTY (f)->previous_frame = NULL;
2284 #endif
2285
2286 /* Update the frame parameter alist. */
2287 old_alist_elt = Fassq (prop, f->param_alist);
2288 if (EQ (old_alist_elt, Qnil))
2289 f->param_alist = Fcons (Fcons (prop, val), f->param_alist);
2290 else
2291 Fsetcdr (old_alist_elt, val);
2292
2293 /* Update some other special parameters in their special places
2294 in addition to the alist. */
2295
2296 if (EQ (prop, Qbuffer_predicate))
2297 f->buffer_predicate = val;
2298
2299 if (! FRAME_WINDOW_P (f))
2300 {
2301 if (EQ (prop, Qmenu_bar_lines))
2302 set_menu_bar_lines (f, val, make_number (FRAME_MENU_BAR_LINES (f)));
2303 else if (EQ (prop, Qname))
2304 set_term_frame_name (f, val);
2305 }
2306
2307 if (EQ (prop, Qminibuffer) && WINDOWP (val))
2308 {
2309 if (! MINI_WINDOW_P (XWINDOW (val)))
2310 error ("Surrogate minibuffer windows must be minibuffer windows");
2311
2312 if ((FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f))
2313 && !EQ (val, f->minibuffer_window))
2314 error ("Can't change the surrogate minibuffer of a frame with its own minibuffer");
2315
2316 /* Install the chosen minibuffer window, with proper buffer. */
2317 f->minibuffer_window = val;
2318 }
2319 }
2320
2321 DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0,
2322 doc: /* Return the parameters-alist of frame FRAME.
2323 It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2324 The meaningful PARMs depend on the kind of frame.
2325 If FRAME is omitted, return information on the currently selected frame. */)
2326 (frame)
2327 Lisp_Object frame;
2328 {
2329 Lisp_Object alist;
2330 FRAME_PTR f;
2331 int height, width;
2332 struct gcpro gcpro1;
2333
2334 if (NILP (frame))
2335 frame = selected_frame;
2336
2337 CHECK_FRAME (frame);
2338 f = XFRAME (frame);
2339
2340 if (!FRAME_LIVE_P (f))
2341 return Qnil;
2342
2343 alist = Fcopy_alist (f->param_alist);
2344 GCPRO1 (alist);
2345
2346 if (!FRAME_WINDOW_P (f))
2347 {
2348 int fg = FRAME_FOREGROUND_PIXEL (f);
2349 int bg = FRAME_BACKGROUND_PIXEL (f);
2350 Lisp_Object elt;
2351
2352 /* If the frame's parameter alist says the colors are
2353 unspecified and reversed, take the frame's background pixel
2354 for foreground and vice versa. */
2355 elt = Fassq (Qforeground_color, alist);
2356 if (CONSP (elt) && STRINGP (XCDR (elt)))
2357 {
2358 if (strncmp (SDATA (XCDR (elt)),
2359 unspecified_bg,
2360 SCHARS (XCDR (elt))) == 0)
2361 store_in_alist (&alist, Qforeground_color, tty_color_name (f, bg));
2362 else if (strncmp (SDATA (XCDR (elt)),
2363 unspecified_fg,
2364 SCHARS (XCDR (elt))) == 0)
2365 store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg));
2366 }
2367 else
2368 store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg));
2369 elt = Fassq (Qbackground_color, alist);
2370 if (CONSP (elt) && STRINGP (XCDR (elt)))
2371 {
2372 if (strncmp (SDATA (XCDR (elt)),
2373 unspecified_fg,
2374 SCHARS (XCDR (elt))) == 0)
2375 store_in_alist (&alist, Qbackground_color, tty_color_name (f, fg));
2376 else if (strncmp (SDATA (XCDR (elt)),
2377 unspecified_bg,
2378 SCHARS (XCDR (elt))) == 0)
2379 store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg));
2380 }
2381 else
2382 store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg));
2383 store_in_alist (&alist, intern ("font"),
2384 build_string (FRAME_MSDOS_P (f)
2385 ? "ms-dos"
2386 : FRAME_W32_P (f) ? "w32term"
2387 :"tty"));
2388 }
2389 store_in_alist (&alist, Qname, f->name);
2390 height = (f->new_text_lines ? f->new_text_lines : FRAME_LINES (f));
2391 store_in_alist (&alist, Qheight, make_number (height));
2392 width = (f->new_text_cols ? f->new_text_cols : FRAME_COLS (f));
2393 store_in_alist (&alist, Qwidth, make_number (width));
2394 store_in_alist (&alist, Qmodeline, (FRAME_WANTS_MODELINE_P (f) ? Qt : Qnil));
2395 store_in_alist (&alist, Qminibuffer,
2396 (! FRAME_HAS_MINIBUF_P (f) ? Qnil
2397 : FRAME_MINIBUF_ONLY_P (f) ? Qonly
2398 : FRAME_MINIBUF_WINDOW (f)));
2399 store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil));
2400 store_in_alist (&alist, Qbuffer_list, frame_buffer_list (frame));
2401 store_in_alist (&alist, Qburied_buffer_list, XFRAME (frame)->buried_buffer_list);
2402
2403 /* I think this should be done with a hook. */
2404 #ifdef HAVE_WINDOW_SYSTEM
2405 if (FRAME_WINDOW_P (f))
2406 x_report_frame_params (f, &alist);
2407 else
2408 #endif
2409 {
2410 /* This ought to be correct in f->param_alist for an X frame. */
2411 Lisp_Object lines;
2412 XSETFASTINT (lines, FRAME_MENU_BAR_LINES (f));
2413 store_in_alist (&alist, Qmenu_bar_lines, lines);
2414 }
2415
2416 UNGCPRO;
2417 return alist;
2418 }
2419
2420
2421 DEFUN ("frame-parameter", Fframe_parameter, Sframe_parameter, 2, 2, 0,
2422 doc: /* Return FRAME's value for parameter PARAMETER.
2423 If FRAME is nil, describe the currently selected frame. */)
2424 (frame, parameter)
2425 Lisp_Object frame, parameter;
2426 {
2427 struct frame *f;
2428 Lisp_Object value;
2429
2430 if (NILP (frame))
2431 frame = selected_frame;
2432 else
2433 CHECK_FRAME (frame);
2434 CHECK_SYMBOL (parameter);
2435
2436 f = XFRAME (frame);
2437 value = Qnil;
2438
2439 if (FRAME_LIVE_P (f))
2440 {
2441 /* Avoid consing in frequent cases. */
2442 if (EQ (parameter, Qname))
2443 value = f->name;
2444 #ifdef HAVE_X_WINDOWS
2445 else if (EQ (parameter, Qdisplay) && FRAME_X_P (f))
2446 value = XCAR (FRAME_X_DISPLAY_INFO (f)->name_list_element);
2447 #endif /* HAVE_X_WINDOWS */
2448 else if (EQ (parameter, Qbackground_color)
2449 || EQ (parameter, Qforeground_color))
2450 {
2451 value = Fassq (parameter, f->param_alist);
2452 if (CONSP (value))
2453 {
2454 value = XCDR (value);
2455 /* Fframe_parameters puts the actual fg/bg color names,
2456 even if f->param_alist says otherwise. This is
2457 important when param_alist's notion of colors is
2458 "unspecified". We need to do the same here. */
2459 if (STRINGP (value) && !FRAME_WINDOW_P (f))
2460 {
2461 const char *color_name;
2462 EMACS_INT csz;
2463
2464 if (EQ (parameter, Qbackground_color))
2465 {
2466 color_name = SDATA (value);
2467 csz = SCHARS (value);
2468 if (strncmp (color_name, unspecified_bg, csz) == 0)
2469 value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f));
2470 else if (strncmp (color_name, unspecified_fg, csz) == 0)
2471 value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f));
2472 }
2473 else if (EQ (parameter, Qforeground_color))
2474 {
2475 color_name = SDATA (value);
2476 csz = SCHARS (value);
2477 if (strncmp (color_name, unspecified_fg, csz) == 0)
2478 value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f));
2479 else if (strncmp (color_name, unspecified_bg, csz) == 0)
2480 value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f));
2481 }
2482 }
2483 }
2484 else
2485 value = Fcdr (Fassq (parameter, Fframe_parameters (frame)));
2486 }
2487 else if (EQ (parameter, Qdisplay_type)
2488 || EQ (parameter, Qbackground_mode))
2489 value = Fcdr (Fassq (parameter, f->param_alist));
2490 else
2491 value = Fcdr (Fassq (parameter, Fframe_parameters (frame)));
2492 }
2493
2494 return value;
2495 }
2496
2497
2498 DEFUN ("modify-frame-parameters", Fmodify_frame_parameters,
2499 Smodify_frame_parameters, 2, 2, 0,
2500 doc: /* Modify the parameters of frame FRAME according to ALIST.
2501 If FRAME is nil, it defaults to the selected frame.
2502 ALIST is an alist of parameters to change and their new values.
2503 Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
2504 The meaningful PARMs depend on the kind of frame.
2505 Undefined PARMs are ignored, but stored in the frame's parameter list
2506 so that `frame-parameters' will return them.
2507
2508 The value of frame parameter FOO can also be accessed
2509 as a frame-local binding for the variable FOO, if you have
2510 enabled such bindings for that variable with `make-variable-frame-local'. */)
2511 (frame, alist)
2512 Lisp_Object frame, alist;
2513 {
2514 FRAME_PTR f;
2515 register Lisp_Object tail, prop, val;
2516
2517 if (EQ (frame, Qnil))
2518 frame = selected_frame;
2519 CHECK_LIVE_FRAME (frame);
2520 f = XFRAME (frame);
2521
2522 /* I think this should be done with a hook. */
2523 #ifdef HAVE_WINDOW_SYSTEM
2524 if (FRAME_WINDOW_P (f))
2525 x_set_frame_parameters (f, alist);
2526 else
2527 #endif
2528 #ifdef MSDOS
2529 if (FRAME_MSDOS_P (f))
2530 IT_set_frame_parameters (f, alist);
2531 else
2532 #endif
2533
2534 {
2535 int length = XINT (Flength (alist));
2536 int i;
2537 Lisp_Object *parms
2538 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
2539 Lisp_Object *values
2540 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
2541
2542 /* Extract parm names and values into those vectors. */
2543
2544 i = 0;
2545 for (tail = alist; CONSP (tail); tail = XCDR (tail))
2546 {
2547 Lisp_Object elt;
2548
2549 elt = XCAR (tail);
2550 parms[i] = Fcar (elt);
2551 values[i] = Fcdr (elt);
2552 i++;
2553 }
2554
2555 /* Now process them in reverse of specified order. */
2556 for (i--; i >= 0; i--)
2557 {
2558 prop = parms[i];
2559 val = values[i];
2560 store_frame_param (f, prop, val);
2561
2562 /* Changing the background color might change the background
2563 mode, so that we have to load new defface specs.
2564 Call frame-set-background-mode to do that. */
2565 if (EQ (prop, Qbackground_color))
2566 call1 (Qframe_set_background_mode, frame);
2567 }
2568 }
2569 return Qnil;
2570 }
2571 \f
2572 DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
2573 0, 1, 0,
2574 doc: /* Height in pixels of a line in the font in frame FRAME.
2575 If FRAME is omitted, the selected frame is used.
2576 For a terminal frame, the value is always 1. */)
2577 (frame)
2578 Lisp_Object frame;
2579 {
2580 struct frame *f;
2581
2582 if (NILP (frame))
2583 frame = selected_frame;
2584 CHECK_FRAME (frame);
2585 f = XFRAME (frame);
2586
2587 #ifdef HAVE_WINDOW_SYSTEM
2588 if (FRAME_WINDOW_P (f))
2589 return make_number (x_char_height (f));
2590 else
2591 #endif
2592 return make_number (1);
2593 }
2594
2595
2596 DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
2597 0, 1, 0,
2598 doc: /* Width in pixels of characters in the font in frame FRAME.
2599 If FRAME is omitted, the selected frame is used.
2600 On a graphical screen, the width is the standard width of the default font.
2601 For a terminal screen, the value is always 1. */)
2602 (frame)
2603 Lisp_Object frame;
2604 {
2605 struct frame *f;
2606
2607 if (NILP (frame))
2608 frame = selected_frame;
2609 CHECK_FRAME (frame);
2610 f = XFRAME (frame);
2611
2612 #ifdef HAVE_WINDOW_SYSTEM
2613 if (FRAME_WINDOW_P (f))
2614 return make_number (x_char_width (f));
2615 else
2616 #endif
2617 return make_number (1);
2618 }
2619
2620 DEFUN ("frame-pixel-height", Fframe_pixel_height,
2621 Sframe_pixel_height, 0, 1, 0,
2622 doc: /* Return a FRAME's height in pixels.
2623 This counts only the height available for text lines,
2624 not menu bars on window-system Emacs frames.
2625 For a terminal frame, the result really gives the height in characters.
2626 If FRAME is omitted, the selected frame is used. */)
2627 (frame)
2628 Lisp_Object frame;
2629 {
2630 struct frame *f;
2631
2632 if (NILP (frame))
2633 frame = selected_frame;
2634 CHECK_FRAME (frame);
2635 f = XFRAME (frame);
2636
2637 #ifdef HAVE_WINDOW_SYSTEM
2638 if (FRAME_WINDOW_P (f))
2639 return make_number (x_pixel_height (f));
2640 else
2641 #endif
2642 return make_number (FRAME_LINES (f));
2643 }
2644
2645 DEFUN ("frame-pixel-width", Fframe_pixel_width,
2646 Sframe_pixel_width, 0, 1, 0,
2647 doc: /* Return FRAME's width in pixels.
2648 For a terminal frame, the result really gives the width in characters.
2649 If FRAME is omitted, the selected frame is used. */)
2650 (frame)
2651 Lisp_Object frame;
2652 {
2653 struct frame *f;
2654
2655 if (NILP (frame))
2656 frame = selected_frame;
2657 CHECK_FRAME (frame);
2658 f = XFRAME (frame);
2659
2660 #ifdef HAVE_WINDOW_SYSTEM
2661 if (FRAME_WINDOW_P (f))
2662 return make_number (x_pixel_width (f));
2663 else
2664 #endif
2665 return make_number (FRAME_COLS (f));
2666 }
2667 \f
2668 DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
2669 doc: /* Specify that the frame FRAME has LINES lines.
2670 Optional third arg non-nil means that redisplay should use LINES lines
2671 but that the idea of the actual height of the frame should not be changed. */)
2672 (frame, lines, pretend)
2673 Lisp_Object frame, lines, pretend;
2674 {
2675 register struct frame *f;
2676
2677 CHECK_NUMBER (lines);
2678 if (NILP (frame))
2679 frame = selected_frame;
2680 CHECK_LIVE_FRAME (frame);
2681 f = XFRAME (frame);
2682
2683 /* I think this should be done with a hook. */
2684 #ifdef HAVE_WINDOW_SYSTEM
2685 if (FRAME_WINDOW_P (f))
2686 {
2687 if (XINT (lines) != FRAME_LINES (f))
2688 x_set_window_size (f, 1, FRAME_COLS (f), XINT (lines));
2689 do_pending_window_change (0);
2690 }
2691 else
2692 #endif
2693 change_frame_size (f, XINT (lines), 0, !NILP (pretend), 0, 0);
2694 return Qnil;
2695 }
2696
2697 DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 3, 0,
2698 doc: /* Specify that the frame FRAME has COLS columns.
2699 Optional third arg non-nil means that redisplay should use COLS columns
2700 but that the idea of the actual width of the frame should not be changed. */)
2701 (frame, cols, pretend)
2702 Lisp_Object frame, cols, pretend;
2703 {
2704 register struct frame *f;
2705 CHECK_NUMBER (cols);
2706 if (NILP (frame))
2707 frame = selected_frame;
2708 CHECK_LIVE_FRAME (frame);
2709 f = XFRAME (frame);
2710
2711 /* I think this should be done with a hook. */
2712 #ifdef HAVE_WINDOW_SYSTEM
2713 if (FRAME_WINDOW_P (f))
2714 {
2715 if (XINT (cols) != FRAME_COLS (f))
2716 x_set_window_size (f, 1, XINT (cols), FRAME_LINES (f));
2717 do_pending_window_change (0);
2718 }
2719 else
2720 #endif
2721 change_frame_size (f, 0, XINT (cols), !NILP (pretend), 0, 0);
2722 return Qnil;
2723 }
2724
2725 DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0,
2726 doc: /* Sets size of FRAME to COLS by ROWS, measured in characters. */)
2727 (frame, cols, rows)
2728 Lisp_Object frame, cols, rows;
2729 {
2730 register struct frame *f;
2731
2732 CHECK_LIVE_FRAME (frame);
2733 CHECK_NUMBER (cols);
2734 CHECK_NUMBER (rows);
2735 f = XFRAME (frame);
2736
2737 /* I think this should be done with a hook. */
2738 #ifdef HAVE_WINDOW_SYSTEM
2739 if (FRAME_WINDOW_P (f))
2740 {
2741 if (XINT (rows) != FRAME_LINES (f)
2742 || XINT (cols) != FRAME_COLS (f)
2743 || f->new_text_lines || f->new_text_cols)
2744 x_set_window_size (f, 1, XINT (cols), XINT (rows));
2745 do_pending_window_change (0);
2746 }
2747 else
2748 #endif
2749 change_frame_size (f, XINT (rows), XINT (cols), 0, 0, 0);
2750
2751 return Qnil;
2752 }
2753
2754 DEFUN ("set-frame-position", Fset_frame_position,
2755 Sset_frame_position, 3, 3, 0,
2756 doc: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
2757 This is actually the position of the upper left corner of the frame.
2758 Negative values for XOFFSET or YOFFSET are interpreted relative to
2759 the rightmost or bottommost possible position (that stays within the screen). */)
2760 (frame, xoffset, yoffset)
2761 Lisp_Object frame, xoffset, yoffset;
2762 {
2763 register struct frame *f;
2764
2765 CHECK_LIVE_FRAME (frame);
2766 CHECK_NUMBER (xoffset);
2767 CHECK_NUMBER (yoffset);
2768 f = XFRAME (frame);
2769
2770 /* I think this should be done with a hook. */
2771 #ifdef HAVE_WINDOW_SYSTEM
2772 if (FRAME_WINDOW_P (f))
2773 x_set_offset (f, XINT (xoffset), XINT (yoffset), 1);
2774 #endif
2775
2776 return Qt;
2777 }
2778
2779 \f
2780 /***********************************************************************
2781 Frame Parameters
2782 ***********************************************************************/
2783
2784 /* Connect the frame-parameter names for X frames
2785 to the ways of passing the parameter values to the window system.
2786
2787 The name of a parameter, as a Lisp symbol,
2788 has an `x-frame-parameter' property which is an integer in Lisp
2789 that is an index in this table. */
2790
2791 struct frame_parm_table {
2792 char *name;
2793 Lisp_Object *variable;
2794 };
2795
2796 static struct frame_parm_table frame_parms[] =
2797 {
2798 {"auto-raise", &Qauto_raise},
2799 {"auto-lower", &Qauto_lower},
2800 {"background-color", 0},
2801 {"border-color", &Qborder_color},
2802 {"border-width", &Qborder_width},
2803 {"cursor-color", &Qcursor_color},
2804 {"cursor-type", &Qcursor_type},
2805 {"font", 0},
2806 {"foreground-color", 0},
2807 {"icon-name", &Qicon_name},
2808 {"icon-type", &Qicon_type},
2809 {"internal-border-width", &Qinternal_border_width},
2810 {"menu-bar-lines", &Qmenu_bar_lines},
2811 {"mouse-color", &Qmouse_color},
2812 {"name", &Qname},
2813 {"scroll-bar-width", &Qscroll_bar_width},
2814 {"title", &Qtitle},
2815 {"unsplittable", &Qunsplittable},
2816 {"vertical-scroll-bars", &Qvertical_scroll_bars},
2817 {"visibility", &Qvisibility},
2818 {"tool-bar-lines", &Qtool_bar_lines},
2819 {"scroll-bar-foreground", &Qscroll_bar_foreground},
2820 {"scroll-bar-background", &Qscroll_bar_background},
2821 {"screen-gamma", &Qscreen_gamma},
2822 {"line-spacing", &Qline_spacing},
2823 {"left-fringe", &Qleft_fringe},
2824 {"right-fringe", &Qright_fringe},
2825 {"wait-for-wm", &Qwait_for_wm},
2826 {"fullscreen", &Qfullscreen},
2827 {"font-backend", &Qfont_backend}
2828 };
2829
2830 #ifdef HAVE_WINDOW_SYSTEM
2831
2832 extern Lisp_Object Qbox;
2833 extern Lisp_Object Qtop;
2834
2835 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2836 wanted positions of the WM window (not Emacs window).
2837 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
2838 window (FRAME_X_WINDOW).
2839 */
2840
2841 void
2842 x_fullscreen_adjust (f, width, height, top_pos, left_pos)
2843 struct frame *f;
2844 int *width;
2845 int *height;
2846 int *top_pos;
2847 int *left_pos;
2848 {
2849 int newwidth = FRAME_COLS (f);
2850 int newheight = FRAME_LINES (f);
2851
2852 *top_pos = f->top_pos;
2853 *left_pos = f->left_pos;
2854
2855 if (f->want_fullscreen & FULLSCREEN_HEIGHT)
2856 {
2857 int ph;
2858
2859 ph = FRAME_X_DISPLAY_INFO (f)->height;
2860 newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph);
2861 ph = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, newheight) - f->y_pixels_diff;
2862 newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph);
2863 *top_pos = 0;
2864 }
2865
2866 if (f->want_fullscreen & FULLSCREEN_WIDTH)
2867 {
2868 int pw;
2869
2870 pw = FRAME_X_DISPLAY_INFO (f)->width;
2871 newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw);
2872 pw = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, newwidth) - f->x_pixels_diff;
2873 newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw);
2874 *left_pos = 0;
2875 }
2876
2877 *width = newwidth;
2878 *height = newheight;
2879 }
2880
2881
2882 /* Change the parameters of frame F as specified by ALIST.
2883 If a parameter is not specially recognized, do nothing special;
2884 otherwise call the `x_set_...' function for that parameter.
2885 Except for certain geometry properties, always call store_frame_param
2886 to store the new value in the parameter alist. */
2887
2888 void
2889 x_set_frame_parameters (f, alist)
2890 FRAME_PTR f;
2891 Lisp_Object alist;
2892 {
2893 Lisp_Object tail;
2894
2895 /* If both of these parameters are present, it's more efficient to
2896 set them both at once. So we wait until we've looked at the
2897 entire list before we set them. */
2898 int width, height;
2899
2900 /* Same here. */
2901 Lisp_Object left, top;
2902
2903 /* Same with these. */
2904 Lisp_Object icon_left, icon_top;
2905
2906 /* Record in these vectors all the parms specified. */
2907 Lisp_Object *parms;
2908 Lisp_Object *values;
2909 int i, p;
2910 int left_no_change = 0, top_no_change = 0;
2911 int icon_left_no_change = 0, icon_top_no_change = 0;
2912 int fullscreen_is_being_set = 0;
2913
2914 struct gcpro gcpro1, gcpro2;
2915
2916 i = 0;
2917 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
2918 i++;
2919
2920 parms = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
2921 values = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
2922
2923 /* Extract parm names and values into those vectors. */
2924
2925 i = 0;
2926 for (tail = alist; CONSP (tail); tail = XCDR (tail))
2927 {
2928 Lisp_Object elt;
2929
2930 elt = XCAR (tail);
2931 parms[i] = Fcar (elt);
2932 values[i] = Fcdr (elt);
2933 i++;
2934 }
2935 /* TAIL and ALIST are not used again below here. */
2936 alist = tail = Qnil;
2937
2938 GCPRO2 (*parms, *values);
2939 gcpro1.nvars = i;
2940 gcpro2.nvars = i;
2941
2942 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
2943 because their values appear in VALUES and strings are not valid. */
2944 top = left = Qunbound;
2945 icon_left = icon_top = Qunbound;
2946
2947 /* Provide default values for HEIGHT and WIDTH. */
2948 width = (f->new_text_cols ? f->new_text_cols : FRAME_COLS (f));
2949 height = (f->new_text_lines ? f->new_text_lines : FRAME_LINES (f));
2950
2951 /* Process foreground_color and background_color before anything else.
2952 They are independent of other properties, but other properties (e.g.,
2953 cursor_color) are dependent upon them. */
2954 /* Process default font as well, since fringe widths depends on it. */
2955 /* Also, process fullscreen, width and height depend upon that */
2956 for (p = 0; p < i; p++)
2957 {
2958 Lisp_Object prop, val;
2959
2960 prop = parms[p];
2961 val = values[p];
2962 if (EQ (prop, Qforeground_color)
2963 || EQ (prop, Qbackground_color)
2964 || EQ (prop, Qfont)
2965 || EQ (prop, Qfullscreen))
2966 {
2967 register Lisp_Object param_index, old_value;
2968 int count = SPECPDL_INDEX ();
2969
2970 old_value = get_frame_param (f, prop);
2971 fullscreen_is_being_set |= EQ (prop, Qfullscreen);
2972
2973 if (NILP (Fequal (val, old_value)))
2974 {
2975 /* For :font attributes, the frame_parm_handler
2976 x_set_font calls `face-set-after-frame-default'.
2977 Unless we bind inhibit-face-set-after-frame-default
2978 here, this would reset the :font attribute that we
2979 just applied to the default value for new faces. */
2980 specbind (Qinhibit_face_set_after_frame_default, Qt);
2981
2982 store_frame_param (f, prop, val);
2983
2984 param_index = Fget (prop, Qx_frame_parameter);
2985 if (NATNUMP (param_index)
2986 && (XFASTINT (param_index)
2987 < sizeof (frame_parms)/sizeof (frame_parms[0]))
2988 && FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])
2989 (*(FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])) (f, val, old_value);
2990 unbind_to (count, Qnil);
2991 }
2992 }
2993 }
2994
2995 /* Now process them in reverse of specified order. */
2996 for (i--; i >= 0; i--)
2997 {
2998 Lisp_Object prop, val;
2999
3000 prop = parms[i];
3001 val = values[i];
3002
3003 if (EQ (prop, Qwidth) && NATNUMP (val))
3004 width = XFASTINT (val);
3005 else if (EQ (prop, Qheight) && NATNUMP (val))
3006 height = XFASTINT (val);
3007 else if (EQ (prop, Qtop))
3008 top = val;
3009 else if (EQ (prop, Qleft))
3010 left = val;
3011 else if (EQ (prop, Qicon_top))
3012 icon_top = val;
3013 else if (EQ (prop, Qicon_left))
3014 icon_left = val;
3015 else if (EQ (prop, Qforeground_color)
3016 || EQ (prop, Qbackground_color)
3017 || EQ (prop, Qfont)
3018 || EQ (prop, Qfullscreen))
3019 /* Processed above. */
3020 continue;
3021 else
3022 {
3023 register Lisp_Object param_index, old_value;
3024
3025 old_value = get_frame_param (f, prop);
3026
3027 store_frame_param (f, prop, val);
3028
3029 param_index = Fget (prop, Qx_frame_parameter);
3030 if (NATNUMP (param_index)
3031 && (XFASTINT (param_index)
3032 < sizeof (frame_parms)/sizeof (frame_parms[0]))
3033 && FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])
3034 (*(FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])) (f, val, old_value);
3035 }
3036 }
3037
3038 /* Don't die if just one of these was set. */
3039 if (EQ (left, Qunbound))
3040 {
3041 left_no_change = 1;
3042 if (f->left_pos < 0)
3043 left = Fcons (Qplus, Fcons (make_number (f->left_pos), Qnil));
3044 else
3045 XSETINT (left, f->left_pos);
3046 }
3047 if (EQ (top, Qunbound))
3048 {
3049 top_no_change = 1;
3050 if (f->top_pos < 0)
3051 top = Fcons (Qplus, Fcons (make_number (f->top_pos), Qnil));
3052 else
3053 XSETINT (top, f->top_pos);
3054 }
3055
3056 /* If one of the icon positions was not set, preserve or default it. */
3057 if (EQ (icon_left, Qunbound) || ! INTEGERP (icon_left))
3058 {
3059 icon_left_no_change = 1;
3060 icon_left = Fcdr (Fassq (Qicon_left, f->param_alist));
3061 if (NILP (icon_left))
3062 XSETINT (icon_left, 0);
3063 }
3064 if (EQ (icon_top, Qunbound) || ! INTEGERP (icon_top))
3065 {
3066 icon_top_no_change = 1;
3067 icon_top = Fcdr (Fassq (Qicon_top, f->param_alist));
3068 if (NILP (icon_top))
3069 XSETINT (icon_top, 0);
3070 }
3071
3072 if (FRAME_VISIBLE_P (f) && fullscreen_is_being_set)
3073 {
3074 /* If the frame is visible already and the fullscreen parameter is
3075 being set, it is too late to set WM manager hints to specify
3076 size and position.
3077 Here we first get the width, height and position that applies to
3078 fullscreen. We then move the frame to the appropriate
3079 position. Resize of the frame is taken care of in the code after
3080 this if-statement. */
3081 int new_left, new_top;
3082
3083 x_fullscreen_adjust (f, &width, &height, &new_top, &new_left);
3084 if (new_top != f->top_pos || new_left != f->left_pos)
3085 x_set_offset (f, new_left, new_top, 1);
3086 }
3087
3088 /* Don't set these parameters unless they've been explicitly
3089 specified. The window might be mapped or resized while we're in
3090 this function, and we don't want to override that unless the lisp
3091 code has asked for it.
3092
3093 Don't set these parameters unless they actually differ from the
3094 window's current parameters; the window may not actually exist
3095 yet. */
3096 {
3097 Lisp_Object frame;
3098
3099 check_frame_size (f, &height, &width);
3100
3101 XSETFRAME (frame, f);
3102
3103 if (width != FRAME_COLS (f)
3104 || height != FRAME_LINES (f)
3105 || f->new_text_lines || f->new_text_cols)
3106 Fset_frame_size (frame, make_number (width), make_number (height));
3107
3108 if ((!NILP (left) || !NILP (top))
3109 && ! (left_no_change && top_no_change)
3110 && ! (NUMBERP (left) && XINT (left) == f->left_pos
3111 && NUMBERP (top) && XINT (top) == f->top_pos))
3112 {
3113 int leftpos = 0;
3114 int toppos = 0;
3115
3116 /* Record the signs. */
3117 f->size_hint_flags &= ~ (XNegative | YNegative);
3118 if (EQ (left, Qminus))
3119 f->size_hint_flags |= XNegative;
3120 else if (INTEGERP (left))
3121 {
3122 leftpos = XINT (left);
3123 if (leftpos < 0)
3124 f->size_hint_flags |= XNegative;
3125 }
3126 else if (CONSP (left) && EQ (XCAR (left), Qminus)
3127 && CONSP (XCDR (left))
3128 && INTEGERP (XCAR (XCDR (left))))
3129 {
3130 leftpos = - XINT (XCAR (XCDR (left)));
3131 f->size_hint_flags |= XNegative;
3132 }
3133 else if (CONSP (left) && EQ (XCAR (left), Qplus)
3134 && CONSP (XCDR (left))
3135 && INTEGERP (XCAR (XCDR (left))))
3136 {
3137 leftpos = XINT (XCAR (XCDR (left)));
3138 }
3139
3140 if (EQ (top, Qminus))
3141 f->size_hint_flags |= YNegative;
3142 else if (INTEGERP (top))
3143 {
3144 toppos = XINT (top);
3145 if (toppos < 0)
3146 f->size_hint_flags |= YNegative;
3147 }
3148 else if (CONSP (top) && EQ (XCAR (top), Qminus)
3149 && CONSP (XCDR (top))
3150 && INTEGERP (XCAR (XCDR (top))))
3151 {
3152 toppos = - XINT (XCAR (XCDR (top)));
3153 f->size_hint_flags |= YNegative;
3154 }
3155 else if (CONSP (top) && EQ (XCAR (top), Qplus)
3156 && CONSP (XCDR (top))
3157 && INTEGERP (XCAR (XCDR (top))))
3158 {
3159 toppos = XINT (XCAR (XCDR (top)));
3160 }
3161
3162
3163 /* Store the numeric value of the position. */
3164 f->top_pos = toppos;
3165 f->left_pos = leftpos;
3166
3167 f->win_gravity = NorthWestGravity;
3168
3169 /* Actually set that position, and convert to absolute. */
3170 x_set_offset (f, leftpos, toppos, -1);
3171 }
3172
3173 if ((!NILP (icon_left) || !NILP (icon_top))
3174 && ! (icon_left_no_change && icon_top_no_change))
3175 x_wm_set_icon_position (f, XINT (icon_left), XINT (icon_top));
3176 }
3177
3178 UNGCPRO;
3179 }
3180
3181
3182 /* Insert a description of internally-recorded parameters of frame X
3183 into the parameter alist *ALISTPTR that is to be given to the user.
3184 Only parameters that are specific to the X window system
3185 and whose values are not correctly recorded in the frame's
3186 param_alist need to be considered here. */
3187
3188 void
3189 x_report_frame_params (f, alistptr)
3190 struct frame *f;
3191 Lisp_Object *alistptr;
3192 {
3193 char buf[16];
3194 Lisp_Object tem;
3195
3196 /* Represent negative positions (off the top or left screen edge)
3197 in a way that Fmodify_frame_parameters will understand correctly. */
3198 XSETINT (tem, f->left_pos);
3199 if (f->left_pos >= 0)
3200 store_in_alist (alistptr, Qleft, tem);
3201 else
3202 store_in_alist (alistptr, Qleft, Fcons (Qplus, Fcons (tem, Qnil)));
3203
3204 XSETINT (tem, f->top_pos);
3205 if (f->top_pos >= 0)
3206 store_in_alist (alistptr, Qtop, tem);
3207 else
3208 store_in_alist (alistptr, Qtop, Fcons (Qplus, Fcons (tem, Qnil)));
3209
3210 store_in_alist (alistptr, Qborder_width,
3211 make_number (f->border_width));
3212 store_in_alist (alistptr, Qinternal_border_width,
3213 make_number (FRAME_INTERNAL_BORDER_WIDTH (f)));
3214 store_in_alist (alistptr, Qleft_fringe,
3215 make_number (FRAME_LEFT_FRINGE_WIDTH (f)));
3216 store_in_alist (alistptr, Qright_fringe,
3217 make_number (FRAME_RIGHT_FRINGE_WIDTH (f)));
3218 store_in_alist (alistptr, Qscroll_bar_width,
3219 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f)
3220 ? make_number (0)
3221 : FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0
3222 ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
3223 /* nil means "use default width"
3224 for non-toolkit scroll bar.
3225 ruler-mode.el depends on this. */
3226 : Qnil));
3227 sprintf (buf, "%ld", (long) FRAME_X_WINDOW (f));
3228 store_in_alist (alistptr, Qwindow_id,
3229 build_string (buf));
3230 #ifdef HAVE_X_WINDOWS
3231 #ifdef USE_X_TOOLKIT
3232 /* Tooltip frame may not have this widget. */
3233 if (FRAME_X_OUTPUT (f)->widget)
3234 #endif
3235 sprintf (buf, "%ld", (long) FRAME_OUTER_WINDOW (f));
3236 store_in_alist (alistptr, Qouter_window_id,
3237 build_string (buf));
3238 #endif
3239 store_in_alist (alistptr, Qicon_name, f->icon_name);
3240 FRAME_SAMPLE_VISIBILITY (f);
3241 store_in_alist (alistptr, Qvisibility,
3242 (FRAME_VISIBLE_P (f) ? Qt
3243 : FRAME_ICONIFIED_P (f) ? Qicon : Qnil));
3244 store_in_alist (alistptr, Qdisplay,
3245 XCAR (FRAME_X_DISPLAY_INFO (f)->name_list_element));
3246
3247 if (FRAME_X_OUTPUT (f)->parent_desc == FRAME_X_DISPLAY_INFO (f)->root_window)
3248 tem = Qnil;
3249 else
3250 XSETFASTINT (tem, FRAME_X_OUTPUT (f)->parent_desc);
3251 store_in_alist (alistptr, Qexplicit_name, (f->explicit_name ? Qt : Qnil));
3252 store_in_alist (alistptr, Qparent_id, tem);
3253 }
3254
3255
3256 /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is
3257 the previous value of that parameter, NEW_VALUE is the new value. */
3258
3259 void
3260 x_set_fullscreen (f, new_value, old_value)
3261 struct frame *f;
3262 Lisp_Object new_value, old_value;
3263 {
3264 if (NILP (new_value))
3265 f->want_fullscreen = FULLSCREEN_NONE;
3266 else if (EQ (new_value, Qfullboth))
3267 f->want_fullscreen = FULLSCREEN_BOTH;
3268 else if (EQ (new_value, Qfullwidth))
3269 f->want_fullscreen = FULLSCREEN_WIDTH;
3270 else if (EQ (new_value, Qfullheight))
3271 f->want_fullscreen = FULLSCREEN_HEIGHT;
3272
3273 if (FRAME_TERMINAL (f)->fullscreen_hook != NULL)
3274 FRAME_TERMINAL (f)->fullscreen_hook (f);
3275 }
3276
3277
3278 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
3279 the previous value of that parameter, NEW_VALUE is the new value. */
3280
3281 void
3282 x_set_line_spacing (f, new_value, old_value)
3283 struct frame *f;
3284 Lisp_Object new_value, old_value;
3285 {
3286 if (NILP (new_value))
3287 f->extra_line_spacing = 0;
3288 else if (NATNUMP (new_value))
3289 f->extra_line_spacing = XFASTINT (new_value);
3290 else
3291 signal_error ("Invalid line-spacing", new_value);
3292 if (FRAME_VISIBLE_P (f))
3293 redraw_frame (f);
3294 }
3295
3296
3297 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
3298 the previous value of that parameter, NEW_VALUE is the new value. */
3299
3300 void
3301 x_set_screen_gamma (f, new_value, old_value)
3302 struct frame *f;
3303 Lisp_Object new_value, old_value;
3304 {
3305 Lisp_Object bgcolor;
3306
3307 if (NILP (new_value))
3308 f->gamma = 0;
3309 else if (NUMBERP (new_value) && XFLOATINT (new_value) > 0)
3310 /* The value 0.4545 is the normal viewing gamma. */
3311 f->gamma = 1.0 / (0.4545 * XFLOATINT (new_value));
3312 else
3313 signal_error ("Invalid screen-gamma", new_value);
3314
3315 /* Apply the new gamma value to the frame background. */
3316 bgcolor = Fassq (Qbackground_color, f->param_alist);
3317 if (CONSP (bgcolor) && (bgcolor = XCDR (bgcolor), STRINGP (bgcolor)))
3318 {
3319 Lisp_Object index = Fget (Qbackground_color, Qx_frame_parameter);
3320 if (NATNUMP (index)
3321 && (XFASTINT (index)
3322 < sizeof (frame_parms)/sizeof (frame_parms[0]))
3323 && FRAME_RIF (f)->frame_parm_handlers[XFASTINT (index)])
3324 (*FRAME_RIF (f)->frame_parm_handlers[XFASTINT (index)])
3325 (f, bgcolor, Qnil);
3326 }
3327
3328 Fclear_face_cache (Qnil);
3329 }
3330
3331
3332 void
3333 x_set_font (f, arg, oldval)
3334 struct frame *f;
3335 Lisp_Object arg, oldval;
3336 {
3337 Lisp_Object frame;
3338 int fontset = -1;
3339 Lisp_Object font_object;
3340
3341 /* Set the frame parameter back to the old value because we mail
3342 fail to use ARG as the new parameter value. */
3343 store_frame_param (f, Qfont, oldval);
3344
3345 /* ARG is a fontset name, a font name, or a font object.
3346 In the last case, this function never fail. */
3347 if (STRINGP (arg))
3348 {
3349 fontset = fs_query_fontset (arg, 0);
3350 if (fontset < 0)
3351 {
3352 font_object = font_open_by_name (f, SDATA (arg));
3353 if (NILP (font_object))
3354 error ("Font `%s' is not defined", SDATA (arg));
3355 arg = AREF (font_object, FONT_NAME_INDEX);
3356 }
3357 else if (fontset > 0)
3358 {
3359 Lisp_Object ascii_font = fontset_ascii (fontset);
3360
3361 font_object = font_open_by_name (f, SDATA (ascii_font));
3362 if (NILP (font_object))
3363 error ("Font `%s' is not defined", SDATA (arg));
3364 arg = fontset_name (fontset);
3365 }
3366 else
3367 error ("The default fontset can't be used for a frame font");
3368 }
3369 else if (FONT_OBJECT_P (arg))
3370 {
3371 font_object = arg;
3372 /* This is store the XLFD font name in the frame parameter for
3373 backward compatiblity. We should store the font-object
3374 itself in the future. */
3375 arg = AREF (font_object, FONT_NAME_INDEX);
3376 }
3377 else
3378 signal_error ("Invalid font", arg);
3379
3380 if (! NILP (Fequal (font_object, oldval)))
3381 return;
3382 x_new_font (f, font_object, fontset);
3383 store_frame_param (f, Qfont, arg);
3384 /* Recalculate toolbar height. */
3385 f->n_tool_bar_rows = 0;
3386 /* Ensure we redraw it. */
3387 clear_current_matrices (f);
3388
3389 recompute_basic_faces (f);
3390
3391 do_pending_window_change (0);
3392
3393 /* Don't call `face-set-after-frame-default' when faces haven't been
3394 initialized yet. This is the case when called from
3395 Fx_create_frame. In that case, the X widget or window doesn't
3396 exist either, and we can end up in x_report_frame_params with a
3397 null widget which gives a segfault. */
3398 if (FRAME_FACE_CACHE (f))
3399 {
3400 XSETFRAME (frame, f);
3401 call1 (Qface_set_after_frame_default, frame);
3402 }
3403 }
3404
3405
3406 void
3407 x_set_font_backend (f, new_value, old_value)
3408 struct frame *f;
3409 Lisp_Object new_value, old_value;
3410 {
3411 if (! NILP (new_value)
3412 && !CONSP (new_value))
3413 {
3414 char *p0, *p1;
3415
3416 CHECK_STRING (new_value);
3417 p0 = p1 = SDATA (new_value);
3418 new_value = Qnil;
3419 while (*p0)
3420 {
3421 while (*p1 && *p1 != ',') p1++;
3422 if (p0 < p1)
3423 new_value = Fcons (Fintern (make_string (p0, p1 - p0), Qnil),
3424 new_value);
3425 if (*p1)
3426 p1++;
3427 p0 = p1;
3428 }
3429 new_value = Fnreverse (new_value);
3430 }
3431
3432 if (! NILP (old_value) && ! NILP (Fequal (old_value, new_value)))
3433 return;
3434
3435 if (FRAME_FONT (f))
3436 free_all_realized_faces (Qnil);
3437
3438 new_value = font_update_drivers (f, NILP (new_value) ? Qt : new_value);
3439 if (NILP (new_value))
3440 {
3441 if (NILP (old_value))
3442 error ("No font backend available");
3443 font_update_drivers (f, old_value);
3444 error ("None of specified font backends are available");
3445 }
3446 store_frame_param (f, Qfont_backend, new_value);
3447
3448 if (FRAME_FONT (f))
3449 {
3450 Lisp_Object frame;
3451
3452 XSETFRAME (frame, f);
3453 x_set_font (f, Fframe_parameter (frame, Qfont), Qnil);
3454 ++face_change_count;
3455 ++windows_or_buffers_changed;
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 Qexplicit_name = intern ("explicit-name");
4279 staticpro (&Qexplicit_name);
4280 Qheight = intern ("height");
4281 staticpro (&Qheight);
4282 Qicon = intern ("icon");
4283 staticpro (&Qicon);
4284 Qminibuffer = intern ("minibuffer");
4285 staticpro (&Qminibuffer);
4286 Qmodeline = intern ("modeline");
4287 staticpro (&Qmodeline);
4288 Qonly = intern ("only");
4289 staticpro (&Qonly);
4290 Qwidth = intern ("width");
4291 staticpro (&Qwidth);
4292 Qgeometry = intern ("geometry");
4293 staticpro (&Qgeometry);
4294 Qicon_left = intern ("icon-left");
4295 staticpro (&Qicon_left);
4296 Qicon_top = intern ("icon-top");
4297 staticpro (&Qicon_top);
4298 Qleft = intern ("left");
4299 staticpro (&Qleft);
4300 Qright = intern ("right");
4301 staticpro (&Qright);
4302 Quser_position = intern ("user-position");
4303 staticpro (&Quser_position);
4304 Quser_size = intern ("user-size");
4305 staticpro (&Quser_size);
4306 Qwindow_id = intern ("window-id");
4307 staticpro (&Qwindow_id);
4308 #ifdef HAVE_X_WINDOWS
4309 Qouter_window_id = intern ("outer-window-id");
4310 staticpro (&Qouter_window_id);
4311 #endif
4312 Qparent_id = intern ("parent-id");
4313 staticpro (&Qparent_id);
4314 Qx = intern ("x");
4315 staticpro (&Qx);
4316 Qw32 = intern ("w32");
4317 staticpro (&Qw32);
4318 Qpc = intern ("pc");
4319 staticpro (&Qpc);
4320 Qmac = intern ("mac");
4321 staticpro (&Qmac);
4322 Qvisible = intern ("visible");
4323 staticpro (&Qvisible);
4324 Qbuffer_predicate = intern ("buffer-predicate");
4325 staticpro (&Qbuffer_predicate);
4326 Qbuffer_list = intern ("buffer-list");
4327 staticpro (&Qbuffer_list);
4328 Qburied_buffer_list = intern ("buried-buffer-list");
4329 staticpro (&Qburied_buffer_list);
4330 Qdisplay_type = intern ("display-type");
4331 staticpro (&Qdisplay_type);
4332 Qbackground_mode = intern ("background-mode");
4333 staticpro (&Qbackground_mode);
4334 Qnoelisp = intern ("noelisp");
4335 staticpro (&Qnoelisp);
4336 Qtty_color_mode = intern ("tty-color-mode");
4337 staticpro (&Qtty_color_mode);
4338 Qtty = intern ("tty");
4339 staticpro (&Qtty);
4340 Qtty_type = intern ("tty-type");
4341 staticpro (&Qtty_type);
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 just before the frame is
4465 actually deleted, or some time later (or even both when an earlier function
4466 in `delete-frame-functions' (indirectly) calls `delete-frame'
4467 recursively). */);
4468 Vdelete_frame_functions = Qnil;
4469 Qdelete_frame_functions = intern ("delete-frame-functions");
4470 staticpro (&Qdelete_frame_functions);
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 DEFVAR_BOOL ("focus-follows-mouse", &focus_follows_mouse,
4488 doc: /* Non-nil if window system changes focus when you move the mouse.
4489 You should set this variable to tell Emacs how your window manager
4490 handles focus, since there is no way in general for Emacs to find out
4491 automatically. */);
4492 #ifdef HAVE_WINDOW_SYSTEM
4493 #if defined(HAVE_NTGUI) || defined(MAC_OS)
4494 focus_follows_mouse = 0;
4495 #else
4496 focus_follows_mouse = 1;
4497 #endif
4498 #else
4499 focus_follows_mouse = 0;
4500 #endif
4501
4502 staticpro (&Vframe_list);
4503
4504 defsubr (&Sactive_minibuffer_window);
4505 defsubr (&Sframep);
4506 defsubr (&Sframe_live_p);
4507 defsubr (&Swindow_system);
4508 defsubr (&Smake_terminal_frame);
4509 defsubr (&Shandle_switch_frame);
4510 defsubr (&Sselect_frame);
4511 defsubr (&Sselected_frame);
4512 defsubr (&Swindow_frame);
4513 defsubr (&Sframe_root_window);
4514 defsubr (&Sframe_first_window);
4515 defsubr (&Sframe_selected_window);
4516 defsubr (&Sset_frame_selected_window);
4517 defsubr (&Sframe_list);
4518 defsubr (&Snext_frame);
4519 defsubr (&Sprevious_frame);
4520 defsubr (&Sdelete_frame);
4521 defsubr (&Smouse_position);
4522 defsubr (&Smouse_pixel_position);
4523 defsubr (&Sset_mouse_position);
4524 defsubr (&Sset_mouse_pixel_position);
4525 #if 0
4526 defsubr (&Sframe_configuration);
4527 defsubr (&Srestore_frame_configuration);
4528 #endif
4529 defsubr (&Smake_frame_visible);
4530 defsubr (&Smake_frame_invisible);
4531 defsubr (&Siconify_frame);
4532 defsubr (&Sframe_visible_p);
4533 defsubr (&Svisible_frame_list);
4534 defsubr (&Sraise_frame);
4535 defsubr (&Slower_frame);
4536 defsubr (&Sredirect_frame_focus);
4537 defsubr (&Sframe_focus);
4538 defsubr (&Sframe_parameters);
4539 defsubr (&Sframe_parameter);
4540 defsubr (&Smodify_frame_parameters);
4541 defsubr (&Sframe_char_height);
4542 defsubr (&Sframe_char_width);
4543 defsubr (&Sframe_pixel_height);
4544 defsubr (&Sframe_pixel_width);
4545 defsubr (&Sset_frame_height);
4546 defsubr (&Sset_frame_width);
4547 defsubr (&Sset_frame_size);
4548 defsubr (&Sset_frame_position);
4549
4550 #ifdef HAVE_WINDOW_SYSTEM
4551 defsubr (&Sx_get_resource);
4552 defsubr (&Sx_parse_geometry);
4553 #endif
4554
4555 }
4556
4557 /* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
4558 (do not change this comment) */