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