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