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