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