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