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