Commit | Line | Data |
---|---|---|
ff11dfa1 | 1 | /* Generic frame functions. |
1113d9db | 2 | Copyright (C) 1989, 1992 Free Software Foundation. |
dc6f92b8 JB |
3 | |
4 | This file is part of GNU Emacs. | |
5 | ||
6 | GNU Emacs is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
1113d9db | 8 | the Free Software Foundation; either version 2, or (at your option) |
dc6f92b8 JB |
9 | any later version. |
10 | ||
11 | GNU Emacs is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU Emacs; see the file COPYING. If not, write to | |
18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | ||
d5e7c279 JB |
20 | #include <stdio.h> |
21 | ||
dc6f92b8 | 22 | #include "config.h" |
e5d77022 | 23 | |
ff11dfa1 | 24 | #ifdef MULTI_FRAME |
e5d77022 | 25 | |
dc6f92b8 | 26 | #include "lisp.h" |
ff11dfa1 | 27 | #include "frame.h" |
dc6f92b8 | 28 | #include "window.h" |
d5e7c279 | 29 | #include "termhooks.h" |
dc6f92b8 JB |
30 | |
31 | Lisp_Object Vemacs_iconified; | |
ff11dfa1 JB |
32 | Lisp_Object Qframep; |
33 | Lisp_Object Qlive_frame_p; | |
34 | Lisp_Object Vframe_list; | |
35 | Lisp_Object Vterminal_frame; | |
36 | Lisp_Object Vdefault_minibuffer_frame; | |
37 | Lisp_Object Vdefault_frame_alist; | |
bc93c097 | 38 | Lisp_Object Qminibuffer; |
dc6f92b8 JB |
39 | |
40 | extern Lisp_Object Vminibuffer_list; | |
41 | extern Lisp_Object get_minibuffer (); | |
42 | \f | |
ff11dfa1 JB |
43 | DEFUN ("framep", Fframep, Sframep, 1, 1, 0, |
44 | "Return non-nil if OBJECT is a frame.\n\ | |
45 | Value is t for a termcap frame (a character-only terminal),\n\ | |
46 | `x' for an Emacs frame that is really an X window.\n\ | |
47 | Also see `live-frame-p'.") | |
f9898cc6 JB |
48 | (object) |
49 | Lisp_Object object; | |
dc6f92b8 | 50 | { |
ff11dfa1 | 51 | if (XTYPE (object) != Lisp_Frame) |
dc6f92b8 | 52 | return Qnil; |
ff11dfa1 | 53 | switch (XFRAME (object)->output_method) |
dc6f92b8 JB |
54 | { |
55 | case output_termcap: | |
56 | return Qt; | |
57 | case output_x_window: | |
58 | return intern ("x"); | |
59 | default: | |
60 | abort (); | |
61 | } | |
62 | } | |
63 | ||
ff11dfa1 JB |
64 | DEFUN ("live-frame-p", Flive_frame_p, Slive_frame_p, 1, 1, 0, |
65 | "Return non-nil if OBJECT is a frame which has not been deleted.\n\ | |
66 | Value is nil if OBJECT is not a live frame. If object is a live\n\ | |
67 | frame, the return value indicates what sort of output device it is\n\ | |
68 | displayed on. Value is t for a termcap frame (a character-only\n\ | |
69 | terminal), `x' for an Emacs frame being displayed in an X window.") | |
f9898cc6 JB |
70 | (object) |
71 | Lisp_Object object; | |
72 | { | |
ff11dfa1 JB |
73 | return ((FRAMEP (object) |
74 | && FRAME_LIVE_P (XFRAME (object))) | |
75 | ? Fframep (object) | |
f9898cc6 JB |
76 | : Qnil); |
77 | } | |
78 | ||
ff11dfa1 JB |
79 | struct frame * |
80 | make_frame (mini_p) | |
dc6f92b8 JB |
81 | int mini_p; |
82 | { | |
ff11dfa1 JB |
83 | Lisp_Object frame; |
84 | register struct frame *f; | |
dc6f92b8 JB |
85 | register Lisp_Object root_window; |
86 | register Lisp_Object mini_window; | |
87 | ||
ff11dfa1 | 88 | frame = Fmake_vector (((sizeof (struct frame) - (sizeof (Lisp_Vector) |
d5e7c279 JB |
89 | - sizeof (Lisp_Object))) |
90 | / sizeof (Lisp_Object)), | |
dc6f92b8 | 91 | make_number (0)); |
ff11dfa1 JB |
92 | XSETTYPE (frame, Lisp_Frame); |
93 | f = XFRAME (frame); | |
94 | ||
95 | f->cursor_x = 0; | |
96 | f->cursor_y = 0; | |
97 | f->current_glyphs = 0; | |
98 | f->desired_glyphs = 0; | |
99 | f->visible = 0; | |
100 | f->display.nothing = 0; | |
101 | f->iconified = 0; | |
102 | f->wants_modeline = 1; | |
103 | f->auto_raise = 0; | |
104 | f->auto_lower = 0; | |
105 | f->no_split = 0; | |
106 | f->garbaged = 0; | |
107 | f->has_minibuffer = mini_p; | |
108 | f->focus_frame = frame; | |
109 | ||
110 | f->param_alist = Qnil; | |
dc6f92b8 JB |
111 | |
112 | root_window = make_window (0); | |
113 | if (mini_p) | |
114 | { | |
115 | mini_window = make_window (0); | |
116 | XWINDOW (root_window)->next = mini_window; | |
117 | XWINDOW (mini_window)->prev = root_window; | |
118 | XWINDOW (mini_window)->mini_p = Qt; | |
ff11dfa1 JB |
119 | XWINDOW (mini_window)->frame = frame; |
120 | f->minibuffer_window = mini_window; | |
dc6f92b8 JB |
121 | } |
122 | else | |
123 | { | |
124 | mini_window = Qnil; | |
125 | XWINDOW (root_window)->next = Qnil; | |
ff11dfa1 | 126 | f->minibuffer_window = Qnil; |
dc6f92b8 JB |
127 | } |
128 | ||
ff11dfa1 | 129 | XWINDOW (root_window)->frame = frame; |
dc6f92b8 JB |
130 | |
131 | /* 10 is arbitrary, | |
132 | just so that there is "something there." | |
ff11dfa1 | 133 | Correct size will be set up later with change_frame_size. */ |
dc6f92b8 | 134 | |
ff11dfa1 JB |
135 | f->width = 10; |
136 | f->height = 10; | |
dc6f92b8 JB |
137 | |
138 | XFASTINT (XWINDOW (root_window)->width) = 10; | |
139 | XFASTINT (XWINDOW (root_window)->height) = (mini_p ? 9 : 10); | |
140 | ||
141 | if (mini_p) | |
142 | { | |
143 | XFASTINT (XWINDOW (mini_window)->width) = 10; | |
144 | XFASTINT (XWINDOW (mini_window)->top) = 9; | |
145 | XFASTINT (XWINDOW (mini_window)->height) = 1; | |
146 | } | |
147 | ||
ff11dfa1 | 148 | /* Choose a buffer for the frame's root window. */ |
5bce042c JB |
149 | { |
150 | Lisp_Object buf; | |
151 | ||
152 | XWINDOW (root_window)->buffer = Qt; | |
153 | buf = Fcurrent_buffer (); | |
154 | /* If buf is a 'hidden' buffer (i.e. one whose name starts with | |
155 | a space), try to find another one. */ | |
156 | if (XSTRING (Fbuffer_name (buf))->data[0] == ' ') | |
157 | buf = Fother_buffer (buf); | |
158 | Fset_window_buffer (root_window, buf); | |
159 | } | |
160 | ||
dc6f92b8 JB |
161 | if (mini_p) |
162 | { | |
163 | XWINDOW (mini_window)->buffer = Qt; | |
164 | Fset_window_buffer (mini_window, | |
265a9e55 | 165 | (NILP (Vminibuffer_list) |
dc6f92b8 JB |
166 | ? get_minibuffer (0) |
167 | : Fcar (Vminibuffer_list))); | |
168 | } | |
169 | ||
ff11dfa1 JB |
170 | f->root_window = root_window; |
171 | f->selected_window = root_window; | |
d5e7c279 JB |
172 | /* Make sure this window seems more recently used than |
173 | a newly-created, never-selected window. */ | |
ff11dfa1 | 174 | XFASTINT (XWINDOW (f->selected_window)->use_time) = ++window_select_count; |
dc6f92b8 | 175 | |
ff11dfa1 | 176 | Vframe_list = Fcons (frame, Vframe_list); |
dc6f92b8 | 177 | |
ff11dfa1 | 178 | return f; |
dc6f92b8 JB |
179 | } |
180 | \f | |
ff11dfa1 | 181 | /* Make a frame using a separate minibuffer window on another frame. |
dc6f92b8 JB |
182 | MINI_WINDOW is the minibuffer window to use. nil means use the |
183 | default (the global minibuffer). */ | |
184 | ||
ff11dfa1 JB |
185 | struct frame * |
186 | make_frame_without_minibuffer (mini_window) | |
dc6f92b8 JB |
187 | register Lisp_Object mini_window; |
188 | { | |
ff11dfa1 | 189 | register struct frame *f; |
dc6f92b8 JB |
190 | |
191 | /* Choose the minibuffer window to use. */ | |
265a9e55 | 192 | if (NILP (mini_window)) |
dc6f92b8 | 193 | { |
ff11dfa1 JB |
194 | if (XTYPE (Vdefault_minibuffer_frame) != Lisp_Frame) |
195 | error ("default-minibuffer-frame must be set when creating minibufferless frames"); | |
196 | if (! FRAME_LIVE_P (XFRAME (Vdefault_minibuffer_frame))) | |
197 | error ("default-minibuffer-frame must be a live frame"); | |
198 | mini_window = XFRAME (Vdefault_minibuffer_frame)->minibuffer_window; | |
dc6f92b8 JB |
199 | } |
200 | else | |
201 | { | |
202 | CHECK_WINDOW (mini_window, 0); | |
203 | } | |
204 | ||
ff11dfa1 JB |
205 | /* Make a frame containing just a root window. */ |
206 | f = make_frame (0); | |
dc6f92b8 JB |
207 | |
208 | /* Install the chosen minibuffer window, with proper buffer. */ | |
ff11dfa1 | 209 | f->minibuffer_window = mini_window; |
dc6f92b8 | 210 | Fset_window_buffer (mini_window, |
265a9e55 | 211 | (NILP (Vminibuffer_list) |
dc6f92b8 JB |
212 | ? get_minibuffer (0) |
213 | : Fcar (Vminibuffer_list))); | |
ff11dfa1 | 214 | return f; |
dc6f92b8 JB |
215 | } |
216 | ||
ff11dfa1 | 217 | /* Make a frame containing only a minibuffer window. */ |
dc6f92b8 | 218 | |
ff11dfa1 JB |
219 | struct frame * |
220 | make_minibuffer_frame () | |
dc6f92b8 | 221 | { |
ff11dfa1 | 222 | /* First make a frame containing just a root window, no minibuffer. */ |
dc6f92b8 | 223 | |
ff11dfa1 | 224 | register struct frame *f = make_frame (0); |
dc6f92b8 | 225 | register Lisp_Object mini_window; |
ff11dfa1 | 226 | register Lisp_Object frame; |
dc6f92b8 | 227 | |
ff11dfa1 | 228 | XSET (frame, Lisp_Frame, f); |
dc6f92b8 JB |
229 | |
230 | /* ??? Perhaps leave it to the user program to set auto_raise. */ | |
ff11dfa1 JB |
231 | f->auto_raise = 1; |
232 | f->auto_lower = 0; | |
233 | f->no_split = 1; | |
234 | f->wants_modeline = 0; | |
235 | f->has_minibuffer = 1; | |
dc6f92b8 JB |
236 | |
237 | /* Now label the root window as also being the minibuffer. | |
238 | Avoid infinite looping on the window chain by marking next pointer | |
239 | as nil. */ | |
240 | ||
ff11dfa1 | 241 | mini_window = f->minibuffer_window = f->root_window; |
dc6f92b8 JB |
242 | XWINDOW (mini_window)->mini_p = Qt; |
243 | XWINDOW (mini_window)->next = Qnil; | |
244 | XWINDOW (mini_window)->prev = mini_window; | |
ff11dfa1 | 245 | XWINDOW (mini_window)->frame = frame; |
dc6f92b8 JB |
246 | |
247 | /* Put the proper buffer in that window. */ | |
248 | ||
249 | Fset_window_buffer (mini_window, | |
265a9e55 | 250 | (NILP (Vminibuffer_list) |
dc6f92b8 JB |
251 | ? get_minibuffer (0) |
252 | : Fcar (Vminibuffer_list))); | |
ff11dfa1 | 253 | return f; |
dc6f92b8 JB |
254 | } |
255 | \f | |
ff11dfa1 | 256 | /* Construct a frame that refers to the terminal (stdin and stdout). */ |
dc6f92b8 | 257 | |
ff11dfa1 JB |
258 | struct frame * |
259 | make_terminal_frame () | |
dc6f92b8 | 260 | { |
ff11dfa1 JB |
261 | register struct frame *f; |
262 | ||
263 | Vframe_list = Qnil; | |
264 | f = make_frame (1); | |
265 | f->name = build_string ("terminal"); | |
266 | f->visible = 1; | |
267 | f->display.nothing = 1; /* Nonzero means frame isn't deleted. */ | |
268 | XSET (Vterminal_frame, Lisp_Frame, f); | |
269 | return f; | |
dc6f92b8 JB |
270 | } |
271 | \f | |
ff11dfa1 JB |
272 | DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, 0, |
273 | "Select the frame FRAME. FRAMES's selected window becomes \"the\"\n\ | |
d5e7c279 | 274 | selected window. If the optional parameter NO-ENTER is non-nil, don't\n\ |
ff11dfa1 JB |
275 | focus on that frame.") |
276 | (frame, no_enter) | |
277 | Lisp_Object frame, no_enter; | |
dc6f92b8 | 278 | { |
ff11dfa1 | 279 | CHECK_LIVE_FRAME (frame, 0); |
dc6f92b8 | 280 | |
ff11dfa1 JB |
281 | if (selected_frame == XFRAME (frame)) |
282 | return frame; | |
dc6f92b8 | 283 | |
ff11dfa1 JB |
284 | selected_frame = XFRAME (frame); |
285 | if (! FRAME_MINIBUF_ONLY_P (selected_frame)) | |
286 | last_nonminibuf_frame = selected_frame; | |
d5e7c279 | 287 | |
ff11dfa1 | 288 | Fselect_window (XFRAME (frame)->selected_window); |
dc6f92b8 JB |
289 | |
290 | #ifdef HAVE_X_WINDOWS | |
ff11dfa1 JB |
291 | #ifdef MULTI_FRAME |
292 | if (FRAME_IS_X (XFRAME (frame)) | |
265a9e55 | 293 | && NILP (no_enter)) |
dc6f92b8 | 294 | { |
ff11dfa1 | 295 | Ffocus_frame (frame); |
dc6f92b8 JB |
296 | } |
297 | #endif | |
298 | #endif | |
ff11dfa1 | 299 | choose_minibuf_frame (); |
dc6f92b8 | 300 | |
ff11dfa1 | 301 | return frame; |
dc6f92b8 JB |
302 | } |
303 | ||
ff11dfa1 JB |
304 | DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0, |
305 | "Return the frame that is now selected.") | |
dc6f92b8 JB |
306 | () |
307 | { | |
308 | Lisp_Object tem; | |
ff11dfa1 | 309 | XSET (tem, Lisp_Frame, selected_frame); |
dc6f92b8 JB |
310 | return tem; |
311 | } | |
312 | ||
ff11dfa1 JB |
313 | DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0, |
314 | "Return the frame object that window WINDOW is on.") | |
dc6f92b8 JB |
315 | (window) |
316 | Lisp_Object window; | |
317 | { | |
318 | CHECK_WINDOW (window, 0); | |
ff11dfa1 | 319 | return XWINDOW (window)->frame; |
dc6f92b8 JB |
320 | } |
321 | ||
ff11dfa1 JB |
322 | DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0, |
323 | "Returns the root-window of FRAME.") | |
324 | (frame) | |
325 | Lisp_Object frame; | |
dc6f92b8 | 326 | { |
ff11dfa1 JB |
327 | if (NILP (frame)) |
328 | XSET (frame, Lisp_Frame, selected_frame); | |
f9898cc6 | 329 | else |
ff11dfa1 | 330 | CHECK_LIVE_FRAME (frame, 0); |
dc6f92b8 | 331 | |
ff11dfa1 | 332 | return XFRAME (frame)->root_window; |
dc6f92b8 JB |
333 | } |
334 | ||
ff11dfa1 JB |
335 | DEFUN ("frame-selected-window", Fframe_selected_window, |
336 | Sframe_selected_window, 0, 1, 0, | |
337 | "Return the selected window of frame object FRAME.") | |
338 | (frame) | |
339 | Lisp_Object frame; | |
dc6f92b8 | 340 | { |
ff11dfa1 JB |
341 | if (NILP (frame)) |
342 | XSET (frame, Lisp_Frame, selected_frame); | |
f9898cc6 | 343 | else |
ff11dfa1 | 344 | CHECK_LIVE_FRAME (frame, 0); |
dc6f92b8 | 345 | |
ff11dfa1 | 346 | return XFRAME (frame)->selected_window; |
dc6f92b8 JB |
347 | } |
348 | ||
ff11dfa1 | 349 | DEFUN ("frame-list", Fframe_list, Sframe_list, |
dc6f92b8 | 350 | 0, 0, 0, |
ff11dfa1 | 351 | "Return a list of all frames.") |
dc6f92b8 JB |
352 | () |
353 | { | |
ff11dfa1 | 354 | return Fcopy_sequence (Vframe_list); |
dc6f92b8 JB |
355 | } |
356 | ||
ff11dfa1 | 357 | #ifdef MULTI_FRAME |
f9898cc6 | 358 | |
ff11dfa1 JB |
359 | /* Return the next frame in the frame list after FRAME. |
360 | If MINIBUF is non-nil, include all frames. | |
361 | If MINIBUF is nil, exclude minibuffer-only frames. | |
362 | If MINIBUF is a window, include only frames using that window for | |
f9898cc6 | 363 | their minibuffer. */ |
dc6f92b8 | 364 | Lisp_Object |
ff11dfa1 JB |
365 | next_frame (frame, minibuf) |
366 | Lisp_Object frame; | |
f9898cc6 | 367 | Lisp_Object minibuf; |
dc6f92b8 JB |
368 | { |
369 | Lisp_Object tail; | |
370 | int passed = 0; | |
371 | ||
ff11dfa1 JB |
372 | /* There must always be at least one frame in Vframe_list. */ |
373 | if (! CONSP (Vframe_list)) | |
f9898cc6 JB |
374 | abort (); |
375 | ||
dc6f92b8 | 376 | while (1) |
ff11dfa1 | 377 | for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr) |
dc6f92b8 JB |
378 | { |
379 | if (passed) | |
d5e7c279 | 380 | { |
ff11dfa1 | 381 | Lisp_Object f = XCONS (tail)->car; |
f9898cc6 | 382 | |
ff11dfa1 | 383 | /* Decide whether this frame is eligible to be returned, |
f9898cc6 | 384 | according to minibuf. */ |
ff11dfa1 | 385 | if ((NILP (minibuf) && ! FRAME_MINIBUF_ONLY_P (XFRAME (f))) |
f9898cc6 | 386 | || XTYPE (minibuf) != Lisp_Window |
ff11dfa1 JB |
387 | || EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf) |
388 | || EQ (f, frame)) | |
389 | return f; | |
d5e7c279 | 390 | } |
dc6f92b8 | 391 | |
ff11dfa1 | 392 | if (EQ (frame, XCONS (tail)->car)) |
dc6f92b8 JB |
393 | passed++; |
394 | } | |
395 | } | |
396 | ||
ff11dfa1 JB |
397 | /* Return the previous frame in the frame list before FRAME. |
398 | If MINIBUF is non-nil, include all frames. | |
399 | If MINIBUF is nil, exclude minibuffer-only frames. | |
400 | If MINIBUF is a window, include only frames using that window for | |
f9898cc6 | 401 | their minibuffer. */ |
dc6f92b8 | 402 | Lisp_Object |
ff11dfa1 JB |
403 | prev_frame (frame, minibuf) |
404 | Lisp_Object frame; | |
f9898cc6 | 405 | Lisp_Object minibuf; |
dc6f92b8 JB |
406 | { |
407 | Lisp_Object tail; | |
408 | Lisp_Object prev; | |
409 | ||
ff11dfa1 JB |
410 | /* There must always be at least one frame in Vframe_list. */ |
411 | if (! CONSP (Vframe_list)) | |
f9898cc6 JB |
412 | abort (); |
413 | ||
dc6f92b8 JB |
414 | prev = Qnil; |
415 | while (1) | |
f9898cc6 | 416 | { |
ff11dfa1 | 417 | for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr) |
f9898cc6 JB |
418 | { |
419 | Lisp_Object scr = XCONS (tail)->car; | |
420 | ||
ff11dfa1 | 421 | if (XTYPE (scr) != Lisp_Frame) |
f9898cc6 JB |
422 | abort (); |
423 | ||
ff11dfa1 | 424 | if (EQ (frame, scr) && !NILP (prev)) |
f9898cc6 JB |
425 | return prev; |
426 | ||
ff11dfa1 | 427 | /* Decide whether this frame is eligible to be returned, |
f9898cc6 | 428 | according to minibuf. */ |
ff11dfa1 | 429 | if ((NILP (minibuf) && ! FRAME_MINIBUF_ONLY_P (XFRAME (scr))) |
f9898cc6 | 430 | || XTYPE (minibuf) != Lisp_Window |
ff11dfa1 | 431 | || EQ (FRAME_MINIBUF_WINDOW (XFRAME (scr)), minibuf)) |
f9898cc6 JB |
432 | prev = scr; |
433 | } | |
434 | ||
265a9e55 | 435 | if (NILP (prev)) |
ff11dfa1 JB |
436 | /* We went through the whole frame list without finding a single |
437 | acceptable frame. Return the original frame. */ | |
438 | prev = frame; | |
f9898cc6 JB |
439 | } |
440 | ||
dc6f92b8 JB |
441 | } |
442 | ||
ff11dfa1 JB |
443 | DEFUN ("next-frame", Fnext_frame, Snext_frame, 0, 2, 0, |
444 | "Return the next frame in the frame list after FRAME.\n\ | |
445 | If optional argument MINIBUF is non-nil, include all frames. If\n\ | |
446 | MINIBUF is nil or omitted, exclude minibuffer-only frames. If\n\ | |
447 | MINIBUF is a window, include only frames using that window for their\n\ | |
f9898cc6 | 448 | minibuffer.") |
ff11dfa1 JB |
449 | (frame, miniframe) |
450 | Lisp_Object frame, miniframe; | |
dc6f92b8 JB |
451 | { |
452 | Lisp_Object tail; | |
453 | ||
ff11dfa1 JB |
454 | if (NILP (frame)) |
455 | XSET (frame, Lisp_Frame, selected_frame); | |
f9898cc6 | 456 | else |
ff11dfa1 | 457 | CHECK_LIVE_FRAME (frame, 0); |
dc6f92b8 | 458 | |
ff11dfa1 | 459 | return next_frame (frame, miniframe); |
dc6f92b8 | 460 | } |
ff11dfa1 | 461 | #endif /* MULTI_FRAME */ |
dc6f92b8 | 462 | \f |
ff11dfa1 JB |
463 | DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 1, "", |
464 | "Delete FRAME, permanently eliminating it from use.\n\ | |
465 | If omitted, FRAME defaults to the selected frame.\n\ | |
466 | A frame may not be deleted if its minibuffer is used by other frames.") | |
467 | (frame) | |
468 | Lisp_Object frame; | |
dc6f92b8 | 469 | { |
ff11dfa1 | 470 | struct frame *f; |
dc6f92b8 JB |
471 | union display displ; |
472 | ||
ff11dfa1 | 473 | if (EQ (frame, Qnil)) |
dc6f92b8 | 474 | { |
ff11dfa1 JB |
475 | f = selected_frame; |
476 | XSET (frame, Lisp_Frame, f); | |
dc6f92b8 JB |
477 | } |
478 | else | |
479 | { | |
ff11dfa1 JB |
480 | CHECK_FRAME (frame, 0); |
481 | f = XFRAME (frame); | |
dc6f92b8 JB |
482 | } |
483 | ||
ff11dfa1 | 484 | if (! FRAME_LIVE_P (f)) |
f9898cc6 JB |
485 | return; |
486 | ||
ff11dfa1 JB |
487 | /* Are there any other frames besides this one? */ |
488 | if (f == selected_frame && EQ (next_frame (frame, Qt), frame)) | |
489 | error ("Attempt to delete the only frame"); | |
d5e7c279 | 490 | |
ff11dfa1 JB |
491 | /* Does this frame have a minibuffer, and is it the surrogate |
492 | minibuffer for any other frame? */ | |
493 | if (FRAME_HAS_MINIBUF (XFRAME (frame))) | |
dc6f92b8 | 494 | { |
ff11dfa1 | 495 | Lisp_Object frames; |
1113d9db | 496 | |
ff11dfa1 JB |
497 | for (frames = Vframe_list; |
498 | CONSP (frames); | |
499 | frames = XCONS (frames)->cdr) | |
1113d9db | 500 | { |
ff11dfa1 | 501 | Lisp_Object this = XCONS (frames)->car; |
1113d9db | 502 | |
ff11dfa1 JB |
503 | if (! EQ (this, frame) |
504 | && EQ (frame, | |
505 | (WINDOW_FRAME | |
1113d9db | 506 | (XWINDOW |
ff11dfa1 JB |
507 | (FRAME_MINIBUF_WINDOW |
508 | (XFRAME (this))))))) | |
509 | error ("Attempt to delete a surrogate minibuffer frame"); | |
1113d9db | 510 | } |
dc6f92b8 JB |
511 | } |
512 | ||
ff11dfa1 JB |
513 | /* Don't let the frame remain selected. */ |
514 | if (f == selected_frame) | |
515 | Fselect_frame (next_frame (frame, Qt)); | |
dc6f92b8 | 516 | |
ff11dfa1 JB |
517 | /* Don't allow minibuf_window to remain on a deleted frame. */ |
518 | if (EQ (f->minibuffer_window, minibuf_window)) | |
dc6f92b8 | 519 | { |
ff11dfa1 | 520 | Fset_window_buffer (selected_frame->minibuffer_window, |
dc6f92b8 | 521 | XWINDOW (minibuf_window)->buffer); |
ff11dfa1 | 522 | minibuf_window = selected_frame->minibuffer_window; |
dc6f92b8 JB |
523 | } |
524 | ||
ff11dfa1 JB |
525 | Vframe_list = Fdelq (frame, Vframe_list); |
526 | f->visible = 0; | |
527 | displ = f->display; | |
528 | f->display.nothing = 0; | |
dc6f92b8 | 529 | |
d5e7c279 | 530 | #ifdef HAVE_X_WINDOWS |
ff11dfa1 JB |
531 | if (FRAME_IS_X (f)) |
532 | x_destroy_window (f, displ); | |
d5e7c279 JB |
533 | #endif |
534 | ||
ff11dfa1 | 535 | /* If we've deleted the last_nonminibuf_frame, then try to find |
d5e7c279 | 536 | another one. */ |
ff11dfa1 | 537 | if (f == last_nonminibuf_frame) |
d5e7c279 | 538 | { |
ff11dfa1 | 539 | Lisp_Object frames; |
1113d9db | 540 | |
ff11dfa1 | 541 | last_nonminibuf_frame = 0; |
d5e7c279 | 542 | |
ff11dfa1 JB |
543 | for (frames = Vframe_list; |
544 | CONSP (frames); | |
545 | frames = XCONS (frames)->cdr) | |
d5e7c279 | 546 | { |
ff11dfa1 JB |
547 | f = XFRAME (XCONS (frames)->car); |
548 | if (!FRAME_MINIBUF_ONLY_P (f)) | |
d5e7c279 | 549 | { |
ff11dfa1 | 550 | last_nonminibuf_frame = f; |
d5e7c279 JB |
551 | break; |
552 | } | |
553 | } | |
554 | } | |
dc6f92b8 | 555 | |
ff11dfa1 JB |
556 | /* If we've deleted Vdefault_minibuffer_frame, try to find another |
557 | one. Prefer minibuffer-only frames, but also notice frames | |
1113d9db | 558 | with other windows. */ |
ff11dfa1 | 559 | if (EQ (frame, Vdefault_minibuffer_frame)) |
1113d9db | 560 | { |
ff11dfa1 | 561 | Lisp_Object frames; |
1113d9db | 562 | |
ff11dfa1 JB |
563 | /* The last frame we saw with a minibuffer, minibuffer-only or not. */ |
564 | Lisp_Object frame_with_minibuf = Qnil; | |
1113d9db | 565 | |
ff11dfa1 JB |
566 | for (frames = Vframe_list; |
567 | CONSP (frames); | |
568 | frames = XCONS (frames)->cdr) | |
1113d9db | 569 | { |
ff11dfa1 | 570 | Lisp_Object this = XCONS (frames)->car; |
1113d9db | 571 | |
ff11dfa1 | 572 | if (XTYPE (this) != Lisp_Frame) |
1113d9db | 573 | abort (); |
ff11dfa1 | 574 | f = XFRAME (this); |
1113d9db | 575 | |
ff11dfa1 | 576 | if (FRAME_HAS_MINIBUF (f)) |
1113d9db | 577 | { |
ff11dfa1 JB |
578 | frame_with_minibuf = this; |
579 | if (FRAME_MINIBUF_ONLY_P (f)) | |
1113d9db JB |
580 | break; |
581 | } | |
582 | } | |
583 | ||
ff11dfa1 JB |
584 | /* We know that there must be some frame with a minibuffer out |
585 | there. If this were not true, all of the frames present | |
1113d9db | 586 | would have to be minibufferless, which implies that at some |
ff11dfa1 | 587 | point their minibuffer frames must have been deleted, but |
1113d9db | 588 | that is prohibited at the top; you can't delete surrogate |
ff11dfa1 JB |
589 | minibuffer frames. */ |
590 | if (NILP (frame_with_minibuf)) | |
1113d9db JB |
591 | abort (); |
592 | ||
ff11dfa1 | 593 | Vdefault_minibuffer_frame = frame_with_minibuf; |
1113d9db JB |
594 | } |
595 | ||
dc6f92b8 JB |
596 | return Qnil; |
597 | } | |
598 | \f | |
599 | /* Return mouse position in character cell units. */ | |
600 | ||
f9898cc6 | 601 | DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0, |
ff11dfa1 | 602 | "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\ |
f9898cc6 | 603 | If Emacs is running on a mouseless terminal or hasn't been programmed\n\ |
ff11dfa1 | 604 | to read the mouse position, it returns the selected frame for FRAME\n\ |
f9898cc6 JB |
605 | and nil for X and Y.") |
606 | () | |
dc6f92b8 | 607 | { |
f9898cc6 | 608 | Lisp_Object x, y, dummy; |
ff11dfa1 | 609 | FRAME_PTR f; |
dc6f92b8 | 610 | |
f9898cc6 | 611 | if (mouse_position_hook) |
ff11dfa1 | 612 | (*mouse_position_hook) (&f, &x, &y, &dummy); |
f9898cc6 JB |
613 | else |
614 | { | |
ff11dfa1 | 615 | f = selected_frame; |
f9898cc6 JB |
616 | x = y = Qnil; |
617 | } | |
dc6f92b8 | 618 | |
ff11dfa1 | 619 | XSET (dummy, Lisp_Frame, f); |
f9898cc6 | 620 | return Fcons (dummy, Fcons (make_number (x), make_number (y))); |
dc6f92b8 JB |
621 | } |
622 | ||
623 | DEFUN ("set-mouse-position", Fset_mouse_position, Sset_mouse_position, 3, 3, 0, | |
ff11dfa1 JB |
624 | "Move the mouse pointer to the center of cell (X,Y) in FRAME.\n\ |
625 | WARNING: If you use this under X, you should do `unfocus-frame' afterwards.") | |
626 | (frame, x, y) | |
627 | Lisp_Object frame, x, y; | |
dc6f92b8 | 628 | { |
ff11dfa1 | 629 | CHECK_LIVE_FRAME (frame, 0); |
dc6f92b8 JB |
630 | CHECK_NUMBER (x, 2); |
631 | CHECK_NUMBER (y, 1); | |
632 | ||
633 | #ifdef HAVE_X_WINDOWS | |
ff11dfa1 | 634 | if (FRAME_IS_X (XFRAME (frame))) |
dc6f92b8 | 635 | /* Warping the mouse will cause enternotify and focus events. */ |
ff11dfa1 | 636 | x_set_mouse_position (XFRAME (frame), x, y); |
dc6f92b8 JB |
637 | #endif |
638 | ||
639 | return Qnil; | |
640 | } | |
641 | \f | |
642 | #if 0 | |
643 | /* ??? Can this be replaced with a Lisp function? | |
06b1a5ef JB |
644 | It is used in minibuf.c. Can we get rid of that? |
645 | Yes. All uses in minibuf.c are gone, and parallels to these | |
ff11dfa1 | 646 | functions have been defined in frame.el. */ |
dc6f92b8 | 647 | |
ff11dfa1 | 648 | DEFUN ("frame-configuration", Fframe_configuration, Sframe_configuration, |
dc6f92b8 | 649 | 0, 0, 0, |
ff11dfa1 JB |
650 | "Return object describing current frame configuration.\n\ |
651 | The frame configuration is the current mouse position and selected frame.\n\ | |
652 | This object can be given to `restore-frame-configuration'\n\ | |
653 | to restore this frame configuration.") | |
dc6f92b8 JB |
654 | () |
655 | { | |
f9898cc6 | 656 | Lisp_Object c, time; |
dc6f92b8 | 657 | |
f9898cc6 | 658 | c = Fmake_vector (make_number(4), Qnil); |
ff11dfa1 | 659 | XVECTOR (c)->contents[0] = Fselected_frame(); |
f9898cc6 JB |
660 | if (mouse_position_hook) |
661 | (*mouse_position_hook) (&XVECTOR (c)->contents[1] | |
662 | &XVECTOR (c)->contents[2], | |
663 | &XVECTOR (c)->contents[3], | |
664 | &time); | |
dc6f92b8 JB |
665 | return c; |
666 | } | |
667 | ||
ff11dfa1 JB |
668 | DEFUN ("restore-frame-configuration", Frestore_frame_configuration, |
669 | Srestore_frame_configuration, | |
dc6f92b8 | 670 | 1, 1, 0, |
ff11dfa1 | 671 | "Restores frame configuration CONFIGURATION.") |
dc6f92b8 JB |
672 | (config) |
673 | Lisp_Object config; | |
674 | { | |
ff11dfa1 | 675 | Lisp_Object x_pos, y_pos, frame; |
dc6f92b8 JB |
676 | |
677 | CHECK_VECTOR (config, 0); | |
678 | if (XVECTOR (config)->size != 3) | |
679 | { | |
ff11dfa1 | 680 | error ("Wrong size vector passed to restore-frame-configuration"); |
dc6f92b8 | 681 | } |
ff11dfa1 JB |
682 | frame = XVECTOR (config)->contents[0]; |
683 | CHECK_LIVE_FRAME (frame, 0); | |
dc6f92b8 | 684 | |
ff11dfa1 | 685 | Fselect_frame (frame, Qnil); |
dc6f92b8 JB |
686 | |
687 | #if 0 | |
ff11dfa1 | 688 | /* This seems to interfere with the frame selection mechanism. jla */ |
f9898cc6 JB |
689 | x_pos = XVECTOR (config)->contents[2]; |
690 | y_pos = XVECTOR (config)->contents[3]; | |
ff11dfa1 | 691 | set_mouse_position (frame, XINT (x_pos), XINT (y_pos)); |
dc6f92b8 JB |
692 | #endif |
693 | ||
ff11dfa1 | 694 | return frame; |
dc6f92b8 JB |
695 | } |
696 | #endif | |
697 | \f | |
ff11dfa1 | 698 | DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible, |
dc6f92b8 | 699 | 1, 1, 0, |
ff11dfa1 JB |
700 | "Make the frame FRAME visible (assuming it is an X-window).\n\ |
701 | Also raises the frame so that nothing obscures it.") | |
702 | (frame) | |
703 | Lisp_Object frame; | |
dc6f92b8 | 704 | { |
ff11dfa1 | 705 | CHECK_LIVE_FRAME (frame, 0); |
dc6f92b8 | 706 | |
ff11dfa1 JB |
707 | if (FRAME_IS_X (XFRAME (frame))) |
708 | x_make_frame_visible (XFRAME (frame)); | |
dc6f92b8 | 709 | |
ff11dfa1 | 710 | return frame; |
dc6f92b8 JB |
711 | } |
712 | ||
ff11dfa1 | 713 | DEFUN ("make-frame-invisible", Fmake_frame_invisible, Smake_frame_invisible, |
dc6f92b8 | 714 | 1, 1, 0, |
ff11dfa1 JB |
715 | "Make the frame FRAME invisible (assuming it is an X-window).") |
716 | (frame) | |
717 | Lisp_Object frame; | |
dc6f92b8 | 718 | { |
ff11dfa1 | 719 | CHECK_LIVE_FRAME (frame, 0); |
dc6f92b8 | 720 | |
ff11dfa1 JB |
721 | if (FRAME_IS_X (XFRAME (frame))) |
722 | x_make_frame_invisible (XFRAME (frame)); | |
dc6f92b8 JB |
723 | |
724 | return Qnil; | |
725 | } | |
726 | ||
ff11dfa1 | 727 | DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame, |
dc6f92b8 | 728 | 1, 1, 0, |
ff11dfa1 JB |
729 | "Make the frame FRAME into an icon.") |
730 | (frame) | |
731 | Lisp_Object frame; | |
dc6f92b8 | 732 | { |
ff11dfa1 | 733 | CHECK_LIVE_FRAME (frame, 0); |
dc6f92b8 | 734 | |
ff11dfa1 JB |
735 | if (FRAME_IS_X (XFRAME (frame))) |
736 | x_iconify_frame (XFRAME (frame)); | |
dc6f92b8 JB |
737 | |
738 | return Qnil; | |
739 | } | |
740 | ||
ff11dfa1 | 741 | DEFUN ("frame-visible-p", Fframe_visible_p, Sframe_visible_p, |
dc6f92b8 | 742 | 1, 1, 0, |
ff11dfa1 JB |
743 | "Return t if FRAME is now \"visible\" (actually in use for display).\n\ |
744 | A frame that is not \"visible\" is not updated and, if it works through\n\ | |
dc6f92b8 JB |
745 | a window system, it may not show at all.\n\ |
746 | Return the symbol `icon' if window is visible only as an icon.") | |
ff11dfa1 JB |
747 | (frame) |
748 | Lisp_Object frame; | |
dc6f92b8 | 749 | { |
ff11dfa1 | 750 | CHECK_LIVE_FRAME (frame, 0); |
dc6f92b8 | 751 | |
ff11dfa1 | 752 | if (XFRAME (frame)->visible) |
dc6f92b8 | 753 | return Qt; |
ff11dfa1 | 754 | if (XFRAME (frame)->iconified) |
dc6f92b8 JB |
755 | return intern ("icon"); |
756 | return Qnil; | |
757 | } | |
758 | ||
ff11dfa1 | 759 | DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list, |
dc6f92b8 | 760 | 0, 0, 0, |
ff11dfa1 | 761 | "Return a list of all frames now \"visible\" (being updated).") |
dc6f92b8 JB |
762 | () |
763 | { | |
ff11dfa1 JB |
764 | Lisp_Object tail, frame; |
765 | struct frame *f; | |
dc6f92b8 JB |
766 | Lisp_Object value; |
767 | ||
768 | value = Qnil; | |
ff11dfa1 | 769 | for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr) |
dc6f92b8 | 770 | { |
ff11dfa1 JB |
771 | frame = XCONS (tail)->car; |
772 | if (XTYPE (frame) != Lisp_Frame) | |
dc6f92b8 | 773 | continue; |
ff11dfa1 JB |
774 | f = XFRAME (frame); |
775 | if (f->visible) | |
776 | value = Fcons (frame, value); | |
dc6f92b8 JB |
777 | } |
778 | return value; | |
779 | } | |
d5e7c279 JB |
780 | |
781 | ||
782 | \f | |
ff11dfa1 | 783 | DEFUN ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus, |
d5e7c279 | 784 | 1, 2, 0, |
ff11dfa1 JB |
785 | "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\ |
786 | This means that, after reading a keystroke typed at FRAME,\n\ | |
787 | `last-event-frame' will be FOCUS-FRAME.\n\ | |
d5e7c279 | 788 | \n\ |
ff11dfa1 JB |
789 | If FOCUS-FRAME is omitted or eq to FRAME, any existing redirection is\n\ |
790 | cancelled, and the frame again receives its own keystrokes.\n\ | |
d5e7c279 | 791 | \n\ |
ff11dfa1 JB |
792 | The redirection lasts until the next call to `redirect-frame-focus'\n\ |
793 | or `select-frame'.\n\ | |
d5e7c279 JB |
794 | \n\ |
795 | This is useful for temporarily redirecting keystrokes to the minibuffer\n\ | |
ff11dfa1 JB |
796 | window when a frame doesn't have its own minibuffer.") |
797 | (frame, focus_frame) | |
798 | Lisp_Object frame, focus_frame; | |
d5e7c279 | 799 | { |
ff11dfa1 | 800 | CHECK_LIVE_FRAME (frame, 0); |
f9898cc6 | 801 | |
ff11dfa1 JB |
802 | if (NILP (focus_frame)) |
803 | focus_frame = frame; | |
d5e7c279 | 804 | else |
ff11dfa1 | 805 | CHECK_LIVE_FRAME (focus_frame, 1); |
d5e7c279 | 806 | |
ff11dfa1 | 807 | XFRAME (frame)->focus_frame = focus_frame; |
d5e7c279 | 808 | |
ff11dfa1 JB |
809 | if (frame_rehighlight_hook) |
810 | (*frame_rehighlight_hook) (); | |
d5e7c279 JB |
811 | |
812 | return Qnil; | |
813 | } | |
814 | ||
815 | ||
ff11dfa1 JB |
816 | DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0, |
817 | "Return the frame to which FRAME's keystrokes are currently being sent.\n\ | |
818 | See `redirect-frame-focus'.") | |
819 | (frame) | |
820 | Lisp_Object frame; | |
d5e7c279 | 821 | { |
ff11dfa1 JB |
822 | CHECK_LIVE_FRAME (frame, 0); |
823 | return FRAME_FOCUS_FRAME (XFRAME (frame)); | |
d5e7c279 JB |
824 | } |
825 | ||
826 | ||
dc6f92b8 JB |
827 | \f |
828 | Lisp_Object | |
ff11dfa1 JB |
829 | get_frame_param (frame, prop) |
830 | register struct frame *frame; | |
dc6f92b8 JB |
831 | Lisp_Object prop; |
832 | { | |
833 | register Lisp_Object tem; | |
834 | ||
ff11dfa1 | 835 | tem = Fassq (prop, frame->param_alist); |
dc6f92b8 JB |
836 | if (EQ (tem, Qnil)) |
837 | return tem; | |
838 | return Fcdr (tem); | |
839 | } | |
840 | ||
841 | void | |
842 | store_in_alist (alistptr, propname, val) | |
843 | Lisp_Object *alistptr, val; | |
844 | char *propname; | |
845 | { | |
846 | register Lisp_Object tem; | |
847 | register Lisp_Object prop; | |
848 | ||
849 | prop = intern (propname); | |
850 | tem = Fassq (prop, *alistptr); | |
851 | if (EQ (tem, Qnil)) | |
852 | *alistptr = Fcons (Fcons (prop, val), *alistptr); | |
853 | else | |
854 | Fsetcdr (tem, val); | |
855 | } | |
856 | ||
857 | void | |
ff11dfa1 JB |
858 | store_frame_param (f, prop, val) |
859 | struct frame *f; | |
dc6f92b8 JB |
860 | Lisp_Object prop, val; |
861 | { | |
862 | register Lisp_Object tem; | |
863 | ||
ff11dfa1 | 864 | tem = Fassq (prop, f->param_alist); |
dc6f92b8 | 865 | if (EQ (tem, Qnil)) |
ff11dfa1 | 866 | f->param_alist = Fcons (Fcons (prop, val), f->param_alist); |
dc6f92b8 JB |
867 | else |
868 | Fsetcdr (tem, val); | |
bc93c097 JB |
869 | |
870 | if (EQ (prop, Qminibuffer) | |
871 | && XTYPE (val) == Lisp_Window) | |
872 | { | |
873 | if (! MINI_WINDOW_P (XWINDOW (val))) | |
874 | error ("Surrogate minibuffer windows must be minibuffer windows."); | |
875 | ||
ff11dfa1 JB |
876 | if (FRAME_HAS_MINIBUF (f) || FRAME_MINIBUF_ONLY_P (f)) |
877 | error ("Can't change the surrogate minibuffer of a frame with its own minibuffer."); | |
bc93c097 JB |
878 | |
879 | /* Install the chosen minibuffer window, with proper buffer. */ | |
ff11dfa1 | 880 | f->minibuffer_window = val; |
bc93c097 | 881 | } |
dc6f92b8 JB |
882 | } |
883 | ||
ff11dfa1 JB |
884 | DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0, |
885 | "Return the parameters-alist of frame FRAME.\n\ | |
dc6f92b8 | 886 | It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.\n\ |
ff11dfa1 JB |
887 | The meaningful PARMs depend on the kind of frame.") |
888 | (frame) | |
889 | Lisp_Object frame; | |
dc6f92b8 JB |
890 | { |
891 | Lisp_Object alist; | |
ff11dfa1 | 892 | struct frame *f; |
dc6f92b8 | 893 | |
ff11dfa1 JB |
894 | if (EQ (frame, Qnil)) |
895 | f = selected_frame; | |
dc6f92b8 JB |
896 | else |
897 | { | |
ff11dfa1 JB |
898 | CHECK_FRAME (frame, 0); |
899 | f = XFRAME (frame); | |
dc6f92b8 JB |
900 | } |
901 | ||
ff11dfa1 | 902 | if (f->display.nothing == 0) |
dc6f92b8 JB |
903 | return Qnil; |
904 | ||
ff11dfa1 JB |
905 | alist = Fcopy_alist (f->param_alist); |
906 | store_in_alist (&alist, "name", f->name); | |
907 | store_in_alist (&alist, "height", make_number (f->height)); | |
908 | store_in_alist (&alist, "width", make_number (f->width)); | |
909 | store_in_alist (&alist, "modeline", (f->wants_modeline ? Qt : Qnil)); | |
f9898cc6 | 910 | store_in_alist (&alist, "minibuffer", |
ff11dfa1 JB |
911 | (FRAME_HAS_MINIBUF (f) |
912 | ? (FRAME_MINIBUF_ONLY_P (f) ? intern ("only") : Qt) | |
913 | : FRAME_MINIBUF_WINDOW (f))); | |
914 | store_in_alist (&alist, "unsplittable", (f->no_split ? Qt : Qnil)); | |
dc6f92b8 | 915 | |
ff11dfa1 JB |
916 | if (FRAME_IS_X (f)) |
917 | x_report_frame_params (f, &alist); | |
dc6f92b8 JB |
918 | return alist; |
919 | } | |
920 | ||
ff11dfa1 JB |
921 | DEFUN ("modify-frame-parameters", Fmodify_frame_parameters, |
922 | Smodify_frame_parameters, 2, 2, 0, | |
923 | "Modify the parameters of frame FRAME according to ALIST.\n\ | |
dc6f92b8 JB |
924 | ALIST is an alist of parameters to change and their new values.\n\ |
925 | Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\ | |
ff11dfa1 JB |
926 | The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.") |
927 | (frame, alist) | |
928 | Lisp_Object frame, alist; | |
dc6f92b8 | 929 | { |
ff11dfa1 | 930 | register struct frame *f; |
dc6f92b8 JB |
931 | register Lisp_Object tail, elt, prop, val; |
932 | ||
ff11dfa1 JB |
933 | if (EQ (frame, Qnil)) |
934 | f = selected_frame; | |
dc6f92b8 JB |
935 | else |
936 | { | |
ff11dfa1 JB |
937 | CHECK_LIVE_FRAME (frame, 0); |
938 | f = XFRAME (frame); | |
dc6f92b8 JB |
939 | } |
940 | ||
ff11dfa1 | 941 | if (FRAME_IS_X (f)) |
dc6f92b8 JB |
942 | for (tail = alist; !EQ (tail, Qnil); tail = Fcdr (tail)) |
943 | { | |
944 | elt = Fcar (tail); | |
945 | prop = Fcar (elt); | |
946 | val = Fcdr (elt); | |
ff11dfa1 JB |
947 | x_set_frame_param (f, prop, val, |
948 | get_frame_param (f, prop)); | |
949 | store_frame_param (f, prop, val); | |
dc6f92b8 JB |
950 | } |
951 | ||
952 | return Qnil; | |
953 | } | |
954 | \f | |
955 | ||
ff11dfa1 JB |
956 | DEFUN ("frame-pixel-size", Fframe_pixel_size, |
957 | Sframe_pixel_size, 1, 1, 0, | |
958 | "Return a cons (width . height) of FRAME's size in pixels.") | |
959 | (frame) | |
960 | Lisp_Object frame; | |
dc6f92b8 | 961 | { |
ff11dfa1 | 962 | register struct frame *f; |
dc6f92b8 JB |
963 | int width, height; |
964 | ||
ff11dfa1 JB |
965 | CHECK_LIVE_FRAME (frame, 0); |
966 | f = XFRAME (frame); | |
dc6f92b8 | 967 | |
ff11dfa1 JB |
968 | return Fcons (make_number (x_pixel_width (f)), |
969 | make_number (x_pixel_height (f))); | |
dc6f92b8 JB |
970 | } |
971 | ||
ff11dfa1 JB |
972 | DEFUN ("frame-height", Fframe_height, Sframe_height, 0, 0, 0, |
973 | "Return number of lines available for display on selected frame.") | |
dc6f92b8 JB |
974 | () |
975 | { | |
ff11dfa1 | 976 | return make_number (FRAME_HEIGHT (selected_frame)); |
dc6f92b8 JB |
977 | } |
978 | ||
ff11dfa1 JB |
979 | DEFUN ("frame-width", Fframe_width, Sframe_width, 0, 0, 0, |
980 | "Return number of columns available for display on selected frame.") | |
dc6f92b8 JB |
981 | () |
982 | { | |
ff11dfa1 | 983 | return make_number (FRAME_WIDTH (selected_frame)); |
dc6f92b8 JB |
984 | } |
985 | ||
ff11dfa1 JB |
986 | DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0, |
987 | "Specify that the frame FRAME has LINES lines.\n\ | |
dc6f92b8 | 988 | Optional third arg non-nil means that redisplay should use LINES lines\n\ |
ff11dfa1 JB |
989 | but that the idea of the actual height of the frame should not be changed.") |
990 | (frame, rows, pretend) | |
dc6f92b8 JB |
991 | Lisp_Object rows, pretend; |
992 | { | |
ff11dfa1 | 993 | register struct frame *f; |
dc6f92b8 JB |
994 | |
995 | CHECK_NUMBER (rows, 0); | |
ff11dfa1 JB |
996 | if (NILP (frame)) |
997 | f = selected_frame; | |
dc6f92b8 JB |
998 | else |
999 | { | |
ff11dfa1 JB |
1000 | CHECK_LIVE_FRAME (frame, 0); |
1001 | f = XFRAME (frame); | |
dc6f92b8 JB |
1002 | } |
1003 | ||
ff11dfa1 | 1004 | if (FRAME_IS_X (f)) |
dc6f92b8 | 1005 | { |
ff11dfa1 JB |
1006 | if (XINT (rows) != f->width) |
1007 | x_set_window_size (f, f->width, XINT (rows)); | |
dc6f92b8 JB |
1008 | } |
1009 | else | |
ff11dfa1 | 1010 | change_frame_size (f, XINT (rows), 0, !NILP (pretend)); |
dc6f92b8 JB |
1011 | return Qnil; |
1012 | } | |
1013 | ||
ff11dfa1 JB |
1014 | DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 3, 0, |
1015 | "Specify that the frame FRAME has COLS columns.\n\ | |
dc6f92b8 | 1016 | Optional third arg non-nil means that redisplay should use COLS columns\n\ |
ff11dfa1 JB |
1017 | but that the idea of the actual width of the frame should not be changed.") |
1018 | (frame, cols, pretend) | |
dc6f92b8 JB |
1019 | Lisp_Object cols, pretend; |
1020 | { | |
ff11dfa1 | 1021 | register struct frame *f; |
dc6f92b8 | 1022 | CHECK_NUMBER (cols, 0); |
ff11dfa1 JB |
1023 | if (NILP (frame)) |
1024 | f = selected_frame; | |
dc6f92b8 JB |
1025 | else |
1026 | { | |
ff11dfa1 JB |
1027 | CHECK_LIVE_FRAME (frame, 0); |
1028 | f = XFRAME (frame); | |
dc6f92b8 JB |
1029 | } |
1030 | ||
ff11dfa1 | 1031 | if (FRAME_IS_X (f)) |
dc6f92b8 | 1032 | { |
ff11dfa1 JB |
1033 | if (XINT (cols) != f->width) |
1034 | x_set_window_size (f, XINT (cols), f->height); | |
dc6f92b8 JB |
1035 | } |
1036 | else | |
ff11dfa1 | 1037 | change_frame_size (selected_frame, 0, XINT (cols), !NILP (pretend)); |
dc6f92b8 JB |
1038 | return Qnil; |
1039 | } | |
1040 | ||
ff11dfa1 JB |
1041 | DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0, |
1042 | "Sets size of FRAME to COLS by ROWS, measured in characters.") | |
1043 | (frame, cols, rows) | |
1044 | Lisp_Object frame, cols, rows; | |
dc6f92b8 | 1045 | { |
ff11dfa1 | 1046 | register struct frame *f; |
dc6f92b8 JB |
1047 | int mask; |
1048 | ||
ff11dfa1 | 1049 | CHECK_LIVE_FRAME (frame, 0); |
dc6f92b8 JB |
1050 | CHECK_NUMBER (cols, 2); |
1051 | CHECK_NUMBER (rows, 1); | |
ff11dfa1 | 1052 | f = XFRAME (frame); |
dc6f92b8 | 1053 | |
ff11dfa1 | 1054 | if (FRAME_IS_X (f)) |
dc6f92b8 | 1055 | { |
ff11dfa1 JB |
1056 | if (XINT (rows) != f->height || XINT (cols) != f->width) |
1057 | x_set_window_size (f, XINT (cols), XINT (rows)); | |
dc6f92b8 JB |
1058 | } |
1059 | else | |
ff11dfa1 | 1060 | change_frame_size (f, XINT (rows), XINT (cols), 0); |
dc6f92b8 JB |
1061 | |
1062 | return Qnil; | |
1063 | } | |
1064 | ||
ff11dfa1 JB |
1065 | DEFUN ("set-frame-position", Fset_frame_position, |
1066 | Sset_frame_position, 3, 3, 0, | |
1067 | "Sets position of FRAME in pixels to XOFFSET by YOFFSET.\n\ | |
f9898cc6 | 1068 | If XOFFSET or YOFFSET are negative, they are interpreted relative to\n\ |
ff11dfa1 JB |
1069 | the leftmost or bottommost position FRAME could occupy without going\n\ |
1070 | off the frame.") | |
1071 | (frame, xoffset, yoffset) | |
1072 | Lisp_Object frame, xoffset, yoffset; | |
dc6f92b8 | 1073 | { |
ff11dfa1 | 1074 | register struct frame *f; |
dc6f92b8 JB |
1075 | int mask; |
1076 | ||
ff11dfa1 | 1077 | CHECK_LIVE_FRAME (frame, 0); |
dc6f92b8 JB |
1078 | CHECK_NUMBER (xoffset, 1); |
1079 | CHECK_NUMBER (yoffset, 2); | |
ff11dfa1 | 1080 | f = XFRAME (frame); |
dc6f92b8 | 1081 | |
ff11dfa1 JB |
1082 | if (FRAME_IS_X (f)) |
1083 | x_set_offset (f, XINT (xoffset), XINT (yoffset)); | |
dc6f92b8 JB |
1084 | |
1085 | return Qt; | |
1086 | } | |
1087 | \f | |
dc6f92b8 JB |
1088 | #ifndef HAVE_X11 |
1089 | DEFUN ("rubber-band-rectangle", Frubber_band_rectangle, Srubber_band_rectangle, | |
1090 | 3, 3, "", | |
ff11dfa1 JB |
1091 | "Ask user to specify a window position and size on FRAME with the mouse.\n\ |
1092 | Arguments are FRAME, NAME and GEO. NAME is a name to be displayed as\n\ | |
dc6f92b8 JB |
1093 | the purpose of this rectangle. GEO is an X-windows size spec that can\n\ |
1094 | specify defaults for some sizes/positions. If GEO specifies everything,\n\ | |
1095 | the mouse is not used.\n\ | |
ff11dfa1 JB |
1096 | Returns a list of five values: (FRAME LEFT TOP WIDTH HEIGHT).") |
1097 | (frame, name, geo) | |
1098 | Lisp_Object frame; | |
dc6f92b8 JB |
1099 | Lisp_Object name; |
1100 | Lisp_Object geo; | |
1101 | { | |
1102 | int vals[4]; | |
1103 | Lisp_Object nums[4]; | |
1104 | int i; | |
1105 | ||
ff11dfa1 | 1106 | CHECK_FRAME (frame, 0); |
dc6f92b8 JB |
1107 | CHECK_STRING (name, 1); |
1108 | CHECK_STRING (geo, 2); | |
1109 | ||
ff11dfa1 | 1110 | switch (XFRAME (frame)->output_method) |
dc6f92b8 JB |
1111 | { |
1112 | case output_x_window: | |
ff11dfa1 | 1113 | x_rubber_band (XFRAME (frame), &vals[0], &vals[1], &vals[2], &vals[3], |
dc6f92b8 JB |
1114 | XSTRING (geo)->data, XSTRING (name)->data); |
1115 | break; | |
1116 | ||
1117 | default: | |
1118 | return Qnil; | |
1119 | } | |
1120 | ||
1121 | for (i = 0; i < 4; i++) | |
1122 | XFASTINT (nums[i]) = vals[i]; | |
ff11dfa1 | 1123 | return Fcons (frame, Flist (4, nums)); |
dc6f92b8 JB |
1124 | return Qnil; |
1125 | } | |
1126 | #endif /* not HAVE_X11 */ | |
1127 | \f | |
ff11dfa1 | 1128 | choose_minibuf_frame () |
dc6f92b8 | 1129 | { |
ff11dfa1 JB |
1130 | /* For lowest-level minibuf, put it on currently selected frame |
1131 | if frame has a minibuffer. */ | |
dc6f92b8 | 1132 | if (minibuf_level == 0 |
ff11dfa1 JB |
1133 | && selected_frame != 0 |
1134 | && !EQ (minibuf_window, selected_frame->minibuffer_window) | |
1135 | && !EQ (Qnil, selected_frame->minibuffer_window)) | |
dc6f92b8 | 1136 | { |
ff11dfa1 | 1137 | Fset_window_buffer (selected_frame->minibuffer_window, |
dc6f92b8 | 1138 | XWINDOW (minibuf_window)->buffer); |
ff11dfa1 | 1139 | minibuf_window = selected_frame->minibuffer_window; |
dc6f92b8 JB |
1140 | } |
1141 | } | |
1142 | \f | |
ff11dfa1 | 1143 | syms_of_frame () |
dc6f92b8 | 1144 | { |
ff11dfa1 JB |
1145 | Qframep = intern ("framep"); |
1146 | Qlive_frame_p = intern ("live_frame_p"); | |
bc93c097 | 1147 | Qminibuffer = intern ("minibuffer"); |
f9898cc6 | 1148 | |
ff11dfa1 JB |
1149 | staticpro (&Qframep); |
1150 | staticpro (&Qlive_frame_p); | |
bc93c097 | 1151 | staticpro (&Qminibuffer); |
dc6f92b8 | 1152 | |
ff11dfa1 | 1153 | staticpro (&Vframe_list); |
dc6f92b8 | 1154 | |
ff11dfa1 JB |
1155 | DEFVAR_LISP ("terminal-frame", &Vterminal_frame, |
1156 | "The initial frame-object, which represents Emacs's stdout."); | |
dc6f92b8 JB |
1157 | |
1158 | DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified, | |
ff11dfa1 | 1159 | "Non-nil if all of emacs is iconified and frame updates are not needed."); |
dc6f92b8 JB |
1160 | Vemacs_iconified = Qnil; |
1161 | ||
ff11dfa1 JB |
1162 | DEFVAR_LISP ("default-minibuffer-frame", &Vdefault_minibuffer_frame, |
1163 | "Minibufferless frames use this frame's minibuffer.\n\ | |
f9898cc6 | 1164 | \n\ |
ff11dfa1 | 1165 | Emacs cannot create minibufferless frames unless this is set to an\n\ |
f9898cc6 JB |
1166 | appropriate surrogate.\n\ |
1167 | \n\ | |
1168 | Emacs consults this variable only when creating minibufferless\n\ | |
ff11dfa1 | 1169 | frames; once the frame is created, it sticks with its assigned\n\ |
f9898cc6 JB |
1170 | minibuffer, no matter what this variable is set to. This means that\n\ |
1171 | this variable doesn't necessarily say anything meaningful about the\n\ | |
ff11dfa1 | 1172 | current set of frames, or where the minibuffer is currently being\n\ |
f9898cc6 | 1173 | displayed."); |
ff11dfa1 | 1174 | Vdefault_minibuffer_frame = Qnil; |
dc6f92b8 | 1175 | |
ff11dfa1 JB |
1176 | DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist, |
1177 | "Alist of default values for frame creation.\n\ | |
5bce042c | 1178 | These may be set in your init file, like this:\n\ |
ff11dfa1 | 1179 | (setq default-frame-alist '((width . 80) (height . 55)))\n\ |
5bce042c JB |
1180 | These override values given in window system configuration data, like\n\ |
1181 | X Windows' defaults database.\n\ | |
ff11dfa1 JB |
1182 | For values specific to the first Emacs frame, see `initial-frame-alist'.\n\ |
1183 | For values specific to the separate minibuffer frame, see\n\ | |
1184 | `minibuffer-frame-alist'."); | |
1185 | Vdefault_frame_alist = Qnil; | |
1186 | ||
1187 | defsubr (&Sframep); | |
1188 | defsubr (&Slive_frame_p); | |
1189 | defsubr (&Sselect_frame); | |
1190 | defsubr (&Sselected_frame); | |
1191 | defsubr (&Swindow_frame); | |
1192 | defsubr (&Sframe_root_window); | |
1193 | defsubr (&Sframe_selected_window); | |
1194 | defsubr (&Sframe_list); | |
1195 | defsubr (&Snext_frame); | |
1196 | defsubr (&Sdelete_frame); | |
f9898cc6 | 1197 | defsubr (&Smouse_position); |
dc6f92b8 JB |
1198 | defsubr (&Sset_mouse_position); |
1199 | #if 0 | |
ff11dfa1 JB |
1200 | defsubr (&Sframe_configuration); |
1201 | defsubr (&Srestore_frame_configuration); | |
dc6f92b8 | 1202 | #endif |
ff11dfa1 JB |
1203 | defsubr (&Smake_frame_visible); |
1204 | defsubr (&Smake_frame_invisible); | |
1205 | defsubr (&Siconify_frame); | |
1206 | defsubr (&Sframe_visible_p); | |
1207 | defsubr (&Svisible_frame_list); | |
1208 | defsubr (&Sredirect_frame_focus); | |
1209 | defsubr (&Sframe_focus); | |
1210 | defsubr (&Sframe_parameters); | |
1211 | defsubr (&Smodify_frame_parameters); | |
1212 | defsubr (&Sframe_pixel_size); | |
1213 | defsubr (&Sframe_height); | |
1214 | defsubr (&Sframe_width); | |
1215 | defsubr (&Sset_frame_height); | |
1216 | defsubr (&Sset_frame_width); | |
1217 | defsubr (&Sset_frame_size); | |
1218 | defsubr (&Sset_frame_position); | |
dc6f92b8 JB |
1219 | #ifndef HAVE_X11 |
1220 | defsubr (&Srubber_band_rectangle); | |
1221 | #endif /* HAVE_X11 */ | |
1222 | } | |
e5d77022 JB |
1223 | |
1224 | #endif |