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