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