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