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