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