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