Commit | Line | Data |
---|---|---|
ff11dfa1 | 1 | /* Generic frame functions. |
e9bffc61 | 2 | |
ba318903 | 3 | Copyright (C) 1993-1995, 1997, 1999-2014 Free Software Foundation, Inc. |
dc6f92b8 JB |
4 | |
5 | This file is part of GNU Emacs. | |
6 | ||
9ec0b715 | 7 | GNU Emacs is free software: you can redistribute it and/or modify |
dc6f92b8 | 8 | it under the terms of the GNU General Public License as published by |
9ec0b715 GM |
9 | the Free Software Foundation, either version 3 of the License, or |
10 | (at your option) any later version. | |
dc6f92b8 JB |
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 | |
9ec0b715 | 18 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
dc6f92b8 | 19 | |
18160b98 | 20 | #include <config.h> |
565620a5 RS |
21 | |
22 | #include <stdio.h> | |
9055082e PE |
23 | #include <errno.h> |
24 | #include <limits.h> | |
620f13b0 PE |
25 | |
26 | #include <c-ctype.h> | |
27 | ||
cc38027b | 28 | #include "lisp.h" |
83be827a | 29 | #include "character.h" |
17a2cbbd DC |
30 | |
31 | #ifdef HAVE_WINDOW_SYSTEM | |
32 | #include TERM_HEADER | |
33 | #endif /* HAVE_WINDOW_SYSTEM */ | |
34 | ||
2538fae4 AI |
35 | #include "buffer.h" |
36 | /* These help us bind and responding to switch-frame events. */ | |
37 | #include "commands.h" | |
38 | #include "keyboard.h" | |
cc38027b | 39 | #include "frame.h" |
972f4259 | 40 | #include "blockinput.h" |
28d440ab | 41 | #include "termchar.h" |
bc1ed486 | 42 | #include "termhooks.h" |
dfcf069d | 43 | #include "dispextern.h" |
f769f1b2 | 44 | #include "window.h" |
e0c8ad78 | 45 | #include "font.h" |
2cc7b62f | 46 | #ifdef HAVE_WINDOW_SYSTEM |
e0c8ad78 KH |
47 | #include "fontset.h" |
48 | #endif | |
87485d6f MW |
49 | #ifdef MSDOS |
50 | #include "msdos.h" | |
4aec4b29 | 51 | #include "dosfns.h" |
87485d6f | 52 | #endif |
e5d77022 | 53 | |
dc4db71c CY |
54 | #ifdef HAVE_NS |
55 | Lisp_Object Qns_parse_geometry; | |
56 | #endif | |
57 | ||
972f4259 KS |
58 | Lisp_Object Qframep, Qframe_live_p; |
59 | Lisp_Object Qicon, Qmodeline; | |
9fb0c957 | 60 | Lisp_Object Qonly, Qnone; |
4b298d5a | 61 | Lisp_Object Qx, Qw32, Qpc, Qns; |
f7af3f7b | 62 | Lisp_Object Qvisible; |
8b60f7bc | 63 | Lisp_Object Qdisplay_type; |
955cbe7b | 64 | static Lisp_Object Qbackground_mode; |
c53956fe | 65 | Lisp_Object Qnoelisp; |
972f4259 | 66 | |
955cbe7b | 67 | static Lisp_Object Qx_frame_parameter; |
972f4259 | 68 | Lisp_Object Qx_resource_name; |
6ed8eeff | 69 | Lisp_Object Qterminal; |
972f4259 KS |
70 | |
71 | /* Frame parameters (set or reported). */ | |
72 | ||
73 | Lisp_Object Qauto_raise, Qauto_lower; | |
74 | Lisp_Object Qborder_color, Qborder_width; | |
75 | Lisp_Object Qcursor_color, Qcursor_type; | |
972f4259 KS |
76 | Lisp_Object Qheight, Qwidth; |
77 | Lisp_Object Qleft, Qright; | |
78 | Lisp_Object Qicon_left, Qicon_top, Qicon_type, Qicon_name; | |
54ee7410 | 79 | Lisp_Object Qtooltip; |
972f4259 | 80 | Lisp_Object Qinternal_border_width; |
880e6158 | 81 | Lisp_Object Qright_divider_width, Qbottom_divider_width; |
972f4259 KS |
82 | Lisp_Object Qmouse_color; |
83 | Lisp_Object Qminibuffer; | |
84 | Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars; | |
85 | Lisp_Object Qvisibility; | |
86 | Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background; | |
87 | Lisp_Object Qscreen_gamma; | |
88 | Lisp_Object Qline_spacing; | |
955cbe7b | 89 | static Lisp_Object Quser_position, Quser_size; |
972f4259 | 90 | Lisp_Object Qwait_for_wm; |
955cbe7b | 91 | static Lisp_Object Qwindow_id; |
972f4259 | 92 | #ifdef HAVE_X_WINDOWS |
955cbe7b | 93 | static Lisp_Object Qouter_window_id; |
972f4259 KS |
94 | #endif |
95 | Lisp_Object Qparent_id; | |
96 | Lisp_Object Qtitle, Qname; | |
955cbe7b | 97 | static Lisp_Object Qexplicit_name; |
972f4259 | 98 | Lisp_Object Qunsplittable; |
bfeabdc3 | 99 | Lisp_Object Qmenu_bar_lines, Qtool_bar_lines, Qtool_bar_position; |
972f4259 | 100 | Lisp_Object Qleft_fringe, Qright_fringe; |
955cbe7b PE |
101 | Lisp_Object Qbuffer_predicate; |
102 | static Lisp_Object Qbuffer_list, Qburied_buffer_list; | |
94674d18 | 103 | Lisp_Object Qtty_color_mode; |
28d440ab | 104 | Lisp_Object Qtty, Qtty_type; |
dc6f92b8 | 105 | |
3f1c6666 | 106 | Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth, Qmaximized; |
cad9ef74 | 107 | Lisp_Object Qsticky; |
1a356571 | 108 | Lisp_Object Qfont_backend; |
0a708637 | 109 | Lisp_Object Qalpha; |
972f4259 KS |
110 | |
111 | Lisp_Object Qface_set_after_frame_default; | |
112 | ||
8e015705 BJ |
113 | static Lisp_Object Qfocus_in_hook; |
114 | static Lisp_Object Qfocus_out_hook; | |
29208e82 | 115 | static Lisp_Object Qdelete_frame_functions; |
da1da002 | 116 | |
3d5ee10a | 117 | static Lisp_Object Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource; |
6799bb26 | 118 | |
5492865b DA |
119 | /* The currently selected frame. */ |
120 | ||
121 | Lisp_Object selected_frame; | |
122 | ||
123 | /* A frame which is not just a mini-buffer, or NULL if there are no such | |
124 | frames. This is usually the most recent such frame that was selected. */ | |
125 | ||
126 | static struct frame *last_nonminibuf_frame; | |
127 | ||
caecb91c | 128 | /* False means there are no visible garbaged frames. */ |
5492865b DA |
129 | bool frame_garbaged; |
130 | ||
81626931 PE |
131 | #ifdef HAVE_WINDOW_SYSTEM |
132 | static void x_report_frame_params (struct frame *, Lisp_Object *); | |
133 | #endif | |
134 | ||
f00af5b1 | 135 | /* These setters are used only in this file, so they can be private. */ |
b0ab8123 | 136 | static void |
f00af5b1 PE |
137 | fset_buffer_predicate (struct frame *f, Lisp_Object val) |
138 | { | |
139 | f->buffer_predicate = val; | |
140 | } | |
b0ab8123 | 141 | static void |
f00af5b1 PE |
142 | fset_minibuffer_window (struct frame *f, Lisp_Object val) |
143 | { | |
144 | f->minibuffer_window = val; | |
145 | } | |
146 | ||
d9f07150 DA |
147 | struct frame * |
148 | decode_live_frame (register Lisp_Object frame) | |
149 | { | |
150 | if (NILP (frame)) | |
151 | frame = selected_frame; | |
152 | CHECK_LIVE_FRAME (frame); | |
153 | return XFRAME (frame); | |
154 | } | |
155 | ||
156 | struct frame * | |
157 | decode_any_frame (register Lisp_Object frame) | |
158 | { | |
159 | if (NILP (frame)) | |
160 | frame = selected_frame; | |
161 | CHECK_FRAME (frame); | |
162 | return XFRAME (frame); | |
163 | } | |
164 | ||
7452b7bd DA |
165 | bool |
166 | window_system_available (struct frame *f) | |
167 | { | |
168 | if (f) | |
169 | return FRAME_WINDOW_P (f) || FRAME_MSDOS_P (f); | |
170 | else | |
171 | #ifdef HAVE_WINDOW_SYSTEM | |
172 | return x_display_list != NULL; | |
173 | #else | |
174 | return 0; | |
175 | #endif | |
176 | } | |
177 | ||
178 | struct frame * | |
179 | decode_window_system_frame (Lisp_Object frame) | |
180 | { | |
181 | struct frame *f = decode_live_frame (frame); | |
3d5ee10a | 182 | |
7452b7bd DA |
183 | if (!window_system_available (f)) |
184 | error ("Window system frame should be used"); | |
185 | return f; | |
186 | } | |
187 | ||
188 | void | |
189 | check_window_system (struct frame *f) | |
190 | { | |
191 | if (!window_system_available (f)) | |
192 | error (f ? "Window system frame should be used" | |
193 | : "Window system is not in use or not initialized"); | |
194 | } | |
195 | ||
a249de79 | 196 | static void |
971de7fb | 197 | set_menu_bar_lines_1 (Lisp_Object window, int n) |
a249de79 RS |
198 | { |
199 | struct window *w = XWINDOW (window); | |
880e6158 | 200 | struct frame *f = XFRAME (WINDOW_FRAME (w)); |
a249de79 | 201 | |
5f24fa51 | 202 | w->top_line += n; |
880e6158 | 203 | w->pixel_top += n * FRAME_LINE_HEIGHT (f); |
5f24fa51 | 204 | w->total_lines -= n; |
880e6158 | 205 | w->pixel_height -= n * FRAME_LINE_HEIGHT (f); |
177c0ea7 | 206 | |
a249de79 | 207 | /* Handle just the top child in a vertical split. */ |
e74aeda8 DA |
208 | if (WINDOW_VERTICAL_COMBINATION_P (w)) |
209 | set_menu_bar_lines_1 (w->contents, n); | |
210 | else if (WINDOW_HORIZONTAL_COMBINATION_P (w)) | |
211 | /* Adjust all children in a horizontal split. */ | |
212 | for (window = w->contents; !NILP (window); window = w->next) | |
213 | { | |
214 | w = XWINDOW (window); | |
215 | set_menu_bar_lines_1 (window, n); | |
216 | } | |
a249de79 RS |
217 | } |
218 | ||
e48f782c | 219 | void |
971de7fb | 220 | set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) |
a249de79 RS |
221 | { |
222 | int nlines; | |
223 | int olines = FRAME_MENU_BAR_LINES (f); | |
224 | ||
225 | /* Right now, menu bars don't work properly in minibuf-only frames; | |
226 | most of the commands try to apply themselves to the minibuffer | |
e3678b64 | 227 | frame itself, and get an error because you can't switch buffers |
a249de79 RS |
228 | in or split the minibuffer window. */ |
229 | if (FRAME_MINIBUF_ONLY_P (f)) | |
230 | return; | |
231 | ||
b8898fda | 232 | if (TYPE_RANGED_INTEGERP (int, value)) |
a249de79 RS |
233 | nlines = XINT (value); |
234 | else | |
235 | nlines = 0; | |
236 | ||
57aeea1e RS |
237 | if (nlines != olines) |
238 | { | |
94ae2ad4 | 239 | windows_or_buffers_changed = 14; |
57aeea1e RS |
240 | FRAME_WINDOW_SIZES_CHANGED (f) = 1; |
241 | FRAME_MENU_BAR_LINES (f) = nlines; | |
880e6158 | 242 | FRAME_MENU_BAR_HEIGHT (f) = nlines * FRAME_LINE_HEIGHT (f); |
e69b0960 | 243 | set_menu_bar_lines_1 (f->root_window, nlines - olines); |
bd0443bb | 244 | adjust_frame_glyphs (f); |
57aeea1e | 245 | } |
a249de79 RS |
246 | } |
247 | \f | |
a249de79 | 248 | Lisp_Object Vframe_list; |
a249de79 | 249 | |
dc6f92b8 | 250 | \f |
ff11dfa1 | 251 | DEFUN ("framep", Fframep, Sframep, 1, 1, 0, |
14ff1ee0 | 252 | doc: /* Return non-nil if OBJECT is a frame. |
89baa1df EZ |
253 | Value is: |
254 | t for a termcap frame (a character-only terminal), | |
255 | 'x' for an Emacs frame that is really an X window, | |
256 | 'w32' for an Emacs frame that is a window on MS-Windows display, | |
257 | 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display, | |
258 | 'pc' for a direct-write MS-DOS frame. | |
14ff1ee0 | 259 | See also `frame-live-p'. */) |
5842a27b | 260 | (Lisp_Object object) |
dc6f92b8 | 261 | { |
e35d291d | 262 | if (!FRAMEP (object)) |
dc6f92b8 | 263 | return Qnil; |
ff11dfa1 | 264 | switch (XFRAME (object)->output_method) |
dc6f92b8 | 265 | { |
3224dac1 | 266 | case output_initial: /* The initial frame is like a termcap frame. */ |
dc6f92b8 JB |
267 | case output_termcap: |
268 | return Qt; | |
269 | case output_x_window: | |
fd0c2bd1 | 270 | return Qx; |
fbd6baed GV |
271 | case output_w32: |
272 | return Qw32; | |
bb221971 RS |
273 | case output_msdos_raw: |
274 | return Qpc; | |
edfda783 AR |
275 | case output_ns: |
276 | return Qns; | |
dc6f92b8 | 277 | default: |
1088b922 | 278 | emacs_abort (); |
dc6f92b8 JB |
279 | } |
280 | } | |
281 | ||
dbc4e1c1 | 282 | DEFUN ("frame-live-p", Fframe_live_p, Sframe_live_p, 1, 1, 0, |
14ff1ee0 PJ |
283 | doc: /* Return non-nil if OBJECT is a frame which has not been deleted. |
284 | Value is nil if OBJECT is not a live frame. If object is a live | |
6ed8eeff | 285 | frame, the return value indicates what sort of terminal device it is |
f6fa0866 | 286 | displayed on. See the documentation of `framep' for possible |
4e10df59 | 287 | return values. */) |
5842a27b | 288 | (Lisp_Object object) |
f9898cc6 | 289 | { |
ff11dfa1 JB |
290 | return ((FRAMEP (object) |
291 | && FRAME_LIVE_P (XFRAME (object))) | |
292 | ? Fframep (object) | |
f9898cc6 JB |
293 | : Qnil); |
294 | } | |
295 | ||
a7ca3326 | 296 | DEFUN ("window-system", Fwindow_system, Swindow_system, 0, 1, 0, |
428a555e | 297 | doc: /* The name of the window system that FRAME is displaying through. |
89baa1df EZ |
298 | The value is a symbol: |
299 | nil for a termcap frame (a character-only terminal), | |
300 | 'x' for an Emacs frame that is really an X window, | |
301 | 'w32' for an Emacs frame that is a window on MS-Windows display, | |
302 | 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display, | |
303 | 'pc' for a direct-write MS-DOS frame. | |
304 | ||
305 | FRAME defaults to the currently selected frame. | |
306 | ||
307 | Use of this function as a predicate is deprecated. Instead, | |
308 | use `display-graphic-p' or any of the other `display-*-p' | |
309 | predicates which report frame's specific UI-related capabilities. */) | |
5842a27b | 310 | (Lisp_Object frame) |
428a555e KL |
311 | { |
312 | Lisp_Object type; | |
313 | if (NILP (frame)) | |
314 | frame = selected_frame; | |
315 | ||
316 | type = Fframep (frame); | |
317 | ||
318 | if (NILP (type)) | |
319 | wrong_type_argument (Qframep, frame); | |
320 | ||
321 | if (EQ (type, Qt)) | |
322 | return Qnil; | |
323 | else | |
324 | return type; | |
a3547743 | 325 | } |
428a555e | 326 | |
ff11dfa1 | 327 | struct frame * |
959067a1 | 328 | make_frame (bool mini_p) |
dc6f92b8 | 329 | { |
ff11dfa1 JB |
330 | Lisp_Object frame; |
331 | register struct frame *f; | |
880e6158 | 332 | register struct window *rw, *mw; |
dc6f92b8 JB |
333 | register Lisp_Object root_window; |
334 | register Lisp_Object mini_window; | |
e9c96c62 GM |
335 | |
336 | f = allocate_frame (); | |
36af7d69 | 337 | XSETFRAME (frame, f); |
ff11dfa1 | 338 | |
62efea5e DA |
339 | /* Initialize Lisp data. Note that allocate_frame initializes all |
340 | Lisp data to nil, so do it only for slots which should not be nil. */ | |
f00af5b1 | 341 | fset_tool_bar_position (f, Qtop); |
62efea5e DA |
342 | |
343 | /* Initialize non-Lisp data. Note that allocate_frame zeroes out all | |
344 | non-Lisp data, so do it only for slots which should not be zero. | |
345 | To avoid subtle bugs and for the sake of readability, it's better to | |
346 | initialize enum members explicitly even if their values are zero. */ | |
655ab9a3 SM |
347 | f->wants_modeline = true; |
348 | f->redisplay = true; | |
349 | f->garbaged = true; | |
3a43d2dd | 350 | f->vertical_scroll_bar_type = vertical_scroll_bar_none; |
655ab9a3 SM |
351 | f->column_width = 1; /* !FRAME_WINDOW_P value. */ |
352 | f->line_height = 1; /* !FRAME_WINDOW_P value. */ | |
93421a1f | 353 | #ifdef HAVE_WINDOW_SYSTEM |
5af5757b | 354 | f->want_fullscreen = FULLSCREEN_NONE; |
93421a1f | 355 | #endif |
dc6f92b8 | 356 | |
cc38027b | 357 | root_window = make_window (); |
880e6158 | 358 | rw = XWINDOW (root_window); |
dc6f92b8 JB |
359 | if (mini_p) |
360 | { | |
cc38027b | 361 | mini_window = make_window (); |
880e6158 MR |
362 | mw = XWINDOW (mini_window); |
363 | wset_next (rw, mini_window); | |
364 | wset_prev (mw, root_window); | |
365 | mw->mini = 1; | |
366 | wset_frame (mw, frame); | |
f00af5b1 | 367 | fset_minibuffer_window (f, mini_window); |
dc6f92b8 JB |
368 | } |
369 | else | |
370 | { | |
371 | mini_window = Qnil; | |
880e6158 | 372 | wset_next (rw, Qnil); |
f00af5b1 | 373 | fset_minibuffer_window (f, Qnil); |
dc6f92b8 JB |
374 | } |
375 | ||
880e6158 | 376 | wset_frame (rw, frame); |
dc6f92b8 JB |
377 | |
378 | /* 10 is arbitrary, | |
379 | just so that there is "something there." | |
ff11dfa1 | 380 | Correct size will be set up later with change_frame_size. */ |
dc6f92b8 | 381 | |
5af5757b KS |
382 | SET_FRAME_COLS (f, 10); |
383 | FRAME_LINES (f) = 10; | |
880e6158 MR |
384 | SET_FRAME_WIDTH (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f)); |
385 | SET_FRAME_HEIGHT (f, FRAME_LINES (f) * FRAME_LINE_HEIGHT (f)); | |
dc6f92b8 | 386 | |
880e6158 MR |
387 | rw->total_cols = 10; |
388 | rw->pixel_width = rw->total_cols * FRAME_COLUMN_WIDTH (f); | |
389 | rw->total_lines = mini_p ? 9 : 10; | |
390 | rw->pixel_height = rw->total_lines * FRAME_LINE_HEIGHT (f); | |
dc6f92b8 JB |
391 | |
392 | if (mini_p) | |
393 | { | |
880e6158 MR |
394 | mw->top_line = rw->total_lines; |
395 | mw->pixel_top = rw->pixel_height; | |
396 | mw->total_cols = rw->total_cols; | |
397 | mw->pixel_width = rw->pixel_width; | |
398 | mw->total_lines = 1; | |
399 | mw->pixel_height = FRAME_LINE_HEIGHT (f); | |
dc6f92b8 JB |
400 | } |
401 | ||
ff11dfa1 | 402 | /* Choose a buffer for the frame's root window. */ |
5bce042c | 403 | { |
ed08365b | 404 | Lisp_Object buf = Fcurrent_buffer (); |
5bce042c | 405 | |
ed08365b DA |
406 | /* If current buffer is hidden, try to find another one. */ |
407 | if (BUFFER_HIDDEN_P (XBUFFER (buf))) | |
e10ac9f1 | 408 | buf = other_buffer_safely (buf); |
fa54c6ae | 409 | |
18082e2d GM |
410 | /* Use set_window_buffer, not Fset_window_buffer, and don't let |
411 | hooks be run by it. The reason is that the whole frame/window | |
cd1181db | 412 | arrangement is not yet fully initialized at this point. Windows |
18082e2d GM |
413 | don't have the right size, glyph matrices aren't initialized |
414 | etc. Running Lisp functions at this point surely ends in a | |
415 | SEGV. */ | |
5af5757b | 416 | set_window_buffer (root_window, buf, 0, 0); |
6c6f1994 | 417 | fset_buffer_list (f, list1 (buf)); |
5bce042c JB |
418 | } |
419 | ||
dc6f92b8 | 420 | if (mini_p) |
822995f8 DA |
421 | set_window_buffer (mini_window, |
422 | (NILP (Vminibuffer_list) | |
423 | ? get_minibuffer (0) | |
424 | : Fcar (Vminibuffer_list)), | |
425 | 0, 0); | |
dc6f92b8 | 426 | |
f00af5b1 PE |
427 | fset_root_window (f, root_window); |
428 | fset_selected_window (f, root_window); | |
d5e7c279 JB |
429 | /* Make sure this window seems more recently used than |
430 | a newly-created, never-selected window. */ | |
e69b0960 | 431 | XWINDOW (f->selected_window)->use_time = ++window_select_count; |
dc6f92b8 | 432 | |
ff11dfa1 | 433 | return f; |
dc6f92b8 JB |
434 | } |
435 | \f | |
bba88bb1 | 436 | #ifdef HAVE_WINDOW_SYSTEM |
ff11dfa1 | 437 | /* Make a frame using a separate minibuffer window on another frame. |
dc6f92b8 JB |
438 | MINI_WINDOW is the minibuffer window to use. nil means use the |
439 | default (the global minibuffer). */ | |
440 | ||
ff11dfa1 | 441 | struct frame * |
971de7fb | 442 | make_frame_without_minibuffer (register Lisp_Object mini_window, KBOARD *kb, Lisp_Object display) |
dc6f92b8 | 443 | { |
ff11dfa1 | 444 | register struct frame *f; |
363b873b | 445 | struct gcpro gcpro1; |
dc6f92b8 | 446 | |
b0660239 | 447 | if (!NILP (mini_window)) |
b7826503 | 448 | CHECK_LIVE_WINDOW (mini_window); |
dc6f92b8 | 449 | |
b0660239 | 450 | if (!NILP (mini_window) |
d3d50620 | 451 | && FRAME_KBOARD (XFRAME (XWINDOW (mini_window)->frame)) != kb) |
6ed8eeff | 452 | error ("Frame and minibuffer must be on the same terminal"); |
662ac59a | 453 | |
ff11dfa1 JB |
454 | /* Make a frame containing just a root window. */ |
455 | f = make_frame (0); | |
dc6f92b8 | 456 | |
b0660239 KH |
457 | if (NILP (mini_window)) |
458 | { | |
459 | /* Use default-minibuffer-frame if possible. */ | |
1344aad4 TT |
460 | if (!FRAMEP (KVAR (kb, Vdefault_minibuffer_frame)) |
461 | || ! FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame)))) | |
b0660239 | 462 | { |
363b873b RS |
463 | Lisp_Object frame_dummy; |
464 | ||
465 | XSETFRAME (frame_dummy, f); | |
466 | GCPRO1 (frame_dummy); | |
b0660239 | 467 | /* If there's no minibuffer frame to use, create one. */ |
15dbb4d6 PE |
468 | kset_default_minibuffer_frame |
469 | (kb, call1 (intern ("make-initial-minibuffer-frame"), display)); | |
363b873b | 470 | UNGCPRO; |
b0660239 | 471 | } |
177c0ea7 | 472 | |
e69b0960 DA |
473 | mini_window |
474 | = XFRAME (KVAR (kb, Vdefault_minibuffer_frame))->minibuffer_window; | |
b0660239 | 475 | } |
a2812a26 | 476 | |
f00af5b1 | 477 | fset_minibuffer_window (f, mini_window); |
a2812a26 RS |
478 | |
479 | /* Make the chosen minibuffer window display the proper minibuffer, | |
480 | unless it is already showing a minibuffer. */ | |
e74aeda8 | 481 | if (NILP (Fmemq (XWINDOW (mini_window)->contents, Vminibuffer_list))) |
08908aca MR |
482 | /* Use set_window_buffer instead of Fset_window_buffer (see |
483 | discussion of bug#11984, bug#12025, bug#12026). */ | |
484 | set_window_buffer (mini_window, | |
485 | (NILP (Vminibuffer_list) | |
486 | ? get_minibuffer (0) | |
487 | : Fcar (Vminibuffer_list)), 0, 0); | |
ff11dfa1 | 488 | return f; |
dc6f92b8 JB |
489 | } |
490 | ||
ff11dfa1 | 491 | /* Make a frame containing only a minibuffer window. */ |
dc6f92b8 | 492 | |
ff11dfa1 | 493 | struct frame * |
971de7fb | 494 | make_minibuffer_frame (void) |
dc6f92b8 | 495 | { |
ff11dfa1 | 496 | /* First make a frame containing just a root window, no minibuffer. */ |
dc6f92b8 | 497 | |
ff11dfa1 | 498 | register struct frame *f = make_frame (0); |
dc6f92b8 | 499 | register Lisp_Object mini_window; |
ff11dfa1 | 500 | register Lisp_Object frame; |
dc6f92b8 | 501 | |
2d80a27a | 502 | XSETFRAME (frame, f); |
dc6f92b8 | 503 | |
804518aa | 504 | f->auto_raise = 0; |
ff11dfa1 JB |
505 | f->auto_lower = 0; |
506 | f->no_split = 1; | |
507 | f->wants_modeline = 0; | |
dc6f92b8 JB |
508 | |
509 | /* Now label the root window as also being the minibuffer. | |
510 | Avoid infinite looping on the window chain by marking next pointer | |
511 | as nil. */ | |
512 | ||
f00af5b1 PE |
513 | mini_window = f->root_window; |
514 | fset_minibuffer_window (f, mini_window); | |
c98ff5dd | 515 | XWINDOW (mini_window)->mini = 1; |
e8c17b81 PE |
516 | wset_next (XWINDOW (mini_window), Qnil); |
517 | wset_prev (XWINDOW (mini_window), Qnil); | |
518 | wset_frame (XWINDOW (mini_window), frame); | |
dc6f92b8 JB |
519 | |
520 | /* Put the proper buffer in that window. */ | |
521 | ||
08908aca MR |
522 | /* Use set_window_buffer instead of Fset_window_buffer (see |
523 | discussion of bug#11984, bug#12025, bug#12026). */ | |
524 | set_window_buffer (mini_window, | |
525 | (NILP (Vminibuffer_list) | |
526 | ? get_minibuffer (0) | |
527 | : Fcar (Vminibuffer_list)), 0, 0); | |
ff11dfa1 | 528 | return f; |
dc6f92b8 | 529 | } |
bba88bb1 | 530 | #endif /* HAVE_WINDOW_SYSTEM */ |
dc6f92b8 | 531 | \f |
28d440ab | 532 | /* Construct a frame that refers to a terminal. */ |
dc6f92b8 | 533 | |
8a401434 | 534 | static printmax_t tty_frame_count; |
bb1513c9 | 535 | |
ff11dfa1 | 536 | struct frame * |
3224dac1 | 537 | make_initial_frame (void) |
dc6f92b8 | 538 | { |
3224dac1 | 539 | struct frame *f; |
6ed8eeff | 540 | struct terminal *terminal; |
d063751a | 541 | Lisp_Object frame; |
bb1513c9 | 542 | |
1bc973c2 | 543 | eassert (initial_kboard); |
b4f0ee5d | 544 | |
bb1513c9 RS |
545 | /* The first call must initialize Vframe_list. */ |
546 | if (! (NILP (Vframe_list) || CONSP (Vframe_list))) | |
547 | Vframe_list = Qnil; | |
ff11dfa1 | 548 | |
6ed8eeff | 549 | terminal = init_initial_terminal (); |
3224dac1 KL |
550 | |
551 | f = make_frame (1); | |
552 | XSETFRAME (frame, f); | |
553 | ||
554 | Vframe_list = Fcons (frame, Vframe_list); | |
555 | ||
6ed8eeff | 556 | tty_frame_count = 1; |
f00af5b1 | 557 | fset_name (f, build_pure_c_string ("F1")); |
3224dac1 | 558 | |
edfa7fa0 | 559 | SET_FRAME_VISIBLE (f, 1); |
3224dac1 | 560 | |
6ed8eeff KL |
561 | f->output_method = terminal->type; |
562 | f->terminal = terminal; | |
563 | f->terminal->reference_count++; | |
3224dac1 | 564 | f->output_data.nothing = 0; |
a3547743 | 565 | |
3224dac1 KL |
566 | FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR; |
567 | FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR; | |
a3547743 | 568 | |
3224dac1 | 569 | FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; |
3b8eff32 CY |
570 | |
571 | /* The default value of menu-bar-mode is t. */ | |
572 | set_menu_bar_lines (f, make_number (1), Qnil); | |
3224dac1 | 573 | |
edfda783 AR |
574 | if (!noninteractive) |
575 | init_frame_faces (f); | |
edfda783 | 576 | |
5492865b DA |
577 | last_nonminibuf_frame = f; |
578 | ||
3224dac1 KL |
579 | return f; |
580 | } | |
581 | ||
582 | ||
81626931 | 583 | static struct frame * |
6ed8eeff | 584 | make_terminal_frame (struct terminal *terminal) |
3224dac1 KL |
585 | { |
586 | register struct frame *f; | |
3224dac1 | 587 | Lisp_Object frame; |
8a401434 | 588 | char name[sizeof "F" + INT_STRLEN_BOUND (printmax_t)]; |
ab797f65 | 589 | |
4e213843 SM |
590 | if (!terminal->name) |
591 | error ("Terminal is not live, can't create new frames on it"); | |
ab797f65 | 592 | |
ff11dfa1 | 593 | f = make_frame (1); |
d063751a | 594 | |
2d80a27a | 595 | XSETFRAME (frame, f); |
d063751a RS |
596 | Vframe_list = Fcons (frame, Vframe_list); |
597 | ||
f00af5b1 | 598 | fset_name (f, make_formatted_string (name, "F%"pMd, ++tty_frame_count)); |
bb1513c9 | 599 | |
edfa7fa0 DA |
600 | SET_FRAME_VISIBLE (f, 1); |
601 | ||
1266f9ef EZ |
602 | f->terminal = terminal; |
603 | f->terminal->reference_count++; | |
bb221971 | 604 | #ifdef MSDOS |
99dda2cd | 605 | f->output_data.tty->display_info = &the_only_display_info; |
2d764c78 EZ |
606 | if (!inhibit_window_system |
607 | && (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame)) | |
608 | || XFRAME (selected_frame)->output_method == output_msdos_raw)) | |
02ab7130 | 609 | f->output_method = output_msdos_raw; |
2d764c78 EZ |
610 | else |
611 | f->output_method = output_termcap; | |
5bbdf7aa DN |
612 | #else /* not MSDOS */ |
613 | f->output_method = output_termcap; | |
614 | create_tty_output (f); | |
615 | FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR; | |
616 | FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR; | |
617 | #endif /* not MSDOS */ | |
574a1a90 | 618 | |
1266f9ef | 619 | FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; |
880e6158 MR |
620 | FRAME_MENU_BAR_LINES (f) = NILP (Vmenu_bar_mode) ? 0 : 1; |
621 | FRAME_MENU_BAR_HEIGHT (f) = FRAME_MENU_BAR_LINES (f) * FRAME_LINE_HEIGHT (f); | |
1266f9ef | 622 | |
caecb91c | 623 | /* Set the top frame to the newly created frame. */ |
1266f9ef EZ |
624 | if (FRAMEP (FRAME_TTY (f)->top_frame) |
625 | && FRAME_LIVE_P (XFRAME (FRAME_TTY (f)->top_frame))) | |
edfa7fa0 | 626 | SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f)->top_frame), 2); /* obscured */ |
1266f9ef EZ |
627 | |
628 | FRAME_TTY (f)->top_frame = frame; | |
629 | ||
1a6d3623 EZ |
630 | if (!noninteractive) |
631 | init_frame_faces (f); | |
1a578e9b | 632 | |
ff11dfa1 | 633 | return f; |
dc6f92b8 | 634 | } |
bb1513c9 | 635 | |
ed8dad6b KL |
636 | /* Get a suitable value for frame parameter PARAMETER for a newly |
637 | created frame, based on (1) the user-supplied frame parameter | |
c1ef4455 | 638 | alist SUPPLIED_PARMS, and (2) CURRENT_VALUE. */ |
ed8dad6b KL |
639 | |
640 | static Lisp_Object | |
641 | get_future_frame_param (Lisp_Object parameter, | |
642 | Lisp_Object supplied_parms, | |
643 | char *current_value) | |
644 | { | |
645 | Lisp_Object result; | |
646 | ||
647 | result = Fassq (parameter, supplied_parms); | |
648 | if (NILP (result)) | |
e69b0960 | 649 | result = Fassq (parameter, XFRAME (selected_frame)->param_alist); |
ed8dad6b KL |
650 | if (NILP (result) && current_value != NULL) |
651 | result = build_string (current_value); | |
ed8dad6b KL |
652 | if (!NILP (result) && !STRINGP (result)) |
653 | result = XCDR (result); | |
654 | if (NILP (result) || !STRINGP (result)) | |
655 | result = Qnil; | |
656 | ||
657 | return result; | |
658 | } | |
659 | ||
bb1513c9 | 660 | DEFUN ("make-terminal-frame", Fmake_terminal_frame, Smake_terminal_frame, |
14ff1ee0 | 661 | 1, 1, 0, |
28d440ab | 662 | doc: /* Create an additional terminal frame, possibly on another terminal. |
14ff1ee0 | 663 | This function takes one argument, an alist specifying frame parameters. |
28d440ab | 664 | |
c6bf3022 CY |
665 | You can create multiple frames on a single text terminal, but only one |
666 | of them (the selected terminal frame) is actually displayed. | |
28d440ab KL |
667 | |
668 | In practice, generally you don't need to specify any parameters, | |
669 | except when you want to create a new frame on another terminal. | |
670 | In that case, the `tty' parameter specifies the device file to open, | |
671 | and the `tty-type' parameter specifies the terminal type. Example: | |
672 | ||
673 | (make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm"))) | |
674 | ||
0b0d3e0b KL |
675 | Note that changing the size of one terminal frame automatically |
676 | affects all frames on the same terminal device. */) | |
5842a27b | 677 | (Lisp_Object parms) |
bb1513c9 RS |
678 | { |
679 | struct frame *f; | |
6ed8eeff | 680 | struct terminal *t = NULL; |
574a1a90 | 681 | Lisp_Object frame, tem; |
8d2666fe | 682 | struct frame *sf = SELECTED_FRAME (); |
bb1513c9 | 683 | |
541580aa | 684 | #ifdef MSDOS |
2d764c78 EZ |
685 | if (sf->output_method != output_msdos_raw |
686 | && sf->output_method != output_termcap) | |
1088b922 | 687 | emacs_abort (); |
574a1a90 RS |
688 | #else /* not MSDOS */ |
689 | ||
99b72cc4 | 690 | #ifdef WINDOWSNT /* This should work now! */ |
8d2666fe | 691 | if (sf->output_method != output_termcap) |
bb1513c9 | 692 | error ("Not using an ASCII terminal now; cannot make a new ASCII frame"); |
bb221971 | 693 | #endif |
574a1a90 | 694 | #endif /* not MSDOS */ |
a3547743 | 695 | |
b6660415 | 696 | { |
6ed8eeff | 697 | Lisp_Object terminal; |
bb1513c9 | 698 | |
6ed8eeff | 699 | terminal = Fassq (Qterminal, parms); |
090cf9db | 700 | if (CONSP (terminal)) |
28d440ab | 701 | { |
6ed8eeff KL |
702 | terminal = XCDR (terminal); |
703 | t = get_terminal (terminal, 1); | |
28d440ab | 704 | } |
1266f9ef EZ |
705 | #ifdef MSDOS |
706 | if (t && t != the_only_display_info.terminal) | |
707 | /* msdos.c assumes a single tty_display_info object. */ | |
708 | error ("Multiple terminals are not supported on this platform"); | |
709 | if (!t) | |
710 | t = the_only_display_info.terminal; | |
711 | #endif | |
28d440ab | 712 | } |
a3547743 | 713 | |
6ed8eeff | 714 | if (!t) |
a3547743 | 715 | { |
b6660415 | 716 | char *name = 0, *type = 0; |
ed8dad6b | 717 | Lisp_Object tty, tty_type; |
b6660415 | 718 | |
ed8dad6b KL |
719 | tty = get_future_frame_param |
720 | (Qtty, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame)) | |
721 | ? FRAME_TTY (XFRAME (selected_frame))->name | |
722 | : NULL)); | |
723 | if (!NILP (tty)) | |
5b71542d | 724 | name = xlispstrdupa (tty); |
a3547743 | 725 | |
ed8dad6b KL |
726 | tty_type = get_future_frame_param |
727 | (Qtty_type, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame)) | |
728 | ? FRAME_TTY (XFRAME (selected_frame))->type | |
729 | : NULL)); | |
730 | if (!NILP (tty_type)) | |
5b71542d | 731 | type = xlispstrdupa (tty_type); |
b6660415 | 732 | |
dc6c0eda | 733 | t = init_tty (name, type, 0); /* Errors are not fatal. */ |
b6660415 | 734 | } |
bb1513c9 | 735 | |
6ed8eeff | 736 | f = make_terminal_frame (t); |
574a1a90 | 737 | |
9628b887 KL |
738 | { |
739 | int width, height; | |
0b0d3e0b | 740 | get_tty_size (fileno (FRAME_TTY (f)->input), &width, &height); |
880e6158 | 741 | change_frame_size (f, width, height, 0, 0, 0, 0); |
9628b887 | 742 | } |
a3547743 | 743 | |
bd0443bb | 744 | adjust_frame_glyphs (f); |
bb1513c9 RS |
745 | calculate_costs (f); |
746 | XSETFRAME (frame, f); | |
84231434 DA |
747 | |
748 | store_in_alist (&parms, Qtty_type, build_string (t->display_info.tty->type)); | |
9acc1074 | 749 | store_in_alist (&parms, Qtty, |
84231434 DA |
750 | (t->display_info.tty->name |
751 | ? build_string (t->display_info.tty->name) | |
752 | : Qnil)); | |
bb1513c9 | 753 | Fmodify_frame_parameters (frame, parms); |
a3547743 | 754 | |
87f1940e EZ |
755 | /* Make the frame face alist be frame-specific, so that each |
756 | frame could change its face definitions independently. */ | |
f00af5b1 | 757 | fset_face_alist (f, Fcopy_alist (sf->face_alist)); |
87f1940e EZ |
758 | /* Simple Fcopy_alist isn't enough, because we need the contents of |
759 | the vectors which are the CDRs of associations in face_alist to | |
760 | be copied as well. */ | |
e69b0960 | 761 | for (tem = f->face_alist; CONSP (tem); tem = XCDR (tem)) |
f3fbd155 | 762 | XSETCDR (XCAR (tem), Fcopy_sequence (XCDR (XCAR (tem)))); |
bb1513c9 RS |
763 | return frame; |
764 | } | |
1e8324d9 | 765 | |
dc6f92b8 | 766 | \f |
1e8324d9 GM |
767 | /* Perform the switch to frame FRAME. |
768 | ||
769 | If FRAME is a switch-frame event `(switch-frame FRAME1)', use | |
770 | FRAME1 as frame. | |
771 | ||
772 | If TRACK is non-zero and the frame that currently has the focus | |
773 | redirects its focus to the selected frame, redirect that focused | |
774 | frame's focus to FRAME instead. | |
775 | ||
776 | FOR_DELETION non-zero means that the selected frame is being | |
6ed8eeff | 777 | deleted, which includes the possibility that the frame's terminal |
216e6a14 MR |
778 | is dead. |
779 | ||
780 | The value of NORECORD is passed as argument to Fselect_window. */ | |
1e8324d9 | 781 | |
61f94483 | 782 | Lisp_Object |
971de7fb | 783 | do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object norecord) |
dc6f92b8 | 784 | { |
8d2666fe | 785 | struct frame *sf = SELECTED_FRAME (); |
177c0ea7 | 786 | |
2f0b07e0 JB |
787 | /* If FRAME is a switch-frame event, extract the frame we should |
788 | switch to. */ | |
789 | if (CONSP (frame) | |
7539e11f KR |
790 | && EQ (XCAR (frame), Qswitch_frame) |
791 | && CONSP (XCDR (frame))) | |
792 | frame = XCAR (XCDR (frame)); | |
2f0b07e0 | 793 | |
09907c3a KH |
794 | /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for |
795 | a switch-frame event to arrive after a frame is no longer live, | |
796 | especially when deleting the initial frame during startup. */ | |
b7826503 | 797 | CHECK_FRAME (frame); |
09907c3a KH |
798 | if (! FRAME_LIVE_P (XFRAME (frame))) |
799 | return Qnil; | |
dc6f92b8 | 800 | |
8d2666fe | 801 | if (sf == XFRAME (frame)) |
ff11dfa1 | 802 | return frame; |
dc6f92b8 | 803 | |
a42e9724 JB |
804 | /* If a frame's focus has been redirected toward the currently |
805 | selected frame, we should change the redirection to point to the | |
806 | newly selected frame. This means that if the focus is redirected | |
807 | from a minibufferless frame to a surrogate minibuffer frame, we | |
808 | can use `other-window' to switch between all the frames using | |
809 | that minibuffer frame, and the focus redirection will follow us | |
810 | around. */ | |
655ab9a3 SM |
811 | #if 0 |
812 | /* This is too greedy; it causes inappropriate focus redirection | |
813 | that's hard to get rid of. */ | |
0aed85f4 KH |
814 | if (track) |
815 | { | |
816 | Lisp_Object tail; | |
a42e9724 | 817 | |
7539e11f | 818 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) |
0aed85f4 KH |
819 | { |
820 | Lisp_Object focus; | |
a42e9724 | 821 | |
7539e11f | 822 | if (!FRAMEP (XCAR (tail))) |
1088b922 | 823 | emacs_abort (); |
a42e9724 | 824 | |
7539e11f | 825 | focus = FRAME_FOCUS_FRAME (XFRAME (XCAR (tail))); |
a42e9724 | 826 | |
8d2666fe | 827 | if (FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ()) |
7539e11f | 828 | Fredirect_frame_focus (XCAR (tail), frame); |
0aed85f4 KH |
829 | } |
830 | } | |
831 | #else /* ! 0 */ | |
832 | /* Instead, apply it only to the frame we're pointing to. */ | |
032d78fe | 833 | #ifdef HAVE_WINDOW_SYSTEM |
1e8324d9 | 834 | if (track && FRAME_WINDOW_P (XFRAME (frame))) |
0aed85f4 KH |
835 | { |
836 | Lisp_Object focus, xfocus; | |
837 | ||
d7266360 | 838 | xfocus = x_get_focus_frame (XFRAME (frame)); |
0aed85f4 KH |
839 | if (FRAMEP (xfocus)) |
840 | { | |
841 | focus = FRAME_FOCUS_FRAME (XFRAME (xfocus)); | |
8d2666fe | 842 | if (FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ()) |
0aed85f4 KH |
843 | Fredirect_frame_focus (xfocus, frame); |
844 | } | |
845 | } | |
846 | #endif /* HAVE_X_WINDOWS */ | |
847 | #endif /* ! 0 */ | |
a42e9724 | 848 | |
1e8324d9 | 849 | if (!for_deletion && FRAME_HAS_MINIBUF_P (sf)) |
550f0e6a GM |
850 | resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf)), 1); |
851 | ||
a4e628d4 | 852 | if (FRAME_TERMCAP_P (XFRAME (frame)) || FRAME_MSDOS_P (XFRAME (frame))) |
9628b887 | 853 | { |
f009190a EZ |
854 | Lisp_Object top_frame = FRAME_TTY (XFRAME (frame))->top_frame; |
855 | ||
856 | /* Don't mark the frame garbaged and/or obscured if we are | |
857 | switching to the frame that is already the top frame of that | |
858 | TTY. */ | |
859 | if (!EQ (frame, top_frame)) | |
860 | { | |
861 | if (FRAMEP (top_frame)) | |
862 | /* Mark previously displayed frame as now obscured. */ | |
863 | SET_FRAME_VISIBLE (XFRAME (top_frame), 2); | |
864 | SET_FRAME_VISIBLE (XFRAME (frame), 1); | |
865 | } | |
9628b887 KL |
866 | FRAME_TTY (XFRAME (frame))->top_frame = frame; |
867 | } | |
868 | ||
8d2666fe GM |
869 | selected_frame = frame; |
870 | if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame))) | |
871 | last_nonminibuf_frame = XFRAME (selected_frame); | |
d5e7c279 | 872 | |
e69b0960 | 873 | Fselect_window (XFRAME (frame)->selected_window, norecord); |
dc6f92b8 | 874 | |
074577b8 | 875 | /* We want to make sure that the next event generates a frame-switch |
eb8c3be9 | 876 | event to the appropriate frame. This seems kludgy to me, but |
074577b8 JB |
877 | before you take it out, make sure that evaluating something like |
878 | (select-window (frame-root-window (new-frame))) doesn't end up | |
879 | with your typing being interpreted in the new frame instead of | |
880 | the one you're actually typing in. */ | |
ef352596 | 881 | internal_last_event_frame = Qnil; |
074577b8 | 882 | |
ff11dfa1 | 883 | return frame; |
dc6f92b8 JB |
884 | } |
885 | ||
a7ca3326 | 886 | DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e", |
216e6a14 | 887 | doc: /* Select FRAME. |
14ff1ee0 | 888 | Subsequent editing commands apply to its selected window. |
216e6a14 MR |
889 | Optional argument NORECORD means to neither change the order of |
890 | recently selected windows nor the buffer list. | |
891 | ||
14ff1ee0 | 892 | The selection of FRAME lasts until the next time the user does |
216e6a14 MR |
893 | something to select a different frame, or until the next time |
894 | this function is called. If you are using a window system, the | |
895 | previously selected frame may be restored as the selected frame | |
057bce6f | 896 | when returning to the command loop, because it still may have |
c6bf3022 CY |
897 | the window system's input focus. On a text terminal, the next |
898 | redisplay will display FRAME. | |
e4ed805e LT |
899 | |
900 | This function returns FRAME, or nil if FRAME has been deleted. */) | |
5842a27b | 901 | (Lisp_Object frame, Lisp_Object norecord) |
0aed85f4 | 902 | { |
216e6a14 | 903 | return do_switch_frame (frame, 1, 0, norecord); |
0aed85f4 KH |
904 | } |
905 | ||
20dc6fbb | 906 | DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 1, "e", |
14ff1ee0 PJ |
907 | doc: /* Handle a switch-frame event EVENT. |
908 | Switch-frame events are usually bound to this function. | |
909 | A switch-frame event tells Emacs that the window manager has requested | |
910 | that the user's events be directed to the frame mentioned in the event. | |
911 | This function selects the selected window of the frame of EVENT. | |
912 | ||
913 | If EVENT is frame object, handle it as if it were a switch-frame event | |
914 | to that frame. */) | |
5842a27b | 915 | (Lisp_Object event) |
0aed85f4 | 916 | { |
6951cd71 | 917 | /* Preserve prefix arg that the command loop just cleared. */ |
15dbb4d6 | 918 | kset_prefix_arg (current_kboard, Vcurrent_prefix_arg); |
dee091a3 | 919 | Frun_hooks (1, &Qmouse_leave_buffer_hook); |
511fa0d3 SM |
920 | /* `switch-frame' implies a focus in. */ |
921 | call1 (intern ("handle-focus-in"), event); | |
216e6a14 | 922 | return do_switch_frame (event, 0, 0, Qnil); |
0aed85f4 KH |
923 | } |
924 | ||
a7ca3326 | 925 | DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0, |
14ff1ee0 | 926 | doc: /* Return the frame that is now selected. */) |
5842a27b | 927 | (void) |
dc6f92b8 | 928 | { |
8d2666fe | 929 | return selected_frame; |
dc6f92b8 | 930 | } |
4a7cfafc | 931 | \f |
ff11dfa1 | 932 | DEFUN ("frame-list", Fframe_list, Sframe_list, |
dc6f92b8 | 933 | 0, 0, 0, |
c15dfb29 | 934 | doc: /* Return a list of all live frames. */) |
5842a27b | 935 | (void) |
dc6f92b8 | 936 | { |
d74c1900 GM |
937 | Lisp_Object frames; |
938 | frames = Fcopy_sequence (Vframe_list); | |
6a65b1b5 | 939 | #ifdef HAVE_WINDOW_SYSTEM |
d74c1900 GM |
940 | if (FRAMEP (tip_frame)) |
941 | frames = Fdelq (tip_frame, frames); | |
6a65b1b5 | 942 | #endif |
d74c1900 | 943 | return frames; |
dc6f92b8 JB |
944 | } |
945 | ||
565212e5 DA |
946 | /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the |
947 | same tty (for tty frames) or among frames which uses FRAME's keyboard. | |
948 | If MINIBUF is nil, do not consider minibuffer-only candidate. | |
7216e43b | 949 | If MINIBUF is `visible', do not consider an invisible candidate. |
565212e5 DA |
950 | If MINIBUF is a window, consider only its own frame and candidate now |
951 | using that window as the minibuffer. | |
952 | If MINIBUF is 0, consider candidate if it is visible or iconified. | |
953 | Otherwise consider any candidate and return nil if CANDIDATE is not | |
954 | acceptable. */ | |
955 | ||
956 | static Lisp_Object | |
957 | candidate_frame (Lisp_Object candidate, Lisp_Object frame, Lisp_Object minibuf) | |
958 | { | |
959 | struct frame *c = XFRAME (candidate), *f = XFRAME (frame); | |
960 | ||
961 | if ((!FRAME_TERMCAP_P (c) && !FRAME_TERMCAP_P (f) | |
962 | && FRAME_KBOARD (c) == FRAME_KBOARD (f)) | |
963 | || (FRAME_TERMCAP_P (c) && FRAME_TERMCAP_P (f) | |
964 | && FRAME_TTY (c) == FRAME_TTY (f))) | |
965 | { | |
966 | if (NILP (minibuf)) | |
967 | { | |
968 | if (!FRAME_MINIBUF_ONLY_P (c)) | |
969 | return candidate; | |
970 | } | |
971 | else if (EQ (minibuf, Qvisible)) | |
972 | { | |
565212e5 DA |
973 | if (FRAME_VISIBLE_P (c)) |
974 | return candidate; | |
975 | } | |
976 | else if (WINDOWP (minibuf)) | |
977 | { | |
978 | if (EQ (FRAME_MINIBUF_WINDOW (c), minibuf) | |
979 | || EQ (WINDOW_FRAME (XWINDOW (minibuf)), candidate) | |
980 | || EQ (WINDOW_FRAME (XWINDOW (minibuf)), | |
981 | FRAME_FOCUS_FRAME (c))) | |
982 | return candidate; | |
983 | } | |
984 | else if (XFASTINT (minibuf) == 0) | |
985 | { | |
565212e5 DA |
986 | if (FRAME_VISIBLE_P (c) || FRAME_ICONIFIED_P (c)) |
987 | return candidate; | |
988 | } | |
989 | else | |
990 | return candidate; | |
991 | } | |
992 | return Qnil; | |
993 | } | |
994 | ||
995 | /* Return the next frame in the frame list after FRAME. */ | |
f7af3f7b | 996 | |
66a9dbbe | 997 | static Lisp_Object |
971de7fb | 998 | next_frame (Lisp_Object frame, Lisp_Object minibuf) |
dc6f92b8 | 999 | { |
5b04e9f9 | 1000 | Lisp_Object f, tail; |
dc6f92b8 JB |
1001 | int passed = 0; |
1002 | ||
ff11dfa1 | 1003 | /* There must always be at least one frame in Vframe_list. */ |
565212e5 | 1004 | eassert (CONSP (Vframe_list)); |
dbc4e1c1 | 1005 | |
565212e5 | 1006 | while (passed < 2) |
5b04e9f9 | 1007 | FOR_EACH_FRAME (tail, f) |
dc6f92b8 | 1008 | { |
565212e5 | 1009 | if (passed) |
d5e7c279 | 1010 | { |
565212e5 DA |
1011 | f = candidate_frame (f, frame, minibuf); |
1012 | if (!NILP (f)) | |
ff11dfa1 | 1013 | return f; |
d5e7c279 | 1014 | } |
d06a8a56 | 1015 | if (EQ (frame, f)) |
dc6f92b8 JB |
1016 | passed++; |
1017 | } | |
565212e5 | 1018 | return frame; |
dc6f92b8 JB |
1019 | } |
1020 | ||
565212e5 | 1021 | /* Return the previous frame in the frame list before FRAME. */ |
f7af3f7b | 1022 | |
66a9dbbe | 1023 | static Lisp_Object |
971de7fb | 1024 | prev_frame (Lisp_Object frame, Lisp_Object minibuf) |
dc6f92b8 | 1025 | { |
5b04e9f9 | 1026 | Lisp_Object f, tail, prev = Qnil; |
dc6f92b8 | 1027 | |
ff11dfa1 | 1028 | /* There must always be at least one frame in Vframe_list. */ |
5b04e9f9 | 1029 | eassert (CONSP (Vframe_list)); |
f9898cc6 | 1030 | |
5b04e9f9 | 1031 | FOR_EACH_FRAME (tail, f) |
f9898cc6 | 1032 | { |
d06a8a56 JB |
1033 | if (EQ (frame, f) && !NILP (prev)) |
1034 | return prev; | |
565212e5 DA |
1035 | f = candidate_frame (f, frame, minibuf); |
1036 | if (!NILP (f)) | |
1037 | prev = f; | |
f9898cc6 | 1038 | } |
d06a8a56 JB |
1039 | |
1040 | /* We've scanned the entire list. */ | |
1041 | if (NILP (prev)) | |
1042 | /* We went through the whole frame list without finding a single | |
1043 | acceptable frame. Return the original frame. */ | |
1044 | return frame; | |
1045 | else | |
1046 | /* There were no acceptable frames in the list before FRAME; otherwise, | |
1047 | we would have returned directly from the loop. Since PREV is the last | |
1048 | acceptable frame in the list, return it. */ | |
1049 | return prev; | |
dc6f92b8 JB |
1050 | } |
1051 | ||
ef2c57ac | 1052 | |
ff11dfa1 | 1053 | DEFUN ("next-frame", Fnext_frame, Snext_frame, 0, 2, 0, |
14ff1ee0 PJ |
1054 | doc: /* Return the next frame in the frame list after FRAME. |
1055 | It considers only frames on the same terminal as FRAME. | |
1056 | By default, skip minibuffer-only frames. | |
1057 | If omitted, FRAME defaults to the selected frame. | |
1058 | If optional argument MINIFRAME is nil, exclude minibuffer-only frames. | |
1059 | If MINIFRAME is a window, include only its own frame | |
1060 | and any frame now using that window as the minibuffer. | |
1061 | If MINIFRAME is `visible', include all visible frames. | |
1062 | If MINIFRAME is 0, include all visible and iconified frames. | |
1063 | Otherwise, include all frames. */) | |
5842a27b | 1064 | (Lisp_Object frame, Lisp_Object miniframe) |
dc6f92b8 | 1065 | { |
ff11dfa1 | 1066 | if (NILP (frame)) |
8d2666fe | 1067 | frame = selected_frame; |
b7826503 | 1068 | CHECK_LIVE_FRAME (frame); |
ff11dfa1 | 1069 | return next_frame (frame, miniframe); |
dc6f92b8 | 1070 | } |
dbc4e1c1 | 1071 | |
ef2c57ac | 1072 | DEFUN ("previous-frame", Fprevious_frame, Sprevious_frame, 0, 2, 0, |
14ff1ee0 PJ |
1073 | doc: /* Return the previous frame in the frame list before FRAME. |
1074 | It considers only frames on the same terminal as FRAME. | |
1075 | By default, skip minibuffer-only frames. | |
1076 | If omitted, FRAME defaults to the selected frame. | |
1077 | If optional argument MINIFRAME is nil, exclude minibuffer-only frames. | |
1078 | If MINIFRAME is a window, include only its own frame | |
1079 | and any frame now using that window as the minibuffer. | |
1080 | If MINIFRAME is `visible', include all visible frames. | |
1081 | If MINIFRAME is 0, include all visible and iconified frames. | |
1082 | Otherwise, include all frames. */) | |
5842a27b | 1083 | (Lisp_Object frame, Lisp_Object miniframe) |
ef2c57ac | 1084 | { |
ef2c57ac | 1085 | if (NILP (frame)) |
8d2666fe | 1086 | frame = selected_frame; |
b7826503 | 1087 | CHECK_LIVE_FRAME (frame); |
ef2c57ac RM |
1088 | return prev_frame (frame, miniframe); |
1089 | } | |
9718b207 MR |
1090 | |
1091 | DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame, | |
1092 | Slast_nonminibuf_frame, 0, 0, 0, | |
1093 | doc: /* Return last non-minibuffer frame selected. */) | |
1094 | (void) | |
1095 | { | |
1096 | Lisp_Object frame = Qnil; | |
1097 | ||
1098 | if (last_nonminibuf_frame) | |
1099 | XSETFRAME (frame, last_nonminibuf_frame); | |
1100 | ||
1101 | return frame; | |
1102 | } | |
dc6f92b8 | 1103 | \f |
808c0f20 RS |
1104 | /* Return 1 if it is ok to delete frame F; |
1105 | 0 if all frames aside from F are invisible. | |
1106 | (Exception: if F is the terminal frame, and we are using X, return 1.) */ | |
dc6f92b8 | 1107 | |
4475bec4 | 1108 | static int |
a10c8269 | 1109 | other_visible_frames (struct frame *f) |
808c0f20 | 1110 | { |
5b04e9f9 | 1111 | Lisp_Object frames, this; |
c08c95c7 | 1112 | |
5b04e9f9 | 1113 | FOR_EACH_FRAME (frames, this) |
1de11f56 | 1114 | { |
1de11f56 CY |
1115 | if (f == XFRAME (this)) |
1116 | continue; | |
c08c95c7 | 1117 | |
1de11f56 CY |
1118 | /* Verify that we can still talk to the frame's X window, |
1119 | and note any recent change in visibility. */ | |
83fc0554 | 1120 | #ifdef HAVE_X_WINDOWS |
1de11f56 | 1121 | if (FRAME_WINDOW_P (XFRAME (this))) |
edfa7fa0 | 1122 | x_sync (XFRAME (this)); |
5e7b7c5b RS |
1123 | #endif |
1124 | ||
1de11f56 CY |
1125 | if (FRAME_VISIBLE_P (XFRAME (this)) |
1126 | || FRAME_ICONIFIED_P (XFRAME (this)) | |
1127 | /* Allow deleting the terminal frame when at least one X | |
1128 | frame exists. */ | |
1129 | || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f))) | |
1130 | return 1; | |
c08c95c7 | 1131 | } |
1de11f56 | 1132 | return 0; |
808c0f20 RS |
1133 | } |
1134 | ||
bfff6445 MR |
1135 | /* Make sure that minibuf_window doesn't refer to FRAME's minibuffer |
1136 | window. Preferably use the selected frame's minibuffer window | |
1137 | instead. If the selected frame doesn't have one, get some other | |
1138 | frame's minibuffer window. SELECT non-zero means select the new | |
1139 | minibuffer window. */ | |
1140 | static void | |
1141 | check_minibuf_window (Lisp_Object frame, int select) | |
1142 | { | |
1143 | struct frame *f = decode_live_frame (frame); | |
1144 | ||
98b7f4bd DA |
1145 | XSETFRAME (frame, f); |
1146 | ||
bfff6445 MR |
1147 | if (WINDOWP (minibuf_window) && EQ (f->minibuffer_window, minibuf_window)) |
1148 | { | |
f5adc984 | 1149 | Lisp_Object frames, this, window = make_number (0); |
bfff6445 MR |
1150 | |
1151 | if (!EQ (frame, selected_frame) | |
1152 | && FRAME_HAS_MINIBUF_P (XFRAME (selected_frame))) | |
1153 | window = FRAME_MINIBUF_WINDOW (XFRAME (selected_frame)); | |
1154 | else | |
1155 | FOR_EACH_FRAME (frames, this) | |
1156 | { | |
1157 | if (!EQ (this, frame) && FRAME_HAS_MINIBUF_P (XFRAME (this))) | |
1158 | { | |
1159 | window = FRAME_MINIBUF_WINDOW (XFRAME (this)); | |
1160 | break; | |
1161 | } | |
1162 | } | |
1163 | ||
8b098236 MR |
1164 | /* Don't abort if no window was found (Bug#15247). */ |
1165 | if (WINDOWP (window)) | |
bfff6445 MR |
1166 | { |
1167 | /* Use set_window_buffer instead of Fset_window_buffer (see | |
1168 | discussion of bug#11984, bug#12025, bug#12026). */ | |
1169 | set_window_buffer (window, XWINDOW (minibuf_window)->contents, 0, 0); | |
1170 | minibuf_window = window; | |
1171 | ||
1172 | /* SELECT non-zero usually means that FRAME's minibuffer | |
1173 | window was selected; select the new one. */ | |
1174 | if (select) | |
1175 | Fselect_window (minibuf_window, Qnil); | |
1176 | } | |
1177 | } | |
1178 | } | |
1179 | ||
1180 | ||
56f2de10 MR |
1181 | /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME |
1182 | unconditionally. x_connection_closed and delete_terminal use | |
1183 | this. Any other value of FORCE implements the semantics | |
1184 | described for Fdelete_frame. */ | |
1185 | Lisp_Object | |
971de7fb | 1186 | delete_frame (Lisp_Object frame, Lisp_Object force) |
808c0f20 | 1187 | { |
d9f07150 | 1188 | struct frame *f = decode_any_frame (frame); |
d3e2acb6 | 1189 | struct frame *sf; |
bedb9c0e KL |
1190 | struct kboard *kb; |
1191 | ||
cf5fc6db | 1192 | int minibuffer_selected, is_tooltip_frame; |
808c0f20 | 1193 | |
808c0f20 RS |
1194 | if (! FRAME_LIVE_P (f)) |
1195 | return Qnil; | |
1196 | ||
e39a993c | 1197 | if (NILP (force) && !other_visible_frames (f)) |
808c0f20 | 1198 | error ("Attempt to delete the sole visible or iconified frame"); |
d5e7c279 | 1199 | |
56f2de10 | 1200 | /* x_connection_closed must have set FORCE to `noelisp' in order |
00c5fd51 | 1201 | to delete the last frame, if it is gone. */ |
56f2de10 | 1202 | if (NILP (XCDR (Vframe_list)) && !EQ (force, Qnoelisp)) |
e9687ee8 RS |
1203 | error ("Attempt to delete the only frame"); |
1204 | ||
d9f07150 DA |
1205 | XSETFRAME (frame, f); |
1206 | ||
ff11dfa1 JB |
1207 | /* Does this frame have a minibuffer, and is it the surrogate |
1208 | minibuffer for any other frame? */ | |
d9f07150 | 1209 | if (FRAME_HAS_MINIBUF_P (f)) |
dc6f92b8 | 1210 | { |
5b04e9f9 | 1211 | Lisp_Object frames, this; |
1113d9db | 1212 | |
5b04e9f9 | 1213 | FOR_EACH_FRAME (frames, this) |
1113d9db | 1214 | { |
2e5ce5de | 1215 | Lisp_Object fminiw; |
2e5ce5de | 1216 | |
e560aba9 PE |
1217 | if (EQ (this, frame)) |
1218 | continue; | |
1219 | ||
1220 | fminiw = FRAME_MINIBUF_WINDOW (XFRAME (this)); | |
1221 | ||
1222 | if (WINDOWP (fminiw) && EQ (frame, WINDOW_FRAME (XWINDOW (fminiw)))) | |
a31787b1 | 1223 | { |
56f2de10 MR |
1224 | /* If we MUST delete this frame, delete the other first. |
1225 | But do this only if FORCE equals `noelisp'. */ | |
1226 | if (EQ (force, Qnoelisp)) | |
1227 | delete_frame (this, Qnoelisp); | |
a31787b1 RS |
1228 | else |
1229 | error ("Attempt to delete a surrogate minibuffer frame"); | |
1230 | } | |
1113d9db | 1231 | } |
dc6f92b8 JB |
1232 | } |
1233 | ||
cf5fc6db | 1234 | is_tooltip_frame = !NILP (Fframe_parameter (frame, intern ("tooltip"))); |
54ee7410 | 1235 | |
56f2de10 MR |
1236 | /* Run `delete-frame-functions' unless FORCE is `noelisp' or |
1237 | frame is a tooltip. FORCE is set to `noelisp' when handling | |
1238 | a disconnect from the terminal, so we don't dare call Lisp | |
1239 | code. */ | |
cf5fc6db | 1240 | if (NILP (Vrun_hooks) || is_tooltip_frame) |
58555d81 | 1241 | ; |
54ee7410 | 1242 | else if (EQ (force, Qnoelisp)) |
58555d81 SM |
1243 | pending_funcalls |
1244 | = Fcons (list3 (Qrun_hook_with_args, Qdelete_frame_functions, frame), | |
1245 | pending_funcalls); | |
1246 | else | |
1dd3c2d9 CY |
1247 | { |
1248 | #ifdef HAVE_X_WINDOWS | |
58179cce | 1249 | /* Also, save clipboard to the clipboard manager. */ |
1dd3c2d9 CY |
1250 | x_clipboard_manager_save_frame (frame); |
1251 | #endif | |
1252 | ||
1253 | safe_call2 (Qrun_hook_with_args, Qdelete_frame_functions, frame); | |
1254 | } | |
0e662342 | 1255 | |
b6660415 KL |
1256 | /* The hook may sometimes (indirectly) cause the frame to be deleted. */ |
1257 | if (! FRAME_LIVE_P (f)) | |
1258 | return Qnil; | |
1259 | ||
a31787b1 RS |
1260 | /* At this point, we are committed to deleting the frame. |
1261 | There is no more chance for errors to prevent it. */ | |
1262 | ||
99b92e64 | 1263 | minibuffer_selected = EQ (minibuf_window, selected_window); |
d3e2acb6 | 1264 | sf = SELECTED_FRAME (); |
ff11dfa1 | 1265 | /* Don't let the frame remain selected. */ |
8d2666fe | 1266 | if (f == sf) |
06537cc8 | 1267 | { |
691a357f PE |
1268 | Lisp_Object tail; |
1269 | Lisp_Object frame1 = Qnil; | |
06537cc8 | 1270 | |
42fe2e88 DA |
1271 | /* Look for another visible frame on the same terminal. |
1272 | Do not call next_frame here because it may loop forever. | |
1273 | See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15025. */ | |
1274 | FOR_EACH_FRAME (tail, frame1) | |
1275 | if (!EQ (frame, frame1) | |
1276 | && (FRAME_TERMINAL (XFRAME (frame)) | |
1277 | == FRAME_TERMINAL (XFRAME (frame1))) | |
1278 | && FRAME_VISIBLE_P (XFRAME (frame1))) | |
1279 | break; | |
06537cc8 RS |
1280 | |
1281 | /* If there is none, find *some* other frame. */ | |
1282 | if (NILP (frame1) || EQ (frame1, frame)) | |
1283 | { | |
1284 | FOR_EACH_FRAME (tail, frame1) | |
1285 | { | |
fca177d4 | 1286 | if (! EQ (frame, frame1) && FRAME_LIVE_P (XFRAME (frame1))) |
c6bf3022 CY |
1287 | { |
1288 | /* Do not change a text terminal's top-frame. */ | |
1289 | struct frame *f1 = XFRAME (frame1); | |
1290 | if (FRAME_TERMCAP_P (f1) || FRAME_MSDOS_P (f1)) | |
1291 | { | |
1292 | Lisp_Object top_frame = FRAME_TTY (f1)->top_frame; | |
1293 | if (!EQ (top_frame, frame)) | |
1294 | frame1 = top_frame; | |
1295 | } | |
1296 | break; | |
1297 | } | |
06537cc8 RS |
1298 | } |
1299 | } | |
ac71ced7 SM |
1300 | #ifdef NS_IMPL_COCOA |
1301 | else | |
1302 | /* Under NS, there is no system mechanism for choosing a new | |
1303 | window to get focus -- it is left to application code. | |
1304 | So the portion of THIS application interfacing with NS | |
1305 | needs to know about it. We call Fraise_frame, but the | |
1306 | purpose is really to transfer focus. */ | |
1307 | Fraise_frame (frame1); | |
1308 | #endif | |
06537cc8 | 1309 | |
216e6a14 | 1310 | do_switch_frame (frame1, 0, 1, Qnil); |
79a65b7f | 1311 | sf = SELECTED_FRAME (); |
06537cc8 | 1312 | } |
dc6f92b8 | 1313 | |
ff11dfa1 | 1314 | /* Don't allow minibuf_window to remain on a deleted frame. */ |
bfff6445 | 1315 | check_minibuf_window (frame, minibuffer_selected); |
dc6f92b8 | 1316 | |
130adcb7 | 1317 | /* Don't let echo_area_window to remain on a deleted frame. */ |
e69b0960 DA |
1318 | if (EQ (f->minibuffer_window, echo_area_window)) |
1319 | echo_area_window = sf->minibuffer_window; | |
130adcb7 | 1320 | |
bb2a0a65 RS |
1321 | /* Clear any X selections for this frame. */ |
1322 | #ifdef HAVE_X_WINDOWS | |
1323 | if (FRAME_X_P (f)) | |
1324 | x_clear_frame_selections (f); | |
1325 | #endif | |
1326 | ||
177c0ea7 JB |
1327 | /* Free glyphs. |
1328 | This function must be called before the window tree of the | |
18082e2d GM |
1329 | frame is deleted because windows contain dynamically allocated |
1330 | memory. */ | |
1331 | free_glyphs (f); | |
1332 | ||
1ccdfd33 | 1333 | #ifdef HAVE_WINDOW_SYSTEM |
50e3873c KH |
1334 | /* Give chance to each font driver to free a frame specific data. */ |
1335 | font_update_drivers (f, Qnil); | |
1ccdfd33 | 1336 | #endif |
50e3873c | 1337 | |
4a88b3b0 JB |
1338 | /* Mark all the windows that used to be on FRAME as deleted, and then |
1339 | remove the reference to them. */ | |
e69b0960 | 1340 | delete_all_child_windows (f->root_window); |
f00af5b1 | 1341 | fset_root_window (f, Qnil); |
4a88b3b0 | 1342 | |
ff11dfa1 | 1343 | Vframe_list = Fdelq (frame, Vframe_list); |
edfa7fa0 | 1344 | SET_FRAME_VISIBLE (f, 0); |
dc6f92b8 | 1345 | |
a90af46f CY |
1346 | /* Allow the vector of menu bar contents to be freed in the next |
1347 | garbage collection. The frame object itself may not be garbage | |
1348 | collected until much later, because recent_keys and other data | |
1349 | structures can still refer to it. */ | |
f00af5b1 | 1350 | fset_menu_bar_vector (f, Qnil); |
acc49a52 | 1351 | |
d59a1afb DA |
1352 | /* If FRAME's buffer lists contains killed |
1353 | buffers, this helps GC to reclaim them. */ | |
1354 | fset_buffer_list (f, Qnil); | |
1355 | fset_buried_buffer_list (f, Qnil); | |
1356 | ||
ebbbc028 | 1357 | free_font_driver_list (f); |
70fdbb46 JM |
1358 | xfree (f->namebuf); |
1359 | xfree (f->decode_mode_spec_buffer); | |
1360 | xfree (FRAME_INSERT_COST (f)); | |
1361 | xfree (FRAME_DELETEN_COST (f)); | |
1362 | xfree (FRAME_INSERTN_COST (f)); | |
1363 | xfree (FRAME_DELETE_COST (f)); | |
d2bee99e | 1364 | |
8678b9cc | 1365 | /* Since some events are handled at the interrupt level, we may get |
6ed8eeff | 1366 | an event for f at any time; if we zero out the frame's terminal |
8678b9cc | 1367 | now, then we may trip up the event-handling code. Instead, we'll |
6ed8eeff KL |
1368 | promise that the terminal of the frame must be valid until we |
1369 | have called the window-system-dependent frame destruction | |
1370 | routine. */ | |
dbc4e1c1 | 1371 | |
d5e7c279 | 1372 | |
428a555e | 1373 | { |
56a0e352 | 1374 | struct terminal *terminal; |
caa50be2 JD |
1375 | block_input (); |
1376 | if (FRAME_TERMINAL (f)->delete_frame_hook) | |
1377 | (*FRAME_TERMINAL (f)->delete_frame_hook) (f); | |
56a0e352 | 1378 | terminal = FRAME_TERMINAL (f); |
a3547743 | 1379 | f->output_data.nothing = 0; |
b09cca6a | 1380 | f->terminal = 0; /* Now the frame is dead. */ |
caa50be2 | 1381 | unblock_input (); |
428a555e | 1382 | |
6ed8eeff | 1383 | /* If needed, delete the terminal that this frame was on. |
b09cca6a | 1384 | (This must be done after the frame is killed.) */ |
6ed8eeff | 1385 | terminal->reference_count--; |
a2addb04 TH |
1386 | #ifdef USE_GTK |
1387 | /* FIXME: Deleting the terminal crashes emacs because of a GTK | |
1388 | bug. | |
1389 | http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */ | |
1390 | if (terminal->reference_count == 0 && terminal->type == output_x_window) | |
1391 | terminal->reference_count = 1; | |
1392 | #endif /* USE_GTK */ | |
6ed8eeff | 1393 | if (terminal->reference_count == 0) |
bedb9c0e | 1394 | { |
174105f7 SM |
1395 | Lisp_Object tmp; |
1396 | XSETTERMINAL (tmp, terminal); | |
1397 | ||
bedb9c0e | 1398 | kb = NULL; |
174105f7 | 1399 | Fdelete_terminal (tmp, NILP (force) ? Qt : force); |
bedb9c0e KL |
1400 | } |
1401 | else | |
6ed8eeff | 1402 | kb = terminal->kboard; |
428a555e | 1403 | } |
8678b9cc | 1404 | |
ff11dfa1 | 1405 | /* If we've deleted the last_nonminibuf_frame, then try to find |
d5e7c279 | 1406 | another one. */ |
ff11dfa1 | 1407 | if (f == last_nonminibuf_frame) |
d5e7c279 | 1408 | { |
5b04e9f9 | 1409 | Lisp_Object frames, this; |
1113d9db | 1410 | |
ff11dfa1 | 1411 | last_nonminibuf_frame = 0; |
d5e7c279 | 1412 | |
5b04e9f9 | 1413 | FOR_EACH_FRAME (frames, this) |
d5e7c279 | 1414 | { |
5b04e9f9 | 1415 | f = XFRAME (this); |
ff11dfa1 | 1416 | if (!FRAME_MINIBUF_ONLY_P (f)) |
d5e7c279 | 1417 | { |
ff11dfa1 | 1418 | last_nonminibuf_frame = f; |
d5e7c279 JB |
1419 | break; |
1420 | } | |
1421 | } | |
1422 | } | |
dc6f92b8 | 1423 | |
8ceb7434 RS |
1424 | /* If there's no other frame on the same kboard, get out of |
1425 | single-kboard state if we're in it for this kboard. */ | |
bedb9c0e KL |
1426 | if (kb != NULL) |
1427 | { | |
5b04e9f9 | 1428 | Lisp_Object frames, this; |
bedb9c0e | 1429 | /* Some frame we found on the same kboard, or nil if there are none. */ |
5b04e9f9 | 1430 | Lisp_Object frame_on_same_kboard = Qnil; |
8ceb7434 | 1431 | |
5b04e9f9 DA |
1432 | FOR_EACH_FRAME (frames, this) |
1433 | if (kb == FRAME_KBOARD (XFRAME (this))) | |
1434 | frame_on_same_kboard = this; | |
8ceb7434 | 1435 | |
bedb9c0e KL |
1436 | if (NILP (frame_on_same_kboard)) |
1437 | not_single_kboard_state (kb); | |
1438 | } | |
8ceb7434 RS |
1439 | |
1440 | ||
c4c6d073 KH |
1441 | /* If we've deleted this keyboard's default_minibuffer_frame, try to |
1442 | find another one. Prefer minibuffer-only frames, but also notice | |
1443 | frames with other windows. */ | |
1344aad4 | 1444 | if (kb != NULL && EQ (frame, KVAR (kb, Vdefault_minibuffer_frame))) |
1113d9db | 1445 | { |
5b04e9f9 | 1446 | Lisp_Object frames, this; |
1113d9db | 1447 | |
ff11dfa1 | 1448 | /* The last frame we saw with a minibuffer, minibuffer-only or not. */ |
5b04e9f9 | 1449 | Lisp_Object frame_with_minibuf = Qnil; |
32fda9ba | 1450 | /* Some frame we found on the same kboard, or nil if there are none. */ |
5b04e9f9 | 1451 | Lisp_Object frame_on_same_kboard = Qnil; |
32fda9ba | 1452 | |
5b04e9f9 | 1453 | FOR_EACH_FRAME (frames, this) |
1113d9db | 1454 | { |
5b04e9f9 | 1455 | struct frame *f1 = XFRAME (this); |
1113d9db | 1456 | |
c4c6d073 KH |
1457 | /* Consider only frames on the same kboard |
1458 | and only those with minibuffers. */ | |
bedb9c0e | 1459 | if (kb == FRAME_KBOARD (f1) |
c4c6d073 | 1460 | && FRAME_HAS_MINIBUF_P (f1)) |
1113d9db | 1461 | { |
ff11dfa1 | 1462 | frame_with_minibuf = this; |
c4c6d073 | 1463 | if (FRAME_MINIBUF_ONLY_P (f1)) |
1113d9db JB |
1464 | break; |
1465 | } | |
32fda9ba | 1466 | |
bedb9c0e | 1467 | if (kb == FRAME_KBOARD (f1)) |
32fda9ba | 1468 | frame_on_same_kboard = this; |
1113d9db JB |
1469 | } |
1470 | ||
32fda9ba RS |
1471 | if (!NILP (frame_on_same_kboard)) |
1472 | { | |
1473 | /* We know that there must be some frame with a minibuffer out | |
1474 | there. If this were not true, all of the frames present | |
1475 | would have to be minibufferless, which implies that at some | |
1476 | point their minibuffer frames must have been deleted, but | |
1477 | that is prohibited at the top; you can't delete surrogate | |
1478 | minibuffer frames. */ | |
1479 | if (NILP (frame_with_minibuf)) | |
1088b922 | 1480 | emacs_abort (); |
1113d9db | 1481 | |
15dbb4d6 | 1482 | kset_default_minibuffer_frame (kb, frame_with_minibuf); |
32fda9ba RS |
1483 | } |
1484 | else | |
1485 | /* No frames left on this kboard--say no minibuffer either. */ | |
15dbb4d6 | 1486 | kset_default_minibuffer_frame (kb, Qnil); |
1113d9db JB |
1487 | } |
1488 | ||
e681c92a | 1489 | /* Cause frame titles to update--necessary if we now have just one frame. */ |
cf5fc6db | 1490 | if (!is_tooltip_frame) |
2ec9db5d | 1491 | update_mode_lines = 15; |
e681c92a | 1492 | |
dc6f92b8 JB |
1493 | return Qnil; |
1494 | } | |
56f2de10 MR |
1495 | |
1496 | DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "", | |
1497 | doc: /* Delete FRAME, permanently eliminating it from use. | |
1498 | FRAME defaults to the selected frame. | |
1499 | ||
1500 | A frame may not be deleted if its minibuffer is used by other frames. | |
1501 | Normally, you may not delete a frame if all other frames are invisible, | |
1502 | but if the second optional argument FORCE is non-nil, you may do so. | |
1503 | ||
1504 | This function runs `delete-frame-functions' before actually | |
1505 | deleting the frame, unless the frame is a tooltip. | |
1506 | The functions are run with one argument, the frame to be deleted. */) | |
5842a27b | 1507 | (Lisp_Object frame, Lisp_Object force) |
56f2de10 MR |
1508 | { |
1509 | return delete_frame (frame, !NILP (force) ? Qt : Qnil); | |
1510 | } | |
1511 | ||
dc6f92b8 JB |
1512 | \f |
1513 | /* Return mouse position in character cell units. */ | |
1514 | ||
f9898cc6 | 1515 | DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0, |
14ff1ee0 PJ |
1516 | doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position. |
1517 | The position is given in character cells, where (0, 0) is the | |
d0cd961e EZ |
1518 | upper-left corner of the frame, X is the horizontal offset, and Y is |
1519 | the vertical offset. | |
14ff1ee0 PJ |
1520 | If Emacs is running on a mouseless terminal or hasn't been programmed |
1521 | to read the mouse position, it returns the selected frame for FRAME | |
1522 | and nil for X and Y. | |
1523 | If `mouse-position-function' is non-nil, `mouse-position' calls it, | |
1524 | passing the normal return value to that function as an argument, | |
1525 | and returns whatever that function returns. */) | |
5842a27b | 1526 | (void) |
dc6f92b8 | 1527 | { |
a10c8269 | 1528 | struct frame *f; |
dbc4e1c1 | 1529 | Lisp_Object lispy_dummy; |
beb0bc36 | 1530 | Lisp_Object x, y, retval; |
cb2255b3 | 1531 | struct gcpro gcpro1; |
dc6f92b8 | 1532 | |
8d2666fe | 1533 | f = SELECTED_FRAME (); |
c5074d8c RS |
1534 | x = y = Qnil; |
1535 | ||
1536 | /* It's okay for the hook to refrain from storing anything. */ | |
6ed8eeff | 1537 | if (FRAME_TERMINAL (f)->mouse_position_hook) |
4973679b PE |
1538 | { |
1539 | enum scroll_bar_part party_dummy; | |
1540 | Time time_dummy; | |
1541 | (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, -1, | |
1542 | &lispy_dummy, &party_dummy, | |
1543 | &x, &y, | |
1544 | &time_dummy); | |
1545 | } | |
1546 | ||
76db7eb4 KH |
1547 | if (! NILP (x)) |
1548 | { | |
4973679b PE |
1549 | int col = XINT (x); |
1550 | int row = XINT (y); | |
8126c3b4 | 1551 | pixel_to_glyph_coords (f, col, row, &col, &row, NULL, 1); |
76db7eb4 KH |
1552 | XSETINT (x, col); |
1553 | XSETINT (y, row); | |
1554 | } | |
2d80a27a | 1555 | XSETFRAME (lispy_dummy, f); |
beb0bc36 | 1556 | retval = Fcons (lispy_dummy, Fcons (x, y)); |
cb2255b3 | 1557 | GCPRO1 (retval); |
beb0bc36 | 1558 | if (!NILP (Vmouse_position_function)) |
cb2255b3 GM |
1559 | retval = call1 (Vmouse_position_function, retval); |
1560 | RETURN_UNGCPRO (retval); | |
dc6f92b8 JB |
1561 | } |
1562 | ||
152e6c70 RS |
1563 | DEFUN ("mouse-pixel-position", Fmouse_pixel_position, |
1564 | Smouse_pixel_position, 0, 0, 0, | |
14ff1ee0 PJ |
1565 | doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position. |
1566 | The position is given in pixel units, where (0, 0) is the | |
d0cd961e EZ |
1567 | upper-left corner of the frame, X is the horizontal offset, and Y is |
1568 | the vertical offset. | |
14ff1ee0 PJ |
1569 | If Emacs is running on a mouseless terminal or hasn't been programmed |
1570 | to read the mouse position, it returns the selected frame for FRAME | |
1571 | and nil for X and Y. */) | |
5842a27b | 1572 | (void) |
152e6c70 | 1573 | { |
a10c8269 | 1574 | struct frame *f; |
152e6c70 | 1575 | Lisp_Object lispy_dummy; |
152e6c70 | 1576 | Lisp_Object x, y; |
152e6c70 | 1577 | |
8d2666fe | 1578 | f = SELECTED_FRAME (); |
152e6c70 RS |
1579 | x = y = Qnil; |
1580 | ||
1581 | /* It's okay for the hook to refrain from storing anything. */ | |
6ed8eeff | 1582 | if (FRAME_TERMINAL (f)->mouse_position_hook) |
4973679b PE |
1583 | { |
1584 | enum scroll_bar_part party_dummy; | |
1585 | Time time_dummy; | |
1586 | (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, -1, | |
1587 | &lispy_dummy, &party_dummy, | |
1588 | &x, &y, | |
1589 | &time_dummy); | |
1590 | } | |
1591 | ||
2d80a27a | 1592 | XSETFRAME (lispy_dummy, f); |
152e6c70 RS |
1593 | return Fcons (lispy_dummy, Fcons (x, y)); |
1594 | } | |
1595 | ||
dc6f92b8 | 1596 | DEFUN ("set-mouse-position", Fset_mouse_position, Sset_mouse_position, 3, 3, 0, |
14ff1ee0 PJ |
1597 | doc: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME. |
1598 | Coordinates are relative to the frame, not a window, | |
1599 | so the coordinates of the top left character in the frame | |
1600 | may be nonzero due to left-hand scroll bars or the menu bar. | |
1601 | ||
d0cd961e EZ |
1602 | The position is given in character cells, where (0, 0) is the |
1603 | upper-left corner of the frame, X is the horizontal offset, and Y is | |
1604 | the vertical offset. | |
1605 | ||
14ff1ee0 PJ |
1606 | This function is a no-op for an X frame that is not visible. |
1607 | If you have just created a frame, you must wait for it to become visible | |
1608 | before calling this function on it, like this. | |
1609 | (while (not (frame-visible-p frame)) (sleep-for .5)) */) | |
5842a27b | 1610 | (Lisp_Object frame, Lisp_Object x, Lisp_Object y) |
dc6f92b8 | 1611 | { |
b7826503 | 1612 | CHECK_LIVE_FRAME (frame); |
d311d28c PE |
1613 | CHECK_TYPE_RANGED_INTEGER (int, x); |
1614 | CHECK_TYPE_RANGED_INTEGER (int, y); | |
dc6f92b8 | 1615 | |
dbc4e1c1 | 1616 | /* I think this should be done with a hook. */ |
032d78fe GV |
1617 | #ifdef HAVE_WINDOW_SYSTEM |
1618 | if (FRAME_WINDOW_P (XFRAME (frame))) | |
d19be8a9 | 1619 | /* Warping the mouse will cause enternotify and focus events. */ |
d4d76014 | 1620 | x_set_mouse_position (XFRAME (frame), XINT (x), XINT (y)); |
bb221971 | 1621 | #else |
bcd77a2b | 1622 | #if defined (MSDOS) |
bb221971 RS |
1623 | if (FRAME_MSDOS_P (XFRAME (frame))) |
1624 | { | |
216e6a14 | 1625 | Fselect_frame (frame, Qnil); |
bb221971 RS |
1626 | mouse_moveto (XINT (x), XINT (y)); |
1627 | } | |
4d1d51d2 NR |
1628 | #else |
1629 | #ifdef HAVE_GPM | |
1630 | { | |
216e6a14 | 1631 | Fselect_frame (frame, Qnil); |
4d1d51d2 NR |
1632 | term_mouse_moveto (XINT (x), XINT (y)); |
1633 | } | |
1634 | #endif | |
bb221971 | 1635 | #endif |
dc6f92b8 JB |
1636 | #endif |
1637 | ||
1638 | return Qnil; | |
1639 | } | |
152e6c70 RS |
1640 | |
1641 | DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position, | |
1642 | Sset_mouse_pixel_position, 3, 3, 0, | |
14ff1ee0 | 1643 | doc: /* Move the mouse pointer to pixel position (X,Y) in FRAME. |
d0cd961e EZ |
1644 | The position is given in pixels, where (0, 0) is the upper-left corner |
1645 | of the frame, X is the horizontal offset, and Y is the vertical offset. | |
1646 | ||
14ff1ee0 PJ |
1647 | Note, this is a no-op for an X frame that is not visible. |
1648 | If you have just created a frame, you must wait for it to become visible | |
1649 | before calling this function on it, like this. | |
1650 | (while (not (frame-visible-p frame)) (sleep-for .5)) */) | |
5842a27b | 1651 | (Lisp_Object frame, Lisp_Object x, Lisp_Object y) |
152e6c70 | 1652 | { |
b7826503 | 1653 | CHECK_LIVE_FRAME (frame); |
d311d28c PE |
1654 | CHECK_TYPE_RANGED_INTEGER (int, x); |
1655 | CHECK_TYPE_RANGED_INTEGER (int, y); | |
152e6c70 RS |
1656 | |
1657 | /* I think this should be done with a hook. */ | |
032d78fe GV |
1658 | #ifdef HAVE_WINDOW_SYSTEM |
1659 | if (FRAME_WINDOW_P (XFRAME (frame))) | |
d19be8a9 | 1660 | /* Warping the mouse will cause enternotify and focus events. */ |
d4d76014 | 1661 | x_set_mouse_pixel_position (XFRAME (frame), XINT (x), XINT (y)); |
bb221971 | 1662 | #else |
bcd77a2b | 1663 | #if defined (MSDOS) |
bb221971 RS |
1664 | if (FRAME_MSDOS_P (XFRAME (frame))) |
1665 | { | |
216e6a14 | 1666 | Fselect_frame (frame, Qnil); |
bb221971 RS |
1667 | mouse_moveto (XINT (x), XINT (y)); |
1668 | } | |
67f6e31c NR |
1669 | #else |
1670 | #ifdef HAVE_GPM | |
1671 | { | |
216e6a14 | 1672 | Fselect_frame (frame, Qnil); |
67f6e31c NR |
1673 | term_mouse_moveto (XINT (x), XINT (y)); |
1674 | } | |
1675 | #endif | |
bb221971 | 1676 | #endif |
152e6c70 RS |
1677 | #endif |
1678 | ||
1679 | return Qnil; | |
1680 | } | |
dc6f92b8 | 1681 | \f |
f57e2426 | 1682 | static void make_frame_visible_1 (Lisp_Object); |
98ce1622 | 1683 | |
a7ca3326 | 1684 | DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible, |
fc25d15d | 1685 | 0, 1, "", |
14ff1ee0 PJ |
1686 | doc: /* Make the frame FRAME visible (assuming it is an X window). |
1687 | If omitted, FRAME defaults to the currently selected frame. */) | |
5842a27b | 1688 | (Lisp_Object frame) |
dc6f92b8 | 1689 | { |
d9f07150 | 1690 | struct frame *f = decode_live_frame (frame); |
dc6f92b8 | 1691 | |
dbc4e1c1 | 1692 | /* I think this should be done with a hook. */ |
032d78fe | 1693 | #ifdef HAVE_WINDOW_SYSTEM |
d9f07150 | 1694 | if (FRAME_WINDOW_P (f)) |
edfa7fa0 | 1695 | x_make_frame_visible (f); |
fd0c2bd1 | 1696 | #endif |
dc6f92b8 | 1697 | |
d9f07150 | 1698 | make_frame_visible_1 (f->root_window); |
98ce1622 | 1699 | |
d19be8a9 | 1700 | /* Make menu bar update for the Buffers and Frames menus. */ |
655ab9a3 | 1701 | /* windows_or_buffers_changed = 15; FIXME: Why? */ |
565620a5 | 1702 | |
d9f07150 | 1703 | XSETFRAME (frame, f); |
ff11dfa1 | 1704 | return frame; |
dc6f92b8 JB |
1705 | } |
1706 | ||
98ce1622 | 1707 | /* Update the display_time slot of the buffers shown in WINDOW |
cd1181db | 1708 | and all its descendants. */ |
98ce1622 RS |
1709 | |
1710 | static void | |
971de7fb | 1711 | make_frame_visible_1 (Lisp_Object window) |
98ce1622 RS |
1712 | { |
1713 | struct window *w; | |
1714 | ||
e74aeda8 | 1715 | for (; !NILP (window); window = w->next) |
98ce1622 RS |
1716 | { |
1717 | w = XWINDOW (window); | |
e74aeda8 DA |
1718 | if (WINDOWP (w->contents)) |
1719 | make_frame_visible_1 (w->contents); | |
1720 | else | |
1721 | bset_display_time (XBUFFER (w->contents), Fcurrent_time ()); | |
98ce1622 RS |
1722 | } |
1723 | } | |
1724 | ||
ff11dfa1 | 1725 | DEFUN ("make-frame-invisible", Fmake_frame_invisible, Smake_frame_invisible, |
808c0f20 | 1726 | 0, 2, "", |
c38eb027 | 1727 | doc: /* Make the frame FRAME invisible. |
14ff1ee0 | 1728 | If omitted, FRAME defaults to the currently selected frame. |
c38eb027 CY |
1729 | On graphical displays, invisible frames are not updated and are |
1730 | usually not displayed at all, even in a window system's \"taskbar\". | |
1731 | ||
14ff1ee0 | 1732 | Normally you may not make FRAME invisible if all other frames are invisible, |
c38eb027 CY |
1733 | but if the second optional argument FORCE is non-nil, you may do so. |
1734 | ||
c6bf3022 CY |
1735 | This function has no effect on text terminal frames. Such frames are |
1736 | always considered visible, whether or not they are currently being | |
c38eb027 | 1737 | displayed in the terminal. */) |
5842a27b | 1738 | (Lisp_Object frame, Lisp_Object force) |
dc6f92b8 | 1739 | { |
d9f07150 | 1740 | struct frame *f = decode_live_frame (frame); |
1aa66088 | 1741 | |
d9f07150 | 1742 | if (NILP (force) && !other_visible_frames (f)) |
808c0f20 RS |
1743 | error ("Attempt to make invisible the sole visible or iconified frame"); |
1744 | ||
bfff6445 MR |
1745 | /* Don't allow minibuf_window to remain on an invisible frame. */ |
1746 | check_minibuf_window (frame, EQ (minibuf_window, selected_window)); | |
9c394f17 | 1747 | |
dbc4e1c1 | 1748 | /* I think this should be done with a hook. */ |
032d78fe | 1749 | #ifdef HAVE_WINDOW_SYSTEM |
d9f07150 DA |
1750 | if (FRAME_WINDOW_P (f)) |
1751 | x_make_frame_invisible (f); | |
fd0c2bd1 | 1752 | #endif |
dc6f92b8 | 1753 | |
d19be8a9 | 1754 | /* Make menu bar update for the Buffers and Frames menus. */ |
94ae2ad4 | 1755 | windows_or_buffers_changed = 16; |
565620a5 | 1756 | |
dc6f92b8 JB |
1757 | return Qnil; |
1758 | } | |
1759 | ||
a7ca3326 | 1760 | DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame, |
1aa66088 | 1761 | 0, 1, "", |
14ff1ee0 PJ |
1762 | doc: /* Make the frame FRAME into an icon. |
1763 | If omitted, FRAME defaults to the currently selected frame. */) | |
5842a27b | 1764 | (Lisp_Object frame) |
dc6f92b8 | 1765 | { |
d9f07150 | 1766 | struct frame *f = decode_live_frame (frame); |
9c394f17 | 1767 | |
08908aca | 1768 | /* Don't allow minibuf_window to remain on an iconified frame. */ |
bfff6445 | 1769 | check_minibuf_window (frame, EQ (minibuf_window, selected_window)); |
9c394f17 | 1770 | |
dbc4e1c1 | 1771 | /* I think this should be done with a hook. */ |
032d78fe | 1772 | #ifdef HAVE_WINDOW_SYSTEM |
d9f07150 DA |
1773 | if (FRAME_WINDOW_P (f)) |
1774 | x_iconify_frame (f); | |
fd0c2bd1 | 1775 | #endif |
dc6f92b8 | 1776 | |
d19be8a9 | 1777 | /* Make menu bar update for the Buffers and Frames menus. */ |
94ae2ad4 | 1778 | windows_or_buffers_changed = 17; |
565620a5 | 1779 | |
dc6f92b8 JB |
1780 | return Qnil; |
1781 | } | |
1782 | ||
ff11dfa1 | 1783 | DEFUN ("frame-visible-p", Fframe_visible_p, Sframe_visible_p, |
dc6f92b8 | 1784 | 1, 1, 0, |
c38eb027 CY |
1785 | doc: /* Return t if FRAME is \"visible\" (actually in use for display). |
1786 | Return the symbol `icon' if FRAME is iconified or \"minimized\". | |
1787 | Return nil if FRAME was made invisible, via `make-frame-invisible'. | |
1788 | On graphical displays, invisible frames are not updated and are | |
1789 | usually not displayed at all, even in a window system's \"taskbar\". | |
1790 | ||
c6bf3022 | 1791 | If FRAME is a text terminal frame, this always returns t. |
c38eb027 CY |
1792 | Such frames are always considered visible, whether or not they are |
1793 | currently being displayed on the terminal. */) | |
5842a27b | 1794 | (Lisp_Object frame) |
dc6f92b8 | 1795 | { |
b7826503 | 1796 | CHECK_LIVE_FRAME (frame); |
dc6f92b8 | 1797 | |
a42e9724 | 1798 | if (FRAME_VISIBLE_P (XFRAME (frame))) |
dc6f92b8 | 1799 | return Qt; |
a42e9724 | 1800 | if (FRAME_ICONIFIED_P (XFRAME (frame))) |
fd0c2bd1 | 1801 | return Qicon; |
dc6f92b8 JB |
1802 | return Qnil; |
1803 | } | |
1804 | ||
ff11dfa1 | 1805 | DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list, |
dc6f92b8 | 1806 | 0, 0, 0, |
14ff1ee0 | 1807 | doc: /* Return a list of all frames now \"visible\" (being updated). */) |
5842a27b | 1808 | (void) |
dc6f92b8 | 1809 | { |
5b04e9f9 DA |
1810 | Lisp_Object tail, frame, value = Qnil; |
1811 | ||
1812 | FOR_EACH_FRAME (tail, frame) | |
1813 | if (FRAME_VISIBLE_P (XFRAME (frame))) | |
1814 | value = Fcons (frame, value); | |
dc6f92b8 | 1815 | |
dc6f92b8 JB |
1816 | return value; |
1817 | } | |
d5e7c279 JB |
1818 | |
1819 | ||
a7ca3326 | 1820 | DEFUN ("raise-frame", Fraise_frame, Sraise_frame, 0, 1, "", |
14ff1ee0 | 1821 | doc: /* Bring FRAME to the front, so it occludes any frames it overlaps. |
e4ed805e | 1822 | If FRAME is invisible or iconified, make it visible. |
14ff1ee0 PJ |
1823 | If you don't specify a frame, the selected frame is used. |
1824 | If Emacs is displaying on an ordinary terminal or some other device which | |
1bf72735 | 1825 | doesn't support multiple overlapping frames, this function selects FRAME. */) |
5842a27b | 1826 | (Lisp_Object frame) |
dbc4e1c1 | 1827 | { |
d9f07150 | 1828 | struct frame *f = decode_live_frame (frame); |
828ac693 | 1829 | |
d9f07150 | 1830 | XSETFRAME (frame, f); |
a3547743 | 1831 | |
1bf72735 | 1832 | if (FRAME_TERMCAP_P (f)) |
c6bf3022 | 1833 | /* On a text terminal select FRAME. */ |
216e6a14 | 1834 | Fselect_frame (frame, Qnil); |
1bf72735 MR |
1835 | else |
1836 | /* Do like the documentation says. */ | |
1837 | Fmake_frame_visible (frame); | |
8a981af5 | 1838 | |
6ed8eeff KL |
1839 | if (FRAME_TERMINAL (f)->frame_raise_lower_hook) |
1840 | (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 1); | |
dbc4e1c1 JB |
1841 | |
1842 | return Qnil; | |
1843 | } | |
1844 | ||
b49f5578 | 1845 | /* Should we have a corresponding function called Flower_Power? */ |
e518d5e1 | 1846 | DEFUN ("lower-frame", Flower_frame, Slower_frame, 0, 1, "", |
14ff1ee0 PJ |
1847 | doc: /* Send FRAME to the back, so it is occluded by any frames that overlap it. |
1848 | If you don't specify a frame, the selected frame is used. | |
1849 | If Emacs is displaying on an ordinary terminal or some other device which | |
1850 | doesn't support multiple overlapping frames, this function does nothing. */) | |
5842a27b | 1851 | (Lisp_Object frame) |
dbc4e1c1 | 1852 | { |
d9f07150 | 1853 | struct frame *f = decode_live_frame (frame); |
a3547743 | 1854 | |
6ed8eeff KL |
1855 | if (FRAME_TERMINAL (f)->frame_raise_lower_hook) |
1856 | (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 0); | |
dbc4e1c1 JB |
1857 | |
1858 | return Qnil; | |
1859 | } | |
1860 | ||
d5e7c279 | 1861 | \f |
a7ca3326 | 1862 | DEFUN ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus, |
d5e7c279 | 1863 | 1, 2, 0, |
14ff1ee0 PJ |
1864 | doc: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME. |
1865 | In other words, switch-frame events caused by events in FRAME will | |
1866 | request a switch to FOCUS-FRAME, and `last-event-frame' will be | |
1867 | FOCUS-FRAME after reading an event typed at FRAME. | |
1868 | ||
8137e7b3 MR |
1869 | If FOCUS-FRAME is nil, any existing redirection is canceled, and the |
1870 | frame again receives its own keystrokes. | |
14ff1ee0 PJ |
1871 | |
1872 | Focus redirection is useful for temporarily redirecting keystrokes to | |
1873 | a surrogate minibuffer frame when a frame doesn't have its own | |
1874 | minibuffer window. | |
1875 | ||
66a9dbbe | 1876 | A frame's focus redirection can be changed by `select-frame'. If frame |
14ff1ee0 PJ |
1877 | FOO is selected, and then a different frame BAR is selected, any |
1878 | frames redirecting their focus to FOO are shifted to redirect their | |
1879 | focus to BAR. This allows focus redirection to work properly when the | |
1880 | user switches from one frame to another using `select-window'. | |
1881 | ||
1882 | This means that a frame whose focus is redirected to itself is treated | |
1883 | differently from a frame whose focus is redirected to nil; the former | |
66a9dbbe | 1884 | is affected by `select-frame', while the latter is not. |
14ff1ee0 PJ |
1885 | |
1886 | The redirection lasts until `redirect-frame-focus' is called to change it. */) | |
5842a27b | 1887 | (Lisp_Object frame, Lisp_Object focus_frame) |
d5e7c279 | 1888 | { |
13144095 JB |
1889 | /* Note that we don't check for a live frame here. It's reasonable |
1890 | to redirect the focus of a frame you're about to delete, if you | |
1891 | know what other frame should receive those keystrokes. */ | |
d9f07150 | 1892 | struct frame *f = decode_any_frame (frame); |
f9898cc6 | 1893 | |
a42e9724 | 1894 | if (! NILP (focus_frame)) |
b7826503 | 1895 | CHECK_LIVE_FRAME (focus_frame); |
d5e7c279 | 1896 | |
f00af5b1 | 1897 | fset_focus_frame (f, focus_frame); |
d5e7c279 | 1898 | |
6ed8eeff KL |
1899 | if (FRAME_TERMINAL (f)->frame_rehighlight_hook) |
1900 | (*FRAME_TERMINAL (f)->frame_rehighlight_hook) (f); | |
177c0ea7 | 1901 | |
d5e7c279 JB |
1902 | return Qnil; |
1903 | } | |
1904 | ||
1905 | ||
d9f07150 | 1906 | DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 0, 1, 0, |
14ff1ee0 | 1907 | doc: /* Return the frame to which FRAME's keystrokes are currently being sent. |
d9f07150 DA |
1908 | If FRAME is omitted or nil, the selected frame is used. |
1909 | Return nil if FRAME's focus is not redirected. | |
14ff1ee0 | 1910 | See `redirect-frame-focus'. */) |
5842a27b | 1911 | (Lisp_Object frame) |
d5e7c279 | 1912 | { |
d9f07150 | 1913 | return FRAME_FOCUS_FRAME (decode_live_frame (frame)); |
d5e7c279 JB |
1914 | } |
1915 | ||
fcd42c11 DA |
1916 | DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0, |
1917 | doc: /* Set the input focus to FRAME. | |
97fc2468 DA |
1918 | FRAME nil means use the selected frame. |
1919 | If there is no window system support, this function does nothing. */) | |
fcd42c11 DA |
1920 | (Lisp_Object frame) |
1921 | { | |
97fc2468 | 1922 | #ifdef HAVE_WINDOW_SYSTEM |
fcd42c11 | 1923 | x_focus_frame (decode_window_system_frame (frame)); |
97fc2468 | 1924 | #endif |
fcd42c11 DA |
1925 | return Qnil; |
1926 | } | |
d5e7c279 | 1927 | |
dc6f92b8 | 1928 | \f |
329ca574 RS |
1929 | /* Return the value of frame parameter PROP in frame FRAME. */ |
1930 | ||
298819b9 | 1931 | #ifdef HAVE_WINDOW_SYSTEM |
336fe071 | 1932 | #if !HAVE_NS && !HAVE_NTGUI |
81626931 PE |
1933 | static |
1934 | #endif | |
dc6f92b8 | 1935 | Lisp_Object |
971de7fb | 1936 | get_frame_param (register struct frame *frame, Lisp_Object prop) |
dc6f92b8 JB |
1937 | { |
1938 | register Lisp_Object tem; | |
1939 | ||
e69b0960 | 1940 | tem = Fassq (prop, frame->param_alist); |
dc6f92b8 JB |
1941 | if (EQ (tem, Qnil)) |
1942 | return tem; | |
1943 | return Fcdr (tem); | |
1944 | } | |
298819b9 | 1945 | #endif |
dc6f92b8 | 1946 | |
a18b8cb5 | 1947 | /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */ |
fa54c6ae RS |
1948 | |
1949 | void | |
971de7fb | 1950 | frames_discard_buffer (Lisp_Object buffer) |
fa54c6ae RS |
1951 | { |
1952 | Lisp_Object frame, tail; | |
1953 | ||
1954 | FOR_EACH_FRAME (tail, frame) | |
1955 | { | |
f00af5b1 PE |
1956 | fset_buffer_list |
1957 | (XFRAME (frame), Fdelq (buffer, XFRAME (frame)->buffer_list)); | |
1958 | fset_buried_buffer_list | |
1959 | (XFRAME (frame), Fdelq (buffer, XFRAME (frame)->buried_buffer_list)); | |
fa54c6ae RS |
1960 | } |
1961 | } | |
1962 | ||
329ca574 RS |
1963 | /* Modify the alist in *ALISTPTR to associate PROP with VAL. |
1964 | If the alist already has an element for PROP, we change it. */ | |
1965 | ||
dc6f92b8 | 1966 | void |
971de7fb | 1967 | store_in_alist (Lisp_Object *alistptr, Lisp_Object prop, Lisp_Object val) |
dc6f92b8 JB |
1968 | { |
1969 | register Lisp_Object tem; | |
dc6f92b8 | 1970 | |
dc6f92b8 JB |
1971 | tem = Fassq (prop, *alistptr); |
1972 | if (EQ (tem, Qnil)) | |
1973 | *alistptr = Fcons (Fcons (prop, val), *alistptr); | |
1974 | else | |
1975 | Fsetcdr (tem, val); | |
1976 | } | |
1977 | ||
e5317d61 | 1978 | static int |
d311d28c | 1979 | frame_name_fnn_p (char *str, ptrdiff_t len) |
e5317d61 | 1980 | { |
5e073ec7 | 1981 | if (len > 1 && str[0] == 'F' && '0' <= str[1] && str[1] <= '9') |
e5317d61 | 1982 | { |
5e073ec7 PE |
1983 | char *p = str + 2; |
1984 | while ('0' <= *p && *p <= '9') | |
1985 | p++; | |
1986 | if (p == str + len) | |
e5317d61 EZ |
1987 | return 1; |
1988 | } | |
1989 | return 0; | |
1990 | } | |
1991 | ||
1992 | /* Set the name of the terminal frame. Also used by MSDOS frames. | |
1993 | Modeled after x_set_name which is used for WINDOW frames. */ | |
1994 | ||
66a9dbbe | 1995 | static void |
971de7fb | 1996 | set_term_frame_name (struct frame *f, Lisp_Object name) |
e5317d61 EZ |
1997 | { |
1998 | f->explicit_name = ! NILP (name); | |
1999 | ||
2000 | /* If NAME is nil, set the name to F<num>. */ | |
2001 | if (NILP (name)) | |
2002 | { | |
8a401434 | 2003 | char namebuf[sizeof "F" + INT_STRLEN_BOUND (printmax_t)]; |
e5317d61 EZ |
2004 | |
2005 | /* Check for no change needed in this very common case | |
2006 | before we do any consing. */ | |
e69b0960 | 2007 | if (frame_name_fnn_p (SSDATA (f->name), SBYTES (f->name))) |
e5317d61 EZ |
2008 | return; |
2009 | ||
a8290ec3 | 2010 | name = make_formatted_string (namebuf, "F%"pMd, ++tty_frame_count); |
e5317d61 EZ |
2011 | } |
2012 | else | |
2013 | { | |
b7826503 | 2014 | CHECK_STRING (name); |
e5317d61 EZ |
2015 | |
2016 | /* Don't change the name if it's already NAME. */ | |
e69b0960 | 2017 | if (! NILP (Fstring_equal (name, f->name))) |
e5317d61 EZ |
2018 | return; |
2019 | ||
2020 | /* Don't allow the user to set the frame name to F<num>, so it | |
2021 | doesn't clash with the names we generate for terminal frames. */ | |
42a5b22f | 2022 | if (frame_name_fnn_p (SSDATA (name), SBYTES (name))) |
e5317d61 EZ |
2023 | error ("Frame names of the form F<num> are usurped by Emacs"); |
2024 | } | |
2025 | ||
f00af5b1 | 2026 | fset_name (f, name); |
2ec9db5d | 2027 | update_mode_lines = 16; |
e5317d61 EZ |
2028 | } |
2029 | ||
75b09539 | 2030 | #ifdef HAVE_NTGUI |
880e6158 MR |
2031 | void |
2032 | set_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) | |
2033 | { | |
2034 | register Lisp_Object old_alist_elt; | |
2035 | ||
2036 | old_alist_elt = Fassq (prop, f->param_alist); | |
2037 | if (EQ (old_alist_elt, Qnil)) | |
2038 | fset_param_alist (f, Fcons (Fcons (prop, val), f->param_alist)); | |
2039 | else | |
2040 | Fsetcdr (old_alist_elt, val); | |
2041 | } | |
75b09539 | 2042 | #endif |
880e6158 | 2043 | |
dc6f92b8 | 2044 | void |
971de7fb | 2045 | store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) |
dc6f92b8 | 2046 | { |
7eb63b72 | 2047 | register Lisp_Object old_alist_elt; |
dc6f92b8 | 2048 | |
a18b8cb5 | 2049 | /* The buffer-list parameters are stored in a special place and not |
52eb77a6 | 2050 | in the alist. All buffers must be live. */ |
fa54c6ae RS |
2051 | if (EQ (prop, Qbuffer_list)) |
2052 | { | |
52eb77a6 CY |
2053 | Lisp_Object list = Qnil; |
2054 | for (; CONSP (val); val = XCDR (val)) | |
2055 | if (!NILP (Fbuffer_live_p (XCAR (val)))) | |
2056 | list = Fcons (XCAR (val), list); | |
f00af5b1 | 2057 | fset_buffer_list (f, Fnreverse (list)); |
fa54c6ae RS |
2058 | return; |
2059 | } | |
a18b8cb5 KL |
2060 | if (EQ (prop, Qburied_buffer_list)) |
2061 | { | |
52eb77a6 CY |
2062 | Lisp_Object list = Qnil; |
2063 | for (; CONSP (val); val = XCDR (val)) | |
2064 | if (!NILP (Fbuffer_live_p (XCAR (val)))) | |
2065 | list = Fcons (XCAR (val), list); | |
f00af5b1 | 2066 | fset_buried_buffer_list (f, Fnreverse (list)); |
a18b8cb5 KL |
2067 | return; |
2068 | } | |
fa54c6ae | 2069 | |
7eb63b72 GM |
2070 | /* If PROP is a symbol which is supposed to have frame-local values, |
2071 | and it is set up based on this frame, switch to the global | |
2072 | binding. That way, we can create or alter the frame-local binding | |
2073 | without messing up the symbol's status. */ | |
2074 | if (SYMBOLP (prop)) | |
2075 | { | |
ce5b453a SM |
2076 | struct Lisp_Symbol *sym = XSYMBOL (prop); |
2077 | start: | |
2078 | switch (sym->redirect) | |
2079 | { | |
2080 | case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; | |
2081 | case SYMBOL_PLAINVAL: case SYMBOL_FORWARDED: break; | |
2082 | case SYMBOL_LOCALIZED: | |
2083 | { struct Lisp_Buffer_Local_Value *blv = sym->val.blv; | |
a04e2c62 | 2084 | if (blv->frame_local && blv_found (blv) && XFRAME (blv->where) == f) |
ce5b453a SM |
2085 | swap_in_global_binding (sym); |
2086 | break; | |
2087 | } | |
1088b922 | 2088 | default: emacs_abort (); |
ce5b453a | 2089 | } |
7eb63b72 GM |
2090 | } |
2091 | ||
9b2cd403 SM |
2092 | /* The tty color needed to be set before the frame's parameter |
2093 | alist was updated with the new value. This is not true any more, | |
2094 | but we still do this test early on. */ | |
2095 | if (FRAME_TERMCAP_P (f) && EQ (prop, Qtty_color_mode) | |
2096 | && f == FRAME_TTY (f)->previous_frame) | |
2097 | /* Force redisplay of this tty. */ | |
2098 | FRAME_TTY (f)->previous_frame = NULL; | |
94674d18 | 2099 | |
7eb63b72 | 2100 | /* Update the frame parameter alist. */ |
e69b0960 | 2101 | old_alist_elt = Fassq (prop, f->param_alist); |
7eb63b72 | 2102 | if (EQ (old_alist_elt, Qnil)) |
f00af5b1 | 2103 | fset_param_alist (f, Fcons (Fcons (prop, val), f->param_alist)); |
dc6f92b8 | 2104 | else |
7eb63b72 | 2105 | Fsetcdr (old_alist_elt, val); |
bc93c097 | 2106 | |
7eb63b72 GM |
2107 | /* Update some other special parameters in their special places |
2108 | in addition to the alist. */ | |
177c0ea7 | 2109 | |
329ca574 | 2110 | if (EQ (prop, Qbuffer_predicate)) |
f00af5b1 | 2111 | fset_buffer_predicate (f, val); |
329ca574 | 2112 | |
032d78fe | 2113 | if (! FRAME_WINDOW_P (f)) |
e5317d61 EZ |
2114 | { |
2115 | if (EQ (prop, Qmenu_bar_lines)) | |
2116 | set_menu_bar_lines (f, val, make_number (FRAME_MENU_BAR_LINES (f))); | |
2117 | else if (EQ (prop, Qname)) | |
2118 | set_term_frame_name (f, val); | |
2119 | } | |
a249de79 | 2120 | |
e35d291d | 2121 | if (EQ (prop, Qminibuffer) && WINDOWP (val)) |
bc93c097 JB |
2122 | { |
2123 | if (! MINI_WINDOW_P (XWINDOW (val))) | |
6b61353c | 2124 | error ("Surrogate minibuffer windows must be minibuffer windows"); |
bc93c097 | 2125 | |
213bac8a | 2126 | if ((FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f)) |
e69b0960 | 2127 | && !EQ (val, f->minibuffer_window)) |
7af7ef38 | 2128 | error ("Can't change the surrogate minibuffer of a frame with its own minibuffer"); |
bc93c097 JB |
2129 | |
2130 | /* Install the chosen minibuffer window, with proper buffer. */ | |
f00af5b1 | 2131 | fset_minibuffer_window (f, val); |
bc93c097 | 2132 | } |
dc6f92b8 JB |
2133 | } |
2134 | ||
ff11dfa1 | 2135 | DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0, |
14ff1ee0 PJ |
2136 | doc: /* Return the parameters-alist of frame FRAME. |
2137 | It is a list of elements of the form (PARM . VALUE), where PARM is a symbol. | |
2138 | The meaningful PARMs depend on the kind of frame. | |
d9f07150 | 2139 | If FRAME is omitted or nil, return information on the currently selected frame. */) |
5842a27b | 2140 | (Lisp_Object frame) |
dc6f92b8 JB |
2141 | { |
2142 | Lisp_Object alist; | |
d9f07150 | 2143 | struct frame *f = decode_any_frame (frame); |
dd10ec4f | 2144 | int height, width; |
57629833 | 2145 | struct gcpro gcpro1; |
dc6f92b8 | 2146 | |
f769f1b2 | 2147 | if (!FRAME_LIVE_P (f)) |
dc6f92b8 JB |
2148 | return Qnil; |
2149 | ||
e69b0960 | 2150 | alist = Fcopy_alist (f->param_alist); |
57629833 | 2151 | GCPRO1 (alist); |
177c0ea7 | 2152 | |
2d764c78 | 2153 | if (!FRAME_WINDOW_P (f)) |
bb221971 | 2154 | { |
4aec4b29 EZ |
2155 | int fg = FRAME_FOREGROUND_PIXEL (f); |
2156 | int bg = FRAME_BACKGROUND_PIXEL (f); | |
e1d0bbc9 EZ |
2157 | Lisp_Object elt; |
2158 | ||
2159 | /* If the frame's parameter alist says the colors are | |
2160 | unspecified and reversed, take the frame's background pixel | |
2161 | for foreground and vice versa. */ | |
2162 | elt = Fassq (Qforeground_color, alist); | |
19b5e79b | 2163 | if (CONSP (elt) && STRINGP (XCDR (elt))) |
70de9f06 | 2164 | { |
42a5b22f | 2165 | if (strncmp (SSDATA (XCDR (elt)), |
70de9f06 | 2166 | unspecified_bg, |
d5db4077 | 2167 | SCHARS (XCDR (elt))) == 0) |
70de9f06 | 2168 | store_in_alist (&alist, Qforeground_color, tty_color_name (f, bg)); |
42a5b22f | 2169 | else if (strncmp (SSDATA (XCDR (elt)), |
70de9f06 | 2170 | unspecified_fg, |
d5db4077 | 2171 | SCHARS (XCDR (elt))) == 0) |
70de9f06 EZ |
2172 | store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg)); |
2173 | } | |
e1d0bbc9 EZ |
2174 | else |
2175 | store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg)); | |
2176 | elt = Fassq (Qbackground_color, alist); | |
19b5e79b | 2177 | if (CONSP (elt) && STRINGP (XCDR (elt))) |
70de9f06 | 2178 | { |
42a5b22f | 2179 | if (strncmp (SSDATA (XCDR (elt)), |
70de9f06 | 2180 | unspecified_fg, |
d5db4077 | 2181 | SCHARS (XCDR (elt))) == 0) |
70de9f06 | 2182 | store_in_alist (&alist, Qbackground_color, tty_color_name (f, fg)); |
42a5b22f | 2183 | else if (strncmp (SSDATA (XCDR (elt)), |
70de9f06 | 2184 | unspecified_bg, |
d5db4077 | 2185 | SCHARS (XCDR (elt))) == 0) |
70de9f06 EZ |
2186 | store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg)); |
2187 | } | |
e1d0bbc9 EZ |
2188 | else |
2189 | store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg)); | |
2d764c78 EZ |
2190 | store_in_alist (&alist, intern ("font"), |
2191 | build_string (FRAME_MSDOS_P (f) | |
2192 | ? "ms-dos" | |
4ec0d3c1 | 2193 | : FRAME_W32_P (f) ? "w32term" |
4ec0d3c1 | 2194 | :"tty")); |
bb221971 | 2195 | } |
e69b0960 | 2196 | store_in_alist (&alist, Qname, f->name); |
880e6158 MR |
2197 | height = (f->new_height |
2198 | ? (f->new_pixelwise | |
2199 | ? (f->new_height / FRAME_LINE_HEIGHT (f)) | |
2200 | : f->new_height) | |
2201 | : FRAME_LINES (f)); | |
dd10ec4f | 2202 | store_in_alist (&alist, Qheight, make_number (height)); |
880e6158 MR |
2203 | width = (f->new_width |
2204 | ? (f->new_pixelwise | |
2205 | ? (f->new_width / FRAME_COLUMN_WIDTH (f)) | |
2206 | : f->new_width) | |
2207 | : FRAME_COLS (f)); | |
dd10ec4f | 2208 | store_in_alist (&alist, Qwidth, make_number (width)); |
f769f1b2 | 2209 | store_in_alist (&alist, Qmodeline, (FRAME_WANTS_MODELINE_P (f) ? Qt : Qnil)); |
fd0c2bd1 | 2210 | store_in_alist (&alist, Qminibuffer, |
39acc701 | 2211 | (! FRAME_HAS_MINIBUF_P (f) ? Qnil |
f769f1b2 KH |
2212 | : FRAME_MINIBUF_ONLY_P (f) ? Qonly |
2213 | : FRAME_MINIBUF_WINDOW (f))); | |
2214 | store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil)); | |
d9f07150 DA |
2215 | store_in_alist (&alist, Qbuffer_list, f->buffer_list); |
2216 | store_in_alist (&alist, Qburied_buffer_list, f->buried_buffer_list); | |
fd0c2bd1 | 2217 | |
dbc4e1c1 | 2218 | /* I think this should be done with a hook. */ |
032d78fe GV |
2219 | #ifdef HAVE_WINDOW_SYSTEM |
2220 | if (FRAME_WINDOW_P (f)) | |
ff11dfa1 | 2221 | x_report_frame_params (f, &alist); |
b6dd20ed | 2222 | else |
fd0c2bd1 | 2223 | #endif |
16a3738c KH |
2224 | { |
2225 | /* This ought to be correct in f->param_alist for an X frame. */ | |
2226 | Lisp_Object lines; | |
f4e93c40 | 2227 | XSETFASTINT (lines, FRAME_MENU_BAR_LINES (f)); |
16a3738c KH |
2228 | store_in_alist (&alist, Qmenu_bar_lines, lines); |
2229 | } | |
57629833 GM |
2230 | |
2231 | UNGCPRO; | |
dc6f92b8 JB |
2232 | return alist; |
2233 | } | |
2234 | ||
8b60f7bc | 2235 | |
a7ca3326 | 2236 | DEFUN ("frame-parameter", Fframe_parameter, Sframe_parameter, 2, 2, 0, |
14ff1ee0 PJ |
2237 | doc: /* Return FRAME's value for parameter PARAMETER. |
2238 | If FRAME is nil, describe the currently selected frame. */) | |
5842a27b | 2239 | (Lisp_Object frame, Lisp_Object parameter) |
8b60f7bc | 2240 | { |
d9f07150 DA |
2241 | struct frame *f = decode_any_frame (frame); |
2242 | Lisp_Object value = Qnil; | |
8b60f7bc | 2243 | |
b7826503 | 2244 | CHECK_SYMBOL (parameter); |
177c0ea7 | 2245 | |
d9f07150 | 2246 | XSETFRAME (frame, f); |
177c0ea7 | 2247 | |
8b60f7bc GM |
2248 | if (FRAME_LIVE_P (f)) |
2249 | { | |
5cd62b8c | 2250 | /* Avoid consing in frequent cases. */ |
67d853e6 | 2251 | if (EQ (parameter, Qname)) |
e69b0960 | 2252 | value = f->name; |
6345f6aa GM |
2253 | #ifdef HAVE_X_WINDOWS |
2254 | else if (EQ (parameter, Qdisplay) && FRAME_X_P (f)) | |
aad3612f | 2255 | value = XCAR (FRAME_DISPLAY_INFO (f)->name_list_element); |
6345f6aa | 2256 | #endif /* HAVE_X_WINDOWS */ |
75700ff2 GM |
2257 | else if (EQ (parameter, Qbackground_color) |
2258 | || EQ (parameter, Qforeground_color)) | |
67d853e6 | 2259 | { |
e69b0960 | 2260 | value = Fassq (parameter, f->param_alist); |
67d853e6 | 2261 | if (CONSP (value)) |
5f65b39d | 2262 | { |
5f65b39d EZ |
2263 | value = XCDR (value); |
2264 | /* Fframe_parameters puts the actual fg/bg color names, | |
2265 | even if f->param_alist says otherwise. This is | |
2266 | important when param_alist's notion of colors is | |
2267 | "unspecified". We need to do the same here. */ | |
2268 | if (STRINGP (value) && !FRAME_WINDOW_P (f)) | |
2269 | { | |
c9b08ba8 | 2270 | const char *color_name; |
d311d28c | 2271 | ptrdiff_t csz; |
e1d0bbc9 EZ |
2272 | |
2273 | if (EQ (parameter, Qbackground_color)) | |
2274 | { | |
42a5b22f | 2275 | color_name = SSDATA (value); |
d5db4077 | 2276 | csz = SCHARS (value); |
e1d0bbc9 EZ |
2277 | if (strncmp (color_name, unspecified_bg, csz) == 0) |
2278 | value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f)); | |
2279 | else if (strncmp (color_name, unspecified_fg, csz) == 0) | |
2280 | value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f)); | |
2281 | } | |
2282 | else if (EQ (parameter, Qforeground_color)) | |
2283 | { | |
42a5b22f | 2284 | color_name = SSDATA (value); |
d5db4077 | 2285 | csz = SCHARS (value); |
e1d0bbc9 EZ |
2286 | if (strncmp (color_name, unspecified_fg, csz) == 0) |
2287 | value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f)); | |
2288 | else if (strncmp (color_name, unspecified_bg, csz) == 0) | |
2289 | value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f)); | |
2290 | } | |
5f65b39d EZ |
2291 | } |
2292 | } | |
b23236fb EZ |
2293 | else |
2294 | value = Fcdr (Fassq (parameter, Fframe_parameters (frame))); | |
67d853e6 | 2295 | } |
75700ff2 GM |
2296 | else if (EQ (parameter, Qdisplay_type) |
2297 | || EQ (parameter, Qbackground_mode)) | |
e69b0960 | 2298 | value = Fcdr (Fassq (parameter, f->param_alist)); |
75700ff2 | 2299 | else |
ce5b453a SM |
2300 | /* FIXME: Avoid this code path at all (as well as code duplication) |
2301 | by sharing more code with Fframe_parameters. */ | |
75700ff2 | 2302 | value = Fcdr (Fassq (parameter, Fframe_parameters (frame))); |
8b60f7bc | 2303 | } |
177c0ea7 | 2304 | |
8b60f7bc GM |
2305 | return value; |
2306 | } | |
2307 | ||
2308 | ||
a7ca3326 | 2309 | DEFUN ("modify-frame-parameters", Fmodify_frame_parameters, |
ff11dfa1 | 2310 | Smodify_frame_parameters, 2, 2, 0, |
14ff1ee0 PJ |
2311 | doc: /* Modify the parameters of frame FRAME according to ALIST. |
2312 | If FRAME is nil, it defaults to the selected frame. | |
2313 | ALIST is an alist of parameters to change and their new values. | |
2314 | Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol. | |
2315 | The meaningful PARMs depend on the kind of frame. | |
2316 | Undefined PARMs are ignored, but stored in the frame's parameter list | |
2317 | so that `frame-parameters' will return them. | |
2318 | ||
2319 | The value of frame parameter FOO can also be accessed | |
2320 | as a frame-local binding for the variable FOO, if you have | |
cf36572d GM |
2321 | enabled such bindings for that variable with `make-variable-frame-local'. |
2322 | Note that this functionality is obsolete as of Emacs 22.2, and its | |
2323 | use is not recommended. Explicitly check for a frame-parameter instead. */) | |
5842a27b | 2324 | (Lisp_Object frame, Lisp_Object alist) |
dc6f92b8 | 2325 | { |
d9f07150 | 2326 | struct frame *f = decode_live_frame (frame); |
ec3058af DA |
2327 | register Lisp_Object prop, val; |
2328 | ||
2329 | CHECK_LIST (alist); | |
dc6f92b8 | 2330 | |
dbc4e1c1 | 2331 | /* I think this should be done with a hook. */ |
032d78fe GV |
2332 | #ifdef HAVE_WINDOW_SYSTEM |
2333 | if (FRAME_WINDOW_P (f)) | |
fd0c2bd1 | 2334 | x_set_frame_parameters (f, alist); |
329ca574 | 2335 | else |
bb221971 RS |
2336 | #endif |
2337 | #ifdef MSDOS | |
2338 | if (FRAME_MSDOS_P (f)) | |
2339 | IT_set_frame_parameters (f, alist); | |
2340 | else | |
329ca574 | 2341 | #endif |
574a1a90 | 2342 | |
41d44f1f | 2343 | { |
d311d28c PE |
2344 | EMACS_INT length = XFASTINT (Flength (alist)); |
2345 | ptrdiff_t i; | |
2346 | Lisp_Object *parms; | |
2347 | Lisp_Object *values; | |
2348 | USE_SAFE_ALLOCA; | |
2349 | SAFE_ALLOCA_LISP (parms, 2 * length); | |
2350 | values = parms + length; | |
41d44f1f RS |
2351 | |
2352 | /* Extract parm names and values into those vectors. */ | |
2353 | ||
ec3058af | 2354 | for (i = 0; CONSP (alist); alist = XCDR (alist)) |
41d44f1f | 2355 | { |
213bac8a | 2356 | Lisp_Object elt; |
41d44f1f | 2357 | |
ec3058af | 2358 | elt = XCAR (alist); |
41d44f1f RS |
2359 | parms[i] = Fcar (elt); |
2360 | values[i] = Fcdr (elt); | |
2361 | i++; | |
2362 | } | |
2363 | ||
2364 | /* Now process them in reverse of specified order. */ | |
5ffe6683 | 2365 | while (--i >= 0) |
41d44f1f RS |
2366 | { |
2367 | prop = parms[i]; | |
2368 | val = values[i]; | |
2369 | store_frame_param (f, prop, val); | |
33d537f0 | 2370 | |
043604ee CY |
2371 | if (EQ (prop, Qforeground_color) |
2372 | || EQ (prop, Qbackground_color)) | |
2373 | update_face_from_frame_parameter (f, prop, val); | |
41d44f1f | 2374 | } |
d311d28c PE |
2375 | |
2376 | SAFE_FREE (); | |
41d44f1f | 2377 | } |
3b58be21 | 2378 | return Qnil; |
dc6f92b8 JB |
2379 | } |
2380 | \f | |
a26a1f95 | 2381 | DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height, |
14ff1ee0 PJ |
2382 | 0, 1, 0, |
2383 | doc: /* Height in pixels of a line in the font in frame FRAME. | |
d9f07150 | 2384 | If FRAME is omitted or nil, the selected frame is used. |
14ff1ee0 | 2385 | For a terminal frame, the value is always 1. */) |
5842a27b | 2386 | (Lisp_Object frame) |
dc6f92b8 | 2387 | { |
032d78fe | 2388 | #ifdef HAVE_WINDOW_SYSTEM |
d9f07150 DA |
2389 | struct frame *f = decode_any_frame (frame); |
2390 | ||
032d78fe | 2391 | if (FRAME_WINDOW_P (f)) |
1700db3c | 2392 | return make_number (FRAME_LINE_HEIGHT (f)); |
a26a1f95 | 2393 | else |
dc6d9681 | 2394 | #endif |
a26a1f95 RS |
2395 | return make_number (1); |
2396 | } | |
dc6d9681 | 2397 | |
dc6f92b8 | 2398 | |
a26a1f95 | 2399 | DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width, |
14ff1ee0 PJ |
2400 | 0, 1, 0, |
2401 | doc: /* Width in pixels of characters in the font in frame FRAME. | |
d9f07150 | 2402 | If FRAME is omitted or nil, the selected frame is used. |
31b7cc74 | 2403 | On a graphical screen, the width is the standard width of the default font. |
14ff1ee0 | 2404 | For a terminal screen, the value is always 1. */) |
5842a27b | 2405 | (Lisp_Object frame) |
dc6f92b8 | 2406 | { |
032d78fe | 2407 | #ifdef HAVE_WINDOW_SYSTEM |
d9f07150 DA |
2408 | struct frame *f = decode_any_frame (frame); |
2409 | ||
032d78fe | 2410 | if (FRAME_WINDOW_P (f)) |
1700db3c | 2411 | return make_number (FRAME_COLUMN_WIDTH (f)); |
a26a1f95 RS |
2412 | else |
2413 | #endif | |
2414 | return make_number (1); | |
dc6f92b8 JB |
2415 | } |
2416 | ||
177c0ea7 | 2417 | DEFUN ("frame-pixel-height", Fframe_pixel_height, |
a26a1f95 | 2418 | Sframe_pixel_height, 0, 1, 0, |
14ff1ee0 | 2419 | doc: /* Return a FRAME's height in pixels. |
d9f07150 | 2420 | If FRAME is omitted or nil, the selected frame is used. The exact value |
9ec6f100 GM |
2421 | of the result depends on the window-system and toolkit in use: |
2422 | ||
2423 | In the Gtk+ version of Emacs, it includes only any window (including | |
4c36be58 | 2424 | the minibuffer or echo area), mode line, and header line. It does not |
9ec6f100 GM |
2425 | include the tool bar or menu bar. |
2426 | ||
02615da0 JD |
2427 | With other graphical versions, it also includes the tool bar and the |
2428 | menu bar. | |
9ec6f100 | 2429 | |
c6bf3022 | 2430 | For a text terminal, it includes the menu bar. In this case, the |
9ec6f100 GM |
2431 | result is really in characters rather than pixels (i.e., is identical |
2432 | to `frame-height'). */) | |
5842a27b | 2433 | (Lisp_Object frame) |
dc6f92b8 | 2434 | { |
d9f07150 | 2435 | struct frame *f = decode_any_frame (frame); |
a26a1f95 | 2436 | |
032d78fe GV |
2437 | #ifdef HAVE_WINDOW_SYSTEM |
2438 | if (FRAME_WINDOW_P (f)) | |
f435830e | 2439 | return make_number (FRAME_PIXEL_HEIGHT (f)); |
a26a1f95 | 2440 | else |
dc6d9681 | 2441 | #endif |
5af5757b | 2442 | return make_number (FRAME_LINES (f)); |
a26a1f95 RS |
2443 | } |
2444 | ||
177c0ea7 | 2445 | DEFUN ("frame-pixel-width", Fframe_pixel_width, |
a26a1f95 | 2446 | Sframe_pixel_width, 0, 1, 0, |
14ff1ee0 PJ |
2447 | doc: /* Return FRAME's width in pixels. |
2448 | For a terminal frame, the result really gives the width in characters. | |
d9f07150 | 2449 | If FRAME is omitted or nil, the selected frame is used. */) |
5842a27b | 2450 | (Lisp_Object frame) |
a26a1f95 | 2451 | { |
d9f07150 | 2452 | struct frame *f = decode_any_frame (frame); |
dc6f92b8 | 2453 | |
032d78fe GV |
2454 | #ifdef HAVE_WINDOW_SYSTEM |
2455 | if (FRAME_WINDOW_P (f)) | |
f435830e | 2456 | return make_number (FRAME_PIXEL_WIDTH (f)); |
a26a1f95 RS |
2457 | else |
2458 | #endif | |
5af5757b | 2459 | return make_number (FRAME_COLS (f)); |
a26a1f95 | 2460 | } |
fb0cf781 J |
2461 | |
2462 | DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width, | |
2463 | Stool_bar_pixel_width, 0, 1, 0, | |
2464 | doc: /* Return width in pixels of FRAME's tool bar. | |
2465 | The result is greater than zero only when the tool bar is on the left | |
d9f07150 DA |
2466 | or right side of FRAME. If FRAME is omitted or nil, the selected frame |
2467 | is used. */) | |
fb0cf781 J |
2468 | (Lisp_Object frame) |
2469 | { | |
fb0cf781 | 2470 | #ifdef FRAME_TOOLBAR_WIDTH |
d9f07150 DA |
2471 | struct frame *f = decode_any_frame (frame); |
2472 | ||
2473 | if (FRAME_WINDOW_P (f)) | |
2474 | return make_number (FRAME_TOOLBAR_WIDTH (f)); | |
fb0cf781 | 2475 | #endif |
4ddb20d6 | 2476 | return make_number (0); |
fb0cf781 | 2477 | } |
880e6158 MR |
2478 | |
2479 | DEFUN ("frame-text-cols", Fframe_text_cols, Sframe_text_cols, 0, 1, 0, | |
2480 | doc: /* Return width in columns of FRAME's text area. */) | |
2481 | (Lisp_Object frame) | |
2482 | { | |
2483 | return make_number (FRAME_COLS (decode_any_frame (frame))); | |
2484 | } | |
2485 | ||
2486 | DEFUN ("frame-text-lines", Fframe_text_lines, Sframe_text_lines, 0, 1, 0, | |
2487 | doc: /* Return height in lines of FRAME's text area. */) | |
2488 | (Lisp_Object frame) | |
2489 | { | |
2490 | return make_number (FRAME_LINES (decode_any_frame (frame))); | |
2491 | } | |
2492 | ||
2493 | DEFUN ("frame-total-cols", Fframe_total_cols, Sframe_total_cols, 0, 1, 0, | |
2494 | doc: /* Return total columns of FRAME. */) | |
2495 | (Lisp_Object frame) | |
2496 | { | |
2497 | return make_number (FRAME_TOTAL_COLS (decode_any_frame (frame))); | |
2498 | } | |
2499 | ||
2500 | DEFUN ("frame-text-width", Fframe_text_width, Sframe_text_width, 0, 1, 0, | |
2501 | doc: /* Return text area width of FRAME in pixels. */) | |
2502 | (Lisp_Object frame) | |
2503 | { | |
2504 | return make_number (FRAME_TEXT_WIDTH (decode_any_frame (frame))); | |
2505 | } | |
2506 | ||
2507 | DEFUN ("frame-text-height", Fframe_text_height, Sframe_text_height, 0, 1, 0, | |
2508 | doc: /* Return text area height of FRAME in pixels. */) | |
2509 | (Lisp_Object frame) | |
2510 | { | |
2511 | return make_number (FRAME_TEXT_HEIGHT (decode_any_frame (frame))); | |
2512 | } | |
2513 | ||
2514 | DEFUN ("frame-scroll-bar-width", Fscroll_bar_width, Sscroll_bar_width, 0, 1, 0, | |
2515 | doc: /* Return scroll bar width of FRAME in pixels. */) | |
2516 | (Lisp_Object frame) | |
2517 | { | |
c44de18d | 2518 | return make_number (FRAME_SCROLL_BAR_AREA_WIDTH (decode_any_frame (frame))); |
880e6158 MR |
2519 | } |
2520 | ||
2521 | DEFUN ("frame-fringe-width", Ffringe_width, Sfringe_width, 0, 1, 0, | |
2522 | doc: /* Return fringe width of FRAME in pixels. */) | |
2523 | (Lisp_Object frame) | |
2524 | { | |
2525 | return make_number (FRAME_TOTAL_FRINGE_WIDTH (decode_any_frame (frame))); | |
2526 | } | |
2527 | ||
2528 | DEFUN ("frame-border-width", Fborder_width, Sborder_width, 0, 1, 0, | |
2529 | doc: /* Return border width of FRAME in pixels. */) | |
2530 | (Lisp_Object frame) | |
2531 | { | |
2532 | return make_number (FRAME_INTERNAL_BORDER_WIDTH (decode_any_frame (frame))); | |
2533 | } | |
2534 | ||
2535 | DEFUN ("frame-right-divider-width", Fright_divider_width, Sright_divider_width, 0, 1, 0, | |
2536 | doc: /* Return width (in pixels) of vertical window dividers on FRAME. */) | |
2537 | (Lisp_Object frame) | |
2538 | { | |
2539 | return make_number (FRAME_RIGHT_DIVIDER_WIDTH (decode_any_frame (frame))); | |
2540 | } | |
2541 | ||
2542 | DEFUN ("frame-bottom-divider-width", Fbottom_divider_width, Sbottom_divider_width, 0, 1, 0, | |
2543 | doc: /* Return width (in pixels) of horizontal window dividers on FRAME. */) | |
2544 | (Lisp_Object frame) | |
2545 | { | |
2546 | return make_number (FRAME_BOTTOM_DIVIDER_WIDTH (decode_any_frame (frame))); | |
2547 | } | |
a26a1f95 | 2548 | \f |
880e6158 MR |
2549 | DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 4, 0, |
2550 | doc: /* Specify that the frame FRAME has HEIGHT text lines. | |
2551 | Optional third arg PRETEND non-nil means that redisplay should use | |
2552 | HEIGHT lines but that the idea of the actual height of the frame should | |
2553 | not be changed. Optional fourth argument PIXELWISE non-nil means that | |
2554 | FRAME should be HEIGHT pixels high. */) | |
2555 | (Lisp_Object frame, Lisp_Object height, Lisp_Object pretend, Lisp_Object pixelwise) | |
dc6f92b8 | 2556 | { |
d9f07150 | 2557 | register struct frame *f = decode_live_frame (frame); |
dc6f92b8 | 2558 | |
880e6158 | 2559 | CHECK_TYPE_RANGED_INTEGER (int, height); |
dc6f92b8 | 2560 | |
dbc4e1c1 | 2561 | /* I think this should be done with a hook. */ |
032d78fe GV |
2562 | #ifdef HAVE_WINDOW_SYSTEM |
2563 | if (FRAME_WINDOW_P (f)) | |
dc6f92b8 | 2564 | { |
880e6158 MR |
2565 | if (NILP (pixelwise)) |
2566 | { | |
2567 | if (XINT (height) != FRAME_LINES (f)) | |
2568 | x_set_window_size (f, 1, FRAME_COLS (f), XINT (height), 0); | |
2569 | ||
2570 | do_pending_window_change (0); | |
2571 | } | |
2572 | else if (XINT (height) != FRAME_TEXT_HEIGHT (f)) | |
2573 | { | |
2574 | x_set_window_size (f, 1, FRAME_TEXT_WIDTH (f), XINT (height), 1); | |
2575 | do_pending_window_change (0); | |
2576 | } | |
dc6f92b8 JB |
2577 | } |
2578 | else | |
fd0c2bd1 | 2579 | #endif |
880e6158 MR |
2580 | change_frame_size (f, 0, XINT (height), !NILP (pretend), 0, 0, |
2581 | NILP (pixelwise) ? 0 : 1); | |
dc6f92b8 JB |
2582 | return Qnil; |
2583 | } | |
2584 | ||
880e6158 MR |
2585 | DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 4, 0, |
2586 | doc: /* Specify that the frame FRAME has WIDTH columns. | |
2587 | Optional third arg PRETEND non-nil means that redisplay should use WIDTH | |
2588 | columns but that the idea of the actual width of the frame should not | |
2589 | be changed. Optional fourth argument PIXELWISE non-nil means that FRAME | |
2590 | should be WIDTH pixels wide. */) | |
2591 | (Lisp_Object frame, Lisp_Object width, Lisp_Object pretend, Lisp_Object pixelwise) | |
dc6f92b8 | 2592 | { |
d9f07150 DA |
2593 | register struct frame *f = decode_live_frame (frame); |
2594 | ||
880e6158 | 2595 | CHECK_TYPE_RANGED_INTEGER (int, width); |
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)) | |
dc6f92b8 | 2600 | { |
880e6158 MR |
2601 | if (NILP (pixelwise)) |
2602 | { | |
2603 | if (XINT (width) != FRAME_COLS (f)) | |
2604 | x_set_window_size (f, 1, XINT (width), FRAME_LINES (f), 0); | |
2605 | ||
2606 | do_pending_window_change (0); | |
2607 | } | |
2608 | else if (XINT (width) != FRAME_TEXT_WIDTH (f)) | |
2609 | { | |
2610 | x_set_window_size (f, 1, XINT (width), FRAME_TEXT_HEIGHT (f), 1); | |
2611 | do_pending_window_change (0); | |
2612 | } | |
dc6f92b8 JB |
2613 | } |
2614 | else | |
fd0c2bd1 | 2615 | #endif |
880e6158 MR |
2616 | change_frame_size (f, XINT (width), 0, !NILP (pretend), 0, 0, |
2617 | NILP (pixelwise) ? 0 : 1); | |
dc6f92b8 JB |
2618 | return Qnil; |
2619 | } | |
2620 | ||
880e6158 MR |
2621 | DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 4, 0, |
2622 | doc: /* Sets size of FRAME to WIDTH by HEIGHT, measured in characters. | |
2623 | Optional argument PIXELWISE non-nil means to measure in pixels. */) | |
2624 | (Lisp_Object frame, Lisp_Object width, Lisp_Object height, Lisp_Object pixelwise) | |
dc6f92b8 | 2625 | { |
4c131798 | 2626 | register struct frame *f = decode_live_frame (frame); |
dc6f92b8 | 2627 | |
880e6158 MR |
2628 | CHECK_TYPE_RANGED_INTEGER (int, width); |
2629 | CHECK_TYPE_RANGED_INTEGER (int, height); | |
dc6f92b8 | 2630 | |
dbc4e1c1 | 2631 | /* I think this should be done with a hook. */ |
032d78fe GV |
2632 | #ifdef HAVE_WINDOW_SYSTEM |
2633 | if (FRAME_WINDOW_P (f)) | |
dc6f92b8 | 2634 | { |
880e6158 MR |
2635 | if (!NILP (pixelwise) |
2636 | ? (XINT (width) != FRAME_TEXT_WIDTH (f) | |
2637 | || XINT (height) != FRAME_TEXT_HEIGHT (f) | |
2638 | || f->new_height || f->new_width) | |
2639 | : (XINT (width) != FRAME_COLS (f) | |
2640 | || XINT (height) != FRAME_LINES (f) | |
2641 | || f->new_height || f->new_width)) | |
2642 | { | |
2643 | x_set_window_size (f, 1, XINT (width), XINT (height), | |
2644 | NILP (pixelwise) ? 0 : 1); | |
2645 | do_pending_window_change (0); | |
2646 | } | |
dc6f92b8 JB |
2647 | } |
2648 | else | |
fd0c2bd1 | 2649 | #endif |
880e6158 MR |
2650 | change_frame_size (f, XINT (width), XINT (height), 0, 0, 0, |
2651 | NILP (pixelwise) ? 0 : 1); | |
dc6f92b8 JB |
2652 | |
2653 | return Qnil; | |
2654 | } | |
2655 | ||
177c0ea7 | 2656 | DEFUN ("set-frame-position", Fset_frame_position, |
ff11dfa1 | 2657 | Sset_frame_position, 3, 3, 0, |
14ff1ee0 | 2658 | doc: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET. |
4c131798 DA |
2659 | If FRAME is nil, the selected frame is used. XOFFSET and YOFFSET are |
2660 | actually the position of the upper left corner of the frame. Negative | |
2661 | values for XOFFSET or YOFFSET are interpreted relative to the rightmost | |
2662 | or bottommost possible position (that stays within the screen). */) | |
5842a27b | 2663 | (Lisp_Object frame, Lisp_Object xoffset, Lisp_Object yoffset) |
dc6f92b8 | 2664 | { |
4c131798 | 2665 | register struct frame *f = decode_live_frame (frame); |
dc6f92b8 | 2666 | |
d311d28c PE |
2667 | CHECK_TYPE_RANGED_INTEGER (int, xoffset); |
2668 | CHECK_TYPE_RANGED_INTEGER (int, yoffset); | |
dc6f92b8 | 2669 | |
dbc4e1c1 | 2670 | /* I think this should be done with a hook. */ |
032d78fe GV |
2671 | #ifdef HAVE_WINDOW_SYSTEM |
2672 | if (FRAME_WINDOW_P (f)) | |
c7c70761 | 2673 | x_set_offset (f, XINT (xoffset), XINT (yoffset), 1); |
fd0c2bd1 | 2674 | #endif |
dc6f92b8 JB |
2675 | |
2676 | return Qt; | |
2677 | } | |
dc6d9681 | 2678 | |
dc6f92b8 | 2679 | \f |
972f4259 KS |
2680 | /*********************************************************************** |
2681 | Frame Parameters | |
2682 | ***********************************************************************/ | |
2683 | ||
2684 | /* Connect the frame-parameter names for X frames | |
2685 | to the ways of passing the parameter values to the window system. | |
2686 | ||
2687 | The name of a parameter, as a Lisp symbol, | |
2688 | has an `x-frame-parameter' property which is an integer in Lisp | |
2689 | that is an index in this table. */ | |
2690 | ||
2691 | struct frame_parm_table { | |
675e2c69 | 2692 | const char *name; |
972f4259 KS |
2693 | Lisp_Object *variable; |
2694 | }; | |
2695 | ||
94eed851 | 2696 | static const struct frame_parm_table frame_parms[] = |
972f4259 KS |
2697 | { |
2698 | {"auto-raise", &Qauto_raise}, | |
2699 | {"auto-lower", &Qauto_lower}, | |
2700 | {"background-color", 0}, | |
2701 | {"border-color", &Qborder_color}, | |
2702 | {"border-width", &Qborder_width}, | |
2703 | {"cursor-color", &Qcursor_color}, | |
2704 | {"cursor-type", &Qcursor_type}, | |
2705 | {"font", 0}, | |
2706 | {"foreground-color", 0}, | |
2707 | {"icon-name", &Qicon_name}, | |
2708 | {"icon-type", &Qicon_type}, | |
2709 | {"internal-border-width", &Qinternal_border_width}, | |
880e6158 MR |
2710 | {"right-divider-width", &Qright_divider_width}, |
2711 | {"bottom-divider-width", &Qbottom_divider_width}, | |
972f4259 KS |
2712 | {"menu-bar-lines", &Qmenu_bar_lines}, |
2713 | {"mouse-color", &Qmouse_color}, | |
2714 | {"name", &Qname}, | |
2715 | {"scroll-bar-width", &Qscroll_bar_width}, | |
2716 | {"title", &Qtitle}, | |
2717 | {"unsplittable", &Qunsplittable}, | |
2718 | {"vertical-scroll-bars", &Qvertical_scroll_bars}, | |
2719 | {"visibility", &Qvisibility}, | |
2720 | {"tool-bar-lines", &Qtool_bar_lines}, | |
2721 | {"scroll-bar-foreground", &Qscroll_bar_foreground}, | |
2722 | {"scroll-bar-background", &Qscroll_bar_background}, | |
2723 | {"screen-gamma", &Qscreen_gamma}, | |
2724 | {"line-spacing", &Qline_spacing}, | |
2725 | {"left-fringe", &Qleft_fringe}, | |
2726 | {"right-fringe", &Qright_fringe}, | |
2727 | {"wait-for-wm", &Qwait_for_wm}, | |
2728 | {"fullscreen", &Qfullscreen}, | |
0a708637 | 2729 | {"font-backend", &Qfont_backend}, |
cad9ef74 JD |
2730 | {"alpha", &Qalpha}, |
2731 | {"sticky", &Qsticky}, | |
bfeabdc3 | 2732 | {"tool-bar-position", &Qtool_bar_position}, |
972f4259 KS |
2733 | }; |
2734 | ||
0fda9b75 | 2735 | #ifdef HAVE_NTGUI |
972f4259 | 2736 | |
972f4259 | 2737 | /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the |
bd45aef7 | 2738 | wanted positions of the WM window (not Emacs window). |
972f4259 KS |
2739 | Return in *WIDTH and *HEIGHT the wanted width and height of Emacs |
2740 | window (FRAME_X_WINDOW). | |
2741 | */ | |
2742 | ||
dfcf069d | 2743 | void |
971de7fb | 2744 | x_fullscreen_adjust (struct frame *f, int *width, int *height, int *top_pos, int *left_pos) |
dc6f92b8 | 2745 | { |
5af5757b KS |
2746 | int newwidth = FRAME_COLS (f); |
2747 | int newheight = FRAME_LINES (f); | |
aad3612f | 2748 | Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f); |
dc6f92b8 | 2749 | |
5af5757b KS |
2750 | *top_pos = f->top_pos; |
2751 | *left_pos = f->left_pos; | |
3df1fda2 | 2752 | |
5af5757b | 2753 | if (f->want_fullscreen & FULLSCREEN_HEIGHT) |
972f4259 KS |
2754 | { |
2755 | int ph; | |
2756 | ||
a0fe6cca | 2757 | ph = x_display_pixel_height (dpyinfo); |
5af5757b KS |
2758 | newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph); |
2759 | ph = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, newheight) - f->y_pixels_diff; | |
2760 | newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph); | |
972f4259 KS |
2761 | *top_pos = 0; |
2762 | } | |
dc6f92b8 | 2763 | |
5af5757b | 2764 | if (f->want_fullscreen & FULLSCREEN_WIDTH) |
972f4259 KS |
2765 | { |
2766 | int pw; | |
2767 | ||
a0fe6cca | 2768 | pw = x_display_pixel_width (dpyinfo); |
5af5757b KS |
2769 | newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw); |
2770 | pw = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, newwidth) - f->x_pixels_diff; | |
2771 | newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw); | |
972f4259 KS |
2772 | *left_pos = 0; |
2773 | } | |
dc6f92b8 | 2774 | |
972f4259 KS |
2775 | *width = newwidth; |
2776 | *height = newheight; | |
2777 | } | |
dc6f92b8 | 2778 | |
0fda9b75 | 2779 | #endif /* HAVE_NTGUI */ |
81626931 PE |
2780 | |
2781 | #ifdef HAVE_WINDOW_SYSTEM | |
beb0bc36 | 2782 | |
972f4259 KS |
2783 | /* Change the parameters of frame F as specified by ALIST. |
2784 | If a parameter is not specially recognized, do nothing special; | |
2785 | otherwise call the `x_set_...' function for that parameter. | |
2786 | Except for certain geometry properties, always call store_frame_param | |
2787 | to store the new value in the parameter alist. */ | |
14ff1ee0 | 2788 | |
972f4259 | 2789 | void |
a10c8269 | 2790 | x_set_frame_parameters (struct frame *f, Lisp_Object alist) |
972f4259 KS |
2791 | { |
2792 | Lisp_Object tail; | |
dc6f92b8 | 2793 | |
972f4259 KS |
2794 | /* If both of these parameters are present, it's more efficient to |
2795 | set them both at once. So we wait until we've looked at the | |
2796 | entire list before we set them. */ | |
2797 | int width, height; | |
3df1fda2 | 2798 | |
972f4259 KS |
2799 | /* Same here. */ |
2800 | Lisp_Object left, top; | |
2801 | ||
2802 | /* Same with these. */ | |
2803 | Lisp_Object icon_left, icon_top; | |
2804 | ||
2805 | /* Record in these vectors all the parms specified. */ | |
2806 | Lisp_Object *parms; | |
2807 | Lisp_Object *values; | |
f66c7cf8 | 2808 | ptrdiff_t i, p; |
959067a1 | 2809 | bool left_no_change = 0, top_no_change = 0; |
af025ae8 | 2810 | #ifdef HAVE_X_WINDOWS |
959067a1 | 2811 | bool icon_left_no_change = 0, icon_top_no_change = 0; |
af025ae8 | 2812 | #endif |
959067a1 | 2813 | bool size_changed = 0; |
972f4259 KS |
2814 | struct gcpro gcpro1, gcpro2; |
2815 | ||
2816 | i = 0; | |
7d7bbefd | 2817 | for (tail = alist; CONSP (tail); tail = XCDR (tail)) |
972f4259 KS |
2818 | i++; |
2819 | ||
38182d90 PE |
2820 | parms = alloca (i * sizeof *parms); |
2821 | values = alloca (i * sizeof *values); | |
972f4259 KS |
2822 | |
2823 | /* Extract parm names and values into those vectors. */ | |
2824 | ||
2825 | i = 0; | |
d7b10f4c | 2826 | for (tail = alist; CONSP (tail); tail = XCDR (tail)) |
972f4259 KS |
2827 | { |
2828 | Lisp_Object elt; | |
2829 | ||
d7b10f4c | 2830 | elt = XCAR (tail); |
972f4259 KS |
2831 | parms[i] = Fcar (elt); |
2832 | values[i] = Fcdr (elt); | |
2833 | i++; | |
2834 | } | |
2835 | /* TAIL and ALIST are not used again below here. */ | |
2836 | alist = tail = Qnil; | |
2837 | ||
2838 | GCPRO2 (*parms, *values); | |
2839 | gcpro1.nvars = i; | |
2840 | gcpro2.nvars = i; | |
2841 | ||
2842 | /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP, | |
2843 | because their values appear in VALUES and strings are not valid. */ | |
2844 | top = left = Qunbound; | |
2845 | icon_left = icon_top = Qunbound; | |
2846 | ||
2847 | /* Provide default values for HEIGHT and WIDTH. */ | |
880e6158 MR |
2848 | width = (f->new_width |
2849 | ? (f->new_pixelwise | |
8960529e MR |
2850 | ? f->new_width |
2851 | : (f->new_width * FRAME_COLUMN_WIDTH (f))) | |
2852 | : FRAME_TEXT_WIDTH (f)); | |
880e6158 MR |
2853 | height = (f->new_height |
2854 | ? (f->new_pixelwise | |
8960529e MR |
2855 | ? f->new_height |
2856 | : (f->new_height * FRAME_LINE_HEIGHT (f))) | |
2857 | : FRAME_TEXT_HEIGHT (f)); | |
972f4259 KS |
2858 | |
2859 | /* Process foreground_color and background_color before anything else. | |
2860 | They are independent of other properties, but other properties (e.g., | |
2861 | cursor_color) are dependent upon them. */ | |
2862 | /* Process default font as well, since fringe widths depends on it. */ | |
972f4259 KS |
2863 | for (p = 0; p < i; p++) |
2864 | { | |
2865 | Lisp_Object prop, val; | |
2866 | ||
2867 | prop = parms[p]; | |
2868 | val = values[p]; | |
2869 | if (EQ (prop, Qforeground_color) | |
2870 | || EQ (prop, Qbackground_color) | |
3f1c6666 | 2871 | || EQ (prop, Qfont)) |
972f4259 KS |
2872 | { |
2873 | register Lisp_Object param_index, old_value; | |
2874 | ||
2875 | old_value = get_frame_param (f, prop); | |
972f4259 KS |
2876 | if (NILP (Fequal (val, old_value))) |
2877 | { | |
2878 | store_frame_param (f, prop, val); | |
2879 | ||
2880 | param_index = Fget (prop, Qx_frame_parameter); | |
2881 | if (NATNUMP (param_index) | |
2882 | && (XFASTINT (param_index) | |
2883 | < sizeof (frame_parms)/sizeof (frame_parms[0])) | |
fa971ac3 KL |
2884 | && FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)]) |
2885 | (*(FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])) (f, val, old_value); | |
972f4259 KS |
2886 | } |
2887 | } | |
2888 | } | |
2889 | ||
2890 | /* Now process them in reverse of specified order. */ | |
c5101a77 | 2891 | while (i-- != 0) |
972f4259 KS |
2892 | { |
2893 | Lisp_Object prop, val; | |
2894 | ||
2895 | prop = parms[i]; | |
2896 | val = values[i]; | |
2897 | ||
d311d28c | 2898 | if (EQ (prop, Qwidth) && RANGED_INTEGERP (0, val, INT_MAX)) |
3f1c6666 JD |
2899 | { |
2900 | size_changed = 1; | |
8960529e | 2901 | width = XFASTINT (val) * FRAME_COLUMN_WIDTH (f) ; |
3f1c6666 | 2902 | } |
d311d28c | 2903 | else if (EQ (prop, Qheight) && RANGED_INTEGERP (0, val, INT_MAX)) |
3f1c6666 JD |
2904 | { |
2905 | size_changed = 1; | |
8960529e | 2906 | height = XFASTINT (val) * FRAME_LINE_HEIGHT (f); |
3f1c6666 | 2907 | } |
972f4259 KS |
2908 | else if (EQ (prop, Qtop)) |
2909 | top = val; | |
2910 | else if (EQ (prop, Qleft)) | |
2911 | left = val; | |
2912 | else if (EQ (prop, Qicon_top)) | |
2913 | icon_top = val; | |
2914 | else if (EQ (prop, Qicon_left)) | |
2915 | icon_left = val; | |
2916 | else if (EQ (prop, Qforeground_color) | |
2917 | || EQ (prop, Qbackground_color) | |
3f1c6666 | 2918 | || EQ (prop, Qfont)) |
972f4259 KS |
2919 | /* Processed above. */ |
2920 | continue; | |
2921 | else | |
2922 | { | |
2923 | register Lisp_Object param_index, old_value; | |
2924 | ||
2925 | old_value = get_frame_param (f, prop); | |
2926 | ||
2927 | store_frame_param (f, prop, val); | |
2928 | ||
2929 | param_index = Fget (prop, Qx_frame_parameter); | |
2930 | if (NATNUMP (param_index) | |
2931 | && (XFASTINT (param_index) | |
2932 | < sizeof (frame_parms)/sizeof (frame_parms[0])) | |
fa971ac3 KL |
2933 | && FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)]) |
2934 | (*(FRAME_RIF (f)->frame_parm_handlers[XINT (param_index)])) (f, val, old_value); | |
972f4259 KS |
2935 | } |
2936 | } | |
2937 | ||
2938 | /* Don't die if just one of these was set. */ | |
5fbfb018 | 2939 | if (EQ (left, Qunbound)) |
972f4259 KS |
2940 | { |
2941 | left_no_change = 1; | |
5af5757b | 2942 | if (f->left_pos < 0) |
6c6f1994 | 2943 | left = list2 (Qplus, make_number (f->left_pos)); |
972f4259 | 2944 | else |
5af5757b | 2945 | XSETINT (left, f->left_pos); |
972f4259 | 2946 | } |
5fbfb018 | 2947 | if (EQ (top, Qunbound)) |
972f4259 KS |
2948 | { |
2949 | top_no_change = 1; | |
5af5757b | 2950 | if (f->top_pos < 0) |
6c6f1994 | 2951 | top = list2 (Qplus, make_number (f->top_pos)); |
972f4259 | 2952 | else |
5af5757b | 2953 | XSETINT (top, f->top_pos); |
972f4259 KS |
2954 | } |
2955 | ||
2956 | /* If one of the icon positions was not set, preserve or default it. */ | |
d311d28c | 2957 | if (! TYPE_RANGED_INTEGERP (int, icon_left)) |
972f4259 | 2958 | { |
af025ae8 | 2959 | #ifdef HAVE_X_WINDOWS |
972f4259 | 2960 | icon_left_no_change = 1; |
af025ae8 | 2961 | #endif |
e69b0960 | 2962 | icon_left = Fcdr (Fassq (Qicon_left, f->param_alist)); |
972f4259 KS |
2963 | if (NILP (icon_left)) |
2964 | XSETINT (icon_left, 0); | |
2965 | } | |
d311d28c | 2966 | if (! TYPE_RANGED_INTEGERP (int, icon_top)) |
972f4259 | 2967 | { |
af025ae8 | 2968 | #ifdef HAVE_X_WINDOWS |
972f4259 | 2969 | icon_top_no_change = 1; |
af025ae8 | 2970 | #endif |
e69b0960 | 2971 | icon_top = Fcdr (Fassq (Qicon_top, f->param_alist)); |
972f4259 KS |
2972 | if (NILP (icon_top)) |
2973 | XSETINT (icon_top, 0); | |
2974 | } | |
2975 | ||
972f4259 KS |
2976 | /* Don't set these parameters unless they've been explicitly |
2977 | specified. The window might be mapped or resized while we're in | |
2978 | this function, and we don't want to override that unless the lisp | |
2979 | code has asked for it. | |
2980 | ||
2981 | Don't set these parameters unless they actually differ from the | |
2982 | window's current parameters; the window may not actually exist | |
2983 | yet. */ | |
2984 | { | |
2985 | Lisp_Object frame; | |
2986 | ||
880e6158 | 2987 | /* Make this 1, eventually. */ |
8960529e | 2988 | check_frame_size (f, &width, &height, 1); |
972f4259 KS |
2989 | |
2990 | XSETFRAME (frame, f); | |
2991 | ||
3f1c6666 | 2992 | if (size_changed |
8960529e MR |
2993 | && (width != FRAME_TEXT_WIDTH (f) |
2994 | || height != FRAME_TEXT_HEIGHT (f) | |
880e6158 | 2995 | || f->new_height || f->new_width)) |
8960529e | 2996 | Fset_frame_size (frame, make_number (width), make_number (height), Qt); |
972f4259 KS |
2997 | |
2998 | if ((!NILP (left) || !NILP (top)) | |
2999 | && ! (left_no_change && top_no_change) | |
5af5757b KS |
3000 | && ! (NUMBERP (left) && XINT (left) == f->left_pos |
3001 | && NUMBERP (top) && XINT (top) == f->top_pos)) | |
972f4259 KS |
3002 | { |
3003 | int leftpos = 0; | |
3004 | int toppos = 0; | |
3005 | ||
3006 | /* Record the signs. */ | |
5af5757b | 3007 | f->size_hint_flags &= ~ (XNegative | YNegative); |
972f4259 | 3008 | if (EQ (left, Qminus)) |
5af5757b | 3009 | f->size_hint_flags |= XNegative; |
b8898fda | 3010 | else if (TYPE_RANGED_INTEGERP (int, left)) |
972f4259 KS |
3011 | { |
3012 | leftpos = XINT (left); | |
3013 | if (leftpos < 0) | |
5af5757b | 3014 | f->size_hint_flags |= XNegative; |
972f4259 KS |
3015 | } |
3016 | else if (CONSP (left) && EQ (XCAR (left), Qminus) | |
3017 | && CONSP (XCDR (left)) | |
b8898fda | 3018 | && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (left)), INT_MAX)) |
972f4259 KS |
3019 | { |
3020 | leftpos = - XINT (XCAR (XCDR (left))); | |
5af5757b | 3021 | f->size_hint_flags |= XNegative; |
972f4259 KS |
3022 | } |
3023 | else if (CONSP (left) && EQ (XCAR (left), Qplus) | |
3024 | && CONSP (XCDR (left)) | |
b8898fda | 3025 | && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left)))) |
972f4259 KS |
3026 | { |
3027 | leftpos = XINT (XCAR (XCDR (left))); | |
3028 | } | |
3029 | ||
3030 | if (EQ (top, Qminus)) | |
5af5757b | 3031 | f->size_hint_flags |= YNegative; |
b8898fda | 3032 | else if (TYPE_RANGED_INTEGERP (int, top)) |
972f4259 KS |
3033 | { |
3034 | toppos = XINT (top); | |
3035 | if (toppos < 0) | |
5af5757b | 3036 | f->size_hint_flags |= YNegative; |
972f4259 KS |
3037 | } |
3038 | else if (CONSP (top) && EQ (XCAR (top), Qminus) | |
3039 | && CONSP (XCDR (top)) | |
b8898fda | 3040 | && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (top)), INT_MAX)) |
972f4259 KS |
3041 | { |
3042 | toppos = - XINT (XCAR (XCDR (top))); | |
5af5757b | 3043 | f->size_hint_flags |= YNegative; |
972f4259 KS |
3044 | } |
3045 | else if (CONSP (top) && EQ (XCAR (top), Qplus) | |
3046 | && CONSP (XCDR (top)) | |
b8898fda | 3047 | && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top)))) |
972f4259 KS |
3048 | { |
3049 | toppos = XINT (XCAR (XCDR (top))); | |
3050 | } | |
3051 | ||
3052 | ||
3053 | /* Store the numeric value of the position. */ | |
5af5757b KS |
3054 | f->top_pos = toppos; |
3055 | f->left_pos = leftpos; | |
972f4259 | 3056 | |
5af5757b | 3057 | f->win_gravity = NorthWestGravity; |
972f4259 KS |
3058 | |
3059 | /* Actually set that position, and convert to absolute. */ | |
3060 | x_set_offset (f, leftpos, toppos, -1); | |
3061 | } | |
52b8a085 | 3062 | #ifdef HAVE_X_WINDOWS |
972f4259 KS |
3063 | if ((!NILP (icon_left) || !NILP (icon_top)) |
3064 | && ! (icon_left_no_change && icon_top_no_change)) | |
3065 | x_wm_set_icon_position (f, XINT (icon_left), XINT (icon_top)); | |
52b8a085 | 3066 | #endif /* HAVE_X_WINDOWS */ |
972f4259 KS |
3067 | } |
3068 | ||
3069 | UNGCPRO; | |
3070 | } | |
3071 | ||
3072 | ||
3073 | /* Insert a description of internally-recorded parameters of frame X | |
3074 | into the parameter alist *ALISTPTR that is to be given to the user. | |
3075 | Only parameters that are specific to the X window system | |
3076 | and whose values are not correctly recorded in the frame's | |
3077 | param_alist need to be considered here. */ | |
3078 | ||
3079 | void | |
971de7fb | 3080 | x_report_frame_params (struct frame *f, Lisp_Object *alistptr) |
972f4259 | 3081 | { |
972f4259 | 3082 | Lisp_Object tem; |
82ef37c1 PE |
3083 | uprintmax_t w; |
3084 | char buf[INT_BUFSIZE_BOUND (w)]; | |
972f4259 KS |
3085 | |
3086 | /* Represent negative positions (off the top or left screen edge) | |
3087 | in a way that Fmodify_frame_parameters will understand correctly. */ | |
5af5757b KS |
3088 | XSETINT (tem, f->left_pos); |
3089 | if (f->left_pos >= 0) | |
972f4259 KS |
3090 | store_in_alist (alistptr, Qleft, tem); |
3091 | else | |
6c6f1994 | 3092 | store_in_alist (alistptr, Qleft, list2 (Qplus, tem)); |
972f4259 | 3093 | |
5af5757b KS |
3094 | XSETINT (tem, f->top_pos); |
3095 | if (f->top_pos >= 0) | |
972f4259 KS |
3096 | store_in_alist (alistptr, Qtop, tem); |
3097 | else | |
6c6f1994 | 3098 | store_in_alist (alistptr, Qtop, list2 (Qplus, tem)); |
972f4259 KS |
3099 | |
3100 | store_in_alist (alistptr, Qborder_width, | |
5af5757b | 3101 | make_number (f->border_width)); |
972f4259 | 3102 | store_in_alist (alistptr, Qinternal_border_width, |
5af5757b | 3103 | make_number (FRAME_INTERNAL_BORDER_WIDTH (f))); |
880e6158 MR |
3104 | store_in_alist (alistptr, Qright_divider_width, |
3105 | make_number (FRAME_RIGHT_DIVIDER_WIDTH (f))); | |
3106 | store_in_alist (alistptr, Qbottom_divider_width, | |
3107 | make_number (FRAME_BOTTOM_DIVIDER_WIDTH (f))); | |
972f4259 | 3108 | store_in_alist (alistptr, Qleft_fringe, |
5af5757b | 3109 | make_number (FRAME_LEFT_FRINGE_WIDTH (f))); |
972f4259 | 3110 | store_in_alist (alistptr, Qright_fringe, |
5af5757b | 3111 | make_number (FRAME_RIGHT_FRINGE_WIDTH (f))); |
972f4259 KS |
3112 | store_in_alist (alistptr, Qscroll_bar_width, |
3113 | (! FRAME_HAS_VERTICAL_SCROLL_BARS (f) | |
3114 | ? make_number (0) | |
5af5757b KS |
3115 | : FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 |
3116 | ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) | |
972f4259 KS |
3117 | /* nil means "use default width" |
3118 | for non-toolkit scroll bar. | |
3119 | ruler-mode.el depends on this. */ | |
3120 | : Qnil)); | |
208a048d EZ |
3121 | /* FRAME_X_WINDOW is not guaranteed to return an integer. E.g., on |
3122 | MS-Windows it returns a value whose type is HANDLE, which is | |
3123 | actually a pointer. Explicit casting avoids compiler | |
3124 | warnings. */ | |
82ef37c1 | 3125 | w = (uintptr_t) FRAME_X_WINDOW (f); |
972f4259 | 3126 | store_in_alist (alistptr, Qwindow_id, |
62aba0d4 | 3127 | make_formatted_string (buf, "%"pMu, w)); |
972f4259 KS |
3128 | #ifdef HAVE_X_WINDOWS |
3129 | #ifdef USE_X_TOOLKIT | |
3130 | /* Tooltip frame may not have this widget. */ | |
3131 | if (FRAME_X_OUTPUT (f)->widget) | |
3132 | #endif | |
82ef37c1 | 3133 | w = (uintptr_t) FRAME_OUTER_WINDOW (f); |
972f4259 | 3134 | store_in_alist (alistptr, Qouter_window_id, |
62aba0d4 | 3135 | make_formatted_string (buf, "%"pMu, w)); |
972f4259 | 3136 | #endif |
e69b0960 | 3137 | store_in_alist (alistptr, Qicon_name, f->icon_name); |
972f4259 KS |
3138 | store_in_alist (alistptr, Qvisibility, |
3139 | (FRAME_VISIBLE_P (f) ? Qt | |
3140 | : FRAME_ICONIFIED_P (f) ? Qicon : Qnil)); | |
3141 | store_in_alist (alistptr, Qdisplay, | |
aad3612f | 3142 | XCAR (FRAME_DISPLAY_INFO (f)->name_list_element)); |
972f4259 | 3143 | |
aad3612f | 3144 | if (FRAME_X_OUTPUT (f)->parent_desc == FRAME_DISPLAY_INFO (f)->root_window) |
972f4259 KS |
3145 | tem = Qnil; |
3146 | else | |
ec6ecaad | 3147 | tem = make_natnum ((uintptr_t) FRAME_X_OUTPUT (f)->parent_desc); |
5839d7e8 | 3148 | store_in_alist (alistptr, Qexplicit_name, (f->explicit_name ? Qt : Qnil)); |
972f4259 | 3149 | store_in_alist (alistptr, Qparent_id, tem); |
e69b0960 | 3150 | store_in_alist (alistptr, Qtool_bar_position, f->tool_bar_position); |
972f4259 KS |
3151 | } |
3152 | ||
3153 | ||
3154 | /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is | |
3155 | the previous value of that parameter, NEW_VALUE is the new value. */ | |
3156 | ||
3157 | void | |
971de7fb | 3158 | x_set_fullscreen (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) |
972f4259 | 3159 | { |
972f4259 | 3160 | if (NILP (new_value)) |
5af5757b | 3161 | f->want_fullscreen = FULLSCREEN_NONE; |
3f1c6666 | 3162 | else if (EQ (new_value, Qfullboth) || EQ (new_value, Qfullscreen)) |
5af5757b | 3163 | f->want_fullscreen = FULLSCREEN_BOTH; |
972f4259 | 3164 | else if (EQ (new_value, Qfullwidth)) |
5af5757b | 3165 | f->want_fullscreen = FULLSCREEN_WIDTH; |
972f4259 | 3166 | else if (EQ (new_value, Qfullheight)) |
5af5757b | 3167 | f->want_fullscreen = FULLSCREEN_HEIGHT; |
3f1c6666 JD |
3168 | else if (EQ (new_value, Qmaximized)) |
3169 | f->want_fullscreen = FULLSCREEN_MAXIMIZED; | |
d761dd42 | 3170 | |
a3547743 | 3171 | if (FRAME_TERMINAL (f)->fullscreen_hook != NULL) |
974b73e8 | 3172 | FRAME_TERMINAL (f)->fullscreen_hook (f); |
972f4259 KS |
3173 | } |
3174 | ||
3175 | ||
3176 | /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is | |
3177 | the previous value of that parameter, NEW_VALUE is the new value. */ | |
3178 | ||
3179 | void | |
971de7fb | 3180 | x_set_line_spacing (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) |
972f4259 KS |
3181 | { |
3182 | if (NILP (new_value)) | |
3183 | f->extra_line_spacing = 0; | |
d311d28c | 3184 | else if (RANGED_INTEGERP (0, new_value, INT_MAX)) |
972f4259 | 3185 | f->extra_line_spacing = XFASTINT (new_value); |
fdda0220 EZ |
3186 | else if (FLOATP (new_value)) |
3187 | { | |
3188 | int new_spacing = XFLOAT_DATA (new_value) * FRAME_LINE_HEIGHT (f) + 0.5; | |
3189 | ||
3190 | if (new_spacing >= 0) | |
3191 | f->extra_line_spacing = new_spacing; | |
3192 | else | |
3193 | signal_error ("Invalid line-spacing", new_value); | |
3194 | } | |
972f4259 | 3195 | else |
9dc95187 | 3196 | signal_error ("Invalid line-spacing", new_value); |
972f4259 KS |
3197 | if (FRAME_VISIBLE_P (f)) |
3198 | redraw_frame (f); | |
3199 | } | |
3200 | ||
3201 | ||
3202 | /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is | |
3203 | the previous value of that parameter, NEW_VALUE is the new value. */ | |
3204 | ||
3205 | void | |
971de7fb | 3206 | x_set_screen_gamma (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) |
972f4259 | 3207 | { |
05fc2ef7 CY |
3208 | Lisp_Object bgcolor; |
3209 | ||
972f4259 KS |
3210 | if (NILP (new_value)) |
3211 | f->gamma = 0; | |
3212 | else if (NUMBERP (new_value) && XFLOATINT (new_value) > 0) | |
05fc2ef7 CY |
3213 | /* The value 0.4545 is the normal viewing gamma. */ |
3214 | f->gamma = 1.0 / (0.4545 * XFLOATINT (new_value)); | |
972f4259 | 3215 | else |
9dc95187 | 3216 | signal_error ("Invalid screen-gamma", new_value); |
972f4259 | 3217 | |
05fc2ef7 | 3218 | /* Apply the new gamma value to the frame background. */ |
e69b0960 | 3219 | bgcolor = Fassq (Qbackground_color, f->param_alist); |
05fc2ef7 CY |
3220 | if (CONSP (bgcolor) && (bgcolor = XCDR (bgcolor), STRINGP (bgcolor))) |
3221 | { | |
76c1cebc PE |
3222 | Lisp_Object parm_index = Fget (Qbackground_color, Qx_frame_parameter); |
3223 | if (NATNUMP (parm_index) | |
3224 | && (XFASTINT (parm_index) | |
05fc2ef7 | 3225 | < sizeof (frame_parms)/sizeof (frame_parms[0])) |
76c1cebc PE |
3226 | && FRAME_RIF (f)->frame_parm_handlers[XFASTINT (parm_index)]) |
3227 | (*FRAME_RIF (f)->frame_parm_handlers[XFASTINT (parm_index)]) | |
6baa22c1 | 3228 | (f, bgcolor, Qnil); |
05fc2ef7 CY |
3229 | } |
3230 | ||
3231 | Fclear_face_cache (Qnil); | |
972f4259 KS |
3232 | } |
3233 | ||
3234 | ||
3235 | void | |
971de7fb | 3236 | x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
972f4259 | 3237 | { |
6045c4fd | 3238 | Lisp_Object font_object; |
e0c8ad78 | 3239 | int fontset = -1; |
6045c4fd PE |
3240 | #ifdef HAVE_X_WINDOWS |
3241 | Lisp_Object font_param = arg; | |
3242 | #endif | |
972f4259 | 3243 | |
178377e1 | 3244 | /* Set the frame parameter back to the old value because we may |
e0c8ad78 KH |
3245 | fail to use ARG as the new parameter value. */ |
3246 | store_frame_param (f, Qfont, oldval); | |
0169d360 | 3247 | |
d507f8d7 KH |
3248 | /* ARG is a fontset name, a font name, a cons of fontset name and a |
3249 | font object, or a font object. In the last case, this function | |
3250 | never fail. */ | |
e0c8ad78 KH |
3251 | if (STRINGP (arg)) |
3252 | { | |
3253 | fontset = fs_query_fontset (arg, 0); | |
3254 | if (fontset < 0) | |
0169d360 | 3255 | { |
d7ea76b4 | 3256 | font_object = font_open_by_name (f, arg); |
e0c8ad78 | 3257 | if (NILP (font_object)) |
42a5b22f | 3258 | error ("Font `%s' is not defined", SSDATA (arg)); |
e0c8ad78 | 3259 | arg = AREF (font_object, FONT_NAME_INDEX); |
0169d360 | 3260 | } |
e0c8ad78 KH |
3261 | else if (fontset > 0) |
3262 | { | |
d7ea76b4 | 3263 | font_object = font_open_by_name (f, fontset_ascii (fontset)); |
e0c8ad78 KH |
3264 | if (NILP (font_object)) |
3265 | error ("Font `%s' is not defined", SDATA (arg)); | |
97d42150 | 3266 | arg = AREF (font_object, FONT_NAME_INDEX); |
e0c8ad78 | 3267 | } |
0169d360 | 3268 | else |
e0c8ad78 | 3269 | error ("The default fontset can't be used for a frame font"); |
0169d360 | 3270 | } |
d507f8d7 KH |
3271 | else if (CONSP (arg) && STRINGP (XCAR (arg)) && FONT_OBJECT_P (XCDR (arg))) |
3272 | { | |
3273 | /* This is the case that the ASCII font of F's fontset XCAR | |
3274 | (arg) is changed to the font XCDR (arg) by | |
3275 | `set-fontset-font'. */ | |
3276 | fontset = fs_query_fontset (XCAR (arg), 0); | |
3277 | if (fontset < 0) | |
3278 | error ("Unknown fontset: %s", SDATA (XCAR (arg))); | |
3279 | font_object = XCDR (arg); | |
3280 | arg = AREF (font_object, FONT_NAME_INDEX); | |
6045c4fd | 3281 | #ifdef HAVE_X_WINDOWS |
581e51e8 | 3282 | font_param = Ffont_get (font_object, QCname); |
6045c4fd | 3283 | #endif |
d507f8d7 | 3284 | } |
e0c8ad78 | 3285 | else if (FONT_OBJECT_P (arg)) |
698ca23e | 3286 | { |
e0c8ad78 | 3287 | font_object = arg; |
6045c4fd | 3288 | #ifdef HAVE_X_WINDOWS |
581e51e8 | 3289 | font_param = Ffont_get (font_object, QCname); |
6045c4fd | 3290 | #endif |
b17ae93a | 3291 | /* This is to store the XLFD font name in the frame parameter for |
057bce6f | 3292 | backward compatibility. We should store the font-object |
e0c8ad78 KH |
3293 | itself in the future. */ |
3294 | arg = AREF (font_object, FONT_NAME_INDEX); | |
b17ae93a | 3295 | fontset = FRAME_FONTSET (f); |
518c4881 KH |
3296 | /* Check if we can use the current fontset. If not, set FONTSET |
3297 | to -1 to generate a new fontset from FONT-OBJECT. */ | |
3298 | if (fontset >= 0) | |
3299 | { | |
3300 | Lisp_Object ascii_font = fontset_ascii (fontset); | |
3301 | Lisp_Object spec = font_spec_from_name (ascii_font); | |
3302 | ||
e483264c SM |
3303 | if (NILP (spec)) |
3304 | signal_error ("Invalid font name", ascii_font); | |
3305 | ||
518c4881 KH |
3306 | if (! font_match_p (spec, font_object)) |
3307 | fontset = -1; | |
3308 | } | |
698ca23e | 3309 | } |
e0c8ad78 KH |
3310 | else |
3311 | signal_error ("Invalid font", arg); | |
972f4259 | 3312 | |
e0c8ad78 KH |
3313 | if (! NILP (Fequal (font_object, oldval))) |
3314 | return; | |
5a9aae2e | 3315 | |
e0c8ad78 KH |
3316 | x_new_font (f, font_object, fontset); |
3317 | store_frame_param (f, Qfont, arg); | |
581e51e8 JD |
3318 | #ifdef HAVE_X_WINDOWS |
3319 | store_frame_param (f, Qfont_param, font_param); | |
3320 | #endif | |
e0c8ad78 KH |
3321 | /* Recalculate toolbar height. */ |
3322 | f->n_tool_bar_rows = 0; | |
acfe4602 | 3323 | |
e0c8ad78 KH |
3324 | /* Ensure we redraw it. */ |
3325 | clear_current_matrices (f); | |
ca03f883 | 3326 | |
acfe4602 MR |
3327 | /* Attempt to hunt down bug#16028. */ |
3328 | SET_FRAME_GARBAGED (f); | |
3329 | ||
e0c8ad78 | 3330 | recompute_basic_faces (f); |
972f4259 KS |
3331 | |
3332 | do_pending_window_change (0); | |
3333 | ||
a6f75881 CY |
3334 | /* We used to call face-set-after-frame-default here, but it leads to |
3335 | recursive calls (since that function can set the `default' face's | |
3336 | font which in turns changes the frame's `font' parameter). | |
3337 | Also I don't know what this call is meant to do, but it seems the | |
3338 | wrong way to do it anyway (it does a lot more work than what seems | |
3339 | reasonable in response to a change to `font'). */ | |
972f4259 KS |
3340 | } |
3341 | ||
3342 | ||
1a356571 | 3343 | void |
971de7fb | 3344 | x_set_font_backend (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) |
1a356571 | 3345 | { |
1a356571 KH |
3346 | if (! NILP (new_value) |
3347 | && !CONSP (new_value)) | |
3348 | { | |
3349 | char *p0, *p1; | |
1bf72735 | 3350 | |
1a356571 | 3351 | CHECK_STRING (new_value); |
42a5b22f | 3352 | p0 = p1 = SSDATA (new_value); |
1a356571 KH |
3353 | new_value = Qnil; |
3354 | while (*p0) | |
3355 | { | |
620f13b0 | 3356 | while (*p1 && ! c_isspace (*p1) && *p1 != ',') p1++; |
1a356571 KH |
3357 | if (p0 < p1) |
3358 | new_value = Fcons (Fintern (make_string (p0, p1 - p0), Qnil), | |
3359 | new_value); | |
3360 | if (*p1) | |
22e64f7c KH |
3361 | { |
3362 | int c; | |
3363 | ||
620f13b0 | 3364 | while ((c = *++p1) && c_isspace (c)); |
22e64f7c | 3365 | } |
1a356571 KH |
3366 | p0 = p1; |
3367 | } | |
8fb9e675 KH |
3368 | new_value = Fnreverse (new_value); |
3369 | } | |
3370 | ||
3371 | if (! NILP (old_value) && ! NILP (Fequal (old_value, new_value))) | |
3372 | return; | |
3373 | ||
e0c8ad78 | 3374 | if (FRAME_FONT (f)) |
dfdf55c0 | 3375 | free_all_realized_faces (Qnil); |
1a356571 | 3376 | |
dfdf55c0 | 3377 | new_value = font_update_drivers (f, NILP (new_value) ? Qt : new_value); |
8fb9e675 | 3378 | if (NILP (new_value)) |
dfdf55c0 KH |
3379 | { |
3380 | if (NILP (old_value)) | |
3381 | error ("No font backend available"); | |
3382 | font_update_drivers (f, old_value); | |
3383 | error ("None of specified font backends are available"); | |
3384 | } | |
8fb9e675 KH |
3385 | store_frame_param (f, Qfont_backend, new_value); |
3386 | ||
e0c8ad78 | 3387 | if (FRAME_FONT (f)) |
8fb9e675 KH |
3388 | { |
3389 | Lisp_Object frame; | |
3390 | ||
3391 | XSETFRAME (frame, f); | |
3392 | x_set_font (f, Fframe_parameter (frame, Qfont), Qnil); | |
3393 | ++face_change_count; | |
94ae2ad4 | 3394 | windows_or_buffers_changed = 18; |
8fb9e675 | 3395 | } |
1a356571 | 3396 | } |
1a356571 KH |
3397 | |
3398 | ||
972f4259 | 3399 | void |
971de7fb | 3400 | x_set_fringe_width (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) |
972f4259 KS |
3401 | { |
3402 | compute_fringe_widths (f, 1); | |
bfeabdc3 JD |
3403 | #ifdef HAVE_X_WINDOWS |
3404 | /* Must adjust this so window managers report correct number of columns. */ | |
3405 | if (FRAME_X_WINDOW (f) != 0) | |
3406 | x_wm_set_size_hint (f, 0, 0); | |
3407 | #endif | |
972f4259 KS |
3408 | } |
3409 | ||
3410 | void | |
971de7fb | 3411 | x_set_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
972f4259 | 3412 | { |
d311d28c | 3413 | CHECK_TYPE_RANGED_INTEGER (int, arg); |
972f4259 | 3414 | |
5af5757b | 3415 | if (XINT (arg) == f->border_width) |
972f4259 KS |
3416 | return; |
3417 | ||
972f4259 | 3418 | if (FRAME_X_WINDOW (f) != 0) |
dac85f4b | 3419 | error ("Cannot change the border width of a frame"); |
972f4259 | 3420 | |
5af5757b | 3421 | f->border_width = XINT (arg); |
972f4259 KS |
3422 | } |
3423 | ||
3424 | void | |
971de7fb | 3425 | x_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
972f4259 | 3426 | { |
5af5757b | 3427 | int old = FRAME_INTERNAL_BORDER_WIDTH (f); |
972f4259 | 3428 | |
d311d28c | 3429 | CHECK_TYPE_RANGED_INTEGER (int, arg); |
5af5757b KS |
3430 | FRAME_INTERNAL_BORDER_WIDTH (f) = XINT (arg); |
3431 | if (FRAME_INTERNAL_BORDER_WIDTH (f) < 0) | |
3432 | FRAME_INTERNAL_BORDER_WIDTH (f) = 0; | |
972f4259 KS |
3433 | |
3434 | #ifdef USE_X_TOOLKIT | |
3435 | if (FRAME_X_OUTPUT (f)->edit_widget) | |
3436 | widget_store_internal_border (FRAME_X_OUTPUT (f)->edit_widget); | |
3437 | #endif | |
3438 | ||
5af5757b | 3439 | if (FRAME_INTERNAL_BORDER_WIDTH (f) == old) |
972f4259 KS |
3440 | return; |
3441 | ||
3442 | if (FRAME_X_WINDOW (f) != 0) | |
3443 | { | |
880e6158 MR |
3444 | x_set_window_size (f, 0, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 1); |
3445 | SET_FRAME_GARBAGED (f); | |
3446 | do_pending_window_change (0); | |
3447 | } | |
3448 | else | |
3449 | SET_FRAME_GARBAGED (f); | |
3450 | } | |
3451 | ||
3452 | void | |
3453 | x_set_right_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |
3454 | { | |
3455 | int old = FRAME_RIGHT_DIVIDER_WIDTH (f); | |
3456 | ||
3457 | CHECK_TYPE_RANGED_INTEGER (int, arg); | |
3458 | FRAME_RIGHT_DIVIDER_WIDTH (f) = XINT (arg); | |
3459 | if (FRAME_RIGHT_DIVIDER_WIDTH (f) < 0) | |
3460 | FRAME_RIGHT_DIVIDER_WIDTH (f) = 0; | |
3461 | ||
3462 | if (FRAME_RIGHT_DIVIDER_WIDTH (f) == old) | |
3463 | return; | |
3464 | ||
3465 | if (FRAME_X_WINDOW (f) != 0) | |
3466 | { | |
3467 | x_set_window_size (f, 0, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 1); | |
3468 | SET_FRAME_GARBAGED (f); | |
3469 | do_pending_window_change (0); | |
3470 | } | |
3471 | else | |
3472 | SET_FRAME_GARBAGED (f); | |
3473 | } | |
3474 | ||
3475 | void | |
3476 | x_set_bottom_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |
3477 | { | |
3478 | int old = FRAME_BOTTOM_DIVIDER_WIDTH (f); | |
3479 | ||
3480 | CHECK_TYPE_RANGED_INTEGER (int, arg); | |
3481 | FRAME_BOTTOM_DIVIDER_WIDTH (f) = XINT (arg); | |
3482 | if (FRAME_BOTTOM_DIVIDER_WIDTH (f) < 0) | |
3483 | FRAME_BOTTOM_DIVIDER_WIDTH (f) = 0; | |
3484 | ||
3485 | if (FRAME_BOTTOM_DIVIDER_WIDTH (f) == old) | |
3486 | return; | |
3487 | ||
3488 | if (FRAME_X_WINDOW (f) != 0) | |
3489 | { | |
3490 | x_set_window_size (f, 0, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 1); | |
972f4259 KS |
3491 | SET_FRAME_GARBAGED (f); |
3492 | do_pending_window_change (0); | |
3493 | } | |
3494 | else | |
3495 | SET_FRAME_GARBAGED (f); | |
3496 | } | |
3497 | ||
3498 | void | |
971de7fb | 3499 | x_set_visibility (struct frame *f, Lisp_Object value, Lisp_Object oldval) |
972f4259 KS |
3500 | { |
3501 | Lisp_Object frame; | |
3502 | XSETFRAME (frame, f); | |
3503 | ||
3504 | if (NILP (value)) | |
3505 | Fmake_frame_invisible (frame, Qt); | |
3506 | else if (EQ (value, Qicon)) | |
3507 | Ficonify_frame (frame); | |
3508 | else | |
3509 | Fmake_frame_visible (frame); | |
3510 | } | |
3511 | ||
3512 | void | |
971de7fb | 3513 | x_set_autoraise (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
972f4259 KS |
3514 | { |
3515 | f->auto_raise = !EQ (Qnil, arg); | |
3516 | } | |
3517 | ||
3518 | void | |
971de7fb | 3519 | x_set_autolower (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
972f4259 KS |
3520 | { |
3521 | f->auto_lower = !EQ (Qnil, arg); | |
3522 | } | |
3523 | ||
3524 | void | |
971de7fb | 3525 | x_set_unsplittable (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
972f4259 KS |
3526 | { |
3527 | f->no_split = !NILP (arg); | |
3528 | } | |
3529 | ||
3530 | void | |
971de7fb | 3531 | x_set_vertical_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
972f4259 KS |
3532 | { |
3533 | if ((EQ (arg, Qleft) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f)) | |
3534 | || (EQ (arg, Qright) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) | |
3535 | || (NILP (arg) && FRAME_HAS_VERTICAL_SCROLL_BARS (f)) | |
3536 | || (!NILP (arg) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f))) | |
3537 | { | |
3538 | FRAME_VERTICAL_SCROLL_BAR_TYPE (f) | |
3539 | = (NILP (arg) | |
3540 | ? vertical_scroll_bar_none | |
3541 | : EQ (Qleft, arg) | |
3542 | ? vertical_scroll_bar_left | |
3543 | : EQ (Qright, arg) | |
3544 | ? vertical_scroll_bar_right | |
6b61353c KH |
3545 | : EQ (Qleft, Vdefault_frame_scroll_bars) |
3546 | ? vertical_scroll_bar_left | |
3547 | : EQ (Qright, Vdefault_frame_scroll_bars) | |
3548 | ? vertical_scroll_bar_right | |
3549 | : vertical_scroll_bar_none); | |
972f4259 KS |
3550 | |
3551 | /* We set this parameter before creating the X window for the | |
3552 | frame, so we can get the geometry right from the start. | |
3553 | However, if the window hasn't been created yet, we shouldn't | |
3554 | call x_set_window_size. */ | |
3555 | if (FRAME_X_WINDOW (f)) | |
880e6158 MR |
3556 | x_set_window_size (f, 0, FRAME_TEXT_WIDTH (f), |
3557 | FRAME_TEXT_HEIGHT (f), 1); | |
972f4259 KS |
3558 | do_pending_window_change (0); |
3559 | } | |
3560 | } | |
3561 | ||
3562 | void | |
971de7fb | 3563 | x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
972f4259 | 3564 | { |
880e6158 | 3565 | int unit = FRAME_COLUMN_WIDTH (f); |
972f4259 KS |
3566 | |
3567 | if (NILP (arg)) | |
3568 | { | |
3569 | x_set_scroll_bar_default_width (f); | |
3570 | ||
3571 | if (FRAME_X_WINDOW (f)) | |
880e6158 MR |
3572 | x_set_window_size (f, 0, FRAME_TEXT_WIDTH (f), |
3573 | FRAME_TEXT_HEIGHT (f), 1); | |
972f4259 KS |
3574 | do_pending_window_change (0); |
3575 | } | |
b8898fda | 3576 | else if (RANGED_INTEGERP (1, arg, INT_MAX) |
5af5757b | 3577 | && XFASTINT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f)) |
972f4259 | 3578 | { |
5af5757b | 3579 | FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFASTINT (arg); |
880e6158 | 3580 | FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + unit - 1) / unit; |
972f4259 | 3581 | if (FRAME_X_WINDOW (f)) |
880e6158 MR |
3582 | x_set_window_size (f, 0, FRAME_TEXT_WIDTH (f), |
3583 | FRAME_TEXT_HEIGHT (f), 1); | |
972f4259 KS |
3584 | do_pending_window_change (0); |
3585 | } | |
3586 | ||
44c5e192 MR |
3587 | /* Eventually remove the following call. It should have been done by |
3588 | x_set_window_size already. */ | |
880e6158 | 3589 | change_frame_size (f, 0, 0, 0, 0, 0, 1); |
972f4259 KS |
3590 | XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0; |
3591 | XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0; | |
3592 | } | |
3593 | ||
0a708637 | 3594 | void |
971de7fb | 3595 | x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
0a708637 GM |
3596 | { |
3597 | double alpha = 1.0; | |
3598 | double newval[2]; | |
b8898fda | 3599 | int i; |
0a708637 GM |
3600 | Lisp_Object item; |
3601 | ||
3602 | for (i = 0; i < 2; i++) | |
3603 | { | |
3604 | newval[i] = 1.0; | |
3605 | if (CONSP (arg)) | |
3606 | { | |
3607 | item = CAR (arg); | |
3608 | arg = CDR (arg); | |
3609 | } | |
3610 | else | |
1fd877d6 | 3611 | item = arg; |
0a708637 | 3612 | |
62e62ea8 CY |
3613 | if (NILP (item)) |
3614 | alpha = - 1.0; | |
3615 | else if (FLOATP (item)) | |
3616 | { | |
3617 | alpha = XFLOAT_DATA (item); | |
7216e43b | 3618 | if (! (0 <= alpha && alpha <= 1.0)) |
62e62ea8 CY |
3619 | args_out_of_range (make_float (0.0), make_float (1.0)); |
3620 | } | |
3621 | else if (INTEGERP (item)) | |
3622 | { | |
b8898fda | 3623 | EMACS_INT ialpha = XINT (item); |
7216e43b | 3624 | if (! (0 <= ialpha && alpha <= 100)) |
62e62ea8 | 3625 | args_out_of_range (make_number (0), make_number (100)); |
7216e43b | 3626 | alpha = ialpha / 100.0; |
62e62ea8 CY |
3627 | } |
3628 | else | |
3629 | wrong_type_argument (Qnumberp, item); | |
0a708637 GM |
3630 | newval[i] = alpha; |
3631 | } | |
3632 | ||
3633 | for (i = 0; i < 2; i++) | |
3634 | f->alpha[i] = newval[i]; | |
3635 | ||
59bc82c0 | 3636 | #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) |
4d7e6e51 | 3637 | block_input (); |
0a708637 | 3638 | x_set_frame_alpha (f); |
4d7e6e51 | 3639 | unblock_input (); |
0a708637 GM |
3640 | #endif |
3641 | ||
3642 | return; | |
3643 | } | |
3644 | ||
582ed56c DA |
3645 | #ifndef HAVE_NS |
3646 | ||
7a0c745a DA |
3647 | /* Non-zero if mouse is grabbed on DPYINFO |
3648 | and we know the frame where it is. */ | |
3649 | ||
3650 | bool x_mouse_grabbed (Display_Info *dpyinfo) | |
3651 | { | |
3652 | return (dpyinfo->grabbed | |
3653 | && dpyinfo->last_mouse_frame | |
3654 | && FRAME_LIVE_P (dpyinfo->last_mouse_frame)); | |
3655 | } | |
3656 | ||
18da0d8a DA |
3657 | /* Re-highlight something with mouse-face properties |
3658 | on DPYINFO using saved frame and mouse position. */ | |
3659 | ||
3660 | void | |
3661 | x_redo_mouse_highlight (Display_Info *dpyinfo) | |
3662 | { | |
3663 | if (dpyinfo->last_mouse_motion_frame | |
3664 | && FRAME_LIVE_P (dpyinfo->last_mouse_motion_frame)) | |
3665 | note_mouse_highlight (dpyinfo->last_mouse_motion_frame, | |
3666 | dpyinfo->last_mouse_motion_x, | |
3667 | dpyinfo->last_mouse_motion_y); | |
3668 | } | |
3669 | ||
582ed56c DA |
3670 | #endif /* HAVE_NS */ |
3671 | ||
972f4259 KS |
3672 | /* Subroutines of creating an X frame. */ |
3673 | ||
3674 | /* Make sure that Vx_resource_name is set to a reasonable value. | |
3675 | Fix it up, or set it to `emacs' if it is too hopeless. */ | |
3676 | ||
3677 | void | |
971de7fb | 3678 | validate_x_resource_name (void) |
972f4259 | 3679 | { |
8a401434 | 3680 | ptrdiff_t len = 0; |
972f4259 | 3681 | /* Number of valid characters in the resource name. */ |
8a401434 | 3682 | ptrdiff_t good_count = 0; |
972f4259 | 3683 | /* Number of invalid characters in the resource name. */ |
8a401434 | 3684 | ptrdiff_t bad_count = 0; |
972f4259 | 3685 | Lisp_Object new; |
8a401434 | 3686 | ptrdiff_t i; |
972f4259 KS |
3687 | |
3688 | if (!STRINGP (Vx_resource_class)) | |
3689 | Vx_resource_class = build_string (EMACS_CLASS); | |
3690 | ||
3691 | if (STRINGP (Vx_resource_name)) | |
3692 | { | |
3693 | unsigned char *p = SDATA (Vx_resource_name); | |
972f4259 KS |
3694 | |
3695 | len = SBYTES (Vx_resource_name); | |
3696 | ||
3697 | /* Only letters, digits, - and _ are valid in resource names. | |
3698 | Count the valid characters and count the invalid ones. */ | |
3699 | for (i = 0; i < len; i++) | |
3700 | { | |
3701 | int c = p[i]; | |
3702 | if (! ((c >= 'a' && c <= 'z') | |
3703 | || (c >= 'A' && c <= 'Z') | |
3704 | || (c >= '0' && c <= '9') | |
3705 | || c == '-' || c == '_')) | |
3706 | bad_count++; | |
3707 | else | |
3708 | good_count++; | |
3709 | } | |
3710 | } | |
3711 | else | |
3712 | /* Not a string => completely invalid. */ | |
3713 | bad_count = 5, good_count = 0; | |
3714 | ||
3715 | /* If name is valid already, return. */ | |
3716 | if (bad_count == 0) | |
3717 | return; | |
3718 | ||
8a401434 PE |
3719 | /* If name is entirely invalid, or nearly so, or is so implausibly |
3720 | large that alloca might not work, use `emacs'. */ | |
3721 | if (good_count < 2 || MAX_ALLOCA - sizeof ".customization" < len) | |
972f4259 KS |
3722 | { |
3723 | Vx_resource_name = build_string ("emacs"); | |
3724 | return; | |
3725 | } | |
3726 | ||
3727 | /* Name is partly valid. Copy it and replace the invalid characters | |
3728 | with underscores. */ | |
3729 | ||
3730 | Vx_resource_name = new = Fcopy_sequence (Vx_resource_name); | |
3731 | ||
3732 | for (i = 0; i < len; i++) | |
3733 | { | |
3734 | int c = SREF (new, i); | |
3735 | if (! ((c >= 'a' && c <= 'z') | |
3736 | || (c >= 'A' && c <= 'Z') | |
3737 | || (c >= '0' && c <= '9') | |
3738 | || c == '-' || c == '_')) | |
3739 | SSET (new, i, '_'); | |
3740 | } | |
3741 | } | |
3742 | ||
b5251fe7 | 3743 | /* Get specified attribute from resource database RDB. |
972f4259 KS |
3744 | See Fx_get_resource below for other parameters. */ |
3745 | ||
3746 | static Lisp_Object | |
971de7fb | 3747 | xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Lisp_Object component, Lisp_Object subclass) |
972f4259 KS |
3748 | { |
3749 | register char *value; | |
3750 | char *name_key; | |
3751 | char *class_key; | |
3752 | ||
3753 | CHECK_STRING (attribute); | |
3754 | CHECK_STRING (class); | |
3755 | ||
3756 | if (!NILP (component)) | |
3757 | CHECK_STRING (component); | |
3758 | if (!NILP (subclass)) | |
3759 | CHECK_STRING (subclass); | |
3760 | if (NILP (component) != NILP (subclass)) | |
3761 | error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither"); | |
3762 | ||
3763 | validate_x_resource_name (); | |
3764 | ||
3765 | /* Allocate space for the components, the dots which separate them, | |
3766 | and the final '\0'. Make them big enough for the worst case. */ | |
38182d90 PE |
3767 | name_key = alloca (SBYTES (Vx_resource_name) |
3768 | + (STRINGP (component) | |
3769 | ? SBYTES (component) : 0) | |
3770 | + SBYTES (attribute) | |
3771 | + 3); | |
3772 | ||
3773 | class_key = alloca (SBYTES (Vx_resource_class) | |
3774 | + SBYTES (class) | |
3775 | + (STRINGP (subclass) | |
3776 | ? SBYTES (subclass) : 0) | |
3777 | + 3); | |
972f4259 KS |
3778 | |
3779 | /* Start with emacs.FRAMENAME for the name (the specific one) | |
3780 | and with `Emacs' for the class key (the general one). */ | |
42a5b22f PE |
3781 | strcpy (name_key, SSDATA (Vx_resource_name)); |
3782 | strcpy (class_key, SSDATA (Vx_resource_class)); | |
972f4259 KS |
3783 | |
3784 | strcat (class_key, "."); | |
42a5b22f | 3785 | strcat (class_key, SSDATA (class)); |
972f4259 KS |
3786 | |
3787 | if (!NILP (component)) | |
3788 | { | |
3789 | strcat (class_key, "."); | |
42a5b22f | 3790 | strcat (class_key, SSDATA (subclass)); |
972f4259 KS |
3791 | |
3792 | strcat (name_key, "."); | |
42a5b22f | 3793 | strcat (name_key, SSDATA (component)); |
972f4259 KS |
3794 | } |
3795 | ||
3796 | strcat (name_key, "."); | |
42a5b22f | 3797 | strcat (name_key, SSDATA (attribute)); |
972f4259 KS |
3798 | |
3799 | value = x_get_string_resource (rdb, name_key, class_key); | |
3800 | ||
7d652d97 | 3801 | if (value && *value) |
972f4259 KS |
3802 | return build_string (value); |
3803 | else | |
3804 | return Qnil; | |
3805 | } | |
3806 | ||
3807 | ||
3808 | DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 2, 4, 0, | |
3809 | doc: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database. | |
3810 | This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the | |
3811 | class, where INSTANCE is the name under which Emacs was invoked, or | |
3812 | the name specified by the `-name' or `-rn' command-line arguments. | |
3813 | ||
3814 | The optional arguments COMPONENT and SUBCLASS add to the key and the | |
3815 | class, respectively. You must specify both of them or neither. | |
3816 | If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE' | |
3817 | and the class is `Emacs.CLASS.SUBCLASS'. */) | |
2bf7d27a DA |
3818 | (Lisp_Object attribute, Lisp_Object class, Lisp_Object component, |
3819 | Lisp_Object subclass) | |
972f4259 | 3820 | { |
7452b7bd | 3821 | check_window_system (NULL); |
972f4259 KS |
3822 | |
3823 | return xrdb_get_resource (check_x_display_info (Qnil)->xrdb, | |
3824 | attribute, class, component, subclass); | |
3825 | } | |
3826 | ||
3827 | /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */ | |
3828 | ||
3829 | Lisp_Object | |
2bf7d27a DA |
3830 | display_x_get_resource (Display_Info *dpyinfo, Lisp_Object attribute, |
3831 | Lisp_Object class, Lisp_Object component, | |
3832 | Lisp_Object subclass) | |
972f4259 KS |
3833 | { |
3834 | return xrdb_get_resource (dpyinfo->xrdb, | |
3835 | attribute, class, component, subclass); | |
3836 | } | |
3837 | ||
018c5e19 PE |
3838 | #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT |
3839 | /* Used when C code wants a resource value. */ | |
3840 | /* Called from oldXMenu/Create.c. */ | |
3841 | char * | |
3842 | x_get_resource_string (const char *attribute, const char *class) | |
3843 | { | |
8a401434 | 3844 | char *result; |
018c5e19 | 3845 | struct frame *sf = SELECTED_FRAME (); |
8a401434 PE |
3846 | ptrdiff_t invocation_namelen = SBYTES (Vinvocation_name); |
3847 | USE_SAFE_ALLOCA; | |
018c5e19 PE |
3848 | |
3849 | /* Allocate space for the components, the dots which separate them, | |
3850 | and the final '\0'. */ | |
98c6f1e3 PE |
3851 | char *name_key = SAFE_ALLOCA (invocation_namelen + strlen (attribute) + 2); |
3852 | char *class_key = alloca ((sizeof (EMACS_CLASS) - 1) + strlen (class) + 2); | |
018c5e19 | 3853 | |
8a401434 | 3854 | esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute); |
018c5e19 PE |
3855 | sprintf (class_key, "%s.%s", EMACS_CLASS, class); |
3856 | ||
aad3612f | 3857 | result = x_get_string_resource (FRAME_DISPLAY_INFO (sf)->xrdb, |
8a401434 PE |
3858 | name_key, class_key); |
3859 | SAFE_FREE (); | |
3860 | return result; | |
018c5e19 PE |
3861 | } |
3862 | #endif | |
3863 | ||
972f4259 KS |
3864 | /* Return the value of parameter PARAM. |
3865 | ||
3866 | First search ALIST, then Vdefault_frame_alist, then the X defaults | |
3867 | database, using ATTRIBUTE as the attribute name and CLASS as its class. | |
3868 | ||
3869 | Convert the resource to the type specified by desired_type. | |
3870 | ||
3871 | If no default is specified, return Qunbound. If you call | |
3872 | x_get_arg, make sure you deal with Qunbound in a reasonable way, | |
3873 | and don't let it get stored in any Lisp-visible variables! */ | |
3874 | ||
3875 | Lisp_Object | |
eec47d6b DN |
3876 | x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param, |
3877 | const char *attribute, const char *class, enum resource_types type) | |
972f4259 KS |
3878 | { |
3879 | register Lisp_Object tem; | |
3880 | ||
3881 | tem = Fassq (param, alist); | |
d00368cf RS |
3882 | |
3883 | if (!NILP (tem)) | |
3884 | { | |
3885 | /* If we find this parm in ALIST, clear it out | |
3886 | so that it won't be "left over" at the end. */ | |
5f694926 | 3887 | Lisp_Object tail; |
d00368cf | 3888 | XSETCAR (tem, Qnil); |
5f694926 RS |
3889 | /* In case the parameter appears more than once in the alist, |
3890 | clear it out. */ | |
3891 | for (tail = alist; CONSP (tail); tail = XCDR (tail)) | |
3892 | if (CONSP (XCAR (tail)) | |
3893 | && EQ (XCAR (XCAR (tail)), param)) | |
3894 | XSETCAR (XCAR (tail), Qnil); | |
d00368cf RS |
3895 | } |
3896 | else | |
972f4259 | 3897 | tem = Fassq (param, Vdefault_frame_alist); |
d00368cf RS |
3898 | |
3899 | /* If it wasn't specified in ALIST or the Lisp-level defaults, | |
3900 | look in the X resources. */ | |
972f4259 KS |
3901 | if (EQ (tem, Qnil)) |
3902 | { | |
4e23bedb | 3903 | if (attribute && dpyinfo) |
972f4259 KS |
3904 | { |
3905 | tem = display_x_get_resource (dpyinfo, | |
3906 | build_string (attribute), | |
3907 | build_string (class), | |
3908 | Qnil, Qnil); | |
3909 | ||
3910 | if (NILP (tem)) | |
3911 | return Qunbound; | |
3912 | ||
3913 | switch (type) | |
3914 | { | |
3915 | case RES_TYPE_NUMBER: | |
42a5b22f | 3916 | return make_number (atoi (SSDATA (tem))); |
972f4259 | 3917 | |
93318cbd | 3918 | case RES_TYPE_BOOLEAN_NUMBER: |
42a5b22f PE |
3919 | if (!strcmp (SSDATA (tem), "on") |
3920 | || !strcmp (SSDATA (tem), "true")) | |
93318cbd | 3921 | return make_number (1); |
42a5b22f | 3922 | return make_number (atoi (SSDATA (tem))); |
93318cbd JD |
3923 | break; |
3924 | ||
972f4259 | 3925 | case RES_TYPE_FLOAT: |
42a5b22f | 3926 | return make_float (atof (SSDATA (tem))); |
972f4259 KS |
3927 | |
3928 | case RES_TYPE_BOOLEAN: | |
3929 | tem = Fdowncase (tem); | |
42a5b22f | 3930 | if (!strcmp (SSDATA (tem), "on") |
edfda783 | 3931 | #ifdef HAVE_NS |
42a5b22f | 3932 | || !strcmp (SSDATA (tem), "yes") |
edfda783 | 3933 | #endif |
42a5b22f | 3934 | || !strcmp (SSDATA (tem), "true")) |
972f4259 KS |
3935 | return Qt; |
3936 | else | |
3937 | return Qnil; | |
3938 | ||
3939 | case RES_TYPE_STRING: | |
3940 | return tem; | |
3941 | ||
3942 | case RES_TYPE_SYMBOL: | |
3943 | /* As a special case, we map the values `true' and `on' | |
3944 | to Qt, and `false' and `off' to Qnil. */ | |
3945 | { | |
3946 | Lisp_Object lower; | |
3947 | lower = Fdowncase (tem); | |
42a5b22f | 3948 | if (!strcmp (SSDATA (lower), "on") |
edfda783 | 3949 | #ifdef HAVE_NS |
42a5b22f | 3950 | || !strcmp (SSDATA (lower), "yes") |
edfda783 | 3951 | #endif |
42a5b22f | 3952 | || !strcmp (SSDATA (lower), "true")) |
972f4259 | 3953 | return Qt; |
42a5b22f | 3954 | else if (!strcmp (SSDATA (lower), "off") |
edfda783 | 3955 | #ifdef HAVE_NS |
42a5b22f | 3956 | || !strcmp (SSDATA (lower), "no") |
edfda783 | 3957 | #endif |
42a5b22f | 3958 | || !strcmp (SSDATA (lower), "false")) |
972f4259 KS |
3959 | return Qnil; |
3960 | else | |
3961 | return Fintern (tem, Qnil); | |
3962 | } | |
3963 | ||
3964 | default: | |
1088b922 | 3965 | emacs_abort (); |
972f4259 KS |
3966 | } |
3967 | } | |
3968 | else | |
3969 | return Qunbound; | |
3970 | } | |
3971 | return Fcdr (tem); | |
3972 | } | |
3973 | ||
2f7c71a1 | 3974 | static Lisp_Object |
eec47d6b DN |
3975 | x_frame_get_arg (struct frame *f, Lisp_Object alist, Lisp_Object param, |
3976 | const char *attribute, const char *class, | |
3977 | enum resource_types type) | |
972f4259 | 3978 | { |
aad3612f | 3979 | return x_get_arg (FRAME_DISPLAY_INFO (f), |
972f4259 KS |
3980 | alist, param, attribute, class, type); |
3981 | } | |
3982 | ||
3983 | /* Like x_frame_get_arg, but also record the value in f->param_alist. */ | |
3984 | ||
3985 | Lisp_Object | |
eec47d6b DN |
3986 | x_frame_get_and_record_arg (struct frame *f, Lisp_Object alist, |
3987 | Lisp_Object param, | |
3988 | const char *attribute, const char *class, | |
3989 | enum resource_types type) | |
972f4259 KS |
3990 | { |
3991 | Lisp_Object value; | |
3992 | ||
aad3612f | 3993 | value = x_get_arg (FRAME_DISPLAY_INFO (f), alist, param, |
972f4259 | 3994 | attribute, class, type); |
edd1c685 | 3995 | if (! NILP (value) && ! EQ (value, Qunbound)) |
972f4259 KS |
3996 | store_frame_param (f, param, value); |
3997 | ||
3998 | return value; | |
3999 | } | |
4000 | ||
4001 | ||
4002 | /* Record in frame F the specified or default value according to ALIST | |
4003 | of the parameter named PROP (a Lisp symbol). | |
4004 | If no value is specified for PROP, look for an X default for XPROP | |
4005 | on the frame named NAME. | |
4006 | If that is not found either, use the value DEFLT. */ | |
4007 | ||
4008 | Lisp_Object | |
eec47d6b DN |
4009 | x_default_parameter (struct frame *f, Lisp_Object alist, Lisp_Object prop, |
4010 | Lisp_Object deflt, const char *xprop, const char *xclass, | |
4011 | enum resource_types type) | |
972f4259 KS |
4012 | { |
4013 | Lisp_Object tem; | |
4014 | ||
4015 | tem = x_frame_get_arg (f, alist, prop, xprop, xclass, type); | |
4016 | if (EQ (tem, Qunbound)) | |
4017 | tem = deflt; | |
6c6f1994 | 4018 | x_set_frame_parameters (f, list1 (Fcons (prop, tem))); |
972f4259 KS |
4019 | return tem; |
4020 | } | |
4021 | ||
4022 | ||
e543ae91 JD |
4023 | #if !defined (HAVE_X_WINDOWS) && defined (NoValue) |
4024 | ||
4025 | /* | |
4026 | * XParseGeometry parses strings of the form | |
4027 | * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where | |
4028 | * width, height, xoffset, and yoffset are unsigned integers. | |
4029 | * Example: "=80x24+300-49" | |
4030 | * The equal sign is optional. | |
4031 | * It returns a bitmask that indicates which of the four values | |
4032 | * were actually found in the string. For each value found, | |
4033 | * the corresponding argument is updated; for each value | |
4034 | * not found, the corresponding argument is left unchanged. | |
4035 | */ | |
4036 | ||
4037 | static int | |
e543ae91 JD |
4038 | XParseGeometry (char *string, |
4039 | int *x, int *y, | |
4040 | unsigned int *width, unsigned int *height) | |
4041 | { | |
4042 | int mask = NoValue; | |
05642592 | 4043 | char *strind; |
2d9783e0 | 4044 | unsigned long tempWidth, tempHeight; |
05642592 | 4045 | long int tempX, tempY; |
e543ae91 JD |
4046 | char *nextCharacter; |
4047 | ||
05642592 PE |
4048 | if (string == NULL || *string == '\0') |
4049 | return mask; | |
e543ae91 JD |
4050 | if (*string == '=') |
4051 | string++; /* ignore possible '=' at beg of geometry spec */ | |
4052 | ||
05642592 | 4053 | strind = string; |
e543ae91 JD |
4054 | if (*strind != '+' && *strind != '-' && *strind != 'x') |
4055 | { | |
05642592 | 4056 | tempWidth = strtoul (strind, &nextCharacter, 10); |
e543ae91 | 4057 | if (strind == nextCharacter) |
05642592 | 4058 | return 0; |
e543ae91 JD |
4059 | strind = nextCharacter; |
4060 | mask |= WidthValue; | |
4061 | } | |
4062 | ||
4063 | if (*strind == 'x' || *strind == 'X') | |
4064 | { | |
4065 | strind++; | |
05642592 | 4066 | tempHeight = strtoul (strind, &nextCharacter, 10); |
e543ae91 | 4067 | if (strind == nextCharacter) |
05642592 | 4068 | return 0; |
e543ae91 JD |
4069 | strind = nextCharacter; |
4070 | mask |= HeightValue; | |
4071 | } | |
4072 | ||
05642592 | 4073 | if (*strind == '+' || *strind == '-') |
e543ae91 JD |
4074 | { |
4075 | if (*strind == '-') | |
05642592 PE |
4076 | mask |= XNegative; |
4077 | tempX = strtol (strind, &nextCharacter, 10); | |
4078 | if (strind == nextCharacter) | |
4079 | return 0; | |
4080 | strind = nextCharacter; | |
e543ae91 | 4081 | mask |= XValue; |
05642592 | 4082 | if (*strind == '+' || *strind == '-') |
e543ae91 JD |
4083 | { |
4084 | if (*strind == '-') | |
05642592 PE |
4085 | mask |= YNegative; |
4086 | tempY = strtol (strind, &nextCharacter, 10); | |
4087 | if (strind == nextCharacter) | |
4088 | return 0; | |
4089 | strind = nextCharacter; | |
e543ae91 JD |
4090 | mask |= YValue; |
4091 | } | |
4092 | } | |
4093 | ||
4094 | /* If strind isn't at the end of the string then it's an invalid | |
4095 | geometry specification. */ | |
4096 | ||
05642592 PE |
4097 | if (*strind != '\0') |
4098 | return 0; | |
e543ae91 JD |
4099 | |
4100 | if (mask & XValue) | |
05642592 | 4101 | *x = clip_to_bounds (INT_MIN, tempX, INT_MAX); |
e543ae91 | 4102 | if (mask & YValue) |
05642592 | 4103 | *y = clip_to_bounds (INT_MIN, tempY, INT_MAX); |
e543ae91 | 4104 | if (mask & WidthValue) |
05642592 | 4105 | *width = min (tempWidth, UINT_MAX); |
e543ae91 | 4106 | if (mask & HeightValue) |
05642592 PE |
4107 | *height = min (tempHeight, UINT_MAX); |
4108 | return mask; | |
e543ae91 JD |
4109 | } |
4110 | ||
4111 | #endif /* !defined (HAVE_X_WINDOWS) && defined (NoValue) */ | |
972f4259 KS |
4112 | |
4113 | \f | |
7ab5d780 GM |
4114 | /* NS used to define x-parse-geometry in ns-win.el, but that confused |
4115 | make-docfile: the documentation string in ns-win.el was used for | |
4116 | x-parse-geometry even in non-NS builds. | |
4117 | ||
4118 | With two definitions of x-parse-geometry in this file, various | |
4119 | things still get confused (eg M-x apropos documentation), so that | |
4120 | it is best if the two definitions just share the same doc-string. | |
4121 | */ | |
972f4259 | 4122 | DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0, |
7ab5d780 | 4123 | doc: /* Parse a display geometry string STRING. |
972f4259 KS |
4124 | Returns an alist of the form ((top . TOP), (left . LEFT) ... ). |
4125 | The properties returned may include `top', `left', `height', and `width'. | |
7ab5d780 | 4126 | For X, the value of `left' or `top' may be an integer, |
972f4259 | 4127 | or a list (+ N) meaning N pixels relative to top/left corner, |
7ab5d780 GM |
4128 | or a list (- N) meaning -N pixels relative to bottom/right corner. |
4129 | On Nextstep, this just calls `ns-parse-geometry'. */) | |
5842a27b | 4130 | (Lisp_Object string) |
972f4259 KS |
4131 | { |
4132 | int geometry, x, y; | |
4133 | unsigned int width, height; | |
4134 | Lisp_Object result; | |
4135 | ||
4136 | CHECK_STRING (string); | |
4137 | ||
e543ae91 JD |
4138 | #ifdef HAVE_NS |
4139 | if (strchr (SSDATA (string), ' ') != NULL) | |
4140 | return call1 (Qns_parse_geometry, string); | |
4141 | #endif | |
51b59d79 | 4142 | geometry = XParseGeometry (SSDATA (string), |
972f4259 | 4143 | &x, &y, &width, &height); |
972f4259 KS |
4144 | result = Qnil; |
4145 | if (geometry & XValue) | |
4146 | { | |
4147 | Lisp_Object element; | |
4148 | ||
4149 | if (x >= 0 && (geometry & XNegative)) | |
6c6f1994 | 4150 | element = list3 (Qleft, Qminus, make_number (-x)); |
972f4259 | 4151 | else if (x < 0 && ! (geometry & XNegative)) |
6c6f1994 | 4152 | element = list3 (Qleft, Qplus, make_number (x)); |
972f4259 KS |
4153 | else |
4154 | element = Fcons (Qleft, make_number (x)); | |
4155 | result = Fcons (element, result); | |
4156 | } | |
4157 | ||
4158 | if (geometry & YValue) | |
4159 | { | |
4160 | Lisp_Object element; | |
4161 | ||
4162 | if (y >= 0 && (geometry & YNegative)) | |
6c6f1994 | 4163 | element = list3 (Qtop, Qminus, make_number (-y)); |
972f4259 | 4164 | else if (y < 0 && ! (geometry & YNegative)) |
6c6f1994 | 4165 | element = list3 (Qtop, Qplus, make_number (y)); |
972f4259 KS |
4166 | else |
4167 | element = Fcons (Qtop, make_number (y)); | |
4168 | result = Fcons (element, result); | |
4169 | } | |
4170 | ||
4171 | if (geometry & WidthValue) | |
4172 | result = Fcons (Fcons (Qwidth, make_number (width)), result); | |
4173 | if (geometry & HeightValue) | |
4174 | result = Fcons (Fcons (Qheight, make_number (height)), result); | |
4175 | ||
4176 | return result; | |
7ab5d780 | 4177 | } |
dc4db71c | 4178 | |
972f4259 KS |
4179 | |
4180 | /* Calculate the desired size and position of frame F. | |
4181 | Return the flags saying which aspects were specified. | |
4182 | ||
4183 | Also set the win_gravity and size_hint_flags of F. | |
4184 | ||
4185 | Adjust height for toolbar if TOOLBAR_P is 1. | |
4186 | ||
4187 | This function does not make the coordinates positive. */ | |
4188 | ||
c024ac08 | 4189 | #define DEFAULT_ROWS 35 |
972f4259 KS |
4190 | #define DEFAULT_COLS 80 |
4191 | ||
959067a1 DA |
4192 | long |
4193 | x_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p) | |
972f4259 KS |
4194 | { |
4195 | register Lisp_Object tem0, tem1, tem2; | |
4196 | long window_prompting = 0; | |
aad3612f | 4197 | Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f); |
972f4259 KS |
4198 | |
4199 | /* Default values if we fall through. | |
4200 | Actually, if that happens we should get | |
4201 | window manager prompting. */ | |
880e6158 | 4202 | SET_FRAME_WIDTH (f, DEFAULT_COLS * FRAME_COLUMN_WIDTH (f)); |
5af5757b | 4203 | SET_FRAME_COLS (f, DEFAULT_COLS); |
880e6158 | 4204 | SET_FRAME_HEIGHT (f, DEFAULT_ROWS * FRAME_LINE_HEIGHT (f)); |
5af5757b | 4205 | FRAME_LINES (f) = DEFAULT_ROWS; |
880e6158 | 4206 | |
972f4259 KS |
4207 | /* Window managers expect that if program-specified |
4208 | positions are not (0,0), they're intentional, not defaults. */ | |
5af5757b KS |
4209 | f->top_pos = 0; |
4210 | f->left_pos = 0; | |
972f4259 | 4211 | |
880e6158 | 4212 | /* Ensure that old new_width and new_height will not override the |
972f4259 KS |
4213 | values set here. */ |
4214 | /* ++KFS: This was specific to W32, but seems ok for all platforms */ | |
880e6158 | 4215 | f->new_width = f->new_height = f->new_pixelwise = 0; |
972f4259 KS |
4216 | |
4217 | tem0 = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER); | |
4218 | tem1 = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER); | |
4219 | tem2 = x_get_arg (dpyinfo, parms, Quser_size, 0, 0, RES_TYPE_NUMBER); | |
4220 | if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound)) | |
4221 | { | |
4222 | if (!EQ (tem0, Qunbound)) | |
4223 | { | |
4224 | CHECK_NUMBER (tem0); | |
b8898fda PE |
4225 | if (! (0 <= XINT (tem0) && XINT (tem0) <= INT_MAX)) |
4226 | xsignal1 (Qargs_out_of_range, tem0); | |
5af5757b | 4227 | FRAME_LINES (f) = XINT (tem0); |
972f4259 KS |
4228 | } |
4229 | if (!EQ (tem1, Qunbound)) | |
4230 | { | |
4231 | CHECK_NUMBER (tem1); | |
b8898fda PE |
4232 | if (! (0 <= XINT (tem1) && XINT (tem1) <= INT_MAX)) |
4233 | xsignal1 (Qargs_out_of_range, tem1); | |
5af5757b | 4234 | SET_FRAME_COLS (f, XINT (tem1)); |
972f4259 KS |
4235 | } |
4236 | if (!NILP (tem2) && !EQ (tem2, Qunbound)) | |
4237 | window_prompting |= USSize; | |
4238 | else | |
4239 | window_prompting |= PSize; | |
4240 | } | |
4241 | ||
972f4259 KS |
4242 | |
4243 | /* This used to be done _before_ calling x_figure_window_size, but | |
4244 | since the height is reset here, this was really a no-op. I | |
4245 | assume that moving it here does what Gerd intended (although he | |
4246 | no longer can remember what that was... ++KFS, 2003-03-25. */ | |
4247 | ||
4248 | /* Add the tool-bar height to the initial frame height so that the | |
4249 | user gets a text display area of the size he specified with -g or | |
4250 | via .Xdefaults. Later changes of the tool-bar height don't | |
4251 | change the frame size. This is done so that users can create | |
4252 | tall Emacs frames without having to guess how tall the tool-bar | |
4253 | will get. */ | |
880e6158 | 4254 | if (toolbar_p && FRAME_TOOL_BAR_HEIGHT (f)) |
972f4259 KS |
4255 | { |
4256 | int margin, relief, bar_height; | |
4257 | ||
4258 | relief = (tool_bar_button_relief >= 0 | |
4259 | ? tool_bar_button_relief | |
4260 | : DEFAULT_TOOL_BAR_BUTTON_RELIEF); | |
4261 | ||
b8898fda | 4262 | if (RANGED_INTEGERP (1, Vtool_bar_button_margin, INT_MAX)) |
972f4259 KS |
4263 | margin = XFASTINT (Vtool_bar_button_margin); |
4264 | else if (CONSP (Vtool_bar_button_margin) | |
b8898fda | 4265 | && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin), INT_MAX)) |
972f4259 KS |
4266 | margin = XFASTINT (XCDR (Vtool_bar_button_margin)); |
4267 | else | |
4268 | margin = 0; | |
4269 | ||
880e6158 | 4270 | /* PXW: We should be able to not round here. */ |
972f4259 | 4271 | bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief; |
5af5757b | 4272 | FRAME_LINES (f) += (bar_height + FRAME_LINE_HEIGHT (f) - 1) / FRAME_LINE_HEIGHT (f); |
972f4259 KS |
4273 | } |
4274 | ||
4275 | compute_fringe_widths (f, 0); | |
4276 | ||
880e6158 MR |
4277 | SET_FRAME_WIDTH (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f)); |
4278 | SET_FRAME_HEIGHT(f, FRAME_LINES (f) * FRAME_LINE_HEIGHT (f)); | |
972f4259 KS |
4279 | |
4280 | tem0 = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER); | |
4281 | tem1 = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER); | |
4282 | tem2 = x_get_arg (dpyinfo, parms, Quser_position, 0, 0, RES_TYPE_NUMBER); | |
4283 | if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound)) | |
4284 | { | |
4285 | if (EQ (tem0, Qminus)) | |
4286 | { | |
5af5757b | 4287 | f->top_pos = 0; |
972f4259 KS |
4288 | window_prompting |= YNegative; |
4289 | } | |
4290 | else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus) | |
4291 | && CONSP (XCDR (tem0)) | |
b8898fda | 4292 | && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (tem0)), INT_MAX)) |
972f4259 | 4293 | { |
5af5757b | 4294 | f->top_pos = - XINT (XCAR (XCDR (tem0))); |
972f4259 KS |
4295 | window_prompting |= YNegative; |
4296 | } | |
4297 | else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus) | |
4298 | && CONSP (XCDR (tem0)) | |
b8898fda | 4299 | && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0)))) |
972f4259 | 4300 | { |
5af5757b | 4301 | f->top_pos = XINT (XCAR (XCDR (tem0))); |
972f4259 KS |
4302 | } |
4303 | else if (EQ (tem0, Qunbound)) | |
5af5757b | 4304 | f->top_pos = 0; |
972f4259 KS |
4305 | else |
4306 | { | |
d311d28c | 4307 | CHECK_TYPE_RANGED_INTEGER (int, tem0); |
5af5757b KS |
4308 | f->top_pos = XINT (tem0); |
4309 | if (f->top_pos < 0) | |
972f4259 KS |
4310 | window_prompting |= YNegative; |
4311 | } | |
4312 | ||
4313 | if (EQ (tem1, Qminus)) | |
4314 | { | |
5af5757b | 4315 | f->left_pos = 0; |
972f4259 KS |
4316 | window_prompting |= XNegative; |
4317 | } | |
4318 | else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus) | |
4319 | && CONSP (XCDR (tem1)) | |
b8898fda | 4320 | && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (tem1)), INT_MAX)) |
972f4259 | 4321 | { |
5af5757b | 4322 | f->left_pos = - XINT (XCAR (XCDR (tem1))); |
972f4259 KS |
4323 | window_prompting |= XNegative; |
4324 | } | |
4325 | else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus) | |
4326 | && CONSP (XCDR (tem1)) | |
b8898fda | 4327 | && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1)))) |
972f4259 | 4328 | { |
5af5757b | 4329 | f->left_pos = XINT (XCAR (XCDR (tem1))); |
972f4259 KS |
4330 | } |
4331 | else if (EQ (tem1, Qunbound)) | |
5af5757b | 4332 | f->left_pos = 0; |
972f4259 KS |
4333 | else |
4334 | { | |
d311d28c | 4335 | CHECK_TYPE_RANGED_INTEGER (int, tem1); |
5af5757b KS |
4336 | f->left_pos = XINT (tem1); |
4337 | if (f->left_pos < 0) | |
972f4259 KS |
4338 | window_prompting |= XNegative; |
4339 | } | |
4340 | ||
4341 | if (!NILP (tem2) && ! EQ (tem2, Qunbound)) | |
4342 | window_prompting |= USPosition; | |
4343 | else | |
4344 | window_prompting |= PPosition; | |
4345 | } | |
4346 | ||
972f4259 KS |
4347 | if (window_prompting & XNegative) |
4348 | { | |
4349 | if (window_prompting & YNegative) | |
5af5757b | 4350 | f->win_gravity = SouthEastGravity; |
972f4259 | 4351 | else |
5af5757b | 4352 | f->win_gravity = NorthEastGravity; |
972f4259 KS |
4353 | } |
4354 | else | |
4355 | { | |
4356 | if (window_prompting & YNegative) | |
5af5757b | 4357 | f->win_gravity = SouthWestGravity; |
972f4259 | 4358 | else |
5af5757b | 4359 | f->win_gravity = NorthWestGravity; |
972f4259 KS |
4360 | } |
4361 | ||
5af5757b | 4362 | f->size_hint_flags = window_prompting; |
972f4259 KS |
4363 | |
4364 | return window_prompting; | |
4365 | } | |
4366 | ||
4367 | ||
4368 | ||
4369 | #endif /* HAVE_WINDOW_SYSTEM */ | |
4370 | ||
e044e4fc | 4371 | void |
971de7fb | 4372 | frame_make_pointer_invisible (void) |
e044e4fc JD |
4373 | { |
4374 | if (! NILP (Vmake_pointer_invisible)) | |
4375 | { | |
abeafb2a | 4376 | struct frame *f; |
ece2d4ed JD |
4377 | if (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame))) |
4378 | return; | |
4379 | ||
abeafb2a | 4380 | f = SELECTED_FRAME (); |
e044e4fc JD |
4381 | if (f && !f->pointer_invisible |
4382 | && FRAME_TERMINAL (f)->toggle_invisible_pointer_hook) | |
4383 | { | |
4384 | f->mouse_moved = 0; | |
4385 | FRAME_TERMINAL (f)->toggle_invisible_pointer_hook (f, 1); | |
4386 | f->pointer_invisible = 1; | |
4387 | } | |
4388 | } | |
4389 | } | |
4390 | ||
4391 | void | |
971de7fb | 4392 | frame_make_pointer_visible (void) |
e044e4fc JD |
4393 | { |
4394 | /* We don't check Vmake_pointer_invisible here in case the | |
4395 | pointer was invisible when Vmake_pointer_invisible was set to nil. */ | |
abeafb2a | 4396 | struct frame *f; |
e044e4fc | 4397 | |
ece2d4ed JD |
4398 | if (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame))) |
4399 | return; | |
4400 | ||
abeafb2a | 4401 | f = SELECTED_FRAME (); |
e044e4fc JD |
4402 | if (f && f->pointer_invisible && f->mouse_moved |
4403 | && FRAME_TERMINAL (f)->toggle_invisible_pointer_hook) | |
4404 | { | |
4405 | FRAME_TERMINAL (f)->toggle_invisible_pointer_hook (f, 0); | |
4406 | f->pointer_invisible = 0; | |
4407 | } | |
4408 | } | |
4409 | ||
c978536f JD |
4410 | DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p, |
4411 | Sframe_pointer_visible_p, 0, 1, 0, | |
4412 | doc: /* Return t if the mouse pointer displayed on FRAME is visible. | |
4413 | Otherwise it returns nil. FRAME omitted or nil means the | |
4414 | selected frame. This is useful when `make-pointer-invisible' is set. */) | |
4415 | (Lisp_Object frame) | |
4416 | { | |
d9f07150 | 4417 | return decode_any_frame (frame)->pointer_invisible ? Qnil : Qt; |
c978536f | 4418 | } |
972f4259 | 4419 | |
6799bb26 JD |
4420 | |
4421 | \f | |
4422 | /*********************************************************************** | |
4423 | Multimonitor data | |
4424 | ***********************************************************************/ | |
4425 | ||
4426 | #ifdef HAVE_WINDOW_SYSTEM | |
4427 | ||
3d5ee10a PE |
4428 | # if (defined HAVE_NS \ |
4429 | || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR))) | |
6799bb26 JD |
4430 | void |
4431 | free_monitors (struct MonitorInfo *monitors, int n_monitors) | |
4432 | { | |
4433 | int i; | |
4434 | for (i = 0; i < n_monitors; ++i) | |
4435 | xfree (monitors[i].name); | |
4436 | xfree (monitors); | |
4437 | } | |
3d5ee10a | 4438 | # endif |
6799bb26 JD |
4439 | |
4440 | Lisp_Object | |
4441 | make_monitor_attribute_list (struct MonitorInfo *monitors, | |
4442 | int n_monitors, | |
4443 | int primary_monitor, | |
4444 | Lisp_Object monitor_frames, | |
4445 | const char *source) | |
4446 | { | |
4447 | Lisp_Object attributes_list = Qnil; | |
4448 | Lisp_Object primary_monitor_attributes = Qnil; | |
4449 | int i; | |
4450 | ||
4451 | for (i = 0; i < n_monitors; ++i) | |
4452 | { | |
4453 | Lisp_Object geometry, workarea, attributes = Qnil; | |
4454 | struct MonitorInfo *mi = &monitors[i]; | |
4455 | ||
4456 | if (mi->geom.width == 0) continue; | |
4457 | ||
4458 | workarea = list4i (mi->work.x, mi->work.y, | |
4459 | mi->work.width, mi->work.height); | |
4460 | geometry = list4i (mi->geom.x, mi->geom.y, | |
4461 | mi->geom.width, mi->geom.height); | |
9acc1074 | 4462 | attributes = Fcons (Fcons (Qsource, build_string (source)), |
6799bb26 JD |
4463 | attributes); |
4464 | attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)), | |
4465 | attributes); | |
4466 | attributes = Fcons (Fcons (Qmm_size, | |
4467 | list2i (mi->mm_width, mi->mm_height)), | |
4468 | attributes); | |
4469 | attributes = Fcons (Fcons (Qworkarea, workarea), attributes); | |
4470 | attributes = Fcons (Fcons (Qgeometry, geometry), attributes); | |
4471 | if (mi->name) | |
4472 | attributes = Fcons (Fcons (Qname, make_string (mi->name, | |
4473 | strlen (mi->name))), | |
4474 | attributes); | |
4475 | ||
4476 | if (i == primary_monitor) | |
4477 | primary_monitor_attributes = attributes; | |
4478 | else | |
4479 | attributes_list = Fcons (attributes, attributes_list); | |
4480 | } | |
4481 | ||
4482 | if (!NILP (primary_monitor_attributes)) | |
4483 | attributes_list = Fcons (primary_monitor_attributes, attributes_list); | |
4484 | return attributes_list; | |
4485 | } | |
4486 | ||
4487 | #endif /* HAVE_WINDOW_SYSTEM */ | |
4488 | ||
972f4259 KS |
4489 | \f |
4490 | /*********************************************************************** | |
4491 | Initialization | |
4492 | ***********************************************************************/ | |
4493 | ||
4494 | void | |
971de7fb | 4495 | syms_of_frame (void) |
972f4259 | 4496 | { |
cd3520a4 JB |
4497 | DEFSYM (Qframep, "framep"); |
4498 | DEFSYM (Qframe_live_p, "frame-live-p"); | |
4499 | DEFSYM (Qexplicit_name, "explicit-name"); | |
4500 | DEFSYM (Qheight, "height"); | |
4501 | DEFSYM (Qicon, "icon"); | |
4502 | DEFSYM (Qminibuffer, "minibuffer"); | |
4503 | DEFSYM (Qmodeline, "modeline"); | |
4504 | DEFSYM (Qonly, "only"); | |
9fb0c957 | 4505 | DEFSYM (Qnone, "none"); |
cd3520a4 JB |
4506 | DEFSYM (Qwidth, "width"); |
4507 | DEFSYM (Qgeometry, "geometry"); | |
4508 | DEFSYM (Qicon_left, "icon-left"); | |
4509 | DEFSYM (Qicon_top, "icon-top"); | |
4510 | DEFSYM (Qtooltip, "tooltip"); | |
4511 | DEFSYM (Qleft, "left"); | |
4512 | DEFSYM (Qright, "right"); | |
4513 | DEFSYM (Quser_position, "user-position"); | |
4514 | DEFSYM (Quser_size, "user-size"); | |
4515 | DEFSYM (Qwindow_id, "window-id"); | |
972f4259 | 4516 | #ifdef HAVE_X_WINDOWS |
cd3520a4 | 4517 | DEFSYM (Qouter_window_id, "outer-window-id"); |
972f4259 | 4518 | #endif |
cd3520a4 JB |
4519 | DEFSYM (Qparent_id, "parent-id"); |
4520 | DEFSYM (Qx, "x"); | |
4521 | DEFSYM (Qw32, "w32"); | |
4522 | DEFSYM (Qpc, "pc"); | |
cd3520a4 JB |
4523 | DEFSYM (Qns, "ns"); |
4524 | DEFSYM (Qvisible, "visible"); | |
4525 | DEFSYM (Qbuffer_predicate, "buffer-predicate"); | |
4526 | DEFSYM (Qbuffer_list, "buffer-list"); | |
4527 | DEFSYM (Qburied_buffer_list, "buried-buffer-list"); | |
4528 | DEFSYM (Qdisplay_type, "display-type"); | |
4529 | DEFSYM (Qbackground_mode, "background-mode"); | |
4530 | DEFSYM (Qnoelisp, "noelisp"); | |
4531 | DEFSYM (Qtty_color_mode, "tty-color-mode"); | |
4532 | DEFSYM (Qtty, "tty"); | |
4533 | DEFSYM (Qtty_type, "tty-type"); | |
4534 | ||
4535 | DEFSYM (Qface_set_after_frame_default, "face-set-after-frame-default"); | |
4536 | ||
4537 | DEFSYM (Qfullwidth, "fullwidth"); | |
4538 | DEFSYM (Qfullheight, "fullheight"); | |
4539 | DEFSYM (Qfullboth, "fullboth"); | |
4540 | DEFSYM (Qmaximized, "maximized"); | |
4541 | DEFSYM (Qx_resource_name, "x-resource-name"); | |
4542 | DEFSYM (Qx_frame_parameter, "x-frame-parameter"); | |
4543 | ||
4544 | DEFSYM (Qterminal, "terminal"); | |
a3547743 | 4545 | |
6799bb26 JD |
4546 | DEFSYM (Qgeometry, "geometry"); |
4547 | DEFSYM (Qworkarea, "workarea"); | |
4548 | DEFSYM (Qmm_size, "mm-size"); | |
4549 | DEFSYM (Qframes, "frames"); | |
4550 | DEFSYM (Qsource, "source"); | |
4551 | ||
dc4db71c | 4552 | #ifdef HAVE_NS |
cd3520a4 | 4553 | DEFSYM (Qns_parse_geometry, "ns-parse-geometry"); |
dc4db71c CY |
4554 | #endif |
4555 | ||
972f4259 KS |
4556 | { |
4557 | int i; | |
4558 | ||
4559 | for (i = 0; i < sizeof (frame_parms) / sizeof (frame_parms[0]); i++) | |
4560 | { | |
d67b4f80 | 4561 | Lisp_Object v = intern_c_string (frame_parms[i].name); |
972f4259 KS |
4562 | if (frame_parms[i].variable) |
4563 | { | |
4564 | *frame_parms[i].variable = v; | |
4565 | staticpro (frame_parms[i].variable); | |
4566 | } | |
4567 | Fput (v, Qx_frame_parameter, make_number (i)); | |
4568 | } | |
4569 | } | |
4570 | ||
2731a0ad | 4571 | #ifdef HAVE_WINDOW_SYSTEM |
29208e82 | 4572 | DEFVAR_LISP ("x-resource-name", Vx_resource_name, |
972f4259 KS |
4573 | doc: /* The name Emacs uses to look up X resources. |
4574 | `x-get-resource' uses this as the first component of the instance name | |
4575 | when requesting resource values. | |
4576 | Emacs initially sets `x-resource-name' to the name under which Emacs | |
4577 | was invoked, or to the value specified with the `-name' or `-rn' | |
4578 | switches, if present. | |
4579 | ||
4580 | It may be useful to bind this variable locally around a call | |
4581 | to `x-get-resource'. See also the variable `x-resource-class'. */); | |
4582 | Vx_resource_name = Qnil; | |
4583 | ||
29208e82 | 4584 | DEFVAR_LISP ("x-resource-class", Vx_resource_class, |
972f4259 KS |
4585 | doc: /* The class Emacs uses to look up X resources. |
4586 | `x-get-resource' uses this as the first component of the instance class | |
4587 | when requesting resource values. | |
4588 | ||
4589 | Emacs initially sets `x-resource-class' to "Emacs". | |
4590 | ||
4591 | Setting this variable permanently is not a reasonable thing to do, | |
4592 | but binding this variable locally around a call to `x-get-resource' | |
4593 | is a reasonable practice. See also the variable `x-resource-name'. */); | |
4594 | Vx_resource_class = build_string (EMACS_CLASS); | |
0a708637 | 4595 | |
29208e82 | 4596 | DEFVAR_LISP ("frame-alpha-lower-limit", Vframe_alpha_lower_limit, |
0a708637 GM |
4597 | doc: /* The lower limit of the frame opacity (alpha transparency). |
4598 | The value should range from 0 (invisible) to 100 (completely opaque). | |
ca58fa73 | 4599 | You can also use a floating number between 0.0 and 1.0. */); |
0a708637 | 4600 | Vframe_alpha_lower_limit = make_number (20); |
2731a0ad | 4601 | #endif |
972f4259 | 4602 | |
29208e82 | 4603 | DEFVAR_LISP ("default-frame-alist", Vdefault_frame_alist, |
972f4259 KS |
4604 | doc: /* Alist of default values for frame creation. |
4605 | These may be set in your init file, like this: | |
5ff00c42 | 4606 | (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))) |
972f4259 KS |
4607 | These override values given in window system configuration data, |
4608 | including X Windows' defaults database. | |
4609 | For values specific to the first Emacs frame, see `initial-frame-alist'. | |
095fe281 | 4610 | For window-system specific values, see `window-system-default-frame-alist'. |
972f4259 KS |
4611 | For values specific to the separate minibuffer frame, see |
4612 | `minibuffer-frame-alist'. | |
4613 | The `menu-bar-lines' element of the list controls whether new frames | |
4614 | have menu bars; `menu-bar-mode' works by altering this element. | |
4615 | Setting this variable does not affect existing frames, only new ones. */); | |
fac580eb | 4616 | Vdefault_frame_alist = Qnil; |
972f4259 | 4617 | |
29208e82 | 4618 | DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars, |
6b61353c KH |
4619 | doc: /* Default position of scroll bars on this window-system. */); |
4620 | #ifdef HAVE_WINDOW_SYSTEM | |
5e617bc2 | 4621 | #if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS)) |
303500aa CY |
4622 | /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by |
4623 | default. */ | |
6b61353c | 4624 | Vdefault_frame_scroll_bars = Qright; |
303500aa CY |
4625 | #else |
4626 | Vdefault_frame_scroll_bars = Qleft; | |
4627 | #endif | |
6b61353c KH |
4628 | #else |
4629 | Vdefault_frame_scroll_bars = Qnil; | |
4630 | #endif | |
4631 | ||
fd9547e8 JD |
4632 | DEFVAR_BOOL ("scroll-bar-adjust-thumb-portion", |
4633 | scroll_bar_adjust_thumb_portion_p, | |
4634 | doc: /* Adjust thumb for overscrolling for Gtk+ and MOTIF. | |
4635 | Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards | |
4636 | even if the end of the buffer is shown (i.e. overscrolling). | |
4637 | Set to nil if you want the thumb to be at the bottom when the end of the buffer | |
4638 | is shown. Also, the thumb fills the whole scroll bar when the entire buffer | |
4639 | is visible. In this case you can not overscroll. */); | |
4640 | scroll_bar_adjust_thumb_portion_p = 1; | |
4641 | ||
29208e82 | 4642 | DEFVAR_LISP ("terminal-frame", Vterminal_frame, |
daf01701 | 4643 | doc: /* The initial frame-object, which represents Emacs's stdout. */); |
972f4259 | 4644 | |
29208e82 | 4645 | DEFVAR_LISP ("mouse-position-function", Vmouse_position_function, |
972f4259 KS |
4646 | doc: /* If non-nil, function to transform normal value of `mouse-position'. |
4647 | `mouse-position' calls this function, passing its usual return value as | |
4648 | argument, and returns whatever this function returns. | |
4649 | This abnormal hook exists for the benefit of packages like `xt-mouse.el' | |
4650 | which need to do mouse handling at the Lisp level. */); | |
4651 | Vmouse_position_function = Qnil; | |
4652 | ||
29208e82 | 4653 | DEFVAR_LISP ("mouse-highlight", Vmouse_highlight, |
972f4259 KS |
4654 | doc: /* If non-nil, clickable text is highlighted when mouse is over it. |
4655 | If the value is an integer, highlighting is only shown after moving the | |
4656 | mouse, while keyboard input turns off the highlight even when the mouse | |
4657 | is over the clickable text. However, the mouse shape still indicates | |
4658 | when the mouse is over clickable text. */); | |
4659 | Vmouse_highlight = Qt; | |
4660 | ||
29208e82 | 4661 | DEFVAR_LISP ("make-pointer-invisible", Vmake_pointer_invisible, |
e044e4fc JD |
4662 | doc: /* If non-nil, make pointer invisible while typing. |
4663 | The pointer becomes visible again when the mouse is moved. */); | |
4664 | Vmake_pointer_invisible = Qt; | |
4665 | ||
8e015705 BJ |
4666 | DEFVAR_LISP ("focus-in-hook", Vfocus_in_hook, |
4667 | doc: /* Normal hook run when a frame gains input focus. */); | |
4668 | Vfocus_in_hook = Qnil; | |
4669 | DEFSYM (Qfocus_in_hook, "focus-in-hook"); | |
4670 | ||
4671 | DEFVAR_LISP ("focus-out-hook", Vfocus_out_hook, | |
4672 | doc: /* Normal hook run when a frame loses input focus. */); | |
4673 | Vfocus_out_hook = Qnil; | |
4674 | DEFSYM (Qfocus_out_hook, "focus-out-hook"); | |
4675 | ||
29208e82 | 4676 | DEFVAR_LISP ("delete-frame-functions", Vdelete_frame_functions, |
e5d9c0d1 | 4677 | doc: /* Functions run before deleting a frame. |
972f4259 | 4678 | The functions are run with one arg, the frame to be deleted. |
e519a50b KL |
4679 | See `delete-frame'. |
4680 | ||
58555d81 SM |
4681 | Note that functions in this list may be called just before the frame is |
4682 | actually deleted, or some time later (or even both when an earlier function | |
4683 | in `delete-frame-functions' (indirectly) calls `delete-frame' | |
4684 | recursively). */); | |
972f4259 | 4685 | Vdelete_frame_functions = Qnil; |
cd3520a4 | 4686 | DEFSYM (Qdelete_frame_functions, "delete-frame-functions"); |
972f4259 | 4687 | |
29208e82 | 4688 | DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode, |
e1fd756b GM |
4689 | doc: /* Non-nil if Menu-Bar mode is enabled. |
4690 | See the command `menu-bar-mode' for a description of this minor mode. | |
4691 | Setting this variable directly does not take effect; | |
4692 | either customize it (see the info node `Easy Customization') | |
4693 | or call the function `menu-bar-mode'. */); | |
6431f2e6 CY |
4694 | Vmenu_bar_mode = Qt; |
4695 | ||
29208e82 | 4696 | DEFVAR_LISP ("tool-bar-mode", Vtool_bar_mode, |
9d794026 GM |
4697 | doc: /* Non-nil if Tool-Bar mode is enabled. |
4698 | See the command `tool-bar-mode' for a description of this minor mode. | |
4699 | Setting this variable directly does not take effect; | |
4700 | either customize it (see the info node `Easy Customization') | |
4701 | or call the function `tool-bar-mode'. */); | |
c8c59954 | 4702 | #ifdef HAVE_WINDOW_SYSTEM |
6431f2e6 | 4703 | Vtool_bar_mode = Qt; |
c8c59954 GM |
4704 | #else |
4705 | Vtool_bar_mode = Qnil; | |
4706 | #endif | |
6431f2e6 | 4707 | |
972f4259 KS |
4708 | DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame, |
4709 | doc: /* Minibufferless frames use this frame's minibuffer. | |
972f4259 KS |
4710 | Emacs cannot create minibufferless frames unless this is set to an |
4711 | appropriate surrogate. | |
4712 | ||
4713 | Emacs consults this variable only when creating minibufferless | |
4714 | frames; once the frame is created, it sticks with its assigned | |
4715 | minibuffer, no matter what this variable is set to. This means that | |
4716 | this variable doesn't necessarily say anything meaningful about the | |
4717 | current set of frames, or where the minibuffer is currently being | |
4718 | displayed. | |
4719 | ||
4720 | This variable is local to the current terminal and cannot be buffer-local. */); | |
4721 | ||
29208e82 | 4722 | DEFVAR_BOOL ("focus-follows-mouse", focus_follows_mouse, |
da1da002 MR |
4723 | doc: /* Non-nil if window system changes focus when you move the mouse. |
4724 | You should set this variable to tell Emacs how your window manager | |
4725 | handles focus, since there is no way in general for Emacs to find out | |
86677b58 | 4726 | automatically. See also `mouse-autoselect-window'. */); |
da1da002 | 4727 | focus_follows_mouse = 0; |
a3547743 | 4728 | |
880e6158 | 4729 | DEFVAR_BOOL ("frame-resize-pixelwise", frame_resize_pixelwise, |
f96d0a6b MR |
4730 | doc: /* Non-nil means resize frames pixelwise. |
4731 | If this option is nil, resizing a frame rounds its sizes to the frame's | |
4732 | current values of `frame-char-height' and `frame-char-width'. If this | |
4733 | is non-nil, no rounding occurs, hence frame sizes can increase/decrease | |
4734 | by one pixel. | |
4735 | ||
4736 | With some window managers you have to set this to non-nil in order to | |
ca58fa73 GM |
4737 | fully maximize frames. To resize your initial frame pixelwise, |
4738 | set this option to a non-nil value in your init file. */); | |
880e6158 MR |
4739 | frame_resize_pixelwise = 0; |
4740 | ||
972f4259 KS |
4741 | staticpro (&Vframe_list); |
4742 | ||
972f4259 KS |
4743 | defsubr (&Sframep); |
4744 | defsubr (&Sframe_live_p); | |
428a555e | 4745 | defsubr (&Swindow_system); |
972f4259 KS |
4746 | defsubr (&Smake_terminal_frame); |
4747 | defsubr (&Shandle_switch_frame); | |
972f4259 KS |
4748 | defsubr (&Sselect_frame); |
4749 | defsubr (&Sselected_frame); | |
972f4259 KS |
4750 | defsubr (&Sframe_list); |
4751 | defsubr (&Snext_frame); | |
4752 | defsubr (&Sprevious_frame); | |
9718b207 | 4753 | defsubr (&Slast_nonminibuf_frame); |
972f4259 KS |
4754 | defsubr (&Sdelete_frame); |
4755 | defsubr (&Smouse_position); | |
4756 | defsubr (&Smouse_pixel_position); | |
4757 | defsubr (&Sset_mouse_position); | |
4758 | defsubr (&Sset_mouse_pixel_position); | |
4759 | #if 0 | |
4760 | defsubr (&Sframe_configuration); | |
4761 | defsubr (&Srestore_frame_configuration); | |
4762 | #endif | |
4763 | defsubr (&Smake_frame_visible); | |
4764 | defsubr (&Smake_frame_invisible); | |
4765 | defsubr (&Siconify_frame); | |
4766 | defsubr (&Sframe_visible_p); | |
4767 | defsubr (&Svisible_frame_list); | |
4768 | defsubr (&Sraise_frame); | |
4769 | defsubr (&Slower_frame); | |
fcd42c11 | 4770 | defsubr (&Sx_focus_frame); |
972f4259 KS |
4771 | defsubr (&Sredirect_frame_focus); |
4772 | defsubr (&Sframe_focus); | |
4773 | defsubr (&Sframe_parameters); | |
4774 | defsubr (&Sframe_parameter); | |
4775 | defsubr (&Smodify_frame_parameters); | |
4776 | defsubr (&Sframe_char_height); | |
4777 | defsubr (&Sframe_char_width); | |
4778 | defsubr (&Sframe_pixel_height); | |
4779 | defsubr (&Sframe_pixel_width); | |
880e6158 MR |
4780 | defsubr (&Sframe_text_cols); |
4781 | defsubr (&Sframe_text_lines); | |
4782 | defsubr (&Sframe_total_cols); | |
4783 | defsubr (&Sframe_text_width); | |
4784 | defsubr (&Sframe_text_height); | |
4785 | defsubr (&Sscroll_bar_width); | |
4786 | defsubr (&Sfringe_width); | |
4787 | defsubr (&Sborder_width); | |
4788 | defsubr (&Sright_divider_width); | |
4789 | defsubr (&Sbottom_divider_width); | |
fb0cf781 | 4790 | defsubr (&Stool_bar_pixel_width); |
972f4259 KS |
4791 | defsubr (&Sset_frame_height); |
4792 | defsubr (&Sset_frame_width); | |
4793 | defsubr (&Sset_frame_size); | |
4794 | defsubr (&Sset_frame_position); | |
c978536f | 4795 | defsubr (&Sframe_pointer_visible_p); |
972f4259 KS |
4796 | |
4797 | #ifdef HAVE_WINDOW_SYSTEM | |
4798 | defsubr (&Sx_get_resource); | |
4799 | defsubr (&Sx_parse_geometry); | |
4800 | #endif | |
4801 | ||
dc6f92b8 | 4802 | } |